From f26508e8c587cfb766d02afa601898ba969cbe8f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 24 Nov 2023 12:23:11 +0100 Subject: [PATCH 01/22] fix issue 880: Functions renaming after NONBE_UNIFIED_DECODING_PATHS; under UNIFIED_DECODING_PATHS_FUNCTION_NAMES --- lib_com/ivas_prot.h | 47 +- lib_com/options.h | 1 + lib_dec/ivas_dec.c | 1990 ++++++++++++++++++------ lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_init_dec.c | 4 + lib_dec/ivas_ism_renderer.c | 10 + lib_dec/ivas_jbm_dec.c | 24 +- lib_dec/ivas_masa_dec.c | 43 + lib_dec/ivas_objectRenderer_internal.c | 2 +- lib_dec/ivas_omasa_dec.c | 20 +- lib_dec/ivas_osba_dec.c | 12 +- lib_dec/ivas_sba_rendering_internal.c | 2 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.c | 12 + 14 files changed, 1689 insertions(+), 482 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index cdd5a6bfd0..dc8ab06fe2 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -310,6 +310,25 @@ void stereo_dmx_evs_close_encoder( STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ ); +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +ivas_error ivas_dec( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : output synthesis signals */ +); + +ivas_error ivas_dec_render( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of samples wanted */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif +); +#else ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ #if( defined SPLIT_REND_WITH_HEAD_ROT && !defined NONBE_UNIFIED_DECODING_PATHS_FIX ) @@ -319,6 +338,7 @@ ivas_error ivas_dec( int16_t *data /* o : output synthesis signal */ #endif ); +#endif ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -784,6 +804,7 @@ void ivas_apply_non_diegetic_panning( * JBM prototypes *----------------------------------------------------------------------------------*/ +#ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES ivas_error ivas_jbm_dec_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : output synthesis signals */ @@ -801,7 +822,7 @@ ivas_error ivas_jbm_dec_render( int16_t *data /* o : output synthesis signal */ #endif ); - +#endif ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ @@ -5216,6 +5237,13 @@ void ivas_spar_param_to_masa_param_mapping( const int16_t subframe /* i : Subframe to map */ ); +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +void ivas_dec_copy_masa_meta_to_buffer( + JBM_METADATA_HANDLE hJbmMetadata, /* o : metadata handle for buffering in JBM */ + MASA_DECODER_EXT_OUT_META *extOutMeta /* i : MASA external output metadata */ +); + +#endif /*---------------------------------------------------------------------------------* * Binaural FastConv Renderer Prototypes @@ -5693,7 +5721,11 @@ ivas_error ivas_osba_data_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +ivas_error ivas_osba_dirac_td_binaural( +#else ivas_error ivas_osba_dirac_td_binaural_jbm( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ @@ -5876,7 +5908,11 @@ ivas_error ivas_omasa_dirac_td_binaural( const int16_t output_frame /* i : output frame length per channel */ ); #endif +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +ivas_error ivas_omasa_dirac_td_binaural( +#else ivas_error ivas_omasa_dirac_td_binaural_jbm( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ @@ -5899,7 +5935,11 @@ void ivas_omasa_rearrange_channels( const int16_t output_frame /* i : output frame length per channel */ ); +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +void ivas_omasa_dirac_rend( +#else void ivas_omasa_dirac_rend_jbm( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ @@ -5931,9 +5971,12 @@ void ivas_omasa_separate_object_render( float *output_f[], /* i/o: output signals */ const int16_t output_frame /* i : output frame length per channel */ ); - #endif +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +void ivas_omasa_separate_object_render( +#else void ivas_omasa_separate_object_render_jbm( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesRendered, /* i : number of samples rendered */ #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX diff --git a/lib_com/options.h b/lib_com/options.h index 388e939538..3901a4cedc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -165,6 +165,7 @@ #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 */ +#define UNIFIED_DECODING_PATHS_FUNCTION_NAMES /* VA: issue 880: Functions renaming after NONBE_UNIFIED_DECODING_PATHS */ #endif #define NONBE_FIX_874_OMASA_BRSW_2TD /* Nokia: issue 874: Fixes the crashes with the long test vectors that prompted switching to TD*/ #define NONBE_FIX_871_ACELP_CRASH_IN_OSBA /* FhG: isse 871: crash in ACELP core encoder with OSBA */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 7ed71d5d6c..536b1c7ff4 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -45,38 +45,31 @@ #include "wmc_auto.h" +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +/*--------------------------------------------------------------------------* + * Local function declaration + *--------------------------------------------------------------------------*/ + +static void ivas_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); + + /*--------------------------------------------------------------------------* * ivas_dec() * - * Principal IVAS decoder routine + * Principal IVAS decoder routine, decoding of metadata and transport channels *--------------------------------------------------------------------------*/ -#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 */ -#else - int16_t *data /* o : output synthesis signal */ -#endif + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : transport channel signals */ ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ - float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* '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; @@ -84,9 +77,6 @@ ivas_error ivas_dec( ivas_error error; int16_t num_md_sub_frames; int32_t ism_total_brate; -#ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t nchan_out_syn_output; -#endif push_wmops( "ivas_dec" ); @@ -95,57 +85,41 @@ ivas_error ivas_dec( *----------------------------------------------------------------*/ output_Fs = st_ivas->hDecoderConfig->output_Fs; - nchan_out = st_ivas->hDecoderConfig->nchan_out; + nchan_out = st_ivas->hTcBuffer->nchan_transport_jbm; output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); - for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX p_output[n] = st_ivas->p_output_f[n]; - } - - /*----------------------------------------------------------------* - * Update combined orientation access index - *----------------------------------------------------------------*/ - -#ifndef NONBE_UNIFIED_DECODING_PATHS - if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( p_output[n] != NULL ) + { + set_zero( p_output[n], L_FRAME48k ); + } #else - ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + p_output[n] = output_f[n]; #endif + } -#ifdef SPLIT_REND_WITH_HEAD_ROT - /*----------------------------------------------------------------* - * Binaural split rendering setup - *----------------------------------------------------------------*/ - - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( !st_ivas->hDecoderConfig->Opt_tsm ) { - ivas_set_split_rend_ht_setup( &st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData ); + 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 + Rendering + * Decoding + pre-rendering *----------------------------------------------------------------*/ if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) { - for ( n = 0; n < nchan_out; n++ ) - { - /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); - } - p_output[n] = st_ivas->p_output_f[n]; - } - /* zero output when first frame(s) is lost */ for ( n = 0; n < nchan_out; n++ ) { @@ -162,7 +136,6 @@ ivas_error ivas_dec( else if ( st_ivas->ivas_format == STEREO_FORMAT ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; - if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; @@ -174,8 +147,7 @@ ivas_error ivas_dec( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - /* Rendering */ - if ( st_ivas->renderer_type == RENDERER_MC ) + if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) { ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); } @@ -232,111 +204,21 @@ ivas_error ivas_dec( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - /* Rendering */ - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); - - ivas_param_ism_params_to_masa_param_mapping( st_ivas ); - - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) - { - ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); - } - else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) - { - ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, output_frame ); - } - else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) - { - ivas_param_ism_dec( st_ivas, p_output ); - - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) - { - /* Convert CICP19 -> Ambisonics */ - ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); - } - } + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } - else /* ISM_MODE_DISC */ + else if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { - /* Loudspeaker or Ambisonics rendering */ - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) - { - ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); - } - else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) - { - ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, output_frame ); - } - else if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { - /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ - ivas_ism_render( st_ivas, p_output, output_frame ); - } -#ifdef DEBUGGING - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) -#else - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) -#endif - { - /* Convert to Ambisonics; used also for ISM->HOA3->binaural rendering */ - ivas_ism2sba( p_output, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); - } - - /* Binaural rendering */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) - { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { -#endif - if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } -#ifdef SPLIT_REND_WITH_HEAD_ROT - } -#endif - } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) -#endif - { - return error; - } -#ifndef FIX_881_REMOVE_LFE_ADDITION_IN_ISM - ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); -#endif - } -#ifdef DEBUGGING - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - ivas_binaural_cldfb( st_ivas, p_output ); - } -#endif + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); } } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { set_s( nb_bits_metadata, 0, MAX_SCE ); + /* read parameters from the bitstream */ if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hQMetaData != NULL ) { @@ -346,6 +228,15 @@ ivas_error ivas_dec( { return error; } + + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + ivas_dec_copy_masa_meta_to_buffer( st_ivas->hJbmMetadata, st_ivas->hMasa->data.extOutMeta ); +#else + ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); +#endif + } } else if ( st_ivas->ivas_format == SBA_FORMAT ) { @@ -357,13 +248,14 @@ ivas_error ivas_dec( if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 ) { + st_ivas->hCPE[0]->brate_surplus = 0; st_ivas->hCPE[0]->element_brate = ivas_total_brate; } /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -382,22 +274,11 @@ ivas_error ivas_dec( return error; } } -#ifdef DEBUG_LBR_SBA - /* SCE Decoder Output */ - for ( int16_t t = 0; t < 960; t++ ) - { - for ( int16_t c = 0; c < st_ivas->nchan_transport; c++ ) - { - float val = output[c][t] / MAX16B_FLT; - dbgwrite( &val, sizeof( float ), 1, 1, "int_dec_core_out.raw" ); - } - } -#endif + #ifdef DEBUG_SBA_AUDIO_DUMP /* Dump audio signal after core-decoding */ ivas_spar_dump_signal_wav( output_frame, NULL, output, st_ivas->nchan_transport, spar_foa_dec_wav[0], "core-decoding" ); #endif - /* TCs remapping */ nchan_remapped = st_ivas->nchan_transport; if ( st_ivas->sba_dirac_stereo_flag ) @@ -430,6 +311,7 @@ ivas_error ivas_dec( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } #endif + if ( st_ivas->ivas_format == SBA_FORMAT ) { nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); @@ -454,33 +336,6 @@ ivas_error ivas_dec( /* loudness correction */ ivas_dirac_dec_binaural_sba_gain( p_output, nchan_remapped, output_frame ); } - - /* Loudspeakers, Ambisonics or Binaural rendering */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - else if ( st_ivas->ivas_format == MASA_FORMAT ) - { - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) - { - if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, 0, output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->renderer_type == RENDERER_DIRAC ) - { - ivas_dirac_dec( st_ivas, p_output, nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - } - else if ( !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) - { - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ - { - return error; - } - } } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -545,32 +400,11 @@ ivas_error ivas_dec( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - /* Rendering */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) - { - if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - } - else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } - else if ( st_ivas->renderer_type == RENDERER_DIRAC ) - { - ivas_omasa_dirac_rend( st_ivas, p_output, output_frame ); - } - - /* external output */ - if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { /* sanity check in case of bitrate switching */ if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) @@ -579,6 +413,12 @@ ivas_error ivas_dec( } ivas_omasa_rearrange_channels( p_output, nchan_transport_ism, output_frame ); + +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + ivas_dec_copy_masa_meta_to_buffer( st_ivas->hJbmMetadata, st_ivas->hMasa->data.extOutMeta ); +#else + ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); +#endif } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -616,7 +456,7 @@ ivas_error ivas_dec( /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } @@ -642,10 +482,10 @@ ivas_error ivas_dec( if ( st_ivas->hSpar->hPCA != NULL ) { - ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); ivas_sba_dirac_stereo_dec( st_ivas, &p_output[sba_ch_idx], output_frame, 0 ); } @@ -674,10 +514,11 @@ ivas_error ivas_dec( #endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); } - else if ( st_ivas->renderer_type != RENDERER_DISABLE ) + else if ( st_ivas->renderer_type != RENDERER_DISABLE && !st_ivas->sba_dirac_stereo_flag ) { ivas_spar_dec_agc_pca( st_ivas, &p_output[sba_ch_idx], output_frame ); } @@ -687,104 +528,68 @@ ivas_error ivas_dec( /* loudness correction */ ivas_dirac_dec_binaural_sba_gain( &p_output[sba_ch_idx], nchan_remapped, output_frame ); } - - /* Loudspeakers, Ambisonics or Binaural rendering */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || - st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &p_output[sba_ch_idx], nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) - { - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - ivas_sba_upmixer_renderer( st_ivas, &p_output[sba_ch_idx], output_frame ); - } - } - else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_OSBA_STEREO || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) ) + else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) - { - ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); - } - else /* stereo output */ - { - /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case */ - if ( nchan_ism == 1 ) - { - mvr2r( p_output[2], p_output[3], output_frame ); - mvr2r( p_output[1], p_output[2], output_frame ); - } - - ivas_ism_render( st_ivas, p_output, output_frame ); - } + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + /* add W */ for ( n = 0; n < nchan_out; n++ ) { v_add( p_output[n], p_output[n + max( nchan_out, nchan_ism )], p_output[n], output_frame ); } } - else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS ) - { - if ( ( error = ivas_osba_render( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + + if ( st_ivas->mc_mode == MC_MODE_MCT ) { - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + /* LFE channel decoder */ + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); + + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } - } - else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ - { - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + + /* HP filtering */ + for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - for ( n = 0; n < nchan_ism; n++ ) + if ( n != LFE_CHANNEL ) { - delay_signal( p_output[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } } - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) { - return error; + if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) + { + ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); + } } - if ( st_ivas->ism_mode == ISM_MODE_NONE ) + if ( ( st_ivas->renderer_type == RENDERER_MC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ) ) { - for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) + if ( st_ivas->renderer_type == RENDERER_MC ) { - mvr2r( p_output[n], p_output[n + nchan_ism], output_frame ); + ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); } - - for ( n = 0; n < nchan_ism; n++ ) + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { - set_zero( p_output[n], output_frame ); + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); } } } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - - if ( st_ivas->mc_mode == MC_MODE_MCT ) + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { /* LFE channel decoder */ ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); - if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) + ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); + + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -798,79 +603,1413 @@ ivas_error ivas_dec( } } - if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) - { - ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); - } - /* Rendering */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + if ( st_ivas->renderer_type == RENDERER_MC && ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + /* Compensate loudness for not doing full upmix */ + for ( n = 4; n < 8; n++ ) + { + v_multc( p_output[n], 2.0f, p_output[n], output_frame ); + } + + if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) + { + ivas_ls_setup_conversion( st_ivas, audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); + } + } + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + /* read Parametric MC parameters from the bitstream */ + ivas_param_mc_dec_read_BS( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] ); + + if ( st_ivas->nCPE == 1 ) + { + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE > 1 ) + { + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* HP filtering */ + for ( n = 0; n < st_ivas->nchan_transport; n++ ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + /* Rendering */ + if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) + { + ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); + } + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + if ( st_ivas->hOutSetup.separateChannelEnabled ) + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; /* Metadata is always with CPE in the case of separated channel */ + } + + /* read McMASA parameters from the bitstream */ + if ( ( error = ivas_masa_decode( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->hOutSetup.separateChannelEnabled ) + { + /* Decode the transport audio signals */ + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ + n = LFE_CHANNEL - 1; + + /* Decode the separated channel to output[n] to be combined with the synthesized channels */ + if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ + if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || + 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 ) ) + { + ivas_lfe_synth_with_filters( st_ivas->hMasa->hMasaLfeSynth, p_output, output_frame, n, LFE_CHANNEL ); + } + 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 */ + delay_signal( p_output[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + } + } + else + { + if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_rend_crendProcessSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } - else + else if ( st_ivas->nCPE == 1 ) { - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) -#endif + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } + } + } + + if ( st_ivas->sba_dirac_stereo_flag ) /* use the flag to trigger the DFT upmix */ + { + ivas_sba_dirac_stereo_dec( st_ivas, p_output, output_frame, 1 ); + } + + /* HP filtering */ + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) + { + ivas_mono_stereo_downmix_mcmasa( st_ivas, p_output, output_frame ); + } + } + } + + /*----------------------------------------------------------------* + * Write IVAS transport channels + *----------------------------------------------------------------*/ + +#ifndef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 || !st_ivas->hDecoderConfig->Opt_5ms ) +#else + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) +#endif + { + ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); + } + else + { + /* directly copy to tc buffers */ + ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); + } + + /*----------------------------------------------------------------* + * Common updates + *----------------------------------------------------------------*/ + + if ( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */ + { + st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; + st_ivas->last_active_ivas_total_brate = ( ivas_total_brate <= IVAS_SID_5k2 ) ? st_ivas->last_active_ivas_total_brate : ivas_total_brate; + } + + if ( st_ivas->ini_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ + { + st_ivas->ini_frame++; + } + + if ( st_ivas->ini_active_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && ivas_total_brate > IVAS_SID_5k2 ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ + { + st_ivas->ini_active_frame++; + } + + st_ivas->last_ivas_format = st_ivas->ivas_format; + +#ifdef DEBUG_MODE_INFO + dbgwrite( &st_ivas->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" ); + dbgwrite( &st_ivas->BER_detect, sizeof( int16_t ), 1, output_frame, "res/BER_detect" ); + { + float tmpF = ivas_total_brate / 1000.0f; + dbgwrite( &tmpF, sizeof( float ), 1, output_frame, "res/ivas_total_brate.dec" ); + } +#endif + + pop_wmops(); + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_dec_render() + * + * Principal IVAS internal rendering routine + *--------------------------------------------------------------------------*/ + +ivas_error ivas_dec_render( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of samples wanted */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif +) +{ + 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; + int16_t nSamplesAskedLocal; + ivas_error error; + float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; + float *p_tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t nchan_out_syn_output; +#endif + + push_wmops( "ivas_dec_render" ); + + /*----------------------------------------------------------------* + * Initialization of local vars after struct has been set + *----------------------------------------------------------------*/ + + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + output_Fs = st_ivas->hDecoderConfig->output_Fs; + nchan_out = st_ivas->hDecoderConfig->nchan_out; + nchan_transport = st_ivas->hTcBuffer->nchan_transport_jbm; + output_config = st_ivas->hDecoderConfig->output_config; + nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; + + for ( n = 0; n < MAX_OUTPUT_CHANNELS + 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 + } + +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + 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 + /*----------------------------------------------------------------* + * Combine orientations + *----------------------------------------------------------------*/ + + if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + { + return error; + } +#else + /*----------------------------------------------------------------* + * Update combined orientation access index + *----------------------------------------------------------------*/ + + if ( st_ivas->hCombinedOrientationData != NULL ) + { + /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ + st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start -= st_ivas->hTcBuffer->n_samples_discard; + + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + } +#endif + + /*----------------------------------------------------------------* + * Rendering + *----------------------------------------------------------------*/ + + if ( st_ivas->ivas_format == UNDEFINED_FORMAT ) + { + assert( 0 ); + } + else if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + { + ivas_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); + } + else if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + /* Rendering */ + if ( st_ivas->renderer_type == RENDERER_MC ) + { + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output ); + } + } + else if ( st_ivas->ivas_format == ISM_FORMAT ) + { + /* Rendering */ + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output ); + } + else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + { + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); + } + else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_param_ism_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + /* Convert CICP19 -> Ambisonics */ + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); + } + } + } + else /* ISM_MODE_DISC */ + { + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + + /* Loudspeaker or Ambisonics rendering */ + if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { + /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ + ivas_ism_render_sf( st_ivas, p_output, *nSamplesRendered ); + } + else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + { + ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); + } + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + /* Convert to Ambisonics; used also for ISM->HOA3->binaural rendering */ + ivas_ism2sba_sf( st_ivas->hTcBuffer->tc, p_output, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); + } + + /* Binaural rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { +#if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } +#ifndef FIX_881_REMOVE_LFE_ADDITION_IN_ISM + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); +#endif + } +#ifdef DEBUGGING + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + ivas_binaural_cldfb_sf( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->nb_subframes, p_output ); + } +#endif + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + { + nchan_remapped = nchan_transport; + + /* Loudspeakers, Ambisonics or Binaural rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); + } + else if ( st_ivas->ivas_format == MASA_FORMAT ) + { + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) + { + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + for ( n = 0; n < nchan_remapped; n++ ) + { + mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); + } + + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, 0, output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->renderer_type == RENDERER_DIRAC ) + { + ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + } + } + else + { + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + nchan_remapped = st_ivas->nchan_transport; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + } + else + { + ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); + } + } + else if ( st_ivas->renderer_type == RENDERER_DIRAC ) + { +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + ivas_omasa_dirac_rend( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); +#else + ivas_omasa_dirac_rend_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); +#endif + } + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + nchan_remapped = nchan_transport; + + /* Loudspeakers, Ambisonics or Binaural rendering */ + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + } + else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO ) + { + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + +#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX + /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/ + if ( st_ivas->nchan_ism == 1 && st_ivas->hDecoderConfig->Opt_tsm == 0 ) + { + mvr2r( p_tc[2], p_output[3], *nSamplesRendered ); + mvr2r( p_tc[1], p_output[2], *nSamplesRendered ); + p_tc[1] = p_output[2]; + p_tc[2] = p_output[3]; + } +#endif + + /* render objects */ + ivas_ism_render_sf( st_ivas, p_output, *nSamplesRendered ); + + /* add already rendered SBA part */ + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); + } + } + 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_FIX + 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]; + + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) + { + p_output_ism[n] = &output_ism[n][0]; + } + + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, 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 < 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 ); + } +#endif + } + else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ + { + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output[st_ivas->nchan_ism] ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); + } + } + else + { + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); + } + else + { + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { +#ifdef DEBUGGING + assert( st_ivas->ism_mode == ISM_MODE_NONE ); +#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 + } + } + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + int16_t crendInPlaceRotation = FALSE; + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) + { + if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) + { + crendInPlaceRotation = TRUE; + ivas_mc2sba( st_ivas->hTransSetup, p_tc, p_output, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); + } + } + + /* Rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, 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 ) + { + return error; + } + } + 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; + } + + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + } + else if ( st_ivas->renderer_type == RENDERER_MC ) + { + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output ); + } + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_mc2sba( st_ivas->hIntSetup, p_tc, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + } + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + ivas_mc_paramupmix_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc, p_output ); + + + /* Rendering */ + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*handled in CLDFB domain already*/ + if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + { + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); + } + } + else if ( st_ivas->renderer_type == RENDERER_MC ) + { + ivas_ls_setup_conversion( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output, p_output ); + } + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + } + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + ivas_param_mc_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + int16_t offset = hSpatParamRendCom->slots_rendered * hSpatParamRendCom->slot_size; + nchan_remapped = st_ivas->nchan_transport; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); + } + else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ + { + ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + /* we still need to copy the separate channel if available */ + 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 + } + } + } + + /* copy discrete C and TD LFE from internal TC to output */ + if ( st_ivas->hOutSetup.separateChannelEnabled ) + { + if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || + 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 + } + } + } + } + + /*----------------------------------------------------------------* + * Write IVAS output channels + * - compensation for saturation + * - float to integer conversion + *----------------------------------------------------------------*/ + + st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered; + st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered; + +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); +#endif + + 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; + } + *nSamplesRendered -= st_ivas->hTcBuffer->n_samples_discard; + st_ivas->hTcBuffer->n_samples_discard = 0; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses; + } + else + { + nchan_out_syn_output = nchan_out; + } + + if ( st_ivas->hDecoderConfig->Opt_Limiter ) +#endif + { + if ( st_ivas->ivas_format != MONO_FORMAT ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); +#endif + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + switch ( pcm_resolution ) + { + case PCM_INT16: +#endif +#ifdef DEBUGGING + st_ivas->noClipping += +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output( p_output, *nSamplesRendered, nchan_out_syn_output, (int16_t *) data ); +#else + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + break; + case PCM_FLOAT32: + ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out_syn_output, (float *) data ); + break; + default: + error = IVAS_ERR_UNKNOWN; + break; + } +#endif + + *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; + + pop_wmops(); + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_dec_tc_buffer_playout() + * + * + *--------------------------------------------------------------------------*/ + +static void ivas_dec_tc_buffer_playout( + Decoder_Struct *st_ivas, + const uint16_t nSamplesAsked, + uint16_t *nSamplesRendered, + float *output[] ) +{ + int16_t ch_idx, slot_size, slots_to_render, first_sf, last_sf; + + slot_size = st_ivas->hTcBuffer->n_samples_granularity; + + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ + slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, nSamplesAsked / slot_size ); + st_ivas->hTcBuffer->slots_rendered += slots_to_render; + *nSamplesRendered = (uint16_t) slots_to_render * slot_size; + first_sf = st_ivas->hTcBuffer->subframes_rendered; + last_sf = first_sf; + + while ( slots_to_render > 0 ) + { + slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; + last_sf++; + } + + for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) + { + mvr2r( st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); + } + + st_ivas->hTcBuffer->subframes_rendered = last_sf; + + return; +} +#else +/*--------------------------------------------------------------------------* + * ivas_dec() + * + * Principal IVAS decoder routine, decoding of metadata and transport channels + *--------------------------------------------------------------------------*/ + +ivas_error ivas_jbm_dec_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : transport channel signals */ +) +{ + 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 */ +#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; + AUDIO_CONFIG output_config; + ivas_error error; + int16_t num_md_sub_frames; + int32_t ism_total_brate; + + push_wmops( "ivas_dec" ); + + /*----------------------------------------------------------------* + * Initialization of local vars after struct has been set + *----------------------------------------------------------------*/ + + output_Fs = st_ivas->hDecoderConfig->output_Fs; + nchan_out = st_ivas->hTcBuffer->nchan_transport_jbm; + output_config = st_ivas->hDecoderConfig->output_config; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + + output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + + 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 + *----------------------------------------------------------------*/ + + if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) + { + /* zero output when first frame(s) is lost */ + for ( n = 0; n < nchan_out; n++ ) + { + set_f( p_output[n], 0.0f, output_frame ); + } + +#ifdef DEBUG_MODE_INFO + create_sce_dec( st_ivas, 0, ivas_total_brate ); + output_debug_mode_info_dec( st_ivas->hSCE[0]->hCoreCoder, 1, output_frame, NULL ); + destroy_sce_dec( st_ivas->hSCE[0] ); + st_ivas->hSCE[0] = NULL; +#endif + } + else if ( st_ivas->ivas_format == STEREO_FORMAT ) + { + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* HP filtering */ + for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) + { + ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); + } + } + else if ( st_ivas->ivas_format == ISM_FORMAT ) + { + /* Metadata decoding and configuration */ + if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) + { +#ifdef NONBE_FIX_898_ISM_BRATE_CRASH + ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ); +#else + if ( ( error = ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + /* decode dominant object first so the noise energy of the other objects can be limited */ + if ( ( error = ivas_sce_dec( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) + { + return error; + } + + ivas_ism_dtx_limit_noise_energy_for_near_silence( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); + } + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else /* ISM_MODE_DISC */ + { + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + for ( n = 0; n < st_ivas->nchan_transport; n++ ) + { + /* for DTX frames, dominant object has already been decoded before */ + if ( !( ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) && n == st_ivas->hISMDTX.sce_id_dtx ) ) + { + if ( ( error = ivas_sce_dec( st_ivas, n, &p_output[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* HP filtering */ + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + } + else if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + { + set_s( nb_bits_metadata, 0, MAX_SCE ); + + + /* read parameters from the bitstream */ + if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hQMetaData != NULL ) + { + st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + + if ( ( error = ivas_masa_decode( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); + } + } + else if ( st_ivas->ivas_format == SBA_FORMAT ) + { + if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 ) + { + st_ivas->hCPE[0]->brate_surplus = 0; + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + } + + /* core-decoding of transport channels */ + if ( st_ivas->nSCE == 1 ) + { + if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE == 1 ) + { + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE > 1 ) + { + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#ifdef DEBUG_SBA_AUDIO_DUMP + /* Dump audio signal after core-decoding */ + ivas_spar_dump_signal_wav( output_frame, NULL, output, st_ivas->nchan_transport, spar_foa_dec_wav[0], "core-decoding" ); +#endif + /* TCs remapping */ + nchan_remapped = st_ivas->nchan_transport; + if ( st_ivas->sba_dirac_stereo_flag ) + { + nchan_remapped = nchan_out; + + if ( st_ivas->ivas_format == SBA_FORMAT ) + { + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, p_output, p_output, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + + if ( st_ivas->hSpar->hPCA != NULL ) + { + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output ); + } + + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + } + + ivas_sba_dirac_stereo_dec( st_ivas, p_output, output_frame, st_ivas->ivas_format == MC_FORMAT ); + } + else if ( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( ivas_total_brate > IVAS_SID_5k2 || ( ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) + { + nchan_remapped = 1; /* Only one channel transported */ + } + + /* HP filtering */ +#ifndef DEBUG_SPAR_BYPASS_EVS_CODEC + for ( n = 0; n < nchan_remapped; n++ ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } +#endif + + if ( st_ivas->ivas_format == SBA_FORMAT ) + { + nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, p_output, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); + } + else if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + ivas_spar_dec_agc_pca( st_ivas, p_output, output_frame ); + } + } + + if ( st_ivas->ivas_format == MASA_FORMAT ) + { + ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); + } + else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain( p_output, nchan_remapped, output_frame ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + int16_t nchan_ism, nchan_transport_ism; + int16_t dirac_bs_md_write_idx; + + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); + + /* Set the number of objects for the parametric rendering */ + dirac_bs_md_write_idx = 0; + if ( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->numIsmDirections = 0; + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + { + st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism; + } + + dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ + } + + /* MASA metadata decoding */ + if ( ( error = ivas_masa_decode( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Configuration of combined-format bit-budget distribution */ + ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); + + st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); + + /* set ISM parameters and decode ISM metadata in OMASA format */ + if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* decode ISM channels */ + for ( n = 0; n < nchan_transport_ism; n++ ) + { + if ( ( error = ivas_sce_dec( st_ivas, n, &p_output[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* decode MASA channels */ + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->hCPE[0]->nchan_out == 1 ) + { + mvr2r( p_output[0], p_output[1], output_frame ); /* Copy mono signal to stereo output channels */ + } + + /* HP filtering */ + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + } + else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + /* sanity check in case of bitrate switching */ + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); + } + + ivas_omasa_rearrange_channels( p_output, nchan_transport_ism, output_frame ); + + ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); + } + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int16_t nchan_ism, sba_ch_idx; - ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); -#ifdef SPLIT_REND_WITH_HEAD_ROT - } -#endif + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); + nchan_ism = st_ivas->nchan_ism; + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + /* set ISM parameters and decode ISM metadata in OSBA format */ + if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; } - else if ( st_ivas->renderer_type == RENDERER_MC ) + sba_ch_idx = st_ivas->nchan_ism; + } + else + { + nb_bits_metadata[1] += NO_BITS_MASA_ISM_NO_OBJ; + sba_ch_idx = 0; + } + + /* SBA metadata decoding */ + if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 ) + { + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + } + + /* core-decoding of transport channels */ + if ( st_ivas->nSCE == 1 ) + { + if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { - ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); + return error; } - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + } + else if ( st_ivas->nCPE == 1 ) + { + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { - ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); + return error; } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + } + else if ( st_ivas->nCPE > 1 ) + { + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + return error; + } + } + + if ( st_ivas->sba_dirac_stereo_flag ) + { + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &p_output[sba_ch_idx], &p_output[sba_ch_idx], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + + if ( st_ivas->hSpar->hPCA != NULL ) + { + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); + } + + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + + ivas_sba_dirac_stereo_dec( st_ivas, &p_output[sba_ch_idx], output_frame, 0 ); + } + + /* HP filtering */ + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + nchan_remapped = ivas_sba_remapTCs( &p_output[sba_ch_idx], st_ivas, output_frame ); + +#ifdef DEBUG_OSBA + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + int16_t nchan = st_ivas->nchan_transport + st_ivas->nchan_ism; + for ( int16_t t = 0; t < output_frame; t++ ) + { + for ( int16_t c = 0; c < nchan; c++ ) { - if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } + int16_t val = (int16_t) ( output[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); } - else - { + } + } #endif - if ( ( ivas_td_binaural_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); -#ifdef SPLIT_REND_WITH_HEAD_ROT - } -#endif + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); + } + else if ( st_ivas->renderer_type != RENDERER_DISABLE && !st_ivas->sba_dirac_stereo_flag ) + { + ivas_spar_dec_agc_pca( st_ivas, &p_output[sba_ch_idx], output_frame ); + } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain( &p_output[sba_ch_idx], nchan_remapped, output_frame ); + } + else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + + /* add W */ + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_output[n + max( nchan_out, nchan_ism )], p_output[n], output_frame ); } } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + + if ( st_ivas->mc_mode == MC_MODE_MCT ) { + /* LFE channel decoder */ ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); - ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); - - if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -884,62 +2023,60 @@ ivas_error ivas_dec( } } - ivas_mc_paramupmix_dec( st_ivas, p_output ); - - if ( st_ivas->transport_config != st_ivas->intern_config && - ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) && - ( output_config == IVAS_AUDIO_CONFIG_FOA || output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) - { - ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); - } - - /* Rendering */ - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) + if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif + if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) { - ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); + ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); } } - else if ( st_ivas->renderer_type == RENDERER_MC ) + + if ( ( st_ivas->renderer_type == RENDERER_MC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ) ) { - if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) + if ( st_ivas->renderer_type == RENDERER_MC ) { - ivas_ls_setup_conversion( st_ivas, audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); + ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); } - else + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { - ivas_ls_setup_conversion( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, output_frame, p_output, p_output ); + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); } } - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + /* LFE channel decoder */ + ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); + + ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); + + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { - ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); + return error; } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + + /* HP filtering */ + for ( n = 0; n < st_ivas->nchan_transport; n++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( n != LFE_CHANNEL ) { - if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - else + } + + /* Rendering */ + if ( st_ivas->renderer_type == RENDERER_MC && ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + { + /* Compensate loudness for not doing full upmix */ + for ( n = 4; n < 8; n++ ) { -#endif - if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } + v_multc( p_output[n], 2.0f, p_output[n], output_frame ); + } - ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); -#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) + { + ivas_ls_setup_conversion( st_ivas, audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); } -#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) @@ -973,10 +2110,6 @@ ivas_error ivas_dec( { ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); } - else - { - ivas_param_mc_dec( st_ivas, p_output ); - } } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { @@ -999,8 +2132,8 @@ ivas_error ivas_dec( return error; } - /* Identify the index of the separated channel */ - n = st_ivas->hOutSetup.separateChannelIndex; + /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ + n = LFE_CHANNEL - 1; /* Decode the separated channel to output[n] to be combined with the synthesized channels */ if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) @@ -1050,28 +2183,7 @@ ivas_error ivas_dec( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - /* Rendering */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ - { - ivas_dirac_dec( st_ivas, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); - - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) - { - ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, 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++ ) - { - set_zero( p_output[n], output_frame ); - } - } - } - else if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) + if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) { ivas_mono_stereo_downmix_mcmasa( st_ivas, p_output, output_frame ); } @@ -1079,57 +2191,22 @@ ivas_error ivas_dec( } /*----------------------------------------------------------------* - * Write IVAS output channels - * - compensation for saturation - * - float to integer conversion + * Write IVAS transport channels *----------------------------------------------------------------*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses; - } - else - { - nchan_out_syn_output = nchan_out; - } - - if ( st_ivas->hDecoderConfig->Opt_Limiter ) -#endif - { -#ifndef DISABLE_LIMITER -#ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out_syn_output, output_frame, st_ivas->BER_detect ); +#ifndef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 || !st_ivas->hDecoderConfig->Opt_5ms ) #else - ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, output_frame, st_ivas->BER_detect ); -#endif + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) #endif + { + ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); } - -#ifdef SPLIT_REND_WITH_HEAD_ROT - switch ( pcm_resolution ) + else { - case PCM_INT16: -#endif -#ifdef DEBUGGING - st_ivas->noClipping += -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_syn_output( p_output, output_frame, nchan_out_syn_output, (int16_t *) data ); -#else - ivas_syn_output( p_output, output_frame, nchan_out, data ); -#endif - -#ifdef SPLIT_REND_WITH_HEAD_ROT - break; - case PCM_FLOAT32: - ivas_syn_output_f( p_output, output_frame, nchan_out_syn_output, (float *) data ); - break; - default: - error = IVAS_ERR_UNKNOWN; - break; + /* directly copy to tc buffers */ + ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); } -#endif /*----------------------------------------------------------------* * Common updates @@ -1153,21 +2230,6 @@ ivas_error ivas_dec( st_ivas->last_ivas_format = st_ivas->ivas_format; -#ifdef NONBE_UNIFIED_DECODING_PATHS - /* update global combined orientation start index */ - ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, output_frame ); -#endif - - /* in case first frame(s) was/were lost, deallocate output buffers */ - if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) - { - for ( n = 0; n < nchan_out; n++ ) - { - free( st_ivas->p_output_f[n] ); - st_ivas->p_output_f[n] = NULL; - } - } - #ifdef DEBUG_MODE_INFO dbgwrite( &st_ivas->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" ); dbgwrite( &st_ivas->BER_detect, sizeof( int16_t ), 1, output_frame, "res/BER_detect" ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 25fc8d99fe..f1ac123f47 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1691,7 +1691,7 @@ void ivas_dirac_dec_render( 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 + float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; #endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ea60e71a2f..33b209cd12 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2269,8 +2269,10 @@ ivas_error ivas_init_decoder( } } +#ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES if ( st_ivas->hJbmMetadata == NULL ) { +#endif if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -2278,7 +2280,9 @@ ivas_error ivas_init_decoder( return error; } } +#ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES } +#endif /*-----------------------------------------------------------------* * Allocate floating-point output audio buffers diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 63c8f47d2c..8e5768b18e 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -625,6 +625,15 @@ void ivas_omasa_separate_object_render( } #endif +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +/*-------------------------------------------------------------------------* + * ivas_omasa_separate_object_render() + * + * Rendering separated objects and mixing them to the parametrically rendered signals + *-------------------------------------------------------------------------*/ + +void ivas_omasa_separate_object_render( +#else /*-------------------------------------------------------------------------* * ivas_omasa_separate_object_render_jbm() * @@ -632,6 +641,7 @@ void ivas_omasa_separate_object_render( *-------------------------------------------------------------------------*/ void ivas_omasa_separate_object_render_jbm( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesRendered, /* i : number of samples rendered */ #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index f5b5d5d08a..1af29dd663 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -52,13 +52,14 @@ static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); +#ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); - +#endif static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs ); - +#ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc() * @@ -779,7 +780,7 @@ ivas_error ivas_jbm_dec_tc( pop_wmops(); return IVAS_ERR_OK; } - +#endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_feed_tc_to_renderer() @@ -804,7 +805,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( p_data_f[n] = &data_f[n][0]; } - #ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) #else @@ -943,7 +943,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( return; } - +#ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES /*--------------------------------------------------------------------------* * ivas_dec_render() * @@ -1628,7 +1628,7 @@ ivas_error ivas_jbm_dec_render( pop_wmops(); return IVAS_ERR_OK; } - +#endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_dec_flush_renderer() @@ -1856,7 +1856,11 @@ ivas_error ivas_jbm_dec_flush_renderer( set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); /* render the last subframe */ +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2666,7 +2670,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( return IVAS_ERR_OK; } - +#ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_playout() * @@ -2705,7 +2709,7 @@ static void ivas_jbm_dec_tc_buffer_playout( return; } - +#endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_close() @@ -2993,7 +2997,7 @@ ivas_error ivas_jbm_dec_metadata_open( return IVAS_ERR_OK; } - +#ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_masa_meta_to_buffer() * @@ -3036,7 +3040,7 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( return; } - +#endif /*--------------------------------------------------------------------------* * ivas_jbm_masa_sf_to_slot_map() diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index a160275ea9..c43920f440 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -2495,3 +2495,46 @@ static int16_t ivas_decode_masaism_metadata( return ( nb_bits_read - *next_bit_pos ); } + + +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +/*--------------------------------------------------------------------------* + * ivas_dec_copy_masa_meta_to_buffer() + * + * Copy decoded MASA metadata to a ring buffer + *--------------------------------------------------------------------------*/ + +void ivas_dec_copy_masa_meta_to_buffer( + JBM_METADATA_HANDLE hJbmMetadata, /* o : metadata handle for buffering in JBM */ + MASA_DECODER_EXT_OUT_META *extOutMeta /* i : MASA external output metadata */ +) +{ + int16_t sf, dir, band; + int16_t write_idx; + + for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + write_idx = ( hJbmMetadata->sf_write_idx + sf ) % hJbmMetadata->sf_md_buffer_length; + + for ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) + { + for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + hJbmMetadata->directionIndexBuffer[dir][write_idx][band] = extOutMeta->directionIndex[dir][sf][band]; + hJbmMetadata->directToTotalRatioBuffer[dir][write_idx][band] = extOutMeta->directToTotalRatio[dir][sf][band]; + hJbmMetadata->spreadCoherenceBuffer[dir][write_idx][band] = extOutMeta->spreadCoherence[dir][sf][band]; + } + } + + for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + hJbmMetadata->diffuseToTotalRatioBuffer[write_idx][band] = extOutMeta->diffuseToTotalRatio[sf][band]; + hJbmMetadata->surroundCoherenceBuffer[write_idx][band] = extOutMeta->surroundCoherence[sf][band]; + } + + hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections; + } + + return; +} +#endif diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index a0f522711e..d3c2986051 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -310,7 +310,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( int16_t original_slots_rendered; float *p_bin_output[BINAURAL_CHANNELS]; #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - float output_local[MAX_OUTPUT_CHANNELS][L_FRAME48k]; // VE2SB: TBV + float output_local[MAX_OUTPUT_CHANNELS][L_FRAME48k]; #endif push_wmops( "ivas_td_binaural_renderer_sf_splitBinaural" ); diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index daf217575a..f5bb172ada 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -619,6 +619,15 @@ void ivas_omasa_dirac_rend( } #endif +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +/*--------------------------------------------------------------------------* + * ivas_omasa_dirac_rend() + * + * Rendering in OMASA format JBM + *--------------------------------------------------------------------------*/ + +void ivas_omasa_dirac_rend( +#else /*--------------------------------------------------------------------------* * ivas_omasa_dirac_rend_jbm() * @@ -626,6 +635,7 @@ void ivas_omasa_dirac_rend( *--------------------------------------------------------------------------*/ void ivas_omasa_dirac_rend_jbm( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ @@ -659,7 +669,11 @@ void ivas_omasa_dirac_rend_jbm( ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + ivas_omasa_separate_object_render( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); +#else ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); +#endif #else ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, output_f, subframes_rendered, slots_rendered ); #endif @@ -726,10 +740,14 @@ ivas_error ivas_omasa_dirac_td_binaural( /*--------------------------------------------------------------------------* * ivas_omasa_dirac_td_binaural_render() * - * Binaural rendering in OMASA format for JBM + * Binaural rendering in OMASA format *--------------------------------------------------------------------------*/ +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +ivas_error ivas_omasa_dirac_td_binaural( +#else ivas_error ivas_omasa_dirac_td_binaural_jbm( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index a30ddfb557..c69ce40505 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -118,6 +118,15 @@ void ivas_osba_data_close( } +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES +/*--------------------------------------------------------------------------* + * ivas_osba_dirac_td_binaural() + * + * Binaural rendering in OSBA format + *--------------------------------------------------------------------------*/ + +ivas_error ivas_osba_dirac_td_binaural( +#else /*--------------------------------------------------------------------------* * ivas_osba_dirac_td_binaural_jbm() * @@ -125,6 +134,7 @@ void ivas_osba_data_close( *--------------------------------------------------------------------------*/ ivas_error ivas_osba_dirac_td_binaural_jbm( +#endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ @@ -135,7 +145,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( int16_t n; ivas_error error; #ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - float output_separated_objects[BINAURAL_CHANNELS][L_FRAME48k]; // VE2SB: TBV + float output_separated_objects[BINAURAL_CHANNELS][L_FRAME48k]; float *p_sepobj[BINAURAL_CHANNELS]; int16_t channel_offset; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index a87cdaca30..452f478e91 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -424,7 +424,7 @@ 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 + float buffer_tmp[HOA3_CHANNELS][L_FRAME48k]; #endif int16_t sba_num_chans; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 5db840877a..e27f6272cd 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -912,7 +912,7 @@ typedef struct decoder_tc_buffer_structure { 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 + float *tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ #else float *tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b1ac64db2d..a8061055a2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1490,7 +1490,11 @@ static ivas_error IVAS_DEC_GetTcSamples( else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) { /* run the main IVAS decoding routine */ +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + if ( ( error = ivas_dec( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1567,9 +1571,17 @@ static ivas_error IVAS_DEC_GetRenderedSamples( /* run the main IVAS decoding routine */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + error = ivas_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); +#else error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); +#endif +#else +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES + error = ivas_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); #else error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); +#endif #endif return error; -- GitLab From a9b3da8aeaf1b8b1d319ba334bbc02c23cd79d11 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 24 Nov 2023 13:14:32 +0100 Subject: [PATCH 02/22] remove the "_jbm_" from other function names --- lib_com/ivas_prot.h | 40 +++---- lib_dec/ivas_dec.c | 8 +- lib_dec/ivas_dirac_dec.c | 12 +- lib_dec/ivas_init_dec.c | 23 ++-- lib_dec/ivas_ism_dec.c | 11 +- lib_dec/ivas_ism_param_dec.c | 10 +- lib_dec/ivas_ism_renderer.c | 2 +- lib_dec/ivas_jbm_dec.c | 114 +++++++++---------- lib_dec/ivas_masa_dec.c | 12 +- lib_dec/ivas_mc_param_dec.c | 7 +- lib_dec/ivas_mc_paramupmix_dec.c | 10 +- lib_dec/ivas_mct_dec.c | 10 +- lib_dec/ivas_sba_dec.c | 5 +- lib_dec/ivas_spar_decoder.c | 8 +- lib_dec/lib_dec.c | 6 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- 16 files changed, 141 insertions(+), 139 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index dc8ab06fe2..d69d55c1d4 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -801,7 +801,7 @@ void ivas_apply_non_diegetic_panning( /*----------------------------------------------------------------------------------* - * JBM prototypes + * decoder->rendering TC buffer prototypes *----------------------------------------------------------------------------------*/ #ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES @@ -840,7 +840,7 @@ ivas_error ivas_jbm_dec_flush_renderer( #endif ); -void ivas_jbm_dec_feed_tc_to_renderer( +void ivas_dec_feed_tc_to_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ @@ -851,19 +851,19 @@ ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); -void ivas_jbm_dec_get_adapted_linear_interpolator( +void ivas_dec_get_adapted_linear_interpolator( const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ const int16_t interp_length, /* i : length of the interpolator to be created */ float *interpolator /* o : the interpolator */ ); -void ivas_jbm_dec_get_adapted_subframes( +void ivas_dec_get_adapted_subframes( const int16_t nCldfbTs, /* i : number of time slots in the current frame */ int16_t *subframe_nbslots, /* i/o: subframe grid */ int16_t *nb_subframes /* i/o: number of subframes in the frame */ ); -void ivas_jbm_dec_get_md_map( +void ivas_dec_get_md_map( const int16_t default_len, /* i : default frame length in metadata slots */ const int16_t len, /* i : length of the modfied frames in metadata slots */ const int16_t subframe_len, /* i : default length of a subframe */ @@ -872,17 +872,17 @@ void ivas_jbm_dec_get_md_map( int16_t *map /* o : metadata index map */ ); -int16_t ivas_jbm_dec_get_num_tc_channels( +int16_t ivas_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -void ivas_jbm_dec_copy_tc_no_tsm( +void ivas_dec_copy_tc_to_tsm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *tc[], /* i : transport channels */ const int16_t output_frame /* i : output frame size */ ); -void ivas_jbm_dec_get_md_map_even_spacing( +void ivas_dec_get_md_map_even_spacing( const int16_t len, /* i : length of the modfied frames in metadata slots */ const int16_t subframe_len, /* i : default length of a subframe */ const int16_t offset, /* i : current read offset into the md buffer */ @@ -890,19 +890,19 @@ void ivas_jbm_dec_get_md_map_even_spacing( int16_t *map /* o : metadata index map */ ); -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( +TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); /*! r: render granularity */ -int16_t ivas_jbm_dec_get_render_granularity( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ +int16_t ivas_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ + const int32_t output_Fs /* i : sampling rate */ ); -ivas_error ivas_jbm_dec_tc_buffer_open( +ivas_error ivas_dec_tc_buffer_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ const int16_t nchan_transport_jbm, /* i : number of real transport channels */ @@ -911,7 +911,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); -ivas_error ivas_jbm_dec_tc_buffer_reconfigure( +ivas_error ivas_dec_tc_buffer_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ @@ -920,19 +920,19 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ); -void ivas_jbm_dec_tc_buffer_close( +void ivas_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); -void ivas_jbm_dec_td_renderers_adapt_subframes( +void ivas_dec_td_renderers_adapt_subframes( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -ivas_error ivas_jbm_dec_metadata_open( +ivas_error ivas_dec_metadata_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -void ivas_jbm_masa_sf_to_sf_map( +void ivas_masa_sf_to_sf_map( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 536b1c7ff4..fca4a14472 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -743,8 +743,8 @@ ivas_error ivas_dec( } else { - /* directly copy to tc buffers */ - ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); + /* directly copy to TC buffers */ + ivas_dec_copy_tc_to_tsm( st_ivas, p_output, output_frame ); } /*----------------------------------------------------------------* @@ -2204,8 +2204,8 @@ ivas_error ivas_jbm_dec_tc( } else { - /* directly copy to tc buffers */ - ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); + /* directly copy to TC buffers */ + ivas_dec_copy_tc_to_tsm( st_ivas, p_output, output_frame ); } /*----------------------------------------------------------------* diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index f1ac123f47..fdc8f68439 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -975,7 +975,7 @@ ivas_error ivas_dirac_dec_config( { nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_to_allocate, nchan_to_allocate, st_ivas->hSpatParamRendCom->slot_size ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_to_allocate, nchan_to_allocate, st_ivas->hSpatParamRendCom->slot_size ) ) != IVAS_ERR_OK ) { return error; } @@ -1540,7 +1540,7 @@ void ivas_dirac_dec_set_md_map( num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; hSpatParamRendCom->subframes_rendered = 0; - ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpatParamRendCom->subframe_nbslots, &hSpatParamRendCom->nb_subframes ); + ivas_dec_get_adapted_subframes( nCldfbTs, hSpatParamRendCom->subframe_nbslots, &hSpatParamRendCom->nb_subframes ); /* copy also to tc buffer */ /* only for non-combined formats and combinded formats w/o discrete objects */ @@ -1556,15 +1556,15 @@ void ivas_dirac_dec_set_md_map( if ( st_ivas->ivas_format == MASA_FORMAT ) { - ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); + ivas_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); } else if ( hDirAC == NULL || hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 ) { - ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); + ivas_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); } else { - ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, hSpatParamRendCom->dirac_read_idx, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); + ivas_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, hSpatParamRendCom->dirac_read_idx, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); } if ( hDirAC == NULL || hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 ) @@ -2458,7 +2458,7 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); + ivas_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); interp_offset = 0; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 33b209cd12..b62027d95d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2026,9 +2026,9 @@ ivas_error ivas_init_decoder( { #endif granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); - n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_channels_transport_jbm = ivas_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -2081,9 +2081,9 @@ ivas_error ivas_init_decoder( { granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); - n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_channels_transport_jbm = ivas_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -2092,9 +2092,9 @@ ivas_error ivas_init_decoder( { granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); - n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_channels_transport_jbm = ivas_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -2249,12 +2249,11 @@ ivas_error ivas_init_decoder( #else if ( st_ivas->hTcBuffer == NULL ) #endif - { /* no module has yet open the TC buffer, open a default one */ - n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_channels_transport_jbm = ivas_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, ivas_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } @@ -2263,7 +2262,7 @@ ivas_error ivas_init_decoder( if ( st_ivas->hTcBuffer == NULL ) { /* we need the handle anyway, but without the buffer*/ - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) { return error; } @@ -2275,7 +2274,7 @@ ivas_error ivas_init_decoder( #endif if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - if ( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -2792,7 +2791,7 @@ void ivas_destroy_dec( st_ivas->hDecoderConfig = NULL; } - ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); + ivas_dec_tc_buffer_close( &st_ivas->hTcBuffer ); if ( st_ivas->hJbmMetadata != NULL ) { diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 7d22eb50ba..b8237c67b8 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -144,7 +144,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ - tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { @@ -339,6 +339,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ + #ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) #endif @@ -347,8 +348,8 @@ static ivas_error ivas_ism_bitrate_switching_dec( DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_buffer_mode_new = ivas_dec_get_tc_buffer_mode( st_ivas ); + tc_nchan_tc_new = ivas_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; @@ -363,11 +364,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( tc_nchan_full_new = 0; } - /* reconfigure buffer */ + /* reconfigure TC buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index d355798f6d..f99b2eabc5 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -633,7 +633,7 @@ ivas_error ivas_param_ism_dec_open( if ( st_ivas->hTcBuffer == NULL ) { - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } @@ -646,7 +646,7 @@ ivas_error ivas_param_ism_dec_open( if ( st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } @@ -997,7 +997,7 @@ void ivas_ism_dec_digest_tc( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes( st_ivas ); if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || @@ -1037,7 +1037,7 @@ void ivas_ism_dec_digest_tc( } else { - ivas_jbm_dec_get_adapted_linear_interpolator( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); + ivas_dec_get_adapted_linear_interpolator( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); } /* also get the gains here */ @@ -1137,7 +1137,7 @@ void ivas_param_ism_dec_digest_tc( push_wmops( "ivas_param_ism_dec" ); /* general setup */ - ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); + ivas_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 8e5768b18e..bd64999c95 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -299,7 +299,7 @@ void ivas_ism_render_sf( if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) #endif { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); + ivas_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); interp_offset = 0; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1af29dd663..2a0b617d5d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -50,14 +50,14 @@ * Local function prototypes *-----------------------------------------------------------------------*/ -static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); +static void ivas_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); #ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); #endif -static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs ); +static void ivas_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs ); #ifndef UNIFIED_DECODING_PATHS_FUNCTION_NAMES /*--------------------------------------------------------------------------* @@ -742,8 +742,8 @@ ivas_error ivas_jbm_dec_tc( } else { - /* directly copy to tc buffers */ - ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); + /* directly copy to TC buffers */ + ivas_dec_copy_tc_to_tsm( st_ivas, p_output, output_frame ); } /*----------------------------------------------------------------* @@ -783,12 +783,12 @@ ivas_error ivas_jbm_dec_tc( #endif /*--------------------------------------------------------------------------* - * ivas_jbm_dec_feed_tc_to_renderer() + * ivas_dec_feed_tc_to_renderer() * - * Feed decoded transport channels and metadata to the IVAS JBM renderer routine + * Feed decoded transport channels and metadata to the IVAS renderer routine *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_feed_tc_to_renderer( +void ivas_dec_feed_tc_to_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ @@ -811,7 +811,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hDecoderConfig->Opt_tsm ) #endif { - ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); + ivas_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); } else { @@ -821,16 +821,16 @@ void ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes( st_ivas ); if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + ivas_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes( st_ivas ); } else if ( st_ivas->ivas_format == ISM_FORMAT ) { @@ -899,7 +899,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( else { #ifdef NONBE_FIX_904_JBM_SBA_RS_FOA - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes( st_ivas ); #endif ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); @@ -923,7 +923,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { if ( st_ivas->mc_mode == MC_MODE_MCT ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes( st_ivas ); } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { @@ -1631,7 +1631,7 @@ ivas_error ivas_jbm_dec_render( #endif /*--------------------------------------------------------------------------* - * ivas_jbm_dec_dec_flush_renderer() + * ivas_jbm_dec_flush_renderer() * * Flush samples if renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ @@ -1950,12 +1950,12 @@ ivas_error ivas_jbm_dec_set_discard_samples( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_adapted_linear_interpolator() + * ivas_dec_get_adapted_linear_interpolator() * * Get an interpolator that is adapted to time scale modified IVAS frame *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_get_adapted_linear_interpolator( +void ivas_dec_get_adapted_linear_interpolator( const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ const int16_t interp_length, /* i : length of the interpolator to be created */ float *interpolator /* o : the interpolator */ @@ -1994,12 +1994,12 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_adapted_subframes() + * ivas_dec_get_adapted_subframes() * * Get an interpolator that is adapted to time scale modified IVAS frame *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_get_adapted_subframes( +void ivas_dec_get_adapted_subframes( const int16_t nCldfbTs, /* i : number of time slots in the current frame */ int16_t *subframe_nbslots, /* i/o: subframe grid */ int16_t *nb_subframes /* i/o: number of subframes in the frame */ @@ -2039,12 +2039,12 @@ void ivas_jbm_dec_get_adapted_subframes( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_adapted_linear_interpolator() + * ivas_dec_get_md_map() * - * Get an meta data map adapted to a time scale modified IVAS frame + * Get an meta data map adapted to a time scale *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_get_md_map( +void ivas_dec_get_md_map( const int16_t default_len, /* i : default frame length in metadata slots */ const int16_t len, /* i : length of the modfied frames in metadata slots */ const int16_t subframe_len, /* i : default length of a subframe */ @@ -2091,12 +2091,12 @@ void ivas_jbm_dec_get_md_map( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_md_map_even_spacing() + * ivas_dec_get_md_map_even_spacing() * * Get an meta data map adapted to a time scale modified IVAS frame. Distribute slots evenly across the modified frame. *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_get_md_map_even_spacing( +void ivas_dec_get_md_map_even_spacing( const int16_t len, /* i : length of the modfied frames in metadata slots */ const int16_t subframe_len, /* i : default length of a subframe */ const int16_t offset, /* i : current read offset into the md buffer */ @@ -2154,12 +2154,12 @@ void ivas_jbm_dec_get_md_map_even_spacing( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_num_tc_channels() + * ivas_dec_get_num_tc_channels() * - * Get the number of transport channels provided by the JBM transport channel decode function + * Get the number of transport channels *--------------------------------------------------------------------------*/ -int16_t ivas_jbm_dec_get_num_tc_channels( +int16_t ivas_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ) { @@ -2306,13 +2306,13 @@ int16_t ivas_jbm_dec_get_num_tc_channels( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_copy_tc() + * ivas_dec_copy_tc() * * Copy interleaved transport chnannels to the correct buffers, update the TC * buffer handle *--------------------------------------------------------------------------*/ -static void ivas_jbm_dec_copy_tc( +static void ivas_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ int16_t *nSamplesResidual, /* o : number of samples that will be left for the next frame */ @@ -2365,16 +2365,16 @@ static void ivas_jbm_dec_copy_tc( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_render_granularity() + * ivas_dec_get_render_granularity() * * *--------------------------------------------------------------------------*/ /*! r: render granularity */ -int16_t ivas_jbm_dec_get_render_granularity( +int16_t ivas_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ ) { @@ -2401,12 +2401,12 @@ int16_t ivas_jbm_dec_get_render_granularity( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_buffer_open() + * ivas_dec_tc_buffer_open() * * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_tc_buffer_open( +ivas_error ivas_dec_tc_buffer_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ const int16_t nchan_transport_jbm, /* i : number of real transport channels */ @@ -2530,12 +2530,12 @@ ivas_error ivas_jbm_dec_tc_buffer_open( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_buffer_reconfigure() + * ivas_dec_tc_buffer_reconfigure() * - * open and initialize JBM transport channel buffer + * open and initialize TC buffer *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_tc_buffer_reconfigure( +ivas_error ivas_dec_tc_buffer_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ @@ -2712,12 +2712,12 @@ static void ivas_jbm_dec_tc_buffer_playout( #endif /*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_buffer_close() + * ivas_dec_tc_buffer_close() * - * Close JBM transport channel buffer + * Close TC buffer *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_tc_buffer_close( +void ivas_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { @@ -2745,12 +2745,12 @@ void ivas_jbm_dec_tc_buffer_close( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_td_renderers_adapt_subframes() + * ivas_dec_td_renderers_adapt_subframes() * - * Close JBM transport channel buffer + * *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_td_renderers_adapt_subframes( +void ivas_dec_td_renderers_adapt_subframes( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -2792,12 +2792,12 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_tc_buffer_mode() + * ivas_dec_get_tc_buffer_mode() * * *--------------------------------------------------------------------------*/ -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( +TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { @@ -2849,7 +2849,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( } break; case RENDERER_MC: - if ( ivas_jbm_dec_get_num_tc_channels( st_ivas ) != st_ivas->hDecoderConfig->nchan_out ) + if ( ivas_dec_get_num_tc_channels( st_ivas ) != st_ivas->hDecoderConfig->nchan_out ) { buffer_mode = TC_BUFFER_MODE_RENDERER; } @@ -2885,12 +2885,12 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_copy_tc_no_tsm() + * ivas_dec_copy_tc_to_tsm() * * *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_copy_tc_no_tsm( +void ivas_dec_copy_tc_to_tsm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *tc[], /* i : transport channels */ const int16_t output_frame /* i : output frame size */ @@ -2972,12 +2972,12 @@ void ivas_jbm_dec_copy_tc_no_tsm( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_metadata_open() + * ivas_dec_metadata_open() * - * Open structure for metadata buffering in JBM + * Open structure for metadata buffering *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_metadata_open( +ivas_error ivas_dec_metadata_open( Decoder_Struct *st_ivas ) { JBM_METADATA_HANDLE hJbmMetadata; @@ -3043,12 +3043,12 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( #endif /*--------------------------------------------------------------------------* - * ivas_jbm_masa_sf_to_slot_map() + * ivas_masa_sf_to_slot_map() * - * Map input MASA metadata subframes to slots in JBM processing + * Map input MASA metadata subframes to slots *--------------------------------------------------------------------------*/ -static void ivas_jbm_masa_sf_to_slot_map( +static void ivas_masa_sf_to_slot_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nCldfbTs /* i : number of CLDFB time slots */ ) @@ -3064,7 +3064,7 @@ static void ivas_jbm_masa_sf_to_slot_map( num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; /* Map input subframes to slots */ - ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map ); + ivas_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map ); for ( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ ) { @@ -3082,12 +3082,12 @@ static void ivas_jbm_masa_sf_to_slot_map( /*--------------------------------------------------------------------------* - * ivas_jbm_masa_sf_to_sf_map() + * ivas_masa_sf_to_sf_map() * * Map input MASA metadata subframes to output subframes in JBM processing *--------------------------------------------------------------------------*/ -void ivas_jbm_masa_sf_to_sf_map( +void ivas_masa_sf_to_sf_map( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index c43920f440..fe498d77cb 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -641,7 +641,7 @@ ivas_error ivas_masa_dec_open( buffer_mode = TC_BUFFER_MODE_BUFFER; } - nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + nchan_transport = ivas_dec_get_num_tc_channels( st_ivas ); nchan_to_allocate = nchan_transport; if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -655,7 +655,7 @@ ivas_error ivas_masa_dec_open( nchan_to_allocate++; } - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1468,8 +1468,8 @@ ivas_error ivas_masa_dec_reconfigure( int16_t n_samples_granularity; n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); - tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + buffer_mode_new = ivas_dec_get_tc_buffer_mode( st_ivas ); + tc_nchan_transport = ivas_dec_get_num_tc_channels( st_ivas ); tc_nchan_to_allocate = tc_nchan_transport; if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) @@ -1514,10 +1514,10 @@ ivas_error ivas_masa_dec_reconfigure( tc_nchan_to_allocate++; } - + /* reconfigure TC buffer */ if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 3352a79781..a2e06d2116 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -466,7 +466,7 @@ ivas_error ivas_param_mc_dec_open( if ( st_ivas->hTcBuffer == NULL ) { - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1470,11 +1470,12 @@ void ivas_param_mc_dec_digest_tc( { hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); } + /* adapt subframes */ hParamMC->num_slots = nCldfbSlots; hParamMC->slots_rendered = 0; hParamMC->subframes_rendered = 0; - ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); + ivas_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); @@ -2240,7 +2241,7 @@ static void ivas_param_mc_dec_compute_interpolator( } else { - ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, interp_length, interpolator ); + ivas_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, interp_length, interpolator ); } return; diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 57065ed325..a47d5a66c3 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -498,9 +498,9 @@ void ivas_mc_paramupmix_dec_digest_tc( ivas_param_upmix_dec_decorr_subframes( st_ivas, nSamplesForRendering ); /* adapt subframes */ - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_dec_td_renderers_adapt_subframes( st_ivas ); - ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hMCParamUpmix->param_interpolator ); + ivas_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hMCParamUpmix->param_interpolator ); pop_wmops(); return; @@ -703,7 +703,7 @@ ivas_error ivas_mc_paramupmix_dec_open( } hMCParamUpmix->free_param_interpolator = 1; - ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator ); + ivas_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator ); #ifndef NONBE_UNIFIED_DECODING_PATHS } #endif @@ -719,7 +719,7 @@ ivas_error ivas_mc_paramupmix_dec_open( TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; - nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + nchan_tc = ivas_dec_get_num_tc_channels( st_ivas ); nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) @@ -733,7 +733,7 @@ ivas_error ivas_mc_paramupmix_dec_open( nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; } - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 167d8b6727..61eb8f413e 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -797,7 +797,7 @@ static ivas_error ivas_mc_dec_reconfig( /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ - tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1333,8 +1333,8 @@ static ivas_error ivas_mc_dec_reconfig( DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_buffer_mode_new = ivas_dec_get_tc_buffer_mode( st_ivas ); + tc_nchan_tc_new = ivas_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; @@ -1361,12 +1361,12 @@ static ivas_error ivas_mc_dec_reconfig( tc_nchan_full_new = tc_nchan_allocate_new; } - /* reconfigure buffer */ + /* reconfigure TC buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || tc_granularity_new != hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index d5b5d8ff14..02f1426504 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -613,7 +613,7 @@ ivas_error ivas_sba_dec_reconfigure( TC_BUFFER_MODE tc_buffer_mode; tc_buffer_mode = TC_BUFFER_MODE_RENDERER; - tc_nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_nchan_tc = ivas_dec_get_num_tc_channels( st_ivas ); tc_nchan_to_allocate = tc_nchan_tc; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { @@ -650,9 +650,10 @@ ivas_error ivas_sba_dec_reconfigure( } } + /* reconfigure TC buffer */ if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || granularity_new != st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 76e5c6f1fb..e5311bf341 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -224,7 +224,7 @@ ivas_error ivas_spar_dec_open( int16_t granularity; buffer_mode = TC_BUFFER_MODE_RENDERER; - nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + nchan_tc = ivas_dec_get_num_tc_channels( st_ivas ); nchan_to_allocate = num_channels_internal; if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -267,7 +267,7 @@ ivas_error ivas_spar_dec_open( nchan_to_allocate = 0; } #endif - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -1259,7 +1259,7 @@ void ivas_spar_dec_set_render_map( hSpar->subframes_rendered = 0; set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes ); + ivas_dec_get_adapted_subframes( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes ); /* copy also to tc buffer */ /* only for non-combined formats and combinded formats w/o discrete objects */ @@ -1269,7 +1269,7 @@ void ivas_spar_dec_set_render_map( mvs2s( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); } - ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map ); + ivas_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map ); return; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a8061055a2..87ac5d4bee 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1534,7 +1534,7 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( st_ivas = hIvasDec->st_ivas; /* feed the TCs to the IVAS renderer */ - ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesForRendering, nSamplesResidual, pcmBuf ); + ivas_dec_feed_tc_to_renderer( st_ivas, nSamplesForRendering, nSamplesResidual, pcmBuf ); return IVAS_ERR_OK; } @@ -1841,7 +1841,7 @@ ivas_error IVAS_DEC_GetMasaMetadata( if ( getFromJbmBuffer ) { - ivas_jbm_masa_sf_to_sf_map( hIvasDec->st_ivas ); + ivas_masa_sf_to_sf_map( hIvasDec->st_ivas ); } *hMasaExtOutMeta = hIvasDec->st_ivas->hMasa->data.extOutMeta; @@ -3506,7 +3506,7 @@ static ivas_error evs_dec_main( if ( !st_ivas->hDecoderConfig->Opt_tsm ) #endif { - ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); + ivas_dec_copy_tc_to_tsm( st_ivas, p_output, nOutSamples ); } else if ( floatBuf != NULL ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 52f7718069..eaaf1e30c8 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -333,7 +333,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ } - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_dec_get_num_tc_channels( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 13b408bb5da302485348f4f7debf5820ddd4a748 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 24 Nov 2023 14:14:52 +0100 Subject: [PATCH 03/22] clang-format + remove nested UNIFIED_DECODING_PATHS_FUNCTION_NAMES switches --- lib_dec/ivas_dec.c | 599 ++++++++++++++++++++++++++++++++------- lib_dec/ivas_omasa_dec.c | 11 +- 2 files changed, 505 insertions(+), 105 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index fca4a14472..e437ad4819 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -231,11 +231,7 @@ ivas_error ivas_dec( if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { -#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES ivas_dec_copy_masa_meta_to_buffer( st_ivas->hJbmMetadata, st_ivas->hMasa->data.extOutMeta ); -#else - ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); -#endif } } else if ( st_ivas->ivas_format == SBA_FORMAT ) @@ -414,11 +410,7 @@ ivas_error ivas_dec( ivas_omasa_rearrange_channels( p_output, nchan_transport_ism, output_frame ); -#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES ivas_dec_copy_masa_meta_to_buffer( st_ivas->hJbmMetadata, st_ivas->hMasa->data.extOutMeta ); -#else - ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); -#endif } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -1044,11 +1036,7 @@ ivas_error ivas_dec_render( { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { -#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1060,11 +1048,7 @@ ivas_error ivas_dec_render( } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) { -#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES ivas_omasa_dirac_rend( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); -#else - ivas_omasa_dirac_rend_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); -#endif } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -1076,11 +1060,7 @@ ivas_error ivas_dec_render( { if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { -#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1229,16 +1209,13 @@ ivas_error ivas_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; } @@ -1525,20 +1502,35 @@ static void ivas_dec_tc_buffer_playout( /*--------------------------------------------------------------------------* * ivas_dec() * - * Principal IVAS decoder routine, decoding of metadata and transport channels + * Principal IVAS decoder routine *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : transport channel signals */ +#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 */ ) { - 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 */ -#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 */ + // 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 */ +#else + int16_t *data /* o : output synthesis signal */ #endif +) +{ + int16_t n, output_frame, nchan_out; + Decoder_State *st; /* used for bitstream handling */ + float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* 'float' buffer for output synthesis */ int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; int32_t output_Fs, ivas_total_brate; @@ -1546,6 +1538,9 @@ ivas_error ivas_jbm_dec_tc( ivas_error error; int16_t num_md_sub_frames; int32_t ism_total_brate; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t nchan_out_syn_output; +#endif push_wmops( "ivas_dec" ); @@ -1554,41 +1549,57 @@ ivas_error ivas_jbm_dec_tc( *----------------------------------------------------------------*/ output_Fs = st_ivas->hDecoderConfig->output_Fs; - nchan_out = st_ivas->hTcBuffer->nchan_transport_jbm; + nchan_out = st_ivas->hDecoderConfig->nchan_out; output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); - for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) + 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]; - if ( p_output[n] != NULL ) - { - set_zero( p_output[n], L_FRAME48k ); - } + } + + /*----------------------------------------------------------------* + * Update combined orientation access index + *----------------------------------------------------------------*/ + +#ifndef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + { + return error; + } #else - p_output[n] = output_f[n]; + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); #endif - } -#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX - if ( !st_ivas->hDecoderConfig->Opt_tsm ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*----------------------------------------------------------------* + * Binaural split rendering setup + *----------------------------------------------------------------*/ + + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - 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]; - } + ivas_set_split_rend_ht_setup( &st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData ); } #endif /*----------------------------------------------------------------* - * Decoding + pre-rendering + * Decoding + Rendering *----------------------------------------------------------------*/ if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) { + for ( n = 0; n < nchan_out; n++ ) + { + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); + } + p_output[n] = st_ivas->p_output_f[n]; + } + /* zero output when first frame(s) is lost */ for ( n = 0; n < nchan_out; n++ ) { @@ -1605,6 +1616,7 @@ ivas_error ivas_jbm_dec_tc( else if ( st_ivas->ivas_format == STEREO_FORMAT ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; + if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; @@ -1616,7 +1628,8 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) + /* Rendering */ + if ( st_ivas->renderer_type == RENDERER_MC ) { ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); } @@ -1673,21 +1686,111 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + /* Rendering */ + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); + + ivas_param_ism_params_to_masa_param_mapping( st_ivas ); + + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + } + else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + { + ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, output_frame ); + } + else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_param_ism_dec( st_ivas, p_output ); + + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + /* Convert CICP19 -> Ambisonics */ + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); + } + } } - else if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) + else /* ISM_MODE_DISC */ { - /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain( p_output, st_ivas->nchan_transport, output_frame ); + /* Loudspeaker or Ambisonics rendering */ + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + } + else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + { + ivas_apply_non_diegetic_panning( p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, output_frame ); + } + else if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { + /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ + ivas_ism_render( st_ivas, p_output, output_frame ); + } +#ifdef DEBUGGING + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) +#else + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) +#endif + { + /* Convert to Ambisonics; used also for ISM->HOA3->binaural rendering */ + ivas_ism2sba( p_output, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); + } + + /* Binaural rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } +#ifndef FIX_881_REMOVE_LFE_ADDITION_IN_ISM + ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); +#endif + } +#ifdef DEBUGGING + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + ivas_binaural_cldfb( st_ivas, p_output ); + } +#endif } } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { set_s( nb_bits_metadata, 0, MAX_SCE ); - /* read parameters from the bitstream */ if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hQMetaData != NULL ) { @@ -1697,11 +1800,6 @@ ivas_error ivas_jbm_dec_tc( { return error; } - - if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) - { - ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); - } } else if ( st_ivas->ivas_format == SBA_FORMAT ) { @@ -1713,14 +1811,13 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 ) { - st_ivas->hCPE[0]->brate_surplus = 0; st_ivas->hCPE[0]->element_brate = ivas_total_brate; } /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -1739,11 +1836,22 @@ ivas_error ivas_jbm_dec_tc( return error; } } - +#ifdef DEBUG_LBR_SBA + /* SCE Decoder Output */ + for ( int16_t t = 0; t < 960; t++ ) + { + for ( int16_t c = 0; c < st_ivas->nchan_transport; c++ ) + { + float val = output[c][t] / MAX16B_FLT; + dbgwrite( &val, sizeof( float ), 1, 1, "int_dec_core_out.raw" ); + } + } +#endif #ifdef DEBUG_SBA_AUDIO_DUMP /* Dump audio signal after core-decoding */ ivas_spar_dump_signal_wav( output_frame, NULL, output, st_ivas->nchan_transport, spar_foa_dec_wav[0], "core-decoding" ); #endif + /* TCs remapping */ nchan_remapped = st_ivas->nchan_transport; if ( st_ivas->sba_dirac_stereo_flag ) @@ -1776,7 +1884,6 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } #endif - if ( st_ivas->ivas_format == SBA_FORMAT ) { nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); @@ -1801,6 +1908,33 @@ ivas_error ivas_jbm_dec_tc( /* loudness correction */ ivas_dirac_dec_binaural_sba_gain( p_output, nchan_remapped, output_frame ); } + + /* Loudspeakers, Ambisonics or Binaural rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + else if ( st_ivas->ivas_format == MASA_FORMAT ) + { + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) + { + if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, 0, output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->renderer_type == RENDERER_DIRAC ) + { + ivas_dirac_dec( st_ivas, p_output, nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + else if ( !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) + { + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ + { + return error; + } + } } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -1865,11 +1999,32 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + /* Rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); } - else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + else if ( st_ivas->renderer_type == RENDERER_DIRAC ) + { + ivas_omasa_dirac_rend( st_ivas, p_output, output_frame ); + } + + /* external output */ + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { /* sanity check in case of bitrate switching */ if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) @@ -1878,8 +2033,6 @@ ivas_error ivas_jbm_dec_tc( } ivas_omasa_rearrange_channels( p_output, nchan_transport_ism, output_frame ); - - ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -1917,7 +2070,7 @@ ivas_error ivas_jbm_dec_tc( /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_sce_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } @@ -1943,10 +2096,10 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->hSpar->hPCA != NULL ) { - ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); ivas_sba_dirac_stereo_dec( st_ivas, &p_output[sba_ch_idx], output_frame, 0 ); } @@ -1975,11 +2128,10 @@ ivas_error ivas_jbm_dec_tc( #endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); } - else if ( st_ivas->renderer_type != RENDERER_DISABLE && !st_ivas->sba_dirac_stereo_flag ) + else if ( st_ivas->renderer_type != RENDERER_DISABLE ) { ivas_spar_dec_agc_pca( st_ivas, &p_output[sba_ch_idx], output_frame ); } @@ -1989,16 +2141,93 @@ ivas_error ivas_jbm_dec_tc( /* loudness correction */ ivas_dirac_dec_binaural_sba_gain( &p_output[sba_ch_idx], nchan_remapped, output_frame ); } - else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + + /* Loudspeakers, Ambisonics or Binaural rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || + st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { - ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &p_output[sba_ch_idx], nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + ivas_sba_upmixer_renderer( st_ivas, &p_output[sba_ch_idx], output_frame ); + } + } + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_OSBA_STEREO || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) ) + { + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + } + else /* stereo output */ + { + /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case */ + if ( nchan_ism == 1 ) + { + mvr2r( p_output[2], p_output[3], output_frame ); + mvr2r( p_output[1], p_output[2], output_frame ); + } + + ivas_ism_render( st_ivas, p_output, output_frame ); + } - /* add W */ for ( n = 0; n < nchan_out; n++ ) { v_add( p_output[n], p_output[n + max( nchan_out, nchan_ism )], p_output[n], output_frame ); } } + else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS ) + { + if ( ( error = ivas_osba_render( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) + { + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + for ( n = 0; n < nchan_ism; n++ ) + { + delay_signal( p_output[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + } + } + + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->ism_mode == ISM_MODE_NONE ) + { + for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) + { + mvr2r( p_output[n], p_output[n + nchan_ism], output_frame ); + } + + for ( n = 0; n < nchan_ism; n++ ) + { + set_zero( p_output[n], output_frame ); + } + } + } } else if ( st_ivas->ivas_format == MC_FORMAT ) { @@ -2025,27 +2254,72 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) { - if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) + ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); + } + + /* Rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); + if ( ( error = ivas_rend_crendProcessSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hDecoderConfig, + st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } } - } + else + { + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, + st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, + st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } - if ( ( st_ivas->renderer_type == RENDERER_MC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ) ) + ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + } + else if ( st_ivas->renderer_type == RENDERER_MC ) { - if ( st_ivas->renderer_type == RENDERER_MC ) + ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); + } + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); + if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } } - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + else { - ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); +#endif + if ( ( ivas_td_binaural_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + + ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { - /* LFE channel decoder */ ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); @@ -2064,19 +2338,62 @@ ivas_error ivas_jbm_dec_tc( } } + ivas_mc_paramupmix_dec( st_ivas, p_output ); + + if ( st_ivas->transport_config != st_ivas->intern_config && + ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) && + ( output_config == IVAS_AUDIO_CONFIG_FOA || output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) + { + ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); + } + /* Rendering */ - if ( st_ivas->renderer_type == RENDERER_MC && ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) { - /* Compensate loudness for not doing full upmix */ - for ( n = 4; n < 8; n++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif { - v_multc( p_output[n], 2.0f, p_output[n], output_frame ); + ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); } - + } + else if ( st_ivas->renderer_type == RENDERER_MC ) + { if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { ivas_ls_setup_conversion( st_ivas, audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ), output_frame, p_output, p_output ); } + else + { + ivas_ls_setup_conversion( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, output_frame, p_output, p_output ); + } + } + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, st_ivas->hOutSetup.ambisonics_order, 0.f ); + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + + ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) @@ -2110,6 +2427,10 @@ ivas_error ivas_jbm_dec_tc( { ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); } + else + { + ivas_param_mc_dec( st_ivas, p_output ); + } } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { @@ -2132,8 +2453,8 @@ ivas_error ivas_jbm_dec_tc( return error; } - /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ - n = LFE_CHANNEL - 1; + /* Identify the index of the separated channel */ + n = st_ivas->hOutSetup.separateChannelIndex; /* Decode the separated channel to output[n] to be combined with the synthesized channels */ if ( ( error = ivas_sce_dec( st_ivas, 0, &p_output[n], output_frame, 0 ) ) != IVAS_ERR_OK ) @@ -2183,7 +2504,28 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) + /* Rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ + { + ivas_dirac_dec( st_ivas, p_output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); + + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + { + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, output_frame, 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++ ) + { + set_zero( p_output[n], output_frame ); + } + } + } + else if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) { ivas_mono_stereo_downmix_mcmasa( st_ivas, p_output, output_frame ); } @@ -2191,23 +2533,58 @@ ivas_error ivas_jbm_dec_tc( } /*----------------------------------------------------------------* - * Write IVAS transport channels + * Write IVAS output channels + * - compensation for saturation + * - float to integer conversion *----------------------------------------------------------------*/ -#ifndef NONBE_UNIFIED_DECODING_PATHS - if ( st_ivas->hDecoderConfig->Opt_tsm == 1 || !st_ivas->hDecoderConfig->Opt_5ms ) -#else - if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) -#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses; } else { - /* directly copy to TC buffers */ - ivas_dec_copy_tc_to_tsm( st_ivas, p_output, output_frame ); + nchan_out_syn_output = nchan_out; } + if ( st_ivas->hDecoderConfig->Opt_Limiter ) +#endif + { +#ifndef DISABLE_LIMITER +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out_syn_output, output_frame, st_ivas->BER_detect ); +#else + ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, output_frame, st_ivas->BER_detect ); +#endif +#endif + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + switch ( pcm_resolution ) + { + case PCM_INT16: +#endif +#ifdef DEBUGGING + st_ivas->noClipping += +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output( p_output, output_frame, nchan_out_syn_output, (int16_t *) data ); +#else + ivas_syn_output( p_output, output_frame, nchan_out, data ); +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + break; + case PCM_FLOAT32: + ivas_syn_output_f( p_output, output_frame, nchan_out_syn_output, (float *) data ); + break; + default: + error = IVAS_ERR_UNKNOWN; + break; + } +#endif + /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ @@ -2230,6 +2607,21 @@ ivas_error ivas_jbm_dec_tc( st_ivas->last_ivas_format = st_ivas->ivas_format; +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, output_frame ); +#endif + + /* in case first frame(s) was/were lost, deallocate output buffers */ + if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) + { + for ( n = 0; n < nchan_out; n++ ) + { + free( st_ivas->p_output_f[n] ); + st_ivas->p_output_f[n] = NULL; + } + } + #ifdef DEBUG_MODE_INFO dbgwrite( &st_ivas->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" ); dbgwrite( &st_ivas->BER_detect, sizeof( int16_t ), 1, output_frame, "res/BER_detect" ); @@ -2243,3 +2635,4 @@ ivas_error ivas_jbm_dec_tc( return IVAS_ERR_OK; } #endif +#endif diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index f5bb172ada..6cf91a5c35 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -737,15 +737,22 @@ ivas_error ivas_omasa_dirac_td_binaural( } #endif + +#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES /*--------------------------------------------------------------------------* - * ivas_omasa_dirac_td_binaural_render() + * ivas_omasa_dirac_td_binaural() * * Binaural rendering in OMASA format *--------------------------------------------------------------------------*/ -#ifdef UNIFIED_DECODING_PATHS_FUNCTION_NAMES ivas_error ivas_omasa_dirac_td_binaural( #else +/*--------------------------------------------------------------------------* + * ivas_omasa_dirac_td_binaural_render() + * + * Binaural rendering in OMASA format + *--------------------------------------------------------------------------*/ + ivas_error ivas_omasa_dirac_td_binaural_jbm( #endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ -- GitLab From 3b5c68804a93230d78f5b2dd46becdee395a0b0c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 24 Nov 2023 14:19:57 +0100 Subject: [PATCH 04/22] clang-format --- lib_dec/ivas_jbm_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 2a0b617d5d..726d82c7e5 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2747,7 +2747,7 @@ void ivas_dec_tc_buffer_close( /*--------------------------------------------------------------------------* * ivas_dec_td_renderers_adapt_subframes() * - * + * *--------------------------------------------------------------------------*/ void ivas_dec_td_renderers_adapt_subframes( -- GitLab From f502c30ddc4ba5a58939c9cfc09cecb641a3a615 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 14 Dec 2023 12:36:43 +0100 Subject: [PATCH 05/22] clang-format --- lib_dec/ivas_mct_dec.c | 10 +++++----- lib_dec/ivas_stat_dec.h | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index ace0ca49b4..4c6cc41ea3 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -791,11 +791,11 @@ static ivas_error ivas_mc_dec_reconfig( mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } - /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv - render what still fits in the new granularity */ - tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); - if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) - { + /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv + render what still fits in the new granularity */ + tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 08c5ed37ce..29ae09a7ba 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -912,16 +912,16 @@ 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 */ float *tc[MAX_OUTPUT_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 */ + 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 dd428be229aa16d33dc19c159121ffa542e95957 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 14 Dec 2023 16:28:33 +0100 Subject: [PATCH 06/22] fix merge --- lib_dec/ivas_dec.c | 8 ++++++++ lib_dec/ivas_jbm_dec.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index c38e4902bd..e589e97645 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -96,6 +96,14 @@ ivas_error ivas_dec( } } + 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]; + } + } + /*----------------------------------------------------------------* * Decoding + pre-rendering *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index e4b5c58694..5231624873 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -774,7 +774,6 @@ int16_t ivas_dec_get_num_tc_channels( } if ( st_ivas->ivas_format == SBA_FORMAT ) { - if ( num_tc == 3 ) { num_tc++; @@ -801,6 +800,7 @@ int16_t ivas_dec_get_num_tc_channels( { num_tc = CPE_CHANNELS; } + #ifdef NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA if ( num_tc == 3 ) #else -- GitLab From 97428651f1becdbd0fe85e776d644200cc4045a3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 12:13:21 +0100 Subject: [PATCH 07/22] clang-format --- lib_com/ivas_prot.h | 9 +++++++-- lib_dec/ivas_jbm_dec.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 0d9f76d8ff..13179f42f9 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -313,9 +313,9 @@ void stereo_dmx_evs_close_encoder( STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ ); -ivas_error ivas_dec_tc( +ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signals */ + int16_t *data /* o : output synthesis signals */ ); ivas_error ivas_dec_render( @@ -782,6 +782,11 @@ void ivas_apply_non_diegetic_panning( * decoder->rendering TC buffer prototypes *----------------------------------------------------------------------------------*/ +ivas_error ivas_dec_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : output synthesis signals */ +); + ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 74d732236e..1b2276bd26 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1801,7 +1801,7 @@ void ivas_dec_get_md_map( /*--------------------------------------------------------------------------* * ivas_dec_get_md_map_even_spacing() * - * Get an meta data map adapted to (time scale modified) IVAS frame. + * Get an meta data map adapted to (time scale modified) IVAS frame. * Distribute slots evenly across the (modified) frame. *--------------------------------------------------------------------------*/ -- GitLab From b536f4d8f6019068ff1b319fa889ec826fa48ede Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 15:37:08 +0100 Subject: [PATCH 08/22] ivas_dec_feed_tc_to_renderer() changes for ParamISM --- lib_com/ivas_prot.h | 4 +- lib_com/ivas_tools.c | 8 ++ lib_com/options.h | 2 +- lib_dec/ivas_jbm_dec.c | 236 +++++++++++++++++++++++++++++++++++++---- lib_dec/lib_dec.c | 6 +- 5 files changed, 235 insertions(+), 21 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 13179f42f9..537818c9e5 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -840,12 +840,14 @@ int16_t ivas_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -void ivas_dec_copy_tc_no_tsm( +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS +void ivas_jbm_dec_copy_tc_no_tsm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *tc[], /* i : transport channels */ const int16_t output_frame /* i : output frame size */ ); +#endif void ivas_dec_get_md_map_even_spacing( const int16_t len, /* i : length of the modefied frames in metadata slots */ const int16_t subframe_len, /* i : default length of a subframe */ diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index f91dc214c8..1a465736a0 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -148,12 +148,20 @@ uint32_t ivas_syn_output( } +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +/*-------------------------------------------------------------------* + * ivas_syn_output_f() + * + * Output IVAS synthesis signal into a linear buffer + *-------------------------------------------------------------------*/ +#else /*-------------------------------------------------------------------* * ivas_syn_output_f() * * Output ivas synthesis signal with compensation for saturation * returns number of clipped samples *-------------------------------------------------------------------*/ +#endif /*! r: number of clipped samples */ void ivas_syn_output_f( diff --git a/lib_com/options.h b/lib_com/options.h index 8137e2cf08..219f6c528d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,7 +163,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1209_SID_SIGNALING /* VA: issue 1209: remove dead code in IVAS SID signaling */ - +#define UNIFIED_DECODING_PATHS_LEFTOVERS /* VA: issue 880: remove leftovers ater NONBE_UNIFIED_DECODING_PATHS */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1b2276bd26..71cfbf7243 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -50,8 +50,10 @@ * Local function prototypes *-----------------------------------------------------------------------*/ -static void ivas_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS +static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); +#endif static void ivas_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); @@ -730,11 +732,13 @@ ivas_error ivas_dec_tc( { ivas_syn_output_f( p_output, output_frame, nchan_out, data ); } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS else { - /* directly copy to TC buffers */ - ivas_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); + /* directly copy to tc buffers */ + ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); } +#endif /*----------------------------------------------------------------* * Common updates @@ -772,6 +776,7 @@ ivas_error ivas_dec_tc( } +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS /*--------------------------------------------------------------------------* * ivas_dec_feed_tc_to_renderer() * @@ -787,9 +792,15 @@ void ivas_dec_feed_tc_to_renderer( { float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; - int16_t n, n_render_timeslots; + int16_t n, n_render_timeslots, n_ch_cldfb; + int16_t ch, output_frame; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + float *cldfb_real_buffer; + float *cldfb_imag_buffer; + int16_t cldfb_ch, slot_idx, num_freq_bands; + + hTcBuffer = st_ivas->hTcBuffer; - push_wmops( "ivas_dec_feed_tc_to_renderer" ); for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { p_data_f[n] = &data_f[n][0]; @@ -805,13 +816,196 @@ void ivas_dec_feed_tc_to_renderer( if ( st_ivas->hDecoderConfig->Opt_tsm ) { - ivas_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); + int16_t n_samples_still_available, m; + int16_t n_ch_full_copy; + int16_t n_ch_res_copy; + + n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; + hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; + hTcBuffer->n_samples_available = hTcBuffer->n_samples_granularity * ( hTcBuffer->n_samples_buffered / hTcBuffer->n_samples_granularity ); + *nSamplesResidual = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_available; + n_ch_full_copy = min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); + n_ch_res_copy = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; + n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; + + for ( ch = 0; ch < n_ch_full_copy; ch++ ) + { + set_zero( hTcBuffer->tc[ch], hTcBuffer->n_samples_discard ); + mvr2r( hTcBuffer->tc[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); + for ( m = 0; m < nSamplesForRendering; m++ ) + { + hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_rend + ch]; + } + } + + if ( n_ch_res_copy > 0 ) + { + for ( ; ch < hTcBuffer->nchan_transport_rend; ch++ ) + { + mvr2r( hTcBuffer->tc[ch], p_data_f[ch], n_samples_still_available ); + for ( m = 0; m < nSamplesForRendering; m++ ) + { + p_data_f[ch][n_samples_still_available + m] = data[m * hTcBuffer->nchan_transport_rend + ch]; + } + mvr2r( p_data_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); + } + } + + n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + + //ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); + + /* CLDFB analysis for ParamMC/ParamISM */ + if ( n_ch_cldfb > 0 ) + { + cldfb_real_buffer = NULL; + cldfb_imag_buffer = NULL; + num_freq_bands = 0; + + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc; + cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc; + num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; + //ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, st_ivas->p_output_f ); + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc; + cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc; + num_freq_bands = st_ivas->hParamMC->num_freq_bands; + } +#ifdef DEBUGGING + else + { + assert( 0 && "Residual (direct CLDFB transport channels) only possible for ParamMC/ParamISM!" ); + } +#endif + + output_frame = n_render_timeslots * num_freq_bands; + + //if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) ) + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, p_data_f ); + + for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ ) + { + /* CLDFB Analysis */ + for ( slot_idx = 0; slot_idx < n_render_timeslots; slot_idx++ ) + { + cldfbAnalysis_ts( &( p_data_f[ch][num_freq_bands * slot_idx] ), + &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); + } + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) + { + ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); + } + } + } } else { + output_frame = nSamplesForRendering; + + hTcBuffer->n_samples_buffered = output_frame; + hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; + n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; + + /* CLDFB ana for ParamMC/ParamISM */ + if ( n_ch_cldfb > 0 ) + { + cldfb_real_buffer = NULL; + cldfb_imag_buffer = NULL; + num_freq_bands = 0; + + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc; + cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc; + num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; + ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, st_ivas->p_output_f ); + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc; + cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc; + num_freq_bands = st_ivas->hParamMC->num_freq_bands; + } +#ifdef DEBUGGING + else + { + assert( 0 && "Residual (direct CLDFB transport channels) only possible for ParamMC/ParamISM!" ); + } +#endif + + /* CLDFB Analysis*/ + for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ ) + { + for ( slot_idx = 0; slot_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; slot_idx++ ) + { + cldfbAnalysis_ts( &( st_ivas->p_output_f[ch][num_freq_bands * slot_idx] ), + &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); + } + } + } + *nSamplesResidual = 0; } + hTcBuffer->n_samples_rendered = 0; + hTcBuffer->subframes_rendered = 0; + + return; +} +#else +/*--------------------------------------------------------------------------* + * ivas_dec_feed_tc_to_renderer() + * + * Feed decoded transport channels and metadata to the IVAS JBM renderer routine + *--------------------------------------------------------------------------*/ + +void ivas_dec_feed_tc_to_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i : transport channels */ +) +{ + float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ + float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; + int16_t n, n_render_timeslots; + + push_wmops( "ivas_jbm_dec_feed_tc_to_renderer" ); + for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) + { + p_data_f[n] = &data_f[n][0]; + } + + 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]; /* note: buffers needed in the TD decorellator */ + } + } + + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); + } + else + { + *nSamplesResidual = 0; + } n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; if ( st_ivas->ivas_format == ISM_FORMAT ) @@ -836,6 +1030,7 @@ void ivas_dec_feed_tc_to_renderer( pop_wmops(); return; } +#endif /*--------------------------------------------------------------------------* @@ -2010,15 +2205,16 @@ int16_t ivas_dec_get_num_tc_channels( return num_tc; } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS /*--------------------------------------------------------------------------* - * ivas_dec_copy_tc() + * ivas_jbm_dec_copy_tc() * * Copy interleaved transport chnannels to the correct buffers, update the TC * buffer handle *--------------------------------------------------------------------------*/ -static void ivas_dec_copy_tc( +static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ int16_t *nSamplesResidual, /* o : number of samples that will be left for the next frame */ @@ -2037,8 +2233,8 @@ static void ivas_dec_copy_tc( hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; hTcBuffer->n_samples_available = hTcBuffer->n_samples_granularity * ( hTcBuffer->n_samples_buffered / hTcBuffer->n_samples_granularity ); *nSamplesResidual = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_available; - n_ch_full_copy = min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); - n_ch_res_copy = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; + n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + n_ch_res_copy = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; for ( ch = 0; ch < n_ch_full_copy; ch++ ) { @@ -2046,18 +2242,18 @@ static void ivas_dec_copy_tc( mvr2r( hTcBuffer->tc[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); for ( m = 0; m < nSamplesForRendering; m++ ) { - hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_rend + ch]; + hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; } } if ( n_ch_res_copy > 0 ) { - for ( ; ch < hTcBuffer->nchan_transport_rend; ch++ ) + for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) { mvr2r( hTcBuffer->tc[ch], tc_digest_f[ch], n_samples_still_available ); for ( m = 0; m < nSamplesForRendering; m++ ) { - tc_digest_f[ch][n_samples_still_available + m] = data[m * hTcBuffer->nchan_transport_rend + ch]; + tc_digest_f[ch][n_samples_still_available + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; } mvr2r( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); } @@ -2069,6 +2265,7 @@ static void ivas_dec_copy_tc( return; } +#endif /*--------------------------------------------------------------------------* * ivas_dec_get_render_granularity() @@ -2574,14 +2771,15 @@ TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode( return buffer_mode; } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS /*--------------------------------------------------------------------------* - * ivas_dec_copy_tc_no_tsm() + * ivas_jbm_dec_copy_tc_no_tsm() + * * - * Copy to TC handle in non-JBM processing *--------------------------------------------------------------------------*/ -void ivas_dec_copy_tc_no_tsm( +void ivas_jbm_dec_copy_tc_no_tsm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *tc[], /* i : transport channels */ const int16_t output_frame /* i : output frame size */ @@ -2594,7 +2792,7 @@ void ivas_dec_copy_tc_no_tsm( hTcBuffer = st_ivas->hTcBuffer; hTcBuffer->n_samples_buffered = output_frame; hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; - n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; + n_ch_cldfb = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; #ifdef DEBUGGING assert( st_ivas->hDecoderConfig->Opt_tsm == 0 ); @@ -2642,13 +2840,13 @@ void ivas_dec_copy_tc_no_tsm( } } } - hTcBuffer->n_samples_rendered = 0; hTcBuffer->subframes_rendered = 0; return; } +#endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_metadata_open() @@ -2660,10 +2858,12 @@ ivas_error ivas_jbm_dec_metadata_open( Decoder_Struct *st_ivas ) { JBM_METADATA_HANDLE hJbmMetadata; + if ( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM metadata handle\n" ) ); } + hJbmMetadata->sf_write_idx = 0; hJbmMetadata->sf_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_PARAM_SPATIAL_SUBFRAMES; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9de51a7236..7680e8d3cb 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -4321,11 +4321,15 @@ static ivas_error evs_dec_main( v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS if ( !st_ivas->hDecoderConfig->Opt_tsm ) { - ivas_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); + ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); } +#else else if ( floatBuf != NULL ) +#endif + if ( floatBuf != NULL ) { /* BE workaround */ int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; -- GitLab From b3143cdb8f381b6725a2f9e92230209d4704e75d Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 17:07:12 +0100 Subject: [PATCH 09/22] ivas_dec_feed_tc_to_renderer() simplifications for ParamISM --- lib_dec/ivas_jbm_dec.c | 153 +++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 98 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 71cfbf7243..29c312aa2b 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -781,6 +781,7 @@ ivas_error ivas_dec_tc( * ivas_dec_feed_tc_to_renderer() * * Feed decoded transport channels and metadata to the IVAS renderer routine + * needed for ParamISM and ParamMC *--------------------------------------------------------------------------*/ void ivas_dec_feed_tc_to_renderer( @@ -800,18 +801,32 @@ void ivas_dec_feed_tc_to_renderer( int16_t cldfb_ch, slot_idx, num_freq_bands; hTcBuffer = st_ivas->hTcBuffer; + n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; - for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) - { - p_data_f[n] = &data_f[n][0]; - } + cldfb_real_buffer = NULL; + cldfb_imag_buffer = NULL; + num_freq_bands = 0; - if ( !st_ivas->hDecoderConfig->Opt_tsm ) + if ( n_ch_cldfb > 0 ) { - for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) + if ( st_ivas->ivas_format == ISM_FORMAT ) { - st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; /* note: buffers needed in the TD decorellator */ + cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc; + cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc; + num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc; + cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc; + num_freq_bands = st_ivas->hParamMC->num_freq_bands; } +#ifdef DEBUGGING + else + { + assert( 0 && "Residual (direct CLDFB transport channels) only possible for ParamMC/ParamISM!" ); + } +#endif } if ( st_ivas->hDecoderConfig->Opt_tsm ) @@ -820,13 +835,17 @@ void ivas_dec_feed_tc_to_renderer( int16_t n_ch_full_copy; int16_t n_ch_res_copy; + for ( n = 0; n < n_ch_cldfb; n++ ) + { + p_data_f[n] = &data_f[n][0]; + } + n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; hTcBuffer->n_samples_available = hTcBuffer->n_samples_granularity * ( hTcBuffer->n_samples_buffered / hTcBuffer->n_samples_granularity ); *nSamplesResidual = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_available; n_ch_full_copy = min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); n_ch_res_copy = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; - n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; for ( ch = 0; ch < n_ch_full_copy; ch++ ) { @@ -843,6 +862,7 @@ void ivas_dec_feed_tc_to_renderer( for ( ; ch < hTcBuffer->nchan_transport_rend; ch++ ) { mvr2r( hTcBuffer->tc[ch], p_data_f[ch], n_samples_still_available ); + for ( m = 0; m < nSamplesForRendering; m++ ) { p_data_f[ch][n_samples_still_available + m] = data[m * hTcBuffer->nchan_transport_rend + ch]; @@ -852,113 +872,50 @@ void ivas_dec_feed_tc_to_renderer( } n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; - - //ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); - - /* CLDFB analysis for ParamMC/ParamISM */ - if ( n_ch_cldfb > 0 ) - { - cldfb_real_buffer = NULL; - cldfb_imag_buffer = NULL; - num_freq_bands = 0; - - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc; - cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc; - num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; - //ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, st_ivas->p_output_f ); - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc; - cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc; - num_freq_bands = st_ivas->hParamMC->num_freq_bands; - } -#ifdef DEBUGGING - else - { - assert( 0 && "Residual (direct CLDFB transport channels) only possible for ParamMC/ParamISM!" ); - } -#endif - - output_frame = n_render_timeslots * num_freq_bands; - - //if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) ) - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, p_data_f ); - - for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ ) - { - /* CLDFB Analysis */ - for ( slot_idx = 0; slot_idx < n_render_timeslots; slot_idx++ ) - { - cldfbAnalysis_ts( &( p_data_f[ch][num_freq_bands * slot_idx] ), - &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], - &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], - num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); - } - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) - { - ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); - } - } - } + output_frame = n_render_timeslots * num_freq_bands; } else { - output_frame = nSamplesForRendering; + for ( n = 0; n < n_ch_cldfb; n++ ) + { + p_data_f[n] = &st_ivas->p_output_f[n][0]; + } - hTcBuffer->n_samples_buffered = output_frame; + hTcBuffer->n_samples_buffered = nSamplesForRendering; hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; - n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; + *nSamplesResidual = 0; - /* CLDFB ana for ParamMC/ParamISM */ - if ( n_ch_cldfb > 0 ) - { - cldfb_real_buffer = NULL; - cldfb_imag_buffer = NULL; - num_freq_bands = 0; + output_frame = nSamplesForRendering; + n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS; + } - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc; - cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc; - num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; - ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, st_ivas->p_output_f ); - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc; - cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc; - num_freq_bands = st_ivas->hParamMC->num_freq_bands; - } -#ifdef DEBUGGING - else - { - assert( 0 && "Residual (direct CLDFB transport channels) only possible for ParamMC/ParamISM!" ); - } -#endif + /* CLDFB analysis for ParamMC/ParamISM */ + if ( n_ch_cldfb > 0 ) + { + // if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) ) + if ( st_ivas->ivas_format == ISM_FORMAT ) + { + ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, p_data_f ); - /* CLDFB Analysis*/ for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ ) { - for ( slot_idx = 0; slot_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; slot_idx++ ) + /* CLDFB Analysis */ + for ( slot_idx = 0; slot_idx < n_render_timeslots; slot_idx++ ) { - cldfbAnalysis_ts( &( st_ivas->p_output_f[ch][num_freq_bands * slot_idx] ), + cldfbAnalysis_ts( &( p_data_f[ch][num_freq_bands * slot_idx] ), &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); } } } - - *nSamplesResidual = 0; + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) + { + ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); + } + } } hTcBuffer->n_samples_rendered = 0; -- GitLab From 6f1eff3b85c94e279f6e40c116328020ad045cdb Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 21:00:59 +0100 Subject: [PATCH 10/22] ivas_dec_feed_tc_to_renderer() changes for ParamMC --- lib_com/ivas_prot.h | 2 + lib_dec/ivas_ism_param_dec.c | 119 ++++++++++++++++++++++--------- lib_dec/ivas_jbm_dec.c | 64 ++--------------- lib_dec/ivas_mc_param_dec.c | 34 +++++++++ lib_dec/ivas_mc_paramupmix_dec.c | 16 ++++- 5 files changed, 140 insertions(+), 95 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 537818c9e5..180c3e9d97 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1102,6 +1102,7 @@ void ivas_param_ism_dec_prepare_renderer( const uint16_t nCldfbSlots /* i : number of CLDFB slots in transport channels */ ); +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS void ivas_ism_param_dec_tc_gain_ajust( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamples, /* i : number of samples to be compensate */ @@ -1109,6 +1110,7 @@ void ivas_ism_param_dec_tc_gain_ajust( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); +#endif void ivas_param_ism_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 25f7bda919..9a8182b09c 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -45,12 +45,21 @@ #include "wmc_auto.h" +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +/*-----------------------------------------------------------------------* + * Local function declarations + *-----------------------------------------------------------------------*/ + +static void ivas_ism_param_dec_tc_gain_adjust( Decoder_Struct *st_ivas, const int16_t nSamples, const int16_t nFadeLength, float *transport_channels_f[] ); + +#endif + /*-----------------------------------------------------------------------* * Local function definitions *-----------------------------------------------------------------------*/ static void ivas_param_ism_dec_dequant_DOA( - PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ + PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ const int16_t nchan_ism /* i : number of ISM channels */ ) { @@ -800,50 +809,82 @@ void ivas_param_ism_dec_digest_tc( float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { - int16_t ch, nchan_transport; - int16_t slot_idx; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + int16_t ch, nchan_transport, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; int16_t output_frame; - PARAM_ISM_DEC_HANDLE hParamIsmDec; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - int16_t fade_len; + float *cldfb_real_buffer; + float *cldfb_imag_buffer; /* Initialization */ - hParamIsmDec = st_ivas->hParamIsmDec; - assert( hParamIsmDec ); - hSpatParamRendCom = st_ivas->hSpatParamRendCom; - assert( hSpatParamRendCom ); - output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands; - fade_len = output_frame / 2; - + num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; + output_frame = nCldfbSlots * num_freq_bands; nchan_transport = st_ivas->nchan_transport; + n_ch_cldfb = st_ivas->hTcBuffer->nchan_transport_rend - st_ivas->hTcBuffer->nchan_buffer_full; - push_wmops( "ivas_param_ism_dec_digest_tc" ); + cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc; + cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc; - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - /*TODO : FhG to check*/ - ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, fade_len, transport_channels_f ); - } + /* Adjust TCs energy */ + ivas_ism_param_dec_tc_gain_adjust( st_ivas, output_frame, output_frame / 2, transport_channels_f ); - for ( ch = 0; ch < nchan_transport; ch++ ) + /* CLDFB Analysis */ + for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ ) { - /* CLDFB Analysis */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - if ( st_ivas->hDecoderConfig->Opt_tsm ) + cldfbAnalysis_ts( &( transport_channels_f[ch][num_freq_bands * slot_idx] ), + &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); + } + } +#else + { + int16_t ch, nchan_transport; + int16_t slot_idx; + int16_t output_frame; + PARAM_ISM_DEC_HANDLE hParamIsmDec; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + int16_t fade_len; + + /* Initialization */ + hParamIsmDec = st_ivas->hParamIsmDec; + assert( hParamIsmDec ); + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + assert( hSpatParamRendCom ); + output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands; + fade_len = output_frame / 2; + + nchan_transport = st_ivas->nchan_transport; + + push_wmops( "ivas_param_ism_dec_digest_tc" ); + + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + /*TODO : FhG to check*/ + ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, fade_len, transport_channels_f ); + } + + for ( ch = 0; ch < nchan_transport; ch++ ) + { + /* CLDFB Analysis */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; - float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + float RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - cldfbAnalysis_ts( &( transport_channels_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); - mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); - mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); + cldfbAnalysis_ts( &( transport_channels_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); + mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); + } } } - } - pop_wmops(); + pop_wmops(); +#endif return; } @@ -1004,18 +1045,26 @@ void ivas_param_ism_dec_prepare_renderer( /*-------------------------------------------------------------------------* - * ivas_ism_param_dec_tc_gain_ajust() - * + * ivas_ism_param_dec_tc_gain_adjust() * + * Adjust TCs energy *-------------------------------------------------------------------------*/ -void ivas_ism_param_dec_tc_gain_ajust( +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +static void ivas_ism_param_dec_tc_gain_adjust( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamples, /* i : number of samples to be compensate */ - const uint16_t nFadeLength, /* i : length of the crossfade in samples */ + const int16_t nSamples, /* i : number of samples to be compensate */ + const int16_t nFadeLength, /* i : length of the crossfade in samples */ float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ) - +#else + void ivas_ism_param_dec_tc_gain_ajust( + Decoder_Struct * st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamples, /* i : number of samples to be compensate */ + const uint16_t nFadeLength, /* i : length of the crossfade in samples */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ + ) +#endif { int16_t i; float gain, ene_tc, ene_sum, grad; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 29c312aa2b..4c9dcd4703 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -794,41 +794,12 @@ void ivas_dec_feed_tc_to_renderer( float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; int16_t n, n_render_timeslots, n_ch_cldfb; - int16_t ch, output_frame; + int16_t ch; DECODER_TC_BUFFER_HANDLE hTcBuffer; - float *cldfb_real_buffer; - float *cldfb_imag_buffer; - int16_t cldfb_ch, slot_idx, num_freq_bands; hTcBuffer = st_ivas->hTcBuffer; n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; - cldfb_real_buffer = NULL; - cldfb_imag_buffer = NULL; - num_freq_bands = 0; - - if ( n_ch_cldfb > 0 ) - { - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc; - cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc; - num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc; - cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc; - num_freq_bands = st_ivas->hParamMC->num_freq_bands; - } -#ifdef DEBUGGING - else - { - assert( 0 && "Residual (direct CLDFB transport channels) only possible for ParamMC/ParamISM!" ); - } -#endif - } - if ( st_ivas->hDecoderConfig->Opt_tsm ) { int16_t n_samples_still_available, m; @@ -872,7 +843,6 @@ void ivas_dec_feed_tc_to_renderer( } n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; - output_frame = n_render_timeslots * num_freq_bands; } else { @@ -885,37 +855,17 @@ void ivas_dec_feed_tc_to_renderer( hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; *nSamplesResidual = 0; - output_frame = nSamplesForRendering; n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS; } /* CLDFB analysis for ParamMC/ParamISM */ - if ( n_ch_cldfb > 0 ) + if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) ) { - // if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) ) - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, p_data_f ); - - for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ ) - { - /* CLDFB Analysis */ - for ( slot_idx = 0; slot_idx < n_render_timeslots; slot_idx++ ) - { - cldfbAnalysis_ts( &( p_data_f[ch][num_freq_bands * slot_idx] ), - &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], - &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], - num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); - } - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) - { - ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); - } - } + ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); + } + else if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) + { + ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); } hTcBuffer->n_samples_rendered = 0; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index f4f992de20..f27cdecf77 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1320,6 +1320,39 @@ void ivas_param_mc_dec_read_BS( * *------------------------------------------------------------------------*/ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +void ivas_param_mc_dec_digest_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ +) +{ + int16_t ch, nchan_transport, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; + float *cldfb_real_buffer; + float *cldfb_imag_buffer; + + num_freq_bands = st_ivas->hParamMC->num_freq_bands; + nchan_transport = st_ivas->nchan_transport; + n_ch_cldfb = st_ivas->hTcBuffer->nchan_transport_rend - st_ivas->hTcBuffer->nchan_buffer_full; + + cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc; + cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc; + + /* CLDFB Analysis */ + for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ ) + { + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + cldfbAnalysis_ts( &( transport_channels_f[ch][num_freq_bands * slot_idx] ), + &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); + } + } + + return; +} +#else void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ @@ -1360,6 +1393,7 @@ void ivas_param_mc_dec_digest_tc( return; } +#endif /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index fad0c51a5a..960d70ed30 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -450,12 +450,12 @@ void ivas_mc_paramupmix_dec_close( /*------------------------------------------------------------------------- - * paramupmix_td_decorr_process_jbm() + * paramupmix_td_decorr_process() * * *------------------------------------------------------------------------*/ -static void paramupmix_td_decorr_process_jbm( +static void paramupmix_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr[], /* i/o: SPAR Covar. decoder handle */ float *pcm_in[], /* i : input audio channels */ float **pp_out_pcm, /* o : output audio channels */ @@ -528,6 +528,16 @@ static void ivas_param_upmix_dec_decorr_subframes( nSamplesLeftForTD = nSamplesForRendering; nchan_internal = MC_PARAMUPMIX_COMBINATIONS; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas, -1, st_ivas->hDecoderConfig->ivas_total_brate ); ch++ ) + { + st_ivas->hTcBuffer->tc[ch] = st_ivas->p_output_f[ch]; + } + } + +#endif for ( ch = 0; ch < nchan_internal; ch++ ) { pPcm_tmp[ch] = st_ivas->hTcBuffer->tc[ch + 8]; @@ -538,7 +548,7 @@ static void ivas_param_upmix_dec_decorr_subframes( { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); - paramupmix_td_decorr_process_jbm( hMCParamUpmix->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); + paramupmix_td_decorr_process( hMCParamUpmix->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); for ( ch = 0; ch < nchan_internal; ch++ ) { -- GitLab From 8bbabc97bcf37ba8e1277264a763aeed9bbc5c47 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 21:05:35 +0100 Subject: [PATCH 11/22] fix build 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 7680e8d3cb..f7e28878de 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -4326,10 +4326,10 @@ static ivas_error evs_dec_main( { ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); } -#else else if ( floatBuf != NULL ) -#endif +#else if ( floatBuf != NULL ) +#endif { /* BE workaround */ int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; -- GitLab From 6bcd8ef0ca377139aacb24e0858707e370a54a17 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 21:18:01 +0100 Subject: [PATCH 12/22] fix build warning --- lib_dec/ivas_ism_param_dec.c | 3 +-- lib_dec/ivas_mc_param_dec.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 9a8182b09c..388f86545c 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -810,7 +810,7 @@ void ivas_param_ism_dec_digest_tc( ) { #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS - int16_t ch, nchan_transport, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; + int16_t ch, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; int16_t output_frame; float *cldfb_real_buffer; float *cldfb_imag_buffer; @@ -818,7 +818,6 @@ void ivas_param_ism_dec_digest_tc( /* Initialization */ num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; output_frame = nCldfbSlots * num_freq_bands; - nchan_transport = st_ivas->nchan_transport; n_ch_cldfb = st_ivas->hTcBuffer->nchan_transport_rend - st_ivas->hTcBuffer->nchan_buffer_full; cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index f27cdecf77..330a1474ed 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1327,12 +1327,11 @@ void ivas_param_mc_dec_digest_tc( float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { - int16_t ch, nchan_transport, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; + int16_t ch, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; float *cldfb_real_buffer; float *cldfb_imag_buffer; num_freq_bands = st_ivas->hParamMC->num_freq_bands; - nchan_transport = st_ivas->nchan_transport; n_ch_cldfb = st_ivas->hTcBuffer->nchan_transport_rend - st_ivas->hTcBuffer->nchan_buffer_full; cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc; -- GitLab From 6b7b131dfa0e2ab8bf08d10a30da8dab16c8d99c Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 22:02:51 +0100 Subject: [PATCH 13/22] fixes --- lib_dec/ivas_jbm_dec.c | 5 ++++ lib_dec/ivas_mc_paramupmix_dec.c | 10 ------- lib_dec/lib_dec.c | 48 +++++++++++++++++++++++++++----- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 4c9dcd4703..87c00cc4f5 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -851,6 +851,11 @@ void ivas_dec_feed_tc_to_renderer( p_data_f[n] = &st_ivas->p_output_f[n][0]; } + 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]; /* note: buffers needed in the TD decorellator */ + } + hTcBuffer->n_samples_buffered = nSamplesForRendering; hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; *nSamplesResidual = 0; diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 960d70ed30..cb0437a1ea 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -528,16 +528,6 @@ static void ivas_param_upmix_dec_decorr_subframes( nSamplesLeftForTD = nSamplesForRendering; nchan_internal = MC_PARAMUPMIX_COMBINATIONS; -#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS - if ( !st_ivas->hDecoderConfig->Opt_tsm ) - { - for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas, -1, st_ivas->hDecoderConfig->ivas_total_brate ); ch++ ) - { - st_ivas->hTcBuffer->tc[ch] = st_ivas->p_output_f[ch]; - } - } - -#endif for ( ch = 0; ch < nchan_internal; ch++ ) { pPcm_tmp[ch] = st_ivas->hTcBuffer->tc[ch + 8]; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index f7e28878de..26fcdf83fb 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -112,7 +112,11 @@ static void IVAS_DEC_Close_VoIP( IVAS_DEC_VOIP *hVoIP ); #ifdef SUPPORT_JBM_TRACEFILE static void store_JbmData( IVAS_DEC_VOIP *hVoIP, JB4_DATAUNIT_HANDLE dataUnit, const uint32_t systemTimestamp_ms, const uint16_t extBufferedSamples, const int32_t output_Fs ); #endif +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf ); +#else static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf, int16_t *pcmBuf ); +#endif static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, int16_t *bitstream_format_internal, int16_t *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); @@ -1999,7 +2003,11 @@ static ivas_error IVAS_DEC_GetTcSamples( if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf, NULL ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -4247,10 +4255,15 @@ void IVAS_DEC_PrintDisclaimer( void ) *---------------------------------------------------------------------*/ static ivas_error evs_dec_main( - Decoder_Struct *st_ivas, - const int16_t nOutSamples, + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nOutSamples, /* i : number of samples per channel */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + float *floatBuf /* o : buffer for decoded PCM output */ +#else float *floatBuf, - int16_t *pcmBuf ) + int16_t *pcmBuf +#endif +) { DEC_CORE_HANDLE *hCoreCoder; float mixer_left, mixer_rigth; @@ -4321,15 +4334,35 @@ static ivas_error evs_dec_main( v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); } -#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS + +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + } + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + /* BE workaround */ + int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; + + if ( floatBuf != NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "APA buffer is missing in JBM processing\n" ) ); + } + + /* convert 'float' output data to 'short' */ +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local ); + + mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out ); + } +#else if ( !st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); } else if ( floatBuf != NULL ) -#else - if ( floatBuf != NULL ) -#endif { /* BE workaround */ int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; @@ -4349,6 +4382,7 @@ static ivas_error evs_dec_main( #endif ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } +#endif return IVAS_ERR_OK; } -- GitLab From bf499a5b9053e583dda5b7c02db0e3f590f1488f Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 22:25:52 +0100 Subject: [PATCH 14/22] fixes --- lib_dec/ivas_ism_param_dec.c | 79 ++++++++++++++++++------------------ lib_dec/ivas_jbm_dec.c | 12 +++--- lib_dec/lib_dec.c | 5 +-- 3 files changed, 46 insertions(+), 50 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 388f86545c..3632da5ca3 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -838,51 +838,50 @@ void ivas_param_ism_dec_digest_tc( } } #else - { - int16_t ch, nchan_transport; - int16_t slot_idx; - int16_t output_frame; - PARAM_ISM_DEC_HANDLE hParamIsmDec; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - int16_t fade_len; - /* Initialization */ - hParamIsmDec = st_ivas->hParamIsmDec; - assert( hParamIsmDec ); - hSpatParamRendCom = st_ivas->hSpatParamRendCom; - assert( hSpatParamRendCom ); - output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands; - fade_len = output_frame / 2; + int16_t ch, nchan_transport; + int16_t slot_idx; + int16_t output_frame; + PARAM_ISM_DEC_HANDLE hParamIsmDec; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + int16_t fade_len; - nchan_transport = st_ivas->nchan_transport; + /* Initialization */ + hParamIsmDec = st_ivas->hParamIsmDec; + assert( hParamIsmDec ); + hSpatParamRendCom = st_ivas->hSpatParamRendCom; + assert( hSpatParamRendCom ); + output_frame = nCldfbSlots * hSpatParamRendCom->num_freq_bands; + fade_len = output_frame / 2; - push_wmops( "ivas_param_ism_dec_digest_tc" ); + nchan_transport = st_ivas->nchan_transport; - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - /*TODO : FhG to check*/ - ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, fade_len, transport_channels_f ); - } + push_wmops( "ivas_param_ism_dec_digest_tc" ); - for ( ch = 0; ch < nchan_transport; ch++ ) + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + /*TODO : FhG to check*/ + ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, fade_len, transport_channels_f ); + } + + for ( ch = 0; ch < nchan_transport; ch++ ) + { + /* CLDFB Analysis */ + for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - /* CLDFB Analysis */ - for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + if ( st_ivas->hDecoderConfig->Opt_tsm ) { - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; - float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + float RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; - cldfbAnalysis_ts( &( transport_channels_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); - mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); - mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); - } + cldfbAnalysis_ts( &( transport_channels_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer, ImagBuffer, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); + mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } } + } - - pop_wmops(); + pop_wmops(); #endif return; @@ -1057,12 +1056,12 @@ static void ivas_ism_param_dec_tc_gain_adjust( float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ) #else - void ivas_ism_param_dec_tc_gain_ajust( - Decoder_Struct * st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamples, /* i : number of samples to be compensate */ - const uint16_t nFadeLength, /* i : length of the crossfade in samples */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ - ) +void ivas_ism_param_dec_tc_gain_ajust( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamples, /* i : number of samples to be compensate */ + const uint16_t nFadeLength, /* i : length of the crossfade in samples */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ +) #endif { int16_t i; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 87c00cc4f5..80d36a2ea4 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2145,8 +2145,8 @@ static void ivas_jbm_dec_copy_tc( hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; hTcBuffer->n_samples_available = hTcBuffer->n_samples_granularity * ( hTcBuffer->n_samples_buffered / hTcBuffer->n_samples_granularity ); *nSamplesResidual = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_available; - n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); - n_ch_res_copy = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; + n_ch_full_copy = min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); + n_ch_res_copy = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; for ( ch = 0; ch < n_ch_full_copy; ch++ ) { @@ -2154,18 +2154,18 @@ static void ivas_jbm_dec_copy_tc( mvr2r( hTcBuffer->tc[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); for ( m = 0; m < nSamplesForRendering; m++ ) { - hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; + hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_rend + ch]; } } if ( n_ch_res_copy > 0 ) { - for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) + for ( ; ch < hTcBuffer->nchan_transport_rend; ch++ ) { mvr2r( hTcBuffer->tc[ch], tc_digest_f[ch], n_samples_still_available ); for ( m = 0; m < nSamplesForRendering; m++ ) { - tc_digest_f[ch][n_samples_still_available + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; + tc_digest_f[ch][n_samples_still_available + m] = data[m * st_ivas->hTcBuffer->nchan_transport_rend + ch]; } mvr2r( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); } @@ -2704,7 +2704,7 @@ void ivas_jbm_dec_copy_tc_no_tsm( hTcBuffer = st_ivas->hTcBuffer; hTcBuffer->n_samples_buffered = output_frame; hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; - n_ch_cldfb = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; + n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full; #ifdef DEBUGGING assert( st_ivas->hDecoderConfig->Opt_tsm == 0 ); diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 26fcdf83fb..5387eefd00 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -4336,15 +4336,12 @@ static ivas_error evs_dec_main( #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS - if ( !st_ivas->hDecoderConfig->Opt_tsm ) - { - } if ( st_ivas->hDecoderConfig->Opt_tsm ) { /* BE workaround */ int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; - if ( floatBuf != NULL ) + if ( floatBuf == NULL ) { return ( IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "APA buffer is missing in JBM processing\n" ) ); } -- GitLab From e1956b01ba4d2eff8502123508a4561ffd030845 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Nov 2024 23:32:12 +0100 Subject: [PATCH 15/22] Consolidate writing of TCs --- lib_com/ivas_prot.h | 4 +++ lib_com/ivas_tools.c | 2 +- lib_dec/ivas_jbm_dec.c | 8 ++++-- lib_dec/lib_dec.c | 61 +++++++++++++++++++++++++++++++----------- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 180c3e9d97..2c0ac6113a 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -783,8 +783,12 @@ void ivas_apply_non_diegetic_panning( *----------------------------------------------------------------------------------*/ ivas_error ivas_dec_tc( +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : output synthesis signals */ +#endif ); ivas_error ivas_jbm_dec_flush_renderer( diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 1a465736a0..c8eaa8c6ff 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -152,7 +152,7 @@ uint32_t ivas_syn_output( /*-------------------------------------------------------------------* * ivas_syn_output_f() * - * Output IVAS synthesis signal into a linear buffer + * Copy IVAS synthesis signals into a linear buffer *-------------------------------------------------------------------*/ #else /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 80d36a2ea4..6a125264cd 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -68,8 +68,12 @@ static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t *--------------------------------------------------------------------------*/ ivas_error ivas_dec_tc( +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : transport channel signals */ +#endif ) { int16_t n, output_frame, nchan_out; @@ -724,6 +728,7 @@ ivas_error ivas_dec_tc( } } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS /*----------------------------------------------------------------* * Write IVAS transport channels *----------------------------------------------------------------*/ @@ -732,14 +737,13 @@ ivas_error ivas_dec_tc( { ivas_syn_output_f( p_output, output_frame, nchan_out, data ); } -#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS else { /* directly copy to tc buffers */ ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); } -#endif +#endif /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5387eefd00..75309da807 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -113,7 +113,7 @@ static void IVAS_DEC_Close_VoIP( IVAS_DEC_VOIP *hVoIP ); static void store_JbmData( IVAS_DEC_VOIP *hVoIP, JB4_DATAUNIT_HANDLE dataUnit, const uint32_t systemTimestamp_ms, const uint16_t extBufferedSamples, const int32_t output_Fs ); #endif #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS -static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf ); +static ivas_error evs_dec_main( Decoder_Struct *st_ivas ); #else static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf, int16_t *pcmBuf ); #endif @@ -121,7 +121,11 @@ static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_form static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels ); +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec ); +#else static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); +#endif static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); @@ -1061,7 +1065,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( { uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + int16_t nResidualSamples, nSamplesTcsScaled; +#else int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; +#endif if ( isSplitRend ) { @@ -1085,7 +1093,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } /* IVAS TC decoder */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1098,6 +1110,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_UNKNOWN; } +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + ivas_syn_output_f( hIvasDec->st_ivas->p_output_f, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer ); + +#endif if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -1984,9 +2000,13 @@ static ivas_error IVAS_DEC_Setup( *---------------------------------------------------------------------*/ static ivas_error IVAS_DEC_GetTcSamples( +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +#else IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ float *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ +#endif ) { Decoder_Struct *st_ivas; @@ -1998,13 +2018,14 @@ static ivas_error IVAS_DEC_GetTcSamples( } st_ivas = hIvasDec->st_ivas; - +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS - if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf ) ) != IVAS_ERR_OK ) + if ( ( error = evs_dec_main( st_ivas ) ) != IVAS_ERR_OK ) #else if ( ( error = evs_dec_main( st_ivas, *nOutSamples, pcmBuf, NULL ) ) != IVAS_ERR_OK ) #endif @@ -2015,7 +2036,11 @@ static ivas_error IVAS_DEC_GetTcSamples( else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) { /* run the main IVAS decoding routine */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + if ( ( error = ivas_dec_tc( st_ivas ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -4255,11 +4280,11 @@ void IVAS_DEC_PrintDisclaimer( void ) *---------------------------------------------------------------------*/ static ivas_error evs_dec_main( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nOutSamples, /* i : number of samples per channel */ #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS - float *floatBuf /* o : buffer for decoded PCM output */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ #else + Decoder_Struct *st_ivas, + const int16_t nOutSamples, float *floatBuf, int16_t *pcmBuf #endif @@ -4268,11 +4293,18 @@ static ivas_error evs_dec_main( DEC_CORE_HANDLE *hCoreCoder; float mixer_left, mixer_rigth; float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + int16_t ch, nOutSamples; +#else int16_t ch; +#endif ivas_error error; hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif mdct_switching_dec( hCoreCoder[0] ); @@ -4338,21 +4370,18 @@ static ivas_error evs_dec_main( #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS if ( st_ivas->hDecoderConfig->Opt_tsm ) { - /* BE workaround */ - int16_t pcm_buf_local[L_FRAME48k * MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; + /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ + int16_t pcm_buf_local[L_FRAME48k]; - if ( floatBuf == NULL ) + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { - return ( IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "APA buffer is missing in JBM processing\n" ) ); - } - - /* convert 'float' output data to 'short' */ #ifdef DEBUGGING - st_ivas->noClipping += + st_ivas->noClipping += #endif - ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local ); + ivas_syn_output( &p_output[ch], nOutSamples, 1, pcm_buf_local ); - mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out ); + mvs2r( pcm_buf_local, p_output[ch], nOutSamples ); + } } #else if ( !st_ivas->hDecoderConfig->Opt_tsm ) -- GitLab From 3209f3468deb151bec07d165858f1633136c6151 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Nov 2024 09:17:15 +0100 Subject: [PATCH 16/22] polishing --- lib_com/ivas_cnst.h | 4 +++ lib_com/ivas_prot.h | 25 +++++++--------- lib_dec/ivas_dec.c | 4 +-- lib_dec/ivas_ism_dec.c | 8 +++--- lib_dec/ivas_ism_param_dec.c | 40 ++++++++++++++------------ lib_dec/ivas_ism_renderer.c | 8 +++--- lib_dec/ivas_jbm_dec.c | 23 ++++++++------- lib_dec/ivas_masa_dec.c | 3 +- lib_dec/ivas_mc_param_dec.c | 8 +++--- lib_dec/ivas_mct_dec.c | 8 +++--- lib_dec/ivas_objectRenderer_internal.c | 14 ++++----- lib_dec/ivas_sba_dec.c | 2 +- lib_dec/lib_dec.c | 16 +++++------ 13 files changed, 83 insertions(+), 80 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4a56f13237..c38cb97ad6 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -175,7 +175,11 @@ typedef enum #define MAX_JBM_L_FRAME48k 1920 #define MAX_JBM_L_FRAME_NS 40000000L #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +#define MAX_CLDFB_DIGEST_CHANNELS 3 /* == maximum of ParamISM TCs and ParamISM TCs */ +#else #define MAX_CLDFB_DIGEST_CHANNELS (FOA_CHANNELS + MAX_NUM_OBJECTS) +#endif typedef enum { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2c0ac6113a..45477c9d9e 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -314,8 +314,12 @@ void stereo_dmx_evs_close_encoder( ); ivas_error ivas_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t *data /* o : output synthesis signals */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#else + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : output synthesis signals */ +#endif ); ivas_error ivas_dec_render( @@ -782,16 +786,7 @@ void ivas_apply_non_diegetic_panning( * decoder->rendering TC buffer prototypes *----------------------------------------------------------------------------------*/ -ivas_error ivas_dec_tc( -#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#else - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signals */ -#endif -); - -ivas_error ivas_jbm_dec_flush_renderer( +ivas_error ivas_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ @@ -815,7 +810,7 @@ void ivas_dec_prepare_renderer( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -ivas_error ivas_jbm_dec_set_discard_samples( +ivas_error ivas_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); @@ -1094,7 +1089,7 @@ void ivas_ism_dec_digest_tc( void ivas_param_ism_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + float *p_data_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_ism_dec_dequant_md( @@ -3855,7 +3850,7 @@ void ivas_param_mc_dec_read_BS( void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ - float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output*/ + float *p_data_f[] /* i/o: synthesized core-coder transport channels/DirAC output*/ ); void ivas_param_mc_dec_prepare_renderer( diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 0ad73fa938..aada372a06 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -51,12 +51,12 @@ * Principal IVAS decoder routine *--------------------------------------------------------------------------*/ -ivas_error ivas_dec( +ivas_error ivas_dec_tmp( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t *data /* o : output synthesis signal */ ) { - // TODO: move here function ivas_dec_tc() and rename it to ivas_dec() + // TODO: move here function ivas_dec() st_ivas->ivas_format = UNDEFINED_FORMAT; // temp. to avoid compilation warnings data[0] = 0; // temp. to avoid compilation warnings diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 925b03fe4a..8cfd6d31df 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -122,18 +122,18 @@ static ivas_error ivas_ism_bitrate_switching_dec( mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } - /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv - render what still fits in the new granularity */ + /* when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv + render what still fits in the new granularity */ tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { /* flush already done in IVAS_DEC_ReadFormat() */ } - /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + /* when granularity goes up set samples to discard at the beginning of the frame */ else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 3632da5ca3..5fab638539 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -50,7 +50,7 @@ * Local function declarations *-----------------------------------------------------------------------*/ -static void ivas_ism_param_dec_tc_gain_adjust( Decoder_Struct *st_ivas, const int16_t nSamples, const int16_t nFadeLength, float *transport_channels_f[] ); +static void ivas_ism_param_dec_tc_gain_adjust( Decoder_Struct *st_ivas, const int16_t nSamples, const int16_t nFadeLength, float *p_data_f[] ); #endif @@ -571,19 +571,16 @@ ivas_error ivas_param_ism_dec_open( { n_slots_to_alloc = CLDFB_SLOTS_PER_SUBFRAME * MAX_PARAM_SPATIAL_SUBFRAMES; } - if ( ( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) + if ( ( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ParamISM Rendering handle\n" ) ); } set_zero( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands ); if ( ( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands * sizeof( float ) ) ) == NULL ) { - if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) - { - return error; - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ParamISM Rendering handle\n" ) ); } set_zero( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands ); } @@ -592,11 +589,7 @@ ivas_error ivas_param_ism_dec_open( { if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { - int16_t nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; - if ( ( error = ivas_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } } } @@ -803,13 +796,13 @@ void ivas_ism_dec_digest_tc( * *-------------------------------------------------------------------------*/ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ - float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + float *p_data_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { -#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS int16_t ch, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; int16_t output_frame; float *cldfb_real_buffer; @@ -824,20 +817,29 @@ void ivas_param_ism_dec_digest_tc( cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc; /* Adjust TCs energy */ - ivas_ism_param_dec_tc_gain_adjust( st_ivas, output_frame, output_frame / 2, transport_channels_f ); + ivas_ism_param_dec_tc_gain_adjust( st_ivas, output_frame, output_frame / 2, p_data_f ); /* CLDFB Analysis */ for ( ch = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch++ ) { for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - cldfbAnalysis_ts( &( transport_channels_f[ch][num_freq_bands * slot_idx] ), + cldfbAnalysis_ts( &( p_data_f[ch][num_freq_bands * slot_idx] ), &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); } } + + return; +} #else +void ivas_param_ism_dec_digest_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ +) +{ int16_t ch, nchan_transport; int16_t slot_idx; @@ -882,10 +884,10 @@ void ivas_param_ism_dec_digest_tc( } pop_wmops(); -#endif return; } +#endif /*-------------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index dcd7b63062..93d4257170 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -158,7 +158,7 @@ void ivas_ism_render_sf( float gain, prev_gain; float tc_local[MAX_NUM_OBJECTS][L_FRAME48k]; float *p_tc[MAX_NUM_OBJECTS]; - int16_t ism_md_subframe_update_jbm, slots_to_render, first_sf, last_sf, subframe_idx; + int16_t ism_md_subframe_update, slots_to_render, first_sf, last_sf, subframe_idx; int16_t n_samples_rendered_loop; /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ @@ -186,11 +186,11 @@ void ivas_ism_render_sf( /* Number of subframes to delay metadata to sync with audio */ if ( st_ivas->hDecoderConfig->Opt_delay_comp ) { - ism_md_subframe_update_jbm = max( 0, st_ivas->hTcBuffer->nb_subframes - 3 ); + ism_md_subframe_update = max( 0, st_ivas->hTcBuffer->nb_subframes - 3 ); } else { - ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2; + ism_md_subframe_update = st_ivas->hTcBuffer->nb_subframes - 2; } if ( st_ivas->hDecoderConfig->Opt_tsm ) @@ -231,7 +231,7 @@ void ivas_ism_render_sf( /* Combined rotation: rotate the object positions depending the head and external orientations */ if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 ) { - if ( subframe_idx >= ism_md_subframe_update_jbm ) + if ( subframe_idx >= ism_md_subframe_update ) { rotateAziEle( st_ivas->hIsmMetaData[i]->edited_azimuth, st_ivas->hIsmMetaData[i]->edited_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6a125264cd..428634b409 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -62,12 +62,12 @@ static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t /*--------------------------------------------------------------------------* - * ivas_dec_tc() + * ivas_dec() * * Principal IVAS decoder routine, decoding of metadata and transport channels *--------------------------------------------------------------------------*/ -ivas_error ivas_dec_tc( +ivas_error ivas_dec( #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ #else @@ -87,7 +87,7 @@ ivas_error ivas_dec_tc( int16_t num_md_sub_frames; int32_t ism_total_brate; - push_wmops( "ivas_dec_tc" ); + push_wmops( "ivas_dec" ); /*----------------------------------------------------------------* * Initialization of local vars after struct has been set @@ -784,8 +784,8 @@ ivas_error ivas_dec_tc( /*--------------------------------------------------------------------------* * ivas_dec_feed_tc_to_renderer() * - * Feed decoded transport channels and metadata to the IVAS renderer routine - * needed for ParamISM and ParamMC + * Feed decoded transport channels to the IVAS renderer routine + * + digest TC channels in ParamISM and ParamMC *--------------------------------------------------------------------------*/ void ivas_dec_feed_tc_to_renderer( @@ -1478,12 +1478,12 @@ ivas_error ivas_dec_render( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_flush_renderer() + * ivas_dec_flush_renderer() * - * Flush samples if renderer granularity changes on a bitrate change in JBM + * Flush samples if renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_flush_renderer( +ivas_error ivas_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ @@ -1742,12 +1742,13 @@ ivas_error ivas_jbm_dec_flush_renderer( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_set_discard_samples() + * ivas_dec_set_discard_samples() * - * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change + * Set number of samples to discard in the first subframe + * if the renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_set_discard_samples( +ivas_error ivas_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 149e298c8f..b8af6dd126 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1489,12 +1489,13 @@ ivas_error ivas_masa_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 330a1474ed..b315ed9039 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1322,9 +1322,9 @@ void ivas_param_mc_dec_read_BS( #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS void ivas_param_mc_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ - float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + float *p_data_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { int16_t ch, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; @@ -1342,7 +1342,7 @@ void ivas_param_mc_dec_digest_tc( { for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - cldfbAnalysis_ts( &( transport_channels_f[ch][num_freq_bands * slot_idx] ), + cldfbAnalysis_ts( &( p_data_f[ch][num_freq_bands * slot_idx] ), &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch] ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index b51e588c3a..170534a0ca 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -791,17 +791,17 @@ static ivas_error ivas_mc_dec_reconfig( } } - /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv - render what still fits in the new granularity */ + /* when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv + render what still fits in the new granularity */ tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); if ( tc_granularity_new < hTcBuffer->n_samples_granularity ) { /* flush already done in IVAS_DEC_ReadFormat() */ } - /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + /* when granularity goes up set samples to discard at the beginning of the frame */ else if ( tc_granularity_new > hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 269f7a0fbd..83b4740d11 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -94,7 +94,7 @@ ivas_error ivas_td_binaural_renderer_sf( int16_t ch, slot_size, slots_to_render, output_frame; ivas_error error; - int16_t ism_md_subframe_update_jbm; + int16_t ism_md_subframe_update; int16_t c_indx, nS; int16_t nchan_ism_internal, nchan_ism, ch_offset; @@ -121,16 +121,16 @@ ivas_error ivas_td_binaural_renderer_sf( /* Number of subframes to delay metadata to sync with audio */ if ( st_ivas->hDecoderConfig->Opt_delay_comp ) { - ism_md_subframe_update_jbm = max( 0, st_ivas->hTcBuffer->nb_subframes - 3 ); + ism_md_subframe_update = max( 0, st_ivas->hTcBuffer->nb_subframes - 3 ); } else { - ism_md_subframe_update_jbm = st_ivas->hTcBuffer->nb_subframes - 2; + ism_md_subframe_update = st_ivas->hTcBuffer->nb_subframes - 2; } if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - ism_md_subframe_update_jbm = max( 0, st_ivas->hTcBuffer->nb_subframes - 2 ); + ism_md_subframe_update = max( 0, st_ivas->hTcBuffer->nb_subframes - 2 ); } for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -179,7 +179,7 @@ ivas_error ivas_td_binaural_renderer_sf( } } - if ( subframe_idx == ism_md_subframe_update_jbm ) + if ( subframe_idx == ism_md_subframe_update ) { if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -229,9 +229,9 @@ ivas_error ivas_td_binaural_renderer_sf( } /* Render subframe */ - /* ism_md_subframe_update_jbm != subframe_idx: trigger update only for ism_md_subframe_update_jbm == subframe_idx, + /* ism_md_subframe_update != subframe_idx: trigger update only for ism_md_subframe_update_jbm == subframe_idx, where then the two TDREND_GetMix()-arguments subframe_idx and ism_md_subframe_update are equal, and we want to enforce the update inside TDREND_GetMix to use subframe_idx == 0 */ - if ( ( error = TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0, ism_md_subframe_update_jbm != subframe_idx ) ) != IVAS_ERR_OK ) + if ( ( error = TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0, ism_md_subframe_update != subframe_idx ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index d22fa12d70..c9c9ec26c9 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -209,7 +209,7 @@ ivas_error ivas_sba_dec_reconfigure( } else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 75309da807..fb1746092d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1021,7 +1021,7 @@ ivas_error IVAS_DEC_ReadFormat( #endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -2037,9 +2037,9 @@ static ivas_error IVAS_DEC_GetTcSamples( { /* run the main IVAS decoding routine */ #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS - if ( ( error = ivas_dec_tc( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec( st_ivas ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_dec_tc( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dec( st_ivas, pcmBuf ) ) != IVAS_ERR_OK ) #endif { return error; @@ -4845,19 +4845,19 @@ static ivas_error set_pcm_buffer_to_zero( const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ) { + ivas_error error; + + error = IVAS_ERR_OK; switch ( pcmType ) { case IVAS_DEC_PCM_FLOAT: - set_zero( (float *) buffer, nZeroSamples ); - break; - case IVAS_DEC_PCM_INT16: set_s( (int16_t *) buffer, 0, nZeroSamples ); break; default: - return IVAS_ERR_INTERNAL; + error = IVAS_ERR_INTERNAL; } - return IVAS_ERR_OK; + return error; } -- GitLab From 800b0e718383ffe56ea0a7e266458302fdc099e3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Nov 2024 09:53:42 +0100 Subject: [PATCH 17/22] move last Opt_tsm instances from ivas_dec.c() --- lib_dec/ivas_jbm_dec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 428634b409..13fd2016db 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -214,11 +214,13 @@ ivas_error ivas_dec( { return error; } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } +#endif } else if ( st_ivas->ivas_format == SBA_FORMAT ) { @@ -413,11 +415,13 @@ ivas_error ivas_dec( /* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */ ivas_omasa_render_objects_from_mix( st_ivas, p_output, st_ivas->nchan_ism, output_frame ); } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS if ( st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } +#endif } } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -2855,6 +2859,10 @@ static void ivas_jbm_masa_sf_to_slot_map( int16_t slot_idx; int16_t write_idx, sf_index; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); + +#endif /* Set values */ hJbmMetadata = st_ivas->hJbmMetadata; num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; -- GitLab From fe648e8c45a70ba9f93eda53dd207230454bf123 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Nov 2024 10:05:04 +0100 Subject: [PATCH 18/22] fix build warnings --- lib_dec/ivas_dec.c | 2 +- lib_dec/ivas_jbm_dec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index aada372a06..20f25a494b 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -51,7 +51,7 @@ * Principal IVAS decoder routine *--------------------------------------------------------------------------*/ -ivas_error ivas_dec_tmp( +static ivas_error ivas_dec_tmp( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t *data /* o : output synthesis signal */ ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 13fd2016db..70023421fe 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1748,7 +1748,7 @@ ivas_error ivas_dec_flush_renderer( /*--------------------------------------------------------------------------* * ivas_dec_set_discard_samples() * - * Set number of samples to discard in the first subframe + * Set number of samples to discard in the first subframe * if the renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ -- GitLab From e7a94f0a8a85a37076cd89ad718a3a12ea19443b Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Nov 2024 10:25:58 +0100 Subject: [PATCH 19/22] fix build warnings --- lib_com/ivas_prot.h | 5 +++++ lib_dec/ivas_dec.c | 2 +- lib_dec/lib_dec.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 45477c9d9e..095619cf22 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -313,6 +313,11 @@ void stereo_dmx_evs_close_encoder( STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ ); +ivas_error ivas_dec_tmp( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + int16_t *data /* o : output synthesis signal */ +); + ivas_error ivas_dec( #ifdef UNIFIED_DECODING_PATHS_LEFTOVERS Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 20f25a494b..aada372a06 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -51,7 +51,7 @@ * Principal IVAS decoder routine *--------------------------------------------------------------------------*/ -static ivas_error ivas_dec_tmp( +ivas_error ivas_dec_tmp( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t *data /* o : output synthesis signal */ ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fb1746092d..634cd34dc9 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -4853,6 +4853,9 @@ static ivas_error set_pcm_buffer_to_zero( case IVAS_DEC_PCM_FLOAT: set_s( (int16_t *) buffer, 0, nZeroSamples ); break; + case IVAS_DEC_PCM_INT16: + set_s( (int16_t *) buffer, 0, nZeroSamples ); + break; default: error = IVAS_ERR_INTERNAL; } -- GitLab From c8df4f071d78481bc101081ef13454e27f476b99 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 20 Nov 2024 15:43:37 +0100 Subject: [PATCH 20/22] call ivas_jbm_dec_set_discard_samples() at one common place and only in JBM + revert some renamings --- lib_com/ivas_prot.h | 11 +++++++++-- lib_dec/ivas_ism_dec.c | 32 ++++++++++++++++++-------------- lib_dec/ivas_jbm_dec.c | 38 ++++++++++++++++++++++++++------------ lib_dec/ivas_masa_dec.c | 9 +++++++-- lib_dec/ivas_mct_dec.c | 18 +++++++++++------- lib_dec/ivas_sba_dec.c | 14 +++++++++++++- lib_dec/lib_dec.c | 35 +++++++++++++++++++++++++++++++++-- 7 files changed, 117 insertions(+), 40 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 095619cf22..e597e07b08 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -791,7 +791,7 @@ void ivas_apply_non_diegetic_panning( * decoder->rendering TC buffer prototypes *----------------------------------------------------------------------------------*/ -ivas_error ivas_dec_flush_renderer( +ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ @@ -815,7 +815,7 @@ void ivas_dec_prepare_renderer( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -ivas_error ivas_dec_set_discard_samples( +ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); @@ -865,9 +865,16 @@ TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode( ); /*! r: render granularity */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS int16_t ivas_dec_get_render_granularity( +#else +int16_t ivas_jbm_dec_get_render_granularity( +#endif const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + const ISM_MODE ism_mode, /* i : ISM mode */ +#endif const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 8cfd6d31df..b160fe652b 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -111,7 +111,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( #ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH { #endif - /* transfer subframe info from DirAC or ParamMC to central TC buffer */ + /* transfer subframe info from ParamISM to central TC buffer */ /* only do this if we are not having done everything already in the TC decoding part and having only played out from the TC buffer */ if ( last_ism_mode == ISM_MODE_PARAM && st_ivas->hSpatParamRendCom != NULL && st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) { @@ -122,22 +122,26 @@ static ivas_error ivas_ism_bitrate_switching_dec( mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } - /* when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv - render what still fits in the new granularity */ - tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->ism_mode, MC_MODE_NONE, st_ivas->hDecoderConfig->output_Fs ); +#else + /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv + render what still fits in the new granularity */ + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); - if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) - { - /* flush already done in IVAS_DEC_ReadFormat() */ - } - /* when granularity goes up set samples to discard at the beginning of the frame */ - else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + { + /* flush already done in IVAS_DEC_ReadFormat() */ + } + /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } +#endif #ifndef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH } #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 70023421fe..49323a5e18 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1482,12 +1482,12 @@ ivas_error ivas_dec_render( /*--------------------------------------------------------------------------* - * ivas_dec_flush_renderer() + * ivas_jbm_dec_flush_renderer() * - * Flush samples if renderer granularity changes on a bitrate change + * Flush samples if renderer granularity changes on a bitrate change in JBM *--------------------------------------------------------------------------*/ -ivas_error ivas_dec_flush_renderer( +ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ @@ -1746,13 +1746,13 @@ ivas_error ivas_dec_flush_renderer( /*--------------------------------------------------------------------------* - * ivas_dec_set_discard_samples() + * ivas_jbm_dec_set_discard_samples() * * Set number of samples to discard in the first subframe - * if the renderer granularity changes on a bitrate change + * if the renderer granularity changes on a bitrate change in JBM processing *--------------------------------------------------------------------------*/ -ivas_error ivas_dec_set_discard_samples( +ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) { @@ -1785,24 +1785,24 @@ void ivas_dec_get_adapted_linear_interpolator( float *interpolator /* o : the interpolator */ ) { - int16_t jbm_segment_len, idx; + int16_t segment_len, idx; float dec; #ifdef DEBUGGING assert( default_interp_length % 2 == 0 ); #endif - jbm_segment_len = ( default_interp_length >> 1 ); + segment_len = ( default_interp_length >> 1 ); dec = 1.0f / default_interp_length; interpolator[interp_length - 1] = 1.0f; - for ( idx = interp_length - 2; idx >= jbm_segment_len; idx-- ) + for ( idx = interp_length - 2; idx >= segment_len; idx-- ) { interpolator[idx] = max( 0.0f, interpolator[idx + 1] - dec ); } if ( interpolator[idx + 1] > 0.0f ) { - dec = interpolator[idx + 1] / ( jbm_segment_len + 1 ); + dec = interpolator[idx + 1] / ( segment_len + 1 ); for ( ; idx >= 0; idx-- ) { interpolator[idx] = interpolator[idx + 1] - dec; @@ -2195,11 +2195,18 @@ static void ivas_jbm_dec_copy_tc( *--------------------------------------------------------------------------*/ /*! r: render granularity */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS int16_t ivas_dec_get_render_granularity( +#else +int16_t ivas_jbm_dec_get_render_granularity( +#endif const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + const ISM_MODE ism_mode, /* i : ISM mode */ +#endif + const MC_MODE mc_mode, /* i : MC mode */ + const int32_t output_Fs /* i : sampling rate */ ) { int16_t render_granularity; @@ -2215,6 +2222,13 @@ int16_t ivas_dec_get_render_granularity( render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); } } +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + else if ( ivas_format == MASA_ISM_FORMAT && rendererType == RENDERER_BINAURAL_PARAMETRIC && ism_mode == ISM_MASA_MODE_DISC ) + { + render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as TDrend */ + } + +#endif else { render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index b8af6dd126..4d96e7b358 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1474,7 +1474,11 @@ ivas_error ivas_masa_dec_reconfigure( TC_BUFFER_MODE buffer_mode_new; int16_t n_samples_granularity; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + n_samples_granularity = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->ism_mode, MC_MODE_NONE, st_ivas->hDecoderConfig->output_Fs ); +#else n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); +#endif buffer_mode_new = ivas_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_dec_get_num_tc_channels( st_ivas ); @@ -1489,13 +1493,13 @@ ivas_error ivas_masa_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1508,6 +1512,7 @@ ivas_error ivas_masa_dec_reconfigure( /* flush already done in IVAS_DEC_ReadFormat() */ } } +#endif } else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 170534a0ca..fb84207014 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -791,21 +791,25 @@ static ivas_error ivas_mc_dec_reconfig( } } - /* when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv - render what still fits in the new granularity */ - tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); - if ( tc_granularity_new < hTcBuffer->n_samples_granularity ) +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, ISM_MODE_NONE, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#else + /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv + render what still fits in the new granularity */ + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { /* flush already done in IVAS_DEC_ReadFormat() */ } - /* when granularity goes up set samples to discard at the beginning of the frame */ - else if ( tc_granularity_new > hTcBuffer->n_samples_granularity ) + /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } +#endif if ( st_ivas->mc_mode == MC_MODE_MCT ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index c9c9ec26c9..6f76971f9f 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -202,6 +202,17 @@ ivas_error ivas_sba_dec_reconfigure( granularity_new *= JBM_CLDFB_SLOTS_IN_SUBFRAME; } +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + { + /* make sure the changed number of slots in the last subframe is not lost in the following steps */ + if ( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + } + st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + } +#else /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { @@ -209,7 +220,7 @@ ivas_error ivas_sba_dec_reconfigure( } else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -221,6 +232,7 @@ ivas_error ivas_sba_dec_reconfigure( } st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; } +#endif } /* save old */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 634cd34dc9..6ef56ce21f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1008,12 +1008,42 @@ ivas_error IVAS_DEC_ReadFormat( *intern_audio_config = st_ivas->intern_config; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || + ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) ) + { + int16_t tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->ism_mode, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + + st_ivas->nchan_transport = nchan_transport_old; + + /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv ) + render what still fits in the new granularity */ + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + } + /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + } +#else if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) { /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ - int16_t tc_granularity_new = ivas_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); #ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH st_ivas->nchan_transport = nchan_transport_old; #else @@ -1021,12 +1051,13 @@ ivas_error IVAS_DEC_ReadFormat( #endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) { return error; } } } +#endif } st_ivas->ism_mode = ism_mode_old; -- GitLab From c63648e52df231680d5bb544f152ae2103a0b88a Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Nov 2024 09:27:58 +0100 Subject: [PATCH 21/22] improve comment --- lib_dec/lib_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 6ef56ce21f..bd8b25ca56 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2089,9 +2089,10 @@ static ivas_error IVAS_DEC_GetTcSamples( /*---------------------------------------------------------------------* - * IVAS_DEC_Rendered_FeedTcSamples( ) + * IVAS_DEC_RendererFeedTcSamples( ) * * Feed decoded transport channels samples to the renderer + * Handle residual samples to TSM for the next call *---------------------------------------------------------------------*/ static ivas_error IVAS_DEC_RendererFeedTcSamples( -- GitLab From 7ba8a75405ad7bf5188e1d34404c67825e636ac2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 7 Apr 2025 18:15:05 +0200 Subject: [PATCH 22/22] simplifications --- lib_com/ivas_tools.c | 9 --------- lib_dec/ivas_jbm_dec.c | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 2695d52a01..c075bb851e 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -149,20 +149,11 @@ uint32_t ivas_syn_output( } -#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS /*-------------------------------------------------------------------* * ivas_syn_output_f() * * Copy IVAS synthesis signals into a linear buffer *-------------------------------------------------------------------*/ -#else -/*-------------------------------------------------------------------* - * ivas_syn_output_f() - * - * Output ivas synthesis signal with compensation for saturation - * returns number of clipped samples - *-------------------------------------------------------------------*/ -#endif /*! r: number of clipped samples */ void ivas_syn_output_f( diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9accbd2b03..28e4a4d30d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -737,9 +737,9 @@ ivas_error ivas_dec( * Write IVAS transport channels *----------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_tsm ) + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) { - ivas_syn_output_f( p_output, output_frame, nchan_out, data ); + ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); } else { @@ -832,7 +832,7 @@ void ivas_dec_feed_tc_to_renderer( mvr2r( hTcBuffer->tc[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); for ( m = 0; m < nSamplesForRendering; m++ ) { - hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_rend + ch]; + hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * hTcBuffer->nchan_transport_rend + ch]; } } @@ -850,7 +850,7 @@ void ivas_dec_feed_tc_to_renderer( } } - n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + n_render_timeslots = hTcBuffer->n_samples_available / hTcBuffer->n_samples_granularity; } else { @@ -861,7 +861,7 @@ void ivas_dec_feed_tc_to_renderer( 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]; /* note: buffers needed in the TD decorellator */ + hTcBuffer->tc[n] = st_ivas->p_output_f[n]; /* note: buffers needed in the TD decorellator */ } hTcBuffer->n_samples_buffered = nSamplesForRendering; @@ -876,7 +876,7 @@ void ivas_dec_feed_tc_to_renderer( { ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); } - else if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) + else if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC && hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER ) { ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); } @@ -1643,7 +1643,7 @@ ivas_error ivas_jbm_dec_flush_renderer( mvr2r( st_ivas->hMasaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); } - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -1663,6 +1663,7 @@ ivas_error ivas_jbm_dec_flush_renderer( ISM_MODE ism_mode_orig; RENDERER_TYPE renderer_type_orig; int32_t ivas_total_brate; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; renderer_type_orig = st_ivas->renderer_type; ism_mode_orig = st_ivas->ism_mode; @@ -1709,12 +1710,12 @@ ivas_error ivas_jbm_dec_flush_renderer( set_s( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available ); set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); - if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) - /* render the last subframe */ - if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) - { - return error; - } + /* render the last subframe */ + if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, (uint16_t) n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + #ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN st_ivas->ism_mode = ism_mode_orig; st_ivas->renderer_type = renderer_type_orig; -- GitLab