From a929ee31a3796c5361337720fe210d1444c255ba Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 14:10:37 +0200 Subject: [PATCH 01/12] issue 876: fixes within NONBE_UNIFIED_DECODING_PATHS; under NONBE_UNIFIED_DECODING_PATHS_FIX --- lib_com/options.h | 3 ++ lib_dec/ivas_dec.c | 7 ++++- lib_dec/ivas_jbm_dec.c | 55 +++++++++++++++++++++++++++++++++---- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.c | 35 +++++++++++++++++------ lib_rend/ivas_output_init.c | 4 +++ 6 files changed, 89 insertions(+), 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9de0874dbb..e484e61694 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,9 @@ #define NONBE_FIX_856_TCX_LTP_SYNTH_FILTER /* FhG: issue 856: correct filtering length for tcx-ltp synth filtering*/ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ +#ifdef NONBE_UNIFIED_DECODING_PATHS +#define NONBE_UNIFIED_DECODING_PATHS_FIX /* VA: issue 876: fixes within NONBE_UNIFIED_DECODING_PATHS */ +#endif #define NONBE_FIX_861_MASA_CRASH_STEREO_SWITCHING /* VA: issue 861: fix MASA 2TC crash when switching from MDCT stereo to TD/DFT stereo */ #define BE_FIX_867_PARAMC_RECONFIG /* FhG: issue #867: fix ParamMC CLDFB buffer dealloc when reconfiguring */ #define NONBE_FIX_850_MASA_HBR_META_RATIO_DECODING /* Nokia: issue #850: Fixes rare non-valid diffuseness and energy ratio values in 2dir MASA. */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index bef9fa9b8d..1db1a149aa 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -51,8 +51,12 @@ * Principal IVAS decoder routine *--------------------------------------------------------------------------*/ +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX +// TODO: move here function ivas_jbm_dec_tc() and rename it to ivas_dec() + +#else ivas_error ivas_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ @@ -1160,3 +1164,4 @@ ivas_error ivas_dec( pop_wmops(); return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3e91dce044..7d3ae62450 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -71,9 +71,11 @@ ivas_error ivas_jbm_dec_tc( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ - float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ + Decoder_State *st; /* used for bitstream handling */ + float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX float output_f[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* TODO: can be allocated dynamically using st_ivas->p_output_f */ +#endif int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; int32_t output_Fs, ivas_total_brate; @@ -97,7 +99,11 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + p_output[n] = st_ivas->p_output_f[n]; +#else p_output[n] = output_f[n]; +#endif } /*----------------------------------------------------------------* @@ -935,7 +941,9 @@ ivas_error ivas_jbm_dec_render( { int16_t n, nchan_out; int16_t nchan_transport; +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis */ +#endif int16_t nchan_remapped; int32_t output_Fs; AUDIO_CONFIG output_config; @@ -960,10 +968,13 @@ ivas_error ivas_jbm_dec_render( output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; - for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + p_output[n] = st_ivas->p_output_f[n]; +#else p_output[n] = &output[n][0]; +#endif } for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) @@ -1257,11 +1268,19 @@ ivas_error ivas_jbm_dec_render( #endif for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + mvr2r( p_output[n], p_output[n + st_ivas->nchan_ism], *nSamplesRendered ); +#else mvr2r( output[n], output[n + st_ivas->nchan_ism], *nSamplesRendered ); +#endif } for ( n = 0; n < st_ivas->nchan_ism; n++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + set_zero( p_output[n], *nSamplesRendered ); +#else set_zero( output[n], *nSamplesRendered ); +#endif } } } @@ -1296,16 +1315,13 @@ ivas_error ivas_jbm_dec_render( else { #endif - #if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) - #endif - { return error; } @@ -1423,15 +1439,24 @@ ivas_error ivas_jbm_dec_render( /* we still need to copy the separate channel if available */ if ( st_ivas->hOutSetup.separateChannelEnabled ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); } else if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_5_1 && ( output_config == IVAS_AUDIO_CONFIG_5_1_2 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1 ) ) { for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + set_zero( p_output[n], *nSamplesRendered ); +#else set_zero( output[n], *nSamplesRendered ); +#endif } } } @@ -1443,13 +1468,22 @@ ivas_error ivas_jbm_dec_render( output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, p_output[LFE_CHANNEL], *nSamplesRendered ); + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, output[LFE_CHANNEL], *nSamplesRendered ); mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } } } @@ -2069,7 +2103,16 @@ int16_t ivas_jbm_dec_get_num_tc_channels( output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( st_ivas->ivas_format == MONO_FORMAT ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + } + else if ( st_ivas->ivas_format == STEREO_FORMAT && st_ivas->hDecoderConfig->nchan_out == 1 ) +#else if ( st_ivas->ivas_format == STEREO_FORMAT && st_ivas->hDecoderConfig->nchan_out == 1 ) +#endif { num_tc = 1; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4b0135f3af..d2f0596a39 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1010,7 +1010,7 @@ typedef struct decoder_config_structure /* temp. development parameters */ int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ #endif - int16_t Opt_tsm; + int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t Opt_Limiter; #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5abb39cd86..01d9c11265 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -973,7 +973,7 @@ ivas_error IVAS_DEC_GetSamples( ) { ivas_error error; - int16_t nOutSamplesElse, result, nSamplesToRender; + int16_t nOutSamplesElse, nSamplesToRender; uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; @@ -1088,7 +1088,11 @@ ivas_error IVAS_DEC_GetSamples( int16_t nResidualSamples, nSamplesTcsScaled; nSamplesRendered += nSamplesRendered_loop; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) +#else if ( nTransportChannels != hIvasDec->nTransportChannelsOld ) +#endif { if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) { @@ -1096,32 +1100,34 @@ ivas_error IVAS_DEC_GetSamples( } } - /* decode TCs only */ + /* IVAS decoder */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } + /* JBM */ if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { return IVAS_ERR_UNKNOWN; } - result = apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ); - if ( result != 0 ) + + if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; } + assert( nTimeScalerOutSamples <= APA_BUF ); + nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; } else { - nTimeScalerOutSamples = hIvasDec->nSamplesFrame * nTransportChannels; + nSamplesTcsScaled = hIvasDec->nSamplesFrame; } - nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; - /* render IVAS frames */ + /* IVAS renderer */ if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -1138,7 +1144,7 @@ ivas_error IVAS_DEC_GetSamples( hIvasDec->hasBeenFedFrame = false; } - /* render IVAS frames directly to the output buffer */ + /* render IVAS frames directly to the output buffer */ nSamplesToRender = nSamplesAsked - nSamplesRendered; #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -3133,8 +3139,19 @@ static ivas_error printConfigInfo_dec( get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] ); fprintf( stdout, "Output configuration: %s\n", config_str ); + #ifdef NONBE_UNIFIED_DECODING_PATHS - fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + AUDIO_CONFIG output_config = st_ivas->hDecoderConfig->output_config; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif +#endif + { + fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); + } #endif if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 7f4301cc2e..fd96b6b5e1 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -278,7 +278,11 @@ int16_t ivas_get_nchan_buffers_dec( if ( st_ivas->ivas_format == MONO_FORMAT ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; +#else nchan_out_buff = 0; +#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { -- GitLab From 2f614e03e71061b66ceb9eb0330eed690577af4d Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 14:29:05 +0200 Subject: [PATCH 02/12] fix builds --- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_dec.c | 11 ++++++++++- lib_dec/lib_dec.c | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1cbac362b6..5b2ddb0528 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -311,7 +311,7 @@ void stereo_dmx_evs_close_encoder( ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ -#ifdef SPLIT_REND_WITH_HEAD_ROT +#if( defined SPLIT_REND_WITH_HEAD_ROT && !defined NONBE_UNIFIED_DECODING_PATHS_FIX ) const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 1db1a149aa..bb2ee2c14e 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -52,8 +52,17 @@ *--------------------------------------------------------------------------*/ #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX -// TODO: move here function ivas_jbm_dec_tc() and rename it to ivas_dec() +ivas_error ivas_dec( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + int16_t *data /* o : output synthesis signal */ +) +{ + // TODO: move here function ivas_jbm_dec_tc() and rename it to ivas_dec() + st_ivas = NULL; // temp. to avoid compilation warnings + data = NULL; // temp. to avoid compilation warnings + return IVAS_ERR_OK; +} #else ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 01d9c11265..62e059b804 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3144,7 +3144,7 @@ static ivas_error printConfigInfo_dec( #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX AUDIO_CONFIG output_config = st_ivas->hDecoderConfig->output_config; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif -- GitLab From efe76f27cddb7f5c57a258f6e167af3249956e20 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 14:34:41 +0200 Subject: [PATCH 03/12] fix instrumented build --- lib_dec/lib_dec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 62e059b804..000ea5085b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3038,6 +3038,9 @@ static ivas_error printConfigInfo_dec( { ivas_error error; char config_str[50]; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + AUDIO_CONFIG output_config; +#endif /*-----------------------------------------------------------------* * Print info on screen @@ -3137,12 +3140,16 @@ static ivas_error printConfigInfo_dec( } } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + output_config = st_ivas->hDecoderConfig->output_config; + get_channel_config( output_config, &config_str[0] ); +#else get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] ); +#endif fprintf( stdout, "Output configuration: %s\n", config_str ); #ifdef NONBE_UNIFIED_DECODING_PATHS #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - AUDIO_CONFIG output_config = st_ivas->hDecoderConfig->output_config; #ifdef SPLIT_REND_WITH_HEAD_ROT if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #else -- GitLab From 25a80877acb7cdd0b8fefcc9469b84ca611b1024 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 14:38:12 +0200 Subject: [PATCH 04/12] fix compilation warning --- lib_dec/ivas_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index bb2ee2c14e..6b08408aa6 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -58,8 +58,8 @@ ivas_error ivas_dec( ) { // TODO: move here function ivas_jbm_dec_tc() and rename it to ivas_dec() - st_ivas = NULL; // temp. to avoid compilation warnings - data = NULL; // temp. to avoid compilation warnings + st_ivas->ivas_format = UNDEFINED_FORMAT; // temp. to avoid compilation warnings + data[0] = 0; // temp. to avoid compilation warnings return IVAS_ERR_OK; } -- GitLab From 78ec4e8329bea86e36918c5233ff32131847749c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 14:58:42 +0200 Subject: [PATCH 05/12] fix USAN error --- lib_dec/ivas_jbm_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 7d3ae62450..1268eb4076 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1505,7 +1505,11 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + for ( n = 0; n < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ ) +#else for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) +#endif { p_output[n] += st_ivas->hTcBuffer->n_samples_discard; } -- GitLab From f000ced21fe1e2664ae598be144abc11a7b9bec9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 15:21:09 +0200 Subject: [PATCH 06/12] fix USAN error --- lib_dec/ivas_jbm_dec.c | 3 +++ lib_dec/ivas_mc_paramupmix_dec.c | 5 +++++ lib_dec/lib_dec.c | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1268eb4076..ac6943c9ae 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1315,13 +1315,16 @@ ivas_error ivas_jbm_dec_render( else { #endif + #if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + #endif + { return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index fe93a65ee7..f44d28875f 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -565,7 +565,12 @@ void ivas_mc_paramupmix_dec_render( #else ivas_mc_paramupmix_dec_sf( st_ivas, output_f_local ); #endif + +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + for ( ch = 0; ch < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ ) +#else for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) +#endif { output_f_local[ch] += n_samples_sf; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 000ea5085b..85a0af232c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -973,7 +973,11 @@ ivas_error IVAS_DEC_GetSamples( ) { ivas_error error; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + int16_t nOutSamplesElse, result, nSamplesToRender; +#else int16_t nOutSamplesElse, nSamplesToRender; +#endif uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; @@ -1114,6 +1118,7 @@ ivas_error IVAS_DEC_GetSamples( return IVAS_ERR_UNKNOWN; } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -1121,11 +1126,26 @@ ivas_error IVAS_DEC_GetSamples( assert( nTimeScalerOutSamples <= APA_BUF ); nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; +#else + result = apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ); + if ( result != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + assert( nTimeScalerOutSamples <= APA_BUF ); +#endif } else { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX nSamplesTcsScaled = hIvasDec->nSamplesFrame; +#else + nTimeScalerOutSamples = hIvasDec->nSamplesFrame * nTransportChannels; +#endif } +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX + nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; +#endif /* IVAS renderer */ if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) -- GitLab From 85a15d4d4e03caae9783d8124481f23a4870088a Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 15:28:53 +0200 Subject: [PATCH 07/12] fix warning --- lib_dec/lib_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 85a0af232c..15624a55cc 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -974,9 +974,9 @@ ivas_error IVAS_DEC_GetSamples( { ivas_error error; #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - int16_t nOutSamplesElse, result, nSamplesToRender; -#else int16_t nOutSamplesElse, nSamplesToRender; +#else + int16_t nOutSamplesElse, result, nSamplesToRender; #endif uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; -- GitLab From c819a76845472a35b0025d9a676c9500bb8a41cd Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 23 Oct 2023 09:58:10 +0200 Subject: [PATCH 08/12] memory saving in evs_dec_main() --- lib_dec/lib_dec.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 15624a55cc..5dc48ac9b2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1147,7 +1147,7 @@ ivas_error IVAS_DEC_GetSamples( nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; #endif - /* IVAS renderer */ + /* Feed decoded transport channels samples to the renderer */ if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -1166,7 +1166,6 @@ ivas_error IVAS_DEC_GetSamples( /* render IVAS frames directly to the output buffer */ nSamplesToRender = nSamplesAsked - nSamplesRendered; - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) #else @@ -1507,7 +1506,7 @@ static ivas_error IVAS_DEC_GetTcSamples( /*---------------------------------------------------------------------* * IVAS_DEC_Rendered_FeedTcSamples( ) * - * Main function to decode to PCM data of the transport channels + * Feed decoded transport channels samples to the renderer *---------------------------------------------------------------------*/ static ivas_error IVAS_DEC_RendererFeedTcSamples( @@ -1536,7 +1535,7 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( /*---------------------------------------------------------------------* * IVAS_DEC_GetRenderedSamples( ) * - * Main function to render the transport channels to PCM output datat + * Main function to render the transport channels to PCM output data *---------------------------------------------------------------------*/ static ivas_error IVAS_DEC_GetRenderedSamples( @@ -2801,7 +2800,6 @@ ivas_error IVAS_DEC_Flush( nSamplesToRender = (uint16_t) *nSamplesFlushed; /* render IVAS frames */ - #ifdef SPLIT_REND_WITH_HEAD_ROT error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); #else @@ -3359,7 +3357,9 @@ static ivas_error evs_dec_main( int16_t *pcmBuf ) { DEC_CORE_HANDLE *hCoreCoder; +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX float output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN][L_FRAME48k]; +#endif float mixer_left, mixer_rigth; float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; int16_t ch; @@ -3372,7 +3372,11 @@ static ivas_error evs_dec_main( for ( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + p_output[ch] = st_ivas->p_output_f[ch]; +#else p_output[ch] = output[ch]; +#endif } /* run the main EVS decoding routine */ @@ -3380,14 +3384,22 @@ static ivas_error evs_dec_main( { if ( hCoreCoder[0]->Opt_AMR_WB ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0] ) ) != IVAS_ERR_OK ) +#else if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0] ) ) != IVAS_ERR_OK ) +#endif { return error; } } else { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3397,21 +3409,33 @@ static ivas_error evs_dec_main( { if ( hCoreCoder[0]->bfi == 0 ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#endif { return error; } } else if ( hCoreCoder[0]->bfi == 2 ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) +#endif { return error; } } else { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3424,8 +3448,13 @@ static ivas_error evs_dec_main( { mixer_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; mixer_rigth = 1.f - mixer_left; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + v_multc( p_output[0], mixer_rigth, p_output[1], nOutSamples ); + v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); +#else v_multc( output[0], mixer_rigth, output[1], nOutSamples ); v_multc( output[0], mixer_left, output[0], nOutSamples ); +#endif } #ifndef NONBE_UNIFIED_DECODING_PATHS -- GitLab From 4127bad9861621337ccee24274bc3e32321d3c6e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 23 Oct 2023 17:46:44 +0200 Subject: [PATCH 09/12] avoid allocation of 'st_ivas->hTcBuffer->tc_buffer[]' --- lib_com/ivas_prot.h | 21 +++ lib_dec/ivas_dirac_dec.c | 48 ++++-- lib_dec/ivas_init_dec.c | 3 + lib_dec/ivas_ism_renderer.c | 29 +++- lib_dec/ivas_jbm_dec.c | 154 ++++++++++++++----- lib_dec/ivas_omasa_dec.c | 25 ++- lib_dec/ivas_osba_dec.c | 88 ++++++++++- lib_dec/ivas_sba_rendering_internal.c | 24 ++- lib_rend/ivas_dirac_dec_binaural_functions.c | 22 +++ lib_rend/ivas_output_init.c | 6 + 10 files changed, 353 insertions(+), 67 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5b2ddb0528..e02b73b418 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5338,6 +5338,7 @@ void ivas_param_mc_mc2sba_cldfb( const float gain_lfe /* i : gain applied to LFE */ ); +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX void ivas_ism2sba( float *buffer_td[], /* i/o: TD signal buffers */ ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ @@ -5347,6 +5348,7 @@ void ivas_ism2sba( const int16_t sba_order /* i : SBA order */ ); +#endif void ivas_ism2sba_sf( float *buffer_in[], /* i : TC buffer */ float *buffer_out[], /* o : TD signal buffers */ @@ -5720,11 +5722,13 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( float *output_f[] /* o : rendered time signal */ ); +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX ivas_error ivas_osba_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* o : output synthesis signal */ const int16_t output_frame /* i : output frame length per channel */ ); +#endif ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -5733,11 +5737,21 @@ ivas_error ivas_osba_ism_metadata_dec( int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX +ivas_error ivas_osba_render_sf( + 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 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ +); +#else ivas_error ivas_osba_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: core-coder transport channels/object output */ const int16_t output_frame /* i : output frame length per channel */ ); +#endif void ivas_osba_data_close( SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ @@ -5891,12 +5905,14 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( float *output_f[] /* o : rendered time signal */ ); +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX void ivas_omasa_dirac_rend( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* o : output synthesis signal */ const int16_t output_frame /* i : output frame length per channel */ ); +#endif void ivas_omasa_rearrange_channels( float *output[], /* o : output synthesis signal */ const int16_t nchan_transport_ism, /* i : number of ISM TCs */ @@ -5928,6 +5944,7 @@ void ivas_omasa_separate_object_renderer_close( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX void ivas_omasa_separate_object_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float input_f[][L_FRAME48k], /* i : separated object signal */ @@ -5935,9 +5952,13 @@ void ivas_omasa_separate_object_render( const int16_t output_frame /* i : output frame length per channel */ ); +#endif void ivas_omasa_separate_object_render_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesRendered, /* i : number of samples rendered */ +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + float input_f[][L_FRAME48k], /* i : separated object signal */ +#endif float *output_f[], /* o : rendered time signal */ const int16_t subframes_rendered, /* i : number of subframes rendered */ const int16_t slots_rendered /* i : number of CLDFB slots rendered */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 876ae9130d..ef22eeb68f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1691,6 +1691,9 @@ void ivas_dirac_dec_render( uint16_t slot_size, n_samples_sf, ch, nchan_intern; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; float *output_f_local[MAX_OUTPUT_CHANNELS]; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; // VE2SB: TBV +#endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -1700,7 +1703,11 @@ void ivas_dirac_dec_render( #endif for ( ch = 0; ch < nchan_intern; ch++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + output_f_local[ch] = output_f_local_buff[ch]; +#else output_f_local[ch] = output_f[ch]; +#endif } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -1734,6 +1741,13 @@ void ivas_dirac_dec_render( #endif } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + for ( ch = 0; ch < nchan_intern; ch++ ) + { + mvr2r( output_f_local_buff[ch], output_f[ch], *nSamplesRendered ); + } + +#endif if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1753,10 +1767,10 @@ void ivas_dirac_dec_render( /*------------------------------------------------------------------------- - * ivas_dirac_dec() - * - * DirAC decoding process - *------------------------------------------------------------------------*/ + * ivas_dirac_dec_render_sf() + * + * DirAC decoding renderer process + *------------------------------------------------------------------------*/ void ivas_dirac_dec_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -2079,8 +2093,8 @@ void ivas_dirac_dec_render_sf( } /*-----------------------------------------------------------------* - * protoype signal computation - *-----------------------------------------------------------------*/ + * protoype signal computation + *-----------------------------------------------------------------*/ if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { @@ -2163,8 +2177,8 @@ void ivas_dirac_dec_render_sf( /*-----------------------------------------------------------------* - * Compute DirAC parameters at decoder side - *-----------------------------------------------------------------*/ + * Compute DirAC parameters at decoder side + *-----------------------------------------------------------------*/ if ( hDirAC->hConfig->dec_param_estim == TRUE ) { @@ -2250,8 +2264,8 @@ void ivas_dirac_dec_render_sf( #endif /*-----------------------------------------------------------------* - * frequency domain decorrelation - *-----------------------------------------------------------------*/ + * frequency domain decorrelation + *-----------------------------------------------------------------*/ if ( hDirACRend->proto_signal_decorr_on == 1 ) { @@ -2310,8 +2324,8 @@ void ivas_dirac_dec_render_sf( } /*-----------------------------------------------------------------* - * output synthesis - *-----------------------------------------------------------------*/ + * output synthesis + *-----------------------------------------------------------------*/ if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) { @@ -2412,8 +2426,8 @@ void ivas_dirac_dec_render_sf( } /*-----------------------------------------------------------------* - * CLDFB synthesis (and binaural rendering) - *-----------------------------------------------------------------*/ + * CLDFB synthesis (and binaural rendering) + *-----------------------------------------------------------------*/ index_slot = slot_idx_start_cldfb_synth; @@ -2631,7 +2645,7 @@ void ivas_dirac_dec_render_sf( else if ( ( st_ivas->hLsSetupCustom->separate_ch_found ) && ( hDirACRend->hOutSetup.separateChannelIndex == ch ) ) { /* Move the separated channel to the correct place. Thus, the separated channel is - * combined with the synthesized channels here when there is a matching channel. */ + * combined with the synthesized channels here when there is a matching channel. */ mvr2r( tmp_separated, &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); } else @@ -2647,7 +2661,7 @@ void ivas_dirac_dec_render_sf( if ( !st_ivas->hLsSetupCustom->separate_ch_found ) { /* Pan the separated channel and mix with the synthesized channels. Thus, the separated channel - * is combined with the synthesized channels here when there is no matching channel. */ + * is combined with the synthesized channels here when there is no matching channel. */ v_multc_acc( tmp_separated, st_ivas->hLsSetupCustom->separate_ch_gains[idx_in], &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); } @@ -2687,7 +2701,7 @@ void ivas_dirac_dec_render_sf( else if ( ( hDirACRend->hOutSetup.separateChannelEnabled ) && ( hDirACRend->hOutSetup.separateChannelIndex == ch ) ) { /* The separated channel is already set to output_f[hOutSetup.separateChannelIndex]. Thus, the separated - * channel is combined with the synthesized channels here. */ + * channel is combined with the synthesized channels here. */ } else { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7ed132c87b..cd8ea5dd36 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2255,6 +2255,9 @@ ivas_error ivas_init_decoder( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + set_zero( st_ivas->p_output_f[n], 48000 / FRAMES_PER_SEC ); +#endif } #ifndef NONBE_UNIFIED_DECODING_PATHS } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 94060ae8ef..9e7b472691 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -254,6 +254,9 @@ void ivas_ism_render_sf( int16_t tc_offset; int16_t interp_offset; float gain, prev_gain; +#ifdef NONBE_UNIFIED_DECODING_PATHS + float tc_local[MAX_NUM_OBJECTS][L_FRAME48k]; +#endif num_objects = st_ivas->nchan_transport; if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -266,6 +269,12 @@ void ivas_ism_render_sf( tc_offset = st_ivas->hTcBuffer->n_samples_rendered; interp_offset = st_ivas->hTcBuffer->n_samples_rendered; +#ifdef NONBE_UNIFIED_DECODING_PATHS + for ( i = 0; i < num_objects; i++ ) + { + mvr2r( output_f[i], tc_local[i], n_samples_to_render ); + } +#endif for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { @@ -312,7 +321,11 @@ void ivas_ism_render_sf( if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) { g1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; +#ifdef NONBE_UNIFIED_DECODING_PATHS + tc = &tc_local[i][tc_offset]; +#else tc = &st_ivas->hTcBuffer->tc[i][tc_offset]; +#endif for ( k = 0; k < n_samples_to_render; k++ ) { g2 = 1.0f - *g1; @@ -487,7 +500,7 @@ void ivas_omasa_separate_object_renderer_close( return; } - +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX /*-------------------------------------------------------------------------* * ivas_omasa_separate_object_render() * @@ -598,7 +611,7 @@ void ivas_omasa_separate_object_render( return; } - +#endif /*-------------------------------------------------------------------------* * ivas_omasa_separate_object_render_jbm() @@ -607,8 +620,11 @@ void ivas_omasa_separate_object_render( *-------------------------------------------------------------------------*/ void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesRendered, /* i : number of samples rendered */ +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + float input_f[][L_FRAME48k], /* i : separated object signal */ +#endif float *output_f[], /* o : rendered time signal */ const int16_t subframes_rendered, /* i : number of subframes rendered */ const int16_t slots_rendered /* i : number of CLDFB slots rendered */ @@ -627,7 +643,9 @@ void ivas_omasa_separate_object_render_jbm( int16_t azimuth, elevation; int16_t num_objects; uint8_t single_separated; +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX float *input_f[MAX_TRANSPORT_CHANNELS]; +#endif float *output_f_local[MAX_OUTPUT_CHANNELS]; int16_t offsetSamples; int16_t n_samples_sf, md_idx; @@ -658,10 +676,13 @@ void ivas_omasa_separate_object_render_jbm( { output_f_local[j] = output_f[j]; } +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX for ( obj = 0; obj < num_objects; obj++ ) { input_f[obj] = &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples]; } +#endif + slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size; first_sf = subframes_rendered; last_sf = first_sf; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ac6943c9ae..817f245853 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -101,11 +101,25 @@ ivas_error ivas_jbm_dec_tc( { #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX p_output[n] = st_ivas->p_output_f[n]; + if ( p_output[n] != NULL ) + { + set_zero( p_output[n], L_FRAME48k ); + } #else p_output[n] = output_f[n]; #endif } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) + { + st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; + } + } + +#endif /*----------------------------------------------------------------* * Decoding + pre-rendering *----------------------------------------------------------------*/ @@ -977,10 +991,29 @@ ivas_error ivas_jbm_dec_render( #endif } - for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( !st_ivas->hDecoderConfig->Opt_tsm ) { - p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; + for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) + { + p_tc[n] = p_output[n]; + } + + for ( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + { + st_ivas->hTcBuffer->tc[n] = p_output[n]; + } } + else + { +#endif + for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) + { + p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; + } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + } +#endif #ifndef NONBE_UNIFIED_DECODING_PATHS /*----------------------------------------------------------------* @@ -1144,7 +1177,7 @@ ivas_error ivas_jbm_dec_render( ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); } } - else /* SBA_MODE_SPAR */ + else { if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) { @@ -1204,6 +1237,12 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_osba_render_sf( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } +#else float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_output_ism[MAX_OUTPUT_CHANNELS]; @@ -1229,6 +1268,7 @@ ivas_error ivas_jbm_dec_render( } v_multc( p_output[n], 0.5f, p_output[n], *nSamplesRendered ); } +#endif } else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ { @@ -1254,7 +1294,7 @@ ivas_error ivas_jbm_dec_render( { ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); } - else /* SBA_MODE_SPAR */ + else { if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) { @@ -2419,27 +2459,38 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } else { - if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( st_ivas->hDecoderConfig->Opt_tsm ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); +#endif + 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]; - offset += n_samp_full; - } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; + offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_residual; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + else { - hTcBuffer->tc[ch_idx] = NULL; + hTcBuffer->tc_buffer = NULL; } +#endif } } @@ -2551,27 +2602,38 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( else { #endif - if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( st_ivas->hDecoderConfig->Opt_tsm ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); +#endif + 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]; - offset += n_samp_full; - } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; + offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_residual; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + else { - hTcBuffer->tc[ch_idx] = NULL; + hTcBuffer->tc_buffer = NULL; } +#endif #ifdef NONBE_UNIFIED_DECODING_PATHS } #endif @@ -2603,6 +2665,13 @@ static void ivas_jbm_dec_tc_buffer_playout( first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + return; + } +#endif + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -2817,10 +2886,19 @@ void ivas_jbm_dec_copy_tc_no_tsm( n_ch_cldfb = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; /* copy full tcs*/ - for ( ch_idx = 0; ch_idx < n_ch_full_copy; ch_idx++ ) +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( st_ivas->hDecoderConfig->Opt_tsm ) { - mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); +#endif + for ( ch_idx = 0; ch_idx < n_ch_full_copy; ch_idx++ ) + { + mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); + } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX } + ch_idx = 0; +#endif + /* CLDFB ana for ParamMC/ParamISM */ if ( n_ch_cldfb > 0 ) { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 16f7462ef7..4c1b157171 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -579,7 +579,7 @@ ivas_error ivas_omasa_ism_metadata_dec( return IVAS_ERR_OK; } - +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX /*--------------------------------------------------------------------------* * ivas_omasa_dirac_rend() * @@ -617,7 +617,7 @@ void ivas_omasa_dirac_rend( return; } - +#endif /*--------------------------------------------------------------------------* * ivas_omasa_dirac_rend_jbm() @@ -636,14 +636,33 @@ void ivas_omasa_dirac_rend_jbm( { int16_t subframes_rendered; int16_t slots_rendered; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + int16_t n; + float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; + + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + mvr2r( output_f[CPE_CHANNELS], data_separated_objects[0], nSamplesAsked ); + } + else + { + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + mvr2r( output_f[n + CPE_CHANNELS], data_separated_objects[n], nSamplesAsked ); + } + } +#endif subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; - ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); +#else ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, output_f, subframes_rendered, slots_rendered ); +#endif return; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 9c8f2a5b86..ce8f2248b7 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -134,8 +134,29 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( { int16_t n; ivas_error error; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; // VE2SB: TBV + float *p_sepobj[MAX_NUM_OBJECTS]; + int16_t channel_offset; + + for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) + { + p_sepobj[n] = &data_separated_objects[n][0]; + } + + channel_offset = st_ivas->nchan_ism; + + for ( n = 0; n < channel_offset; n++ ) + { + mvr2r( output_f[n], data_separated_objects[n], nSamplesAsked ); + } +#endif +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[channel_offset] ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -183,7 +204,11 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( { #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -193,7 +218,11 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( int16_t i; for ( i = 0; i < nSamplesAsked; i++ ) { - output_f[n][i] = 0.5f * output_f[2 + n][i] + 0.5f * output_f[n][i]; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + output_f[n][i] = 0.5f * output_f[channel_offset + n][i] + 0.5f * output_f[n][i]; +#else + output_f[n][i] = 0.5f * output_f[2 + n][i] + 0.5f * output_f[n][i]; +#endif } } #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -202,7 +231,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( return IVAS_ERR_OK; } - +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX /*--------------------------------------------------------------------------* * ivas_osba_dirac_td_binaural() * @@ -336,7 +365,7 @@ ivas_error ivas_osba_dirac_td_binaural( return IVAS_ERR_OK; } - +#endif /*-------------------------------------------------------------------------* * ivas_osba_ism_metadata_dec() @@ -368,7 +397,59 @@ ivas_error ivas_osba_ism_metadata_dec( return IVAS_ERR_OK; } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX +/*-------------------------------------------------------------------------* + * ivas_osba_render_sf() + * + * Object + SBA rendering process. + *-------------------------------------------------------------------------*/ +ivas_error ivas_osba_render_sf( + 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 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + float *p_output[] /* o : rendered time signal */ +) +{ + int16_t n; + float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_output_ism[MAX_OUTPUT_CHANNELS]; + ivas_error error; + + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) + { + p_output_ism[n] = &output_ism[n][0]; + } + + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + mvr2r( p_output[n], output_ism[n], nSamplesAsked ); + } + + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) + { + ivas_ism_render_sf( st_ivas, p_output_ism, *nSamplesRendered ); + } + + for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) + { + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) + { + v_add( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered ); + } + + v_multc( p_output[n], 0.5f, p_output[n], *nSamplesRendered ); + } + + return IVAS_ERR_OK; +} +#else /*-------------------------------------------------------------------------* * ivas_osba_render() * @@ -428,3 +509,4 @@ ivas_error ivas_osba_render( return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 7ab8bf7fc4..2560d8ef9c 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -339,7 +339,7 @@ int16_t ivas_sba_remapTCs( return ( nchan_remapped ); } - +#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX /*-------------------------------------------------------------------------* * ivas_ism2sba() * @@ -402,9 +402,11 @@ void ivas_ism2sba( return; } +#endif + /*-------------------------------------------------------------------------* - * ivas_ism2sba() + * ivas_ism2sba_sf() * * ISM transformed into SBA in TD domain. *-------------------------------------------------------------------------*/ @@ -421,6 +423,9 @@ void ivas_ism2sba_sf( { int16_t i, j, k; float g1, *g2, *tc, *out, gain, prev_gain; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + float buffer_tmp[HOA3_CHANNELS][L_FRAME48k]; // VE2SB: TBV +#endif int16_t sba_num_chans; assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); @@ -430,7 +435,11 @@ void ivas_ism2sba_sf( sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); for ( j = 0; j < sba_num_chans; j++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + set_zero( buffer_tmp[j], n_samples_to_render ); +#else set_zero( buffer_out[j], n_samples_to_render ); +#endif } for ( i = 0; i < num_objects; i++ ) @@ -439,7 +448,11 @@ void ivas_ism2sba_sf( { g2 = hIsmRendererData->interpolator + offset; tc = buffer_in[i] + offset; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + out = buffer_tmp[j]; +#else out = buffer_out[j]; +#endif gain = hIsmRendererData->gains[i][j]; prev_gain = hIsmRendererData->prev_gains[i][j]; for ( k = 0; k < n_samples_to_render; k++ ) @@ -450,6 +463,13 @@ void ivas_ism2sba_sf( } } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + for ( j = 0; j < sba_num_chans; j++ ) + { + mvr2r( buffer_tmp[j], buffer_out[j], n_samples_to_render ); + } +#endif + return; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 0edeee6e38..f6c6c961b9 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -463,7 +463,11 @@ void ivas_dirac_dec_binaural_render( uint16_t nchan_out; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; float *output_f_local[MAX_OUTPUT_CHANNELS]; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + int16_t output_length; +#endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_out = BINAURAL_CHANNELS; #ifdef DEBUGGING @@ -471,7 +475,11 @@ void ivas_dirac_dec_binaural_render( #endif for ( ch = 0; ch < nchan_out; ch++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + output_f_local[ch] = output_f_local_buff[ch]; +#else output_f_local[ch] = output_f[ch]; +#endif } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -489,6 +497,9 @@ void ivas_dirac_dec_binaural_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); +#endif +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + output_length = 0; #endif for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { @@ -500,12 +511,23 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + output_length += n_samples_sf; + +#endif #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); #endif } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + for ( ch = 0; ch < nchan_out; ch++ ) + { + mvr2r( output_f_local_buff[ch], output_f[ch], output_length ); + } + +#endif if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) { hSpatParamRendCom->dirac_read_idx = ( hSpatParamRendCom->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index fd96b6b5e1..9717b1106a 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -327,6 +327,12 @@ int16_t ivas_get_nchan_buffers_dec( { nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + else if ( output_config == IVAS_AUDIO_CONFIG_STEREO || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + nchan_out_buff = 2 * CPE_CHANNELS; + } +#endif else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) { nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); -- GitLab From f3f3e57499f35fee975159d7409f161c34dbe7c9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 23 Oct 2023 18:23:04 +0200 Subject: [PATCH 10/12] fixes --- lib_dec/ivas_dirac_dec.c | 34 +++++++++++++++++----------------- lib_dec/ivas_init_dec.c | 3 --- lib_dec/ivas_ism_renderer.c | 8 ++++---- lib_dec/ivas_osba_dec.c | 4 ++-- lib_dec/ivas_stat_dec.h | 22 +++++++++++++--------- 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ef22eeb68f..ae1c57c132 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1767,10 +1767,10 @@ void ivas_dirac_dec_render( /*------------------------------------------------------------------------- - * ivas_dirac_dec_render_sf() - * - * DirAC decoding renderer process - *------------------------------------------------------------------------*/ + * ivas_dirac_dec_render_sf() + * + * DirAC decoding renderer process + *------------------------------------------------------------------------*/ void ivas_dirac_dec_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -2093,8 +2093,8 @@ void ivas_dirac_dec_render_sf( } /*-----------------------------------------------------------------* - * protoype signal computation - *-----------------------------------------------------------------*/ + * protoype signal computation + *-----------------------------------------------------------------*/ if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { @@ -2177,8 +2177,8 @@ void ivas_dirac_dec_render_sf( /*-----------------------------------------------------------------* - * Compute DirAC parameters at decoder side - *-----------------------------------------------------------------*/ + * Compute DirAC parameters at decoder side + *-----------------------------------------------------------------*/ if ( hDirAC->hConfig->dec_param_estim == TRUE ) { @@ -2264,8 +2264,8 @@ void ivas_dirac_dec_render_sf( #endif /*-----------------------------------------------------------------* - * frequency domain decorrelation - *-----------------------------------------------------------------*/ + * frequency domain decorrelation + *-----------------------------------------------------------------*/ if ( hDirACRend->proto_signal_decorr_on == 1 ) { @@ -2324,8 +2324,8 @@ void ivas_dirac_dec_render_sf( } /*-----------------------------------------------------------------* - * output synthesis - *-----------------------------------------------------------------*/ + * output synthesis + *-----------------------------------------------------------------*/ if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) { @@ -2426,8 +2426,8 @@ void ivas_dirac_dec_render_sf( } /*-----------------------------------------------------------------* - * CLDFB synthesis (and binaural rendering) - *-----------------------------------------------------------------*/ + * CLDFB synthesis (and binaural rendering) + *-----------------------------------------------------------------*/ index_slot = slot_idx_start_cldfb_synth; @@ -2645,7 +2645,7 @@ void ivas_dirac_dec_render_sf( else if ( ( st_ivas->hLsSetupCustom->separate_ch_found ) && ( hDirACRend->hOutSetup.separateChannelIndex == ch ) ) { /* Move the separated channel to the correct place. Thus, the separated channel is - * combined with the synthesized channels here when there is a matching channel. */ + * combined with the synthesized channels here when there is a matching channel. */ mvr2r( tmp_separated, &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); } else @@ -2661,7 +2661,7 @@ void ivas_dirac_dec_render_sf( if ( !st_ivas->hLsSetupCustom->separate_ch_found ) { /* Pan the separated channel and mix with the synthesized channels. Thus, the separated channel - * is combined with the synthesized channels here when there is no matching channel. */ + * is combined with the synthesized channels here when there is no matching channel. */ v_multc_acc( tmp_separated, st_ivas->hLsSetupCustom->separate_ch_gains[idx_in], &( output_f[ch][subframe_start_sample] ), num_samples_subframe ); } @@ -2701,7 +2701,7 @@ void ivas_dirac_dec_render_sf( else if ( ( hDirACRend->hOutSetup.separateChannelEnabled ) && ( hDirACRend->hOutSetup.separateChannelIndex == ch ) ) { /* The separated channel is already set to output_f[hOutSetup.separateChannelIndex]. Thus, the separated - * channel is combined with the synthesized channels here. */ + * channel is combined with the synthesized channels here. */ } else { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index cd8ea5dd36..7ed132c87b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2255,9 +2255,6 @@ ivas_error ivas_init_decoder( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } -#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - set_zero( st_ivas->p_output_f[n], 48000 / FRAMES_PER_SEC ); -#endif } #ifndef NONBE_UNIFIED_DECODING_PATHS } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 9e7b472691..1e0338d4ca 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -254,8 +254,8 @@ void ivas_ism_render_sf( int16_t tc_offset; int16_t interp_offset; float gain, prev_gain; -#ifdef NONBE_UNIFIED_DECODING_PATHS - float tc_local[MAX_NUM_OBJECTS][L_FRAME48k]; +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + float tc_local[MAX_NUM_OBJECTS][L_FRAME48k]; // VE2SB: TBV #endif num_objects = st_ivas->nchan_transport; @@ -269,7 +269,7 @@ void ivas_ism_render_sf( tc_offset = st_ivas->hTcBuffer->n_samples_rendered; interp_offset = st_ivas->hTcBuffer->n_samples_rendered; -#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX for ( i = 0; i < num_objects; i++ ) { mvr2r( output_f[i], tc_local[i], n_samples_to_render ); @@ -321,7 +321,7 @@ void ivas_ism_render_sf( if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) { g1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; -#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX tc = &tc_local[i][tc_offset]; #else tc = &st_ivas->hTcBuffer->tc[i][tc_offset]; diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index ce8f2248b7..77934109f0 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -205,7 +205,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( #endif #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) #endif @@ -219,7 +219,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( for ( i = 0; i < nSamplesAsked; i++ ) { #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - output_f[n][i] = 0.5f * output_f[channel_offset + n][i] + 0.5f * output_f[n][i]; + output_f[n][i] = 0.5f * output_f[channel_offset + n][i] + 0.5f * p_sepobj[n][i]; #else output_f[n][i] = 0.5f * output_f[2 + n][i] + 0.5f * output_f[n][i]; #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index d2f0596a39..5db840877a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -910,16 +910,20 @@ typedef struct ivas_masa_ism_data_structure typedef struct decoder_tc_buffer_structure { - float *tc_buffer; /* the buffer itself */ + float *tc_buffer; /* the buffer itself */ +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + float *tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ // VE2SB: TBV +#else float *tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ - int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - int16_t nchan_buffer_full; /* number of channels to be fully buffered */ - int16_t n_samples_available; /* samples still available for rendering in the current frame */ - int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - int16_t n_samples_rendered; /* samples already rendered in the current frame */ - int16_t n_samples_granularity; /* render granularity */ +#endif + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ + int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + int16_t nchan_buffer_full; /* number of channels to be fully buffered */ + int16_t n_samples_available; /* samples still available for rendering in the current frame */ + int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + int16_t n_samples_rendered; /* samples already rendered in the current frame */ + int16_t n_samples_granularity; /* render granularity */ int16_t n_samples_flushed; int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; int16_t nb_subframes; -- GitLab From 2abba0af0eec58115f6d5744f97f8ad9fb82e5d4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 23 Oct 2023 19:52:58 +0200 Subject: [PATCH 11/12] fixes --- Makefile | 2 +- lib_dec/ivas_dirac_dec.c | 6 +++++- lib_dec/ivas_ism_renderer.c | 23 +++++++++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8955e04e66..2b4be9040c 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ LDLIBS += -lm CCCLANG = clang ifeq "$(CLANG)" "1" CC = $(CCCLANG) -CFLAGS += -fsanitize=memory +CFLAGS += -fsanitize=memory -fsanitize-memory-track-origins LDFLAGS += -fsanitize=memory endif ifeq "$(CLANG)" "2" diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ae1c57c132..cac0b5a359 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1705,6 +1705,7 @@ void ivas_dirac_dec_render( { #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX output_f_local[ch] = output_f_local_buff[ch]; + set_zero( output_f_local_buff[ch], nSamplesAsked ); #else output_f_local[ch] = output_f[ch]; #endif @@ -1744,7 +1745,10 @@ void ivas_dirac_dec_render( #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX for ( ch = 0; ch < nchan_intern; ch++ ) { - mvr2r( output_f_local_buff[ch], output_f[ch], *nSamplesRendered ); + if ( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( st_ivas->hDirACRend->hOutSetup.separateChannelIndex == ch || st_ivas->hDirACRend->hOutSetup.separateChannelIndex + 1 == ch ) ) ) + { + mvr2r( output_f_local_buff[ch], output_f[ch], *nSamplesRendered ); + } } #endif diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 1e0338d4ca..6c6ff2efee 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -623,7 +623,7 @@ void ivas_omasa_separate_object_render_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesRendered, /* i : number of samples rendered */ #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - float input_f[][L_FRAME48k], /* i : separated object signal */ + float input_f_in[][L_FRAME48k], /* i : separated object signal */ #endif float *output_f[], /* o : rendered time signal */ const int16_t subframes_rendered, /* i : number of subframes rendered */ @@ -643,9 +643,7 @@ void ivas_omasa_separate_object_render_jbm( int16_t azimuth, elevation; int16_t num_objects; uint8_t single_separated; -#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX float *input_f[MAX_TRANSPORT_CHANNELS]; -#endif float *output_f_local[MAX_OUTPUT_CHANNELS]; int16_t offsetSamples; int16_t n_samples_sf, md_idx; @@ -676,10 +674,23 @@ void ivas_omasa_separate_object_render_jbm( { output_f_local[j] = output_f[j]; } -#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX - for ( obj = 0; obj < num_objects; obj++ ) + +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( st_ivas->hDecoderConfig->Opt_tsm ) { - input_f[obj] = &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples]; +#endif + for ( obj = 0; obj < num_objects; obj++ ) + { + input_f[obj] = &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples]; + } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + } + else + { + for ( obj = 0; obj < num_objects; obj++ ) + { + input_f[obj] = input_f_in[obj]; + } } #endif -- GitLab From 162c39090a7140cfff6226487b80e6b45b61b14f Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 23 Oct 2023 19:53:29 +0200 Subject: [PATCH 12/12] revert unintentional change --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2b4be9040c..8955e04e66 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ LDLIBS += -lm CCCLANG = clang ifeq "$(CLANG)" "1" CC = $(CCCLANG) -CFLAGS += -fsanitize=memory -fsanitize-memory-track-origins +CFLAGS += -fsanitize=memory LDFLAGS += -fsanitize=memory endif ifeq "$(CLANG)" "2" -- GitLab