diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6e4433136eb5713d10136b9d709cf60eaff6ea7..3fbaf04204e3b111aca6f8cacf8b7d2c5fe8fd47 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1867,7 +1867,7 @@ ltv-usan: - ivas-linux-fast artifacts: name: "$CI_JOB_NAME--main--sha-$CI_COMMIT_SHORT_SHA" - expire_in: 4 weeks + expire_in: 7 weeks when: always paths: - ep_015.g192 diff --git a/apps/decoder.c b/apps/decoder.c index f35d12fd0d987d1fb68520182c4d2dd0565d369e..dbd92244ded83d335caedabb58e58af019a954c8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -445,8 +445,14 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; +#ifdef LIB_DEC_REVISION + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, + arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, + arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -750,6 +756,13 @@ int main( } pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); +#ifdef LIB_DEC_REVISION + if ( pcmBuf == NULL ) + { + fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); + goto cleanup; + } +#endif /*-----------------------------------------------------------------* * Decoding @@ -1051,18 +1064,30 @@ static bool parseCmdlIVAS_dec( if ( strcmp( argv_to_upper, "-VOIP" ) == 0 ) { +#ifdef LIB_DEC_REVISION + arg->voipMode = true; +#else arg->voipMode = 1; +#endif i++; } else if ( strcmp( argv_to_upper, "-VOIP_HF_ONLY=0" ) == 0 ) { +#ifdef LIB_DEC_REVISION + arg->voipMode = true; +#else arg->voipMode = 1; +#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP; i++; } else if ( strcmp( argv_to_upper, "-VOIP_HF_ONLY=1" ) == 0 ) { +#ifdef LIB_DEC_REVISION + arg->voipMode = true; +#else arg->voipMode = 1; +#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF; i++; } @@ -1212,6 +1237,10 @@ static bool parseCmdlIVAS_dec( { if ( !is_digits_only( argv[i] ) ) { +#ifdef LIB_DEC_REVISION + fprintf( stderr, "Error: Render frame size is invalid or not specified!\n\n" ); + usage_dec(); +#endif return false; } @@ -1793,6 +1822,7 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifndef LIB_DEC_REVISION int32_t pcmFrameSize; if ( ( error = IVAS_DEC_GetPcmFrameSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK ) @@ -1800,7 +1830,7 @@ static ivas_error initOnFirstGoodFrame( fprintf( stderr, "\nError in IVAS_DEC_GetPcmFrameSize, error code: %d\n", error ); return error; } - +#endif if ( isSplitRend ) { /* Open split rendering metadata writer */ @@ -1858,7 +1888,23 @@ static ivas_error initOnFirstGoodFrame( } } +#ifdef LIB_DEC_REVISION + int16_t pcmFrameSize; + if ( ( error = IVAS_DEC_GetOutputBufferSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetOutputBufferSize, error code: %d\n", error ); + return error; + } + +#endif int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); +#ifdef LIB_DEC_REVISION + if ( zeroBuf == NULL ) + { + fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); + return IVAS_ERR_FAILED_ALLOC; + } +#endif memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); for ( int16_t i = 0; i < numInitialBadFrames; ++i ) @@ -2072,6 +2118,19 @@ static ivas_error decodeG192( SplitFileReadWrite *splitRendWriter = NULL; int16_t isSplitRend, isSplitCoded; +#ifdef VARIABLE_SPEED_DECODING +#ifdef LIB_DEC_REVISION + if ( arg.tsmEnabled ) + { + if ( ( error = IVAS_DEC_EnableTsm( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_EnableTsm, code: %d\n", error ); + return error; + } + } + +#endif +#endif if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); @@ -3386,7 +3445,12 @@ static ivas_error decodeVoIP( { if ( ( error = IVAS_DEC_HasDecodedFirstGoodFrame( hIvasDec, &decodedGoodFrame ) ) != IVAS_ERR_OK ) { +#ifdef LIB_DEC_REVISION + fprintf( stderr, "Error in IVAS_DEC_HasDecodedFirstGoodFrame(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); +#else fprintf( stderr, "Error in IVAS_DEC_HasDecodedFirstGoodFrame, code: %d\n", error ); + +#endif goto cleanup; } @@ -3398,6 +3462,9 @@ static ivas_error decodeVoIP( if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) { +#ifdef LIB_DEC_REVISION + fprintf( stderr, "Error in initOnFirstGoodFrame(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); +#endif goto cleanup; } } diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 6ff92edc432007dd083f990978bb5d20b666d7b3..64aab53ed057511ce8f8a2079e1b6903933aadc9 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -985,6 +985,9 @@ int main( while ( 1 ) { +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + int16_t bfi = 0; +#endif int16_t num_in_channels; num_in_channels = inBuffer.config.numChannels; @@ -993,7 +996,11 @@ int main( { ivas_error error_tmp; numSamplesRead = (int16_t) inBufferSize; +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten, &bfi ); +#else error_tmp = split_rend_read_bits_from_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten ); +#endif if ( error_tmp != IVAS_ERR_OK ) { if ( error_tmp == IVAS_ERR_END_OF_FILE ) @@ -1060,19 +1067,33 @@ int main( /* Read from split renderer bfi file if specified */ if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame ) { +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST int16_t bfi; +#endif if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) ); goto cleanup; } +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } +#endif + } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( splitBinNeedsNewFrame ) + { if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); goto cleanup; } } +#endif for ( i = 0; i < args.inConfig.numBinBuses; ++i ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ad871926d001f44a3bea01b9766aeedc512c44ec..fb8973884e0d6072e11721aa1a78f7e85bbd864d 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -656,6 +656,13 @@ void ivas_renderer_select( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifdef NONBE_1303_REND_GRANULARITY +/*! r: secondary binaural renderer type */ +RENDERER_TYPE ivas_renderer_secondary_select( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +#endif ivas_error ivas_mc_enc_config( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -799,8 +806,12 @@ void ivas_apply_non_diegetic_panning( *----------------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( +#ifdef LIB_DEC_REVISION + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : output synthesis signals */ +#endif ); ivas_error ivas_jbm_dec_render( @@ -885,10 +896,16 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( +#ifdef NONBE_1303_REND_GRANULARITY + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ + const int32_t output_Fs /* i : sampling rate */ +#else const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ +#endif ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -5791,6 +5808,15 @@ void ivas_omasa_render_objects_from_mix( const int16_t output_frame /* i : output frame length per channel */ ); +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT +void ivas_omasa_gain_masa_tc( + float *output[], /* i/o : output synthesis signal */ + const float gainMasa, /* i : gain for MASA transport channels */ + const int16_t nchan_transport_ism, /* i : number of ISM TCs */ + const int16_t output_frame /* i : output frame length per channel */ +); +#endif + void ivas_omasa_dirac_rend_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of samples requested */ diff --git a/lib_com/options.h b/lib_com/options.h index df4047ce4a9a760571e63111b21d587eaa184420..23a9a303de024d9dd1365cf7113a47909c21fc16 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,9 +160,8 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ -#define FIX_1285_RENDER_CONFIG_PTR_COMPARE /* Philips: Warning about pointer comparison in the render config reader */ -#define FIX_1298_MEMORY_OPT_IVAS_CORE_ENC /* VA: issue 1298: Memory saving in ivas_core_enc() */ -#define SIMPLIFY_IVAS_CORE /* VA: simplify ivas core coder functions */ +#define LIB_DEC_REVISION /* VA: cleaning and simplification of lib_dec.c */ + /* #################### End BE switches ################################## */ @@ -172,13 +171,12 @@ /* all switches in this category should start with "NONBE_" */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ -#define NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING /* Ericsson: issue 1180, corrected long term mute loop attnuation after 200ms in PhECU-PLC */ -#define NONBE_FIX_1297_SPAR_JBM_MEM_SAN /*Dolby: issue 1297, SPAR + JBM + BR switch memory sanitizer*/ -#define NONBE_1289_STEREO_SW_TO_MONO /* VA: issue 1289: Fix glitch when stereo signal is decoded to mono n TD->DFT switching */ -#define NONBE_1122_JBM_FIX_PLAYOUT_DELAY_IN_DTX /* FhG: Avoid JBM ignoring safety margin and setting playout delay to 0 during DTX */ +#define NONBE_1293_CRASH_FIRST_FRAME_LOST /* VA: issue 1293: fix G.192 decoder crash when first frame is lost */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS /* Eri: issue 1296: ITD resampling can occasionally read out of bounds, especially when the requested subframes are short (1.25 ms). Seen for headtracking+JBM. */ -#define NONBE_1303_GRANULARITY_OSBA_REND /* VA: issue 1303: Correctly set the granularity in OSBA, Disc mode, and BINAURAL_ROOM_REVERB output */ +#define NONBE_1118_EVS_LR_HQ_BITERROR /* VA: issue 1118: fix EVS decoder crash in LR-HQ in case of bit errors */ +#define NONBE_1303_REND_GRANULARITY /* VA: issue 1303: Renderer granularity revision */ +#define NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT /* Nokia: issue 1305: Fix OMASA ext output in case of object editing */ + /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 7fbc2b262a69212bfb5fd35fb34598cf4da73a31..18b6c30c5c8e96896c5cdd24b425549b85eb75e0 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -5905,13 +5905,10 @@ void core_switching_post_enc( ); ivas_error core_switching_post_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *synth, /* i/o: output synthesis */ - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ -#ifndef SIMPLIFY_IVAS_CORE - const IVAS_FORMAT ivas_format, /* i : IVAS format */ -#endif + Decoder_State *st, /* i/o: decoder state structure */ + float *synth, /* i/o: output synthesis */ + float *output, /* i/o: LB synth/upsampled LB synth */ + float output_mem[], /* i : OLA memory from last TCX/HQ frame */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */ diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 7e7e5d2f07b5485f17a48c28220ba3d43b28a841..9055f2b547f7c91c97241cfad16db483a40c8a96 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -263,13 +263,11 @@ static void trans_ana( const int16_t time_offs, /* i : Time offset */ const float est_mus_content, /* i : 0.0=speech_like ... 1.0=Music (==st->env_stab ) */ const int16_t last_fec, /* i : signal that previous frame was concealed with fec_alg*/ -#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING - const int16_t element_mode, /* i : element_mode req to handle EVS_MONO specific BE path */ -#endif - float *alpha, /* o : Magnitude modification factors for fade to average */ - float *beta, /* o : Magnitude modification factors for fade to average */ - float *beta_mute, /* o : Factor for long-term mute */ - float Xavg[LGW_MAX] /* o : Frequency group average gain to fade to */ + const int16_t element_mode, /* i : element_mode req to handle EVS_MONO specific BE path*/ + float *alpha, /* o : Magnitude modification factors for fade to average */ + float *beta, /* o : Magnitude modification factors for fade to average */ + float *beta_mute, /* o : Factor for long-term mute */ + float Xavg[LGW_MAX] /* o : Frequency group average gain to fade to */ ) { const float *w_hamm; @@ -419,7 +417,7 @@ static void trans_ana( { mag_chg[k] = 0; } -#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING + if ( element_mode != EVS_MONO ) { if ( k == 0 && burst_len > BETA_MUTE_THR ) /* beta_mute final long term attenuation adjusted only once per frame in the first sub-band, Ref Eq(184) in 26.447 */ @@ -434,12 +432,7 @@ static void trans_ana( *beta_mute *= BETA_MUTE_FAC; } } -#else - if ( burst_len > BETA_MUTE_THR ) - { - *beta_mute *= BETA_MUTE_FAC; - } -#endif + alpha[k] = mag_chg[k]; beta[k] = (float) ( sqrt( 1.0f - SQR( alpha[k] ) ) * *beta_mute ); if ( k >= LGW32k - 1 ) @@ -2114,11 +2107,7 @@ static void hq_phase_ecu( *time_offs = 0; /* IVAS reset of offset time counter, timeoffset variable later also used to calculate burst length */ } -#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING trans_ana( prevsynth + 2 * output_frame - Lprot - *time_offs + ph_ecu_lookahead, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, *last_fec, element_mode, alpha, beta, beta_mute, Xavg ); -#else - trans_ana( prevsynth + 2 * output_frame - Lprot - *time_offs + ph_ecu_lookahead, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, *last_fec, alpha, beta, beta_mute, Xavg ); -#endif spec_ana( prevsynth + 2 * output_frame - Lprot - *time_offs + ph_ecu_lookahead, plocs, plocsi, num_p, X_sav, output_frame, bwidth, element_mode, &noise_fac, pcorr ); if ( prev_bfi && *last_fec ) @@ -2146,11 +2135,7 @@ static void hq_phase_ecu( *time_offs = (int16_t) INT16_MAX; /* high value --> continued muting will ensure that the now saturated seed is not creating tones */ } -#ifdef NONBE_FIX_1180_HQMDCT_PHECU_LT_MUTING trans_ana( prevsynth + 2 * output_frame - Lprot, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, 0, element_mode, alpha, beta, beta_mute, Xavg ); /* 1.0 stable-music, 0.0 speech-like */ -#else - trans_ana( prevsynth + 2 * output_frame - Lprot, mag_chg, &ph_dith, mag_chg_1st, output_frame, *time_offs, env_stab, 0, alpha, beta, beta_mute, Xavg ); /* 1.0 stable-music, 0.0 speech-like */ -#endif } mvr2r( X_sav, X, Lprot ); diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index af0fb30bee63399f87c557f649f091a1a0ffd35f..6445970f2a9309bce07356f9ef270e1d315b7668 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -553,13 +553,10 @@ ivas_error core_switching_pre_dec( *---------------------------------------------------------------------*/ ivas_error core_switching_post_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *synth, /* i/o: output synthesis */ - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ -#ifndef SIMPLIFY_IVAS_CORE - const IVAS_FORMAT ivas_format, /* i : IVAS format */ -#endif + Decoder_State *st, /* i/o: decoder state structure */ + float *synth, /* i/o: output synthesis */ + float *output, /* i/o: LB synth/upsampled LB synth */ + float output_mem[], /* i : OLA memory from last TCX/HQ frame */ const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ const int16_t core_switching_flag, /* i : ACELP->HQ switching flag */ @@ -681,11 +678,7 @@ ivas_error core_switching_post_dec( synth[i + delay_comp] = ( synth[i + delay_comp] * i + ( tmpDelta - i ) * st->previoussynth[i + delay_comp] ) / tmpDelta; } -#ifdef SIMPLIFY_IVAS_CORE if ( ( st->element_mode == IVAS_CPE_MDCT || ( st->is_ism_format && st->core == TCX_20_CORE /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40 ) -#else - if ( ( st->element_mode == IVAS_CPE_MDCT || ( ivas_format == ISM_FORMAT && st->core == TCX_20_CORE /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40 ) -#endif { /* smooth transitions to avoid pops in car noise items */ smoothTransitionDtxToTcx( synth, output_frame, delay_comp ); diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index b520c6a592154e24b76c10d0f1bc2c17a50c9562..c5bbddd0606e6859fa229a291c38db4fd2a67cb3 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -274,11 +274,7 @@ ivas_error evs_dec( * Postprocessing for ACELP/MDCT core switching *---------------------------------------------------------------------*/ -#ifdef SIMPLIFY_IVAS_CORE if ( ( error = core_switching_post_dec( st, synth, NULL, NULL, 0, output_frame, core_switching_flag, 0, -1, EVS_MONO ) ) != IVAS_ERR_OK ) -#else - if ( ( error = core_switching_post_dec( st, synth, NULL, NULL, 0, MONO_FORMAT, output_frame, core_switching_flag, 0, -1, EVS_MONO ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/hq_lr_dec.c b/lib_dec/hq_lr_dec.c index b2389c53e698b09a6b255b92ed5b5510613c126a..ccb840404f9e58408cf21593892029e5ae5bfa31 100644 --- a/lib_dec/hq_lr_dec.c +++ b/lib_dec/hq_lr_dec.c @@ -635,10 +635,30 @@ void hq_lr_dec( IF( sub( i, highband ) >= 0 ) { +#ifdef NONBE_1118_EVS_LR_HQ_BITERROR + /* safety check in case of bit errors */ + if ( Ep_fx[i] > 536788991 /* max(Q30) */ ) + { + st->BER_detect = 1; + set_f( yout, 0, inner_frame ); + return; + } + +#endif enerH_fx = L_add( enerH_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ } ELSE IF( sub( i, lowband ) >= 0 ) { +#ifdef NONBE_1118_EVS_LR_HQ_BITERROR + /* safety check in case of bit errors */ + if ( Ep_fx[i] > 536788991 /* max(Q30) */ ) + { + st->BER_detect = 1; + set_f( yout, 0, inner_frame ); + return; + } + +#endif enerL_fx = L_add( enerL_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ } } diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 2e46b11dfe54c5f6d73f2e32562e591d04d3c8c3..eb961c38dcd7b54608520c7a3684fa5948502c73 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -70,9 +70,7 @@ ivas_error ivas_core_dec( Decoder_State **sts, *st; STEREO_ICBWE_DEC_HANDLE hStereoICBWE; STEREO_TD_DEC_DATA_HANDLE hStereoTD; -#ifdef SIMPLIFY_IVAS_CORE STEREO_CNG_DEC_HANDLE hStereoCng; -#endif int16_t sharpFlag[CPE_CHANNELS]; float synth[CPE_CHANNELS][L_FRAME48k]; float tmp_buffer[L_FRAME48k]; @@ -118,9 +116,7 @@ ivas_error ivas_core_dec( last_element_brate = hSCE->last_element_brate; /* note: this parameter is unused */ last_element_mode = IVAS_SCE; hStereoTD = NULL; -#ifdef SIMPLIFY_IVAS_CORE hStereoCng = NULL; -#endif p_output_mem = NULL; nchan_out = 1; if ( st_ivas != NULL && st_ivas->ivas_format == ISM_FORMAT ) @@ -139,9 +135,7 @@ ivas_error ivas_core_dec( last_element_mode = hCPE->last_element_mode; hStereoICBWE = hCPE->hStereoICBWE; hStereoTD = hCPE->hStereoTD; -#ifdef SIMPLIFY_IVAS_CORE hStereoCng = hCPE->hStereoCng; -#endif p_output_mem = hCPE->output_mem[1]; nchan_out = hCPE->nchan_out; @@ -235,11 +229,7 @@ ivas_error ivas_core_dec( } /* n_channels loop */ /* MDCT stereo -> DFT stereo switching */ -#ifdef SIMPLIFY_IVAS_CORE if ( last_element_mode == IVAS_CPE_MDCT && sts[0]->element_mode == IVAS_CPE_DFT ) -#else - if ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_MDCT && hCPE->element_mode == IVAS_CPE_DFT ) -#endif { int16_t ovl, fade_len; if ( sts[0]->L_frame != sts[0]->last_L_frame ) @@ -256,17 +246,10 @@ ivas_error ivas_core_dec( } } -#ifdef SIMPLIFY_IVAS_CORE if ( hStereoCng != NULL ) { hStereoCng->flag_cna_fade = 0; } -#else - if ( hCPE != NULL && hCPE->hStereoCng != NULL ) - { - hCPE->hStereoCng->flag_cna_fade = 0; - } -#endif save_hb_synth = NULL; if ( sba_dirac_stereo_flag && hSCE && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) @@ -296,11 +279,7 @@ ivas_error ivas_core_dec( if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { -#ifdef SIMPLIFY_IVAS_CORE ivas_combined_format_brate_sanity( element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); -#else - ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); -#endif } /*------------------------------------------------------------------* @@ -369,11 +348,7 @@ ivas_error ivas_core_dec( if ( st->core == ACELP_CORE ) { /* ACELP core decoder */ -#ifdef SIMPLIFY_IVAS_CORE if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) -#else - if ( ( error = acelp_core_dec( st, output[n], synth[n], save_hb_synth, bwe_exc_extended[n], voice_factors[n], old_syn_12k8_16k[n], sharpFlag[n], pitch_buf[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh, tdm_lsfQ_PCh, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hCPE == NULL ? NULL : hCPE->hStereoCng, read_sid_info ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -445,17 +420,10 @@ ivas_error ivas_core_dec( * Stereo CNG updates *---------------------------------------------------------------------*/ -#ifdef SIMPLIFY_IVAS_CORE if ( sts[0]->element_mode == IVAS_CPE_TD && hStereoCng != NULL ) { stereo_cng_compute_PScorr( output, &hStereoCng->c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); } -#else - if ( sts[0]->element_mode == IVAS_CPE_TD && hCPE->hStereoCng != NULL ) - { - stereo_cng_compute_PScorr( output, &hCPE->hStereoCng->c_PS_LT, sts[0]->L_frame, sts[1]->L_frame ); - } -#endif /*---------------------------------------------------------------------* * Postprocessing, BWEs and updates @@ -494,11 +462,7 @@ ivas_error ivas_core_dec( mvr2r( synth[n], hSCE->save_synth, output_frame ); } -#ifdef SIMPLIFY_IVAS_CORE if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -510,11 +474,7 @@ ivas_error ivas_core_dec( } /* if we transition from inactive to active coding in MDCT-Stereo DTX and the output format is mono DMX, we need to sync the upsampled buffer between channels here */ -#ifdef SIMPLIFY_IVAS_CORE if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || last_element_mode == IVAS_CPE_DFT ) ) -#else - if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_DFT ) ) ) -#endif { mvr2r( sts[0]->previoussynth, sts[1]->previoussynth, st->hTcxDec->L_frameTCX ); } @@ -689,11 +649,7 @@ ivas_error ivas_core_dec( mvr2r( tmp_buffer, st->hb_prev_synth_buffer, tmps ); } -#ifdef SIMPLIFY_IVAS_CORE if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( st->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) -#else - if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) -#endif { /* Delay hb_synth */ delay_signal( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); @@ -746,11 +702,7 @@ ivas_error ivas_core_dec( } else /* IVAS_CPE_DFT */ { -#ifdef SIMPLIFY_IVAS_CORE if ( last_element_mode == IVAS_CPE_MDCT ) -#else - if ( hCPE->last_element_mode == IVAS_CPE_MDCT ) -#endif { stereo_mdct2dft_update( hCPE, output[0], synth[0] ); } diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 59be959bd6f8004d015fdc8f3cc7ed26da421836..dea4a372110ab591c868549e88e0eba7b6e734d1 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -77,9 +77,7 @@ ivas_error ivas_cpe_dec( float res_buf[STEREO_DFT_N_8k]; CPE_DEC_HANDLE hCPE; Decoder_State **sts; -#ifdef SIMPLIFY_IVAS_CORE STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; -#endif int32_t ivas_total_brate; ivas_error error; int32_t cpe_brate; @@ -119,14 +117,12 @@ ivas_error ivas_cpe_dec( return error; } -#ifdef SIMPLIFY_IVAS_CORE hConfigDft = NULL; - IF( hCPE->hStereoDft != NULL ) + if ( hCPE->hStereoDft != NULL ) { hConfigDft = hCPE->hStereoDft->hConfig; } -#endif /*------------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -183,19 +179,11 @@ ivas_error ivas_cpe_dec( { if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } else { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } else @@ -203,19 +191,11 @@ ivas_error ivas_cpe_dec( /* Note: This only works for stereo operation. If DTX would be applied for multiple CPEs a different bitrate signaling is needed */ if ( ivas_total_brate <= IVAS_SID_5k2 ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } else { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } } @@ -442,11 +422,7 @@ ivas_error ivas_cpe_dec( * Core Decoder *----------------------------------------------------------------*/ -#ifdef SIMPLIFY_IVAS_CORE if ( hCPE->element_mode != IVAS_CPE_DFT || ( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) -#else - if ( hCPE->element_mode != IVAS_CPE_DFT || ( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) -#endif { if ( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) { @@ -465,11 +441,7 @@ ivas_error ivas_cpe_dec( * Stereo decoder & upmixing *----------------------------------------------------------------*/ -#ifdef SIMPLIFY_IVAS_CORE if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) -#else - if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) ) -#endif { float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 74ea4a34b8efb8c6418870932c36436d71f91531..aac6720870adeffc57f7256c376e544e8dfb385b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2126,6 +2126,7 @@ ivas_error ivas_init_decoder( return error; } } +#ifndef NONBE_1303_REND_GRANULARITY granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -2134,6 +2135,7 @@ ivas_error ivas_init_decoder( { return error; } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -2166,6 +2168,7 @@ ivas_error ivas_init_decoder( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; +#ifndef NONBE_1303_REND_GRANULARITY if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { @@ -2189,6 +2192,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif } if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -2203,7 +2207,7 @@ ivas_error ivas_init_decoder( if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -2382,12 +2386,18 @@ ivas_error ivas_init_decoder( *-----------------------------------------------------------------*/ if ( st_ivas->hTcBuffer == NULL ) - { /* no module has yet open the TC buffer, open a default one */ +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), output_Fs ); + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) +#else n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 0438755a31f1aa7e7b7f0e00118af8da5573b71b..e7c793caf3b12202f04b08b34f54f605491ebd19 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -122,6 +122,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } +#ifndef NONBE_1303_REND_GRANULARITY /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); @@ -138,7 +139,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } } - +#endif if ( st_ivas->ism_mode != last_ism_mode ) { /* EFAP handle */ @@ -306,7 +307,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; - +#ifdef NONBE_1303_REND_GRANULARITY + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index df1be1d5b1bb3a8a83cbc8f357960e9b281e8a19..93202b94cf4be011f19d3dce226026341ba3ad90 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -403,7 +403,11 @@ ivas_error ivas_param_ism_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef NONBE_1303_REND_GRANULARITY + int16_t i, granularity; +#else int16_t i; +#endif PARAM_ISM_DEC_HANDLE hParamIsmDec; IVAS_OUTPUT_SETUP hOutSetup; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -539,6 +543,9 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hParamIsmDec = hParamIsmDec; st_ivas->hSpatParamRendCom = hSpatParamRendCom; +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); +#endif if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) { @@ -578,7 +585,11 @@ ivas_error ivas_param_ism_dec_open( if ( st_ivas->hTcBuffer == NULL ) { +#ifdef NONBE_1303_REND_GRANULARITY + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -591,7 +602,11 @@ ivas_error ivas_param_ism_dec_open( if ( st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; +#ifdef NONBE_1303_REND_GRANULARITY + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 648f6a10608c3daa120a5b5949cfb4d5b1997303..4d381bc980151e80faa7d864389d1cb45aef3fd1 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -66,8 +66,12 @@ static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( +#ifdef LIB_DEC_REVISION + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#else Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *data /* o : transport channel signals */ +#endif ) { int16_t n, output_frame, nchan_out; @@ -727,11 +731,16 @@ ivas_error ivas_jbm_dec_tc( * Write IVAS transport channels *----------------------------------------------------------------*/ +#ifdef LIB_DEC_REVISION + if ( st_ivas->hDecoderConfig->Opt_tsm == 0 ) +#else if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) { + ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); } else +#endif { /* directly copy to tc buffers */ ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, output_frame ); @@ -1533,45 +1542,33 @@ ivas_error ivas_jbm_dec_flush_renderer( } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN if ( ism_mode_old == ISM_SBA_MODE_DISC ) { -#endif float *tc_local[MAX_TRANSPORT_CHANNELS]; int16_t last_spar_md_idx; int16_t last_dirac_md_idx; uint16_t nSamplesAvailableNext; -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN ISM_MODE ism_mode_orig; RENDERER_TYPE renderer_type_orig; int32_t ivas_total_brate; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; renderer_type_orig = st_ivas->renderer_type; ism_mode_orig = st_ivas->ism_mode; st_ivas->ism_mode = ism_mode_old; st_ivas->renderer_type = renderer_type_old; st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; -#endif last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN #ifdef DEBUGGING assert( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); #endif -#else -#ifdef DEBUGGING - assert( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); -#endif -#endif + /* copy from ISM delay buffer to the correct place in tcs */ for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx][hTcBuffer->n_samples_rendered]; -#else - tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; -#endif mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); } @@ -1596,17 +1593,17 @@ ivas_error ivas_jbm_dec_flush_renderer( { return error; } -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN + st_ivas->ism_mode = ism_mode_orig; st_ivas->renderer_type = renderer_type_orig; st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; } -#endif } else { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); } + hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; } @@ -2091,6 +2088,31 @@ static void ivas_jbm_dec_copy_tc( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( +#ifdef NONBE_1303_REND_GRANULARITY + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ + const int32_t output_Fs /* i : sampling rate */ +) +{ + int16_t render_granularity; + + if ( renderer_type == RENDERER_BINAURAL_OBJECTS_TD || /* TD renderer */ + renderer_type == RENDERER_BINAURAL_MIXER_CONV || renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM || /* Crend */ + renderer_type_sec == RENDERER_BINAURAL_OBJECTS_TD /* TD rend as a secondary renderer -> set the common granularity for both renderers */ + ) + { + /* 5 ms granularity */ + render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + } + else + { + /* 1.25 ms granularity */ + render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); + } + + return render_granularity; +} +#else const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ @@ -2117,6 +2139,7 @@ int16_t ivas_jbm_dec_get_render_granularity( return render_granularity; } +#endif /*--------------------------------------------------------------------------* @@ -2862,6 +2885,13 @@ void ivas_dec_prepare_renderer( { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + /* MASA transport gaining for edited disc OMASA EXT. For ISMs, only metadata is modified */ + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 ) + { + ivas_omasa_gain_masa_tc( st_ivas->hTcBuffer->tc, st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->nchan_ism, st_ivas->hTcBuffer->n_samples_available ); + } +#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { @@ -2937,6 +2967,16 @@ void ivas_dec_prepare_renderer( { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + /* MASA transport gaining for edited param_one OMASA EXT. For ISMs, only metadata is modified. */ + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 ) + { + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + v_multc( st_ivas->hTcBuffer->tc[n], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available ); + } + } +#endif } else { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 48c6f455718cf29ae43dd9ffdceb831e28e3cc58..62e711718a6791a1936b064fc67314703101e66c 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -696,6 +696,9 @@ ivas_error ivas_masa_dec_open( if ( st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { int16_t nchan_to_allocate, nchan_transport; +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity; +#endif TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; @@ -727,7 +730,13 @@ ivas_error ivas_masa_dec_open( nchan_to_allocate++; } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1474,7 +1483,11 @@ ivas_error ivas_masa_dec_reconfigure( TC_BUFFER_MODE buffer_mode_new; int16_t n_samples_granularity; +#ifdef NONBE_1303_REND_GRANULARITY + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); +#else n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); +#endif buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -1489,9 +1502,11 @@ ivas_error ivas_masa_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } +#ifndef NONBE_1303_REND_GRANULARITY if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ + if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) @@ -1507,6 +1522,7 @@ ivas_error ivas_masa_dec_reconfigure( /* flush already done in IVAS_DEC_ReadFormat() */ } } +#endif } else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index e97adc27d1b5bf41b8bcae7fea8f723f0d39c078..048f26e3793a5c1faf855fc2717e2339acfaa2eb 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -437,6 +437,9 @@ ivas_error ivas_param_mc_dec_open( if ( hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) { int16_t n_cldfb_slots; +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity; +#endif n_cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; if ( st_ivas->hDecoderConfig->Opt_tsm ) @@ -457,7 +460,13 @@ ivas_error ivas_param_mc_dec_open( if ( st_ivas->hTcBuffer == NULL ) { +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 26a5124783e4fea8c45a2a06bd22006080e12d87..81bd4023a4042ed86b75f0dfc67e49ec93243a91 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -374,6 +374,9 @@ ivas_error ivas_mc_paramupmix_dec_open( { int16_t nchan_to_allocate; int16_t nchan_tc; +#ifdef NONBE_1303_REND_GRANULARITY + int16_t granularity; +#endif TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; @@ -391,7 +394,13 @@ ivas_error ivas_mc_paramupmix_dec_open( nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 164a245eaa14315eba30633741fe98e15e0fea72..4c2ace3908d87e207b260bd1605d7d72f12daf99 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -260,11 +260,7 @@ ivas_error ivas_mct_dec( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ -#ifdef SIMPLIFY_IVAS_CORE if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -793,9 +789,11 @@ static ivas_error ivas_mc_dec_reconfig( } } +#ifndef NONBE_1303_REND_GRANULARITY /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { /* flush already done in IVAS_DEC_ReadFormat() */ @@ -808,7 +806,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } - +#endif if ( st_ivas->mc_mode == MC_MODE_MCT ) { st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) ); @@ -1295,6 +1293,9 @@ static ivas_error ivas_mc_dec_reconfig( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; +#ifdef NONBE_1303_REND_GRANULARITY + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index d20c793304375637482876b13bec1ea478696f82..597480b8eacb3f164ec4f752e9a97999113d0c03 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -61,9 +61,13 @@ ivas_error ivas_td_binaural_open( num_src = st_ivas->nchan_ism; } +#ifdef NONBE_1303_REND_GRANULARITY + if ( st_ivas->hHrtfTD == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary ) +#else if ( st_ivas->hHrtfTD == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary && ( st_ivas->ivas_format != SBA_ISM_FORMAT ) // ToDo: temporary hack to avoid ASAN errors -> see issue #1202 ) +#endif { return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in TD renderer" ); } @@ -181,7 +185,11 @@ ivas_error ivas_td_binaural_renderer_sf( if ( subframe_idx == ism_md_subframe_update_jbm ) { +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#endif { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; @@ -194,7 +202,19 @@ ivas_error ivas_td_binaural_renderer_sf( ismMetaData[nS].yaw = st_ivas->hIsmMetaData[nS]->edited_yaw; ismMetaData[nS].pitch = st_ivas->hIsmMetaData[nS]->edited_pitch; ismMetaData[nS].non_diegetic_flag = st_ivas->hIsmMetaData[nS]->non_diegetic_flag; +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + /* DISC OMASA ISM gaining with TDREND is done in ivas_dec_prepare_renderer()*/ + ismMetaData[nS].gain = 1; + } + else + { + ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; + } +#else ismMetaData[nS].gain = st_ivas->hIsmMetaData[nS]->edited_gain; +#endif hIsmMetaData[nS] = &ismMetaData[nS]; } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 497233122c18d6ca348482825ecfe08b4e6cdef3..b468df043993c4d2c19114735ca1808b1a0ab95b 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -1321,3 +1321,28 @@ void ivas_omasa_render_objects_from_mix( return; } + +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT +/*--------------------------------------------------------------------------* + * ivas_omasa_gain_masa_tc() + * + * in case of external rendering with object editing, MASA transport channels + * need to be gained + *--------------------------------------------------------------------------*/ + +void ivas_omasa_gain_masa_tc( + float *output[], /* i/o : output synthesis signal */ + const float gainMasa, /* i : gain */ + const int16_t nchan_transport_ism, /* i : number of ISM TCs */ + const int16_t output_frame /* i : output frame length per channel */ +) +{ + /* Edited OMASA EXT MASA transport gaining */ + for ( int16_t ch = 0; ch < 2; ch++ ) + { + v_multc( output[nchan_transport_ism + ch], gainMasa, output[nchan_transport_ism + ch], output_frame ); + } + + return; +} +#endif diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index ac06064065adf793661d74449a5524a64fac188f..305d99ef994f9720defb93e4d00454a5223658ff 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -479,3 +479,36 @@ void ivas_renderer_select( return; } + + +#ifdef NONBE_1303_REND_GRANULARITY +/*-------------------------------------------------------------------------* + * ivas_renderer_secondary_select() + * + * Select IVAS secondary binaural renderer (used in combine formats) + *-------------------------------------------------------------------------*/ + +/*! r: secondary binaural renderer type */ +RENDERER_TYPE ivas_renderer_secondary_select( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + RENDERER_TYPE renderer_type; + AUDIO_CONFIG output_config; + + /* disabled by default */ + renderer_type = RENDERER_DISABLE; + output_config = st_ivas->hDecoderConfig->output_config; + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_BINAURAL ) + { + renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + } + + return renderer_type; +} +#endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 4bb13325b20bbaa5125e582abb59385038a46f54..2164e490d425e88a6226aa426ed73318a339baa5 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -163,6 +163,7 @@ ivas_error ivas_sba_dec_reconfigure( /* we may need to flush only for binaural and OSBA and TSM */ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifndef NONBE_1303_REND_GRANULARITY RENDERER_TYPE renderer_type_new; int16_t sba_order_internal; @@ -183,11 +184,7 @@ ivas_error ivas_sba_dec_reconfigure( } else { -#ifdef NONBE_1303_GRANULARITY_OSBA_REND if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#else - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif { renderer_type_new = RENDERER_BINAURAL_FASTCONV; } @@ -197,7 +194,11 @@ ivas_error ivas_sba_dec_reconfigure( } } +#endif /* determine new granularity */ +#ifdef NONBE_1303_REND_GRANULARITY + granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); +#else granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /* this will change anyway only with binaural */ @@ -205,7 +206,19 @@ ivas_error ivas_sba_dec_reconfigure( { granularity_new *= JBM_CLDFB_SLOTS_IN_SUBFRAME; } +#endif +#ifdef NONBE_1303_REND_GRANULARITY + if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + { + /* make sure the changed number of slots in the last subframe is not lost in the following steps */ + if ( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + } + st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + } +#else /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { @@ -225,6 +238,7 @@ ivas_error ivas_sba_dec_reconfigure( } st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; } +#endif } /* save old */ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index e984b9251c4485b22093acaefd410df653c7e726..205bc77859b29600c31d51af54718c96006e863c 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -228,8 +228,10 @@ ivas_error ivas_spar_dec_open( nchan_to_allocate += st_ivas->nchan_ism; } +#ifndef NONBE_1303_REND_GRANULARITY granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); +#endif if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) ) { if ( ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) @@ -249,6 +251,11 @@ ivas_error ivas_spar_dec_open( nchan_to_allocate = 2 * BINAURAL_CHANNELS; } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), output_Fs ); + + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -258,6 +265,7 @@ ivas_error ivas_spar_dec_open( } if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index a831a74d23f6409a177b94a675025812e25a7cc5..a0565824af3b9e04a3837f163d527a58015f685f 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1141,11 +1141,7 @@ void synchro_synthesis( /* handling of TD->DFT switching */ for ( n = 0; n < hCPE->nchan_out; n++ ) { -#ifdef NONBE_1289_STEREO_SW_TO_MONO if ( ( !use_cldfb_for_last_dft && hCPE->last_element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag && dft_mono_brate_switch != -1 ) || dft_mono_brate_switch == 1 ) -#else - if ( ( hCPE->last_element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag && dft_mono_brate_switch != -1 ) || dft_mono_brate_switch == 1 ) -#endif { float *pPrev_synth; float inv_fade_len = 1.f / delay_diff; diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index ad3ba459a6c4f5209525ae9de41398cb13465765..6f6844f3abf46110fcd2e84bf0cfe6639a4ce799 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -683,7 +683,6 @@ static void JB4_targetPlayoutDelay( *targetStartUp = ( *targetMin + *targetMax ) / 2; } -#ifdef NONBE_1122_JBM_FIX_PLAYOUT_DELAY_IN_DTX #ifdef NONBE_1122_KEEP_EVS_MODE_UNCHANGED if ( !h->evsMode ) { @@ -693,12 +692,6 @@ static void JB4_targetPlayoutDelay( } #endif *targetStartUp = JB4_MAX( *targetStartUp, (uint32_t) h->safetyMargin ); -#else - if ( *targetStartUp < 60 ) - { - *targetStartUp = 60; - } -#endif return; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 70036f9465e4ab4a661fa562d48030d49b35798f..37b50287ad714e62d7754339bf05a4a26dacc877 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -55,7 +55,9 @@ struct IVAS_DEC_VOIP { +#ifndef LIB_DEC_REVISION uint16_t nSamplesFrame; /* Total number of samples in a frame (includes number of channels) */ +#endif JB4_HANDLE hJBM; uint16_t lastDecodedWasActive; JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ @@ -79,8 +81,10 @@ struct IVAS_DEC bool isInitialized; int16_t bitstreamformat; /* Bitstream format flag (G.192/MIME/VOIP_G192_RTP/VOIP_RTPDUMP) */ - bool Opt_VOIP; /* flag indicating VOIP mode with JBM */ - int16_t tsm_scale; /* scale for TSM operation */ +#ifdef DEBUGGING + bool Opt_VOIP; /* flag indicating VOIP mode with JBM */ +#endif + int16_t tsm_scale; /* scale for TSM operation */ int16_t tsm_max_scaling; int16_t timeScalingDone; /* have we done already one TSM in a 20ms frame? */ float tsm_quality; @@ -90,7 +94,9 @@ struct IVAS_DEC bool hasBeenFedFrame; bool updateOrientation; uint16_t nSamplesAvailableNext; +#ifndef LIB_DEC_REVISION int16_t nSamplesRendered; +#endif int16_t nTransportChannelsOld; int16_t amrwb_rfc4867_flag; /* MIME from rfc4867 is used */ int16_t sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ @@ -108,19 +114,32 @@ struct IVAS_DEC * Local function declarations *---------------------------------------------------------------------*/ +#ifdef LIB_DEC_REVISION +static void ivas_destroy_handle_VoIP( IVAS_DEC_VOIP *hVoIP ); +#else static void IVAS_DEC_Close_VoIP( IVAS_DEC_VOIP *hVoIP ); +#endif #ifdef SUPPORT_JBM_TRACEFILE static void store_JbmData( IVAS_DEC_VOIP *hVoIP, JB4_DATAUNIT_HANDLE dataUnit, const uint32_t systemTimestamp_ms, const uint16_t extBufferedSamples, const int32_t output_Fs ); #endif +#ifdef LIB_DEC_REVISION +static ivas_error evs_dec_main( Decoder_Struct *st_ivas ); +#else static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf, int16_t *pcmBuf ); +#endif static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, int16_t *bitstream_format_internal, int16_t *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); +#ifdef LIB_DEC_REVISION +static ivas_error ivas_dec_setup_all( IVAS_DEC_HANDLE hIvasDec, uint8_t *nTransportChannels, const int16_t isSplitRend, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +static ivas_error apa_setup( IVAS_DEC_HANDLE hIvasDec, const bool isInitialized_voip, const uint16_t nTransportChannels ); +#else static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels ); static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); +#endif static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType ); static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); @@ -132,6 +151,7 @@ static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplit static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesRendered ); + /*---------------------------------------------------------------------* * IVAS_DEC_Open() * @@ -171,7 +191,9 @@ ivas_error IVAS_DEC_Open( hIvasDec->needNewFrame = false; hIvasDec->nTransportChannelsOld = 0; hIvasDec->nSamplesAvailableNext = 0; +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesRendered = 0; +#endif hIvasDec->nSamplesFrame = 0; hIvasDec->hasBeenFedFrame = false; hIvasDec->hasBeenFedFirstGoodFrame = false; @@ -186,7 +208,9 @@ ivas_error IVAS_DEC_Open( hIvasDec->mode = mode; hIvasDec->bitstreamformat = G192; +#ifdef DEBUGGING hIvasDec->Opt_VOIP = 0; +#endif hIvasDec->amrwb_rfc4867_flag = -1; hIvasDec->prev_ft_speech = 1; /* RXDTX handler previous frametype flag for G.192 format AMRWB SID_FIRST detection */ hIvasDec->CNG = 0; /* RXDTX handler CNG = 1, no CNG = 0*/ @@ -322,7 +346,7 @@ static void init_decoder_config( /*---------------------------------------------------------------------* * IVAS_DEC_Close( ) * - * + * Deallocate IVAS decoder memory handles *---------------------------------------------------------------------*/ void IVAS_DEC_Close( @@ -337,7 +361,11 @@ void IVAS_DEC_Close( if ( ( *phIvasDec )->hVoIP ) { +#ifdef LIB_DEC_REVISION + ivas_destroy_handle_VoIP( ( *phIvasDec )->hVoIP ); +#else IVAS_DEC_Close_VoIP( ( *phIvasDec )->hVoIP ); +#endif ( *phIvasDec )->hVoIP = NULL; } @@ -404,19 +432,47 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( return IVAS_DEC_BS_UNKOWN; } +#ifdef LIB_DEC_REVISION + +/*---------------------------------------------------------------------* + * create_flush_buffer() + * + * Create flush buffer - needed for binaural outputs with TSM or in VoIP mode + *---------------------------------------------------------------------*/ + +static ivas_error create_flush_buffer( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); + if ( hIvasDec->flushbuffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate JBM flush buffer" ); + } + + hIvasDec->pcmType = IVAS_DEC_PCM_INT16; + set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + + return IVAS_ERR_OK; +} + +#endif + /*---------------------------------------------------------------------* * IVAS_DEC_Configure( ) * * Decoder configuration - * legacy code behavior: if no output format set, then it's EVS mono + * legacy behavior: if no output format set, then it's EVS mono *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Configure( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const uint32_t sampleRate, /* i : output sampling frequency */ - const AUDIO_CONFIG outputConfig, /* i : output configuration */ - const bool tsmEnabled, /* i : enable TSM */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const uint32_t sampleRate, /* i : output sampling frequency */ + const AUDIO_CONFIG outputConfig, /* i : output configuration */ +#ifndef LIB_DEC_REVISION + const bool tsmEnabled, /* i : enable TSM */ +#endif const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ @@ -475,7 +531,9 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); } +#ifndef LIB_DEC_REVISION hDecoderConfig->Opt_tsm = (int16_t) tsmEnabled; +#endif hDecoderConfig->Opt_LsCustom = (int16_t) customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = (int16_t) enableHeadRotation; hDecoderConfig->orientation_tracking = orientation_tracking; @@ -523,13 +581,14 @@ ivas_error IVAS_DEC_Configure( } hIvasDec->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesAvailableNext = 0; hIvasDec->nSamplesRendered = 0; hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; - /* init flush buffer if necessary (only needed for binaural)*/ + /* Init flush buffer if necessary (only needed for binaural)*/ if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); @@ -540,6 +599,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } +#endif return IVAS_ERR_OK; } @@ -548,7 +608,7 @@ ivas_error IVAS_DEC_Configure( /*---------------------------------------------------------------------* * IVAS_DEC_EnableSplitRendering( ) * - * Intitialize Split rendering + * Update IVAS decoder config. if Split rendering is enabled *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_EnableSplitRendering( @@ -574,7 +634,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( /*---------------------------------------------------------------------* * get_render_framesize_ms( ) * - * Get the 5ms flag + * Get render framesize in ms *---------------------------------------------------------------------*/ static int16_t get_render_frame_size_ms( @@ -587,7 +647,7 @@ static int16_t get_render_frame_size_ms( /*---------------------------------------------------------------------* * IVAS_DEC_SetRenderFramesize( ) * - * Get the 5ms flag + * Set render framesize *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_SetRenderFramesize( @@ -606,6 +666,7 @@ ivas_error IVAS_DEC_SetRenderFramesize( { hIvasDec->st_ivas->hExtOrientationData->num_subframes = (int16_t) render_framesize; } + if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) { hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (int16_t) render_framesize; @@ -618,7 +679,7 @@ ivas_error IVAS_DEC_SetRenderFramesize( /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesize( ) * - * Get the 5ms flag + * Get render framesize *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetRenderFramesize( @@ -678,6 +739,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeMs( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetReferencesUpdateFrequency( ) * @@ -702,7 +764,7 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency( /*---------------------------------------------------------------------* * IVAS_DEC_GetGetNumOrientationSubframes( ) * - * Get the number of subframes for head/ecernal orientation per render frame + * Get the number of subframes for head/external orientation per render frame *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetNumOrientationSubframes( @@ -745,8 +807,11 @@ ivas_error IVAS_DEC_EnableVoIP( hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; +#ifdef DEBUGGING hIvasDec->Opt_VOIP = 1; +#endif hDecoderConfig->Opt_tsm = 1; + if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) { hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); @@ -770,7 +835,9 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->lastDecodedWasActive = 0; hIvasDec->hVoIP->hCurrentDataUnit = NULL; +#ifndef LIB_DEC_REVISION hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif hIvasDec->hVoIP->nSamplesRendered20ms = 0; #define WMC_TOOL_SKIP @@ -793,6 +860,7 @@ ivas_error IVAS_DEC_EnableVoIP( { return IVAS_ERR_FAILED_ALLOC; } + #ifdef NONBE_1122_KEEP_EVS_MODE_UNCHANGED if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { @@ -800,13 +868,21 @@ ivas_error IVAS_DEC_EnableVoIP( } #endif - /* init flush buffer if necessary (only needed for binaural)*/ +#ifdef LIB_DEC_REVISION + /* init flush buffer (needed for binaural outputs) */ + if ( ( error = create_flush_buffer( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in create_flush_buffer , code: %d\n", error ); + return error; + } +#else if ( hIvasDec->flushbuffer == NULL && ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } +#endif return IVAS_ERR_OK; } @@ -896,12 +972,57 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->needNewFrame = false; hIvasDec->hasBeenFedFrame = true; +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesRendered = 0; +#endif hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; return IVAS_ERR_OK; } +#ifdef NONBE_1303_REND_GRANULARITY + +/*---------------------------------------------------------------------* + * renderer_type_to_mode() + * + * Convert (codec library) renderer type to (API public) binaural renderer mode + *---------------------------------------------------------------------*/ + +/*! r: binaural renderer mode (API type) */ +static IVAS_BIN_RENDERER_TYPE renderer_type_to_mode( + const RENDERER_TYPE renderer_type /* i : renderer type (codec library type) */ +) +{ + IVAS_BIN_RENDERER_TYPE binaural_renderer; + + switch ( renderer_type ) + { + case RENDERER_BINAURAL_OBJECTS_TD: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_TDREND; + break; + case RENDERER_BINAURAL_MIXER_CONV: + case RENDERER_BINAURAL_MIXER_CONV_ROOM: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_CREND; + break; + case RENDERER_BINAURAL_FASTCONV: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_FASTCONV; + break; + case RENDERER_BINAURAL_FASTCONV_ROOM: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_FASTCONV; + break; + case RENDERER_BINAURAL_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC_ROOM: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_PARAMBIN; + break; + default: + binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; + break; + } + + return binaural_renderer; +} + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_ReadFormat( ) @@ -925,7 +1046,11 @@ ivas_error IVAS_DEC_ReadFormat( MC_MODE mc_mode_old; int16_t nchan_transport_old; AUDIO_CONFIG intern_config_old, transport_config_old, output_config; +#ifdef NONBE_1303_REND_GRANULARITY + RENDERER_TYPE renderer_type_old, renderer_type_sec_new, renderer_type_sec_old; +#else RENDERER_TYPE renderer_type_old; +#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -940,6 +1065,9 @@ ivas_error IVAS_DEC_ReadFormat( intern_config_old = st_ivas->intern_config; transport_config_old = st_ivas->transport_config; renderer_type_old = st_ivas->renderer_type; +#ifdef NONBE_1303_REND_GRANULARITY + renderer_type_sec_old = ivas_renderer_secondary_select( st_ivas ); +#endif output_config = st_ivas->hDecoderConfig->output_config; @@ -961,8 +1089,15 @@ ivas_error IVAS_DEC_ReadFormat( return ( IVAS_ERROR( IVAS_ERR_INVALID_INPUT_FORMAT, "IVAS format switching is not allowed." ) ); } + /* Select binaural renderer */ ivas_renderer_select( st_ivas ); +#ifdef NONBE_1303_REND_GRANULARITY + *binaural_renderer = renderer_type_to_mode( st_ivas->renderer_type ); + /* Select secondary binaural renderer (used in combine formats) */ + renderer_type_sec_new = ivas_renderer_secondary_select( st_ivas ); + *binaural_renderer_sec = renderer_type_to_mode( renderer_type_sec_new ); +#else switch ( st_ivas->renderer_type ) { case RENDERER_BINAURAL_OBJECTS_TD: @@ -992,7 +1127,9 @@ ivas_error IVAS_DEC_ReadFormat( { *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND; } +#endif + /* select HRTF audio configuration to load the right HRTF set for the external binary file */ *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) { @@ -1040,20 +1177,48 @@ ivas_error IVAS_DEC_ReadFormat( } } -#ifdef NONBE_FIX_1297_SPAR_JBM_MEM_SAN +#ifdef NONBE_1303_REND_GRANULARITY + /* JBM: compensate when binaural renderer granularity changes (happens in bitrate switching) */ + if ( st_ivas->ini_active_frame > 0 && st_ivas->hDecoderConfig->Opt_tsm && + ( ( renderer_type_old != st_ivas->renderer_type ) || + ( renderer_type_sec_old != renderer_type_sec_new ) ) ) + { + int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); + + st_ivas->nchan_transport = nchan_transport_old; + + if ( st_ivas->hTcBuffer == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* when granularity goes down, render what still fits in the new granularity */ + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + } + /* when granularity goes up, discard samples at the beginning of the frame */ + else if ( tc_granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && ( ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) || ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode != ISM_SBA_MODE_DISC ) ) ) ) -#else - if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || - ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) -#endif { /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ int16_t tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); st_ivas->nchan_transport = nchan_transport_old; + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, pcm_type_API_to_internal( hIvasDec->pcmType ), hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) @@ -1061,6 +1226,7 @@ ivas_error IVAS_DEC_ReadFormat( return error; } } +#endif } } @@ -1078,7 +1244,7 @@ ivas_error IVAS_DEC_ReadFormat( /*---------------------------------------------------------------------* * IVAS_DEC_GetSamplesDecoder( ) * - * Main function to decode transport channels, do TSM and feed to renderer. + * Main function to run setup, decode transport channels, do TSM and feed to renderer. *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSamplesDecoder( @@ -1088,23 +1254,50 @@ ivas_error IVAS_DEC_GetSamplesDecoder( ) { ivas_error error; + Decoder_Struct *st_ivas; +#ifdef LIB_DEC_REVISION + uint16_t nTimeScalerOutSamples; + uint8_t nTransportChannels; + int16_t nResidualSamples, nSamplesTcsScaled; + bool isInitialized_voip; +#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - /* If TSM is generally enabled, we have to wait for the first good frame. - Otherwise, we directly decode the first frame in any case. */ - if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame && !hIvasDec->isInitialized ) /* note: 'isInitialized' is related to EVS decoder */ + { + return IVAS_ERR_OK; + } +#endif + + st_ivas = hIvasDec->st_ivas; +#ifdef LIB_DEC_REVISION + isInitialized_voip = hIvasDec->apaExecBuffer != NULL; +#endif + + if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) /* wait for the first good frame */ { +#ifdef LIB_DEC_REVISION + /*-----------------------------------------------------------------* + * Setup all decoder parts (IVAS decoder, ISAR) + *-----------------------------------------------------------------*/ + + if ( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } +#else uint16_t l_ts, nTimeScalerOutSamples; uint8_t nTransportChannels; int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; if ( isSplitRend ) { - if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + if ( ( error = isar_set_split_rend_setup( st_ivas->hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { return error; } @@ -1115,28 +1308,74 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return error; } - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) + if ( st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) { if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) { return error; } } +#endif +#ifdef LIB_DEC_REVISION + /*-----------------------------------------------------------------* + * IVAS decoder: decode transport channels and metadata + *-----------------------------------------------------------------*/ + + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) + { + if ( ( error = evs_dec_main( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( hIvasDec->mode == IVAS_DEC_MODE_IVAS ) + { + if ( ( error = ivas_jbm_dec_tc( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + hIvasDec->isInitialized = true; /* Initialization done in ivas_dec() */ + } + + if ( hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasDec->hasDecodedFirstGoodFrame = true; + } +#else /* IVAS TC decoder */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { return error; } +#endif - /* JBM */ - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + /*-----------------------------------------------------------------* + * JBM + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDecoderConfig->Opt_tsm ) { +#ifdef LIB_DEC_REVISION + if ( nTransportChannels != hIvasDec->nTransportChannelsOld ) + { + if ( ( error = apa_setup( hIvasDec, isInitialized_voip, nTransportChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#endif if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { return IVAS_ERR_UNKNOWN; } +#ifdef LIB_DEC_REVISION + ivas_syn_output_f( hIvasDec->st_ivas->p_output_f, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer ); + +#endif if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -1151,13 +1390,20 @@ ivas_error IVAS_DEC_GetSamplesDecoder( nSamplesTcsScaled = hIvasDec->nSamplesFrame; } - /* Feed decoded transport channels samples to the renderer */ + /*-----------------------------------------------------------------* + * Feed decoded transport channels samples to the renderer + *-----------------------------------------------------------------*/ + +#ifdef LIB_DEC_REVISION + ivas_jbm_dec_feed_tc_to_renderer( st_ivas, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ); +#else if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; } +#endif - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + if ( st_ivas->hDecoderConfig->Opt_tsm ) { /* feed residual samples to TSM for the next call */ if ( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) @@ -1170,15 +1416,19 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIvasDec->hasBeenPreparedRendering = false; - if ( hIvasDec->st_ivas->hIsmMetaData[0] ) + /*-----------------------------------------------------------------* + * Set editable metadata + *-----------------------------------------------------------------*/ + + if ( st_ivas->hIsmMetaData[0] ) { - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { int16_t obj; - ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + ISM_METADATA_HANDLE *hIsmMetaData = st_ivas->hIsmMetaData; + for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) { hIsmMetaData[obj]->edited_azimuth = hIsmMetaData[obj]->azimuth; hIsmMetaData[obj]->edited_elevation = hIsmMetaData[obj]->elevation; @@ -1188,21 +1438,21 @@ ivas_error IVAS_DEC_GetSamplesDecoder( hIsmMetaData[obj]->edited_gain = 1.0f; } - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; + st_ivas->hSbaIsmData->gain_bed = 1.0f; } } } } - if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) + if ( st_ivas->hParamIsmDec != NULL ) { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { int16_t obj = 0; - PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + PARAM_ISM_DEC_HANDLE hParamIsmDec = st_ivas->hParamIsmDec; + for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) { hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; @@ -1217,7 +1467,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /*---------------------------------------------------------------------* * IVAS_DEC_GetEditableParameters( ) * - * + * Get editable metadata parameters *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetEditableParameters( @@ -1234,6 +1484,15 @@ ivas_error IVAS_DEC_GetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasEditableParameters->num_obj = 0; + + return IVAS_ERR_OK; + } +#endif + st_ivas = hIvasDec->st_ivas; ism_mode = st_ivas->ism_mode; @@ -1305,7 +1564,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius = st_ivas->hIsmMetaData[obj]->radius; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; + st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; hIvasEditableParameters->ism_metadata[obj].gain = st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } @@ -1332,7 +1591,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].radius = st_ivas->hIsmMetaData[obj]->radius; /* reset the otherwise unused "gain" field for the object */ - hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; + st_ivas->hIsmMetaData[obj]->edited_gain = 1.0f; hIvasEditableParameters->ism_metadata[obj].gain = st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } @@ -1356,7 +1615,7 @@ ivas_error IVAS_DEC_GetEditableParameters( /*---------------------------------------------------------------------* * IVAS_DEC_SetEditableParameters( ) * - * Main function to decode to PCM data + * Set editable metadata parameters *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_SetEditableParameters( @@ -1373,6 +1632,13 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + st_ivas = hIvasDec->st_ivas; ism_mode = st_ivas->ism_mode; @@ -1389,14 +1655,13 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef DEBUGGING - assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); -#endif - if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) { +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; @@ -1418,6 +1683,9 @@ ivas_error IVAS_DEC_SetEditableParameters( } else if ( ism_mode == ISM_MODE_PARAM ) { +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { st_ivas->hParamIsmDec->edited_azimuth_values[obj] = hIvasEditableParameters.ism_metadata[obj].azimuth; @@ -1475,6 +1743,9 @@ ivas_error IVAS_DEC_SetEditableParameters( int16_t id_th; float threshold_azi, threshold_ele; +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { if ( st_ivas->hMasaIsmData != NULL ) @@ -1567,6 +1838,13 @@ ivas_error IVAS_DEC_SetEditableParameters( /* Copy edited values to hIsmMetaData struct */ if ( st_ivas->hIsmMetaData[obj] != NULL ) { +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; + st_ivas->hIsmMetaData[obj]->edited_elevation = hIvasEditableParameters.ism_metadata[obj].elevation; + st_ivas->hIsmMetaData[obj]->edited_yaw = hIvasEditableParameters.ism_metadata[obj].yaw; + st_ivas->hIsmMetaData[obj]->edited_pitch = hIvasEditableParameters.ism_metadata[obj].pitch; + st_ivas->hIsmMetaData[obj]->edited_radius = hIvasEditableParameters.ism_metadata[obj].radius; +#endif st_ivas->hIsmMetaData[obj]->azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; st_ivas->hIsmMetaData[obj]->elevation = hIvasEditableParameters.ism_metadata[obj].elevation; st_ivas->hIsmMetaData[obj]->yaw = hIvasEditableParameters.ism_metadata[obj].yaw; @@ -1606,7 +1884,12 @@ ivas_error IVAS_DEC_PrepareRenderer( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ivas_dec_prepare_renderer( hIvasDec->st_ivas ); +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( hIvasDec->hasBeenFedFirstGoodFrame || hIvasDec->isInitialized ) /* note: 'isInitialized' is related to EVS decoder */ +#endif + { + ivas_dec_prepare_renderer( hIvasDec->st_ivas ); + } hIvasDec->hasBeenPreparedRendering = true; @@ -1630,9 +1913,12 @@ ivas_error IVAS_DEC_GetSamplesRenderer( ) { ivas_error error; +#ifndef LIB_DEC_REVISION int16_t nSamplesToRender; +#endif uint16_t nSamplesRendered, nSamplesRendered_loop; uint8_t nOutChannels; + Decoder_Struct *st_ivas; nSamplesRendered = 0; nOutChannels = 0; @@ -1649,13 +1935,15 @@ ivas_error IVAS_DEC_GetSamplesRenderer( return IVAS_ERR_UNKNOWN; } + st_ivas = hIvasDec->st_ivas; + if ( hIvasDec->updateOrientation ) { /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ - if ( ( error = combine_external_and_head_orientations_dec( hIvasDec->st_ivas->hHeadTrackData, hIvasDec->st_ivas->hExtOrientationData, hIvasDec->st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) { return error; } @@ -1664,9 +1952,9 @@ ivas_error IVAS_DEC_GetSamplesRenderer( * Binaural split rendering setup *----------------------------------------------------------------*/ - if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL && ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( st_ivas->hCombinedOrientationData != NULL && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - isar_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat ); + isar_set_split_rend_ht_setup( &st_ivas->hSplitBinRend->splitrend, st_ivas->hCombinedOrientationData->Quaternions, st_ivas->hCombinedOrientationData->Rmat ); } hIvasDec->updateOrientation = false; @@ -1682,38 +1970,59 @@ ivas_error IVAS_DEC_GetSamplesRenderer( } /* check if we are still at the beginning with bad frames, put out zeroes, keep track of subframes */ - if ( !hIvasDec->isInitialized && hIvasDec->st_ivas->bfi ) + if ( !hIvasDec->isInitialized && st_ivas->bfi ) { hIvasDec->hasBeenFedFrame = false; - set_s( pcmBuf, 0, hIvasDec->st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); + set_s( pcmBuf, 0, st_ivas->hDecoderConfig->nchan_out * nSamplesAsked ); +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + nSamplesRendered = nSamplesAsked; +#else hIvasDec->nSamplesRendered += nSamplesAsked; *nOutSamples = nSamplesAsked; +#endif hIvasDec->nSamplesAvailableNext -= nSamplesAsked; +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST if ( hIvasDec->nSamplesAvailableNext == 0 ) { hIvasDec->needNewFrame = true; *needNewFrame = true; } +#endif } else { - nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; + nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; hIvasDec->hasBeenFedFrame = false; + /* check for possible flushed samples from a rate switch */ if ( hIvasDec->nSamplesFlushed > 0 ) { +#ifndef LIB_DEC_REVISION void *pPcmBuffer; +#endif #ifdef DEBUGGING assert( hIvasDec->pcmType == pcmType ); #endif +#ifdef LIB_DEC_REVISION + /* note: offset (rendered samples) is always 0 */ +#else pPcmBuffer = pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ); +#endif if ( pcmType == IVAS_DEC_PCM_INT16 ) { +#ifdef LIB_DEC_REVISION + mvs2s( (int16_t *) hIvasDec->flushbuffer, pcmBuf, hIvasDec->nSamplesFlushed * nOutChannels ); +#else mvs2s( (int16_t *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); +#endif } else if ( pcmType == IVAS_DEC_PCM_FLOAT ) { +#ifdef LIB_DEC_REVISION + mvr2r( (float *) hIvasDec->flushbuffer, pcmBuf, hIvasDec->nSamplesFlushed * nOutChannels ); +#else mvr2r( (float *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); +#endif } #ifdef DEBUGGING else @@ -1721,18 +2030,27 @@ ivas_error IVAS_DEC_GetSamplesRenderer( assert( 0 && "wrong PCM type for the flush buffer!" ); } #endif +#ifdef LIB_DEC_REVISION + nSamplesRendered = hIvasDec->nSamplesFlushed; +#else nSamplesRendered += hIvasDec->nSamplesFlushed; +#endif hIvasDec->nSamplesFlushed = 0; } /* render IVAS frames directly to the output buffer */ +#ifdef LIB_DEC_REVISION + if ( ( error = ivas_jbm_dec_render( st_ivas, nSamplesAsked - nSamplesRendered, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) +#else nSamplesToRender = nSamplesAsked - nSamplesRendered; if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) +#endif { return error; } nSamplesRendered += nSamplesRendered_loop; +#ifndef NONBE_1293_CRASH_FIRST_FRAME_LOST nSamplesToRender -= nSamplesRendered_loop; if ( hIvasDec->nSamplesAvailableNext == 0 ) { @@ -1743,8 +2061,21 @@ ivas_error IVAS_DEC_GetSamplesRenderer( { *needNewFrame = false; } +#endif } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + } + else + { + *needNewFrame = false; + } + +#endif *nOutSamples = nSamplesRendered; return IVAS_ERR_OK; @@ -1754,7 +2085,7 @@ ivas_error IVAS_DEC_GetSamplesRenderer( /*---------------------------------------------------------------------* * IVAS_DEC_GetSplitBinauralBitstream( ) * - * + * Get split-rendering bitstream *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSplitBinauralBitstream( @@ -1814,8 +2145,8 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && - ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { numSamplesPerChannelToDecode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; @@ -1849,6 +2180,13 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return error; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + /* change buffer layout */ for ( i = 0; i < numSamplesPerChannelToDecode; ++i ) { @@ -1951,6 +2289,20 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } +#ifdef LIB_DEC_REVISION +/*---------------------------------------------------------------------* + * ivas_dec_setup_all() + * + * Set-up all decoder parts: IVAS decoder, ISAR + *---------------------------------------------------------------------*/ + +static ivas_error ivas_dec_setup_all( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint8_t *nTransportChannels, /* o : number of decoded transport PCM channels */ + const int16_t isSplitRend, /* i : split rendering enabled flag */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +) +#else /*---------------------------------------------------------------------* * IVAS_DEC_Setup( ) * @@ -1962,6 +2314,7 @@ static ivas_error IVAS_DEC_Setup( uint16_t *nTcBufferGranularity, /* o : granularity of the TC Buffer */ uint8_t *nTransportChannels /* o : number of decoded transport PCM channels */ ) +#endif { ivas_error error; @@ -1982,6 +2335,17 @@ static ivas_error IVAS_DEC_Setup( st_ivas = hIvasDec->st_ivas; +#ifdef LIB_DEC_REVISION + /* Setup IVAS split rendering */ + if ( isSplitRend ) + { + if ( ( error = isar_set_split_rend_setup( st_ivas->hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#endif /*----------------------------------------------------------------* * IVAS decoder setup * - read IVAS format signaling @@ -1999,14 +2363,21 @@ static ivas_error IVAS_DEC_Setup( } *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; +#ifndef LIB_DEC_REVISION *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; +#endif /*-----------------------------------------------------------------* * ISAR: * - initialize ISAR handle at the first frame * - reconfigure the ISAR handle in case of bitrate switching (renderer might change) *-----------------------------------------------------------------*/ + +#ifdef LIB_DEC_REVISION + if ( st_ivas->ini_frame == 0 && isSplitRend ) +#else if ( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) +#endif { if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) { @@ -2026,7 +2397,7 @@ static ivas_error IVAS_DEC_Setup( return IVAS_ERR_OK; } - +#ifndef LIB_DEC_REVISION /*---------------------------------------------------------------------* * IVAS_DEC_GetTcSamples( ) * @@ -2165,7 +2536,7 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( return IVAS_ERR_OK; } - +#endif /*---------------------------------------------------------------------* * IVAS_DEC_GetNumObjects( ) @@ -2244,7 +2615,7 @@ ivas_error IVAS_DEC_GetFormat( /*---------------------------------------------------------------------* * getInputBufferSize() * - * + * Get size of output buffer in samples *---------------------------------------------------------------------*/ static int16_t getOutputBufferSize( @@ -2279,7 +2650,7 @@ static int16_t getOutputBufferSize( /*---------------------------------------------------------------------* * IVAS_DEC_GetOutputBufferSize() * - * + * Returns size of output buffer in samples *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetOutputBufferSize( @@ -2341,10 +2712,10 @@ ivas_error IVAS_DEC_GetNumOutputChannels( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetObjectMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_ISM_METADATA *metadata, /* o : struct where metadata decoded in most recently decoded frame will be written */ - const uint16_t zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ - const uint16_t objectIdx /* i : index of the queried object */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_ISM_METADATA *metadata, /* o : struct where metadata decoded in most recently decoded frame will be written */ + const uint16_t zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ + const uint16_t objectIdx /* i : index of the queried object */ ) { Decoder_Struct *st_ivas; @@ -2414,7 +2785,11 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor = 1.f; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } +#ifdef NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) +#else else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) +#endif { metadata->azimuth = st_ivas->hIsmMetaData[objectIdx]->edited_azimuth; metadata->elevation = st_ivas->hIsmMetaData[objectIdx]->edited_elevation; @@ -2530,7 +2905,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( /*---------------------------------------------------------------------* * IVAS_DEC_FeedRefRotData( ) * - * Feed the decoder with the reference rotation + * Feed the decoder with the reference rotation data *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedRefRotData( @@ -2879,18 +3254,22 @@ ivas_error IVAS_DEC_HRTF_binary_close( { Decoder_Struct *st_ivas; - st_ivas = hIvasDec->st_ivas; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + st_ivas = hIvasDec->st_ivas; + if ( st_ivas->hDecoderConfig->Opt_HRTF_binary && st_ivas->ini_frame > 0 ) { +#ifdef NONBE_1303_REND_GRANULARITY + if ( !( binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) +#else if ( !( binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_old == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && ( hIvasDec->st_ivas->ivas_format != SBA_ISM_FORMAT ) // ToDo: temporary hack to avoid ASAN errors -> see issue #1202 ) +#endif { ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); } @@ -2973,7 +3352,7 @@ static ivas_error copyRendererConfigStruct( /*---------------------------------------------------------------------* * IVAS_DEC_GetRenderConfig( ) * - * + * Return renderer configuration parameters handle *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetRenderConfig( @@ -2993,12 +3372,12 @@ ivas_error IVAS_DEC_GetRenderConfig( /*---------------------------------------------------------------------* * IVAS_DEC_GetDefaultRenderConfig( ) * - * + * Return default renderer configuration parameters *---------------------------------------------------------------------*/ /*! r: error code*/ ivas_error IVAS_DEC_GetDefaultRenderConfig( - IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ + IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ ) { RENDER_CONFIG_DATA RCin; @@ -3017,7 +3396,7 @@ ivas_error IVAS_DEC_GetDefaultRenderConfig( /*---------------------------------------------------------------------* * IVAS_DEC_FeedRenderConfig( ) * - * + * Set renderer configuration (acoustic environment) parameters *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedRenderConfig( @@ -3026,6 +3405,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; + Decoder_Struct *st_ivas; ivas_error error; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) @@ -3034,6 +3414,8 @@ ivas_error IVAS_DEC_FeedRenderConfig( } hRenderConfig = hIvasDec->st_ivas->hRenderConfig; + st_ivas = hIvasDec->st_ivas; + #ifdef DEBUGGING hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) @@ -3067,53 +3449,42 @@ ivas_error IVAS_DEC_FeedRenderConfig( /* Re-initialize reverb instance if already available */ /* TD renderer Jot reverberator */ - if ( hIvasDec->st_ivas->hReverb != NULL ) + if ( st_ivas->hReverb != NULL ) { - if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } } /* CREND Jot reverberator */ - if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0] != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) + if ( st_ivas->hCrendWrapper != NULL && st_ivas->hCrendWrapper->hCrend[0] != NULL && st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) { - if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend[0]->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } } - /* FB reverberator */ - if ( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL ) + /* Parametric renderer reverberator */ + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->hReverb != NULL ) { - ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) ); - if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), - hIvasDec->st_ivas->hHrtfStatistics, - hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, - CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, - &( hRenderConfig->roomAcoustics ), - hIvasDec->st_ivas->hDecoderConfig->output_Fs, - NULL, - NULL, - NULL ) ) != IVAS_ERR_OK ) + ivas_binaural_reverb_close( &( st_ivas->hDiracDecBin[0]->hReverb ) ); + + if ( ( error = ivas_binaural_reverb_init( &( st_ivas->hDiracDecBin[0]->hReverb ), st_ivas->hHrtfStatistics, st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, + &( hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; } } - /* Fastconv CLDFB reverberator */ - if ( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL ) + + /* FastConv renderer reverberator */ + if ( st_ivas->hBinRenderer != NULL && st_ivas->hBinRenderer->hReverb != NULL ) { - ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) ); - if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), - hIvasDec->st_ivas->hHrtfStatistics, - hIvasDec->st_ivas->hBinRenderer->conv_band, - hIvasDec->st_ivas->hBinRenderer->timeSlots, - &( hRenderConfig->roomAcoustics ), - hIvasDec->st_ivas->hDecoderConfig->output_Fs, - NULL, - NULL, - NULL ) ) != IVAS_ERR_OK ) + ivas_binaural_reverb_close( &( st_ivas->hBinRenderer->hReverb ) ); + + if ( ( error = ivas_binaural_reverb_init( &( st_ivas->hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, st_ivas->hBinRenderer->conv_band, st_ivas->hBinRenderer->timeSlots, + &( hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; } @@ -3130,9 +3501,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; } - if ( is_split_rendering_enabled( hIvasDec->st_ivas->hDecoderConfig, hRenderConfig ) ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, hRenderConfig ) ) { - if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + if ( ( error = isar_split_rend_validate_config( &hRenderConfig->split_rend_config, ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -3145,7 +3516,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( /*---------------------------------------------------------------------* * IVAS_DEC_GetDelay( ) * - * + * Return IVAS decoder delay in nanoseconds *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetDelay( @@ -3191,7 +3562,7 @@ ivas_error IVAS_DEC_GetDelay( /*---------------------------------------------------------------------* * IVAS_DEC_HasDecodedFirstGoodFrame( ) * - * + * Return flag indicating if the decoder has decoded a good frame *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( @@ -3209,7 +3580,7 @@ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( return IVAS_ERR_OK; } - +#ifndef LIB_DEC_REVISION /*---------------------------------------------------------------------* * IVAS_DEC_GetPcmFrameSize( ) * @@ -3237,7 +3608,7 @@ ivas_error IVAS_DEC_GetPcmFrameSize( return IVAS_ERR_OK; } - +#endif /*---------------------------------------------------------------------* * isSidFrame( ) @@ -3264,6 +3635,13 @@ static bool isSidFrame( return false; } + +/*---------------------------------------------------------------------* + * bsCompactToSerial( ) + * + * Bitstream conversion to Byte format + *---------------------------------------------------------------------*/ + static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, @@ -3418,6 +3796,43 @@ ivas_error IVAS_DEC_VoIP_SetScale( return IVAS_ERR_OK; } +#ifdef VARIABLE_SPEED_DECODING +#ifdef LIB_DEC_REVISION + +/*---------------------------------------------------------------------* + * IVAS_DEC_EnableTsm( ) + * + * Enable Time-Scale Modification (TSM) + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_EnableTsm( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + AUDIO_CONFIG output_config; + ivas_error error; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hIvasDec->st_ivas->hDecoderConfig->Opt_tsm = 1; + + /* init flush buffer if necessary (only needed for binaural) */ + output_config = hIvasDec->st_ivas->hDecoderConfig->output_config; + if ( hIvasDec->flushbuffer == NULL && ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + if ( ( error = create_flush_buffer( hIvasDec ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + return IVAS_ERR_OK; +} + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_TSM_SetQuality( ) @@ -3456,6 +3871,7 @@ ivas_error IVAS_DEC_TSM_SetQuality( return IVAS_ERR_OK; } +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) @@ -3521,10 +3937,19 @@ ivas_error IVAS_DEC_VoIP_GetSamples( nSamplesBuffered = 0; if ( hIvasDec->hasBeenFedFirstGoodFrame ) { +#ifdef LIB_DEC_REVISION + /* check if the TC buffer already exists, otherweise nothing is buffered anyway */ + if ( st_ivas->hTcBuffer != NULL ) + { + nSamplesBuffered = st_ivas->hTcBuffer->n_samples_buffered - st_ivas->hTcBuffer->n_samples_rendered; + nSamplesBuffered += hVoIP->nSamplesRendered20ms; + } +#else if ( ( error = IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ) ) != IVAS_ERR_OK ) { return error; } +#endif } extBufferedSamples = nSamplesBuffered; @@ -3631,7 +4056,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesRendered = 0; +#endif } } @@ -3643,8 +4070,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, ( *nSamplesRendered ) * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); *nSamplesRendered += nSamplesToZero; - +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesRendered += nSamplesToZero; +#endif hIvasDec->nSamplesAvailableNext -= nSamplesToZero; update_voip_rendered20ms( hIvasDec, nSamplesToZero ); } @@ -3658,15 +4086,17 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { if ( hIvasDec->nSamplesAvailableNext == 0 || hIvasDec->nSamplesAvailableNext == hIvasDec->nSamplesFrame ) { +#ifndef LIB_DEC_REVISION uint16_t nSamplesFlushed_ref = hIvasDec->nSamplesFlushed; - - if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) +#endif + if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, NULL ) ) != IVAS_ERR_OK ) { return error; } - +#ifndef LIB_DEC_REVISION hIvasDec->nSamplesFlushed = nSamplesFlushed_ref; +#endif *bitstreamReadDone = false; *parametersAvailableForEditing = true; return IVAS_ERR_OK; @@ -3698,10 +4128,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * - * Function to flush remaining audio in VoIP + * Update the number of samples that have been rendered since the last 20ms render border *---------------------------------------------------------------------*/ static void update_voip_rendered20ms( @@ -3713,12 +4144,20 @@ static void update_voip_rendered20ms( nSamplesRenderedTotal = hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered; /* we have crossed a 20ms border, reset the time scaling done flag */ +#ifdef LIB_DEC_REVISION + if ( nSamplesRenderedTotal >= hIvasDec->nSamplesFrame ) +#else if ( nSamplesRenderedTotal >= hIvasDec->hVoIP->nSamplesFrame ) +#endif { hIvasDec->timeScalingDone = 0; } +#ifdef LIB_DEC_REVISION + hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->nSamplesFrame; +#else hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; +#endif return; } @@ -3727,7 +4166,7 @@ static void update_voip_rendered20ms( /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) * - * Function to flush remaining audio in VoIP + * Function to flush remaining audio samples in VoIP *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Flush( @@ -3755,12 +4194,17 @@ ivas_error IVAS_DEC_Flush( error = IVAS_ERR_OK; if ( nSamplesToRender > 0 && hIvasDec->st_ivas->ivas_format != MONO_FORMAT ) { +#ifdef LIB_DEC_REVISION + error = ivas_jbm_dec_render( hIvasDec->st_ivas, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); +#else error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); +#endif } else { *nSamplesFlushed = 0; } + return error; } @@ -3772,8 +4216,9 @@ ivas_error IVAS_DEC_Flush( *---------------------------------------------------------------------*/ bool IVAS_DEC_VoIP_IsEmpty( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked /* i : number of output samples asked */ +) { if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL ) { @@ -3808,13 +4253,17 @@ ivas_error IVAS_DEC_VoIP_Get_CA_offset( /*---------------------------------------------------------------------* - * IVAS_DEC_Close_VoIP( ) - * + * ivas_destroy_handle_VoIP( ) * + * Deallocate VoIP handle *---------------------------------------------------------------------*/ +#ifdef LIB_DEC_REVISION +static void ivas_destroy_handle_VoIP( +#else static void IVAS_DEC_Close_VoIP( - IVAS_DEC_VOIP *hVoIP /* i/o: IVAS decoder handle */ +#endif + IVAS_DEC_VOIP *hVoIP /* i/o: VoIP decoder handle */ ) { JB4_Destroy( &hVoIP->hJBM ); @@ -4133,6 +4582,11 @@ ivas_error IVAS_DEC_PrintConfig( #ifdef DEBUGGING +/*---------------------------------------------------------------------* + * IVAS_DEC_PrintConfigWithBitstream( ) + * + * + *---------------------------------------------------------------------*/ #define WMC_TOOL_SKIP void IVAS_DEC_PrintConfigWithBitstream( IVAS_DEC_HANDLE hIvasDec, @@ -4158,6 +4612,13 @@ void IVAS_DEC_PrintConfigWithBitstream( return; } + +/*---------------------------------------------------------------------* + * IVAS_DEC_PrintConfigWithVoipBitstream( ) + * + * + *---------------------------------------------------------------------*/ + void IVAS_DEC_PrintConfigWithVoipBitstream( IVAS_DEC_HANDLE hIvasDec, const bool quietModeEnabled, @@ -4208,19 +4669,31 @@ void IVAS_DEC_PrintDisclaimer( void ) *---------------------------------------------------------------------*/ static ivas_error evs_dec_main( +#ifdef LIB_DEC_REVISION + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +#else Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf, - int16_t *pcmBuf ) + int16_t *pcmBuf +#endif +) { DEC_CORE_HANDLE *hCoreCoder; float mixer_left, mixer_rigth; float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; +#ifdef LIB_DEC_REVISION + int16_t ch, nOutSamples; +#else int16_t ch; +#endif ivas_error error; hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; +#ifdef LIB_DEC_REVISION + nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif mdct_switching_dec( hCoreCoder[0] ); @@ -4282,6 +4755,27 @@ static ivas_error evs_dec_main( v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); } +#ifdef LIB_DEC_REVISION + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ + int16_t pcm_buf_local[L_FRAME48k]; + + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) + { +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output( &p_output[ch], nOutSamples, 1, pcm_buf_local ); + + mvs2r( pcm_buf_local, p_output[ch], nOutSamples ); + } + } + else // ToDo: the 'else' branch can be removed once UNIFIED_DECODING_PATHS_LEFTOVERS is merged + { + ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); + } +#else if ( !st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); @@ -4306,6 +4800,7 @@ static ivas_error evs_dec_main( #endif ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } +#endif return IVAS_ERR_OK; } @@ -4505,6 +5000,18 @@ static ivas_error input_format_API_to_internal( } +#ifdef LIB_DEC_REVISION +/*---------------------------------------------------------------------* + * apa_setup() + * + * Setup APA decoder + *---------------------------------------------------------------------*/ + +static ivas_error apa_setup( + IVAS_DEC_HANDLE hIvasDec, + const bool isInitialized_voip, + const uint16_t nTransportChannels ) +#else /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_reconfigure() * @@ -4515,17 +5022,27 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ) +#endif { int16_t apa_buffer_size; +#ifdef LIB_DEC_REVISION + uint16_t l_ts; + + l_ts = (uint16_t) hIvasDec->st_ivas->hTcBuffer->n_samples_granularity; + if ( !isInitialized_voip ) +#else apa_buffer_size = hIvasDec->nSamplesFrame; if ( hIvasDec->apaExecBuffer == NULL ) +#endif { DECODER_CONFIG_HANDLE hDecoderConfig; +#ifndef LIB_DEC_REVISION if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { +#endif uint16_t wss, css; float startQuality; @@ -4583,16 +5100,22 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( } set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); +#ifndef LIB_DEC_REVISION } +#endif } else { +#ifndef LIB_DEC_REVISION if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { +#endif if ( apa_reconfigure( hIvasDec->hTimeScaler, nTransportChannels, l_ts ) != 0 ) { return IVAS_ERR_INIT_ERROR; } + + /* realloc apa_exe_buffer */ apa_buffer_size = APA_BUF_PER_CHANNEL; free( hIvasDec->apaExecBuffer ); if ( ( hIvasDec->apaExecBuffer = malloc( sizeof( float ) * apa_buffer_size * nTransportChannels ) ) == NULL ) @@ -4600,8 +5123,10 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); +#ifndef LIB_DEC_REVISION } /* realloc apa_exe_buffer */ +#endif } hIvasDec->nTransportChannelsOld = nTransportChannels; @@ -4792,7 +5317,7 @@ PCM_RESOLUTION pcm_type_API_to_internal( /*-------------------------------------------------------------------* * ivas_create_handle_isar() * - * Initialize IVAS decoder split rend handle + * Initialize IVAS decoder split-rendering handle *-------------------------------------------------------------------*/ static ivas_error ivas_create_handle_isar( @@ -5006,7 +5531,7 @@ static ivas_error ivas_dec_reconfig_split_rend( /*-------------------------------------------------------------------* * ivas_dec_init_split_rend() * - * IVAS decoder split rend init + * IVAS decoder split rendering initialization *-------------------------------------------------------------------*/ static ivas_error ivas_dec_init_split_rend( @@ -5060,12 +5585,12 @@ static ivas_error ivas_dec_init_split_rend( /*---------------------------------------------------------------------* * IVAS_DEC_is_split_rendering_coded_out() * - * + * Return flag to indicate if split rendering is enabled *---------------------------------------------------------------------*/ /*! r: decoder error code */ ivas_error IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index bfe6dd6e0b7edfea683a02305e3b5f7d96621b44..2a02fd46ec55fda164b1b58f3216de3fe97bfe87 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -122,7 +122,9 @@ ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint32_t sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ +#ifndef LIB_DEC_REVISION const bool tsmEnabled, /* i : enable TSM */ + #endif const IVAS_RENDER_FRAMESIZE renderFramesize,/* i : rendering frame size */ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ @@ -295,12 +297,19 @@ ivas_error IVAS_DEC_VoIP_SetScale( const int16_t scale /* i : TSM scale to set */ ); +#ifdef VARIABLE_SPEED_DECODING +#ifdef LIB_DEC_REVISION +ivas_error IVAS_DEC_EnableTsm( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +); +#endif + /*! r: error code */ ivas_error IVAS_DEC_TSM_SetQuality( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const float quality /* i : target TSM quality */ + const float quality /* i : target TSM quality */ ); - +#endif /*! r: error code */ ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ @@ -497,12 +506,13 @@ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( bool *hasDecodedFirstGoodFrame /* o : flag indicating if the decoder has decoded a good frame since it was configured */ ); +#ifndef LIB_DEC_REVISION /*! r: error code */ ivas_error IVAS_DEC_GetPcmFrameSize( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ int32_t *pcmFrameSize /* o : total size of the PCM output frame. This takes into account the number of output channels */ ); - +#endif /*! r: true if decoder has no data in VoIP jitter buffer */ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 8ec10ee28e75ca9816248a688335ca1d81c89cba..53669f7b65db36fa94ab15c1422cc01c82da9132 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -90,14 +90,7 @@ ivas_error ivas_core_enc( float *inp[CPE_CHANNELS]; float new_inp_resamp16k[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k]; /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */ -#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC - float *shb_speech; - float *hb_speech; -#else - float shb_speech[L_FRAME16k]; - float hb_speech[L_FRAME16k / 4]; -#endif - float *new_swb_speech; + float *shb_speech, *hb_speech, *new_swb_speech; float new_swb_speech_buffer[L_FRAME48k + STEREO_DFT_OVL_MAX]; float bwe_exc_extended[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; float voice_factors[CPE_CHANNELS][NB_SUBFR16k]; @@ -159,9 +152,6 @@ ivas_error ivas_core_enc( input_Fs = sts[0]->input_Fs; input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); -#ifndef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC - set_f( new_swb_speech_buffer, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); -#endif for ( n = 0; n < n_CoreChannels; n++ ) { @@ -202,11 +192,7 @@ ivas_error ivas_core_enc( diff_nBits = 0; if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { -#ifdef SIMPLIFY_IVAS_CORE ivas_combined_format_brate_sanity( element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); -#else - ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); -#endif } /*---------------------------------------------------------------------* @@ -346,9 +332,7 @@ ivas_error ivas_core_enc( * WB BWE encoding *---------------------------------------------------------------------*/ -#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC hb_speech = new_swb_speech_buffer; /* reuse existing buffer: hb_speech[L_FRAME16k/4]; */ -#endif if ( input_Fs >= 16000 && st->bwidth < SWB && st->hBWE_TD != NULL ) { @@ -373,10 +357,8 @@ ivas_error ivas_core_enc( *---------------------------------------------------------------------*/ new_swb_speech = new_swb_speech_buffer + STEREO_DFT_OVL_MAX; -#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC set_f( new_swb_speech_buffer, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); shb_speech = new_inp_resamp16k[n]; /* reuse existing buffer: shb_speech[L_FRAME16k] */ -#endif if ( !st->Opt_SC_VBR && input_Fs >= 32000 && st->hBWE_TD != NULL ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 5dc7ded887a27814afc1b46f2f3481886a66749f..7c5b66cb8ca5f650ab98d7c24ccafb800a315059 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -68,9 +68,7 @@ ivas_error ivas_cpe_enc( ) { CPE_ENC_HANDLE hCPE; -#ifdef SIMPLIFY_IVAS_CORE STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; -#endif Encoder_State **sts; int16_t n, n_CoreChannels; float old_inp_12k8[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8 */ @@ -209,14 +207,12 @@ ivas_error ivas_cpe_enc( return error; } -#ifdef SIMPLIFY_IVAS_CORE hConfigDft = NULL; - IF( hCPE->hStereoDft != NULL ) + if ( hCPE->hStereoDft != NULL ) { hConfigDft = hCPE->hStereoDft->hConfig; } -#endif /*----------------------------------------------------------------* * Set TD stereo parameters *----------------------------------------------------------------*/ @@ -291,39 +287,23 @@ ivas_error ivas_cpe_enc( if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 || -#ifdef SIMPLIFY_IVAS_CORE ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ -#else - ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ -#endif { if ( st_ivas->hQMetaData != NULL ) { if ( ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } else { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } else { /* note; "bits_frame_nominal" needed in TD stereo as well */ -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } } @@ -394,25 +374,13 @@ ivas_error ivas_cpe_enc( if ( hCPE->element_mode == IVAS_CPE_DFT ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_hybrid_ITD_flag( hConfigDft, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); -#else - stereo_dft_hybrid_ITD_flag( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); -#endif /* Time Domain ITD compensation using extrapolation */ #ifdef DEBUG_MODE_DFT -#ifdef SIMPLIFY_IVAS_CORE stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hConfigDft->hybrid_itd_flag, hConfigDft->itd_mode, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); #else - stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->hConfig->itd_mode, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); -#endif -#else -#ifdef SIMPLIFY_IVAS_CORE stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hConfigDft->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); -#else - stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem ); -#endif #endif /* DFT on right and left input channels */ @@ -424,11 +392,7 @@ ivas_error ivas_cpe_enc( #endif /* Update DFT Stereo memories */ -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_enc_update( hCPE->hStereoDft, max_bwidth ); -#else - stereo_dft_enc_update( hCPE->hStereoDft, sts[0]->max_bwidth ); -#endif /* DFT stereo processing */ stereo_dft_enc_process( hCPE, vad_flag_dtx, vad_hover_flag, input_frame ); @@ -519,11 +483,7 @@ ivas_error ivas_cpe_enc( error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], -#ifdef SIMPLIFY_IVAS_CORE fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, hEncoderConfig->last_ivas_total_brate, ivas_total_brate ); -#else - fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -574,11 +534,7 @@ ivas_error ivas_cpe_enc( set_bw_stereo( hCPE ); /* reconfiguration of MDCT stereo */ -#ifdef SIMPLIFY_IVAS_CORE if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != max_bwidth ) ) -#else - if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) ) -#endif { initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 ); hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); @@ -601,15 +557,9 @@ ivas_error ivas_cpe_enc( int16_t igf; int16_t bw; -#ifdef SIMPLIFY_IVAS_CORE bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : max_bwidth; igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode ); if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) -#else - bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth; - igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode ); - if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -676,19 +626,11 @@ ivas_error ivas_cpe_enc( /* Reconfigure DFT Stereo for inactive frames */ if ( sts[0]->core_brate == SID_2k40 ) { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft->hConfig, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } else { -#ifdef SIMPLIFY_IVAS_CORE stereo_dft_config( hConfigDft, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#else - stereo_dft_config( hCPE->hStereoDft->hConfig, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); -#endif } stereo_dft_cng_side_gain( hCPE->hStereoDft, hCPE->hStereoCng, sts[0]->core_brate, sts[0]->last_core_brate, sts[0]->bwidth ); diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 68166262c33b97ef7f1a20f4d6beb79c02967919..913fe907542f53f549525d32fd9ce63a3930eedc 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -166,11 +166,8 @@ ivas_error ivas_sce_enc( /* set flag for sampling rate of OL S/M classifier */ flag_16k_smc = 0; -#ifdef SIMPLIFY_IVAS_CORE if ( ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate ) -#else - if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate ) -#endif + { flag_16k_smc = 1; } diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 8709ce9b839a647c709394de76fb1f8ea22c4951..7e050abc068ffad6beb394193e3b8bf346a2ad61 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1539,6 +1539,17 @@ static ivas_error renderSplitBinauralWithPostRot( } else { +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + if ( splitBinInput->numCachedSamples == 0 ) + { + numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outAudio.config.numSamplesPerChannel; + splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; + } + else + { + splitBinInput->numCachedSamples -= outAudio.config.numSamplesPerChannel; + } +#endif if ( splitBinInput->base.inConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index c5810cb6d3f60c77a872dee496c0397576d33f45..3be1a116d7a5543c6ead08e89245837286259547 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -151,6 +151,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; } +#ifdef NONBE_1303_REND_GRANULARITY + output_Fs = st_ivas->hDecoderConfig->output_Fs; + nBins = st_ivas->hSpatParamRendCom->num_freq_bands; + renderer_type = st_ivas->renderer_type; + +#endif for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; @@ -169,10 +175,11 @@ ivas_error ivas_dirac_dec_init_binaural_data( hDiracDecBin->phHrtfParambin = NULL; } +#ifndef NONBE_1303_REND_GRANULARITY output_Fs = st_ivas->hDecoderConfig->output_Fs; nBins = st_ivas->hSpatParamRendCom->num_freq_bands; renderer_type = st_ivas->renderer_type; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { for ( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) @@ -324,11 +331,15 @@ ivas_error ivas_dirac_dec_init_binaural_data( nchan_to_allocate = BINAURAL_CHANNELS + st_ivas->nchan_ism; } +#ifdef NONBE_1303_REND_GRANULARITY + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, ivas_renderer_secondary_select( st_ivas ), output_Fs ); +#else n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ } +#endif if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 2d09fd49a76bc54023123d20a29112ebcfe5fe32..5873ebd96aef56346b9c4c25dadadfe55769b882 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -39,11 +39,6 @@ #include "wmc_auto.h" -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - - /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ @@ -56,6 +51,7 @@ static void sincResample( const float *input, float *output, const int16_t lengt * * Apply ITD by delaying late channel *---------------------------------------------------------------------*/ + void TDREND_Apply_ITD( float *input, /* i : Input subframe to be time adjusted */ float *out_left, /* o : Output left channel with ITD applied */ @@ -163,6 +159,7 @@ void TDREND_Apply_ITD( * The sinc resampling reads SFX_SPAT_BIN_SINC_M (5) samples outside of * the target frame. *---------------------------------------------------------------------*/ + static void sincResample( const float *input, /*i : Input signal */ float *output, /*o : Output signal */ @@ -188,7 +185,6 @@ static void sincResample( return; } - /* Compute fractional time step */ t_step = (float) ( length_in ) / (float) ( length_out ); t_frac = 0; @@ -216,9 +212,6 @@ static void sincResample( p_forward++; p_backward--; } -#ifndef NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS - tmp += ( *p_forward ) * ( *p_sinc_forward ); /* Integer index always rounded down --> 4 steps backward, 5 steps forward */ -#endif output[i] = tmp; diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 377c1b22ad0e75e29d7f6147a2ec5440545c234d..fed68002a7071b092ef446b067fe9b8ea7bc97c1 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2369,11 +2369,8 @@ ivas_error RenderConfigReader_read( errorHandler( item, ERROR_VALUE_INVALID ); return IVAS_ERR_INVALID_RENDER_CONFIG; } -#ifdef FIX_1285_RENDER_CONFIG_PTR_COMPARE + if ( i >= pRenderConfigReader->nFG || pRenderConfigReader->pFG[i].pFc == NULL ) -#else - if ( i > pRenderConfigReader->nFG || &pRenderConfigReader->pFG[i] == NULL ) -#endif { return IVAS_ERR_INVALID_RENDER_CONFIG; } diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index e0c7df92d64c4ff04b548ebc7c0eb6d71d442f83..9cc6e4bf7e33946f0b77d5794bf5794cc82770a0 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -331,11 +331,20 @@ ivas_error split_rend_write_bitstream_to_file( * *-----------------------------------------------------------------------------------------*/ +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST +ivas_error split_rend_read_bits_from_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written, + int16_t *bfi ) +#else ivas_error split_rend_read_bits_from_file( SplitFileReadWrite *hSplitRendFileReadWrite, uint8_t *bits, int32_t *bits_read, int32_t *bits_written ) +#endif { char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "SPLIT_FRAME"; char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN]; @@ -398,6 +407,13 @@ ivas_error split_rend_read_bits_from_file( *bits_read = 0; *bits_written = bit_len; +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + *bfi = 0; + if ( bit_len == 0 ) + { + *bfi = 1; + } +#endif return IVAS_ERR_OK; } diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 1362ce1226e3eaaf9b0ae7263c1eb6c0d1ea5fee..4450eeded41e6be5efceb93834b83e5d39f21c31 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -73,11 +73,20 @@ ivas_error split_rend_write_bitstream_to_file( int32_t *bits_written ); /* read split rend coded bits from file */ +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST +ivas_error split_rend_read_bits_from_file( + SplitFileReadWrite *hSplitRendFileReadWrite, + uint8_t *bits, + int32_t *bits_read, + int32_t *bits_written, + int16_t *bfi ); +#else ivas_error split_rend_read_bits_from_file( SplitFileReadWrite *hSplitRendFileReadWrite, uint8_t *bits, int32_t *bits_read, int32_t *bits_written ); +#endif /* read split pre rend delay */ ivas_error split_rend_read_pre_rend_delay_ns( diff --git a/tests/renderer/utils.py b/tests/renderer/utils.py index aac6a3d7c8e5b46557d29d8313905dea9731fe08..13b03edc0bb6288e7933575aa5dab5b49c34d469 100644 --- a/tests/renderer/utils.py +++ b/tests/renderer/utils.py @@ -230,28 +230,29 @@ def run_renderer( # if in REF or CUT creation mode use the comparetestv if test_info.config.option.create_ref or test_info.config.option.create_cut: - FORMAT_TO_FILE = FORMAT_TO_FILE_COMPARETEST - elif test_info.config.option.use_ltv: + format_to_file = FORMAT_TO_FILE_COMPARETEST + else: + format_to_file = FORMAT_TO_FILE_SMOKETEST + + if test_info.config.option.use_ltv: if test_info.config.option.ltv_dir: - FORMAT_TO_FILE = dict() + format_to_file = dict() for k, v in FORMAT_TO_FILE_LTV.items(): - FORMAT_TO_FILE[k] = str(v).replace( + format_to_file[k] = str(v).replace( str(LTV_DIR), str(test_info.config.option.ltv_dir) ) else: - FORMAT_TO_FILE = FORMAT_TO_FILE_LTV - else: - FORMAT_TO_FILE = FORMAT_TO_FILE_SMOKETEST + format_to_file = FORMAT_TO_FILE_LTV if in_file is None: if metadata_input is not None: in_file = metadata_input in_name = metadata_input.stem elif not isinstance(in_fmt, str): - in_file = FORMAT_TO_FILE[in_fmt.stem] + in_file = format_to_file[in_fmt.stem] in_name = in_fmt.stem else: - in_file = FORMAT_TO_FILE[in_fmt] + in_file = format_to_file[in_fmt] in_name = in_fmt if out_file is None: diff --git a/tests/test_26444.py b/tests/test_26444.py index 054242c4c98e439389ee718d8fde8ac3304c2477..cdf065ef3e437fb740e61a34af4e065f8d4bc9e7 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -167,7 +167,7 @@ def test_evs_26444( output_differs, reason = cmp_pcm( reffile, testfile, - output_config, + 1, fs, get_mld=get_mld, mld_lim=get_mld_lim,