From 5fae92c8be850607e78d3f77a8c9d9589d47f4de Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 May 2023 10:04:25 +0200 Subject: [PATCH 01/17] typo in comments --- lib_dec/lib_dec.c | 6 ++---- lib_dec/lib_dec.h | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 17c718bb48..a8689a5bf8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -535,8 +535,8 @@ ivas_error IVAS_DEC_Configure( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ + const uint16_t speedFac, /* i : speed factor for variable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ @@ -557,11 +557,9 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; hIvasDec->Opt_VOIP = 1; - #ifdef JBM_TSM_ON_TCS hDecoderConfig->voip_active = 1; #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index fd8735dda6..8151f581c5 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -266,8 +266,8 @@ ivas_error IVAS_DEC_VoIP_Flush( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ + const uint16_t speedFac, /* i : speed factor for variable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ -- GitLab From d1648520de1bf46db7f2495a2f34053bb1dd1b7a Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 May 2023 09:53:43 +0200 Subject: [PATCH 02/17] VARIABLE_SPEED_DECODING: formal improvements --- apps/decoder.c | 4 +-- lib_com/ivas_prot.h | 4 +-- lib_dec/ivas_jbm_dec.c | 21 ++++++++++++--- lib_dec/ivas_objectRenderer_internal.c | 9 ++++--- lib_dec/lib_dec.c | 37 +++++++++++++++++++++++--- readme.txt | 2 ++ 6 files changed, 62 insertions(+), 15 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 9b6b856765..449e08223f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1010,7 +1010,7 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-VS" ) == 0 ) { i++; - int tmp = 100; + int32_t tmp = 100; arg->variableSpeedMode = true; if ( i < argc - 3 ) { @@ -1037,7 +1037,7 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-VOIP_FRAMESIZE" ) == 0 ) { i++; - int tmp; + int32_t tmp; if ( i < argc - 3 ) { if ( !is_digits_only( argv[i] ) ) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5d4faf0eb0..b832c03e70 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5715,10 +5715,10 @@ ivas_error ivas_td_binaural_renderer( ); #ifdef JBM_TSM_ON_TCS -void ObjRenderIVASSubframe( +ivas_error ivas_td_binaural_renderer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index f33a5e01e6..6c58e143bb 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -716,6 +716,7 @@ ivas_error ivas_jbm_dec_render( else /* ISM_MODE_DISC */ { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + /* Loudspeaker or Ambisonics rendering */ if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -731,7 +732,9 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -834,7 +837,11 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); } } @@ -995,7 +1002,9 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Binaural rendering */ if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + { + return error; } else if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -1050,7 +1059,11 @@ ivas_error ivas_jbm_dec_flush_renderer( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 873c75938a..ff65660697 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -85,16 +85,17 @@ ivas_error ivas_td_binaural_renderer( #ifdef JBM_TSM_ON_TCS /*---------------------------------------------------------------------* - * ObjRenderIVASFrame() + * ivas_td_binaural_renderer_sf() * * Receives the current frames for the object streams, updates metadata * and renders the current frame. *---------------------------------------------------------------------*/ -void ObjRenderIVASSubframe( +ivas_error ivas_td_binaural_renderer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t n_samples_asked ) + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ +) { int16_t first_sf, last_sf, subframe_idx; float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -116,7 +117,7 @@ void ObjRenderIVASSubframe( } slot_size = st_ivas->hTcBuffer->n_samples_granularity; /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_asked / slot_size ); + slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_granularity / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; st_ivas->hTcBuffer->slots_rendered += slots_to_render; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a8689a5bf8..99c6c20e01 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1889,6 +1889,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_VS_FRAME_NEEDED; } #endif + #ifdef JBM_TSM_ON_TCS if ( hVoIP->nSamplesAvailableNext == 0 ) { @@ -1907,6 +1908,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; dataUnit = NULL; + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) { @@ -1966,6 +1968,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef VARIABLE_SPEED_DECODING } #endif + /* decode */ if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { @@ -2060,6 +2063,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hVoIP->lastDecodedWasActive = 1; } #endif + /* limit scale to range supported by time scaler */ if ( scale < APA_MIN_SCALE ) { @@ -3195,14 +3199,30 @@ static ivas_error input_format_API_to_internal( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS -static int16_t IVAS_DEC_VoIP_GetRenderGranularity( Decoder_Struct *st_ivas ) +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetRenderGranularity() + * + * + *---------------------------------------------------------------------*/ + +static int16_t IVAS_DEC_VoIP_GetRenderGranularity( + Decoder_Struct *st_ivas ) { return st_ivas->hTcBuffer->n_samples_granularity; } -static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasDec ) + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetRendererConfig() + * + * + *---------------------------------------------------------------------*/ + +static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( + IVAS_DEC_HANDLE hIvasDec ) { JBM_RENDERER_TYPE rendererType; rendererType = JBM_RENDERER_NONE; @@ -3219,7 +3239,17 @@ static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasD return rendererType; } -ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ) + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_reconfigure() + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_VoIP_reconfigure( + IVAS_DEC_HANDLE hIvasDec, + const uint16_t nTransportChannels, + const uint16_t l_ts ) { IVAS_DEC_VOIP *hVoIP; @@ -3240,6 +3270,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n #else startQuality = 1.0f; #endif + /* get current renderer type*/ hVoIP->rendererType = IVAS_DEC_VoIP_GetRendererConfig( hIvasDec ); hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; diff --git a/readme.txt b/readme.txt index 21a5a19e79..5660aa353f 100644 --- a/readme.txt +++ b/readme.txt @@ -245,6 +245,8 @@ Options: The decoder may read rtpdump files containing TS26.445 Annex A.2.2 EVS RTP Payload Format. The SDP parameter hf_only is required. Reading RFC4867 AMR/AMR-WB RTP payload format is not supported. +-VS fac : Varaible Speed mode: change speed of playout fac as integer in percent. + fac<100 faster, fac>100 slower -Tracefile TF : VoIP mode: Generate trace file named TF -fec_cfg_file : Optimal channel aware configuration computed by the JBM as described in Section 6.3.1 of TS26.448. The output is -- GitLab From b3a3a4fe3d64bed8ee85e6f1f5962d7c77e5e9a9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 May 2023 12:30:31 +0200 Subject: [PATCH 03/17] JBM_TSM_ON_TCS: formal improvements --- Workspace_msvc/lib_com.vcxproj | 2 +- Workspace_msvc/lib_debug.vcxproj | 2 +- Workspace_msvc/lib_dec.vcxproj | 2 +- Workspace_msvc/lib_enc.vcxproj | 2 +- Workspace_msvc/lib_rend.vcxproj | 2 +- lib_com/ivas_prot.h | 125 +++++++++++++------------- lib_dec/ivas_jbm_dec.c | 145 ++++++++++++++++++++++++++----- 7 files changed, 192 insertions(+), 88 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index bfe36b1f48..23aa2ae3f0 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -78,7 +78,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 9b7b580661..3b648fae04 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -73,7 +73,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) false diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 760621d7a4..80910aa5e7 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_rend;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index d9f8e974f0..3378ac10f0 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 4bd0ca9a93..865652649a 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index b832c03e70..363b0ca4e3 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -263,11 +263,11 @@ uint32_t ivas_syn_output( #ifdef JBM_TSM_ON_TCS void ivas_syn_output_f( - float *synth[], /* i/o: float synthesis signal */ - const int16_t output_frame, /* i : output frame length (one channel) */ - const int16_t n_channels, /* i : number of output channels */ - float *synth_out /* o : integer 16 bits synthesis signal */ - ); + float *synth[], /* i/o: float synthesis signal */ + const int16_t output_frame, /* i : output frame length (one channel) */ + const int16_t n_channels, /* i : number of output channels */ + float *synth_out /* o : integer 16 bits synthesis signal */ +); #endif void ivas_initialize_handles_enc( @@ -312,10 +312,10 @@ ivas_error ivas_dec( ivas_error ivas_dec_setup( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - #ifdef JBM_TSM_ON_TCS +#ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : flushed PCM samples */ + uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ + int16_t *data /* o : flushed PCM samples */ #endif ); @@ -759,102 +759,107 @@ void dtx_read_padding_bits( const int16_t num_bits ); + #ifdef JBM_TSM_ON_TCS /*----------------------------------------------------------------------------------* * JBM prototypes *----------------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : output synthesis signal */ ); ivas_error ivas_jbm_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of samples wanted */ - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ - int16_t *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of samples wanted */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ + int16_t *data /* o : output synthesis signal */ ); ivas_error ivas_jbm_dec_flush_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - const MC_MODE mc_mode_old, /* i : old MC mode */ - const ISM_MODE ism_mode_old, /* i : old ISM mode */ - uint16_t *nSamplesRendered, /* o : number of samples flushed */ - int16_t *data /* o : rendered samples */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t tc_granularity_new, /* i : new renderer granularity */ + const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ + const AUDIO_CONFIG intern_config_old, /* i : old internal config */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ + const MC_MODE mc_mode_old, /* i : old MC mode */ + const ISM_MODE ism_mode_old, /* i : old ISM mode */ + uint16_t *nSamplesRendered, /* o : number of samples flushed */ + int16_t *data /* o : rendered samples */ ); ivas_error ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i: : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i/o: transport channels/output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i/o: transport channels/output synthesis signal */ ); ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); void ivas_jbm_dec_get_adapted_linear_interpolator( - const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ - const int16_t interp_length, /* i : length of the interpolator to be created */ - float *interpolator /* o : the interpolator */ + const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ + const int16_t interp_length, /* i : length of the interpolator to be created */ + float *interpolator /* o : the interpolator */ ); void ivas_jbm_dec_get_adapted_subframes( - const int16_t nCldfbTs, /* i : number of time slots in the current frame */ - int16_t *subframe_nbslots, /* i/o: subframe grid */ - int16_t *nb_subframes /* i/o: number of subframes in the frame */ + const int16_t nCldfbTs, /* i : number of time slots in the current frame */ + int16_t *subframe_nbslots, /* i/o: subframe grid */ + int16_t *nb_subframes /* i/o: number of subframes in the frame */ ); void ivas_jbm_dec_get_md_map( - const int16_t default_len, /* i : default frame length in metadata slots */ - const int16_t len, /* i : length of the modfied frames in metadata slots */ - const int16_t subframe_len, /* i : default length of a subframe */ - const int16_t offset, /* i : current read offset into the md buffer */ - const int16_t buf_len, /* i : length of the metadata buffer */ - int16_t *map /* o : metadata index map */ + const int16_t default_len, /* i : default frame length in metadata slots */ + const int16_t len, /* i : length of the modfied frames in metadata slots */ + const int16_t subframe_len, /* i : default length of a subframe */ + const int16_t offset, /* i : current read offset into the md buffer */ + const int16_t buf_len, /* i : length of the metadata buffer */ + int16_t *map /* o : metadata index map */ ); -int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ); /* i : IVAS decoder handle */ +int16_t ivas_jbm_dec_get_num_tc_channels( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +); TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -int16_t ivas_jbm_dec_get_render_granularity( /* o : render granularity */ - const RENDERER_TYPE rendererType, /* i : renderer type */ - const int32_t output_Fs /* i : sampling rate */ +/*! r: render granularity */ +int16_t ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const int32_t output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const int16_t nchan_transport_jbm, /* i : number of real transport channels */ - const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ + const int16_t nchan_transport_jbm, /* i : number of real transport channels */ + const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ + const int16_t nchan_full, /* i : nubmer of channels to fully store */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ + const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ + const int16_t nchan_full, /* i : new number of channels to fully store */ + const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ); void ivas_jbm_dec_tc_buffer_close( - DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ + DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); + void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6c58e143bb..1105b42e71 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -51,15 +51,18 @@ /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ + static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); + static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc() * - * Principal IVAS decoder routine, decoding of metadata and transport channels + * Principal IVAS JBM decoder routine, decoding of metadata and transport channels *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : transport channel signal */ @@ -535,10 +538,11 @@ ivas_error ivas_jbm_dec_tc( return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_feed_tc_to_renderer() * - * Feed decoded transport channels and metadata to the IVAS renderer routine + * Feed decoded transport channels and metadata to the IVAS JBM renderer routine *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_feed_tc_to_renderer( @@ -623,8 +627,9 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( /*--------------------------------------------------------------------------* * ivas_dec_render() * - * Principal IVAS rendering routine + * Principal IVAS JBM rendering routine *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of samples wanted */ @@ -633,7 +638,6 @@ ivas_error ivas_jbm_dec_render( int16_t *data /* o : output synthesis signal */ ) { - int16_t n, nchan_out; int16_t nchan_transport; float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ /* IVAS_fmToDo: buffer can be allocated dynamically based on the actual number of output channels */ @@ -658,6 +662,7 @@ ivas_error ivas_jbm_dec_render( nchan_transport = st_ivas->hTcBuffer->nchan_transport_jbm; output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { p_output[n] = &output[n][0]; @@ -820,6 +825,7 @@ ivas_error ivas_jbm_dec_render( { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -851,8 +857,6 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - - /* Rendering */ int16_t offset = st_ivas->hDirAC->slots_rendered * st_ivas->hDirAC->slot_size; nchan_remapped = st_ivas->nchan_transport; @@ -864,7 +868,6 @@ ivas_error ivas_jbm_dec_render( { ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* we still need to copy the separate channel if available */ @@ -906,8 +909,10 @@ ivas_error ivas_jbm_dec_render( * - compensation for saturation * - float to integer conversion *----------------------------------------------------------------*/ + st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered; st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered; + if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) { for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) @@ -937,6 +942,7 @@ ivas_error ivas_jbm_dec_render( * * Flush samples if renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ @@ -970,7 +976,8 @@ ivas_error ivas_jbm_dec_flush_renderer( assert( n_samples_still_available < tc_granularity_new ); if ( n_slots_still_available ) { - int ch_idx; + int16_t ch_idx; + /* render what is still there with zero padding */ for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -979,6 +986,7 @@ ivas_error ivas_jbm_dec_flush_renderer( set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); mvr2r( hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_rendered + n_samples_to_render, hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_granularity, n_samples_still_available ); } + /* simple change of the slot info */ hTcBuffer->num_slots = 1; hTcBuffer->nb_subframes = 1; @@ -1010,7 +1018,9 @@ ivas_error ivas_jbm_dec_flush_renderer( { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set_f( st_ivas->hIsmRendererData->interpolator, 1.0f, hTcBuffer->n_samples_granularity ); + ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, @@ -1055,6 +1065,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) @@ -1064,6 +1075,7 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } } @@ -1095,6 +1107,7 @@ ivas_error ivas_jbm_dec_flush_renderer( * * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) @@ -1113,9 +1126,11 @@ ivas_error ivas_jbm_dec_set_discard_samples( /* set last subframes number to max to ensure correct continuation */ st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; } + return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * @@ -1154,13 +1169,17 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( { set_f( interpolator, 0.0f, idx + 1 ); } + + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_subframes() * * Get an interpolator that is adapted to time scale modified IVAS frame *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_adapted_subframes( const int16_t nCldfbTs, /* i : number of time slots in the current frame */ int16_t *subframe_nbslots, /* i/o: subframe grid */ @@ -1169,6 +1188,7 @@ void ivas_jbm_dec_get_adapted_subframes( { uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; 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) */ nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); @@ -1178,10 +1198,13 @@ void ivas_jbm_dec_get_adapted_subframes( *nb_subframes = 1; nCldfbSlotsLocal -= nSlotsInFirstSubframe; } + *nb_subframes += (int16_t) ceilf( (float) nCldfbSlotsLocal / (float) PARAM_MC_MAX_NSLOTS_IN_SUBFRAME ); nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; + set_s( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); + if ( nSlotsInFirstSubframe > 0 ) { subframe_nbslots[0] = nSlotsInFirstSubframe; @@ -1190,14 +1213,17 @@ void ivas_jbm_dec_get_adapted_subframes( { subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; } + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * * Get an meta data map adapted to a time scale modified IVAS frame *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_md_map( const int16_t default_len, /* i : default frame length in metadata slots */ const int16_t len, /* i : length of the modfied frames in metadata slots */ @@ -1209,19 +1235,19 @@ void ivas_jbm_dec_get_md_map( { int16_t jbm_segment_len, map_idx, src_idx, src_idx_map; float dec, src_idx_f; + #ifdef DEBUGGING assert( default_len % 2 == 0 ); #endif - jbm_segment_len = ( default_len >> 1 ); dec = 1.0f / default_len; - for ( map_idx = len - 1, src_idx = default_len - 1; map_idx >= jbm_segment_len; map_idx--, src_idx-- ) { src_idx_map = max( 0, src_idx / subframe_len ); map[map_idx] = ( offset + src_idx_map ) % buf_len; } + /* changed part (first segment), interpolate index to parameters (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ if ( src_idx >= 0 ) @@ -1239,14 +1265,20 @@ void ivas_jbm_dec_get_md_map( { set_s( map, offset, map_idx + 1 ); } + + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_num_tc_channels() * * Get the number of transport channels provided by the JBM transport channel decode function *--------------------------------------------------------------------------*/ -int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ) /* i : IVAS decoder handle */ + +int16_t ivas_jbm_dec_get_num_tc_channels( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +) { int16_t num_tc; int32_t ivas_total_brate; @@ -1342,12 +1374,14 @@ int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ) /* i : IVAS return num_tc; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_tc() * * Copy interleaved transport chnannels to the correct buffers, update the TC * buffer handle *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ @@ -1362,7 +1396,6 @@ void ivas_jbm_dec_copy_tc( int16_t n_ch_full_copy; int16_t n_ch_res_copy; - hTcBuffer = st_ivas->hTcBuffer; n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; @@ -1393,12 +1426,22 @@ void ivas_jbm_dec_copy_tc( } } hTcBuffer->n_samples_rendered = 0; + return; } -int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, - const int32_t output_Fs ) +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_render_granularity() + * + * + *--------------------------------------------------------------------------*/ + +/*! r: render granularity */ +int16_t ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const int32_t output_Fs /* i : sampling rate */ +) { int16_t render_granularity; @@ -1414,11 +1457,13 @@ int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, return render_granularity; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() * - * open and initialize the transport channel buffer + * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc_buffer_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ @@ -1443,8 +1488,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } + hTcBuffer->tc_buffer_mode = tc_buffer_mode; hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; hTcBuffer->nchan_transport_internal = nchan_transport_internal; @@ -1478,11 +1524,16 @@ ivas_error ivas_jbm_dec_tc_buffer_open( int16_t n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); int16_t n_samp_residual = hTcBuffer->n_samples_granularity - 1; int32_t offset; + nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ); + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; @@ -1500,14 +1551,17 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } st_ivas->hTcBuffer = hTcBuffer; + return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_reconfigure() * - * open and initialize the transport channel buffer + * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc_buffer_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ @@ -1574,7 +1628,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( n_samp_residual = hTcBuffer->n_samples_granularity - 1; nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ); + + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) @@ -1595,7 +1654,14 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( return error; } -void ivas_jbm_dec_tc_buffer_playout( + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_playout() + * + * + *--------------------------------------------------------------------------*/ + +static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, @@ -1605,6 +1671,7 @@ void ivas_jbm_dec_tc_buffer_playout( int16_t ch_idx, slot_size, slots_to_render, first_sf, last_sf; slot_size = st_ivas->hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, nSamplesAsked / slot_size ); st_ivas->hTcBuffer->slots_rendered += slots_to_render; @@ -1622,8 +1689,17 @@ void ivas_jbm_dec_tc_buffer_playout( } st_ivas->hTcBuffer->subframes_rendered = last_sf; + + return; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_close() + * + * Close JBM transport channel buffer + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) @@ -1645,20 +1721,31 @@ void ivas_jbm_dec_tc_buffer_close( free( *phTcBuffer ); *phTcBuffer = NULL; } + return; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_td_renderers_adapt_subframes() + * + * Close JBM transport channel buffer + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas ) + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { 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; 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; nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; st_ivas->hTcBuffer->nb_subframes = 0; + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->nb_subframes = 1; @@ -1668,19 +1755,32 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; set_s( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes ); + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; } + if ( nSlotsInLastSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; } + st_ivas->hTcBuffer->slots_rendered = 0; st_ivas->hTcBuffer->subframes_rendered = 0; + + return; } -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas ) +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_tc_buffer_mode() + * + * + *--------------------------------------------------------------------------*/ + +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_BUFFER; @@ -1749,7 +1849,6 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas ) #endif } - return buffer_mode; } #endif -- GitLab From 54e9ced6fe82b6b7f563f9e92c48ecc8f4edff90 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 May 2023 18:30:44 +0200 Subject: [PATCH 04/17] formal issues within JBM_TSM_ON_TCS --- apps/decoder.c | 20 +--- lib_com/fd_cng_com.c | 2 +- lib_com/ivas_cnst.h | 1 + lib_com/ivas_prot.h | 22 ++-- lib_com/ivas_td_decorr.c | 2 +- lib_dec/fd_cng_dec.c | 2 - lib_dec/ivas_binRenderer_internal.c | 14 ++- lib_dec/ivas_dirac_dec.c | 41 +++++-- lib_dec/ivas_dirac_output_synthesis_cov.c | 15 ++- lib_dec/ivas_init_dec.c | 23 ++-- lib_dec/ivas_ism_dec.c | 13 ++- lib_dec/ivas_ism_dtx_dec.c | 1 + lib_dec/ivas_ism_param_dec.c | 112 ++++++++++++++----- lib_dec/ivas_ism_renderer.c | 11 +- lib_dec/ivas_jbm_dec.c | 98 ++++++---------- lib_dec/ivas_masa_dec.c | 6 +- lib_dec/ivas_mct_dec.c | 5 +- lib_dec/ivas_objectRenderer_internal.c | 28 ++++- lib_dec/ivas_out_setup_conversion.c | 2 +- lib_dec/ivas_sba_dec.c | 45 +++++++- lib_dec/ivas_sba_rendering_internal.c | 5 +- lib_dec/ivas_spar_decoder.c | 55 ++++++++- lib_dec/ivas_stat_dec.h | 13 ++- lib_dec/jbm_pcmdsp_apa.c | 4 +- lib_dec/lib_dec.c | 46 ++++++-- lib_dec/lib_dec.h | 18 +-- lib_rend/ivas_crend.c | 42 ++++--- lib_rend/ivas_dirac_dec_binaural_functions.c | 41 +++++-- lib_rend/ivas_objectRenderer.c | 3 +- lib_rend/ivas_prot_rend.h | 52 ++++----- lib_rend/ivas_rotation.c | 2 +- lib_rend/ivas_sba_rendering.c | 3 + lib_rend/lib_rend.c | 9 +- 33 files changed, 505 insertions(+), 251 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 449e08223f..b4a840b10c 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -84,7 +84,6 @@ static #endif #ifdef JBM_TSM_ON_TCS #define JBM_FRONTEND_FETCH_FRAMESIZE_MS 20 -#define FRAME_SIZE_NS 20000000L #endif typedef struct @@ -2574,6 +2573,7 @@ static ivas_error decodeVariableSpeed( #endif nSamplesAvailableNext = 0; nOutSamples = (int16_t) ( arg.output_Fs / 1000 * VARIABLE_SPEED_FETCH_FRAMESIZE_MS ); + /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data * - Read the bitstream packet @@ -2641,13 +2641,10 @@ static ivas_error decodeVariableSpeed( /* decode and get samples */ do { - error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, - pcmBuf, 0, - &nSamplesAvailableNext + error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, 0, &nSamplesAvailableNext #ifdef SUPPORT_JBM_TRACEFILE , - writeJbmTraceFileFrameWrapper, - jbmTraceWriter + writeJbmTraceFileFrameWrapper, jbmTraceWriter #endif ); if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED ) @@ -2746,7 +2743,6 @@ static ivas_error decodeVariableSpeed( } } - /* Write current frame */ if ( decodedGoodFrame ) { @@ -2833,6 +2829,7 @@ static ivas_error decodeVariableSpeed( /*------------------------------------------------------------------------------------------* * Flush what is still left in the VoIP Buffers.... *------------------------------------------------------------------------------------------*/ + while ( nSamplesAvailableNext > 0 ) { int16_t nSamplesFlushed; @@ -2893,25 +2890,19 @@ static ivas_error decodeVariableSpeed( } /* decode and get samples */ - if ( ( error = IVAS_DEC_VoIP_Flush( hIvasDec, nOutSamples, - pcmBuf, - &nSamplesAvailableNext, - &nSamplesFlushed ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesAvailableNext, &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - /* Write current frame */ - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); goto cleanup; } - /* Write ISm metadata to external file(s) */ if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) { @@ -2969,6 +2960,7 @@ static ivas_error decodeVariableSpeed( #endif } } + /*------------------------------------------------------------------------------------------* * Printouts after decoding has finished *------------------------------------------------------------------------------------------*/ diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 99ae9894f4..e31ce67d13 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -966,7 +966,6 @@ void SynthesisSTFT_dirac( mvr2r( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize ); set_f( olapBuffer + hFdCngCom->frameSize, 0.0f, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/ - for ( i = hFdCngCom->frameSize / 4; i < 3 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] += fftBuffer[i] * olapWin[i - hFdCngCom->frameSize / 4]; @@ -1009,6 +1008,7 @@ void SynthesisSTFT_dirac( } #endif + /*------------------------------------------------------------------- * mhvals() * diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index b5e3964319..9cd8475d41 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -219,6 +219,7 @@ typedef enum #define MAX_JBM_L_FRAME_NS 40000000L #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH #define MAX_CLDFB_DIGEST_CHANNELS 4 + typedef enum { TC_BUFFER_MODE_NONE = 0, diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 363b0ca4e3..32a6db03b6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -767,7 +767,7 @@ void dtx_read_padding_bits( ivas_error ivas_jbm_dec_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signal */ + float *data /* o : output synthesis signals */ ); ivas_error ivas_jbm_dec_render( @@ -841,7 +841,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ const int16_t nchan_transport_jbm, /* i : number of real transport channels */ const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ + const int16_t nchan_full, /* i : number of channels to fully store */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); @@ -1023,7 +1023,7 @@ ivas_error ivas_ism_dec_config( const ISM_MODE last_ism_mode /* i/o: last ISM mode */ #ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change */ + uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ int16_t *data /* o : flushed PCM samples */ #endif ); @@ -1044,7 +1044,7 @@ void ivas_param_ism_dec( #ifdef JBM_TSM_ON_TCS void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); void ivas_param_ism_dec_digest_tc( @@ -3462,7 +3462,7 @@ ivas_error ivas_sba_digest_tc( const int16_t nCldfbSlots, /* i : number of CLDFB slots */ const int16_t nSamplesForRendering, /* i : number of samples provided */ float *data[] /* i : transport channel samples */ - ); +); #endif void ivas_init_dec_get_num_cldfb_instances( @@ -3698,7 +3698,8 @@ void generate_masking_noise_lb_dirac( void ivas_dirac_dec_set_md_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ); + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +); void ivas_dirac_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -4581,7 +4582,7 @@ void ivas_spar_dec_agc_pca( void ivas_spar_dec_set_render_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs + const int16_t nCldfbTs /* i : number of CLDFB time slots */ ); void ivas_spar_dec_set_render_params( @@ -5304,8 +5305,9 @@ void ivas_binaural_cldfb( #ifdef JBM_TSM_ON_TCS void ivas_binaural_cldfb_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, + const int16_t n_samples_to_render, /* i : output frame length per channel */ float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + ); #endif @@ -5404,6 +5406,8 @@ void ivas_ism2sba_sf( const int16_t sba_order /* i : Ambisonic (SBA) order */ ); #endif + + /*----------------------------------------------------------------------------------* * Amplitude Panning VBAP prototypes *----------------------------------------------------------------------------------*/ @@ -5479,7 +5483,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - int16_t num_timeslots, /* i : number of time slots to process */ + const int16_t num_timeslots, /* i : number of time slots to process */ #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 9a08c06f6a..7714915177 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -480,7 +480,7 @@ static void ivas_td_decorr_APD_sections( void ivas_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr, /* i/o: SPAR Covar. decoder handle */ #ifdef JBM_TSM_ON_TCS - float *pcm_in[], + float *pcm_in[], /* i : input audio channels */ #else float pcm_in[][L_FRAME48k], /* i : input audio channels */ #endif diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 7f8eba27c0..8b62e54a8d 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1829,7 +1829,6 @@ void generate_masking_noise_lb_dirac( n_samples_out = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS * nCldfbTs; n_samples_start = 0; - /*LB CLDFB - CNA from STFT*/ #ifdef DEBUG_MODE_DIRAC { @@ -1951,7 +1950,6 @@ void generate_masking_noise_lb_dirac( return; } - #endif diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index bfe0a4bb53..5de5f881fa 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -997,17 +997,19 @@ void ivas_binaural_cldfb( return; } + + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------------* - * ivas_binaural_cldfb() + * ivas_binaural_cldfb_sf() * * Perform CLDFB analysis, fastconv binaural rendering and CLDFB synthesis *-------------------------------------------------------------------------*/ void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; @@ -1021,6 +1023,7 @@ void ivas_binaural_cldfb_sf( /* Implement a 5 msec loops */ maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); slot_size = st_ivas->hTcBuffer->nb_subframes; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; @@ -1028,6 +1031,7 @@ void ivas_binaural_cldfb_sf( slot_index_start = st_ivas->hTcBuffer->slots_rendered; slot_index_start_cldfb = 0; st_ivas->hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -1086,7 +1090,9 @@ void ivas_binaural_cldfb_sf( slot_index_start += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_index_start_cldfb += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; } + st_ivas->hTcBuffer->subframes_rendered = last_sf; + return; } #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 2801c9c146..51122aa40a 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2898,9 +2898,11 @@ void ivas_qmetadata_to_dirac( * * Set metadata index mapping for DirAC *------------------------------------------------------------------------*/ + void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) { int16_t num_slots_in_subfr; DIRAC_DEC_HANDLE hDirAC; @@ -2942,6 +2944,7 @@ void ivas_dirac_dec_set_md_map( { float tmp; int16_t sf_idx, slot_idx, slot_idx_abs; + slot_idx_abs = 0; for ( sf_idx = 0; sf_idx < hDirAC->nb_subframes; sf_idx++ ) { @@ -2953,17 +2956,20 @@ void ivas_dirac_dec_set_md_map( } hDirAC->render_to_md_map[sf_idx] = ( (int16_t) roundf( tmp / (float) hDirAC->subframe_nbslots[sf_idx] ) + hDirAC->dirac_read_idx ) % hDirAC->dirac_md_buffer_length; } + set_s( &hDirAC->render_to_md_map[hDirAC->nb_subframes], 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME - hDirAC->nb_subframes ); } return; } + /*------------------------------------------------------------------------- * ivas_dirac_dec() * * DirAC decoding process *------------------------------------------------------------------------*/ + void ivas_dirac_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ @@ -2982,17 +2988,21 @@ void ivas_dirac_dec( { output_f_local[n] = &output_f[n][0]; } + for ( n = 0; n < nchan_transport; n++ ) { st_ivas->hTcBuffer->tc[n] = output_f[n]; } + if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->sba_mode != SBA_MODE_SPAR ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; st_ivas->hTcBuffer->tc[nchan_transport] = &cng_td_buffer[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], DEFAULT_JBM_CLDFB_TIMESLOTS, st->cna_dirac_flag && st->flag_cna ); } + ivas_dirac_dec_set_md_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL ); @@ -3001,6 +3011,7 @@ void ivas_dirac_dec( output_f_local[n] += n_samples_sf; } } + if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % st_ivas->hDirAC->dirac_md_buffer_length; @@ -3021,13 +3032,20 @@ void ivas_dirac_dec( return; } + +/*------------------------------------------------------------------------- + * ivas_dirac_dec_render() + * + * DirAC decoding renderer process + *------------------------------------------------------------------------*/ + void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -3046,16 +3064,19 @@ void ivas_dirac_dec_render( output_f_local[ch] = output_f[ch]; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; last_sf++; } + #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif @@ -3079,16 +3100,20 @@ void ivas_dirac_dec_render( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; + return; } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec() * * DirAC decoding process *------------------------------------------------------------------------*/ + #ifndef JBM_TSM_ON_TCS void ivas_dirac_dec( #else diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 892cfe4acb..44a9d7e597 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -104,8 +104,12 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_in * nchan_in ); set_zero( h_dirac_output_synthesis_state->cy_old[idx], nchan_out * nchan_out ); set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); + #ifdef JBM_TSM_ON_TCS - h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ); + if ( ( h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); + } set_zero( h_dirac_output_synthesis_state->mixing_matrix[idx], nchan_out * nchan_in ); #endif } @@ -118,6 +122,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( h_dirac_output_synthesis_state->mixing_matrix[idx] = NULL; #endif } + for ( idx = 0; idx < num_param_bands_residual; idx++ ) { if ( ( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) @@ -125,8 +130,12 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); } set_zero( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx], nchan_out * nchan_out ); + #ifdef JBM_TSM_ON_TCS - h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ); + if ( ( h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); + } set_zero( h_dirac_output_synthesis_state->mixing_matrix_res[idx], nchan_out * nchan_out ); #endif } @@ -158,6 +167,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_cov_open() @@ -285,6 +295,7 @@ void ivas_dirac_dec_output_synthesis_cov_close( free( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] ); h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = NULL; } + #ifdef JBM_TSM_ON_TCS if ( h_dirac_output_synthesis_state->mixing_matrix[idx] != NULL ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ef9cbdf54b..5b20676539 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -680,6 +680,9 @@ ivas_error ivas_init_decoder( int16_t i, k, n; int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; +#ifdef JBM_TSM_ON_TCS + int16_t granularity, n_channels_transport_jbm; +#endif int32_t output_Fs, ivas_total_brate; int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; @@ -1334,13 +1337,13 @@ ivas_error ivas_init_decoder( return error; } } + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { - int16_t granularity; - int16_t n_channels_transport_jbm; granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; @@ -1379,13 +1382,13 @@ ivas_error ivas_init_decoder( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { - int16_t granularity; - int16_t n_channels_transport_jbm; granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; @@ -1414,6 +1417,7 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay *-----------------------------------------------------------------*/ + #ifdef MC_PARAMUPMIX_MODE if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) #else @@ -1489,15 +1493,21 @@ ivas_error ivas_init_decoder( } #ifdef JBM_TSM_ON_TCS + /*-----------------------------------------------------------------* + * Allocate and initialize JBM struct + buffer + *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ - int16_t n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } } + if ( st_ivas->hTcBuffer == NULL ) { /* we need the handle anyway, but without the buffer*/ @@ -1511,9 +1521,6 @@ ivas_error ivas_init_decoder( return error; } -#ifdef JBM_TSM_ON_TCS - -#endif /*------------------------------------------------------------------------- * destroy_core_dec() diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 5706261093..7414b19a3b 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -55,8 +55,8 @@ static ivas_error ivas_ism_bitrate_switching( const ISM_MODE last_ism_mode /* i : last ISM mode */ #ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, - int16_t *data + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + int16_t *data /* o : rendered samples */ #endif ) { @@ -66,7 +66,6 @@ static ivas_error ivas_ism_bitrate_switching( #ifdef FIX_416_ISM_BR_SWITCHING int16_t numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; #endif - #ifdef JBM_TSM_ON_TCS TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; @@ -151,9 +150,11 @@ static ivas_error ivas_ism_bitrate_switching( st_ivas->hTcBuffer->slots_rendered = st_ivas->hDirAC->slots_rendered; mvs2s( st_ivas->hDirAC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } + /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) @@ -316,6 +317,7 @@ static ivas_error ivas_ism_bitrate_switching( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_full_new; @@ -326,15 +328,18 @@ static ivas_error ivas_ism_bitrate_switching( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; tc_nchan_full_new = tc_nchan_allocate_new; } + if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { tc_nchan_full_new = 0; } + /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new ) @@ -344,6 +349,7 @@ static ivas_error ivas_ism_bitrate_switching( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hDirAC != NULL ) { @@ -351,6 +357,7 @@ static ivas_error ivas_ism_bitrate_switching( st_ivas->hDirAC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots; st_ivas->hDirAC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hDirAC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index b2bc737fa2..daf4b4b3ed 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -133,6 +133,7 @@ ivas_error ivas_ism_dtx_dec( ism_mode_bstr = (ISM_MODE) ( idx + 1 ); st_ivas->ism_mode = ism_mode_bstr; } + #ifdef JBM_TSM_ON_TCS if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, NULL ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 7e0f65a663..667ecd088c 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -157,6 +157,7 @@ static void ivas_ism_get_proto_matrix( return; } + #ifdef JBM_TSM_ON_TCS static void ivas_param_ism_collect_slot( DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -185,9 +186,11 @@ static void ivas_param_ism_collect_slot( ref_power[bin_idx] += tmp; } } + return; } + static void ivas_param_ism_compute_mixing_matrix( const int16_t nchan_ism, /* i : number of ISM channels */ DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -404,6 +407,7 @@ static void ivas_param_ism_compute_mixing_matrix( } #endif + #ifdef JBM_TSM_ON_TCS static void ivas_param_ism_render_slot( DIRAC_DEC_HANDLE hDirAC, @@ -822,9 +826,16 @@ ivas_error ivas_param_ism_dec_open( } else { - hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ); + if ( ( hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } set_zero( hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands ); - hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ); + + if ( ( hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } set_zero( hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands ); } if ( st_ivas->hTcBuffer == NULL ) @@ -1287,6 +1298,7 @@ void ivas_param_ism_dec( RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; } + #ifdef JBM_TSM_ON_TCS cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][slot_idx_start * hDirAC->num_freq_bands] ), hDirAC->num_freq_bands * hDirAC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); @@ -1325,21 +1337,29 @@ void ivas_param_ism_dec( } #ifdef JBM_TSM_ON_TCS + +/*-------------------------------------------------------------------------* + * ivas_ism_dec_digest_tc() + * + * + *-------------------------------------------------------------------------*/ + void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas ) + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - if ( - st_ivas->renderer_type == RENDERER_TD_PANNING || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || - 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->hDecoderConfig->Opt_Headrotation == 0 ) ) + if ( st_ivas->renderer_type == RENDERER_TD_PANNING || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || + 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->hDecoderConfig->Opt_Headrotation == 0 ) ) { int16_t i, num_objects; int16_t azimuth, elevation; + /* we have a full frame interpolator, adapt it */ /* for BE testing */ if ( ( st_ivas->hDecoderConfig->output_Fs / (int32_t) FRAMES_PER_SECOND ) == st_ivas->hTcBuffer->n_samples_available ) @@ -1372,6 +1392,7 @@ void ivas_ism_dec_digest_tc( for ( i = 0; i < num_objects; i++ ) { mvr2r( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->prev_gains[i], MAX_OUTPUT_CHANNELS ); + if ( st_ivas->intern_config == AUDIO_CONFIG_STEREO ) { ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, @@ -1384,15 +1405,15 @@ void ivas_ism_dec_digest_tc( // TODO tmu review when #215 is resolved azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hHeadTrackData == NULL ) { - - if ( st_ivas->hIntSetup.is_planar_setup ) { /* If no elevation support in output format, then rendering should be done with zero elevation */ elevation = 0; } + if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); @@ -1406,13 +1427,21 @@ void ivas_ism_dec_digest_tc( } } } + return; } + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_digest_tc() + * + * + *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ) { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; @@ -1422,7 +1451,6 @@ void ivas_param_ism_dec_digest_tc( 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]; - DIRAC_DEC_HANDLE hDirAC; /* Initialization */ @@ -1541,21 +1569,27 @@ void ivas_param_ism_dec_digest_tc( /* Compute mixing matrix */ ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hDirAC, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hDirAC->hParamIsmRendering->mixing_matrix_lin ); - pop_wmops(); return; } -static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, - IVAS_OUTPUT_SETUP hSetup, - const int16_t nchan_transport, - const int16_t nchan_out, - const int16_t nchan_out_woLFE, - float *output_f[] /* o : rendered time signal */ + +/*-------------------------------------------------------------------------* + * ivas_ism_param_dec_render_sf() + * + * + *-------------------------------------------------------------------------*/ + +static void ivas_ism_param_dec_render_sf( + Decoder_Struct *st_ivas, + IVAS_OUTPUT_SETUP hSetup, + const int16_t nchan_transport, + const int16_t nchan_out, + const int16_t nchan_out_woLFE, + float *output_f[] /* o : rendered time signal */ ) { - int16_t ch, slot_idx, i, index_slot; /* CLDFB Output Buffers */ float Cldfb_RealBuffer[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -1593,7 +1627,6 @@ static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, Cldfb_ImagBuffer_in[ch] = &hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc[index_slot * hDirAC->num_freq_bands * nchan_transport + ch * hDirAC->num_freq_bands]; } - /* Compute bandwise rendering to target LS using covariance rendering */ ivas_param_ism_render_slot( hDirAC, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirAC->hParamIsmRendering->mixing_matrix_lin, index_slot, slot_idx, @@ -1630,16 +1663,26 @@ static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, idx_in++; } } + hDirAC->slots_rendered += hDirAC->subframe_nbslots[subframe_idx]; hDirAC->subframes_rendered++; + + return; } + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_render() + * + * + *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t ch, slots_to_render, first_sf, last_sf, subframe_idx; @@ -1667,11 +1710,13 @@ void ivas_param_ism_dec_render( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; @@ -1680,10 +1725,12 @@ void ivas_param_ism_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif + for ( ch = 0; ch < nchan_out; ch++ ) { output_f_local[ch] = &output_f[ch][0]; } + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { ivas_ism_param_dec_render_sf( st_ivas, hSetup, nchan_transport, nchan_out, nchan_out_woLFE, output_f_local ); @@ -1693,6 +1740,7 @@ void ivas_param_ism_dec_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { /* copy the memories */ @@ -1714,10 +1762,11 @@ void ivas_param_ism_dec_render( st_ivas->hIsmMetaData[ch]->elevation = st_ivas->hDirAC->elevation_values[ch]; } } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; + return; } - #endif @@ -1766,6 +1815,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hDirAC->numSimultaneousDirections = 1; azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[0] ); elevation[0] = (int16_t) roundf( hDirAC->elevation_values[0] ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) @@ -1809,6 +1859,7 @@ void ivas_param_ism_params_to_masa_param_mapping( } } } + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) @@ -1825,6 +1876,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hDirAC->numSimultaneousDirections = 1; azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[0] ); elevation[0] = (int16_t) roundf( hDirAC->elevation_values[0] ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 95c153fc80..f9461f894b 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -109,6 +109,7 @@ ivas_error ivas_ism_renderer_open( st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 ); } #endif + return error; } @@ -233,6 +234,12 @@ void ivas_ism_render( } #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------------* + * ivas_ism_render_sf() + * + * Object rendering process + *-------------------------------------------------------------------------*/ + void ivas_ism_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: core-coder transport channels/object output */ @@ -263,6 +270,7 @@ void ivas_ism_render_sf( { /* Calculate rotation matrix from the quaternion */ QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[st_ivas->hHeadTrackData->num_quaternions++], Rmat ); + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); @@ -271,7 +279,6 @@ void ivas_ism_render_sf( for ( i = 0; i < num_objects; i++ ) { - /* Head rotation: rotate the object positions depending the head's orientation */ if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) { @@ -302,6 +309,7 @@ void ivas_ism_render_sf( output_f[j2][k] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ ); } } + /* update here only in case of head rotation */ if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) { @@ -309,6 +317,7 @@ void ivas_ism_render_sf( } } } + return; } #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1105b42e71..867dada3e0 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -65,7 +65,7 @@ static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint1 ivas_error ivas_jbm_dec_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : transport channel signal */ + float *data /* o : transport channel signals */ ) { int16_t n, output_frame, nchan_out; @@ -153,7 +153,6 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - // VE: call ivas_ism_metadata_dec() with 'st_ivas' - TBD if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) { return error; @@ -212,13 +211,7 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->hQMetaData != NULL ) { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - ivas_dirac_dec_read_BS( - ivas_total_brate, - st, - st_ivas->hDirAC, - st_ivas->hQMetaData, - &nb_bits_metadata[0], - st_ivas->sba_mode, + ivas_dirac_dec_read_BS( ivas_total_brate, st, st_ivas->hDirAC, st_ivas->hQMetaData, &nb_bits_metadata[0], st_ivas->sba_mode, #ifdef HODIRAC st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, #endif @@ -547,8 +540,8 @@ ivas_error ivas_jbm_dec_tc( ivas_error ivas_jbm_dec_feed_tc_to_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i: : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ float *data /* i : transport channels */ ) { @@ -741,20 +734,11 @@ ivas_error ivas_jbm_dec_render( { return error; } + } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - 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, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, st_ivas->hDecoderConfig, NULL, NULL, + NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -771,6 +755,7 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { nchan_remapped = nchan_transport; + /* Loudspeakers, Ambisonics or Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { @@ -810,18 +795,8 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, - st_ivas->hTcBuffer, - 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->hHeadTrackData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -967,6 +942,7 @@ ivas_error ivas_jbm_dec_flush_renderer( *nSamplesRendered = 0; hTcBuffer = st_ivas->hTcBuffer; + /* get number of possible slots in new granularity */ n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; n_slots_still_available = n_samples_still_available / tc_granularity_new; @@ -974,6 +950,7 @@ ivas_error ivas_jbm_dec_flush_renderer( n_samples_to_render = *nSamplesRendered; n_samples_still_available -= n_samples_to_render; assert( n_samples_still_available < tc_granularity_new ); + if ( n_slots_still_available ) { int16_t ch_idx; @@ -1014,6 +991,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { return error; } + } else if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ @@ -1021,21 +999,12 @@ ivas_error ivas_jbm_dec_flush_renderer( ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - 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, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, 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 ) { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, p_output, p_output ); } } @@ -1050,18 +1019,8 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - intern_config_old, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - 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->hHeadTrackData, hIntSetupOld, + st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -1102,6 +1061,7 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_set_discard_samples() * @@ -1157,6 +1117,7 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( { interpolator[idx] = max( 0.0f, interpolator[idx + 1] - dec ); } + if ( interpolator[idx + 1] > 0.0f ) { dec = interpolator[idx + 1] / ( jbm_segment_len + 1 ); @@ -1209,6 +1170,7 @@ void ivas_jbm_dec_get_adapted_subframes( { subframe_nbslots[0] = nSlotsInFirstSubframe; } + if ( nSlotsInLastSubframe > 0 ) { subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; @@ -1382,12 +1344,12 @@ int16_t ivas_jbm_dec_get_num_tc_channels( * buffer handle *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_copy_tc( +static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ int16_t *nSamplesResidual, /* o : number of samples that will be left for the next frame */ float *data, /* i : (interleaved) transport channel samples */ - float *tc_digest_f[] /* o : samples that will be directly digestest (eg. by CLDFB) */ + float *tc_digest_f[] /* o : samples that will be directly digested (e.g. by CLDFB) */ ) { int16_t ch; @@ -1413,6 +1375,7 @@ void ivas_jbm_dec_copy_tc( hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; } } + if ( n_ch_res_copy > 0 ) { for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) @@ -1425,6 +1388,7 @@ void ivas_jbm_dec_copy_tc( mvr2r( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); } } + hTcBuffer->n_samples_rendered = 0; return; @@ -1469,7 +1433,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ const int16_t nchan_transport_jbm, /* i : number of real transport channels */ const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ + const int16_t nchan_full, /* i : number of channels to fully store */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { @@ -1527,13 +1491,14 @@ ivas_error ivas_jbm_dec_tc_buffer_open( nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); - offset = 0; + offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; @@ -1619,8 +1584,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->nchan_buffer_full = nchan_full; nchan_residual = nchan_transport_internal - nchan_full; hTcBuffer->n_samples_granularity = n_samples_granularity; +#ifdef DEBUGGING /* what is remaining from last frames needs always be smaller than n_samples_granularity */ assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); +#endif /* realloc buffers */ free( hTcBuffer->tc_buffer ); @@ -1633,8 +1600,8 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -1678,11 +1645,13 @@ static void ivas_jbm_dec_tc_buffer_playout( *nSamplesRendered = (uint16_t) slots_to_render * slot_size; first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; last_sf++; } + for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { mvr2r( st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); @@ -1772,6 +1741,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_tc_buffer_mode() * diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 2c9fcbd008..2ce96b635c 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -411,11 +411,13 @@ ivas_error ivas_masa_dec_open( { int16_t nchan_to_allocate; TC_BUFFER_MODE buffer_mode; + buffer_mode = TC_BUFFER_MODE_RENDERER; if ( st_ivas->mc_mode == MC_MODE_MCMASA && ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) { buffer_mode = TC_BUFFER_MODE_BUFFER; } + nchan_to_allocate = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { @@ -1278,11 +1280,13 @@ ivas_error ivas_masa_dec_reconfigure( buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_nchan_to_allocate = tc_nchan_transport; if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } + if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -1292,6 +1296,7 @@ ivas_error ivas_masa_dec_reconfigure( } } #endif + return error; } @@ -1571,7 +1576,6 @@ void ivas_spar_param_to_masa_param_mapping( float slot_fac; #endif - /* Set values */ hDirAC = st_ivas->hDirAC; hDirAC->numSimultaneousDirections = 1; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 19a0909461..90b7496b62 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -927,7 +927,6 @@ static ivas_error ivas_mc_dec_reconfig( } #endif - if ( last_mc_mode == MC_MODE_MCT ) { if ( st_ivas->hMCT != NULL && st_ivas->nchan_transport <= CPE_CHANNELS ) @@ -1331,6 +1330,7 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_full_new; @@ -1350,6 +1350,7 @@ static ivas_error ivas_mc_dec_reconfig( { tc_nchan_full_new = 0; } + /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || @@ -1360,6 +1361,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hDirAC != NULL ) { @@ -1379,5 +1381,6 @@ static ivas_error ivas_mc_dec_reconfig( } } #endif + return error; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index ff65660697..bc4ad29025 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -83,6 +83,7 @@ ivas_error ivas_td_binaural_renderer( ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL, output, output_frame ); } + #ifdef JBM_TSM_ON_TCS /*---------------------------------------------------------------------* * ivas_td_binaural_renderer_sf() @@ -103,24 +104,31 @@ ivas_error ivas_td_binaural_renderer_sf( float *output_f_local[BINAURAL_CHANNELS]; float *tc_local[MAX_TRANSPORT_CHANNELS]; int16_t ch, slot_size, slots_to_render, output_frame; + ivas_error error; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_reverb_signal[ch] = reverb_signal[ch]; } + for ( ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { tc_local[ch] = st_ivas->hTcBuffer->tc[ch] + st_ivas->hTcBuffer->n_samples_rendered; } + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { output_f_local[ch] = output[ch]; } + slot_size = st_ivas->hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_granularity / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; st_ivas->hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -130,22 +138,28 @@ ivas_error ivas_td_binaural_renderer_sf( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { output_frame = st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] * st_ivas->hTcBuffer->n_samples_granularity; + /* Update object position(s) */ TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, tc_local ); /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, - st_ivas->hDecoderConfig->Opt_Headrotation, + TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[0] : NULL, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL ); if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) { - ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ); + if ( ( error = ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } /* Render subframe */ - TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0 ); + if ( ( error = TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ { @@ -156,16 +170,20 @@ ivas_error ivas_td_binaural_renderer_sf( v_add( reverb_signal[1], output_f_local[1], output_f_local[1], output_frame ); } } + for ( ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { tc_local[ch] += output_frame; } + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { output_f_local[ch] += output_frame; } } + st_ivas->hTcBuffer->subframes_rendered = last_sf; - return; + + return IVAS_ERR_OK; } #endif diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 3f95113f60..1d6db5eebf 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1161,7 +1161,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - int16_t num_timeslots, + const int16_t num_timeslots, #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 0dcaec91da..581262fc52 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -201,6 +201,7 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + #ifdef JBM_TSM_ON_TCS /* synchronize subframe info */ st_ivas->hSpar->num_slots = st_ivas->hTcBuffer->num_slots; @@ -291,6 +292,7 @@ ivas_error ivas_sba_dec_reconfigure( { return error; } + #ifdef JBM_TSM_ON_TCS /* synchronize subframe info */ st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots; @@ -377,8 +379,9 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_TSM_ON_TCS /*-----------------------------------------------------------------* - * TC buffer + * JBM TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_to_allocate; @@ -424,10 +427,17 @@ ivas_error ivas_sba_dec_reconfigure( } } #endif + return error; } #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------* + * ivas_sba_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + ivas_error ivas_sba_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nCldfbSlots, /* i : number of CLDFB slots */ @@ -445,22 +455,27 @@ ivas_error ivas_sba_dec_digest_tc( { ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); } + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } + if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { int16_t nSamplesLeftForTD, default_frame; float *decorr_signal[BINAURAL_CHANNELS]; float *p_tc[2 * BINAURAL_CHANNELS]; + default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx + BINAURAL_CHANNELS]; p_tc[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx]; } + while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); @@ -473,21 +488,30 @@ ivas_error ivas_sba_dec_digest_tc( nSamplesLeftForTD -= nSamplesToDecorr; } } + /* if we have a late CNG generation, do it here */ if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->sba_mode != SBA_MODE_SPAR ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); } + return error; } + +/*-------------------------------------------------------------------* + * ivas_sba_dec_render() + * + * + *-------------------------------------------------------------------*/ + void ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -503,7 +527,9 @@ void ivas_sba_dec_render( st_ivas->hDecoderConfig->ivas_total_brate #endif ); + nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + #ifdef DEBUGGING assert( hSpar ); #endif @@ -511,12 +537,15 @@ void ivas_sba_dec_render( { output_f_local[ch] = output_f[ch]; } + slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hSpar->num_slots - hSpar->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hSpar->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hSpar->subframe_nbslots[last_sf]; @@ -525,9 +554,11 @@ void ivas_sba_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { int16_t n_samples_sf = slot_size * hSpar->subframe_nbslots[subframe_idx]; + ivas_spar_dec_upmixer_sf( st_ivas, output_f_local, nchan_internal ); for ( ch = 0; ch < nchan_out; ch++ ) { @@ -539,6 +570,7 @@ void ivas_sba_dec_render( { ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); } + if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -550,6 +582,7 @@ void ivas_sba_dec_render( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + *nSamplesAvailable = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size; return; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 6d71f1f8b8..5fe6c91312 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -92,6 +92,7 @@ void ivas_sba2mc_cldfb( g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m]; p_realOut = realOut[n]; p_imagOut = imagOut[n]; + #ifdef JBM_TSM_ON_TCS for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) #else @@ -115,6 +116,7 @@ void ivas_sba2mc_cldfb( { p_realOut = realOut[n]; p_imagOut = imagOut[n]; + #ifdef JBM_TSM_ON_TCS for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) #else @@ -429,7 +431,6 @@ void ivas_sba_upmixer_renderer( const int16_t output_frame /* i : output frame length */ ) { - int16_t nchan_internal; #ifndef JBM_TSM_ON_TCS int16_t i; @@ -466,10 +467,12 @@ void ivas_sba_upmixer_renderer( #ifdef JBM_TSM_ON_TCS float *output_f[MAX_OUTPUT_CHANNELS]; int16_t ch; + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { output_f[ch] = output[ch]; } + ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); #else ivas_sba_linear_renderer( output, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index d1104594a1..6f70700113 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -213,6 +213,7 @@ ivas_error ivas_spar_dec_open( hSpar->subframes_rendered = 0; hSpar->slots_rendered = 0; hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; + /* init render timeslot mapping */ { int16_t map_idx; @@ -222,6 +223,7 @@ ivas_error ivas_spar_dec_open( hSpar->render_to_md_map[map_idx] = map_idx; } } + /* allocate transport channels*/ if ( st_ivas->hDecoderConfig->voip_active == 1 && st_ivas->hTcBuffer == NULL ) { @@ -1115,14 +1117,20 @@ static void ivas_spar_calc_smooth_facs( return; } + #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------* + * ivas_spar_dec_agc_pca() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_agc_pca( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float output[][L_FRAME48k], /* i/o: input/output audio channels */ const int16_t output_frame /* i : output frame length */ ) { - int16_t nchan_transport; int16_t num_in_ingest; DECODER_CONFIG_HANDLE hDecoderConfig; @@ -1160,6 +1168,7 @@ void ivas_spar_dec_agc_pca( { num_in_ingest = nchan_transport; } + /*---------------------------------------------------------------------* * AGC *---------------------------------------------------------------------*/ @@ -1179,12 +1188,21 @@ void ivas_spar_dec_agc_pca( #endif } pop_wmops(); + return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_set_render_map() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_set_render_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ) + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) { SPAR_DEC_HANDLE hSpar; @@ -1203,6 +1221,8 @@ void ivas_spar_dec_set_render_map( return; } + + /*-------------------------------------------------------------------* * ivas_spar_dec_upmixer() * @@ -1219,11 +1239,14 @@ void ivas_spar_dec_set_render_params( int16_t num_bands_out; hSpar = st_ivas->hSpar; + /*---------------------------------------------------------------------* * Gen umx mat *---------------------------------------------------------------------*/ + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi #ifdef HODIRAC , @@ -1236,6 +1259,13 @@ void ivas_spar_dec_set_render_params( return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nchan_transport, /* i : number of transport channels */ @@ -1253,6 +1283,7 @@ void ivas_spar_dec_digest_tc( float *p_tc[MAX_SPAR_INTERNAL_CHANNELS]; int16_t nchan_internal, ch; int16_t nSamplesLeftForTD, default_frame; + /* TD decorrelator */ default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -1262,6 +1293,7 @@ void ivas_spar_dec_digest_tc( st_ivas->hDecoderConfig->ivas_total_brate #endif ); + for ( ch = 0; ch < nchan_internal; ch++ ) { pPcm_tmp[ch] = Pcm_tmp[ch]; @@ -1271,6 +1303,7 @@ void ivas_spar_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); + ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); #ifdef HODIRAC if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) @@ -1301,16 +1334,23 @@ void ivas_spar_dec_digest_tc( { p_tc[ch] += nSamplesToDecorr; } + nSamplesLeftForTD -= nSamplesToDecorr; } } ivas_spar_dec_set_render_params( st_ivas, nCldfbSlots ); - return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_upmixer() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_upmixer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float output[][L_FRAME48k], /* i/o: input/output audio channels */ @@ -1330,10 +1370,12 @@ void ivas_spar_dec_upmixer( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n_samples_sf = JBM_CLDFB_SLOTS_IN_SUBFRAME * NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { output_f_local[n] = &output[n][0]; } + for ( n = 0; n < nchan_internal; n++ ) { st_ivas->hTcBuffer->tc[n] = output[n]; @@ -1342,10 +1384,12 @@ void ivas_spar_dec_upmixer( /*---------------------------------------------------------------------* * TD decorrelation *---------------------------------------------------------------------*/ + for ( i = 0; i < nchan_internal; i++ ) { pPcm_tmp[i] = Pcm_tmp[i]; } + if ( hSpar->hMdDec->td_decorr_flag ) { ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); @@ -1376,7 +1420,6 @@ void ivas_spar_dec_upmixer( #endif } - ivas_spar_dec_set_render_params( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); if ( st_ivas->hDirAC != 0 ) @@ -1392,10 +1435,12 @@ void ivas_spar_dec_upmixer( output_f_local[n] += n_samples_sf; } } + for ( n = 0; n < nchan_internal; n++ ) { st_ivas->hTcBuffer->tc[n] = NULL; } + if ( st_ivas->hDirAC != 0 ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1407,6 +1452,7 @@ void ivas_spar_dec_upmixer( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + return; } #endif @@ -1418,6 +1464,7 @@ void ivas_spar_dec_upmixer( * * IVAS SPAR upmixer *-------------------------------------------------------------------*/ + void ivas_spar_dec_upmixer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output[], /* o : output audio channels */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 98df8c3dca..711c55b160 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -440,6 +440,7 @@ typedef struct param_ism_rendering float *Cldfb_RealBuffer_tc; float *Cldfb_ImagBuffer_tc; #endif + } PARAM_ISM_RENDERING_DATA, *PARAM_ISM_RENDERING_HANDLE; @@ -1259,8 +1260,11 @@ typedef struct decoder_tc_buffer_structure int16_t slots_rendered; int16_t num_slots; int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */ + } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; #endif + + /*----------------------------------------------------------------------------------* * * Main IVAS decoder structure @@ -1350,6 +1354,11 @@ typedef struct Decoder_Struct RENDER_CONFIG_DATA *hRenderConfig; /* Renderer config pointer */ int32_t binaural_latency_ns; /* Binauralization latency in ns */ +#ifdef JBM_TSM_ON_TCS + /* JBM module */ + DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM handle */ +#endif + #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ #endif @@ -1357,10 +1366,6 @@ typedef struct Decoder_Struct int16_t ism_extmeta_active; /* Extended metadata active in decoder */ int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ - -#ifdef JBM_TSM_ON_TCS - DECODER_TC_BUFFER_HANDLE hTcBuffer; -#endif } Decoder_Struct; /* clang-format on */ diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index c224b4cfbf..9742a01183 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -412,7 +412,9 @@ bool apa_set_renderer_residual_samples( return 0; } -bool apa_set_evs_compat_mode( apa_state_t *ps, bool mode ) +bool apa_set_evs_compat_mode( + apa_state_t *ps, + bool mode ) { /* make sure pointer is valid */ if ( ps == NULL ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 99c6c20e01..62e83686a0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -279,6 +279,7 @@ static void init_decoder_config( #ifdef JBM_TSM_ON_TCS hDecoderConfig->voip_active = 0; #endif + return; } @@ -580,7 +581,6 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #endif - #ifndef JBM_TSM_ON_TCS assert( hDecoderConfig->nchan_out > 0 && "EXT output not yet supported in VoIP mode" ); #endif @@ -610,6 +610,7 @@ ivas_error IVAS_DEC_EnableVoIP( #else hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs * hDecoderConfig->nchan_out / FRAMES_PER_SEC ); #endif + #ifdef JBM_TSM_ON_TCS /* postpone init of the buffers until we know the real number of TCs*/ hIvasDec->hVoIP->apaExecBuffer = NULL; @@ -678,7 +679,6 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #ifdef JBM_TSM_ON_TCS - /* postpone init of time scaler until we know the real number of TCs */ hIvasDec->hVoIP->hTimeScaler = NULL; /* create output pcm fifo*/ @@ -931,6 +931,7 @@ static ivas_error IVAS_DEC_Setup( return error; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetTcSamples( ) * @@ -1999,6 +2000,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef JBM_TSM_ON_TCS uint16_t l_ts = 1; uint16_t nSamplesRendered_loop; + /* setup ivas decoder and get the number of TCs */ /* might render some remaining samples from the previous frame too if the renderer granularity changed */ if ( hVoIP->hFifoOut ) @@ -2020,11 +2022,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return error; } } + nSamplesRendered += nSamplesRendered_loop; if ( nTransportChannels != hVoIP->nTransportChannelsOld ) { IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ); } + /* decode TCs only */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hVoIP->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { @@ -2119,10 +2123,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { /* render IVAS frames */ int16_t nResidualSamples; + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hVoIP->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; } + /* feed residual samples to TSM for the next call */ if ( apa_set_renderer_residual_samples( hVoIP->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) { @@ -2160,6 +2166,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif #ifdef JBM_TSM_ON_TCS } + if ( hIvasDec->hasBeenFedFirstGoodFrame && hVoIP->rendererType != JBM_RENDERER_NONE ) { uint16_t nSamplesRendered_loop; @@ -2167,12 +2174,15 @@ ivas_error IVAS_DEC_VoIP_GetSamples( if ( hVoIP->hFifoOut ) { int16_t rendererPcmBuf[( MAX_OUTPUT_CHANNELS * L_FRAME_MAX * APA_MAX_SCALE ) / 100]; + nSamplesToRender = nSamplesPerChannel - pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ); + /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hVoIP->nSamplesAvailableNext, rendererPcmBuf ) ) != IVAS_ERR_OK ) { return error; } + if ( pcmdsp_fifo_write( hVoIP->hFifoOut, (uint8_t *) rendererPcmBuf, nSamplesRendered_loop ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -2181,13 +2191,16 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else { nSamplesToRender = nSamplesPerChannel - nSamplesRendered; + /* render IVAS frames directly to the output buffer */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hVoIP->nSamplesAvailableNext, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) { return error; } } + nSamplesRendered += nSamplesRendered_loop; + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext == 0 ) { @@ -2202,12 +2215,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else { hVoIP->nSamplesAvailableNext = max( 0, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ) - nSamplesPerChannel ); + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext < nSamplesPerChannel ) { hVoIP->needNewFrame = true; } #endif + hVoIP->nSamplesAvailableNext = 0; } #endif @@ -2270,6 +2285,7 @@ ivas_error IVAS_DEC_VoIP_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; #endif + error = IVAS_ERR_OK; hVoIP = hIvasDec->hVoIP; @@ -2278,6 +2294,7 @@ ivas_error IVAS_DEC_VoIP_Flush( #else *nSamplesFlushed = min( nSamplesPerChannel, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ) ); #endif + #ifdef JBM_TSM_ON_TCS if ( hVoIP->rendererType == JBM_RENDERER_NONE ) { @@ -2301,25 +2318,28 @@ ivas_error IVAS_DEC_VoIP_Flush( } else { - nSamplesToRender = (uint16_t) *nSamplesFlushed; /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hVoIP->nSamplesAvailableNext, rendererPcmBuf ) ) != IVAS_ERR_OK ) { return error; } + if ( pcmdsp_fifo_write( hVoIP->hFifoOut, (uint8_t *) rendererPcmBuf, nSamplesFlushedLocal ) != 0 ) { return IVAS_ERR_UNKNOWN; } + if ( pcmdsp_fifo_read( hVoIP->hFifoOut, nSamplesFlushedLocal, (uint8_t *) pcmBuf ) != 0 ) { return IVAS_ERR_UNKNOWN; } + *nSamplesAvailableNext = hVoIP->nSamplesAvailableNext; *nSamplesFlushed = (int16_t) nSamplesFlushedLocal; } #endif + return error; } #endif @@ -2335,7 +2355,7 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ #ifdef JBM_TSM_ON_TCS , - int16_t nSamplesAsked + const int16_t nSamplesAsked #endif ) { @@ -2389,6 +2409,7 @@ static void IVAS_DEC_Close_VoIP( #else pcmdsp_fifo_destroy( &hVoIP->hFifoAfterTimeScaler ); #endif + if ( hVoIP->apaExecBuffer != NULL ) { free( hVoIP->apaExecBuffer ); @@ -2974,7 +2995,6 @@ static ivas_error evs_dec_main( /* BE workaround */ int16_t pcm_buf_local[L_FRAME48k]; - /* convert 'float' output data to 'short' */ #ifdef DEBUGGING st_ivas->noClipping += @@ -3008,6 +3028,7 @@ static ivas_error evs_dec_main( #ifdef JBM_TSM_ON_TCS } #endif + return error; } @@ -3255,7 +3276,6 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_VOIP *hVoIP; ivas_error error; - hVoIP = hIvasDec->hVoIP; if ( hIvasDec->hVoIP->hTimeScaler == NULL ) @@ -3298,12 +3318,13 @@ ivas_error IVAS_DEC_VoIP_reconfigure( { return IVAS_ERR_INIT_ERROR; } - hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ); - set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); - if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) + + if ( ( hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); + if ( apa_init( &hIvasDec->hVoIP->hTimeScaler, nTransportChannels ) != IVAS_ERR_OK || apa_set_rate( hIvasDec->hVoIP->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || @@ -3313,6 +3334,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( { return IVAS_ERR_INIT_ERROR; } + if ( hVoIP->hFifoOut == NULL && hVoIP->rendererType == JBM_RENDERER_NONE ) { /* we still need the FIFO out buffer */ @@ -3332,6 +3354,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( } } #endif + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { if ( apa_set_evs_compat_mode( hIvasDec->hVoIP->hTimeScaler, true ) != 0 ) @@ -3349,12 +3372,11 @@ ivas_error IVAS_DEC_VoIP_reconfigure( /* realloc apa_exe_buffer */ free( hIvasDec->hVoIP->apaExecBuffer ); - hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ); - set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); - if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) + if ( ( hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); } hIvasDec->hVoIP->nTransportChannelsOld = (uint8_t) nTransportChannels; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 8151f581c5..9e098992a5 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -229,8 +229,8 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( #ifdef VARIABLE_SPEED_DECODING /*! r: error code */ ivas_error IVAS_DEC_VoIP_SetScale( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t scale /* i : TSM scale to set */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t scale /* i : TSM scale to set */ ); #endif @@ -242,7 +242,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( const uint32_t systemTimestamp_ms /* i : current system timestamp */ #if defined( JBM_TSM_ON_TCS ) || defined(VARIABLE_SPEED_DECODING ) , - uint16_t *sampleAvailableNext /* o : samples available for the next call */ + uint16_t *sampleAvailableNext /* o : samples available for the next call */ #endif #ifdef SUPPORT_JBM_TRACEFILE , JbmTraceFileWriterFn jbmWriterFn, @@ -252,11 +252,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #if defined( JBM_TSM_ON_TCS ) || defined(VARIABLE_SPEED_DECODING ) ivas_error IVAS_DEC_VoIP_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 */ - 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 */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ + 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 */ + 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 */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ + int16_t *nSamplesFlushed /* o : number of samples flushed */ ); #endif @@ -386,7 +386,7 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ #ifdef JBM_TSM_ON_TCS , - int16_t nSamplesAsked + const int16_t nSamplesAsked #endif ); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index a7572aea3f..76e7b36d02 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1145,12 +1145,14 @@ ivas_error ivas_rend_crendProcess( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; + #ifdef JBM_TSM_ON_TCS for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { p_pcm_tmp[i] = pcm_tmp[i]; } #endif + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) @@ -1212,20 +1214,28 @@ ivas_error ivas_rend_crendProcess( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crendProcessSubframe() + * + * + *-----------------------------------------------------------------------------------------*/ + ivas_error ivas_rend_crendProcessSubframe( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - DECODER_TC_BUFFER_HANDLE hTcBuffer, - float *input_f[], - float *output[], /* i/o: input/output audio channels */ - const int16_t n_samples_to_render, - const int32_t output_Fs ) + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +) { int16_t subframe_idx, subframe_len; int16_t nchan_out, nchan_in, ch, first_sf, last_sf, slot_size, slots_to_render; @@ -1245,10 +1255,12 @@ ivas_error ivas_rend_crendProcessSubframe( in_config = getIvasAudioConfigFromRendAudioConfig( inRendConfig ); inConfigType = getAudioConfigType( inRendConfig ); + if ( ( error = getAudioConfigNumChannels( outRendConfig, &nchan_out ) ) != IVAS_ERR_OK ) { return error; } + if ( ( error = getAudioConfigNumChannels( inRendConfig, &nchan_in ) ) != IVAS_ERR_OK ) { return error; @@ -1258,17 +1270,20 @@ ivas_error ivas_rend_crendProcessSubframe( { tc_local[ch] = input_f[ch]; } + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_pcm_tmp[ch] = pcm_tmp[ch]; } slot_size = hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); first_sf = hTcBuffer->subframes_rendered; last_sf = first_sf; hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= hTcBuffer->subframe_nbslots[last_sf]; @@ -1278,9 +1293,9 @@ ivas_error ivas_rend_crendProcessSubframe( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { subframe_len = hTcBuffer->subframe_nbslots[subframe_idx] * hTcBuffer->n_samples_granularity; + if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) { - /* Rotation in SHD for: MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL SBA SPAR -> BINAURAL or BINAURAL_ROOM @@ -1331,7 +1346,6 @@ ivas_error ivas_rend_crendProcessSubframe( mvr2r( pcm_tmp[ch], output[ch], n_samples_to_render ); } - hTcBuffer->subframes_rendered = last_sf; pop_wmops(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 06fd160bb2..ec05cab974 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -140,6 +140,8 @@ static void ivas_dirac_dec_binaural_internal_sf( Decoder_Struct *st_ivas, float static void ivas_dirac_dec_decorrelate_slot_sf( DIRAC_DEC_HANDLE hDirAC, const int8_t slot, float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); #endif #endif + + /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -408,8 +410,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - -#endif /* JBM_TMS_ON_TCS*/ +#endif return IVAS_ERR_OK; } @@ -489,14 +490,21 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*------------------------------------------------------------------------- + * void ivas_dirac_dec_binaural_render() + * + * + *------------------------------------------------------------------------*/ + void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -515,16 +523,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] = output_f[ch]; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; last_sf++; } + #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif @@ -541,16 +552,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; return; } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec_binaural() * @@ -612,14 +626,15 @@ void ivas_dirac_dec_binaural( #endif } output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + #ifdef JBM_TSM_ON_TCS - { - ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); - } + ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); + #else ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, output_f, decorr_signal, output_frame ); #endif } + #ifdef JBM_TSM_ON_TCS if ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) { @@ -634,7 +649,9 @@ void ivas_dirac_dec_binaural( { #ifdef JBM_TSM_ON_TCS int16_t n_samples_sf = slot_size * st_ivas->hDirAC->subframe_nbslots[subframe]; + ivas_dirac_dec_binaural_internal( st_ivas, p_output, nchan_transport, subframe ); + for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { p_output[ch] += n_samples_sf; @@ -658,12 +675,14 @@ void ivas_dirac_dec_binaural( ivas_dirac_dec_binaural_internal( st_ivas, output_f, nchan_transport, 0u, (uint8_t) MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif + #ifdef JBM_TSM_ON_TCS for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { st_ivas->hTcBuffer->tc[ch] = NULL; } #endif + return; } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index e163862eeb..cd81110511 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -316,7 +316,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( } } - if ( hReverb != NULL && hReverb->pConfig.roomAcoustics.late_reverb_on ) { /* add reverb to rendered signals */ @@ -452,7 +451,7 @@ void TDREND_Update_object_positions( const IVAS_FORMAT in_format, /* i : Format of input sources */ const ISM_METADATA_HANDLE *hIsmMetaData, /* i : Input metadata for ISM objects */ #ifdef JBM_TSM_ON_TCS - float *output[] + float *output[] /* i/o: SCE/MC channels */ #else float output[][L_FRAME48k] /* i/o: SCE/MC channels */ #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index b43a048f38..77a170c044 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -171,12 +171,12 @@ void ivas_dirac_dec_binaural( #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -247,7 +247,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: SCE channels / Binaural synthesis */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ #else float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ #endif @@ -524,7 +524,8 @@ void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ); ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend ); + CREND_WRAPPER_HANDLE *pCrend +); ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, @@ -535,7 +536,7 @@ ivas_error ivas_rend_crendProcess( IVAS_OUTPUT_SETUP_HANDLE hIntSetup, EFAP_HANDLE hEFAPdata, #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: input/output audio channels */ + float *output[], /* i/o: input/output audio channels */ #else float output[][L_FRAME48k], /* i/o: input/output audio channels */ #endif @@ -544,18 +545,19 @@ ivas_error ivas_rend_crendProcess( #ifdef JBM_TSM_ON_TCS ivas_error ivas_rend_crendProcessSubframe( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - DECODER_TC_BUFFER_HANDLE hTcBuffer, - float *input_f[], - float *output[], /* i/o: input/output audio channels */ - const int16_t n_samples_to_render, - const int32_t output_Fs ); + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +); #endif @@ -651,8 +653,8 @@ ivas_error ivas_reverb_process( const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const int16_t mix_signals, /* i : add reverb to output signal */ #ifdef JBM_TSM_ON_TCS - float *pcm_in[], /* i : the PCM audio to apply reverb on */ - float *pcm_out[], /* o : the PCM audio with reverb applied */ + float *pcm_in[], /* i : the PCM audio to apply reverb on */ + float *pcm_out[], /* o : the PCM audio with reverb applied */ #else float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */ float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */ @@ -892,7 +894,7 @@ void rotateFrame_shd( void rotateFrame_sd( HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: unrotated SD signal buffer in TD */ + float *output[], /* i/o: unrotated SD signal buffer in TD */ #else float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ #endif @@ -908,7 +910,7 @@ void rotateFrame_shd_cldfb( float Rmat[3][3], /* i : real-space rotation matrix */ const int16_t nInChannels, /* i : number of channels */ #ifdef JBM_TSM_ON_TCS - const int16_t numTimeSlots, /* i : number of time slots to process */ + const int16_t numTimeSlots, /* i : number of time slots to process */ #endif const int16_t shd_rot_max_order /* i : split-order rotation method */ ); diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 5719e2ffdd..29f638bf68 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -511,7 +511,7 @@ void rotateFrame_shd_cldfb( float Rmat[3][3], /* i : real-space rotation matrix */ const int16_t nInChannels, /* i : number of channels */ #ifdef JBM_TSM_ON_TCS - const int16_t numTimeSlots, + const int16_t numTimeSlots, /* i : number of time slots to process */ #endif const int16_t shd_rot_max_order /* i : split-order rotation method */ ) diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index c549461c37..7affa9a913 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -93,10 +93,12 @@ void ivas_sba_prototype_renderer_sf( outChEnd = 2; } slot_idx_start = hSpar->slots_rendered; + /* Apply mixing matrix */ for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { int16_t md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; + /* determine SPAR parameters for this time slot */ ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); @@ -202,6 +204,7 @@ void ivas_sba_prototype_renderer_sf( } #endif + #ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ef5561ca98..98e7ce2a10 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4422,6 +4422,7 @@ static ivas_error renderIsmToBinauralRoom( const IVAS_REND_HeadRotData *headRotData; #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4804,10 +4805,10 @@ static ivas_error renderMcToBinaural( IVAS_REND_AudioConfig inConfig; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4888,10 +4889,10 @@ static ivas_error renderMcToBinauralRoom( IVAS_REND_AudioConfig inConfig; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4975,7 +4976,6 @@ static ivas_error renderMcCustomLsToBinauralRoom( IVAS_REND_AudioBuffer tmpRotBuffer; IVAS_REND_AudioBuffer tmpMcBuffer; IVAS_REND_AudioBuffer *tmpBufPtr; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; #endif @@ -5231,10 +5231,8 @@ static ivas_error renderSbaToBinaural( IVAS_REND_AudioBuffer outAudio ) { float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; @@ -5303,7 +5301,6 @@ static ivas_error renderSbaToBinauralRoom( IVAS_REND_AudioBuffer tmpRotBuffer; IVAS_REND_AudioBuffer tmpMcBuffer; IVAS_REND_AudioBuffer *tmpBufPtr; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; #endif -- GitLab From c86d5fa6c02cc950cb4eb64a460b3935e82f9616 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 May 2023 10:47:39 +0200 Subject: [PATCH 05/17] formal issues improvements (foramtting, comments, return error for malloc()) --- apps/decoder.c | 3 +- lib_com/fd_cng_com.c | 1 + lib_com/ivas_prot.h | 236 +++++++++++----------- lib_com/ivas_tools.c | 2 + lib_com/options.h | 4 +- lib_dec/fd_cng_dec.c | 1 + lib_dec/ivas_binRenderer_internal.c | 1 + lib_dec/ivas_dec.c | 22 +- lib_dec/ivas_dirac_dec.c | 49 ++--- lib_dec/ivas_dirac_output_synthesis_cov.c | 9 +- lib_dec/ivas_ism_param_dec.c | 2 + lib_dec/ivas_jbm_dec.c | 24 ++- lib_dec/ivas_mc_param_dec.c | 24 ++- lib_dec/ivas_objectRenderer_internal.c | 6 +- lib_dec/ivas_sba_dec.c | 5 +- lib_dec/ivas_spar_decoder.c | 3 + lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.c | 9 +- lib_rend/ivas_sba_rendering.c | 11 +- 19 files changed, 229 insertions(+), 185 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index b4a840b10c..62c72fea0e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2279,8 +2279,7 @@ static ivas_error decodeVoIP( /* decode and get samples */ - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, - pcmBuf, systemTime_ms + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms #if defined( JBM_TSM_ON_TCS ) || defined( VARIABLE_SPEED_DECODING ) , &nSamplesAvailableNext diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index e31ce67d13..f0408ea3dd 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -940,6 +940,7 @@ void SynthesisSTFT( return; } + #ifdef JBM_TSM_ON_TCS /*------------------------------------------------------------------- * SynthesisSTFT_dirac() diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 32a6db03b6..80480d9916 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -252,9 +252,9 @@ ivas_error ivas_compute_core_buffers( /*! r: number of clipped samples */ uint32_t ivas_syn_output( #ifdef JBM_TSM_ON_TCS - float *synth[], /* i/o: float synthesis signal */ + float *synth[], /* i/o: float synthesis signal */ #else - float synth[][L_FRAME48k], /* i/o: float synthesis signal */ + float synth[][L_FRAME48k], /* i/o: float synthesis signal */ #endif const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ @@ -863,6 +863,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( ); #endif + /*----------------------------------------------------------------------------------* * ISM prototypes *----------------------------------------------------------------------------------*/ @@ -1024,7 +1025,7 @@ ivas_error ivas_ism_dec_config( #ifdef JBM_TSM_ON_TCS , uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ - int16_t *data /* o : flushed PCM samples */ + int16_t *data /* o : flushed PCM samples */ #endif ); @@ -1048,17 +1049,17 @@ void ivas_ism_dec_digest_tc( ); void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -3457,11 +3458,11 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_TSM_ON_TCS ivas_error ivas_sba_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering, /* i : number of samples provided */ - float *data[] /* i : transport channel samples */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering, /* i : number of samples provided */ + float *data[] /* i : transport channel samples */ ); #endif @@ -3690,32 +3691,32 @@ void ivas_dirac_dec_read_BS( #ifdef JBM_TSM_ON_TCS void generate_masking_noise_lb_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ + const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ + const int16_t cna_flag /* i : CNA flag for LB and HB */ ); void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nCldfbTs /* i : number of CLDFB time slots */ ); void ivas_dirac_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_transport /* i : number of transport channels */ ); #endif #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -3726,9 +3727,9 @@ void ivas_dirac_dec_render_sf( #endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ #else - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif const int16_t nchan_transport, /* i : number of transport channels */ float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], @@ -3891,7 +3892,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ const int16_t nchan_transport, /* i : number of transport channels */ #ifdef JBM_TSM_ON_TCS - const int16_t nbslots, /* i : number of slots to process */ + const int16_t nbslots, /* i : number of slots to process */ #endif const float *onset_filter #ifdef HODIRAC @@ -3904,12 +3905,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( ); void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ + DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ #ifdef JBM_TSM_ON_TCS - const int16_t nbslots, /* i : number of slots to process */ - const int16_t diff_md_idx, /* i : md slot idx of diffuseness to use */ + const int16_t nbslots, /* i : number of slots to process */ + const int16_t diff_md_idx, /* i : md slot idx of diffuseness to use */ #endif float *reference_power_smooth, float qualityBasedSmFactor @@ -3955,8 +3956,8 @@ void ivas_dirac_dec_compute_directional_responses( const int16_t md_idx, #endif const float *surCohRatio, - const int16_t shd_rot_max_order, /* i : split-order rotation method */ - const float *p_Rmat /* i : rotation matrix */ + const int16_t shd_rot_max_order, /* i : split-order rotation method */ + const float *p_Rmat /* i : rotation matrix */ #ifdef HODIRAC , const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ @@ -4096,17 +4097,17 @@ void ivas_param_mc_dec_read_BS( #ifdef JBM_TSM_ON_TCS void ivas_param_mc_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); 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 */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -4115,7 +4116,7 @@ void ivas_param_mc_dec( #ifdef JBM_TSM_ON_TCS float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ #else - float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ + float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ #endif ); @@ -4249,8 +4250,9 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_output_synthesis_get_interpolator( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - const uint16_t interp_length ); + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ + const uint16_t interp_length /* i : interpolator length */ +); #endif void ivas_dirac_dec_output_synthesis_cov_init( @@ -4268,8 +4270,8 @@ void ivas_dirac_dec_output_synthesis_cov_close( void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( #ifdef JBM_TSM_ON_TCS - float *RealBuffer, /* i : input channel filter bank samples (real part) */ - float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ + float *RealBuffer, /* i : input channel filter bank samples (real part) */ + float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ #else float RealBuffer[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], /* i : input channel filter bank samples (real part) */ float ImagBuffer[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], /* i : input channel filter bank samples (imaginary part */ @@ -4280,14 +4282,14 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( const int16_t nchan_in /* i : number of input channels */ #ifndef JBM_TSM_ON_TCS , - const int16_t idx_slot /* i : index of the slot to be added to the input covariance */ + const int16_t idx_slot /* i : index of the slot to be added to the input covariance */ #endif ); void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( #ifdef JBM_TSM_ON_TCS - float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ - float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ + float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ + float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ #else float Cldfb_RealBuffer_in[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], /* i : CLDFB samples of the transport channels (real part) */ float Cldfb_ImagBuffer_in[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], /* i : CLDFB samples of the transport channels (imaginary part) */ @@ -4295,17 +4297,17 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */ #ifdef JBM_TSM_ON_TCS - float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ - float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ + float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ + float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ #else float mixing_matrix[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : parameter band wise mixing matrices (direct part) */ float mixing_matrix_res[PARAM_MC_MAX_PARAMETER_BANDS_RES][MAX_CICP_CHANNELS * MAX_CICP_CHANNELS], /* i : parameter band wise mixing matrices (residual part) */ #endif - const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ - const uint16_t slot_idx_tot, /* i : time slot index for the current slot within the frame */ - const int16_t nX, /* i : number of input channels */ - const int16_t nY, /* i : number of output channels */ - PARAM_MC_DEC_HANDLE hParamMC /* i : handle to the Parametric MC decoder state */ + const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ + const uint16_t slot_idx_tot, /* i : time slot index for the current slot within the frame */ + const int16_t nX, /* i : number of input channels */ + const int16_t nY, /* i : number of output channels */ + PARAM_MC_DEC_HANDLE hParamMC /* i : handle to the Parametric MC decoder state */ ); int16_t computeMixingMatricesISM( @@ -4390,7 +4392,7 @@ void ivas_sba_upmixer_renderer( ivas_error ivas_sba_linear_renderer( #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ #else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif @@ -4411,7 +4413,7 @@ void ivas_sba_mix_matrix_determiner( #ifdef JBM_TSM_ON_TCS void ivas_sba_prototype_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ float inIm[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* i : Input audio in CLDFB domain, imag */ ); @@ -4575,46 +4577,46 @@ int16_t ivas_is_res_channel( #ifdef JBM_TSM_ON_TCS void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int16_t output_frame /* i : output frame length */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int16_t output_frame /* i : output frame length */ ); void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nCldfbTs /* i : number of CLDFB time slots */ ); void ivas_spar_dec_set_render_params( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ ); void ivas_spar_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); ivas_error ivas_sba_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); void ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); void ivas_spar_dec_upmixer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output audio channels */ - const int16_t nchan_internal /* i : number of internal channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float *output[], /* o : output audio channels */ + const int16_t nchan_internal /* i : number of internal channels */ ); #endif @@ -4711,7 +4713,7 @@ void ivas_get_spar_md_from_dirac( #ifdef HODIRAC int16_t ivas_get_spar_dec_md_num_subframes( - const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int32_t ivas_total_brate ); #endif @@ -5250,7 +5252,7 @@ void ivas_masa_prerender( #ifdef JBM_TSM_ON_TCS #ifndef FIX_355_REFACTOR_PARAMBIN_TO_5MS void ivas_spar_param_to_masa_param_mapping_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ int16_t azimuth[CLDFB_NO_CHANNELS_MAX], int16_t elevation[CLDFB_NO_CHANNELS_MAX], float energy_ratio1[CLDFB_NO_CHANNELS_MAX], @@ -5304,9 +5306,9 @@ void ivas_binaural_cldfb( #ifdef JBM_TSM_ON_TCS void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t n_samples_to_render, /* i : output frame length per channel */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ); #endif @@ -5328,8 +5330,8 @@ void ivas_binaural_add_LFE( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t output_frame, /* i : length of input frame */ #ifdef JBM_TSM_ON_TCS - float *input_f[], /* i : transport channels */ - float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */ + float *input_f[], /* i : transport channels */ + float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */ #else float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ #endif @@ -5347,7 +5349,7 @@ ivas_error ivas_ism_renderer_open( void ivas_ism_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: core-coder transport channels/object output */ + float *output_f[], /* i/o: core-coder transport channels/object output */ #else float output_f[][L_FRAME48k], /* i/o: core-coder transport channels/object output */ #endif @@ -5356,9 +5358,9 @@ void ivas_ism_render( #ifdef JBM_TSM_ON_TCS void ivas_ism_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t n_samples_to_render /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: core-coder transport channels/object output */ + const int16_t n_samples_to_render /* i : output frame length per channel */ ); #endif @@ -5372,10 +5374,10 @@ void ivas_ism_get_stereo_gains( void ivas_mc2sba( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ #ifdef JBM_TSM_ON_TCS - float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ - float *buffer_td[], /* o : MC signals (on input) and the HOA3 (on output) */ + float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ + float *buffer_td[], /* o : MC signals (on input) and the HOA3 (on output) */ #else - float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */ + float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */ #endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t sba_order, /* i : SBA order */ @@ -5384,9 +5386,9 @@ void ivas_mc2sba( void ivas_ism2sba( #ifdef JBM_TSM_ON_TCS - float *buffer_td[], /* i/o: TD signal buffers */ + float *buffer_td[], /* i/o: TD signal buffers */ #else - float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ + float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ #endif ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */ @@ -5397,13 +5399,13 @@ void ivas_ism2sba( #ifdef JBM_TSM_ON_TCS void ivas_ism2sba_sf( - float *buffer_in[], /* i : TC buffer */ - float *buffer_out[], /* o : TD signal buffers */ - ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ - const int16_t num_objects, /* i : number of objects */ - const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int16_t offset, /* i : offset for the interpolatr */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ + float *buffer_in[], /* i : TC buffer */ + float *buffer_out[], /* o : TD signal buffers */ + ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ + const int16_t num_objects, /* i : number of objects */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int16_t offset, /* i : offset for the interpolatr */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ ); #endif @@ -5463,10 +5465,10 @@ void ivas_ls_setup_conversion( #endif const int16_t output_frame, /* i : frame length */ #ifdef JBM_TSM_ON_TCS - float *input[], /* i : LS input/output synthesis signal */ - float *output[] /* i/o: LS input/output synthesis signal */ + float *input[], /* i : LS input/output synthesis signal */ + float *output[] /* i/o: LS input/output synthesis signal */ #else - float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ + float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ #endif ); @@ -5481,9 +5483,9 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( ); void ivas_lssetupconversion_process_param_mc( - Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ + Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - const int16_t num_timeslots, /* i : number of time slots to process */ + const int16_t num_timeslots, /* i : number of time slots to process */ #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ @@ -5716,17 +5718,17 @@ ivas_error ivas_td_binaural_open( ivas_error ivas_td_binaural_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: SCE channels / Binaural synthesis */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ #else - float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ #endif const int16_t output_frame /* i : output frame length */ ); #ifdef JBM_TSM_ON_TCS ivas_error ivas_td_binaural_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); #endif diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index ce4abafeb5..cf59a751a6 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -163,6 +163,7 @@ uint32_t ivas_syn_output( return noClipping; } + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------* * ivas_syn_output_f() @@ -197,6 +198,7 @@ void ivas_syn_output_f( } #endif + /*-------------------------------------------------------------------* * mvr2r_inc() * diff --git a/lib_com/options.h b/lib_com/options.h index 4150e91a5d..a14c7b8033 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -208,8 +208,8 @@ #define FIX_642 /* FhG: Fix for issue 642, buggy DoA-array access in DirAC head rotation*/ #define FIX_443_FD_CNG_INIT /* FhG: correct bitrate value for FD-CNG init */ -#define VARIABLE_SPEED_DECODING /* FhG: variable speed decoding employing the JBM functioniality */ -#define JBM_TSM_ON_TCS /* FhG: run the TSM part of JBM on the TCs instead of the final output pcm waveforms */ +#define VARIABLE_SPEED_DECODING /* FhG: Contribution 37: variable speed decoding employing the JBM functioniality */ +#define JBM_TSM_ON_TCS /* FhG: Contribution 37: run the TSM part of JBM on the TCs instead of the final output pcm waveforms */ #define FIX_DTX_428 /* FhG: fix for issue 428, crash with DTX and bitrate switching */ diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 8b62e54a8d..0921f0bee2 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1798,6 +1798,7 @@ void generate_stereo_masking_noise( return; } + #ifdef JBM_TSM_ON_TCS /*------------------------------------------------------------------- * generate_masking_noise_hf_cldfb() diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 5de5f881fa..c0a79befaf 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1073,6 +1073,7 @@ void ivas_binaural_cldfb_sf( #else ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif + /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 0af1699564..7f163fdb1f 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -297,13 +297,7 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - NULL, - NULL, - NULL, - NULL, + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, #ifdef JBM_TSM_ON_TCS p_output, #else @@ -570,13 +564,8 @@ ivas_error ivas_dec( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, + st_ivas->hHeadTrackData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, #ifdef JBM_TSM_ON_TCS p_output, #else @@ -624,6 +613,7 @@ ivas_error ivas_dec( { return error; } + ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); #else if ( ( ivas_td_binaural_renderer( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) @@ -679,6 +669,7 @@ ivas_error ivas_dec( { return error; } + #ifdef JBM_TSM_ON_TCS ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); #else @@ -722,6 +713,7 @@ ivas_error ivas_dec( { return error; } + #ifdef JBM_TSM_ON_TCS ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); #else @@ -897,6 +889,7 @@ ivas_error ivas_dec( * - compensation for saturation * - float to integer conversion *----------------------------------------------------------------*/ + #ifdef JBM_TSM_ON_TCS ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, output_frame, st_ivas->BER_detect ); @@ -912,6 +905,7 @@ ivas_error ivas_dec( #endif ivas_syn_output( output, output_frame, nchan_out, data ); #endif + /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 51122aa40a..1f40d8e58f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -282,6 +282,9 @@ ivas_error ivas_dirac_dec_config( int16_t nchan_transport_orig; #ifdef HODIRAC int16_t hodirac_flag; +#endif +#ifdef JBM_TSM_ON_TCS + int16_t map_idx; #endif DIRAC_CONFIG_FLAG flag_config; @@ -1133,29 +1136,26 @@ ivas_error ivas_dirac_dec_config( if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES; + #ifdef JBM_TSM_ON_TCS + set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); + for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) { - int16_t map_idx; - set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) - { - hDirAC->render_to_md_map[map_idx] = map_idx; - } + hDirAC->render_to_md_map[map_idx] = map_idx; } + #endif } else if ( st_ivas->ivas_format == MASA_FORMAT ) { hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; hDirAC->dirac_bs_md_write_idx = DELAY_MASA_PARAM_DEC_SFR; + #ifdef JBM_TSM_ON_TCS + set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); + for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) { - int16_t map_idx; - set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) - { - hDirAC->render_to_md_map[map_idx] = map_idx; - } + hDirAC->render_to_md_map[map_idx] = map_idx; } #endif } @@ -1181,13 +1181,11 @@ ivas_error ivas_dirac_dec_config( hDirAC->dirac_estimator_idx = 0; } #ifdef JBM_TSM_ON_TCS + + set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); + for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) { - int16_t map_idx; - set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) - { - hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx * num_slots_in_subfr / JBM_CLDFB_SLOTS_IN_SUBFRAME; - } + hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx * num_slots_in_subfr / JBM_CLDFB_SLOTS_IN_SUBFRAME; } #endif } @@ -1501,6 +1499,7 @@ ivas_error ivas_dirac_dec_config( } } #endif + #ifdef JBM_TSM_ON_TCS /* allocate transport channels*/ if ( flag_config == DIRAC_OPEN ) @@ -1527,7 +1526,6 @@ ivas_error ivas_dirac_dec_config( } } } - #endif /* JBM_TMS_ON_TCS*/ return error; @@ -2622,6 +2620,7 @@ void ivas_qmetadata_to_dirac( band_end = band_grouping[band + 1]; #ifdef JBM_TSM_ON_TCS tmp_write_idx_param_band = hDirAC->dirac_bs_md_write_idx; + for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) #else for ( block = 0; block < hDirAC->nb_subframes; block++ ) @@ -2638,6 +2637,7 @@ void ivas_qmetadata_to_dirac( #endif hDirAC->spreadCoherence[block][b] = 0.0f; hDirAC->surroundingCoherence[block][b] = 0.0f; + #ifdef JBM_TSM_ON_TCS if ( hDirAC->hConfig->dec_param_estim == FALSE ) { @@ -2834,6 +2834,7 @@ void ivas_qmetadata_to_dirac( for ( b = band_grouping[band]; b < hDirAC->num_freq_bands; b++ ) { tmp_write_idx_band = hDirAC->dirac_bs_md_write_idx; + #ifdef JBM_TSM_ON_TCS for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) #else @@ -2901,7 +2902,7 @@ void ivas_qmetadata_to_dirac( void ivas_dirac_dec_set_md_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nCldfbTs /* i : number of CLDFB time slots */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ ) { int16_t num_slots_in_subfr; @@ -3326,6 +3327,7 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + #ifdef JBM_TSM_ON_TCS for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) #else @@ -3354,7 +3356,6 @@ void ivas_dirac_dec_render_sf( if ( hDirAC->hConfig->dec_param_estim == FALSE ) { - /* compute response */ if ( hDirAC->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { @@ -3418,7 +3419,6 @@ void ivas_dirac_dec_render_sf( } } - if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData->shd_rot_max_order == 1 ) { ivas_dirac_dec_compute_directional_responses( hDirAC, @@ -3459,7 +3459,6 @@ void ivas_dirac_dec_render_sf( } } - #ifdef JBM_TSM_ON_TCS for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) #else @@ -3909,6 +3908,7 @@ void ivas_dirac_dec_render_sf( } #endif } + #ifndef JBM_TSM_ON_TCS if ( hDirAC->hConfig->dec_param_estim == 0 ) { @@ -3984,8 +3984,9 @@ void ivas_dirac_dec_render_sf( qualityBasedSmFactor = st_ivas->hMasa->data.dir_decode_quality; qualityBasedSmFactor *= qualityBasedSmFactor; } + #ifdef JBM_TSM_ON_TCS - /* Workaround for BE (should be gone when #393 is adressed) */ + /* ToDo: Workaround for BE (should be gone when #393 is adressed) */ if ( hDirAC->hConfig->dec_param_estim == 1 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 44a9d7e597..ffe6fea382 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -170,14 +170,15 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------* - * ivas_dirac_dec_output_synthesis_cov_open() + * ivas_dirac_dec_output_synthesis_get_interpolator() + * * - * Sets up the state and parameters for the Covariance Synthesis *-------------------------------------------------------------------*/ void ivas_dirac_dec_output_synthesis_get_interpolator( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - const uint16_t interp_length ) + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ + const uint16_t interp_length /* i : interpolator length */ +) { int16_t idx; diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 667ecd088c..92c6de6e87 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -446,6 +446,7 @@ static void ivas_param_ism_render_slot( } #endif + static void ivas_param_ism_rendering( DIRAC_DEC_HANDLE hDirAC, float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -811,6 +812,7 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hISMDTX.dtx_flag = 0; st_ivas->hDirAC = hDirAC; + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 867dada3e0..edec404d2f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -64,7 +64,7 @@ static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint1 *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : transport channel signals */ ) { @@ -132,6 +132,7 @@ ivas_error ivas_jbm_dec_tc( { hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } + if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) { #ifdef MC_PARAMUPMIX_MODE @@ -213,9 +214,9 @@ ivas_error ivas_jbm_dec_tc( st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; ivas_dirac_dec_read_BS( ivas_total_brate, st, st_ivas->hDirAC, st_ivas->hQMetaData, &nb_bits_metadata[0], st_ivas->sba_mode, #ifdef HODIRAC - st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, + st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, #endif - st_ivas->hSpar->dirac_to_spar_md_bands ); + st_ivas->hSpar->dirac_to_spar_md_bands ); } if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) @@ -539,10 +540,10 @@ ivas_error ivas_jbm_dec_tc( *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i : transport channels */ + float *data /* i : transport channels */ ) { @@ -733,7 +734,7 @@ ivas_error ivas_jbm_dec_render( if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; - } + } } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -742,6 +743,7 @@ ivas_error ivas_jbm_dec_render( { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); } #ifdef DEBUGGING @@ -770,7 +772,11 @@ ivas_error ivas_jbm_dec_render( { mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); } - ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) { @@ -850,6 +856,7 @@ ivas_error ivas_jbm_dec_render( { mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); } else if ( st_ivas->intern_config == AUDIO_CONFIG_5_1 && ( output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 ) ) @@ -860,6 +867,7 @@ ivas_error ivas_jbm_dec_render( } } } + /* copy discrete C and TD LFE from internal TC to output */ if ( st_ivas->hOutSetup.separateChannelEnabled ) { @@ -990,7 +998,7 @@ ivas_error ivas_jbm_dec_flush_renderer( if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; - } + } } else if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index d19e2d33cc..6f2c6dc671 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -481,10 +481,18 @@ ivas_error ivas_param_mc_dec_open( #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active && hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) { - hParamMC->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ); + if ( ( hParamMC->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } set_zero( hParamMC->Cldfb_RealBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands ); - hParamMC->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ); + + if ( ( hParamMC->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } set_zero( hParamMC->Cldfb_ImagBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands ); + if ( st_ivas->hTcBuffer == NULL ) { if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -498,6 +506,7 @@ ivas_error ivas_param_mc_dec_open( hParamMC->Cldfb_RealBuffer_tc = NULL; hParamMC->Cldfb_ImagBuffer_tc = NULL; } + hParamMC->subframes_rendered = 0; hParamMC->slots_rendered = 0; #endif @@ -652,7 +661,6 @@ ivas_error ivas_param_mc_dec_reconfig( hParamMC->slot_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX; hParamMC->subframe_nbslots = CLDFB_NO_COL_MAX / PARAM_MC_NSUBFRAMES_DEC; #endif - hParamMC->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands; @@ -1408,7 +1416,14 @@ void ivas_param_mc_dec_read_BS( return; } + #ifdef JBM_TSM_ON_TCS +/*------------------------------------------------------------------------- + * ivas_param_mc_dec_digest_tc() + * + * + *------------------------------------------------------------------------*/ + void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ @@ -1552,6 +1567,7 @@ void ivas_param_mc_dec_digest_tc( return; } + /*------------------------------------------------------------------------- * ivas_param_mc_dec() * @@ -1833,11 +1849,13 @@ void ivas_param_mc_dec_render( } #endif + /*------------------------------------------------------------------------- * ivas_param_mc_dec() * * Parametric MC decoding process *------------------------------------------------------------------------*/ + #ifdef JBM_TSM_ON_TCS void ivas_param_mc_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index bc4ad29025..d84df109d5 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -93,8 +93,8 @@ ivas_error ivas_td_binaural_renderer( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { @@ -152,7 +152,7 @@ ivas_error ivas_td_binaural_renderer_sf( if ( ( error = ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ) ) != IVAS_ERR_OK ) { return error; - } + } } /* Render subframe */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 581262fc52..97e532836f 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -129,6 +129,7 @@ ivas_error ivas_sba_dec_reconfigure( * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ + ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); nSCE_old = st_ivas->nSCE; @@ -137,6 +138,7 @@ ivas_error ivas_sba_dec_reconfigure( sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + #ifdef JBM_TSM_ON_TCS /* save old */ if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) @@ -210,6 +212,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); #endif + if ( st_ivas->nchan_transport == 1 ) { st_ivas->element_mode_init = IVAS_SCE; @@ -435,7 +438,7 @@ ivas_error ivas_sba_dec_reconfigure( /*-------------------------------------------------------------------* * ivas_sba_dec_digest_tc() * - * + * *-------------------------------------------------------------------*/ ivas_error ivas_sba_dec_digest_tc( diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 6f70700113..39dc870e9b 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1872,6 +1872,7 @@ void ivas_spar_dec_upmixer( cldfb_in_ts_im[out_ch][ts][cldfb_band] = out_im[out_ch]; } } + #ifdef JBM_TSM_ON_TCS if ( ( ( slot_idx_start + ts + 1 ) == hSpar->num_slots ) || ( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ) != ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) ) { @@ -2030,10 +2031,12 @@ void ivas_spar_dec_upmixer( #ifndef JBM_TSM_ON_TCS } #endif + #ifdef JBM_TSM_ON_TCS hSpar->slots_rendered += hSpar->subframe_nbslots[hSpar->subframes_rendered]; hSpar->subframes_rendered++; #endif + pop_wmops(); return; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 711c55b160..0e7a9ae856 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1356,7 +1356,7 @@ typedef struct Decoder_Struct #ifdef JBM_TSM_ON_TCS /* JBM module */ - DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ #endif #ifdef DEBUGGING diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 62e83686a0..a170a8b393 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -907,6 +907,7 @@ static ivas_error IVAS_DEC_Setup( Decoder_Struct *st_ivas; st_ivas = hIvasDec->st_ivas; + /*----------------------------------------------------------------* * IVAS decoder setup * - read IVAS format signaling @@ -2271,11 +2272,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #if defined( VARIABLE_SPEED_DECODING ) || defined( JBM_TSM_ON_TCS ) ivas_error IVAS_DEC_VoIP_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_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 */ 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 */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ + int16_t *nSamplesFlushed /* o : number of samples flushed */ ) { ivas_error error; diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 7affa9a913..4baae9d082 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -44,13 +44,13 @@ #include "wmc_auto.h" +#ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------* - * ivas_sba_prototype_renderer() + * ivas_sba_prototype_renderer_sf() * * Render prototype audio signals using SBA mixing matrices *-------------------------------------------------------------------*/ -#ifdef JBM_TSM_ON_TCS void ivas_sba_prototype_renderer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ @@ -206,6 +206,12 @@ void ivas_sba_prototype_renderer_sf( #ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS +/*-------------------------------------------------------------------* + * ivas_sba_prototype_renderer() + * + * Render prototype audio signals using SBA mixing matrices + *-------------------------------------------------------------------*/ + void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ @@ -329,6 +335,7 @@ void ivas_sba_prototype_renderer( inIm[out_ch][ts][cldfb_band] = out_im[out_ch]; } } + #ifdef JBM_TSM_ON_TCS /* Update mixing matrices */ if ( ( ( slot_idx_start + ts + 1 ) == hSpar->num_slots ) || ( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ) != ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) ) -- GitLab From 2abbd763ad7d989ce053cae18577849972b7b172 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 May 2023 10:51:42 +0200 Subject: [PATCH 06/17] typo in print-out --- apps/decoder.c | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 62c72fea0e..e44bc61764 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1365,7 +1365,7 @@ static void usage_dec( void ) fprintf( stdout, "-VOIP_no_bad_frame : VoIP mode: do not put out bad frames in the beginning as silence \n" ); #endif #ifdef VARIABLE_SPEED_DECODING - fprintf( stdout, "-VS fac : Varaible Speed mode: change speed of playout fac as integer in percent. fac<100 faster, fac>100 slower\n" ); + fprintf( stdout, "-VS fac : Variable Speed mode: change speed of playout fac as integer in percent. fac<100 faster, fac>100 slower\n" ); #endif #ifdef JBM_TSM_ON_TCS #ifdef DEBUG_JBM_CMD_OPTION diff --git a/readme.txt b/readme.txt index 5660aa353f..45cde4e9d0 100644 --- a/readme.txt +++ b/readme.txt @@ -245,7 +245,7 @@ Options: The decoder may read rtpdump files containing TS26.445 Annex A.2.2 EVS RTP Payload Format. The SDP parameter hf_only is required. Reading RFC4867 AMR/AMR-WB RTP payload format is not supported. --VS fac : Varaible Speed mode: change speed of playout fac as integer in percent. +-VS fac : Variable Speed mode: change speed of playout fac as integer in percent. fac<100 faster, fac>100 slower -Tracefile TF : VoIP mode: Generate trace file named TF -fec_cfg_file : Optimal channel aware configuration computed by the JBM -- GitLab From 039a66b4566f873c89f8b65c16bb160997a8ae78 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 17 May 2023 09:37:57 +0000 Subject: [PATCH 07/17] Update decoder.c: initialize bool data type parameter to 'false' instead of 0 --- apps/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index e44bc61764..852e0bf373 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -858,7 +858,7 @@ static bool parseCmdlIVAS_dec( arg->no_diegetic_pan = 0.f; #endif #ifdef VARIABLE_SPEED_DECODING - arg->variableSpeedMode = 0; + arg->variableSpeedMode = false; arg->tsmScale = 100; arg->tsmScaleFileEnabled = false; arg->tsmScaleFileName = NULL; -- GitLab From ba929d409bf1c4da21f08381c6af8656eaf30bbb Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 22 May 2023 10:00:27 +0200 Subject: [PATCH 08/17] - move IVAS_DEC_EnableVoIP() - print-out VoIP and VS info --- apps/decoder.c | 51 +++++++++++++++++++++++++++++++++++++---------- lib_dec/lib_dec.c | 13 +++++++++++- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 24a9fc5959..1f36e17f24 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -398,6 +398,31 @@ int main( goto cleanup; } +#ifdef JBM_TSM_ON_TCS + /*------------------------------------------------------------------------------------------* + * Configure VoIP mode + *------------------------------------------------------------------------------------------*/ + + if ( arg.voipMode ) + { + if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VOIP, 100, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#ifdef VARIABLE_SPEED_DECODING + else if ( arg.variableSpeedMode ) + { + if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VARIABLE_SPEED, arg.tsmScale, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCould not enable Variable Play Speed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#endif +#endif + #ifdef DEBUGGING /*-----------------------------------------------------------------* * Preview bitstream and print config information @@ -428,6 +453,20 @@ int main( BS_Reader_Rewind( hBsReader ); IVAS_DEC_PrintConfigWithBitstream( hIvasDec, arg.quietModeEnabled, bit_stream, num_bits ); + +#ifdef VARIABLE_SPEED_DECODING + if ( arg.variableSpeedMode ) + { + if ( arg.tsmScaleFileEnabled ) + { + fprintf( stdout, "Variable speed file: %s\n", arg.tsmScaleFileName ); + } + else + { + fprintf( stdout, "Variable speed factor: %i\n", arg.tsmScale ); + } + } +#endif } /*------------------------------------------------------------------------------------------* @@ -592,30 +631,22 @@ int main( if ( arg.voipMode ) { -#ifdef JBM_TSM_ON_TCS - if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VOIP, 100, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) -#else +#ifndef JBM_TSM_ON_TCS #ifdef VARIABLE_SPEED_DECODING if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VOIP, 100, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) -#endif #endif { fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - +#endif error = decodeVoIP( arg, hBsReader, hIvasDec ); } #ifdef VARIABLE_SPEED_DECODING else if ( arg.variableSpeedMode ) { - if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VARIABLE_SPEED, arg.tsmScale, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nCould not enable Variable Play Speed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } error = decodeVariableSpeed( arg, hBsReader, headRotReader, refRotReader, referenceVectorReader, hIvasDec ); } #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 337864b553..54a212240c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2671,7 +2671,7 @@ static ivas_error printConfigInfo_dec( } /*-----------------------------------------------------------------* - * Print number of output configuration + * Print output configuration *-----------------------------------------------------------------*/ if ( st_ivas->ivas_format == MONO_FORMAT ) @@ -2790,6 +2790,17 @@ static ivas_error printConfigInfo_dec( } } +#ifdef JBM_TSM_ON_TCS + /*-----------------------------------------------------------------* + * Print VoIP mode info + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDecoderConfig->voip_active ) + { + fprintf( stdout, "VoIP mode: ON\n" ); + } +#endif + return IVAS_ERR_OK; } -- GitLab From 130b1ea156e989c49369dfc49361be84e72bb7c9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 22 May 2023 10:11:06 +0200 Subject: [PATCH 09/17] put variable speed decoding under DEBUGGING --- apps/decoder.c | 33 +++++++++++++++++++++------------ readme.txt | 2 -- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 1f36e17f24..bf69c8a2da 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -127,8 +127,6 @@ typedef struct #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ #endif - -#endif #ifdef DEBUG_JBM_CMD_OPTION bool noBadFrameDelay; #endif @@ -143,6 +141,7 @@ typedef struct uint16_t frontendFetchSizeMs; #endif #endif +#endif } DecArguments; @@ -155,10 +154,10 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, HeadRotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING static ivas_error decodeVariableSpeed( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, HeadRotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #endif -#ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); @@ -412,6 +411,7 @@ int main( } } #ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING else if ( arg.variableSpeedMode ) { if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VARIABLE_SPEED, arg.tsmScale, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) @@ -422,6 +422,7 @@ int main( } #endif #endif +#endif #ifdef DEBUGGING /*-----------------------------------------------------------------* @@ -455,6 +456,7 @@ int main( IVAS_DEC_PrintConfigWithBitstream( hIvasDec, arg.quietModeEnabled, bit_stream, num_bits ); #ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING if ( arg.variableSpeedMode ) { if ( arg.tsmScaleFileEnabled ) @@ -466,6 +468,7 @@ int main( fprintf( stdout, "Variable speed factor: %i\n", arg.tsmScale ); } } +#endif #endif } @@ -645,10 +648,12 @@ int main( error = decodeVoIP( arg, hBsReader, hIvasDec ); } #ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING else if ( arg.variableSpeedMode ) { error = decodeVariableSpeed( arg, hBsReader, headRotReader, refRotReader, referenceVectorReader, hIvasDec ); } +#endif #endif else { @@ -876,6 +881,8 @@ static bool parseCmdlIVAS_dec( arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->Opt_non_diegetic_pan = 0; arg->non_diegetic_pan_gain = 0.f; + +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING arg->variableSpeedMode = false; arg->tsmScale = 100; @@ -889,6 +896,7 @@ static bool parseCmdlIVAS_dec( #endif #ifdef DEBUG_JBM_CMD_OPTION arg->noBadFrameDelay = false; +#endif #endif /*-----------------------------------------------------------------* @@ -1015,7 +1023,6 @@ static bool parseCmdlIVAS_dec( } #endif /* #ifdef DEBUG_MODE_INFO_TWEAK */ #endif /* #ifdef DEBUG_MODE_INFO */ -#endif /* #ifdef DEBUGGING */ #ifdef DEBUG_JBM_CMD_OPTION else if ( strcmp( argv_to_upper, "-VOIP_NO_BAD_FRAME" ) == 0 ) { @@ -1072,6 +1079,7 @@ static bool parseCmdlIVAS_dec( } #endif #endif +#endif /* #ifdef DEBUGGING */ else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) { @@ -1348,6 +1356,13 @@ static void usage_dec( void ) #ifdef DEBUG_JBM_CMD_OPTION fprintf( stdout, "-VOIP_no_bad_frame : VoIP mode: do not put out bad frames in the beginning as silence \n" ); #endif + fprintf( stdout, " The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" ); + fprintf( stdout, " EVS RTP Payload Format. The SDP parameter hf_only is required.\n" ); + fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" ); +#ifdef SUPPORT_JBM_TRACEFILE + fprintf( stdout, "-Tracefile TF : VoIP mode: Generate trace file named TF\n" ); +#endif +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING fprintf( stdout, "-VS fac : Variable Speed mode: change speed of playout fac as integer in percent. fac<100 faster, fac>100 slower\n" ); #endif @@ -1355,13 +1370,7 @@ static void usage_dec( void ) #ifdef DEBUG_JBM_CMD_OPTION fprintf( stdout, "-VOIP_framesize : VoIP mode: acoustic frontend fetch frame size (must be multiples of 5!)\n" ); #endif - #endif - fprintf( stdout, " The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" ); - fprintf( stdout, " EVS RTP Payload Format. The SDP parameter hf_only is required.\n" ); - fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" ); -#ifdef SUPPORT_JBM_TRACEFILE - fprintf( stdout, "-Tracefile TF : VoIP mode: Generate trace file named TF\n" ); #endif fprintf( stdout, "-fec_cfg_file : Optimal channel aware configuration computed by the JBM \n" ); fprintf( stdout, " as described in Section 6.3.1 of TS26.448. The output is \n" ); @@ -2474,6 +2483,7 @@ cleanup: } +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING /*---------------------------------------------------------------------* * decodeVariableSpeed() @@ -3005,10 +3015,9 @@ cleanup: return error; } - #endif -#ifdef DEBUGGING + /*---------------------------------------------------------------------* * parseForcedRendModeDec() * diff --git a/readme.txt b/readme.txt index 45cde4e9d0..21a5a19e79 100644 --- a/readme.txt +++ b/readme.txt @@ -245,8 +245,6 @@ Options: The decoder may read rtpdump files containing TS26.445 Annex A.2.2 EVS RTP Payload Format. The SDP parameter hf_only is required. Reading RFC4867 AMR/AMR-WB RTP payload format is not supported. --VS fac : Variable Speed mode: change speed of playout fac as integer in percent. - fac<100 faster, fac>100 slower -Tracefile TF : VoIP mode: Generate trace file named TF -fec_cfg_file : Optimal channel aware configuration computed by the JBM as described in Section 6.3.1 of TS26.448. The output is -- GitLab From 6c90257eb62cc177694048fef5fb631702947279 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 22 May 2023 10:19:38 +0200 Subject: [PATCH 10/17] sanity check for scaling factor limitation --- apps/decoder.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index bf69c8a2da..72f30f6fed 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1031,7 +1031,6 @@ static bool parseCmdlIVAS_dec( } #endif #ifdef VARIABLE_SPEED_DECODING - else if ( strcmp( argv_to_upper, "-VS" ) == 0 ) { i++; @@ -1045,7 +1044,6 @@ static bool parseCmdlIVAS_dec( arg->tsmScaleFileName = argv[i]; i++; } - else { if ( ( sscanf( argv[i], "%d", &tmp ) > 0 ) ) @@ -1054,6 +1052,13 @@ static bool parseCmdlIVAS_dec( } } arg->tsmScale = (uint16_t) tmp; + + if ( arg->tsmScale < 50 || arg->tsmScale > 150 ) + { + fprintf( stderr, "Error: Scaling factor value must be 50 <= fac <= 150!\n\n" ); + usage_dec(); + return false; + } } } #endif @@ -1364,7 +1369,8 @@ static void usage_dec( void ) #endif #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING - fprintf( stdout, "-VS fac : Variable Speed mode: change speed of playout fac as integer in percent. fac<100 faster, fac>100 slower\n" ); + fprintf( stdout, "-VS fac : Variable Speed mode: change speed of playout fac as integer in percent.\n" ); + fprintf( stdout, " 50 <= fac <= 150; fac<100 faster, fac>100 slower\n" ); #endif #ifdef JBM_TSM_ON_TCS #ifdef DEBUG_JBM_CMD_OPTION -- GitLab From 48dd19d5a7af3db3d3b0da49678fef123076aaee Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 22 May 2023 10:32:57 +0200 Subject: [PATCH 11/17] clang-format --- lib_dec/ivas_dirac_dec.c | 22 ++++++++++---------- lib_dec/ivas_spar_decoder.c | 10 ++++----- lib_rend/ivas_dirac_dec_binaural_functions.c | 21 +++++-------------- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 501d8dc442..2ef3a1056b 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -420,12 +420,12 @@ ivas_error ivas_dirac_dec_config( { return error; } - } + } else if ( st_ivas->hDecoderConfig->ivas_total_brate <= IVAS_256k && hDirAC->azimuth2 != NULL ) { ivas_dirac_deallocate_parameters( hDirAC, 2 ); - } } + } /* band config needed only for SPAR with FOA output */ if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA && st_ivas->sba_mode == SBA_MODE_SPAR && !hodirac_flag ) @@ -707,9 +707,9 @@ ivas_error ivas_dirac_dec_config( { hDirAC->proto_index_dir[hDirAC->sba_map_tc[k]] = k; } - } } } + } /* direct/diffuse responses */ if ( flag_config == DIRAC_OPEN ) @@ -1079,7 +1079,7 @@ ivas_error ivas_dirac_dec_config( { return error; } - } + } else { hDirAC->azimuth2 = NULL; @@ -1102,7 +1102,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->hConfig->dec_param_estim_old != hDirAC->hConfig->dec_param_estim ) ) { ivas_dirac_deallocate_parameters( hDirAC, 1 ); - } + } hDirAC->dirac_md_buffer_length = ( MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_DIRAC_PARAM_DEC_SFR ) * num_slots_in_subfr; hDirAC->dirac_bs_md_write_idx = DELAY_DIRAC_PARAM_DEC_SFR * num_slots_in_subfr; hDirAC->spar_to_dirac_write_idx = DELAY_DIRAC_PARAM_DEC_SFR * num_slots_in_subfr; @@ -1113,8 +1113,8 @@ ivas_error ivas_dirac_dec_config( { return error; } - } - } + } + } #ifdef JBM_TSM_ON_TCS /* allocate transport channels*/ @@ -1715,8 +1715,8 @@ void ivas_dirac_dec_read_BS( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */ int16_t *nb_bits, /* o : number of bits read */ const SBA_MODE sba_mode, /* i : SBA mode */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { int16_t i, j, b, dir, orig_dirac_bands; @@ -1899,8 +1899,8 @@ void ivas_qmetadata_to_dirac( MASA_DECODER_HANDLE hMasa, /* i : MASA decoder structure */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const SBA_MODE sba_mode, /* i : SBA mode */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { int16_t block, band; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index a99cdba7ff..7609099b5f 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -972,8 +972,8 @@ static void ivas_spar_get_skip_mat( } } } - } - } + } + } return; } @@ -1331,7 +1331,7 @@ void ivas_spar_dec_upmixer( mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); } } - } + } ivas_spar_dec_set_render_params( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); @@ -1561,7 +1561,7 @@ void ivas_spar_dec_upmixer( mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], output[nchan_internal - 1 - i], output_frame ); } } - } + } #endif hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; @@ -1720,7 +1720,7 @@ void ivas_spar_dec_upmixer( out_im[out_ch] += cldfb_in_ts_im[in_ch][ts][cldfb_band] * cldfb_par; } } - } + } /*update CLDFB data with the parameter-modified data*/ for ( out_ch = 0; out_ch < numch_out; out_ch++ ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index ae338277af..525935ffbf 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -52,7 +52,7 @@ * Local constants *------------------------------------------------------------------------*/ -#define CLDFB_HALF_BIN_FREQUENCY_OFFSET 0.5f +#define CLDFB_HALF_BIN_FREQUENCY_OFFSET 0.5f #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN ( 2.0f ) #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f ) @@ -93,7 +93,6 @@ static void adaptTransportSignalsHeadtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackD static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nBins, float Rmat[3][3] ); #endif - static void formulate2x2MixingMatrix( float Ein1, float Ein2, float CinRe, float CinIm, float Eout1, float Eout2, float CoutRe, float CoutIm, float Q[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Mre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Mim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], const float regularizationFactor ); static void hrtfShGetHrtf( const int16_t bin, const int16_t aziDeg, const int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp ); @@ -105,10 +104,6 @@ static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Ai static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); -#ifdef JBM_TSM_ON_TCS -#endif - - /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -213,7 +208,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - } + } else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) { set_f( hBinaural->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); @@ -442,7 +437,6 @@ void ivas_dirac_dec_binaural( { ivas_spar_dec_set_render_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); } - #endif if ( st_ivas->hDiracDecBin->useTdDecorr ) @@ -510,8 +504,7 @@ void ivas_dirac_dec_binaural( /*------------------------------------------------------------------------- * Local functions *------------------------------------------------------------------------*/ -#ifdef JBM_TSM_ON_TCS -#endif + static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, @@ -1374,8 +1367,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( return; } -#ifdef JBM_TSM_ON_TCS -#endif static void ivas_dirac_dec_binaural_process_output( Decoder_Struct *st_ivas, @@ -1511,8 +1502,6 @@ static void ivas_dirac_dec_binaural_process_output( return; } -#ifdef JBM_TSM_ON_TCS -#endif static void adaptTransportSignalsHeadtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, @@ -2200,8 +2189,8 @@ static void hrtfShGetHrtf( /*! r: Configured reqularization factor value */ float configure_reqularization_factor( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) { float reqularizationFactor; -- GitLab From 54ec1fe8a2154b3b500df53054b196b969fb24fa Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 22 May 2023 11:43:02 +0200 Subject: [PATCH 12/17] - more code under DEBUGGING - change "uint8_t mode" to "IVAS_DEC_VOIP_MODE voipMode" --- apps/decoder.c | 5 ++++- lib_com/ivas_error.h | 6 +++--- lib_com/options.h | 2 +- lib_dec/lib_dec.c | 30 +++++++++++++++++------------- lib_dec/lib_dec.h | 2 ++ 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 72f30f6fed..e35f1a9def 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2598,6 +2598,7 @@ static ivas_error decodeVariableSpeed( goto cleanup; } } + /* Reference rotation */ if ( arg.enableReferenceRotation ) { @@ -2614,6 +2615,7 @@ static ivas_error decodeVariableSpeed( goto cleanup; } } + /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -2644,12 +2646,13 @@ static ivas_error decodeVariableSpeed( writeJbmTraceFileFrameWrapper, jbmTraceWriter #endif ); - if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED ) + if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + if ( error == IVAS_ERR_VS_FRAME_NEEDED ) { if ( arg.tsmScaleFileEnabled ) diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index ce51109207..1b03606d76 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -87,14 +87,14 @@ typedef enum IVAS_ERR_ISM_INVALID_METADATA_VALUE, IVAS_ERR_INVALID_MASA_FORMAT_METADATA_FILE, IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, -#ifdef VARIABLE_SPEED_DECODING - IVAS_ERR_VS_FRAME_NEEDED, -#endif #ifdef DEBUGGING IVAS_ERR_INVALID_FORCE_MODE, #ifdef DEBUG_AGC_ENCODER_CMD_OPTION IVAS_ERR_INVALID_AGC, #endif +#ifdef VARIABLE_SPEED_DECODING + IVAS_ERR_VS_FRAME_NEEDED, +#endif #endif /*----------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 6f282f9d3b..4267e213c3 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/lib_dec.c b/lib_dec/lib_dec.c index 54a212240c..265af66a56 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -63,7 +63,7 @@ struct IVAS_DEC_VOIP JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ uint16_t *bs_conversion_buf; /* Buffer for bitstream conversion from packed to serial */ #ifdef VARIABLE_SPEED_DECODING - uint8_t mode; + IVAS_DEC_VOIP_MODE voipMode; uint16_t speedFac; bool needNewFrame; #endif @@ -588,7 +588,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->lastDecodedWasActive = 0; hIvasDec->hVoIP->hCurrentDataUnit = NULL; #ifdef VARIABLE_SPEED_DECODING - hIvasDec->hVoIP->mode = voipMode; + hIvasDec->hVoIP->voipMode = voipMode; hIvasDec->hVoIP->speedFac = speedFac; hIvasDec->hVoIP->needNewFrame = false; #endif @@ -627,7 +627,7 @@ ivas_error IVAS_DEC_EnableVoIP( /* initialize JBM */ #ifdef VARIABLE_SPEED_DECODING hIvasDec->hVoIP->hJBM = NULL; - if ( hIvasDec->hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) + if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VOIP ) { #endif if ( ( error = JB4_Create( &hIvasDec->hVoIP->hJBM ) != IVAS_ERR_OK ) != IVAS_ERR_OK ) @@ -674,7 +674,7 @@ ivas_error IVAS_DEC_EnableVoIP( /* create output pcm fifo*/ /* :TODO: also provide CLDFB output FIFO if things work out */ #ifdef VARIABLE_SPEED_DECODING - if ( hIvasDec->hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) + if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { hIvasDec->hVoIP->needNewFrame = true; } @@ -798,7 +798,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } #ifdef VARIABLE_SPEED_DECODING - if ( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) + if ( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { hIvasDec->hVoIP->needNewFrame = false; } @@ -1772,6 +1772,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( } #ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_SetScale( ) * @@ -1792,6 +1793,7 @@ ivas_error IVAS_DEC_VoIP_SetScale( return error; } #endif +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) @@ -1869,6 +1871,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( while ( pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ) < nSamplesPerChannel ) #endif { +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->needNewFrame ) { @@ -1877,6 +1880,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_VS_FRAME_NEEDED; } #endif +#endif #ifdef JBM_TSM_ON_TCS if ( hVoIP->nSamplesAvailableNext == 0 ) @@ -1898,7 +1902,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dataUnit = NULL; #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VOIP ) { #endif /* pop one access unit from the jitter buffer */ @@ -1909,7 +1913,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #ifdef VARIABLE_SPEED_DECODING } - else if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) + else if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { scale = hVoIP->speedFac; maxScaling = hVoIP->speedFac; @@ -1937,7 +1941,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VOIP ) { #endif /* copy bitstream into decoder state */ @@ -2031,7 +2035,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VOIP ) { #endif if ( dataUnit ) @@ -2189,7 +2193,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( nSamplesRendered += nSamplesRendered_loop; #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext == 0 ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext == 0 ) { hVoIP->needNewFrame = true; } @@ -2204,7 +2208,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hVoIP->nSamplesAvailableNext = max( 0, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ) - nSamplesPerChannel ); #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext < nSamplesPerChannel ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext < nSamplesPerChannel ) { hVoIP->needNewFrame = true; } @@ -3265,7 +3269,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( DECODER_CONFIG_HANDLE hDecoderConfig; #ifdef VARIABLE_SPEED_DECODING - startQuality = hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ? -2.0f : 1.0f; + startQuality = hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ? -2.0f : 1.0f; #else startQuality = 1.0f; #endif @@ -3324,7 +3328,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( } } #ifdef VARIABLE_SPEED_DECODING - else if ( hIvasDec->hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) + else if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { if ( pcmdsp_fifo_create( &hIvasDec->hVoIP->hFifoOut ) != 0 || pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, (uint16_t) ( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 3d632b6b15..16dcecb112 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -222,12 +222,14 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( ); #ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING /*! r: error code */ ivas_error IVAS_DEC_VoIP_SetScale( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t scale /* i : TSM scale to set */ ); #endif +#endif /*! r: error code */ ivas_error IVAS_DEC_VoIP_GetSamples( -- GitLab From 9dcdba30695ab8ad6574045fc26a4625e17e9d91 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 22 May 2023 12:14:55 +0200 Subject: [PATCH 13/17] re-enable DEBUGGING switch --- lib_com/options.h | 2 +- lib_dec/lib_dec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4267e213c3..6f282f9d3b 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/lib_dec.c b/lib_dec/lib_dec.c index 265af66a56..ff02bb1782 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1873,7 +1873,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->needNewFrame ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->needNewFrame ) { /* we need another bs frame fed into the decoder...*/ *sampleAvailableNext = 0; -- GitLab From 62a690006520a66679870ad3f8cd9c62bf84a5ca Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 May 2023 14:20:00 +0200 Subject: [PATCH 14/17] remove dead code in ivas_sba_prototype_renderer_sf() --- lib_com/ivas_prot.h | 8 -- lib_rend/ivas_sba_rendering.c | 161 ---------------------------------- 2 files changed, 169 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index eb023c8b20..556daf327b 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4351,14 +4351,6 @@ void ivas_sba_mix_matrix_determiner( const int16_t output_frame /* i : output frame length */ ); -#ifdef JBM_TSM_ON_TCS -void ivas_sba_prototype_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* i : Input audio in CLDFB domain, imag */ -); -#endif - /* AGC */ /*! r: AGC enable flag */ int16_t ivas_agc_enc_get_flag( diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index fe57ed3e03..059cd847e1 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -44,167 +44,6 @@ #include "wmc_auto.h" -#ifdef JBM_TSM_ON_TCS -/*-------------------------------------------------------------------* - * ivas_sba_prototype_renderer_sf() - * - * Render prototype audio signals using SBA mixing matrices - *-------------------------------------------------------------------*/ - -void ivas_sba_prototype_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* i : Input audio in CLDFB domain, imag */ -) -{ - float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; - SPAR_DEC_HANDLE hSpar; - DECODER_CONFIG_HANDLE hDecoderConfig; - int16_t num_spar_bands, spar_band; - int16_t b, ts; - int16_t num_cldfb_bands, numch_in, numch_out; - int16_t cldfb_band; - int16_t out_ch, in_ch; - int16_t firstInCh, inChEnd, firstOutCh, outChEnd; - int16_t slot_idx_start; - - push_wmops( "ivas_sba_prototype_renderer" ); - - hSpar = st_ivas->hSpar; - hDecoderConfig = st_ivas->hDecoderConfig; - num_spar_bands = hSpar->hFbMixer->pFb->filterbank_num_bands; - - num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; - numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; - - if ( st_ivas->nchan_transport == 1 ) - { - firstInCh = 0; - inChEnd = 1; - firstOutCh = 0; - outChEnd = 1; - } - else /* 2 TC */ - { - firstInCh = 0; - inChEnd = 2; - firstOutCh = 1; - outChEnd = 2; - } - slot_idx_start = hSpar->slots_rendered; - - /* Apply mixing matrix */ - for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) - { - int16_t md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; - - /* determine SPAR parameters for this time slot */ - ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); - - for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) - { - float out_re[IVAS_SPAR_MAX_CH]; - float out_im[IVAS_SPAR_MAX_CH]; - float cldfb_par; - ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band; - - for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) - { - out_re[out_ch] = 0.0f; - out_im[out_ch] = 0.0f; - - for ( in_ch = firstInCh; in_ch < inChEnd; in_ch++ ) - { - if ( cldfb_band < CLDFB_PAR_WEIGHT_START_BAND ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */ - { - spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; - cldfb_par = mixer_mat[out_ch][in_ch][spar_band]; - } - else - { - cldfb_par = 0.0f; - for ( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) - { - /* accumulate contributions from all SPAR bands */ - cldfb_par += mixer_mat[out_ch][in_ch][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band]; - } - } - - out_re[out_ch] += inRe[in_ch][ts][cldfb_band] * cldfb_par; - out_im[out_ch] += inIm[in_ch][ts][cldfb_band] * cldfb_par; - } - } - - /*update CLDFB data with the parameter-modified data*/ - for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) - { - inRe[out_ch][ts][cldfb_band] = out_re[out_ch]; - inIm[out_ch][ts][cldfb_band] = out_im[out_ch]; - } - } - - /* Update mixing matrices */ - if ( ( ( slot_idx_start + ts + 1 ) == hSpar->num_slots ) || ( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ) != ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) ) - { - /* we have crossed an unadapted parameter sf border, update previous mixing matrices */ - int16_t md_sf = md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME; - hSpar->i_subframe++; - hSpar->i_subframe = min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); - mvr2r( hSpar->hMdDec->mixer_mat_prev[1][0][0], hSpar->hMdDec->mixer_mat_prev[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - mvr2r( hSpar->hMdDec->mixer_mat_prev[2][0][0], hSpar->hMdDec->mixer_mat_prev[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - - for ( out_ch = 0; out_ch < numch_out; out_ch++ ) - { - for ( in_ch = 0; in_ch < numch_in; in_ch++ ) - { - for ( b = 0; b < num_spar_bands; b++ ) - { - hSpar->hMdDec->mixer_mat_prev[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][b + md_sf * IVAS_MAX_NUM_BANDS]; - } - } - } - } - } - - /* Create prototypes */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) - { - if ( st_ivas->nchan_transport == 1 ) /* Dual mono */ - { - mvr2r( inRe[0][ts], inRe[1][ts], CLDFB_NO_CHANNELS_MAX ); - mvr2r( inIm[0][ts], inIm[1][ts], CLDFB_NO_CHANNELS_MAX ); - } - else if ( st_ivas->nchan_transport == 2 ) /* Opposing cardioids */ - { - float temp_signal[CLDFB_NO_CHANNELS_MAX]; - - v_add( inRe[0][ts], inRe[1][ts], temp_signal, CLDFB_NO_CHANNELS_MAX ); - v_sub( inRe[0][ts], inRe[1][ts], inRe[1][ts], CLDFB_NO_CHANNELS_MAX ); - mvr2r( temp_signal, inRe[0][ts], CLDFB_NO_CHANNELS_MAX ); - v_multc( inRe[0][ts], 0.5f, inRe[0][ts], CLDFB_NO_CHANNELS_MAX ); - v_multc( inRe[1][ts], 0.5f, inRe[1][ts], CLDFB_NO_CHANNELS_MAX ); - - v_add( inIm[0][ts], inIm[1][ts], temp_signal, CLDFB_NO_CHANNELS_MAX ); - v_sub( inIm[0][ts], inIm[1][ts], inIm[1][ts], CLDFB_NO_CHANNELS_MAX ); - mvr2r( temp_signal, inIm[0][ts], CLDFB_NO_CHANNELS_MAX ); - v_multc( inIm[0][ts], 0.5f, inIm[0][ts], CLDFB_NO_CHANNELS_MAX ); - v_multc( inIm[1][ts], 0.5f, inIm[1][ts], CLDFB_NO_CHANNELS_MAX ); - } - } - } - - pop_wmops(); - - return; -} -#endif - - /*-------------------------------------------------------------------* * ivas_sba_prototype_renderer() * -- GitLab From 7b1e13d589b4dcea8939cca4e1f1a979959eba79 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 May 2023 14:24:12 +0200 Subject: [PATCH 15/17] put pcmdsp_fifo_write_zero() under DEBUGGING --- lib_dec/jbm_pcmdsp_fifo.c | 2 ++ lib_dec/jbm_pcmdsp_fifo.h | 3 +++ lib_dec/lib_dec.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/lib_dec/jbm_pcmdsp_fifo.c b/lib_dec/jbm_pcmdsp_fifo.c index fd0df04ca8..108b069402 100644 --- a/lib_dec/jbm_pcmdsp_fifo.c +++ b/lib_dec/jbm_pcmdsp_fifo.c @@ -176,6 +176,7 @@ int16_t pcmdsp_fifo_write( } #ifdef JBM_TSM_ON_TCS +#ifdef DEBUGGING /* Writes the given audio data to the FIFO. */ int16_t pcmdsp_fifo_write_zero( PCMDSP_FIFO_HANDLE h, @@ -217,6 +218,7 @@ int16_t pcmdsp_fifo_write_zero( return 0; } #endif +#endif /* Reads the given number of audio samples from the FIFO. */ int16_t pcmdsp_fifo_read( diff --git a/lib_dec/jbm_pcmdsp_fifo.h b/lib_dec/jbm_pcmdsp_fifo.h index e6c64dc9e8..d16bd2b8d2 100644 --- a/lib_dec/jbm_pcmdsp_fifo.h +++ b/lib_dec/jbm_pcmdsp_fifo.h @@ -73,9 +73,12 @@ void pcmdsp_fifo_destroy( PCMDSP_FIFO_HANDLE *ph ); ivas_error pcmdsp_fifo_init( PCMDSP_FIFO_HANDLE h, uint16_t nSamplesPerChannel, uint16_t nChannels, uint16_t nBytesPerSample ); int16_t pcmdsp_fifo_write( PCMDSP_FIFO_HANDLE h, const uint8_t *samples, uint16_t nSamplesPerChannel ); + #ifdef JBM_TSM_ON_TCS +#ifdef DEBUGGING int16_t pcmdsp_fifo_write_zero( PCMDSP_FIFO_HANDLE h, uint16_t nSamplesPerChannel ); #endif +#endif int16_t pcmdsp_fifo_read( PCMDSP_FIFO_HANDLE h, uint16_t nSamplesPerChannel, uint8_t *samples ); diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0b1cf119ac..b2fd7feeab 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1977,11 +1977,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( nSamplesTcsScaled = hVoIP->nSamplesFrame; if ( hVoIP->hFifoOut != NULL ) { +#ifdef DEBUGGING /* feed zeros to FIFO */ if ( pcmdsp_fifo_write_zero( hVoIP->hFifoOut, nSamplesTcsScaled ) != 0 ) { return IVAS_ERR_UNKNOWN; } +#endif } else { -- GitLab From 807246f52edaa7c78fa2ee4ceb10df3455854a1f Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 25 May 2023 13:32:36 +0200 Subject: [PATCH 16/17] adress remaining ToDo comments, mainly invalid, last valid one done --- lib_dec/ivas_jbm_dec.c | 1 - lib_dec/lib_dec.c | 33 ++++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index e9c5fc91e9..0c37da2bdf 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1732,7 +1732,6 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_BUFFER; - /*:TODO: wrap this maybe nicer without directly accessing the st_ivas struct...*/ switch ( st_ivas->renderer_type ) { /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b2fd7feeab..fc8716c9c1 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -128,6 +128,7 @@ static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferG static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, int16_t *pcmBuf ); +static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); #endif /*---------------------------------------------------------------------* @@ -669,10 +670,8 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #ifdef JBM_TSM_ON_TCS - /* postpone init of time scaler until we know the real number of TCs */ + /* postpone init of time scaler and output FIFO until we know the real number of TCs */ hIvasDec->hVoIP->hTimeScaler = NULL; - /* create output pcm fifo*/ - /* :TODO: also provide CLDFB output FIFO if things work out */ #ifdef VARIABLE_SPEED_DECODING if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { @@ -1043,6 +1042,25 @@ ivas_error IVAS_DEC_GetRenderedSamples( } + return error; +} + +ivas_error IVAS_DEC_GetBufferedNumberOfSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o : IVAS decoder handle */ + int16_t *nSamplesBuffered /* o : number of samples still buffered */ +) +{ + ivas_error error; + error = IVAS_ERR_OK; + + *nSamplesBuffered = 0; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered; + return error; } #endif @@ -1862,7 +1880,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( maxScaling = hVoIP->speedFac; #endif - /* TODO(mcjbm): ringbuffer capacity should be configurable by user */ #ifdef JBM_TSM_ON_TCS if ( ( hVoIP->hFifoOut != NULL && nSamplesPerChannel > hVoIP->hFifoOut->capacity ) || nSamplesPerChannel == 0 ) #else @@ -1900,7 +1917,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } else { - extBufferedSamples = nSamplesRendered; /* TODO: JBM use renderer residual samples here */ + int16_t nSamplesBuffered; + nSamplesBuffered = 0; + if ( hIvasDec->hasBeenFedFirstGoodFrame ) + { + IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ); + } + extBufferedSamples = nSamplesRendered + nSamplesBuffered; } #else extBufferedSamples = pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ); -- GitLab From 111ef87ed077e370dfb8eaf1d246c4d970c50b6b Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 25 May 2023 14:25:16 +0200 Subject: [PATCH 17/17] clang-format --- lib_dec/ivas_objectRenderer_internal.c | 2 +- lib_dec/lib_dec.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 65ae2de79b..ba14104ed9 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -188,7 +188,7 @@ ivas_error ivas_td_binaural_renderer_sf( } if ( subframe_idx == ism_md_subframe_update_jbm ) { - TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, st_ivas->ivas_format, st_ivas->hIsmMetaData ); + TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, st_ivas->ivas_format, st_ivas->hIsmMetaData ); } #else TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, tc_local ); diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 879188a1fd..2042911833 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -452,7 +452,7 @@ ivas_error IVAS_DEC_Configure( const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ const int16_t delayCompensationEnabled /* i : enable delay compensation */ #else - const float non_diegetic_pan_gain /* i : non diegetic panning gain */ + const float non_diegetic_pan_gain /* i : non diegetic panning gain */ #endif ) { @@ -909,10 +909,10 @@ static ivas_error IVAS_DEC_Setup( else { #endif - *nTransportChannels = 1; - *nOutChannels = 1; + *nTransportChannels = 1; + *nOutChannels = 1; #ifdef FIX_473_JITTER_NONDIEGETIC_PANNING - } + } #endif } else -- GitLab