diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1cbac362b6fd285c87418c0635a6878aad5416f7..e02b73b418cea5cdb3c3235b410518d1818b0150 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 @@ -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_com/options.h b/lib_com/options.h index 9de0874dbbe35d2eb19e0e7c99157904c3058bcf..e484e616946edc5e331a6c7cd3e4a8eed9442c0b 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 bef9fa9b8d1e6c9cab28094495c99689638599e3..6b08408aa66c53ff5a91b37af78eda340b4a3398 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -51,8 +51,21 @@ * Principal IVAS decoder routine *--------------------------------------------------------------------------*/ +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX 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->ivas_format = UNDEFINED_FORMAT; // temp. to avoid compilation warnings + data[0] = 0; // temp. to avoid compilation warnings + + return IVAS_ERR_OK; +} +#else +ivas_error ivas_dec( + 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 +1173,4 @@ ivas_error ivas_dec( pop_wmops(); return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 876ae9130d7487f9848250ade82856f36c68a574..cac0b5a359b84eb0f2bef96ff3ac09937a4a1675 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,12 @@ 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]; + set_zero( output_f_local_buff[ch], nSamplesAsked ); +#else output_f_local[ch] = output_f[ch]; +#endif } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -1734,6 +1742,16 @@ void ivas_dirac_dec_render( #endif } +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + for ( ch = 0; ch < nchan_intern; ch++ ) + { + 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 if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1753,9 +1771,9 @@ void ivas_dirac_dec_render( /*------------------------------------------------------------------------- - * ivas_dirac_dec() + * ivas_dirac_dec_render_sf() * - * DirAC decoding process + * DirAC decoding renderer process *------------------------------------------------------------------------*/ void ivas_dirac_dec_render_sf( diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 94060ae8ef99c1e0ab030449636fdd53370ff561..6c6ff2efeebfce27fe4d8ed32690d5cd597fcef3 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_FIX + float tc_local[MAX_NUM_OBJECTS][L_FRAME48k]; // VE2SB: TBV +#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_FIX + 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_FIX + 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_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 */ const int16_t slots_rendered /* i : number of CLDFB slots rendered */ @@ -658,10 +674,26 @@ void ivas_omasa_separate_object_render_jbm( { output_f_local[j] = output_f[j]; } - for ( obj = 0; obj < num_objects; obj++ ) + +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { +#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 { - input_f[obj] = &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples]; + for ( obj = 0; obj < num_objects; obj++ ) + { + input_f[obj] = input_f_in[obj]; + } } +#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 3e91dce0444914a0246ea4d3973b53cd38dfceea..817f2458536690b1f17515290848b91bff83a6dc 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,9 +99,27 @@ 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]; + 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 *----------------------------------------------------------------*/ @@ -935,7 +955,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,16 +982,38 @@ 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++ ) +#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 /*----------------------------------------------------------------* @@ -1133,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 ) { @@ -1193,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]; @@ -1218,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*/ { @@ -1243,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 ) { @@ -1257,11 +1308,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 } } } @@ -1423,15 +1482,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 +1511,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 } } } @@ -1471,7 +1548,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; } @@ -2069,7 +2150,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; } @@ -2369,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 } } @@ -2501,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 @@ -2553,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]; @@ -2767,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_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index fe93a65ee7a9a4c5794ffc2561515dcfcac51a5c..f44d28875f3bc665a872525b94325eb6a1476fe4 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/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 16f7462ef780c291760e6ca3a7eede706b49225e..4c1b157171682b4cda46ea8ca2d853beea787efc 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 9c8f2a5b86109b357ed9ea949614fd75f13fd2fe..77934109f023fea46b0546a5f59138161d07abc9 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 - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + 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 { 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 * p_sepobj[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 7ab8bf7fc4a19392824af09634f5581f3afdcc01..2560d8ef9ce6c1bcb4051bf8b737501426fdadd8 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_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4b0135f3af307817481301dacff5b0e734fcc234..5db840877a48448bb1a587b51c2475c553186d5f 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; @@ -1010,7 +1014,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 5abb39cd868d87ac98410f6ca812563d23e5d1dd..5dc48ac9b29322d546d15f4c55e980c6cdbda8aa 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, nSamplesToRender; +#else int16_t nOutSamplesElse, result, nSamplesToRender; +#endif uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels, nOutChannels; @@ -1088,7 +1092,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 +1104,50 @@ 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; } + +#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; + } + + 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 - /* render IVAS frames */ + /* Feed decoded transport channels samples to the renderer */ if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -1138,9 +1164,8 @@ 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 if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) #else @@ -1481,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( @@ -1510,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( @@ -2775,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 @@ -3032,6 +3056,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 @@ -3131,10 +3158,25 @@ 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 - fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif +#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 ) { @@ -3315,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; @@ -3328,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 */ @@ -3336,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; } @@ -3353,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; } @@ -3380,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 diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 0edeee6e38993c5febd09c598028854c630dfcd6..f6c6c961b9cead13756fcf03c9eae5595725cec2 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 7f4301cc2e0ef357bc9e33ce8fe13ce3a193dff4..9717b1106acdf6e9551e513b0e2784115f9a4814 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 ) { @@ -323,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 ) );