From bf1a29d15435c09245864804cd8226f06f671fcf Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 15 Feb 2024 15:03:57 +0100 Subject: [PATCH 001/130] move decoding and TSM from IVAS_DEC_GetSamples to IVAS_DEC_FeedFrame_Serial --- lib_com/options.h | 2 +- lib_dec/lib_dec.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1e13919859..ac34b1243d 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -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 ################################## */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index d8e7300c7a..1ee9b2fa61 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -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 }; @@ -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; @@ -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; @@ -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; } @@ -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; } @@ -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; } @@ -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 ) { @@ -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; @@ -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; -- GitLab From 72c9211088edcbb55a47f6539fa979e88c23df17 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 19 Mar 2024 12:44:50 +0100 Subject: [PATCH 002/130] rename define --- lib_com/options.h | 4 +++- lib_dec/lib_dec.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ac34b1243d..1f09992b01 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,6 +147,8 @@ /* ################## Start DEVELOPMENT switches ######################### */ +#define OBJ_EDITING_INTERFACE + /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ @@ -161,7 +163,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 ################################## */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 1ee9b2fa61..b92d511cbe 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -92,7 +92,7 @@ struct IVAS_DEC 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 +#ifdef OBJ_EDITING_INTERFACE uint16_t nSamplesFlushed; int16_t *flushbuffer; #endif @@ -177,7 +177,7 @@ ivas_error IVAS_DEC_Open( hIvasDec->hasDecodedFirstGoodFrame = false; hIvasDec->isInitialized = false; hIvasDec->updateOrientation = false; -#ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES +#ifdef OBJ_EDITING_INTERFACE hIvasDec->flushbuffer = NULL; hIvasDec->nSamplesFlushed = 0; #endif @@ -322,7 +322,7 @@ void IVAS_DEC_Close( { free( ( *phIvasDec )->apaExecBuffer ); } -#ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES +#ifdef OBJ_EDITING_INTERFACE if ( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); @@ -492,7 +492,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; -#ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES +#ifdef OBJ_EDITING_INTERFACE /* 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 ) ) { @@ -753,7 +753,7 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_FAILED_ALLOC; } -#ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES +#ifdef OBJ_EDITING_INTERFACE /* 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 ) ) { @@ -854,7 +854,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->nSamplesRendered = 0; hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; -#ifdef FIX_XXX_API_FEEDFRAME_GETSAMPLES +#ifdef OBJ_EDITING_INTERFACE /* decode TCs, do TSM and feed to renderer */ /* setup */ { @@ -1015,7 +1015,7 @@ ivas_error IVAS_DEC_GetSamples( } else { -#ifndef FIX_XXX_API_FEEDFRAME_GETSAMPLES +#ifndef OBJ_EDITING_INTERFACE /* check if we need to run the setup function */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { @@ -1037,7 +1037,7 @@ ivas_error IVAS_DEC_GetSamples( #endif { /* check if we need to run the setup function, tc decoding and feeding the renderer */ -#ifndef FIX_XXX_API_FEEDFRAME_GETSAMPLES +#ifndef OBJ_EDITING_INTERFACE if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { int16_t nResidualSamples, nSamplesTcsScaled; -- GitLab From a24d12dd7e652950d09436408b4b7521cb55d6f1 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 28 Mar 2024 11:48:56 +0100 Subject: [PATCH 003/130] further dissect the decoder functions to have a single point in the processing chain for editing object data, add stubs to the API for editable object data handling --- apps/decoder.c | 72 +++++++++++-- lib_com/common_api_types.h | 11 ++ lib_com/ivas_prot.h | 20 ++++ lib_com/ivas_stat_com.h | 4 + lib_dec/ivas_ism_param_dec.c | 170 ++++++++++++++++++++++++++++++- lib_dec/ivas_jbm_dec.c | 191 ++++++++++++++++++++++++++++++++++- lib_dec/ivas_mc_param_dec.c | 170 ++++++++++++++++++++++++++++++- lib_dec/ivas_stat_dec.h | 4 + lib_dec/lib_dec.c | 147 ++++++++++++++++++++++++++- lib_dec/lib_dec.h | 21 ++++ 10 files changed, 791 insertions(+), 19 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index d993eb4144..18dc59b385 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2081,6 +2081,9 @@ static ivas_error decodeG192( #ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; #endif +#ifdef OBJ_EDITING_INTERFACE + IVAS_EDITABLE_PARAMETERS editableParameters; +#endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { @@ -2342,6 +2345,30 @@ static ivas_error decodeG192( fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } +#ifdef OBJ_EDITING_INTERFACE + /* Do object info editing here */ + /* get object parameters */ + if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + /* edit object parameters...*/ + /* set new object parameters*/ + if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + /* Do the final preparations needed for rendering */ + if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not prepare the renderer: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } +#endif } #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -2932,6 +2959,11 @@ static ivas_error decodeVoIP( int16_t vec_pos_update, vec_pos_len; int16_t nOutSamples = 0; +#ifdef OBJ_EDITING_INTERFACE + bool parameterAvailableForEditing = false; + uint16_t nSamplesRendered = 0; +#endif + vec_pos_update = 0; if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK ) { @@ -3048,7 +3080,9 @@ static ivas_error decodeVoIP( while ( 1 ) { - +#ifdef OBJ_EDITING_INTERFACE + nSamplesRendered = 0; +#endif /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) { @@ -3219,7 +3253,25 @@ static ivas_error decodeVoIP( /* decode and get samples */ - +#ifdef OBJ_EDITING_INTERFACE + while ( nSamplesRendered < nOutSamples ) + { +#endif +#ifdef OBJ_EDITING_INTERFACE +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef SUPPORT_JBM_TRACEFILE + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef SUPPORT_JBM_TRACEFILE + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) +#endif +#endif +#else #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) @@ -3233,10 +3285,18 @@ static ivas_error decodeVoIP( if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) #endif #endif - { - fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } +#endif + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } +#ifdef OBJ_EDITING_INTERFACE + if ( parameterAvailableForEditing == true ) + { + /* do the object editing here */ + } + } /* while ( nSamplesRendered < nOutSamples ) */ +#endif /* write JBM Offset file entry */ if ( jbmOffsetWriter != NULL ) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index f12eb6940f..f9f55e20d4 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -122,9 +122,20 @@ typedef struct _IVAS_ISM_METADATA float yaw; float pitch; int16_t non_diegetic_flag; +#ifdef OBJ_EDITING_INTERFACE + float gain; +#endif } IVAS_ISM_METADATA; +typedef struct _IVAS_EDITABLE_PARAMETERS +{ + + int16_t num_obj; + IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; + float gain_bed; +} IVAS_EDITABLE_PARAMETERS; + typedef struct { float w, x, y, z; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9e15502344..2738e5b1c3 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -822,6 +822,12 @@ void ivas_jbm_dec_feed_tc_to_renderer( float *data /* i/o: transport channels/output synthesis signal */ ); +#ifdef OBJ_EDITING_INTERFACE +void ivas_jbm_dec_prepare_renderer( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif + ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); @@ -1112,6 +1118,13 @@ void ivas_param_ism_dec_digest_tc( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); +#ifdef OBJ_EDITING_INTERFACE +void ivas_param_ism_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +); +#endif + void ivas_ism_param_dec_tc_gain_ajust( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamples, /* i : number of samples to be compensate */ @@ -3861,6 +3874,13 @@ void ivas_param_mc_dec_digest_tc( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ); +#ifdef OBJ_EDITING_INTERFACE +void ivas_param_mc_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +); +#endif + void ivas_param_mc_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 434ddc6080..7ce6768040 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -87,6 +87,10 @@ typedef struct float q_azimuth_old; float q_elevation_old; +#ifdef OBJ_EDITING_INTERFACE + float gain; +#endif + } ISM_METADATA_FRAME, *ISM_METADATA_HANDLE; diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 9337ccb08a..77a23c3c54 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1086,14 +1086,20 @@ void ivas_param_ism_dec_digest_tc( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ) { - int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; - int16_t slot_idx, bin_idx; + int16_t ch, nchan_transport; + int16_t slot_idx; +#ifndef OBJ_EDITING_INTERFACE + int16_t nchan_out, nchan_out_woLFE, i; + int16_t bin_idx; int32_t ivas_total_brate; +#endif int16_t output_frame; +#ifndef OBJ_EDITING_INTERFACE float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; +#endif PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; int16_t fade_len; @@ -1107,6 +1113,8 @@ void ivas_param_ism_dec_digest_tc( fade_len = output_frame / 2; nchan_transport = st_ivas->nchan_transport; + +#ifndef OBJ_EDITING_INTERFACE ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) @@ -1120,9 +1128,10 @@ void ivas_param_ism_dec_digest_tc( nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } - +#endif push_wmops( "ivas_param_ism_dec_digest_tc" ); +#ifndef OBJ_EDITING_INTERFACE /* general setup */ ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); @@ -1197,7 +1206,7 @@ void ivas_param_ism_dec_digest_tc( } } } - +#endif if ( st_ivas->hDecoderConfig->Opt_tsm ) { /*TODO : FhG to check*/ @@ -1219,11 +1228,13 @@ void ivas_param_ism_dec_digest_tc( mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } - +#ifndef OBJ_EDITING_INTERFACE ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); +#endif } } +#ifndef OBJ_EDITING_INTERFACE /* Obtain Mixing Matrix on a frame-level */ for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) { @@ -1232,6 +1243,7 @@ void ivas_param_ism_dec_digest_tc( /* Compute mixing matrix */ ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin ); +#endif pop_wmops(); @@ -1239,6 +1251,154 @@ void ivas_param_ism_dec_digest_tc( } +#ifdef OBJ_EDITING_INTERFACE +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_prepare_renderer() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_param_ism_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +) +{ + int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; + int16_t slot_idx, bin_idx; + int32_t ivas_total_brate; + int16_t output_frame; + float ref_power[CLDFB_NO_CHANNELS_MAX]; + float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; + /* Direct Response/EFAP Gains */ + float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; + PARAM_ISM_DEC_HANDLE hParamIsmDec; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + int16_t fade_len; + + /* Initialization */ + hParamIsmDec = st_ivas->hParamIsmDec; + assert( hParamIsmDec ); + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + assert( hSpatParamRendCom ); + output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands; + fade_len = output_frame / 2; + + nchan_transport = st_ivas->nchan_transport; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + nchan_out = st_ivas->nchan_ism; + nchan_out_woLFE = nchan_out; + st_ivas->hDecoderConfig->nchan_out = nchan_out; + } + else + { + nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; + } + + push_wmops( "ivas_param_ism_dec_digest_tc" ); + + /* general setup */ + ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); + + ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); + + /* set buffers to zero */ + for ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) + { + set_zero( cx_diag[bin_idx], PARAM_ISM_MAX_DMX ); + } + set_zero( ref_power, CLDFB_NO_CHANNELS_MAX ); + + /* Frame-level Processing */ + /* De-quantization */ + if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) + { + ivas_param_ism_dec_dequant_DOA( hParamIsmDec, st_ivas->nchan_ism ); + ivas_param_ism_dec_dequant_powrat( hParamIsmDec ); + st_ivas->hISMDTX.dtx_flag = 0; + } + else + { + st_ivas->hISMDTX.dtx_flag = 1; + } + + /* obtain the direct response using EFAP */ + if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + for ( i = 0; i < st_ivas->nchan_ism; i++ ) + { + efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); + } + } + else + { + int16_t j; + + for ( i = 0; i < st_ivas->nchan_ism; i++ ) + { + for ( j = 0; j < nchan_out_woLFE; j++ ) + { + if ( i == j ) + { + direct_response[i][j] = 1.0f; + } + else + { + direct_response[i][j] = 0.0f; + } + } + } + + for ( j = 0; j < nchan_out_woLFE; j++ ) + { + if ( hParamIsmDec->azimuth_values[j] > 0.0f ) + { + hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 1.0f; + hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.0f; + } + else + { + if ( hParamIsmDec->azimuth_values[j] < 0.0f ) + { + hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.0f; + hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 1.0f; + } + else /* == 0.0f */ + { + hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.5f; + hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.5f; + } + } + } + } + + for ( ch = 0; ch < nchan_transport; ch++ ) + { + /* CLDFB Analysis */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); + } + } + + /* Obtain Mixing Matrix on a frame-level */ + for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) + { + set_f( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin[bin_idx], 0.0f, nchan_transport * nchan_out_woLFE ); + } + + /* Compute mixing matrix */ + ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin ); + + pop_wmops(); + + return; +} +#endif + /*-------------------------------------------------------------------------* * ivas_ism_param_dec_tc_gain_ajust() * diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index c7ad64a60a..d5c9b66ce3 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -808,6 +808,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; +#ifndef OBJ_EDITING_INTERFACE if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); @@ -821,27 +822,35 @@ void ivas_jbm_dec_feed_tc_to_renderer( { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + else +#endif + if ( st_ivas->ivas_format == ISM_FORMAT ) { /* Rendering */ if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { +#ifndef OBJ_EDITING_INTERFACE if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); ivas_param_ism_params_to_masa_param_mapping( st_ivas ); } - else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + else +#endif + if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); } } +#ifndef OBJ_EDITING_INTERFACE else /* ISM_MODE_DISC */ { ivas_ism_dec_digest_tc( st_ivas ); } +#endif } +#ifndef OBJ_EDITING_INTERFACE else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); @@ -937,8 +946,10 @@ void ivas_jbm_dec_feed_tc_to_renderer( } } } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { +#ifndef OBJ_EDITING_INTERFACE if ( st_ivas->mc_mode == MC_MODE_MCT ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); @@ -947,20 +958,194 @@ void ivas_jbm_dec_feed_tc_to_renderer( { ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + else +#endif + if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); } +#ifndef OBJ_EDITING_INTERFACE else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } +#endif } pop_wmops(); return; } +#ifdef OBJ_EDITING_INTERFACE +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_prepare_renderer() + * + * prepare IVAS JBM renderer routine + *--------------------------------------------------------------------------*/ + +void ivas_jbm_dec_prepare_renderer( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t n, n_render_timeslots; + + push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + + n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + + if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + + if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } + } + else if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + } + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + /* Rendering */ + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); + + ivas_param_ism_params_to_masa_param_mapping( st_ivas ); + } + else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_param_ism_dec_prepare_renderer( st_ivas, n_render_timeslots ); + } + } + else /* ISM_MODE_DISC */ + { + ivas_ism_dec_digest_tc( st_ivas ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + ivas_ism_dec_digest_tc( st_ivas ); + + /* delay the objects here for all renderers where it is needed */ + if ( +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + ) && + ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) + { + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + } + } + + if ( !st_ivas->sba_dirac_stereo_flag ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + } + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + else + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } + else + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + } + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + ivas_ism_dec_digest_tc( st_ivas ); + } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) + { + int16_t num_objects; + /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ + num_objects = 0; + if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC ) + { + num_objects = 1; + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + num_objects = st_ivas->nchan_ism; + } + for ( n = 0; n < num_objects; n++ ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + } + delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } + } + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + ivas_param_mc_dec_prepare_renderer( st_ivas, (uint8_t) n_render_timeslots ); + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + + pop_wmops(); + return; +} +#endif /*--------------------------------------------------------------------------* * ivas_dec_render() diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 21bdcfb856..2dd60ccbc2 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1331,7 +1331,171 @@ void ivas_param_mc_dec_digest_tc( ) { PARAM_MC_DEC_HANDLE hParamMC; - int16_t i, ch; + int16_t ch; + int16_t slot_idx; + int16_t nchan_transport; +#ifndef OBJ_EDITING_INTERFACE + int16_t nchan_out_transport, nchan_out_cldfb, i, param_band_idx; + int16_t nchan_out_cov; + /*CLDFB*/ + float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float real_part, imag_part; + /* format converter */ + int16_t channel_active[MAX_OUTPUT_CHANNELS]; + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; +#endif + hParamMC = st_ivas->hParamMC; + assert( hParamMC ); + + push_wmops( "param_mc_dec_digest_tc" ); +#ifndef OBJ_EDITING_INTERFACE + set_s( channel_active, 0, MAX_CICP_CHANNELS ); +#endif + nchan_transport = st_ivas->nchan_transport; + +#ifndef OBJ_EDITING_INTERFACE + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + nchan_out_cldfb = BINAURAL_CHANNELS; + set_s( channel_active, 1, nchan_out_cldfb ); + nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) + { + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cldfb = nchan_out_cov; + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hOutSetup; + } + else + { + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = nchan_out_transport; + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + + /* adapt transient position */ + if ( hParamMC->hMetadataPMC->bAttackPresent ) + { + hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); + } + /* adapt subframes */ + hParamMC->num_slots = nCldfbSlots; + hParamMC->slots_rendered = 0; + hParamMC->subframes_rendered = 0; + ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); + st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; + mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); + + ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); + + for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) + { + set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + } +#endif + /* slot loop for gathering the input data */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + float RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + + /* CLDFB Analysis*/ + for ( ch = 0; ch < nchan_transport; ch++ ) + { + cldfbAnalysis_ts( &( transport_channels_f[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + + mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + } + } +#ifndef OBJ_EDITING_INTERFACE + if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + { + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); + } +#endif + } +#ifndef OBJ_EDITING_INTERFACE + /* map from complex input covariance to real values */ + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) + { + /* Cx for transport channels */ + for ( i = 0; i < nchan_transport * nchan_transport; i++ ) + { + real_part = cx[param_band_idx][i]; + imag_part = cx_imag[param_band_idx][i]; + + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + if ( param_band_idx < hParamMC->max_param_band_abs_cov ) + { + cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); + } + else + { + cx[param_band_idx][i] = real_part; + } + } + } + + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) + { + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); + mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); + } + } + + +#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + ivas_param_mc_get_mono_stereo_mixing_matrices( hParamMC, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, nchan_transport, nchan_out_cov ); + } + else + { +#endif + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); +#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT + } +#endif +#endif + pop_wmops(); + + return; +} + +#ifdef OBJ_EDITING_INTERFACE +/*------------------------------------------------------------------------- + * ivas_param_mc_dec_digest_tc() + * + * + *------------------------------------------------------------------------*/ + +void ivas_param_mc_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +) +{ + PARAM_MC_DEC_HANDLE hParamMC; + int16_t i; int16_t slot_idx, param_band_idx; int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; @@ -1404,6 +1568,7 @@ void ivas_param_mc_dec_digest_tc( /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { +#ifndef OBJ_EDITING_INTERFACE if ( st_ivas->hDecoderConfig->Opt_tsm ) { float RealBuffer[CLDFB_NO_CHANNELS_MAX]; @@ -1418,6 +1583,7 @@ void ivas_param_mc_dec_digest_tc( mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); } } +#endif if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) { ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); @@ -1474,7 +1640,7 @@ void ivas_param_mc_dec_digest_tc( return; } - +#endif /*------------------------------------------------------------------------- * ivas_param_mc_dec_render() diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4deb6748e2..ab37bc9896 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -897,6 +897,10 @@ typedef struct ivas_masa_ism_data_structure int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; uint8_t ism_is_edited[MAX_NUM_OBJECTS]; +#ifdef OBJ_EDITING_INTERFACE + float gain_ism[MAX_NUM_OBJECTS]; + float gain_masa; +#endif int16_t idx_separated_ism; int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a99d38208a..7e0ad2116a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -97,6 +97,9 @@ struct IVAS_DEC #ifdef OBJ_EDITING_INTERFACE uint16_t nSamplesFlushed; int16_t *flushbuffer; + bool hasEditableParameters; + bool enableParameterEditing; + bool hasBeenPreparedRendering; #endif }; @@ -183,6 +186,9 @@ ivas_error IVAS_DEC_Open( #ifdef OBJ_EDITING_INTERFACE hIvasDec->flushbuffer = NULL; hIvasDec->nSamplesFlushed = 0; + hIvasDec->hasEditableParameters = false; + hIvasDec->enableParameterEditing = false; + hIvasDec->hasBeenPreparedRendering = false; #endif hIvasDec->mode = mode; @@ -927,12 +933,74 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } } } + hIvasDec->hasBeenPreparedRendering = false; #endif return IVAS_ERR_OK; } +#ifdef OBJ_EDITING_INTERFACE +/*---------------------------------------------------------------------* + * IVAS_DEC_GetEditableParameters( ) + * + * Main function to decode to PCM data + *---------------------------------------------------------------------*/ +ivas_error IVAS_DEC_GetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) +{ + ivas_error error; + + hIvasEditableParameters = NULL; + + + error = IVAS_ERR_OK; + + return error; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_SetEditableParameters( ) + * + * Main function to decode to PCM data + *---------------------------------------------------------------------*/ +ivas_error IVAS_DEC_SetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) +{ + ivas_error error; + + error = IVAS_ERR_OK; + + return error; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_PrepareRenderer( ) + * + * Main function to decode to PCM data + *---------------------------------------------------------------------*/ +ivas_error IVAS_DEC_PrepareRenderer( + IVAS_DEC_HANDLE hIvasDec ) +{ + ivas_error error; + + error = IVAS_ERR_OK; + + if ( hIvasDec == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); + hIvasDec->hasBeenPreparedRendering = true; + return error; +} + + +#endif + /*---------------------------------------------------------------------* * IVAS_DEC_GetSamples( ) * @@ -954,10 +1022,13 @@ ivas_error IVAS_DEC_GetSamples( ) { ivas_error error; - int16_t nOutSamplesElse, nSamplesToRender; - uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts, nTimeScalerOutSamples; + int16_t nSamplesToRender; + uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts; uint8_t nTransportChannels, nOutChannels; - +#ifndef OBJ_EDITING_INTERFACE + int16_t nOutSamplesElse; + uint16_t nTimeScalerOutSamples; +#endif nSamplesRendered = 0; nOutChannels = 0; nSamplesRendered_loop = 0; @@ -969,6 +1040,14 @@ ivas_error IVAS_DEC_GetSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef OBJ_EDITING_INTERFACE + /* the rendering needs to be prepared at this point */ + if ( hIvasDec->hasBeenPreparedRendering == false ) + { + return IVAS_ERR_UNKNOWN; + } +#endif + if ( hIvasDec->updateOrientation ) { /*----------------------------------------------------------------* @@ -2598,6 +2677,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter #endif +#ifdef OBJ_EDITING_INTERFACE + , + uint16_t *nSamplesRendered, + bool *parametersAvailableForEditing +#endif ) { Decoder_Struct *st_ivas; @@ -2608,14 +2692,21 @@ ivas_error IVAS_DEC_VoIP_GetSamples( uint16_t extBufferedSamples; int16_t result; ivas_error error; +#ifndef OBJ_EDITING_INTERFACE int16_t nSamplesRendered; +#endif uint8_t nOutChannels; st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; +#ifndef OBJ_EDITING_INTERFACE nSamplesRendered = 0; +#endif +#ifdef OBJ_EDITING_INTERFACE + *parametersAvailableForEditing = false; +#endif if ( nSamplesPerChannel == 0 ) { @@ -2623,7 +2714,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ +#ifdef OBJ_EDITING_INTERFACE + while ( *nSamplesRendered < nSamplesPerChannel ) +#else while ( nSamplesRendered < nSamplesPerChannel ) +#endif { if ( hIvasDec->nSamplesAvailableNext == 0 ) { @@ -2736,6 +2831,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; hIvasDec->nSamplesRendered = 0; } +#ifdef OBJ_EDITING_INTERFACE + /* :TODO: only return here if we really have editing initialized */ + if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) + { + *parametersAvailableForEditing = true; + return IVAS_ERR_OK; + } +#endif } /* decode */ @@ -2744,12 +2847,21 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* codec mode to use not known yet - simply output silence */ /* directly set output zero */ int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); +#ifdef OBJ_EDITING_INTERFACE +#ifdef SPLIT_REND_WITH_HEAD_ROT + set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); +#else + set_s( pcmBuf + ( *nSamplesRendered ) * nOutChannels, 0, nSamplesToZero * nOutChannels ); +#endif + *nSamplesRendered += nSamplesToZero; +#else #ifdef SPLIT_REND_WITH_HEAD_ROT set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); #else set_s( pcmBuf + nSamplesRendered * nOutChannels, 0, nSamplesToZero * nOutChannels ); #endif nSamplesRendered += nSamplesToZero; +#endif hIvasDec->nSamplesRendered += nSamplesToZero; hIvasDec->nSamplesAvailableNext -= nSamplesToZero; update_voip_rendered20ms( hIvasDec, nSamplesToZero ); @@ -2758,9 +2870,37 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { int16_t nSamplesToRender, nSamplesRendered_loop; bool tmp; +#ifdef OBJ_EDITING_INTERFACE + nSamplesToRender = nSamplesPerChannel - *nSamplesRendered; +#else nSamplesToRender = nSamplesPerChannel - nSamplesRendered; +#endif + +#ifdef OBJ_EDITING_INTERFACE + /* check if we still need to prepare the renderer */ + if ( hIvasDec->hasBeenPreparedRendering == false ) + { + + if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif /* render IVAS frames directly to the output buffer */ +#ifdef OBJ_EDITING_INTERFACE +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + *nSamplesRendered * nOutChannels, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + + *nSamplesRendered += nSamplesRendered_loop; +#else #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #else @@ -2771,6 +2911,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } nSamplesRendered += nSamplesRendered_loop; +#endif update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 2dccb45525..5df30cbdb8 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -154,6 +154,22 @@ ivas_error IVAS_DEC_FeedFrame_Serial( int16_t bfi /* i : bad frame indicator flag */ ); +#ifdef OBJ_EDITING_INTERFACE +ivas_error IVAS_DEC_GetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters +); + +ivas_error IVAS_DEC_SetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters +); + +ivas_error IVAS_DEC_PrepareRenderer( + IVAS_DEC_HANDLE hIvasDec +); +#endif + /*! r: decoder error code */ ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ @@ -282,6 +298,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( , JbmTraceFileWriterFn jbmWriterFn, void* jbmWriter #endif +#ifdef OBJ_EDITING_INTERFACE + , + uint16_t *nSamplesRendered, + bool *parametersAvailableForEditing +#endif ); ivas_error IVAS_DEC_Flush( -- GitLab From 9e5c8aae3fca657614310846deeee50b2fbe8767 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 8 Apr 2024 15:12:19 +0200 Subject: [PATCH 004/130] object editing interface, start populating the API functions, add example code in the decoder, add functionality for discrete ISM object editing. --- apps/decoder.c | 72 +++++++++++++++++++++++++- lib_com/common_api_types.h | 1 - lib_com/ivas_ism_com.c | 3 ++ lib_com/ivas_prot.h | 5 ++ lib_com/options.h | 2 +- lib_dec/ivas_dirac_dec.c | 3 ++ lib_dec/ivas_init_dec.c | 7 ++- lib_dec/ivas_ism_param_dec.c | 16 ++++++ lib_dec/ivas_ism_renderer.c | 63 ++++++++++++++++++++++ lib_dec/ivas_jbm_dec.c | 5 ++ lib_dec/ivas_objectRenderer_internal.c | 19 +++++++ lib_dec/ivas_stat_dec.h | 11 ++++ lib_dec/lib_dec.c | 57 +++++++++++++++++++- lib_rend/ivas_objectRenderer.c | 9 ++++ lib_rend/ivas_objectRenderer_sources.c | 34 ++++++++++++ lib_rend/ivas_prot_rend.h | 8 +++ 16 files changed, 310 insertions(+), 5 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 18dc59b385..0a956a6846 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -55,6 +55,11 @@ #include "debug.h" #endif #include "wmc_auto.h" +#ifdef OBJ_EDITING_INTERFACE +#ifdef DEBUGGING +#include +#endif +#endif #define WMC_TOOL_SKIP @@ -144,7 +149,11 @@ typedef struct uint16_t acousticEnvironmentId; int16_t Opt_dpid_on; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; - +#ifdef OBJ_EDITING_INTERFACE +#ifdef DEBUGGING + bool objEditEnabled; +#endif +#endif } DecArguments; @@ -1096,6 +1105,13 @@ static bool parseCmdlIVAS_dec( arg->directivityPatternId[i] = 65535; } +#ifdef OBJ_EDITING_INTERFACE +#ifdef DEBUGGING + arg->objEditEnabled = false; +#endif +#endif + + /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -1521,6 +1537,15 @@ static bool parseCmdlIVAS_dec( i += tmp; } +#ifdef OBJ_EDITING_INTERFACE +#ifdef DEBUGGING + else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 ) + { + arg->objEditEnabled = true; + i++; + } +#endif +#endif /*-----------------------------------------------------------------* * Option not recognized @@ -2355,6 +2380,51 @@ static ivas_error decodeG192( } /* edit object parameters...*/ +#ifdef DEBUGGING + if ( arg.objEditEnabled ) + { + /* put the objects equally spaced at the horizontal plane */ + /* and play a little bit with the gains... */ + int16_t obj_idx, non_diegetic_obj_idx; + int16_t num_nondiegetic_objects; + float gain_mean; + float gain_amplitude; + float gain_freq; + float gain_freq_offset; + + num_nondiegetic_objects = 0; + for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + { + num_nondiegetic_objects++; + } + } + if ( num_nondiegetic_objects ) + { + float start_angle, angle_inc; + angle_inc = 360.0f / (float) num_nondiegetic_objects; + start_angle = angle_inc / 2.0f; + for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + { + editableParameters.ism_metadata[obj_idx].elevation = 0.0f; + editableParameters.ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc; + non_diegetic_obj_idx++; + } + } + } + gain_mean = 1.0f; + gain_amplitude = 0.7f; + gain_freq = ( 2.0f * 3.1415f ) / 100.0f; + gain_freq_offset = 2.0f * 3.1415f / (float) ( editableParameters.num_obj + 1 ); + for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + editableParameters.ism_metadata[obj_idx].gain = gain_mean + gain_amplitude * sinf( (float) frame * gain_freq + gain_freq_offset * (float) obj_idx ); + } + } +#endif /* set new object parameters*/ if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) { diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index f9f55e20d4..3fb7aba5ea 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -130,7 +130,6 @@ typedef struct _IVAS_ISM_METADATA typedef struct _IVAS_EDITABLE_PARAMETERS { - int16_t num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; float gain_bed; diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 55f6016fcf..a1ba4caf05 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -417,6 +417,9 @@ void ivas_ism_reset_metadata( hIsmMeta->radius = 1.0f; hIsmMeta->ism_metadata_flag = 0; hIsmMeta->non_diegetic_flag = 0; +#ifdef OBJ_EDITING_INTERFACE + hIsmMeta->gain = 1.0f; +#endif return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2738e5b1c3..258e005745 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1033,6 +1033,11 @@ ivas_error ivas_ism_metadata_dec( DEC_CORE_HANDLE st0 /* i : core-coder handle */ ); +#ifdef OBJ_EDITING_INTERFACE +void ivas_ism_renderer_update_md( + Decoder_Struct *st_ivas /* i/o: main IVAS decoder handle */ +); +#endif /*----------------------------------------------------------------------------------* * Parametric ISM prototypes diff --git a/lib_com/options.h b/lib_com/options.h index 2fec4cf680..ad8c3a5f94 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -/*#define DEBUGGING*/ /* Activate debugging part of the code */ +#define DEBUGGING /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index c8d52aa67e..c201c8511e 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2286,6 +2286,9 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); +#ifdef OBJ_EDITING_INTERFACE + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); +#endif } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b92dc19ded..26a9cb4333 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2138,7 +2138,12 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM +#ifdef OBJ_EDITING_INTERFACE + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD +#endif + ) + ) { if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 77a23c3c54..2300478bf1 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1035,13 +1035,23 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { +#ifdef OBJ_EDITING_INTERFACE + ivas_ism_get_stereo_gains( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], CPE_CHANNELS ); +#else ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); +#endif } else { // TODO tmu review when #215 is resolved +#ifdef OBJ_EDITING_INTERFACE + azimuth = (int16_t) floorf( st_ivas->hIsmRendererData->edited_azimuth[i] + 0.5f ); + elevation = (int16_t) floorf( st_ivas->hIsmRendererData->edited_elevation[i] + 0.5f ); +#else azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); +#endif if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_OSBA_LS || @@ -1057,6 +1067,9 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); +#ifdef OBJ_EDITING_INTERFACE + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], st_ivas->hEFAPdata->numSpk ); +#endif } } else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || @@ -1065,6 +1078,9 @@ void ivas_ism_dec_digest_tc( { /*get HOA gets for direction (ACN/SN3D)*/ ivas_dirac_dec_get_response( azimuth, elevation, st_ivas->hIsmRendererData->gains[i], st_ivas->hIntSetup.ambisonics_order ); +#ifdef OBJ_EDITING_INTERFACE + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], ivas_sba_get_nchan( st_ivas->hIntSetup.ambisonics_order, 0 ) ); +#endif } } } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 7b321c523b..bf00dd5021 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -78,6 +78,17 @@ ivas_error ivas_ism_renderer_open( { set_f( st_ivas->hIsmRendererData->prev_gains[i], 0.0f, MAX_OUTPUT_CHANNELS ); set_f( st_ivas->hIsmRendererData->gains[i], 0.0f, MAX_OUTPUT_CHANNELS ); +#ifdef OBJ_EDITING_INTERFACE + st_ivas->hIsmRendererData->edited_gains[i] = 1.0f; + st_ivas->hIsmRendererData->edited_azimuth[i] = 0.0f; + st_ivas->hIsmRendererData->edited_elevation[i] = 0.0f; + st_ivas->hIsmRendererData->edited_pitch[i] = 0.0f; + st_ivas->hIsmRendererData->edited_yaw[i] = 0.0f; + st_ivas->hIsmRendererData->edited_radius[i] = 1.0f; + st_ivas->hIsmRendererData->last_edited_azimuth[i] = 0.0f; + st_ivas->hIsmRendererData->last_edited_elevation[i] = 0.0f; + st_ivas->hIsmRendererData->non_diegetic_flag[i] = 0; +#endif } if ( st_ivas->hDecoderConfig->Opt_tsm ) @@ -132,6 +143,11 @@ void ivas_ism_renderer_close( return; } +#ifdef OBJ_EDITING_INTERFACE + + +#endif + /*-------------------------------------------------------------------------* * ivas_ism_render_sf() @@ -234,15 +250,26 @@ void ivas_ism_render_sf( { if ( subframe_idx >= ism_md_subframe_update_jbm ) { +#ifdef OBJ_EDITING_INTERFACE + rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#else rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#endif } else { +#ifdef OBJ_EDITING_INTERFACE + rotateAziEle( st_ivas->hIsmRendererData->last_edited_azimuth[i], st_ivas->hIsmRendererData->last_edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#else rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#endif } if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); +#ifdef OBJ_EDITING_INTERFACE + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); +#endif } } @@ -600,3 +627,39 @@ void ivas_omasa_separate_object_render_jbm( return; } + +#ifdef OBJ_EDITING_INTERFACE +/*-------------------------------------------------------------------------* + * ivas_ism_renderer_update_md() + * + * set renderer ISM MD to the bitstream ISM MD values + *-------------------------------------------------------------------------*/ +void ivas_ism_renderer_update_md( + Decoder_Struct *st_ivas /* i/o: main IVAS decoder handle */ +) +{ + ISM_RENDERER_HANDLE hIsmRenderer; + int16_t num_obj, obj_idx; + + + num_obj = st_ivas->nchan_ism; + hIsmRenderer = st_ivas->hIsmRendererData; + + for ( obj_idx = 0; obj_idx < num_obj; obj_idx++ ) + { + hIsmRenderer->last_edited_azimuth[obj_idx] = hIsmRenderer->edited_azimuth[obj_idx]; + hIsmRenderer->last_edited_elevation[obj_idx] = hIsmRenderer->edited_elevation[obj_idx]; + hIsmRenderer->edited_azimuth[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->azimuth; + hIsmRenderer->edited_elevation[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->elevation; + hIsmRenderer->edited_radius[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->radius; + hIsmRenderer->edited_yaw[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->yaw; + hIsmRenderer->edited_pitch[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->pitch; + hIsmRenderer->edited_gains[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->gain; + hIsmRenderer->non_diegetic_flag[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->non_diegetic_flag; + } + + return; +} + + +#endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d5c9b66ce3..6d2b61534e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -146,6 +146,7 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ivas_format == ISM_FORMAT ) { + /* Metadata decoding and configuration */ if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) { @@ -189,6 +190,10 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } +#ifdef OBJ_EDITING_INTERFACE + ivas_ism_renderer_update_md( st_ivas ); +#endif + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 907affdae1..96f47ef9f0 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -173,7 +173,26 @@ ivas_error ivas_td_binaural_renderer_sf( } if ( subframe_idx == ism_md_subframe_update_jbm ) { +#ifdef OBJ_EDITING_INTERFACE + ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; + ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; + int16_t s_idx; + s_idx = 0; + for ( nS = 0; nS < nchan_ism; nS++ ) + { + ismMetaData[nS].azimuth = st_ivas->hIsmRendererData->edited_azimuth[nS]; + ismMetaData[nS].elevation = st_ivas->hIsmRendererData->edited_elevation[nS]; + ismMetaData[nS].radius = st_ivas->hIsmRendererData->edited_radius[nS]; + ismMetaData[nS].yaw = st_ivas->hIsmRendererData->edited_yaw[nS]; + ismMetaData[nS].pitch = st_ivas->hIsmRendererData->edited_pitch[nS]; + ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[nS]; + ismMetaData[nS].gain = st_ivas->hIsmRendererData->edited_gains[nS]; + hIsmMetaData[nS] = &ismMetaData[nS]; + } + if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) +#else if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ab37bc9896..7b5539cd7b 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -808,6 +808,17 @@ typedef struct renderer_struct float *interpolator; int16_t interpolator_length; float gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; +#ifdef OBJ_EDITING_INTERFACE + float edited_gains[MAX_NUM_OBJECTS]; + float edited_azimuth[MAX_NUM_OBJECTS]; + float edited_elevation[MAX_NUM_OBJECTS]; + float edited_yaw[MAX_NUM_OBJECTS]; + float edited_pitch[MAX_NUM_OBJECTS]; + float edited_radius[MAX_NUM_OBJECTS]; + float last_edited_azimuth[MAX_NUM_OBJECTS]; + float last_edited_elevation[MAX_NUM_OBJECTS]; + int16_t non_diegetic_flag[MAX_NUM_OBJECTS]; +#endif } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7e0ad2116a..23f1a05bc4 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -952,7 +952,32 @@ ivas_error IVAS_DEC_GetEditableParameters( { ivas_error error; - hIvasEditableParameters = NULL; + if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; + hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + } + } + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + } + else + { + } error = IVAS_ERR_OK; @@ -973,6 +998,36 @@ ivas_error IVAS_DEC_SetEditableParameters( error = IVAS_ERR_OK; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); +#endif + + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; + hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + } + } + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + } + else + { + } + return error; } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 35d5531633..001a4d7899 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -478,6 +478,9 @@ static void TDREND_Clear_Update_flags( for ( i = 0; i < hBinRendererTd->NumOfSrcs; i++ ) { hBinRendererTd->Sources[i]->SrcSpatial_p->Updated = FALSE; +#ifdef OBJ_EDITING_INTERFACE + hBinRendererTd->Sources[i]->SrcRend_p->SrcGainUpdated = FALSE; +#endif } return; @@ -545,6 +548,12 @@ ivas_error TDREND_Update_object_positions( { return error; } +#ifdef OBJ_EDITING_INTERFACE + if ( ( error = TDREND_MIX_SRC_SetSrcGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif } } diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 3f580df504..e1da7043a4 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -153,6 +153,36 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( return IVAS_ERR_OK; } +#ifdef OBJ_EDITING_INTERFACE +/*-------------------------------------------------------------------* + * TDREND_MIX_SRC_SetSrcGain() + * + * Set the source (i.e. overall gain) for a source for the mixer. + --------------------------------------------------------------------*/ + +ivas_error TDREND_MIX_SRC_SetSrcGain( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float SrcGain_p /* i : Source gain */ +) +{ + if ( SrcInd > hBinRendererTd->MaxSrcInd ) + { + return ( IVAS_ERROR( IVAS_ERR_INVALID_INDEX, "Index exceeds max index\n" ) ); + } + else if ( SrcGain_p < *hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGainMin_p || SrcGain_p > *hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGainMax_p ) + { + return ( IVAS_ERROR( IVAS_ERR_INVALID_INDEX, "gain exceeds gain limits\n" ) ); + } + else + { + *hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGain_p = SrcGain_p; + hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGainUpdated = TRUE; + } + + return IVAS_ERR_OK; +} +#endif /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetPlayState() @@ -224,7 +254,11 @@ static void TDREND_SRC_REND_Init( { SrcRend_p->SrcGainMin_p[nC] = 0.0f; SrcRend_p->SrcGain_p[nC] = 1.0f; +#ifdef OBJ_EDITING_INTERFACE + SrcRend_p->SrcGainMax_p[nC] = 2.0f; +#else SrcRend_p->SrcGainMax_p[nC] = 1.0f; +#endif } SrcRend_p->SrcGainUpdated = FALSE; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 7de4ed3e8c..e1f9794b4f 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -760,6 +760,14 @@ ivas_error TDREND_MIX_SRC_SetPlayState( const TDREND_PlayStatus_t PlayStatus /* i : Play state */ ); +#ifdef OBJ_EDITING_INTERFACE +ivas_error TDREND_MIX_SRC_SetSrcGain( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float SrcGain_p /* i : Source gain */ +); +#endif + void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ -- GitLab From df367c9d1a4845ee4fe659f1800bf117c739770c Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 11 Apr 2024 08:36:01 +0200 Subject: [PATCH 005/130] fixes to make sure all modes run w/o problems when no object editing happens --- apps/decoder.c | 34 ++++++++++--------- lib_dec/ivas_jbm_dec.c | 13 +++++-- lib_dec/ivas_objectRenderer_internal.c | 47 ++++++++++++++++---------- 3 files changed, 57 insertions(+), 37 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0a956a6846..27f01e33d7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2371,18 +2371,20 @@ static ivas_error decodeG192( goto cleanup; } #ifdef OBJ_EDITING_INTERFACE - /* Do object info editing here */ - /* get object parameters */ - if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - /* edit object parameters...*/ #ifdef DEBUGGING if ( arg.objEditEnabled ) { + + /* Do object info editing here */ + /* get object parameters */ + if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + /* edit object parameters...*/ + /* put the objects equally spaced at the horizontal plane */ /* and play a little bit with the gains... */ int16_t obj_idx, non_diegetic_obj_idx; @@ -2415,6 +2417,7 @@ static ivas_error decodeG192( } } } + /* 2 second AM of the object gains. */ gain_mean = 1.0f; gain_amplitude = 0.7f; gain_freq = ( 2.0f * 3.1415f ) / 100.0f; @@ -2423,15 +2426,14 @@ static ivas_error decodeG192( { editableParameters.ism_metadata[obj_idx].gain = gain_mean + gain_amplitude * sinf( (float) frame * gain_freq + gain_freq_offset * (float) obj_idx ); } + /* set new object parameters*/ + if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } } #endif - /* set new object parameters*/ - if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - /* Do the final preparations needed for rendering */ if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6d2b61534e..52a998f317 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -191,7 +191,10 @@ ivas_error ivas_jbm_dec_tc( } #ifdef OBJ_EDITING_INTERFACE - ivas_ism_renderer_update_md( st_ivas ); + if ( st_ivas->ism_mode != ISM_MODE_PARAM && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) ) + { + ivas_ism_renderer_update_md( st_ivas ); + } #endif if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -965,7 +968,11 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else #endif - if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + if ( st_ivas->mc_mode == MC_MODE_PARAMMC +#ifdef OBJ_EDITING_INTERFACE + && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER +#endif + ) { ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); } @@ -1011,7 +1018,7 @@ void ivas_jbm_dec_prepare_renderer( { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } - if ( st_ivas->ivas_format == ISM_FORMAT ) + else if ( st_ivas->ivas_format == ISM_FORMAT ) { /* Rendering */ if ( st_ivas->ism_mode == ISM_MODE_PARAM ) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 96f47ef9f0..8584644d38 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -174,28 +174,39 @@ ivas_error ivas_td_binaural_renderer_sf( if ( subframe_idx == ism_md_subframe_update_jbm ) { #ifdef OBJ_EDITING_INTERFACE - ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; - ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; - int16_t s_idx; - s_idx = 0; - for ( nS = 0; nS < nchan_ism; nS++ ) + if ( st_ivas->ivas_format == ISM_FORMAT ) { - ismMetaData[nS].azimuth = st_ivas->hIsmRendererData->edited_azimuth[nS]; - ismMetaData[nS].elevation = st_ivas->hIsmRendererData->edited_elevation[nS]; - ismMetaData[nS].radius = st_ivas->hIsmRendererData->edited_radius[nS]; - ismMetaData[nS].yaw = st_ivas->hIsmRendererData->edited_yaw[nS]; - ismMetaData[nS].pitch = st_ivas->hIsmRendererData->edited_pitch[nS]; - ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[nS]; - ismMetaData[nS].gain = st_ivas->hIsmRendererData->edited_gains[nS]; - hIsmMetaData[nS] = &ismMetaData[nS]; + ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; + ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; + int16_t s_idx; + s_idx = 0; + for ( nS = 0; nS < nchan_ism; nS++ ) + { + ismMetaData[nS].azimuth = st_ivas->hIsmRendererData->edited_azimuth[nS]; + ismMetaData[nS].elevation = st_ivas->hIsmRendererData->edited_elevation[nS]; + ismMetaData[nS].radius = st_ivas->hIsmRendererData->edited_radius[nS]; + ismMetaData[nS].yaw = st_ivas->hIsmRendererData->edited_yaw[nS]; + ismMetaData[nS].pitch = st_ivas->hIsmRendererData->edited_pitch[nS]; + ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[nS]; + ismMetaData[nS].gain = st_ivas->hIsmRendererData->edited_gains[nS]; + hIsmMetaData[nS] = &ismMetaData[nS]; + } + + if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } } - if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) -#else - if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) -#endif + else { - return error; +#endif + if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef OBJ_EDITING_INTERFACE } +#endif } /* Update the listener's location/orientation */ -- GitLab From d5210093368bf527cd48cac8c87efe6961e97c59 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 23 Apr 2024 09:47:04 +0200 Subject: [PATCH 006/130] fix Linux compile errors --- lib_dec/ivas_ism_param_dec.c | 4 ---- lib_dec/ivas_objectRenderer_internal.c | 2 -- lib_dec/lib_dec.c | 10 +++++++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 2300478bf1..aacde8e88d 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1282,22 +1282,18 @@ void ivas_param_ism_dec_prepare_renderer( int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; int16_t slot_idx, bin_idx; int32_t ivas_total_brate; - int16_t output_frame; float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - int16_t fade_len; /* Initialization */ hParamIsmDec = st_ivas->hParamIsmDec; assert( hParamIsmDec ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; assert( hSpatParamRendCom ); - output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands; - fade_len = output_frame / 2; nchan_transport = st_ivas->nchan_transport; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 8584644d38..4b6ac2cce6 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -178,8 +178,6 @@ ivas_error ivas_td_binaural_renderer_sf( { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; - int16_t s_idx; - s_idx = 0; for ( nS = 0; nS < nchan_ism; nS++ ) { ismMetaData[nS].azimuth = st_ivas->hIsmRendererData->edited_azimuth[nS]; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 23f1a05bc4..0f474d27f8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1078,17 +1078,21 @@ ivas_error IVAS_DEC_GetSamples( { ivas_error error; int16_t nSamplesToRender; - uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts; - uint8_t nTransportChannels, nOutChannels; + uint16_t nSamplesRendered, nSamplesRendered_loop; + uint8_t nOutChannels; #ifndef OBJ_EDITING_INTERFACE + uint8_t nTransportChannels; int16_t nOutSamplesElse; - uint16_t nTimeScalerOutSamples; + uint16_t nTimeScalerOutSamples. l_ts; #endif nSamplesRendered = 0; nOutChannels = 0; nSamplesRendered_loop = 0; +#ifndef OBJ_EDITING_INTERFACE l_ts = 0; nTransportChannels = 0; +#endif + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { -- GitLab From be36c11053235f4882d17101b1611fc4c7e49255 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 29 Apr 2024 11:48:49 +0200 Subject: [PATCH 007/130] object editing interface, created two sub-defines to OBJECT_EDITING_INTERFACE: OBJECT_EDITING_API and OBJECT_EDITING_DECODER to better distinguish between changes needed for the API adaption and changes needed in the decoder itself --- apps/decoder.c | 22 ++++++------- lib_com/common_api_types.h | 4 +-- lib_com/ivas_ism_com.c | 2 +- lib_com/ivas_prot.h | 8 ++--- lib_com/ivas_stat_com.h | 2 +- lib_com/options.h | 6 +++- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_ism_param_dec.c | 22 ++++++------- lib_dec/ivas_ism_renderer.c | 15 +++------ lib_dec/ivas_jbm_dec.c | 18 +++++------ lib_dec/ivas_mc_param_dec.c | 30 ++++-------------- lib_dec/ivas_objectRenderer_internal.c | 4 +-- lib_dec/ivas_stat_dec.h | 4 +-- lib_dec/lib_dec.c | 44 +++++++++++++------------- lib_dec/lib_dec.h | 4 +-- lib_rend/ivas_objectRenderer.c | 4 +-- lib_rend/ivas_objectRenderer_sources.c | 4 +-- lib_rend/ivas_prot_rend.h | 2 +- 19 files changed, 91 insertions(+), 108 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 4e0489ca45..69b14167f9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -55,7 +55,7 @@ #include "debug.h" #endif #include "wmc_auto.h" -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API #ifdef DEBUGGING #include #endif @@ -149,7 +149,7 @@ typedef struct uint16_t acousticEnvironmentId; int16_t Opt_dpid_on; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API #ifdef DEBUGGING bool objEditEnabled; #endif @@ -1105,7 +1105,7 @@ static bool parseCmdlIVAS_dec( arg->directivityPatternId[i] = 65535; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API #ifdef DEBUGGING arg->objEditEnabled = false; #endif @@ -1537,7 +1537,7 @@ static bool parseCmdlIVAS_dec( i += tmp; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API #ifdef DEBUGGING else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 ) { @@ -2106,7 +2106,7 @@ static ivas_error decodeG192( #ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; #endif -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API IVAS_EDITABLE_PARAMETERS editableParameters; #endif @@ -2370,7 +2370,7 @@ static ivas_error decodeG192( fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API #ifdef DEBUGGING if ( arg.objEditEnabled ) { @@ -3028,7 +3028,7 @@ static ivas_error decodeVoIP( int16_t vec_pos_update, vec_pos_len; int16_t nOutSamples = 0; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API bool parameterAvailableForEditing = false; uint16_t nSamplesRendered = 0; #endif @@ -3149,7 +3149,7 @@ static ivas_error decodeVoIP( while ( 1 ) { -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API nSamplesRendered = 0; #endif /* reference vector */ @@ -3322,11 +3322,11 @@ static ivas_error decodeVoIP( /* decode and get samples */ -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API while ( nSamplesRendered < nOutSamples ) { #endif -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) @@ -3359,7 +3359,7 @@ static ivas_error decodeVoIP( fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API if ( parameterAvailableForEditing == true ) { /* do the object editing here */ diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index c6793b86c3..474c467d21 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -122,13 +122,13 @@ typedef struct _IVAS_ISM_METADATA float yaw; float pitch; int16_t non_diegetic_flag; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API float gain; #endif } IVAS_ISM_METADATA; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API typedef struct _IVAS_EDITABLE_PARAMETERS { int16_t num_obj; diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index a1ba4caf05..d32e1179bc 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -417,7 +417,7 @@ void ivas_ism_reset_metadata( hIsmMeta->radius = 1.0f; hIsmMeta->ism_metadata_flag = 0; hIsmMeta->non_diegetic_flag = 0; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER hIsmMeta->gain = 1.0f; #endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 3531670f71..fe5802c3e8 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -822,7 +822,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( float *data /* i/o: transport channels/output synthesis signal */ ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API void ivas_jbm_dec_prepare_renderer( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); @@ -1033,7 +1033,7 @@ ivas_error ivas_ism_metadata_dec( DEC_CORE_HANDLE st0 /* i : core-coder handle */ ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER void ivas_ism_renderer_update_md( Decoder_Struct *st_ivas /* i/o: main IVAS decoder handle */ ); @@ -1116,7 +1116,7 @@ void ivas_param_ism_dec_digest_tc( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API void ivas_param_ism_dec_prepare_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ @@ -3872,7 +3872,7 @@ void ivas_param_mc_dec_digest_tc( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API void ivas_param_mc_dec_prepare_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 7ce6768040..ae5653d05f 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -87,7 +87,7 @@ typedef struct float q_azimuth_old; float q_elevation_old; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER float gain; #endif diff --git a/lib_com/options.h b/lib_com/options.h index 2cd99fffcb..fa563f0cd2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,7 +150,11 @@ /* ################## Start DEVELOPMENT switches ######################### */ -#define OBJ_EDITING_INTERFACE +#define OBJ_EDITING_INTERFACE /* Interface for object editing */ +#ifdef OBJ_EDITING_INTERFACE +#define OBJ_EDITING_API /* object editing changes related to the API */ +#define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ +#endif /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index c201c8511e..280311021a 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2286,7 +2286,7 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); #endif } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index cee995db01..9b57805d78 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2139,7 +2139,7 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD #endif ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index f93be45fb3..813849d79b 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -752,7 +752,7 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER ivas_ism_get_stereo_gains( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], CPE_CHANNELS ); #else @@ -762,7 +762,7 @@ void ivas_ism_dec_digest_tc( else { // TODO tmu review when #215 is resolved -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER azimuth = (int16_t) floorf( st_ivas->hIsmRendererData->edited_azimuth[i] + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmRendererData->edited_elevation[i] + 0.5f ); #else @@ -784,7 +784,7 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], st_ivas->hEFAPdata->numSpk ); #endif } @@ -795,7 +795,7 @@ void ivas_ism_dec_digest_tc( { /*get HOA gets for direction (ACN/SN3D)*/ ivas_dirac_dec_get_response( azimuth, elevation, st_ivas->hIsmRendererData->gains[i], st_ivas->hIntSetup.ambisonics_order ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], ivas_sba_get_nchan( st_ivas->hIntSetup.ambisonics_order, 0 ) ); #endif } @@ -821,13 +821,13 @@ void ivas_param_ism_dec_digest_tc( { int16_t ch, nchan_transport; int16_t slot_idx; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API int16_t nchan_out, nchan_out_woLFE, i; int16_t bin_idx; int32_t ivas_total_brate; #endif int16_t output_frame; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ @@ -847,7 +847,7 @@ void ivas_param_ism_dec_digest_tc( nchan_transport = st_ivas->nchan_transport; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) @@ -864,7 +864,7 @@ void ivas_param_ism_dec_digest_tc( #endif push_wmops( "ivas_param_ism_dec_digest_tc" ); -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API /* general setup */ ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); @@ -961,13 +961,13 @@ void ivas_param_ism_dec_digest_tc( mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); #endif } } -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API /* Obtain Mixing Matrix on a frame-level */ for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) { @@ -984,7 +984,7 @@ void ivas_param_ism_dec_digest_tc( } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /*-------------------------------------------------------------------------* * ivas_param_ism_dec_prepare_renderer() * diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 64c68014d4..d637bce348 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -78,7 +78,7 @@ ivas_error ivas_ism_renderer_open( { set_f( st_ivas->hIsmRendererData->prev_gains[i], 0.0f, MAX_OUTPUT_CHANNELS ); set_f( st_ivas->hIsmRendererData->gains[i], 0.0f, MAX_OUTPUT_CHANNELS ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER st_ivas->hIsmRendererData->edited_gains[i] = 1.0f; st_ivas->hIsmRendererData->edited_azimuth[i] = 0.0f; st_ivas->hIsmRendererData->edited_elevation[i] = 0.0f; @@ -143,11 +143,6 @@ void ivas_ism_renderer_close( return; } -#ifdef OBJ_EDITING_INTERFACE - - -#endif - /*-------------------------------------------------------------------------* * ivas_ism_render_sf() @@ -246,7 +241,7 @@ void ivas_ism_render_sf( { if ( subframe_idx >= ism_md_subframe_update_jbm ) { -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #else rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); @@ -254,7 +249,7 @@ void ivas_ism_render_sf( } else { -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER rotateAziEle( st_ivas->hIsmRendererData->last_edited_azimuth[i], st_ivas->hIsmRendererData->last_edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #else rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); @@ -263,7 +258,7 @@ void ivas_ism_render_sf( if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); #endif } @@ -624,7 +619,7 @@ void ivas_omasa_separate_object_render_jbm( return; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER /*-------------------------------------------------------------------------* * ivas_ism_renderer_update_md() * diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1bbb8b381c..7819919511 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -190,7 +190,7 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER if ( st_ivas->ism_mode != ISM_MODE_PARAM && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) ) { ivas_ism_renderer_update_md( st_ivas ); @@ -825,7 +825,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); @@ -846,7 +846,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( /* Rendering */ if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); @@ -860,14 +860,14 @@ void ivas_jbm_dec_feed_tc_to_renderer( ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); } } -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API else /* ISM_MODE_DISC */ { ivas_ism_dec_digest_tc( st_ivas ); } #endif } -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); @@ -966,7 +966,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( #endif else if ( st_ivas->ivas_format == MC_FORMAT ) { -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API if ( st_ivas->mc_mode == MC_MODE_MCT ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); @@ -978,14 +978,14 @@ void ivas_jbm_dec_feed_tc_to_renderer( else #endif if ( st_ivas->mc_mode == MC_MODE_PARAMMC -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER #endif ) { ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); } -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); @@ -997,7 +997,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( return; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /*--------------------------------------------------------------------------* * ivas_jbm_dec_prepare_renderer() * diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index f65907252f..ba5cfae2b4 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1330,7 +1330,7 @@ void ivas_param_mc_dec_digest_tc( int16_t ch; int16_t slot_idx; int16_t nchan_transport; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API int16_t nchan_out_transport, nchan_out_cldfb, i, param_band_idx; int16_t nchan_out_cov; /*CLDFB*/ @@ -1345,12 +1345,12 @@ void ivas_param_mc_dec_digest_tc( assert( hParamMC ); push_wmops( "param_mc_dec_digest_tc" ); -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API set_s( channel_active, 0, MAX_CICP_CHANNELS ); #endif nchan_transport = st_ivas->nchan_transport; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -1419,14 +1419,14 @@ void ivas_param_mc_dec_digest_tc( mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); } } -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) { ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); } #endif } -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API /* map from complex input covariance to real values */ for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) { @@ -1478,9 +1478,9 @@ void ivas_param_mc_dec_digest_tc( return; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /*------------------------------------------------------------------------- - * ivas_param_mc_dec_digest_tc() + * ivas_param_mc_dec_prepare_renderer() * * *------------------------------------------------------------------------*/ @@ -1564,22 +1564,6 @@ void ivas_param_mc_dec_prepare_renderer( /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { -#ifndef OBJ_EDITING_INTERFACE - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; - float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - - /* CLDFB Analysis*/ - for ( ch = 0; ch < nchan_transport; ch++ ) - { - cldfbAnalysis_ts( &( transport_channels_f[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); - - mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - } - } -#endif if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) { ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 4b6ac2cce6..958eae1266 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -173,7 +173,7 @@ ivas_error ivas_td_binaural_renderer_sf( } if ( subframe_idx == ism_md_subframe_update_jbm ) { -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER if ( st_ivas->ivas_format == ISM_FORMAT ) { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; @@ -202,7 +202,7 @@ ivas_error ivas_td_binaural_renderer_sf( { return error; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER } #endif } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 7b5539cd7b..c92fb692a7 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -808,7 +808,7 @@ typedef struct renderer_struct float *interpolator; int16_t interpolator_length; float gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS]; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER float edited_gains[MAX_NUM_OBJECTS]; float edited_azimuth[MAX_NUM_OBJECTS]; float edited_elevation[MAX_NUM_OBJECTS]; @@ -908,7 +908,7 @@ typedef struct ivas_masa_ism_data_structure int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; uint8_t ism_is_edited[MAX_NUM_OBJECTS]; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER float gain_ism[MAX_NUM_OBJECTS]; float gain_masa; #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0f474d27f8..728a3daa7c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -94,7 +94,7 @@ struct IVAS_DEC 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 OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API uint16_t nSamplesFlushed; int16_t *flushbuffer; bool hasEditableParameters; @@ -183,7 +183,7 @@ ivas_error IVAS_DEC_Open( hIvasDec->hasDecodedFirstGoodFrame = false; hIvasDec->isInitialized = false; hIvasDec->updateOrientation = false; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API hIvasDec->flushbuffer = NULL; hIvasDec->nSamplesFlushed = 0; hIvasDec->hasEditableParameters = false; @@ -331,7 +331,7 @@ void IVAS_DEC_Close( { free( ( *phIvasDec )->apaExecBuffer ); } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API if ( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); @@ -501,7 +501,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /* 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 ) ) { @@ -763,7 +763,7 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_FAILED_ALLOC; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /* 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 ) ) { @@ -864,7 +864,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->nSamplesRendered = 0; hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /* decode TCs, do TSM and feed to renderer */ /* setup */ { @@ -940,7 +940,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /*---------------------------------------------------------------------* * IVAS_DEC_GetEditableParameters( ) * @@ -1080,7 +1080,7 @@ ivas_error IVAS_DEC_GetSamples( int16_t nSamplesToRender; uint16_t nSamplesRendered, nSamplesRendered_loop; uint8_t nOutChannels; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API uint8_t nTransportChannels; int16_t nOutSamplesElse; uint16_t nTimeScalerOutSamples. l_ts; @@ -1088,7 +1088,7 @@ ivas_error IVAS_DEC_GetSamples( nSamplesRendered = 0; nOutChannels = 0; nSamplesRendered_loop = 0; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API l_ts = 0; nTransportChannels = 0; #endif @@ -1099,7 +1099,7 @@ ivas_error IVAS_DEC_GetSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /* the rendering needs to be prepared at this point */ if ( hIvasDec->hasBeenPreparedRendering == false ) { @@ -1157,7 +1157,7 @@ ivas_error IVAS_DEC_GetSamples( } else { -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API /* check if we need to run the setup function */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { @@ -1179,7 +1179,7 @@ ivas_error IVAS_DEC_GetSamples( #endif { /* check if we need to run the setup function, tc decoding and feeding the renderer */ -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { int16_t nResidualSamples, nSamplesTcsScaled; @@ -2736,7 +2736,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter #endif -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API , uint16_t *nSamplesRendered, bool *parametersAvailableForEditing @@ -2751,7 +2751,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( uint16_t extBufferedSamples; int16_t result; ivas_error error; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API int16_t nSamplesRendered; #endif uint8_t nOutChannels; @@ -2760,10 +2760,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; -#ifndef OBJ_EDITING_INTERFACE +#ifndef OBJ_EDITING_API nSamplesRendered = 0; #endif -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API *parametersAvailableForEditing = false; #endif @@ -2773,7 +2773,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API while ( *nSamplesRendered < nSamplesPerChannel ) #else while ( nSamplesRendered < nSamplesPerChannel ) @@ -2890,7 +2890,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; hIvasDec->nSamplesRendered = 0; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /* :TODO: only return here if we really have editing initialized */ if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) { @@ -2906,7 +2906,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* codec mode to use not known yet - simply output silence */ /* directly set output zero */ int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API #ifdef SPLIT_REND_WITH_HEAD_ROT set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); #else @@ -2929,13 +2929,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { int16_t nSamplesToRender, nSamplesRendered_loop; bool tmp; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API nSamplesToRender = nSamplesPerChannel - *nSamplesRendered; #else nSamplesToRender = nSamplesPerChannel - nSamplesRendered; #endif -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API /* check if we still need to prepare the renderer */ if ( hIvasDec->hasBeenPreparedRendering == false ) { @@ -2948,7 +2948,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif /* render IVAS frames directly to the output buffer */ -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 5df30cbdb8..e30e030c9f 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -154,7 +154,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( int16_t bfi /* i : bad frame indicator flag */ ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters @@ -298,7 +298,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( , JbmTraceFileWriterFn jbmWriterFn, void* jbmWriter #endif -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_API , uint16_t *nSamplesRendered, bool *parametersAvailableForEditing diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 001a4d7899..05b0ad8508 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -478,7 +478,7 @@ static void TDREND_Clear_Update_flags( for ( i = 0; i < hBinRendererTd->NumOfSrcs; i++ ) { hBinRendererTd->Sources[i]->SrcSpatial_p->Updated = FALSE; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER hBinRendererTd->Sources[i]->SrcRend_p->SrcGainUpdated = FALSE; #endif } @@ -548,7 +548,7 @@ ivas_error TDREND_Update_object_positions( { return error; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER if ( ( error = TDREND_MIX_SRC_SetSrcGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index e1da7043a4..5969236038 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -153,7 +153,7 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( return IVAS_ERR_OK; } -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetSrcGain() * @@ -254,7 +254,7 @@ static void TDREND_SRC_REND_Init( { SrcRend_p->SrcGainMin_p[nC] = 0.0f; SrcRend_p->SrcGain_p[nC] = 1.0f; -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER SrcRend_p->SrcGainMax_p[nC] = 2.0f; #else SrcRend_p->SrcGainMax_p[nC] = 1.0f; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index e1f9794b4f..5d0da2a72c 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -760,7 +760,7 @@ ivas_error TDREND_MIX_SRC_SetPlayState( const TDREND_PlayStatus_t PlayStatus /* i : Play state */ ); -#ifdef OBJ_EDITING_INTERFACE +#ifdef OBJ_EDITING_DECODER ivas_error TDREND_MIX_SRC_SetSrcGain( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ -- GitLab From 565774e364be20cec9bd6ce4311ed92cc213a89a Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 29 Apr 2024 13:17:46 +0200 Subject: [PATCH 008/130] object editing interface, fix API changes in conjunction with split rendering, add a new define OBJ_EDITING_EXAMPLE for the example code in decoder.c since DEBUGGING is broken at the moment, clang-format, fix small bug in inactive code --- apps/decoder.c | 10 +++---- lib_com/options.h | 3 +- lib_dec/ivas_init_dec.c | 7 ++--- lib_dec/ivas_mc_param_dec.c | 2 +- lib_dec/lib_dec.c | 58 +++++++++++++++++++++++++++++++++++-- 5 files changed, 66 insertions(+), 14 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 4ae5474901..87db265e44 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -56,7 +56,7 @@ #endif #include "wmc_auto.h" #ifdef OBJ_EDITING_API -#ifdef DEBUGGING +#ifdef OBJ_EDITING_EXAMPLE #include #endif #endif @@ -165,7 +165,7 @@ typedef struct int16_t Opt_dpid_on; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; #ifdef OBJ_EDITING_API -#ifdef DEBUGGING +#ifdef OBJ_EDITING_EXAMPLE bool objEditEnabled; #endif #endif @@ -1161,7 +1161,7 @@ static bool parseCmdlIVAS_dec( } #ifdef OBJ_EDITING_API -#ifdef DEBUGGING +#ifdef OBJ_EDITING_EXAMPLE arg->objEditEnabled = false; #endif #endif @@ -1672,7 +1672,7 @@ static bool parseCmdlIVAS_dec( i += tmp; } #ifdef OBJ_EDITING_API -#ifdef DEBUGGING +#ifdef OBJ_EDITING_EXAMPLE else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 ) { arg->objEditEnabled = true; @@ -2579,7 +2579,7 @@ static ivas_error decodeG192( goto cleanup; } #ifdef OBJ_EDITING_API -#ifdef DEBUGGING +#ifdef OBJ_EDITING_EXAMPLE if ( arg.objEditEnabled ) { diff --git a/lib_com/options.h b/lib_com/options.h index 00adef5d00..e592d5a869 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -#define DEBUGGING /* Activate debugging part of the code */ +/*#define DEBUGGING*/ /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -154,6 +154,7 @@ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ +#define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ #endif /* ################### Start BE switches ################################# */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0bb17725a0..1c5bbe24f5 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2147,12 +2147,11 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM #ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD #endif - ) - ) + ) ) { if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index ba5cfae2b4..11fb97c9cf 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1332,7 +1332,7 @@ void ivas_param_mc_dec_digest_tc( int16_t nchan_transport; #ifndef OBJ_EDITING_API int16_t nchan_out_transport, nchan_out_cldfb, i, param_band_idx; - int16_t nchan_out_cov; + int16_t nchan_out_cov; /*CLDFB*/ float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 3327fa6814..639b7dc162 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -98,7 +98,12 @@ struct IVAS_DEC #ifdef OBJ_EDITING_API uint16_t nSamplesFlushed; +#ifdef SPLIT_REND_WITH_HEAD_ROT + void *flushbuffer; + IVAS_DEC_PCM_TYPE pcmType; +#else int16_t *flushbuffer; +#endif bool hasEditableParameters; bool enableParameterEditing; bool hasBeenPreparedRendering; @@ -188,6 +193,9 @@ ivas_error IVAS_DEC_Open( hIvasDec->updateOrientation = false; #ifdef OBJ_EDITING_API hIvasDec->flushbuffer = NULL; +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasDec->pcmType = PCM_NOT_KNOW; +#endif hIvasDec->nSamplesFlushed = 0; hIvasDec->hasEditableParameters = false; hIvasDec->enableParameterEditing = false; @@ -544,8 +552,14 @@ ivas_error IVAS_DEC_Configure( /* 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 ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); + hIvasDec->pcmType = PCM_INT16; + set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); +#else 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 } #endif @@ -815,10 +829,16 @@ ivas_error IVAS_DEC_EnableVoIP( #ifdef OBJ_EDITING_API /* 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 ) ) + if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); + hIvasDec->pcmType = PCM_INT16; + set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); +#else 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 } #endif @@ -922,7 +942,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( 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 ) + if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->pcmType, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) #endif @@ -1133,7 +1153,7 @@ ivas_error IVAS_DEC_GetSamples( #ifndef OBJ_EDITING_API uint8_t nTransportChannels; int16_t nOutSamplesElse; - uint16_t nTimeScalerOutSamples. l_ts; + uint16_t nTimeScalerOutSamples, l_ts; #endif nSamplesRendered = 0; nOutChannels = 0; @@ -1294,7 +1314,29 @@ ivas_error IVAS_DEC_GetSamples( /* check for possible flushed samples from a rate switch */ if ( hIvasDec->nSamplesFlushed > 0 ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + void *pPcmBuffer; +#ifdef DEBUGGING + assert( hIvasDec->pcmType == pcmType ); +#endif + pPcmBuffer = pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ); + if ( pcmType == PCM_INT16 ) + { + mvs2s( (int16_t *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); + } + else if ( pcmType == PCM_FLOAT32 ) + { + mvr2r( (float *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); + } +#ifdef DEBUGGING + else + { + assert( 0 & "wrong PCM type for the flush buffer!" ); + } +#endif +#else mvs2s( hIvasDec->flushbuffer, pcmBuf + nSamplesRendered * nOutChannels, hIvasDec->nSamplesFlushed * nOutChannels ); +#endif nSamplesRendered += hIvasDec->nSamplesFlushed; hIvasDec->nSamplesFlushed = 0; } @@ -1382,6 +1424,16 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; +#ifdef OBJ_EDITING_API + /* init flush buffer for rate switch if not already initizalized */ + if ( hIvasDec->flushbuffer == NULL ) + { + hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); + hIvasDec->pcmType = PCM_FLOAT32; + set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + } +#endif + if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) -- GitLab From ea37c88376e03a66dd09ce3c01a5797b92ae7913 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 29 Apr 2024 13:25:28 +0200 Subject: [PATCH 009/130] ivas object editing, fix Linux comple error, use the correct PCM type enum from the API --- lib_dec/lib_dec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 639b7dc162..c9ca141b25 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -194,7 +194,7 @@ ivas_error IVAS_DEC_Open( #ifdef OBJ_EDITING_API hIvasDec->flushbuffer = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT - hIvasDec->pcmType = PCM_NOT_KNOW; + hIvasDec->pcmType = IVAS_DEC_PCM_INVALID; #endif hIvasDec->nSamplesFlushed = 0; hIvasDec->hasEditableParameters = false; @@ -554,7 +554,7 @@ ivas_error IVAS_DEC_Configure( { #ifdef SPLIT_REND_WITH_HEAD_ROT hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); - hIvasDec->pcmType = PCM_INT16; + hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); #else hIvasDec->flushbuffer = (int16_t *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); @@ -833,7 +833,7 @@ ivas_error IVAS_DEC_EnableVoIP( { #ifdef SPLIT_REND_WITH_HEAD_ROT hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); - hIvasDec->pcmType = PCM_INT16; + hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); #else hIvasDec->flushbuffer = (int16_t *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); @@ -1320,11 +1320,11 @@ ivas_error IVAS_DEC_GetSamples( assert( hIvasDec->pcmType == pcmType ); #endif pPcmBuffer = pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ); - if ( pcmType == PCM_INT16 ) + if ( pcmType == IVAS_DEC_PCM_INT16 ) { mvs2s( (int16_t *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); } - else if ( pcmType == PCM_FLOAT32 ) + else if ( pcmType == IVAS_DEC_PCM_FLOAT ) { mvr2r( (float *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); } @@ -1429,7 +1429,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); - hIvasDec->pcmType = PCM_FLOAT32; + hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif -- GitLab From 6072126cd0498efe5441bdfa65dae5609665494a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 23 May 2024 15:05:56 +0200 Subject: [PATCH 010/130] preliminarily enable object editing for ParamISM under OBJ_EDITING_PARAMISM --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 46 +++++++------- lib_dec/lib_dec.c | 132 ++++++++++++++++++++++++++++++----------- 3 files changed, 125 insertions(+), 54 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e592d5a869..89dd2c92ed 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,7 @@ #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ #define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ +#define OBJ_EDITING_PARAMISM /* obj editing for ParamISM */ #endif /* ################### Start BE switches ################################# */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 460f6e37cc..1544e697fe 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -92,7 +92,7 @@ ivas_error ivas_jbm_dec_tc( output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + output_frame = ( int16_t )( output_Fs / FRAMES_PER_SEC ); for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { @@ -512,7 +512,7 @@ ivas_error ivas_jbm_dec_tc( { for ( int16_t c = 0; c < nchan; c++ ) { - int16_t val = (int16_t) ( output[c][t] + 0.5f ); + int16_t val = ( int16_t )( output[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); } } @@ -1024,6 +1024,7 @@ void ivas_jbm_dec_prepare_renderer( else if ( st_ivas->ivas_format == ISM_FORMAT ) { /* Rendering */ +#ifndef OBJ_EDITING_PARAMISM if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) @@ -1038,6 +1039,9 @@ void ivas_jbm_dec_prepare_renderer( } } else /* ISM_MODE_DISC */ +#else + if ( st_ivas->ism_mode != ISM_MODE_PARAM ) +#endif { ivas_ism_dec_digest_tc( st_ivas ); } @@ -1188,7 +1192,7 @@ ivas_error ivas_jbm_dec_render( const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -1313,7 +1317,7 @@ ivas_error ivas_jbm_dec_render( #ifdef DEBUGGING else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) #else - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) #endif { /* Convert to Ambisonics */ @@ -1348,7 +1352,7 @@ ivas_error ivas_jbm_dec_render( if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1543,8 +1547,8 @@ ivas_error ivas_jbm_dec_render( if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) #endif @@ -1723,7 +1727,7 @@ ivas_error ivas_jbm_dec_render( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_syn_output( p_output, *nSamplesRendered, nchan_out_syn_output, (int16_t *) data ); #else - ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1763,7 +1767,7 @@ ivas_error ivas_jbm_dec_flush_renderer( const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -1845,8 +1849,8 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1868,8 +1872,8 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1919,7 +1923,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { - set_zero( p_output[ch_idx], (int16_t) ( *nSamplesRendered ) ); + set_zero( p_output[ch_idx], ( int16_t )( *nSamplesRendered ) ); } st_ivas->hTcBuffer->slots_rendered += 1; st_ivas->hTcBuffer->subframes_rendered += 1; @@ -2034,7 +2038,7 @@ ivas_error ivas_jbm_dec_set_discard_samples( int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe; /* render first frame with front zero padding and discarding those samples */ - nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; if ( nSlotsInFirstSubframe > 0 ) { @@ -2539,7 +2543,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->n_samples_flushed = 0; hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; nsamp_to_allocate = 0; - nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -2564,7 +2568,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } else { - n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } @@ -2649,9 +2653,9 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( #endif int16_t nMaxSlotsPerSubframeNew; - nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; + nMaxSlotsPerSubframeNew = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; #ifdef DEBUGGING - nMaxSlotsPerSubframeOld = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframeOld = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; assert( hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] == nMaxSlotsPerSubframeOld ); if ( n_samples_granularity < hTcBuffer->n_samples_granularity ) { @@ -2699,7 +2703,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } else { - n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; @@ -2838,7 +2842,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; - nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; st_ivas->hTcBuffer->num_slots = nSlotsAvailable; st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index c9ca141b25..4954c5abae 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -541,7 +541,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->st_ivas->ivas_format = MONO_FORMAT; } - hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; hIvasDec->tsm_scale = 100; @@ -609,7 +609,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( int16_t get_render_frame_size_ms( const IVAS_RENDER_FRAMESIZE render_framesize ) { - return (int16_t) ( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + return ( int16_t )( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); } @@ -682,7 +682,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); + *render_framesize = ( int16_t )( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); return IVAS_ERR_OK; } @@ -724,7 +724,7 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *update_frequency = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); + *update_frequency = ( int16_t )( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); return IVAS_ERR_OK; } @@ -803,7 +803,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->lastDecodedWasActive = 0; hIvasDec->hVoIP->hCurrentDataUnit = NULL; - hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->hVoIP->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->hVoIP->nSamplesRendered20ms = 0; #define WMC_TOOL_SKIP @@ -1004,6 +1004,27 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } } hIvasDec->hasBeenPreparedRendering = false; + + + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t n_render_timeslots = hIvasDec->st_ivas->hTcBuffer->n_samples_available / hIvasDec->st_ivas->hTcBuffer->n_samples_granularity; + + if ( hIvasDec->st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + hIvasDec->st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || + hIvasDec->st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC + ) + { + ivas_dirac_dec_set_md_map( hIvasDec->st_ivas, n_render_timeslots ); + + ivas_param_ism_params_to_masa_param_mapping( hIvasDec->st_ivas ); + } + else if ( hIvasDec->st_ivas->renderer_type == RENDERER_PARAM_ISM || hIvasDec->st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_param_ism_dec_prepare_renderer( hIvasDec->st_ivas, n_render_timeslots ); + } + } + #endif return IVAS_ERR_OK; @@ -1030,17 +1051,42 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) +#ifdef OBJ_EDITING_PARAMISM + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#endif + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; + hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + } + } +#ifdef OBJ_EDITING_PARAMISM + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; + hIvasEditableParameters->ism_metadata[obj].yaw = 0; + hIvasEditableParameters->ism_metadata[obj].pitch = 0; + hIvasEditableParameters->ism_metadata[obj].radius = 0; + hIvasEditableParameters->ism_metadata[obj].gain = 0; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; + } + } + else { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; - hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; - hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; - hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; - hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; - hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + assert( 0 && "This should never happen!" ); } +#endif } else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -1079,17 +1125,37 @@ ivas_error IVAS_DEC_SetEditableParameters( if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) +#ifdef OBJ_EDITING_PARAMISM + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#endif { - hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; - hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; - hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; - hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; + hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + } + } +#ifdef OBJ_EDITING_PARAMISM + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + } } + else + { + assert( 0 && "This should never happen!" ); + } +#endif } else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -1412,7 +1478,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( st_ivas = hIvasDec->st_ivas; output_config = st_ivas->hDecoderConfig->output_config; output_Fs = st_ivas->hDecoderConfig->output_Fs; - numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + numSamplesPerChannelToDecode = ( int16_t )( output_Fs / FRAMES_PER_SEC ); *needNewFrame = false; hSplitBinRend = &st_ivas->hSplitBinRend; @@ -1438,7 +1504,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { - numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); + numSamplesPerChannelToDecode = ( int16_t )( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; } @@ -1510,7 +1576,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } } - max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); + max_band = ( int16_t )( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; @@ -1669,7 +1735,7 @@ static ivas_error IVAS_DEC_GetTcSamples( st_ivas = hIvasDec->st_ivas; - *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + *nOutSamples = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { @@ -1881,7 +1947,7 @@ static int16_t getOutputBufferSize( if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) / FRAMES_PER_SEC ); + return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) / FRAMES_PER_SEC ); } else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { @@ -1890,11 +1956,11 @@ static int16_t getOutputBufferSize( return -1; } - return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * ( st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe ) / FRAMES_PER_SEC ); + return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * ( st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe ) / FRAMES_PER_SEC ); } else { - return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * st_ivas->hDecoderConfig->nchan_out / FRAMES_PER_SEC ); + return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * st_ivas->hDecoderConfig->nchan_out / FRAMES_PER_SEC ); } } @@ -2815,7 +2881,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( /* create data unit for primary copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; @@ -2838,7 +2904,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( { /* create data unit for partial copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; @@ -4224,7 +4290,7 @@ ivas_error IVAS_DEC_GetCldfbSamples( if ( st_ivas->hSplitBinRend.hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) { num_chs = audioCfg2channels( st_ivas->hSplitBinRend.hCldfbDataOut->config ); - maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + maxBand = ( int16_t )( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) { -- GitLab From 97b8022d4d08a9cbf1342d449342ebe022e78803 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 23 May 2024 16:15:27 +0200 Subject: [PATCH 011/130] store modified directions to hSpatParamRendCom --- lib_dec/lib_dec.c | 60 ++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index d932e12c5d..750922d94a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1026,14 +1026,13 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->hasBeenPreparedRendering = false; - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { int16_t n_render_timeslots = hIvasDec->st_ivas->hTcBuffer->n_samples_available / hIvasDec->st_ivas->hTcBuffer->n_samples_granularity; - if ( hIvasDec->st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - hIvasDec->st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || - hIvasDec->st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC - ) + if ( hIvasDec->st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + hIvasDec->st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || + hIvasDec->st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_set_md_map( hIvasDec->st_ivas, n_render_timeslots ); @@ -1090,11 +1089,11 @@ ivas_error IVAS_DEC_GetEditableParameters( #ifdef OBJ_EDITING_PARAMISM else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { - int16_t obj; + int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hSpatParamRendCom->azimuth[0][0]; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hSpatParamRendCom->azimuth[0][0]; hIvasEditableParameters->ism_metadata[obj].yaw = 0; hIvasEditableParameters->ism_metadata[obj].pitch = 0; hIvasEditableParameters->ism_metadata[obj].radius = 0; @@ -1149,26 +1148,39 @@ ivas_error IVAS_DEC_SetEditableParameters( if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) - { - hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; - hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; - hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; - hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; - } - } + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; + hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + } + } #ifdef OBJ_EDITING_PARAMISM else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { - int16_t obj; + int16_t obj, band_idx, sf_idx, bin_idx; + int16_t brange[2]; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + for ( band_idx = 0; band_idx < hIvasDec->st_ivas->hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + brange[0] = hIvasDec->st_ivas->hParamIsmDec->hParamIsm->band_grouping[band_idx]; + brange[1] = hIvasDec->st_ivas->hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) + { + hIvasDec->st_ivas->hSpatParamRendCom->azimuth[sf_idx][bin_idx] = ( int16_t ) hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hSpatParamRendCom->elevation[sf_idx][bin_idx] = ( int16_t ) hIvasEditableParameters.ism_metadata[obj].elevation; + } + } + } } } else @@ -4336,7 +4348,7 @@ ivas_error IVAS_DEC_GetCldfbSamples( if ( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) { num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); - maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + maxBand = ( int16_t )( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) { -- GitLab From e6378fbef61985fc151281381acf81d7e9d4976d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 24 May 2024 09:42:16 +0200 Subject: [PATCH 012/130] edit object directions rather than band-wise DOAs in ParamISM --- lib_dec/ivas_ism_param_dec.c | 59 +++++++++++++++++++++++++----------- lib_dec/ivas_jbm_dec.c | 54 ++++++++++++++++----------------- lib_dec/lib_dec.c | 53 ++++++++++++-------------------- 3 files changed, 88 insertions(+), 78 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 813849d79b..f90b4af0f2 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1384,44 +1384,32 @@ void ivas_param_ism_dec_render( return; } - +#ifdef OBJ_EDITING_PARAMISM /*-------------------------------------------------------------------------* * ivas_param_ism_params_to_masa_param_mapping() * * *-------------------------------------------------------------------------*/ -void ivas_param_ism_params_to_masa_param_mapping( +void ivas_param_ism_obj2band( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - PARAM_ISM_DEC_HANDLE hParamIsmDec; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + int16_t nBins; int16_t band_idx, bin_idx, sf_idx; int16_t brange[2]; int16_t azimuth[2]; int16_t elevation[2]; float power_ratio[2]; - int32_t ivas_total_brate; + + PARAM_ISM_DEC_HANDLE hParamIsmDec; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - - if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) - { - ivas_param_ism_dec_dequant_DOA( hParamIsmDec, st_ivas->nchan_ism ); - ivas_param_ism_dec_dequant_powrat( hParamIsmDec ); - st_ivas->hISMDTX.dtx_flag = 0; - } - else - { - st_ivas->hISMDTX.dtx_flag = 1; - } - if ( st_ivas->hISMDTX.dtx_flag ) { float energy_ratio; @@ -1485,6 +1473,41 @@ void ivas_param_ism_params_to_masa_param_mapping( } } } +} +#endif + +/*-------------------------------------------------------------------------* + * ivas_param_ism_params_to_masa_param_mapping() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_param_ism_params_to_masa_param_mapping( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + PARAM_ISM_DEC_HANDLE hParamIsmDec; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + int32_t ivas_total_brate; + + hParamIsmDec = st_ivas->hParamIsmDec; + + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + + if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) + { + ivas_param_ism_dec_dequant_DOA( hParamIsmDec, st_ivas->nchan_ism ); + ivas_param_ism_dec_dequant_powrat( hParamIsmDec ); + st_ivas->hISMDTX.dtx_flag = 0; + } + else + { + st_ivas->hISMDTX.dtx_flag = 1; + } + +#ifdef OBJ_EDITING_PARAMISM + ivas_param_ism_obj2band( st_ivas ); +#endif return; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 8bd78b4459..67f7868564 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -92,7 +92,7 @@ ivas_error ivas_jbm_dec_tc( output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - output_frame = ( int16_t )( output_Fs / FRAMES_PER_SEC ); + output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { @@ -512,7 +512,7 @@ ivas_error ivas_jbm_dec_tc( { for ( int16_t c = 0; c < nchan; c++ ) { - int16_t val = ( int16_t )( output[c][t] + 0.5f ); + int16_t val = (int16_t) ( output[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); } } @@ -1028,9 +1028,11 @@ void ivas_jbm_dec_prepare_renderer( else if ( st_ivas->ivas_format == ISM_FORMAT ) { /* Rendering */ -#ifndef OBJ_EDITING_PARAMISM if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { +#ifdef OBJ_EDITING_PARAMISM + +#else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); @@ -1041,11 +1043,9 @@ void ivas_jbm_dec_prepare_renderer( { ivas_param_ism_dec_prepare_renderer( st_ivas, n_render_timeslots ); } +#endif } else /* ISM_MODE_DISC */ -#else - if ( st_ivas->ism_mode != ISM_MODE_PARAM ) -#endif { ivas_ism_dec_digest_tc( st_ivas ); } @@ -1196,7 +1196,7 @@ ivas_error ivas_jbm_dec_render( const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -1321,7 +1321,7 @@ ivas_error ivas_jbm_dec_render( #ifdef DEBUGGING else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) #else - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) #endif { /* Convert to Ambisonics */ @@ -1356,7 +1356,7 @@ ivas_error ivas_jbm_dec_render( if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1551,8 +1551,8 @@ ivas_error ivas_jbm_dec_render( if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) #endif @@ -1731,7 +1731,7 @@ ivas_error ivas_jbm_dec_render( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_syn_output( p_output, *nSamplesRendered, nchan_out_syn_output, (int16_t *) data ); #else - ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1771,7 +1771,7 @@ ivas_error ivas_jbm_dec_flush_renderer( const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -1853,8 +1853,8 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1898,8 +1898,8 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif #endif { @@ -1950,7 +1950,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { - set_zero( p_output[ch_idx], ( int16_t )( *nSamplesRendered ) ); + set_zero( p_output[ch_idx], (int16_t) ( *nSamplesRendered ) ); } st_ivas->hTcBuffer->slots_rendered += 1; st_ivas->hTcBuffer->subframes_rendered += 1; @@ -2065,7 +2065,7 @@ ivas_error ivas_jbm_dec_set_discard_samples( int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe; /* render first frame with front zero padding and discarding those samples */ - nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; if ( nSlotsInFirstSubframe > 0 ) { @@ -2138,7 +2138,7 @@ void ivas_jbm_dec_get_adapted_subframes( uint16_t nCldfbSlotsLocal = nCldfbTs; /* get last subframe size from previous frame, determine how many slots have to be processed - in the first subframe (i.e. potential leftover of a 5ms subframe) */ +in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); *nb_subframes = 0; if ( nSlotsInFirstSubframe > 0 ) @@ -2198,7 +2198,7 @@ void ivas_jbm_dec_get_md_map( } /* changed part (first segment), interpolate index to parameters - (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ +(we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ if ( src_idx >= 0 ) { dec = ( (float) ( src_idx + 1 ) ) / ( (float) jbm_segment_len ); @@ -2574,7 +2574,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->n_samples_flushed = 0; hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; nsamp_to_allocate = 0; - nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -2599,7 +2599,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } else { - n_samp_full = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } @@ -2693,9 +2693,9 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( #endif int16_t nMaxSlotsPerSubframeNew; - nMaxSlotsPerSubframeNew = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; + nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; #ifdef DEBUGGING - nMaxSlotsPerSubframeOld = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframeOld = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; assert( hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] == nMaxSlotsPerSubframeOld ); if ( n_samples_granularity < hTcBuffer->n_samples_granularity ) { @@ -2743,7 +2743,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } else { - n_samp_full = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; @@ -2886,7 +2886,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; - nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; st_ivas->hTcBuffer->num_slots = nSlotsAvailable; st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 750922d94a..7276c6ccdd 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -563,7 +563,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->st_ivas->ivas_format = MONO_FORMAT; } - hIvasDec->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; hIvasDec->tsm_scale = 100; @@ -631,7 +631,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( int16_t get_render_frame_size_ms( const IVAS_RENDER_FRAMESIZE render_framesize ) { - return ( int16_t )( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + return (int16_t) ( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); } @@ -702,7 +702,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *render_framesize = ( int16_t )( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); + *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); return IVAS_ERR_OK; } @@ -744,7 +744,7 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *update_frequency = ( int16_t )( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); + *update_frequency = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); return IVAS_ERR_OK; } @@ -823,7 +823,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->lastDecodedWasActive = 0; hIvasDec->hVoIP->hCurrentDataUnit = NULL; - hIvasDec->hVoIP->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->hVoIP->nSamplesRendered20ms = 0; #define WMC_TOOL_SKIP @@ -1092,8 +1092,8 @@ ivas_error IVAS_DEC_GetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hSpatParamRendCom->azimuth[0][0]; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hSpatParamRendCom->azimuth[0][0]; + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; hIvasEditableParameters->ism_metadata[obj].yaw = 0; hIvasEditableParameters->ism_metadata[obj].pitch = 0; hIvasEditableParameters->ism_metadata[obj].radius = 0; @@ -1163,24 +1163,11 @@ ivas_error IVAS_DEC_SetEditableParameters( #ifdef OBJ_EDITING_PARAMISM else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { - int16_t obj, band_idx, sf_idx, bin_idx; - int16_t brange[2]; + int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - for ( band_idx = 0; band_idx < hIvasDec->st_ivas->hParamIsmDec->hParamIsm->nbands; band_idx++ ) - { - brange[0] = hIvasDec->st_ivas->hParamIsmDec->hParamIsm->band_grouping[band_idx]; - brange[1] = hIvasDec->st_ivas->hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; - - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) - { - hIvasDec->st_ivas->hSpatParamRendCom->azimuth[sf_idx][bin_idx] = ( int16_t ) hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hSpatParamRendCom->elevation[sf_idx][bin_idx] = ( int16_t ) hIvasEditableParameters.ism_metadata[obj].elevation; - } - } - } + hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; } } else @@ -1510,7 +1497,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( st_ivas = hIvasDec->st_ivas; output_config = st_ivas->hDecoderConfig->output_config; output_Fs = st_ivas->hDecoderConfig->output_Fs; - numSamplesPerChannelToDecode = ( int16_t )( output_Fs / FRAMES_PER_SEC ); + numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC ); *needNewFrame = false; hSplitBinRend = st_ivas->hSplitBinRend; @@ -1536,7 +1523,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { - numSamplesPerChannelToDecode = ( int16_t )( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); + numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; } @@ -1608,7 +1595,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } } - max_band = ( int16_t )( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); + max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; @@ -1770,7 +1757,7 @@ static ivas_error IVAS_DEC_GetTcSamples( st_ivas = hIvasDec->st_ivas; - *nOutSamples = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { @@ -1982,7 +1969,7 @@ static int16_t getOutputBufferSize( if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) / FRAMES_PER_SEC ); + return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) / FRAMES_PER_SEC ); } else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { @@ -1991,11 +1978,11 @@ static int16_t getOutputBufferSize( return -1; } - return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * ( st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe ) / FRAMES_PER_SEC ); + return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * ( st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe ) / FRAMES_PER_SEC ); } else { - return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * st_ivas->hDecoderConfig->nchan_out / FRAMES_PER_SEC ); + return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * st_ivas->hDecoderConfig->nchan_out / FRAMES_PER_SEC ); } } @@ -2927,7 +2914,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( /* create data unit for primary copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; @@ -2950,7 +2937,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( { /* create data unit for partial copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; @@ -4348,7 +4335,7 @@ ivas_error IVAS_DEC_GetCldfbSamples( if ( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) { num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); - maxBand = ( int16_t )( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) { -- GitLab From fb3991290028d41a8d215b77acfbb9ea996e1bb3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 24 May 2024 10:46:19 +0200 Subject: [PATCH 013/130] restore original code with OBJ_EDITING_INTERFACE disabled --- lib_com/options.h | 2 +- lib_dec/ivas_ism_param_dec.c | 81 ++++++++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 468570e54a..76784ddcdb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,7 +150,7 @@ /* ################## Start DEVELOPMENT switches ######################### */ -#define OBJ_EDITING_INTERFACE /* Interface for object editing */ +//#define OBJ_EDITING_INTERFACE /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index f90b4af0f2..56221e0ac2 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1487,9 +1487,22 @@ void ivas_param_ism_params_to_masa_param_mapping( ) { PARAM_ISM_DEC_HANDLE hParamIsmDec; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; int32_t ivas_total_brate; +#ifndef OBJ_EDITING_PARAMISM + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + + int16_t nBins; + int16_t band_idx, bin_idx, sf_idx; + int16_t brange[2]; + int16_t azimuth[2]; + int16_t elevation[2]; + float power_ratio[2]; + + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + nBins = hSpatParamRendCom->num_freq_bands; +#endif + hParamIsmDec = st_ivas->hParamIsmDec; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1505,8 +1518,70 @@ void ivas_param_ism_params_to_masa_param_mapping( st_ivas->hISMDTX.dtx_flag = 1; } -#ifdef OBJ_EDITING_PARAMISM - ivas_param_ism_obj2band( st_ivas ); +#ifndef OBJ_EDITING_PARAMISM + if ( st_ivas->hISMDTX.dtx_flag ) + { + float energy_ratio; + energy_ratio = powf( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence, 2.0f ); + + hSpatParamRendCom->numSimultaneousDirections = 1; + azimuth[0] = (int16_t) roundf( hParamIsmDec->azimuth_values[0] ); + elevation[0] = (int16_t) roundf( hParamIsmDec->elevation_values[0] ); + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) + { + hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; + hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; + + hSpatParamRendCom->energy_ratio1[sf_idx][bin_idx] = energy_ratio; + + hSpatParamRendCom->spreadCoherence[sf_idx][bin_idx] = 0.0f; + hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx] = 0.0; + } + } + } + else + { + hSpatParamRendCom->numSimultaneousDirections = 2; + for ( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + + azimuth[0] = (int16_t) roundf( hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); + elevation[0] = (int16_t) roundf( hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); + power_ratio[0] = hParamIsmDec->power_ratios[band_idx][0][0]; + + azimuth[1] = (int16_t) roundf( hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); + elevation[1] = (int16_t) roundf( hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); + power_ratio[1] = hParamIsmDec->power_ratios[band_idx][0][1]; + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) + { + hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; + hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; + hSpatParamRendCom->energy_ratio1[sf_idx][bin_idx] = power_ratio[0]; + hSpatParamRendCom->azimuth2[sf_idx][bin_idx] = azimuth[1]; + hSpatParamRendCom->elevation2[sf_idx][bin_idx] = elevation[1]; + hSpatParamRendCom->energy_ratio2[sf_idx][bin_idx] = power_ratio[1]; + } + } + } + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) + { + hSpatParamRendCom->spreadCoherence[sf_idx][bin_idx] = 0.0f; + hSpatParamRendCom->spreadCoherence2[sf_idx][bin_idx] = 0.0f; + hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx] = 0.0; + } + } + } #endif return; -- GitLab From 7d6fab89ae351f1fd557b5aa127dce281629f9c3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 24 May 2024 11:15:02 +0200 Subject: [PATCH 014/130] fix compile error with OBJ_EDITING_INTERFACE disabled --- lib_dec/ivas_mc_param_dec.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 7a6c3bc689..3b82182daa 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1334,6 +1334,7 @@ void ivas_param_mc_dec_digest_tc( int16_t ch; int16_t slot_idx; int16_t nchan_transport; + #ifndef OBJ_EDITING_API int16_t nchan_out_transport, nchan_out_cldfb, i, param_band_idx; int16_t nchan_out_cov; @@ -1345,10 +1346,12 @@ void ivas_param_mc_dec_digest_tc( int16_t channel_active[MAX_OUTPUT_CHANNELS]; IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; #endif + hParamMC = st_ivas->hParamMC; assert( hParamMC ); push_wmops( "param_mc_dec_digest_tc" ); + #ifndef OBJ_EDITING_API set_s( channel_active, 0, MAX_CICP_CHANNELS ); #endif @@ -1463,19 +1466,8 @@ void ivas_param_mc_dec_digest_tc( } -#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - ivas_param_mc_get_mono_stereo_mixing_matrices( hParamMC, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, nchan_transport, nchan_out_cov ); - } - else - { -#endif - /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); -#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT - } -#endif + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); #endif pop_wmops(); -- GitLab From 5ac32c22475f60fa1a911dc9afd443bfb7f91946 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 24 May 2024 11:26:47 +0200 Subject: [PATCH 015/130] fix formatting --- lib_dec/ivas_ism_param_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 56221e0ac2..aa938e8811 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1490,9 +1490,9 @@ void ivas_param_ism_params_to_masa_param_mapping( int32_t ivas_total_brate; #ifndef OBJ_EDITING_PARAMISM - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - int16_t nBins; + int16_t nBins; int16_t band_idx, bin_idx, sf_idx; int16_t brange[2]; int16_t azimuth[2]; -- GitLab From b34b1d69596f583411d12c16749aa30aa4bbdd53 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 24 May 2024 12:00:25 +0200 Subject: [PATCH 016/130] delete broken code from tests/codec_be_on_mr_nonselection/test_param_file.py --- .../test_param_file.py | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/tests/codec_be_on_mr_nonselection/test_param_file.py b/tests/codec_be_on_mr_nonselection/test_param_file.py index 5cc5b9299a..34e92b715a 100644 --- a/tests/codec_be_on_mr_nonselection/test_param_file.py +++ b/tests/codec_be_on_mr_nonselection/test_param_file.py @@ -189,23 +189,6 @@ def test_param_file_tests( enc_split, update_ref, ) - else: - print_encoder_commandline( - dut_encoder_frontend, - ref_encoder_frontend, - reference_path, - dut_base_path, - bitrate, - sampling_rate, - testv_file, - bitstream_file, - enc_split, - update_ref, - ) - if sba_br_switching_dtx == 1 and not keep_files: - is_exist = os.path.exists(cut_file) - if is_exist: - os.remove(cut_file) # check for networkSimulator_g192 command line if sim_opts != "": @@ -450,47 +433,6 @@ def encode( add_option_list=enc_opts_list, ) -def print_encoder_commandline( - dut_encoder_frontend, - ref_encoder_frontend, - reference_path, - dut_base_path, - bitrate, - sampling_rate, - testv_file, - bitstream_file, - enc_opts_list, - update_ref, -): - """ - Call REF and/or DUT encoder. - """ - # directories - dut_out_dir = f"{dut_base_path}/param_file/enc" - ref_out_dir = f"{reference_path}/param_file/enc" - - ref_out_file = f"{ref_out_dir}/{bitstream_file}" - dut_out_file = f"{dut_out_dir}/{bitstream_file}" - - if update_ref == 1 or update_ref == 2: - # call REF encoder - ref_encoder_frontend.print_cmdline( - bitrate, - sampling_rate, - testv_file, - ref_out_file, - add_option_list=enc_opts_list, - ) - - if update_ref in [0, 2]: - # call DUT encoder - dut_encoder_frontend.print_cmdline( - bitrate, - sampling_rate, - testv_file, - dut_out_file, - add_option_list=enc_opts_list, - ) def simulate( reference_path, -- GitLab From 32358cc839a901c86380a73f37ee337190901b4b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 24 May 2024 12:35:17 +0200 Subject: [PATCH 017/130] fix merge errors --- lib_dec/ivas_ism_param_dec.c | 20 ++++++++++++++------ lib_dec/ivas_jbm_dec.c | 7 +++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index aa938e8811..bef59c9431 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -819,12 +819,16 @@ void ivas_param_ism_dec_digest_tc( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ) { +#ifndef OBJ_EDITING_API int16_t ch, nchan_transport; int16_t slot_idx; -#ifndef OBJ_EDITING_API int16_t nchan_out, nchan_out_woLFE, i; int16_t bin_idx; int32_t ivas_total_brate; +#else + int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; + int16_t slot_idx, bin_idx; + int32_t ivas_total_brate; #endif int16_t output_frame; #ifndef OBJ_EDITING_API @@ -862,6 +866,7 @@ void ivas_param_ism_dec_digest_tc( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } #endif + push_wmops( "ivas_param_ism_dec_digest_tc" ); #ifndef OBJ_EDITING_API @@ -940,6 +945,7 @@ void ivas_param_ism_dec_digest_tc( } } #endif + if ( st_ivas->hDecoderConfig->Opt_tsm ) { /*TODO : FhG to check*/ @@ -961,6 +967,7 @@ void ivas_param_ism_dec_digest_tc( mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } + #ifndef OBJ_EDITING_API ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); #endif @@ -1486,25 +1493,26 @@ void ivas_param_ism_params_to_masa_param_mapping( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef OBJ_EDITING_PARAMISM PARAM_ISM_DEC_HANDLE hParamIsmDec; int32_t ivas_total_brate; - -#ifndef OBJ_EDITING_PARAMISM + hParamIsmDec = st_ivas->hParamIsmDec; +#else + PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - int16_t nBins; int16_t band_idx, bin_idx, sf_idx; int16_t brange[2]; int16_t azimuth[2]; int16_t elevation[2]; float power_ratio[2]; + int32_t ivas_total_brate; + hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; #endif - hParamIsmDec = st_ivas->hParamIsmDec; - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 67f7868564..8832eac99e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -828,7 +828,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } @@ -921,7 +921,10 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } } else { -- GitLab From f1f85f75c7a87d2035bc5e5423d5651c9d191749 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 27 May 2024 10:52:07 +0200 Subject: [PATCH 018/130] improve readability of ivas_jbm_dec.c --- lib_dec/ivas_jbm_dec.c | 377 +++++++++++++++++++++-------------------- 1 file changed, 189 insertions(+), 188 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 8832eac99e..cbdc38bd41 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -146,7 +146,6 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ivas_format == ISM_FORMAT ) { - /* Metadata decoding and configuration */ if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) { @@ -921,6 +920,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + if ( st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); @@ -998,191 +998,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( return; } -#ifdef OBJ_EDITING_API -/*--------------------------------------------------------------------------* - * ivas_jbm_dec_prepare_renderer() - * - * prepare IVAS JBM renderer routine - *--------------------------------------------------------------------------*/ - -void ivas_jbm_dec_prepare_renderer( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - int16_t n, n_render_timeslots; - - push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); - - n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; - - if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - - if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm ) - { - ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); - } - } - else if ( st_ivas->ivas_format == STEREO_FORMAT ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - } - else if ( st_ivas->ivas_format == ISM_FORMAT ) - { - /* Rendering */ - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) - { -#ifdef OBJ_EDITING_PARAMISM - -#else - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); - - ivas_param_ism_params_to_masa_param_mapping( st_ivas ); - } - else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) - { - ivas_param_ism_dec_prepare_renderer( st_ivas, n_render_timeslots ); - } -#endif - } - else /* ISM_MODE_DISC */ - { - ivas_ism_dec_digest_tc( st_ivas ); - } - } - else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) - { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - ivas_ism_dec_digest_tc( st_ivas ); - - /* delay the objects here for all renderers where it is needed */ - if ( -#ifdef SPLIT_REND_WITH_HEAD_ROT - ( -#endif - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL -#ifdef SPLIT_REND_WITH_HEAD_ROT - ) && - ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif - ) - { - for ( n = 0; n < st_ivas->nchan_ism; n++ ) - { - delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); - } - } - - if ( !st_ivas->sba_dirac_stereo_flag ) - { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) - { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); - } - - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - } - else - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); - } - } - else - { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); - } - - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - ivas_ism_dec_digest_tc( st_ivas ); - } - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) - { - int16_t num_objects; - /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ - num_objects = 0; - if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC ) - { - num_objects = 1; - } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - num_objects = st_ivas->nchan_ism; - } - for ( n = 0; n < num_objects; n++ ) - { - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) - { - v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); - } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { -#endif - delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); -#ifdef SPLIT_REND_WITH_HEAD_ROT - } -#endif - } - } - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) - { - ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) - { - ivas_param_mc_dec_prepare_renderer( st_ivas, (uint8_t) n_render_timeslots ); - } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) - { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - } - - pop_wmops(); - return; -} -#endif /*--------------------------------------------------------------------------* * ivas_dec_render() @@ -2141,7 +1956,7 @@ void ivas_jbm_dec_get_adapted_subframes( uint16_t nCldfbSlotsLocal = nCldfbTs; /* get last subframe size from previous frame, determine how many slots have to be processed -in the first subframe (i.e. potential leftover of a 5ms subframe) */ + in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); *nb_subframes = 0; if ( nSlotsInFirstSubframe > 0 ) @@ -2201,7 +2016,7 @@ void ivas_jbm_dec_get_md_map( } /* changed part (first segment), interpolate index to parameters -(we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ + (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ if ( src_idx >= 0 ) { dec = ( (float) ( src_idx + 1 ) ) / ( (float) jbm_segment_len ); @@ -3280,3 +3095,189 @@ void ivas_jbm_masa_sf_to_sf_map( return; } + +#ifdef OBJ_EDITING_API +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_prepare_renderer() + * + * prepare IVAS JBM renderer routine + *--------------------------------------------------------------------------*/ + +void ivas_jbm_dec_prepare_renderer( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t n, n_render_timeslots; + + push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + + n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + + if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + + if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } + } + else if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + } + else if ( st_ivas->ivas_format == ISM_FORMAT ) + { + /* Rendering */ + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { +#ifdef OBJ_EDITING_PARAMISM + +#else + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); + + ivas_param_ism_params_to_masa_param_mapping( st_ivas ); + } + else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_param_ism_dec_prepare_renderer( st_ivas, n_render_timeslots ); + } +#endif + } + else /* ISM_MODE_DISC */ + { + ivas_ism_dec_digest_tc( st_ivas ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + ivas_ism_dec_digest_tc( st_ivas ); + + /* delay the objects here for all renderers where it is needed */ + if ( +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + ) && + ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) + { + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + } + } + + if ( !st_ivas->sba_dirac_stereo_flag ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + } + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + else + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } + } + else + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + } + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + ivas_ism_dec_digest_tc( st_ivas ); + } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) + { + int16_t num_objects; + /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ + num_objects = 0; + if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC ) + { + num_objects = 1; + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + num_objects = st_ivas->nchan_ism; + } + for ( n = 0; n < num_objects; n++ ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { +#endif + delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + } + } + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + ivas_param_mc_dec_prepare_renderer( st_ivas, (uint8_t) n_render_timeslots ); + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + + pop_wmops(); + return; +} +#endif -- GitLab From d21747728d251b29a5bdf4705feb50d8dfd512e6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 27 May 2024 11:08:09 +0200 Subject: [PATCH 019/130] improve readability of lib_dec/ivas_jbm_dec.c --- lib_dec/ivas_jbm_dec.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index cbdc38bd41..3ebcdadb81 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -852,7 +852,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else #endif - if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); } @@ -959,15 +959,20 @@ void ivas_jbm_dec_feed_tc_to_renderer( { v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); } - delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { +#endif + delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } } } } -#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { -#ifndef OBJ_EDITING_API if ( st_ivas->mc_mode == MC_MODE_MCT ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); @@ -976,23 +981,24 @@ void ivas_jbm_dec_feed_tc_to_renderer( { ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } - else -#endif - if ( st_ivas->mc_mode == MC_MODE_PARAMMC -#ifdef OBJ_EDITING_API - && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER -#endif - ) + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); } -#ifndef OBJ_EDITING_API else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } -#endif } +#else + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) + { + ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); + } + } +#endif pop_wmops(); return; -- GitLab From 62aea3aa5ad42825f65f70805dabfedb05637e1e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 27 May 2024 11:26:39 +0200 Subject: [PATCH 020/130] fix formatting --- lib_dec/ivas_jbm_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3ebcdadb81..a7fb6b3832 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -852,7 +852,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else #endif - if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); } -- GitLab From 8740b424d6426bcc2656479339963a7969a95c77 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 27 May 2024 12:04:27 +0200 Subject: [PATCH 021/130] enable OBJ_EDITING_INTERFACE --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 76784ddcdb..e66e02803a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,12 +150,12 @@ /* ################## Start DEVELOPMENT switches ######################### */ -//#define OBJ_EDITING_INTERFACE /* Interface for object editing */ +#define OBJ_EDITING_INTERFACE /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ #define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ -#define OBJ_EDITING_PARAMISM /* obj editing for ParamISM */ +/*#define OBJ_EDITING_PARAMISM*/ /* obj editing for ParamISM */ #endif /* ################### Start BE switches ################################# */ -- GitLab From 2bf2f4bfd980331dc986accfb86024662c3e3f31 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 27 May 2024 12:31:01 +0200 Subject: [PATCH 022/130] fix compile errors --- lib_dec/ivas_ism_param_dec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index bef59c9431..73b99f7ec8 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -826,9 +826,8 @@ void ivas_param_ism_dec_digest_tc( int16_t bin_idx; int32_t ivas_total_brate; #else - int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; - int16_t slot_idx, bin_idx; - int32_t ivas_total_brate; + int16_t ch, nchan_transport; + int16_t slot_idx; #endif int16_t output_frame; #ifndef OBJ_EDITING_API -- GitLab From 1680c156dba97a389d649880bb829c6184d894c0 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 27 May 2024 13:16:52 +0200 Subject: [PATCH 023/130] fix object position editing for paramISM --- lib_com/ivas_prot.h | 4 ++++ lib_com/options.h | 2 +- lib_dec/ivas_ism_param_dec.c | 42 +++++++++++++++++++++++++----------- lib_dec/ivas_jbm_dec.c | 7 +++--- lib_dec/lib_dec.c | 20 ----------------- 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index da2e3def80..f913d8db1f 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1122,6 +1122,10 @@ void ivas_param_ism_dec_digest_tc( ); #ifdef OBJ_EDITING_API +void ivas_param_ism_dec_dequant_md( + Decoder_Struct *st_ivas +); + void ivas_param_ism_dec_prepare_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ diff --git a/lib_com/options.h b/lib_com/options.h index e66e02803a..468570e54a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,7 +155,7 @@ #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ #define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ -/*#define OBJ_EDITING_PARAMISM*/ /* obj editing for ParamISM */ +#define OBJ_EDITING_PARAMISM /* obj editing for ParamISM */ #endif /* ################### Start BE switches ################################# */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index bef59c9431..598b27b5f1 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -882,6 +882,7 @@ void ivas_param_ism_dec_digest_tc( } set_zero( ref_power, CLDFB_NO_CHANNELS_MAX ); + /* Frame-level Processing */ /* De-quantization */ if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) @@ -992,6 +993,32 @@ void ivas_param_ism_dec_digest_tc( #ifdef OBJ_EDITING_API +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_prepare_renderer() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_param_ism_dec_dequant_md( + Decoder_Struct *st_ivas +) +{ + /* De-quantization */ + if ( !( st_ivas->hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 || st_ivas->hDecoderConfig->ivas_total_brate == FRAME_NO_DATA ) ) + { + ivas_param_ism_dec_dequant_DOA( st_ivas->hParamIsmDec, st_ivas->nchan_ism ); + ivas_param_ism_dec_dequant_powrat( st_ivas->hParamIsmDec ); + st_ivas->hISMDTX.dtx_flag = 0; + } + else + { + st_ivas->hISMDTX.dtx_flag = 1; + } + + return; +} + + /*-------------------------------------------------------------------------* * ivas_param_ism_dec_prepare_renderer() * @@ -1048,19 +1075,6 @@ void ivas_param_ism_dec_prepare_renderer( } set_zero( ref_power, CLDFB_NO_CHANNELS_MAX ); - /* Frame-level Processing */ - /* De-quantization */ - if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) - { - ivas_param_ism_dec_dequant_DOA( hParamIsmDec, st_ivas->nchan_ism ); - ivas_param_ism_dec_dequant_powrat( hParamIsmDec ); - st_ivas->hISMDTX.dtx_flag = 0; - } - else - { - st_ivas->hISMDTX.dtx_flag = 1; - } - /* obtain the direct response using EFAP */ if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) ) { @@ -1515,6 +1529,7 @@ void ivas_param_ism_params_to_masa_param_mapping( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; +#ifndef OBJ_EDITING_API if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) { ivas_param_ism_dec_dequant_DOA( hParamIsmDec, st_ivas->nchan_ism ); @@ -1525,6 +1540,7 @@ void ivas_param_ism_params_to_masa_param_mapping( { st_ivas->hISMDTX.dtx_flag = 1; } +#endif #ifndef OBJ_EDITING_PARAMISM if ( st_ivas->hISMDTX.dtx_flag ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index a7fb6b3832..7e8f77c2e3 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -165,6 +165,9 @@ ivas_error ivas_jbm_dec_tc( { return error; } +#ifdef OBJ_EDITING_API + ivas_param_ism_dec_dequant_md( st_ivas ); +#endif } else /* ISM_MODE_DISC */ { @@ -3137,9 +3140,6 @@ void ivas_jbm_dec_prepare_renderer( /* Rendering */ if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { -#ifdef OBJ_EDITING_PARAMISM - -#else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); @@ -3150,7 +3150,6 @@ void ivas_jbm_dec_prepare_renderer( { ivas_param_ism_dec_prepare_renderer( st_ivas, n_render_timeslots ); } -#endif } else /* ISM_MODE_DISC */ { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7276c6ccdd..72e9f55f0b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1024,26 +1024,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } } hIvasDec->hasBeenPreparedRendering = false; - - - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) - { - int16_t n_render_timeslots = hIvasDec->st_ivas->hTcBuffer->n_samples_available / hIvasDec->st_ivas->hTcBuffer->n_samples_granularity; - - if ( hIvasDec->st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - hIvasDec->st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || - hIvasDec->st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - ivas_dirac_dec_set_md_map( hIvasDec->st_ivas, n_render_timeslots ); - - ivas_param_ism_params_to_masa_param_mapping( hIvasDec->st_ivas ); - } - else if ( hIvasDec->st_ivas->renderer_type == RENDERER_PARAM_ISM || hIvasDec->st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) - { - ivas_param_ism_dec_prepare_renderer( hIvasDec->st_ivas, n_render_timeslots ); - } - } - #endif return IVAS_ERR_OK; -- GitLab From 2cbff27027e1a4cc31ce9ad98c09fc5f0f129208 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 27 May 2024 13:53:25 +0200 Subject: [PATCH 024/130] fix compile errors --- lib_com/ivas_prot.h | 2 + lib_dec/ivas_ism_param_dec.c | 119 +++-------------------------------- lib_dec/ivas_jbm_dec.c | 23 +++---- 3 files changed, 23 insertions(+), 121 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f913d8db1f..590d4cb749 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1147,9 +1147,11 @@ void ivas_param_ism_dec_render( float *output_f[] /* o : rendered time signal */ ); +#ifndef OBJ_EDITING_PARAMISM void ivas_param_ism_params_to_masa_param_mapping( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#endif /*----------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 90e737ebeb..6334de4afe 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -453,14 +453,14 @@ ivas_error ivas_param_ism_dec_open( * set input parameters *-----------------------------------------------------------------*/ - hSpatParamRendCom->slot_size = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); + hSpatParamRendCom->slot_size = ( int16_t )( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); set_s( hSpatParamRendCom->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hSpatParamRendCom->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); hSpatParamRendCom->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS; hSpatParamRendCom->subframes_rendered = 0; hSpatParamRendCom->slots_rendered = 0; hSpatParamRendCom->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; - hSpatParamRendCom->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); + hSpatParamRendCom->num_freq_bands = ( int16_t )( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); hParamIsmDec->hParamIsm->nbands = MAX_PARAM_ISM_NBANDS; @@ -720,7 +720,7 @@ void ivas_ism_dec_digest_tc( /* for BE testing */ if ( ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) == st_ivas->hTcBuffer->n_samples_available ) { - int16_t interpolator_length = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + int16_t interpolator_length = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_OSBA_AMBI || @@ -742,7 +742,7 @@ void ivas_ism_dec_digest_tc( } else { - ivas_jbm_dec_get_adapted_linear_interpolator( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); + ivas_jbm_dec_get_adapted_linear_interpolator( ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); } /* also get the gains here */ @@ -999,8 +999,7 @@ void ivas_param_ism_dec_digest_tc( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_dequant_md( - Decoder_Struct *st_ivas -) + Decoder_Struct *st_ivas ) { /* De-quantization */ if ( !( st_ivas->hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 || st_ivas->hDecoderConfig->ivas_total_brate == FRAME_NO_DATA ) ) @@ -1014,7 +1013,7 @@ void ivas_param_ism_dec_dequant_md( st_ivas->hISMDTX.dtx_flag = 1; } - return; + return; } @@ -1031,7 +1030,6 @@ void ivas_param_ism_dec_prepare_renderer( { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; int16_t slot_idx, bin_idx; - int32_t ivas_total_brate; float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ @@ -1046,7 +1044,6 @@ void ivas_param_ism_dec_prepare_renderer( assert( hSpatParamRendCom ); nchan_transport = st_ivas->nchan_transport; - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -1404,113 +1401,18 @@ void ivas_param_ism_dec_render( return; } -#ifdef OBJ_EDITING_PARAMISM -/*-------------------------------------------------------------------------* - * ivas_param_ism_params_to_masa_param_mapping() - * - * - *-------------------------------------------------------------------------*/ - -void ivas_param_ism_obj2band( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - - int16_t nBins; - int16_t band_idx, bin_idx, sf_idx; - int16_t brange[2]; - int16_t azimuth[2]; - int16_t elevation[2]; - float power_ratio[2]; - - PARAM_ISM_DEC_HANDLE hParamIsmDec; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - - hParamIsmDec = st_ivas->hParamIsmDec; - hSpatParamRendCom = st_ivas->hSpatParamRendCom; - nBins = hSpatParamRendCom->num_freq_bands; - - if ( st_ivas->hISMDTX.dtx_flag ) - { - float energy_ratio; - energy_ratio = powf( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence, 2.0f ); - - hSpatParamRendCom->numSimultaneousDirections = 1; - azimuth[0] = (int16_t) roundf( hParamIsmDec->azimuth_values[0] ); - elevation[0] = (int16_t) roundf( hParamIsmDec->elevation_values[0] ); - - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) - { - hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; - hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; - - hSpatParamRendCom->energy_ratio1[sf_idx][bin_idx] = energy_ratio; - - hSpatParamRendCom->spreadCoherence[sf_idx][bin_idx] = 0.0f; - hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx] = 0.0; - } - } - } - else - { - hSpatParamRendCom->numSimultaneousDirections = 2; - for ( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) - { - brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; - brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; - - azimuth[0] = (int16_t) roundf( hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); - elevation[0] = (int16_t) roundf( hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); - power_ratio[0] = hParamIsmDec->power_ratios[band_idx][0][0]; - - azimuth[1] = (int16_t) roundf( hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); - elevation[1] = (int16_t) roundf( hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); - power_ratio[1] = hParamIsmDec->power_ratios[band_idx][0][1]; - - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) - { - hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0]; - hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0]; - hSpatParamRendCom->energy_ratio1[sf_idx][bin_idx] = power_ratio[0]; - hSpatParamRendCom->azimuth2[sf_idx][bin_idx] = azimuth[1]; - hSpatParamRendCom->elevation2[sf_idx][bin_idx] = elevation[1]; - hSpatParamRendCom->energy_ratio2[sf_idx][bin_idx] = power_ratio[1]; - } - } - } - - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) - { - hSpatParamRendCom->spreadCoherence[sf_idx][bin_idx] = 0.0f; - hSpatParamRendCom->spreadCoherence2[sf_idx][bin_idx] = 0.0f; - hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx] = 0.0; - } - } - } -} -#endif /*-------------------------------------------------------------------------* * ivas_param_ism_params_to_masa_param_mapping() * * *-------------------------------------------------------------------------*/ - +#ifndef OBJ_EDITING_PARAMISM void ivas_param_ism_params_to_masa_param_mapping( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { -#ifdef OBJ_EDITING_PARAMISM - PARAM_ISM_DEC_HANDLE hParamIsmDec; - int32_t ivas_total_brate; - hParamIsmDec = st_ivas->hParamIsmDec; -#else + PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; int16_t nBins; @@ -1524,9 +1426,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; -#endif - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; #ifndef OBJ_EDITING_API if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) @@ -1541,7 +1441,6 @@ void ivas_param_ism_params_to_masa_param_mapping( } #endif -#ifndef OBJ_EDITING_PARAMISM if ( st_ivas->hISMDTX.dtx_flag ) { float energy_ratio; @@ -1605,7 +1504,7 @@ void ivas_param_ism_params_to_masa_param_mapping( } } } -#endif return; } +#endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 7e8f77c2e3..804d51ad4d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -92,7 +92,7 @@ ivas_error ivas_jbm_dec_tc( output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + output_frame = ( int16_t )( output_Fs / FRAMES_PER_SEC ); for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { @@ -514,7 +514,7 @@ ivas_error ivas_jbm_dec_tc( { for ( int16_t c = 0; c < nchan; c++ ) { - int16_t val = (int16_t) ( output[c][t] + 0.5f ); + int16_t val = ( int16_t )( output[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); } } @@ -1777,7 +1777,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { - set_zero( p_output[ch_idx], (int16_t) ( *nSamplesRendered ) ); + set_zero( p_output[ch_idx], ( int16_t )( *nSamplesRendered ) ); } st_ivas->hTcBuffer->slots_rendered += 1; st_ivas->hTcBuffer->subframes_rendered += 1; @@ -1892,7 +1892,7 @@ ivas_error ivas_jbm_dec_set_discard_samples( int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe; /* render first frame with front zero padding and discarding those samples */ - nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; if ( nSlotsInFirstSubframe > 0 ) { @@ -2401,7 +2401,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->n_samples_flushed = 0; hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; nsamp_to_allocate = 0; - nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -2426,7 +2426,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } else { - n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } @@ -2520,9 +2520,9 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( #endif int16_t nMaxSlotsPerSubframeNew; - nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; + nMaxSlotsPerSubframeNew = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; #ifdef DEBUGGING - nMaxSlotsPerSubframeOld = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframeOld = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; assert( hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] == nMaxSlotsPerSubframeOld ); if ( n_samples_granularity < hTcBuffer->n_samples_granularity ) { @@ -2570,7 +2570,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } else { - n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; @@ -2713,7 +2713,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; - nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; st_ivas->hTcBuffer->num_slots = nSlotsAvailable; st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; @@ -3143,8 +3143,9 @@ void ivas_jbm_dec_prepare_renderer( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); - +#ifndef OBJ_EDITING_PARAMISM ivas_param_ism_params_to_masa_param_mapping( st_ivas ); +#endif } else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { -- GitLab From c245e0d226f466349ee6345a43d77de027bc07d2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 27 May 2024 14:04:07 +0200 Subject: [PATCH 025/130] fix formatting --- lib_dec/ivas_ism_param_dec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 6334de4afe..0d823509bf 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -453,14 +453,14 @@ ivas_error ivas_param_ism_dec_open( * set input parameters *-----------------------------------------------------------------*/ - hSpatParamRendCom->slot_size = ( int16_t )( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); + hSpatParamRendCom->slot_size = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); set_s( hSpatParamRendCom->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hSpatParamRendCom->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); hSpatParamRendCom->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS; hSpatParamRendCom->subframes_rendered = 0; hSpatParamRendCom->slots_rendered = 0; hSpatParamRendCom->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; - hSpatParamRendCom->num_freq_bands = ( int16_t )( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); + hSpatParamRendCom->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); hParamIsmDec->hParamIsm->nbands = MAX_PARAM_ISM_NBANDS; @@ -720,7 +720,7 @@ void ivas_ism_dec_digest_tc( /* for BE testing */ if ( ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) == st_ivas->hTcBuffer->n_samples_available ) { - int16_t interpolator_length = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + int16_t interpolator_length = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_OSBA_AMBI || @@ -742,7 +742,7 @@ void ivas_ism_dec_digest_tc( } else { - ivas_jbm_dec_get_adapted_linear_interpolator( ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); + ivas_jbm_dec_get_adapted_linear_interpolator( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); } /* also get the gains here */ -- GitLab From 58cc9dedb52d6c9e2e8b7135230110b3d5140c8c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 27 May 2024 15:12:39 +0200 Subject: [PATCH 026/130] fix crash in object renderer --- lib_rend/ivas_objectRenderer.c | 2 +- lib_rend/ivas_objectRenderer_sources.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 5c56f4fcc6..3d9ef48b92 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -585,7 +585,7 @@ ivas_error TDREND_Update_object_positions( { return error; } -#ifdef OBJ_EDITING_DECODER +#if 0 if ( ( error = TDREND_MIX_SRC_SetSrcGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 06e6d0516a..f65c9ef70e 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -186,7 +186,7 @@ ivas_error TDREND_MIX_SRC_SetDistAtten( } #endif -#ifdef OBJ_EDITING_DECODER +#if 0 /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetSrcGain() * -- GitLab From bfe5372ae53f3aee3b1e3662d1af090fde690ef6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 28 May 2024 13:07:11 +0200 Subject: [PATCH 027/130] fix crash with RENDERER_BINAURAL_PARAMETRIC --- lib_dec/ivas_init_dec.c | 78 ++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d0dc9ed81e..6b4b23fed9 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -125,7 +125,7 @@ static ivas_error ivas_dec_reconfig_split_rend( if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) { - if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc_( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); } @@ -175,7 +175,7 @@ static ivas_error ivas_dec_reconfig_split_rend( } } - free( hSplitRendWrapper->hCldfbHandles ); + free_( hSplitRendWrapper->hCldfbHandles ); hSplitRendWrapper->hCldfbHandles = NULL; } @@ -226,7 +226,7 @@ static ivas_error ivas_dec_init_split_rend( if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) { - if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc_( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); } @@ -2045,7 +2045,7 @@ ivas_error ivas_init_decoder( if ( n > 0 ) { - if ( ( st_ivas->mem_hp20_out = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) + if ( ( st_ivas->mem_hp20_out = (float **) malloc_( n * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } @@ -2057,7 +2057,7 @@ ivas_error ivas_init_decoder( for ( i = 0; i < n; i++ ) { - if ( ( st_ivas->mem_hp20_out[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) + if ( ( st_ivas->mem_hp20_out[i] = (float *) malloc_( L_HP20_MEM * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } @@ -2237,7 +2237,11 @@ ivas_error ivas_init_decoder( } if ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && - ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) && + ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC +#ifdef OBJ_EDITING_DECODER + || st_ivas->ism_mode == ISM_MODE_PARAM +#endif + ) && ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || @@ -2248,7 +2252,7 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM #ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM #endif ) ) { @@ -2444,7 +2448,7 @@ ivas_error ivas_init_decoder( for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + if ( ( st_ivas->p_output_f[n] = (float *) malloc_( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } @@ -2474,127 +2478,127 @@ void destroy_core_dec( if ( hCoreCoder->hGSCDec != NULL ) { - free( hCoreCoder->hGSCDec ); + free_( hCoreCoder->hGSCDec ); hCoreCoder->hGSCDec = NULL; } if ( hCoreCoder->hPFstat != NULL ) { - free( hCoreCoder->hPFstat ); + free_( hCoreCoder->hPFstat ); hCoreCoder->hPFstat = NULL; } if ( hCoreCoder->hMusicPF != NULL ) { - free( hCoreCoder->hMusicPF ); + free_( hCoreCoder->hMusicPF ); hCoreCoder->hMusicPF = NULL; } if ( hCoreCoder->hBPF != NULL ) { - free( hCoreCoder->hBPF ); + free_( hCoreCoder->hBPF ); hCoreCoder->hBPF = NULL; } if ( hCoreCoder->hBWE_zero != NULL ) { - free( hCoreCoder->hBWE_zero ); + free_( hCoreCoder->hBWE_zero ); hCoreCoder->hBWE_zero = NULL; } if ( hCoreCoder->hTdCngDec != NULL ) { - free( hCoreCoder->hTdCngDec ); + free_( hCoreCoder->hTdCngDec ); hCoreCoder->hTdCngDec = NULL; } if ( hCoreCoder->hSC_VBR != NULL ) { - free( hCoreCoder->hSC_VBR ); + free_( hCoreCoder->hSC_VBR ); hCoreCoder->hSC_VBR = NULL; } if ( hCoreCoder->hAmrwb_IO != NULL ) { - free( hCoreCoder->hAmrwb_IO ); + free_( hCoreCoder->hAmrwb_IO ); hCoreCoder->hAmrwb_IO = NULL; } if ( hCoreCoder->hBWE_TD != NULL ) { - free( hCoreCoder->hBWE_TD ); + free_( hCoreCoder->hBWE_TD ); hCoreCoder->hBWE_TD = NULL; } if ( hCoreCoder->hBWE_FD != NULL ) { - free( hCoreCoder->hBWE_FD ); + free_( hCoreCoder->hBWE_FD ); hCoreCoder->hBWE_FD = NULL; } if ( hCoreCoder->hBWE_FD_HR != NULL ) { - free( hCoreCoder->hBWE_FD_HR ); + free_( hCoreCoder->hBWE_FD_HR ); hCoreCoder->hBWE_FD_HR = NULL; } if ( hCoreCoder->hWIDec != NULL ) { - free( hCoreCoder->hWIDec ); + free_( hCoreCoder->hWIDec ); hCoreCoder->hWIDec = NULL; } if ( hCoreCoder->hTECDec != NULL ) { - free( hCoreCoder->hTECDec ); + free_( hCoreCoder->hTECDec ); hCoreCoder->hTECDec = NULL; } if ( hCoreCoder->hTcxLtpDec != NULL ) { - free( hCoreCoder->hTcxLtpDec ); + free_( hCoreCoder->hTcxLtpDec ); hCoreCoder->hTcxLtpDec = NULL; } if ( hCoreCoder->hTcxDec != NULL ) { - free( hCoreCoder->hTcxDec ); + free_( hCoreCoder->hTcxDec ); hCoreCoder->hTcxDec = NULL; } if ( hCoreCoder->hTcxCfg != NULL ) { - free( hCoreCoder->hTcxCfg ); + free_( hCoreCoder->hTcxCfg ); hCoreCoder->hTcxCfg = NULL; } if ( hCoreCoder->hTonalMDCTConc != NULL ) { - free( hCoreCoder->hTonalMDCTConc ); + free_( hCoreCoder->hTonalMDCTConc ); hCoreCoder->hTonalMDCTConc = NULL; } if ( hCoreCoder->hIGFDec != NULL ) { - free( hCoreCoder->hIGFDec ); + free_( hCoreCoder->hIGFDec ); hCoreCoder->hIGFDec = NULL; } if ( hCoreCoder->hPlcInfo != NULL ) { - free( hCoreCoder->hPlcInfo ); + free_( hCoreCoder->hPlcInfo ); hCoreCoder->hPlcInfo = NULL; } if ( hCoreCoder->hHQ_core != NULL ) { - free( hCoreCoder->hHQ_core ); + free_( hCoreCoder->hHQ_core ); hCoreCoder->hHQ_core = NULL; } if ( hCoreCoder->hHQ_nbfec != NULL ) { - free( hCoreCoder->hHQ_nbfec ); + free_( hCoreCoder->hHQ_nbfec ); hCoreCoder->hHQ_nbfec = NULL; } @@ -2774,10 +2778,10 @@ void ivas_destroy_dec( { for ( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) { - free( st_ivas->mem_hp20_out[i] ); + free_( st_ivas->mem_hp20_out[i] ); st_ivas->mem_hp20_out[i] = NULL; } - free( st_ivas->mem_hp20_out ); + free_( st_ivas->mem_hp20_out ); st_ivas->mem_hp20_out = NULL; } @@ -2805,7 +2809,7 @@ void ivas_destroy_dec( /* HOA decoder matrix */ if ( st_ivas->hoa_dec_mtx != NULL ) { - free( st_ivas->hoa_dec_mtx ); + free_( st_ivas->hoa_dec_mtx ); st_ivas->hoa_dec_mtx = NULL; } @@ -2872,7 +2876,7 @@ void ivas_destroy_dec( /* Custom LS configuration handle */ if ( st_ivas->hLsSetupCustom != NULL ) { - free( st_ivas->hLsSetupCustom ); + free_( st_ivas->hLsSetupCustom ); st_ivas->hLsSetupCustom = NULL; } @@ -2930,7 +2934,7 @@ void ivas_destroy_dec( if ( st_ivas->hDecoderConfig != NULL ) { - free( st_ivas->hDecoderConfig ); + free_( st_ivas->hDecoderConfig ); st_ivas->hDecoderConfig = NULL; } @@ -2938,7 +2942,7 @@ void ivas_destroy_dec( if ( st_ivas->hJbmMetadata != NULL ) { - free( st_ivas->hJbmMetadata ); + free_( st_ivas->hJbmMetadata ); st_ivas->hJbmMetadata = NULL; } @@ -2947,13 +2951,13 @@ void ivas_destroy_dec( { if ( st_ivas->p_output_f[i] != NULL ) { - free( st_ivas->p_output_f[i] ); + free_( st_ivas->p_output_f[i] ); st_ivas->p_output_f[i] = NULL; } } /* main IVAS handle */ - free( st_ivas ); + free_( st_ivas ); return; } -- GitLab From 42d3d24d4729fe463c9eb1e5d959db69e355947a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 28 May 2024 14:29:42 +0200 Subject: [PATCH 028/130] fix formatting --- lib_dec/ivas_jbm_dec.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 804d51ad4d..e3ab199e7e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -92,7 +92,7 @@ ivas_error ivas_jbm_dec_tc( output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - output_frame = ( int16_t )( output_Fs / FRAMES_PER_SEC ); + output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { @@ -514,7 +514,7 @@ ivas_error ivas_jbm_dec_tc( { for ( int16_t c = 0; c < nchan; c++ ) { - int16_t val = ( int16_t )( output[c][t] + 0.5f ); + int16_t val = (int16_t) ( output[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); } } @@ -1777,7 +1777,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { for ( ch_idx = 0; ch_idx < st_ivas->hDecoderConfig->nchan_out; ch_idx++ ) { - set_zero( p_output[ch_idx], ( int16_t )( *nSamplesRendered ) ); + set_zero( p_output[ch_idx], (int16_t) ( *nSamplesRendered ) ); } st_ivas->hTcBuffer->slots_rendered += 1; st_ivas->hTcBuffer->subframes_rendered += 1; @@ -1892,7 +1892,7 @@ ivas_error ivas_jbm_dec_set_discard_samples( int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe; /* render first frame with front zero padding and discarding those samples */ - nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; if ( nSlotsInFirstSubframe > 0 ) { @@ -2401,7 +2401,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->n_samples_flushed = 0; hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; nsamp_to_allocate = 0; - nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -2426,7 +2426,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } else { - n_samp_full = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } @@ -2520,9 +2520,9 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( #endif int16_t nMaxSlotsPerSubframeNew; - nMaxSlotsPerSubframeNew = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; + nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; #ifdef DEBUGGING - nMaxSlotsPerSubframeOld = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframeOld = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; assert( hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] == nMaxSlotsPerSubframeOld ); if ( n_samples_granularity < hTcBuffer->n_samples_granularity ) { @@ -2570,7 +2570,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } else { - n_samp_full = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; @@ -2713,7 +2713,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; - nMaxSlotsPerSubframe = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; st_ivas->hTcBuffer->num_slots = nSlotsAvailable; st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; -- GitLab From 5a51be44916c877e9e0a7512c541a06cae034180 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 4 Jun 2024 15:52:15 +0200 Subject: [PATCH 029/130] experimental workaround for crashes in JBM smoke tests --- lib_dec/lib_dec.c | 4 ++++ scripts/check-format.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 72e9f55f0b..8b3f9c2e3c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -957,6 +957,10 @@ ivas_error IVAS_DEC_FeedFrame_Serial( #ifdef OBJ_EDITING_API /* decode TCs, do TSM and feed to renderer */ /* setup */ + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + } + else { uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; diff --git a/scripts/check-format.sh b/scripts/check-format.sh index db6c681e9d..442cb0ef3d 100755 --- a/scripts/check-format.sh +++ b/scripts/check-format.sh @@ -38,7 +38,7 @@ if [ ! -d "lib_com" ]; then exit 255 fi -CLANG_FORMAT=clang-format +CLANG_FORMAT=clang-format.exe CLANG_FORMAT_REQUIRED_VERSION="13.0" # list (with space between entries) of substrings that are excluded from the file list, e.g. very large files -- GitLab From 5137726a564e4f28f9f60aceba92c21c51b87cbd Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 4 Jun 2024 17:15:05 +0200 Subject: [PATCH 030/130] fix formatting --- lib_dec/ivas_jbm_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 599828b60c..4c860b68c9 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -855,7 +855,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else #endif - if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); } -- GitLab From 20e156b376358feb866f746bc43a145b97601c0b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 5 Jun 2024 07:48:07 +0200 Subject: [PATCH 031/130] temporarily disable OBJ_EDITING_INTERFACE --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 65a3ce893b..1b5c581b35 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,7 +150,7 @@ /* ################## Start DEVELOPMENT switches ######################### */ -#define OBJ_EDITING_INTERFACE /* Interface for object editing */ +/*#define OBJ_EDITING_INTERFACE*/ /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ -- GitLab From dc92cea88c6844dfd63bf5e930384621ca67d27f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 5 Jun 2024 09:02:14 +0200 Subject: [PATCH 032/130] enable OBJ_EDITING_INTERFACE --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7473f5ea7f..4550bacf27 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,7 +150,7 @@ /* ################## Start DEVELOPMENT switches ######################### */ -/*#define OBJ_EDITING_INTERFACE*/ /* Interface for object editing */ +#define OBJ_EDITING_INTERFACE /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ -- GitLab From ef7d029c9f9719912a5cad9b5c77c2a29c160896 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 5 Jun 2024 12:37:44 +0200 Subject: [PATCH 033/130] fix crash with bitrate switching and DTX --- lib_dec/ivas_jbm_dec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5af752388d..86c5a7a942 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -158,6 +158,9 @@ ivas_error ivas_jbm_dec_tc( } ivas_ism_dtx_limit_noise_energy_for_near_silence( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); +#ifdef OBJ_EDITING_API + ivas_param_ism_dec_dequant_md( st_ivas ); +#endif } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { -- GitLab From f4f4f3dbb2b9b1fd91dd80e0f28f899a78d39ca9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 5 Jun 2024 15:40:34 +0200 Subject: [PATCH 034/130] re-enable code to set up parametric binaural rendering --- lib_com/ivas_prot.h | 2 -- lib_dec/ivas_ism_param_dec.c | 4 ++-- lib_dec/ivas_jbm_dec.c | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5b5d7a0d38..8f66031705 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1147,11 +1147,9 @@ void ivas_param_ism_dec_render( float *output_f[] /* o : rendered time signal */ ); -#ifndef OBJ_EDITING_PARAMISM void ivas_param_ism_params_to_masa_param_mapping( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -#endif /*----------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 1c1c0a9b49..899c7eaa95 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1406,7 +1406,6 @@ void ivas_param_ism_dec_render( * * *-------------------------------------------------------------------------*/ -#ifndef OBJ_EDITING_PARAMISM void ivas_param_ism_params_to_masa_param_mapping( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -1419,7 +1418,9 @@ void ivas_param_ism_params_to_masa_param_mapping( int16_t azimuth[2]; int16_t elevation[2]; float power_ratio[2]; +#ifndef OBJ_EDITING_API int32_t ivas_total_brate; +#endif hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -1506,4 +1507,3 @@ void ivas_param_ism_params_to_masa_param_mapping( return; } -#endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 86c5a7a942..0272d8895c 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3122,9 +3122,7 @@ void ivas_jbm_dec_prepare_renderer( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); -#ifndef OBJ_EDITING_PARAMISM ivas_param_ism_params_to_masa_param_mapping( st_ivas ); -#endif } else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { -- GitLab From 4338c04006a73c67eab79a76d5a7d7b2e0423233 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 6 Jun 2024 11:26:35 +0200 Subject: [PATCH 035/130] enable parallel compilation in VS --- Workspace_msvc/decoder.vcxproj | 1 + Workspace_msvc/encoder.vcxproj | 1 + Workspace_msvc/isar_post_rend.vcxproj | 1 + Workspace_msvc/lib_com.vcxproj | 3 +- Workspace_msvc/lib_com.vcxproj.filters | 3 +- Workspace_msvc/lib_debug.vcxproj | 1 + Workspace_msvc/lib_dec.vcxproj | 1 + Workspace_msvc/lib_enc.vcxproj | 1 + Workspace_msvc/lib_isar.vcxproj | 3 +- Workspace_msvc/lib_lc3plus.vcxproj | 3 +- Workspace_msvc/lib_rend.vcxproj | 1 + Workspace_msvc/lib_rend.vcxproj.filters | 72 ------------------------- Workspace_msvc/lib_util.vcxproj | 1 + Workspace_msvc/renderer.vcxproj | 1 + 14 files changed, 17 insertions(+), 76 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index c124382c9c..7b76a18b59 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -83,6 +83,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj index 309dc15253..45b1d8d6db 100644 --- a/Workspace_msvc/encoder.vcxproj +++ b/Workspace_msvc/encoder.vcxproj @@ -83,6 +83,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj index 170ff20545..446886bcbf 100644 --- a/Workspace_msvc/isar_post_rend.vcxproj +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -80,6 +80,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 223f837a2e..02fed70930 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -73,6 +73,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) @@ -223,7 +224,7 @@ - + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index b7c9cc3bdb..6010db15eb 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -473,6 +473,7 @@ common_ivas_c + @@ -552,4 +553,4 @@ {b95b7bed-a666-4a00-9332-2b528638503e} - + \ No newline at end of file diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 5e986bb167..5229874e92 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -69,6 +69,7 @@ Default %(DisableSpecificWarnings) false + true $(OutDir)$(TargetName).lib diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 3c7ea3e597..ae549a78d9 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -83,6 +83,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index ba0c4c9b6f..dd340a50a3 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -83,6 +83,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index fceeb731ce..2c7f6d848e 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -83,6 +83,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) @@ -197,4 +198,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 55a291fa9c..54ee84d041 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -73,6 +73,7 @@ OldStyle false false + true Console @@ -182,4 +183,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 27d4a19a69..8d1ec03ce5 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -83,6 +83,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 942c63712f..889057cb7c 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -32,30 +32,12 @@ rend_c - - rend_c - - - rend_c - - - rend_c - - - rend_c - rend_c rend_c - - rend_c - - - rend_c - rend_c @@ -83,15 +65,6 @@ rend_c - - rend_c - - - rend_c - - - rend_c - rend_c @@ -113,9 +86,6 @@ rend_c - - rend_c - rend_c @@ -134,24 +104,6 @@ rend_c - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - rend_c @@ -161,30 +113,12 @@ rend_c - - rend_c - - - rend_c - - - rend_c - rend_c - - rend_h - - - rend_h - - - rend_h - rend_h @@ -203,12 +137,6 @@ rend_h - - rend_h - - - rend_h - diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 79e5545f3f..b5a11d5013 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -68,6 +68,7 @@ Default %(DisableSpecificWarnings) false + true $(OutDir)$(TargetName).lib diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index 0a7c72a16c..7f89a1ccc6 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -80,6 +80,7 @@ Default %(DisableSpecificWarnings) false + true _DEBUG;%(PreprocessorDefinitions) -- GitLab From f839ca5d7c8eaa41b3e11c98c8840f7a5098505f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 6 Jun 2024 11:53:11 +0200 Subject: [PATCH 036/130] fix uninitialized edited values --- lib_dec/lib_dec.c | 4783 +++++++++++++++++++++++---------------------- 1 file changed, 2402 insertions(+), 2381 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2a3a9eeb3e..4146031fcf 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -563,7 +563,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->st_ivas->ivas_format = MONO_FORMAT; } - hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; hIvasDec->tsm_scale = 100; @@ -625,7 +625,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( int16_t get_render_frame_size_ms( const IVAS_RENDER_FRAMESIZE render_framesize ) { - return (int16_t) ( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + return ( int16_t )( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); } @@ -696,7 +696,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); + *render_framesize = ( int16_t )( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); return IVAS_ERR_OK; } @@ -738,7 +738,7 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *update_frequency = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); + *update_frequency = ( int16_t )( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); return IVAS_ERR_OK; } @@ -817,7 +817,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->lastDecodedWasActive = 0; hIvasDec->hVoIP->hCurrentDataUnit = NULL; - hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->hVoIP->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->hVoIP->nSamplesRendered20ms = 0; #define WMC_TOOL_SKIP @@ -1022,354 +1022,375 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } } hIvasDec->hasBeenPreparedRendering = false; + + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { +#ifdef OBJ_EDITING_PARAMISM + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#endif + { + int16_t obj; + ISM_RENDERER_HANDLE hIsmRendererData = hIvasDec->st_ivas->hIsmRendererData; + for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + { + + hIsmRendererData->edited_azimuth[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; + hIsmRendererData->edited_elevation[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; + hIsmRendererData->edited_yaw[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIsmRendererData->edited_pitch[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIsmRendererData->edited_radius[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + hIsmRendererData->edited_gains[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + } + } + } #endif - return IVAS_ERR_OK; + return IVAS_ERR_OK; } #ifdef OBJ_EDITING_API -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetEditableParameters( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) -{ - ivas_error error; - - if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ivas_error IVAS_DEC_GetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS * hIvasEditableParameters ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + ivas_error error; - hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) - { + if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { #ifdef OBJ_EDITING_PARAMISM - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif - { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; - hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; - hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; - hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; - hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; - hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; + hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + } } - } #ifdef OBJ_EDITING_PARAMISM - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) - { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; + hIvasEditableParameters->ism_metadata[obj].yaw = 0; + hIvasEditableParameters->ism_metadata[obj].pitch = 0; + hIvasEditableParameters->ism_metadata[obj].radius = 0; + hIvasEditableParameters->ism_metadata[obj].gain = 0; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; + } + } + else { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; - hIvasEditableParameters->ism_metadata[obj].yaw = 0; - hIvasEditableParameters->ism_metadata[obj].pitch = 0; - hIvasEditableParameters->ism_metadata[obj].radius = 0; - hIvasEditableParameters->ism_metadata[obj].gain = 0; - hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; + assert( 0 && "This should never happen!" ); } +#endif + } + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) + { } else { - assert( 0 && "This should never happen!" ); } -#endif - } - else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - } - else - { - } - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; - return error; -} + return error; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_SetEditableParameters( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_SetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) -{ - ivas_error error; + ivas_error IVAS_DEC_SetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) + { + ivas_error error; - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } #ifdef DEBUGGING - assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); + assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); #endif - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) - { + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { #ifdef OBJ_EDITING_PARAMISM - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif - { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; - hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; - hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; - hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; + hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + } } - } #ifdef OBJ_EDITING_PARAMISM - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) - { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + } + } + else { - hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + assert( 0 && "This should never happen!" ); } +#endif + } + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) + { } else { - assert( 0 && "This should never happen!" ); } -#endif - } - else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - } - else - { - } - return error; -} + return error; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_PrepareRenderer( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_PrepareRenderer( - IVAS_DEC_HANDLE hIvasDec ) -{ - ivas_error error; + ivas_error IVAS_DEC_PrepareRenderer( + IVAS_DEC_HANDLE hIvasDec ) + { + ivas_error error; - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; - if ( hIvasDec == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); - hIvasDec->hasBeenPreparedRendering = true; - return error; -} + ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); + hIvasDec->hasBeenPreparedRendering = true; + return error; + } #endif -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetSamples( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ + ivas_error IVAS_DEC_GetSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : indication that the decoder needs a new frame */ -) -{ - ivas_error error; - int16_t nSamplesToRender; - uint16_t nSamplesRendered, nSamplesRendered_loop; - uint8_t nOutChannels; + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ + ) + { + ivas_error error; + int16_t nSamplesToRender; + uint16_t nSamplesRendered, nSamplesRendered_loop; + uint8_t nOutChannels; #ifndef OBJ_EDITING_API - uint8_t nTransportChannels; - int16_t nOutSamplesElse; - uint16_t nTimeScalerOutSamples, l_ts; + uint8_t nTransportChannels; + int16_t nOutSamplesElse; + uint16_t nTimeScalerOutSamples, l_ts; #endif - nSamplesRendered = 0; - nOutChannels = 0; - nSamplesRendered_loop = 0; + nSamplesRendered = 0; + nOutChannels = 0; + nSamplesRendered_loop = 0; #ifndef OBJ_EDITING_API - l_ts = 0; - nTransportChannels = 0; + l_ts = 0; + nTransportChannels = 0; #endif - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } #ifdef OBJ_EDITING_API - /* the rendering needs to be prepared at this point */ - if ( hIvasDec->hasBeenPreparedRendering == false ) - { - return IVAS_ERR_UNKNOWN; - } + /* the rendering needs to be prepared at this point */ + if ( hIvasDec->hasBeenPreparedRendering == false ) + { + return IVAS_ERR_UNKNOWN; + } #endif - if ( hIvasDec->updateOrientation ) - { - /*----------------------------------------------------------------* + if ( hIvasDec->updateOrientation ) + { + /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ - if ( ( error = combine_external_and_head_orientations_dec( hIvasDec->st_ivas->hHeadTrackData, hIvasDec->st_ivas->hExtOrientationData, hIvasDec->st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = combine_external_and_head_orientations_dec( hIvasDec->st_ivas->hHeadTrackData, hIvasDec->st_ivas->hExtOrientationData, hIvasDec->st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + { + return error; + } #ifdef SPLIT_REND_WITH_HEAD_ROT - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * Binaural split rendering setup *----------------------------------------------------------------*/ - if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL && ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - isar_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat ); - } + if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL && ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + isar_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat ); + } #endif - hIvasDec->updateOrientation = false; - } - - if ( !hIvasDec->hasBeenFedFrame && hIvasDec->nSamplesAvailableNext == 0 ) - { - /* no frame was fed, do nothing but ask for a frame */ - *needNewFrame = true; - *nOutSamples = 0; - hIvasDec->needNewFrame = true; - return IVAS_ERR_OK; - } + hIvasDec->updateOrientation = false; + } - /* check if we are still at the beginning with bad frames, put out zeroes, keep track of subframes */ - if ( !hIvasDec->isInitialized && hIvasDec->st_ivas->bfi ) - { - hIvasDec->hasBeenFedFrame = false; - set_s( pcmBuf, 0, hIvasDec->st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); - hIvasDec->nSamplesRendered += nSamplesAsked; - *nOutSamples = nSamplesAsked; - hIvasDec->nSamplesAvailableNext -= nSamplesAsked; - if ( hIvasDec->nSamplesAvailableNext == 0 ) + if ( !hIvasDec->hasBeenFedFrame && hIvasDec->nSamplesAvailableNext == 0 ) { - hIvasDec->needNewFrame = true; + /* no frame was fed, do nothing but ask for a frame */ *needNewFrame = true; + *nOutSamples = 0; + hIvasDec->needNewFrame = true; + return IVAS_ERR_OK; } - } - else - { -#ifndef OBJ_EDITING_API - /* check if we need to run the setup function */ - if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { - /* setup */ -#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, &nSamplesRendered_loop, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) -#endif + /* check if we are still at the beginning with bad frames, put out zeroes, keep track of subframes */ + if ( !hIvasDec->isInitialized && hIvasDec->st_ivas->bfi ) + { + hIvasDec->hasBeenFedFrame = false; + set_s( pcmBuf, 0, hIvasDec->st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); + hIvasDec->nSamplesRendered += nSamplesAsked; + *nOutSamples = nSamplesAsked; + hIvasDec->nSamplesAvailableNext -= nSamplesAsked; + if ( hIvasDec->nSamplesAvailableNext == 0 ) { - return error; + hIvasDec->needNewFrame = true; + *needNewFrame = true; } } -#endif + else { - /* check if we need to run the setup function, tc decoding and feeding the renderer */ #ifndef OBJ_EDITING_API + /* check if we need to run the setup function */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { - int16_t nResidualSamples, nSamplesTcsScaled; - nSamplesRendered += nSamplesRendered_loop; - - 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; - } - } + /* setup */ +#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, &nSamplesRendered_loop, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) +#endif - /* IVAS decoder */ - if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } - - /* JBM */ - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + } +#endif + { + /* check if we need to run the setup function, tc decoding and feeding the renderer */ +#ifndef OBJ_EDITING_API + if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { - if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + int16_t nResidualSamples, nSamplesTcsScaled; + nSamplesRendered += nSamplesRendered_loop; + + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) { - return IVAS_ERR_UNKNOWN; + if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) + { + return error; + } } - if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + /* IVAS decoder */ + if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { - return IVAS_ERR_UNKNOWN; + return error; } - assert( nTimeScalerOutSamples <= APA_BUF ); - nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; - hIvasDec->timeScalingDone = 1; - } - else - { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - } + /* 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; + hIvasDec->timeScalingDone = 1; + } + else + { + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); + dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); #endif - /* Feed decoded transport channels samples to the renderer */ - if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) - { - return error; - } + /* Feed decoded transport channels samples to the renderer */ + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); + dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); #endif - 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 ) + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { - return IVAS_ERR_UNKNOWN; + /* 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; + } } + hIvasDec->hasBeenFedFrame = false; } - hIvasDec->hasBeenFedFrame = false; - } #else nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; hIvasDec->hasBeenFedFrame = false; @@ -1404,285 +1425,285 @@ ivas_error IVAS_DEC_GetSamples( } #endif - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = nSamplesAsked - nSamplesRendered; + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = nSamplesAsked - nSamplesRendered; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) #endif - { - return error; - } + { + return error; + } - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; - if ( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - } - else - { - *needNewFrame = false; + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; + if ( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + } + else + { + *needNewFrame = false; + } } } - } - *nOutSamples = nSamplesRendered; + *nOutSamples = nSamplesRendered; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } #ifdef SPLIT_REND_WITH_HEAD_ROT -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetSplitBinauralBitstream( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetSplitBinauralBitstream( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : indication that the decoder needs a new frame */ -) -{ - Decoder_Struct *st_ivas; - AUDIO_CONFIG output_config; - int32_t output_Fs; - float *pOutput[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; - float output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; - float pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; - 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]; - int16_t numSamplesPerChannelToDecode; - int16_t i, j; - ivas_error error; - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; - int16_t max_band; - int16_t pcm_out_flag; - int16_t td_input; - int16_t numPoses; - int16_t slots_rendered, slots_rendered_new; - int16_t ro_md_flag; - IVAS_QUATERNION Quaternion; - - error = IVAS_ERR_OK; - st_ivas = hIvasDec->st_ivas; - output_config = st_ivas->hDecoderConfig->output_config; - output_Fs = st_ivas->hDecoderConfig->output_Fs; - numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + ivas_error IVAS_DEC_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ + ) + { + Decoder_Struct *st_ivas; + AUDIO_CONFIG output_config; + int32_t output_Fs; + float *pOutput[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; + float output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; + float pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; + 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]; + int16_t numSamplesPerChannelToDecode; + int16_t i, j; + ivas_error error; + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + int16_t max_band; + int16_t pcm_out_flag; + int16_t td_input; + int16_t numPoses; + int16_t slots_rendered, slots_rendered_new; + int16_t ro_md_flag; + IVAS_QUATERNION Quaternion; + + error = IVAS_ERR_OK; + st_ivas = hIvasDec->st_ivas; + output_config = st_ivas->hDecoderConfig->output_config; + output_Fs = st_ivas->hDecoderConfig->output_Fs; + numSamplesPerChannelToDecode = ( int16_t )( output_Fs / FRAMES_PER_SEC ); - *needNewFrame = false; - hSplitBinRend = st_ivas->hSplitBinRend; + *needNewFrame = false; + hSplitBinRend = st_ivas->hSplitBinRend; - if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } - numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; #ifdef OBJ_EDITING_API - /* init flush buffer for rate switch if not already initizalized */ - if ( hIvasDec->flushbuffer == NULL ) - { - hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); - hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; - set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); - } + /* init flush buffer for rate switch if not already initizalized */ + if ( hIvasDec->flushbuffer == NULL ) + { + hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); + hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; + set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + } #endif - if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && - ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) - { - numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); - numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; - } - - if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) - { - return IVAS_ERR_WRONG_PARAMS; - } + if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + numSamplesPerChannelToDecode = ( int16_t )( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); + numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; + } - if ( st_ivas->hTcBuffer == NULL || hIvasDec->hasBeenFedFrame ) - { - slots_rendered = 0; - } - else - { - /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { - slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + return IVAS_ERR_WRONG_PARAMS; + } + + if ( st_ivas->hTcBuffer == NULL || hIvasDec->hasBeenFedFrame ) + { + slots_rendered = 0; } else { - slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; + /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + } + else + { + slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; + } } - } - /* Decode and render */ - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) - { - return error; - } + /* Decode and render */ + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + { + return error; + } - /* change buffer layout */ - for ( i = 0; i < numSamplesPerChannelToDecode; ++i ) - { - for ( j = 0; j < BINAURAL_CHANNELS * numPoses; ++j ) + /* change buffer layout */ + for ( i = 0; i < numSamplesPerChannelToDecode; ++i ) { - output[j][i] = pcmBuf[i * BINAURAL_CHANNELS * numPoses + j]; + for ( j = 0; j < BINAURAL_CHANNELS * numPoses; ++j ) + { + output[j][i] = pcmBuf[i * BINAURAL_CHANNELS * numPoses + j]; + } + } + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + pOutput[i] = output[i]; } - } - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) - { - pOutput[i] = output[i]; - } - if ( st_ivas->hTcBuffer == NULL ) - { - slots_rendered_new = 0; - } - else - { - /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + if ( st_ivas->hTcBuffer == NULL ) { - slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + slots_rendered_new = 0; } else { - slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; + /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + } + else + { + slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; + } } - } - for ( i = 0; i < BINAURAL_CHANNELS * numPoses; ++i ) - { - for ( j = slots_rendered; j < slots_rendered_new; ++j ) + for ( i = 0; i < BINAURAL_CHANNELS * numPoses; ++i ) { - mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[i][j], Cldfb_RealBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); - mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[i][j], Cldfb_ImagBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); + for ( j = slots_rendered; j < slots_rendered_new; ++j ) + { + mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[i][j], Cldfb_RealBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); + mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[i][j], Cldfb_ImagBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); + } } - } - max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); - pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; + max_band = ( int16_t )( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); + pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; - if ( st_ivas->hBinRendererTd != NULL ) - { - ro_md_flag = 1; - } - else - { - ro_md_flag = 0; - } + if ( st_ivas->hBinRendererTd != NULL ) + { + ro_md_flag = 1; + } + else + { + ro_md_flag = 0; + } - if ( st_ivas->hHeadTrackData != NULL ) - { - Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; - } - else - { - Quaternion.w = -3.0f; - Quaternion.x = 0.0f; - Quaternion.y = 0.0f; - Quaternion.z = 0.0f; - } + if ( st_ivas->hHeadTrackData != NULL ) + { + Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; + } + else + { + Quaternion.w = -3.0f; + Quaternion.x = 0.0f; + Quaternion.y = 0.0f; + Quaternion.z = 0.0f; + } - if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, - Quaternion, - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, #endif - st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - splitRendBits, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK ) - { - return error; - } + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + Cldfb_RealBuffer_Binaural, + Cldfb_ImagBuffer_Binaural, + max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK ) + { + return error; + } - /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ - if ( pcm_out_flag ) - { - if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ + if ( pcm_out_flag ) { + if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + { #ifndef DISABLE_LIMITER - ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); #endif - } - else - { - ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); - } + } + else + { + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); + } #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += #endif - ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); - } + ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + } - free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); + free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); - return error; -} + return error; + } #endif -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_Setup( ) * * *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_Setup( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t *nTcBufferGranularity, /* o : granularity of the TC Buffer */ - uint8_t *nTransportChannels, /* o : number of decoded transport PCM channels */ - uint8_t *nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame */ + static ivas_error IVAS_DEC_Setup( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t * nTcBufferGranularity, /* o : granularity of the TC Buffer */ + uint8_t * nTransportChannels, /* o : number of decoded transport PCM channels */ + uint8_t * nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ + uint16_t * nSamplesRendered, /* o : number of samples flushed from the last frame */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif -) -{ - ivas_error error; + ) + { + ivas_error error; - *nSamplesRendered = 0; + *nSamplesRendered = 0; - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) - { - if ( hIvasDec->st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { - *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; - *nOutChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; + if ( hIvasDec->st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + { + *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; + *nOutChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; + } + else + { + *nTransportChannels = 1; + *nOutChannels = 1; + } } else { - *nTransportChannels = 1; - *nOutChannels = 1; - } - } - else - { - Decoder_Struct *st_ivas; + Decoder_Struct *st_ivas; - st_ivas = hIvasDec->st_ivas; + st_ivas = hIvasDec->st_ivas; - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * IVAS decoder setup * - read IVAS format signaling * - read IVAS format specific signaling @@ -1690,550 +1711,550 @@ static ivas_error IVAS_DEC_Setup( * - reconfigure the decoder when the number of TC or IVAS total bitrate change *----------------------------------------------------------------*/ - if ( st_ivas->bfi == 0 ) - { + if ( st_ivas->bfi == 0 ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, pcm_type_API_to_internal( pcmType ), data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, pcm_type_API_to_internal( pcmType ), data ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - { - return error; + { + return error; + } } - } - *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; - *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; - *nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; + *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; + *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; + *nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; #ifdef SPLIT_REND_WITH_HEAD_ROT - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * ISAR: * - initialize ISAR handle at the first frame * - reconfigure the ISAR handle in case of bitrate switching (renderer might change) *-----------------------------------------------------------------*/ - if ( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) - { - if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + if ( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) { - return error; + if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } } - } #endif - } + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetTcSamples( ) * * Main function to decode to PCM data of the transport channels *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_GetTcSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - float *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ - int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ -) -{ - Decoder_Struct *st_ivas; - ivas_error error; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + static ivas_error IVAS_DEC_GetTcSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + Decoder_Struct *st_ivas; + ivas_error error; - st_ivas = hIvasDec->st_ivas; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + st_ivas = hIvasDec->st_ivas; - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) - { - if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf, NULL ) ) != IVAS_ERR_OK ) + *nOutSamples = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { - return error; + if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) - { - /* run the main IVAS decoding routine */ - if ( ( error = ivas_jbm_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) + else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) { - return error; + /* run the main IVAS decoding routine */ + if ( ( error = ivas_jbm_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) + { + return error; + } + + hIvasDec->isInitialized = true; /* Initialization done in ivas_dec() */ } - hIvasDec->isInitialized = true; /* Initialization done in ivas_dec() */ - } + if ( hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasDec->hasDecodedFirstGoodFrame = true; + } - if ( hIvasDec->hasBeenFedFirstGoodFrame ) - { - hIvasDec->hasDecodedFirstGoodFrame = true; + return IVAS_ERR_OK; } - return IVAS_ERR_OK; -} - -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_Rendered_FeedTcSamples( ) * * Feed decoded transport channels samples to the renderer *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_RendererFeedTcSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call */ - float *pcmBuf /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ -) -{ - Decoder_Struct *st_ivas; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + static ivas_error IVAS_DEC_RendererFeedTcSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call */ + float *pcmBuf /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + Decoder_Struct *st_ivas; - st_ivas = hIvasDec->st_ivas; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - /* feed the TCs to the IVAS renderer */ - ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesForRendering, nSamplesResidual, pcmBuf ); + st_ivas = hIvasDec->st_ivas; - return IVAS_ERR_OK; -} + /* feed the TCs to the IVAS renderer */ + ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesForRendering, nSamplesResidual, pcmBuf ); + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + + /*---------------------------------------------------------------------* * IVAS_DEC_GetRenderedSamples( ) * * Main function to render the transport channels to PCM output data *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_GetRenderedSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renderer pipeline */ + static ivas_error IVAS_DEC_GetRenderedSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renderer pipeline */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf /* o : output synthesis signal */ #else int16_t *pcmBuf #endif -) -{ - Decoder_Struct *st_ivas; - ivas_error error; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + Decoder_Struct *st_ivas; + ivas_error error; - st_ivas = hIvasDec->st_ivas; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; - /* run the main IVAS decoding routine */ + /* run the main IVAS decoding routine */ #ifdef SPLIT_REND_WITH_HEAD_ROT - error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); + error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); #else error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); #endif - return error; -} + return error; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetBufferedNumberOfSamples( ) * * Returns the number of objects available in the decoded bitstream *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *nSamplesBuffered /* o : number of samples still buffered */ -) -{ - *nSamplesBuffered = 0; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t * nSamplesBuffered /* o : number of samples still buffered */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + *nSamplesBuffered = 0; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - /* check if the TC buffer already exists, otherweise nothing is buffered anyway */ - if ( hIvasDec->st_ivas->hTcBuffer != NULL ) - { - *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered; - *nSamplesBuffered += hIvasDec->hVoIP->nSamplesRendered20ms; - } + /* check if the TC buffer already exists, otherweise nothing is buffered anyway */ + if ( hIvasDec->st_ivas->hTcBuffer != NULL ) + { + *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered; + *nSamplesBuffered += hIvasDec->hVoIP->nSamplesRendered20ms; + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetNumObjects( ) * * Returns the number of objects available in the decoded bitstream *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetNumObjects( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t *numObjects /* o : number of objects for which the decoder has been configured */ -) -{ - int16_t is_masa_ism; - is_masa_ism = 0; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ivas_error IVAS_DEC_GetNumObjects( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t * numObjects /* o : number of objects for which the decoder has been configured */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + int16_t is_masa_ism; + is_masa_ism = 0; - if ( hIvasDec->st_ivas->hMasa != NULL ) - { - if ( hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { - is_masa_ism = 1; + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - } - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || is_masa_ism ) - { - *numObjects = hIvasDec->st_ivas->nchan_ism; - } - else - { - *numObjects = 0; - } - return IVAS_ERR_OK; -} + if ( hIvasDec->st_ivas->hMasa != NULL ) + { + if ( hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + { + is_masa_ism = 1; + } + } + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || is_masa_ism ) + { + *numObjects = hIvasDec->st_ivas->nchan_ism; + } + else + { + *numObjects = 0; + } + + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetFormat( ) * * Returns the format of currently decoded bitstream. * Note: bitstream format is only known after the first (good) frame has been decoded. *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetFormat( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_BS_FORMAT *format /* o : format detected from bitstream fed to the decoder */ -) -{ - if ( hIvasDec->hasDecodedFirstGoodFrame ) + ivas_error IVAS_DEC_GetFormat( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_BS_FORMAT * format /* o : format detected from bitstream fed to the decoder */ + ) { - *format = mapIvasFormat( hIvasDec->st_ivas->ivas_format ); - } - else - { - *format = IVAS_DEC_BS_UNKOWN; - } + if ( hIvasDec->hasDecodedFirstGoodFrame ) + { + *format = mapIvasFormat( hIvasDec->st_ivas->ivas_format ); + } + else + { + *format = IVAS_DEC_BS_UNKOWN; + } - if ( *format == IVAS_DEC_BS_MASA && hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) - { - *format = IVAS_DEC_BS_MASA_ISM; - } + if ( *format == IVAS_DEC_BS_MASA && hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + { + *format = IVAS_DEC_BS_MASA_ISM; + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * getInputBufferSize() * * *---------------------------------------------------------------------*/ -static int16_t getOutputBufferSize( - const Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -) -{ - if ( st_ivas->hDecoderConfig == NULL ) - { - return -1; - } - - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + static int16_t getOutputBufferSize( + const Decoder_Struct *st_ivas /* i : IVAS decoder handle */ + ) { - return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) / FRAMES_PER_SEC ); - } - else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) - { - if ( st_ivas->hLsSetupCustom == NULL ) + if ( st_ivas->hDecoderConfig == NULL ) { return -1; } - return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * ( st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe ) / FRAMES_PER_SEC ); - } - else - { - return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * st_ivas->hDecoderConfig->nchan_out / FRAMES_PER_SEC ); + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) / FRAMES_PER_SEC ); + } + else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + if ( st_ivas->hLsSetupCustom == NULL ) + { + return -1; + } + + return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * ( st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe ) / FRAMES_PER_SEC ); + } + else + { + return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * st_ivas->hDecoderConfig->nchan_out / FRAMES_PER_SEC ); + } } -} -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetOutputBufferSize() * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetOutputBufferSize( - const IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ - int16_t *outputBufferSize /* o : total number of samples expected in the output buffer for current decoder configuration */ -) -{ - if ( outputBufferSize == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ivas_error IVAS_DEC_GetOutputBufferSize( + const IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ + int16_t *outputBufferSize /* o : total number of samples expected in the output buffer for current decoder configuration */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( outputBufferSize == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *outputBufferSize = getOutputBufferSize( hIvasDec->st_ivas ); + *outputBufferSize = getOutputBufferSize( hIvasDec->st_ivas ); - if ( *outputBufferSize == -1 ) - { - return IVAS_ERR_INVALID_OUTPUT_BUFFER_SIZE; - } - else - { - return IVAS_ERR_OK; + if ( *outputBufferSize == -1 ) + { + return IVAS_ERR_INVALID_OUTPUT_BUFFER_SIZE; + } + else + { + return IVAS_ERR_OK; + } } -} -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetNumOutputChannels( ) * * Returns number of output channels *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetNumOutputChannels( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *numOutputChannels /* o : number of PCM output channels */ -) -{ - if ( hIvasDec->hasDecodedFirstGoodFrame ) - { - *numOutputChannels = hIvasDec->st_ivas->hDecoderConfig->nchan_out; - } - else + ivas_error IVAS_DEC_GetNumOutputChannels( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t * numOutputChannels /* o : number of PCM output channels */ + ) { - *numOutputChannels = 0; - } + if ( hIvasDec->hasDecodedFirstGoodFrame ) + { + *numOutputChannels = hIvasDec->st_ivas->hDecoderConfig->nchan_out; + } + else + { + *numOutputChannels = 0; + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetObjectMetadata( ) * * Get metadata of one object decoded in the most recent frame *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetObjectMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_ISM_METADATA *metadata, /* o : struct where metadata decoded in most recently decoded frame will be written */ - const uint16_t zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ - const uint16_t objectIdx /* i : index of the queried object */ -) -{ - Decoder_Struct *st_ivas; - ISM_METADATA_HANDLE hIsmMeta; - int16_t is_masa_ism; - is_masa_ism = 0; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ivas_error IVAS_DEC_GetObjectMetadata( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_ISM_METADATA * metadata, /* o : struct where metadata decoded in most recently decoded frame will be written */ + const uint16_t zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ + const uint16_t objectIdx /* i : index of the queried object */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + Decoder_Struct *st_ivas; + ISM_METADATA_HANDLE hIsmMeta; + int16_t is_masa_ism; + is_masa_ism = 0; - st_ivas = hIvasDec->st_ivas; - if ( hIvasDec->st_ivas->hMasa != NULL ) - { - if ( hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { - is_masa_ism = 1; + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - } - if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != MASA_ISM_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT && is_masa_ism == 0 ) - { - return IVAS_ERR_WRONG_MODE; - } - if ( objectIdx >= st_ivas->nchan_ism ) - { - return IVAS_ERR_INVALID_INDEX; - } + st_ivas = hIvasDec->st_ivas; + if ( hIvasDec->st_ivas->hMasa != NULL ) + { + if ( hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + { + is_masa_ism = 1; + } + } + if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != MASA_ISM_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT && is_masa_ism == 0 ) + { + return IVAS_ERR_WRONG_MODE; + } - hIsmMeta = st_ivas->hIsmMetaData[objectIdx]; + if ( objectIdx >= st_ivas->nchan_ism ) + { + return IVAS_ERR_INVALID_INDEX; + } - if ( hIsmMeta == NULL || zero_flag || ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) ) - { - metadata->azimuth = 0.f; - metadata->elevation = 0.f; - metadata->radius = 1.f; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->yaw = 0.f; - metadata->pitch = 0.f; - metadata->non_diegetic_flag = 0; - } - else - { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; - } + hIsmMeta = st_ivas->hIsmMetaData[objectIdx]; - return IVAS_ERR_OK; -} + if ( hIsmMeta == NULL || zero_flag || ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) ) + { + metadata->azimuth = 0.f; + metadata->elevation = 0.f; + metadata->radius = 1.f; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->yaw = 0.f; + metadata->pitch = 0.f; + metadata->non_diegetic_flag = 0; + } + else + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + + /*---------------------------------------------------------------------* * IVAS_DEC_GetMasaMetadata( ) * * Get metadata of the most recently decoded MASA frame *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetMasaMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ - const uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ivas_error IVAS_DEC_GetMasaMetadata( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + MASA_DECODER_EXT_OUT_META_HANDLE * hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ + const uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - if ( hIvasDec->st_ivas->ivas_format != MASA_FORMAT && hIvasDec->st_ivas->ivas_format != MASA_ISM_FORMAT ) - { - return IVAS_ERR_WRONG_MODE; - } + if ( hIvasDec->st_ivas->ivas_format != MASA_FORMAT && hIvasDec->st_ivas->ivas_format != MASA_ISM_FORMAT ) + { + return IVAS_ERR_WRONG_MODE; + } - if ( getFromJbmBuffer ) - { - ivas_jbm_masa_sf_to_sf_map( hIvasDec->st_ivas ); - } + if ( getFromJbmBuffer ) + { + ivas_jbm_masa_sf_to_sf_map( hIvasDec->st_ivas ); + } - *hMasaExtOutMeta = hIvasDec->st_ivas->hMasa->data.extOutMeta; + *hMasaExtOutMeta = hIvasDec->st_ivas->hMasa->data.extOutMeta; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_FeedHeadTrackData( ) * * Feed the decoder with the head tracking data *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_FeedHeadTrackData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ - IVAS_VECTOR3 Pos, /* i : listener position */ + ivas_error IVAS_DEC_FeedHeadTrackData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ + IVAS_VECTOR3 Pos, /* i : listener position */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const int16_t subframe_idx, /* i : subframe index */ - const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ + const int16_t subframe_idx, /* i : subframe index */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ #else const int16_t subframe_idx /* i : subframe index */ #endif -) -{ - HEAD_TRACK_DATA_HANDLE hHeadTrackData; - ivas_error error; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + HEAD_TRACK_DATA_HANDLE hHeadTrackData; + ivas_error error; - hHeadTrackData = hIvasDec->st_ivas->hHeadTrackData; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - if ( hHeadTrackData == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + hHeadTrackData = hIvasDec->st_ivas->hHeadTrackData; + + if ( hHeadTrackData == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - /* Move head-tracking data to the decoder handle */ - /* check for Euler angle signaling */ - if ( orientation.w == -3.0f ) - { - Euler2Quat( deg2rad( orientation.x ), deg2rad( orientation.y ), deg2rad( orientation.z ), &orientation ); - } + /* Move head-tracking data to the decoder handle */ + /* check for Euler angle signaling */ + if ( orientation.w == -3.0f ) + { + Euler2Quat( deg2rad( orientation.x ), deg2rad( orientation.y ), deg2rad( orientation.z ), &orientation ); + } - if ( ( error = ivas_orient_trk_Process( hHeadTrackData->OrientationTracker, orientation, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hHeadTrackData->Quaternions[subframe_idx] ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = ivas_orient_trk_Process( hHeadTrackData->OrientationTracker, orientation, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hHeadTrackData->Quaternions[subframe_idx] ) ) != IVAS_ERR_OK ) + { + return error; + } - hHeadTrackData->Pos[subframe_idx].x = Pos.x; - hHeadTrackData->Pos[subframe_idx].y = Pos.y; - hHeadTrackData->Pos[subframe_idx].z = Pos.z; + hHeadTrackData->Pos[subframe_idx].x = Pos.x; + hHeadTrackData->Pos[subframe_idx].y = Pos.y; + hHeadTrackData->Pos[subframe_idx].z = Pos.z; #ifdef SPLIT_REND_WITH_HEAD_ROT - hHeadTrackData->sr_pose_pred_axis = rot_axis; + hHeadTrackData->sr_pose_pred_axis = rot_axis; #endif - hIvasDec->updateOrientation = true; + hIvasDec->updateOrientation = true; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_FeedRefRotData( ) * * Feed the decoder with the reference rotation *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_FeedRefRotData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION rotation /* i : reference rotation data */ -) -{ - ivas_orient_trk_state_t *pOtr; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHeadTrackData == NULL || hIvasDec->st_ivas->hHeadTrackData->OrientationTracker == NULL ) + ivas_error IVAS_DEC_FeedRefRotData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_QUATERNION rotation /* i : reference rotation data */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + ivas_orient_trk_state_t *pOtr; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHeadTrackData == NULL || hIvasDec->st_ivas->hHeadTrackData->OrientationTracker == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; + pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; - pOtr->refRot.w = rotation.w; - pOtr->refRot.x = rotation.x; - pOtr->refRot.z = rotation.z; - pOtr->refRot.y = rotation.y; + pOtr->refRot.w = rotation.w; + pOtr->refRot.x = rotation.x; + pOtr->refRot.z = rotation.z; + pOtr->refRot.y = rotation.y; - hIvasDec->updateOrientation = true; + hIvasDec->updateOrientation = true; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_FeedRefVectorData( ) * * Feed the decoder with a reference vector spanning from listenerPos @@ -2241,401 +2262,401 @@ ivas_error IVAS_DEC_FeedRefRotData( * OTR_TRACKING_REF_POS_LEV modes. *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_FeedRefVectorData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_VECTOR3 listenerPos, /* i : Listener position */ - const IVAS_VECTOR3 refPos /* i : Reference position */ -) -{ - ivas_orient_trk_state_t *pOtr; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHeadTrackData == NULL || hIvasDec->st_ivas->hHeadTrackData->OrientationTracker == NULL ) + ivas_error IVAS_DEC_FeedRefVectorData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_VECTOR3 listenerPos, /* i : Listener position */ + const IVAS_VECTOR3 refPos /* i : Reference position */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + ivas_orient_trk_state_t *pOtr; - pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHeadTrackData == NULL || hIvasDec->st_ivas->hHeadTrackData->OrientationTracker == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hIvasDec->updateOrientation = true; + pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; - return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos ); -} + hIvasDec->updateOrientation = true; + return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos ); + } -/*---------------------------------------------------------------------* + + /*---------------------------------------------------------------------* * IVAS_DEC_FeedExternalOrientationData( ) * * Feed the decoder with the external orientation data *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_FeedExternalOrientationData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : external orientation data */ - int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ - int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t subframe_idx /* i : subframe index */ -) -{ - EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ivas_error IVAS_DEC_FeedExternalOrientationData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_QUATERNION orientation, /* i : external orientation data */ + int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ + int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const int16_t subframe_idx /* i : subframe index */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hExternalOrientationData = hIvasDec->st_ivas->hExtOrientationData; + hExternalOrientationData = hIvasDec->st_ivas->hExtOrientationData; - if ( hExternalOrientationData == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hExternalOrientationData == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - /* Move external orientation data to the decoder handle (invert orientations) */ - QuaternionInverse( orientation, &hExternalOrientationData->Quaternions[subframe_idx] ); + /* Move external orientation data to the decoder handle (invert orientations) */ + QuaternionInverse( orientation, &hExternalOrientationData->Quaternions[subframe_idx] ); - hExternalOrientationData->enableHeadRotation[subframe_idx] = enableHeadRotation; - hExternalOrientationData->enableExternalOrientation[subframe_idx] = enableExternalOrientation; - hExternalOrientationData->enableRotationInterpolation[subframe_idx] = enableRotationInterpolation; - hExternalOrientationData->numFramesToTargetOrientation[subframe_idx] = numFramesToTargetOrientation; + hExternalOrientationData->enableHeadRotation[subframe_idx] = enableHeadRotation; + hExternalOrientationData->enableExternalOrientation[subframe_idx] = enableExternalOrientation; + hExternalOrientationData->enableRotationInterpolation[subframe_idx] = enableRotationInterpolation; + hExternalOrientationData->numFramesToTargetOrientation[subframe_idx] = numFramesToTargetOrientation; - hIvasDec->updateOrientation = true; + hIvasDec->updateOrientation = true; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_FeedCustomLsData( ) * * Feed the decoder with the Custom loudspeaker data *---------------------------------------------------------------------*/ -/*! r: error code */ -ivas_error IVAS_DEC_FeedCustomLsData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_CUSTOM_LS_DATA hLsCustomData /* i : Custom loudspeaker setup data */ -) -{ - int16_t i, is_planar; - IVAS_LSSETUP_CUSTOM_HANDLE hLsSetupCustom; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + /*! r: error code */ + ivas_error IVAS_DEC_FeedCustomLsData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_CUSTOM_LS_DATA hLsCustomData /* i : Custom loudspeaker setup data */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + int16_t i, is_planar; + IVAS_LSSETUP_CUSTOM_HANDLE hLsSetupCustom; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hLsSetupCustom = hIvasDec->st_ivas->hLsSetupCustom; + hLsSetupCustom = hIvasDec->st_ivas->hLsSetupCustom; - if ( hLsSetupCustom == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hLsSetupCustom == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - /* Move Custom LS layout data to the decoder handle */ + /* Move Custom LS layout data to the decoder handle */ - /* Loudspeaker azimuths and elevations */ - hLsSetupCustom->num_spk = hLsCustomData.num_spk; + /* Loudspeaker azimuths and elevations */ + hLsSetupCustom->num_spk = hLsCustomData.num_spk; - mvr2r( hLsCustomData.azimuth, hLsSetupCustom->ls_azimuth, hLsCustomData.num_spk ); - mvr2r( hLsCustomData.elevation, hLsSetupCustom->ls_elevation, hLsCustomData.num_spk ); + mvr2r( hLsCustomData.azimuth, hLsSetupCustom->ls_azimuth, hLsCustomData.num_spk ); + mvr2r( hLsCustomData.elevation, hLsSetupCustom->ls_elevation, hLsCustomData.num_spk ); - /* Set planar flag */ - is_planar = 1; - for ( i = 0; i < hLsCustomData.num_spk; i++ ) - { - if ( is_planar && hLsSetupCustom->ls_elevation[i] != 0.0f ) + /* Set planar flag */ + is_planar = 1; + for ( i = 0; i < hLsCustomData.num_spk; i++ ) { - is_planar = 0; + if ( is_planar && hLsSetupCustom->ls_elevation[i] != 0.0f ) + { + is_planar = 0; + } } - } - hLsSetupCustom->is_planar_setup = is_planar; + hLsSetupCustom->is_planar_setup = is_planar; - /* Loudspeaker LFE */ - hLsSetupCustom->num_lfe = hLsCustomData.num_lfe; - mvs2s( hLsCustomData.lfe_idx, hLsSetupCustom->lfe_idx, hLsCustomData.num_lfe ); + /* Loudspeaker LFE */ + hLsSetupCustom->num_lfe = hLsCustomData.num_lfe; + mvs2s( hLsCustomData.lfe_idx, hLsSetupCustom->lfe_idx, hLsCustomData.num_lfe ); - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfHandle( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetHrtfHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_HANDLE **hHrtfTD /* o : HRTF handle */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfTD == NULL ) + ivas_error IVAS_DEC_GetHrtfHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_HANDLE * *hHrtfTD /* o : HRTF handle */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfTD == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *hHrtfTD = &hIvasDec->st_ivas->hHrtfTD; + *hHrtfTD = &hIvasDec->st_ivas->hHrtfTD; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfCRendHandle( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetHrtfCRendHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_CREND_HANDLE **hSetOfHRTF /* o : Set of HRTF handle */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSetOfHRTF == NULL ) + ivas_error IVAS_DEC_GetHrtfCRendHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_CREND_HANDLE * *hSetOfHRTF /* o : Set of HRTF handle */ + ) { - return IVAS_ERR_WRONG_PARAMS; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSetOfHRTF == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } - *hSetOfHRTF = &hIvasDec->st_ivas->hSetOfHRTF; + *hSetOfHRTF = &hIvasDec->st_ivas->hSetOfHRTF; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfFastConvHandle( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetHrtfFastConvHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_FASTCONV_HANDLE **hHrtfFastConv /* o : FASTCONV HRTF handle */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfFastConv == NULL ) + ivas_error IVAS_DEC_GetHrtfFastConvHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_FASTCONV_HANDLE * *hHrtfFastConv /* o : FASTCONV HRTF handle */ + ) { - return IVAS_ERR_WRONG_PARAMS; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfFastConv == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } - *hHrtfFastConv = &hIvasDec->st_ivas->hHrtfFastConv; + *hHrtfFastConv = &hIvasDec->st_ivas->hHrtfFastConv; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfParamBinHandle( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetHrtfParamBinHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfParambin == NULL ) + ivas_error IVAS_DEC_GetHrtfParamBinHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_PARAMBIN_HANDLE * *hHrtfParambin /* o : Parametric binauralizer HRTF handle */ + ) { - return IVAS_ERR_WRONG_PARAMS; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfParambin == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } - *hHrtfParambin = &hIvasDec->st_ivas->hHrtfParambin; + *hHrtfParambin = &hIvasDec->st_ivas->hHrtfParambin; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfStatisticsHandle( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetHrtfStatisticsHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) + ivas_error IVAS_DEC_GetHrtfStatisticsHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE * *hHrtfStatistics /* o : HRTF statistics handle */ + ) { - return IVAS_ERR_WRONG_PARAMS; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } - *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; + *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * copyRendererConfigStruct( ) * * *---------------------------------------------------------------------*/ -static ivas_error copyRendererConfigStruct( - RENDER_CONFIG_HANDLE hRCin, - IVAS_RENDER_CONFIG_HANDLE hRCout ) -{ - if ( hRCin == NULL || hRCout == NULL ) + static ivas_error copyRendererConfigStruct( + RENDER_CONFIG_HANDLE hRCin, + IVAS_RENDER_CONFIG_HANDLE hRCout ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hRCin == NULL || hRCout == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } #ifdef DEBUGGING - switch ( hRCin->renderer_type_override ) - { - case IVAS_RENDER_TYPE_OVERRIDE_CREND: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; - break; - case IVAS_RENDER_TYPE_OVERRIDE_FASTCONV: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; - break; - default: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; - break; - } + switch ( hRCin->renderer_type_override ) + { + case IVAS_RENDER_TYPE_OVERRIDE_CREND: + hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; + break; + case IVAS_RENDER_TYPE_OVERRIDE_FASTCONV: + hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; + break; + default: + hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; + break; + } #endif - hRCout->roomAcoustics.override = hRCin->roomAcoustics.override; - hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; - hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; - hRCout->roomAcoustics.inputPreDelay = hRCin->roomAcoustics.inputPreDelay; + hRCout->roomAcoustics.override = hRCin->roomAcoustics.override; + hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; + hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; + hRCout->roomAcoustics.inputPreDelay = hRCin->roomAcoustics.inputPreDelay; - mvr2r( hRCin->roomAcoustics.pFc_input, hRCout->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); - mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); - mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); - mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); + mvr2r( hRCin->roomAcoustics.pFc_input, hRCout->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); + mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); + mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); + mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); #ifdef SPLIT_REND_WITH_HEAD_ROT - hRCout->split_rend_config = hRCin->split_rend_config; + hRCout->split_rend_config = hRCin->split_rend_config; #endif - hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; - hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; + hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; + hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetRenderConfig( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetRenderConfig( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL || hRCout == NULL ) + ivas_error IVAS_DEC_GetRenderConfig( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL || hRCout == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + return copyRendererConfigStruct( hIvasDec->st_ivas->hRenderConfig, hRCout ); } - return copyRendererConfigStruct( hIvasDec->st_ivas->hRenderConfig, hRCout ); -} + /*! r: error code*/ + ivas_error IVAS_DEC_GetDefaultRenderConfig( + IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ + ) + { + RENDER_CONFIG_DATA RCin; + RENDER_CONFIG_HANDLE hRCin = &RCin; + ivas_error error; -/*! r: error code*/ -ivas_error IVAS_DEC_GetDefaultRenderConfig( - IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ -) -{ - RENDER_CONFIG_DATA RCin; - RENDER_CONFIG_HANDLE hRCin = &RCin; - ivas_error error; + if ( ( error = ivas_render_config_init_from_rom( &hRCin ) ) != IVAS_ERR_OK ) + { + return error; + } - if ( ( error = ivas_render_config_init_from_rom( &hRCin ) ) != IVAS_ERR_OK ) - { - return error; + return copyRendererConfigStruct( hRCin, hRCout ); } - return copyRendererConfigStruct( hRCin, hRCout ); -} - -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_FeedRenderConfig( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_FeedRenderConfig( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ -) -{ - RENDER_CONFIG_HANDLE hRenderConfig; - ivas_error error; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) + ivas_error IVAS_DEC_FeedRenderConfig( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + RENDER_CONFIG_HANDLE hRenderConfig; + ivas_error error; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hRenderConfig = hIvasDec->st_ivas->hRenderConfig; + hRenderConfig = hIvasDec->st_ivas->hRenderConfig; #ifdef DEBUGGING - hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; - if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) - { - hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; - } - if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND ) - { - hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; - } + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; + if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) + { + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; + } + if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND ) + { + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; + } #endif - hRenderConfig->roomAcoustics.override = renderConfig.roomAcoustics.override; - hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; - hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay; - hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.roomAcoustics.inputPreDelay; + hRenderConfig->roomAcoustics.override = renderConfig.roomAcoustics.override; + hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; + hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay; + hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.roomAcoustics.inputPreDelay; - hRenderConfig->roomAcoustics.use_er = 0; - if ( renderConfig.roomAcoustics.use_er == 1 ) - { - hRenderConfig->roomAcoustics.use_er = renderConfig.roomAcoustics.use_er; - hRenderConfig->roomAcoustics.lowComplexity = renderConfig.roomAcoustics.lowComplexity; - hRenderConfig->roomAcoustics.dimensions = renderConfig.roomAcoustics.dimensions; - hRenderConfig->roomAcoustics.ListenerOrigin = renderConfig.roomAcoustics.ListenerOrigin; + hRenderConfig->roomAcoustics.use_er = 0; + if ( renderConfig.roomAcoustics.use_er == 1 ) + { + hRenderConfig->roomAcoustics.use_er = renderConfig.roomAcoustics.use_er; + hRenderConfig->roomAcoustics.lowComplexity = renderConfig.roomAcoustics.lowComplexity; + hRenderConfig->roomAcoustics.dimensions = renderConfig.roomAcoustics.dimensions; + hRenderConfig->roomAcoustics.ListenerOrigin = renderConfig.roomAcoustics.ListenerOrigin; - mvr2r( renderConfig.roomAcoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); - } + mvr2r( renderConfig.roomAcoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); + } - mvr2r( renderConfig.roomAcoustics.pFc_input, hRenderConfig->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); - mvr2r( renderConfig.roomAcoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); - mvr2r( renderConfig.roomAcoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); + mvr2r( renderConfig.roomAcoustics.pFc_input, hRenderConfig->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); + mvr2r( renderConfig.roomAcoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); + mvr2r( renderConfig.roomAcoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); - /* Re-initialize reverb instance if already available */ + /* Re-initialize reverb instance if already available */ #ifdef SPLIT_REND_WITH_HEAD_ROT - /* TD renderer Jot reverberator */ - if ( hIvasDec->st_ivas->hReverb != NULL ) - { - if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + /* TD renderer Jot reverberator */ + if ( hIvasDec->st_ivas->hReverb != NULL ) { - return error; + if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - /* CREND Jot reverberator */ - if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0] != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) - { - if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + /* CREND Jot reverberator */ + if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0] != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) { - return error; + if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - /* FB reverberator */ - if ( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL ) - { - ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) ); - if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) + /* FB reverberator */ + if ( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL ) { - return error; + ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) ); + if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } } - } #else /* TD renderer Jot reverberator */ if ( hIvasDec->st_ivas->hReverb != NULL ) @@ -2665,265 +2686,242 @@ ivas_error IVAS_DEC_FeedRenderConfig( } } #endif - /* Fastconv CLDFB reverberator */ - if ( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL ) - { - ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) ); - if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hBinRenderer->conv_band, hIvasDec->st_ivas->hBinRenderer->timeSlots, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) + /* Fastconv CLDFB reverberator */ + if ( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL ) { - return error; + ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) ); + if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hBinRenderer->conv_band, hIvasDec->st_ivas->hBinRenderer->timeSlots, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); - mvr2r( renderConfig.distAtt, hRenderConfig->distAtt, 3 ); + mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); + mvr2r( renderConfig.distAtt, hRenderConfig->distAtt, 3 ); #ifdef SPLIT_REND_WITH_HEAD_ROT - hRenderConfig->split_rend_config = renderConfig.split_rend_config; + hRenderConfig->split_rend_config = renderConfig.split_rend_config; - /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ - if ( hRenderConfig->split_rend_config.dof == 0 ) - { - hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; - } + /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ + if ( hRenderConfig->split_rend_config.dof == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } - if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + { + return error; + } #endif - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetDelay( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetDelay( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *nSamples, /* o : decoder delay in samples */ - int32_t *timeScale /* o : time scale of the delay, equal to decoder output sampling rate */ -) -{ - Decoder_Struct *st_ivas; - DECODER_CONFIG_HANDLE hDecoderConfig; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || nSamples == NULL || timeScale == NULL ) + ivas_error IVAS_DEC_GetDelay( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t * nSamples, /* o : decoder delay in samples */ + int32_t * timeScale /* o : time scale of the delay, equal to decoder output sampling rate */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + Decoder_Struct *st_ivas; + DECODER_CONFIG_HANDLE hDecoderConfig; - if ( !hIvasDec->hasDecodedFirstGoodFrame ) - { - /* Delay depends on IVAS format, which is unknown until first frame has been decoded */ - return IVAS_ERR_WAITING_FOR_BITSTREAM; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || nSamples == NULL || timeScale == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - st_ivas = hIvasDec->st_ivas; - hDecoderConfig = st_ivas->hDecoderConfig; + if ( !hIvasDec->hasDecodedFirstGoodFrame ) + { + /* Delay depends on IVAS format, which is unknown until first frame has been decoded */ + return IVAS_ERR_WAITING_FOR_BITSTREAM; + } + + st_ivas = hIvasDec->st_ivas; + hDecoderConfig = st_ivas->hDecoderConfig; #ifdef SPLIT_REND_WITH_HEAD_ROT - nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ); + nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ); #else nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0] ) ); #endif - nSamples[2] = (int16_t) roundf( (float) st_ivas->binaural_latency_ns * hDecoderConfig->output_Fs / 1000000000.f ); - nSamples[0] = nSamples[1] + nSamples[2]; + nSamples[2] = (int16_t) roundf( (float) st_ivas->binaural_latency_ns * hDecoderConfig->output_Fs / 1000000000.f ); + nSamples[0] = nSamples[1] + nSamples[2]; - if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - /* note: in MASA, all delay is compensated at the decoder by default, so subtract the encoder delay for print-out */ - nSamples[1] -= NS2SA( hDecoderConfig->output_Fs, IVAS_ENC_DELAY_NS ); - } + if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + /* note: in MASA, all delay is compensated at the decoder by default, so subtract the encoder delay for print-out */ + nSamples[1] -= NS2SA( hDecoderConfig->output_Fs, IVAS_ENC_DELAY_NS ); + } - *timeScale = hDecoderConfig->output_Fs; + *timeScale = hDecoderConfig->output_Fs; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_HasDecodedFirstGoodFrame( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - bool *hasDecodedFirstGoodFrame /* o : flag indicating if the decoder has decoded a good frame since it was configured */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hasDecodedFirstGoodFrame == NULL ) + ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + bool *hasDecodedFirstGoodFrame /* o : flag indicating if the decoder has decoded a good frame since it was configured */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hasDecodedFirstGoodFrame == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *hasDecodedFirstGoodFrame = hIvasDec->hasDecodedFirstGoodFrame; + *hasDecodedFirstGoodFrame = hIvasDec->hasDecodedFirstGoodFrame; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetPcmFrameSize( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetPcmFrameSize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int32_t *pcmFrameSize /* o : total size of the PCM output frame. This takes into account the number of output channels */ -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || pcmFrameSize == NULL ) + ivas_error IVAS_DEC_GetPcmFrameSize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int32_t * pcmFrameSize /* o : total size of the PCM output frame. This takes into account the number of output channels */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || pcmFrameSize == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - if ( hIvasDec->hasDecodedFirstGoodFrame ) - { - *pcmFrameSize = hIvasDec->st_ivas->hDecoderConfig->nchan_out * hIvasDec->st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC; - } - else - { - *pcmFrameSize = 0; - } + if ( hIvasDec->hasDecodedFirstGoodFrame ) + { + *pcmFrameSize = hIvasDec->st_ivas->hDecoderConfig->nchan_out * hIvasDec->st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC; + } + else + { + *pcmFrameSize = 0; + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * isSidFrame( ) * * Check if a frame contains a SID *---------------------------------------------------------------------*/ -static bool isSidFrame( - const uint16_t size ) -{ - if ( size == SID_1k75 / FRAMES_PER_SEC ) - { - return true; /* AMR-WB SID */ - } - else if ( size == SID_2k40 / FRAMES_PER_SEC ) - { - return true; /* EVS SID */ - } - else if ( size == IVAS_SID_5k2 / FRAMES_PER_SEC ) + static bool isSidFrame( + const uint16_t size ) { - return true; /* IVAS SID */ - } + if ( size == SID_1k75 / FRAMES_PER_SEC ) + { + return true; /* AMR-WB SID */ + } + else if ( size == SID_2k40 / FRAMES_PER_SEC ) + { + return true; /* EVS SID */ + } + else if ( size == IVAS_SID_5k2 / FRAMES_PER_SEC ) + { + return true; /* IVAS SID */ + } - return false; -} + return false; + } -static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, uint16_t num_bits ) -{ + static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, uint16_t num_bits ) + { /* Bitstream conversion is not counted towards complexity and memory usage */ #define WMC_TOOL_SKIP - uint32_t i; - uint8_t byte = 0; - const uint8_t mask = 0x80; + uint32_t i; + uint8_t byte = 0; + const uint8_t mask = 0x80; - for ( i = 0; i < num_bits; ++i ) - { - if ( i % 8 == 0 ) + for ( i = 0; i < num_bits; ++i ) { - byte = compact[i / 8]; - } + if ( i % 8 == 0 ) + { + byte = compact[i / 8]; + } - serial[i] = ( byte & mask ) >> 7; + serial[i] = ( byte & mask ) >> 7; - byte <<= 1; - } + byte <<= 1; + } - /* Add 4 padding bytes required by core coder */ - for ( i = 0; i < 4 * 8; ++i ) - { - serial[num_bits + i] = 0; - } + /* Add 4 padding bytes required by core coder */ + for ( i = 0; i < 4 * 8; ++i ) + { + serial[num_bits + i] = 0; + } #undef WMC_TOOL_SKIP -} + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_FeedFrame( ) * * Feed RTP packet into internal jitter buffer *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_VoIP_FeedFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint8_t *au, /* i : buffer containing input access unit */ - const uint16_t auSize, /* i : size of the access unit */ - const uint16_t rtpSequenceNumber, /* i : RTP sequence number (16 bits) */ - const uint32_t rtpTimeStamp, /* i : RTP timestamp (32 bits) */ - const uint32_t rcvTime_ms, /* i : receive time of the RTP packet in milliseconds */ - const bool qBit /* i : Q bit for AMR-WB IO */ -) -{ - JB4_DATAUNIT_HANDLE dataUnit; - int16_t partialCopyFrameType, partialCopyOffset; - int16_t result; - - if ( auSize == 0 ) - { - return IVAS_ERR_OK; /* ignore empty/NO_DATA frame - shouldn't be transmitted in RTP */ - } - if ( ( auSize + 7 ) / 8 > MAX_AU_SIZE ) - { - return IVAS_ERR_INVALID_BITSTREAM; - } - - partialCopyFrameType = 0; - partialCopyOffset = 0; - - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) - { - /* check if frame contains a partial copy and get its offset */ - evs_dec_previewFrame( au, auSize, &partialCopyFrameType, &partialCopyOffset ); - } + ivas_error IVAS_DEC_VoIP_FeedFrame( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint8_t * au, /* i : buffer containing input access unit */ + const uint16_t auSize, /* i : size of the access unit */ + const uint16_t rtpSequenceNumber, /* i : RTP sequence number (16 bits) */ + const uint32_t rtpTimeStamp, /* i : RTP timestamp (32 bits) */ + const uint32_t rcvTime_ms, /* i : receive time of the RTP packet in milliseconds */ + const bool qBit /* i : Q bit for AMR-WB IO */ + ) + { + JB4_DATAUNIT_HANDLE dataUnit; + int16_t partialCopyFrameType, partialCopyOffset; + int16_t result; + + if ( auSize == 0 ) + { + return IVAS_ERR_OK; /* ignore empty/NO_DATA frame - shouldn't be transmitted in RTP */ + } + if ( ( auSize + 7 ) / 8 > MAX_AU_SIZE ) + { + return IVAS_ERR_INVALID_BITSTREAM; + } - /* create data unit for primary copy in the frame */ - dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); - dataUnit->dataSize = auSize; - dataUnit->duration = 20; - dataUnit->sequenceNumber = rtpSequenceNumber; - dataUnit->silenceIndicator = isSidFrame( dataUnit->dataSize ); - dataUnit->timeScale = 1000; - dataUnit->rcvTime = rcvTime_ms; - dataUnit->timeStamp = rtpTimeStamp; - dataUnit->partial_frame = 0; - dataUnit->partialCopyOffset = partialCopyOffset; - dataUnit->qBit = qBit; + partialCopyFrameType = 0; + partialCopyOffset = 0; - /* add the frame to the JBM */ - result = JB4_PushDataUnit( hIvasDec->hVoIP->hJBM, dataUnit, rcvTime_ms ); - if ( result != 0 ) - { - return IVAS_ERR_UNKNOWN; - } + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + { + /* check if frame contains a partial copy and get its offset */ + evs_dec_previewFrame( au, auSize, &partialCopyFrameType, &partialCopyOffset ); + } - if ( partialCopyFrameType != RF_NO_DATA && partialCopyOffset != 0 ) - { - /* create data unit for partial copy in the frame */ + /* create data unit for primary copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; - dataUnit->silenceIndicator = 0; /* there are no partial copies for SID frames */ + dataUnit->silenceIndicator = isSidFrame( dataUnit->dataSize ); dataUnit->timeScale = 1000; dataUnit->rcvTime = rcvTime_ms; - dataUnit->timeStamp = rtpTimeStamp - partialCopyOffset * dataUnit->duration; - dataUnit->partial_frame = 1; + dataUnit->timeStamp = rtpTimeStamp; + dataUnit->partial_frame = 0; dataUnit->partialCopyOffset = partialCopyOffset; dataUnit->qBit = qBit; @@ -2933,266 +2931,289 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( { return IVAS_ERR_UNKNOWN; } - } - return IVAS_ERR_OK; -} + if ( partialCopyFrameType != RF_NO_DATA && partialCopyOffset != 0 ) + { + /* create data unit for partial copy in the frame */ + dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); + mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); + dataUnit->dataSize = auSize; + dataUnit->duration = 20; + dataUnit->sequenceNumber = rtpSequenceNumber; + dataUnit->silenceIndicator = 0; /* there are no partial copies for SID frames */ + dataUnit->timeScale = 1000; + dataUnit->rcvTime = rcvTime_ms; + dataUnit->timeStamp = rtpTimeStamp - partialCopyOffset * dataUnit->duration; + dataUnit->partial_frame = 1; + dataUnit->partialCopyOffset = partialCopyOffset; + dataUnit->qBit = qBit; + + /* add the frame to the JBM */ + result = JB4_PushDataUnit( hIvasDec->hVoIP->hJBM, dataUnit, rcvTime_ms ); + if ( result != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } -/*---------------------------------------------------------------------* + return IVAS_ERR_OK; + } + + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_SetScale( ) * * Set the TSM scale *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_VoIP_SetScale( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t maxScaling, /* i : max allowed absolute difference in samples from the default 20ms frame size */ - const int16_t scale /* i : TSM scale to set in percent of the default frame size */ -) -{ - ivas_error error; + ivas_error IVAS_DEC_VoIP_SetScale( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t maxScaling, /* i : max allowed absolute difference in samples from the default 20ms frame size */ + const int16_t scale /* i : TSM scale to set in percent of the default frame size */ + ) + { + ivas_error error; - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) - { - return IVAS_ERR_TSM_NOT_ENABLED; - } - else - { - hIvasDec->tsm_scale = scale; - hIvasDec->tsm_max_scaling = maxScaling; - } + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) + { + return IVAS_ERR_TSM_NOT_ENABLED; + } + else + { + hIvasDec->tsm_scale = scale; + hIvasDec->tsm_max_scaling = maxScaling; + } - return error; -} + return error; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_SetScale( ) * * Set the TSM scale *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_TSM_SetQuality( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const float quality /* i : target TSM quality */ -) -{ - ivas_error error; + ivas_error IVAS_DEC_TSM_SetQuality( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const float quality /* i : target TSM quality */ + ) + { + ivas_error error; - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) - { - return IVAS_ERR_TSM_NOT_ENABLED; - } - else - { - hIvasDec->tsm_quality = quality; - } + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) + { + return IVAS_ERR_TSM_NOT_ENABLED; + } + else + { + hIvasDec->tsm_quality = quality; + } - return error; -} + return error; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) * * Main function to decode one frame in VoIP *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + ivas_error IVAS_DEC_VoIP_GetSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif - const uint32_t systemTimestamp_ms /* i : current system timestamp */ + const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE - , - JbmTraceFileWriterFn jbmWriterFn, - void *jbmWriter + , + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter #endif #ifdef OBJ_EDITING_API - , - uint16_t *nSamplesRendered, - bool *parametersAvailableForEditing + , + uint16_t *nSamplesRendered, + bool *parametersAvailableForEditing #endif -) -{ - Decoder_Struct *st_ivas; - DECODER_CONFIG_HANDLE hDecoderConfig; - IVAS_DEC_VOIP *hVoIP; - uint32_t extBufferedTime_ms, scale, maxScaling; - JB4_DATAUNIT_HANDLE dataUnit; - uint16_t extBufferedSamples; - int16_t result; - ivas_error error; + ) + { + Decoder_Struct *st_ivas; + DECODER_CONFIG_HANDLE hDecoderConfig; + IVAS_DEC_VOIP *hVoIP; + uint32_t extBufferedTime_ms, scale, maxScaling; + JB4_DATAUNIT_HANDLE dataUnit; + uint16_t extBufferedSamples; + int16_t result; + ivas_error error; #ifndef OBJ_EDITING_API - int16_t nSamplesRendered; + int16_t nSamplesRendered; #endif - uint8_t nOutChannels; + uint8_t nOutChannels; - st_ivas = hIvasDec->st_ivas; - hDecoderConfig = st_ivas->hDecoderConfig; - hVoIP = hIvasDec->hVoIP; - nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; + st_ivas = hIvasDec->st_ivas; + hDecoderConfig = st_ivas->hDecoderConfig; + hVoIP = hIvasDec->hVoIP; + nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; #ifndef OBJ_EDITING_API - nSamplesRendered = 0; + nSamplesRendered = 0; #endif #ifdef OBJ_EDITING_API - *parametersAvailableForEditing = false; + *parametersAvailableForEditing = false; #endif - if ( nSamplesPerChannel == 0 ) - { - return IVAS_ERR_WRONG_PARAMS; - } + if ( nSamplesPerChannel == 0 ) + { + return IVAS_ERR_WRONG_PARAMS; + } - /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ + /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ #ifdef OBJ_EDITING_API - while ( *nSamplesRendered < nSamplesPerChannel ) + while ( *nSamplesRendered < nSamplesPerChannel ) #else while ( nSamplesRendered < nSamplesPerChannel ) #endif - { - if ( hIvasDec->nSamplesAvailableNext == 0 ) { - int16_t nSamplesBuffered; - nSamplesBuffered = 0; - if ( hIvasDec->hasBeenFedFirstGoodFrame ) + if ( hIvasDec->nSamplesAvailableNext == 0 ) { - if ( ( error = IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ) ) != IVAS_ERR_OK ) + int16_t nSamplesBuffered; + nSamplesBuffered = 0; + if ( hIvasDec->hasBeenFedFirstGoodFrame ) { - return error; + if ( ( error = IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - extBufferedSamples = nSamplesBuffered; - extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; - dataUnit = NULL; + extBufferedSamples = nSamplesBuffered; + extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; + dataUnit = NULL; - /* pop one access unit from the jitter buffer */ - result = JB4_PopDataUnit( hVoIP->hJBM, systemTimestamp_ms, extBufferedTime_ms, &dataUnit, &scale, &maxScaling ); - if ( result != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - maxScaling = maxScaling * hDecoderConfig->output_Fs / 1000; + /* pop one access unit from the jitter buffer */ + result = JB4_PopDataUnit( hVoIP->hJBM, systemTimestamp_ms, extBufferedTime_ms, &dataUnit, &scale, &maxScaling ); + if ( result != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + maxScaling = maxScaling * hDecoderConfig->output_Fs / 1000; #ifdef DEBUG_MODE_JBM - dbgwrite( &extBufferedSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_extBufferedSamples.dat" ); - dbgwrite( &systemTimestamp_ms, sizeof( uint32_t ), 1, 1, "./res/JBM_systemTimestamp.dat" ); - dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); - dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); + dbgwrite( &extBufferedSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_extBufferedSamples.dat" ); + dbgwrite( &systemTimestamp_ms, sizeof( uint32_t ), 1, 1, "./res/JBM_systemTimestamp.dat" ); + dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); + dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif - /* avoid time scaling multiple times within one 20ms frame*/ - if ( scale != 100U ) - { - if ( hIvasDec->timeScalingDone ) + /* avoid time scaling multiple times within one 20ms frame*/ + if ( scale != 100U ) { - scale = 100; + if ( hIvasDec->timeScalingDone ) + { + scale = 100; + } } - } - /* limit scale to range supported by time scaler */ - if ( scale < APA_MIN_SCALE ) - { - scale = APA_MIN_SCALE; - } - else if ( scale > APA_MAX_SCALE ) - { - scale = APA_MAX_SCALE; - } + /* limit scale to range supported by time scaler */ + if ( scale < APA_MIN_SCALE ) + { + scale = APA_MIN_SCALE; + } + else if ( scale > APA_MAX_SCALE ) + { + scale = APA_MAX_SCALE; + } - if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (int16_t) maxScaling, (int16_t) scale ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (int16_t) maxScaling, (int16_t) scale ) ) != IVAS_ERR_OK ) + { + return error; + } - /* copy bitstream into decoder state */ - if ( dataUnit ) - { - hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; + /* copy bitstream into decoder state */ + if ( dataUnit ) + { + hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; - bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); + bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ) != IVAS_ERR_OK ) - { - return error; + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else if ( hIvasDec->hasDecodedFirstGoodFrame ) - { - /* Decoder has been initialized with first good frame - do PLC */ - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ) != IVAS_ERR_OK ) + else if ( hIvasDec->hasDecodedFirstGoodFrame ) { - return error; + /* Decoder has been initialized with first good frame - do PLC */ + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } } - } #ifdef SUPPORT_JBM_TRACEFILE - /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ - if ( jbmWriterFn != NULL && jbmWriter != NULL ) - { - /* write JBM trace data entry */ - store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); - if ( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) + /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ + if ( jbmWriterFn != NULL && jbmWriter != NULL ) { - fprintf( stderr, "\nError writing JBM Trace data to file\n" ); - return IVAS_ERR_UNKNOWN; + /* write JBM trace data entry */ + store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); + if ( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing JBM Trace data to file\n" ); + return IVAS_ERR_UNKNOWN; + } } - } #endif - if ( dataUnit ) - { - if ( dataUnit->partial_frame != 0 ) + if ( dataUnit ) + { + if ( dataUnit->partial_frame != 0 ) + { + hVoIP->lastDecodedWasActive = 1; + } + else + { + hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; + } + + /* data unit memory is no longer used */ + JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); + } + + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { - hVoIP->lastDecodedWasActive = 1; + hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; + hIvasDec->nSamplesRendered = 0; } - else +#ifdef OBJ_EDITING_API + /* :TODO: only return here if we really have editing initialized */ + if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) { - hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; + *parametersAvailableForEditing = true; + return IVAS_ERR_OK; } - - /* data unit memory is no longer used */ - JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); +#endif } + /* decode */ if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { - hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; - hIvasDec->nSamplesRendered = 0; - } -#ifdef OBJ_EDITING_API - /* :TODO: only return here if we really have editing initialized */ - if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) - { - *parametersAvailableForEditing = true; - return IVAS_ERR_OK; - } -#endif - } - - /* decode */ - if ( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - /* codec mode to use not known yet - simply output silence */ - /* directly set output zero */ - int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); + /* codec mode to use not known yet - simply output silence */ + /* directly set output zero */ + int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); #ifdef OBJ_EDITING_API #ifdef SPLIT_REND_WITH_HEAD_ROT - set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); + set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); #else - set_s( pcmBuf + ( *nSamplesRendered ) * nOutChannels, 0, nSamplesToZero * nOutChannels ); + set_s( pcmBuf + ( *nSamplesRendered ) * nOutChannels, 0, nSamplesToZero * nOutChannels ); #endif - *nSamplesRendered += nSamplesToZero; + *nSamplesRendered += nSamplesToZero; #else #ifdef SPLIT_REND_WITH_HEAD_ROT set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); @@ -3201,44 +3222,44 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif nSamplesRendered += nSamplesToZero; #endif - hIvasDec->nSamplesRendered += nSamplesToZero; - hIvasDec->nSamplesAvailableNext -= nSamplesToZero; - update_voip_rendered20ms( hIvasDec, nSamplesToZero ); - } - else - { - int16_t nSamplesToRender, nSamplesRendered_loop; - bool tmp; + hIvasDec->nSamplesRendered += nSamplesToZero; + hIvasDec->nSamplesAvailableNext -= nSamplesToZero; + update_voip_rendered20ms( hIvasDec, nSamplesToZero ); + } + else + { + int16_t nSamplesToRender, nSamplesRendered_loop; + bool tmp; #ifdef OBJ_EDITING_API - nSamplesToRender = nSamplesPerChannel - *nSamplesRendered; + nSamplesToRender = nSamplesPerChannel - *nSamplesRendered; #else nSamplesToRender = nSamplesPerChannel - nSamplesRendered; #endif #ifdef OBJ_EDITING_API - /* check if we still need to prepare the renderer */ - if ( hIvasDec->hasBeenPreparedRendering == false ) - { - - if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) + /* check if we still need to prepare the renderer */ + if ( hIvasDec->hasBeenPreparedRendering == false ) { - return error; + + if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) + { + return error; + } } - } #endif - /* render IVAS frames directly to the output buffer */ + /* render IVAS frames directly to the output buffer */ #ifdef OBJ_EDITING_API #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + *nSamplesRendered * nOutChannels, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + *nSamplesRendered * nOutChannels, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #endif - { - return error; - } + { + return error; + } - *nSamplesRendered += nSamplesRendered_loop; + *nSamplesRendered += nSamplesRendered_loop; #else #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) @@ -3251,1475 +3272,1475 @@ ivas_error IVAS_DEC_VoIP_GetSamples( nSamplesRendered += nSamplesRendered_loop; #endif - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); + } } - } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * * Function to flush remaining audio in VoIP *---------------------------------------------------------------------*/ -static void update_voip_rendered20ms( - IVAS_DEC_HANDLE hIvasDec, - const int16_t nSamplesRendered ) -{ - int16_t nSamplesRenderedTotal; - nSamplesRenderedTotal = hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered; - /* we have crossed a 20ms border, reset the time scaling done flag */ - if ( nSamplesRenderedTotal >= hIvasDec->hVoIP->nSamplesFrame ) + static void update_voip_rendered20ms( + IVAS_DEC_HANDLE hIvasDec, + const int16_t nSamplesRendered ) { - hIvasDec->timeScalingDone = 0; + int16_t nSamplesRenderedTotal; + nSamplesRenderedTotal = hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered; + /* we have crossed a 20ms border, reset the time scaling done flag */ + if ( nSamplesRenderedTotal >= hIvasDec->hVoIP->nSamplesFrame ) + { + hIvasDec->timeScalingDone = 0; + } + hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; } - hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; -} -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) * * Function to flush remaining audio in VoIP *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_Flush( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + ivas_error IVAS_DEC_Flush( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif - int16_t *nSamplesFlushed /* o : number of samples flushed */ -) -{ - ivas_error error; - uint16_t nSamplesToRender; - uint16_t nSamplesFlushedLocal; + int16_t *nSamplesFlushed /* o : number of samples flushed */ + ) + { + ivas_error error; + uint16_t nSamplesToRender; + uint16_t nSamplesFlushedLocal; - *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); + *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); - nSamplesToRender = (uint16_t) *nSamplesFlushed; + nSamplesToRender = (uint16_t) *nSamplesFlushed; - /* render IVAS frames */ - error = IVAS_ERR_OK; - if ( nSamplesToRender > 0 && hIvasDec->st_ivas->ivas_format != MONO_FORMAT ) - { + /* render IVAS frames */ + error = IVAS_ERR_OK; + if ( nSamplesToRender > 0 && hIvasDec->st_ivas->ivas_format != MONO_FORMAT ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT - error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); + error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); #else error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); #endif + } + else + { + *nSamplesFlushed = 0; + } + return error; } - else - { - *nSamplesFlushed = 0; - } - return error; -} -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_IsEmpty( ) * * *---------------------------------------------------------------------*/ -bool IVAS_DEC_VoIP_IsEmpty( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked ) -{ - return ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && ( hIvasDec->nSamplesAvailableNext < nSamplesAsked ) ); -} + bool IVAS_DEC_VoIP_IsEmpty( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked ) + { + return ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && ( hIvasDec->nSamplesAvailableNext < nSamplesAsked ) ); + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Get_CA_offset( ) * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_VoIP_Get_CA_offset( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *optimum_offset, - int16_t *FEC_hi ) -{ - if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || hIvasDec->hVoIP->hJBM == NULL ) + ivas_error IVAS_DEC_VoIP_Get_CA_offset( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t * optimum_offset, + int16_t * FEC_hi ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || hIvasDec->hVoIP->hJBM == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *optimum_offset = JB4_getFECoffset( hIvasDec->hVoIP->hJBM ); - *FEC_hi = JB4_FECoffset( hIvasDec->hVoIP->hJBM ); + *optimum_offset = JB4_getFECoffset( hIvasDec->hVoIP->hJBM ); + *FEC_hi = JB4_FECoffset( hIvasDec->hVoIP->hJBM ); - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_Close_VoIP( ) * * *---------------------------------------------------------------------*/ -static void IVAS_DEC_Close_VoIP( - IVAS_DEC_VOIP *hVoIP /* i/o: IVAS decoder handle */ -) -{ - JB4_Destroy( &hVoIP->hJBM ); - - if ( hVoIP->bs_conversion_buf != NULL ) + static void IVAS_DEC_Close_VoIP( + IVAS_DEC_VOIP * hVoIP /* i/o: IVAS decoder handle */ + ) { + JB4_Destroy( &hVoIP->hJBM ); + + if ( hVoIP->bs_conversion_buf != NULL ) + { #define WMC_TOOL_SKIP - /* Bitstream conversion is not counted towards complexity and memory usage */ - free( hVoIP->bs_conversion_buf ); + /* Bitstream conversion is not counted towards complexity and memory usage */ + free( hVoIP->bs_conversion_buf ); #undef WMC_TOOL_SKIP - } + } - free( hVoIP ); + free( hVoIP ); - return; -} + return; + } #ifdef SUPPORT_JBM_TRACEFILE -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * store_JbmData() * * Store JBM trace data entry *---------------------------------------------------------------------*/ -static void store_JbmData( - IVAS_DEC_VOIP *hVoIP, - JB4_DATAUNIT_HANDLE dataUnit, - const uint32_t systemTimestamp_ms, - const uint16_t extBufferedSamples, - const int32_t output_Fs ) -{ - IVAS_JBM_TRACE_DATA *JbmTraceData; - - if ( hVoIP == NULL ) + static void store_JbmData( + IVAS_DEC_VOIP * hVoIP, + JB4_DATAUNIT_HANDLE dataUnit, + const uint32_t systemTimestamp_ms, + const uint16_t extBufferedSamples, + const int32_t output_Fs ) { - return; - } + IVAS_JBM_TRACE_DATA *JbmTraceData; - JbmTraceData = &hVoIP->JbmTraceData; + if ( hVoIP == NULL ) + { + return; + } - JbmTraceData->systemTimestamp_ms = systemTimestamp_ms; - JbmTraceData->extBufferedSamples = extBufferedSamples; - JbmTraceData->lastDecodedWasActive = hVoIP->lastDecodedWasActive; - JbmTraceData->output_Fs = output_Fs; - JbmTraceData->dataUnit_flag = dataUnit != NULL; - if ( dataUnit != NULL ) - { - JbmTraceData->sequenceNumber = dataUnit->sequenceNumber; - JbmTraceData->timeStamp = dataUnit->timeStamp; - JbmTraceData->rcvTime = dataUnit->rcvTime; - JbmTraceData->partial_frame = dataUnit->partial_frame; - JbmTraceData->partialCopyOffset = dataUnit->partialCopyOffset; - } + JbmTraceData = &hVoIP->JbmTraceData; - return; -} + JbmTraceData->systemTimestamp_ms = systemTimestamp_ms; + JbmTraceData->extBufferedSamples = extBufferedSamples; + JbmTraceData->lastDecodedWasActive = hVoIP->lastDecodedWasActive; + JbmTraceData->output_Fs = output_Fs; + JbmTraceData->dataUnit_flag = dataUnit != NULL; + if ( dataUnit != NULL ) + { + JbmTraceData->sequenceNumber = dataUnit->sequenceNumber; + JbmTraceData->timeStamp = dataUnit->timeStamp; + JbmTraceData->rcvTime = dataUnit->rcvTime; + JbmTraceData->partial_frame = dataUnit->partial_frame; + JbmTraceData->partialCopyOffset = dataUnit->partialCopyOffset; + } + return; + } -/*---------------------------------------------------------------------* + + /*---------------------------------------------------------------------* * IVAS_DEC_GetJbmData() * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetJbmData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_JBM_TRACE_DATA *JbmTraceData /* o : JBM Trace data */ + ivas_error IVAS_DEC_GetJbmData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_JBM_TRACE_DATA * JbmTraceData /* o : JBM Trace data */ -) -{ - if ( hIvasDec->hVoIP == NULL ) + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec->hVoIP == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *JbmTraceData = hIvasDec->hVoIP->JbmTraceData; + *JbmTraceData = hIvasDec->hVoIP->JbmTraceData; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } #endif -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetErrorMessage( ) * * Maps error codes to error description strings *---------------------------------------------------------------------*/ -const char *IVAS_DEC_GetErrorMessage( - ivas_error error /* i : decoder error code enum */ -) -{ - return ivas_error_to_string( error ); -} + const char *IVAS_DEC_GetErrorMessage( + ivas_error error /* i : decoder error code enum */ + ) + { + return ivas_error_to_string( error ); + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * get_channel_config() * * Gets a str related to input config *---------------------------------------------------------------------*/ -static ivas_error get_channel_config( - AUDIO_CONFIG config, - char *str ) -{ - if ( config == IVAS_AUDIO_CONFIG_MONO ) - { - strcpy( str, "Mono" ); - } - else if ( config == IVAS_AUDIO_CONFIG_STEREO ) + static ivas_error get_channel_config( + AUDIO_CONFIG config, + char *str ) { - strcpy( str, "Stereo" ); - } - else if ( config == IVAS_AUDIO_CONFIG_5_1 ) - { - strcpy( str, "Multichannel 5.1 (CICP6)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_7_1 ) - { - strcpy( str, "Multichannel 7.1 (CICP12)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_5_1_2 ) - { - strcpy( str, "Multichannel 5.1+2 (CICP14)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_5_1_4 ) - { - strcpy( str, "Multichannel 5.1+4 (CICP16)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_7_1_4 ) - { - strcpy( str, "Multichannel 7.1+4 (CICP19)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) - { - strcpy( str, "Multichannel (custom loudspeaker layout)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_FOA ) - { - strcpy( str, "Ambisonics: First Order (FOA)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_HOA2 ) - { - strcpy( str, "Ambisonics: Second Order (HOA2)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_HOA3 ) - { - strcpy( str, "Ambisonics: Third Order (HOA3)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL ) - { - strcpy( str, "Binaural: no room" ); - } - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - strcpy( str, "Binaural: room with impulse responses" ); - } - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - strcpy( str, "Binaural: room with reverb" ); - } + if ( config == IVAS_AUDIO_CONFIG_MONO ) + { + strcpy( str, "Mono" ); + } + else if ( config == IVAS_AUDIO_CONFIG_STEREO ) + { + strcpy( str, "Stereo" ); + } + else if ( config == IVAS_AUDIO_CONFIG_5_1 ) + { + strcpy( str, "Multichannel 5.1 (CICP6)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_7_1 ) + { + strcpy( str, "Multichannel 7.1 (CICP12)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_5_1_2 ) + { + strcpy( str, "Multichannel 5.1+2 (CICP14)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_5_1_4 ) + { + strcpy( str, "Multichannel 5.1+4 (CICP16)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_7_1_4 ) + { + strcpy( str, "Multichannel 7.1+4 (CICP19)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + strcpy( str, "Multichannel (custom loudspeaker layout)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_FOA ) + { + strcpy( str, "Ambisonics: First Order (FOA)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_HOA2 ) + { + strcpy( str, "Ambisonics: Second Order (HOA2)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_HOA3 ) + { + strcpy( str, "Ambisonics: Third Order (HOA3)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL ) + { + strcpy( str, "Binaural: no room" ); + } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + strcpy( str, "Binaural: room with impulse responses" ); + } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + strcpy( str, "Binaural: room with reverb" ); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) - { - strcpy( str, "BINAURAL_SPLIT_CODED" ); - } - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - strcpy( str, "Binaural_Split_PCM" ); - } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + strcpy( str, "BINAURAL_SPLIT_CODED" ); + } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + strcpy( str, "Binaural_Split_PCM" ); + } #endif - else if ( config == IVAS_AUDIO_CONFIG_EXTERNAL ) - { - strcpy( str, "External renderer" ); - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Incorrect Input/Output Configuration" ); - } + else if ( config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + strcpy( str, "External renderer" ); + } + else + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Incorrect Input/Output Configuration" ); + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * printConfigInfo_dec( ) * * *---------------------------------------------------------------------*/ -static ivas_error printConfigInfo_dec( - Decoder_Struct *st_ivas, - const int16_t bitstreamformat, - const bool Opt_VOIP, - const bool quietModeEnabled ) -{ - ivas_error error; - char config_str[50]; - AUDIO_CONFIG output_config; + static ivas_error printConfigInfo_dec( + Decoder_Struct * st_ivas, + const int16_t bitstreamformat, + const bool Opt_VOIP, + const bool quietModeEnabled ) + { + ivas_error error; + char config_str[50]; + AUDIO_CONFIG output_config; - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print info on screen *-----------------------------------------------------------------*/ - fprintf( stdout, "\n" ); + fprintf( stdout, "\n" ); - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print output sampling frequency *-----------------------------------------------------------------*/ - fprintf( stdout, "Output sampling rate: %d Hz\n", st_ivas->hDecoderConfig->output_Fs ); + fprintf( stdout, "Output sampling rate: %d Hz\n", st_ivas->hDecoderConfig->output_Fs ); - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print bitrate *-----------------------------------------------------------------*/ - if ( !quietModeEnabled ) - { - if ( !Opt_VOIP ) + if ( !quietModeEnabled ) { - fprintf( stdout, "Bitrate: %.2f kbps\n", (float) st_ivas->hDecoderConfig->ivas_total_brate / 1000 ); - - if ( st_ivas->hDecoderConfig->ivas_total_brate <= 0 ) + if ( !Opt_VOIP ) { - if ( bitstreamformat == G192 ) - { - fprintf( stdout, "Active Bitrate not identified in bitstream file \n" ); - } - else /* MIME */ + fprintf( stdout, "Bitrate: %.2f kbps\n", (float) st_ivas->hDecoderConfig->ivas_total_brate / 1000 ); + + if ( st_ivas->hDecoderConfig->ivas_total_brate <= 0 ) { - fprintf( stdout, "Active Bitrate not identified from first MIME frame \n" ); + if ( bitstreamformat == G192 ) + { + fprintf( stdout, "Active Bitrate not identified in bitstream file \n" ); + } + else /* MIME */ + { + fprintf( stdout, "Active Bitrate not identified from first MIME frame \n" ); + } } } } - } - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print output configuration *-----------------------------------------------------------------*/ - if ( st_ivas->ivas_format == MONO_FORMAT ) - { - if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + if ( st_ivas->ivas_format == MONO_FORMAT ) { - fprintf( stdout, "Output configuration: mono EVS bit-exact decoding to stereo\n" ); - fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); + if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + { + fprintf( stdout, "Output configuration: mono EVS bit-exact decoding to stereo\n" ); + fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); + } + else + { + fprintf( stdout, "Output configuration: mono EVS bit-exact decoding\n" ); + } } else { - fprintf( stdout, "Output configuration: mono EVS bit-exact decoding\n" ); - } - } - else - { - if ( !quietModeEnabled ) - { - if ( st_ivas->ivas_format == STEREO_FORMAT ) - { - fprintf( stdout, "Input configuration: Stereo\n" ); - } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + if ( !quietModeEnabled ) { - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + if ( st_ivas->ivas_format == STEREO_FORMAT ) { - fprintf( stdout, "Input configuration: ISM (ParamISM): 2 transport channels\n" ); + fprintf( stdout, "Input configuration: Stereo\n" ); } - else + else if ( st_ivas->ivas_format == ISM_FORMAT ) { - fprintf( stdout, "Input configuration: ISM: %d transport channel(s)\n", st_ivas->nchan_transport ); + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + fprintf( stdout, "Input configuration: ISM (ParamISM): 2 transport channels\n" ); + } + else + { + fprintf( stdout, "Input configuration: ISM: %d transport channel(s)\n", st_ivas->nchan_transport ); + } } - } - else if ( st_ivas->ivas_format == SBA_FORMAT ) - { - fprintf( stdout, "Input configuration: Scene Based Audio, Ambisonic order %i%s, %d transport channel(s)\n", st_ivas->sba_order, st_ivas->sba_planar ? " (Planar)" : "", st_ivas->nchan_transport ); - } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - fprintf( stdout, "Input configuration: Combined Scene Based Audio, Ambisonic order %i, with %d Objects \n", st_ivas->sba_order, st_ivas->nchan_ism ); - } - else if ( st_ivas->ivas_format == MASA_FORMAT ) - { - fprintf( stdout, "Input configuration: MASA - %d channel(s)\n", st_ivas->nchan_transport ); - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( ( error = get_channel_config( st_ivas->transport_config, &config_str[0] ) ) != IVAS_ERR_OK ) + else if ( st_ivas->ivas_format == SBA_FORMAT ) { - return error; + fprintf( stdout, "Input configuration: Scene Based Audio, Ambisonic order %i%s, %d transport channel(s)\n", st_ivas->sba_order, st_ivas->sba_planar ? " (Planar)" : "", st_ivas->nchan_transport ); + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + fprintf( stdout, "Input configuration: Combined Scene Based Audio, Ambisonic order %i, with %d Objects \n", st_ivas->sba_order, st_ivas->nchan_ism ); } + else if ( st_ivas->ivas_format == MASA_FORMAT ) + { + fprintf( stdout, "Input configuration: MASA - %d channel(s)\n", st_ivas->nchan_transport ); + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( ( error = get_channel_config( st_ivas->transport_config, &config_str[0] ) ) != IVAS_ERR_OK ) + { + return error; + } - fprintf( stdout, "Input configuration: %s\n", config_str ); - } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - fprintf( stdout, "Input configuration: combined ISM and MASA (%i ISM stream(s)) \n", st_ivas->nchan_ism ); + fprintf( stdout, "Input configuration: %s\n", config_str ); + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + fprintf( stdout, "Input configuration: combined ISM and MASA (%i ISM stream(s)) \n", st_ivas->nchan_ism ); + } } - } - output_config = st_ivas->hDecoderConfig->output_config; - get_channel_config( output_config, &config_str[0] ); - fprintf( stdout, "Output configuration: %s\n", config_str ); + output_config = st_ivas->hDecoderConfig->output_config; + get_channel_config( output_config, &config_str[0] ); + fprintf( stdout, "Output configuration: %s\n", config_str ); #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - { - fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); - } - if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) - { - fprintf( stdout, "HRIR/BRIR file: ON\n" ); - } - - if ( st_ivas->hDecoderConfig->Opt_RendConfigCustom ) - { - fprintf( stdout, "Renderer config. file: ON\n" ); - } + { + fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); + } + if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + { + fprintf( stdout, "HRIR/BRIR file: ON\n" ); + } - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - fprintf( stdout, "Head rotation: ON\n" ); - } + if ( st_ivas->hDecoderConfig->Opt_RendConfigCustom ) + { + fprintf( stdout, "Renderer config. file: ON\n" ); + } - if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) - { - fprintf( stdout, "External orientation: ON\n" ); - } + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + fprintf( stdout, "Head rotation: ON\n" ); + } - if ( st_ivas->hDecoderConfig->orientation_tracking != IVAS_HEAD_ORIENT_TRK_NONE ) - { - switch ( st_ivas->hDecoderConfig->orientation_tracking ) + if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - case IVAS_HEAD_ORIENT_TRK_AVG: - fprintf( stdout, "Orientation tracking: AVG\n" ); - break; - case IVAS_HEAD_ORIENT_TRK_REF: - fprintf( stdout, "Orientation tracking: REF\n" ); - break; - case IVAS_HEAD_ORIENT_TRK_REF_VEC: - fprintf( stdout, "Orientation tracking: REF_VEC\n" ); - break; - case IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV: - fprintf( stdout, "Orientation tracking: REF_VEC_LEV\n" ); - break; - default: - break; + fprintf( stdout, "External orientation: ON\n" ); } - } - if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) - { - fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); - } + if ( st_ivas->hDecoderConfig->orientation_tracking != IVAS_HEAD_ORIENT_TRK_NONE ) + { + switch ( st_ivas->hDecoderConfig->orientation_tracking ) + { + case IVAS_HEAD_ORIENT_TRK_AVG: + fprintf( stdout, "Orientation tracking: AVG\n" ); + break; + case IVAS_HEAD_ORIENT_TRK_REF: + fprintf( stdout, "Orientation tracking: REF\n" ); + break; + case IVAS_HEAD_ORIENT_TRK_REF_VEC: + fprintf( stdout, "Orientation tracking: REF_VEC\n" ); + break; + case IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV: + fprintf( stdout, "Orientation tracking: REF_VEC_LEV\n" ); + break; + default: + break; + } + } - if ( st_ivas->hDecoderConfig->Opt_dpid_on ) - { - fprintf( stdout, "Directivity pattern: ON\n" ); - } + if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + { + fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); + } - if ( st_ivas->hDecoderConfig->Opt_aeid_on ) - { - fprintf( stdout, "Acoustic environment ID:ON\n" ); + if ( st_ivas->hDecoderConfig->Opt_dpid_on ) + { + fprintf( stdout, "Directivity pattern: ON\n" ); + } + + if ( st_ivas->hDecoderConfig->Opt_aeid_on ) + { + fprintf( stdout, "Acoustic environment ID:ON\n" ); + } } - } - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print TSM mode info *-----------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - fprintf( stdout, "TSM mode: ON\n" ); - } + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + fprintf( stdout, "TSM mode: ON\n" ); + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_PrintConfig( ) * * Print decoder set-up info *---------------------------------------------------------------------*/ -void IVAS_DEC_PrintConfig( - const IVAS_DEC_HANDLE hIvasDec, - const bool quietModeEnabled, - const bool voipMode ) -{ - printConfigInfo_dec( hIvasDec->st_ivas, hIvasDec->bitstreamformat, voipMode, quietModeEnabled ); + void IVAS_DEC_PrintConfig( + const IVAS_DEC_HANDLE hIvasDec, + const bool quietModeEnabled, + const bool voipMode ) + { + printConfigInfo_dec( hIvasDec->st_ivas, hIvasDec->bitstreamformat, voipMode, quietModeEnabled ); - return; -} + return; + } #ifdef DEBUGGING #define WMC_TOOL_SKIP -void IVAS_DEC_PrintConfigWithBitstream( - IVAS_DEC_HANDLE hIvasDec, - const bool quietModeEnabled, - uint16_t bit_stream[], - const int16_t num_bits ) -{ - Decoder_Struct *st_ivas; + void IVAS_DEC_PrintConfigWithBitstream( + IVAS_DEC_HANDLE hIvasDec, + const bool quietModeEnabled, + uint16_t bit_stream[], + const int16_t num_bits ) + { + Decoder_Struct *st_ivas; - /* Create a copy of decoder struct that will be modified by preview_indices(), + /* Create a copy of decoder struct that will be modified by preview_indices(), * leaving the original decoder struct unchanged. The additional memory used here * should not be counted towards memory footprint of the decoder. */ - st_ivas = malloc( sizeof( Decoder_Struct ) ); - memcpy( st_ivas, hIvasDec->st_ivas, sizeof( Decoder_Struct ) ); + st_ivas = malloc( sizeof( Decoder_Struct ) ); + memcpy( st_ivas, hIvasDec->st_ivas, sizeof( Decoder_Struct ) ); - preview_indices( st_ivas, bit_stream, num_bits ); + preview_indices( st_ivas, bit_stream, num_bits ); - /* Print config from modified decoder struct */ - printConfigInfo_dec( st_ivas, hIvasDec->bitstreamformat, hIvasDec->Opt_VOIP, quietModeEnabled ); + /* Print config from modified decoder struct */ + printConfigInfo_dec( st_ivas, hIvasDec->bitstreamformat, hIvasDec->Opt_VOIP, quietModeEnabled ); - free( st_ivas ); + free( st_ivas ); - return; -} + return; + } -void IVAS_DEC_PrintConfigWithVoipBitstream( - IVAS_DEC_HANDLE hIvasDec, - const bool quietModeEnabled, - uint8_t *au, - const uint16_t auSizeBits ) -{ - Decoder_Struct *st_ivas; - uint16_t bit_stream[MAX_BITS_PER_FRAME + 4 * 8]; + void IVAS_DEC_PrintConfigWithVoipBitstream( + IVAS_DEC_HANDLE hIvasDec, + const bool quietModeEnabled, + uint8_t *au, + const uint16_t auSizeBits ) + { + Decoder_Struct *st_ivas; + uint16_t bit_stream[MAX_BITS_PER_FRAME + 4 * 8]; - /* Create a copy of decoder struct that will be modified by preview_indices(), + /* Create a copy of decoder struct that will be modified by preview_indices(), * leaving the original decoder struct unchanged. The additional memory used here * should not be counted towards memory footprint of the decoder. */ - st_ivas = malloc( sizeof( Decoder_Struct ) ); - memcpy( st_ivas, hIvasDec->st_ivas, sizeof( Decoder_Struct ) ); + st_ivas = malloc( sizeof( Decoder_Struct ) ); + memcpy( st_ivas, hIvasDec->st_ivas, sizeof( Decoder_Struct ) ); - bsCompactToSerial( au, bit_stream, auSizeBits ); - preview_indices( st_ivas, bit_stream, auSizeBits ); + bsCompactToSerial( au, bit_stream, auSizeBits ); + preview_indices( st_ivas, bit_stream, auSizeBits ); - /* Print config from modified decoder struct */ - printConfigInfo_dec( st_ivas, hIvasDec->bitstreamformat, hIvasDec->Opt_VOIP, quietModeEnabled ); + /* Print config from modified decoder struct */ + printConfigInfo_dec( st_ivas, hIvasDec->bitstreamformat, hIvasDec->Opt_VOIP, quietModeEnabled ); - free( st_ivas ); + free( st_ivas ); - return; -} + return; + } #undef WMC_TOOL_SKIP #endif -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_PrintDisclaimer( ) * * Print IVAS disclaimer to console *---------------------------------------------------------------------*/ -void IVAS_DEC_PrintDisclaimer( void ) -{ - print_disclaimer( stderr ); + void IVAS_DEC_PrintDisclaimer( void ) + { + print_disclaimer( stderr ); - return; -} + return; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * evs_dec_main( ) * * EVS codec main decoder fucntion *---------------------------------------------------------------------*/ -static ivas_error evs_dec_main( - Decoder_Struct *st_ivas, - const int16_t nOutSamples, - float *floatBuf, - int16_t *pcmBuf ) -{ - DEC_CORE_HANDLE *hCoreCoder; - float mixer_left, mixer_rigth; - float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; - int16_t ch; - ivas_error error; + static ivas_error evs_dec_main( + Decoder_Struct * st_ivas, + const int16_t nOutSamples, + float *floatBuf, + int16_t *pcmBuf ) + { + DEC_CORE_HANDLE *hCoreCoder; + float mixer_left, mixer_rigth; + float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; + int16_t ch; + ivas_error error; - hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; - hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; + hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - mdct_switching_dec( hCoreCoder[0] ); + mdct_switching_dec( hCoreCoder[0] ); - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) - { - p_output[ch] = st_ivas->p_output_f[ch]; - } + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) + { + p_output[ch] = st_ivas->p_output_f[ch]; + } - /* run the main EVS decoding routine */ - if ( hCoreCoder[0]->codec_mode == MODE1 ) - { - if ( hCoreCoder[0]->Opt_AMR_WB ) + /* run the main EVS decoding routine */ + if ( hCoreCoder[0]->codec_mode == MODE1 ) { - if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0] ) ) != IVAS_ERR_OK ) + if ( hCoreCoder[0]->Opt_AMR_WB ) { - return error; + if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0] ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else - { - if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) + else { - return error; + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) + { + return error; + } } } - } - else - { - if ( hCoreCoder[0]->bfi == 0 ) + else { - if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) + if ( hCoreCoder[0]->bfi == 0 ) { - return error; + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else if ( hCoreCoder[0]->bfi == 2 ) - { - if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) + else if ( hCoreCoder[0]->bfi == 2 ) { - return error; + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else - { - if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) + else { - return error; + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) + { + return error; + } } } - } - st_ivas->BER_detect = hCoreCoder[0]->BER_detect; + st_ivas->BER_detect = hCoreCoder[0]->BER_detect; - if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) - { - mixer_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; - mixer_rigth = 1.f - mixer_left; - v_multc( p_output[0], mixer_rigth, p_output[1], nOutSamples ); - v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); - } + if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + { + mixer_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; + mixer_rigth = 1.f - mixer_left; + v_multc( p_output[0], mixer_rigth, p_output[1], nOutSamples ); + v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); + } - if ( !st_ivas->hDecoderConfig->Opt_tsm ) - { - ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); - } - else if ( floatBuf != NULL ) - { - /* BE workaround */ - int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); + } + else if ( floatBuf != NULL ) + { + /* BE workaround */ + int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; - /* convert 'float' output data to 'short' */ + /* convert 'float' output data to 'short' */ #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += #endif - ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local ); + ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local ); - mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out ); - } - else - { + mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out ); + } + else + { #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += #endif - ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); - } + ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } #ifdef DEBUGGING -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetBer_detect_flag() * * return BER_detect flag *---------------------------------------------------------------------*/ -bool IVAS_DEC_GetBerDetectFlag( - IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ -) -{ - if ( hIvasDec->st_ivas->BER_detect == 1 ) + bool IVAS_DEC_GetBerDetectFlag( + IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ + ) { - return 1; - } - else - { - return 0; + if ( hIvasDec->st_ivas->BER_detect == 1 ) + { + return 1; + } + else + { + return 0; + } } -} -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetNoCLipping() * * return number of clipped samples *---------------------------------------------------------------------*/ -int32_t IVAS_DEC_GetNoCLipping( - IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ -) -{ - return hIvasDec->st_ivas->noClipping; -} + int32_t IVAS_DEC_GetNoCLipping( + IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ + ) + { + return hIvasDec->st_ivas->noClipping; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetCntFramesLimited() * * return number of frames where limiter is applied *---------------------------------------------------------------------*/ -int32_t IVAS_DEC_GetCntFramesLimited( - IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ -) -{ - if ( hIvasDec->st_ivas->hLimiter == NULL ) - { - return 0; - } - else + int32_t IVAS_DEC_GetCntFramesLimited( + IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ + ) { - return hIvasDec->st_ivas->hLimiter->cnt_frames_limited; + if ( hIvasDec->st_ivas->hLimiter == NULL ) + { + return 0; + } + else + { + return hIvasDec->st_ivas->hLimiter->cnt_frames_limited; + } } -} -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * forcedRendModeApiToInternalDec() * * *---------------------------------------------------------------------*/ -static ivas_error forcedRendModeApiToInternalDec( - const IVAS_DEC_FORCED_REND_MODE forcedRendMode, - int16_t *forcedModeInternal ) -{ - switch ( forcedRendMode ) + static ivas_error forcedRendModeApiToInternalDec( + const IVAS_DEC_FORCED_REND_MODE forcedRendMode, + int16_t *forcedModeInternal ) { - case IVAS_DEC_FORCE_REND_TD_RENDERER: - *forcedModeInternal = FORCE_TD_RENDERER; - break; - case IVAS_DEC_FORCE_REND_CLDFB_RENDERER: - *forcedModeInternal = FORCE_CLDFB_RENDERER; - break; - case IVAS_DEC_FORCE_REND_UNFORCED: - *forcedModeInternal = -1; - break; - default: - return IVAS_ERR_INVALID_FORCE_MODE; - break; - } + switch ( forcedRendMode ) + { + case IVAS_DEC_FORCE_REND_TD_RENDERER: + *forcedModeInternal = FORCE_TD_RENDERER; + break; + case IVAS_DEC_FORCE_REND_CLDFB_RENDERER: + *forcedModeInternal = FORCE_CLDFB_RENDERER; + break; + case IVAS_DEC_FORCE_REND_UNFORCED: + *forcedModeInternal = -1; + break; + default: + return IVAS_ERR_INVALID_FORCE_MODE; + break; + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_SetForcedRendMode() * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_SetForcedRendMode( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_DEC_FORCED_REND_MODE forcedRendMode /* i : forced renderer mode */ -) -{ - int16_t newForcedRend; - ivas_error error; - - if ( ( error = forcedRendModeApiToInternalDec( forcedRendMode, &newForcedRend ) ) != IVAS_ERR_OK ) + ivas_error IVAS_DEC_SetForcedRendMode( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_DEC_FORCED_REND_MODE forcedRendMode /* i : forced renderer mode */ + ) { - return error; - } + int16_t newForcedRend; + ivas_error error; - if ( hIvasDec->st_ivas->hDecoderConfig->force_rend != newForcedRend ) - { - hIvasDec->st_ivas->hDecoderConfig->force_rend = newForcedRend; - } + if ( ( error = forcedRendModeApiToInternalDec( forcedRendMode, &newForcedRend ) ) != IVAS_ERR_OK ) + { + return error; + } - return IVAS_ERR_OK; -} + if ( hIvasDec->st_ivas->hDecoderConfig->force_rend != newForcedRend ) + { + hIvasDec->st_ivas->hDecoderConfig->force_rend = newForcedRend; + } + + return IVAS_ERR_OK; + } #ifdef DEBUG_SBA_AUDIO_DUMP -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetSbaDebugParams( ) * * Returns SBA debug parameters *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetSbaDebugParams( - const IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *numOutputChannels, - int16_t *numTransportChannels, - int16_t *pca_ingest_channels ) -{ - if ( hIvasDec->st_ivas == NULL ) + ivas_error IVAS_DEC_GetSbaDebugParams( + const IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *numOutputChannels, + int16_t *numTransportChannels, + int16_t *pca_ingest_channels ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - if ( hIvasDec->st_ivas->ivas_format != SBA_FORMAT || hIvasDec->st_ivas->hSpar == NULL ) - { - *numOutputChannels = 1; - *numTransportChannels = 1; - *pca_ingest_channels = 1; - } - else - { - *numOutputChannels = hIvasDec->st_ivas->hSpar->numOutChannels; - *numTransportChannels = hIvasDec->st_ivas->nchan_transport; - *pca_ingest_channels = hIvasDec->st_ivas->hSpar->pca_ingest_channels; - } + if ( hIvasDec->st_ivas->ivas_format != SBA_FORMAT || hIvasDec->st_ivas->hSpar == NULL ) + { + *numOutputChannels = 1; + *numTransportChannels = 1; + *pca_ingest_channels = 1; + } + else + { + *numOutputChannels = hIvasDec->st_ivas->hSpar->numOutChannels; + *numTransportChannels = hIvasDec->st_ivas->nchan_transport; + *pca_ingest_channels = hIvasDec->st_ivas->hSpar->pca_ingest_channels; + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } #endif /* DEBUG_SBA_AUDIO_DUMP */ #endif /* DEBUGGING */ -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * input_format_API_to_internal() * * *---------------------------------------------------------------------*/ -static ivas_error input_format_API_to_internal( - IVAS_DEC_INPUT_FORMAT input_format, - int16_t *bitstream_format_internal, - int16_t *sdp_hf_only, - const bool is_voip_enabled ) -{ - switch ( input_format ) + static ivas_error input_format_API_to_internal( + IVAS_DEC_INPUT_FORMAT input_format, + int16_t * bitstream_format_internal, + int16_t * sdp_hf_only, + const bool is_voip_enabled ) { - case IVAS_DEC_INPUT_FORMAT_G192: - *bitstream_format_internal = is_voip_enabled ? VOIP_G192_RTP : G192; - *sdp_hf_only = 0; - break; - case IVAS_DEC_INPUT_FORMAT_MIME: - *bitstream_format_internal = MIME; - *sdp_hf_only = 0; - break; - case IVAS_DEC_INPUT_FORMAT_RTPDUMP: - assert( is_voip_enabled && "RTP dump only supported in VoIP mode" ); - *bitstream_format_internal = VOIP_RTPDUMP; - *sdp_hf_only = 0; - break; - case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF: - assert( is_voip_enabled && "RTP dump only supported in VoIP mode" ); - *bitstream_format_internal = VOIP_RTPDUMP; - *sdp_hf_only = 1; - break; - default: - return IVAS_ERR_INVALID_BITSTREAM; - break; - } + switch ( input_format ) + { + case IVAS_DEC_INPUT_FORMAT_G192: + *bitstream_format_internal = is_voip_enabled ? VOIP_G192_RTP : G192; + *sdp_hf_only = 0; + break; + case IVAS_DEC_INPUT_FORMAT_MIME: + *bitstream_format_internal = MIME; + *sdp_hf_only = 0; + break; + case IVAS_DEC_INPUT_FORMAT_RTPDUMP: + assert( is_voip_enabled && "RTP dump only supported in VoIP mode" ); + *bitstream_format_internal = VOIP_RTPDUMP; + *sdp_hf_only = 0; + break; + case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF: + assert( is_voip_enabled && "RTP dump only supported in VoIP mode" ); + *bitstream_format_internal = VOIP_RTPDUMP; + *sdp_hf_only = 1; + break; + default: + return IVAS_ERR_INVALID_BITSTREAM; + break; + } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_reconfigure() * * *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_VoIP_reconfigure( - IVAS_DEC_HANDLE hIvasDec, - const uint16_t nTransportChannels, - const uint16_t l_ts ) -{ - int16_t apa_buffer_size; - - apa_buffer_size = hIvasDec->nSamplesFrame; - - if ( hIvasDec->apaExecBuffer == NULL ) + static ivas_error IVAS_DEC_VoIP_reconfigure( + IVAS_DEC_HANDLE hIvasDec, + const uint16_t nTransportChannels, + const uint16_t l_ts ) { - DECODER_CONFIG_HANDLE hDecoderConfig; + int16_t apa_buffer_size; - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + apa_buffer_size = hIvasDec->nSamplesFrame; + + if ( hIvasDec->apaExecBuffer == NULL ) { - uint16_t wss, css; - float startQuality; + DECODER_CONFIG_HANDLE hDecoderConfig; - startQuality = hIvasDec->tsm_quality; - apa_buffer_size = APA_BUF_PER_CHANNEL; + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + uint16_t wss, css; + float startQuality; - /* get current renderer type*/ - hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; + startQuality = hIvasDec->tsm_quality; + apa_buffer_size = APA_BUF_PER_CHANNEL; - if ( hDecoderConfig->output_Fs == 8000 ) - { - wss = 1; - css = 1; - } - else if ( hDecoderConfig->output_Fs == 16000 ) - { - wss = 2; - css = 1; - } - else if ( hDecoderConfig->output_Fs == 32000 ) - { - wss = 4; - css = 2; - } - else if ( hDecoderConfig->output_Fs == 48000 ) - { - wss = 6; - css = 3; - } - else - { - return IVAS_ERR_INIT_ERROR; - } + /* get current renderer type*/ + hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; - if ( apa_init( &hIvasDec->hTimeScaler, nTransportChannels ) != IVAS_ERR_OK || - apa_set_rate( hIvasDec->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || - apa_set_complexity_options( hIvasDec->hTimeScaler, wss, css ) != 0 || - apa_set_quality( hIvasDec->hTimeScaler, startQuality, 4, 4 ) != 0 || - apa_set_renderer_granularity( hIvasDec->hTimeScaler, l_ts ) != 0 ) - { - return IVAS_ERR_INIT_ERROR; - } + if ( hDecoderConfig->output_Fs == 8000 ) + { + wss = 1; + css = 1; + } + else if ( hDecoderConfig->output_Fs == 16000 ) + { + wss = 2; + css = 1; + } + else if ( hDecoderConfig->output_Fs == 32000 ) + { + wss = 4; + css = 2; + } + else if ( hDecoderConfig->output_Fs == 48000 ) + { + wss = 6; + css = 3; + } + else + { + return IVAS_ERR_INIT_ERROR; + } - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) - { - if ( apa_set_evs_compat_mode( hIvasDec->hTimeScaler, true ) != 0 ) + if ( apa_init( &hIvasDec->hTimeScaler, nTransportChannels ) != IVAS_ERR_OK || + apa_set_rate( hIvasDec->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || + apa_set_complexity_options( hIvasDec->hTimeScaler, wss, css ) != 0 || + apa_set_quality( hIvasDec->hTimeScaler, startQuality, 4, 4 ) != 0 || + apa_set_renderer_granularity( hIvasDec->hTimeScaler, l_ts ) != 0 ) { return IVAS_ERR_INIT_ERROR; } - } - if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); - } + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + { + if ( apa_set_evs_compat_mode( hIvasDec->hTimeScaler, true ) != 0 ) + { + return IVAS_ERR_INIT_ERROR; + } + } + + if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); + } - set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); + set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); + } } - } - else - { - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + else { - if ( apa_reconfigure( hIvasDec->hTimeScaler, nTransportChannels, l_ts ) != 0 ) - { - return IVAS_ERR_INIT_ERROR; - } - apa_buffer_size = APA_BUF_PER_CHANNEL; - free( hIvasDec->apaExecBuffer ); - if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); + if ( apa_reconfigure( hIvasDec->hTimeScaler, nTransportChannels, l_ts ) != 0 ) + { + return IVAS_ERR_INIT_ERROR; + } + apa_buffer_size = APA_BUF_PER_CHANNEL; + free( hIvasDec->apaExecBuffer ); + if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); + } + set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); } - set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); + /* realloc apa_exe_buffer */ } - /* realloc apa_exe_buffer */ - } - hIvasDec->nTransportChannelsOld = nTransportChannels; + hIvasDec->nTransportChannelsOld = nTransportChannels; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } #ifdef SPLIT_REND_WITH_HEAD_ROT -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetSplitRendBitstreamHeader() * * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ + ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC * pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE * poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ - int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ - int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ + int16_t * pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ + int16_t * pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ + int16_t * pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ #else - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + int16_t * pCodec_frame_size_ms /* o: pointer to codec frame size setting */ #endif -) -{ - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec; - *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms; - *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode; + *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec; + *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms; + *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; - *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; + *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; + *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; #endif - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_GetCldfbSamples() * * API function to output CLDFB samples *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetCldfbSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ - float *out_imag, /* o : buffer for decoded PCM imag output in CLDFB domain */ - AUDIO_CONFIG *audio_config, /* o : audio configuration */ - int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ -) -{ - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; - int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSplitBinRend == NULL ) + ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ + float *out_imag, /* o : buffer for decoded PCM imag output in CLDFB domain */ + AUDIO_CONFIG *audio_config, /* o : audio configuration */ + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; - hSplitBinRend = hIvasDec->st_ivas->hSplitBinRend; - num_samples = 0; - - if ( hSplitBinRend->hCldfbDataOut != NULL ) - { - *audio_config = hSplitBinRend->hCldfbDataOut->config; - if ( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSplitBinRend == NULL ) { - num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); - maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hSplitBinRend = hIvasDec->st_ivas->hSplitBinRend; + num_samples = 0; - for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + if ( hSplitBinRend->hCldfbDataOut != NULL ) + { + *audio_config = hSplitBinRend->hCldfbDataOut->config; + if ( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) { - for ( b = 0; b < maxBand; b++ ) + num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); + maxBand = ( int16_t )( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) { - for ( ch = 0; ch < num_chs; ch++ ) + for ( b = 0; b < maxBand; b++ ) { - *out_real++ = hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx][b]; - *out_imag++ = hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx][b]; + for ( ch = 0; ch < num_chs; ch++ ) + { + *out_real++ = hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx][b]; + *out_imag++ = hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx][b]; + } } } + num_samples = CLDFB_NO_COL_MAX * maxBand; } - num_samples = CLDFB_NO_COL_MAX * maxBand; } - } - else - { - *audio_config = IVAS_AUDIO_CONFIG_INVALID; - } + else + { + *audio_config = IVAS_AUDIO_CONFIG_INVALID; + } - *nOutSamples = num_samples; + *nOutSamples = num_samples; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * pcm_buffer_offset() * * *---------------------------------------------------------------------*/ -static void *pcm_buffer_offset( - void *buffer, - const IVAS_DEC_PCM_TYPE pcmType, - const int32_t offset ) -{ - switch ( pcmType ) + static void *pcm_buffer_offset( + void *buffer, + const IVAS_DEC_PCM_TYPE pcmType, + const int32_t offset ) { - case IVAS_DEC_PCM_FLOAT: - { - float *tmpBuf = (float *) buffer; - return (void *) ( tmpBuf + offset ); - } - break; - case IVAS_DEC_PCM_INT16: + switch ( pcmType ) { - int16_t *tmpBuf = (int16_t *) buffer; - return (void *) ( tmpBuf + offset ); - } - break; - default: + case IVAS_DEC_PCM_FLOAT: + { + float *tmpBuf = (float *) buffer; + return (void *) ( tmpBuf + offset ); + } break; - } + case IVAS_DEC_PCM_INT16: + { + int16_t *tmpBuf = (int16_t *) buffer; + return (void *) ( tmpBuf + offset ); + } + break; + default: + break; + } - return NULL; -} + return NULL; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * set_pcm_buffer_to_zero() * * *---------------------------------------------------------------------*/ -static ivas_error set_pcm_buffer_to_zero( - void *buffer, - const IVAS_DEC_PCM_TYPE pcmType, - const int16_t nZeroSamples ) -{ - ivas_error error; - - error = IVAS_ERR_OK; - switch ( pcmType ) + static ivas_error set_pcm_buffer_to_zero( + void *buffer, + const IVAS_DEC_PCM_TYPE pcmType, + const int16_t nZeroSamples ) { - case IVAS_DEC_PCM_FLOAT: - set_zero( (float *) buffer, nZeroSamples ); - break; - case IVAS_DEC_PCM_INT16: - set_s( (int16_t *) buffer, 0, nZeroSamples ); - break; - default: - error = IVAS_ERR_INTERNAL; - } + ivas_error error; - return error; -} + error = IVAS_ERR_OK; + switch ( pcmType ) + { + case IVAS_DEC_PCM_FLOAT: + set_zero( (float *) buffer, nZeroSamples ); + break; + case IVAS_DEC_PCM_INT16: + set_s( (int16_t *) buffer, 0, nZeroSamples ); + break; + default: + error = IVAS_ERR_INTERNAL; + } + return error; + } -/*---------------------------------------------------------------------* + + /*---------------------------------------------------------------------* * pcm_type_API_to_internal() * * *---------------------------------------------------------------------*/ -PCM_RESOLUTION pcm_type_API_to_internal( - const IVAS_DEC_PCM_TYPE pcmType ) -{ - PCM_RESOLUTION pcm_resolution; - pcm_resolution = PCM_NOT_KNOW; - - switch ( pcmType ) + PCM_RESOLUTION pcm_type_API_to_internal( + const IVAS_DEC_PCM_TYPE pcmType ) { - case IVAS_DEC_PCM_FLOAT: - pcm_resolution = PCM_FLOAT32; - break; - case IVAS_DEC_PCM_INT16: - pcm_resolution = PCM_INT16; - break; - default: - pcm_resolution = PCM_NOT_KNOW; - } + PCM_RESOLUTION pcm_resolution; + pcm_resolution = PCM_NOT_KNOW; - return pcm_resolution; -} + switch ( pcmType ) + { + case IVAS_DEC_PCM_FLOAT: + pcm_resolution = PCM_FLOAT32; + break; + case IVAS_DEC_PCM_INT16: + pcm_resolution = PCM_INT16; + break; + default: + pcm_resolution = PCM_NOT_KNOW; + } + + return pcm_resolution; + } -/*-------------------------------------------------------------------* + /*-------------------------------------------------------------------* * ivas_create_handle_isar() * * Initialize IVAS decoder split rend handle *-------------------------------------------------------------------*/ -static ivas_error ivas_create_handle_isar( - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out /* o : ISAR split binaural rendering handle */ -) -{ - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; - - if ( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL ) + static ivas_error ivas_create_handle_isar( + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE * hSplitBinRend_out /* o : ISAR split binaural rendering handle */ + ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); - } + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; - isar_init_split_rend_handles( &hSplitBinRend->splitrend ); + if ( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); + } - hSplitBinRend->hMultiBinCldfbData = NULL; - hSplitBinRend->hCldfbDataOut = NULL; - hSplitBinRend->numTdSamplesPerChannelCached = 0; + isar_init_split_rend_handles( &hSplitBinRend->splitrend ); - *hSplitBinRend_out = hSplitBinRend; + hSplitBinRend->hMultiBinCldfbData = NULL; + hSplitBinRend->hCldfbDataOut = NULL; + hSplitBinRend->numTdSamplesPerChannelCached = 0; - return IVAS_ERR_OK; -} + *hSplitBinRend_out = hSplitBinRend; + + return IVAS_ERR_OK; + } -/*-------------------------------------------------------------------* + /*-------------------------------------------------------------------* * ivas_destroy_handle_isar() * * destroy IVAS decoder split rend handle *-------------------------------------------------------------------*/ -static void ivas_destroy_handle_isar( - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend /* i/o: ISAR split binaural rendering handle */ -) -{ - if ( *hSplitBinRend != NULL ) + static void ivas_destroy_handle_isar( + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE * hSplitBinRend /* i/o: ISAR split binaural rendering handle */ + ) { - ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); - - if ( ( *hSplitBinRend )->hCldfbDataOut != NULL ) + if ( *hSplitBinRend != NULL ) { - free( ( *hSplitBinRend )->hCldfbDataOut ); - ( *hSplitBinRend )->hCldfbDataOut = NULL; + ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); + + if ( ( *hSplitBinRend )->hCldfbDataOut != NULL ) + { + free( ( *hSplitBinRend )->hCldfbDataOut ); + ( *hSplitBinRend )->hCldfbDataOut = NULL; + } } - } - return; -} + return; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_is_split_rendering_enabled() * * *---------------------------------------------------------------------*/ -/*! r: decoder error code */ -ivas_error IVAS_DEC_is_split_rendering_enabled( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *isSplitRend /* o : flag to indicate if split rendering is enabled */ -) -{ - Decoder_Struct *st_ivas; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + /*! r: decoder error code */ + ivas_error IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t * isSplitRend /* o : flag to indicate if split rendering is enabled */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + Decoder_Struct *st_ivas; - st_ivas = hIvasDec->st_ivas; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; - *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ); + *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ); - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*-------------------------------------------------------------------* + /*-------------------------------------------------------------------* * ivas_dec_reconfig_split_rend() * * IVAS decoder split rend reconfig *-------------------------------------------------------------------*/ -static ivas_error ivas_dec_reconfig_split_rend( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -) -{ - ivas_error error; - int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; - SPLIT_REND_WRAPPER *hSplitRendWrapper; - - hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in_flag = 0; - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + static ivas_error ivas_dec_reconfig_split_rend( + Decoder_Struct * st_ivas /* i : IVAS decoder structure */ + ) { - cldfb_in_flag = 1; - } + ivas_error error; + int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; + SPLIT_REND_WRAPPER *hSplitRendWrapper; - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; - isCldfbNeeded = 0; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in_flag = 1; + } - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - cldfb_in_flag = 0; - } + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); - if ( st_ivas->renderer_type != RENDERER_DISABLE ) - { - if ( cldfb_in_flag == 0 ) + isCldfbNeeded = 0; + + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { - isCldfbNeeded = 1; + cldfb_in_flag = 0; } - else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) + + if ( st_ivas->renderer_type != RENDERER_DISABLE ) { - isCldfbNeeded = 1; + if ( cldfb_in_flag == 0 ) + { + isCldfbNeeded = 1; + } + else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) + { + isCldfbNeeded = 1; + } + else if ( pcm_out_flag && cldfb_in_flag ) + { + isCldfbNeeded = 1; + } } - else if ( pcm_out_flag && cldfb_in_flag ) + else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) { isCldfbNeeded = 1; } - } - else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) - { - isCldfbNeeded = 1; - } - if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) - { - if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); - } + if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) - { - hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; - } + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } - num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) - { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + for ( ch = 0; ch < num_ch; ch++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); + } } - } - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - return error; + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } } } - } - else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) - { - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) + else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) { - if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) { - deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); - hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } } - } - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); - hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + } } - } - free( hSplitRendWrapper->hCldfbHandles ); - hSplitRendWrapper->hCldfbHandles = NULL; - } + free( hSplitRendWrapper->hCldfbHandles ); + hSplitRendWrapper->hCldfbHandles = NULL; + } - if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && - ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && - !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && + ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && + !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { - if ( st_ivas->hTdRendHandles[i] != NULL ) + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { - st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; - ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); + if ( st_ivas->hTdRendHandles[i] != NULL ) + { + st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); + } } } - } - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*-------------------------------------------------------------------* + /*-------------------------------------------------------------------* * ivas_dec_init_split_rend() * * IVAS decoder split rend init *-------------------------------------------------------------------*/ -static ivas_error ivas_dec_init_split_rend( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -) -{ - ivas_error error; - int16_t cldfb_in_flag, pcm_out_flag; - int16_t mixed_td_cldfb_flag; + static ivas_error ivas_dec_init_split_rend( + Decoder_Struct * st_ivas /* i : IVAS decoder structure */ + ) + { + ivas_error error; + int16_t cldfb_in_flag, pcm_out_flag; + int16_t mixed_td_cldfb_flag; - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in_flag = 0; + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - cldfb_in_flag = 1; - } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in_flag = 1; + } - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); - if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) - { - if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + } } - } - mixed_td_cldfb_flag = 0; - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - mixed_td_cldfb_flag = 1; - } + mixed_td_cldfb_flag = 0; + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + mixed_td_cldfb_flag = 1; + } - error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); - return error; -} + return error; + } -/*---------------------------------------------------------------------* + /*---------------------------------------------------------------------* * IVAS_DEC_is_split_rendering_coded_out() * * *---------------------------------------------------------------------*/ -/*! r: decoder error code */ -ivas_error IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ -) -{ - Decoder_Struct *st_ivas; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + /*! r: decoder error code */ + ivas_error IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t * isSplitCoded /* o : flag to indicate if split rendering is enabled */ + ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + Decoder_Struct *st_ivas; - st_ivas = hIvasDec->st_ivas; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *isSplitCoded = 0; + st_ivas = hIvasDec->st_ivas; - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) - { - *isSplitCoded = 1; - } + *isSplitCoded = 0; - return IVAS_ERR_OK; -} + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + *isSplitCoded = 1; + } + + return IVAS_ERR_OK; + } #endif -- GitLab From 9aef31570a2e1ddab77e1f7ac2398067236a7686 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 6 Jun 2024 11:54:01 +0200 Subject: [PATCH 037/130] fix formatting --- lib_dec/lib_dec.c | 4766 ++++++++++++++++++++++----------------------- 1 file changed, 2383 insertions(+), 2383 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 4146031fcf..c5aa936dd8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -563,7 +563,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->st_ivas->ivas_format = MONO_FORMAT; } - hIvasDec->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; hIvasDec->tsm_scale = 100; @@ -625,7 +625,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( int16_t get_render_frame_size_ms( const IVAS_RENDER_FRAMESIZE render_framesize ) { - return ( int16_t )( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + return (int16_t) ( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); } @@ -696,7 +696,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *render_framesize = ( int16_t )( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); + *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); return IVAS_ERR_OK; } @@ -738,7 +738,7 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *update_frequency = ( int16_t )( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); + *update_frequency = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); return IVAS_ERR_OK; } @@ -817,7 +817,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->lastDecodedWasActive = 0; hIvasDec->hVoIP->hCurrentDataUnit = NULL; - hIvasDec->hVoIP->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->hVoIP->nSamplesRendered20ms = 0; #define WMC_TOOL_SKIP @@ -1042,355 +1042,355 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIsmRendererData->edited_gains[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; } } - } + } #endif - return IVAS_ERR_OK; + return IVAS_ERR_OK; } #ifdef OBJ_EDITING_API - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetEditableParameters( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS * hIvasEditableParameters ) - { - ivas_error error; +ivas_error IVAS_DEC_GetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) +{ + ivas_error error; - if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) - { + hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { #ifdef OBJ_EDITING_PARAMISM - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) - { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; - hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; - hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; - hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; - hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; - hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; - } + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; + hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } + } #ifdef OBJ_EDITING_PARAMISM - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) - { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) - { - hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; - hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; - hIvasEditableParameters->ism_metadata[obj].yaw = 0; - hIvasEditableParameters->ism_metadata[obj].pitch = 0; - hIvasEditableParameters->ism_metadata[obj].radius = 0; - hIvasEditableParameters->ism_metadata[obj].gain = 0; - hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; - } - } - else + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { - assert( 0 && "This should never happen!" ); + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; + hIvasEditableParameters->ism_metadata[obj].yaw = 0; + hIvasEditableParameters->ism_metadata[obj].pitch = 0; + hIvasEditableParameters->ism_metadata[obj].radius = 0; + hIvasEditableParameters->ism_metadata[obj].gain = 0; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; } -#endif - } - else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) - { } else { + assert( 0 && "This should never happen!" ); } +#endif + } + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + } + else + { + } - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; - return error; - } + return error; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_SetEditableParameters( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_SetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) - { - ivas_error error; +ivas_error IVAS_DEC_SetEditableParameters( + IVAS_DEC_HANDLE hIvasDec, + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) +{ + ivas_error error; - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } #ifdef DEBUGGING - assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); + assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); #endif - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) - { + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { #ifdef OBJ_EDITING_PARAMISM - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) - { - hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; - hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; - hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; - hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; - } + hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; + hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } + } #ifdef OBJ_EDITING_PARAMISM - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) - { - int16_t obj; - for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) - { - hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - } - } - else + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj; + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - assert( 0 && "This should never happen!" ); + hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; } -#endif - } - else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) - { } else { + assert( 0 && "This should never happen!" ); } - - return error; +#endif + } + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + } + else + { } - /*---------------------------------------------------------------------* + return error; +} + +/*---------------------------------------------------------------------* * IVAS_DEC_PrepareRenderer( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_PrepareRenderer( - IVAS_DEC_HANDLE hIvasDec ) - { - ivas_error error; - - error = IVAS_ERR_OK; +ivas_error IVAS_DEC_PrepareRenderer( + IVAS_DEC_HANDLE hIvasDec ) +{ + ivas_error error; - if ( hIvasDec == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + error = IVAS_ERR_OK; - ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); - hIvasDec->hasBeenPreparedRendering = true; - return error; + if ( hIvasDec == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); + hIvasDec->hasBeenPreparedRendering = true; + return error; +} + #endif - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetSamples( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ +ivas_error IVAS_DEC_GetSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : indication that the decoder needs a new frame */ - ) - { - ivas_error error; - int16_t nSamplesToRender; - uint16_t nSamplesRendered, nSamplesRendered_loop; - uint8_t nOutChannels; + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ +) +{ + ivas_error error; + int16_t nSamplesToRender; + uint16_t nSamplesRendered, nSamplesRendered_loop; + uint8_t nOutChannels; #ifndef OBJ_EDITING_API - uint8_t nTransportChannels; - int16_t nOutSamplesElse; - uint16_t nTimeScalerOutSamples, l_ts; + uint8_t nTransportChannels; + int16_t nOutSamplesElse; + uint16_t nTimeScalerOutSamples, l_ts; #endif - nSamplesRendered = 0; - nOutChannels = 0; - nSamplesRendered_loop = 0; + nSamplesRendered = 0; + nOutChannels = 0; + nSamplesRendered_loop = 0; #ifndef OBJ_EDITING_API - l_ts = 0; - nTransportChannels = 0; + l_ts = 0; + nTransportChannels = 0; #endif - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } #ifdef OBJ_EDITING_API - /* the rendering needs to be prepared at this point */ - if ( hIvasDec->hasBeenPreparedRendering == false ) - { - return IVAS_ERR_UNKNOWN; - } + /* the rendering needs to be prepared at this point */ + if ( hIvasDec->hasBeenPreparedRendering == false ) + { + return IVAS_ERR_UNKNOWN; + } #endif - if ( hIvasDec->updateOrientation ) - { - /*----------------------------------------------------------------* + if ( hIvasDec->updateOrientation ) + { + /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ - if ( ( error = combine_external_and_head_orientations_dec( hIvasDec->st_ivas->hHeadTrackData, hIvasDec->st_ivas->hExtOrientationData, hIvasDec->st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = combine_external_and_head_orientations_dec( hIvasDec->st_ivas->hHeadTrackData, hIvasDec->st_ivas->hExtOrientationData, hIvasDec->st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + { + return error; + } #ifdef SPLIT_REND_WITH_HEAD_ROT - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * Binaural split rendering setup *----------------------------------------------------------------*/ - if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL && ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - isar_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat ); - } + if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL && ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + isar_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat ); + } #endif - hIvasDec->updateOrientation = false; - } + hIvasDec->updateOrientation = false; + } + + if ( !hIvasDec->hasBeenFedFrame && hIvasDec->nSamplesAvailableNext == 0 ) + { + /* no frame was fed, do nothing but ask for a frame */ + *needNewFrame = true; + *nOutSamples = 0; + hIvasDec->needNewFrame = true; + return IVAS_ERR_OK; + } - if ( !hIvasDec->hasBeenFedFrame && hIvasDec->nSamplesAvailableNext == 0 ) + /* check if we are still at the beginning with bad frames, put out zeroes, keep track of subframes */ + if ( !hIvasDec->isInitialized && hIvasDec->st_ivas->bfi ) + { + hIvasDec->hasBeenFedFrame = false; + set_s( pcmBuf, 0, hIvasDec->st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); + hIvasDec->nSamplesRendered += nSamplesAsked; + *nOutSamples = nSamplesAsked; + hIvasDec->nSamplesAvailableNext -= nSamplesAsked; + if ( hIvasDec->nSamplesAvailableNext == 0 ) { - /* no frame was fed, do nothing but ask for a frame */ - *needNewFrame = true; - *nOutSamples = 0; hIvasDec->needNewFrame = true; - return IVAS_ERR_OK; + *needNewFrame = true; } - - /* check if we are still at the beginning with bad frames, put out zeroes, keep track of subframes */ - if ( !hIvasDec->isInitialized && hIvasDec->st_ivas->bfi ) + } + else + { +#ifndef OBJ_EDITING_API + /* check if we need to run the setup function */ + if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { - hIvasDec->hasBeenFedFrame = false; - set_s( pcmBuf, 0, hIvasDec->st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); - hIvasDec->nSamplesRendered += nSamplesAsked; - *nOutSamples = nSamplesAsked; - hIvasDec->nSamplesAvailableNext -= nSamplesAsked; - if ( hIvasDec->nSamplesAvailableNext == 0 ) + /* setup */ +#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, &nSamplesRendered_loop, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) +#endif + { - hIvasDec->needNewFrame = true; - *needNewFrame = true; + return error; } } - else +#endif { + /* check if we need to run the setup function, tc decoding and feeding the renderer */ #ifndef OBJ_EDITING_API - /* check if we need to run the setup function */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { - /* setup */ -#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, &nSamplesRendered_loop, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) -#endif + int16_t nResidualSamples, nSamplesTcsScaled; + nSamplesRendered += nSamplesRendered_loop; + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) { - return error; + if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) + { + return error; + } } - } -#endif - { - /* check if we need to run the setup function, tc decoding and feeding the renderer */ -#ifndef OBJ_EDITING_API - if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + + /* IVAS decoder */ + if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { - int16_t nResidualSamples, nSamplesTcsScaled; - nSamplesRendered += nSamplesRendered_loop; + return error; + } - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) + /* JBM */ + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { - if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) - { - return error; - } + return IVAS_ERR_UNKNOWN; } - /* IVAS decoder */ - if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) + if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { - return error; + return IVAS_ERR_UNKNOWN; } - /* 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; - hIvasDec->timeScalingDone = 1; - } - else - { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - } + assert( nTimeScalerOutSamples <= APA_BUF ); + nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; + hIvasDec->timeScalingDone = 1; + } + else + { + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); + dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); #endif - /* Feed decoded transport channels samples to the renderer */ - if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) - { - return error; - } + /* Feed decoded transport channels samples to the renderer */ + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); + dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); #endif - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + 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 ) { - /* 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; - } + return IVAS_ERR_UNKNOWN; } - hIvasDec->hasBeenFedFrame = false; } + hIvasDec->hasBeenFedFrame = false; + } #else nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; hIvasDec->hasBeenFedFrame = false; @@ -1425,285 +1425,285 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } #endif - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = nSamplesAsked - nSamplesRendered; + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = nSamplesAsked - nSamplesRendered; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) #endif - { - return error; - } + { + return error; + } - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; - if ( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - } - else - { - *needNewFrame = false; - } + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; + if ( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + } + else + { + *needNewFrame = false; } } + } - *nOutSamples = nSamplesRendered; + *nOutSamples = nSamplesRendered; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} #ifdef SPLIT_REND_WITH_HEAD_ROT - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetSplitBinauralBitstream( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetSplitBinauralBitstream( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : indication that the decoder needs a new frame */ - ) - { - Decoder_Struct *st_ivas; - AUDIO_CONFIG output_config; - int32_t output_Fs; - float *pOutput[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; - float output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; - float pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; - 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]; - int16_t numSamplesPerChannelToDecode; - int16_t i, j; - ivas_error error; - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; - int16_t max_band; - int16_t pcm_out_flag; - int16_t td_input; - int16_t numPoses; - int16_t slots_rendered, slots_rendered_new; - int16_t ro_md_flag; - IVAS_QUATERNION Quaternion; - - error = IVAS_ERR_OK; - st_ivas = hIvasDec->st_ivas; - output_config = st_ivas->hDecoderConfig->output_config; - output_Fs = st_ivas->hDecoderConfig->output_Fs; - numSamplesPerChannelToDecode = ( int16_t )( output_Fs / FRAMES_PER_SEC ); +ivas_error IVAS_DEC_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ +) +{ + Decoder_Struct *st_ivas; + AUDIO_CONFIG output_config; + int32_t output_Fs; + float *pOutput[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; + float output[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; + float pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; + 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]; + int16_t numSamplesPerChannelToDecode; + int16_t i, j; + ivas_error error; + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + int16_t max_band; + int16_t pcm_out_flag; + int16_t td_input; + int16_t numPoses; + int16_t slots_rendered, slots_rendered_new; + int16_t ro_md_flag; + IVAS_QUATERNION Quaternion; - *needNewFrame = false; - hSplitBinRend = st_ivas->hSplitBinRend; + error = IVAS_ERR_OK; + st_ivas = hIvasDec->st_ivas; + output_config = st_ivas->hDecoderConfig->output_config; + output_Fs = st_ivas->hDecoderConfig->output_Fs; + numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC ); - if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) - { - return error; - } + *needNewFrame = false; + hSplitBinRend = st_ivas->hSplitBinRend; + + if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } - numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; #ifdef OBJ_EDITING_API - /* init flush buffer for rate switch if not already initizalized */ - if ( hIvasDec->flushbuffer == NULL ) - { - hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); - hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; - set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); - } + /* init flush buffer for rate switch if not already initizalized */ + if ( hIvasDec->flushbuffer == NULL ) + { + hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); + hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; + set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + } #endif - if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && - ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) - { - numSamplesPerChannelToDecode = ( int16_t )( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); - numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; - } + if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); + numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; + } - if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) - { - return IVAS_ERR_WRONG_PARAMS; - } + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + { + return IVAS_ERR_WRONG_PARAMS; + } - if ( st_ivas->hTcBuffer == NULL || hIvasDec->hasBeenFedFrame ) + if ( st_ivas->hTcBuffer == NULL || hIvasDec->hasBeenFedFrame ) + { + slots_rendered = 0; + } + else + { + /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - slots_rendered = 0; + slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); } else { - /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - } - else - { - slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; - } - } - - /* Decode and render */ - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) - { - return error; + slots_rendered = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; } + } - /* change buffer layout */ - for ( i = 0; i < numSamplesPerChannelToDecode; ++i ) - { - for ( j = 0; j < BINAURAL_CHANNELS * numPoses; ++j ) - { - output[j][i] = pcmBuf[i * BINAURAL_CHANNELS * numPoses + j]; - } - } - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + /* Decode and render */ + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* change buffer layout */ + for ( i = 0; i < numSamplesPerChannelToDecode; ++i ) + { + for ( j = 0; j < BINAURAL_CHANNELS * numPoses; ++j ) { - pOutput[i] = output[i]; + output[j][i] = pcmBuf[i * BINAURAL_CHANNELS * numPoses + j]; } + } + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + pOutput[i] = output[i]; + } - if ( st_ivas->hTcBuffer == NULL ) + if ( st_ivas->hTcBuffer == NULL ) + { + slots_rendered_new = 0; + } + else + { + /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - slots_rendered_new = 0; + slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); } else { - /* this is needed for OMASA-DISC, because the td-rend granularity is 240 samples at 48kHz, leading to wrong slot count. */ - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - } - else - { - slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; - } + slots_rendered_new = st_ivas->hTcBuffer->n_samples_rendered / st_ivas->hTcBuffer->n_samples_granularity; } + } - for ( i = 0; i < BINAURAL_CHANNELS * numPoses; ++i ) + for ( i = 0; i < BINAURAL_CHANNELS * numPoses; ++i ) + { + for ( j = slots_rendered; j < slots_rendered_new; ++j ) { - for ( j = slots_rendered; j < slots_rendered_new; ++j ) - { - mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[i][j], Cldfb_RealBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); - mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[i][j], Cldfb_ImagBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); - } + mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[i][j], Cldfb_RealBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); + mvr2r( hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[i][j], Cldfb_ImagBuffer_Binaural[i][j - slots_rendered], CLDFB_NO_CHANNELS_MAX ); } + } - max_band = ( int16_t )( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); - pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; + max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); + pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; - if ( st_ivas->hBinRendererTd != NULL ) - { - ro_md_flag = 1; - } - else - { - ro_md_flag = 0; - } + if ( st_ivas->hBinRendererTd != NULL ) + { + ro_md_flag = 1; + } + else + { + ro_md_flag = 0; + } - if ( st_ivas->hHeadTrackData != NULL ) - { - Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; - } - else - { - Quaternion.w = -3.0f; - Quaternion.x = 0.0f; - Quaternion.y = 0.0f; - Quaternion.z = 0.0f; - } + if ( st_ivas->hHeadTrackData != NULL ) + { + Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; + } + else + { + Quaternion.w = -3.0f; + Quaternion.x = 0.0f; + Quaternion.y = 0.0f; + Quaternion.z = 0.0f; + } - if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, - Quaternion, - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, #endif - st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - splitRendBits, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK ) - { - return error; - } + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + Cldfb_RealBuffer_Binaural, + Cldfb_ImagBuffer_Binaural, + max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK ) + { + return error; + } - /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ - if ( pcm_out_flag ) + /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ + if ( pcm_out_flag ) + { + if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { - if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) - { #ifndef DISABLE_LIMITER - ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); #endif - } - else - { - ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); - } + } + else + { + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); + } #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += #endif - ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); - } + ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + } - free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); + free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); - return error; - } + return error; +} #endif - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_Setup( ) * * *---------------------------------------------------------------------*/ - static ivas_error IVAS_DEC_Setup( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t * nTcBufferGranularity, /* o : granularity of the TC Buffer */ - uint8_t * nTransportChannels, /* o : number of decoded transport PCM channels */ - uint8_t * nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ - uint16_t * nSamplesRendered, /* o : number of samples flushed from the last frame */ +static ivas_error IVAS_DEC_Setup( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t *nTcBufferGranularity, /* o : granularity of the TC Buffer */ + uint8_t *nTransportChannels, /* o : number of decoded transport PCM channels */ + uint8_t *nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ + uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif - ) - { - ivas_error error; +) +{ + ivas_error error; - *nSamplesRendered = 0; + *nSamplesRendered = 0; - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + { + if ( hIvasDec->st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { - if ( hIvasDec->st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) - { - *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; - *nOutChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; - } - else - { - *nTransportChannels = 1; - *nOutChannels = 1; - } + *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; + *nOutChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; } else { - Decoder_Struct *st_ivas; + *nTransportChannels = 1; + *nOutChannels = 1; + } + } + else + { + Decoder_Struct *st_ivas; - st_ivas = hIvasDec->st_ivas; + st_ivas = hIvasDec->st_ivas; - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * IVAS decoder setup * - read IVAS format signaling * - read IVAS format specific signaling @@ -1711,550 +1711,550 @@ ivas_error IVAS_DEC_FeedFrame_Serial( * - reconfigure the decoder when the number of TC or IVAS total bitrate change *----------------------------------------------------------------*/ - if ( st_ivas->bfi == 0 ) - { + if ( st_ivas->bfi == 0 ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, pcm_type_API_to_internal( pcmType ), data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, pcm_type_API_to_internal( pcmType ), data ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - { - return error; - } + { + return error; } + } - *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; - *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; - *nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; + *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; + *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; + *nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; #ifdef SPLIT_REND_WITH_HEAD_ROT - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * ISAR: * - initialize ISAR handle at the first frame * - reconfigure the ISAR handle in case of bitrate switching (renderer might change) *-----------------------------------------------------------------*/ - if ( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) + if ( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) + { + if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - -#endif } - return IVAS_ERR_OK; +#endif } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetTcSamples( ) * * Main function to decode to PCM data of the transport channels *---------------------------------------------------------------------*/ - static ivas_error IVAS_DEC_GetTcSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - float *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ - int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ - ) - { - Decoder_Struct *st_ivas; - ivas_error error; +static ivas_error IVAS_DEC_GetTcSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ +) +{ + Decoder_Struct *st_ivas; + ivas_error error; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - st_ivas = hIvasDec->st_ivas; + st_ivas = hIvasDec->st_ivas; - *nOutSamples = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + { + if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf, NULL ) ) != IVAS_ERR_OK ) { - if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf, NULL ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) + } + else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) + { + /* run the main IVAS decoding routine */ + if ( ( error = ivas_jbm_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) { - /* run the main IVAS decoding routine */ - if ( ( error = ivas_jbm_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) - { - return error; - } - - hIvasDec->isInitialized = true; /* Initialization done in ivas_dec() */ + return error; } - if ( hIvasDec->hasBeenFedFirstGoodFrame ) - { - hIvasDec->hasDecodedFirstGoodFrame = true; - } + hIvasDec->isInitialized = true; /* Initialization done in ivas_dec() */ + } - return IVAS_ERR_OK; + if ( hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasDec->hasDecodedFirstGoodFrame = true; } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_Rendered_FeedTcSamples( ) * * Feed decoded transport channels samples to the renderer *---------------------------------------------------------------------*/ - static ivas_error IVAS_DEC_RendererFeedTcSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call */ - float *pcmBuf /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ - ) - { - Decoder_Struct *st_ivas; +static ivas_error IVAS_DEC_RendererFeedTcSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call */ + float *pcmBuf /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ +) +{ + Decoder_Struct *st_ivas; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - st_ivas = hIvasDec->st_ivas; + st_ivas = hIvasDec->st_ivas; - /* feed the TCs to the IVAS renderer */ - ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesForRendering, nSamplesResidual, pcmBuf ); + /* feed the TCs to the IVAS renderer */ + ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesForRendering, nSamplesResidual, pcmBuf ); - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetRenderedSamples( ) * * Main function to render the transport channels to PCM output data *---------------------------------------------------------------------*/ - static ivas_error IVAS_DEC_GetRenderedSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renderer pipeline */ +static ivas_error IVAS_DEC_GetRenderedSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renderer pipeline */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf /* o : output synthesis signal */ #else int16_t *pcmBuf #endif - ) - { - Decoder_Struct *st_ivas; - ivas_error error; +) +{ + Decoder_Struct *st_ivas; + ivas_error error; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - st_ivas = hIvasDec->st_ivas; + st_ivas = hIvasDec->st_ivas; - /* run the main IVAS decoding routine */ + /* run the main IVAS decoding routine */ #ifdef SPLIT_REND_WITH_HEAD_ROT - error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); + error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); #else error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); #endif - return error; - } + return error; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetBufferedNumberOfSamples( ) * * Returns the number of objects available in the decoded bitstream *---------------------------------------------------------------------*/ - static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t * nSamplesBuffered /* o : number of samples still buffered */ - ) +static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *nSamplesBuffered /* o : number of samples still buffered */ +) +{ + *nSamplesBuffered = 0; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { - *nSamplesBuffered = 0; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - /* check if the TC buffer already exists, otherweise nothing is buffered anyway */ - if ( hIvasDec->st_ivas->hTcBuffer != NULL ) - { - *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered; - *nSamplesBuffered += hIvasDec->hVoIP->nSamplesRendered20ms; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - return IVAS_ERR_OK; + /* check if the TC buffer already exists, otherweise nothing is buffered anyway */ + if ( hIvasDec->st_ivas->hTcBuffer != NULL ) + { + *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered; + *nSamplesBuffered += hIvasDec->hVoIP->nSamplesRendered20ms; } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetNumObjects( ) * * Returns the number of objects available in the decoded bitstream *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetNumObjects( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t * numObjects /* o : number of objects for which the decoder has been configured */ - ) - { - int16_t is_masa_ism; - is_masa_ism = 0; +ivas_error IVAS_DEC_GetNumObjects( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t *numObjects /* o : number of objects for which the decoder has been configured */ +) +{ + int16_t is_masa_ism; + is_masa_ism = 0; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - if ( hIvasDec->st_ivas->hMasa != NULL ) - { - if ( hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) - { - is_masa_ism = 1; - } - } - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || is_masa_ism ) - { - *numObjects = hIvasDec->st_ivas->nchan_ism; - } - else + if ( hIvasDec->st_ivas->hMasa != NULL ) + { + if ( hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) { - *numObjects = 0; + is_masa_ism = 1; } - - return IVAS_ERR_OK; + } + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || is_masa_ism ) + { + *numObjects = hIvasDec->st_ivas->nchan_ism; + } + else + { + *numObjects = 0; } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetFormat( ) * * Returns the format of currently decoded bitstream. * Note: bitstream format is only known after the first (good) frame has been decoded. *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetFormat( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_BS_FORMAT * format /* o : format detected from bitstream fed to the decoder */ - ) +ivas_error IVAS_DEC_GetFormat( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_BS_FORMAT *format /* o : format detected from bitstream fed to the decoder */ +) +{ + if ( hIvasDec->hasDecodedFirstGoodFrame ) { - if ( hIvasDec->hasDecodedFirstGoodFrame ) - { - *format = mapIvasFormat( hIvasDec->st_ivas->ivas_format ); - } - else - { - *format = IVAS_DEC_BS_UNKOWN; - } - - if ( *format == IVAS_DEC_BS_MASA && hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) - { - *format = IVAS_DEC_BS_MASA_ISM; - } + *format = mapIvasFormat( hIvasDec->st_ivas->ivas_format ); + } + else + { + *format = IVAS_DEC_BS_UNKOWN; + } - return IVAS_ERR_OK; + if ( *format == IVAS_DEC_BS_MASA && hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + { + *format = IVAS_DEC_BS_MASA_ISM; } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * getInputBufferSize() * * *---------------------------------------------------------------------*/ - static int16_t getOutputBufferSize( - const Decoder_Struct *st_ivas /* i : IVAS decoder handle */ - ) +static int16_t getOutputBufferSize( + const Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +) +{ + if ( st_ivas->hDecoderConfig == NULL ) { - if ( st_ivas->hDecoderConfig == NULL ) - { - return -1; - } + return -1; + } - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) / FRAMES_PER_SEC ); + } + else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + if ( st_ivas->hLsSetupCustom == NULL ) { - return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) / FRAMES_PER_SEC ); + return -1; } - else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) - { - if ( st_ivas->hLsSetupCustom == NULL ) - { - return -1; - } - return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * ( st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe ) / FRAMES_PER_SEC ); - } - else - { - return ( int16_t )( st_ivas->hDecoderConfig->output_Fs * st_ivas->hDecoderConfig->nchan_out / FRAMES_PER_SEC ); - } + return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * ( st_ivas->hLsSetupCustom->num_spk + st_ivas->hLsSetupCustom->num_lfe ) / FRAMES_PER_SEC ); + } + else + { + return (int16_t) ( st_ivas->hDecoderConfig->output_Fs * st_ivas->hDecoderConfig->nchan_out / FRAMES_PER_SEC ); } +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetOutputBufferSize() * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetOutputBufferSize( - const IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ - int16_t *outputBufferSize /* o : total number of samples expected in the output buffer for current decoder configuration */ - ) +ivas_error IVAS_DEC_GetOutputBufferSize( + const IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ + int16_t *outputBufferSize /* o : total number of samples expected in the output buffer for current decoder configuration */ +) +{ + if ( outputBufferSize == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { - if ( outputBufferSize == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *outputBufferSize = getOutputBufferSize( hIvasDec->st_ivas ); + *outputBufferSize = getOutputBufferSize( hIvasDec->st_ivas ); - if ( *outputBufferSize == -1 ) - { - return IVAS_ERR_INVALID_OUTPUT_BUFFER_SIZE; - } - else - { - return IVAS_ERR_OK; - } + if ( *outputBufferSize == -1 ) + { + return IVAS_ERR_INVALID_OUTPUT_BUFFER_SIZE; + } + else + { + return IVAS_ERR_OK; } +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetNumOutputChannels( ) * * Returns number of output channels *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetNumOutputChannels( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t * numOutputChannels /* o : number of PCM output channels */ - ) +ivas_error IVAS_DEC_GetNumOutputChannels( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *numOutputChannels /* o : number of PCM output channels */ +) +{ + if ( hIvasDec->hasDecodedFirstGoodFrame ) { - if ( hIvasDec->hasDecodedFirstGoodFrame ) - { - *numOutputChannels = hIvasDec->st_ivas->hDecoderConfig->nchan_out; - } - else - { - *numOutputChannels = 0; - } - - return IVAS_ERR_OK; + *numOutputChannels = hIvasDec->st_ivas->hDecoderConfig->nchan_out; } + else + { + *numOutputChannels = 0; + } + + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetObjectMetadata( ) * * Get metadata of one object decoded in the most recent frame *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetObjectMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_ISM_METADATA * metadata, /* o : struct where metadata decoded in most recently decoded frame will be written */ - const uint16_t zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ - const uint16_t objectIdx /* i : index of the queried object */ - ) - { - Decoder_Struct *st_ivas; - ISM_METADATA_HANDLE hIsmMeta; - int16_t is_masa_ism; - is_masa_ism = 0; +ivas_error IVAS_DEC_GetObjectMetadata( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_ISM_METADATA *metadata, /* o : struct where metadata decoded in most recently decoded frame will be written */ + const uint16_t zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ + const uint16_t objectIdx /* i : index of the queried object */ +) +{ + Decoder_Struct *st_ivas; + ISM_METADATA_HANDLE hIsmMeta; + int16_t is_masa_ism; + is_masa_ism = 0; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - st_ivas = hIvasDec->st_ivas; - if ( hIvasDec->st_ivas->hMasa != NULL ) - { - if ( hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) - { - is_masa_ism = 1; - } - } - if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != MASA_ISM_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT && is_masa_ism == 0 ) + st_ivas = hIvasDec->st_ivas; + if ( hIvasDec->st_ivas->hMasa != NULL ) + { + if ( hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) { - return IVAS_ERR_WRONG_MODE; + is_masa_ism = 1; } + } + if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != MASA_ISM_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT && is_masa_ism == 0 ) + { + return IVAS_ERR_WRONG_MODE; + } - if ( objectIdx >= st_ivas->nchan_ism ) - { - return IVAS_ERR_INVALID_INDEX; - } + if ( objectIdx >= st_ivas->nchan_ism ) + { + return IVAS_ERR_INVALID_INDEX; + } - hIsmMeta = st_ivas->hIsmMetaData[objectIdx]; + hIsmMeta = st_ivas->hIsmMetaData[objectIdx]; - if ( hIsmMeta == NULL || zero_flag || ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) ) - { - metadata->azimuth = 0.f; - metadata->elevation = 0.f; - metadata->radius = 1.f; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->yaw = 0.f; - metadata->pitch = 0.f; - metadata->non_diegetic_flag = 0; - } - else - { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; - } - - return IVAS_ERR_OK; + if ( hIsmMeta == NULL || zero_flag || ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) ) + { + metadata->azimuth = 0.f; + metadata->elevation = 0.f; + metadata->radius = 1.f; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->yaw = 0.f; + metadata->pitch = 0.f; + metadata->non_diegetic_flag = 0; + } + else + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetMasaMetadata( ) * * Get metadata of the most recently decoded MASA frame *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetMasaMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - MASA_DECODER_EXT_OUT_META_HANDLE * hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ - const uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ - ) +ivas_error IVAS_DEC_GetMasaMetadata( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ + const uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - if ( hIvasDec->st_ivas->ivas_format != MASA_FORMAT && hIvasDec->st_ivas->ivas_format != MASA_ISM_FORMAT ) - { - return IVAS_ERR_WRONG_MODE; - } + if ( hIvasDec->st_ivas->ivas_format != MASA_FORMAT && hIvasDec->st_ivas->ivas_format != MASA_ISM_FORMAT ) + { + return IVAS_ERR_WRONG_MODE; + } - if ( getFromJbmBuffer ) - { - ivas_jbm_masa_sf_to_sf_map( hIvasDec->st_ivas ); - } + if ( getFromJbmBuffer ) + { + ivas_jbm_masa_sf_to_sf_map( hIvasDec->st_ivas ); + } - *hMasaExtOutMeta = hIvasDec->st_ivas->hMasa->data.extOutMeta; + *hMasaExtOutMeta = hIvasDec->st_ivas->hMasa->data.extOutMeta; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_FeedHeadTrackData( ) * * Feed the decoder with the head tracking data *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_FeedHeadTrackData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ - IVAS_VECTOR3 Pos, /* i : listener position */ +ivas_error IVAS_DEC_FeedHeadTrackData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ + IVAS_VECTOR3 Pos, /* i : listener position */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const int16_t subframe_idx, /* i : subframe index */ - const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ + const int16_t subframe_idx, /* i : subframe index */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ #else const int16_t subframe_idx /* i : subframe index */ #endif - ) - { - HEAD_TRACK_DATA_HANDLE hHeadTrackData; - ivas_error error; +) +{ + HEAD_TRACK_DATA_HANDLE hHeadTrackData; + ivas_error error; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hHeadTrackData = hIvasDec->st_ivas->hHeadTrackData; + hHeadTrackData = hIvasDec->st_ivas->hHeadTrackData; - if ( hHeadTrackData == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hHeadTrackData == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - /* Move head-tracking data to the decoder handle */ - /* check for Euler angle signaling */ - if ( orientation.w == -3.0f ) - { - Euler2Quat( deg2rad( orientation.x ), deg2rad( orientation.y ), deg2rad( orientation.z ), &orientation ); - } + /* Move head-tracking data to the decoder handle */ + /* check for Euler angle signaling */ + if ( orientation.w == -3.0f ) + { + Euler2Quat( deg2rad( orientation.x ), deg2rad( orientation.y ), deg2rad( orientation.z ), &orientation ); + } - if ( ( error = ivas_orient_trk_Process( hHeadTrackData->OrientationTracker, orientation, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hHeadTrackData->Quaternions[subframe_idx] ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = ivas_orient_trk_Process( hHeadTrackData->OrientationTracker, orientation, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hHeadTrackData->Quaternions[subframe_idx] ) ) != IVAS_ERR_OK ) + { + return error; + } - hHeadTrackData->Pos[subframe_idx].x = Pos.x; - hHeadTrackData->Pos[subframe_idx].y = Pos.y; - hHeadTrackData->Pos[subframe_idx].z = Pos.z; + hHeadTrackData->Pos[subframe_idx].x = Pos.x; + hHeadTrackData->Pos[subframe_idx].y = Pos.y; + hHeadTrackData->Pos[subframe_idx].z = Pos.z; #ifdef SPLIT_REND_WITH_HEAD_ROT - hHeadTrackData->sr_pose_pred_axis = rot_axis; + hHeadTrackData->sr_pose_pred_axis = rot_axis; #endif - hIvasDec->updateOrientation = true; + hIvasDec->updateOrientation = true; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_FeedRefRotData( ) * * Feed the decoder with the reference rotation *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_FeedRefRotData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION rotation /* i : reference rotation data */ - ) - { - ivas_orient_trk_state_t *pOtr; +ivas_error IVAS_DEC_FeedRefRotData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_QUATERNION rotation /* i : reference rotation data */ +) +{ + ivas_orient_trk_state_t *pOtr; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHeadTrackData == NULL || hIvasDec->st_ivas->hHeadTrackData->OrientationTracker == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHeadTrackData == NULL || hIvasDec->st_ivas->hHeadTrackData->OrientationTracker == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; + pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; - pOtr->refRot.w = rotation.w; - pOtr->refRot.x = rotation.x; - pOtr->refRot.z = rotation.z; - pOtr->refRot.y = rotation.y; + pOtr->refRot.w = rotation.w; + pOtr->refRot.x = rotation.x; + pOtr->refRot.z = rotation.z; + pOtr->refRot.y = rotation.y; - hIvasDec->updateOrientation = true; + hIvasDec->updateOrientation = true; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_FeedRefVectorData( ) * * Feed the decoder with a reference vector spanning from listenerPos @@ -2262,401 +2262,401 @@ ivas_error IVAS_DEC_FeedFrame_Serial( * OTR_TRACKING_REF_POS_LEV modes. *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_FeedRefVectorData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_VECTOR3 listenerPos, /* i : Listener position */ - const IVAS_VECTOR3 refPos /* i : Reference position */ - ) - { - ivas_orient_trk_state_t *pOtr; +ivas_error IVAS_DEC_FeedRefVectorData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_VECTOR3 listenerPos, /* i : Listener position */ + const IVAS_VECTOR3 refPos /* i : Reference position */ +) +{ + ivas_orient_trk_state_t *pOtr; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHeadTrackData == NULL || hIvasDec->st_ivas->hHeadTrackData->OrientationTracker == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHeadTrackData == NULL || hIvasDec->st_ivas->hHeadTrackData->OrientationTracker == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; + pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; - hIvasDec->updateOrientation = true; + hIvasDec->updateOrientation = true; - return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos ); - } + return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos ); +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_FeedExternalOrientationData( ) * * Feed the decoder with the external orientation data *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_FeedExternalOrientationData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : external orientation data */ - int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ - int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t subframe_idx /* i : subframe index */ - ) - { - EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; +ivas_error IVAS_DEC_FeedExternalOrientationData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_QUATERNION orientation, /* i : external orientation data */ + int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ + int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const int16_t subframe_idx /* i : subframe index */ +) +{ + EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hExternalOrientationData = hIvasDec->st_ivas->hExtOrientationData; + hExternalOrientationData = hIvasDec->st_ivas->hExtOrientationData; - if ( hExternalOrientationData == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hExternalOrientationData == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - /* Move external orientation data to the decoder handle (invert orientations) */ - QuaternionInverse( orientation, &hExternalOrientationData->Quaternions[subframe_idx] ); + /* Move external orientation data to the decoder handle (invert orientations) */ + QuaternionInverse( orientation, &hExternalOrientationData->Quaternions[subframe_idx] ); - hExternalOrientationData->enableHeadRotation[subframe_idx] = enableHeadRotation; - hExternalOrientationData->enableExternalOrientation[subframe_idx] = enableExternalOrientation; - hExternalOrientationData->enableRotationInterpolation[subframe_idx] = enableRotationInterpolation; - hExternalOrientationData->numFramesToTargetOrientation[subframe_idx] = numFramesToTargetOrientation; + hExternalOrientationData->enableHeadRotation[subframe_idx] = enableHeadRotation; + hExternalOrientationData->enableExternalOrientation[subframe_idx] = enableExternalOrientation; + hExternalOrientationData->enableRotationInterpolation[subframe_idx] = enableRotationInterpolation; + hExternalOrientationData->numFramesToTargetOrientation[subframe_idx] = numFramesToTargetOrientation; - hIvasDec->updateOrientation = true; + hIvasDec->updateOrientation = true; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_FeedCustomLsData( ) * * Feed the decoder with the Custom loudspeaker data *---------------------------------------------------------------------*/ - /*! r: error code */ - ivas_error IVAS_DEC_FeedCustomLsData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_CUSTOM_LS_DATA hLsCustomData /* i : Custom loudspeaker setup data */ - ) - { - int16_t i, is_planar; - IVAS_LSSETUP_CUSTOM_HANDLE hLsSetupCustom; +/*! r: error code */ +ivas_error IVAS_DEC_FeedCustomLsData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_CUSTOM_LS_DATA hLsCustomData /* i : Custom loudspeaker setup data */ +) +{ + int16_t i, is_planar; + IVAS_LSSETUP_CUSTOM_HANDLE hLsSetupCustom; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hLsSetupCustom = hIvasDec->st_ivas->hLsSetupCustom; + hLsSetupCustom = hIvasDec->st_ivas->hLsSetupCustom; - if ( hLsSetupCustom == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hLsSetupCustom == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - /* Move Custom LS layout data to the decoder handle */ + /* Move Custom LS layout data to the decoder handle */ - /* Loudspeaker azimuths and elevations */ - hLsSetupCustom->num_spk = hLsCustomData.num_spk; + /* Loudspeaker azimuths and elevations */ + hLsSetupCustom->num_spk = hLsCustomData.num_spk; - mvr2r( hLsCustomData.azimuth, hLsSetupCustom->ls_azimuth, hLsCustomData.num_spk ); - mvr2r( hLsCustomData.elevation, hLsSetupCustom->ls_elevation, hLsCustomData.num_spk ); + mvr2r( hLsCustomData.azimuth, hLsSetupCustom->ls_azimuth, hLsCustomData.num_spk ); + mvr2r( hLsCustomData.elevation, hLsSetupCustom->ls_elevation, hLsCustomData.num_spk ); - /* Set planar flag */ - is_planar = 1; - for ( i = 0; i < hLsCustomData.num_spk; i++ ) + /* Set planar flag */ + is_planar = 1; + for ( i = 0; i < hLsCustomData.num_spk; i++ ) + { + if ( is_planar && hLsSetupCustom->ls_elevation[i] != 0.0f ) { - if ( is_planar && hLsSetupCustom->ls_elevation[i] != 0.0f ) - { - is_planar = 0; - } + is_planar = 0; } - hLsSetupCustom->is_planar_setup = is_planar; + } + hLsSetupCustom->is_planar_setup = is_planar; - /* Loudspeaker LFE */ - hLsSetupCustom->num_lfe = hLsCustomData.num_lfe; - mvs2s( hLsCustomData.lfe_idx, hLsSetupCustom->lfe_idx, hLsCustomData.num_lfe ); + /* Loudspeaker LFE */ + hLsSetupCustom->num_lfe = hLsCustomData.num_lfe; + mvs2s( hLsCustomData.lfe_idx, hLsSetupCustom->lfe_idx, hLsCustomData.num_lfe ); - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfHandle( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetHrtfHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_HANDLE * *hHrtfTD /* o : HRTF handle */ - ) +ivas_error IVAS_DEC_GetHrtfHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_HANDLE **hHrtfTD /* o : HRTF handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfTD == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfTD == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *hHrtfTD = &hIvasDec->st_ivas->hHrtfTD; + *hHrtfTD = &hIvasDec->st_ivas->hHrtfTD; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfCRendHandle( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetHrtfCRendHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_CREND_HANDLE * *hSetOfHRTF /* o : Set of HRTF handle */ - ) +ivas_error IVAS_DEC_GetHrtfCRendHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_CREND_HANDLE **hSetOfHRTF /* o : Set of HRTF handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSetOfHRTF == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSetOfHRTF == NULL ) - { - return IVAS_ERR_WRONG_PARAMS; - } + return IVAS_ERR_WRONG_PARAMS; + } - *hSetOfHRTF = &hIvasDec->st_ivas->hSetOfHRTF; + *hSetOfHRTF = &hIvasDec->st_ivas->hSetOfHRTF; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfFastConvHandle( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetHrtfFastConvHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_FASTCONV_HANDLE * *hHrtfFastConv /* o : FASTCONV HRTF handle */ - ) +ivas_error IVAS_DEC_GetHrtfFastConvHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_FASTCONV_HANDLE **hHrtfFastConv /* o : FASTCONV HRTF handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfFastConv == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfFastConv == NULL ) - { - return IVAS_ERR_WRONG_PARAMS; - } + return IVAS_ERR_WRONG_PARAMS; + } - *hHrtfFastConv = &hIvasDec->st_ivas->hHrtfFastConv; + *hHrtfFastConv = &hIvasDec->st_ivas->hHrtfFastConv; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfParamBinHandle( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetHrtfParamBinHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_PARAMBIN_HANDLE * *hHrtfParambin /* o : Parametric binauralizer HRTF handle */ - ) +ivas_error IVAS_DEC_GetHrtfParamBinHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfParambin == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfParambin == NULL ) - { - return IVAS_ERR_WRONG_PARAMS; - } + return IVAS_ERR_WRONG_PARAMS; + } - *hHrtfParambin = &hIvasDec->st_ivas->hHrtfParambin; + *hHrtfParambin = &hIvasDec->st_ivas->hHrtfParambin; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfStatisticsHandle( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetHrtfStatisticsHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_STATISTICS_HANDLE * *hHrtfStatistics /* o : HRTF statistics handle */ - ) +ivas_error IVAS_DEC_GetHrtfStatisticsHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) - { - return IVAS_ERR_WRONG_PARAMS; - } + return IVAS_ERR_WRONG_PARAMS; + } - *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; + *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * copyRendererConfigStruct( ) * * *---------------------------------------------------------------------*/ - static ivas_error copyRendererConfigStruct( - RENDER_CONFIG_HANDLE hRCin, - IVAS_RENDER_CONFIG_HANDLE hRCout ) +static ivas_error copyRendererConfigStruct( + RENDER_CONFIG_HANDLE hRCin, + IVAS_RENDER_CONFIG_HANDLE hRCout ) +{ + if ( hRCin == NULL || hRCout == NULL ) { - if ( hRCin == NULL || hRCout == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } #ifdef DEBUGGING - switch ( hRCin->renderer_type_override ) - { - case IVAS_RENDER_TYPE_OVERRIDE_CREND: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; - break; - case IVAS_RENDER_TYPE_OVERRIDE_FASTCONV: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; - break; - default: - hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; - break; - } + switch ( hRCin->renderer_type_override ) + { + case IVAS_RENDER_TYPE_OVERRIDE_CREND: + hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; + break; + case IVAS_RENDER_TYPE_OVERRIDE_FASTCONV: + hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; + break; + default: + hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; + break; + } #endif - hRCout->roomAcoustics.override = hRCin->roomAcoustics.override; - hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; - hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; - hRCout->roomAcoustics.inputPreDelay = hRCin->roomAcoustics.inputPreDelay; + hRCout->roomAcoustics.override = hRCin->roomAcoustics.override; + hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; + hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; + hRCout->roomAcoustics.inputPreDelay = hRCin->roomAcoustics.inputPreDelay; - mvr2r( hRCin->roomAcoustics.pFc_input, hRCout->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); - mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); - mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); - mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); + mvr2r( hRCin->roomAcoustics.pFc_input, hRCout->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); + mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); + mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); + mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); #ifdef SPLIT_REND_WITH_HEAD_ROT - hRCout->split_rend_config = hRCin->split_rend_config; + hRCout->split_rend_config = hRCin->split_rend_config; #endif - hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; - hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; + hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; + hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetRenderConfig( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetRenderConfig( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ - ) +ivas_error IVAS_DEC_GetRenderConfig( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL || hRCout == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL || hRCout == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - return copyRendererConfigStruct( hIvasDec->st_ivas->hRenderConfig, hRCout ); + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - /*! r: error code*/ - ivas_error IVAS_DEC_GetDefaultRenderConfig( - IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ - ) - { - RENDER_CONFIG_DATA RCin; - RENDER_CONFIG_HANDLE hRCin = &RCin; - ivas_error error; + return copyRendererConfigStruct( hIvasDec->st_ivas->hRenderConfig, hRCout ); +} - if ( ( error = ivas_render_config_init_from_rom( &hRCin ) ) != IVAS_ERR_OK ) - { - return error; - } +/*! r: error code*/ +ivas_error IVAS_DEC_GetDefaultRenderConfig( + IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ +) +{ + RENDER_CONFIG_DATA RCin; + RENDER_CONFIG_HANDLE hRCin = &RCin; + ivas_error error; - return copyRendererConfigStruct( hRCin, hRCout ); + if ( ( error = ivas_render_config_init_from_rom( &hRCin ) ) != IVAS_ERR_OK ) + { + return error; } + return copyRendererConfigStruct( hRCin, hRCout ); +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_FeedRenderConfig( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_FeedRenderConfig( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ - ) - { - RENDER_CONFIG_HANDLE hRenderConfig; - ivas_error error; +ivas_error IVAS_DEC_FeedRenderConfig( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ +) +{ + RENDER_CONFIG_HANDLE hRenderConfig; + ivas_error error; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hRenderConfig = hIvasDec->st_ivas->hRenderConfig; + hRenderConfig = hIvasDec->st_ivas->hRenderConfig; #ifdef DEBUGGING - hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; - if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) - { - hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; - } - if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND ) - { - hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; - } + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; + if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) + { + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV; + } + if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND ) + { + hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; + } #endif - hRenderConfig->roomAcoustics.override = renderConfig.roomAcoustics.override; - hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; - hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay; - hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.roomAcoustics.inputPreDelay; + hRenderConfig->roomAcoustics.override = renderConfig.roomAcoustics.override; + hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; + hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay; + hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.roomAcoustics.inputPreDelay; - hRenderConfig->roomAcoustics.use_er = 0; - if ( renderConfig.roomAcoustics.use_er == 1 ) - { - hRenderConfig->roomAcoustics.use_er = renderConfig.roomAcoustics.use_er; - hRenderConfig->roomAcoustics.lowComplexity = renderConfig.roomAcoustics.lowComplexity; - hRenderConfig->roomAcoustics.dimensions = renderConfig.roomAcoustics.dimensions; - hRenderConfig->roomAcoustics.ListenerOrigin = renderConfig.roomAcoustics.ListenerOrigin; + hRenderConfig->roomAcoustics.use_er = 0; + if ( renderConfig.roomAcoustics.use_er == 1 ) + { + hRenderConfig->roomAcoustics.use_er = renderConfig.roomAcoustics.use_er; + hRenderConfig->roomAcoustics.lowComplexity = renderConfig.roomAcoustics.lowComplexity; + hRenderConfig->roomAcoustics.dimensions = renderConfig.roomAcoustics.dimensions; + hRenderConfig->roomAcoustics.ListenerOrigin = renderConfig.roomAcoustics.ListenerOrigin; - mvr2r( renderConfig.roomAcoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); - } + mvr2r( renderConfig.roomAcoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); + } - mvr2r( renderConfig.roomAcoustics.pFc_input, hRenderConfig->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); - mvr2r( renderConfig.roomAcoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); - mvr2r( renderConfig.roomAcoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); + mvr2r( renderConfig.roomAcoustics.pFc_input, hRenderConfig->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); + mvr2r( renderConfig.roomAcoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); + mvr2r( renderConfig.roomAcoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); - /* Re-initialize reverb instance if already available */ + /* Re-initialize reverb instance if already available */ #ifdef SPLIT_REND_WITH_HEAD_ROT - /* TD renderer Jot reverberator */ - if ( hIvasDec->st_ivas->hReverb != NULL ) + /* TD renderer Jot reverberator */ + if ( hIvasDec->st_ivas->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } - /* CREND Jot reverberator */ - if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0] != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) + /* CREND Jot reverberator */ + if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0] != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } - /* FB reverberator */ - if ( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL ) + /* FB reverberator */ + if ( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) ); + if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) { - ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) ); - if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } #else /* TD renderer Jot reverberator */ if ( hIvasDec->st_ivas->hReverb != NULL ) @@ -2686,242 +2686,265 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } } #endif - /* Fastconv CLDFB reverberator */ - if ( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL ) + /* Fastconv CLDFB reverberator */ + if ( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) ); + if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hBinRenderer->conv_band, hIvasDec->st_ivas->hBinRenderer->timeSlots, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) { - ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) ); - if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hBinRenderer->conv_band, hIvasDec->st_ivas->hBinRenderer->timeSlots, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } - mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); - mvr2r( renderConfig.distAtt, hRenderConfig->distAtt, 3 ); + mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); + mvr2r( renderConfig.distAtt, hRenderConfig->distAtt, 3 ); #ifdef SPLIT_REND_WITH_HEAD_ROT - hRenderConfig->split_rend_config = renderConfig.split_rend_config; + hRenderConfig->split_rend_config = renderConfig.split_rend_config; - /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ - if ( hRenderConfig->split_rend_config.dof == 0 ) - { - hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; - } + /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ + if ( hRenderConfig->split_rend_config.dof == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } - if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + { + return error; + } #endif - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetDelay( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetDelay( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t * nSamples, /* o : decoder delay in samples */ - int32_t * timeScale /* o : time scale of the delay, equal to decoder output sampling rate */ - ) - { - Decoder_Struct *st_ivas; - DECODER_CONFIG_HANDLE hDecoderConfig; +ivas_error IVAS_DEC_GetDelay( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *nSamples, /* o : decoder delay in samples */ + int32_t *timeScale /* o : time scale of the delay, equal to decoder output sampling rate */ +) +{ + Decoder_Struct *st_ivas; + DECODER_CONFIG_HANDLE hDecoderConfig; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || nSamples == NULL || timeScale == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || nSamples == NULL || timeScale == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - if ( !hIvasDec->hasDecodedFirstGoodFrame ) - { - /* Delay depends on IVAS format, which is unknown until first frame has been decoded */ - return IVAS_ERR_WAITING_FOR_BITSTREAM; - } + if ( !hIvasDec->hasDecodedFirstGoodFrame ) + { + /* Delay depends on IVAS format, which is unknown until first frame has been decoded */ + return IVAS_ERR_WAITING_FOR_BITSTREAM; + } - st_ivas = hIvasDec->st_ivas; - hDecoderConfig = st_ivas->hDecoderConfig; + st_ivas = hIvasDec->st_ivas; + hDecoderConfig = st_ivas->hDecoderConfig; #ifdef SPLIT_REND_WITH_HEAD_ROT - nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ); + nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ); #else nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0] ) ); #endif - nSamples[2] = (int16_t) roundf( (float) st_ivas->binaural_latency_ns * hDecoderConfig->output_Fs / 1000000000.f ); - nSamples[0] = nSamples[1] + nSamples[2]; + nSamples[2] = (int16_t) roundf( (float) st_ivas->binaural_latency_ns * hDecoderConfig->output_Fs / 1000000000.f ); + nSamples[0] = nSamples[1] + nSamples[2]; - if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - /* note: in MASA, all delay is compensated at the decoder by default, so subtract the encoder delay for print-out */ - nSamples[1] -= NS2SA( hDecoderConfig->output_Fs, IVAS_ENC_DELAY_NS ); - } + if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + /* note: in MASA, all delay is compensated at the decoder by default, so subtract the encoder delay for print-out */ + nSamples[1] -= NS2SA( hDecoderConfig->output_Fs, IVAS_ENC_DELAY_NS ); + } - *timeScale = hDecoderConfig->output_Fs; + *timeScale = hDecoderConfig->output_Fs; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_HasDecodedFirstGoodFrame( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - bool *hasDecodedFirstGoodFrame /* o : flag indicating if the decoder has decoded a good frame since it was configured */ - ) +ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + bool *hasDecodedFirstGoodFrame /* o : flag indicating if the decoder has decoded a good frame since it was configured */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hasDecodedFirstGoodFrame == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hasDecodedFirstGoodFrame == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *hasDecodedFirstGoodFrame = hIvasDec->hasDecodedFirstGoodFrame; + *hasDecodedFirstGoodFrame = hIvasDec->hasDecodedFirstGoodFrame; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetPcmFrameSize( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetPcmFrameSize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int32_t * pcmFrameSize /* o : total size of the PCM output frame. This takes into account the number of output channels */ - ) +ivas_error IVAS_DEC_GetPcmFrameSize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int32_t *pcmFrameSize /* o : total size of the PCM output frame. This takes into account the number of output channels */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || pcmFrameSize == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || pcmFrameSize == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - if ( hIvasDec->hasDecodedFirstGoodFrame ) - { - *pcmFrameSize = hIvasDec->st_ivas->hDecoderConfig->nchan_out * hIvasDec->st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC; - } - else - { - *pcmFrameSize = 0; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - return IVAS_ERR_OK; + if ( hIvasDec->hasDecodedFirstGoodFrame ) + { + *pcmFrameSize = hIvasDec->st_ivas->hDecoderConfig->nchan_out * hIvasDec->st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC; + } + else + { + *pcmFrameSize = 0; } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * isSidFrame( ) * * Check if a frame contains a SID *---------------------------------------------------------------------*/ - static bool isSidFrame( - const uint16_t size ) +static bool isSidFrame( + const uint16_t size ) +{ + if ( size == SID_1k75 / FRAMES_PER_SEC ) { - if ( size == SID_1k75 / FRAMES_PER_SEC ) - { - return true; /* AMR-WB SID */ - } - else if ( size == SID_2k40 / FRAMES_PER_SEC ) - { - return true; /* EVS SID */ - } - else if ( size == IVAS_SID_5k2 / FRAMES_PER_SEC ) - { - return true; /* IVAS SID */ - } - - return false; + return true; /* AMR-WB SID */ } - - static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, uint16_t num_bits ) + else if ( size == SID_2k40 / FRAMES_PER_SEC ) + { + return true; /* EVS SID */ + } + else if ( size == IVAS_SID_5k2 / FRAMES_PER_SEC ) { + return true; /* IVAS SID */ + } + + return false; +} + +static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, uint16_t num_bits ) +{ /* Bitstream conversion is not counted towards complexity and memory usage */ #define WMC_TOOL_SKIP - uint32_t i; - uint8_t byte = 0; - const uint8_t mask = 0x80; + uint32_t i; + uint8_t byte = 0; + const uint8_t mask = 0x80; - for ( i = 0; i < num_bits; ++i ) + for ( i = 0; i < num_bits; ++i ) + { + if ( i % 8 == 0 ) { - if ( i % 8 == 0 ) - { - byte = compact[i / 8]; - } + byte = compact[i / 8]; + } - serial[i] = ( byte & mask ) >> 7; + serial[i] = ( byte & mask ) >> 7; - byte <<= 1; - } + byte <<= 1; + } - /* Add 4 padding bytes required by core coder */ - for ( i = 0; i < 4 * 8; ++i ) - { - serial[num_bits + i] = 0; - } -#undef WMC_TOOL_SKIP + /* Add 4 padding bytes required by core coder */ + for ( i = 0; i < 4 * 8; ++i ) + { + serial[num_bits + i] = 0; } +#undef WMC_TOOL_SKIP +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_VoIP_FeedFrame( ) * * Feed RTP packet into internal jitter buffer *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_VoIP_FeedFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint8_t * au, /* i : buffer containing input access unit */ - const uint16_t auSize, /* i : size of the access unit */ - const uint16_t rtpSequenceNumber, /* i : RTP sequence number (16 bits) */ - const uint32_t rtpTimeStamp, /* i : RTP timestamp (32 bits) */ - const uint32_t rcvTime_ms, /* i : receive time of the RTP packet in milliseconds */ - const bool qBit /* i : Q bit for AMR-WB IO */ - ) - { - JB4_DATAUNIT_HANDLE dataUnit; - int16_t partialCopyFrameType, partialCopyOffset; - int16_t result; - - if ( auSize == 0 ) - { - return IVAS_ERR_OK; /* ignore empty/NO_DATA frame - shouldn't be transmitted in RTP */ - } - if ( ( auSize + 7 ) / 8 > MAX_AU_SIZE ) - { - return IVAS_ERR_INVALID_BITSTREAM; - } +ivas_error IVAS_DEC_VoIP_FeedFrame( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint8_t *au, /* i : buffer containing input access unit */ + const uint16_t auSize, /* i : size of the access unit */ + const uint16_t rtpSequenceNumber, /* i : RTP sequence number (16 bits) */ + const uint32_t rtpTimeStamp, /* i : RTP timestamp (32 bits) */ + const uint32_t rcvTime_ms, /* i : receive time of the RTP packet in milliseconds */ + const bool qBit /* i : Q bit for AMR-WB IO */ +) +{ + JB4_DATAUNIT_HANDLE dataUnit; + int16_t partialCopyFrameType, partialCopyOffset; + int16_t result; + + if ( auSize == 0 ) + { + return IVAS_ERR_OK; /* ignore empty/NO_DATA frame - shouldn't be transmitted in RTP */ + } + if ( ( auSize + 7 ) / 8 > MAX_AU_SIZE ) + { + return IVAS_ERR_INVALID_BITSTREAM; + } - partialCopyFrameType = 0; - partialCopyOffset = 0; + partialCopyFrameType = 0; + partialCopyOffset = 0; - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) - { - /* check if frame contains a partial copy and get its offset */ - evs_dec_previewFrame( au, auSize, &partialCopyFrameType, &partialCopyOffset ); - } + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + { + /* check if frame contains a partial copy and get its offset */ + evs_dec_previewFrame( au, auSize, &partialCopyFrameType, &partialCopyOffset ); + } - /* create data unit for primary copy in the frame */ + /* create data unit for primary copy in the frame */ + dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); + mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); + dataUnit->dataSize = auSize; + dataUnit->duration = 20; + dataUnit->sequenceNumber = rtpSequenceNumber; + dataUnit->silenceIndicator = isSidFrame( dataUnit->dataSize ); + dataUnit->timeScale = 1000; + dataUnit->rcvTime = rcvTime_ms; + dataUnit->timeStamp = rtpTimeStamp; + dataUnit->partial_frame = 0; + dataUnit->partialCopyOffset = partialCopyOffset; + dataUnit->qBit = qBit; + + /* add the frame to the JBM */ + result = JB4_PushDataUnit( hIvasDec->hVoIP->hJBM, dataUnit, rcvTime_ms ); + if ( result != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + + if ( partialCopyFrameType != RF_NO_DATA && partialCopyOffset != 0 ) + { + /* create data unit for partial copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; - dataUnit->silenceIndicator = isSidFrame( dataUnit->dataSize ); + dataUnit->silenceIndicator = 0; /* there are no partial copies for SID frames */ dataUnit->timeScale = 1000; dataUnit->rcvTime = rcvTime_ms; - dataUnit->timeStamp = rtpTimeStamp; - dataUnit->partial_frame = 0; + dataUnit->timeStamp = rtpTimeStamp - partialCopyOffset * dataUnit->duration; + dataUnit->partial_frame = 1; dataUnit->partialCopyOffset = partialCopyOffset; dataUnit->qBit = qBit; @@ -2931,289 +2954,266 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { return IVAS_ERR_UNKNOWN; } - - if ( partialCopyFrameType != RF_NO_DATA && partialCopyOffset != 0 ) - { - /* create data unit for partial copy in the frame */ - dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); - dataUnit->dataSize = auSize; - dataUnit->duration = 20; - dataUnit->sequenceNumber = rtpSequenceNumber; - dataUnit->silenceIndicator = 0; /* there are no partial copies for SID frames */ - dataUnit->timeScale = 1000; - dataUnit->rcvTime = rcvTime_ms; - dataUnit->timeStamp = rtpTimeStamp - partialCopyOffset * dataUnit->duration; - dataUnit->partial_frame = 1; - dataUnit->partialCopyOffset = partialCopyOffset; - dataUnit->qBit = qBit; - - /* add the frame to the JBM */ - result = JB4_PushDataUnit( hIvasDec->hVoIP->hJBM, dataUnit, rcvTime_ms ); - if ( result != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - - return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* * IVAS_DEC_VoIP_SetScale( ) * * Set the TSM scale *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_VoIP_SetScale( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t maxScaling, /* i : max allowed absolute difference in samples from the default 20ms frame size */ - const int16_t scale /* i : TSM scale to set in percent of the default frame size */ - ) - { - ivas_error error; - - error = IVAS_ERR_OK; +ivas_error IVAS_DEC_VoIP_SetScale( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t maxScaling, /* i : max allowed absolute difference in samples from the default 20ms frame size */ + const int16_t scale /* i : TSM scale to set in percent of the default frame size */ +) +{ + ivas_error error; - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) - { - return IVAS_ERR_TSM_NOT_ENABLED; - } - else - { - hIvasDec->tsm_scale = scale; - hIvasDec->tsm_max_scaling = maxScaling; - } + error = IVAS_ERR_OK; - return error; + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) + { + return IVAS_ERR_TSM_NOT_ENABLED; + } + else + { + hIvasDec->tsm_scale = scale; + hIvasDec->tsm_max_scaling = maxScaling; } - /*---------------------------------------------------------------------* + return error; +} + +/*---------------------------------------------------------------------* * IVAS_DEC_VoIP_SetScale( ) * * Set the TSM scale *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_TSM_SetQuality( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const float quality /* i : target TSM quality */ - ) - { - ivas_error error; - - error = IVAS_ERR_OK; +ivas_error IVAS_DEC_TSM_SetQuality( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const float quality /* i : target TSM quality */ +) +{ + ivas_error error; - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) - { - return IVAS_ERR_TSM_NOT_ENABLED; - } - else - { - hIvasDec->tsm_quality = quality; - } + error = IVAS_ERR_OK; - return error; + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) + { + return IVAS_ERR_TSM_NOT_ENABLED; + } + else + { + hIvasDec->tsm_quality = quality; } + return error; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) * * Main function to decode one frame in VoIP *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ +ivas_error IVAS_DEC_VoIP_GetSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif - const uint32_t systemTimestamp_ms /* i : current system timestamp */ + const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE - , - JbmTraceFileWriterFn jbmWriterFn, - void *jbmWriter + , + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter #endif #ifdef OBJ_EDITING_API - , - uint16_t *nSamplesRendered, - bool *parametersAvailableForEditing + , + uint16_t *nSamplesRendered, + bool *parametersAvailableForEditing #endif - ) - { - Decoder_Struct *st_ivas; - DECODER_CONFIG_HANDLE hDecoderConfig; - IVAS_DEC_VOIP *hVoIP; - uint32_t extBufferedTime_ms, scale, maxScaling; - JB4_DATAUNIT_HANDLE dataUnit; - uint16_t extBufferedSamples; - int16_t result; - ivas_error error; +) +{ + Decoder_Struct *st_ivas; + DECODER_CONFIG_HANDLE hDecoderConfig; + IVAS_DEC_VOIP *hVoIP; + uint32_t extBufferedTime_ms, scale, maxScaling; + JB4_DATAUNIT_HANDLE dataUnit; + uint16_t extBufferedSamples; + int16_t result; + ivas_error error; #ifndef OBJ_EDITING_API - int16_t nSamplesRendered; + int16_t nSamplesRendered; #endif - uint8_t nOutChannels; + uint8_t nOutChannels; - st_ivas = hIvasDec->st_ivas; - hDecoderConfig = st_ivas->hDecoderConfig; - hVoIP = hIvasDec->hVoIP; - nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; + st_ivas = hIvasDec->st_ivas; + hDecoderConfig = st_ivas->hDecoderConfig; + hVoIP = hIvasDec->hVoIP; + nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; #ifndef OBJ_EDITING_API - nSamplesRendered = 0; + nSamplesRendered = 0; #endif #ifdef OBJ_EDITING_API - *parametersAvailableForEditing = false; + *parametersAvailableForEditing = false; #endif - if ( nSamplesPerChannel == 0 ) - { - return IVAS_ERR_WRONG_PARAMS; - } + if ( nSamplesPerChannel == 0 ) + { + return IVAS_ERR_WRONG_PARAMS; + } - /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ + /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ #ifdef OBJ_EDITING_API - while ( *nSamplesRendered < nSamplesPerChannel ) + while ( *nSamplesRendered < nSamplesPerChannel ) #else while ( nSamplesRendered < nSamplesPerChannel ) #endif + { + if ( hIvasDec->nSamplesAvailableNext == 0 ) { - if ( hIvasDec->nSamplesAvailableNext == 0 ) + int16_t nSamplesBuffered; + nSamplesBuffered = 0; + if ( hIvasDec->hasBeenFedFirstGoodFrame ) { - int16_t nSamplesBuffered; - nSamplesBuffered = 0; - if ( hIvasDec->hasBeenFedFirstGoodFrame ) + if ( ( error = IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ) ) != IVAS_ERR_OK ) { - if ( ( error = IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } - extBufferedSamples = nSamplesBuffered; - extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; - dataUnit = NULL; + extBufferedSamples = nSamplesBuffered; + extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; + dataUnit = NULL; - /* pop one access unit from the jitter buffer */ - result = JB4_PopDataUnit( hVoIP->hJBM, systemTimestamp_ms, extBufferedTime_ms, &dataUnit, &scale, &maxScaling ); - if ( result != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - maxScaling = maxScaling * hDecoderConfig->output_Fs / 1000; + /* pop one access unit from the jitter buffer */ + result = JB4_PopDataUnit( hVoIP->hJBM, systemTimestamp_ms, extBufferedTime_ms, &dataUnit, &scale, &maxScaling ); + if ( result != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + maxScaling = maxScaling * hDecoderConfig->output_Fs / 1000; #ifdef DEBUG_MODE_JBM - dbgwrite( &extBufferedSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_extBufferedSamples.dat" ); - dbgwrite( &systemTimestamp_ms, sizeof( uint32_t ), 1, 1, "./res/JBM_systemTimestamp.dat" ); - dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); - dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); + dbgwrite( &extBufferedSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_extBufferedSamples.dat" ); + dbgwrite( &systemTimestamp_ms, sizeof( uint32_t ), 1, 1, "./res/JBM_systemTimestamp.dat" ); + dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); + dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif - /* avoid time scaling multiple times within one 20ms frame*/ - if ( scale != 100U ) + /* avoid time scaling multiple times within one 20ms frame*/ + if ( scale != 100U ) + { + if ( hIvasDec->timeScalingDone ) { - if ( hIvasDec->timeScalingDone ) - { - scale = 100; - } + scale = 100; } + } - /* limit scale to range supported by time scaler */ - if ( scale < APA_MIN_SCALE ) - { - scale = APA_MIN_SCALE; - } - else if ( scale > APA_MAX_SCALE ) - { - scale = APA_MAX_SCALE; - } + /* limit scale to range supported by time scaler */ + if ( scale < APA_MIN_SCALE ) + { + scale = APA_MIN_SCALE; + } + else if ( scale > APA_MAX_SCALE ) + { + scale = APA_MAX_SCALE; + } - if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (int16_t) maxScaling, (int16_t) scale ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (int16_t) maxScaling, (int16_t) scale ) ) != IVAS_ERR_OK ) + { + return error; + } - /* copy bitstream into decoder state */ - if ( dataUnit ) - { - hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; + /* copy bitstream into decoder state */ + if ( dataUnit ) + { + hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; - bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); + bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ) != IVAS_ERR_OK ) + { + return error; } - else if ( hIvasDec->hasDecodedFirstGoodFrame ) + } + else if ( hIvasDec->hasDecodedFirstGoodFrame ) + { + /* Decoder has been initialized with first good frame - do PLC */ + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ) != IVAS_ERR_OK ) { - /* Decoder has been initialized with first good frame - do PLC */ - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } #ifdef SUPPORT_JBM_TRACEFILE - /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ - if ( jbmWriterFn != NULL && jbmWriter != NULL ) + /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ + if ( jbmWriterFn != NULL && jbmWriter != NULL ) + { + /* write JBM trace data entry */ + store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); + if ( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) { - /* write JBM trace data entry */ - store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); - if ( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError writing JBM Trace data to file\n" ); - return IVAS_ERR_UNKNOWN; - } + fprintf( stderr, "\nError writing JBM Trace data to file\n" ); + return IVAS_ERR_UNKNOWN; } + } #endif - if ( dataUnit ) - { - if ( dataUnit->partial_frame != 0 ) - { - hVoIP->lastDecodedWasActive = 1; - } - else - { - hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; - } - - /* data unit memory is no longer used */ - JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); - } - - if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + if ( dataUnit ) + { + if ( dataUnit->partial_frame != 0 ) { - hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; - hIvasDec->nSamplesRendered = 0; + hVoIP->lastDecodedWasActive = 1; } -#ifdef OBJ_EDITING_API - /* :TODO: only return here if we really have editing initialized */ - if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) + else { - *parametersAvailableForEditing = true; - return IVAS_ERR_OK; + hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; } -#endif + + /* data unit memory is no longer used */ + JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); } - /* decode */ if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { - /* codec mode to use not known yet - simply output silence */ - /* directly set output zero */ - int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); + hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; + hIvasDec->nSamplesRendered = 0; + } +#ifdef OBJ_EDITING_API + /* :TODO: only return here if we really have editing initialized */ + if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) + { + *parametersAvailableForEditing = true; + return IVAS_ERR_OK; + } +#endif + } + + /* decode */ + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + /* codec mode to use not known yet - simply output silence */ + /* directly set output zero */ + int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); #ifdef OBJ_EDITING_API #ifdef SPLIT_REND_WITH_HEAD_ROT - set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); + set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); #else - set_s( pcmBuf + ( *nSamplesRendered ) * nOutChannels, 0, nSamplesToZero * nOutChannels ); + set_s( pcmBuf + ( *nSamplesRendered ) * nOutChannels, 0, nSamplesToZero * nOutChannels ); #endif - *nSamplesRendered += nSamplesToZero; + *nSamplesRendered += nSamplesToZero; #else #ifdef SPLIT_REND_WITH_HEAD_ROT set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); @@ -3222,44 +3222,44 @@ ivas_error IVAS_DEC_FeedFrame_Serial( #endif nSamplesRendered += nSamplesToZero; #endif - hIvasDec->nSamplesRendered += nSamplesToZero; - hIvasDec->nSamplesAvailableNext -= nSamplesToZero; - update_voip_rendered20ms( hIvasDec, nSamplesToZero ); - } - else - { - int16_t nSamplesToRender, nSamplesRendered_loop; - bool tmp; + hIvasDec->nSamplesRendered += nSamplesToZero; + hIvasDec->nSamplesAvailableNext -= nSamplesToZero; + update_voip_rendered20ms( hIvasDec, nSamplesToZero ); + } + else + { + int16_t nSamplesToRender, nSamplesRendered_loop; + bool tmp; #ifdef OBJ_EDITING_API - nSamplesToRender = nSamplesPerChannel - *nSamplesRendered; + nSamplesToRender = nSamplesPerChannel - *nSamplesRendered; #else nSamplesToRender = nSamplesPerChannel - nSamplesRendered; #endif #ifdef OBJ_EDITING_API - /* check if we still need to prepare the renderer */ - if ( hIvasDec->hasBeenPreparedRendering == false ) - { + /* check if we still need to prepare the renderer */ + if ( hIvasDec->hasBeenPreparedRendering == false ) + { - if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) + { + return error; } + } #endif - /* render IVAS frames directly to the output buffer */ + /* render IVAS frames directly to the output buffer */ #ifdef OBJ_EDITING_API #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + *nSamplesRendered * nOutChannels, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + *nSamplesRendered * nOutChannels, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #endif - { - return error; - } + { + return error; + } - *nSamplesRendered += nSamplesRendered_loop; + *nSamplesRendered += nSamplesRendered_loop; #else #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) @@ -3272,1475 +3272,1475 @@ ivas_error IVAS_DEC_FeedFrame_Serial( nSamplesRendered += nSamplesRendered_loop; #endif - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); - } + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } - - return IVAS_ERR_OK; } - /*---------------------------------------------------------------------* + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * * Function to flush remaining audio in VoIP *---------------------------------------------------------------------*/ - static void update_voip_rendered20ms( - IVAS_DEC_HANDLE hIvasDec, - const int16_t nSamplesRendered ) +static void update_voip_rendered20ms( + IVAS_DEC_HANDLE hIvasDec, + const int16_t nSamplesRendered ) +{ + int16_t nSamplesRenderedTotal; + nSamplesRenderedTotal = hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered; + /* we have crossed a 20ms border, reset the time scaling done flag */ + if ( nSamplesRenderedTotal >= hIvasDec->hVoIP->nSamplesFrame ) { - int16_t nSamplesRenderedTotal; - nSamplesRenderedTotal = hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered; - /* we have crossed a 20ms border, reset the time scaling done flag */ - if ( nSamplesRenderedTotal >= hIvasDec->hVoIP->nSamplesFrame ) - { - hIvasDec->timeScalingDone = 0; - } - hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; + hIvasDec->timeScalingDone = 0; } + hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) * * Function to flush remaining audio in VoIP *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_Flush( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ +ivas_error IVAS_DEC_Flush( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif - int16_t *nSamplesFlushed /* o : number of samples flushed */ - ) - { - ivas_error error; - uint16_t nSamplesToRender; - uint16_t nSamplesFlushedLocal; + int16_t *nSamplesFlushed /* o : number of samples flushed */ +) +{ + ivas_error error; + uint16_t nSamplesToRender; + uint16_t nSamplesFlushedLocal; - *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); + *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); - nSamplesToRender = (uint16_t) *nSamplesFlushed; + nSamplesToRender = (uint16_t) *nSamplesFlushed; - /* render IVAS frames */ - error = IVAS_ERR_OK; - if ( nSamplesToRender > 0 && hIvasDec->st_ivas->ivas_format != MONO_FORMAT ) - { + /* render IVAS frames */ + error = IVAS_ERR_OK; + if ( nSamplesToRender > 0 && hIvasDec->st_ivas->ivas_format != MONO_FORMAT ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT - error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); + error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); #else error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); #endif - } - else - { - *nSamplesFlushed = 0; - } - return error; } + else + { + *nSamplesFlushed = 0; + } + return error; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_VoIP_IsEmpty( ) * * *---------------------------------------------------------------------*/ - bool IVAS_DEC_VoIP_IsEmpty( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked ) - { - return ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && ( hIvasDec->nSamplesAvailableNext < nSamplesAsked ) ); - } +bool IVAS_DEC_VoIP_IsEmpty( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked ) +{ + return ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && ( hIvasDec->nSamplesAvailableNext < nSamplesAsked ) ); +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Get_CA_offset( ) * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_VoIP_Get_CA_offset( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t * optimum_offset, - int16_t * FEC_hi ) +ivas_error IVAS_DEC_VoIP_Get_CA_offset( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *optimum_offset, + int16_t *FEC_hi ) +{ + if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || hIvasDec->hVoIP->hJBM == NULL ) { - if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || hIvasDec->hVoIP->hJBM == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *optimum_offset = JB4_getFECoffset( hIvasDec->hVoIP->hJBM ); - *FEC_hi = JB4_FECoffset( hIvasDec->hVoIP->hJBM ); + *optimum_offset = JB4_getFECoffset( hIvasDec->hVoIP->hJBM ); + *FEC_hi = JB4_FECoffset( hIvasDec->hVoIP->hJBM ); - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_Close_VoIP( ) * * *---------------------------------------------------------------------*/ - static void IVAS_DEC_Close_VoIP( - IVAS_DEC_VOIP * hVoIP /* i/o: IVAS decoder handle */ - ) - { - JB4_Destroy( &hVoIP->hJBM ); +static void IVAS_DEC_Close_VoIP( + IVAS_DEC_VOIP *hVoIP /* i/o: IVAS decoder handle */ +) +{ + JB4_Destroy( &hVoIP->hJBM ); - if ( hVoIP->bs_conversion_buf != NULL ) - { + if ( hVoIP->bs_conversion_buf != NULL ) + { #define WMC_TOOL_SKIP - /* Bitstream conversion is not counted towards complexity and memory usage */ - free( hVoIP->bs_conversion_buf ); + /* Bitstream conversion is not counted towards complexity and memory usage */ + free( hVoIP->bs_conversion_buf ); #undef WMC_TOOL_SKIP - } + } - free( hVoIP ); + free( hVoIP ); - return; - } + return; +} #ifdef SUPPORT_JBM_TRACEFILE - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * store_JbmData() * * Store JBM trace data entry *---------------------------------------------------------------------*/ - static void store_JbmData( - IVAS_DEC_VOIP * hVoIP, - JB4_DATAUNIT_HANDLE dataUnit, - const uint32_t systemTimestamp_ms, - const uint16_t extBufferedSamples, - const int32_t output_Fs ) - { - IVAS_JBM_TRACE_DATA *JbmTraceData; - - if ( hVoIP == NULL ) - { - return; - } +static void store_JbmData( + IVAS_DEC_VOIP *hVoIP, + JB4_DATAUNIT_HANDLE dataUnit, + const uint32_t systemTimestamp_ms, + const uint16_t extBufferedSamples, + const int32_t output_Fs ) +{ + IVAS_JBM_TRACE_DATA *JbmTraceData; - JbmTraceData = &hVoIP->JbmTraceData; + if ( hVoIP == NULL ) + { + return; + } - JbmTraceData->systemTimestamp_ms = systemTimestamp_ms; - JbmTraceData->extBufferedSamples = extBufferedSamples; - JbmTraceData->lastDecodedWasActive = hVoIP->lastDecodedWasActive; - JbmTraceData->output_Fs = output_Fs; - JbmTraceData->dataUnit_flag = dataUnit != NULL; - if ( dataUnit != NULL ) - { - JbmTraceData->sequenceNumber = dataUnit->sequenceNumber; - JbmTraceData->timeStamp = dataUnit->timeStamp; - JbmTraceData->rcvTime = dataUnit->rcvTime; - JbmTraceData->partial_frame = dataUnit->partial_frame; - JbmTraceData->partialCopyOffset = dataUnit->partialCopyOffset; - } + JbmTraceData = &hVoIP->JbmTraceData; - return; + JbmTraceData->systemTimestamp_ms = systemTimestamp_ms; + JbmTraceData->extBufferedSamples = extBufferedSamples; + JbmTraceData->lastDecodedWasActive = hVoIP->lastDecodedWasActive; + JbmTraceData->output_Fs = output_Fs; + JbmTraceData->dataUnit_flag = dataUnit != NULL; + if ( dataUnit != NULL ) + { + JbmTraceData->sequenceNumber = dataUnit->sequenceNumber; + JbmTraceData->timeStamp = dataUnit->timeStamp; + JbmTraceData->rcvTime = dataUnit->rcvTime; + JbmTraceData->partial_frame = dataUnit->partial_frame; + JbmTraceData->partialCopyOffset = dataUnit->partialCopyOffset; } + return; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetJbmData() * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetJbmData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_JBM_TRACE_DATA * JbmTraceData /* o : JBM Trace data */ +ivas_error IVAS_DEC_GetJbmData( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_JBM_TRACE_DATA *JbmTraceData /* o : JBM Trace data */ - ) +) +{ + if ( hIvasDec->hVoIP == NULL ) { - if ( hIvasDec->hVoIP == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *JbmTraceData = hIvasDec->hVoIP->JbmTraceData; + *JbmTraceData = hIvasDec->hVoIP->JbmTraceData; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} #endif - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetErrorMessage( ) * * Maps error codes to error description strings *---------------------------------------------------------------------*/ - const char *IVAS_DEC_GetErrorMessage( - ivas_error error /* i : decoder error code enum */ - ) - { - return ivas_error_to_string( error ); - } +const char *IVAS_DEC_GetErrorMessage( + ivas_error error /* i : decoder error code enum */ +) +{ + return ivas_error_to_string( error ); +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * get_channel_config() * * Gets a str related to input config *---------------------------------------------------------------------*/ - static ivas_error get_channel_config( - AUDIO_CONFIG config, - char *str ) +static ivas_error get_channel_config( + AUDIO_CONFIG config, + char *str ) +{ + if ( config == IVAS_AUDIO_CONFIG_MONO ) { - if ( config == IVAS_AUDIO_CONFIG_MONO ) - { - strcpy( str, "Mono" ); - } - else if ( config == IVAS_AUDIO_CONFIG_STEREO ) - { - strcpy( str, "Stereo" ); - } - else if ( config == IVAS_AUDIO_CONFIG_5_1 ) - { - strcpy( str, "Multichannel 5.1 (CICP6)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_7_1 ) - { - strcpy( str, "Multichannel 7.1 (CICP12)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_5_1_2 ) - { - strcpy( str, "Multichannel 5.1+2 (CICP14)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_5_1_4 ) - { - strcpy( str, "Multichannel 5.1+4 (CICP16)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_7_1_4 ) - { - strcpy( str, "Multichannel 7.1+4 (CICP19)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) - { - strcpy( str, "Multichannel (custom loudspeaker layout)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_FOA ) - { - strcpy( str, "Ambisonics: First Order (FOA)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_HOA2 ) - { - strcpy( str, "Ambisonics: Second Order (HOA2)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_HOA3 ) - { - strcpy( str, "Ambisonics: Third Order (HOA3)" ); - } - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL ) - { - strcpy( str, "Binaural: no room" ); - } - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - strcpy( str, "Binaural: room with impulse responses" ); - } - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - strcpy( str, "Binaural: room with reverb" ); - } + strcpy( str, "Mono" ); + } + else if ( config == IVAS_AUDIO_CONFIG_STEREO ) + { + strcpy( str, "Stereo" ); + } + else if ( config == IVAS_AUDIO_CONFIG_5_1 ) + { + strcpy( str, "Multichannel 5.1 (CICP6)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_7_1 ) + { + strcpy( str, "Multichannel 7.1 (CICP12)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_5_1_2 ) + { + strcpy( str, "Multichannel 5.1+2 (CICP14)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_5_1_4 ) + { + strcpy( str, "Multichannel 5.1+4 (CICP16)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_7_1_4 ) + { + strcpy( str, "Multichannel 7.1+4 (CICP19)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + strcpy( str, "Multichannel (custom loudspeaker layout)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_FOA ) + { + strcpy( str, "Ambisonics: First Order (FOA)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_HOA2 ) + { + strcpy( str, "Ambisonics: Second Order (HOA2)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_HOA3 ) + { + strcpy( str, "Ambisonics: Third Order (HOA3)" ); + } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL ) + { + strcpy( str, "Binaural: no room" ); + } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + strcpy( str, "Binaural: room with impulse responses" ); + } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + strcpy( str, "Binaural: room with reverb" ); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) - { - strcpy( str, "BINAURAL_SPLIT_CODED" ); - } - else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - strcpy( str, "Binaural_Split_PCM" ); - } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + strcpy( str, "BINAURAL_SPLIT_CODED" ); + } + else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + strcpy( str, "Binaural_Split_PCM" ); + } #endif - else if ( config == IVAS_AUDIO_CONFIG_EXTERNAL ) - { - strcpy( str, "External renderer" ); - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Incorrect Input/Output Configuration" ); - } - - return IVAS_ERR_OK; + else if ( config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + strcpy( str, "External renderer" ); + } + else + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Incorrect Input/Output Configuration" ); } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * printConfigInfo_dec( ) * * *---------------------------------------------------------------------*/ - static ivas_error printConfigInfo_dec( - Decoder_Struct * st_ivas, - const int16_t bitstreamformat, - const bool Opt_VOIP, - const bool quietModeEnabled ) - { - ivas_error error; - char config_str[50]; - AUDIO_CONFIG output_config; +static ivas_error printConfigInfo_dec( + Decoder_Struct *st_ivas, + const int16_t bitstreamformat, + const bool Opt_VOIP, + const bool quietModeEnabled ) +{ + ivas_error error; + char config_str[50]; + AUDIO_CONFIG output_config; - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print info on screen *-----------------------------------------------------------------*/ - fprintf( stdout, "\n" ); + fprintf( stdout, "\n" ); - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print output sampling frequency *-----------------------------------------------------------------*/ - fprintf( stdout, "Output sampling rate: %d Hz\n", st_ivas->hDecoderConfig->output_Fs ); + fprintf( stdout, "Output sampling rate: %d Hz\n", st_ivas->hDecoderConfig->output_Fs ); - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print bitrate *-----------------------------------------------------------------*/ - if ( !quietModeEnabled ) + if ( !quietModeEnabled ) + { + if ( !Opt_VOIP ) { - if ( !Opt_VOIP ) - { - fprintf( stdout, "Bitrate: %.2f kbps\n", (float) st_ivas->hDecoderConfig->ivas_total_brate / 1000 ); + fprintf( stdout, "Bitrate: %.2f kbps\n", (float) st_ivas->hDecoderConfig->ivas_total_brate / 1000 ); - if ( st_ivas->hDecoderConfig->ivas_total_brate <= 0 ) + if ( st_ivas->hDecoderConfig->ivas_total_brate <= 0 ) + { + if ( bitstreamformat == G192 ) { - if ( bitstreamformat == G192 ) - { - fprintf( stdout, "Active Bitrate not identified in bitstream file \n" ); - } - else /* MIME */ - { - fprintf( stdout, "Active Bitrate not identified from first MIME frame \n" ); - } + fprintf( stdout, "Active Bitrate not identified in bitstream file \n" ); + } + else /* MIME */ + { + fprintf( stdout, "Active Bitrate not identified from first MIME frame \n" ); } } } + } - /*-----------------------------------------------------------------* + /*-----------------------------------------------------------------* * Print output configuration *-----------------------------------------------------------------*/ - if ( st_ivas->ivas_format == MONO_FORMAT ) + if ( st_ivas->ivas_format == MONO_FORMAT ) + { + if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) { - if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) - { - fprintf( stdout, "Output configuration: mono EVS bit-exact decoding to stereo\n" ); - fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); - } - else - { - fprintf( stdout, "Output configuration: mono EVS bit-exact decoding\n" ); - } + fprintf( stdout, "Output configuration: mono EVS bit-exact decoding to stereo\n" ); + fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); } else { - if ( !quietModeEnabled ) + fprintf( stdout, "Output configuration: mono EVS bit-exact decoding\n" ); + } + } + else + { + if ( !quietModeEnabled ) + { + if ( st_ivas->ivas_format == STEREO_FORMAT ) { - if ( st_ivas->ivas_format == STEREO_FORMAT ) - { - fprintf( stdout, "Input configuration: Stereo\n" ); - } - else if ( st_ivas->ivas_format == ISM_FORMAT ) - { - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) - { - fprintf( stdout, "Input configuration: ISM (ParamISM): 2 transport channels\n" ); - } - else - { - fprintf( stdout, "Input configuration: ISM: %d transport channel(s)\n", st_ivas->nchan_transport ); - } - } - else if ( st_ivas->ivas_format == SBA_FORMAT ) - { - fprintf( stdout, "Input configuration: Scene Based Audio, Ambisonic order %i%s, %d transport channel(s)\n", st_ivas->sba_order, st_ivas->sba_planar ? " (Planar)" : "", st_ivas->nchan_transport ); - } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - fprintf( stdout, "Input configuration: Combined Scene Based Audio, Ambisonic order %i, with %d Objects \n", st_ivas->sba_order, st_ivas->nchan_ism ); - } - else if ( st_ivas->ivas_format == MASA_FORMAT ) - { - fprintf( stdout, "Input configuration: MASA - %d channel(s)\n", st_ivas->nchan_transport ); - } - else if ( st_ivas->ivas_format == MC_FORMAT ) + fprintf( stdout, "Input configuration: Stereo\n" ); + } + else if ( st_ivas->ivas_format == ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( ( error = get_channel_config( st_ivas->transport_config, &config_str[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - - fprintf( stdout, "Input configuration: %s\n", config_str ); + fprintf( stdout, "Input configuration: ISM (ParamISM): 2 transport channels\n" ); } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + else { - fprintf( stdout, "Input configuration: combined ISM and MASA (%i ISM stream(s)) \n", st_ivas->nchan_ism ); + fprintf( stdout, "Input configuration: ISM: %d transport channel(s)\n", st_ivas->nchan_transport ); } } - - output_config = st_ivas->hDecoderConfig->output_config; - get_channel_config( output_config, &config_str[0] ); - fprintf( stdout, "Output configuration: %s\n", config_str ); - -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#else - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) -#endif + else if ( st_ivas->ivas_format == SBA_FORMAT ) { - fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); + fprintf( stdout, "Input configuration: Scene Based Audio, Ambisonic order %i%s, %d transport channel(s)\n", st_ivas->sba_order, st_ivas->sba_planar ? " (Planar)" : "", st_ivas->nchan_transport ); } - if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - fprintf( stdout, "HRIR/BRIR file: ON\n" ); + fprintf( stdout, "Input configuration: Combined Scene Based Audio, Ambisonic order %i, with %d Objects \n", st_ivas->sba_order, st_ivas->nchan_ism ); } - - if ( st_ivas->hDecoderConfig->Opt_RendConfigCustom ) + else if ( st_ivas->ivas_format == MASA_FORMAT ) { - fprintf( stdout, "Renderer config. file: ON\n" ); + fprintf( stdout, "Input configuration: MASA - %d channel(s)\n", st_ivas->nchan_transport ); } - - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + else if ( st_ivas->ivas_format == MC_FORMAT ) { - fprintf( stdout, "Head rotation: ON\n" ); - } + if ( ( error = get_channel_config( st_ivas->transport_config, &config_str[0] ) ) != IVAS_ERR_OK ) + { + return error; + } - if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) - { - fprintf( stdout, "External orientation: ON\n" ); + fprintf( stdout, "Input configuration: %s\n", config_str ); } - - if ( st_ivas->hDecoderConfig->orientation_tracking != IVAS_HEAD_ORIENT_TRK_NONE ) + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - switch ( st_ivas->hDecoderConfig->orientation_tracking ) - { - case IVAS_HEAD_ORIENT_TRK_AVG: - fprintf( stdout, "Orientation tracking: AVG\n" ); - break; - case IVAS_HEAD_ORIENT_TRK_REF: - fprintf( stdout, "Orientation tracking: REF\n" ); - break; - case IVAS_HEAD_ORIENT_TRK_REF_VEC: - fprintf( stdout, "Orientation tracking: REF_VEC\n" ); - break; - case IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV: - fprintf( stdout, "Orientation tracking: REF_VEC_LEV\n" ); - break; - default: - break; - } + fprintf( stdout, "Input configuration: combined ISM and MASA (%i ISM stream(s)) \n", st_ivas->nchan_ism ); } + } + + output_config = st_ivas->hDecoderConfig->output_config; + get_channel_config( output_config, &config_str[0] ); + fprintf( stdout, "Output configuration: %s\n", config_str ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif + { + fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); + } + if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + { + fprintf( stdout, "HRIR/BRIR file: ON\n" ); + } + + if ( st_ivas->hDecoderConfig->Opt_RendConfigCustom ) + { + fprintf( stdout, "Renderer config. file: ON\n" ); + } - if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) - { - fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); - } + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + fprintf( stdout, "Head rotation: ON\n" ); + } - if ( st_ivas->hDecoderConfig->Opt_dpid_on ) - { - fprintf( stdout, "Directivity pattern: ON\n" ); - } + if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + { + fprintf( stdout, "External orientation: ON\n" ); + } - if ( st_ivas->hDecoderConfig->Opt_aeid_on ) + if ( st_ivas->hDecoderConfig->orientation_tracking != IVAS_HEAD_ORIENT_TRK_NONE ) + { + switch ( st_ivas->hDecoderConfig->orientation_tracking ) { - fprintf( stdout, "Acoustic environment ID:ON\n" ); + case IVAS_HEAD_ORIENT_TRK_AVG: + fprintf( stdout, "Orientation tracking: AVG\n" ); + break; + case IVAS_HEAD_ORIENT_TRK_REF: + fprintf( stdout, "Orientation tracking: REF\n" ); + break; + case IVAS_HEAD_ORIENT_TRK_REF_VEC: + fprintf( stdout, "Orientation tracking: REF_VEC\n" ); + break; + case IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV: + fprintf( stdout, "Orientation tracking: REF_VEC_LEV\n" ); + break; + default: + break; } } - /*-----------------------------------------------------------------* - * Print TSM mode info - *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + { + fprintf( stdout, "Non-diegetic panning: %.2f\n", st_ivas->hDecoderConfig->non_diegetic_pan_gain * 90.f ); + } - if ( st_ivas->hDecoderConfig->Opt_tsm ) + if ( st_ivas->hDecoderConfig->Opt_dpid_on ) { - fprintf( stdout, "TSM mode: ON\n" ); + fprintf( stdout, "Directivity pattern: ON\n" ); } - return IVAS_ERR_OK; + if ( st_ivas->hDecoderConfig->Opt_aeid_on ) + { + fprintf( stdout, "Acoustic environment ID:ON\n" ); + } + } + + /*-----------------------------------------------------------------* + * Print TSM mode info + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + fprintf( stdout, "TSM mode: ON\n" ); } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* + +/*---------------------------------------------------------------------* * IVAS_DEC_PrintConfig( ) * * Print decoder set-up info *---------------------------------------------------------------------*/ - void IVAS_DEC_PrintConfig( - const IVAS_DEC_HANDLE hIvasDec, - const bool quietModeEnabled, - const bool voipMode ) - { - printConfigInfo_dec( hIvasDec->st_ivas, hIvasDec->bitstreamformat, voipMode, quietModeEnabled ); +void IVAS_DEC_PrintConfig( + const IVAS_DEC_HANDLE hIvasDec, + const bool quietModeEnabled, + const bool voipMode ) +{ + printConfigInfo_dec( hIvasDec->st_ivas, hIvasDec->bitstreamformat, voipMode, quietModeEnabled ); - return; - } + return; +} #ifdef DEBUGGING #define WMC_TOOL_SKIP - void IVAS_DEC_PrintConfigWithBitstream( - IVAS_DEC_HANDLE hIvasDec, - const bool quietModeEnabled, - uint16_t bit_stream[], - const int16_t num_bits ) - { - Decoder_Struct *st_ivas; +void IVAS_DEC_PrintConfigWithBitstream( + IVAS_DEC_HANDLE hIvasDec, + const bool quietModeEnabled, + uint16_t bit_stream[], + const int16_t num_bits ) +{ + Decoder_Struct *st_ivas; - /* Create a copy of decoder struct that will be modified by preview_indices(), + /* Create a copy of decoder struct that will be modified by preview_indices(), * leaving the original decoder struct unchanged. The additional memory used here * should not be counted towards memory footprint of the decoder. */ - st_ivas = malloc( sizeof( Decoder_Struct ) ); - memcpy( st_ivas, hIvasDec->st_ivas, sizeof( Decoder_Struct ) ); + st_ivas = malloc( sizeof( Decoder_Struct ) ); + memcpy( st_ivas, hIvasDec->st_ivas, sizeof( Decoder_Struct ) ); - preview_indices( st_ivas, bit_stream, num_bits ); + preview_indices( st_ivas, bit_stream, num_bits ); - /* Print config from modified decoder struct */ - printConfigInfo_dec( st_ivas, hIvasDec->bitstreamformat, hIvasDec->Opt_VOIP, quietModeEnabled ); + /* Print config from modified decoder struct */ + printConfigInfo_dec( st_ivas, hIvasDec->bitstreamformat, hIvasDec->Opt_VOIP, quietModeEnabled ); - free( st_ivas ); + free( st_ivas ); - return; - } + return; +} - void IVAS_DEC_PrintConfigWithVoipBitstream( - IVAS_DEC_HANDLE hIvasDec, - const bool quietModeEnabled, - uint8_t *au, - const uint16_t auSizeBits ) - { - Decoder_Struct *st_ivas; - uint16_t bit_stream[MAX_BITS_PER_FRAME + 4 * 8]; +void IVAS_DEC_PrintConfigWithVoipBitstream( + IVAS_DEC_HANDLE hIvasDec, + const bool quietModeEnabled, + uint8_t *au, + const uint16_t auSizeBits ) +{ + Decoder_Struct *st_ivas; + uint16_t bit_stream[MAX_BITS_PER_FRAME + 4 * 8]; - /* Create a copy of decoder struct that will be modified by preview_indices(), + /* Create a copy of decoder struct that will be modified by preview_indices(), * leaving the original decoder struct unchanged. The additional memory used here * should not be counted towards memory footprint of the decoder. */ - st_ivas = malloc( sizeof( Decoder_Struct ) ); - memcpy( st_ivas, hIvasDec->st_ivas, sizeof( Decoder_Struct ) ); + st_ivas = malloc( sizeof( Decoder_Struct ) ); + memcpy( st_ivas, hIvasDec->st_ivas, sizeof( Decoder_Struct ) ); - bsCompactToSerial( au, bit_stream, auSizeBits ); - preview_indices( st_ivas, bit_stream, auSizeBits ); + bsCompactToSerial( au, bit_stream, auSizeBits ); + preview_indices( st_ivas, bit_stream, auSizeBits ); - /* Print config from modified decoder struct */ - printConfigInfo_dec( st_ivas, hIvasDec->bitstreamformat, hIvasDec->Opt_VOIP, quietModeEnabled ); + /* Print config from modified decoder struct */ + printConfigInfo_dec( st_ivas, hIvasDec->bitstreamformat, hIvasDec->Opt_VOIP, quietModeEnabled ); - free( st_ivas ); + free( st_ivas ); - return; - } + return; +} #undef WMC_TOOL_SKIP #endif - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_PrintDisclaimer( ) * * Print IVAS disclaimer to console *---------------------------------------------------------------------*/ - void IVAS_DEC_PrintDisclaimer( void ) - { - print_disclaimer( stderr ); +void IVAS_DEC_PrintDisclaimer( void ) +{ + print_disclaimer( stderr ); - return; - } + return; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * evs_dec_main( ) * * EVS codec main decoder fucntion *---------------------------------------------------------------------*/ - static ivas_error evs_dec_main( - Decoder_Struct * st_ivas, - const int16_t nOutSamples, - float *floatBuf, - int16_t *pcmBuf ) - { - DEC_CORE_HANDLE *hCoreCoder; - float mixer_left, mixer_rigth; - float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; - int16_t ch; - ivas_error error; +static ivas_error evs_dec_main( + Decoder_Struct *st_ivas, + const int16_t nOutSamples, + float *floatBuf, + int16_t *pcmBuf ) +{ + DEC_CORE_HANDLE *hCoreCoder; + float mixer_left, mixer_rigth; + float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; + int16_t ch; + ivas_error error; - hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; - hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; + hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - mdct_switching_dec( hCoreCoder[0] ); + mdct_switching_dec( hCoreCoder[0] ); - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) - { - p_output[ch] = st_ivas->p_output_f[ch]; - } + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) + { + p_output[ch] = st_ivas->p_output_f[ch]; + } - /* run the main EVS decoding routine */ - if ( hCoreCoder[0]->codec_mode == MODE1 ) + /* run the main EVS decoding routine */ + if ( hCoreCoder[0]->codec_mode == MODE1 ) + { + if ( hCoreCoder[0]->Opt_AMR_WB ) { - if ( hCoreCoder[0]->Opt_AMR_WB ) + if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0] ) ) != IVAS_ERR_OK ) { - if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0] ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - else + } + else + { + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) { - if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } } - else + } + else + { + if ( hCoreCoder[0]->bfi == 0 ) { - if ( hCoreCoder[0]->bfi == 0 ) + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) { - if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - else if ( hCoreCoder[0]->bfi == 2 ) + } + else if ( hCoreCoder[0]->bfi == 2 ) + { + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) { - if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - else + } + else + { + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) { - if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } } + } - st_ivas->BER_detect = hCoreCoder[0]->BER_detect; + st_ivas->BER_detect = hCoreCoder[0]->BER_detect; - if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) - { - mixer_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; - mixer_rigth = 1.f - mixer_left; - v_multc( p_output[0], mixer_rigth, p_output[1], nOutSamples ); - v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); - } + if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + { + mixer_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; + mixer_rigth = 1.f - mixer_left; + v_multc( p_output[0], mixer_rigth, p_output[1], nOutSamples ); + v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); + } - if ( !st_ivas->hDecoderConfig->Opt_tsm ) - { - ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); - } - else if ( floatBuf != NULL ) - { - /* BE workaround */ - int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); + } + else if ( floatBuf != NULL ) + { + /* BE workaround */ + int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; - /* convert 'float' output data to 'short' */ + /* convert 'float' output data to 'short' */ #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += #endif - ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local ); + ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local ); - mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out ); - } - else - { + mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out ); + } + else + { #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += #endif - ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); - } - - return IVAS_ERR_OK; + ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } + return IVAS_ERR_OK; +} + #ifdef DEBUGGING - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetBer_detect_flag() * * return BER_detect flag *---------------------------------------------------------------------*/ - bool IVAS_DEC_GetBerDetectFlag( - IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ - ) +bool IVAS_DEC_GetBerDetectFlag( + IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ +) +{ + if ( hIvasDec->st_ivas->BER_detect == 1 ) { - if ( hIvasDec->st_ivas->BER_detect == 1 ) - { - return 1; - } - else - { - return 0; - } + return 1; + } + else + { + return 0; } +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetNoCLipping() * * return number of clipped samples *---------------------------------------------------------------------*/ - int32_t IVAS_DEC_GetNoCLipping( - IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ - ) - { - return hIvasDec->st_ivas->noClipping; - } +int32_t IVAS_DEC_GetNoCLipping( + IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ +) +{ + return hIvasDec->st_ivas->noClipping; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetCntFramesLimited() * * return number of frames where limiter is applied *---------------------------------------------------------------------*/ - int32_t IVAS_DEC_GetCntFramesLimited( - IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ - ) +int32_t IVAS_DEC_GetCntFramesLimited( + IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ +) +{ + if ( hIvasDec->st_ivas->hLimiter == NULL ) { - if ( hIvasDec->st_ivas->hLimiter == NULL ) - { - return 0; - } - else - { - return hIvasDec->st_ivas->hLimiter->cnt_frames_limited; - } + return 0; + } + else + { + return hIvasDec->st_ivas->hLimiter->cnt_frames_limited; } +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * forcedRendModeApiToInternalDec() * * *---------------------------------------------------------------------*/ - static ivas_error forcedRendModeApiToInternalDec( - const IVAS_DEC_FORCED_REND_MODE forcedRendMode, - int16_t *forcedModeInternal ) +static ivas_error forcedRendModeApiToInternalDec( + const IVAS_DEC_FORCED_REND_MODE forcedRendMode, + int16_t *forcedModeInternal ) +{ + switch ( forcedRendMode ) { - switch ( forcedRendMode ) - { - case IVAS_DEC_FORCE_REND_TD_RENDERER: - *forcedModeInternal = FORCE_TD_RENDERER; - break; - case IVAS_DEC_FORCE_REND_CLDFB_RENDERER: - *forcedModeInternal = FORCE_CLDFB_RENDERER; - break; - case IVAS_DEC_FORCE_REND_UNFORCED: - *forcedModeInternal = -1; - break; - default: - return IVAS_ERR_INVALID_FORCE_MODE; - break; - } - - return IVAS_ERR_OK; + case IVAS_DEC_FORCE_REND_TD_RENDERER: + *forcedModeInternal = FORCE_TD_RENDERER; + break; + case IVAS_DEC_FORCE_REND_CLDFB_RENDERER: + *forcedModeInternal = FORCE_CLDFB_RENDERER; + break; + case IVAS_DEC_FORCE_REND_UNFORCED: + *forcedModeInternal = -1; + break; + default: + return IVAS_ERR_INVALID_FORCE_MODE; + break; } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* + +/*---------------------------------------------------------------------* * IVAS_DEC_SetForcedRendMode() * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_SetForcedRendMode( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_DEC_FORCED_REND_MODE forcedRendMode /* i : forced renderer mode */ - ) - { - int16_t newForcedRend; - ivas_error error; - - if ( ( error = forcedRendModeApiToInternalDec( forcedRendMode, &newForcedRend ) ) != IVAS_ERR_OK ) - { - return error; - } +ivas_error IVAS_DEC_SetForcedRendMode( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_DEC_FORCED_REND_MODE forcedRendMode /* i : forced renderer mode */ +) +{ + int16_t newForcedRend; + ivas_error error; - if ( hIvasDec->st_ivas->hDecoderConfig->force_rend != newForcedRend ) - { - hIvasDec->st_ivas->hDecoderConfig->force_rend = newForcedRend; - } + if ( ( error = forcedRendModeApiToInternalDec( forcedRendMode, &newForcedRend ) ) != IVAS_ERR_OK ) + { + return error; + } - return IVAS_ERR_OK; + if ( hIvasDec->st_ivas->hDecoderConfig->force_rend != newForcedRend ) + { + hIvasDec->st_ivas->hDecoderConfig->force_rend = newForcedRend; } + return IVAS_ERR_OK; +} + #ifdef DEBUG_SBA_AUDIO_DUMP - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetSbaDebugParams( ) * * Returns SBA debug parameters *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetSbaDebugParams( - const IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *numOutputChannels, - int16_t *numTransportChannels, - int16_t *pca_ingest_channels ) +ivas_error IVAS_DEC_GetSbaDebugParams( + const IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *numOutputChannels, + int16_t *numTransportChannels, + int16_t *pca_ingest_channels ) +{ + if ( hIvasDec->st_ivas == NULL ) { - if ( hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - if ( hIvasDec->st_ivas->ivas_format != SBA_FORMAT || hIvasDec->st_ivas->hSpar == NULL ) - { - *numOutputChannels = 1; - *numTransportChannels = 1; - *pca_ingest_channels = 1; - } - else - { - *numOutputChannels = hIvasDec->st_ivas->hSpar->numOutChannels; - *numTransportChannels = hIvasDec->st_ivas->nchan_transport; - *pca_ingest_channels = hIvasDec->st_ivas->hSpar->pca_ingest_channels; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - return IVAS_ERR_OK; + if ( hIvasDec->st_ivas->ivas_format != SBA_FORMAT || hIvasDec->st_ivas->hSpar == NULL ) + { + *numOutputChannels = 1; + *numTransportChannels = 1; + *pca_ingest_channels = 1; } + else + { + *numOutputChannels = hIvasDec->st_ivas->hSpar->numOutChannels; + *numTransportChannels = hIvasDec->st_ivas->nchan_transport; + *pca_ingest_channels = hIvasDec->st_ivas->hSpar->pca_ingest_channels; + } + + return IVAS_ERR_OK; +} #endif /* DEBUG_SBA_AUDIO_DUMP */ #endif /* DEBUGGING */ - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * input_format_API_to_internal() * * *---------------------------------------------------------------------*/ - static ivas_error input_format_API_to_internal( - IVAS_DEC_INPUT_FORMAT input_format, - int16_t * bitstream_format_internal, - int16_t * sdp_hf_only, - const bool is_voip_enabled ) +static ivas_error input_format_API_to_internal( + IVAS_DEC_INPUT_FORMAT input_format, + int16_t *bitstream_format_internal, + int16_t *sdp_hf_only, + const bool is_voip_enabled ) +{ + switch ( input_format ) { - switch ( input_format ) - { - case IVAS_DEC_INPUT_FORMAT_G192: - *bitstream_format_internal = is_voip_enabled ? VOIP_G192_RTP : G192; - *sdp_hf_only = 0; - break; - case IVAS_DEC_INPUT_FORMAT_MIME: - *bitstream_format_internal = MIME; - *sdp_hf_only = 0; - break; - case IVAS_DEC_INPUT_FORMAT_RTPDUMP: - assert( is_voip_enabled && "RTP dump only supported in VoIP mode" ); - *bitstream_format_internal = VOIP_RTPDUMP; - *sdp_hf_only = 0; - break; - case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF: - assert( is_voip_enabled && "RTP dump only supported in VoIP mode" ); - *bitstream_format_internal = VOIP_RTPDUMP; - *sdp_hf_only = 1; - break; - default: - return IVAS_ERR_INVALID_BITSTREAM; - break; - } - - return IVAS_ERR_OK; + case IVAS_DEC_INPUT_FORMAT_G192: + *bitstream_format_internal = is_voip_enabled ? VOIP_G192_RTP : G192; + *sdp_hf_only = 0; + break; + case IVAS_DEC_INPUT_FORMAT_MIME: + *bitstream_format_internal = MIME; + *sdp_hf_only = 0; + break; + case IVAS_DEC_INPUT_FORMAT_RTPDUMP: + assert( is_voip_enabled && "RTP dump only supported in VoIP mode" ); + *bitstream_format_internal = VOIP_RTPDUMP; + *sdp_hf_only = 0; + break; + case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF: + assert( is_voip_enabled && "RTP dump only supported in VoIP mode" ); + *bitstream_format_internal = VOIP_RTPDUMP; + *sdp_hf_only = 1; + break; + default: + return IVAS_ERR_INVALID_BITSTREAM; + break; } + return IVAS_ERR_OK; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_VoIP_reconfigure() * * *---------------------------------------------------------------------*/ - static ivas_error IVAS_DEC_VoIP_reconfigure( - IVAS_DEC_HANDLE hIvasDec, - const uint16_t nTransportChannels, - const uint16_t l_ts ) - { - int16_t apa_buffer_size; - - apa_buffer_size = hIvasDec->nSamplesFrame; +static ivas_error IVAS_DEC_VoIP_reconfigure( + IVAS_DEC_HANDLE hIvasDec, + const uint16_t nTransportChannels, + const uint16_t l_ts ) +{ + int16_t apa_buffer_size; - if ( hIvasDec->apaExecBuffer == NULL ) - { - DECODER_CONFIG_HANDLE hDecoderConfig; + apa_buffer_size = hIvasDec->nSamplesFrame; - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - uint16_t wss, css; - float startQuality; + if ( hIvasDec->apaExecBuffer == NULL ) + { + DECODER_CONFIG_HANDLE hDecoderConfig; - startQuality = hIvasDec->tsm_quality; - apa_buffer_size = APA_BUF_PER_CHANNEL; + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + uint16_t wss, css; + float startQuality; - /* get current renderer type*/ - hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; + startQuality = hIvasDec->tsm_quality; + apa_buffer_size = APA_BUF_PER_CHANNEL; - if ( hDecoderConfig->output_Fs == 8000 ) - { - wss = 1; - css = 1; - } - else if ( hDecoderConfig->output_Fs == 16000 ) - { - wss = 2; - css = 1; - } - else if ( hDecoderConfig->output_Fs == 32000 ) - { - wss = 4; - css = 2; - } - else if ( hDecoderConfig->output_Fs == 48000 ) - { - wss = 6; - css = 3; - } - else - { - return IVAS_ERR_INIT_ERROR; - } + /* get current renderer type*/ + hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; - if ( apa_init( &hIvasDec->hTimeScaler, nTransportChannels ) != IVAS_ERR_OK || - apa_set_rate( hIvasDec->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || - apa_set_complexity_options( hIvasDec->hTimeScaler, wss, css ) != 0 || - apa_set_quality( hIvasDec->hTimeScaler, startQuality, 4, 4 ) != 0 || - apa_set_renderer_granularity( hIvasDec->hTimeScaler, l_ts ) != 0 ) - { - return IVAS_ERR_INIT_ERROR; - } + if ( hDecoderConfig->output_Fs == 8000 ) + { + wss = 1; + css = 1; + } + else if ( hDecoderConfig->output_Fs == 16000 ) + { + wss = 2; + css = 1; + } + else if ( hDecoderConfig->output_Fs == 32000 ) + { + wss = 4; + css = 2; + } + else if ( hDecoderConfig->output_Fs == 48000 ) + { + wss = 6; + css = 3; + } + else + { + return IVAS_ERR_INIT_ERROR; + } - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) - { - if ( apa_set_evs_compat_mode( hIvasDec->hTimeScaler, true ) != 0 ) - { - return IVAS_ERR_INIT_ERROR; - } - } + if ( apa_init( &hIvasDec->hTimeScaler, nTransportChannels ) != IVAS_ERR_OK || + apa_set_rate( hIvasDec->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || + apa_set_complexity_options( hIvasDec->hTimeScaler, wss, css ) != 0 || + apa_set_quality( hIvasDec->hTimeScaler, startQuality, 4, 4 ) != 0 || + apa_set_renderer_granularity( hIvasDec->hTimeScaler, l_ts ) != 0 ) + { + return IVAS_ERR_INIT_ERROR; + } - if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + { + if ( apa_set_evs_compat_mode( hIvasDec->hTimeScaler, true ) != 0 ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); + return IVAS_ERR_INIT_ERROR; } + } - set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); + if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + + set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); } - else + } + else + { + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + if ( apa_reconfigure( hIvasDec->hTimeScaler, nTransportChannels, l_ts ) != 0 ) { - if ( apa_reconfigure( hIvasDec->hTimeScaler, nTransportChannels, l_ts ) != 0 ) - { - return IVAS_ERR_INIT_ERROR; - } - apa_buffer_size = APA_BUF_PER_CHANNEL; - free( hIvasDec->apaExecBuffer ); - if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); - } - set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); + return IVAS_ERR_INIT_ERROR; + } + apa_buffer_size = APA_BUF_PER_CHANNEL; + free( hIvasDec->apaExecBuffer ); + if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } - /* realloc apa_exe_buffer */ + set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); } + /* realloc apa_exe_buffer */ + } - hIvasDec->nTransportChannelsOld = nTransportChannels; + hIvasDec->nTransportChannelsOld = nTransportChannels; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} #ifdef SPLIT_REND_WITH_HEAD_ROT - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetSplitRendBitstreamHeader() * * *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC * pCodec, /* o : pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE * poseCorrection, /* o : pointer to pose correction mode */ +ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t * pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ - int16_t * pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ - int16_t * pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ + int16_t *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ + int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ + int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ #else - int16_t * pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ #endif - ) +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec; - *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms; - *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode; + *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec; + *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms; + *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; - *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; + *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; + *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; #endif - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_GetCldfbSamples() * * API function to output CLDFB samples *---------------------------------------------------------------------*/ - ivas_error IVAS_DEC_GetCldfbSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ - float *out_imag, /* o : buffer for decoded PCM imag output in CLDFB domain */ - AUDIO_CONFIG *audio_config, /* o : audio configuration */ - int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ - ) - { - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; - int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; +ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ + float *out_imag, /* o : buffer for decoded PCM imag output in CLDFB domain */ + AUDIO_CONFIG *audio_config, /* o : audio configuration */ + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ +) +{ + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + int16_t ch, b, slot_idx, num_chs, maxBand, num_samples; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSplitBinRend == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hSplitBinRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - hSplitBinRend = hIvasDec->st_ivas->hSplitBinRend; - num_samples = 0; + hSplitBinRend = hIvasDec->st_ivas->hSplitBinRend; + num_samples = 0; - if ( hSplitBinRend->hCldfbDataOut != NULL ) + if ( hSplitBinRend->hCldfbDataOut != NULL ) + { + *audio_config = hSplitBinRend->hCldfbDataOut->config; + if ( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) { - *audio_config = hSplitBinRend->hCldfbDataOut->config; - if ( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) - { - num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); - maxBand = ( int16_t )( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); + maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); - for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + { + for ( b = 0; b < maxBand; b++ ) { - for ( b = 0; b < maxBand; b++ ) + for ( ch = 0; ch < num_chs; ch++ ) { - for ( ch = 0; ch < num_chs; ch++ ) - { - *out_real++ = hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx][b]; - *out_imag++ = hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx][b]; - } + *out_real++ = hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer[ch][slot_idx][b]; + *out_imag++ = hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer[ch][slot_idx][b]; } } - num_samples = CLDFB_NO_COL_MAX * maxBand; } + num_samples = CLDFB_NO_COL_MAX * maxBand; } - else - { - *audio_config = IVAS_AUDIO_CONFIG_INVALID; - } + } + else + { + *audio_config = IVAS_AUDIO_CONFIG_INVALID; + } - *nOutSamples = num_samples; + *nOutSamples = num_samples; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * pcm_buffer_offset() * * *---------------------------------------------------------------------*/ - static void *pcm_buffer_offset( - void *buffer, - const IVAS_DEC_PCM_TYPE pcmType, - const int32_t offset ) +static void *pcm_buffer_offset( + void *buffer, + const IVAS_DEC_PCM_TYPE pcmType, + const int32_t offset ) +{ + switch ( pcmType ) { - switch ( pcmType ) + case IVAS_DEC_PCM_FLOAT: { - case IVAS_DEC_PCM_FLOAT: - { - float *tmpBuf = (float *) buffer; - return (void *) ( tmpBuf + offset ); - } - break; - case IVAS_DEC_PCM_INT16: - { - int16_t *tmpBuf = (int16_t *) buffer; - return (void *) ( tmpBuf + offset ); - } - break; - default: - break; + float *tmpBuf = (float *) buffer; + return (void *) ( tmpBuf + offset ); } - - return NULL; + break; + case IVAS_DEC_PCM_INT16: + { + int16_t *tmpBuf = (int16_t *) buffer; + return (void *) ( tmpBuf + offset ); + } + break; + default: + break; } + return NULL; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * set_pcm_buffer_to_zero() * * *---------------------------------------------------------------------*/ - static ivas_error set_pcm_buffer_to_zero( - void *buffer, - const IVAS_DEC_PCM_TYPE pcmType, - const int16_t nZeroSamples ) - { - ivas_error error; - - error = IVAS_ERR_OK; - switch ( pcmType ) - { - case IVAS_DEC_PCM_FLOAT: - set_zero( (float *) buffer, nZeroSamples ); - break; - case IVAS_DEC_PCM_INT16: - set_s( (int16_t *) buffer, 0, nZeroSamples ); - break; - default: - error = IVAS_ERR_INTERNAL; - } +static ivas_error set_pcm_buffer_to_zero( + void *buffer, + const IVAS_DEC_PCM_TYPE pcmType, + const int16_t nZeroSamples ) +{ + ivas_error error; - return error; + error = IVAS_ERR_OK; + switch ( pcmType ) + { + case IVAS_DEC_PCM_FLOAT: + set_zero( (float *) buffer, nZeroSamples ); + break; + case IVAS_DEC_PCM_INT16: + set_s( (int16_t *) buffer, 0, nZeroSamples ); + break; + default: + error = IVAS_ERR_INTERNAL; } + return error; +} + - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * pcm_type_API_to_internal() * * *---------------------------------------------------------------------*/ - PCM_RESOLUTION pcm_type_API_to_internal( - const IVAS_DEC_PCM_TYPE pcmType ) - { - PCM_RESOLUTION pcm_resolution; - pcm_resolution = PCM_NOT_KNOW; - - switch ( pcmType ) - { - case IVAS_DEC_PCM_FLOAT: - pcm_resolution = PCM_FLOAT32; - break; - case IVAS_DEC_PCM_INT16: - pcm_resolution = PCM_INT16; - break; - default: - pcm_resolution = PCM_NOT_KNOW; - } +PCM_RESOLUTION pcm_type_API_to_internal( + const IVAS_DEC_PCM_TYPE pcmType ) +{ + PCM_RESOLUTION pcm_resolution; + pcm_resolution = PCM_NOT_KNOW; - return pcm_resolution; + switch ( pcmType ) + { + case IVAS_DEC_PCM_FLOAT: + pcm_resolution = PCM_FLOAT32; + break; + case IVAS_DEC_PCM_INT16: + pcm_resolution = PCM_INT16; + break; + default: + pcm_resolution = PCM_NOT_KNOW; } + return pcm_resolution; +} + - /*-------------------------------------------------------------------* +/*-------------------------------------------------------------------* * ivas_create_handle_isar() * * Initialize IVAS decoder split rend handle *-------------------------------------------------------------------*/ - static ivas_error ivas_create_handle_isar( - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE * hSplitBinRend_out /* o : ISAR split binaural rendering handle */ - ) - { - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; +static ivas_error ivas_create_handle_isar( + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out /* o : ISAR split binaural rendering handle */ +) +{ + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; - if ( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); - } + if ( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); + } - isar_init_split_rend_handles( &hSplitBinRend->splitrend ); + isar_init_split_rend_handles( &hSplitBinRend->splitrend ); - hSplitBinRend->hMultiBinCldfbData = NULL; - hSplitBinRend->hCldfbDataOut = NULL; - hSplitBinRend->numTdSamplesPerChannelCached = 0; + hSplitBinRend->hMultiBinCldfbData = NULL; + hSplitBinRend->hCldfbDataOut = NULL; + hSplitBinRend->numTdSamplesPerChannelCached = 0; - *hSplitBinRend_out = hSplitBinRend; + *hSplitBinRend_out = hSplitBinRend; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*-------------------------------------------------------------------* +/*-------------------------------------------------------------------* * ivas_destroy_handle_isar() * * destroy IVAS decoder split rend handle *-------------------------------------------------------------------*/ - static void ivas_destroy_handle_isar( - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE * hSplitBinRend /* i/o: ISAR split binaural rendering handle */ - ) +static void ivas_destroy_handle_isar( + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend /* i/o: ISAR split binaural rendering handle */ +) +{ + if ( *hSplitBinRend != NULL ) { - if ( *hSplitBinRend != NULL ) - { - ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); + ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); - if ( ( *hSplitBinRend )->hCldfbDataOut != NULL ) - { - free( ( *hSplitBinRend )->hCldfbDataOut ); - ( *hSplitBinRend )->hCldfbDataOut = NULL; - } + if ( ( *hSplitBinRend )->hCldfbDataOut != NULL ) + { + free( ( *hSplitBinRend )->hCldfbDataOut ); + ( *hSplitBinRend )->hCldfbDataOut = NULL; } - - return; } + return; +} - /*---------------------------------------------------------------------* + +/*---------------------------------------------------------------------* * IVAS_DEC_is_split_rendering_enabled() * * *---------------------------------------------------------------------*/ - /*! r: decoder error code */ - ivas_error IVAS_DEC_is_split_rendering_enabled( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t * isSplitRend /* o : flag to indicate if split rendering is enabled */ - ) - { - Decoder_Struct *st_ivas; +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitRend /* o : flag to indicate if split rendering is enabled */ +) +{ + Decoder_Struct *st_ivas; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - st_ivas = hIvasDec->st_ivas; + st_ivas = hIvasDec->st_ivas; - *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ); + *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ); - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*-------------------------------------------------------------------* +/*-------------------------------------------------------------------* * ivas_dec_reconfig_split_rend() * * IVAS decoder split rend reconfig *-------------------------------------------------------------------*/ - static ivas_error ivas_dec_reconfig_split_rend( - Decoder_Struct * st_ivas /* i : IVAS decoder structure */ - ) - { - ivas_error error; - int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; - SPLIT_REND_WRAPPER *hSplitRendWrapper; +static ivas_error ivas_dec_reconfig_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; + SPLIT_REND_WRAPPER *hSplitRendWrapper; - hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in_flag = 0; + hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - cldfb_in_flag = 1; - } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in_flag = 1; + } - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); - isCldfbNeeded = 0; + isCldfbNeeded = 0; + + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + cldfb_in_flag = 0; + } - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + if ( cldfb_in_flag == 0 ) { - cldfb_in_flag = 0; + isCldfbNeeded = 1; } - - if ( st_ivas->renderer_type != RENDERER_DISABLE ) + else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) { - if ( cldfb_in_flag == 0 ) - { - isCldfbNeeded = 1; - } - else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) - { - isCldfbNeeded = 1; - } - else if ( pcm_out_flag && cldfb_in_flag ) - { - isCldfbNeeded = 1; - } + isCldfbNeeded = 1; } - else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + else if ( pcm_out_flag && cldfb_in_flag ) { isCldfbNeeded = 1; } + } + else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + { + isCldfbNeeded = 1; + } - if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) + if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) + { + if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) { - if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) - { - hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; - } + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } - num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); } + } - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } } - else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) + } + else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) + { + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) { - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) + if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) { - if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) - { - deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); - hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; - } + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; } + } - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) { - if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) - { - deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); - hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; - } + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; } - - free( hSplitRendWrapper->hCldfbHandles ); - hSplitRendWrapper->hCldfbHandles = NULL; } - if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && - ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && - !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + free( hSplitRendWrapper->hCldfbHandles ); + hSplitRendWrapper->hCldfbHandles = NULL; + } + + if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && + ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && + !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { - for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + if ( st_ivas->hTdRendHandles[i] != NULL ) { - if ( st_ivas->hTdRendHandles[i] != NULL ) - { - st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; - ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); - } + st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); } } - - return IVAS_ERR_OK; } + return IVAS_ERR_OK; +} + - /*-------------------------------------------------------------------* +/*-------------------------------------------------------------------* * ivas_dec_init_split_rend() * * IVAS decoder split rend init *-------------------------------------------------------------------*/ - static ivas_error ivas_dec_init_split_rend( - Decoder_Struct * st_ivas /* i : IVAS decoder structure */ - ) - { - ivas_error error; - int16_t cldfb_in_flag, pcm_out_flag; - int16_t mixed_td_cldfb_flag; +static ivas_error ivas_dec_init_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in_flag, pcm_out_flag; + int16_t mixed_td_cldfb_flag; - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in_flag = 0; + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - cldfb_in_flag = 1; - } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in_flag = 1; + } - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); - if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + { + if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) { - if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); } + } - mixed_td_cldfb_flag = 0; - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - mixed_td_cldfb_flag = 1; - } + mixed_td_cldfb_flag = 0; + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + mixed_td_cldfb_flag = 1; + } - error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); - return error; - } + return error; +} - /*---------------------------------------------------------------------* +/*---------------------------------------------------------------------* * IVAS_DEC_is_split_rendering_coded_out() * * *---------------------------------------------------------------------*/ - /*! r: decoder error code */ - ivas_error IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t * isSplitCoded /* o : flag to indicate if split rendering is enabled */ - ) - { - Decoder_Struct *st_ivas; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ +) +{ + Decoder_Struct *st_ivas; - st_ivas = hIvasDec->st_ivas; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - *isSplitCoded = 0; + st_ivas = hIvasDec->st_ivas; - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) - { - *isSplitCoded = 1; - } + *isSplitCoded = 0; - return IVAS_ERR_OK; + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { + *isSplitCoded = 1; } + + return IVAS_ERR_OK; +} #endif -- GitLab From 79f4aa973f71831b84417ef25f6cfd2e7f7436a2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 6 Jun 2024 12:23:02 +0200 Subject: [PATCH 038/130] fix NULL-pointer read --- lib_dec/lib_dec.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index c5aa936dd8..9bbecfa9e0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1023,23 +1023,26 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } hIvasDec->hasBeenPreparedRendering = false; - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( hIvasDec->st_ivas->hIsmRendererData != NULL ) { + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { #ifdef OBJ_EDITING_PARAMISM - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif - { - int16_t obj; - ISM_RENDERER_HANDLE hIsmRendererData = hIvasDec->st_ivas->hIsmRendererData; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) { + int16_t obj; + ISM_RENDERER_HANDLE hIsmRendererData = hIvasDec->st_ivas->hIsmRendererData; + for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + { - hIsmRendererData->edited_azimuth[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; - hIsmRendererData->edited_elevation[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; - hIsmRendererData->edited_yaw[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; - hIsmRendererData->edited_pitch[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; - hIsmRendererData->edited_radius[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; - hIsmRendererData->edited_gains[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + hIsmRendererData->edited_azimuth[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; + hIsmRendererData->edited_elevation[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; + hIsmRendererData->edited_yaw[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIsmRendererData->edited_pitch[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIsmRendererData->edited_radius[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + hIsmRendererData->edited_gains[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + } } } } -- GitLab From b691d9590b2e6b7f23d3fa81aec13d5309eb500c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 6 Jun 2024 14:54:50 +0200 Subject: [PATCH 039/130] restore BE-ness of ISM with head tracking when object editing is not in use --- lib_dec/ivas_ism_renderer.c | 26 ++++++++++++++++++++------ lib_dec/ivas_stat_dec.h | 1 + lib_dec/lib_dec.c | 2 ++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 2c90d802cc..5fcf67591e 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -245,18 +245,32 @@ void ivas_ism_render_sf( if ( subframe_idx >= ism_md_subframe_update_jbm ) { #ifdef OBJ_EDITING_DECODER - rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); -#else - rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + /* + Due to a smoothing in the MD decoder, setting the edited values to the original ones + does not recover the same output as without the object-editing feature. + Therefore, the smoothed unedited values must be used here, when no editing has been performed. + */ + if ( st_ivas->hIsmRendererData->has_been_edited ) + { + rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + } + else #endif + { + rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + } } else { #ifdef OBJ_EDITING_DECODER - rotateAziEle( st_ivas->hIsmRendererData->last_edited_azimuth[i], st_ivas->hIsmRendererData->last_edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); -#else - rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + if ( st_ivas->hIsmRendererData->has_been_edited ) + { + rotateAziEle( st_ivas->hIsmRendererData->last_edited_azimuth[i], st_ivas->hIsmRendererData->last_edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + } #endif + { + rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + } } if ( st_ivas->hEFAPdata != NULL ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index fd708d8e84..07d51a4fa1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -818,6 +818,7 @@ typedef struct renderer_struct float last_edited_azimuth[MAX_NUM_OBJECTS]; float last_edited_elevation[MAX_NUM_OBJECTS]; int16_t non_diegetic_flag[MAX_NUM_OBJECTS]; + int16_t has_been_edited; #endif } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9bbecfa9e0..dd6ee1938e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1042,6 +1042,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIsmRendererData->edited_pitch[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; hIsmRendererData->edited_radius[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; hIsmRendererData->edited_gains[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + hIsmRendererData->has_been_edited = 0; } } } @@ -1160,6 +1161,7 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + hIvasDec->st_ivas->hIsmRendererData->has_been_edited = 1; } } #ifdef OBJ_EDITING_PARAMISM -- GitLab From 6e44b2b2baf5e31a82b4afdccb97125f601920e9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 7 Jun 2024 10:58:47 +0200 Subject: [PATCH 040/130] set up the correct number of DirAC instances for split rendering --- apps/decoder.c | 8 +++++++- lib_dec/lib_dec.c | 35 +++++++++++++++++++++++++++++++++-- lib_dec/lib_dec.h | 5 +++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 23a2e85f45..b6dfc61e55 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2563,7 +2563,13 @@ static ivas_error decodeG192( } #endif /* Feed into decoder */ - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi +#if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) + , + isSplitRend, + splitRendBits +#endif + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index dd6ee1938e..ab15390dc8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -871,6 +871,11 @@ ivas_error IVAS_DEC_FeedFrame_Serial( uint16_t *serial, /* i : buffer containing serial input bitstream. Each bit should be stored as a single uint16_t value */ const uint16_t num_bits, /* i : number of bits in input bitstream */ int16_t bfi /* i : bad frame indicator flag */ +#if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) + , + int16_t isSplitRend, + ISAR_SPLIT_REND_BITS_DATA *splitRendBits +#endif ) { ivas_error error; @@ -959,6 +964,18 @@ ivas_error IVAS_DEC_FeedFrame_Serial( uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; + + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( isSplitRend ) + { + if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->pcmType, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) #else @@ -1505,10 +1522,12 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( *needNewFrame = false; hSplitBinRend = st_ivas->hSplitBinRend; +#ifndef OBJ_EDITING_API if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { return error; } +#endif numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -3149,7 +3168,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 +#if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) + , + 0, + 0 +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -3157,7 +3182,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else if ( hIvasDec->hasDecodedFirstGoodFrame ) { /* Decoder has been initialized with first good frame - do PLC */ - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 +#if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) + , + 0, + 0 +#endif + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index fb102e7f91..d41da45866 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -152,6 +152,11 @@ ivas_error IVAS_DEC_FeedFrame_Serial( uint16_t *serial, /* i : buffer containing serial input bitstream. Each bit should be stored as a single uint16_t value */ const uint16_t num_bits, /* i : number of bits in input bitstream */ int16_t bfi /* i : bad frame indicator flag */ +#if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) + , + int16_t isSplitRend, + ISAR_SPLIT_REND_BITS_DATA *splitRendBits +#endif ); #ifdef OBJ_EDITING_API -- GitLab From 8788ede23525b4318fdcf48152cfd9166161e826 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 7 Jun 2024 12:04:47 +0200 Subject: [PATCH 041/130] fix double free in split-rendering smoke tests --- lib_dec/lib_dec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index ab15390dc8..2a030efb9c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1677,7 +1677,12 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } - free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); +#ifdef OBJ_EDITING_API + if ( *needNewFrame ) +#endif + { + free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); + } return error; } -- GitLab From 7c871aa79c26cb874fa46f59eff4dcbe164c64d4 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 7 Jun 2024 12:14:42 +0200 Subject: [PATCH 042/130] fix formatting --- apps/decoder.c | 10 +++++----- lib_dec/lib_dec.c | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index b6dfc61e55..c0d3c3c928 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2563,13 +2563,13 @@ static ivas_error decodeG192( } #endif /* Feed into decoder */ - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi #if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) - , - isSplitRend, - splitRendBits + , + isSplitRend, + splitRendBits #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2a030efb9c..2d7231cab0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -967,13 +967,13 @@ ivas_error IVAS_DEC_FeedFrame_Serial( #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( isSplitRend ) - { - if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + if ( isSplitRend ) { - return error; + if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } } - } #endif #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -3175,11 +3175,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 #if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) - , - 0, - 0 + , + 0, + 0 #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } @@ -3187,13 +3187,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else if ( hIvasDec->hasDecodedFirstGoodFrame ) { /* Decoder has been initialized with first good frame - do PLC */ - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 #if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) - , - 0, - 0 + , + 0, + 0 #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 86c4f1ba8e11f606b1ba0c5aff706a6ace1bfd4a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 7 Jun 2024 14:43:44 +0200 Subject: [PATCH 043/130] store edited values in new variables for ParamISM --- lib_dec/ivas_ism_param_dec.c | 12 ++++++++++-- lib_dec/ivas_stat_dec.h | 7 +++++++ lib_dec/lib_dec.c | 21 +++++++++++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 899c7eaa95..3a3e9a7bff 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1075,8 +1075,16 @@ void ivas_param_ism_dec_prepare_renderer( { for ( i = 0; i < st_ivas->nchan_ism; i++ ) { - efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); - } +#ifdef OBJ_EDITING_PARAMISM + if ( hParamIsmDec->has_been_edited ) + { + efap_determine_gains(st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP); + } +#endif + { + efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); + } + } } else { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 07d51a4fa1..40d84c13a8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -422,6 +422,13 @@ typedef struct ivas_param_ism_dec_data_structure float elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; float power_ratios[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; +#ifdef OBJ_EDITING_PARAMISM + float edited_azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; + float edited_elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; + float edited_power_ratios[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; + int16_t has_been_edited; +#endif + /*sub-modules*/ PARAM_ISM_CONFIG_HANDLE hParamIsm; /* Parametric ISM common handle */ PARAM_ISM_RENDERING_HANDLE hParamIsmRendering; /* ParamISM rendering handle */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2d7231cab0..428f26943b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1052,16 +1052,28 @@ ivas_error IVAS_DEC_FeedFrame_Serial( ISM_RENDERER_HANDLE hIsmRendererData = hIvasDec->st_ivas->hIsmRendererData; for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) { - hIsmRendererData->edited_azimuth[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; hIsmRendererData->edited_elevation[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; hIsmRendererData->edited_yaw[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; hIsmRendererData->edited_pitch[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; hIsmRendererData->edited_radius[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; hIsmRendererData->edited_gains[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; - hIsmRendererData->has_been_edited = 0; } + hIsmRendererData->has_been_edited = 0; } +#ifdef OBJ_EDITING_PARAMISM + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj = 0; + PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; + for (obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++) + { + hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; + hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->azimuth_values[obj]; + } + hParamIsmDec->has_been_edited = 0; + } +#endif } } #endif @@ -1187,9 +1199,10 @@ ivas_error IVAS_DEC_SetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; } + hIvasDec->st_ivas->hParamIsmDec->has_been_edited = 1; } else { -- GitLab From 7157527014fea753efa9c7e8a904692fb3a45b87 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 7 Jun 2024 14:44:35 +0200 Subject: [PATCH 044/130] fix formatting --- lib_dec/ivas_ism_param_dec.c | 16 ++++++++-------- lib_dec/ivas_stat_dec.h | 8 ++++---- lib_dec/lib_dec.c | 26 +++++++++++++------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 3a3e9a7bff..70a49c0452 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1076,15 +1076,15 @@ void ivas_param_ism_dec_prepare_renderer( for ( i = 0; i < st_ivas->nchan_ism; i++ ) { #ifdef OBJ_EDITING_PARAMISM - if ( hParamIsmDec->has_been_edited ) - { - efap_determine_gains(st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP); - } + if ( hParamIsmDec->has_been_edited ) + { + efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP ); + } #endif - { - efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); - } - } + { + efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); + } + } } else { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 40d84c13a8..8c1ca3cf38 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -423,10 +423,10 @@ typedef struct ivas_param_ism_dec_data_structure float power_ratios[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; #ifdef OBJ_EDITING_PARAMISM - float edited_azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; - float edited_elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; - float edited_power_ratios[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; - int16_t has_been_edited; + float edited_azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; + float edited_elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; + float edited_power_ratios[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; + int16_t has_been_edited; #endif /*sub-modules*/ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 428f26943b..8019e95cd6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1059,20 +1059,20 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIsmRendererData->edited_radius[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; hIsmRendererData->edited_gains[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; } - hIsmRendererData->has_been_edited = 0; + hIsmRendererData->has_been_edited = 0; } #ifdef OBJ_EDITING_PARAMISM - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) - { - int16_t obj = 0; - PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; - for (obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++) - { - hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; - hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->azimuth_values[obj]; - } - hParamIsmDec->has_been_edited = 0; - } + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj = 0; + PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; + for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + { + hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; + hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->azimuth_values[obj]; + } + hParamIsmDec->has_been_edited = 0; + } #endif } } @@ -1202,7 +1202,7 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; } - hIvasDec->st_ivas->hParamIsmDec->has_been_edited = 1; + hIvasDec->st_ivas->hParamIsmDec->has_been_edited = 1; } else { -- GitLab From dd98e38b6969f1a3ff1ce83410430f81459778fc Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 7 Jun 2024 15:27:25 +0200 Subject: [PATCH 045/130] fix msan error --- lib_dec/lib_dec.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 8019e95cd6..9ba7cbc3c3 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1061,21 +1061,24 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } hIsmRendererData->has_been_edited = 0; } + } + } #ifdef OBJ_EDITING_PARAMISM - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) + { + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj = 0; + PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; + for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) { - int16_t obj = 0; - PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) - { - hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; - hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->azimuth_values[obj]; - } - hParamIsmDec->has_been_edited = 0; + hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; + hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->azimuth_values[obj]; } -#endif + hParamIsmDec->has_been_edited = 0; } } +#endif #endif return IVAS_ERR_OK; -- GitLab From 7cdeb3733239ff8c1ba0796d1a2118d0619e39cd Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 11:24:16 +0200 Subject: [PATCH 046/130] write out the edited metadata --- lib_dec/ivas_init_dec.c | 5 +++- lib_dec/lib_dec.c | 63 +++++++++++++++++++++++++++++++++++------ 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d42d8a6667..9afaa63d8c 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1993,7 +1993,10 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM #ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD + || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC + || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM + || st_ivas->renderer_type == RENDERER_DISABLE #endif ) ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9ba7cbc3c3..51bee94e6d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2163,14 +2163,61 @@ ivas_error IVAS_DEC_GetObjectMetadata( } else { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; +#ifdef OBJ_EDITING_DECODER + if ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + if ( st_ivas->hIsmRendererData->has_been_edited ) + { + metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->elevation = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; + metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; + metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; + metadata->spread = 0.f; + metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; + metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; + } + else + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } + } + else if ( st_ivas->ism_mode == ISM_MODE_DISC ) + { + if ( st_ivas->hParamIsmDec->has_been_edited ) + { + metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; + metadata->elevation = st_ivas->hParamIsmDec->edited_elevation_values[objectIdx]; + } + else + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + } + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } +#else + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; +#endif } return IVAS_ERR_OK; -- GitLab From 5e9d007591118a523c24f8142a76db9dcb7828e2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 11:25:13 +0200 Subject: [PATCH 047/130] fix formatting --- lib_dec/ivas_init_dec.c | 5 +- lib_dec/lib_dec.c | 104 ++++++++++++++++++++-------------------- 2 files changed, 53 insertions(+), 56 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 9afaa63d8c..1154022682 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1993,10 +1993,7 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM #ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD - || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC - || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM - || st_ivas->renderer_type == RENDERER_DISABLE + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_DISABLE #endif ) ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 51bee94e6d..63941376f4 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2164,59 +2164,59 @@ ivas_error IVAS_DEC_GetObjectMetadata( else { #ifdef OBJ_EDITING_DECODER - if ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - if ( st_ivas->hIsmRendererData->has_been_edited ) - { - metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->elevation = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; - metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; - metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; - metadata->spread = 0.f; - metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; - metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; - } - else - { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; - } - } - else if ( st_ivas->ism_mode == ISM_MODE_DISC ) - { - if ( st_ivas->hParamIsmDec->has_been_edited ) - { - metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; - metadata->elevation = st_ivas->hParamIsmDec->edited_elevation_values[objectIdx]; - } - else - { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - } - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; - } + if ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + if ( st_ivas->hIsmRendererData->has_been_edited ) + { + metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->elevation = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; + metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; + metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; + metadata->spread = 0.f; + metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; + metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; + } + else + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } + } + else if ( st_ivas->ism_mode == ISM_MODE_DISC ) + { + if ( st_ivas->hParamIsmDec->has_been_edited ) + { + metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; + metadata->elevation = st_ivas->hParamIsmDec->edited_elevation_values[objectIdx]; + } + else + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + } + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } #else - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; #endif } -- GitLab From ed62c82c44271c41580c569889ba0508de25e26a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 11:56:05 +0200 Subject: [PATCH 048/130] temporarily fix smoke text with EXT output --- lib_dec/lib_dec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 63941376f4..1303092ef1 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2164,7 +2164,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( else { #ifdef OBJ_EDITING_DECODER - if ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_MODE_DISC ) { if ( st_ivas->hIsmRendererData->has_been_edited ) { @@ -2189,7 +2189,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } } - else if ( st_ivas->ism_mode == ISM_MODE_DISC ) + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { if ( st_ivas->hParamIsmDec->has_been_edited ) { @@ -2208,6 +2208,10 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor = 1.f; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + + } #else metadata->azimuth = hIsmMeta->azimuth; metadata->elevation = hIsmMeta->elevation; -- GitLab From cfd6eeef14889688328eb0620fdc9b4acd0502dd Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 12:44:26 +0200 Subject: [PATCH 049/130] fix compile errors --- lib_dec/ivas_jbm_dec.c | 24 ++++++------------------ lib_dec/lib_dec.h | 2 +- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 221e201a3d..05cd3212f6 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3068,20 +3068,12 @@ void ivas_jbm_dec_prepare_renderer( ivas_ism_dec_digest_tc( st_ivas ); /* delay the objects here for all renderers where it is needed */ - if ( -#ifdef SPLIT_REND_WITH_HEAD_ROT - ( -#endif - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL -#ifdef SPLIT_REND_WITH_HEAD_ROT - ) && - ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif - ) + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) && + ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -3150,14 +3142,10 @@ void ivas_jbm_dec_prepare_renderer( { v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { -#endif delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } } } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 04dfb5d678..17e2fa666b 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -150,7 +150,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( uint16_t *serial, /* i : buffer containing serial input bitstream. Each bit should be stored as a single uint16_t value */ const uint16_t num_bits, /* i : number of bits in input bitstream */ int16_t bfi /* i : bad frame indicator flag */ -#if defined( OBJ_EDITING_API ) && defined( SPLIT_REND_WITH_HEAD_ROT ) +#if defined( OBJ_EDITING_API ) , int16_t isSplitRend, ISAR_SPLIT_REND_BITS_DATA *splitRendBits -- GitLab From d85b7c9be18d667cdc561a232e0ab921f9192e58 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 13:43:31 +0200 Subject: [PATCH 050/130] enable object editing for OSBA --- lib_dec/ivas_init_dec.c | 6 +++++- lib_dec/ivas_objectRenderer_internal.c | 2 +- lib_dec/lib_dec.c | 23 ++++++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 35d63eee11..c21d4851f2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1941,7 +1941,11 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM #ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_DISABLE + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD + || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC + || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM + || st_ivas->renderer_type == RENDERER_DISABLE + || st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC #endif ) ) { diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index da8f02d171..ad03ffdbc9 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -174,7 +174,7 @@ ivas_error ivas_td_binaural_renderer_sf( if ( subframe_idx == ism_md_subframe_update_jbm ) { #ifdef OBJ_EDITING_DECODER - if ( st_ivas->ivas_format == ISM_FORMAT ) + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 40dce3f09f..2e5e336e20 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2121,7 +2121,28 @@ ivas_error IVAS_DEC_GetObjectMetadata( } else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - + if (st_ivas->hIsmRendererData->has_been_edited) + { + metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->elevation = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; + metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; + metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; + metadata->spread = 0.f; + metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; + metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; + } + else + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } } #else metadata->azimuth = hIsmMeta->azimuth; -- GitLab From b01e35188d6245b17cc1258a3159acaf0c2ad1c6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 13:48:13 +0200 Subject: [PATCH 051/130] fix formatting --- apps/decoder.c | 13 ++++----- lib_dec/ivas_init_dec.c | 6 +---- lib_dec/lib_dec.c | 60 ++++++++++++++++++++--------------------- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 71fa4566a3..deb44ba20b 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3366,17 +3366,18 @@ static ivas_error decodeVoIP( #endif #ifdef SUPPORT_JBM_TRACEFILE - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, #ifdef OBJ_EDITING_API - &nSamplesRendered, ¶meterAvailableForEditing + &nSamplesRendered, ¶meterAvailableForEditing #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing #ifdef OBJ_EDITING_API - &nSamplesRendered, ¶meterAvailableForEditing + & nSamplesRendered, + ¶meterAvailableForEditing #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c21d4851f2..b1b259466d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1941,11 +1941,7 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM #ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD - || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC - || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM - || st_ivas->renderer_type == RENDERER_DISABLE - || st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_DISABLE || st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC #endif ) ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2e5e336e20..76ea1f74d7 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2119,31 +2119,31 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor = 1.f; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } - else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - if (st_ivas->hIsmRendererData->has_been_edited) - { - metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->elevation = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; - metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; - metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; - metadata->spread = 0.f; - metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; - metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; - } - else - { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; - } - } + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + if ( st_ivas->hIsmRendererData->has_been_edited ) + { + metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->elevation = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; + metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; + metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; + metadata->spread = 0.f; + metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; + metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; + } + else + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } + } #else metadata->azimuth = hIsmMeta->azimuth; metadata->elevation = hIsmMeta->elevation; @@ -3200,14 +3200,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* directly set output zero */ int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); #ifdef OBJ_EDITING_API - set_pcm_buffer_to_zero(pcm_buffer_offset(pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels), pcmType, nSamplesToZero * nOutChannels); - *nSamplesRendered += nSamplesToZero; + set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); + *nSamplesRendered += nSamplesToZero; #else set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); nSamplesRendered += nSamplesToZero; #endif - hIvasDec->nSamplesRendered += nSamplesToZero; + hIvasDec->nSamplesRendered += nSamplesToZero; hIvasDec->nSamplesAvailableNext -= nSamplesToZero; update_voip_rendered20ms( hIvasDec, nSamplesToZero ); } @@ -3237,9 +3237,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef OBJ_EDITING_API if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_GetSamples(hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset(pcmBuf, pcmType, nSamplesRendered * nOutChannels), &nSamplesRendered_loop, &tmp)) != IVAS_ERR_OK) + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #endif - { + { return error; } -- GitLab From 8db774ffdef40558de9e45d073f86038ab39ad42 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 15:46:30 +0200 Subject: [PATCH 052/130] fix crash with EXT output from OSBA --- lib_dec/ivas_sba_dec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index d13268858c..bcbd72a1c8 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -456,7 +456,15 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM +#ifdef OBJ_EDITING_DECODER + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || + st_ivas->renderer_type == RENDERER_DISABLE || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC +#endif + ) ) { if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { -- GitLab From 0720c782cf1eb45a41ef210305939bd05fa3bc56 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 16:16:17 +0200 Subject: [PATCH 053/130] fix formatting --- lib_dec/ivas_sba_dec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index bcbd72a1c8..90190d9500 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -456,15 +456,15 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM #ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || - st_ivas->renderer_type == RENDERER_DISABLE || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC + || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || + st_ivas->renderer_type == RENDERER_DISABLE || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC #endif - ) ) + ) ) { if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { -- GitLab From f73c6d3532c8ae272300b09fa80b5edcf5e06354 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 17:12:59 +0200 Subject: [PATCH 054/130] fix decoder hang-up --- lib_dec/lib_dec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 76ea1f74d7..f3794d14e7 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3243,7 +3243,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return error; } - nSamplesRendered += nSamplesRendered_loop; +#ifdef OBJ_EDITING_API + *nSamplesRendered += nSamplesRendered_loop; +#else + nSamplesRendered += nSamplesRendered_loop; +#endif update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } } -- GitLab From 9a231370ce43efbfeacc853f77858301e518fb11 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 11 Jun 2024 14:32:42 +0200 Subject: [PATCH 055/130] fix compile error with OBJ_EDITING_INTERFACE disabled --- apps/decoder.c | 3 ++- lib_com/options.h | 2 +- lib_dec/lib_dec.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index deb44ba20b..7764ed8f81 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3366,8 +3366,9 @@ static ivas_error decodeVoIP( #endif #ifdef SUPPORT_JBM_TRACEFILE - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter #ifdef OBJ_EDITING_API + , &nSamplesRendered, ¶meterAvailableForEditing #endif ) ) != IVAS_ERR_OK ) diff --git a/lib_com/options.h b/lib_com/options.h index a59b12efec..72c5c08c54 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,7 +150,7 @@ /* ################## Start DEVELOPMENT switches ######################### */ -#define OBJ_EDITING_INTERFACE /* Interface for object editing */ +//#define OBJ_EDITING_INTERFACE /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index f3794d14e7..fe54c9d55f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2100,6 +2100,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } } +#ifdef OBJ_EDITING_PARAMISM else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { if ( st_ivas->hParamIsmDec->has_been_edited ) @@ -2119,6 +2120,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor = 1.f; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } +#endif else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { if ( st_ivas->hIsmRendererData->has_been_edited ) -- GitLab From 0afa194e3eef43834793f11ce6acf216fb46ee43 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 11 Jun 2024 14:37:13 +0200 Subject: [PATCH 056/130] fix formatting --- apps/decoder.c | 2 +- lib_dec/lib_dec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 7764ed8f81..126e14484e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3368,7 +3368,7 @@ static ivas_error decodeVoIP( #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter #ifdef OBJ_EDITING_API - , + , &nSamplesRendered, ¶meterAvailableForEditing #endif ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fe54c9d55f..9e55fd2d7d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3248,7 +3248,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef OBJ_EDITING_API *nSamplesRendered += nSamplesRendered_loop; #else - nSamplesRendered += nSamplesRendered_loop; + nSamplesRendered += nSamplesRendered_loop; #endif update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } -- GitLab From 810fd5e54275df64e1dc64ab57aab1d8ba9aba3f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 11 Jun 2024 15:14:16 +0200 Subject: [PATCH 057/130] re-enable OBJ_EDITING_INTERFACE --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 333e4108ff..9d43a26e59 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,7 +150,7 @@ /* ################## Start DEVELOPMENT switches ######################### */ -//#define OBJ_EDITING_INTERFACE /* Interface for object editing */ +#define OBJ_EDITING_INTERFACE /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ #define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ -- GitLab From 2eae948ab22f57370db34f1632f7bea5567d7c3b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 10:50:44 +0200 Subject: [PATCH 058/130] fix crash with OMASA to EXT conditions --- lib_dec/ivas_init_dec.c | 7 ++++++- lib_dec/lib_dec.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b1b259466d..f955b3d4d6 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1891,7 +1891,12 @@ ivas_error ivas_init_decoder( } } - if ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + if ( ( st_ivas->renderer_type == RENDERER_DIRAC +#ifdef OBJ_EDITING_PARAMISM + || st_ivas->renderer_type == RENDERER_DISABLE +#endif + ) && + ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9e55fd2d7d..2dbc8d828d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2121,7 +2121,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } #endif - else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { if ( st_ivas->hIsmRendererData->has_been_edited ) { -- GitLab From bfe0f88a0c51d203d5395409527b21bdcd062d6c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 14:00:44 +0200 Subject: [PATCH 059/130] fix crash with OMASA and bitrate switching --- lib_dec/ivas_omasa_dec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 465f013317..e42b684424 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -433,7 +433,11 @@ ivas_error ivas_omasa_dec_config( } } - if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT ) + if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT +#ifdef OBJ_EDITING_API + || st_ivas->renderer_type == RENDERER_DISABLE +#endif + ) { /* Allocate 'hIsmRendererData' handle */ if ( ( error = ivas_omasa_combine_separate_ism_with_masa_open( st_ivas ) ) != IVAS_ERR_OK ) -- GitLab From 7e3954a6b956e1cf0d3feddb3b792bbb61b69c1d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 15:37:28 +0200 Subject: [PATCH 060/130] fix brokem MD output with OMASA --- lib_dec/lib_dec.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2dbc8d828d..cf0e071a5a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2146,16 +2146,18 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } } -#else - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + else #endif + { + metadata->azimuth = hIsmMeta->azimuth; + metadata->elevation = hIsmMeta->elevation; + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; + metadata->spread = 0.f; + metadata->gainFactor = 1.f; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; + } } return IVAS_ERR_OK; -- GitLab From 4cc3c105db64525834e00214b38b477f3fbd4634 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 16:18:41 +0200 Subject: [PATCH 061/130] fix msan error with OMASA conditions --- lib_dec/lib_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index cf0e071a5a..b4e38b3efb 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -994,10 +994,10 @@ ivas_error IVAS_DEC_FeedFrame_Serial( if ( hIvasDec->st_ivas->hIsmRendererData != NULL ) { - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { #ifdef OBJ_EDITING_PARAMISM - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif { int16_t obj; -- GitLab From 4cf7e20173288f474f1a4b2e0c2be70a864fc37e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 1 Jul 2024 11:04:15 +0200 Subject: [PATCH 062/130] clean up experimental code changes --- Workspace_msvc/decoder.vcxproj | 3 +- lib_com/common_api_types.h | 1 - lib_dec/ivas_stat_dec.h | 1 - lib_dec/lib_dec.c | 5 +-- lib_rend/ivas_objectRenderer_sources.c | 31 ------------------ tests/conftest.py | 44 -------------------------- 6 files changed, 2 insertions(+), 83 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index 7b76a18b59..00e29933a4 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -83,7 +83,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) @@ -174,4 +173,4 @@ - \ No newline at end of file + diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 8cbdfcb3cd..9230ab453b 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -139,7 +139,6 @@ typedef struct _IVAS_EDITABLE_PARAMETERS { int16_t num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; - float gain_bed; } IVAS_EDITABLE_PARAMETERS; #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b2533bf837..f8ec2d31eb 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -425,7 +425,6 @@ typedef struct ivas_param_ism_dec_data_structure #ifdef OBJ_EDITING_PARAMISM float edited_azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; float edited_elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; - float edited_power_ratios[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; int16_t has_been_edited; #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b4e38b3efb..da7f20633c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -918,10 +918,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( #ifdef OBJ_EDITING_API /* decode TCs, do TSM and feed to renderer */ /* setup */ - if ( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - } - else + if ( hIvasDec->hasBeenFedFirstGoodFrame ) { uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index d836a55934..ca42e50dcb 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -181,37 +181,6 @@ ivas_error TDREND_MIX_SRC_SetDistAtten( return IVAS_ERR_OK; } -#if 0 -/*-------------------------------------------------------------------* - * TDREND_MIX_SRC_SetSrcGain() - * - * Set the source (i.e. overall gain) for a source for the mixer. - --------------------------------------------------------------------*/ - -ivas_error TDREND_MIX_SRC_SetSrcGain( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float SrcGain_p /* i : Source gain */ -) -{ - if ( SrcInd > hBinRendererTd->MaxSrcInd ) - { - return ( IVAS_ERROR( IVAS_ERR_INVALID_INDEX, "Index exceeds max index\n" ) ); - } - else if ( SrcGain_p < *hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGainMin_p || SrcGain_p > *hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGainMax_p ) - { - return ( IVAS_ERROR( IVAS_ERR_INVALID_INDEX, "gain exceeds gain limits\n" ) ); - } - else - { - *hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGain_p = SrcGain_p; - hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGainUpdated = TRUE; - } - - return IVAS_ERR_OK; -} -#endif - /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetPlayState() diff --git a/tests/conftest.py b/tests/conftest.py index efddc22da9..cec06c2061 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -301,50 +301,6 @@ class EncoderFrontend: self.stderr = None self.timeout = timeout - def print_cmdline(self, - bitrate: int, - input_sampling_rate: int, - input_path: Path, - output_bitstream_path: Path, - sba_order: Optional[str] = None, - dtx_mode: Optional[bool] = False, - max_band: Optional[str] = None, - pca: Optional[bool] = None, - quiet_mode: Optional[bool] = True, - add_option_list: Optional[list] = None, - ) -> None: - command = [self._path] - - # add optional parameters - if sba_order is not None: - command.extend(["-sba", sba_order]) - - if dtx_mode: - command.extend(["-dtx"]) - - if max_band is not None: - command.extend(["-max_band", max_band]) - - if pca: - command.extend(["-pca"]) - - if quiet_mode: - command.extend(["-q"]) - - if add_option_list is not None: - command.extend(add_option_list) - - # add mandatory parameters - command += [ - str(bitrate), - str(input_sampling_rate), - str(input_path), - str(output_bitstream_path), - ] - - cmd_str = textwrap.indent(" ".join(command), prefix="\t") - log_dbg_msg(f"{self._type} encoder command:\n{cmd_str}") - def run( self, bitrate: int, -- GitLab From f8ffa3b57238fba3a0c2e497c450007fbd3f8e50 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 1 Jul 2024 13:11:12 +0200 Subject: [PATCH 063/130] fix metadata values in the editable MD handle in IVAS_DEC_GetObjectMetadata --- lib_dec/lib_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index da7f20633c..e79c3e3adc 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2077,7 +2077,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( if ( st_ivas->hIsmRendererData->has_been_edited ) { metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->elevation = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; @@ -2123,7 +2123,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( if ( st_ivas->hIsmRendererData->has_been_edited ) { metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->elevation = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; -- GitLab From 21e828af85196e53681813b8457f626f51427e61 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 1 Jul 2024 14:55:38 +0200 Subject: [PATCH 064/130] insert a missing else ivas_ism_render_sf --- lib_dec/ivas_ism_renderer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 5fcf67591e..db58be278e 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -267,6 +267,7 @@ void ivas_ism_render_sf( { rotateAziEle( st_ivas->hIsmRendererData->last_edited_azimuth[i], st_ivas->hIsmRendererData->last_edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); } + else #endif { rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); -- GitLab From ee1d8eec992256e464337791b4d56973a61c251a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 1 Jul 2024 14:58:55 +0200 Subject: [PATCH 065/130] temporarily skip check for has_been_edited --- lib_dec/ivas_ism_param_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index f767da0267..9be29d1886 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1063,10 +1063,11 @@ void ivas_param_ism_dec_prepare_renderer( for ( i = 0; i < st_ivas->nchan_ism; i++ ) { #ifdef OBJ_EDITING_PARAMISM - if ( hParamIsmDec->has_been_edited ) + if ( 1 ) { efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP ); } + else #endif { efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); -- GitLab From 594b4637d81f1d80d98c19677b7f995ceac5661f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 1 Jul 2024 15:02:26 +0200 Subject: [PATCH 066/130] fix formatting --- lib_dec/ivas_ism_param_dec.c | 2 +- lib_dec/ivas_ism_renderer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 9be29d1886..f835bf9027 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1067,7 +1067,7 @@ void ivas_param_ism_dec_prepare_renderer( { efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP ); } - else + else #endif { efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index db58be278e..b113d76af1 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -267,7 +267,7 @@ void ivas_ism_render_sf( { rotateAziEle( st_ivas->hIsmRendererData->last_edited_azimuth[i], st_ivas->hIsmRendererData->last_edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); } - else + else #endif { rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); -- GitLab From 342866a7784385e92f06b87f72b0812747a46313 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 2 Jul 2024 10:31:23 +0200 Subject: [PATCH 067/130] fix bug with setting the edited elevation values --- lib_dec/ivas_ism_param_dec.c | 11 +++-------- lib_dec/lib_dec.c | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index f835bf9027..2dfd5ca909 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1063,15 +1063,10 @@ void ivas_param_ism_dec_prepare_renderer( for ( i = 0; i < st_ivas->nchan_ism; i++ ) { #ifdef OBJ_EDITING_PARAMISM - if ( 1 ) - { - efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP ); - } - else + efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP ); +#else + efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); #endif - { - efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); - } } } else diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index c6dd56331e..6b8ded1a45 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1022,7 +1022,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) { hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; - hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->azimuth_values[obj]; + hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; } hParamIsmDec->has_been_edited = 0; } -- GitLab From 7ed892e6846503bc0e954a89765ef06fb9200f92 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 2 Jul 2024 11:06:08 +0200 Subject: [PATCH 068/130] emporatily disable check for st_ivas->hIsmRendererData->has_been_edited --- lib_dec/ivas_ism_renderer.c | 4 ++-- lib_dec/lib_dec.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index b113d76af1..39d0d36e3c 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -250,7 +250,7 @@ void ivas_ism_render_sf( does not recover the same output as without the object-editing feature. Therefore, the smoothed unedited values must be used here, when no editing has been performed. */ - if ( st_ivas->hIsmRendererData->has_been_edited ) + if ( 1 ) { rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); } @@ -263,7 +263,7 @@ void ivas_ism_render_sf( else { #ifdef OBJ_EDITING_DECODER - if ( st_ivas->hIsmRendererData->has_been_edited ) + if ( 1 ) { rotateAziEle( st_ivas->hIsmRendererData->last_edited_azimuth[i], st_ivas->hIsmRendererData->last_edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e411ed245a..7f52358d84 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2123,7 +2123,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( #ifdef OBJ_EDITING_DECODER if ( st_ivas->ism_mode == ISM_MODE_DISC ) { - if ( st_ivas->hIsmRendererData->has_been_edited ) + if ( 1 ) { metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; @@ -2149,7 +2149,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( #ifdef OBJ_EDITING_PARAMISM else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( st_ivas->hParamIsmDec->has_been_edited ) + if ( 1 ) { metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; metadata->elevation = st_ivas->hParamIsmDec->edited_elevation_values[objectIdx]; @@ -2169,7 +2169,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( #endif else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - if ( st_ivas->hIsmRendererData->has_been_edited ) + if ( 1 ) { metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; -- GitLab From 7cde1f13ddf6434b13515b74a3edde437b2b4ad7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 2 Jul 2024 14:14:18 +0200 Subject: [PATCH 069/130] replace last_edited_azimuth by edited_azimuth in ivas_ism_render_sf --- lib_dec/ivas_ism_renderer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 39d0d36e3c..908622b927 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -265,7 +265,7 @@ void ivas_ism_render_sf( #ifdef OBJ_EDITING_DECODER if ( 1 ) { - rotateAziEle( st_ivas->hIsmRendererData->last_edited_azimuth[i], st_ivas->hIsmRendererData->last_edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); } else #endif -- GitLab From 19e4481ade392cdbcc98187985f010496b135917 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 09:35:12 +0200 Subject: [PATCH 070/130] clean up if-conditions in ivas_ism_renderer.c --- lib_dec/ivas_ism_renderer.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 908622b927..326a979809 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -245,33 +245,18 @@ void ivas_ism_render_sf( if ( subframe_idx >= ism_md_subframe_update_jbm ) { #ifdef OBJ_EDITING_DECODER - /* - Due to a smoothing in the MD decoder, setting the edited values to the original ones - does not recover the same output as without the object-editing feature. - Therefore, the smoothed unedited values must be used here, when no editing has been performed. - */ - if ( 1 ) - { - rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); - } - else + rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#else + rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #endif - { - rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); - } } else { #ifdef OBJ_EDITING_DECODER - if ( 1 ) - { - rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); - } - else + rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); +#else + rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #endif - { - rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); - } } if ( st_ivas->hEFAPdata != NULL ) { -- GitLab From 621324223dc373e5afadfefa554acb9905c33c87 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 16:00:35 +0200 Subject: [PATCH 071/130] clean up if conditions in IVAS_DEC_GetObjectMetadata --- lib_dec/lib_dec.c | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7f52358d84..db224b1e0b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2123,8 +2123,6 @@ ivas_error IVAS_DEC_GetObjectMetadata( #ifdef OBJ_EDITING_DECODER if ( st_ivas->ism_mode == ISM_MODE_DISC ) { - if ( 1 ) - { metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; @@ -2133,32 +2131,12 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->spread = 0.f; metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; - } - else - { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; - } } #ifdef OBJ_EDITING_PARAMISM else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( 1 ) - { - metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; - metadata->elevation = st_ivas->hParamIsmDec->edited_elevation_values[objectIdx]; - } - else - { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - } + metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; + metadata->elevation = st_ivas->hParamIsmDec->edited_elevation_values[objectIdx]; metadata->radius = hIsmMeta->radius; metadata->yaw = hIsmMeta->yaw; metadata->pitch = hIsmMeta->pitch; @@ -2169,8 +2147,6 @@ ivas_error IVAS_DEC_GetObjectMetadata( #endif else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - if ( 1 ) - { metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; @@ -2179,18 +2155,6 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->spread = 0.f; metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; - } - else - { - metadata->azimuth = hIsmMeta->azimuth; - metadata->elevation = hIsmMeta->elevation; - metadata->radius = hIsmMeta->radius; - metadata->yaw = hIsmMeta->yaw; - metadata->pitch = hIsmMeta->pitch; - metadata->spread = 0.f; - metadata->gainFactor = 1.f; - metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; - } } else #endif -- GitLab From c09473aa0497cf5b144785a0f232d7a6f8747cd9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 16:01:05 +0200 Subject: [PATCH 072/130] fix formatting --- lib_dec/lib_dec.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index db224b1e0b..baf6a88c9b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2123,14 +2123,14 @@ ivas_error IVAS_DEC_GetObjectMetadata( #ifdef OBJ_EDITING_DECODER if ( st_ivas->ism_mode == ISM_MODE_DISC ) { - metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; - metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; - metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; - metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; - metadata->spread = 0.f; - metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; - metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; + metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; + metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; + metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; + metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; + metadata->spread = 0.f; + metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; + metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; } #ifdef OBJ_EDITING_PARAMISM else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) @@ -2147,14 +2147,14 @@ ivas_error IVAS_DEC_GetObjectMetadata( #endif else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; - metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; - metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; - metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; - metadata->spread = 0.f; - metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; - metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; + metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; + metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; + metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; + metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; + metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; + metadata->spread = 0.f; + metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; + metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; } else #endif -- GitLab From e6acf154da43569aa7cd44ddc9f58f8fc7ba8dc6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 4 Jul 2024 15:57:52 +0200 Subject: [PATCH 073/130] fix initialization of editable parameters in IVAS_DEC_GetEditableParameters --- lib_dec/lib_dec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 84b21f7ee8..0ae4aae295 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1127,10 +1127,10 @@ ivas_error IVAS_DEC_GetEditableParameters( { hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj]; - hIvasEditableParameters->ism_metadata[obj].yaw = 0; - hIvasEditableParameters->ism_metadata[obj].pitch = 0; - hIvasEditableParameters->ism_metadata[obj].radius = 0; - hIvasEditableParameters->ism_metadata[obj].gain = 0; + hIvasEditableParameters->ism_metadata[obj].yaw = 0.0f; + hIvasEditableParameters->ism_metadata[obj].pitch = 0.0f; + hIvasEditableParameters->ism_metadata[obj].radius = 0.0f; + hIvasEditableParameters->ism_metadata[obj].gain = 1.0f; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; } } -- GitLab From 22ac56e1387b78228d0d9781cf73c65539653137 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 4 Jul 2024 16:45:03 +0200 Subject: [PATCH 074/130] disable redundant code --- lib_dec/ivas_ism_renderer.c | 2 +- lib_dec/ivas_jbm_dec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 326a979809..54bae8a6de 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -622,7 +622,7 @@ void ivas_omasa_separate_object_render_jbm( return; } -#ifdef OBJ_EDITING_DECODER +#if 0 /*-------------------------------------------------------------------------* * ivas_ism_renderer_update_md() * diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index c88966ddeb..548e4d2049 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -187,7 +187,7 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } -#ifdef OBJ_EDITING_DECODER +#if 0 if ( st_ivas->ism_mode != ISM_MODE_PARAM && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) ) { ivas_ism_renderer_update_md( st_ivas ); -- GitLab From b6bdf2f14e6429b72af095b53c0ecadfa538c8dc Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 5 Jul 2024 12:06:51 +0200 Subject: [PATCH 075/130] move edited parameters to hMIsmMetaData --- lib_com/ivas_ism_com.c | 3 -- lib_com/ivas_stat_com.h | 14 ++++-- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_ism_param_dec.c | 12 ++--- lib_dec/ivas_ism_renderer.c | 24 ++++------ lib_dec/ivas_objectRenderer_internal.c | 13 +++--- lib_dec/ivas_stat_dec.h | 12 ----- lib_dec/lib_dec.c | 65 ++++++++++++++------------ 8 files changed, 67 insertions(+), 78 deletions(-) diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index d32e1179bc..55f6016fcf 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -417,9 +417,6 @@ void ivas_ism_reset_metadata( hIsmMeta->radius = 1.0f; hIsmMeta->ism_metadata_flag = 0; hIsmMeta->non_diegetic_flag = 0; -#ifdef OBJ_EDITING_DECODER - hIsmMeta->gain = 1.0f; -#endif return; } diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index b219346d34..b642b34f29 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -65,6 +65,16 @@ typedef struct float yaw; /* yaw value read from the input metadata file */ float pitch; /* pitch value read from the input metadata file */ +#ifdef OBJ_EDITING_DECODER + float edited_azimuth; + float edited_elevation; + float edited_radius; + + float edited_yaw; + float edited_pitch; + float edited_gain; +#endif + int16_t non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ ISM_METADATA_ANGLE position_angle; /* Angle structs for azimuth and elevation */ @@ -87,10 +97,6 @@ typedef struct float q_azimuth_old; float q_elevation_old; -#ifdef OBJ_EDITING_DECODER - float gain; -#endif - } ISM_METADATA_FRAME, *ISM_METADATA_HANDLE; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 004b15c7b5..9d3684a8b4 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2257,7 +2257,7 @@ void ivas_dirac_dec_render_sf( { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_DECODER - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); #endif } } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 2dfd5ca909..4554885dee 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -740,8 +740,8 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { #ifdef OBJ_EDITING_DECODER - ivas_ism_get_stereo_gains( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], CPE_CHANNELS ); + ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], CPE_CHANNELS ); #else ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); #endif @@ -750,8 +750,8 @@ void ivas_ism_dec_digest_tc( { // TODO tmu review when #215 is resolved #ifdef OBJ_EDITING_DECODER - azimuth = (int16_t) floorf( st_ivas->hIsmRendererData->edited_azimuth[i] + 0.5f ); - elevation = (int16_t) floorf( st_ivas->hIsmRendererData->edited_elevation[i] + 0.5f ); + azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->edited_azimuth + 0.5f ); + elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->edited_elevation + 0.5f ); #else azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); @@ -772,7 +772,7 @@ void ivas_ism_dec_digest_tc( { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_DECODER - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], st_ivas->hEFAPdata->numSpk ); + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], st_ivas->hEFAPdata->numSpk ); #endif } } @@ -783,7 +783,7 @@ void ivas_ism_dec_digest_tc( /*get HOA gets for direction (ACN/SN3D)*/ ivas_dirac_dec_get_response( azimuth, elevation, st_ivas->hIsmRendererData->gains[i], st_ivas->hIntSetup.ambisonics_order ); #ifdef OBJ_EDITING_DECODER - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], ivas_sba_get_nchan( st_ivas->hIntSetup.ambisonics_order, 0 ) ); + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], ivas_sba_get_nchan( st_ivas->hIntSetup.ambisonics_order, 0 ) ); #endif } } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 54bae8a6de..7bd79aac04 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -82,15 +82,13 @@ ivas_error ivas_ism_renderer_open( set_f( st_ivas->hIsmRendererData->prev_gains[i], 0.0f, MAX_OUTPUT_CHANNELS ); set_f( st_ivas->hIsmRendererData->gains[i], 0.0f, MAX_OUTPUT_CHANNELS ); #ifdef OBJ_EDITING_DECODER - st_ivas->hIsmRendererData->edited_gains[i] = 1.0f; - st_ivas->hIsmRendererData->edited_azimuth[i] = 0.0f; - st_ivas->hIsmRendererData->edited_elevation[i] = 0.0f; - st_ivas->hIsmRendererData->edited_pitch[i] = 0.0f; - st_ivas->hIsmRendererData->edited_yaw[i] = 0.0f; - st_ivas->hIsmRendererData->edited_radius[i] = 1.0f; - st_ivas->hIsmRendererData->last_edited_azimuth[i] = 0.0f; - st_ivas->hIsmRendererData->last_edited_elevation[i] = 0.0f; - st_ivas->hIsmRendererData->non_diegetic_flag[i] = 0; + st_ivas->hIsmMetaData[i]->edited_gain = 1.0f; + st_ivas->hIsmMetaData[i]->edited_azimuth = 0.0f; + st_ivas->hIsmMetaData[i]->edited_elevation = 0.0f; + st_ivas->hIsmMetaData[i]->edited_pitch = 0.0f; + st_ivas->hIsmMetaData[i]->edited_yaw = 0.0f; + st_ivas->hIsmMetaData[i]->edited_radius = 1.0f; + st_ivas->hIsmMetaData[i]->non_diegetic_flag = 0; #endif } @@ -245,7 +243,7 @@ void ivas_ism_render_sf( if ( subframe_idx >= ism_md_subframe_update_jbm ) { #ifdef OBJ_EDITING_DECODER - rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #else rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #endif @@ -253,7 +251,7 @@ void ivas_ism_render_sf( else { #ifdef OBJ_EDITING_DECODER - rotateAziEle( st_ivas->hIsmRendererData->edited_azimuth[i], st_ivas->hIsmRendererData->edited_elevation[i], &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); + rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #else rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #endif @@ -262,7 +260,7 @@ void ivas_ism_render_sf( { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_DECODER - v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->edited_gains[i], st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); + v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); #endif } } @@ -641,8 +639,6 @@ void ivas_ism_renderer_update_md( for ( obj_idx = 0; obj_idx < num_obj; obj_idx++ ) { - hIsmRenderer->last_edited_azimuth[obj_idx] = hIsmRenderer->edited_azimuth[obj_idx]; - hIsmRenderer->last_edited_elevation[obj_idx] = hIsmRenderer->edited_elevation[obj_idx]; hIsmRenderer->edited_azimuth[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->azimuth; hIsmRenderer->edited_elevation[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->elevation; hIsmRenderer->edited_radius[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->radius; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index ad03ffdbc9..8d8826ec01 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -180,13 +180,12 @@ ivas_error ivas_td_binaural_renderer_sf( ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; for ( nS = 0; nS < nchan_ism; nS++ ) { - ismMetaData[nS].azimuth = st_ivas->hIsmRendererData->edited_azimuth[nS]; - ismMetaData[nS].elevation = st_ivas->hIsmRendererData->edited_elevation[nS]; - ismMetaData[nS].radius = st_ivas->hIsmRendererData->edited_radius[nS]; - ismMetaData[nS].yaw = st_ivas->hIsmRendererData->edited_yaw[nS]; - ismMetaData[nS].pitch = st_ivas->hIsmRendererData->edited_pitch[nS]; - ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[nS]; - ismMetaData[nS].gain = st_ivas->hIsmRendererData->edited_gains[nS]; + ismMetaData[nS].azimuth = st_ivas->hIsmMetaData[nS]->edited_azimuth; + ismMetaData[nS].elevation = st_ivas->hIsmMetaData[nS]->edited_elevation; + ismMetaData[nS].radius = st_ivas->hIsmMetaData[nS]->edited_radius; + ismMetaData[nS].yaw = st_ivas->hIsmMetaData[nS]->edited_yaw; + ismMetaData[nS].pitch = st_ivas->hIsmMetaData[nS]->edited_pitch; + ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmMetaData[nS]->non_diegetic_flag; hIsmMetaData[nS] = &ismMetaData[nS]; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index f8ec2d31eb..3bbb3f156b 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -814,18 +814,6 @@ typedef struct renderer_struct float *interpolator; int16_t interpolator_length; float gains[MAX_NUM_OBJECTS][MAX_OUTPUT_CHANNELS]; -#ifdef OBJ_EDITING_DECODER - float edited_gains[MAX_NUM_OBJECTS]; - float edited_azimuth[MAX_NUM_OBJECTS]; - float edited_elevation[MAX_NUM_OBJECTS]; - float edited_yaw[MAX_NUM_OBJECTS]; - float edited_pitch[MAX_NUM_OBJECTS]; - float edited_radius[MAX_NUM_OBJECTS]; - float last_edited_azimuth[MAX_NUM_OBJECTS]; - float last_edited_elevation[MAX_NUM_OBJECTS]; - int16_t non_diegetic_flag[MAX_NUM_OBJECTS]; - int16_t has_been_edited; -#endif } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0ae4aae295..b508462224 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1047,17 +1047,16 @@ ivas_error IVAS_DEC_FeedFrame_Serial( #endif { int16_t obj; - ISM_RENDERER_HANDLE hIsmRendererData = hIvasDec->st_ivas->hIsmRendererData; + ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) { - hIsmRendererData->edited_azimuth[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; - hIsmRendererData->edited_elevation[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; - hIsmRendererData->edited_yaw[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; - hIsmRendererData->edited_pitch[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; - hIsmRendererData->edited_radius[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; - hIsmRendererData->edited_gains[obj] = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + hIsmMetaData[obj]->edited_azimuth = hIsmMetaData[obj]->azimuth; + hIsmMetaData[obj]->edited_elevation = hIsmMetaData[obj]->elevation; + hIsmMetaData[obj]->edited_yaw = hIsmMetaData[obj]->yaw; + hIsmMetaData[obj]->edited_pitch = hIsmMetaData[obj]->pitch; + hIsmMetaData[obj]->edited_radius = hIsmMetaData[obj]->radius; + hIsmMetaData[obj]->edited_gain = 1.0f; } - hIsmRendererData->has_been_edited = 0; } } } @@ -1115,7 +1114,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; - hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->gain; + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } } @@ -1184,14 +1183,16 @@ ivas_error IVAS_DEC_SetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - hIvasDec->st_ivas->hIsmRendererData->edited_azimuth[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmRendererData->edited_elevation[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmRendererData->edited_yaw[obj] = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmRendererData->edited_pitch[obj] = hIvasEditableParameters.ism_metadata[obj].pitch; - hIvasDec->st_ivas->hIsmRendererData->edited_radius[obj] = hIvasEditableParameters.ism_metadata[obj].radius; - hIvasDec->st_ivas->hIsmRendererData->edited_gains[obj] = hIvasEditableParameters.ism_metadata[obj].gain; - hIvasDec->st_ivas->hIsmRendererData->non_diegetic_flag[obj] = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; - hIvasDec->st_ivas->hIsmRendererData->has_been_edited = 1; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; + + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; + + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + + hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } } #ifdef OBJ_EDITING_PARAMISM @@ -2123,14 +2124,16 @@ ivas_error IVAS_DEC_GetObjectMetadata( #ifdef OBJ_EDITING_DECODER if ( st_ivas->ism_mode == ISM_MODE_DISC ) { - metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; - metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; - metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; - metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; + metadata->azimuth = hIsmMeta->edited_azimuth; + metadata->elevation = hIsmMeta->edited_elevation; + metadata->radius = hIsmMeta->edited_radius; + + metadata->yaw = hIsmMeta->edited_yaw; + metadata->pitch = hIsmMeta->edited_pitch; metadata->spread = 0.f; - metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; - metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; + + metadata->gainFactor = hIsmMeta->edited_gain; + metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } #ifdef OBJ_EDITING_PARAMISM else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) @@ -2147,14 +2150,14 @@ ivas_error IVAS_DEC_GetObjectMetadata( #endif else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - metadata->azimuth = st_ivas->hIsmRendererData->edited_azimuth[objectIdx]; - metadata->elevation = st_ivas->hIsmRendererData->edited_elevation[objectIdx]; - metadata->radius = st_ivas->hIsmRendererData->edited_radius[objectIdx]; - metadata->yaw = st_ivas->hIsmRendererData->edited_yaw[objectIdx]; - metadata->pitch = st_ivas->hIsmRendererData->edited_pitch[objectIdx]; + metadata->azimuth = st_ivas->hIsmMetaData[objectIdx]->edited_azimuth; + metadata->elevation = st_ivas->hIsmMetaData[objectIdx]->edited_elevation; + metadata->radius = st_ivas->hIsmMetaData[objectIdx]->edited_radius; + metadata->yaw = st_ivas->hIsmMetaData[objectIdx]->edited_yaw; + metadata->pitch = st_ivas->hIsmMetaData[objectIdx]->edited_pitch; metadata->spread = 0.f; - metadata->gainFactor = st_ivas->hIsmRendererData->edited_gains[objectIdx]; - metadata->non_diegetic_flag = st_ivas->hIsmRendererData->non_diegetic_flag[objectIdx]; + metadata->gainFactor = st_ivas->hIsmMetaData[objectIdx]->edited_gain; + metadata->non_diegetic_flag = st_ivas->hIsmMetaData[objectIdx]->non_diegetic_flag; } else #endif -- GitLab From edee4b08c0ba34b567f60e74f2fce4e5d84e0a2a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 5 Jul 2024 12:26:18 +0200 Subject: [PATCH 076/130] fix formatting --- lib_com/ivas_stat_com.h | 12 ++++++------ lib_dec/lib_dec.c | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index b642b34f29..4889f035e7 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -66,13 +66,13 @@ typedef struct float pitch; /* pitch value read from the input metadata file */ #ifdef OBJ_EDITING_DECODER - float edited_azimuth; - float edited_elevation; - float edited_radius; + float edited_azimuth; + float edited_elevation; + float edited_radius; - float edited_yaw; - float edited_pitch; - float edited_gain; + float edited_yaw; + float edited_pitch; + float edited_gain; #endif int16_t non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b508462224..561e8165f9 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1183,16 +1183,16 @@ ivas_error IVAS_DEC_SetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; - hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } } #ifdef OBJ_EDITING_PARAMISM -- GitLab From f7c7537819661df062c34703b942150739b5e3db Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 5 Jul 2024 13:08:35 +0200 Subject: [PATCH 077/130] initialize edited parameters when opening the ism metadata decoder --- lib_com/ivas_ism_com.c | 10 ++++++++++ lib_dec/ivas_ism_renderer.c | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 55f6016fcf..b50eefc938 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -418,6 +418,16 @@ void ivas_ism_reset_metadata( hIsmMeta->ism_metadata_flag = 0; hIsmMeta->non_diegetic_flag = 0; +#ifdef OBJ_EDITING_DECODER + hIsmMeta->edited_gain = 1.0f; + hIsmMeta->edited_azimuth = 0.0f; + hIsmMeta->edited_elevation = 0.0f; + hIsmMeta->edited_pitch = 0.0f; + hIsmMeta->edited_yaw = 0.0f; + hIsmMeta->edited_radius = 1.0f; + hIsmMeta->non_diegetic_flag = 0; +#endif + return; } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 7bd79aac04..f1900fc8b7 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -81,15 +81,6 @@ ivas_error ivas_ism_renderer_open( { set_f( st_ivas->hIsmRendererData->prev_gains[i], 0.0f, MAX_OUTPUT_CHANNELS ); set_f( st_ivas->hIsmRendererData->gains[i], 0.0f, MAX_OUTPUT_CHANNELS ); -#ifdef OBJ_EDITING_DECODER - st_ivas->hIsmMetaData[i]->edited_gain = 1.0f; - st_ivas->hIsmMetaData[i]->edited_azimuth = 0.0f; - st_ivas->hIsmMetaData[i]->edited_elevation = 0.0f; - st_ivas->hIsmMetaData[i]->edited_pitch = 0.0f; - st_ivas->hIsmMetaData[i]->edited_yaw = 0.0f; - st_ivas->hIsmMetaData[i]->edited_radius = 1.0f; - st_ivas->hIsmMetaData[i]->non_diegetic_flag = 0; -#endif } if ( st_ivas->hDecoderConfig->Opt_tsm ) -- GitLab From 4d75c731073e093e1e9f6e2862344491f126ffec Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 5 Jul 2024 13:33:17 +0200 Subject: [PATCH 078/130] do not allocate ism renderer when it is not required --- lib_dec/ivas_init_dec.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 9772256679..e9967a33e8 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1930,11 +1930,7 @@ ivas_error ivas_init_decoder( } if ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && - ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC -#ifdef OBJ_EDITING_DECODER - || st_ivas->ism_mode == ISM_MODE_PARAM -#endif - ) && + ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) && ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || @@ -1943,11 +1939,7 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM -#ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_DISABLE || st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC -#endif - ) ) + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { -- GitLab From cd68c3549b65df467eeb57e5ad1b58a720f411c2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 5 Jul 2024 13:59:23 +0200 Subject: [PATCH 079/130] fix non-BE-ness when no editing is done --- lib_dec/lib_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 561e8165f9..41bc858ad7 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1038,7 +1038,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } hIvasDec->hasBeenPreparedRendering = false; - if ( hIvasDec->st_ivas->hIsmRendererData != NULL ) + if ( hIvasDec->st_ivas->hIsmMetaData ) { if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { -- GitLab From b4678fa8fc4790fdc48c678b684688a32261e68f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 5 Jul 2024 14:08:58 +0200 Subject: [PATCH 080/130] fix compiler warning --- lib_dec/lib_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 41bc858ad7..e30265fc41 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1038,7 +1038,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } hIvasDec->hasBeenPreparedRendering = false; - if ( hIvasDec->st_ivas->hIsmMetaData ) + if ( hIvasDec->st_ivas->hIsmMetaData[0] ) { if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { -- GitLab From 865515db55a8935c0264dd67a4a60a3fa24ff756 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 5 Jul 2024 14:32:45 +0200 Subject: [PATCH 081/130] do not open the omasa separate-object renderer when it is not required --- lib_dec/ivas_init_dec.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index e9967a33e8..d70774db7d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1890,11 +1890,7 @@ ivas_error ivas_init_decoder( } } - if ( ( st_ivas->renderer_type == RENDERER_DIRAC -#ifdef OBJ_EDITING_PARAMISM - || st_ivas->renderer_type == RENDERER_DISABLE -#endif - ) && + if ( ( st_ivas->renderer_type == RENDERER_DIRAC ) && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ -- GitLab From 26a467c98ec417864d364c3c9578282c65b71dff Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 8 Jul 2024 10:46:20 +0200 Subject: [PATCH 082/130] revert changes to VS project files --- Workspace_msvc/decoder.vcxproj | 2 +- Workspace_msvc/encoder.vcxproj | 1 - Workspace_msvc/isar_post_rend.vcxproj | 1 - Workspace_msvc/lib_com.vcxproj | 3 +- Workspace_msvc/lib_com.vcxproj.filters | 3 +- Workspace_msvc/lib_debug.vcxproj | 1 - Workspace_msvc/lib_dec.vcxproj | 1 - Workspace_msvc/lib_enc.vcxproj | 1 - Workspace_msvc/lib_isar.vcxproj | 3 +- Workspace_msvc/lib_lc3plus.vcxproj | 3 +- Workspace_msvc/lib_rend.vcxproj | 1 - Workspace_msvc/lib_rend.vcxproj.filters | 72 +++++++++++++++++++++++++ Workspace_msvc/lib_util.vcxproj | 1 - Workspace_msvc/renderer.vcxproj | 1 - 14 files changed, 77 insertions(+), 17 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index 00e29933a4..c124382c9c 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -173,4 +173,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj index 45b1d8d6db..309dc15253 100644 --- a/Workspace_msvc/encoder.vcxproj +++ b/Workspace_msvc/encoder.vcxproj @@ -83,7 +83,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj index 446886bcbf..170ff20545 100644 --- a/Workspace_msvc/isar_post_rend.vcxproj +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -80,7 +80,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 02fed70930..223f837a2e 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -73,7 +73,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) @@ -224,7 +223,7 @@ - + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 6010db15eb..b7c9cc3bdb 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -473,7 +473,6 @@ common_ivas_c - @@ -553,4 +552,4 @@ {b95b7bed-a666-4a00-9332-2b528638503e} - \ No newline at end of file + diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 5229874e92..5e986bb167 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -69,7 +69,6 @@ Default %(DisableSpecificWarnings) false - true $(OutDir)$(TargetName).lib diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index ae549a78d9..3c7ea3e597 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -83,7 +83,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index dd340a50a3..ba0c4c9b6f 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -83,7 +83,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index 2c7f6d848e..fceeb731ce 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -83,7 +83,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) @@ -198,4 +197,4 @@ - \ No newline at end of file + diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 54ee84d041..55a291fa9c 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -73,7 +73,6 @@ OldStyle false false - true Console @@ -183,4 +182,4 @@ - \ No newline at end of file + diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 8d1ec03ce5..27d4a19a69 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -83,7 +83,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 889057cb7c..942c63712f 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -32,12 +32,30 @@ rend_c + + rend_c + + + rend_c + + + rend_c + + + rend_c + rend_c rend_c + + rend_c + + + rend_c + rend_c @@ -65,6 +83,15 @@ rend_c + + rend_c + + + rend_c + + + rend_c + rend_c @@ -86,6 +113,9 @@ rend_c + + rend_c + rend_c @@ -104,6 +134,24 @@ rend_c + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + rend_c @@ -113,12 +161,30 @@ rend_c + + rend_c + + + rend_c + + + rend_c + rend_c + + rend_h + + + rend_h + + + rend_h + rend_h @@ -137,6 +203,12 @@ rend_h + + rend_h + + + rend_h + diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 7eb1a0c2b0..4ec7948021 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -68,7 +68,6 @@ Default %(DisableSpecificWarnings) false - true $(OutDir)$(TargetName).lib diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index 7f89a1ccc6..0a7c72a16c 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -80,7 +80,6 @@ Default %(DisableSpecificWarnings) false - true _DEBUG;%(PreprocessorDefinitions) -- GitLab From c7856ec1a2e34dfedab4c6adb0d59b3a5a712bd0 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 8 Jul 2024 11:22:10 +0200 Subject: [PATCH 083/130] do not allocate hIsmRendererData for EXT output in ivas_omasa_dec_config --- lib_dec/ivas_omasa_dec.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index e42b684424..465f013317 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -433,11 +433,7 @@ ivas_error ivas_omasa_dec_config( } } - if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT -#ifdef OBJ_EDITING_API - || st_ivas->renderer_type == RENDERER_DISABLE -#endif - ) + if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT ) { /* Allocate 'hIsmRendererData' handle */ if ( ( error = ivas_omasa_combine_separate_ism_with_masa_open( st_ivas ) ) != IVAS_ERR_OK ) -- GitLab From e3641b41b97c3eca039b5fe098b207c28dc06e70 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 8 Jul 2024 11:38:16 +0200 Subject: [PATCH 084/130] do not allocate ISM renderer ivas_sba_dec_reconfigure when it is not required --- lib_dec/ivas_sba_dec.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 90190d9500..ee2ee850d0 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -448,23 +448,16 @@ ivas_error ivas_sba_dec_reconfigure( return error; } - if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || - st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || - st_ivas->renderer_type == RENDERER_OSBA_STEREO || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM -#ifdef OBJ_EDITING_DECODER - || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || - st_ivas->renderer_type == RENDERER_DISABLE || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC -#endif - ) ) + if ( st_ivas->renderer_type == RENDERER_TD_PANNING || + st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || + st_ivas->renderer_type == RENDERER_OSBA_STEREO || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM + ) { if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { -- GitLab From ee45861c4eb0073e2eff6c2fe1a0c99275ac9a20 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 8 Jul 2024 11:57:39 +0200 Subject: [PATCH 085/130] fix formatting --- lib_dec/ivas_sba_dec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index ee2ee850d0..c01a244b54 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -456,8 +456,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM - ) + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { -- GitLab From ba6886f6990ffbf59f837b932ba508312d3eb0f9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 8 Jul 2024 12:27:04 +0200 Subject: [PATCH 086/130] clean up defines --- lib_com/ivas_ism_com.c | 2 +- lib_com/ivas_prot.h | 2 +- lib_com/ivas_stat_com.h | 2 +- lib_com/options.h | 6 ++---- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_ism_param_dec.c | 10 +++++----- lib_dec/ivas_ism_renderer.c | 6 +++--- lib_dec/ivas_objectRenderer_internal.c | 4 ++-- lib_dec/ivas_stat_dec.h | 4 ++-- lib_dec/lib_dec.c | 16 ++++++++-------- lib_rend/ivas_objectRenderer.c | 2 +- lib_rend/ivas_objectRenderer_sources.c | 2 +- lib_rend/ivas_prot_rend.h | 2 +- 13 files changed, 29 insertions(+), 31 deletions(-) diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index b50eefc938..a47ba733f1 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -418,7 +418,7 @@ void ivas_ism_reset_metadata( hIsmMeta->ism_metadata_flag = 0; hIsmMeta->non_diegetic_flag = 0; -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API hIsmMeta->edited_gain = 1.0f; hIsmMeta->edited_azimuth = 0.0f; hIsmMeta->edited_elevation = 0.0f; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7f5a641ff6..738ae7aacb 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1024,7 +1024,7 @@ ivas_error ivas_ism_metadata_dec( DEC_CORE_HANDLE st0 /* i : core-coder handle */ ); -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API void ivas_ism_renderer_update_md( Decoder_Struct *st_ivas /* i/o: main IVAS decoder handle */ ); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 4889f035e7..f70f6942f3 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -65,7 +65,7 @@ typedef struct float yaw; /* yaw value read from the input metadata file */ float pitch; /* pitch value read from the input metadata file */ -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API float edited_azimuth; float edited_elevation; float edited_radius; diff --git a/lib_com/options.h b/lib_com/options.h index 89d73fb245..9e6b9651e7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,10 +156,8 @@ #define OBJ_EDITING_INTERFACE /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE -#define OBJ_EDITING_API /* object editing changes related to the API */ -#define OBJ_EDITING_DECODER /* object editing changes realted to the decoder functions */ -#define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ -#define OBJ_EDITING_PARAMISM /* obj editing for ParamISM */ +#define OBJ_EDITING_API /* object editing changes related to the API */ +#define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ #endif /* ################### Start BE switches ################################# */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 9d3684a8b4..7e9b12b8fd 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2256,7 +2256,7 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); #endif } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 4554885dee..63036bdebb 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -739,7 +739,7 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], CPE_CHANNELS ); #else @@ -749,7 +749,7 @@ void ivas_ism_dec_digest_tc( else { // TODO tmu review when #215 is resolved -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->edited_azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->edited_elevation + 0.5f ); #else @@ -771,7 +771,7 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], st_ivas->hEFAPdata->numSpk ); #endif } @@ -782,7 +782,7 @@ void ivas_ism_dec_digest_tc( { /*get HOA gets for direction (ACN/SN3D)*/ ivas_dirac_dec_get_response( azimuth, elevation, st_ivas->hIsmRendererData->gains[i], st_ivas->hIntSetup.ambisonics_order ); -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], ivas_sba_get_nchan( st_ivas->hIntSetup.ambisonics_order, 0 ) ); #endif } @@ -1062,7 +1062,7 @@ void ivas_param_ism_dec_prepare_renderer( { for ( i = 0; i < st_ivas->nchan_ism; i++ ) { -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->edited_azimuth_values[i], hParamIsmDec->edited_elevation_values[i], EFAP_MODE_EFAP ); #else efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP ); diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index f1900fc8b7..2e78ee2005 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -233,7 +233,7 @@ void ivas_ism_render_sf( { if ( subframe_idx >= ism_md_subframe_update_jbm ) { -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #else rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); @@ -241,7 +241,7 @@ void ivas_ism_render_sf( } else { -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #else rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); @@ -250,7 +250,7 @@ void ivas_ism_render_sf( if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API v_multc( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmMetaData[i]->edited_gain, st_ivas->hIsmRendererData->gains[i], nchan_out_woLFE ); #endif } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 8d8826ec01..929705fad7 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -173,7 +173,7 @@ ivas_error ivas_td_binaural_renderer_sf( } if ( subframe_idx == ism_md_subframe_update_jbm ) { -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; @@ -201,7 +201,7 @@ ivas_error ivas_td_binaural_renderer_sf( { return error; } -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API } #endif } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3bbb3f156b..9ee4671c75 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -422,7 +422,7 @@ typedef struct ivas_param_ism_dec_data_structure float elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; float power_ratios[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API float edited_azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; float edited_elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; int16_t has_been_edited; @@ -906,7 +906,7 @@ typedef struct ivas_masa_ism_data_structure int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; uint8_t ism_is_edited[MAX_NUM_OBJECTS]; -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API float gain_ism[MAX_NUM_OBJECTS]; float gain_masa; #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e30265fc41..153e81276b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1042,7 +1042,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif { @@ -1060,7 +1060,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } } } -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) { if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) @@ -1102,7 +1102,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif { @@ -1118,7 +1118,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } } -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { int16_t obj; @@ -1176,7 +1176,7 @@ ivas_error IVAS_DEC_SetEditableParameters( if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) #endif { @@ -1195,7 +1195,7 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } } -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { int16_t obj; @@ -2121,7 +2121,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( } else { -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API if ( st_ivas->ism_mode == ISM_MODE_DISC ) { metadata->azimuth = hIsmMeta->edited_azimuth; @@ -2135,7 +2135,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor = hIsmMeta->edited_gain; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } -#ifdef OBJ_EDITING_PARAMISM +#ifdef OBJ_EDITING_API else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 9f9c80a7bc..651e60860a 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -503,7 +503,7 @@ static void TDREND_Clear_Update_flags( for ( i = 0; i < hBinRendererTd->NumOfSrcs; i++ ) { hBinRendererTd->Sources[i]->SrcSpatial_p->Updated = FALSE; -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API hBinRendererTd->Sources[i]->SrcRend_p->SrcGainUpdated = FALSE; #endif } diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index ca42e50dcb..e8b1f412cd 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -252,7 +252,7 @@ static void TDREND_SRC_REND_Init( { SrcRend_p->SrcGainMin_p[nC] = 0.0f; SrcRend_p->SrcGain_p[nC] = 1.0f; -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API SrcRend_p->SrcGainMax_p[nC] = 2.0f; #else SrcRend_p->SrcGainMax_p[nC] = 1.0f; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 47ce7d9eab..81d9f2ce58 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -736,7 +736,7 @@ ivas_error TDREND_MIX_SRC_SetPlayState( const TDREND_PlayStatus_t PlayStatus /* i : Play state */ ); -#ifdef OBJ_EDITING_DECODER +#ifdef OBJ_EDITING_API ivas_error TDREND_MIX_SRC_SetSrcGain( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ -- GitLab From 88a61fe29cb750c47e1d5e9060ec1d30754c6e5d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Jul 2024 12:59:10 +0200 Subject: [PATCH 087/130] evaluate edited parameters in ivas_param_ism_params_to_masa_param_mapping --- lib_dec/ivas_ism_param_dec.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 63036bdebb..b7def6cf93 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1462,14 +1462,23 @@ void ivas_param_ism_params_to_masa_param_mapping( { brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; +#ifdef OBJ_EDITING_API + azimuth[0] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); + elevation[0] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); +#else + azimuth[0] = (int16_t)roundf(hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]]); + elevation[0] = (int16_t)roundf(hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]]); +#endif + power_ratio[0] = hParamIsmDec->power_ratios[band_idx][0][0]; - azimuth[0] = (int16_t) roundf( hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); - elevation[0] = (int16_t) roundf( hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); - power_ratio[0] = hParamIsmDec->power_ratios[band_idx][0][0]; - - azimuth[1] = (int16_t) roundf( hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); - elevation[1] = (int16_t) roundf( hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); - power_ratio[1] = hParamIsmDec->power_ratios[band_idx][0][1]; +#ifdef OBJ_EDITING_API + azimuth[1] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); + elevation[1] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); +#else + azimuth[1] = (int16_t)roundf(hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]]); + elevation[1] = (int16_t)roundf(hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]]); +#endif + power_ratio[1] = hParamIsmDec->power_ratios[band_idx][0][1]; for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { -- GitLab From f0a5effab805f1a80c07abe38477015484580df0 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Jul 2024 13:37:09 +0200 Subject: [PATCH 088/130] fix formatting --- lib_dec/ivas_ism_param_dec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index b7def6cf93..ece763b6cb 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1463,22 +1463,22 @@ void ivas_param_ism_params_to_masa_param_mapping( brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; #ifdef OBJ_EDITING_API - azimuth[0] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); + azimuth[0] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); elevation[0] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); #else - azimuth[0] = (int16_t)roundf(hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]]); - elevation[0] = (int16_t)roundf(hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]]); + azimuth[0] = (int16_t) roundf( hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); + elevation[0] = (int16_t) roundf( hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); #endif - power_ratio[0] = hParamIsmDec->power_ratios[band_idx][0][0]; + power_ratio[0] = hParamIsmDec->power_ratios[band_idx][0][0]; #ifdef OBJ_EDITING_API azimuth[1] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); elevation[1] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); #else - azimuth[1] = (int16_t)roundf(hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]]); - elevation[1] = (int16_t)roundf(hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]]); + azimuth[1] = (int16_t) roundf( hParamIsmDec->azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); + elevation[1] = (int16_t) roundf( hParamIsmDec->elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]] ); #endif - power_ratio[1] = hParamIsmDec->power_ratios[band_idx][0][1]; + power_ratio[1] = hParamIsmDec->power_ratios[band_idx][0][1]; for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { -- GitLab From aca1c503c149165628108af1483d058fd94159c9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Jul 2024 14:06:57 +0200 Subject: [PATCH 089/130] evaluate edited angles in ivas_param_ism_dec_render --- lib_dec/ivas_ism_param_dec.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index ece763b6cb..877b32e5c0 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1373,6 +1373,17 @@ void ivas_param_ism_dec_render( /* store MetaData parameters */ for ( ch = 0; ch < st_ivas->nchan_ism; ch++ ) { +#ifdef OBJ_EDITING_API + if ( st_ivas->hParamIsmDec->azimuth_values[ch] > 180.0f ) + { + st_ivas->hIsmMetaData[ch]->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[ch] - 360.0f; + } + else + { + st_ivas->hIsmMetaData[ch]->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[ch]; + } + st_ivas->hIsmMetaData[ch]->elevation = st_ivas->hParamIsmDec->edited_elevation_values[ch]; +#else if ( st_ivas->hParamIsmDec->azimuth_values[ch] > 180.0f ) { st_ivas->hIsmMetaData[ch]->azimuth = st_ivas->hParamIsmDec->azimuth_values[ch] - 360.0f; @@ -1381,8 +1392,8 @@ void ivas_param_ism_dec_render( { st_ivas->hIsmMetaData[ch]->azimuth = st_ivas->hParamIsmDec->azimuth_values[ch]; } - st_ivas->hIsmMetaData[ch]->elevation = st_ivas->hParamIsmDec->elevation_values[ch]; +#endif } } -- GitLab From 0a6b2a5e2b69fc0b797aa2017ac922cbdedf92c8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Jul 2024 15:21:28 +0200 Subject: [PATCH 090/130] implement manipulation of the gain of the SBA signal in discrete-OSBA decoding --- lib_com/common_api_types.h | 1 + lib_dec/ivas_sba_dec.c | 19 +++++++++++++++++++ lib_dec/ivas_stat_dec.h | 3 +++ lib_dec/lib_dec.c | 9 +++++++++ 4 files changed, 32 insertions(+) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 9230ab453b..8cbdfcb3cd 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -139,6 +139,7 @@ typedef struct _IVAS_EDITABLE_PARAMETERS { int16_t num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; + float gain_bed; } IVAS_EDITABLE_PARAMETERS; #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index c01a244b54..550f0d0bdd 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -824,6 +824,25 @@ ivas_error ivas_sba_dec_render( } } +#ifdef OBJ_EDITING_API + if ( st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + int16_t n; + float gain = st_ivas->hSbaIsmData->gain_bed; + if ( gain != 1.0f ) + { + for ( n = 0; n < nchan_out; n++ ) + { + int16_t i; + for ( i = 0; i < L_FRAME48k; i++ ) + { + output_f_local[st_ivas->nchan_ism][i] *= gain; + } + } + } + } +#endif + *nSamplesAvailableNext = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size; return IVAS_ERR_OK; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 9ee4671c75..83b343692c 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -680,6 +680,9 @@ typedef struct ivas_osba_data float **delayBuffer; int16_t delayBuffer_size; int16_t delayBuffer_nchan; +#ifdef OBJ_EDITING_API + float gain_bed; +#endif } SBA_ISM_DATA, *SBA_ISM_DATA_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 153e81276b..561e5fd3f0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1116,6 +1116,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + hIvasEditableParameters->gain_bed = 1.0f; } } #ifdef OBJ_EDITING_API @@ -1131,6 +1132,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius = 0.0f; hIvasEditableParameters->ism_metadata[obj].gain = 1.0f; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; + hIvasEditableParameters->gain_bed = 1.0f; } } else @@ -1194,6 +1196,13 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } + +#ifdef OBJ_EDITING_API + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hIvasDec->st_ivas->hSbaIsmData->gain_bed = hIvasEditableParameters.gain_bed; + } +#endif } #ifdef OBJ_EDITING_API else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) -- GitLab From 99e770828cc83bed7d2b7b5a2e66949c6e3d8847 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Jul 2024 16:03:42 +0200 Subject: [PATCH 091/130] fix bug in applying SBA gains in OSBA rendering --- lib_dec/ivas_sba_dec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 550f0d0bdd..238ee509cb 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -827,16 +827,15 @@ ivas_error ivas_sba_dec_render( #ifdef OBJ_EDITING_API if ( st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - int16_t n; float gain = st_ivas->hSbaIsmData->gain_bed; if ( gain != 1.0f ) { - for ( n = 0; n < nchan_out; n++ ) + for ( ch = 0; ch < nchan_out; ch++ ) { int16_t i; for ( i = 0; i < L_FRAME48k; i++ ) { - output_f_local[st_ivas->nchan_ism][i] *= gain; + output_f_local[ch][i] *= gain; } } } -- GitLab From 06b342034bb6afedcced9fec4aec072d3feca7fa Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Jul 2024 16:04:22 +0200 Subject: [PATCH 092/130] initialize gain_bed to 1.0f when no editing is done --- lib_dec/lib_dec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 561e5fd3f0..7a2bba8e4c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1057,6 +1057,13 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIsmMetaData[obj]->edited_radius = hIsmMetaData[obj]->radius; hIsmMetaData[obj]->edited_gain = 1.0f; } + +#ifdef OBJ_EDITING_API + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; + } +#endif } } } -- GitLab From f982c8cfbd3db5c5d6fb6ea8b009bf6493dc5e8a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Jul 2024 16:05:32 +0200 Subject: [PATCH 093/130] fix formatting --- lib_dec/lib_dec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7a2bba8e4c..e81104b8a0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1059,10 +1059,10 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } #ifdef OBJ_EDITING_API - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; - } + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; + } #endif } } -- GitLab From e791e95e43b3bbc600e6c24297fe729ead08df14 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Jul 2024 17:13:48 +0200 Subject: [PATCH 094/130] fix crash in prerendered OSBA modes --- lib_dec/ivas_sba_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 238ee509cb..7c414ab6f6 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -825,7 +825,7 @@ ivas_error ivas_sba_dec_render( } #ifdef OBJ_EDITING_API - if ( st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { float gain = st_ivas->hSbaIsmData->gain_bed; if ( gain != 1.0f ) -- GitLab From 62c5ddfb3a9c264f67bfb9f14c9c86574e6c8344 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 10 Jul 2024 09:50:16 +0200 Subject: [PATCH 095/130] set gain_bed to -1.0 when editing it is not supported --- lib_dec/ivas_sba_dec.c | 2 +- lib_dec/lib_dec.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 7c414ab6f6..90f30f5177 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -828,7 +828,7 @@ ivas_error ivas_sba_dec_render( if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { float gain = st_ivas->hSbaIsmData->gain_bed; - if ( gain != 1.0f ) + if ( gain != 1.0f && gain >= 0.0f ) { for ( ch = 0; ch < nchan_out; ch++ ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e81104b8a0..3bbabe4c0e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1106,6 +1106,7 @@ ivas_error IVAS_DEC_GetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + hIvasEditableParameters->gain_bed = -1.0f; hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -1123,8 +1124,11 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; - hIvasEditableParameters->gain_bed = 1.0f; } + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hIvasEditableParameters->gain_bed = 1.0f; + } } #ifdef OBJ_EDITING_API else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) @@ -1139,7 +1143,6 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius = 0.0f; hIvasEditableParameters->ism_metadata[obj].gain = 1.0f; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; - hIvasEditableParameters->gain_bed = 1.0f; } } else -- GitLab From 17c437712faa9c03ebeeab727e3d823a9a193a10 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 10 Jul 2024 10:06:14 +0200 Subject: [PATCH 096/130] fix formatting --- lib_dec/lib_dec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 3bbabe4c0e..2a6d0a611d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1106,7 +1106,7 @@ ivas_error IVAS_DEC_GetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - hIvasEditableParameters->gain_bed = -1.0f; + hIvasEditableParameters->gain_bed = -1.0f; hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -1125,10 +1125,10 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - hIvasEditableParameters->gain_bed = 1.0f; - } + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hIvasEditableParameters->gain_bed = 1.0f; + } } #ifdef OBJ_EDITING_API else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) -- GitLab From 5901df992ccd97ee4b9048398d73c4061dde64a3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 10 Jul 2024 10:15:35 +0200 Subject: [PATCH 097/130] clean up ifdefs --- lib_dec/lib_dec.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2a6d0a611d..f2095bf04a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1042,9 +1042,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -#endif { int16_t obj; ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; @@ -1058,16 +1056,14 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIsmMetaData[obj]->edited_gain = 1.0f; } -#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; } -#endif } } } -#ifdef OBJ_EDITING_API + if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) { if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) @@ -1082,7 +1078,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hParamIsmDec->has_been_edited = 0; } } -#endif #endif return IVAS_ERR_OK; @@ -1110,9 +1105,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -#endif { int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) -- GitLab From 0cb8ced9704b70ae2bb1bfe12ab593307c05a2b3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 10 Jul 2024 10:42:46 +0200 Subject: [PATCH 098/130] fix crash when editing SBA gain in OSBA decoding --- lib_dec/ivas_sba_dec.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 90f30f5177..3abfa76119 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -795,6 +795,25 @@ ivas_error ivas_sba_dec_render( int16_t n_samples_sf = slot_size * hSpar->subframe_nbslots[subframe_idx]; ivas_spar_dec_upmixer_sf( st_ivas, output_f_local, nchan_internal ); + +#ifdef OBJ_EDITING_API + if (st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC) + { + float gain = st_ivas->hSbaIsmData->gain_bed; + if ( gain != 1.0f && gain >= 0.0f ) + { + for (ch = 0; ch < nchan_out; ch++) + { + int16_t i; + for (i = 0; i < n_samples_sf; i++) + { + output_f_local[ch][i] *= gain; + } + } + } + } +#endif + for ( ch = 0; ch < nchan_out; ch++ ) { output_f_local[ch] += n_samples_sf; @@ -824,24 +843,6 @@ ivas_error ivas_sba_dec_render( } } -#ifdef OBJ_EDITING_API - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - float gain = st_ivas->hSbaIsmData->gain_bed; - if ( gain != 1.0f && gain >= 0.0f ) - { - for ( ch = 0; ch < nchan_out; ch++ ) - { - int16_t i; - for ( i = 0; i < L_FRAME48k; i++ ) - { - output_f_local[ch][i] *= gain; - } - } - } - } -#endif - *nSamplesAvailableNext = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size; return IVAS_ERR_OK; -- GitLab From 28cbf7cec67e386d1352330151a1c4c9d41eac65 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 10 Jul 2024 10:43:18 +0200 Subject: [PATCH 099/130] for testing set SBA gain to 0.5 in the decoder application --- apps/decoder.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 4345ff18da..4e7284849f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2559,6 +2559,9 @@ static ivas_error decodeG192( { editableParameters.ism_metadata[obj_idx].gain = gain_mean + gain_amplitude * sinf( (float) frame * gain_freq + gain_freq_offset * (float) obj_idx ); } + + editableParameters.gain_bed = 0.5f; + /* set new object parameters*/ if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) { -- GitLab From 77babe402b3344f2630f4b0c2d8d82e451a58517 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 10 Jul 2024 10:43:45 +0200 Subject: [PATCH 100/130] fix formatting --- apps/decoder.c | 2 +- lib_dec/ivas_sba_dec.c | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 4e7284849f..9ece663072 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2560,7 +2560,7 @@ static ivas_error decodeG192( editableParameters.ism_metadata[obj_idx].gain = gain_mean + gain_amplitude * sinf( (float) frame * gain_freq + gain_freq_offset * (float) obj_idx ); } - editableParameters.gain_bed = 0.5f; + editableParameters.gain_bed = 0.5f; /* set new object parameters*/ if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 3abfa76119..17cf287b29 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -797,21 +797,21 @@ ivas_error ivas_sba_dec_render( ivas_spar_dec_upmixer_sf( st_ivas, output_f_local, nchan_internal ); #ifdef OBJ_EDITING_API - if (st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC) - { - float gain = st_ivas->hSbaIsmData->gain_bed; - if ( gain != 1.0f && gain >= 0.0f ) - { - for (ch = 0; ch < nchan_out; ch++) - { - int16_t i; - for (i = 0; i < n_samples_sf; i++) - { - output_f_local[ch][i] *= gain; - } - } - } - } + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + float gain = st_ivas->hSbaIsmData->gain_bed; + if ( gain != 1.0f && gain >= 0.0f ) + { + for ( ch = 0; ch < nchan_out; ch++ ) + { + int16_t i; + for ( i = 0; i < n_samples_sf; i++ ) + { + output_f_local[ch][i] *= gain; + } + } + } + } #endif for ( ch = 0; ch < nchan_out; ch++ ) -- GitLab From f0395e9c45eb805c7f3e67926e5897a4a0257b92 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 10 Jul 2024 11:12:04 +0200 Subject: [PATCH 101/130] clean up ifdefs in lib_dec/lib_dec.c --- lib_dec/lib_dec.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index f2095bf04a..6a4ebe1676 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1123,7 +1123,6 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->gain_bed = 1.0f; } } -#ifdef OBJ_EDITING_API else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { int16_t obj; @@ -1142,7 +1141,6 @@ ivas_error IVAS_DEC_GetEditableParameters( { assert( 0 && "This should never happen!" ); } -#endif } else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -1181,9 +1179,7 @@ ivas_error IVAS_DEC_SetEditableParameters( if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -#endif { int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) @@ -1200,14 +1196,11 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; } -#ifdef OBJ_EDITING_API if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hIvasDec->st_ivas->hSbaIsmData->gain_bed = hIvasEditableParameters.gain_bed; } -#endif } -#ifdef OBJ_EDITING_API else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { int16_t obj; @@ -1222,7 +1215,6 @@ ivas_error IVAS_DEC_SetEditableParameters( { assert( 0 && "This should never happen!" ); } -#endif } else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) { -- GitLab From bee8e11ebcb86bca04fe58a8d5c7068012b4e908 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 10 Jul 2024 11:24:54 +0200 Subject: [PATCH 102/130] remove unused flag >hParamIsmDec->has_been_edited --- lib_dec/ivas_stat_dec.h | 1 - lib_dec/lib_dec.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 83b343692c..e5bb7556e5 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -425,7 +425,6 @@ typedef struct ivas_param_ism_dec_data_structure #ifdef OBJ_EDITING_API float edited_azimuth_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; float edited_elevation_values[MAX_PARAM_SPATIAL_SUBFRAMES * IVAS_MAX_NUM_BANDS]; - int16_t has_been_edited; #endif /*sub-modules*/ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 6a4ebe1676..5947bb2ea4 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1075,7 +1075,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; } - hParamIsmDec->has_been_edited = 0; } } #endif @@ -1209,7 +1208,6 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; } - hIvasDec->st_ivas->hParamIsmDec->has_been_edited = 1; } else { -- GitLab From 8e60e4947ae0ca9e7505c8d64d4701ad0a71b864 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 10:33:53 +0200 Subject: [PATCH 103/130] implement SBA-gain editing in stereo output --- lib_dec/ivas_jbm_dec.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 548e4d2049..3f673d51f8 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1254,10 +1254,37 @@ ivas_error ivas_jbm_dec_render( ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered ); /* add already rendered SBA part */ - for ( n = 0; n < nchan_out; n++ ) - { - v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); - } +#ifdef OBJ_EDITING_API + if (st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC) + { + float gain = st_ivas->hSbaIsmData->gain_bed; + if ( gain != 1.0f && gain >= 0.0f ) + { + int16_t i; + for (n = 0; n < nchan_out; n++) + { + for (i = 0; i < *nSamplesRendered; i++) + { + p_output[n][i] += p_tc[n + st_ivas->nchan_ism][i] * gain; + } + } + } + else + { + for (n = 0; n < nchan_out; n++) + { + v_add(p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered); + } + } + } + else +#endif + { + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); + } + } } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -- GitLab From 8188511edf57268fc4298fab827610efdf4b5ee0 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 11:00:35 +0200 Subject: [PATCH 104/130] fix formatting --- lib_dec/ivas_jbm_dec.c | 58 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3f673d51f8..dbd7794463 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1255,36 +1255,36 @@ ivas_error ivas_jbm_dec_render( /* add already rendered SBA part */ #ifdef OBJ_EDITING_API - if (st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC) - { - float gain = st_ivas->hSbaIsmData->gain_bed; - if ( gain != 1.0f && gain >= 0.0f ) - { - int16_t i; - for (n = 0; n < nchan_out; n++) - { - for (i = 0; i < *nSamplesRendered; i++) - { - p_output[n][i] += p_tc[n + st_ivas->nchan_ism][i] * gain; - } - } - } - else - { - for (n = 0; n < nchan_out; n++) - { - v_add(p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered); - } - } - } - else + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + float gain = st_ivas->hSbaIsmData->gain_bed; + if ( gain != 1.0f && gain >= 0.0f ) + { + int16_t i; + for ( n = 0; n < nchan_out; n++ ) + { + for ( i = 0; i < *nSamplesRendered; i++ ) + { + p_output[n][i] += p_tc[n + st_ivas->nchan_ism][i] * gain; + } + } + } + else + { + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); + } + } + } + else #endif - { - for ( n = 0; n < nchan_out; n++ ) - { - v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); - } - } + { + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); + } + } } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -- GitLab From 116df66f35af76e2a6a5b9623a3e839154c967a3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 12:26:28 +0200 Subject: [PATCH 105/130] fix ifdef in lib_dec/lib_dec.c --- lib_dec/lib_dec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index d4cd8eab41..a17423495f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -830,7 +830,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( uint16_t *serial, /* i : buffer containing serial input bitstream. Each bit should be stored as a single uint16_t value */ const uint16_t num_bits, /* i : number of bits in input bitstream */ int16_t bfi /* i : bad frame indicator flag */ -#if defined( OBJ_EDITING_API ) +#ifdef OBJ_EDITING_API , int16_t isSplitRend, ISAR_SPLIT_REND_BITS_DATA *splitRendBits @@ -1623,11 +1623,10 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( #ifdef OBJ_EDITING_API if ( *needNewFrame ) -#endif { free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); } - +#endif return error; } -- GitLab From 0e14fc1c5094976d059033e71c6fde9d296767e1 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 12:31:11 +0200 Subject: [PATCH 106/130] clean up code --- apps/decoder.c | 10 +++----- lib_dec/ivas_ism_param_dec.c | 1 + lib_dec/ivas_ism_renderer.c | 34 -------------------------- lib_dec/ivas_jbm_dec.c | 7 ------ lib_dec/ivas_mc_param_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 18 +++++++------- lib_rend/ivas_objectRenderer.c | 6 ----- lib_rend/ivas_objectRenderer_sources.c | 1 - 8 files changed, 14 insertions(+), 65 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index fe5ae947c1..9304a7995a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -155,11 +155,9 @@ typedef struct AcousticEnvironmentSequence aeSequence; bool dpidEnabled; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; -#ifdef OBJ_EDITING_API #ifdef OBJ_EDITING_EXAMPLE bool objEditEnabled; #endif -#endif } DecArguments; @@ -1100,11 +1098,10 @@ static bool parseCmdlIVAS_dec( arg->directivityPatternId[i] = 65535; } -#ifdef OBJ_EDITING_API #ifdef OBJ_EDITING_EXAMPLE arg->objEditEnabled = false; #endif -#endif +# /*-----------------------------------------------------------------* @@ -1559,14 +1556,13 @@ static bool parseCmdlIVAS_dec( i += tmp; } -#ifdef OBJ_EDITING_API + #ifdef OBJ_EDITING_EXAMPLE else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 ) { arg->objEditEnabled = true; i++; } -#endif #endif /*-----------------------------------------------------------------* @@ -2446,7 +2442,7 @@ static ivas_error decodeG192( #endif /* Feed into decoder */ if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi -#if defined( OBJ_EDITING_API ) +#ifdef OBJ_EDITING_API , isSplitRend, splitRendBits diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index cf97101e79..aa9b179a4c 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1403,6 +1403,7 @@ void ivas_param_ism_dec_render( { st_ivas->hIsmMetaData[ch]->azimuth = st_ivas->hParamIsmDec->azimuth_values[ch]; } + st_ivas->hIsmMetaData[ch]->elevation = st_ivas->hParamIsmDec->elevation_values[ch]; #endif } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 2e78ee2005..038313d8be 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -610,37 +610,3 @@ void ivas_omasa_separate_object_render_jbm( return; } - -#if 0 -/*-------------------------------------------------------------------------* - * ivas_ism_renderer_update_md() - * - * set renderer ISM MD to the bitstream ISM MD values - *-------------------------------------------------------------------------*/ -void ivas_ism_renderer_update_md( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder handle */ -) -{ - ISM_RENDERER_HANDLE hIsmRenderer; - int16_t num_obj, obj_idx; - - - num_obj = st_ivas->nchan_ism; - hIsmRenderer = st_ivas->hIsmRendererData; - - for ( obj_idx = 0; obj_idx < num_obj; obj_idx++ ) - { - hIsmRenderer->edited_azimuth[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->azimuth; - hIsmRenderer->edited_elevation[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->elevation; - hIsmRenderer->edited_radius[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->radius; - hIsmRenderer->edited_yaw[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->yaw; - hIsmRenderer->edited_pitch[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->pitch; - hIsmRenderer->edited_gains[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->gain; - hIsmRenderer->non_diegetic_flag[obj_idx] = st_ivas->hIsmMetaData[obj_idx]->non_diegetic_flag; - } - - return; -} - - -#endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index dbd7794463..20d7d9adb9 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -187,13 +187,6 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } -#if 0 - if ( st_ivas->ism_mode != ISM_MODE_PARAM && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) ) - { - ivas_ism_renderer_update_md( st_ivas ); - } -#endif - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 3dfe714e11..9ddcf50f90 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1352,7 +1352,6 @@ void ivas_param_mc_dec_digest_tc( set_s( channel_active, 0, MAX_CICP_CHANNELS ); #endif nchan_transport = st_ivas->nchan_transport; - #ifndef OBJ_EDITING_API nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; @@ -1405,6 +1404,7 @@ void ivas_param_mc_dec_digest_tc( set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); } #endif + /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 17cf287b29..9a6df407d4 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -448,15 +448,15 @@ ivas_error ivas_sba_dec_reconfigure( return error; } - if ( st_ivas->renderer_type == RENDERER_TD_PANNING || - st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || - st_ivas->renderer_type == RENDERER_OSBA_STEREO || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || + st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || + st_ivas->renderer_type == RENDERER_OSBA_STEREO || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 651e60860a..a1c4493c88 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -573,12 +573,6 @@ ivas_error TDREND_Update_object_positions( { return error; } -#if 0 - if ( ( error = TDREND_MIX_SRC_SetSrcGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } } diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 7d42c54ffc..f14433cfaa 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -181,7 +181,6 @@ ivas_error TDREND_MIX_SRC_SetDistAtten( return IVAS_ERR_OK; } - /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetPlayState() * -- GitLab From 54134e4e12cabbd49b7042888b32f98f7c0da8e8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 12:48:04 +0200 Subject: [PATCH 107/130] do not attempt to deallocate pose-correction data with every new frame --- lib_dec/lib_dec.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a17423495f..b46a6b4063 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1621,13 +1621,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } -#ifdef OBJ_EDITING_API - if ( *needNewFrame ) - { - free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); - } -#endif - return error; } -- GitLab From fa565fb4d53eef8736c6d09e1fab6a44d400c83a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 16:24:36 +0200 Subject: [PATCH 108/130] implement object-gain editing in TD renderer --- lib_com/ivas_stat_com.h | 3 +++ lib_dec/ivas_objectRenderer_internal.c | 5 ++--- lib_rend/ivas_objectRenderer.c | 6 ++++++ lib_rend/ivas_objectRenderer_sources.c | 28 ++++++++++++++++++++++++++ lib_rend/ivas_prot_rend.h | 8 ++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index f70f6942f3..d3ac7ac3ec 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -66,6 +66,9 @@ typedef struct float pitch; /* pitch value read from the input metadata file */ #ifdef OBJ_EDITING_API + + float gain; + float edited_azimuth; float edited_elevation; float edited_radius; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 929705fad7..43c5360a8a 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -186,6 +186,7 @@ ivas_error ivas_td_binaural_renderer_sf( ismMetaData[nS].yaw = st_ivas->hIsmMetaData[nS]->edited_yaw; ismMetaData[nS].pitch = st_ivas->hIsmMetaData[nS]->edited_pitch; ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmMetaData[nS]->non_diegetic_flag; + ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; hIsmMetaData[nS] = &ismMetaData[nS]; } @@ -194,16 +195,14 @@ ivas_error ivas_td_binaural_renderer_sf( return error; } } +#endif else { -#endif if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) { return error; } -#ifdef OBJ_EDITING_API } -#endif } /* Update the listener's location/orientation */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index a1c4493c88..5c5c84b614 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -552,6 +552,12 @@ ivas_error TDREND_Update_object_positions( { return error; } +#ifdef OBJ_EDITING_INTERFACE + if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif if ( hIsmMetaData[nS]->non_diegetic_flag ) { diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index f14433cfaa..24d0211481 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -128,6 +128,34 @@ ivas_error TDREND_MIX_SRC_SetDir( return IVAS_ERR_OK; } +#ifdef OBJ_EDITING_INTERFACE +/*-------------------------------------------------------------------* + * TDREND_MIX_SRC_SetSourceGain() + * + * Set source gain + --------------------------------------------------------------------*/ + +ivas_error TDREND_MIX_SRC_SetGain( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float Gain /* i : Gain */ +) +{ + TDREND_SRC_SPATIAL_t *SrcSpatial_p; + + /* Value verification */ + if ( ! ( Gain >= 0.0f && Gain <= 2.0f ) ) + { + return (IVAS_ERROR(IVAS_ERR_WRONG_PARAMS, "Gain out of range. Command is ignored!\n")); + } + else + { + hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGain_p[0] = Gain; + } + + return IVAS_ERR_OK; +} +#endif /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetDirAtten() diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 98de8c0195..8e6980b054 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -720,6 +720,14 @@ ivas_error TDREND_MIX_SRC_SetDir( const float *Vec_p /* i : Direction vector */ ); +#ifdef OBJ_EDITING_INTERFACE +ivas_error TDREND_MIX_SRC_SetGain( + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float Gain /* i : Gain */ +); +#endif + ivas_error TDREND_MIX_SRC_SetDirAtten( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ -- GitLab From aae121c3bec9e76a757b9da9163f54bb470a68e7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 16:25:03 +0200 Subject: [PATCH 109/130] make object gain editing easier to recognize in the output --- apps/decoder.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 9304a7995a..be8cc6cf00 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2471,10 +2471,6 @@ static ivas_error decodeG192( /* and play a little bit with the gains... */ int16_t obj_idx, non_diegetic_obj_idx; int16_t num_nondiegetic_objects; - float gain_mean; - float gain_amplitude; - float gain_freq; - float gain_freq_offset; num_nondiegetic_objects = 0; for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) @@ -2499,14 +2495,11 @@ static ivas_error decodeG192( } } } - /* 2 second AM of the object gains. */ - gain_mean = 1.0f; - gain_amplitude = 0.7f; - gain_freq = ( 2.0f * 3.1415f ) / 100.0f; - gain_freq_offset = 2.0f * 3.1415f / (float) ( editableParameters.num_obj + 1 ); + + /* breakover object gains */ for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) { - editableParameters.ism_metadata[obj_idx].gain = gain_mean + gain_amplitude * sinf( (float) frame * gain_freq + gain_freq_offset * (float) obj_idx ); + editableParameters.ism_metadata[obj_idx].gain = 0.5 + (float) ( ( frame + obj_idx*50) % 250 ) / 250.0f; } editableParameters.gain_bed = 0.5f; -- GitLab From 7abcb78c46321447a2df97c2d8b2129c058bc74a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 16:31:38 +0200 Subject: [PATCH 110/130] fix formatting; --- apps/decoder.c | 2 +- lib_com/ivas_stat_com.h | 2 +- lib_dec/ivas_objectRenderer_internal.c | 2 +- lib_rend/ivas_objectRenderer.c | 8 +++---- lib_rend/ivas_objectRenderer_sources.c | 32 +++++++++++++------------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index be8cc6cf00..f1704f19c7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2499,7 +2499,7 @@ static ivas_error decodeG192( /* breakover object gains */ for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) { - editableParameters.ism_metadata[obj_idx].gain = 0.5 + (float) ( ( frame + obj_idx*50) % 250 ) / 250.0f; + editableParameters.ism_metadata[obj_idx].gain = 0.5 + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; } editableParameters.gain_bed = 0.5f; diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index d3ac7ac3ec..9b52a42cc3 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -67,7 +67,7 @@ typedef struct #ifdef OBJ_EDITING_API - float gain; + float gain; float edited_azimuth; float edited_elevation; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 43c5360a8a..9eed9ca0a1 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -186,7 +186,7 @@ ivas_error ivas_td_binaural_renderer_sf( ismMetaData[nS].yaw = st_ivas->hIsmMetaData[nS]->edited_yaw; ismMetaData[nS].pitch = st_ivas->hIsmMetaData[nS]->edited_pitch; ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmMetaData[nS]->non_diegetic_flag; - ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; + ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; hIsmMetaData[nS] = &ismMetaData[nS]; } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 5c5c84b614..b09a4671da 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -553,10 +553,10 @@ ivas_error TDREND_Update_object_positions( return error; } #ifdef OBJ_EDITING_INTERFACE - if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) + { + return error; + } #endif if ( hIsmMetaData[nS]->non_diegetic_flag ) diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 24d0211481..750a8211d2 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -136,24 +136,24 @@ ivas_error TDREND_MIX_SRC_SetDir( --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetGain( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float Gain /* i : Gain */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float Gain /* i : Gain */ ) { - TDREND_SRC_SPATIAL_t *SrcSpatial_p; - - /* Value verification */ - if ( ! ( Gain >= 0.0f && Gain <= 2.0f ) ) - { - return (IVAS_ERROR(IVAS_ERR_WRONG_PARAMS, "Gain out of range. Command is ignored!\n")); - } - else - { - hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGain_p[0] = Gain; - } - - return IVAS_ERR_OK; + TDREND_SRC_SPATIAL_t *SrcSpatial_p; + + /* Value verification */ + if ( !( Gain >= 0.0f && Gain <= 2.0f ) ) + { + return ( IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Gain out of range. Command is ignored!\n" ) ); + } + else + { + hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGain_p[0] = Gain; + } + + return IVAS_ERR_OK; } #endif -- GitLab From b9f440729210f67bb78dc0540f583df21321d6f6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 16:59:08 +0200 Subject: [PATCH 111/130] set source gain through the new function TDREND_SRC_SPATIAL_SetGain --- lib_rend/ivas_objectRenderer_sources.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 750a8211d2..4466692f47 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -53,6 +53,10 @@ static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, static void TDREND_SRC_SPATIAL_SetDistAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DistAtten_t *DistAtten_p ); +#ifdef OBJ_EDITING_INTERFACE +static void TDREND_SRC_SPATIAL_SetGain(const TDREND_DirAtten_t *DirAtten_p, const float Gain); +#endif + static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p ); static float TDREND_SRC_SPATIAL_GetDistGain( const TDREND_DistAtten_t *DistAtten_p, const float Dist ); @@ -150,7 +154,7 @@ ivas_error TDREND_MIX_SRC_SetGain( } else { - hBinRendererTd->Sources[SrcInd]->SrcRend_p->SrcGain_p[0] = Gain; + TDREND_SRC_SPATIAL_SetGain(hBinRendererTd->Sources[SrcInd], Gain ); } return IVAS_ERR_OK; @@ -561,6 +565,24 @@ static void TDREND_SRC_SPATIAL_SetDistAtten( return; } + + +#ifdef OBJ_EDITING_INTERFACE +/*-------------------------------------------------------------------* + * TDREND_SRC_SPATIAL_SetGain() + * + * Set the object gain + --------------------------------------------------------------------*/ + +static void TDREND_SRC_SPATIAL_SetGain( + const TDREND_SRC_t *Src_p, /* i : Directional attenuation specification */ + const float Gain /* i : Front-pointing vector */ +) +{ + Src_p->SrcRend_p->SrcGain_p[0] = Gain; +} +#endif + /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_GetDirGain() * @@ -612,7 +634,6 @@ static float TDREND_SRC_SPATIAL_GetDirGain( return DirGain; } - /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_GetDistGain() * -- GitLab From 58c2c0c320e1b716dacbf0d8bb6aff19d2070506 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 17:12:48 +0200 Subject: [PATCH 112/130] fix formatting --- lib_rend/ivas_objectRenderer_sources.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 4466692f47..7b504c91ab 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -54,7 +54,7 @@ static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, static void TDREND_SRC_SPATIAL_SetDistAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DistAtten_t *DistAtten_p ); #ifdef OBJ_EDITING_INTERFACE -static void TDREND_SRC_SPATIAL_SetGain(const TDREND_DirAtten_t *DirAtten_p, const float Gain); +static void TDREND_SRC_SPATIAL_SetGain( const TDREND_DirAtten_t *DirAtten_p, const float Gain ); #endif static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p ); @@ -154,7 +154,7 @@ ivas_error TDREND_MIX_SRC_SetGain( } else { - TDREND_SRC_SPATIAL_SetGain(hBinRendererTd->Sources[SrcInd], Gain ); + TDREND_SRC_SPATIAL_SetGain( hBinRendererTd->Sources[SrcInd], Gain ); } return IVAS_ERR_OK; @@ -575,11 +575,11 @@ static void TDREND_SRC_SPATIAL_SetDistAtten( --------------------------------------------------------------------*/ static void TDREND_SRC_SPATIAL_SetGain( - const TDREND_SRC_t *Src_p, /* i : Directional attenuation specification */ - const float Gain /* i : Front-pointing vector */ + const TDREND_SRC_t *Src_p, /* i : Directional attenuation specification */ + const float Gain /* i : Front-pointing vector */ ) { - Src_p->SrcRend_p->SrcGain_p[0] = Gain; + Src_p->SrcRend_p->SrcGain_p[0] = Gain; } #endif -- GitLab From 857dd58b076478432c21dde8c524e3953139df54 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 31 Jul 2024 17:14:05 +0200 Subject: [PATCH 113/130] fix compile error --- apps/decoder.c | 2 +- lib_rend/ivas_objectRenderer_sources.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index f1704f19c7..70ba1e9761 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2499,7 +2499,7 @@ static ivas_error decodeG192( /* breakover object gains */ for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) { - editableParameters.ism_metadata[obj_idx].gain = 0.5 + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; + editableParameters.ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; } editableParameters.gain_bed = 0.5f; diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 7b504c91ab..4ccafbc6dc 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -54,7 +54,7 @@ static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, static void TDREND_SRC_SPATIAL_SetDistAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DistAtten_t *DistAtten_p ); #ifdef OBJ_EDITING_INTERFACE -static void TDREND_SRC_SPATIAL_SetGain( const TDREND_DirAtten_t *DirAtten_p, const float Gain ); +static void TDREND_SRC_SPATIAL_SetGain( const TDREND_SRC_t *Src_p, const float Gain ); #endif static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p ); @@ -145,8 +145,6 @@ ivas_error TDREND_MIX_SRC_SetGain( const float Gain /* i : Gain */ ) { - TDREND_SRC_SPATIAL_t *SrcSpatial_p; - /* Value verification */ if ( !( Gain >= 0.0f && Gain <= 2.0f ) ) { -- GitLab From 4002d2ef46d4dcc4ec153be8ba4e9edbdf1f7dd7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 1 Aug 2024 09:39:24 +0200 Subject: [PATCH 114/130] always initialize hIsmMeta->gain --- lib_com/ivas_ism_com.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index a47ba733f1..99131d5e0f 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -425,6 +425,7 @@ void ivas_ism_reset_metadata( hIsmMeta->edited_pitch = 0.0f; hIsmMeta->edited_yaw = 0.0f; hIsmMeta->edited_radius = 1.0f; + hIsmMeta->gain = 1.0f; hIsmMeta->non_diegetic_flag = 0; #endif -- GitLab From aae6d1f7bc331fee18609348edd6cfeddcb99f7d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 1 Aug 2024 10:48:49 +0200 Subject: [PATCH 115/130] fix renderer crash --- lib_rend/ivas_objectRenderer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index b09a4671da..e4e930d89b 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -783,6 +783,10 @@ ivas_error ivas_td_binaural_renderer_ext( hIsmMetaData[0]->yaw = currentPos->yaw; hIsmMetaData[0]->pitch = currentPos->pitch; hIsmMetaData[0]->radius = currentPos->radius; +#ifdef OBJ_EDITING_INTERFACE + hIsmMetaData[0]->gain = 1.0f; +#endif + hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; } -- GitLab From 1f433372af28bee76a18ee44383ccd44af1266ac Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 1 Aug 2024 11:11:26 +0200 Subject: [PATCH 116/130] fix formatting --- lib_rend/ivas_objectRenderer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index e4e930d89b..dbe5cc8d06 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -786,7 +786,7 @@ ivas_error ivas_td_binaural_renderer_ext( #ifdef OBJ_EDITING_INTERFACE hIsmMetaData[0]->gain = 1.0f; #endif - + hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; } -- GitLab From 38728f909dc6704b3a790a7f0b9448f0cea215ee Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 23 Aug 2024 09:12:18 +0300 Subject: [PATCH 117/130] Implements OMASA object editing (previously implemented in branch nokia/object-editing-interface). Changes to use non-callback API (compared to previous branch). Adds support for object editing in ParamISM to binaural rendering. --- apps/decoder.c | 3 + lib_com/ivas_cnst.h | 5 + lib_com/ivas_prot.h | 4 + lib_com/ivas_stat_com.h | 1 - lib_com/options.h | 4 + lib_dec/ivas_dirac_dec.c | 7 + lib_dec/ivas_init_dec.c | 15 + lib_dec/ivas_ism_dec.c | 25 + lib_dec/ivas_ism_param_dec.c | 46 ++ lib_dec/ivas_ism_renderer.c | 26 + lib_dec/ivas_jbm_dec.c | 27 + lib_dec/ivas_masa_dec.c | 7 + lib_dec/ivas_omasa_dec.c | 83 ++ lib_dec/ivas_stat_dec.h | 23 +- lib_dec/lib_dec.c | 221 +++++- lib_rend/ivas_dirac_dec_binaural_functions.c | 774 +++++++++++++++++++ lib_rend/ivas_dirac_output_synthesis_dec.c | 14 + 17 files changed, 1271 insertions(+), 14 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 70ba1e9761..4afa6f1129 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1769,6 +1769,9 @@ static void usage_dec( void ) fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); fprintf( stdout, "-q : Quiet mode, no frame counter\n" ); fprintf( stdout, " default is deactivated\n" ); +#ifdef OMASA_OBJECT_EDITING + fprintf( stdout, "-obj_edit : enable object editing\n" ); +#endif #ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO_TWEAK fprintf( stdout, "-info : specify subfolder name for debug output\n" ); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 8c72cf2808..4e5d9d8ae5 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1215,6 +1215,11 @@ enum #define MASA_MAXIMUM_TWO_DIR_BANDS 24 #define NBITS_HR_COH 4 #define OMASA_TDREND_MATCHING_GAIN 0.7943f +#ifdef OMASA_OBJECT_EDITING +#define OMASA_GAIN_EDIT_THR 0.06f /* OMASA gain change threshold */ +#define OMASA_AZI_EDIT_THR 1.0f /* OMASA-DISC azimuth change threshold */ +#define OMASA_ELE_EDIT_THR 2.0f /* OMASA-DISC elevation change threshold */ +#endif #define MASA_JBM_RINGBUFFER_FRAMES 3 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 73043f9b7c..6a52809906 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5797,7 +5797,11 @@ void ivas_omasa_dirac_rend_jbm( float *output_f[] /* o : rendered time signal */ ); +#ifdef OMASA_OBJECT_EDITING +void ivas_omasa_preProcessStereoTransportsForEditedObjects( +#else void ivas_omasa_preProcessStereoTransportsForMovedObjects( +#endif Decoder_Struct *st_ivas, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 9b52a42cc3..594e30ff26 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -66,7 +66,6 @@ typedef struct float pitch; /* pitch value read from the input metadata file */ #ifdef OBJ_EDITING_API - float gain; float edited_azimuth; diff --git a/lib_com/options.h b/lib_com/options.h index b9b1d15717..e7df53ae18 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,6 +160,10 @@ #define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ #endif +#define OMASA_OBJECT_EDITING /* Nokia: object editing interface for OMASA */ +#define OBJ_EDITING_PARAMISM_BIN /* Nokia: object editing for ParamISM to binaural */ + + /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 794cf55ea7..f79bd86ad4 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1839,10 +1839,17 @@ void ivas_dirac_dec_render_sf( } } +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + ivas_omasa_preProcessStereoTransportsForEditedObjects( st_ivas, Cldfb_RealBuffer_Temp, Cldfb_ImagBuffer_Temp, hSpatParamRendCom->num_freq_bands, subframe_idx ); + } +#else if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) { ivas_omasa_preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_Temp, Cldfb_ImagBuffer_Temp, hSpatParamRendCom->num_freq_bands, subframe_idx ); } +#endif } for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d70774db7d..3930c3b2c1 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1136,6 +1136,17 @@ ivas_error ivas_init_decoder( if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3; + +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + /* reusing OMASA function for allocating and initializing MASA_ISM rendering handle (even though not in OMASA) */ + if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif } else if ( st_ivas->ism_mode == ISM_MODE_DISC ) { @@ -1453,12 +1464,15 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] ); +#ifndef OMASA_OBJECT_EDITING if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { +#endif if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) { return error; } +#ifndef OMASA_OBJECT_EDITING } else { @@ -1467,6 +1481,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif } else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 4f5dc179dd..36945f8155 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -177,6 +177,10 @@ static ivas_error ivas_ism_bitrate_switching_dec( { /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#ifdef OBJ_EDITING_PARAMISM_BIN + /* Close omasa data struct (used for object editing) */ + ivas_omasa_data_close( &st_ivas->hMasaIsmData ); +#endif /* Open the TD Binaural renderer */ if ( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL ) { @@ -209,6 +213,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#ifdef OBJ_EDITING_PARAMISM_BIN + /* Close omasa data struct (used for object editing) */ + ivas_omasa_data_close( &st_ivas->hMasaIsmData ); +#endif + /* Open Crend Binaural renderer */ if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) { @@ -241,6 +250,14 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } +#ifdef OBJ_EDITING_PARAMISM_BIN + /* Open omasa data struct (used for object editing) */ + if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + /* Close the TD Binaural renderer */ ivas_td_binaural_close( &st_ivas->hBinRendererTd ); @@ -268,6 +285,14 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } +#ifdef OBJ_EDITING_PARAMISM_BIN + /* Open omasa data struct (used for object editing) */ + if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + /* close the crend binaural renderer */ ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index aa9b179a4c..5867b2adcb 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1432,12 +1432,20 @@ void ivas_param_ism_params_to_masa_param_mapping( int16_t azimuth[2]; int16_t elevation[2]; float power_ratio[2]; +#ifdef OBJ_EDITING_PARAMISM_BIN + MASA_ISM_DATA_HANDLE hMasaIsmData; + int16_t obj; + int16_t obj_idx; +#endif #ifndef OBJ_EDITING_API int32_t ivas_total_brate; #endif hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; +#ifdef OBJ_EDITING_PARAMISM_BIN + hMasaIsmData = st_ivas->hMasaIsmData; +#endif nBins = hSpatParamRendCom->num_freq_bands; #ifndef OBJ_EDITING_API @@ -1526,6 +1534,44 @@ void ivas_param_ism_params_to_masa_param_mapping( hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx] = 0.0; } } +#ifdef OBJ_EDITING_PARAMISM_BIN + for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) + { + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + hMasaIsmData->azimuth_ism[obj][sf_idx] = (int16_t) roundf( hParamIsmDec->azimuth_values[obj] ); + hMasaIsmData->elevation_ism[obj][sf_idx] = (int16_t) roundf( hParamIsmDec->elevation_values[obj] ); + } + + hMasaIsmData->azimuth_ism_edited[obj] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[obj] ); + hMasaIsmData->elevation_ism_edited[obj] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[obj] ); + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + set_zero( hMasaIsmData->energy_ratio_ism[obj][sf_idx], CLDFB_NO_CHANNELS_MAX ); + } + } + + for ( obj = 0; obj < MAX_PARAM_ISM_WAVE; obj++ ) + { + for ( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + + obj_idx = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][obj]; + power_ratio[obj] = hParamIsmDec->power_ratios[band_idx][0][obj]; + + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) + { + hMasaIsmData->energy_ratio_ism[obj_idx][sf_idx][bin_idx] = power_ratio[obj]; + } + } + } + } +#endif } return; diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 038313d8be..ae6e452313 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -557,13 +557,39 @@ void ivas_omasa_separate_object_render_jbm( if ( single_separated ) { +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->ism_dir_is_edited[st_ivas->hMasaIsmData->idx_separated_ism] ) + { + azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited[st_ivas->hMasaIsmData->idx_separated_ism]; + elevation = st_ivas->hMasaIsmData->elevation_ism_edited[st_ivas->hMasaIsmData->idx_separated_ism]; + } + else + { + azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism[md_idx]; + elevation = st_ivas->hMasaIsmData->elevation_separated_ism[md_idx]; + } +#else azimuth = st_ivas->hMasaIsmData->azimuth_separated_ism[md_idx]; elevation = st_ivas->hMasaIsmData->elevation_separated_ism[md_idx]; +#endif } else { +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->hMasaIsmData->ism_dir_is_edited[obj] ) + { + azimuth = st_ivas->hMasaIsmData->azimuth_ism_edited[obj]; + elevation = st_ivas->hMasaIsmData->elevation_ism_edited[obj]; + } + else + { + azimuth = st_ivas->hMasaIsmData->azimuth_ism[obj][md_idx]; + elevation = st_ivas->hMasaIsmData->elevation_ism[obj][md_idx]; + } +#else azimuth = st_ivas->hMasaIsmData->azimuth_ism[obj][md_idx]; elevation = st_ivas->hMasaIsmData->elevation_ism[obj][md_idx]; +#endif } if ( st_ivas->hOutSetup.is_planar_setup ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 20d7d9adb9..6eea0419a2 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3133,13 +3133,40 @@ void ivas_jbm_dec_prepare_renderer( { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { +#ifdef OMASA_OBJECT_EDITING + float gainIsm; + gainIsm = OMASA_TDREND_MATCHING_GAIN; + + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + { + gainIsm *= st_ivas->hMasaIsmData->gain_ism_edited[n]; + } + + v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], gainIsm, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); +#else v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); +#endif } if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + int16_t tcBufferSize; + tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size; + + if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + { + for ( int16_t ch = 0; ch < 2; ch++ ) + { + v_multc( st_ivas->hTcBuffer->tc[ch], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[ch], tcBufferSize ); + } + } + } +#endif } } } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 544f3d36bf..4065418900 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -634,7 +634,11 @@ ivas_error ivas_masa_dec_open( ism_total_brate = 0; /* ISM metadata */ +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hIsmMetaData[0] != NULL ) +#else if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hIsmMetaData[0] != NULL && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) +#endif { /* these are not needed -> clean. EXT metafile writer in OMASA needs only the number of ISMs and writes default null-data */ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); @@ -2416,6 +2420,9 @@ static int16_t ivas_decode_masaism_metadata( for ( obj = 0; obj < nchan_ism; obj++ ) { +#ifdef OMASA_OBJECT_EDITING + hMasaIsmData->bits_ism[obj] = bits_ism[obj]; +#endif index = 0; if ( bits_ism[obj] < 8 ) /* if low resolution, can look to the past */ { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 465f013317..8164c2aa65 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -60,7 +60,11 @@ ivas_error ivas_omasa_data_open( ) { MASA_ISM_DATA_HANDLE hMasaIsmData; +#ifdef OMASA_OBJECT_EDITING + int16_t ch; +#else int16_t ch, bin; +#endif int16_t sf, obj_idx; if ( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL ) @@ -68,6 +72,23 @@ ivas_error ivas_omasa_data_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) ); } +#ifdef OMASA_OBJECT_EDITING + for ( int16_t band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) + { + for ( ch = 0; ch < 2; ch++ ) + { + hMasaIsmData->ismPreprocMatrix[ch][ch][band_idx] = 1.0f; + hMasaIsmData->ismPreprocMatrix[1 - ch][ch][band_idx] = 0.0f; + hMasaIsmData->eneMoveIIR[ch][band_idx] = 0.0f; + hMasaIsmData->enePreserveIIR[ch][band_idx] = 0.0f; + } + hMasaIsmData->eneOrigIIR[band_idx] = 0.0f; + hMasaIsmData->preprocEneTarget[band_idx] = 0.0f; + hMasaIsmData->preprocEneRealized[band_idx] = 0.0f; + } + + hMasaIsmData->objectsEdited = 0; +#else for ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) { for ( ch = 0; ch < 2; ch++ ) @@ -82,14 +103,24 @@ ivas_error ivas_omasa_data_open( } hMasaIsmData->objectsMoved = 0; +#endif hMasaIsmData->delayBuffer = NULL; for ( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) { +#ifdef OMASA_OBJECT_EDITING + hMasaIsmData->ism_dir_is_edited[ch] = 0; + hMasaIsmData->ism_gain_is_edited[ch] = 0; +#else hMasaIsmData->ism_is_edited[ch] = 0; +#endif hMasaIsmData->q_elevation_old[ch] = 0.0f; hMasaIsmData->q_azimuth_old[ch] = 0.0f; } +#ifdef OMASA_OBJECT_EDITING + hMasaIsmData->masa_gain_is_edited = 0; + hMasaIsmData->idx_separated_ism = -1; +#endif for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) { @@ -195,7 +226,11 @@ ivas_error ivas_omasa_dec_config( void *data /* o : output synthesis signal */ ) { +#ifdef OMASA_OBJECT_EDITING + int16_t k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old; +#else int16_t k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old, n_MD; +#endif int32_t ivas_total_brate, ism_total_brate, cpe_brate; ISM_MODE ism_mode_old; IVAS_FORMAT ivas_format_orig; @@ -287,6 +322,22 @@ ivas_error ivas_omasa_dec_config( if ( ism_mode_old != st_ivas->ism_mode ) { /* ISM MD reconfig. */ +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->hIsmMetaData[0] == NULL ) + { + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + for ( k = 0; k < st_ivas->nchan_ism; k++ ) + { + ivas_ism_reset_metadata_handle_dec( st_ivas->hIsmMetaData[k] ); + } + } +#else n_MD = 0; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) @@ -337,6 +388,7 @@ ivas_error ivas_omasa_dec_config( ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD ); } +#endif st_ivas->hCPE[0]->element_brate = ivas_total_brate - ism_total_brate; @@ -700,13 +752,44 @@ void ivas_omasa_dirac_rend_jbm( if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { mvr2r( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); + +#ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + /* Gain separated object, if edited */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && st_ivas->hMasaIsmData->idx_separated_ism == n ) + { + v_multc( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[0], *nSamplesRendered ); + } + } + } +#endif } else { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { mvr2r( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); +#ifdef OMASA_OBJECT_EDITING + /* Gain discrete objects, if edited */ + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + { + v_multc( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); + } +#endif } +#ifdef OMASA_OBJECT_EDITING + /* Gain MASA part, if edited */ + if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + { + for ( int16_t ch = 0; ch < 2; ch++ ) + { + v_multc( output_f[ch], st_ivas->hMasaIsmData->gain_masa_edited, output_f[ch], *nSamplesRendered ); + } + } +#endif } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 30568f292a..e9dde1bdaa 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -910,12 +910,23 @@ typedef struct ivas_masa_ism_data_structure int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; +#ifdef OMASA_OBJECT_EDITING + uint8_t ism_dir_is_edited[MAX_NUM_OBJECTS]; +#else uint8_t ism_is_edited[MAX_NUM_OBJECTS]; +#endif #ifdef OBJ_EDITING_API float gain_ism[MAX_NUM_OBJECTS]; float gain_masa; #endif +#ifdef OMASA_OBJECT_EDITING + float gain_ism_edited[MAX_NUM_OBJECTS]; + uint8_t ism_gain_is_edited[MAX_NUM_OBJECTS]; + float gain_masa_edited; + uint8_t masa_gain_is_edited; +#endif + int16_t idx_separated_ism; int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; int16_t elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; @@ -923,13 +934,23 @@ typedef struct ivas_masa_ism_data_structure float q_azimuth_old[MAX_NUM_OBJECTS]; float q_elevation_old[MAX_NUM_OBJECTS]; +#ifdef OMASA_OBJECT_EDITING + uint8_t objectsEdited; + float preprocEneTarget[MASA_FREQUENCY_BANDS]; + float preprocEneRealized[MASA_FREQUENCY_BANDS]; + float ismPreprocMatrix[2][2][MASA_FREQUENCY_BANDS]; + float eneMoveIIR[2][MASA_FREQUENCY_BANDS]; + float enePreserveIIR[2][MASA_FREQUENCY_BANDS]; + float eneOrigIIR[MASA_FREQUENCY_BANDS]; + int16_t bits_ism[MAX_NUM_OBJECTS]; +#else float ismPreprocMatrix[2][2][CLDFB_NO_CHANNELS_MAX]; uint8_t objectsMoved; float eneMoveIIR[2][CLDFB_NO_CHANNELS_MAX]; float enePreserveIIR[2][CLDFB_NO_CHANNELS_MAX]; float preprocEneTarget[CLDFB_NO_CHANNELS_MAX]; float preprocEneRealized[CLDFB_NO_CHANNELS_MAX]; - +#endif float **delayBuffer; int16_t delayBuffer_size; int16_t delayBuffer_nchan; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index f8a210e580..9bd27502fd 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -35,6 +35,9 @@ #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "isar_prot.h" +#ifdef OMASA_OBJECT_EDITING +#include "ivas_rom_com.h" +#endif #include "lib_isar_pre_rend.h" #include "prot.h" #include "jbm_jb4sb.h" @@ -992,7 +995,11 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { +#ifdef OMASA_OBJECT_EDITING + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#endif { int16_t obj; ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; @@ -1037,20 +1044,28 @@ ivas_error IVAS_DEC_FeedFrame_Serial( /*---------------------------------------------------------------------* * IVAS_DEC_GetEditableParameters( ) * - * Main function to decode to PCM data + * *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetEditableParameters( IVAS_DEC_HANDLE hIvasDec, IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) { ivas_error error; + int16_t dirac_read_idx; + + if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || + ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || + ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); + } if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - hIvasEditableParameters->gain_bed = -1.0f; + hIvasEditableParameters->gain_bed = 1.0f; hIvasEditableParameters->num_obj = hIvasDec->st_ivas->nchan_ism; if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -1091,13 +1106,57 @@ ivas_error IVAS_DEC_GetEditableParameters( assert( 0 && "This should never happen!" ); } } - else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) +#ifdef OMASA_OBJECT_EDITING + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { - } - else - { - } + /* object editing possible only in two highest OMASA modes */ + int16_t obj; + if ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hIsmMetaData[obj]->elevation; + hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + + /* reset the otherwise unused "gain" field for the object */ + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + } + } + else + { + /* Handle MONO output */ + if ( hIvasDec->st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) + { + dirac_read_idx = hIvasDec->st_ivas->hSpatParamRendCom->render_to_md_map[hIvasDec->st_ivas->hSpatParamRendCom->subframes_rendered]; + } + else + { + dirac_read_idx = 0; + } + + for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) + { + hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx]; + hIvasEditableParameters->ism_metadata[obj].elevation = hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx]; + + hIvasEditableParameters->ism_metadata[obj].yaw = hIvasDec->st_ivas->hIsmMetaData[obj]->yaw; + hIvasEditableParameters->ism_metadata[obj].pitch = hIvasDec->st_ivas->hIsmMetaData[obj]->pitch; + hIvasEditableParameters->ism_metadata[obj].radius = hIvasDec->st_ivas->hIsmMetaData[obj]->radius; + + /* reset the otherwise unused "gain" field for the object */ + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; + hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; + hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; + } + } + } +#endif error = IVAS_ERR_OK; @@ -1114,14 +1173,22 @@ ivas_error IVAS_DEC_SetEditableParameters( IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) { ivas_error error; + int16_t dirac_read_idx; - error = IVAS_ERR_OK; + if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || + ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || + ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); + } if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + error = IVAS_ERR_OK; + #ifdef DEBUGGING assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); #endif @@ -1155,21 +1222,151 @@ ivas_error IVAS_DEC_SetEditableParameters( int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { +#ifdef OBJ_EDITING_PARAMISM_BIN hIvasDec->st_ivas->hParamIsmDec->edited_azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; hIvasDec->st_ivas->hParamIsmDec->edited_elevation_values[obj] = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + + /* Detect direction editing in Param-ISM mode */ + if ( fabsf( hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj] - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || + fabsf( hIvasDec->st_ivas->hParamIsmDec->elevation_values[obj] - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + } + + /* Detect gain editing in Param-ISM mode */ + if ( fabsf( 1.0f - hIvasEditableParameters.ism_metadata[obj].gain ) > OMASA_GAIN_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; + } +#endif } +#ifdef OBJ_EDITING_PARAMISM_BIN + /* MASA is not present with the ISM format */ + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; +#endif } else { assert( 0 && "This should never happen!" ); } } - else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - } - else +#ifdef OMASA_OBJECT_EDITING + else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { + int16_t obj; + int32_t id_th; + float threshold_azi, threshold_ele; + + for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) + { + if ( hIvasDec->st_ivas->hMasaIsmData != NULL ) + { + /* copy relevant fields also to OMASA structs, but only if the value has been changed. original values are in st_ivas->hIsmMetaData */ + /* first, need to convert float values to ints used internally */ + int16_t new_azi, new_ele; + if ( hIvasEditableParameters.ism_metadata[obj].azimuth > 0.0f ) + { + new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth + 0.5f ); + } + else + { + new_azi = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].azimuth - 0.5f ); + } + + if ( hIvasEditableParameters.ism_metadata[obj].elevation > 0.0f ) + { + new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation + 0.5f ); + } + else + { + new_ele = (int16_t) ( hIvasEditableParameters.ism_metadata[obj].elevation - 0.5f ); + } + + if ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + /* Handle MONO output */ + if ( hIvasDec->st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) + { + dirac_read_idx = hIvasDec->st_ivas->hSpatParamRendCom->render_to_md_map[hIvasDec->st_ivas->hSpatParamRendCom->subframes_rendered]; + } + else + { + dirac_read_idx = 0; + } + + /* determine thresholds for detecting object metadata edit for direction based on quantization resolution of the spatial direction parameters. + * these depend from the number of bits used to transmit the directions, + * which in turn depends from the object priority and importance: + * importance -> priority -> number of bits -> elevation resolution -> elevation ring index -> azimuth resolution. + * leading to elevation_resolution -> elevation threshold and azimuth resolution -> azimuth threshold */ + id_th = (int) ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); + threshold_azi = 360.0f / (float) no_phi_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th]; + threshold_ele = delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; + + if ( ( (float) abs( new_azi - hIvasDec->st_ivas->hMasaIsmData->azimuth_ism[obj][dirac_read_idx] ) > threshold_azi ) || + ( (float) abs( new_ele - hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) > threshold_ele ) ) + { + /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ + hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; + hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; + + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + } + } + else + { + /* detect editing in ISM_MASA_MODE_DISC. optionally, add quantization-resolution -based thresholds */ + if ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth - hIvasEditableParameters.ism_metadata[obj].azimuth ) > OMASA_AZI_EDIT_THR || + fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->elevation - hIvasEditableParameters.ism_metadata[obj].elevation ) > OMASA_ELE_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->azimuth_ism_edited[obj] = new_azi; + hIvasDec->st_ivas->hMasaIsmData->elevation_ism_edited[obj] = new_ele; + + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 0u; + } + } + + /* compare pre-edit gain and the edited one to detect editing */ + if ( fabsf( hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain - hIvasEditableParameters.ism_metadata[obj].gain ) > OMASA_GAIN_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1u; + hIvasDec->st_ivas->hMasaIsmData->gain_ism_edited[obj] = hIvasEditableParameters.ism_metadata[obj].gain; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; + } + } + } + + if ( fabsf( hIvasEditableParameters.gain_bed - 1.0f ) > OMASA_GAIN_EDIT_THR ) + { + hIvasDec->st_ivas->hMasaIsmData->gain_masa_edited = hIvasEditableParameters.gain_bed; + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 1u; + } + else + { + hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; + } } +#endif return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 30ef5b6fb7..da48bea23e 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -752,10 +752,21 @@ static void ivas_dirac_dec_binaural_internal( ivas_sba_prototype_renderer( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe ); } +#ifdef OMASA_OBJECT_EDITING +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) ) || st_ivas->ivas_format == ISM_FORMAT ) +#else + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) ) +#endif + { + ivas_omasa_preProcessStereoTransportsForEditedObjects( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, subframe ); + } +#else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 && st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) { ivas_omasa_preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins, subframe ); } +#endif if ( hCombinedOrientationData ) { @@ -1232,11 +1243,19 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( uint16_t ismDirIndex; ismDirIndex = dirIndex - hSpatParamRendCom->numParametricDirections; assert( hMasaIsmData != NULL && "hMasaIsmData should not be NULL if we use it" ); +#ifdef OMASA_OBJECT_EDITING + if ( hMasaIsmData->ism_dir_is_edited[ismDirIndex] ) + { + aziDeg = hMasaIsmData->azimuth_ism_edited[ismDirIndex]; + eleDeg = hMasaIsmData->elevation_ism_edited[ismDirIndex]; + } +#else if ( hMasaIsmData->ism_is_edited[ismDirIndex] ) { aziDeg = hMasaIsmData->azimuth_ism_edited[ismDirIndex]; eleDeg = hMasaIsmData->elevation_ism_edited[ismDirIndex]; } +#endif else { aziDeg = hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx]; @@ -1670,13 +1689,39 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( { if ( ism_mode == ISM_MASA_MODE_DISC ) { +#ifdef OMASA_OBJECT_EDITING + if ( hMasaIsmData->ism_dir_is_edited[chB] ) + { + aziDeg = hMasaIsmData->azimuth_ism_edited[chB]; + eleDeg = hMasaIsmData->elevation_ism_edited[chB]; + } + else + { + aziDeg = hMasaIsmData->azimuth_ism[chB][dirac_read_idx]; + eleDeg = hMasaIsmData->elevation_ism[chB][dirac_read_idx]; + } +#else aziDeg = hMasaIsmData->azimuth_ism[chB][dirac_read_idx]; eleDeg = hMasaIsmData->elevation_ism[chB][dirac_read_idx]; +#endif } else { +#ifdef OMASA_OBJECT_EDITING + if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && hMasaIsmData->ism_dir_is_edited[hMasaIsmData->idx_separated_ism] ) + { + aziDeg = hMasaIsmData->azimuth_ism_edited[hMasaIsmData->idx_separated_ism]; + eleDeg = hMasaIsmData->elevation_ism_edited[hMasaIsmData->idx_separated_ism]; + } + else + { + aziDeg = hMasaIsmData->azimuth_separated_ism[dirac_read_idx]; + eleDeg = hMasaIsmData->elevation_separated_ism[dirac_read_idx]; + } +#else aziDeg = hMasaIsmData->azimuth_separated_ism[dirac_read_idx]; eleDeg = hMasaIsmData->elevation_separated_ism[dirac_read_idx]; +#endif instantChange = 1; } } @@ -2451,6 +2496,53 @@ static void getDirectPartGains( if ( renderStereoOutputInsteadOfBinaural ) /* In stereo (i.e. non-binaural) rendering mode */ { +#ifdef OMASA_OBJECT_EDITING + *lImagp = 0.0f; + *rImagp = 0.0f; + if ( aziDeg == gainCache->azi && eleDeg == gainCache->ele ) + { + *lRealp = gainCache->shVec[0]; /* Reused memory */ + *rRealp = gainCache->shVec[1]; /* Reused memory */ + } + else + { + /* Convert azi and ele to an azi value of the cone of confusion */ + aziRad = (float) aziDeg * PI_OVER_180; + eleRad = (float) eleDeg * PI_OVER_180; + y = ( sinf( aziRad ) * cosf( eleRad ) ); + mappedX = sqrtf( max( 0.0f, 1.0f - ( y * y ) ) ); + aziRadMapped = atan2f( y, mappedX ); + + /* Determine the real valued amplitude panning gains */ + if ( aziRadMapped >= LsAngleRad ) + { /* Left side */ + *lRealp = 1.0f; + *rRealp = 0.0f; + } + else if ( aziRadMapped <= -LsAngleRad ) + { /* Right side */ + *lRealp = 0.0f; + *rRealp = 1.0f; + } + else /* Tangent panning law */ + { + A = tanf( aziRadMapped ) / tanf( LsAngleRad ); + A2 = ( A - 1.0f ) / max( 0.001f, A + 1.0f ); + A3 = 1.0f / ( A2 * A2 + 1.0f ); + *lRealp = sqrtf( A3 ); + *rRealp = sqrtf( 1.0f - A3 ); + } + /* Scaling to have the same expected gain as for the HRTF rendering */ + *lRealp *= SQRT2; + *rRealp *= SQRT2; + + /* Store to gain cache */ + gainCache->azi = aziDeg; + gainCache->ele = eleDeg; + gainCache->shVec[0] = *lRealp; /* Reuse memory */ + gainCache->shVec[1] = *rRealp; /* Reuse memory */ + } +#else /* Convert azi and ele to an azi value of the cone of confusion */ aziRad = (float) aziDeg * PI_OVER_180; eleRad = (float) eleDeg * PI_OVER_180; @@ -2483,6 +2575,7 @@ static void getDirectPartGains( /* Scaling to have the same expected gain as for the HRTF rendering */ *lRealp *= SQRT2; *rRealp *= SQRT2; +#endif } else /* In regular binaural rendering mode */ { @@ -2636,6 +2729,685 @@ float configure_reqularization_factor( } +#ifdef OMASA_OBJECT_EDITING +/*-------------------------------------------------------------------* + * ivas_omasa_preProcessStereoTransportsForEditedObjects() + * + * + *-------------------------------------------------------------------*/ + +void ivas_omasa_preProcessStereoTransportsForEditedObjects( + Decoder_Struct *st_ivas, + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], + const int16_t nBins, + const int16_t subframe ) +{ + int16_t bin, ch, inCh, outCh, ismDirIndex, slot, band_idx, bin_lo, bin_hi, max_band, n_ism; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + MASA_ISM_DATA_HANDLE hMasaIsmData; +#ifdef OBJ_EDITING_PARAMISM_BIN + PARAM_ISM_DEC_HANDLE hParamIsmDec; +#endif + uint8_t enableCentering; + int16_t dirac_read_idx; + int16_t nSlots; + float panGainsOut[4][2]; + float panGainsIn[4][2]; + float panEnesOut[4][2]; + float panEnesIn[4][2]; + uint8_t ismGainEdited[4]; + uint8_t ismDirEdited[4]; + uint8_t masaGainEdited; +#ifdef OBJ_EDITING_PARAMISM_BIN + uint8_t masaIsmMode; +#endif + + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + hMasaIsmData = st_ivas->hMasaIsmData; +#ifdef OBJ_EDITING_PARAMISM_BIN + hParamIsmDec = st_ivas->hParamIsmDec; + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + masaIsmMode = 1u; + } + else + { + masaIsmMode = 0u; + } +#endif + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) + { + enableCentering = 0; + } + else + { + enableCentering = 1; + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ivas_format == ISM_FORMAT ) +#else + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) +#endif + { + n_ism = st_ivas->nchan_ism; + } + else + { + n_ism = hSpatParamRendCom->numIsmDirections; + } + + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + ismGainEdited[ismDirIndex] = hMasaIsmData->ism_gain_is_edited[ismDirIndex]; + ismDirEdited[ismDirIndex] = hMasaIsmData->ism_dir_is_edited[ismDirIndex]; + } + masaGainEdited = hMasaIsmData->masa_gain_is_edited; + + /* Bypass processing until first object is moved or gained */ + if ( hMasaIsmData->objectsEdited == 0 ) + { + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + if ( ismDirEdited[ismDirIndex] ) + { + hMasaIsmData->objectsEdited = 1; + } + + if ( ismGainEdited[ismDirIndex] ) + { + hMasaIsmData->objectsEdited = 1; + } + } + + if ( masaGainEdited ) + { + hMasaIsmData->objectsEdited = 1; + } + + if ( hMasaIsmData->objectsEdited == 0 ) + { + /* No objects have moved so far */ + return; + } + } + + /* OMASA gaining for discrete OMASA mode with stereo_param/bin_room_param renderer */ + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + /* ISM gaining */ + for ( ch = 0; ch < n_ism; ch++ ) + { + if ( st_ivas->hMasaIsmData->ism_gain_is_edited[ch] ) + { + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + float gain; + gain = st_ivas->hMasaIsmData->gain_ism_edited[ch]; + v_multc( inRe[ch + 2][slot], gain, inRe[ch + 2][slot], nBins ); + v_multc( inIm[ch + 2][slot], gain, inIm[ch + 2][slot], nBins ); + } + } + } + + /* MASA gaining */ + for ( ch = 0; ch < 2; ch++ ) + { + if ( masaGainEdited ) + { + for ( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) + { + float gain_masa; + gain_masa = st_ivas->hMasaIsmData->gain_masa_edited; + v_multc( inRe[ch][slot], gain_masa, inRe[ch][slot], nBins ); + v_multc( inIm[ch][slot], gain_masa, inIm[ch][slot], nBins ); + } + } + } + } +#ifdef OBJ_EDITING_PARAMISM_BIN + else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->hISMDTX.dtx_flag ) /* If dtx on, perform just the smoothing of the processing gains */ + { + float totalTargetEne; + float ismPreprocMtxNew[2][2]; + float ismPreprocMtxIncrement[2][2]; + float nSlotDiv; + float outSlotRe[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float outSlotIm[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float eqVal; + + nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; + nSlotDiv = 1.0f / ( (float) nSlots ); + + /* Use diagonal mixing matrix as the instant mixing matrix, to slowly fade away the editing during dtx */ + for ( ch = 0; ch < 2; ch++ ) + { + ismPreprocMtxNew[ch][ch] = 1.0f; + ismPreprocMtxNew[1 - ch][ch] = 0.0f; + } + + /* Determine the highest band */ + max_band = 0; + while ( max_band < MAX_PARAM_ISM_NBANDS && hParamIsmDec->hParamIsm->band_grouping[max_band] < nBins ) + { + max_band++; + } + + /* Init out array */ + for ( int k = 0; k < nSlots; k++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + } + } + + /* Perform the processing in frequency bands */ + for ( band_idx = 0; band_idx < max_band; band_idx++ ) + { + bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + bin_hi = min( hParamIsmDec->hParamIsm->band_grouping[band_idx + 1], nBins ); + + /* Determine transport energies */ + totalTargetEne = 0.0f; + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( ch = 0; ch < 2; ch++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + totalTargetEne += inRe[ch][slot][bin] * inRe[ch][slot][bin]; + totalTargetEne += inIm[ch][slot][bin] * inIm[ch][slot][bin]; + } + } + } + + /* Get increment value for temporal interpolation */ + for ( inCh = 0; inCh < 2; inCh++ ) + { + for ( outCh = 0; outCh < 2; outCh++ ) + { + ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] ) * nSlotDiv; + } + } + + /* Mix signals */ + hMasaIsmData->preprocEneTarget[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneRealized[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneTarget[band_idx] += totalTargetEne; + + for ( outCh = 0; outCh < 2; outCh++ ) + { + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( inCh = 0; inCh < 2; inCh++ ) + { + hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + outSlotRe[outCh][slot][bin] += inRe[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + outSlotIm[outCh][slot][bin] += inIm[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + } + } + + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + hMasaIsmData->preprocEneRealized[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); + } + } + } + + eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized[band_idx] ) ) ); + + for ( ch = 0; ch < 2; ch++ ) + { + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + inRe[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; + inIm[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; + } + } + } + } + } +#endif + else /* Other processing modes */ + { + float subframeEne; + float subframeEneCh[2]; + float normEnes[2]; + float ratioAccOrig; + float ratioAccNew; + float ratio; + float ismEneThis; + float ismTargetEneThis; + float ismTargetEneThisCh[2]; + float totalTargetEneCh[2]; + float totalTargetEne; + float masaTargetEneThisCh[2]; + float ismPreprocMtxNew[2][2]; + float ismPreprocMtxIncrement[2][2]; + float eneMove[2]; + float enePreserve[2]; + float ismRatioAcc; + float remainderNormEne; + float centeringFactor; + float eneMoveThis; + float enePreserveThis; + float normVal; + float eqVal; + float outSlotRe[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float outSlotIm[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + float newRatios[6]; + float gainIsmThis; + float gainMasaPow2; + float nSlotDiv; + float tempDivisor; + float masaEneThisCh[2]; + float ratioAccNewDivisor; + + + gainMasaPow2 = 1.0f; + if ( masaGainEdited ) + { + gainMasaPow2 = hMasaIsmData->gain_masa_edited; + gainMasaPow2 *= gainMasaPow2; + } + + nSlots = hSpatParamRendCom->subframe_nbslots[subframe]; + dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; + nSlotDiv = 1.0f / ( (float) nSlots ); + + /* Determine panning gains and energies for each object */ + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + /* Get input and output panning gains */ + ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx], + hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx], + panGainsIn[ismDirIndex] ); + + if ( ismDirEdited[ismDirIndex] ) + { + ivas_get_stereo_panning_gains( hMasaIsmData->azimuth_ism_edited[ismDirIndex], + hMasaIsmData->elevation_ism_edited[ismDirIndex], + panGainsOut[ismDirIndex] ); + } + else + { + /* When not edited, input and output pan gains are the same */ + for ( ch = 0; ch < 2; ch++ ) + { + panGainsOut[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch]; + } + } + /* Determine pan enes */ + for ( ch = 0; ch < 2; ch++ ) + { + panEnesOut[ismDirIndex][ch] = panGainsOut[ismDirIndex][ch] * panGainsOut[ismDirIndex][ch]; + panEnesIn[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch] * panGainsIn[ismDirIndex][ch]; + } + } + + /* Determine the highest band */ + max_band = 0; +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( masaIsmMode ) + { +#endif + while ( max_band < MASA_FREQUENCY_BANDS && MASA_band_grouping_24[max_band] < nBins ) + { + max_band++; + } +#ifdef OBJ_EDITING_PARAMISM_BIN + } + else + { + while ( max_band < MAX_PARAM_ISM_NBANDS && hParamIsmDec->hParamIsm->band_grouping[max_band] < nBins ) + { + max_band++; + } + } +#endif + + /* Init out array */ + for ( int k = 0; k < nSlots; k++ ) + { + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + set_zero( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + } + } + + /* Perform the processing in frequency bands */ + for ( band_idx = 0; band_idx < max_band; band_idx++ ) + { + ratioAccOrig = 0.0f; + ratioAccNew = 0.0f; + ismRatioAcc = 0.0f; + + set_zero( subframeEneCh, 2 ); + set_zero( ismPreprocMtxNew[0], 2 ); + set_zero( ismPreprocMtxNew[1], 2 ); + set_zero( eneMove, 2 ); + set_zero( enePreserve, 2 ); +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( masaIsmMode ) + { +#endif + bin_lo = MASA_band_grouping_24[band_idx]; + bin_hi = min( MASA_band_grouping_24[band_idx + 1], nBins ); +#ifdef OBJ_EDITING_PARAMISM_BIN + } + else + { + bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + bin_hi = min( hParamIsmDec->hParamIsm->band_grouping[band_idx + 1], nBins ); + } +#endif + + /* Determine transport normalized energies and subframe energy */ + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( ch = 0; ch < 2; ch++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + subframeEneCh[ch] += inRe[ch][slot][bin] * inRe[ch][slot][bin]; + subframeEneCh[ch] += inIm[ch][slot][bin] * inIm[ch][slot][bin]; + } + } + } + subframeEne = subframeEneCh[0] + subframeEneCh[1]; + totalTargetEneCh[0] = subframeEneCh[0]; + totalTargetEneCh[1] = subframeEneCh[1]; + masaEneThisCh[0] = subframeEneCh[0]; + masaEneThisCh[1] = subframeEneCh[1]; + + /* Gain editing */ + /* For each object, estimate new target energy per channel based on the applied gain */ + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin_lo]; + ratioAccOrig += ratio; + + /* Calculate MASA energy as a residual of original channel energies subtracted with ISM energies */ + for ( ch = 0; ch < 2; ch++ ) + { + masaEneThisCh[ch] -= panEnesIn[ismDirIndex][ch] * ratio * subframeEne; + } + + /* Calculate target energy, gained ratio for accumulation, and transports gains, if ism gain is edited */ + if ( ismGainEdited[ismDirIndex] ) + { + gainIsmThis = hMasaIsmData->gain_ism_edited[ismDirIndex]; + /* ISM original energy */ + ismEneThis = ratio * subframeEne; + + /* ISM target energy */ + ismTargetEneThis = ( gainIsmThis * gainIsmThis ) * ismEneThis; + + ratio *= gainIsmThis * gainIsmThis; + + /* Determine panning energies and channel target energies */ + for ( ch = 0; ch < 2; ch++ ) + { + ismTargetEneThisCh[ch] = panEnesIn[ismDirIndex][ch] * ismTargetEneThis; /* Ism target energy per channel */ + totalTargetEneCh[ch] -= panEnesIn[ismDirIndex][ch] * ismEneThis; /* Reduce original ism energy */ + totalTargetEneCh[ch] += ismTargetEneThisCh[ch]; /* Add ism target energy per channel */ + } + + /* If separated ism edited, apply gain directly to the separated ism */ + if ( ismDirIndex == hMasaIsmData->idx_separated_ism ) + { + /* Separated object gaining is done elsewhere with DIRAC renderer */ + if ( st_ivas->renderer_type != RENDERER_DIRAC ) + { + /* Gain transport channel of separated ism */ + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + inRe[2][slot][bin] = gainIsmThis * inRe[2][slot][bin]; + inIm[2][slot][bin] = gainIsmThis * inIm[2][slot][bin]; + } + } + } + } + } + ratioAccNew += ratio; + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( masaIsmMode ) + { +#endif + /* MASA original ratios */ + ratio = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin_lo] + hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin_lo]; + ratioAccOrig += ratio; + + /* Estimate MASA original energies and determine adjusted target energies and gained ratio for accumulation, if a gain is applied to MASA */ + if ( masaGainEdited ) + { + /* Gained MASA ratio */ + ratio *= gainMasaPow2; + + /* Calculate MASA target energies and add to total target energy estimation */ + for ( ch = 0; ch < 2; ch++ ) + { + masaEneThisCh[ch] = fmaxf( masaEneThisCh[ch], 0.0f ); /* MASA original energy per channel */ + masaTargetEneThisCh[ch] = gainMasaPow2 * masaEneThisCh[ch]; /* MASA target energy per channel */ + totalTargetEneCh[ch] -= masaEneThisCh[ch]; /* Reduce original energy per channel */ + totalTargetEneCh[ch] += masaTargetEneThisCh[ch]; /* Add target energy per channel */ + } + } + + ratioAccNew += ratio; +#ifdef OBJ_EDITING_PARAMISM_BIN + } +#endif + + /* Limit target energies to non-negative values */ + for ( ch = 0; ch < 2; ch++ ) + { + totalTargetEneCh[ch] = max( totalTargetEneCh[ch], 0.0f ); + } + + /* Diffuse ratio accumulation based on gaining */ + if ( masaGainEdited ) + { + ratioAccNew += gainMasaPow2 * ( 1 - ratioAccOrig ); + } + else + { + ratioAccNew += ( 1.0f - ratioAccOrig ); + } + + ratioAccNewDivisor = 1.0f / fmaxf( 1e-12f, ratioAccNew ); /* New target total energy ratio divider */ + + /* Determine and process object energy ratios based on gaining */ + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + newRatios[ismDirIndex + 2] = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin_lo]; /* Determine original object energy ratio */ + if ( ismGainEdited[ismDirIndex] ) + { + gainIsmThis = hMasaIsmData->gain_ism_edited[ismDirIndex]; + newRatios[ismDirIndex + 2] *= ( gainIsmThis * gainIsmThis ); /* Gain original object energy ratio, if edited */ + } + newRatios[ismDirIndex + 2] *= ratioAccNewDivisor; /* Divide with new target total ratio */ + } + + /* Determine and process MASA energy ratios based on gaining */ + newRatios[0] = hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin_lo]; + newRatios[1] = hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin_lo]; + if ( masaGainEdited ) + { + newRatios[0] *= gainMasaPow2; + newRatios[1] *= gainMasaPow2; + } + newRatios[0] *= ratioAccNewDivisor; + newRatios[1] *= ratioAccNewDivisor; + + /* Set adjusted energy ratios */ + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin] = newRatios[ismDirIndex + 2]; + } + hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin] = newRatios[0]; + hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin] = newRatios[1]; + } + + /* Direction editing */ + /* Determine new energetic values after gaining */ + totalTargetEne = totalTargetEneCh[0] + totalTargetEneCh[1]; + tempDivisor = 1.0f / fmaxf( 1e-12f, totalTargetEne ); + normEnes[0] = totalTargetEneCh[0] * tempDivisor; + normEnes[1] = totalTargetEneCh[1] * tempDivisor; + + /* For each ismDir, determine moved and preserve energy ratio per channel */ + for ( ismDirIndex = 0; ismDirIndex < n_ism; ismDirIndex++ ) + { + ratio = hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin_lo]; + + ismRatioAcc += ratio; + + if ( enableCentering ) + { + centeringFactor = fmaxf( 0.0f, 2.0f * fabsf( panEnesIn[ismDirIndex][0] - panEnesOut[ismDirIndex][0] ) - 1.0f ); + for ( ch = 0; ch < 2; ch++ ) + { + panEnesOut[ismDirIndex][ch] *= ( 1.0f - centeringFactor ); + panEnesOut[ismDirIndex][ch] += 0.5f * centeringFactor; + } + } + + for ( ch = 0; ch < 2; ch++ ) + { + eneMoveThis = fmaxf( 0.0f, panEnesIn[ismDirIndex][ch] - panEnesOut[ismDirIndex][ch] ); + enePreserveThis = panEnesIn[ismDirIndex][ch] - eneMoveThis; + + eneMove[ch] += ratio * eneMoveThis; + enePreserve[ch] += ratio * enePreserveThis; + + /* Subtract object parts from normEnes */ + normEnes[ch] -= panEnesIn[ismDirIndex][ch] * ratio; + } + } + + /* Any remaining (non-object) energy is set to be preserved at both channels */ + remainderNormEne = fmaxf( 0.0f, ( 1.0f - ismRatioAcc ) - normEnes[0] - normEnes[1] ); + + /* Normalize */ + for ( ch = 0; ch < 2; ch++ ) + { + enePreserve[ch] += fmaxf( 0.0f, normEnes[ch] + remainderNormEne / 2.0f ); + normVal = 1.0f / fmaxf( EPSILON, eneMove[ch] + enePreserve[ch] ); + normVal *= fminf( 10.0f, totalTargetEneCh[ch] / fmaxf( EPSILON, subframeEneCh[ch] ) ); + eneMove[ch] *= normVal; + enePreserve[ch] *= normVal; + } + + /* Temporally average target energy */ + hMasaIsmData->eneOrigIIR[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->eneOrigIIR[band_idx] += totalTargetEne; + + /* Temporally average energy moving and preserving, and generate the transport signal preprocessing matrix for + * gaining objects and moving objects between left and right */ + for ( ch = 0; ch < 2; ch++ ) + { + hMasaIsmData->eneMoveIIR[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->eneMoveIIR[ch][band_idx] += eneMove[ch] * totalTargetEne; + hMasaIsmData->enePreserveIIR[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->enePreserveIIR[ch][band_idx] += enePreserve[ch] * totalTargetEne; + normVal = 1.0f / fmaxf( EPSILON, hMasaIsmData->eneOrigIIR[band_idx] ); + ismPreprocMtxNew[ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->enePreserveIIR[ch][band_idx] * normVal ) ); + ismPreprocMtxNew[1 - ch][ch] = fminf( 4.0f, sqrtf( hMasaIsmData->eneMoveIIR[ch][band_idx] * normVal ) ); + } + + /* Get increment value for temporal interpolation */ + for ( inCh = 0; inCh < 2; inCh++ ) + { + for ( outCh = 0; outCh < 2; outCh++ ) + { + ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] ) * nSlotDiv; + } + } + + /* Mix signals */ + hMasaIsmData->preprocEneTarget[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneRealized[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; + hMasaIsmData->preprocEneTarget[band_idx] += totalTargetEne; + + for ( outCh = 0; outCh < 2; outCh++ ) + { + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( inCh = 0; inCh < 2; inCh++ ) + { + hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + outSlotRe[outCh][slot][bin] += inRe[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + outSlotIm[outCh][slot][bin] += inIm[inCh][slot][bin] * hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx]; + } + } + + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + hMasaIsmData->preprocEneRealized[band_idx] += ( outSlotRe[outCh][slot][bin] * outSlotRe[outCh][slot][bin] ) + ( outSlotIm[outCh][slot][bin] * outSlotIm[outCh][slot][bin] ); + } + } + } + + eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized[band_idx] ) ) ); + + for ( ch = 0; ch < 2; ch++ ) + { + for ( slot = 0; slot < nSlots; slot++ ) + { + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + inRe[ch][slot][bin] = outSlotRe[ch][slot][bin] * eqVal; + inIm[ch][slot][bin] = outSlotIm[ch][slot][bin] * eqVal; + } + } + } + } + +#ifdef OBJ_EDITING_PARAMISM_BIN + if ( !masaIsmMode ) + { + int16_t obj_idx1, obj_idx2; + + for ( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) + { + bin_lo = hParamIsmDec->hParamIsm->band_grouping[band_idx]; + bin_hi = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + + obj_idx1 = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]; + obj_idx2 = hParamIsmDec->hParamIsm->obj_indices[band_idx][0][1]; + + for ( bin = bin_lo; bin < bin_hi; bin++ ) + { + hSpatParamRendCom->energy_ratio1[dirac_read_idx][bin] = hMasaIsmData->energy_ratio_ism[obj_idx1][dirac_read_idx][bin]; + hSpatParamRendCom->energy_ratio2[dirac_read_idx][bin] = hMasaIsmData->energy_ratio_ism[obj_idx2][dirac_read_idx][bin]; + } + } + } +#endif + } + + return; +} +#else /*-------------------------------------------------------------------* * ivas_omasa_preProcessStereoTransportsForMovedObjects() * @@ -2860,6 +3632,8 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects( return; } +#endif + static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 54ea302165..0bfd43ddd8 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1700,10 +1700,17 @@ void ivas_dirac_dec_compute_directional_responses( for ( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { +#ifdef OMASA_OBJECT_EDITING + if ( hMasaIsm->ism_dir_is_edited[dir] ) + { + ivas_dirac_dec_get_response( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp, hDirACRend->hOutSetup.ambisonics_order ); + } +#else if ( hMasaIsm->ism_is_edited[dir] ) { ivas_dirac_dec_get_response( hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], direct_response_temp, hDirACRend->hOutSetup.ambisonics_order ); } +#endif else { ivas_dirac_dec_get_response( hMasaIsm->azimuth_ism[dir][md_idx], hMasaIsm->elevation_ism[dir][md_idx], direct_response_temp, hDirACRend->hOutSetup.ambisonics_order ); @@ -1810,10 +1817,17 @@ void ivas_dirac_dec_compute_directional_responses( for ( dir = 0; dir < hSpatParamRendCom->numIsmDirections; dir++ ) { +#ifdef OMASA_OBJECT_EDITING + if ( hMasaIsm->ism_dir_is_edited[dir] ) + { + vbap_determine_gains( hVBAPdata, direct_response_temp, hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], 1 ); + } +#else if ( hMasaIsm->ism_is_edited[dir] ) { vbap_determine_gains( hVBAPdata, direct_response_temp, hMasaIsm->azimuth_ism_edited[dir], hMasaIsm->elevation_ism_edited[dir], 1 ); } +#endif else { vbap_determine_gains( hVBAPdata, direct_response_temp, hMasaIsm->azimuth_ism[dir][md_idx], hMasaIsm->elevation_ism[dir][md_idx], 1 ); -- GitLab From 9e668b0ebe8183e0e4f1775be203e2212ee3501f Mon Sep 17 00:00:00 2001 From: lintervo Date: Tue, 27 Aug 2024 15:05:20 +0300 Subject: [PATCH 118/130] fix OMASA DISC BIN path --- lib_dec/lib_dec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9bd27502fd..ea5887e5be 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1177,7 +1177,7 @@ ivas_error IVAS_DEC_SetEditableParameters( if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || - ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) + ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } @@ -1354,6 +1354,18 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 0u; } } + + /* Copy edited values to hIsmMetaData struct */ + if ( hIvasDec->st_ivas->hIsmMetaData[obj] != NULL ) + { + hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; + hIvasDec->st_ivas->hIsmMetaData[obj]->elevation = hIvasEditableParameters.ism_metadata[obj].elevation; + hIvasDec->st_ivas->hIsmMetaData[obj]->yaw = hIvasEditableParameters.ism_metadata[obj].yaw; + hIvasDec->st_ivas->hIsmMetaData[obj]->pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + hIvasDec->st_ivas->hIsmMetaData[obj]->radius = hIvasEditableParameters.ism_metadata[obj].radius; + hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = hIvasEditableParameters.ism_metadata[obj].gain; + hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; + } } if ( fabsf( hIvasEditableParameters.gain_bed - 1.0f ) > OMASA_GAIN_EDIT_THR ) -- GitLab From ea81d144829d66537b70e0bcfaa7946d9477033a Mon Sep 17 00:00:00 2001 From: lintervo Date: Tue, 27 Aug 2024 15:10:17 +0300 Subject: [PATCH 119/130] clang formating --- lib_dec/lib_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index ea5887e5be..81e4f7e9ac 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1177,7 +1177,8 @@ ivas_error IVAS_DEC_SetEditableParameters( if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || - ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) || + hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } -- GitLab From e401e0bdca6511d14e188d09562a7dc095535c22 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 27 Aug 2024 16:44:35 +0200 Subject: [PATCH 120/130] fix merge conflicts --- lib_dec/ivas_mc_param_dec.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index a0ac6922fd..85bb285b87 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1489,12 +1489,11 @@ void ivas_param_mc_dec_prepare_renderer( PARAM_MC_DEC_HANDLE hParamMC; int16_t i; - int16_t i, ch; #ifdef FIX_835_PARAMMC_BUFFER_VALUES int16_t is_next_band, skip_next_band; #endif - int16_t slot_idx, param_band_idx; + int16_t param_band_idx; int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; /*CLDFB*/ @@ -1578,21 +1577,12 @@ void ivas_param_mc_dec_prepare_renderer( set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); #else - for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) - { - set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - } -#endif - - /* slot loop for gathering the input data */ - for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) - { - if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); + set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); } - } +#endif /* map from complex input covariance to real values */ #ifdef FIX_835_PARAMMC_BUFFER_VALUES -- GitLab From 5ac0ce84715e4d99ea351436ba395f022ce02d34 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 27 Aug 2024 17:26:18 +0200 Subject: [PATCH 121/130] fix MC non-BE-ness --- lib_dec/ivas_mc_param_dec.c | 477 +++++++++++++++++++++++------------- 1 file changed, 302 insertions(+), 175 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 85bb285b87..f794f4fac4 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1332,173 +1332,24 @@ void ivas_param_mc_dec_digest_tc( { PARAM_MC_DEC_HANDLE hParamMC; int16_t ch; - int16_t slot_idx; - int16_t nchan_transport; - -#ifndef OBJ_EDITING_API - int16_t nchan_out_transport, nchan_out_cldfb, i, param_band_idx; - int16_t nchan_out_cov; - /*CLDFB*/ - float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float real_part, imag_part; - /* format converter */ - int16_t channel_active[MAX_OUTPUT_CHANNELS]; - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; -#endif - - hParamMC = st_ivas->hParamMC; - assert( hParamMC ); - - push_wmops( "param_mc_dec_digest_tc" ); - -#ifndef OBJ_EDITING_API - set_s( channel_active, 0, MAX_CICP_CHANNELS ); -#endif - nchan_transport = st_ivas->nchan_transport; -#ifndef OBJ_EDITING_API - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - nchan_out_cldfb = BINAURAL_CHANNELS; - set_s( channel_active, 1, nchan_out_cldfb ); - nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - hSynthesisOutputSetup = &st_ivas->hTransSetup; - } - else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) - { - nchan_out_cov = nchan_out_transport; - nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - hSynthesisOutputSetup = &st_ivas->hTransSetup; - } - else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - nchan_out_cldfb = nchan_out_cov; - set_s( channel_active, 1, nchan_out_cov ); - hSynthesisOutputSetup = &st_ivas->hOutSetup; - } - else - { - nchan_out_cov = nchan_out_transport; - nchan_out_cldfb = nchan_out_transport; - set_s( channel_active, 1, nchan_out_cov ); - hSynthesisOutputSetup = &st_ivas->hTransSetup; - } - - /* adapt transient position */ - if ( hParamMC->hMetadataPMC->bAttackPresent ) - { - hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); - } - /* adapt subframes */ - hParamMC->num_slots = nCldfbSlots; - hParamMC->slots_rendered = 0; - hParamMC->subframes_rendered = 0; - ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); - st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; - mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); - - ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); - - for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) - { - set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - } -#endif - - /* slot loop for gathering the input data */ - for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) - { - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; - float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - - /* CLDFB Analysis*/ - for ( ch = 0; ch < nchan_transport; ch++ ) - { - cldfbAnalysis_ts( &( transport_channels_f[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); - - mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - } - } -#ifndef OBJ_EDITING_API - if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) - { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); - } -#endif - } #ifndef OBJ_EDITING_API - /* map from complex input covariance to real values */ - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) - { - /* Cx for transport channels */ - for ( i = 0; i < nchan_transport * nchan_transport; i++ ) - { - real_part = cx[param_band_idx][i]; - imag_part = cx_imag[param_band_idx][i]; - - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - if ( param_band_idx < hParamMC->max_param_band_abs_cov ) - { - cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); - } - else - { - cx[param_band_idx][i] = real_part; - } - } - } - - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ - if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) - { - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) - { - v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); - mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); - } - } - - - /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); -#endif - pop_wmops(); - - return; -} - -#ifdef OBJ_EDITING_API -/*------------------------------------------------------------------------- - * ivas_param_mc_dec_prepare_renderer() - * - * - *------------------------------------------------------------------------*/ - -void ivas_param_mc_dec_prepare_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ -) -{ - PARAM_MC_DEC_HANDLE hParamMC; int16_t i; - +#endif #ifdef FIX_835_PARAMMC_BUFFER_VALUES int16_t is_next_band, skip_next_band; #endif - - int16_t param_band_idx; - int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; + int16_t slot_idx, param_band_idx; + int16_t nchan_transport; +#ifndef OBJ_EDITING_API + int16_t nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; +#endif + /*CLDFB*/ #ifdef FIX_835_PARAMMC_BUFFER_VALUES +#ifndef OBJ_EDITING_API float *pCx, *pCx_imag; +#endif float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; @@ -1507,18 +1358,27 @@ void ivas_param_mc_dec_prepare_renderer( float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; #endif + +#ifndef OBJ_EDITING_API float real_part, imag_part; /* format converter */ - int16_t channel_active[MAX_OUTPUT_CHANNELS]; IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; + int16_t channel_active[MAX_OUTPUT_CHANNELS]; +#endif + hParamMC = st_ivas->hParamMC; assert( hParamMC ); push_wmops( "param_mc_dec_digest_tc" ); +#ifndef OBJ_EDITING_API set_s( channel_active, 0, MAX_CICP_CHANNELS ); +#endif nchan_transport = st_ivas->nchan_transport; + + +#ifndef OBJ_EDITING_API nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -1563,7 +1423,7 @@ void ivas_param_mc_dec_prepare_renderer( mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); - +#endif #ifdef FIX_835_PARAMMC_BUFFER_VALUES /* loop over two bands at a time */ @@ -1577,12 +1437,65 @@ void ivas_param_mc_dec_prepare_renderer( set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); #else - for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) + for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) + { + set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + } +#endif + + /* slot loop for gathering the input data */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - } + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + if ( param_band_idx == 0 ) /* only run cldfbAna once */ + { #endif + float RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + + /* CLDFB Analysis*/ + for ( ch = 0; ch < nchan_transport; ch++ ) + { + cldfbAnalysis_ts( &( transport_channels_f[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + + mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + } +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + } +#endif + } + if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } +#endif + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], + &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + is_next_band ? cx_next_band : cx, + is_next_band ? cx_imag_next_band : cx_imag, + param_band_idx + is_next_band, +#else + cx, + cx_imag, +#endif + hParamMC, + nchan_transport ); +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + } +#endif + } + } +#ifndef OBJ_EDITING_API /* map from complex input covariance to real values */ #ifdef FIX_835_PARAMMC_BUFFER_VALUES @@ -1607,8 +1520,8 @@ void ivas_param_mc_dec_prepare_renderer( real_part = pCx[i]; imag_part = pCx_imag[i]; #else - real_part = cx[param_band_idx][i]; - imag_part = cx_imag[param_band_idx][i]; + real_part = cx[param_band_idx][i]; + imag_part = cx_imag[param_band_idx][i]; #endif /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ @@ -1617,7 +1530,7 @@ void ivas_param_mc_dec_prepare_renderer( #ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); #else - cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); + cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); #endif } else @@ -1625,7 +1538,7 @@ void ivas_param_mc_dec_prepare_renderer( #ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx[i] = real_part; #else - cx[param_band_idx][i] = real_part; + cx[param_band_idx][i] = real_part; #endif } } @@ -1638,11 +1551,11 @@ void ivas_param_mc_dec_prepare_renderer( v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); #else - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) - { - v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); - mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); - } + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); + mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); + } #endif } @@ -1662,7 +1575,7 @@ void ivas_param_mc_dec_prepare_renderer( is_next_band ? cx_next_band : cx, param_band_idx + is_next_band, #else - cx, + cx, #endif hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, @@ -1672,6 +1585,11 @@ void ivas_param_mc_dec_prepare_renderer( nchan_out_cov ); #ifdef FIX_835_PARAMMC_BUFFER_VALUES } +#endif + +#endif + +#ifdef FIX_835_PARAMMC_BUFFER_VALUES } #endif @@ -1679,7 +1597,7 @@ void ivas_param_mc_dec_prepare_renderer( return; } -#endif + /*------------------------------------------------------------------------- * ivas_param_mc_dec_render() @@ -3121,3 +3039,212 @@ static void ivas_param_mc_bs_decode_parameter_values( return; } + + + +#ifdef OBJ_EDITING_API +/*------------------------------------------------------------------------- + * ivas_param_mc_dec_prepare_renderer() + * + * + *------------------------------------------------------------------------*/ + +void ivas_param_mc_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +) +{ + PARAM_MC_DEC_HANDLE hParamMC; + int16_t i; + +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + int16_t is_next_band, skip_next_band; +#endif + + int16_t param_band_idx; + int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; + int16_t nchan_out_cov; + /*CLDFB*/ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + float *pCx, *pCx_imag; + float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#else + float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#endif + float real_part, imag_part; + /* format converter */ + int16_t channel_active[MAX_OUTPUT_CHANNELS]; + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; + + hParamMC = st_ivas->hParamMC; + assert( hParamMC ); + + push_wmops( "param_mc_dec_digest_tc" ); + + set_s( channel_active, 0, MAX_CICP_CHANNELS ); + nchan_transport = st_ivas->nchan_transport; + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + nchan_out_cldfb = BINAURAL_CHANNELS; + set_s( channel_active, 1, nchan_out_cldfb ); + nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) + { + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cldfb = nchan_out_cov; + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hOutSetup; + } + else + { + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = nchan_out_transport; + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + + /* adapt transient position */ + if ( hParamMC->hMetadataPMC->bAttackPresent ) + { + hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); + } + /* adapt subframes */ + hParamMC->num_slots = nCldfbSlots; + hParamMC->slots_rendered = 0; + hParamMC->subframes_rendered = 0; + ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); + st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; + mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); + + ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); + + +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + /* loop over two bands at a time */ + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + /* don't process next band if it exceeds the limit */ + skip_next_band = ( ( param_band_idx + 1 ) == hParamMC->num_param_bands_synth ) ? 1 : 0; + + set_zero( cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); +#else + for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) + { + set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + } +#endif + + /* map from complex input covariance to real values */ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } +#else + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) + { +#endif + /* Cx for transport channels */ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + pCx = is_next_band ? &cx_next_band[0] : &cx[0]; + pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; +#endif + for ( i = 0; i < nchan_transport * nchan_transport; i++ ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + real_part = pCx[i]; + imag_part = pCx_imag[i]; +#else + real_part = cx[param_band_idx][i]; + imag_part = cx_imag[param_band_idx][i]; +#endif + + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + if ( param_band_idx < hParamMC->max_param_band_abs_cov ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); +#else + cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); +#endif + } + else + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + pCx[i] = real_part; +#else + cx[param_band_idx][i] = real_part; +#endif + } + } + } + + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); + mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); +#else + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); + mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); + } +#endif + } + + +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } +#endif + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices( hParamMC, + hSynthesisOutputSetup, +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + is_next_band ? cx_next_band : cx, + param_band_idx + is_next_band, +#else + cx, +#endif + hParamMC->h_output_synthesis_cov_state.mixing_matrix, + hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, + nchan_out_transport, + hParamMC->synthesis_conf, + nchan_transport, + nchan_out_cov ); +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + } + } +#endif + + pop_wmops(); + + return; +} +#endif -- GitLab From 2d45c925630753c1e927dc009e9351e9487176da Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 28 Aug 2024 08:47:47 +0200 Subject: [PATCH 122/130] skip processing in ivas_param_mc_dec_digest_tc --- lib_dec/ivas_mc_param_dec.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index f794f4fac4..26c37cdfc5 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1331,25 +1331,16 @@ void ivas_param_mc_dec_digest_tc( ) { PARAM_MC_DEC_HANDLE hParamMC; - int16_t ch; -#ifndef OBJ_EDITING_API - int16_t i; -#endif + int16_t i, ch; #ifdef FIX_835_PARAMMC_BUFFER_VALUES int16_t is_next_band, skip_next_band; #endif int16_t slot_idx, param_band_idx; - int16_t nchan_transport; -#ifndef OBJ_EDITING_API - int16_t nchan_out_transport, nchan_out_cldfb; + int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; -#endif - /*CLDFB*/ #ifdef FIX_835_PARAMMC_BUFFER_VALUES -#ifndef OBJ_EDITING_API float *pCx, *pCx_imag; -#endif float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; @@ -1358,27 +1349,18 @@ void ivas_param_mc_dec_digest_tc( float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; #endif - -#ifndef OBJ_EDITING_API float real_part, imag_part; /* format converter */ - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; int16_t channel_active[MAX_OUTPUT_CHANNELS]; -#endif - + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; hParamMC = st_ivas->hParamMC; assert( hParamMC ); push_wmops( "param_mc_dec_digest_tc" ); -#ifndef OBJ_EDITING_API set_s( channel_active, 0, MAX_CICP_CHANNELS ); -#endif nchan_transport = st_ivas->nchan_transport; - - -#ifndef OBJ_EDITING_API nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -1423,7 +1405,7 @@ void ivas_param_mc_dec_digest_tc( mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); -#endif + #ifdef FIX_835_PARAMMC_BUFFER_VALUES /* loop over two bands at a time */ @@ -1495,7 +1477,6 @@ void ivas_param_mc_dec_digest_tc( #endif } } -#ifndef OBJ_EDITING_API /* map from complex input covariance to real values */ #ifdef FIX_835_PARAMMC_BUFFER_VALUES @@ -1585,11 +1566,6 @@ void ivas_param_mc_dec_digest_tc( nchan_out_cov ); #ifdef FIX_835_PARAMMC_BUFFER_VALUES } -#endif - -#endif - -#ifdef FIX_835_PARAMMC_BUFFER_VALUES } #endif -- GitLab From f318b817d5e42808b3c9a762fa4ae27278339a33 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 28 Aug 2024 09:42:24 +0200 Subject: [PATCH 123/130] temporarily disable FIX_835_PARAMMC_BUFFER_VALUES --- lib_com/options.h | 2 +- lib_dec/ivas_mc_param_dec.c | 552 ++++++++++++------------------------ 2 files changed, 175 insertions(+), 379 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3d69407b02..c63455cbd2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -185,7 +185,7 @@ #endif #define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define FIX_1166_TDREND_DIV0 /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */ -#define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */ +//#define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 26c37cdfc5..9ddcf50f90 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -86,11 +86,7 @@ static int16_t ivas_param_mc_uniform_decoder( float *seq, const int16_t sz_seq, static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hDirAC, float *ild_q, float *icc_q, const int16_t param_band_index, const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nY, const int16_t nX, float *Cx_state, float *Cproto, float *Cy_state ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES -static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t param_band_idx, float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY ); -#else static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY ); -#endif static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float *mixing_matrix[], float *mixing_matrix_res[], const uint16_t nX, const uint16_t nY ); @@ -1331,36 +1327,32 @@ void ivas_param_mc_dec_digest_tc( ) { PARAM_MC_DEC_HANDLE hParamMC; - int16_t i, ch; -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - int16_t is_next_band, skip_next_band; -#endif - int16_t slot_idx, param_band_idx; - int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; + int16_t ch; + int16_t slot_idx; + int16_t nchan_transport; + +#ifndef OBJ_EDITING_API + int16_t nchan_out_transport, nchan_out_cldfb, i, param_band_idx; int16_t nchan_out_cov; /*CLDFB*/ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - float *pCx, *pCx_imag; - float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#else float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#endif float real_part, imag_part; /* format converter */ int16_t channel_active[MAX_OUTPUT_CHANNELS]; IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; +#endif hParamMC = st_ivas->hParamMC; assert( hParamMC ); push_wmops( "param_mc_dec_digest_tc" ); +#ifndef OBJ_EDITING_API set_s( channel_active, 0, MAX_CICP_CHANNELS ); +#endif nchan_transport = st_ivas->nchan_transport; +#ifndef OBJ_EDITING_API nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -1406,19 +1398,6 @@ void ivas_param_mc_dec_digest_tc( ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); - -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - /* loop over two bands at a time */ - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) - { - /* don't process next band if it exceeds the limit */ - skip_next_band = ( ( param_band_idx + 1 ) == hParamMC->num_param_bands_synth ) ? 1 : 0; - - set_zero( cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); -#else for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) { set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); @@ -1426,154 +1405,203 @@ void ivas_param_mc_dec_digest_tc( } #endif - /* slot loop for gathering the input data */ - for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + /* slot loop for gathering the input data */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + if ( st_ivas->hDecoderConfig->Opt_tsm ) { - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - if ( param_band_idx == 0 ) /* only run cldfbAna once */ - { -#endif - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; - float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - - /* CLDFB Analysis*/ - for ( ch = 0; ch < nchan_transport; ch++ ) - { - cldfbAnalysis_ts( &( transport_channels_f[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + float RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - } -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - } -#endif - } - if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + /* CLDFB Analysis*/ + for ( ch = 0; ch < nchan_transport; ch++ ) { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - if ( is_next_band && skip_next_band ) - { - continue; - } -#endif - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], - &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - is_next_band ? cx_next_band : cx, - is_next_band ? cx_imag_next_band : cx_imag, - param_band_idx + is_next_band, -#else - cx, - cx_imag, -#endif - hParamMC, - nchan_transport ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - } -#endif + cldfbAnalysis_ts( &( transport_channels_f[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + + mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); } } - - /* map from complex input covariance to real values */ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) +#ifndef OBJ_EDITING_API + if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) { - if ( is_next_band && skip_next_band ) - { - continue; - } -#else + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); + } +#endif + } +#ifndef OBJ_EDITING_API + /* map from complex input covariance to real values */ for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) { -#endif - /* Cx for transport channels */ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - pCx = is_next_band ? &cx_next_band[0] : &cx[0]; - pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; -#endif - for ( i = 0; i < nchan_transport * nchan_transport; i++ ) - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - real_part = pCx[i]; - imag_part = pCx_imag[i]; -#else + /* Cx for transport channels */ + for ( i = 0; i < nchan_transport * nchan_transport; i++ ) + { real_part = cx[param_band_idx][i]; imag_part = cx_imag[param_band_idx][i]; -#endif - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - if ( param_band_idx < hParamMC->max_param_band_abs_cov ) - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); -#else + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + if ( param_band_idx < hParamMC->max_param_band_abs_cov ) + { cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); -#endif - } - else - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - pCx[i] = real_part; -#else + } + else + { cx[param_band_idx][i] = real_part; -#endif - } } } + } - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ - if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); - mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); -#else + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) + { for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) { v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); } + } + + + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); #endif - } + pop_wmops(); + + return; +} +#ifdef OBJ_EDITING_API +/*------------------------------------------------------------------------- + * ivas_param_mc_dec_prepare_renderer() + * + * + *------------------------------------------------------------------------*/ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) +void ivas_param_mc_dec_prepare_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ +) +{ + PARAM_MC_DEC_HANDLE hParamMC; + int16_t i; + int16_t slot_idx, param_band_idx; + int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; + int16_t nchan_out_cov; + /*CLDFB*/ + float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float real_part, imag_part; + /* format converter */ + int16_t channel_active[MAX_OUTPUT_CHANNELS]; + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; + + hParamMC = st_ivas->hParamMC; + assert( hParamMC ); + + push_wmops( "param_mc_dec_digest_tc" ); + + set_s( channel_active, 0, MAX_CICP_CHANNELS ); + nchan_transport = st_ivas->nchan_transport; + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + nchan_out_cldfb = BINAURAL_CHANNELS; + set_s( channel_active, 1, nchan_out_cldfb ); + nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) + { + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cldfb = nchan_out_cov; + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hOutSetup; + } + else + { + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = nchan_out_transport; + set_s( channel_active, 1, nchan_out_cov ); + hSynthesisOutputSetup = &st_ivas->hTransSetup; + } + + /* adapt transient position */ + if ( hParamMC->hMetadataPMC->bAttackPresent ) + { + hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); + } + /* adapt subframes */ + hParamMC->num_slots = nCldfbSlots; + hParamMC->slots_rendered = 0; + hParamMC->subframes_rendered = 0; + ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); + st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; + mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); + + ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); + + for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) + { + set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + } + + /* slot loop for gathering the input data */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) { - if ( is_next_band && skip_next_band ) + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); + } + } + + /* map from complex input covariance to real values */ + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) + { + /* Cx for transport channels */ + for ( i = 0; i < nchan_transport * nchan_transport; i++ ) + { + real_part = cx[param_band_idx][i]; + imag_part = cx_imag[param_band_idx][i]; + + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + if ( param_band_idx < hParamMC->max_param_band_abs_cov ) { - continue; + cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); + } + else + { + cx[param_band_idx][i] = real_part; } -#endif - /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices( hParamMC, - hSynthesisOutputSetup, -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - is_next_band ? cx_next_band : cx, - param_band_idx + is_next_band, -#else - cx, -#endif - hParamMC->h_output_synthesis_cov_state.mixing_matrix, - hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, - nchan_out_transport, - hParamMC->synthesis_conf, - nchan_transport, - nchan_out_cov ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES } } -#endif + + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) + { + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); + mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); + } + } + + + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); pop_wmops(); return; } - +#endif /*------------------------------------------------------------------------- * ivas_param_mc_dec_render() @@ -2249,18 +2277,6 @@ static void remove_lfe_from_cy( *------------------------------------------------------------------------*/ static void ivas_param_mc_get_mixing_matrices( -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, - float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ - const int16_t param_band_idx, /* i : parameter band index */ - float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ - float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ - const int16_t nY_intern, /* i : number of channels in the transported format */ - const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ - const int16_t nX, /* i : number of transport channels */ - const int16_t nY_cov /* i : number of covariance synthesis output channels */ -#else PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ @@ -2270,12 +2286,9 @@ static void ivas_param_mc_get_mixing_matrices( const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ const int16_t nX, /* i : number of transport channels */ const int16_t nY_cov /* i : number of covariance synthesis output channels */ -#endif ) { -#ifndef FIX_835_PARAMMC_BUFFER_VALUES int16_t param_band_idx; -#endif float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float Cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; float Cy_diag[MAX_CICP_CHANNELS]; @@ -2345,10 +2358,8 @@ static void ivas_param_mc_get_mixing_matrices( num_lfe_bands = PARAM_MC_MAX_BAND_LFE; } -#ifndef FIX_835_PARAMMC_BUFFER_VALUES for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) { -#endif if ( hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands ) { remove_lfe = 1; @@ -2363,11 +2374,7 @@ static void ivas_param_mc_get_mixing_matrices( brange[0] = hParamMC->band_grouping[param_band_idx]; brange[1] = hParamMC->band_grouping[param_band_idx + 1]; -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - Cx_state = Cx_in; -#else - Cx_state = Cx_in[param_band_idx]; -#endif + Cx_state = Cx_in[param_band_idx]; Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx]; Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx]; @@ -2511,9 +2518,7 @@ static void ivas_param_mc_get_mixing_matrices( { mvr2r( mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX ); } -#ifndef FIX_835_PARAMMC_BUFFER_VALUES } -#endif return; } @@ -3015,212 +3020,3 @@ static void ivas_param_mc_bs_decode_parameter_values( return; } - - - -#ifdef OBJ_EDITING_API -/*------------------------------------------------------------------------- - * ivas_param_mc_dec_prepare_renderer() - * - * - *------------------------------------------------------------------------*/ - -void ivas_param_mc_dec_prepare_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ -) -{ - PARAM_MC_DEC_HANDLE hParamMC; - int16_t i; - -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - int16_t is_next_band, skip_next_band; -#endif - - int16_t param_band_idx; - int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; - int16_t nchan_out_cov; - /*CLDFB*/ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - float *pCx, *pCx_imag; - float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#else - float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#endif - float real_part, imag_part; - /* format converter */ - int16_t channel_active[MAX_OUTPUT_CHANNELS]; - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; - - hParamMC = st_ivas->hParamMC; - assert( hParamMC ); - - push_wmops( "param_mc_dec_digest_tc" ); - - set_s( channel_active, 0, MAX_CICP_CHANNELS ); - nchan_transport = st_ivas->nchan_transport; - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - nchan_out_cldfb = BINAURAL_CHANNELS; - set_s( channel_active, 1, nchan_out_cldfb ); - nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; - hSynthesisOutputSetup = &st_ivas->hTransSetup; - } - else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) - { - nchan_out_cov = nchan_out_transport; - nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - hSynthesisOutputSetup = &st_ivas->hTransSetup; - } - else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) - { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - nchan_out_cldfb = nchan_out_cov; - set_s( channel_active, 1, nchan_out_cov ); - hSynthesisOutputSetup = &st_ivas->hOutSetup; - } - else - { - nchan_out_cov = nchan_out_transport; - nchan_out_cldfb = nchan_out_transport; - set_s( channel_active, 1, nchan_out_cov ); - hSynthesisOutputSetup = &st_ivas->hTransSetup; - } - - /* adapt transient position */ - if ( hParamMC->hMetadataPMC->bAttackPresent ) - { - hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); - } - /* adapt subframes */ - hParamMC->num_slots = nCldfbSlots; - hParamMC->slots_rendered = 0; - hParamMC->subframes_rendered = 0; - ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); - st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; - mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); - - ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); - - -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - /* loop over two bands at a time */ - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) - { - /* don't process next band if it exceeds the limit */ - skip_next_band = ( ( param_band_idx + 1 ) == hParamMC->num_param_bands_synth ) ? 1 : 0; - - set_zero( cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); -#else - for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) - { - set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - } -#endif - - /* map from complex input covariance to real values */ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - if ( is_next_band && skip_next_band ) - { - continue; - } -#else - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) - { -#endif - /* Cx for transport channels */ -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - pCx = is_next_band ? &cx_next_band[0] : &cx[0]; - pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; -#endif - for ( i = 0; i < nchan_transport * nchan_transport; i++ ) - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - real_part = pCx[i]; - imag_part = pCx_imag[i]; -#else - real_part = cx[param_band_idx][i]; - imag_part = cx_imag[param_band_idx][i]; -#endif - - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - if ( param_band_idx < hParamMC->max_param_band_abs_cov ) - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); -#else - cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); -#endif - } - else - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - pCx[i] = real_part; -#else - cx[param_band_idx][i] = real_part; -#endif - } - } - } - - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ - if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) - { -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); - mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); -#else - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) - { - v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); - mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); - } -#endif - } - - -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) - { - if ( is_next_band && skip_next_band ) - { - continue; - } -#endif - /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices( hParamMC, - hSynthesisOutputSetup, -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - is_next_band ? cx_next_band : cx, - param_band_idx + is_next_band, -#else - cx, -#endif - hParamMC->h_output_synthesis_cov_state.mixing_matrix, - hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, - nchan_out_transport, - hParamMC->synthesis_conf, - nchan_transport, - nchan_out_cov ); -#ifdef FIX_835_PARAMMC_BUFFER_VALUES - } - } -#endif - - pop_wmops(); - - return; -} -#endif -- GitLab From 7081b10f0252f9b9bcb0e12226d3f67e30cca54a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 28 Aug 2024 11:30:37 +0200 Subject: [PATCH 124/130] port FIX_835_PARAMMC_BUFFER_VALUES back to this branch --- lib_com/options.h | 2 +- lib_dec/ivas_mc_param_dec.c | 624 ++++++++++++++++++++++-------------- 2 files changed, 378 insertions(+), 248 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c63455cbd2..3d69407b02 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -185,7 +185,7 @@ #endif #define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define FIX_1166_TDREND_DIV0 /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */ -//#define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */ +#define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 9ddcf50f90..4f4c5e700b 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -86,7 +86,11 @@ static int16_t ivas_param_mc_uniform_decoder( float *seq, const int16_t sz_seq, static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hDirAC, float *ild_q, float *icc_q, const int16_t param_band_index, const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nY, const int16_t nX, float *Cx_state, float *Cproto, float *Cy_state ); -static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY ); +#ifdef FIX_835_PARAMMC_BUFFER_VALUES +static void ivas_param_mc_get_mixing_matrices(PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t param_band_idx, float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY); +#else +static void ivas_param_mc_get_mixing_matrices(PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY); +#endif static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float *mixing_matrix[], float *mixing_matrix_res[], const uint16_t nX, const uint16_t nY ); @@ -1484,12 +1488,23 @@ void ivas_param_mc_dec_prepare_renderer( { PARAM_MC_DEC_HANDLE hParamMC; int16_t i; +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + int16_t is_next_band, skip_next_band; +#endif int16_t slot_idx, param_band_idx; int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; /*CLDFB*/ - float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + float *pCx, *pCx_imag; + float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#else + float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#endif float real_part, imag_part; /* format converter */ int16_t channel_active[MAX_OUTPUT_CHANNELS]; @@ -1547,11 +1562,101 @@ void ivas_param_mc_dec_prepare_renderer( ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); - for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) - { - set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - } +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + /* loop over two bands at a time */ + for (param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2) + { + /* don't process next band if it exceeds the limit */ + skip_next_band = ((param_band_idx + 1) == hParamMC->num_param_bands_synth) ? 1 : 0; + + set_zero(cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + set_zero(cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + set_zero(cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + set_zero(cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + + /* slot loop for gathering the input data */ + for (slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++) + { + if (slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex) + { + for (is_next_band = 0; is_next_band < 2; is_next_band++) + { + if (is_next_band && skip_next_band) + { + continue; + } + + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot(&hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], + &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], + is_next_band ? cx_next_band : cx, + is_next_band ? cx_imag_next_band : cx_imag, + param_band_idx + is_next_band, + hParamMC, + nchan_transport + ); + } + } + } + + for (is_next_band = 0; is_next_band < 2; is_next_band++) + { + if (is_next_band && skip_next_band) + { + continue; + } + + pCx = is_next_band ? &cx_next_band[0] : &cx[0]; + pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; + + for (i = 0; i < nchan_transport * nchan_transport; i++) + { + real_part = pCx[i]; + imag_part = pCx_imag[i]; + + if (param_band_idx < hParamMC->max_param_band_abs_cov) + { + pCx[i] = sqrtf(real_part * real_part + imag_part * imag_part); + } + else + { + pCx[i] = real_part; + } + } + } + + + if (hParamMC->hMetadataPMC->bAttackPresent && (hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO)) + { + v_add(cx, cx_next_band, cx, nchan_transport * nchan_transport); + mvr2r(cx, cx_next_band, nchan_transport * nchan_transport); + } + + for (is_next_band = 0; is_next_band < 2; is_next_band++) + { + if (is_next_band && skip_next_band) + { + continue; + } + + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices(hParamMC, + hSynthesisOutputSetup, + is_next_band ? cx_next_band : cx, + param_band_idx + is_next_band, + hParamMC->h_output_synthesis_cov_state.mixing_matrix, + hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, + nchan_out_transport, + hParamMC->synthesis_conf, + nchan_transport, + nchan_out_cov); + } + } +#else + for (param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++) + { + set_zero(cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + set_zero(cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); + } /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) @@ -1596,6 +1701,7 @@ void ivas_param_mc_dec_prepare_renderer( /* generate mixing matrices */ ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); +#endif pop_wmops(); @@ -2277,253 +2383,277 @@ static void remove_lfe_from_cy( *------------------------------------------------------------------------*/ static void ivas_param_mc_get_mixing_matrices( - PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, - float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ - float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ - float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ - const int16_t nY_intern, /* i : number of channels in the transported format */ - const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ - const int16_t nX, /* i : number of transport channels */ - const int16_t nY_cov /* i : number of covariance synthesis output channels */ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, + float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ + const int16_t param_band_idx, /* i : parameter band index */ + float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ + float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ + const int16_t nY_intern, /* i : number of channels in the transported format */ + const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ + const int16_t nX, /* i : number of transport channels */ + const int16_t nY_cov /* i : number of covariance synthesis output channels */ +#else + PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, + float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ + float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ + float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ + const int16_t nY_intern, /* i : number of channels in the transported format */ + const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ + const int16_t nX, /* i : number of transport channels */ + const int16_t nY_cov /* i : number of covariance synthesis output channels */ +#endif ) { - int16_t param_band_idx; - float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float Cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float Cy_diag[MAX_CICP_CHANNELS]; - float Cr[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float Cproto_diag[MAX_CICP_CHANNELS]; - float Cproto[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float mat_mult_buffer1[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float *Cx_state; - float *Cx_old_state; - float Cy_state[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float *Cy_old_state; - int16_t nY_band; - float proto_matrix_noLFE[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; - float *proto_matrix_ptr; - int16_t num_lfe_bands; - int16_t brange[2]; - uint16_t i; - int16_t ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; - float *ptrMM; - float *ptrMM_out; - float Cy_full[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float mixing_matrix_local[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float mixing_matrix_res_local[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - int16_t remove_lfe; - int16_t lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; - - set_zero( Cproto, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); - set_zero( mat_mult_buffer1, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); - set_zero( proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); - - nY_band = nY_cov; - num_lfe_bands = 0; - remove_lfe = 0; - - set_s( lfe_indices, -1, PARAM_MC_LOCAL_SZ_LFE_MAP ); - if ( hSynthesisOutputSetup->num_lfe ) - { - float *proto_matrix_ptr_in; +#ifndef FIX_835_PARAMMC_BUFFER_VALUES + int16_t param_band_idx; +#endif + float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float Cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float Cy_diag[MAX_CICP_CHANNELS]; + float Cr[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float Cproto_diag[MAX_CICP_CHANNELS]; + float Cproto[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float mat_mult_buffer1[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float *Cx_state; + float *Cx_old_state; + float Cy_state[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float *Cy_old_state; + int16_t nY_band; + float proto_matrix_noLFE[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; + float *proto_matrix_ptr; + int16_t num_lfe_bands; + int16_t brange[2]; + uint16_t i; + int16_t ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; + float *ptrMM; + float *ptrMM_out; + float Cy_full[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float mixing_matrix_local[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float mixing_matrix_res_local[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + int16_t remove_lfe; + int16_t lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; + + set_zero(Cproto, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS); + set_zero(mat_mult_buffer1, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS); + set_zero(proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS); + + nY_band = nY_cov; + num_lfe_bands = 0; + remove_lfe = 0; + + set_s(lfe_indices, -1, PARAM_MC_LOCAL_SZ_LFE_MAP); + if (hSynthesisOutputSetup->num_lfe) + { + float *proto_matrix_ptr_in; #ifdef DEBUGGING - assert( ( nY_cov == ( hSynthesisOutputSetup->nchan_out_woLFE + hSynthesisOutputSetup->num_lfe ) ) && "Number of channels do not match!" ); + assert((nY_cov == (hSynthesisOutputSetup->nchan_out_woLFE + hSynthesisOutputSetup->num_lfe)) && "Number of channels do not match!"); +#endif + for (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe; lfe_idx1++) + { + lfe_indices[lfe_idx1 + 1] = hSynthesisOutputSetup->index_lfe[lfe_idx1]; + } + lfe_indices[hSynthesisOutputSetup->num_lfe + 1] = nY_cov; + proto_matrix_ptr = &proto_matrix_noLFE[0]; + proto_matrix_ptr_in = &hParamMC->h_output_synthesis_params.proto_matrix[0]; + set_zero(proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS); + + for (ch_idx1 = 0; ch_idx1 < nX; ch_idx1++) + { + for (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++) + { + for (ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++) + { + *(proto_matrix_ptr++) = *(proto_matrix_ptr_in++); + } + proto_matrix_ptr_in++; + } + proto_matrix_ptr_in--; + } + } + + if (hParamMC->hMetadataPMC->lfe_on) + { + num_lfe_bands = PARAM_MC_MAX_BAND_LFE; + } + +#ifndef FIX_835_PARAMMC_BUFFER_VALUES + for (param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++) + { +#endif + if (hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands) + { + remove_lfe = 1; + nY_band = nY_cov - hSynthesisOutputSetup->num_lfe; + proto_matrix_ptr = proto_matrix_noLFE; + } + else + { + proto_matrix_ptr = hParamMC->h_output_synthesis_params.proto_matrix; + } + + brange[0] = hParamMC->band_grouping[param_band_idx]; + brange[1] = hParamMC->band_grouping[param_band_idx + 1]; + +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + Cx_state = Cx_in; +#else + Cx_state = Cx_in[param_band_idx]; +#endif + Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx]; + Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx]; + + /* Getting mixing mtx */ + /* estimate target cov from input cov and proto_matrix */ + matrix_product(hParamMC->proto_matrix_int, nY_intern, nX, 0, Cx_state, nX, nX, 0, mat_mult_buffer1); + + matrix_product(mat_mult_buffer1, nY_intern, nX, 0, hParamMC->proto_matrix_int, nY_intern, nX, 1, Cproto); + + for (ch_idx1 = 0; ch_idx1 < nY_intern; ch_idx1++) + { + if (Cproto[ch_idx1 + ch_idx1 * nY_intern] < 0.0f) + { + Cproto[ch_idx1 + ch_idx1 * nY_intern] = 0.0f; + } + } + + ivas_param_mc_dequantize_cov(hParamMC, + hParamMC->icld_q + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, + hParamMC->icc_q + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, + param_band_idx, nY_cov, + synth_config, + nY_intern, + nX, Cx_state, Cproto, Cy_state); + + /* Smoothing: Sum over two buffers */ + if (hParamMC->hMetadataPMC->bAttackPresent) + { + /* no smoothing on attacks */ + mvr2r(Cx_state, Cx, nX * nX); + mvr2r(Cy_state, Cy_full, nY_cov * nY_cov); + } + else + { + /* smoothing gains are now identical to one, simply add up */ + v_add(Cx_state, Cx_old_state, Cx, nX * nX); + v_add(Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov); + } + + /* cov buffer update */ + mvr2r(Cx_state, Cx_old_state, nX * nX); + mvr2r(Cy_state, Cy_old_state, nY_cov * nY_cov); + + /* remove LFE if necessary */ + if (remove_lfe) + { + remove_lfe_from_cy(nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full, Cy); + } + else + { + mvr2r(Cy_full, Cy, nY_band * nY_band); + } + + matrix_product(proto_matrix_ptr, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1); + + matrix_product_diag(mat_mult_buffer1, nY_band, nX, 0, proto_matrix_ptr, nY_band, nX, 1, Cproto_diag); + + /* make sure we have no negative entries in Cproto_diag due to rounding errors */ + for (ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++) + { + if (Cproto_diag[ch_idx1] < 0.0f) + { + Cproto_diag[ch_idx1] = 0.0f; + } + } + + /* Computing the mixing matrices */ + + /* bands with decorr */ + if (brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr) + { + computeMixingMatrices(nX, nY_band, Cx, Cy, proto_matrix_ptr, 0, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr); + + /* Compute mixing matrix for residual */ + computeMixingMatricesResidual(nY_band, Cproto_diag, Cr, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_res_local); + + if (remove_lfe) + { + set_zero(mixing_matrix_res[param_band_idx], nY_cov * nY_cov); + + ptrMM = mixing_matrix_res_local; + ptrMM_out = mixing_matrix_res[param_band_idx]; + for (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++) + { + for (ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++) + { + for (lfe_idx2 = 0; lfe_idx2 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx2++) + { + for (ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++) + { + *(ptrMM_out++) = *(ptrMM++); + } + ptrMM_out++; + } + ptrMM_out--; + } + ptrMM_out += nY_cov; + } + } + else + { + mvr2r(mixing_matrix_res_local, mixing_matrix_res[param_band_idx], nY_cov * nY_cov); + } + } + else if (brange[0] < hParamMC->max_band_energy_compensation) + { + /* Compute mixing matrices (energy compensation only) */ + computeMixingMatrices(nX, nY_band, Cx, Cy, proto_matrix_ptr, 1, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr); + } + else + { + /*if neither decorrelation nor energy compensation is applied*/ + for (i = 0; i < nY_band; i++) + { + Cy_diag[i] = Cy[i + nY_band * i]; + Cy_diag[i] = sqrtf(Cy_diag[i] / (Cproto_diag[i] + EPSILON)); + } + + diag_matrix_product(Cy_diag, nY_band, proto_matrix_ptr, nY_band, nX, 0, mixing_matrix_local); + } + if (remove_lfe) + { + set_zero(mixing_matrix[param_band_idx], nX * nY_cov); + + ptrMM = mixing_matrix_local; + ptrMM_out = mixing_matrix[param_band_idx]; + for (ch_idx1 = 0; ch_idx1 < nX; ch_idx1++) + { + for (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++) + { + for (ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++) + { + *(ptrMM_out++) = *(ptrMM++); + } + ptrMM_out++; + } + ptrMM_out--; + } + } + else + { + mvr2r(mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX); + } +#ifndef FIX_835_PARAMMC_BUFFER_VALUES + } #endif - for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe; lfe_idx1++ ) - { - lfe_indices[lfe_idx1 + 1] = hSynthesisOutputSetup->index_lfe[lfe_idx1]; - } - lfe_indices[hSynthesisOutputSetup->num_lfe + 1] = nY_cov; - proto_matrix_ptr = &proto_matrix_noLFE[0]; - proto_matrix_ptr_in = &hParamMC->h_output_synthesis_params.proto_matrix[0]; - set_zero( proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); - - for ( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) - { - for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) - { - for ( ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) - { - *( proto_matrix_ptr++ ) = *( proto_matrix_ptr_in++ ); - } - proto_matrix_ptr_in++; - } - proto_matrix_ptr_in--; - } - } - - if ( hParamMC->hMetadataPMC->lfe_on ) - { - num_lfe_bands = PARAM_MC_MAX_BAND_LFE; - } - - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) - { - if ( hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands ) - { - remove_lfe = 1; - nY_band = nY_cov - hSynthesisOutputSetup->num_lfe; - proto_matrix_ptr = proto_matrix_noLFE; - } - else - { - proto_matrix_ptr = hParamMC->h_output_synthesis_params.proto_matrix; - } - - brange[0] = hParamMC->band_grouping[param_band_idx]; - brange[1] = hParamMC->band_grouping[param_band_idx + 1]; - - Cx_state = Cx_in[param_band_idx]; - Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx]; - Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx]; - - /* Getting mixing mtx */ - /* estimate target cov from input cov and proto_matrix */ - matrix_product( hParamMC->proto_matrix_int, nY_intern, nX, 0, Cx_state, nX, nX, 0, mat_mult_buffer1 ); - - matrix_product( mat_mult_buffer1, nY_intern, nX, 0, hParamMC->proto_matrix_int, nY_intern, nX, 1, Cproto ); - - for ( ch_idx1 = 0; ch_idx1 < nY_intern; ch_idx1++ ) - { - if ( Cproto[ch_idx1 + ch_idx1 * nY_intern] < 0.0f ) - { - Cproto[ch_idx1 + ch_idx1 * nY_intern] = 0.0f; - } - } - - ivas_param_mc_dequantize_cov( hParamMC, - hParamMC->icld_q + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, - hParamMC->icc_q + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, - param_band_idx, nY_cov, - synth_config, - nY_intern, - nX, Cx_state, Cproto, Cy_state ); - - /* Smoothing: Sum over two buffers */ - if ( hParamMC->hMetadataPMC->bAttackPresent ) - { - /* no smoothing on attacks */ - mvr2r( Cx_state, Cx, nX * nX ); - mvr2r( Cy_state, Cy_full, nY_cov * nY_cov ); - } - else - { - /* smoothing gains are now identical to one, simply add up */ - v_add( Cx_state, Cx_old_state, Cx, nX * nX ); - v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov ); - } - - /* cov buffer update */ - mvr2r( Cx_state, Cx_old_state, nX * nX ); - mvr2r( Cy_state, Cy_old_state, nY_cov * nY_cov ); - - /* remove LFE if necessary */ - if ( remove_lfe ) - { - remove_lfe_from_cy( nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full, Cy ); - } - else - { - mvr2r( Cy_full, Cy, nY_band * nY_band ); - } - - matrix_product( proto_matrix_ptr, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1 ); - - matrix_product_diag( mat_mult_buffer1, nY_band, nX, 0, proto_matrix_ptr, nY_band, nX, 1, Cproto_diag ); - - /* make sure we have no negative entries in Cproto_diag due to rounding errors */ - for ( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) - { - if ( Cproto_diag[ch_idx1] < 0.0f ) - { - Cproto_diag[ch_idx1] = 0.0f; - } - } - - /* Computing the mixing matrices */ - - /* bands with decorr */ - if ( brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr ) - { - computeMixingMatrices( nX, nY_band, Cx, Cy, proto_matrix_ptr, 0, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr ); - - /* Compute mixing matrix for residual */ - computeMixingMatricesResidual( nY_band, Cproto_diag, Cr, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_res_local ); - - if ( remove_lfe ) - { - set_zero( mixing_matrix_res[param_band_idx], nY_cov * nY_cov ); - - ptrMM = mixing_matrix_res_local; - ptrMM_out = mixing_matrix_res[param_band_idx]; - for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) - { - for ( ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++ ) - { - for ( lfe_idx2 = 0; lfe_idx2 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx2++ ) - { - for ( ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++ ) - { - *( ptrMM_out++ ) = *( ptrMM++ ); - } - ptrMM_out++; - } - ptrMM_out--; - } - ptrMM_out += nY_cov; - } - } - else - { - mvr2r( mixing_matrix_res_local, mixing_matrix_res[param_band_idx], nY_cov * nY_cov ); - } - } - else if ( brange[0] < hParamMC->max_band_energy_compensation ) - { - /* Compute mixing matrices (energy compensation only) */ - computeMixingMatrices( nX, nY_band, Cx, Cy, proto_matrix_ptr, 1, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr ); - } - else - { - /*if neither decorrelation nor energy compensation is applied*/ - for ( i = 0; i < nY_band; i++ ) - { - Cy_diag[i] = Cy[i + nY_band * i]; - Cy_diag[i] = sqrtf( Cy_diag[i] / ( Cproto_diag[i] + EPSILON ) ); - } - - diag_matrix_product( Cy_diag, nY_band, proto_matrix_ptr, nY_band, nX, 0, mixing_matrix_local ); - } - if ( remove_lfe ) - { - set_zero( mixing_matrix[param_band_idx], nX * nY_cov ); - - ptrMM = mixing_matrix_local; - ptrMM_out = mixing_matrix[param_band_idx]; - for ( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) - { - for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) - { - for ( ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) - { - *( ptrMM_out++ ) = *( ptrMM++ ); - } - ptrMM_out++; - } - ptrMM_out--; - } - } - else - { - mvr2r( mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX ); - } - } - return; + return; } + /*------------------------------------------------------------------------- * param_mc_update_mixing_matrices() * -- GitLab From 2e094daceddf8fdf72148fca65b7d86d46c3cbaa Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 28 Aug 2024 12:17:39 +0200 Subject: [PATCH 125/130] fix formatting --- lib_dec/ivas_mc_param_dec.c | 702 ++++++++++++++++++------------------ 1 file changed, 350 insertions(+), 352 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 4f4c5e700b..cef373b816 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -87,9 +87,9 @@ static int16_t ivas_param_mc_uniform_decoder( float *seq, const int16_t sz_seq, static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hDirAC, float *ild_q, float *icc_q, const int16_t param_band_index, const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nY, const int16_t nX, float *Cx_state, float *Cproto, float *Cy_state ); #ifdef FIX_835_PARAMMC_BUFFER_VALUES -static void ivas_param_mc_get_mixing_matrices(PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t param_band_idx, float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY); +static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t param_band_idx, float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY ); #else -static void ivas_param_mc_get_mixing_matrices(PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY); +static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY ); #endif static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float *mixing_matrix[], float *mixing_matrix_res[], const uint16_t nX, const uint16_t nY ); @@ -1489,21 +1489,21 @@ void ivas_param_mc_dec_prepare_renderer( PARAM_MC_DEC_HANDLE hParamMC; int16_t i; #ifdef FIX_835_PARAMMC_BUFFER_VALUES - int16_t is_next_band, skip_next_band; + int16_t is_next_band, skip_next_band; #endif int16_t slot_idx, param_band_idx; int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; int16_t nchan_out_cov; /*CLDFB*/ #ifdef FIX_835_PARAMMC_BUFFER_VALUES - float *pCx, *pCx_imag; - float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float *pCx, *pCx_imag; + float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; #else - float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; #endif float real_part, imag_part; /* format converter */ @@ -1563,100 +1563,99 @@ void ivas_param_mc_dec_prepare_renderer( ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); #ifdef FIX_835_PARAMMC_BUFFER_VALUES - /* loop over two bands at a time */ - for (param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2) - { - /* don't process next band if it exceeds the limit */ - skip_next_band = ((param_band_idx + 1) == hParamMC->num_param_bands_synth) ? 1 : 0; - - set_zero(cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); - set_zero(cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); - set_zero(cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); - set_zero(cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); - - /* slot loop for gathering the input data */ - for (slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++) - { - if (slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex) - { - for (is_next_band = 0; is_next_band < 2; is_next_band++) - { - if (is_next_band && skip_next_band) - { - continue; - } - - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot(&hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], - &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], - is_next_band ? cx_next_band : cx, - is_next_band ? cx_imag_next_band : cx_imag, - param_band_idx + is_next_band, - hParamMC, - nchan_transport - ); - } - } - } - - for (is_next_band = 0; is_next_band < 2; is_next_band++) - { - if (is_next_band && skip_next_band) - { - continue; - } - - pCx = is_next_band ? &cx_next_band[0] : &cx[0]; - pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; - - for (i = 0; i < nchan_transport * nchan_transport; i++) - { - real_part = pCx[i]; - imag_part = pCx_imag[i]; - - if (param_band_idx < hParamMC->max_param_band_abs_cov) - { - pCx[i] = sqrtf(real_part * real_part + imag_part * imag_part); - } - else - { - pCx[i] = real_part; - } - } - } - - - if (hParamMC->hMetadataPMC->bAttackPresent && (hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO)) - { - v_add(cx, cx_next_band, cx, nchan_transport * nchan_transport); - mvr2r(cx, cx_next_band, nchan_transport * nchan_transport); - } - - for (is_next_band = 0; is_next_band < 2; is_next_band++) - { - if (is_next_band && skip_next_band) - { - continue; - } - - /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices(hParamMC, - hSynthesisOutputSetup, - is_next_band ? cx_next_band : cx, - param_band_idx + is_next_band, - hParamMC->h_output_synthesis_cov_state.mixing_matrix, - hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, - nchan_out_transport, - hParamMC->synthesis_conf, - nchan_transport, - nchan_out_cov); - } - } + /* loop over two bands at a time */ + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + /* don't process next band if it exceeds the limit */ + skip_next_band = ( ( param_band_idx + 1 ) == hParamMC->num_param_bands_synth ) ? 1 : 0; + + set_zero( cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + + /* slot loop for gathering the input data */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + { + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } + + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], + &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], + is_next_band ? cx_next_band : cx, + is_next_band ? cx_imag_next_band : cx_imag, + param_band_idx + is_next_band, + hParamMC, + nchan_transport ); + } + } + } + + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } + + pCx = is_next_band ? &cx_next_band[0] : &cx[0]; + pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; + + for ( i = 0; i < nchan_transport * nchan_transport; i++ ) + { + real_part = pCx[i]; + imag_part = pCx_imag[i]; + + if ( param_band_idx < hParamMC->max_param_band_abs_cov ) + { + pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); + } + else + { + pCx[i] = real_part; + } + } + } + + + if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) + { + v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); + mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); + } + + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } + + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices( hParamMC, + hSynthesisOutputSetup, + is_next_band ? cx_next_band : cx, + param_band_idx + is_next_band, + hParamMC->h_output_synthesis_cov_state.mixing_matrix, + hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, + nchan_out_transport, + hParamMC->synthesis_conf, + nchan_transport, + nchan_out_cov ); + } + } #else - for (param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++) - { - set_zero(cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); - set_zero(cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS); - } + for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) + { + set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + } /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) @@ -2384,276 +2383,275 @@ static void remove_lfe_from_cy( static void ivas_param_mc_get_mixing_matrices( #ifdef FIX_835_PARAMMC_BUFFER_VALUES - PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, - float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ - const int16_t param_band_idx, /* i : parameter band index */ - float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ - float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ - const int16_t nY_intern, /* i : number of channels in the transported format */ - const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ - const int16_t nX, /* i : number of transport channels */ - const int16_t nY_cov /* i : number of covariance synthesis output channels */ + PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, + float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ + const int16_t param_band_idx, /* i : parameter band index */ + float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ + float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ + const int16_t nY_intern, /* i : number of channels in the transported format */ + const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ + const int16_t nX, /* i : number of transport channels */ + const int16_t nY_cov /* i : number of covariance synthesis output channels */ #else - PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, - float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ - float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ - float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ - const int16_t nY_intern, /* i : number of channels in the transported format */ - const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ - const int16_t nX, /* i : number of transport channels */ - const int16_t nY_cov /* i : number of covariance synthesis output channels */ + PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ + IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, + float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ + float *mixing_matrix[], /* o : direct mixing matrices for all parameter bands */ + float *mixing_matrix_res[], /* o : residual mixing matrices for all parameter bands */ + const int16_t nY_intern, /* i : number of channels in the transported format */ + const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ + const int16_t nX, /* i : number of transport channels */ + const int16_t nY_cov /* i : number of covariance synthesis output channels */ #endif ) { #ifndef FIX_835_PARAMMC_BUFFER_VALUES - int16_t param_band_idx; + int16_t param_band_idx; #endif - float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float Cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float Cy_diag[MAX_CICP_CHANNELS]; - float Cr[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float Cproto_diag[MAX_CICP_CHANNELS]; - float Cproto[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float mat_mult_buffer1[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float *Cx_state; - float *Cx_old_state; - float Cy_state[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float *Cy_old_state; - int16_t nY_band; - float proto_matrix_noLFE[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; - float *proto_matrix_ptr; - int16_t num_lfe_bands; - int16_t brange[2]; - uint16_t i; - int16_t ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; - float *ptrMM; - float *ptrMM_out; - float Cy_full[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - float mixing_matrix_local[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; - float mixing_matrix_res_local[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - int16_t remove_lfe; - int16_t lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; - - set_zero(Cproto, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS); - set_zero(mat_mult_buffer1, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS); - set_zero(proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS); - - nY_band = nY_cov; - num_lfe_bands = 0; - remove_lfe = 0; - - set_s(lfe_indices, -1, PARAM_MC_LOCAL_SZ_LFE_MAP); - if (hSynthesisOutputSetup->num_lfe) - { - float *proto_matrix_ptr_in; + float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float Cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float Cy_diag[MAX_CICP_CHANNELS]; + float Cr[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float Cproto_diag[MAX_CICP_CHANNELS]; + float Cproto[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float mat_mult_buffer1[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float *Cx_state; + float *Cx_old_state; + float Cy_state[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float *Cy_old_state; + int16_t nY_band; + float proto_matrix_noLFE[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; + float *proto_matrix_ptr; + int16_t num_lfe_bands; + int16_t brange[2]; + uint16_t i; + int16_t ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; + float *ptrMM; + float *ptrMM_out; + float Cy_full[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + float mixing_matrix_local[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float mixing_matrix_res_local[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; + int16_t remove_lfe; + int16_t lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; + + set_zero( Cproto, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); + set_zero( mat_mult_buffer1, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); + set_zero( proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); + + nY_band = nY_cov; + num_lfe_bands = 0; + remove_lfe = 0; + + set_s( lfe_indices, -1, PARAM_MC_LOCAL_SZ_LFE_MAP ); + if ( hSynthesisOutputSetup->num_lfe ) + { + float *proto_matrix_ptr_in; #ifdef DEBUGGING - assert((nY_cov == (hSynthesisOutputSetup->nchan_out_woLFE + hSynthesisOutputSetup->num_lfe)) && "Number of channels do not match!"); + assert( ( nY_cov == ( hSynthesisOutputSetup->nchan_out_woLFE + hSynthesisOutputSetup->num_lfe ) ) && "Number of channels do not match!" ); #endif - for (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe; lfe_idx1++) - { - lfe_indices[lfe_idx1 + 1] = hSynthesisOutputSetup->index_lfe[lfe_idx1]; - } - lfe_indices[hSynthesisOutputSetup->num_lfe + 1] = nY_cov; - proto_matrix_ptr = &proto_matrix_noLFE[0]; - proto_matrix_ptr_in = &hParamMC->h_output_synthesis_params.proto_matrix[0]; - set_zero(proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS); - - for (ch_idx1 = 0; ch_idx1 < nX; ch_idx1++) - { - for (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++) - { - for (ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++) - { - *(proto_matrix_ptr++) = *(proto_matrix_ptr_in++); - } - proto_matrix_ptr_in++; - } - proto_matrix_ptr_in--; - } - } - - if (hParamMC->hMetadataPMC->lfe_on) - { - num_lfe_bands = PARAM_MC_MAX_BAND_LFE; - } + for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe; lfe_idx1++ ) + { + lfe_indices[lfe_idx1 + 1] = hSynthesisOutputSetup->index_lfe[lfe_idx1]; + } + lfe_indices[hSynthesisOutputSetup->num_lfe + 1] = nY_cov; + proto_matrix_ptr = &proto_matrix_noLFE[0]; + proto_matrix_ptr_in = &hParamMC->h_output_synthesis_params.proto_matrix[0]; + set_zero( proto_matrix_noLFE, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); + + for ( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) + { + for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + { + for ( ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) + { + *( proto_matrix_ptr++ ) = *( proto_matrix_ptr_in++ ); + } + proto_matrix_ptr_in++; + } + proto_matrix_ptr_in--; + } + } + + if ( hParamMC->hMetadataPMC->lfe_on ) + { + num_lfe_bands = PARAM_MC_MAX_BAND_LFE; + } #ifndef FIX_835_PARAMMC_BUFFER_VALUES - for (param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++) - { + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) + { #endif - if (hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands) - { - remove_lfe = 1; - nY_band = nY_cov - hSynthesisOutputSetup->num_lfe; - proto_matrix_ptr = proto_matrix_noLFE; - } - else - { - proto_matrix_ptr = hParamMC->h_output_synthesis_params.proto_matrix; - } - - brange[0] = hParamMC->band_grouping[param_band_idx]; - brange[1] = hParamMC->band_grouping[param_band_idx + 1]; + if ( hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands ) + { + remove_lfe = 1; + nY_band = nY_cov - hSynthesisOutputSetup->num_lfe; + proto_matrix_ptr = proto_matrix_noLFE; + } + else + { + proto_matrix_ptr = hParamMC->h_output_synthesis_params.proto_matrix; + } + + brange[0] = hParamMC->band_grouping[param_band_idx]; + brange[1] = hParamMC->band_grouping[param_band_idx + 1]; #ifdef FIX_835_PARAMMC_BUFFER_VALUES - Cx_state = Cx_in; + Cx_state = Cx_in; #else - Cx_state = Cx_in[param_band_idx]; + Cx_state = Cx_in[param_band_idx]; #endif - Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx]; - Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx]; - - /* Getting mixing mtx */ - /* estimate target cov from input cov and proto_matrix */ - matrix_product(hParamMC->proto_matrix_int, nY_intern, nX, 0, Cx_state, nX, nX, 0, mat_mult_buffer1); - - matrix_product(mat_mult_buffer1, nY_intern, nX, 0, hParamMC->proto_matrix_int, nY_intern, nX, 1, Cproto); - - for (ch_idx1 = 0; ch_idx1 < nY_intern; ch_idx1++) - { - if (Cproto[ch_idx1 + ch_idx1 * nY_intern] < 0.0f) - { - Cproto[ch_idx1 + ch_idx1 * nY_intern] = 0.0f; - } - } - - ivas_param_mc_dequantize_cov(hParamMC, - hParamMC->icld_q + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, - hParamMC->icc_q + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, - param_band_idx, nY_cov, - synth_config, - nY_intern, - nX, Cx_state, Cproto, Cy_state); - - /* Smoothing: Sum over two buffers */ - if (hParamMC->hMetadataPMC->bAttackPresent) - { - /* no smoothing on attacks */ - mvr2r(Cx_state, Cx, nX * nX); - mvr2r(Cy_state, Cy_full, nY_cov * nY_cov); - } - else - { - /* smoothing gains are now identical to one, simply add up */ - v_add(Cx_state, Cx_old_state, Cx, nX * nX); - v_add(Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov); - } - - /* cov buffer update */ - mvr2r(Cx_state, Cx_old_state, nX * nX); - mvr2r(Cy_state, Cy_old_state, nY_cov * nY_cov); - - /* remove LFE if necessary */ - if (remove_lfe) - { - remove_lfe_from_cy(nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full, Cy); - } - else - { - mvr2r(Cy_full, Cy, nY_band * nY_band); - } - - matrix_product(proto_matrix_ptr, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1); - - matrix_product_diag(mat_mult_buffer1, nY_band, nX, 0, proto_matrix_ptr, nY_band, nX, 1, Cproto_diag); - - /* make sure we have no negative entries in Cproto_diag due to rounding errors */ - for (ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++) - { - if (Cproto_diag[ch_idx1] < 0.0f) - { - Cproto_diag[ch_idx1] = 0.0f; - } - } - - /* Computing the mixing matrices */ - - /* bands with decorr */ - if (brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr) - { - computeMixingMatrices(nX, nY_band, Cx, Cy, proto_matrix_ptr, 0, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr); - - /* Compute mixing matrix for residual */ - computeMixingMatricesResidual(nY_band, Cproto_diag, Cr, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_res_local); - - if (remove_lfe) - { - set_zero(mixing_matrix_res[param_band_idx], nY_cov * nY_cov); - - ptrMM = mixing_matrix_res_local; - ptrMM_out = mixing_matrix_res[param_band_idx]; - for (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++) - { - for (ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++) - { - for (lfe_idx2 = 0; lfe_idx2 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx2++) - { - for (ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++) - { - *(ptrMM_out++) = *(ptrMM++); - } - ptrMM_out++; - } - ptrMM_out--; - } - ptrMM_out += nY_cov; - } - } - else - { - mvr2r(mixing_matrix_res_local, mixing_matrix_res[param_band_idx], nY_cov * nY_cov); - } - } - else if (brange[0] < hParamMC->max_band_energy_compensation) - { - /* Compute mixing matrices (energy compensation only) */ - computeMixingMatrices(nX, nY_band, Cx, Cy, proto_matrix_ptr, 1, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr); - } - else - { - /*if neither decorrelation nor energy compensation is applied*/ - for (i = 0; i < nY_band; i++) - { - Cy_diag[i] = Cy[i + nY_band * i]; - Cy_diag[i] = sqrtf(Cy_diag[i] / (Cproto_diag[i] + EPSILON)); - } - - diag_matrix_product(Cy_diag, nY_band, proto_matrix_ptr, nY_band, nX, 0, mixing_matrix_local); - } - if (remove_lfe) - { - set_zero(mixing_matrix[param_band_idx], nX * nY_cov); - - ptrMM = mixing_matrix_local; - ptrMM_out = mixing_matrix[param_band_idx]; - for (ch_idx1 = 0; ch_idx1 < nX; ch_idx1++) - { - for (lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++) - { - for (ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++) - { - *(ptrMM_out++) = *(ptrMM++); - } - ptrMM_out++; - } - ptrMM_out--; - } - } - else - { - mvr2r(mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX); - } + Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx]; + Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx]; + + /* Getting mixing mtx */ + /* estimate target cov from input cov and proto_matrix */ + matrix_product( hParamMC->proto_matrix_int, nY_intern, nX, 0, Cx_state, nX, nX, 0, mat_mult_buffer1 ); + + matrix_product( mat_mult_buffer1, nY_intern, nX, 0, hParamMC->proto_matrix_int, nY_intern, nX, 1, Cproto ); + + for ( ch_idx1 = 0; ch_idx1 < nY_intern; ch_idx1++ ) + { + if ( Cproto[ch_idx1 + ch_idx1 * nY_intern] < 0.0f ) + { + Cproto[ch_idx1 + ch_idx1 * nY_intern] = 0.0f; + } + } + + ivas_param_mc_dequantize_cov( hParamMC, + hParamMC->icld_q + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, + hParamMC->icc_q + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, + param_band_idx, nY_cov, + synth_config, + nY_intern, + nX, Cx_state, Cproto, Cy_state ); + + /* Smoothing: Sum over two buffers */ + if ( hParamMC->hMetadataPMC->bAttackPresent ) + { + /* no smoothing on attacks */ + mvr2r( Cx_state, Cx, nX * nX ); + mvr2r( Cy_state, Cy_full, nY_cov * nY_cov ); + } + else + { + /* smoothing gains are now identical to one, simply add up */ + v_add( Cx_state, Cx_old_state, Cx, nX * nX ); + v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov ); + } + + /* cov buffer update */ + mvr2r( Cx_state, Cx_old_state, nX * nX ); + mvr2r( Cy_state, Cy_old_state, nY_cov * nY_cov ); + + /* remove LFE if necessary */ + if ( remove_lfe ) + { + remove_lfe_from_cy( nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full, Cy ); + } + else + { + mvr2r( Cy_full, Cy, nY_band * nY_band ); + } + + matrix_product( proto_matrix_ptr, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1 ); + + matrix_product_diag( mat_mult_buffer1, nY_band, nX, 0, proto_matrix_ptr, nY_band, nX, 1, Cproto_diag ); + + /* make sure we have no negative entries in Cproto_diag due to rounding errors */ + for ( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) + { + if ( Cproto_diag[ch_idx1] < 0.0f ) + { + Cproto_diag[ch_idx1] = 0.0f; + } + } + + /* Computing the mixing matrices */ + + /* bands with decorr */ + if ( brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr ) + { + computeMixingMatrices( nX, nY_band, Cx, Cy, proto_matrix_ptr, 0, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr ); + + /* Compute mixing matrix for residual */ + computeMixingMatricesResidual( nY_band, Cproto_diag, Cr, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_res_local ); + + if ( remove_lfe ) + { + set_zero( mixing_matrix_res[param_band_idx], nY_cov * nY_cov ); + + ptrMM = mixing_matrix_res_local; + ptrMM_out = mixing_matrix_res[param_band_idx]; + for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + { + for ( ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++ ) + { + for ( lfe_idx2 = 0; lfe_idx2 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx2++ ) + { + for ( ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++ ) + { + *( ptrMM_out++ ) = *( ptrMM++ ); + } + ptrMM_out++; + } + ptrMM_out--; + } + ptrMM_out += nY_cov; + } + } + else + { + mvr2r( mixing_matrix_res_local, mixing_matrix_res[param_band_idx], nY_cov * nY_cov ); + } + } + else if ( brange[0] < hParamMC->max_band_energy_compensation ) + { + /* Compute mixing matrices (energy compensation only) */ + computeMixingMatrices( nX, nY_band, Cx, Cy, proto_matrix_ptr, 1, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix_local, Cr ); + } + else + { + /*if neither decorrelation nor energy compensation is applied*/ + for ( i = 0; i < nY_band; i++ ) + { + Cy_diag[i] = Cy[i + nY_band * i]; + Cy_diag[i] = sqrtf( Cy_diag[i] / ( Cproto_diag[i] + EPSILON ) ); + } + + diag_matrix_product( Cy_diag, nY_band, proto_matrix_ptr, nY_band, nX, 0, mixing_matrix_local ); + } + if ( remove_lfe ) + { + set_zero( mixing_matrix[param_band_idx], nX * nY_cov ); + + ptrMM = mixing_matrix_local; + ptrMM_out = mixing_matrix[param_band_idx]; + for ( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) + { + for ( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + { + for ( ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) + { + *( ptrMM_out++ ) = *( ptrMM++ ); + } + ptrMM_out++; + } + ptrMM_out--; + } + } + else + { + mvr2r( mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX ); + } #ifndef FIX_835_PARAMMC_BUFFER_VALUES - } + } #endif - return; + return; } - /*------------------------------------------------------------------------- * param_mc_update_mixing_matrices() * -- GitLab From ad34cd960fd1714c43c7eaa47125a44e28d2617f Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 28 Aug 2024 14:22:30 +0200 Subject: [PATCH 126/130] [fix] proper merge resolution for FIX_835_PARAMMC_BUFFER_VALUES --- lib_dec/ivas_mc_param_dec.c | 295 +++++++++++++++++++++++++----------- 1 file changed, 204 insertions(+), 91 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index cef373b816..ea71148171 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1332,6 +1332,9 @@ void ivas_param_mc_dec_digest_tc( { PARAM_MC_DEC_HANDLE hParamMC; int16_t ch; +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + int16_t is_next_band, skip_next_band; +#endif int16_t slot_idx; int16_t nchan_transport; @@ -1339,8 +1342,16 @@ void ivas_param_mc_dec_digest_tc( int16_t nchan_out_transport, nchan_out_cldfb, i, param_band_idx; int16_t nchan_out_cov; /*CLDFB*/ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + float *pCx, *pCx_imag; + float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; + float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#else float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#endif float real_part, imag_part; /* format converter */ int16_t channel_active[MAX_OUTPUT_CHANNELS]; @@ -1402,72 +1413,171 @@ void ivas_param_mc_dec_digest_tc( ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); + +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + /* loop over two bands at a time */ + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + /* don't process next band if it exceeds the limit */ + skip_next_band = ( ( param_band_idx + 1 ) == hParamMC->num_param_bands_synth ) ? 1 : 0; + + set_zero( cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); +#else for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) { set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); } +#endif #endif - /* slot loop for gathering the input data */ - for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) - { - if ( st_ivas->hDecoderConfig->Opt_tsm ) + /* slot loop for gathering the input data */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; - float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - - /* CLDFB Analysis*/ - for ( ch = 0; ch < nchan_transport; ch++ ) + if ( st_ivas->hDecoderConfig->Opt_tsm ) { - cldfbAnalysis_ts( &( transport_channels_f[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); +#if defined( FIX_835_PARAMMC_BUFFER_VALUES ) && !defined( OBJ_EDITING_API ) + if ( param_band_idx == 0 ) /* only run cldfbAna once */ + { +#endif + float RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + + /* CLDFB Analysis*/ + for ( ch = 0; ch < nchan_transport; ch++ ) + { + cldfbAnalysis_ts( &( transport_channels_f[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); - mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + mvr2r( RealBuffer, &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + mvr2r( ImagBuffer, &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + } +#if defined( FIX_835_PARAMMC_BUFFER_VALUES ) && !defined( OBJ_EDITING_API ) + } +#endif } - } #ifndef OBJ_EDITING_API - if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) - { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); - } + if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } #endif - } + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], + &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + is_next_band ? cx_next_band : cx, + is_next_band ? cx_imag_next_band : cx_imag, + param_band_idx + is_next_band, +#else + cx, + cx_imag, +#endif + hParamMC, + nchan_transport ); +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + } +#endif + } +#endif + } + #ifndef OBJ_EDITING_API - /* map from complex input covariance to real values */ + /* map from complex input covariance to real values */ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } +#else for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) { - /* Cx for transport channels */ - for ( i = 0; i < nchan_transport * nchan_transport; i++ ) - { +#endif + /* Cx for transport channels */ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + pCx = is_next_band ? &cx_next_band[0] : &cx[0]; + pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; +#endif + for ( i = 0; i < nchan_transport * nchan_transport; i++ ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + real_part = pCx[i]; + imag_part = pCx_imag[i]; +#else real_part = cx[param_band_idx][i]; imag_part = cx_imag[param_band_idx][i]; +#endif - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - if ( param_band_idx < hParamMC->max_param_band_abs_cov ) - { + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ + if ( param_band_idx < hParamMC->max_param_band_abs_cov ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); +#else cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); - } - else - { +#endif + } + else + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + pCx[i] = real_part; +#else cx[param_band_idx][i] = real_part; +#endif + } } } - } - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ - if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) - { + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) + { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); + mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); +#else for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) { v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); } - } - +#endif + } - /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) + { + if ( is_next_band && skip_next_band ) + { + continue; + } +#endif + /* generate mixing matrices */ + ivas_param_mc_get_mixing_matrices( hParamMC, + hSynthesisOutputSetup, +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + is_next_band ? cx_next_band : cx, + param_band_idx + is_next_band, +#else + cx, +#endif + hParamMC->h_output_synthesis_cov_state.mixing_matrix, + hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, + nchan_out_transport, + hParamMC->synthesis_conf, + nchan_transport, + nchan_out_cov ); +#ifdef FIX_835_PARAMMC_BUFFER_VALUES + } + } +#endif #endif pop_wmops(); @@ -1562,6 +1672,7 @@ void ivas_param_mc_dec_prepare_renderer( ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); + #ifdef FIX_835_PARAMMC_BUFFER_VALUES /* loop over two bands at a time */ for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) @@ -1573,133 +1684,134 @@ void ivas_param_mc_dec_prepare_renderer( set_zero( cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); +#else + for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) + { + set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); + } +#endif /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } - +#endif ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], +#ifdef FIX_835_PARAMMC_BUFFER_VALUES is_next_band ? cx_next_band : cx, is_next_band ? cx_imag_next_band : cx_imag, param_band_idx + is_next_band, +#else + cx, + cx_imag, +#endif hParamMC, nchan_transport ); +#ifdef FIX_835_PARAMMC_BUFFER_VALUES } +#endif } } + /* map from complex input covariance to real values */ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } - +#else + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) + { +#endif + /* Cx for transport channels */ +#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx = is_next_band ? &cx_next_band[0] : &cx[0]; pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0]; - +#endif for ( i = 0; i < nchan_transport * nchan_transport; i++ ) { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES real_part = pCx[i]; imag_part = pCx_imag[i]; +#else + real_part = cx[param_band_idx][i]; + imag_part = cx_imag[param_band_idx][i]; +#endif + /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ if ( param_band_idx < hParamMC->max_param_band_abs_cov ) { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx[i] = sqrtf( real_part * real_part + imag_part * imag_part ); +#else + cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); +#endif } else { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES pCx[i] = real_part; +#else + cx[param_band_idx][i] = real_part; +#endif } } } - + /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) { +#ifdef FIX_835_PARAMMC_BUFFER_VALUES v_add( cx, cx_next_band, cx, nchan_transport * nchan_transport ); mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); +#else + for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) + { + v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); + mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); } +#endif + } + +#ifdef FIX_835_PARAMMC_BUFFER_VALUES for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) { continue; } - +#endif /* generate mixing matrices */ ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, +#ifdef FIX_835_PARAMMC_BUFFER_VALUES is_next_band ? cx_next_band : cx, param_band_idx + is_next_band, +#else + cx, +#endif hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); +#ifdef FIX_835_PARAMMC_BUFFER_VALUES } } -#else - for ( param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++ ) - { - set_zero( cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - set_zero( cx_imag[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - } - - /* slot loop for gathering the input data */ - for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) - { - if ( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) - { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], cx, cx_imag, hParamMC, nchan_transport ); - } - } - - /* map from complex input covariance to real values */ - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) - { - /* Cx for transport channels */ - for ( i = 0; i < nchan_transport * nchan_transport; i++ ) - { - real_part = cx[param_band_idx][i]; - imag_part = cx_imag[param_band_idx][i]; - - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - if ( param_band_idx < hParamMC->max_param_band_abs_cov ) - { - cx[param_band_idx][i] = sqrtf( real_part * real_part + imag_part * imag_part ); - } - else - { - cx[param_band_idx][i] = real_part; - } - } - } - - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ - if ( hParamMC->hMetadataPMC->bAttackPresent && ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) ) - { - for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) - { - v_add( cx[param_band_idx], cx[param_band_idx + 1], cx[param_band_idx], nchan_transport * nchan_transport ); - mvr2r( cx[param_band_idx], cx[param_band_idx + 1], nchan_transport * nchan_transport ); - } - } - - - /* generate mixing matrices */ - ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); #endif pop_wmops(); @@ -1708,6 +1820,7 @@ void ivas_param_mc_dec_prepare_renderer( } #endif + /*------------------------------------------------------------------------- * ivas_param_mc_dec_render() * -- GitLab From aef5f5a854de045751344d4079a95533071144c0 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 28 Aug 2024 14:38:08 +0200 Subject: [PATCH 127/130] [cleanup] align with main, mostly whitespace changes --- apps/decoder.c | 2 ++ lib_dec/ivas_ism_param_dec.c | 8 ++++---- lib_dec/ivas_mc_param_dec.c | 14 +++++++++----- lib_dec/ivas_stat_dec.h | 1 + lib_dec/lib_dec.c | 10 ++++++---- lib_rend/ivas_objectRenderer_sources.c | 1 + 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 4afa6f1129..5eb6d9f16f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -158,6 +158,7 @@ typedef struct #ifdef OBJ_EDITING_EXAMPLE bool objEditEnabled; #endif + } DecArguments; @@ -3195,6 +3196,7 @@ static ivas_error decodeVoIP( #ifdef OBJ_EDITING_API nSamplesRendered = 0; #endif + /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 5867b2adcb..b4a37dddf6 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -818,10 +818,8 @@ void ivas_param_ism_dec_digest_tc( ) { #ifndef OBJ_EDITING_API - int16_t ch, nchan_transport; - int16_t slot_idx; - int16_t nchan_out, nchan_out_woLFE, i; - int16_t bin_idx; + int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; + int16_t slot_idx, bin_idx; int32_t ivas_total_brate; #else int16_t ch, nchan_transport; @@ -1420,6 +1418,7 @@ void ivas_param_ism_dec_render( * * *-------------------------------------------------------------------------*/ + void ivas_param_ism_params_to_masa_param_mapping( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -1493,6 +1492,7 @@ void ivas_param_ism_params_to_masa_param_mapping( { brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; brange[1] = hParamIsmDec->hParamIsm->band_grouping[band_idx + 1]; + #ifdef OBJ_EDITING_API azimuth[0] = (int16_t) roundf( hParamIsmDec->edited_azimuth_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); elevation[0] = (int16_t) roundf( hParamIsmDec->edited_elevation_values[hParamIsmDec->hParamIsm->obj_indices[band_idx][0][0]] ); diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index ea71148171..8b26bfbaba 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1331,16 +1331,20 @@ void ivas_param_mc_dec_digest_tc( ) { PARAM_MC_DEC_HANDLE hParamMC; - int16_t ch; +#ifdef OBJ_EDITING_API + int16_t ch, slot_idx; + int16_t nchan_transport; +#else + int16_t i, ch; #ifdef FIX_835_PARAMMC_BUFFER_VALUES int16_t is_next_band, skip_next_band; #endif - int16_t slot_idx; - int16_t nchan_transport; + int16_t slot_idx, param_band_idx; + int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb; + int16_t nchan_out_cov; +#endif #ifndef OBJ_EDITING_API - int16_t nchan_out_transport, nchan_out_cldfb, i, param_band_idx; - int16_t nchan_out_cov; /*CLDFB*/ #ifdef FIX_835_PARAMMC_BUFFER_VALUES float *pCx, *pCx_imag; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index e9dde1bdaa..c7d03b3fc2 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -951,6 +951,7 @@ typedef struct ivas_masa_ism_data_structure float preprocEneTarget[CLDFB_NO_CHANNELS_MAX]; float preprocEneRealized[CLDFB_NO_CHANNELS_MAX]; #endif + float **delayBuffer; int16_t delayBuffer_size; int16_t delayBuffer_nchan; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 473286a2f2..ea548cf58b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1426,14 +1426,16 @@ ivas_error IVAS_DEC_GetSamples( ) { ivas_error error; +#ifdef OBJ_EDITING_API int16_t nSamplesToRender; uint16_t nSamplesRendered, nSamplesRendered_loop; uint8_t nOutChannels; -#ifndef OBJ_EDITING_API - uint8_t nTransportChannels; - int16_t nOutSamplesElse; - uint16_t nTimeScalerOutSamples, l_ts; +#else + int16_t nOutSamplesElse, nSamplesToRender; + uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts, nTimeScalerOutSamples; + uint8_t nTransportChannels, nOutChannels; #endif + nSamplesRendered = 0; nOutChannels = 0; nSamplesRendered_loop = 0; diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 4ccafbc6dc..3276d65d1f 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -632,6 +632,7 @@ static float TDREND_SRC_SPATIAL_GetDirGain( return DirGain; } + /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_GetDistGain() * -- GitLab From a987c5f1fd5cf4ef2fe547f03399a83513033e78 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 29 Aug 2024 13:49:06 +0200 Subject: [PATCH 128/130] do not limit edited object gains in the TD renderer --- lib_rend/ivas_objectRenderer_sources.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 3276d65d1f..4f570e6182 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -145,15 +145,7 @@ ivas_error TDREND_MIX_SRC_SetGain( const float Gain /* i : Gain */ ) { - /* Value verification */ - if ( !( Gain >= 0.0f && Gain <= 2.0f ) ) - { - return ( IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Gain out of range. Command is ignored!\n" ) ); - } - else - { - TDREND_SRC_SPATIAL_SetGain( hBinRendererTd->Sources[SrcInd], Gain ); - } + TDREND_SRC_SPATIAL_SetGain( hBinRendererTd->Sources[SrcInd], Gain ); return IVAS_ERR_OK; } -- GitLab From 7180a139055aaf3c5c0a2d78992f20b65d6fab1b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 30 Aug 2024 10:26:41 +0200 Subject: [PATCH 129/130] fix compile errors with object-editing defines disabled --- lib_dec/ivas_objectRenderer_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 9eed9ca0a1..77d89242a9 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -195,8 +195,8 @@ ivas_error ivas_td_binaural_renderer_sf( return error; } } -#endif else +#endif { if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) { -- GitLab From 7ad3ee7504cc4af7e9ae61bdf0428fcf202cfebb Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 2 Sep 2024 17:11:36 +0200 Subject: [PATCH 130/130] [tryfix] missing line for timeScaling --- lib_dec/lib_dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index ea548cf58b..61ba65f590 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -968,6 +968,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( assert( nTimeScalerOutSamples <= APA_BUF ); nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; + hIvasDec->timeScalingDone = 1; } else { -- GitLab