From 61fecc84daa829d142d239d198151a3e2d0cb3d5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 10:18:54 +0200 Subject: [PATCH 1/7] move ivas_jbm_dec_tc() and ivas_jbm_dec_render() to ivas_dec.c --- lib_dec/ivas_dec.c | 1376 +++++++++++++++++++++++++++++++++- lib_dec/ivas_jbm_dec.c | 1602 +++------------------------------------- 2 files changed, 1479 insertions(+), 1499 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 833cebe88e..9d41953a8b 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -34,31 +34,1391 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif #include "wmc_auto.h" +/*-----------------------------------------------------------------------* + * Local function prototypes + *-----------------------------------------------------------------------*/ + +static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); + +static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); + + /*--------------------------------------------------------------------------* * ivas_dec() * * Principal IVAS decoder routine *--------------------------------------------------------------------------*/ -ivas_error ivas_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t *data /* o : output synthesis signal */ +ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() + 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 */ + 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++ ) + { + p_output[n] = st_ivas->p_output_f[n]; + if ( p_output[n] != NULL ) + { + set_zero( p_output[n], L_FRAME48k ); + } + } + + 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 + *----------------------------------------------------------------*/ + + 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 ); + } + } + 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 ) + { + ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ); + + /* 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_ism_mono_dmx( 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 && st_ivas->hDecoderConfig->Opt_tsm ) + { + 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 ); + + /* external output */ + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + { + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + set_zero( p_output[st_ivas->nchan_transport + n], output_frame ); + } + + ivas_omasa_rearrange_channels( p_output, st_ivas->nchan_ism, output_frame ); + } + } + 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_ism_mono_dmx( st_ivas, p_output, output_frame ); + } + else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + ivas_omasa_rearrange_channels( p_output, nchan_transport_ism, output_frame ); + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + { + /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */ + ivas_omasa_combine_separate_ism_with_masa( st_ivas, p_output, st_ivas->nchan_ism, output_frame ); + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + /* 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 ); + } + + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + 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; + + 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; + } + 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 ) + { + return error; + } + } + 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 ) + { + return error; + } + } + 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 ) + { + 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++ ) + { + int16_t val = (int16_t) ( output[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); + } + } + } +#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 ); + + 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_ism_mono_dmx( 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->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] ); + + if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* HP filtering */ + for ( n = 0; n < st_ivas->nchan_transport; n++ ) + { + if ( n != LFE_CHANNEL ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + } + + 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 ); + } + } + + 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 ( 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->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 ) + { + return error; + } + + /* HP filtering */ + for ( n = 0; n < st_ivas->nchan_transport; n++ ) + { + if ( n != LFE_CHANNEL ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + } + + /* 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++ ) + { + 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_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; + } + } + } + + 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 + *----------------------------------------------------------------*/ + + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) + { + 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_jbm_dec_render( // todo: to be renamed to 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 ) { - // 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 + int16_t n, nchan_out; + int16_t nchan_transport; + 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++ ) + { + p_output[n] = st_ivas->p_output_f[n]; + } + + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) + { + p_tc[n] = &p_output[n][st_ivas->hTcBuffer->n_samples_rendered]; + } + + for ( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + { + st_ivas->hTcBuffer->tc[n] = p_output[n]; + } + } + else + { + 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]; + } + } + + /*----------------------------------------------------------------* + * 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 ); + } + + /*----------------------------------------------------------------* + * Rendering + *----------------------------------------------------------------*/ + + if ( st_ivas->ivas_format == UNDEFINED_FORMAT ) + { + assert( 0 ); + } + else if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + { + ivas_jbm_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_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, st_ivas->renderer_type, p_output, *nSamplesRendered ); + } + else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) + { + ivas_apply_non_diegetic_panning( p_tc[0], p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); + } +#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 */ + 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 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; + } + } +#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_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 ) + { + if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) + { + 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 ) + { + ivas_omasa_dirac_rend_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); + } + else if ( st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT || st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT ) + { + ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); + ivas_omasa_rearrange_channels( p_output, st_ivas->nchan_ism, *nSamplesRendered ); + } + } + 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 ) + { + if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO ) + { + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + + /* 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]; + } + + /* render objects */ + ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered ); + + /* add already rendered SBA part */ + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); + } + } + else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + if ( ( error = ivas_osba_render_sf( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + } + 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-- ) + { + mvr2r( p_output[n], p_output[n + st_ivas->nchan_ism], *nSamplesRendered ); + } + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + set_zero( p_output[n], *nSamplesRendered ); + } + } + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + 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]; + } + 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 + { + 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->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 ) + { + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); + } + + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); + } + else if ( st_ivas->intern_config == 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], *nSamplesRendered ); + } + } + } + + /* 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 ) ) + { + 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 if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) + { + /* Delay the separated channel to sync with the DirAC rendering */ + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); + } + } + } + } + + /*----------------------------------------------------------------* + * 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; + + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); + + if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) + { + 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++ ) + { + 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_jbm_dec_copy_masa_meta_to_buffer() + * + * Copy decoded MASA metadata to a ring buffer + *--------------------------------------------------------------------------*/ + +static void ivas_jbm_dec_copy_masa_meta_to_buffer( + Decoder_Struct *st_ivas ) +{ + int16_t sf, dir, band, write_idx; + JBM_METADATA_HANDLE hJbmMetadata; + MASA_DECODER_EXT_OUT_META *extOutMeta; + + hJbmMetadata = st_ivas->hJbmMetadata; + extOutMeta = st_ivas->hMasa->data.extOutMeta; + + 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; +} + + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_playout() + * + * + *--------------------------------------------------------------------------*/ + +static void ivas_jbm_dec_tc_buffer_playout( + Decoder_Struct *st_ivas, + const uint16_t nSamplesAsked, + uint16_t *nSamplesRendered, + 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++; + } +#ifdef DEBUGGING + assert( slots_to_render == 0 ); +#endif + + 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; +} diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ffb018c06d..006266ebb0 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -52,1025 +52,55 @@ static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); -static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); - -static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); - -static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs ); - - -/*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc() - * - * Principal IVAS JBM decoder routine, decoding of metadata and transport channels - *--------------------------------------------------------------------------*/ - -ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : transport channel 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 */ - 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_jbm_dec_tc" ); - - /*----------------------------------------------------------------* - * 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++ ) - { - p_output[n] = st_ivas->p_output_f[n]; - if ( p_output[n] != NULL ) - { - set_zero( p_output[n], L_FRAME48k ); - } - } - - 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 - *----------------------------------------------------------------*/ - - 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 ); - } - } - 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 ) - { - ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ); - - /* 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_ism_mono_dmx( 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 && st_ivas->hDecoderConfig->Opt_tsm ) - { - 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 ); - - /* external output */ - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) - { - for ( n = 0; n < st_ivas->nchan_ism; n++ ) - { - set_zero( p_output[st_ivas->nchan_transport + n], output_frame ); - } - - ivas_omasa_rearrange_channels( p_output, st_ivas->nchan_ism, output_frame ); - } - } - 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_ism_mono_dmx( st_ivas, p_output, output_frame ); - } - else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) - { - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - ivas_omasa_rearrange_channels( p_output, nchan_transport_ism, output_frame ); - } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) - { - /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */ - ivas_omasa_combine_separate_ism_with_masa( st_ivas, p_output, st_ivas->nchan_ism, output_frame ); - } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) - { - /* 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 ); - } - - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - 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; - - 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; - } - 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 ) - { - return error; - } - } - 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 ) - { - return error; - } - } - 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 ) - { - 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++ ) - { - int16_t val = (int16_t) ( output[c][t] + 0.5f ); - dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); - } - } - } -#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 ); - - 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_ism_mono_dmx( 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->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] ); - - if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* HP filtering */ - for ( n = 0; n < st_ivas->nchan_transport; n++ ) - { - if ( n != LFE_CHANNEL ) - { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); - } - } - - 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 ); - } - } - - 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 ( 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->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 ) - { - return error; - } - - /* HP filtering */ - for ( n = 0; n < st_ivas->nchan_transport; n++ ) - { - if ( n != LFE_CHANNEL ) - { - hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); - } - } - - /* 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++ ) - { - 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_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; - } - } - } - - 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 - *----------------------------------------------------------------*/ - - if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) - { - 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_jbm_dec_feed_tc_to_renderer() - * - * Feed decoded transport channels and metadata to the IVAS JBM renderer routine - *--------------------------------------------------------------------------*/ - -void ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i : 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_rendererer" ); - for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) - { - p_data_f[n] = &data_f[n][0]; - } - - - 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->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - - if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm ) - { - ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); - } - } - else if ( st_ivas->ivas_format == STEREO_FORMAT ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - } - else if ( st_ivas->ivas_format == ISM_FORMAT ) - { - /* Rendering */ - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) - { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); - - ivas_param_ism_params_to_masa_param_mapping( st_ivas ); - } - else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) - { - ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); - } - } - else /* ISM_MODE_DISC */ - { - ivas_ism_dec_digest_tc( st_ivas ); - } - } - else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) - { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - ivas_ism_dec_digest_tc( st_ivas ); - - /* delay the objects here for all renderers where it is needed */ - if ( -#ifdef SPLIT_REND_WITH_HEAD_ROT - ( -#endif - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL -#ifdef SPLIT_REND_WITH_HEAD_ROT - ) && - ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif - ) - { - for ( n = 0; n < st_ivas->nchan_ism; n++ ) - { - delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); - } - } - - if ( !st_ivas->sba_dirac_stereo_flag ) - { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) - { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); - } - - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - } - else - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); - } - } - else - { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); - } - - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - ivas_ism_dec_digest_tc( st_ivas ); - } - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) - { - int16_t num_objects; - /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ - num_objects = 0; - if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC ) - { - num_objects = 1; - } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - num_objects = st_ivas->nchan_ism; - } - for ( n = 0; n < num_objects; n++ ) - { - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) - { - v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); - } - delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); - } - } - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) - { - ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) - { - ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); - } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) - { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - } - } - - pop_wmops(); - return; -} +static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs ); /*--------------------------------------------------------------------------* - * ivas_dec_render() + * ivas_jbm_dec_feed_tc_to_renderer() * - * Principal IVAS JBM rendering routine + * Feed decoded transport channels and metadata to the IVAS JBM renderer routine *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of samples wanted */ - 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 +void ivas_jbm_dec_feed_tc_to_renderer( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i : transport channels */ ) { - int16_t n, nchan_out; - int16_t nchan_transport; - 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; + 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; - for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { - p_output[n] = st_ivas->p_output_f[n]; + p_data_f[n] = &data_f[n][0]; } - if ( !st_ivas->hDecoderConfig->Opt_tsm ) - { - for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) - { - p_tc[n] = &p_output[n][st_ivas->hTcBuffer->n_samples_rendered]; - } - for ( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ ) - { - st_ivas->hTcBuffer->tc[n] = p_output[n]; - } + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); } else { - 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]; - } + *nSamplesResidual = 0; } + n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; - /*----------------------------------------------------------------* - * Update combined orientation access index - *----------------------------------------------------------------*/ - - if ( st_ivas->hCombinedOrientationData != NULL ) + if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { - /* 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 ); - } - - /*----------------------------------------------------------------* - * Rendering - *----------------------------------------------------------------*/ + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - if ( st_ivas->ivas_format == UNDEFINED_FORMAT ) - { - assert( 0 ); - } - else if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) - { - ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); + if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { - /* 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 ); - } + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } else if ( st_ivas->ivas_format == ISM_FORMAT ) { @@ -1079,464 +109,141 @@ ivas_error ivas_jbm_dec_render( { 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_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, st_ivas->renderer_type, p_output, *nSamplesRendered ); - } - else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) - { - ivas_apply_non_diegetic_panning( p_tc[0], p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered ); - } -#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 */ - 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 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; - } - } -#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_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 ) - { - if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) - { - 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 ) - { - ivas_omasa_dirac_rend_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); - } - else if ( st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT || st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT ) - { - ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); - ivas_omasa_rearrange_channels( p_output, st_ivas->nchan_ism, *nSamplesRendered ); - } - } - 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 ) - { - if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO ) - { - *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); - - /* 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]; - } - - /* render objects */ - ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered ); - - /* add already rendered SBA part */ - for ( n = 0; n < nchan_out; n++ ) - { - v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); - } - } - else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - if ( ( error = ivas_osba_render_sf( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) - { - return error; - } - } - 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; - } + ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots ); - 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; + ivas_param_ism_params_to_masa_param_mapping( st_ivas ); } - - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { -#ifdef DEBUGGING - assert( st_ivas->ism_mode == ISM_MODE_NONE ); -#endif - for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) - { - mvr2r( p_output[n], p_output[n + st_ivas->nchan_ism], *nSamplesRendered ); - } - for ( n = 0; n < st_ivas->nchan_ism; n++ ) - { - set_zero( p_output[n], *nSamplesRendered ); - } + ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f ); } } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) + else /* ISM_MODE_DISC */ { - p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; + ivas_ism_dec_digest_tc( st_ivas ); } - if ( st_ivas->mc_mode == MC_MODE_MCT ) + } + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - 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 ); - } - } + ivas_ism_dec_digest_tc( st_ivas ); - /* Rendering */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { + /* delay the objects here for all renderers where it is needed */ + if ( #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 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 ); + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL #ifdef SPLIT_REND_WITH_HEAD_ROT - } + ) && + ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif - } - 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 ); + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + } } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + + if ( !st_ivas->sba_dirac_stereo_flag ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { - if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) - { - return error; - } + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); } - 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 + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + else { - ivas_mc_paramupmix_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc, p_output ); + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) + { + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - /* 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 ) + if ( st_ivas->hDecoderConfig->Opt_tsm ) { - ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } } - 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 ) + else { - 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 ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); } - 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 ) - { - mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); - } + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - 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++ ) - { - set_zero( p_output[n], *nSamplesRendered ); - } - } + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + ivas_ism_dec_digest_tc( st_ivas ); } - /* copy discrete C and TD LFE from internal TC to output */ - if ( st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) { - 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 ) ) + int16_t num_objects; + /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ + num_objects = 0; + if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC ) + { + num_objects = 1; + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - 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 ); + num_objects = st_ivas->nchan_ism; } - else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) + for ( n = 0; n < num_objects; n++ ) { - /* Delay the separated channel to sync with the DirAC rendering */ - mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + } + delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } } } - - /*----------------------------------------------------------------* - * 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; - - /* update global combined orientation start index */ - ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); - - if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) + else if ( st_ivas->ivas_format == MC_FORMAT ) { - 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++ ) + if ( st_ivas->mc_mode == MC_MODE_MCT ) { - p_output[n] += st_ivas->hTcBuffer->n_samples_discard; + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } - *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 ) + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { -#ifndef DISABLE_LIMITER - ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); -#endif + ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f ); + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } -#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; + return; } @@ -2545,49 +1252,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } -/*--------------------------------------------------------------------------* - * ivas_jbm_dec_tc_buffer_playout() - * - * - *--------------------------------------------------------------------------*/ - -static void ivas_jbm_dec_tc_buffer_playout( - Decoder_Struct *st_ivas, - const uint16_t nSamplesAsked, - uint16_t *nSamplesRendered, - 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++; - } -#ifdef DEBUGGING - assert( slots_to_render == 0 ); -#endif - - 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; -} - - /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_close() * @@ -2873,50 +1537,6 @@ ivas_error ivas_jbm_dec_metadata_open( } -/*--------------------------------------------------------------------------* - * ivas_jbm_dec_copy_masa_meta_to_buffer() - * - * Copy decoded MASA metadata to a ring buffer - *--------------------------------------------------------------------------*/ - -static void ivas_jbm_dec_copy_masa_meta_to_buffer( - Decoder_Struct *st_ivas ) -{ - int16_t sf, dir, band; - JBM_METADATA_HANDLE hJbmMetadata; - MASA_DECODER_EXT_OUT_META *extOutMeta; - int16_t write_idx; - - hJbmMetadata = st_ivas->hJbmMetadata; - extOutMeta = st_ivas->hMasa->data.extOutMeta; - - 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; -} - - /*--------------------------------------------------------------------------* * ivas_jbm_masa_sf_to_slot_map() * -- GitLab From 231b11eb23c26135d6db9e7b043080eb495a73fd Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 10:28:53 +0200 Subject: [PATCH 2/7] use local parameter instead of a global one --- lib_dec/ivas_dec.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 9d41953a8b..b874dfa5b5 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -98,7 +98,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to 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++ ) + for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); n++ ) { st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; } @@ -167,6 +167,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() } } + /* core-decoding of transport channels */ for ( n = 0; n < st_ivas->nchan_transport; n++ ) { /* for DTX frames, dominant object has already been decoded before */ @@ -305,7 +306,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); /* external output */ - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -472,10 +473,10 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to 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, 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 ); } @@ -504,7 +505,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to 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, 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 ); } @@ -538,6 +539,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() /* LFE channel decoder */ ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output[LFE_CHANNEL] ); + /* core-decoding of transport channels */ if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; @@ -579,6 +581,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); + /* core-decoding of transport channels */ if ( ( error = ivas_mct_dec( st_ivas, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; @@ -613,6 +616,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() /* read Parametric MC parameters from the bitstream */ ivas_param_mc_dec_read_BS( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] ); + /* core-decoding of transport channels */ if ( st_ivas->nCPE == 1 ) { if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) @@ -655,7 +659,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() if ( st_ivas->hOutSetup.separateChannelEnabled ) { - /* Decode the transport audio signals */ + /* core-decoding of transport channels */ if ( ( error = ivas_cpe_dec( st_ivas, 0, p_output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; @@ -664,7 +668,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() /* 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 */ + /* core-decoding of 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; @@ -685,6 +689,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() } else { + /* 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 ) @@ -723,7 +728,7 @@ ivas_error ivas_jbm_dec_tc( // todo: to be renamed to ivas_dec() * Write IVAS transport channels *----------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) + if ( st_ivas->hDecoderConfig->Opt_tsm ) { ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); } @@ -1029,7 +1034,7 @@ ivas_error ivas_jbm_dec_render( // todo: to be renamed to ivas_dec_render() *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); /* 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 ) + if ( st_ivas->nchan_ism == 1 && !st_ivas->hDecoderConfig->Opt_tsm ) { mvr2r( p_tc[2], p_output[3], *nSamplesRendered ); mvr2r( p_tc[1], p_output[2], *nSamplesRendered ); @@ -1053,7 +1058,7 @@ ivas_error ivas_jbm_dec_render( // todo: to be renamed to ivas_dec_render() return error; } } - else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ + else if ( 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 ) { @@ -1084,7 +1089,7 @@ ivas_error ivas_jbm_dec_render( // todo: to be renamed to ivas_dec_render() return error; } - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { #ifdef DEBUGGING assert( st_ivas->ism_mode == ISM_MODE_NONE ); -- GitLab From cd0e531ec3bcb0e8ecb2b8dd66f0ee62c34d42f7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 12:18:01 +0200 Subject: [PATCH 3/7] remove todo comment --- lib_rend/lib_rend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index a6ddac23a9..575c8bcd94 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4072,7 +4072,7 @@ ivas_error IVAS_REND_SetInputLfePos( * * *-------------------------------------------------------------------*/ -/* ToDo; unused function */ + ivas_error IVAS_REND_RemoveInput( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId /* i : ID of the input */ @@ -8352,7 +8352,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 7509657ef22ef8a024489040763d9e22f542d2e7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 12:24:08 +0200 Subject: [PATCH 4/7] remove todo comment --- lib_dec/lib_dec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index aeb8f84303..e223ff639e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3688,7 +3688,6 @@ ivas_error IVAS_DEC_GetSplitRendBits( * *---------------------------------------------------------------------*/ -// ToDo: currently unused ivas_error IVAS_DEC_GetCldfbSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ float *out_real, /* o : buffer for decoded PCM real output in CLDFB domain */ -- GitLab From 52b02138ff94ab8318a14a2e7b32df529ecbc720 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 12:26:23 +0200 Subject: [PATCH 5/7] update issue number --- lib_dec/dec_tcx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index d8f4b17881..47be9dca1a 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1548,7 +1548,7 @@ void decoder_tcx_tns( if ( ( L_frame == st->L_frame >> 1 ) && st->tcxonly && isTCX5 ) { - if ( st->element_mode == EVS_MONO || L_spec < L_frameTCX ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ + if ( st->element_mode == EVS_MONO || L_spec < L_frameTCX ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue #517) */ { tcx5TnsUngrouping( L_frameTCX >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); } -- GitLab From b08b7511c0415f462cf631fa6aba42f623587762 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 11:40:08 +0000 Subject: [PATCH 6/7] clang-format in lib_rend.c --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 575c8bcd94..8afaf97cd0 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8352,7 +8352,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t ) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From b4a4a22af56a4b4ed3e7632aace12b85c54b9194 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 13:53:02 +0200 Subject: [PATCH 7/7] clang-format --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8afaf97cd0..0df3418ed0 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8352,7 +8352,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t ) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } -- GitLab