From 79cc0ba4b30247d98e48571189a46f4741ec337f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 22 Apr 2025 16:56:34 +0200 Subject: [PATCH 001/351] disable BASOP_Util_Divide3232_Scale_cadence() --- lib_com/basop_util.c | 2 ++ lib_com/basop_util.h | 2 ++ lib_com/options.h | 1 + 3 files changed, 5 insertions(+) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index ec15e9769..60ef2e358 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1010,6 +1010,7 @@ Word32 div_w( Word32 L_num, Word32 L_den ) } } +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) { Word32 z; @@ -1061,6 +1062,7 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) return z; } +#endif #ifdef DIV32_OPT_NEWTON Word32 div_w_newton( Word32 num, Word32 den ); diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index b1d4b5fc1..6192f68bc 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -328,9 +328,11 @@ Word16 BASOP_Util_Divide3232_Scale( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ +#endif #ifdef DIV32_OPT_NEWTON diff --git a/lib_com/options.h b/lib_com/options.h index 2f1e82de8..4285ac231 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,6 +85,7 @@ #define HARM_ENC_INIT //#define HARM_SCE_INIT #define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ +#define REMOVE_BASOP_Util_Divide3232_Scale_cadence /* remove this division variant */ #define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ #define FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat /*FhG: reduces WMOPS - bit-exact*/ #define FIX_1439_SPEEDUP_stereo_icBWE_dec_fx /*FhG: reduces WMOPS - bit-exact*/ -- GitLab From cbf9e004976062690decc76dc595aa487799d743 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 8 Sep 2025 19:30:42 +0200 Subject: [PATCH 002/351] CLDFB memory harmonization --- lib_com/cldfb_evs_fx.c | 176 +++++----- lib_com/cldfb_fx.c | 426 +++-------------------- lib_com/prot_fx.h | 91 +++-- lib_com/rom_com.c | 11 - lib_com/rom_com.h | 2 +- lib_com/stat_com.h | 17 +- lib_dec/acelp_core_dec_fx.c | 5 +- lib_dec/amr_wb_dec_fx.c | 6 +- lib_dec/dec_acelp_tcx_main_fx.c | 7 +- lib_dec/evs_dec_fx.c | 6 +- lib_dec/init_dec_fx.c | 106 +++--- lib_dec/ivas_corecoder_dec_reconfig_fx.c | 6 +- lib_dec/ivas_init_dec_fx.c | 13 +- lib_dec/ivas_stereo_switching_dec_fx.c | 4 +- lib_dec/lib_dec_fx.c | 4 +- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/evs_enc_fx.c | 2 +- lib_enc/init_enc_fx.c | 34 +- lib_enc/ivas_init_enc_fx.c | 3 +- lib_enc/ivas_masa_enc_fx.c | 2 +- lib_enc/ivas_omasa_enc_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 4 - lib_enc/ivas_stereo_switching_enc_fx.c | 8 +- lib_enc/ivas_stereo_td_enc_fx.c | 4 +- lib_enc/lib_enc_fx.c | 2 - lib_enc/prot_fx_enc.h | 4 - lib_enc/stat_enc.h | 1 - lib_isar/isar_splitRendererPost.c | 6 +- lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/lib_isar_pre_rend.c | 4 +- lib_rend/ivas_dirac_ana_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_omasa_ana_fx.c | 2 +- lib_rend/lib_rend_fx.c | 10 +- 35 files changed, 293 insertions(+), 685 deletions(-) diff --git a/lib_com/cldfb_evs_fx.c b/lib_com/cldfb_evs_fx.c index 153f95cf9..609caf5ac 100644 --- a/lib_com/cldfb_evs_fx.c +++ b/lib_com/cldfb_evs_fx.c @@ -48,8 +48,9 @@ #define N40 ( 20 ) #define N60 ( 30 ) -static void -cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ); +static Word16 CLDFB_getNumChannels( const Word32 sampleRate ); + +static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ); #define cplxMpyS( yr, yi, xr, xi, cr, ci, syr, syi, sxr, sxi, CL_x, CL_z, C_c ) \ CL_x = CL_form( *xr, *xi ); \ @@ -722,7 +723,7 @@ void cldfbSynthesis_fx( scaleLB = limitScale32( sub( scale, scaleFactor->lb_scale ) ); scaleHB = limitScale32( sub( scale, scaleFactor->hb_scale ) ); - outScale = cldfbBank->synFilterHeadroom; + outScale = SYN_FILTER_HEADROOM_2_5MS; move16(); scaleMod = sub( add( scale, cldfbBank->outScalefactor ), outScale ); @@ -811,7 +812,6 @@ void cldfbSynthesis_fx( &iBuffer[0], &iBuffer[1], &iAnalysisS[0], &iAnalysisS[m - 1], 2, 2, 2, -2, rRotVctr, iRotVctr, m ); - /* FFT of DST IV */ scale = 0; move16(); @@ -909,25 +909,29 @@ void cldfbSynthesis_fx( /* move filter states */ Copy( &cldfbBank->FilterStates[nTimeSlots * L2], cldfbBank->FilterStates, statesSizeM2 ); set16_fx( &cldfbBank->FilterStates[statesSizeM2], 0, L2 ); + + return; } /*-------------------------------------------------------------------* - * configureClfdb() + * configureCldfb() * * configures a CLDFB handle *--------------------------------------------------------------------*/ -void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */ - const Word16 no_channels, /*!< Number of channels (bands) */ - const Word16 frameSize /*!< FrameSize */ +void configureCldfb( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */ + const Word32 sampling_rate /* i : sampling rate */ ) { + Word16 no_channels; + no_channels = CLDFB_getNumChannels( sampling_rate ); - h_cldfb->no_channels = no_channels; + h_cldfb->no_channels = extract_l( Mpy_32_32_r( sampling_rate, INV_CLDFB_BANDWIDTH_Q31 ) ); move16(); assert( h_cldfb->no_channels >= 10 ); - h_cldfb->no_col = div_l( frameSize, shr( h_cldfb->no_channels, 1 ) ); + h_cldfb->no_col = CLDFB_NO_COL_MAX; move16(); /* was cldfbInitFilterBank()*/ @@ -937,8 +941,6 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */ move16(); h_cldfb->bandsToZero = 0; move16(); - h_cldfb->filtermode = 0; - move16(); h_cldfb->memory = 0; move16(); h_cldfb->memory_length = 0; @@ -954,14 +956,13 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */ h_cldfb->zeros = 0; move16(); - h_cldfb->synFilterHeadroom = SYN_FILTER_HEADROOM_2_5MS; - move16(); cldfb_init_proto_and_twiddles( h_cldfb ); + /* the following is related to the EVS implentation only */ h_cldfb->lsb = no_channels; move16(); - h_cldfb->usb = s_min( no_channels, h_cldfb->no_channels ); /* Does this make any sense? in the previous implemenatation lsb, usb and no_channels are all maxCldfbBands */ + h_cldfb->usb = s_min( no_channels, h_cldfb->no_channels ); move16(); h_cldfb->FilterStates = (void *) h_cldfb->FilterStates; @@ -971,19 +972,23 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */ return; } + /*-------------------------------------------------------------------* * openClfdb() * * open and configures a CLDFB handle *--------------------------------------------------------------------*/ + ivas_error openCldfb( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /*!< Returns handle */ const Word16 type, /*!< analysis or synthesis */ - const Word16 maxCldfbBands, /*!< number of cldfb bands */ - const Word16 frameSize /*!< FrameSize */ + const Word32 sampling_rate /* i : sampling rate */ ) { HANDLE_CLDFB_FILTER_BANK hs; + Word16 buf_len, maxCldfbBands; + + maxCldfbBands = CLDFB_getNumChannels( sampling_rate ); hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ); IF( hs == NULL ) @@ -994,23 +999,31 @@ ivas_error openCldfb( hs->type = type; move16(); + configureCldfb( hs, sampling_rate ); + IF( type == CLDFB_ANALYSIS ) { - hs->FilterStates = (Word16 *) malloc( STATE_BUFFER_SIZE * maxCldfbBands * sizeof( Word16 ) ); + //buf_len = sub( hs->p_filter_length, hs->no_channels ); + buf_len = STATE_BUFFER_SIZE * maxCldfbBands; } ELSE { - hs->FilterStates = (Word16 *) malloc( 2 * STATE_BUFFER_SIZE * maxCldfbBands * sizeof( Word16 ) ); + //buf_len = hs->p_filter_length; + buf_len = 2 * STATE_BUFFER_SIZE * maxCldfbBands; + move16(); } - if ( hs->FilterStates == NULL ) + + IF( ( hs->FilterStates = (Word16 *) malloc( buf_len * sizeof( Word16 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); } + hs->flags = s_and( hs->flags, ~CLDFB_FLAG_KEEP_STATES ); move16(); - configureCldfb( hs, maxCldfbBands, frameSize ); hs->memory = NULL; + hs->memory32 = NULL; + hs->cldfb_state_fx = NULL; hs->memory_length = 0; move16(); @@ -1019,7 +1032,7 @@ ivas_error openCldfb( test(); IF( ( s_and( hs->flags, CLDFB_FLAG_KEEP_STATES ) == 0 ) && ( hs->FilterStates != 0 ) ) { - set16_fx( hs->FilterStates, 0, i_mult( STATE_BUFFER_SIZE, hs->no_channels ) ); + set16_fx( hs->FilterStates, 0, buf_len ); set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) ); hs->FilterStates_eg = 0; @@ -1032,7 +1045,7 @@ ivas_error openCldfb( { IF( s_and( hs->flags, CLDFB_FLAG_KEEP_STATES ) == 0 ) { - set16_fx( hs->FilterStates, 0, i_mult( shl( STATE_BUFFER_SIZE, 1 ), hs->no_channels ) ); + set16_fx( hs->FilterStates, 0, buf_len ); } } hs->FilterStates_eg = 0; @@ -1053,10 +1066,12 @@ ivas_error openCldfb( * * Change sample rate of filter bank *--------------------------------------------------------------------*/ -void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs, - const Word16 newCldfbBands, - const Word16 frameSize, - const Word8 firstFrame ) + +void resampleCldfb( + HANDLE_CLDFB_FILTER_BANK hs, + const Word32 sampling_rate, /* i : sampling rate */ + const Word16 frameSize, + const Word8 firstFrame ) { Word16 timeOffset; @@ -1072,7 +1087,7 @@ void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs, move16(); /* new settings */ - configureCldfb( hs, newCldfbBands, frameSize ); + configureCldfb( hs, sampling_rate ); /* resample cldfb state buffer */ timeOffset = sub( sub( hs->p_filter_length, hs->no_channels ), hs->zeros ); @@ -1104,20 +1119,20 @@ void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs, Returns: headroom */ -Word16 -AnalysisPostSpectrumScaling_Fx( HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle of cldfbBank */ - Word32 **rSubband32, /*!< Real bands Q(cldfbSacle)*/ - Word32 **iSubband32, /*!< Imaginary bands Q(cldfbSacle)*/ - Word16 **rSubband16, /*!< Real bands Q(cldfbSacle)*/ - Word16 **iSubband16, /*!< Imaginary bands Q(cldfbScale)*/ - Word16 *cldfbScale /*!< CLDFB lowband scalefactor */ + +Word16 AnalysisPostSpectrumScaling_Fx( + HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle of cldfbBank */ + Word32 **rSubband32, /*!< Real bands Q(cldfbSacle)*/ + Word32 **iSubband32, /*!< Imaginary bands Q(cldfbSacle)*/ + Word16 **rSubband16, /*!< Real bands Q(cldfbSacle)*/ + Word16 **iSubband16, /*!< Imaginary bands Q(cldfbScale)*/ + Word16 *cldfbScale /*!< CLDFB lowband scalefactor */ ) { Word16 i; Word16 j; Word16 headRoom; - headRoom = BASOP_util_norm_l_dim2_cplx( (const Word32 *const *) rSubband32, (const Word32 *const *) iSubband32, @@ -1215,19 +1230,21 @@ void analysisCldfbEncoder_fx( return; } -void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | pointer to the result in the core look-ahead slot */ - Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot */ - const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ - Word16 **realValues, /*!< i: Q(sf_Values) | the real part of the CLDFB subsamples */ - Word16 **imagValues, /*!< i: Q(sf_Values) | the imaginary part of the CLDFB subsamples */ - Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ - Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ - Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ - Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ - Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ - Word32 *energyValuesSum, /*!< o: Q(2*sf_Values-4) | pointer to sum array of energy values, not initialized*/ - Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ - TEC_ENC_HANDLE hTecEnc ) + +void GetEnergyCldfb( + Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | pointer to the result in the core look-ahead slot */ + Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot */ + const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ + Word16 **realValues, /*!< i: Q(sf_Values) | the real part of the CLDFB subsamples */ + Word16 **imagValues, /*!< i: Q(sf_Values) | the imaginary part of the CLDFB subsamples */ + Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ + Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ + Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ + Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ + Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ + Word32 *energyValuesSum, /*!< o: Q(2*sf_Values-4) | pointer to sum array of energy values, not initialized*/ + Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ + TEC_ENC_HANDLE hTecEnc ) { Word16 j; Word16 k; @@ -1388,14 +1405,12 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) } -Word16 -CLDFB_getNumChannels( Word32 sampleRate ) +static Word16 CLDFB_getNumChannels( + const Word32 sampleRate ) { - Word16 nChannels = 0; move16(); - SWITCH( sampleRate ) { case 48000: @@ -1427,13 +1442,15 @@ CLDFB_getNumChannels( Word32 sampleRate ) return ( nChannels ); } + /*-------------------------------------------------------------------* * cldfb_get_memory_length() * * Return length of filter state for recovery *--------------------------------------------------------------------*/ -static Word16 -cldfb_get_memory_length( HANDLE_CLDFB_FILTER_BANK hs ) + +static Word16 cldfb_get_memory_length( + HANDLE_CLDFB_FILTER_BANK hs ) { IF( EQ_16( hs->type, CLDFB_ANALYSIS ) ) { @@ -1445,39 +1462,21 @@ cldfb_get_memory_length( HANDLE_CLDFB_FILTER_BANK hs ) } } -/*-------------------------------------------------------------------* - * GetEnergyCldfb() - * - * Remove handle - *--------------------------------------------------------------------*/ -void deleteCldfb( HANDLE_CLDFB_FILTER_BANK *h_cldfb ) /* i: cldfb handle */ -{ - IF( *h_cldfb != NULL ) - { - IF( ( *h_cldfb )->FilterStates != NULL ) - { - free( ( *h_cldfb )->FilterStates ); - } - free( *h_cldfb ); - } - *h_cldfb = NULL; -} - /*-------------------------------------------------------------------* * cldfb_init_proto_and_twiddles() * * Initializes rom pointer *--------------------------------------------------------------------*/ -static void -cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */ -{ +static void cldfb_init_proto_and_twiddles( + HANDLE_CLDFB_FILTER_BANK hs /* i: cldfb handle */ +) +{ /*find appropriate set of rotVecs*/ SWITCH( hs->no_channels ) { case 10: - hs->rRotVctr = rRotVectr_10; hs->iRotVctr = iRotVectr_10; hs->synGain = cldfb_synGain[0]; @@ -1585,6 +1584,8 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle } BREAK; } + + return; } @@ -1595,8 +1596,10 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle * * Save the memory of filter; to be restored with cldfb_restore_memory() *--------------------------------------------------------------------*/ -ivas_error -cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */ + +ivas_error cldfb_save_memory( + HANDLE_CLDFB_FILTER_BANK hs /* i: cldfb handle */ +) { test(); IF( hs->memory != NULL || hs->memory_length != 0 ) @@ -1617,6 +1620,7 @@ cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */ { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); } + return IVAS_ERR_OK; } @@ -1626,12 +1630,14 @@ cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */ * * Restores the memory of filter; memory to be save by cldfb_save_memory() *--------------------------------------------------------------------*/ -void cldfb_restore_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */ + +void cldfb_restore_memory( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: cldfb handle */ +) { Word16 size; - size = cldfb_get_memory_length( hs ); /* read the memory */ @@ -1640,7 +1646,6 @@ void cldfb_restore_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */ hs->FilterStates_eg = hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS]; move16(); - /* adjust sample rate if it was changed in the meanwhile */ IF( NE_16( hs->memory_length, size ) ) { @@ -1654,12 +1659,16 @@ void cldfb_restore_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */ return; } + /*-------------------------------------------------------------------* * cldfb_reset_memory() * * Resets the memory of filter. *--------------------------------------------------------------------*/ -void cldfb_reset_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */ + +void cldfb_reset_memory( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: cldfb handle */ +) { Word16 length; @@ -1669,5 +1678,6 @@ void cldfb_reset_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i/o: cldfb handle */ set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) ); hs->FilterStates_eg = 0; move16(); + return; } diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index f0a4e61cf..a30ab3ae6 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -57,8 +57,6 @@ static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ); -static void cldfb_init_proto_and_twiddles_enc_fx( HANDLE_CLDFB_FILTER_BANK hs ); - static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | pointer to the result in the core look-ahead slot */ Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot */ const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ @@ -73,17 +71,13 @@ static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_e Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ TEC_ENC_HANDLE hTecEnc ); -/*-------------------------------------------------------------------* - * cplxMult() - * - * Conduct complex multiplication - *--------------------------------------------------------------------*/ /*-------------------------------------------------------------------* * cldfbAnalysis_ivas() * * Conduct multiple overlap complex low delay MDCT *--------------------------------------------------------------------*/ + void cldfbAnalysis_ivas_fx( const Word32 *timeIn_fx, /* i : time buffer Qx */ Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ @@ -1334,38 +1328,22 @@ void cldfbSynthesis_ivas_fx( return; } -void configureCldfb_ivas_enc_fx( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - const Word32 sampling_rate /* i : sampling rate */ -) -{ - h_cldfb->no_col = CLDFB_NO_COL_MAX; - h_cldfb->bandsToZero = 0; - h_cldfb->nab = 0; - - h_cldfb->no_channels = extract_l( Mpy_32_32_r( sampling_rate, INV_CLDFB_BANDWIDTH_Q31 ) ); - h_cldfb->p_filter_length = i_mult( 10, h_cldfb->no_channels ); - h_cldfb->zeros = 0; - h_cldfb->anaScalefactor = 0; - h_cldfb->synScalefactor = 0; - h_cldfb->filterScale = 1; - cldfb_init_proto_and_twiddles_enc_fx( h_cldfb ); +/*-------------------------------------------------------------------* + * configureCldfb() + * + * configures a CLDFB handle + *--------------------------------------------------------------------*/ - return; -} void configureCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ const Word32 sampling_rate /* i : sampling rate */ ) { - h_cldfb->no_col = CLDFB_NO_COL_MAX; move16(); h_cldfb->bandsToZero = 0; move16(); - h_cldfb->nab = 0; - move16(); // h_cldfb->no_channels = (int16_t) ( sampling_rate * INV_CLDFB_BANDWIDTH + 0.5f ); h_cldfb->no_channels = extract_l( Mpy_32_32_r( sampling_rate, INV_CLDFB_BANDWIDTH_Q31 ) ); @@ -1376,6 +1354,8 @@ void configureCldfb_ivas_fx( move16(); h_cldfb->synScalefactor = 0; move16(); + h_cldfb->filterScale = 1; + move16(); h_cldfb->p_filter_length = i_mult( 10, h_cldfb->no_channels ); move16(); @@ -1383,17 +1363,20 @@ void configureCldfb_ivas_fx( return; } + + /*-------------------------------------------------------------------* * openClfdb() * * open and configures a CLDFB handle *--------------------------------------------------------------------*/ + ivas_error openCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - const Word16 enc_dec ) /* i : encoder/decoder flag */ + const Word16 enc_dec ) /* i : encoder/decoder flag */ { HANDLE_CLDFB_FILTER_BANK hs; Word16 buf_len; @@ -1407,17 +1390,19 @@ ivas_error openCldfb_ivas_fx( move32(); hs->prototype = prototype; move32(); + + configureCldfb_ivas_fx( hs, sampling_rate ); + IF( enc_dec == ENC ) { - configureCldfb_ivas_enc_fx( hs, sampling_rate ); hs->Q_cldfb_state = 0; } ELSE { - configureCldfb_ivas_fx( hs, sampling_rate ); hs->Q_cldfb_state = Q11; } move16(); + hs->memory32 = NULL; hs->FilterStates = NULL; hs->memory_length = 0; @@ -1450,11 +1435,13 @@ ivas_error openCldfb_ivas_fx( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * resampleCldfb_ivas() * * Change sample rate of filter bank *--------------------------------------------------------------------*/ + void resampleCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ const Word32 newSamplerate ) @@ -1475,19 +1462,21 @@ void resampleCldfb_ivas_fx( return; } -static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | pointer to the result in the core look-ahead slot */ - Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot */ - const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ - Word16 **realValues, /*!< i: Q(sf_Values) | the real part of the CLDFB subsamples */ - Word16 **imagValues, /*!< i: Q(sf_Values) | the imaginary part of the CLDFB subsamples */ - Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ - Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ - Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ - Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ - Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ - Word32 *energyValuesSum, /*!< o: Q(2*sf_Values-4) | pointer to sum array of energy values, not initialized*/ - Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ - TEC_ENC_HANDLE hTecEnc ) + +static void GetEnergyCldfb_ivas_fx( + Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | pointer to the result in the core look-ahead slot */ + Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot */ + const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ + Word16 **realValues, /*!< i: Q(sf_Values) | the real part of the CLDFB subsamples */ + Word16 **imagValues, /*!< i: Q(sf_Values) | the imaginary part of the CLDFB subsamples */ + Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ + Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ + Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ + Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ + Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ + Word32 *energyValuesSum, /*!< o: Q(2*sf_Values-4) | pointer to sum array of energy values, not initialized*/ + Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ + TEC_ENC_HANDLE hTecEnc ) { Word16 j; Word16 k; @@ -1713,7 +1702,14 @@ void analysisCldfbEncoder_ivas_fx( return; } -void deleteCldfb_ivas_fx( + +/*-------------------------------------------------------------------* + * deleteCldfb() + * + * Remove and deallcoate handle + *--------------------------------------------------------------------*/ + +void deleteCldfb_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ ) { @@ -1966,351 +1962,13 @@ static void cldfb_init_proto_and_twiddles( return; } -static void cldfb_init_proto_and_twiddles_enc_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -) -{ - /*find appropriate set of rotVecs*/ - SWITCH( hs->no_channels ) - { - case 10: - hs->rot_vec_ana_re_fx = rot_vec_ana_re_L10_fx; - hs->rot_vec_ana_im_fx = rot_vec_ana_im_L10_fx; - hs->rot_vec_syn_re_fx = rot_vec_syn_re_L10_fx; - hs->rot_vec_syn_im_fx = rot_vec_syn_im_L10_fx; - hs->rRotVctr = rRotVectr_10; - hs->iRotVctr = iRotVectr_10; - IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) - { - hs->synScalefactor = add( cldfb_synScale[0], hs->filterScale ); - move16(); - } - ELSE - { - hs->anaScalefactor = add( cldfb_anaScale[0], hs->filterScale ); - move16(); - } - IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_1_25MS ) ) - { - hs->ds = 10; - hs->da = 10; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = NULL; - hs->rot_vec_ana_delay_im_fx = NULL; - hs->rot_vec_syn_delay_re_fx = NULL; - hs->rot_vec_syn_delay_im_fx = NULL; - hs->scale = cldfb_scale_2_5ms[0]; - move16(); - move16(); - hs->p_filter_32 = CLDFB80_10_fx; - } - ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) - { - hs->ds = 40; - hs->da = -20; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_32 = LDQMF_10_fx; - hs->scale = cldfb_scale_5_0ms[0]; - move16(); - move16(); - } - BREAK; - - case 16: - hs->rot_vec_ana_re_fx = rot_vec_ana_re_L16_fx; - hs->rot_vec_ana_im_fx = rot_vec_ana_im_L16_fx; - hs->rot_vec_syn_re_fx = rot_vec_syn_re_L16_fx; - hs->rot_vec_syn_im_fx = rot_vec_syn_im_L16_fx; - hs->rRotVctr = rRotVectr_16; - hs->iRotVctr = iRotVectr_16; - { - hs->anaScalefactor = add( cldfb_anaScale[1], hs->filterScale ); - move16(); - } - IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_1_25MS ) ) - { - hs->ds = 20; - hs->da = 20; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = NULL; - hs->rot_vec_ana_delay_im_fx = NULL; - hs->rot_vec_syn_delay_re_fx = NULL; - hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_32 = CLDFB80_16_fx; - hs->scale = cldfb_scale_2_5ms[1]; - move16(); - move16(); - } - ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) - { - hs->ds = 80; - hs->da = -40; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_32 = LDQMF_16_fx; - hs->scale = cldfb_scale_5_0ms[1]; - move16(); - move16(); - } - BREAK; - - case 20: - hs->rRotVctr = rRotVectr_20; - hs->iRotVctr = iRotVectr_20; - hs->rot_vec_ana_re_fx = rot_vec_ana_re_L20_fx; - hs->rot_vec_ana_im_fx = rot_vec_ana_im_L20_fx; - hs->rot_vec_syn_re_fx = rot_vec_syn_re_L20_fx; - hs->rot_vec_syn_im_fx = rot_vec_syn_im_L20_fx; - IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) - { - hs->synScalefactor = add( cldfb_synScale[2], hs->filterScale ); - move16(); - } - ELSE - { - hs->anaScalefactor = add( cldfb_anaScale[2], hs->filterScale ); - move16(); - } - IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_1_25MS ) ) - { - hs->ds = 20; - hs->da = 20; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = NULL; - hs->rot_vec_ana_delay_im_fx = NULL; - hs->rot_vec_syn_delay_re_fx = NULL; - hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_32 = CLDFB80_20_fx; - hs->scale = cldfb_scale_2_5ms[2]; - move16(); - move16(); - } - ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) - { - hs->ds = 80; - hs->da = -40; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_32 = LDQMF_20_fx; - hs->scale = cldfb_scale_5_0ms[2]; - move16(); - move16(); - } - BREAK; - - case 30: - hs->rot_vec_ana_re_fx = rot_vec_ana_re_L30_fx; - hs->rot_vec_ana_im_fx = rot_vec_ana_im_L30_fx; - hs->rot_vec_syn_re_fx = rot_vec_syn_re_L30_fx; - hs->rot_vec_syn_im_fx = rot_vec_syn_im_L30_fx; - hs->rRotVctr = rRotVectr_30; - hs->iRotVctr = iRotVectr_30; - IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) - { - hs->synScalefactor = add( cldfb_synScale[6], hs->filterScale ); - move16(); - } - ELSE - { - hs->anaScalefactor = add( cldfb_anaScale[6], hs->filterScale ); - move16(); - } - IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_1_25MS ) ) - { - hs->ds = 30; - hs->da = 30; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = NULL; - hs->rot_vec_ana_delay_im_fx = NULL; - hs->rot_vec_syn_delay_re_fx = NULL; - hs->rot_vec_syn_delay_im_fx = NULL; - hs->scale = cldfb_scale_2_5ms[6]; - hs->p_filter_32 = CLDFB80_30_fx; - } - ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) - { - hs->ds = 120; - hs->da = -60; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->scale = cldfb_scale_5_0ms[6]; - hs->p_filter_32 = LDQMF_30_fx; - move16(); - move16(); - } - BREAK; - - case 32: - hs->rot_vec_ana_re_fx = rot_vec_ana_re_L32_fx; - hs->rot_vec_ana_im_fx = rot_vec_ana_im_L32_fx; - hs->rot_vec_syn_re_fx = rot_vec_syn_re_L32_fx; - hs->rot_vec_syn_im_fx = rot_vec_syn_im_L32_fx; - hs->rRotVctr = rRotVectr_32; - hs->iRotVctr = iRotVectr_32; - { - hs->anaScalefactor = add( cldfb_anaScale[3], hs->filterScale ); - move16(); - } - IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_1_25MS ) ) - { - hs->ds = 32; - hs->da = 32; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = NULL; - hs->rot_vec_ana_delay_im_fx = NULL; - hs->rot_vec_syn_delay_re_fx = NULL; - hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_32 = CLDFB80_32_fx; - hs->scale = cldfb_scale_2_5ms[3]; - move16(); - move16(); - } - ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) - { - hs->ds = 160; - hs->da = -80; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->scale = cldfb_scale_5_0ms[3]; - hs->p_filter_32 = LDQMF_32_fx; - move16(); - move16(); - } - BREAK; - - case 40: - hs->rot_vec_ana_re_fx = rot_vec_ana_re_L40_fx; - hs->rot_vec_ana_im_fx = rot_vec_ana_im_L40_fx; - hs->rot_vec_syn_re_fx = rot_vec_syn_re_L40_fx; - hs->rot_vec_syn_im_fx = rot_vec_syn_im_L40_fx; - hs->rRotVctr = rRotVectr_40; - hs->iRotVctr = iRotVectr_40; - IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) - { - hs->synScalefactor = add( cldfb_synScale[4], hs->filterScale ); - move16(); - } - ELSE - { - hs->anaScalefactor = add( cldfb_anaScale[4], hs->filterScale ); - move16(); - } - IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_1_25MS ) ) - { - hs->ds = 40; - hs->da = 40; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = NULL; - hs->rot_vec_ana_delay_im_fx = NULL; - hs->rot_vec_syn_delay_re_fx = NULL; - hs->rot_vec_syn_delay_im_fx = NULL; - hs->scale = cldfb_scale_2_5ms[4]; - hs->p_filter_32 = CLDFB80_40_fx; - move16(); - move16(); - } - ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) - { - hs->ds = 160; - hs->da = -80; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_32 = LDQMF_40_fx; - hs->scale = cldfb_scale_5_0ms[4]; - move16(); - move16(); - } - BREAK; - - case 60: - hs->rot_vec_ana_re_fx = rot_vec_ana_re_L60_fx; - hs->rot_vec_ana_im_fx = rot_vec_ana_im_L60_fx; - hs->rot_vec_syn_re_fx = rot_vec_syn_re_L60_fx; - hs->rot_vec_syn_im_fx = rot_vec_syn_im_L60_fx; - hs->rRotVctr = rRotVectr_60; - hs->iRotVctr = iRotVectr_60; - IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) - { - hs->synScalefactor = add( cldfb_synScale[5], hs->filterScale ); - move16(); - } - ELSE - { - hs->anaScalefactor = add( cldfb_anaScale[5], hs->filterScale ); - move16(); - } - IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_1_25MS ) ) - { - hs->ds = 60; - hs->da = 60; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = NULL; - hs->rot_vec_ana_delay_im_fx = NULL; - hs->rot_vec_syn_delay_re_fx = NULL; - hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_32 = CLDFB80_60_fx; - hs->scale = cldfb_scale_2_5ms[5]; - move16(); - move16(); - } - ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) - { - hs->ds = 240; - hs->da = -120; - move16(); - move16(); - hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; - hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_32 = LDQMF_60_fx; - hs->scale = cldfb_scale_5_0ms[5]; - move16(); - move16(); - } - break; - } - - return; -} /*-------------------------------------------------------------------* * cldfb_save_memory_ivas() * * Save the memory of filter; to be restored with cldfb_restore_memory_ivas() *--------------------------------------------------------------------*/ + ivas_error cldfb_save_memory_ivas_fx( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ ) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ddd0bfdcc..5eb847ad1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4639,28 +4639,30 @@ void cldfbSynthesis_fx( Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ ); -void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< CLDFB Handle */ - const Word16 no_channels, /*!< Number of critically sampled bands */ - const Word16 frameSize /*!< FrameSize */ +void configureCldfb( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< CLDFB Handle */ + const Word32 sampling_rate /* i : sampling rate */ ); -ivas_error openCldfb( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /*!< CLDFB Handle */ - const Word16 type, /*!< analysis or synthesis */ - const Word16 maxCldfbBands, /*!< number of cldfb bands */ - const Word16 frameSize /*!< FrameSize */ +ivas_error openCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /*!< CLDFB Handle */ + const Word16 type, /*!< analysis or synthesis */ + const Word32 sampling_rate /* i : sampling rate */ ); + void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ - const Word16 newCldfbBands, /*!< number of cldfb bands */ + const Word32 sampling_rate, /* i : sampling rate */ const Word16 frameSize, /*!< FrameSize */ const Word8 firstFrame ); -Word16 -AnalysisPostSpectrumScaling_Fx( HANDLE_CLDFB_FILTER_BANK cldfbBank, - Word32 **rSubband32, - Word32 **iSubband32, - Word16 **rSubband16, - Word16 **iSubband16, - Word16 *cldfbScale ); + +Word16 AnalysisPostSpectrumScaling_Fx( + HANDLE_CLDFB_FILTER_BANK cldfbBank, + Word32 **rSubband32, + Word32 **iSubband32, + Word16 **rSubband16, + Word16 **iSubband16, + Word16 *cldfbScale ); void analysisCldfbEncoder_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -4673,28 +4675,32 @@ void analysisCldfbEncoder_fx( Word16 *enerBuffSum_exp, CLDFB_SCALE_FACTOR *scale ); -void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ - Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ - const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ - Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ - Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ - Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ - Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ - Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ - Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ - Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ - Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ - Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ - TEC_ENC_HANDLE hTECEnc ); +void GetEnergyCldfb( + Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ + Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ + const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ + Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ + Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ + Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ + Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ + Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ + Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ + Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ + Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ + Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ + TEC_ENC_HANDLE hTECEnc ); -Word16 -CLDFB_getNumChannels( Word32 sampleRate ); +ivas_error cldfb_save_memory( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: cldfb handle */ +); -void deleteCldfb( HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ +void cldfb_restore_memory( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: cldfb handle */ +); -ivas_error cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ -void cldfb_restore_memory( HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ -void cldfb_reset_memory( HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ +void cldfb_reset_memory( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: cldfb handle */ +); // bits_alloc.c from IVAS void BITS_ALLOC_init_config_acelp( @@ -7385,13 +7391,7 @@ void generate_masking_noise_mdct_ivas_fx( Word32 *mdctBuffer, /* i/o: time-dom Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); -// init_dec_fx.c ivas_error init_decoder_fx( - Decoder_State *st_fx, /* o: Decoder static variables structure */ - const Word16 idchan /* i : channel ID */ -); - -ivas_error init_decoder_ivas_fx( Decoder_State *st_fx, /* o: Decoder static variables structure */ const Word16 idchan, /* i : channel ID */ const MC_MODE mc_mode /* i : MC mode */ @@ -9459,7 +9459,7 @@ Word16 deindex_lvq_ivas_fx( ); -void deleteCldfb_ivas_fx( +void deleteCldfb_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ ); @@ -10246,10 +10246,6 @@ ivas_error acelp_core_dec_fx( const Word16 read_sid_info /* i : read SID info flag */ ); -void destroy_cldfb_decoder_ivas_fx( - Decoder_State *st /* o : Decoder static variables structure */ -); - void wtda_fx32( const Word32 *new_audio, /* i : input audio Q11 */ Word32 *wtda_audio, /* o : windowed audio Q11 */ @@ -10764,11 +10760,6 @@ ivas_error IGF_Reconfig_fx( const Word16 rf_mode /* i : flag to signal the RF mode */ ); -void configureCldfb_ivas_enc_fx( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - const Word32 sampling_rate /* i : sampling rate */ -); - void core_switching_post_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index d9cb1919e..4d100280f 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -6776,17 +6776,6 @@ const Word16 cldfb_scale_2_5ms[7] = 22588/*88.234489 Q8*/ /* 30 bands */ }; -const Word16 cldfb_scale_5_0ms[7] = -{ - 21649/*88.293854 Q8*/, /* 10 bands */ - 21649/*88.299622 Q8*/, /* 16 bands */ - 21649/*88.300926 Q8*/, /* 20 bands */ - 21649/*88.303848 Q8*/, /* 32 bands */ - 21649/*88.304718 Q8*/, /* 40 bands */ - 22535/*88.028412 Q8*/, /* 60 bands */ - 21581/*88.028412 Q8*/ /* 30 bands */ -}; - /*Q31*/ const Word32 rot_vec_syn_re_L10_fx[5] = diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index d91abed59..b99ddbb97 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1155,7 +1155,7 @@ extern const Word16 cldfb_synGain[]; // Q0 extern const Word16 *cldfb_protoFilter_2_5ms[]; // extern const Word16 *cldfb_protoFilter_5_0ms[]; extern const Word16 cldfb_scale_2_5ms[7]; // Q8 -extern const Word16 cldfb_scale_5_0ms[7]; // Q8 + extern const Word32 rot_vec_syn_re_L10_fx[5]; // Q31 extern const Word32 rot_vec_syn_im_L10_fx[5]; // Q31 diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index c50e99711..992adfb7d 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -627,12 +627,14 @@ typedef struct cldfb_filter_bank_struct const Word32 *rot_vec_syn_delay_re_fx; // Q31 const Word32 *rot_vec_syn_delay_im_fx; // Q31 + /* rotation vectors for delay */ const Word32 *rot_vec_ana_re_fx; // Q29 const Word32 *rot_vec_ana_im_fx; // Q29 const Word32 *rot_vec_ana_delay_re_fx; // Q31 const Word32 *rot_vec_ana_delay_im_fx; // Q31 + // Fix variables Word16 *FilterStates; /*!< Pointer to buffer of filter states Q15-FilterStates_eg*/ Word16 FilterStates_e[CLDFB_NO_COL_MAX + 9]; /*!< Filter states time slot exponents */ @@ -642,17 +644,14 @@ typedef struct cldfb_filter_bank_struct const Word16 *iRotVctr; /*Q(sqrt(1.0/16.00))*/ Word16 filterScale; /*!< filter scale Q0*/ - Word16 synGain; /*!< gain for synthesis filterbank Q0*/ - Word16 anaScalefactor; /*!< Scale factor of analysis cldfb Q0*/ - Word16 synScalefactor; /*!< Scale factor of synthesis cldfb Q0*/ - Word16 outScalefactor; /*!< Scale factor of output data (syn only) Q0*/ - Word16 synFilterHeadroom; /*!< Headroom for states in synthesis cldfb filterbank Q0*/ - + Word16 synGain; /*!< gain for synthesis filterbank Q0*/ + Word16 anaScalefactor; /*!< Scale factor of analysis cldfb Q0*/ + Word16 synScalefactor; /*!< Scale factor of synthesis cldfb Q0*/ + Word16 outScalefactor; /*!< Scale factor of output data (syn only) Q0*/ /* memory helper states */ Word16 *memory; // Qx Word32 *memory32; // Q_cldfb_state /*because cldfb_state_fx is word32 which is used to assign values*/ - UWord16 memory_length; /* main filter state */ @@ -663,9 +662,7 @@ typedef struct cldfb_filter_bank_struct /* other parameters */ Word16 bandsToZero; /* bands not synthesized */ - Word16 nab; /* number of active bands */ - Word16 filtermode; - Word16 scale; /* scaling of frequency domain */ /* Q8 */ + Word16 scale; /* scaling of frequency domain Q8 */ } CLDFB_FILTER_BANK, *HANDLE_CLDFB_FILTER_BANK; diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 144762f74..31883fa0b 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1757,9 +1757,8 @@ ivas_error acelp_core_dec_fx( IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame ) { /* resample to ACELP internal sampling rate */ - Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 ); - resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 ); + resampleCldfb( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ), st->L_frame, 0 ); + resampleCldfb( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ), st->L_frame, 0 ); IF( st->ini_frame > 0 ) { diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index d5a3cf71a..82619a87d 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -854,10 +854,8 @@ ivas_error amr_wb_dec_fx( IF( NE_16( i_mult( st_fx->cldfbAna->usb, st_fx->cldfbAna->no_col ), L_FRAME ) ) { /* resample to ACELP internal sampling rate */ - Word16 newCldfbBands = CLDFB_getNumChannels( INT_FS_FX ); - - resampleCldfb( st_fx->cldfbAna, newCldfbBands, L_FRAME, 0 ); - resampleCldfb( st_fx->cldfbBPF, newCldfbBands, L_FRAME, 0 ); + resampleCldfb( st_fx->cldfbAna, INT_FS_FX, L_FRAME, 0 ); + resampleCldfb( st_fx->cldfbBPF, INT_FS_FX, L_FRAME, 0 ); IF( st_fx->ini_frame > 0 ) { diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 3ff221588..a4f4ef77c 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -209,15 +209,14 @@ static void decode_frame_type_fx( Decoder_State *st ) /* Reconf Core */ mode_switch_decoder_LPD_fx( st, st->bwidth, st->total_brate, frame_size_index ); + /* Reconf CLDFB */ IF( NE_16( i_mult( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) { - Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, 50 ) ); - - resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 ); + resampleCldfb( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ), st->L_frame, 0 ); IF( LE_16( st->L_frame, L_FRAME16k ) ) { - resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 ); + resampleCldfb( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ), st->L_frame, 0 ); } } IF( EQ_16( st->bwidth, NB ) ) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index d0231395b..498b20acc 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -1020,10 +1020,8 @@ ivas_error evs_dec_fx( /* check if the CLDFB works on the right sample rate */ IF( NE_16( i_mult( st_fx->cldfbAna->no_channels, st_fx->cldfbAna->no_col ), st_fx->L_frame ) ) { - Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st_fx->L_frame, 50 ) ); - - resampleCldfb( st_fx->cldfbAna, newCldfbBands, st_fx->L_frame, 0 ); - resampleCldfb( st_fx->cldfbBPF, newCldfbBands, st_fx->L_frame, 0 ); + resampleCldfb( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 0 ); + resampleCldfb( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 0 ); } st_fx->cldfbSyn->bandsToZero = 0; diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 7a89118c3..4f4191ee3 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1,3 +1,35 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + /*==================================================================================== EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ @@ -10,13 +42,8 @@ #include "basop_util.h" #include "ivas_prot_fx.h" -/*----------------------------------------------------------------------* - * init_decoder() - * - * Initialization of static variables for the decoder - *----------------------------------------------------------------------*/ - -ivas_error init_decoder_fx( +#if 1 +ivas_error init_decoder_evs( Decoder_State *st_fx, /* o: Decoder static variables structure */ const Word16 idchan /* i : channel ID */ ) @@ -26,9 +53,6 @@ ivas_error init_decoder_fx( error = IVAS_ERR_OK; move16(); - Word16 newCldfbBands; - st_fx->total_num_bits = -1; - move16(); /*-----------------------------------------------------------------* * ACELP core parameters @@ -59,7 +83,6 @@ ivas_error init_decoder_fx( st_fx->extl_brate = 0; move16(); - st_fx->last_coder_type = GENERIC; move16(); st_fx->last_L_frame = st_fx->L_frame; @@ -72,7 +95,6 @@ ivas_error init_decoder_fx( st_fx->last_extl = st_fx->extl; move16(); - /* LSF initilaizations */ Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); @@ -114,6 +136,7 @@ ivas_error init_decoder_fx( st_fx->mem_deemph_fx = 0; // Q_syn move16(); + /*-----------------------------------------------------------------* * SWB BWE parameters *-----------------------------------------------------------------*/ @@ -213,6 +236,7 @@ ivas_error init_decoder_fx( /*-----------------------------------------------------------------* * parameters for fast recovery (WI) *-----------------------------------------------------------------*/ + test(); IF( EQ_32( st_fx->output_Fs, 16000 ) && ( st_fx->element_mode == EVS_MONO ) ) { @@ -317,9 +341,11 @@ ivas_error init_decoder_fx( move16(); st_fx->Q_stat_noise = 31; move16(); + /*-----------------------------------------------------------------* * LD music post-filter *-----------------------------------------------------------------*/ + test(); test(); IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) @@ -644,22 +670,25 @@ ivas_error init_decoder_fx( { st_fx->hBPF = NULL; } + /*-----------------------------------------------------------------* * FD BPF & resampling tools parameters *-----------------------------------------------------------------*/ + /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, CLDFB_getNumChannels( 48000 ), 320 ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000 ) ), IVAS_ERR_OK ) ) { return error; } /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, CLDFB_getNumChannels( 16000 ), 320 ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000 ) ), IVAS_ERR_OK ) ) { return error; } + /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, CLDFB_getNumChannels( st_fx->output_Fs ), st_fx->output_frame_fx ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs ) ), IVAS_ERR_OK ) ) { return error; } @@ -745,11 +774,8 @@ ivas_error init_decoder_fx( st_fx->m_old_frame_type = ACTIVE_FRAME; move16(); - - newCldfbBands = CLDFB_getNumChannels( L_mult0( st_fx->L_frame, 50 ) ); - - resampleCldfb( st_fx->cldfbAna, newCldfbBands, st_fx->L_frame, 1 ); - resampleCldfb( st_fx->cldfbBPF, newCldfbBands, st_fx->L_frame, 1 ); + resampleCldfb( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); + resampleCldfb( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); test(); IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ ) @@ -828,14 +854,14 @@ ivas_error init_decoder_fx( return error; } - +#endif /*----------------------------------------------------------------------* - * init_decoder_ivas_fx() + * init_decoder() * - * Initialization of static variables for the IVAS decoder + * Initialization of static variables for the decoder *----------------------------------------------------------------------*/ -ivas_error init_decoder_ivas_fx( +ivas_error init_decoder_fx( Decoder_State *st_fx, /* o: Decoder static variables structure */ const Word16 idchan, /* i : channel ID */ const MC_MODE mc_mode /* i : MC mode */ @@ -1098,10 +1124,10 @@ ivas_error init_decoder_ivas_fx( st_fx->hWIDec = NULL; } - /* NB post-filter */ /*-----------------------------------------------------------------* * NB/formant post-filter *-----------------------------------------------------------------*/ + test(); test(); IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) @@ -1740,6 +1766,7 @@ ivas_error init_decoder_ivas_fx( * * Initialization of static variables for pre-echo *----------------------------------------------------------------------*/ + void reset_preecho_dec_fx( HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ ) @@ -1771,34 +1798,13 @@ void destroy_cldfb_decoder_fx( Decoder_State *st_fx /* o: Decoder static variables structure */ ) { - /* CLDFB BPF & resampling tools */ - - /* delete analysis for max. SR 16kHz */ - deleteCldfb( &st_fx->cldfbAna ); - - /* delete analysis BPF for max. SR 16kHz */ - deleteCldfb( &st_fx->cldfbBPF ); - - /* delete synthesis for output SR */ - deleteCldfb( &st_fx->cldfbSyn ); + deleteCldfb_fx( &st_fx->cldfbAna ); /* delete analysis for max. SR 16kHz */ + deleteCldfb_fx( &st_fx->cldfbBPF ); /* delete analysis BPF for max. SR 16kHz */ + deleteCldfb_fx( &st_fx->cldfbSyn ); /* delete synthesis for output SR */ + deleteCldfb_fx( &st_fx->cldfbSynHB ); deleteFdCngDec_fx( &st_fx->hFdCngDec ); return; } - -void destroy_cldfb_decoder_ivas_fx( - Decoder_State *st /* o : Decoder static variables structure */ -) -{ - /* CLDFB BPF & resampling tools */ - deleteCldfb_ivas_fx( &st->cldfbAna ); /* delete analysis at max. sampling rate 48kHz */ - deleteCldfb_ivas_fx( &st->cldfbBPF ); /* delete analysis BPF at max. internal sampling rate 16kHz */ - deleteCldfb_ivas_fx( &st->cldfbSyn ); /* delete synthesis at output sampling rate */ - deleteCldfb_ivas_fx( &st->cldfbSynHB ); - - deleteFdCngDec_fx( &st->hFdCngDec ); - - return; -} diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index e91b7f8b0..288cd9a03 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -578,7 +578,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( test(); IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && EQ_16( nchan_transport_old, 1 ) && EQ_16( numCldfbAnalyses_old, 2 ) && GT_16( st_ivas->nchan_transport, 1 ) ) { - deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[1] ) ); + deleteCldfb_fx( &( st_ivas->cldfbAnaDec[1] ) ); numCldfbAnalyses_old = sub( numCldfbAnalyses_old, 1 ); } /* resample CLDFB analysis instances */ @@ -596,7 +596,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* delete superfluous CLDFB synthesis instances */ FOR( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ ) { - deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) ); + deleteCldfb_fx( &( st_ivas->cldfbAnaDec[i] ) ); } } ELSE IF( LT_16( numCldfbAnalyses_old, numCldfbAnalyses ) ) @@ -616,7 +616,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* delete superfluous CLDFB synthesis instances */ FOR( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ ) { - deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) ); + deleteCldfb_fx( &( st_ivas->cldfbSynDec[i] ) ); } } ELSE IF( LT_16( numCldfbSyntheses_old, numCldfbSyntheses ) ) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 5a87800f7..7fc03ad13 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2981,14 +2981,7 @@ void destroy_core_dec_fx( DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ ) { - IF( EQ_16( hCoreCoder->element_mode, EVS_MONO ) ) - { - destroy_cldfb_decoder_fx( hCoreCoder ); - } - ELSE - { - destroy_cldfb_decoder_ivas_fx( hCoreCoder ); - } + destroy_cldfb_decoder_fx( hCoreCoder ); IF( hCoreCoder->hGSCDec != NULL ) { @@ -3241,7 +3234,7 @@ void ivas_destroy_dec_fx( { IF( st_ivas->cldfbAnaDec[i] != NULL ) { - deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) ); + deleteCldfb_fx( &( st_ivas->cldfbAnaDec[i] ) ); } } @@ -3249,7 +3242,7 @@ void ivas_destroy_dec_fx( { IF( st_ivas->cldfbSynDec[i] != NULL ) { - deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) ); + deleteCldfb_fx( &( st_ivas->cldfbSynDec[i] ) ); } } diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index ef4cd013a..2d6ea5292 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -308,8 +308,8 @@ static void deallocate_CoreCoder_fx( /* CLDFB BPF & resampling tools */ IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - deleteCldfb_ivas_fx( &st->cldfbAna ); /* delete analysis at max. sampling rate 48kHz */ - deleteCldfb_ivas_fx( &st->cldfbBPF ); /* delete analysis BPF at max. internal sampling rate 16kHz */ + deleteCldfb_fx( &st->cldfbAna ); /* delete analysis at max. sampling rate 48kHz */ + deleteCldfb_fx( &st->cldfbBPF ); /* delete analysis BPF at max. internal sampling rate 16kHz */ } IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c1cc0bd04..6093a447c 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4534,7 +4534,7 @@ static ivas_error ivas_dec_reconfig_split_rend( { IF( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) { - deleteCldfb_ivas_fx( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + deleteCldfb_fx( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; move32(); } @@ -4544,7 +4544,7 @@ static ivas_error ivas_dec_reconfig_split_rend( { IF( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) { - deleteCldfb_ivas_fx( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); + deleteCldfb_fx( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; move32(); } diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 1580a7818..13e518bc3 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -109,7 +109,7 @@ void amr_wb_enc_fx( move16(); st->coder_type = GENERIC; move16(); - input_frame = st->input_frame_fx; + input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); move16(); /* frame length of the input signal */ st->extl = -1; move16(); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 8e9a82378..90d5a7b4b 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -100,7 +100,7 @@ ivas_error evs_enc_fx( * Initializiation *-----------------------------------------------------------------*/ - input_frame = st->input_frame_fx; + input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); move16(); st->core = -1; move16(); diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 0ee479a7c..a0dea46be 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -576,12 +576,12 @@ ivas_error init_encoder_fx( *-----------------------------------------------------------------*/ /* open analysis for input SR */ - if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st_fx->input_Fs ), st_fx->input_frame_fx ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, st_fx->input_Fs ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = openCldfb( &st_fx->cldfbSynTd, CLDFB_SYNTHESIS, CLDFB_getNumChannels( 16000 ), L_FRAME16k ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &st_fx->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) { return error; } @@ -720,7 +720,7 @@ ivas_error init_encoder_fx( st_fx->input_fx = st_fx->input_buff_fx + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ); set16_fx( st_fx->input_buff_fx + L_FRAME48k, 0, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); - st_fx->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->input_frame_fx ); + st_fx->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ) ); st_fx->Energy_Old_fx = 0; @@ -1014,23 +1014,6 @@ void LPDmem_enc_init_ivas_fx( return; } -/*-----------------------------------------------------------------------* - * destroy_encoder_fx() - * - * Free memory which was allocated in init_encoder_fx() - *-----------------------------------------------------------------------*/ - -void destroy_encoder_fx( - Encoder_State *st_fx /* i/o: Encoder static variables structure */ -) -{ - deleteCldfb( &st_fx->cldfbAnaEnc ); - deleteCldfb( &st_fx->cldfbSynTd ); - - deleteFdCngEnc_fx( &st_fx->hFdCngEnc ); - - return; -} ivas_error init_encoder_ivas_fx( Encoder_State *st, /* i/o: state structure */ @@ -1666,16 +1649,13 @@ ivas_error init_encoder_ivas_fx( IF( EQ_16( st->element_mode, EVS_MONO ) ) { /* open analysis for input SR */ - st->input_frame_fx = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); - - if ( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st->input_Fs ), st->input_frame_fx ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs ) ) != IVAS_ERR_OK ) { return error; } } ELSE { - IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; @@ -1793,7 +1773,7 @@ ivas_error init_encoder_ivas_fx( IF( st->element_mode == EVS_MONO ) { - if ( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, CLDFB_getNumChannels( 16000 ), L_FRAME16k ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) { return error; } @@ -2200,8 +2180,8 @@ void destroy_cldfb_encoder_fx( Encoder_State *st /* i/o: Encoder static variables structure */ ) { - deleteCldfb_ivas_fx( &st->cldfbSynTd ); - deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); + deleteCldfb_fx( &st->cldfbSynTd ); + deleteCldfb_fx( &st->cldfbAnaEnc ); deleteFdCngEnc_fx( &st->hFdCngEnc ); diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 5a3592ad2..3c491edca 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -1198,7 +1198,7 @@ void destroy_evs_core_enc_fx( { Word16 i; - destroy_encoder_fx( hCoreCoder ); + destroy_cldfb_encoder_fx( hCoreCoder ); IF( hCoreCoder->hSignalBuf != NULL ) { @@ -1350,6 +1350,7 @@ void destroy_evs_core_enc_fx( * * Close IVAS encoder handles *-------------------------------------------------------------------------*/ + void ivas_destroy_enc_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 2f765fe05..4c644f250 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -275,7 +275,7 @@ void ivas_masa_enc_close_fx( FOR( i = 0; i < ( *hMasa )->data.num_Cldfb_instances; i++ ) { - deleteCldfb_ivas_fx( &( ( *hMasa )->data.cldfbAnaEnc[i] ) ); + deleteCldfb_fx( &( ( *hMasa )->data.cldfbAnaEnc[i] ) ); } IF( ( *hMasa )->data.hOmasaData != NULL ) diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index cbbbacf09..a8978c1fe 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -242,7 +242,7 @@ void ivas_omasa_enc_close_fx( FOR( i = 0; i < ( *hOMasa )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas_fx( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); + deleteCldfb_fx( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); } FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 180e175ec..a36fe44de 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -472,7 +472,6 @@ ivas_error create_sce_enc_fx( move32(); st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; st->input_Fs = st_ivas->hEncoderConfig->input_Fs; - st->input_frame_fx = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) { @@ -556,9 +555,6 @@ ivas_error create_evs_sce_enc_fx( st_fx->total_brate = st_ivas->hEncoderConfig->ivas_total_brate; move32(); - st_fx->input_frame_fx = extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ); - move16(); - IF( NE_32( ( error = init_encoder_fx( st_fx, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ) ), IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 469bf211a..60215658f 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -183,7 +183,7 @@ static void deallocate_CoreCoder_enc_fx( IF( st->cldfbAnaEnc != NULL ) { - deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); + deleteCldfb_fx( &st->cldfbAnaEnc ); } IF( st->hBWE_TD != NULL ) @@ -194,7 +194,7 @@ static void deallocate_CoreCoder_enc_fx( IF( st->cldfbSynTd != NULL ) { - deleteCldfb_ivas_fx( &st->cldfbSynTd ); + deleteCldfb_fx( &st->cldfbSynTd ); } IF( st->hBWE_FD != NULL ) @@ -362,8 +362,8 @@ ivas_error stereo_memory_enc_fx( IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) || EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) ) { /* Deallocate MDCT CNG structures */ - deleteCldfb_ivas_fx( &hCPE->hCoreCoder[0]->cldfbAnaEnc ); - deleteCldfb_ivas_fx( &hCPE->hCoreCoder[1]->cldfbAnaEnc ); + deleteCldfb_fx( &hCPE->hCoreCoder[0]->cldfbAnaEnc ); + deleteCldfb_fx( &hCPE->hCoreCoder[1]->cldfbAnaEnc ); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 8f1d2d9c9..5b381ee5b 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -263,7 +263,7 @@ ivas_error stereo_set_tdm_fx( /* deallocate CLDFB ana for secondary channel */ IF( st->cldfbAnaEnc != NULL ) { - deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); + deleteCldfb_fx( &st->cldfbAnaEnc ); } /* deallocate BWEs for secondary channel */ @@ -275,7 +275,7 @@ ivas_error stereo_set_tdm_fx( st->hBWE_TD = NULL; } - deleteCldfb_ivas_fx( &st->cldfbSynTd ); + deleteCldfb_fx( &st->cldfbSynTd ); IF( st->hBWE_FD != NULL ) { diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 295608d6f..3faf5a4bf 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1496,8 +1496,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( #ifdef DEBUG_MODE_INFO dbgwrite( inputBuffer, sizeof( int16_t ), inputBufferSize, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, 1, ENC ), ".pcm" ) ); #endif - hCoreCoder->input_frame_fx = inputBufferSize; - move32(); IF( NE_32( ( error = evs_enc_fx( hCoreCoder, inputBuffer, hCoreCoder->mem_hp20_in_fx, inputBufferSize ) ), IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 28389e9e0..3ca99fed2 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4583,10 +4583,6 @@ void copy_encoder_config_fx( const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ ); -void destroy_encoder_fx( - Encoder_State *st_fx /* i/o: Encoder static variables structure */ -); - void amr_wb_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 input_sp[], /* i : i signal Q0*/ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index fdcff722c..e82605860 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1310,7 +1310,6 @@ typedef struct enc_core_structure // Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ // Word32 core_brate_fx; /* core bitrate */ // Word32 last_core_brate_fx; /* previous frame core bitrate */ - Word16 input_frame_fx; /* Frame lenght (function of input_Fs) */ // Word16 extl_fx; /* extension layer */ // Word16 last_extl_fx; /* previous extension layer */ // Word32 extl_brate_fx; /* extension layer bitrate */ diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index f03afbeb8..1d734bed0 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -133,12 +133,12 @@ void isar_splitBinPostRendClose( { IF( ( *hBinHrSplitPostRend )->cldfbSyn[ch] != NULL ) { - deleteCldfb_ivas_fx( &( ( *hBinHrSplitPostRend )->cldfbSyn[ch] ) ); + deleteCldfb_fx( &( ( *hBinHrSplitPostRend )->cldfbSyn[ch] ) ); ( *hBinHrSplitPostRend )->cldfbSyn[ch] = NULL; } IF( ( *hBinHrSplitPostRend )->cldfbAna[ch] != NULL ) { - deleteCldfb_ivas_fx( &( ( *hBinHrSplitPostRend )->cldfbAna[ch] ) ); + deleteCldfb_fx( &( ( *hBinHrSplitPostRend )->cldfbAna[ch] ) ); ( *hBinHrSplitPostRend )->cldfbAna[ch] = NULL; } } @@ -149,7 +149,7 @@ void isar_splitBinPostRendClose( { if ( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] != NULL ) { - deleteCldfb_ivas_fx( &( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] ) ); + deleteCldfb_fx( &( ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] ) ); ( *hBinHrSplitPostRend )->cldfbSynReconsBinDec[i][ch] = NULL; } } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 71e285a9c..3287d668c 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2601,7 +2601,7 @@ void isar_splitBinPreRendClose( { IF( ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] != NULL ) { - deleteCldfb_ivas_fx( &( ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] ) ); + deleteCldfb_fx( &( ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] ) ); ( *hBinHrSplitPreRend )->cldfbSynRotBinDec[i][n] = NULL; } } diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index da4f6542f..1ebb0cca1 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -204,7 +204,7 @@ void ISAR_PRE_REND_close( { IF( hSplitBinRend->hCldfbHandles->cldfbAna[ch] != NULL ) { - deleteCldfb_ivas_fx( &hSplitBinRend->hCldfbHandles->cldfbAna[ch] ); + deleteCldfb_fx( &hSplitBinRend->hCldfbHandles->cldfbAna[ch] ); hSplitBinRend->hCldfbHandles->cldfbAna[ch] = NULL; } } @@ -213,7 +213,7 @@ void ISAR_PRE_REND_close( { IF( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] != NULL ) { - deleteCldfb_ivas_fx( &hSplitBinRend->hCldfbHandles->cldfbSyn[ch] ); + deleteCldfb_fx( &hSplitBinRend->hCldfbHandles->cldfbSyn[ch] ); hSplitBinRend->hCldfbHandles->cldfbSyn[ch] = NULL; } } diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 4e00b9623..011f7bda3 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -196,7 +196,7 @@ void ivas_dirac_ana_close_fx( FOR( i = 0; i < ( *hDirAC )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas_fx( &( ( *hDirAC )->cldfbAnaEnc[i] ) ); + deleteCldfb_fx( &( ( *hDirAC )->cldfbAnaEnc[i] ) ); } FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 432ed8253..dfb45ad6d 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -551,7 +551,7 @@ void masaPrerendClose_fx( FOR( i = 0; i < ( *hMasaPrerendPtr )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas_fx( &( ( *hMasaPrerendPtr )->cldfbAnaEnc[i] ) ); + deleteCldfb_fx( &( ( *hMasaPrerendPtr )->cldfbAnaEnc[i] ) ); } free( ( *hMasaPrerendPtr )->hMasaOut ); diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 1ce8dc77f..2e065e83b 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -414,7 +414,7 @@ void ivas_mcmasa_ana_close( FOR( i = 0; i < ( *hMcMasa )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas_fx( &( ( *hMcMasa )->cldfbAnaEnc[i] ) ); + deleteCldfb_fx( &( ( *hMcMasa )->cldfbAnaEnc[i] ) ); } /* intensity 3-dim */ diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 67e72e84c..2b2e53b97 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -251,7 +251,7 @@ void ivas_omasa_ana_close( FOR( i = 0; i < ( *hOMasa )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas_fx( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); + deleteCldfb_fx( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); } FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c74d77bf9..3721cb4ff 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8940,7 +8940,7 @@ static ivas_error getSamplesInternal( if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const Word16 )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const Word16) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -9197,7 +9197,7 @@ void IVAS_REND_closeCldfb( { IF( cldfbAna[n] != NULL ) { - deleteCldfb_ivas_fx( &( cldfbAna[n] ) ); + deleteCldfb_fx( &( cldfbAna[n] ) ); cldfbAna[n] = NULL; } } @@ -9206,7 +9206,7 @@ void IVAS_REND_closeCldfb( { IF( cldfbSyn[n] != NULL ) { - deleteCldfb_ivas_fx( &( cldfbSyn[n] ) ); + deleteCldfb_fx( &( cldfbSyn[n] ) ); cldfbSyn[n] = NULL; } } @@ -10241,7 +10241,7 @@ static void freeMasaExtRenderer( { IF( hMasaExtRend->cldfbAnaRend[i] != NULL ) { - deleteCldfb_ivas_fx( &hMasaExtRend->cldfbAnaRend[i] ); + deleteCldfb_fx( &hMasaExtRend->cldfbAnaRend[i] ); } } @@ -10249,7 +10249,7 @@ static void freeMasaExtRenderer( { IF( hMasaExtRend->cldfbSynRend[i] != NULL ) { - deleteCldfb_ivas_fx( &hMasaExtRend->cldfbSynRend[i] ); + deleteCldfb_fx( &hMasaExtRend->cldfbSynRend[i] ); } } -- GitLab From 6e90c39b7cefa49ae36eee1cc6e44cb85470b230 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 8 Sep 2025 21:09:06 +0200 Subject: [PATCH 003/351] harmonize init_decoder() --- lib_com/prot_fx.h | 8 +- lib_dec/dec4t64_fx.c | 2 - lib_dec/gs_dec_fx.c | 35 +- lib_dec/init_dec_fx.c | 914 ++----------------------- lib_dec/ivas_cpe_dec_fx.c | 2 +- lib_dec/ivas_sce_dec_fx.c | 17 +- lib_dec/ivas_stereo_switching_dec_fx.c | 2 +- lib_dec/stat_dec.h | 1 - 8 files changed, 80 insertions(+), 901 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 5eb847ad1..20c00a39f 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6683,11 +6683,7 @@ void gsc_dec_fx( Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *Q_exc ); -void GSC_dec_init( - GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ -); - -void GSC_dec_init_ivas_fx( +void GSC_dec_init_fx( GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ ); @@ -7392,7 +7388,7 @@ void generate_masking_noise_mdct_ivas_fx( Word32 *mdctBuffer, /* i/o: time-dom HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); ivas_error init_decoder_fx( - Decoder_State *st_fx, /* o: Decoder static variables structure */ + Decoder_State *st_fx, /* o : Decoder static variables structure */ const Word16 idchan, /* i : channel ID */ const MC_MODE mc_mode /* i : MC mode */ ); diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index ee6ef65a6..1b56c69cf 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -871,8 +871,6 @@ void dec_acelp_fast_fx( move16(); set16_fx( code, 0, L_subfr ); - st->total_num_bits = extract_l( st->total_brate / FRAMES_PER_SEC ); - IF( EQ_16( L_subfr, L_SUBFR ) ) { config = PulseConfTable[cdk_index]; diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index a17ca6feb..d174cd87b 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -867,7 +867,7 @@ void gsc_dec_fx( * Initialize GSC decoder state structure *-------------------------------------------------------------------*/ -void GSC_dec_init( +void GSC_dec_init_fx( GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ ) { @@ -881,43 +881,16 @@ void GSC_dec_init( move16(); move16(); - set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME ); - set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME ); - set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN ); - set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN ); /*Q12*/ - - hGSCDec->last_ener_fx = 0; - move16(); - set16_fx( hGSCDec->last_bitallocation_band, 0, 6 ); - - hGSCDec->Last_frame_ener_fx = MAX_32; - move32(); - return; -} - -void GSC_dec_init_ivas_fx( - GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ -) -{ - hGSCDec->seed_tcx = 15687; /* Q0 */ - move16(); - hGSCDec->cor_strong_limit = 1; - move16(); - set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN ); - hGSCDec->noise_lev = NOISE_LEVEL_SP0; - move16(); set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME16k ); - hGSCDec->Last_GSC_pit_band_idx = 0; - move16(); - - set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN16k ); /*Q12*/ set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME16k ); + set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN16k ); + set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN16k ); /*Q12*/ + hGSCDec->last_ener_fx = 0; move16(); set16_fx( hGSCDec->last_bitallocation_band, 0, 6 ); hGSCDec->Last_frame_ener_fx = MAX_32; move32(); - return; } diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 4f4191ee3..c05e5fb71 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -42,819 +42,7 @@ #include "basop_util.h" #include "ivas_prot_fx.h" -#if 1 -ivas_error init_decoder_evs( - Decoder_State *st_fx, /* o: Decoder static variables structure */ - const Word16 idchan /* i : channel ID */ -) -{ - Word16 i; - ivas_error error; - - error = IVAS_ERR_OK; - move16(); - - /*-----------------------------------------------------------------* - * ACELP core parameters - *-----------------------------------------------------------------*/ - - st_fx->codec_mode = MODE1; - move16(); - st_fx->last_codec_mode = MODE1; - move16(); - st_fx->core = ACELP_CORE; - move16(); - st_fx->L_frame = L_FRAME; - move16(); - st_fx->extl = -1; - move16(); - st_fx->total_brate = 8000; - move16(); - st_fx->last_total_brate = -1; - move16(); - st_fx->last_total_brate_ber = -1; - move32(); - st_fx->core_brate = 8000; - move16(); - st_fx->ini_frame = 0; - move16(); - st_fx->bwidth = NB; - move16(); - st_fx->extl_brate = 0; - move16(); - - st_fx->last_coder_type = GENERIC; - move16(); - st_fx->last_L_frame = st_fx->L_frame; - move16(); - st_fx->last_core_brate = st_fx->core_brate; - move16(); - - st_fx->last_core = -1; - move16(); - st_fx->last_extl = st_fx->extl; - move16(); - - /* LSF initilaizations */ - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - - init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); - - set16_fx( st_fx->mem_MA_fx, 0, M ); - - st_fx->dm_fx.prev_state = 0; // Q0 - move16(); /* This corresponds to st_fx->dispMem in FLP */ - st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); // Q16 - FOR( i = 2; i < 8; i++ ) - { - st_fx->dm_fx.prev_gain_pit[i - 2] = 0; // Q14 - move16(); - } - - st_fx->tilt_code_fx = 0; // Q15 - move16(); - st_fx->gc_threshold_fx = L_deposit_l( 0 ); // Q16 - st_fx->last_good = UNVOICED_CLAS; - move16(); - st_fx->clas_dec = UNVOICED_CLAS; - move16(); - - st_fx->lp_gainp_fx = 0; // Q14 - move16(); - st_fx->lp_gainc_fx = 0; // Q3 - move16(); - - set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC ); // Q_exc - - /* AVQ pre-quantizer memory */ - st_fx->mem_preemp_preQ_fx = 0; - move16(); - st_fx->last_nq_preQ = 0; - move16(); - st_fx->use_acelp_preq = 0; - move16(); - - st_fx->mem_deemph_fx = 0; // Q_syn - move16(); - - /*-----------------------------------------------------------------* - * SWB BWE parameters - *-----------------------------------------------------------------*/ - - test(); - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hBWE_FD = (FD_BWE_DEC_HANDLE) malloc( sizeof( FD_BWE_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); - } - - fd_bwe_dec_init_fx( st_fx->hBWE_FD ); - } - ELSE - { - st_fx->hBWE_FD = NULL; - } - - /*-----------------------------------------------------------------* - * IGF - *-----------------------------------------------------------------*/ - - test(); - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) ); - } - - st_fx->igf = 0; - move16(); - init_igf_dec( st_fx->hIGFDec ); - } - ELSE - { - st_fx->hIGFDec = NULL; - } - - /*-----------------------------------------------------------------* - * HR SWB BWE parameters - *-----------------------------------------------------------------*/ - - IF( st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hBWE_FD_HR = (HR_BWE_DEC_HANDLE) malloc( sizeof( HR_BWE_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HR BWE\n" ) ); - } - - hr_bwe_dec_init( st_fx->hBWE_FD_HR ); - } - ELSE - { - st_fx->hBWE_FD_HR = NULL; - } - set16_fx( st_fx->mem_syn1_fx, 0, M ); - set16_fx( st_fx->mem_syn2_fx, 0, M ); - st_fx->stab_fac_fx = 0; // Q15 - move16(); - st_fx->stab_fac_smooth_fx = 0; // Q15 - move16(); - set16_fx( st_fx->agc_mem_fx, 0, 2 ); // Q0 - set32_fx( st_fx->L_mem_hp_out_fx, 0, 5 ); - set16_fx( st_fx->mem_syn3_fx, 0, M ); - - - Copy( GEWB_Ave_fx, st_fx->lsf_old_fx, M ); - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); - st_fx->mid_lsf_int = 0; - move16(); - st_fx->safety_net = 0; - move16(); - st_fx->GSC_noisy_speech = 0; - move16(); - st_fx->last_voice_factor_fx = 0; // Q6 - move16(); - - - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hGSCDec = (GSC_DEC_HANDLE) malloc( sizeof( GSC_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); - } - - GSC_dec_init( st_fx->hGSCDec ); - } - ELSE - { - st_fx->hGSCDec = NULL; - } - - /*-----------------------------------------------------------------* - * parameters for fast recovery (WI) - *-----------------------------------------------------------------*/ - - test(); - IF( EQ_32( st_fx->output_Fs, 16000 ) && ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hWIDec = (WI_DEC_HANDLE) malloc( sizeof( WI_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FEC WI\n" ) ); - } - - set16_fx( st_fx->hWIDec->old_exc2_fx, 0, L_EXC_MEM ); - set16_fx( st_fx->hWIDec->old_syn2_fx, 0, L_EXC_MEM ); - } - ELSE - { - st_fx->hWIDec = NULL; - } - - /* NB post-filter */ - /*-----------------------------------------------------------------* - * NB/formant post-filter - *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hPFstat = (PFSTAT_HANDLE) malloc( sizeof( PFSTAT ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for NB/formant postflter\n" ) ); - } - - Init_post_filter_fx( st_fx->hPFstat ); - st_fx->psf_lp_noise_fx = 0; // Q8 - move16(); - } - ELSE - { - st_fx->hPFstat = NULL; - } - st_fx->psf_lp_noise_fx = 0; // Q8 - move16(); - - /* FEC */ - st_fx->scaling_flag = 0; - move16(); - st_fx->lp_ener_FEC_av = 500000; // Q0 - move32(); - st_fx->lp_ener_FEC_max = 500000; // Q0 - move32(); - st_fx->prev_bfi = 0; - move16(); - st_fx->lp_ener_FER_fx = 15360; // Q8 - move16(); /*60 in Q8*/ - st_fx->old_enr_LP = 0; // Q5 - move16(); - st_fx->lp_ener_fx = L_deposit_l( 0 ); // Q6 - st_fx->enr_old_fx = L_deposit_l( 0 ); // Q0 - st_fx->bfi_pitch_fx = L_SUBFR_Q6; - move16(); - st_fx->bfi_pitch_frame = L_SUBFR; - move16(); - set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); - st_fx->classifier_Q_mem_syn = 0; - move16(); - st_fx->last_con_tcx = 0; - move16(); - - FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) - { - st_fx->old_pitch_buf_fx[i] = L_SUBFR << 16; // Q16 - move32(); /*15Q16*/ - } - - st_fx->upd_cnt = MAX_UPD_CNT; - move16(); - Copy( GEWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); - - st_fx->seed_acelp = RANDOM_INITSEED; - move16(); - st_fx->seed = RANDOM_INITSEED; - move16(); - st_fx->nbLostCmpt = 0; - move16(); - st_fx->decision_hyst = 0; - move16(); - - - /* Stationary noise UV modification */ - st_fx->unv_cnt = 0; - move16(); - st_fx->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ - st_fx->uv_count = 0; - move16(); - st_fx->act_count = 3; - move16(); - Copy( st_fx->lsp_old_fx, st_fx->lspold_s_fx, M ); // Q15 - st_fx->noimix_seed = RANDOM_INITSEED; - move16(); - st_fx->min_alpha_fx = 32767; // Q15 - move16(); /*1; Q15*/ - st_fx->exc_pe_fx = 0; // Q_stat_noise - move16(); - st_fx->Q_stat_noise = 31; - move16(); - - /*-----------------------------------------------------------------* - * LD music post-filter - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hMusicPF = (MUSIC_POSTFILT_HANDLE) malloc( sizeof( MUSIC_POSTFILT_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LD music postflter\n" ) ); - } - - music_postfilt_init( st_fx->hMusicPF ); - } - ELSE - { - st_fx->hMusicPF = NULL; - } - - /* CNG and DTX */ - test(); - test(); - test(); - IF( idchan == 0 && ( ( st_fx->element_mode == EVS_MONO ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) - { - IF( ( st_fx->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); - } - - td_cng_dec_init_fx( st_fx ); - } - ELSE - { - st_fx->hTdCngDec = NULL; - } - st_fx->cng_type = -1; - move16(); - st_fx->first_CNG = 0; - move16(); - Copy( st_fx->lsp_old_fx, st_fx->lspCNG_fx, M ); // Q15 - - st_fx->CNG_mode = -1; - move16(); - st_fx->last_active_brate = ACELP_7k20; - move32(); - st_fx->last_CNG_L_frame = L_FRAME; - move16(); - - - st_fx->last_vad_fx = 0; - move16(); - - /* HF (6-7kHz) BWE */ - move16(); - st_fx->Q_stat_noise_ge = GE_SHIFT; // Q of ge_sm_fx - move16(); - st_fx->cngTDLevel = 0; - move16(); - st_fx->cngTDLevel_e = 0; - move16(); - - - /*-----------------------------------------------------------------* - * HQ core parameters - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || EQ_16( st_fx->element_mode, IVAS_SCE ) || ( st_fx->element_mode == EVS_MONO ) ) ) - { - IF( ( st_fx->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); - } - - /* HQ core initialization */ - HQ_core_dec_init_fx( st_fx->hHQ_core ); - - IF( st_fx->element_mode == EVS_MONO ) - { - /* HQ NB FEC initialization */ - IF( ( st_fx->hHQ_nbfec = (HQ_NBFEC_HANDLE) malloc( sizeof( HQ_NBFEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ NB FEC\n" ) ); - } - HQ_nbfec_init_fx( st_fx->hHQ_nbfec ); - } - ELSE - { - st_fx->hHQ_nbfec = NULL; - } - } - ELSE - { - st_fx->hHQ_core = NULL; - st_fx->hHQ_nbfec = NULL; - } - st_fx->Qprev_synth_buffer_fx = 15; - move16(); - st_fx->old_bfi_cnt = 0; - move16(); - st_fx->prev_old_bfi = 0; - move16(); - set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); - set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k ); - IF( st_fx->element_mode == EVS_MONO ) - { - set16_fx( st_fx->old_synth_sw_fx, 0, NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ) ); - } - /*-----------------------------------------------------------------* - * TCX core - *-----------------------------------------------------------------*/ - - /* TCX-LTP */ - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - IF( ( st_fx->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); - } - } - ELSE - { - st_fx->hTcxLtpDec = NULL; - } - - /* TCX core */ - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxDec\n" ) ); - } - - set16_fx( st_fx->hTcxDec->FBTCXdelayBuf, 0, 111 ); - - st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ); - st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); - } - ELSE - { - st_fx->hTcxDec = NULL; - } - /* TCX config. data structure */ - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); - } - } - ELSE - { - st_fx->hTcxCfg = NULL; - } - - /* Tonal MDCT concealment data structure */ - - if ( ( st_fx->hTonalMDCTConc = (TonalMDCTConcealPtr) malloc( sizeof( TonalMDCTConceal_INSTANCE ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n" ) ); - } - - st_fx->prev_coder_type = GENERIC; - move16(); - - move16(); - st_fx->tilt_wb_fx = 0; // Q11 - move16(); - - set16_fx( st_fx->prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS ) ); - st_fx->old_bwe_delay = -1; /*Q0*/ - move16(); - - /*-----------------------------------------------------------------* - * TBE parameters - *-----------------------------------------------------------------*/ - - test(); - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st_fx->hBWE_TD = (TD_BWE_DEC_HANDLE) malloc( sizeof( TD_BWE_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); - } - - td_bwe_dec_init_fx( st_fx->hBWE_TD, st_fx->extl, st_fx->output_Fs ); - - st_fx->prev_Q_bwe_exc = 31; - move16(); - } - ELSE - { - st_fx->hBWE_TD = NULL; - } - - st_fx->tilt_swb_fx = 0; // Q24 - move16(); - st_fx->tilt_wb_fx = 0; // Q11 - move16(); - - st_fx->prev_ener_shb_fx = 0; // Q1 - move16(); - st_fx->prev_enerLH_fx = 0; // Q1 - move16(); - st_fx->enerLH_fx = L_deposit_l( 0 ); - st_fx->enerLL_fx = L_deposit_l( 0 ); - st_fx->prev_enerLL_fx = 0; - move16(); - st_fx->prev_fractive = 0; - move16(); - st_fx->prev_bws_cnt = 0; - move16(); - st_fx->bws_cnt = N_WS2N_FRAMES; - move16(); - st_fx->bws_cnt1 = N_NS2W_FRAMES; - move16(); - st_fx->attenu_fx = 3277; // Q15 - move16(); - st_fx->last_inner_frame = L_FRAME8k; - move16(); - st_fx->last_bwidth = 0; - move16(); - - /*-----------------------------------------------------------------* - * channel-aware mode parameters - *-----------------------------------------------------------------*/ - - set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k ); - - st_fx->use_partial_copy = 0; - move16(); - st_fx->prev_use_partial_copy = 0; - move16(); - st_fx->rf_flag = 0; - move16(); - st_fx->rf_flag_last = 0; - st_fx->prev_rf_frame_type = 0; - move16(); - st_fx->next_coder_type = 0; - move16(); - - st_fx->rf_target_bits = 0; - move16(); - - st_fx->rf_indx_nelp_fid = 0; - move16(); - st_fx->rf_indx_nelp_iG1 = 0; - move16(); - st_fx->rf_indx_nelp_iG2[0] = 0; - move16(); - st_fx->rf_indx_nelp_iG2[1] = 0; - move16(); - st_fx->rf_indx_tbeGainFr = 0; - move16(); - - /*----------------------------------------------------------------------------------* - * AMR-WB IO mode parameters - *----------------------------------------------------------------------------------*/ - test(); - IF( st_fx->Opt_AMR_WB || ( st_fx->element_mode == EVS_MONO ) ) - { - IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_DEC_HANDLE) malloc( sizeof( AMRWB_IO_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); - } - - /* AMR-WB IO init */ - amr_wb_dec_init_fx( st_fx->hAmrwb_IO ); - - /* AMR-WB IO HF synth init */ - hf_synth_amr_wb_init_fx( st_fx->hAmrwb_IO ); - } - ELSE - { - st_fx->hAmrwb_IO = NULL; - } - /*-----------------------------------------------------------------* - * HF (6-7kHz) (zero) BWE parameters - *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hBWE_zero = (ZERO_BWE_DEC_HANDLE) malloc( sizeof( ZERO_BWE_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for zero BWE\n" ) ); - } - - hf_synth_init_fx( st_fx->hBWE_zero ); - /* TBV Hack for bit exactness with 26.452, Issue should be corrected there as the the reset is not perform on all values of mem_hp400_fx*/ - set16_fx( st_fx->hBWE_zero->mem_hp400_fx, 0, 6 ); - } - ELSE - { - st_fx->hBWE_zero = NULL; - } - - /* HF synth init */ - hf_synth_amr_wb_init_fx( st_fx->hAmrwb_IO ); - - - st_fx->bpf_off = 0; - move16(); - /*-----------------------------------------------------------------* - * Bass post-filter parameters - *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hBPF = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF\n" ) ); - } - - bass_psfilter_init_fx( st_fx->hBPF ); - } - ELSE - { - st_fx->hBPF = NULL; - } - - /*-----------------------------------------------------------------* - * FD BPF & resampling tools parameters - *-----------------------------------------------------------------*/ - - /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000 ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000 ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs ) ), IVAS_ERR_OK ) ) - { - return error; - } - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move32(); - st_fx->last_active_bandsToZero_bwdec = 0; - st_fx->perc_bwddec = 0; - st_fx->last_flag_filter_NB = 0; - st_fx->active_frame_cnt_bwddec = 0; - st_fx->total_frame_cnt_bwddec = 0; - set16_fx( st_fx->flag_buffer, 0, 20 ); - st_fx->avg_nrg_LT = 0; - - st_fx->Ng_ener_ST_fx = -13056; - move16(); /*-51 IN Q8*/ - st_fx->old_Es_pred_fx = 0; - move16(); - set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); - st_fx->old_Aq_12_8_fx[0] = 4096; - move16(); /*1 in Q12*/ - - /*-----------------------------------------------------------------* - * SC-VBR parameters - *-----------------------------------------------------------------*/ - - IF( st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hSC_VBR = (SC_VBR_DEC_HANDLE) malloc( sizeof( SC_VBR_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); - } - - sc_vbr_dec_init( st_fx->hSC_VBR ); - } - ELSE - { - st_fx->hSC_VBR = NULL; - } - - st_fx->last_ppp_mode_dec = 0; - move16(); - st_fx->old_ppp_mode = 0; - move16(); - st_fx->ppp_mode_dec = 0; - move16(); - st_fx->last_nelp_mode_dec = 0; - move16(); - st_fx->nelp_mode_dec = 0; - move16(); - st_fx->prev_gain_pit_dec_fx = 0; - move16(); - st_fx->prev_tilt_code_dec_fx = 0; - move16(); - st_fx->vbr_hw_BWE_disable_dec = 0; - move16(); - st_fx->last_vbr_hw_BWE_disable_dec = 0; - move16(); - - /*-----------------------------------------------------------------* - * Mode 2 initialization - *-----------------------------------------------------------------*/ - - IF( ( st_fx->hPlcInfo = (T_PLCInfo_HANDLE) malloc( sizeof( T_PLCInfo ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PLC handle\n" ) ); - } - - st_fx->enablePlcWaveadjust = 0; - move16(); - - /* Init Decoder */ - open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->bwidth ); - - st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; - move16(); - st_fx->m_frame_type = ACTIVE_FRAME; - move16(); - st_fx->m_old_frame_type = ACTIVE_FRAME; - move16(); - - resampleCldfb( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); - resampleCldfb( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); - - test(); - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ ) - { - /* Create FD_CNG instance */ - - IF( NE_32( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* Init FD-CNG */ - initFdCngDec_fx( st_fx, st_fx->cldfbSyn->scale ); - } - ELSE - { - st_fx->hFdCngDec = NULL; - } - - st_fx->lp_noise = -167772160l /*-20.f Q23*/; - move32(); - st_fx->force_lpd_reset = 0; - move16(); - - /*-----------------------------------------------------------------* - * initialzie Q values - *-----------------------------------------------------------------*/ - - st_fx->Q_syn2 = 0; - move16(); - st_fx->Q_exc = 8; - st_fx->prev_Q_exc = 0; - move16(); - st_fx->Q_syn = 0; - move16(); - st_fx->prev_Q_syn = 0; - move16(); - - FOR( i = 0; i < L_Q_MEM; i++ ) - { - st_fx->Q_subfr[i] = 8; - move16(); - } - - st_fx->prev_Q_exc_fr = 0; - move16(); - st_fx->prev_Q_syn_fr = 0; - move16(); - - /*----------------------------------------------------------------------------------* - * Stereo/IVAS parameters - *----------------------------------------------------------------------------------*/ - st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ - move16(); - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ - move16(); - st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ - move16(); - st_fx->element_mode = EVS_MONO; /* element mode */ - move16(); - st_fx->element_brate = -1; /* element bitrate */ - move16(); - st_fx->low_rate_mode = 0; /* low-rate mode flag */ - move16(); - st_fx->last_low_rate_mode = 0; /* low-rate mode flag */ - move16(); -#ifdef DEBUGGING - st_fx->id_element = -1; /* element ID */ -#endif - st_fx->extl_orig = -1; /* extension layer */ - move16(); - st_fx->extl_brate_orig = 0; /* extension layer bitrate */ - move16(); - - return error; -} - -#endif /*----------------------------------------------------------------------* * init_decoder() * @@ -862,9 +50,9 @@ ivas_error init_decoder_evs( *----------------------------------------------------------------------*/ ivas_error init_decoder_fx( - Decoder_State *st_fx, /* o: Decoder static variables structure */ - const Word16 idchan, /* i : channel ID */ - const MC_MODE mc_mode /* i : MC mode */ + Decoder_State *st_fx, /* o : Decoder static variables structure */ + const Word16 idchan, /* i : channel ID */ + const MC_MODE mc_mode /* i : MC mode */ ) { Word16 i; @@ -1098,7 +286,7 @@ ivas_error init_decoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); } - GSC_dec_init_ivas_fx( st_fx->hGSCDec ); + GSC_dec_init_fx( st_fx->hGSCDec ); } ELSE { @@ -1444,32 +632,56 @@ ivas_error init_decoder_fx( /*-----------------------------------------------------------------* * FD BPF & resampling tools parameters *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + + IF( st_fx->element_mode == EVS_MONO ) { /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000 ) ), IVAS_ERR_OK ) ) { return error; } /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000 ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* open synthesis for output SR */ + IF( NE_32( ( error = openCldfb( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs ) ), IVAS_ERR_OK ) ) { return error; } } ELSE { - st_fx->cldfbAna = NULL; - st_fx->cldfbBPF = NULL; - } + test(); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + /* open analysis for max. SR 48kHz */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) - { - return error; + /* open analysis BPF for max. SR 16kHz */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE + { + st_fx->cldfbAna = NULL; + st_fx->cldfbBPF = NULL; + } + + /* open synthesis for output SR */ + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) + { + return error; + } } st_fx->cldfbSynHB = NULL; @@ -1630,6 +842,7 @@ ivas_error init_decoder_fx( /*-----------------------------------------------------------------* * Mode 2 initialization *-----------------------------------------------------------------*/ + IF( ( st_fx->element_mode == EVS_MONO ) ) { IF( ( st_fx->hPlcInfo = (T_PLCInfo_HANDLE) malloc( sizeof( T_PLCInfo ) ) ) == NULL ) @@ -1654,18 +867,24 @@ ivas_error init_decoder_fx( st_fx->hTECDec = NULL; } - /* Init Decoder */ - Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - open_decoder_LPD_ivas_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); + IF( st_fx->element_mode == EVS_MONO ) + { + open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->bwidth ); + } + ELSE + { + Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + open_decoder_LPD_ivas_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); + } /* PLC mode initialization */ st_fx->m_decodeMode = DEC_NO_FRAM_LOSS; @@ -1677,11 +896,19 @@ ivas_error init_decoder_fx( st_fx->m_old_frame_type = ACTIVE_FRAME; move16(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + IF( st_fx->element_mode == EVS_MONO ) + { + resampleCldfb( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); + resampleCldfb( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ), st_fx->L_frame, 1 ); + } + ELSE { - resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb_ivas_fx( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + test(); + IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) + { + resampleCldfb_ivas_fx( st_fx->cldfbAna, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb_ivas_fx( st_fx->cldfbBPF, L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); + } } /*-----------------------------------------------------------------* @@ -1694,7 +921,6 @@ ivas_error init_decoder_fx( IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) { /* Create FD_CNG instance */ - IF( NE_32( ( error = createFdCngDec_fx( &st_fx->hFdCngDec ) ), IVAS_ERR_OK ) ) { return error; diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index a149f78b3..720d9905f 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -1320,7 +1320,7 @@ ivas_error create_cpe_dec( st->is_ism_format = 0; move16(); - IF( NE_32( ( error = init_decoder_ivas_fx( st, n, st_ivas->mc_mode ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = init_decoder_fx( st, n, st_ivas->mc_mode ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 6e1893015..77c53c5ef 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -416,22 +416,9 @@ ivas_error create_sce_dec( move16(); } - // if (st_ivas->mode == IVAS_DEC_MODE_EVS) - IF( EQ_16( st->element_mode, EVS_MONO ) ) + IF( ( error = init_decoder_fx( st, 0, st_ivas->mc_mode ) ) != IVAS_ERR_OK ) { - error = init_decoder_fx( st, EVS_MONO ); - IF( error ) - { - return error; - } - } - ELSE - { - error = init_decoder_ivas_fx( st, 0, st_ivas->mc_mode ); - IF( error ) - { - return error; - } + return error; } IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) ) diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 2d6ea5292..a4b8f2353 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -159,7 +159,7 @@ static ivas_error allocate_CoreCoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); } - GSC_dec_init_ivas_fx( st->hGSCDec ); + GSC_dec_init_fx( st->hGSCDec ); } IF( st->hPFstat == NULL ) diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 0c5f7db85..5e99ad185 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1032,7 +1032,6 @@ typedef struct Decoder_State Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME/VOIP_G192_RTP/VOIP_RTPDUMP) */ Word16 sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ Word16 amrwb_rfc4867_flag; /* MIME from rfc4867 is used */ - Word16 total_num_bits; /* == st->total_brate / 50 */ Word16 BER_detect; /* flag to signal detected bit error in the bitstream */ Word32 output_Fs; /* output sampling rate */ Word16 output_frame_fx; /* Output frame length Q0*/ -- GitLab From 1859de271f138e1ba8117af8952e044a94149ee1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 8 Sep 2025 21:47:34 +0200 Subject: [PATCH 004/351] remove create_evs_sce_enc_fx() --- lib_com/ivas_prot_fx.h | 13 +-- lib_dec/init_dec_fx.c | 1 + lib_enc/init_enc_fx.c | 8 +- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 2 +- lib_enc/ivas_init_enc_fx.c | 28 ++--- lib_enc/ivas_sce_enc_fx.c | 134 +++++------------------ 6 files changed, 40 insertions(+), 146 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 12ad07e5c..5ab2b2509 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -60,15 +60,8 @@ void ivas_masa_dec_close_fx( MASA_DECODER_HANDLE *hMasa /* i/o: MASA metadata structure */ ); -ivas_error create_evs_sce_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 sce_id, /* i : SCE # identifier */ - const Word32 element_brate /* i : element bitrate */ -); - void destroy_sce_enc_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - Flag is_evs /* i : Flag to indicate EVS encoder */ + SCE_ENC_HANDLE hSCE /* i/o: SCE encoder structure */ ); void generate_gridEq_fx( @@ -807,10 +800,6 @@ void destroy_core_enc_fx( ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ ); -void destroy_evs_core_enc_fx( - ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ -); - ivas_error ivas_sce_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 sce_id, /* i : SCE # identifier */ diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index c05e5fb71..39cc5d065 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -358,6 +358,7 @@ ivas_error init_decoder_fx( /*-----------------------------------------------------------------* * LD music post-filter *-----------------------------------------------------------------*/ + test(); test(); IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index a0dea46be..00c482f6c 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -886,6 +886,7 @@ ivas_error init_encoder_fx( InitTransientDetection_fx( extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ), NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), &st_fx->transientDetection ); + st_fx->hTranDet = NULL; st_fx->Q_syn2 = 0; move16(); @@ -2124,9 +2125,8 @@ ivas_error init_encoder_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } - Word16 temp; - Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp ); - frame_length = shr( frame_length, sub( 15, temp ) ); + + Word16 frame_length = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); IF( GT_16( st->element_mode, EVS_MONO ) ) { @@ -2134,7 +2134,7 @@ ivas_error init_encoder_ivas_fx( } ELSE { - InitTransientDetection_fx( extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ), + InitTransientDetection_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), &st->transientDetection ); } diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 019361561..ce2fa0d93 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -372,7 +372,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( q_input_buff[sce_id] = st_ivas->hSCE[sce_id]->hCoreCoder[0]->q_old_inp32; move16(); } - destroy_sce_enc_fx( st_ivas->hSCE[sce_id], ( EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) && !st_ivas->hEncoderConfig->stereo_dmx_evs ) ); + destroy_sce_enc_fx( st_ivas->hSCE[sce_id] ); st_ivas->hSCE[sce_id] = NULL; } diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 3c491edca..1b35b7022 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -421,6 +421,7 @@ void ivas_initialize_handles_enc_fx( * * Initialize IVAS encoder state structure *-------------------------------------------------------------------*/ + ivas_error ivas_init_encoder_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) @@ -565,11 +566,13 @@ ivas_error ivas_init_encoder_fx( move16(); sce_id = 0; move16(); + test(); - IF( NE_32( ( error = create_evs_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) ) { return error; } + /* prepare stereo downmix for EVS */ IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) ) { @@ -1034,6 +1037,8 @@ ivas_error ivas_init_encoder_fx( return error; } + + /*------------------------------------------------------------------------- * destroy_core_enc() * @@ -1044,8 +1049,6 @@ void destroy_core_enc_fx( ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ ) { - Word16 i; - destroy_cldfb_encoder_fx( hCoreCoder ); IF( hCoreCoder->hSignalBuf != NULL ) @@ -1056,12 +1059,6 @@ void destroy_core_enc_fx( IF( hCoreCoder->hBstr != NULL ) { - /* reset buffer of indices */ - FOR( i = 0; i < hCoreCoder->hBstr->nb_ind_tot; i++ ) - { - hCoreCoder->hBstr->ind_list[i].nb_bits = -1; - move16(); - } free( hCoreCoder->hBstr ); hCoreCoder->hBstr = NULL; } @@ -1092,8 +1089,7 @@ void destroy_core_enc_fx( IF( hCoreCoder->hVAD_CLDFB != NULL ) { - /* This is not required as we are not allocating memory dynamically */ - // free( hCoreCoder->hVAD_CLDFB ); + free( hCoreCoder->hVAD_CLDFB ); hCoreCoder->hVAD_CLDFB = NULL; } @@ -1198,14 +1194,6 @@ void destroy_evs_core_enc_fx( { Word16 i; - destroy_cldfb_encoder_fx( hCoreCoder ); - - IF( hCoreCoder->hSignalBuf != NULL ) - { - free( hCoreCoder->hSignalBuf ); - hCoreCoder->hSignalBuf = NULL; - } - IF( hCoreCoder->hBstr != NULL ) { /* reset buffer of indices */ @@ -1364,7 +1352,7 @@ void ivas_destroy_enc_fx( { if ( st_ivas->hSCE[i] != NULL ) { - destroy_sce_enc_fx( st_ivas->hSCE[i], EQ_16( st_ivas->hEncoderConfig->element_mode_init, EVS_MONO ) ); + destroy_sce_enc_fx( st_ivas->hSCE[i] ); st_ivas->hSCE[i] = NULL; } } diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index a36fe44de..aeb4f9c60 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -385,17 +385,18 @@ ivas_error ivas_sce_enc_fx( } #endif - pop_wmops(); return error; } + /*------------------------------------------------------------------------- * create_sce_enc() * * Create, allocate and initialize IVAS encoder SCE handle *-------------------------------------------------------------------------*/ + ivas_error create_sce_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const Word16 sce_id, /* i : SCE # identifier */ @@ -404,7 +405,6 @@ ivas_error create_sce_enc_fx( { SCE_ENC_HANDLE hSCE; Encoder_State *st; - ivas_error error; error = IVAS_ERR_OK; @@ -433,6 +433,7 @@ ivas_error create_sce_enc_fx( /*-----------------------------------------------------------------* * Metadata: allocate and initialize *-----------------------------------------------------------------*/ + test(); IF( NE_16( st_ivas->hEncoderConfig->ivas_format, MONO_FORMAT ) && EQ_16( sce_id, sub( st_ivas->nSCE, 1 ) ) ) { @@ -473,123 +474,47 @@ ivas_error create_sce_enc_fx( st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; st->input_Fs = st_ivas->hEncoderConfig->input_Fs; - IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) - { - return error; - } - hSCE->hCoreCoder[0] = st; - - st_ivas->hSCE[sce_id] = hSCE; - - return error; -} - -/*------------------------------------------------------------------------- - * create_evs_sce_enc_fx() - * - * Create, allocate and initialize EVS encoder SCE handle - *-------------------------------------------------------------------------*/ -ivas_error create_evs_sce_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 sce_id, /* i : SCE # identifier */ - const Word32 element_brate /* i : element bitrate */ -) -{ - SCE_ENC_HANDLE hSCE = st_ivas->hSCE[sce_id]; - Encoder_State *st_fx; - - ivas_error error; - - error = IVAS_ERR_OK; - move32(); - - /*-----------------------------------------------------------------* - * Allocate SCE handle - *-----------------------------------------------------------------*/ - - IF( ( hSCE = (SCE_ENC_HANDLE) malloc( sizeof( SCE_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SCE\n" ) ); - } - - /*-----------------------------------------------------------------* - * Initialization - general parameters - *-----------------------------------------------------------------*/ - - hSCE->sce_id = sce_id; - move16(); - hSCE->element_brate = element_brate; - move32(); - hSCE->last_element_brate = hSCE->element_brate; - move32(); - /*-----------------------------------------------------------------* - * Metadata: allocate and initialize - *-----------------------------------------------------------------*/ - test(); - IF( NE_32( st_ivas->hEncoderConfig->ivas_format, MONO_FORMAT ) && EQ_16( sce_id, sub( st_ivas->nSCE, 1 ) ) ) + IF( st->element_mode == EVS_MONO ) { - IF( NE_32( ( error = ivas_initialize_MD_bstr_enc_fx( &( hSCE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = init_encoder_fx( st, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ) ), IVAS_ERR_OK ) ) { return error; } - } - ELSE - { - hSCE->hMetaData = NULL; - } - /*-----------------------------------------------------------------* - * Core Coder, 1 instance: allocate and initialize - *-----------------------------------------------------------------*/ - IF( ( st_fx = (ENC_CORE_HANDLE) malloc( sizeof( Encoder_State ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) ); + /* set pointer to the buffer of indices */ + st->hBstr->ind_list = st_ivas->ind_list; + st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; + st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; + st->hBstr->nb_ind_tot = 0; + move16(); + st->hBstr->nb_bits_tot = 0; + move16(); + st->hBstr->st_ivas = st_ivas; } - memset( st_fx, 0, sizeof( Encoder_State ) ); - - copy_encoder_config_fx( st_ivas, st_fx, 1 ); - - st_fx->bitstreamformat = G192; - move16(); - - st_fx->total_brate = st_ivas->hEncoderConfig->ivas_total_brate; - move32(); - - IF( NE_32( ( error = init_encoder_fx( st_fx, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ) ), IVAS_ERR_OK ) ) + ELSE { - return error; + IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) + { + return error; + } } - /*-----------------------------------------------------------------* - * Bitstream - *-----------------------------------------------------------------*/ - - /* set pointer to the buffer of indices */ - st_fx->hBstr->ind_list = st_ivas->ind_list; - st_fx->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - st_fx->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; - st_fx->hBstr->nb_ind_tot = 0; - move16(); - st_fx->hBstr->nb_bits_tot = 0; - move16(); - st_fx->hBstr->st_ivas = st_ivas; - - hSCE->hCoreCoder[0] = st_fx; + hSCE->hCoreCoder[0] = st; st_ivas->hSCE[sce_id] = hSCE; return error; } + /*------------------------------------------------------------------------- - * destroy_sce_enc_fx() + * destroy_sce_enc() * * Destroy and deallocate IVAS encoder SCE handle *-------------------------------------------------------------------------*/ void destroy_sce_enc_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - Flag is_evs /* i : Flag to indicate EVS encoder*/ + SCE_ENC_HANDLE hSCE /* i/o: SCE encoder structure */ ) { Encoder_State *st; @@ -598,17 +523,8 @@ void destroy_sce_enc_fx( IF( st != NULL ) { - test(); - IF( ( st->element_mode == EVS_MONO ) && is_evs ) - { - destroy_evs_core_enc_fx( st ); - st = NULL; - } - ELSE - { - destroy_core_enc_fx( st ); - st = NULL; - } + destroy_core_enc_fx( st ); + st = NULL; } ivas_destroy_MD_bstr_enc_fx( &( hSCE->hMetaData ) ); -- GitLab From 2a0141aeecb6bb26d6648fdf75e9d5da7c9d63e5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 9 Sep 2025 13:35:23 +0200 Subject: [PATCH 005/351] - updates to init_encoder_ivas_fx() - remove duplication of st->last_vad_spa_fx - remove duplication of st->last_ener_fx --- lib_com/prot_fx.h | 24 +- lib_dec/fd_cng_dec_fx.c | 2 +- lib_enc/fd_cng_enc_fx.c | 39 +- lib_enc/gs_enc_fx.c | 2 +- lib_enc/init_enc_fx.c | 621 +++++++++++++++++++----------- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 2 +- lib_enc/ivas_spar_encoder_fx.c | 2 +- lib_enc/prot_fx_enc.h | 26 +- lib_enc/speech_music_classif_fx.c | 4 +- lib_enc/stat_enc.h | 3 - lib_enc/transient_detection_fx.c | 18 +- 12 files changed, 451 insertions(+), 294 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 20c00a39f..7cf0148eb 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7270,15 +7270,15 @@ void FEC_lsf2lsp_interp( ); -// fd_cng_dec_fx.c -ivas_error createFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ); +ivas_error createFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); void initFdCngDec_fx( DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - Word16 scale ); + const Word16 scale ); -/* Delete the instance of type FD_CNG */ -void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ); +void deleteFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); /* Configure CLDFB-CNG */ void configureFdCngDec_fx( @@ -11053,14 +11053,12 @@ void read_next_force( #endif ivas_error init_encoder_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ - const Word16 interval_SID, /* i : interval for SID update */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ ); ivas_error acelp_core_enc_ivas_fx( diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 47724c6e6..087351c7e 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -193,7 +193,7 @@ void initFdCngDec_ivas_fx( void initFdCngDec_fx( DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - Word16 scale /*Q15*/ ) + const Word16 scale /*Q15*/ ) { /* Initialize common */ HANDLE_FD_CNG_DEC hFdCngDec; diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 587016e5f..fefc18855 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -35,26 +35,33 @@ extern void BASOP_getTables( const PWord16 **ptwiddle, const PWord16 **sin_twidd /************************************* * Create an instance of type FD_CNG * *************************************/ -void createFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc ) +ivas_error createFdCngEnc_fx( + HANDLE_FD_CNG_ENC *hFdCngEnc ) { HANDLE_FD_CNG_ENC hs; + ivas_error error; /* Allocate memory */ - hs = (HANDLE_FD_CNG_ENC) calloc( 1, sizeof( FD_CNG_ENC ) ); - move16(); + IF( ( hs = (HANDLE_FD_CNG_ENC) malloc( sizeof( FD_CNG_ENC ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FD CNG ENC structure" ); + } + IF( ( error = createFdCngCom_fx( &( hs->hFdCngCom ) ) ) != IVAS_ERR_OK ) + { + return error; + } - createFdCngCom_fx( &( hs->hFdCngCom ) ); *hFdCngEnc = hs; move16(); - return; + return IVAS_ERR_OK; } void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, - Word32 input_Fs, /* Q0 */ - Word16 scale ) + const Word32 input_Fs, /* Q0 */ + const Word16 scale ) { Word16 j; HANDLE_FD_CNG_COM hsCom = hsEnc->hFdCngCom; @@ -155,9 +162,11 @@ void initFdCngEnc_fx( /************************************ * Configure FD_CNG * ************************************/ -void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */ - Word16 bandwidth, /* i: bandwidth Q0*/ - Word32 bitrate /* Q0 */ + +void configureFdCngEnc_fx( + HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bandwidth, /* i: bandwidth Q0*/ + const Word32 bitrate /* Q0 */ ) { HANDLE_FD_CNG_COM hsCom = hsEnc->hFdCngCom; @@ -279,6 +288,8 @@ void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variabl BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); hsCom->frameSize = shr( hsCom->fftlen, 1 ); move16(); + + return; } void configureFdCngEnc_ivas_fx( @@ -416,12 +427,14 @@ void configureFdCngEnc_ivas_fx( return; } + /************************************** * Delete the instance of type FD_CNG * **************************************/ -void deleteFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc ) -{ +void deleteFdCngEnc_fx( + HANDLE_FD_CNG_ENC *hFdCngEnc ) +{ HANDLE_FD_CNG_ENC hsEnc; hsEnc = *hFdCngEnc; move16(); @@ -432,6 +445,8 @@ void deleteFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc ) *hFdCngEnc = NULL; move16(); } + + return; } diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 7bf52970d..58f9a8d51 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1000,7 +1000,7 @@ void gsc_enc_fx( highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, - hGSCEnc->last_exc_dct_in_fx, &st_fx->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); exc_dct_in[0] = 0; diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index b8013326f..793c5f9b8 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -// #include "prot_fx.h" /* Function prototypes */ #include "stl.h" #include "ivas_cnst.h" #include "ivas_error.h" @@ -37,112 +36,180 @@ ivas_error init_encoder_fx( move16(); ISM_MODE ism_mode = ISM_MODE_NONE; ivas_error error; + Encoder_State *st = st_fx; error = IVAS_ERR_OK; + Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + /*-----------------------------------------------------------------* * General signal buffers *-----------------------------------------------------------------*/ IF( !vad_only_flag ) { - IF( ( st_fx->hSignalBuf = (SIGNAL_BUFFERS_ENC_HANDLE) malloc( sizeof( SIGNAL_BUFFERS_ENC_DATA ) ) ) == NULL ) + IF( ( st->hSignalBuf = (SIGNAL_BUFFERS_ENC_HANDLE) malloc( sizeof( SIGNAL_BUFFERS_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Signal buffers\n" ) ); } - st_fx->Bin_E_old_fx = st_fx->hSignalBuf->Bin_E_old_fx; - st_fx->mem_decim_fx = st_fx->hSignalBuf->mem_decim_fx; - st_fx->mem_decim16k_fx = st_fx->hSignalBuf->mem_decim16k_fx; - st_fx->old_inp_12k8_fx = st_fx->hSignalBuf->old_inp_12k8_fx; - st_fx->old_inp_16k_fx = st_fx->hSignalBuf->old_inp_16k_fx; - st_fx->buf_speech_enc_pe = st_fx->hSignalBuf->buf_speech_enc_pe; - st_fx->buf_synth = st_fx->hSignalBuf->buf_synth; - st_fx->buf_speech_enc = st_fx->hSignalBuf->buf_speech_enc; - st_fx->buf_wspeech_enc = st_fx->hSignalBuf->buf_wspeech_enc; + st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx; + st->mem_decim_fx = st->hSignalBuf->mem_decim_fx; + st->mem_decim16k_fx = st->hSignalBuf->mem_decim16k_fx; + st->old_inp_12k8_fx = st->hSignalBuf->old_inp_12k8_fx; + st->old_inp_16k_fx = st->hSignalBuf->old_inp_16k_fx; + st->buf_speech_enc_pe = st->hSignalBuf->buf_speech_enc_pe; + st->buf_synth = st->hSignalBuf->buf_synth; + st->buf_speech_enc = st->hSignalBuf->buf_speech_enc; + st->buf_wspeech_enc = st->hSignalBuf->buf_wspeech_enc; + set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); + st->q_Bin_E_old = Q31; + move16(); + set16_fx( st->hSignalBuf->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + st->exp_buf_speech_enc = 0; + move16(); + set16_fx( st->hSignalBuf->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); + st->exp_buf_wspeech_enc = 0; + move16(); /* initializations */ - set16_fx( st_fx->old_inp_12k8_fx, 0, L_INP_MEM ); /* memory of input signal at 12.8kHz */ - set16_fx( st_fx->old_inp_16k_fx, 0, L_INP_MEM ); - set16_fx( st_fx->mem_decim16k_fx, 0, 2 * L_FILT_MAX ); - set16_fx( st_fx->mem_decim_fx, 0, 2 * L_FILT_MAX ); - set32_fx( st_fx->Bin_E_old_fx, 0, L_FFT / 2 ); - st_fx->q_Bin_E_old = Q31; + set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); + st->q_Bin_E_old = Q31; + move16(); + set16_fx( st->mem_decim_fx, 0, shl( L_FILT_MAX, 1 ) ); + set16_fx( st->mem_decim_fx_q_inp, 0, shl( L_FILT_MAX, 1 ) ); + set16_fx( st->mem_decim16k_fx, 0, shl( L_FILT_MAX, 1 ) ); + set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM ); + set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); + st->exp_old_inp_16k = 0; + st->exp_old_inp_12k8 = 0; + move16(); + move16(); + + st->input_buff_fx = st->hSignalBuf->input_buff; + st->input_buff32_fx = st->hSignalBuf->input_buff32; + set16_fx( st->input_buff_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); + st->q_inp = Q15; + move16(); + st->mem_preemph_q = Q15; move16(); + st->mem_q = Q15; + move16(); + st->q_old_inp = Q15; + move16(); + set32_fx( st->input_buff32_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); + st->q_inp32 = Q31; + move16(); + st->q_old_inp32 = Q31; + move16(); + st->old_input_signal_fx = st->input_buff_fx; + st->old_input_signal32_fx = st->input_buff32_fx; - st_fx->input_buff_fx = st_fx->hSignalBuf->input_buff; - set16_fx( st_fx->input_buff_fx, 0, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); - st_fx->old_input_signal_fx = st_fx->input_buff_fx; - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( st->element_mode == EVS_MONO ) { - st_fx->input_fx = st_fx->input_buff_fx + st_fx->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); + st->input32_fx = st->input_buff32_fx + add( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + st->input_fx = st->input_buff_fx + add( frame_length, NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); } ELSE { - st_fx->input_fx = st_fx->input_buff_fx + st_fx->input_Fs / FRAMES_PER_SEC; + st->input32_fx = st->input_buff32_fx + frame_length; + st->input_fx = st->input_buff_fx + frame_length; } } ELSE { - st_fx->hSignalBuf = NULL; - st_fx->Bin_E_old_fx = NULL; - st_fx->mem_decim_fx = NULL; - st_fx->mem_decim16k_fx = NULL; - st_fx->old_inp_12k8_fx = NULL; - st_fx->old_inp_16k_fx = NULL; - st_fx->buf_speech_enc_pe = NULL; - st_fx->buf_synth = NULL; - st_fx->buf_speech_enc = NULL; - st_fx->buf_wspeech_enc = NULL; - st_fx->input_buff_fx = NULL; + st->hSignalBuf = NULL; + st->Bin_E_old_fx = NULL; + st->mem_decim_fx = NULL; + st->mem_decim16k_fx = NULL; + st->old_inp_12k8_fx = NULL; + st->old_inp_16k_fx = NULL; + st->buf_speech_enc_pe = NULL; + st->buf_synth = NULL; + st->buf_speech_enc = NULL; + st->buf_wspeech_enc = NULL; + st->input_buff_fx = NULL; } /*-----------------------------------------------------------------* * ACELP core parameters *-----------------------------------------------------------------*/ - st_fx->last_core = -1; - move16(); - if ( st_fx->Opt_AMR_WB ) + IF( st->Opt_AMR_WB ) { - st_fx->last_core = AMR_WB_CORE; - move16(); + st->last_core = AMR_WB_CORE; + } + ELSE + { + st->last_core = -1; } + move16(); - st_fx->L_frame = L_FRAME; + st->L_frame = L_FRAME; + move16(); + st->last_coder_type = GENERIC; move16(); - st_fx->last_coder_type = GENERIC; + st->coder_type = GENERIC; move16(); - st_fx->last_total_brate = st_fx->total_brate; - move32(); - st_fx->last_total_brate_cng = -1; + st->last_total_brate = st->total_brate; move32(); - st_fx->last_core_brate = st_fx->total_brate; + st->last_bits_frame_nominal = -1; + move16(); + st->last_total_brate_cng = -1; + move16(); + st->last_core_brate = st->total_brate; move32(); - st_fx->extl = -1; + st->dtx_sce_sba = 0; move16(); - st_fx->last_extl = -1; + st->extl = -1; + move16(); + st->last_extl = -1; move16(); - st_fx->last_L_frame = L_FRAME; + st->last_L_frame = L_FRAME; move16(); - st_fx->rate_switching_reset = 0; + st->rate_switching_reset = 0; move16(); - st_fx->rate_switching_reset_16kHz = 0; + st->rate_switching_reset_16kHz = 0; + move16(); + st->clas = UNVOICED_CLAS; + move16(); + st->low_rate_mode = 0; + move16(); + st->ini_frame = 0; + move16(); + st->inactive_coder_type_flag = 0; + move16(); + st->sba_br_sw_while_no_data = 0; move16(); + st->coder_type_raw = VOICED; + move16(); + st->last_coder_type_raw = st->coder_type_raw; + move16(); + + st->flag_ACELP16k = set_ACELP_flag_IVAS( st->element_mode, st->total_brate, st->total_brate, idchan, 0, -1, -1 ); + move16(); + + st->is_ism_format = 0; + move16(); + if ( NE_16( ism_mode, ISM_MODE_NONE ) ) + { + st->is_ism_format = 1; + move16(); + } /*-----------------------------------------------------------------* * Bitstream *-----------------------------------------------------------------*/ IF( !vad_only_flag ) { - IF( ( st_fx->hBstr = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) + IF( ( st->hBstr = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); } } ELSE { - st_fx->hBstr = NULL; + st->hBstr = NULL; } @@ -162,135 +229,231 @@ ivas_error init_encoder_fx( init_gp_clip_fx( st_fx->clip_var_fx ); pitch_ol_init_fx( &st_fx->old_thres_fx, &st_fx->old_pitch, &st_fx->delta_pit, &st_fx->old_corr_fx ); - /*-----------------------------------------------------------------* - * AMR-WB IO initialization - *-----------------------------------------------------------------*/ - test(); - IF( st_fx->Opt_AMR_WB || EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_ENC_HANDLE) malloc( sizeof( AMRWB_IO_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); - } + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + Copy( GEWB_Ave_fx, st->lsfoldbfi0_fx, M ); + Copy( GEWB_Ave_fx, st->lsfoldbfi1_fx, M ); + Copy( GEWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); - amr_wb_enc_init_fx( st_fx->hAmrwb_IO ); - } - ELSE - { - st_fx->hAmrwb_IO = NULL; - } - st_fx->clas = UNVOICED_CLAS; + st->next_force_safety_net = 0; move16(); - set16_fx( st_fx->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); - set16_fx( st_fx->old_wsp_fx, 0, L_WSP_MEM ); - st_fx->mem_deemph_fx = 0; + + st->pstreaklen = 0; move16(); - st_fx->mem_preemph_fx = 0; + st->streaklimit_fx = MAX_WORD16; move16(); - st_fx->mem_preemph16k_fx = 0; + set16_fx( st->mem_MA_fx, 0, M ); + + init_gp_clip_fx( st->clip_var_fx ); + pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx ); + set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); + st->exp_old_wsp = 0; move16(); - st_fx->mem_preemph_enc = 0; + set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); + st->Q_old_wsp2 = 0; move16(); - /* AVQ pre-quantizer memory */ - st_fx->mem_preemp_preQ_fx = 0; + st->mem_preemph_fx = 0; move16(); - st_fx->mem_deemp_preQ_fx = 0; + st->mem_preemph_fx_q_inp = 0; + move16(); + st->mem_preemph16k_fx = 0; move16(); - st_fx->last_nq_preQ = 0; + st->mem_preemph_enc = 0; move16(); - st_fx->use_acelp_preq = 0; + st->exp_mem_preemph_enc = 0; move16(); - /* (Decimated) Weighted Speech Memory */ - st_fx->mem_wsp_enc = 0; + /* AVQ pre-quantizer memory */ + st->mem_preemp_preQ_fx = 0; move16(); - - st_fx->mem_wsp_fx = 0; + st->mem_deemp_preQ_fx = 0; move16(); - st_fx->mem_wsp_q = 0; + st->last_nq_preQ = 0; move16(); - set32_fx( st_fx->Bin_E_fx, 0, L_FFT ); - st_fx->q_Bin_E = Q31; + st->last_code_preq = 0; move16(); - set16_fx( st_fx->mem_decim2_fx, 0, 3 ); - set16_fx( st_fx->lgBin_E_fx, 0, L_FFT / 2 ); - - st_fx->ini_frame = 0; + st->use_acelp_preq = 0; move16(); - st_fx->ee_old_fx = 640; - move32(); /*chk //10 in Q6 */ - st_fx->Nb_ACELP_frames = 0; + st->last_harm_flag_acelp = 0; move16(); - st_fx->audio_frame_cnt = AUDIO_COUNTER_INI; - move16(); /* Initializatin of the audio frame counter mildly into the audio mode */ - /* adaptive lag window memory */ - st_fx->old_pitch_la = 0; + /* (Decimated) Weighted Speech Memory */ + st->mem_wsp_enc = 0; move16(); - st_fx->old_voicing_la = 0; + st->mem_wsp_fx = 0; + move16(); + st->mem_wsp_q = 0; move16(); - set32_fx( st_fx->mem_hp20_in_fx, 0, 5 ); - st_fx->old_hpfilt_in_fx = 0; + set16_fx( st->mem_decim2_fx, 0, 3 ); + set32_fx( st->Bin_E_fx, 0, L_FFT ); + st->q_Bin_E = Q31; move16(); - st_fx->old_hpfilt_out_fx = 0; + + st->ee_old_fx = 640; /* 10.0f in Q6 */ move16(); - st_fx->EnergyLT_fx = 0; - move32(); - st_fx->prev_Q_new = 0; + st->Nb_ACELP_frames = 0; + move16(); + st->audio_frame_cnt = AUDIO_COUNTER_INI; /* Initialization of the audio frame counter mildly into the audio mode */ move16(); + /* adaptive lag window memory */ + st->old_pitch_la = 0; + move16(); + + st->prev_Q_new = 0; + move16(); - IF( EQ_32( st_fx->input_Fs, 8000 ) ) + IF( EQ_32( st->input_Fs, 8000 ) ) { - st_fx->min_band = 1; + st->min_band = 1; move16(); - st_fx->max_band = 16; + st->max_band = 16; move16(); } ELSE { - st_fx->min_band = 0; + st->min_band = 0; move16(); - st_fx->max_band = 19; + st->max_band = 19; move16(); } - IF( st_fx->Opt_AMR_WB ) + + IF( st->Opt_AMR_WB ) { - Copy( mean_isf_amr_wb_fx, st_fx->lsf_old_fx, M ); - E_LPC_isf_isp_conversion( st_fx->lsf_old_fx, st_fx->lsp_old1_fx, M ); + Copy( mean_isf_amr_wb_fx, st->lsf_old_fx, M ); + E_LPC_isf_isp_conversion( st->lsf_old_fx, st->lsp_old1_fx, M ); } ELSE { - Copy( GEWB_Ave_fx, st_fx->lsf_old_fx, M ); - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old1_fx, M, INT_FS_FX ); + Copy( GEWB_Ave_fx, st->lsf_old_fx, M ); + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old1_fx, M, INT_FS_12k8 ); } - Copy( st_fx->lsf_old_fx, st_fx->lsf_old1_fx, M ); - Copy( st_fx->lsp_old1_fx, st_fx->lsp_old_fx, M ); - Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); - Copy( st_fx->lsp_old_fx, st_fx->lspold_enc_fx, M ); + Copy( st->lsf_old_fx, st->lsf_old1_fx, M ); + Copy( st->lsp_old1_fx, st->lsp_old_fx, M ); + Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); + Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); - st_fx->stab_fac_fx = 0; + st->stab_fac_fx = 0; move16(); + /* Bass post-filter memories - encoder side of MODE2 */ - st_fx->bpf_off = 0; + st->bpf_off = 0; + move16(); + st->pst_mem_deemp_err_fx = 0; + move16(); + st->pst_lp_ener_fx = 0; + move16(); + + /* TC coder type */ + st->tc_cnt = 0; + move16(); + + /* find_uv() parameters */ + st->old_dE1_fx = 0; + move16(); + st->old_ind_deltaMax = 0; + move16(); + set32_fx( st->old_enr_ssf_fx, 0, shl( NB_SSF, 1 ) ); + st->spike_hyst = -1; + move16(); + + /* stereo switching memories */ + st->mem_preemph_DFT_fx = 0; + move16(); + st->mem_preemph_DFT_fx_q_inp = 0; + move16(); + set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) ); + st->mem_preemph16k_DFT_fx = 0; + move16(); + set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) ); + + st->sharpFlag = 0; + move16(); + + /* Stationary noise UV modification */ + st->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ + move16(); + st->uv_count = 0; + move16(); + st->act_count = 3; + move16(); + Copy( st->lsp_old_fx, st->lspold_s_fx, M ); + st->noimix_seed = RANDOM_INITSEED; + move16(); + st->min_alpha_fx = 32767; + move16(); + st->exc_pe_fx = 0; + move16(); + st->Q_stat_noise = 15; + move16(); + + /* FEC */ + st->last_clas = UNVOICED_CLAS; + move16(); + st->prev_fmerit = 0; + move16(); + st->fmerit_dt = 0; + move16(); + st->Last_pulse_pos = 0; + move16(); + + FOR( i = 0; i < shl( NB_SUBFR16k, 1 ); i++ ) + { + st->old_pitch_buf_fx[i] = L_SUBFR_Q6; + move16(); + } + + /* mode1 core switching */ + st->old_Es_pred_fx = 0; + move16(); + set16_fx( st->old_Aq_12_8_fx + 1, 0, M ); + st->old_Aq_12_8_fx[0] = ONE_IN_Q12; move16(); - /* TC mode */ - st_fx->tc_cnt = 0; + /* stable short pitch detection */ + st->voicing0_sm_fx = 0; + move16(); + st->voicing_sm_fx = 0; move16(); - st_fx->mCb1_fx = 0; + st->LF_EnergyRatio_sm_fx = 1; + move16(); + st->predecision_flag = 0; move16(); + st->diff_sm_fx = 0; + move32(); + st->energy_sm_fx = 0; + move32(); + + set16_fx( st->pitch, L_SUBFR, 3 ); + set16_fx( st->voicing_fx, 0, 3 ); + + + /*-----------------------------------------------------------------* + * AMR-WB IO initialization + *-----------------------------------------------------------------*/ + test(); + IF( st_fx->Opt_AMR_WB || EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_ENC_HANDLE) malloc( sizeof( AMRWB_IO_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); + } + + amr_wb_enc_init_fx( st_fx->hAmrwb_IO ); + } + ELSE + { + st_fx->hAmrwb_IO = NULL; + } - /* AC mode */ /*-----------------------------------------------------------------* * parameters for AC coder type (GSC) *-----------------------------------------------------------------*/ - // st_fx->GSC_noisy_speech = 0; + st_fx->GSC_noisy_speech = 0; st_fx->GSC_IVAS_mode = 0; move16(); test(); @@ -309,9 +472,6 @@ ivas_error init_encoder_fx( st_fx->hGSCEnc = NULL; } - st_fx->last_ener_fx = 0; - move16(); - st_fx->old_dE1_fx = 0; move16(); st_fx->old_ind_deltaMax = 0; @@ -326,13 +486,6 @@ ivas_error init_encoder_fx( st_fx->GSC_noisy_speech = 0; move16(); - /* speech/music classifier */ - st_fx->Last_pulse_pos = 0; - move16(); - - st_fx->last_vad_spa_fx = 0; - move16(); - /*-----------------------------------------------------------------* * VAD *-----------------------------------------------------------------*/ @@ -450,32 +603,6 @@ ivas_error init_encoder_fx( move16(); - move16(); - st_fx->coder_type_raw = VOICED; - st_fx->last_coder_type_raw = st_fx->coder_type_raw; - move16(); - st_fx->is_ism_format = 0; - move16(); - if ( NE_16( ism_mode, ISM_MODE_NONE ) ) - { - st_fx->is_ism_format = 1; - move16(); - } - /* Stationary noise UV modification */ - st_fx->ge_sm_fx = 640; - move32(); /*Q(GE_SHIFT) */ - st_fx->uv_count = 0; - move16(); - st_fx->act_count = 3; - move16(); - Copy( st_fx->lsp_old_fx, st_fx->lspold_s_fx, M ); - st_fx->noimix_seed = RANDOM_INITSEED; - move16(); - st_fx->min_alpha_fx = 1; - move16(); - st_fx->exc_pe_fx = 0; - move16(); - /*-----------------------------------------------------------------* * DTX *-----------------------------------------------------------------*/ @@ -718,11 +845,6 @@ ivas_error init_encoder_fx( * HQ core parameters *-----------------------------------------------------------------*/ - st_fx->input_fx = st_fx->input_buff_fx + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ); - set16_fx( st_fx->input_buff_fx + L_FRAME48k, 0, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); - st_fx->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ) ); - - st_fx->Energy_Old_fx = 0; move16(); st_fx->Q_old_wtda = 15; @@ -881,6 +1003,7 @@ ivas_error init_encoder_fx( set16_fx( st_fx->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); st_fx->totalNoise_increase_len = 0; move16(); + init_coder_ace_plus_fx( st_fx, st_fx->last_total_brate, 0, -10 /*hack*/ ); IF( ( st_fx->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) @@ -888,9 +1011,7 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } - InitTransientDetection_fx( extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ), - NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), - st_fx->hTranDet, 0 ); + InitTransientDetection_fx( extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ), NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); st_fx->Q_syn2 = 0; move16(); @@ -1021,23 +1142,24 @@ void LPDmem_enc_init_ivas_fx( ivas_error init_encoder_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ - const Word16 interval_SID, /* i : interval for SID update */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ ) { - Word16 i; + Word16 i, frame_length; ivas_error error; Word32 igf_brate; error = IVAS_ERR_OK; move32(); + /* frame_length = st->input_Fs / FRAMES_PER_SEC */ + frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + /*-----------------------------------------------------------------* * General parameters *-----------------------------------------------------------------*/ @@ -1099,8 +1221,7 @@ ivas_error init_encoder_ivas_fx( st->is_ism_format = 0; move16(); - - IF( NE_16( ism_mode, ISM_MODE_NONE ) ) + if ( NE_16( ism_mode, ISM_MODE_NONE ) ) { st->is_ism_format = 1; move16(); @@ -1155,7 +1276,7 @@ ivas_error init_encoder_ivas_fx( set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); st->exp_old_wsp = 0; move16(); - set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); // Needs to change depending on usage. + set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); st->Q_old_wsp2 = 0; move16(); @@ -1170,14 +1291,6 @@ ivas_error init_encoder_ivas_fx( st->exp_mem_preemph_enc = 0; move16(); - st->active_cnt = 0; - move16(); - - st->pst_mem_deemp_err_fx = 0; - move16(); - st->pst_lp_ener_fx = 0; - move16(); - /* AVQ pre-quantizer memory */ st->mem_preemp_preQ_fx = 0; move16(); @@ -1199,10 +1312,12 @@ ivas_error init_encoder_ivas_fx( move16(); st->mem_wsp_q = 0; move16(); + set16_fx( st->mem_decim2_fx, 0, 3 ); set32_fx( st->Bin_E_fx, 0, L_FFT ); st->q_Bin_E = Q31; move16(); + st->ee_old_fx = 640; /* 10.0f in Q6 */ move16(); st->Nb_ACELP_frames = 0; @@ -1301,6 +1416,7 @@ ivas_error init_encoder_ivas_fx( move16(); st->Q_stat_noise = 15; move16(); + /* FEC */ st->last_clas = UNVOICED_CLAS; move16(); @@ -1403,17 +1519,14 @@ ivas_error init_encoder_ivas_fx( move16(); st->old_input_signal_fx = st->input_buff_fx; st->old_input_signal32_fx = st->input_buff32_fx; - /* st->input_Fs / FRAMES_PER_SEC */ - Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); IF( st->element_mode == EVS_MONO ) { - st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); - st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + st->input32_fx = st->input_buff32_fx + add( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + st->input_fx = st->input_buff_fx + add( frame_length, NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); } ELSE { - // st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC st->input32_fx = st->input_buff32_fx + frame_length; st->input_fx = st->input_buff_fx + frame_length; } @@ -1447,7 +1560,14 @@ ivas_error init_encoder_ivas_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Noise estimation\n" ); } - noise_est_init_ivas_fx( st->hNoiseEst ); + IF( st->element_mode == EVS_MONO ) + { + noise_est_init_fx( st->hNoiseEst ); + } + ELSE + { + noise_est_init_ivas_fx( st->hNoiseEst ); + } } ELSE { @@ -1505,7 +1625,14 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) ); } - speech_music_clas_init_ivas_fx( st->hSpMusClas ); + IF( st->element_mode == EVS_MONO ) + { + speech_music_clas_init_fx( st->hSpMusClas ); + } + ELSE + { + speech_music_clas_init_ivas_fx( st->hSpMusClas ); + } st->sp_aud_decision0 = 0; move16(); st->sp_aud_decision1 = 0; @@ -1518,7 +1645,6 @@ ivas_error init_encoder_ivas_fx( st->hSpMusClas = NULL; } - /*-----------------------------------------------------------------* * WB, SWB and FB bandwidth detector *-----------------------------------------------------------------*/ @@ -1546,13 +1672,16 @@ ivas_error init_encoder_ivas_fx( st->bwidth_sw_cnt = 0; move16(); - /*-----------------------------------------------------------------* * DTX *-----------------------------------------------------------------*/ + st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ + move16(); st->lp_speech_32fx = 754974720; /*Q24 (45.0) */ /* Initialize the long-term active speech level in dB */ move32(); + st->lp_noise_fx = 0; + move16(); st->lp_noise_32fx = 0; move16(); st->flag_noisy_speech_snr = 0; @@ -1576,7 +1705,7 @@ ivas_error init_encoder_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } - dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); + dtx_enc_init_fx( st, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ); } ELSE { @@ -1636,7 +1765,14 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } - td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); + IF( st->element_mode == EVS_MONO ) + { + td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); + } + ELSE + { + td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); + } } ELSE { @@ -1651,7 +1787,7 @@ ivas_error init_encoder_ivas_fx( test(); IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - IF( EQ_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode == EVS_MONO ) { /* open analysis for input SR */ IF( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs ) ) != IVAS_ERR_OK ) @@ -1672,10 +1808,20 @@ ivas_error init_encoder_ivas_fx( st->cldfbAnaEnc = NULL; } - st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ - move32(); - st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ - move16(); + IF( st->element_mode == EVS_MONO ) + { + st->energyCoreLookahead_Fx = 0; + move32(); + st->sf_energyCoreLookahead_Fx = 0; + move16(); + } + ELSE + { + st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ + move32(); + st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ + move16(); + } /*-----------------------------------------------------------------* * SC-VBR parameters @@ -1732,7 +1878,14 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - LPDmem_enc_init_ivas_fx( st->hLPDmem ); + IF( st->element_mode == EVS_MONO ) + { + LPDmem_enc_init_fx( st->hLPDmem ); + } + ELSE + { + LPDmem_enc_init_ivas_fx( st->hLPDmem ); + } } ELSE { @@ -1782,6 +1935,8 @@ ivas_error init_encoder_ivas_fx( { return error; } + + InitSWBencBuffer_fx( st /*st_fx->hBWE_TD*/ ); } ELSE { @@ -1789,8 +1944,10 @@ ivas_error init_encoder_ivas_fx( { return error; } + + InitSWBencBuffer_ivas_fx( st ); } - InitSWBencBuffer_ivas_fx( st ); + ResetSHBbuffer_Enc_fx( st ); } ELSE @@ -1923,6 +2080,7 @@ ivas_error init_encoder_ivas_fx( set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); st->hTcxEnc->spectrum_long_e = 0; move16(); + /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; @@ -2032,7 +2190,6 @@ ivas_error init_encoder_ivas_fx( st->last_sr_core = L_mult0( st->last_L_frame, FRAMES_PER_SEC ); move32(); - /* PLC encoder */ IF( st->element_mode == EVS_MONO ) { @@ -2055,35 +2212,37 @@ ivas_error init_encoder_ivas_fx( TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; IF( hTcxEnc != NULL ) { - hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + hTcxEnc->L_frameTCX = frame_length; move16(); } - st->currEnergyHF_fx = 0; - move32(); - st->currEnergyHF_e_fx = 0; - move16(); st->prevEnergyHF_fx = 0; move32(); - /* Initialize TCX */ + IF( st->element_mode == EVS_MONO ) + { + init_coder_ace_plus_fx( st, st->last_total_brate, 0, -10 /*hack*/ ); + } + ELSE + { + /* Initialize Signal Buffers */ + Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); + Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); + st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); + move16(); + shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); + Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); + st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); + move16(); - /* Initialize Signal Buffers */ - Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); - Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); - st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); - move16(); - shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); - Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); - st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); - move16(); - /* Initialize ACELP */ - init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); + init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); + } IF( st->hLPDmem != NULL ) { st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; move16(); } + /*-----------------------------------------------------------------* * FD-CNG encoder *-----------------------------------------------------------------*/ @@ -2095,7 +2254,9 @@ ivas_error init_encoder_ivas_fx( IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { createFdCngEnc_fx( &st->hFdCngEnc ); + initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); + /* initialization for IVAS modes happens in first frame pre-processing */ IF( st->element_mode == EVS_MONO ) { @@ -2113,7 +2274,7 @@ ivas_error init_encoder_ivas_fx( move32(); } - configureFdCngEnc_ivas_fx( st->hFdCngEnc, st->bwidth, total_brate ); + configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, total_brate ); } } ELSE @@ -2130,17 +2291,13 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } - Word16 frame_length = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); - IF( GT_16( st->element_mode, EVS_MONO ) ) { InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); } ELSE { - InitTransientDetection_fx( frame_length, - NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), - st->hTranDet, 0 ); + InitTransientDetection_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index b73702d21..0d063f5af 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1447,7 +1447,7 @@ ivas_error create_cpe_enc_fx( } st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move16(); - IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE, hCPE->element_brate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, n, 0, ISM_MODE_NONE, hCPE->element_brate ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index a48e4807b..170406b20 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -493,7 +493,7 @@ ivas_error create_sce_enc_fx( } ELSE { - IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 04b4049a7..15643b702 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -228,7 +228,7 @@ ivas_error ivas_spar_enc_open_fx( hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; move32(); move32(); - IF( NE_32( ( error = init_encoder_ivas_fx( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = init_encoder_ivas_fx( hSpar->hCoreCoderVAD, st_ivas, 0, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 0fca6ab8c..1842c3252 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1047,8 +1047,7 @@ void calculate_hangover_attenuation_gain_fx( void InitTransientDetection_fx( const Word16 nFrameLength, const Word16 nTCXDelay, - TRAN_DET_HANDLE hTranDet, - const Word16 ext_mem_flag ); + TRAN_DET_HANDLE hTranDet ); void InitTransientDetection_ivas_fx( const Word16 nFrameLength, @@ -1898,9 +1897,6 @@ Word16 encod_tran_ivas_fx( const Word16 Q_new /* i : Input scaling */ ); -/* Delete the instance of type FD_CNG */ -void deleteFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc ); - void coder_acelp_rf_fx( ACELP_config *acelp_cfg_rf, /*i /o : configuration of the ACELP coding*/ const Word16 coder_type, /* input: coding type Q0*/ @@ -1917,18 +1913,22 @@ void coder_acelp_rf_fx( Word16 *syn_rf, /* i/o: pointer to RF synthesis Q_new-1*/ Word16 Q_new, Word16 shift ); -/* Create an instance of type FD_CNG */ -void createFdCngEnc_fx( HANDLE_FD_CNG_ENC *hFdCngEnc ); + +ivas_error createFdCngEnc_fx( + HANDLE_FD_CNG_ENC *hFdCngEnc ); + +void deleteFdCngEnc_fx( + HANDLE_FD_CNG_ENC *hFdCngEnc ); void initFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, - Word32 input_Fs, /* Q0 */ - Word16 scale ); + const Word32 input_Fs, /* Q0 */ + const Word16 scale ); -/* Configure CLDFB-CNG */ -void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hs, /* i/o: Contains the variables related to the CLDFB-based CNG process */ - Word16 bandwidth, /* i: bandwidth Q0*/ - Word32 bitrate /* Q0 */ +void configureFdCngEnc_fx( + HANDLE_FD_CNG_ENC hs, /* i/o: Contains the variables related to the CLDFB-based CNG process */ + const Word16 bandwidth, /* i: bandwidth Q0*/ + const Word32 bitrate /* Q0 */ ); /* Perform noise estimation */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index e2c8f59ff..846b794fe 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -4616,7 +4616,7 @@ static void detect_sparseness_fx( Msp = shl( Msp, 5 ); /* Q8 */ /* find long-term smoothed sparseness */ - IF( st_fx->last_vad_spa_fx == 0 ) + IF( hSpMusClas->last_vad_spa == 0 ) { set16_fx( &hSpMusClas->sparse_buf_fx[0], sparse, HANG_LEN_INIT - 1 ); hSpMusClas->LT_sparse_fx = sparse; @@ -4871,7 +4871,7 @@ static void detect_sparseness_fx( move16(); } - st_fx->last_vad_spa_fx = localVAD_HE_SAD; + hSpMusClas->last_vad_spa = localVAD_HE_SAD; move16(); return; diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 33a139403..899f12a15 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1410,7 +1410,6 @@ typedef struct enc_core_structure Word16 old_Aq_12_8_fx[M + 1]; /* Q12 old Aq[] for core switching */ Word16 old_Es_pred_fx; /* old Es_pred for core switching Q8 */ Word16 music_hysteresis_fx; /* Counter of frames after AUDIO coding mode to prevent UC */ - Word16 last_vad_spa_fx; Word16 last_L_frame; /* ACELP@16kHz - last L_frame value */ Word16 mem_preemph16k_fx; /* ACELP@16kHz - preemphasis filter memory @16kHz Q-1 */ @@ -1782,8 +1781,6 @@ typedef struct enc_core_structure * Fixed point only variables *----------------------------------------------------------------------------------*/ - Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ - Word16 Q_exc; Word16 prev_Q_bwe_exc; diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 89b5464dd..bb8239f90 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -364,8 +364,7 @@ static void InitTCXTransientDetector( void InitTransientDetection_fx( const Word16 nFrameLength, const Word16 nTCXDelay, - TRAN_DET_HANDLE hTranDet, - const Word16 ext_mem_flag ) + TRAN_DET_HANDLE hTranDet ) { /* Init the delay buffer. */ InitDelayBuffer( nFrameLength, nTCXDelay, &hTranDet->delayBuffer ); @@ -377,18 +376,9 @@ void InitTransientDetection_fx( InitTCXTransientDetector( nTCXDelay, &hTranDet->subblockEnergies, &hTranDet->transientDetector ); /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ - IF( ext_mem_flag ) - { - hTranDet->transientDetector.pSubblockEnergies->nDelay = - add( hTranDet->transientDetector.pSubblockEnergies->nDelay, add( ( NSUBBLOCKS + 1 ), ( NSUBBLOCKS_SHIFT + 1 ) ) ); - move16(); - } - ELSE - { - hTranDet->transientDetector.pSubblockEnergies->nDelay = - add( hTranDet->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); - move16(); - } + hTranDet->transientDetector.pSubblockEnergies->nDelay = + add( hTranDet->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); + move16(); return; } -- GitLab From 4d511c5a079a61f4eb594dab8312036fb02cec42 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 9 Sep 2025 14:16:11 +0200 Subject: [PATCH 006/351] - remove obsolete encoder parameters st->last_element_mode, st->extl_orig, and st->extl_brate_orig --- lib_enc/init_enc_fx.c | 345 ++++++++++++++++++++++++++---------------- lib_enc/stat_enc.h | 9 +- 2 files changed, 217 insertions(+), 137 deletions(-) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 793c5f9b8..a53b1f9b7 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -27,8 +27,6 @@ ivas_error init_encoder_fx( ) { Word16 i; - Word32 L_tmp; - Word16 idchan = 0; /* i : channel ID */ Word16 vad_only_flag = 0; /* i : channel ID */ @@ -607,20 +605,24 @@ ivas_error init_encoder_fx( * DTX *-----------------------------------------------------------------*/ - st_fx->lp_speech_fx = 11520; - move16(); /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ - st_fx->lp_noise_fx = 0; + st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ + move16(); + st->lp_speech_32fx = 754974720; /*Q24 (45.0) */ /* Initialize the long-term active speech level in dB */ + move32(); + st->lp_noise_fx = 0; + move16(); + st->lp_noise_32fx = 0; move16(); test(); test(); - IF( ( ( idchan == 0 && st_fx->Opt_DTX_ON ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->Opt_DTX_ON ) ) + IF( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - if ( ( st_fx->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) + IF( ( st->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } - dtx_enc_init_fx( st_fx, var_SID_rate_flag, interval_SID ); + dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); } ELSE { @@ -643,23 +645,25 @@ ivas_error init_encoder_fx( * LP-CNG *-----------------------------------------------------------------*/ - test(); - test(); - test(); - test(); - test(); - IF( ( ( idchan == 0 && st_fx->Opt_DTX_ON && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, EVS_MONO ) ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) + IF( ( ( idchan == 0 && st->Opt_DTX_ON && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || st->element_mode == EVS_MONO ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) { - IF( ( st_fx->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) + IF( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } - td_cng_enc_init_fx( st_fx->hTdCngEnc, st_fx->Opt_DTX_ON, st_fx->max_bwidth ); + IF( st->element_mode == EVS_MONO ) + { + td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); + } + ELSE + { + td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); + } } ELSE { - st_fx->hTdCngEnc = NULL; + st->hTdCngEnc = NULL; } @@ -669,68 +673,73 @@ ivas_error init_encoder_fx( test(); test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { - IF( ( st_fx->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) + IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - LPDmem_enc_init_fx( st_fx->hLPDmem ); + IF( st->element_mode == EVS_MONO ) + { + LPDmem_enc_init_fx( st->hLPDmem ); + } + ELSE + { + LPDmem_enc_init_ivas_fx( st->hLPDmem ); + } } ELSE { - st_fx->hLPDmem = NULL; + st->hLPDmem = NULL; } - /* FEC */ - st_fx->last_clas = UNVOICED_CLAS; - move16(); - - FOR( i = 0; i < 2 * NB_SUBFR16k; i++ ) - { - st_fx->old_pitch_buf_fx[i] = L_SUBFR_Q6; - move16(); - } - st_fx->old_Es_pred_fx = 0; - move16(); - set16_fx( st_fx->old_Aq_12_8_fx + 1, 0, M ); - st_fx->old_Aq_12_8_fx[0] = 4096; - move16(); /*-----------------------------------------------------------------* * CLDFB Analysis *-----------------------------------------------------------------*/ - /* open analysis for input SR */ - if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, st_fx->input_Fs ) ) != IVAS_ERR_OK ) + test(); + test(); + test(); + IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - return error; + IF( st->element_mode == EVS_MONO ) + { + /* open analysis for input SR */ + IF( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) + { + return error; + } + } } - - if ( ( error = openCldfb( &st_fx->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) + ELSE { - return error; + st->cldfbAnaEnc = NULL; } - st_fx->energyCoreLookahead_Fx = 0; - move32(); - st_fx->sf_energyCoreLookahead_Fx = 0; - move16(); + IF( st->element_mode == EVS_MONO ) + { + st->energyCoreLookahead_Fx = 0; + move32(); + st->sf_energyCoreLookahead_Fx = 0; + move16(); + } + ELSE + { + st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ + move32(); + st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ + move16(); + } - /* stable short pitch detection */ - st_fx->voicing0_sm_fx = 0; - move16(); - st_fx->voicing_sm_fx = 0; - move16(); - st_fx->LF_EnergyRatio_sm_fx = 128; - move16(); - st_fx->predecision_flag = 0; - move16(); - st_fx->diff_sm_fx = 0; - move32(); - st_fx->energy_sm_fx = 0; - move32(); /*-----------------------------------------------------------------* * SC-VBR parameters @@ -780,18 +789,21 @@ ivas_error init_encoder_fx( /*-----------------------------------------------------------------* * SWB BWE parameters *-----------------------------------------------------------------*/ - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + test(); + IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - IF( ( st_fx->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) + IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); } - fd_bwe_enc_init_fx( st_fx->hBWE_FD ); + fd_bwe_enc_init_fx( st->hBWE_FD ); + st->Q_old_wtda = 0; + move16(); } ELSE { - st_fx->hBWE_FD = NULL; + st->hBWE_FD = NULL; } st_fx->prev_Q_shb = 0; @@ -803,27 +815,42 @@ ivas_error init_encoder_fx( * TBE parameters *-----------------------------------------------------------------*/ - IF( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + test(); + IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - IF( ( st_fx->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) + IF( ( st->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - // IF ((error = openCldfb(&st_fx->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS)) != IVAS_ERR_OK) - //{ - // return error; - // } + IF( st->element_mode == EVS_MONO ) + { + if ( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) + { + return error; + } - InitSWBencBuffer_fx( st_fx /*st_fx->hBWE_TD*/ ); - ResetSHBbuffer_Enc_fx( st_fx /*st_fx->hBWE_TD*/ ); + InitSWBencBuffer_fx( st /*st_fx->hBWE_TD*/ ); + } + ELSE + { + IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) + { + return error; + } + + InitSWBencBuffer_ivas_fx( st ); + } + + ResetSHBbuffer_Enc_fx( st ); } ELSE { - st_fx->hBWE_TD = NULL; - // st_fx->cldfbSynTd = NULL; + st->hBWE_TD = NULL; + st->cldfbSynTd = NULL; } + test(); IF( st_fx->Opt_RF_ON || st_fx->element_mode == EVS_MONO ) { @@ -860,41 +887,46 @@ ivas_error init_encoder_fx( * TCX core *-----------------------------------------------------------------*/ + // ToDo: reduction possible for MCT_CHAN_MODE_LFE channel test(); - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { - IF( ( st_fx->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) + IF( ( st->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) ); } + set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); + st->hTcxEnc->spectrum_long_e = 0; + move16(); /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ - /*st_fx->hTcxEnc->spectrum[0] = st_fx->hTcxEnc->spectrum_long; - st_fx->hTcxEnc->spectrum[1] = st_fx->hTcxEnc->spectrum_long + N_TCX10_MAX;*/ - - st_fx->hTcxEnc->spectrum_fx[0] = st_fx->hTcxEnc->spectrum_long_fx; - st_fx->hTcxEnc->spectrum_fx[1] = st_fx->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; + st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; + st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; + move32(); + move32(); + st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; + move16(); + move16(); - set16_fx( st_fx->hTcxEnc->old_out_fx, 0, L_FRAME32k ); - st_fx->hTcxEnc->Q_old_out = 0; + set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); + st->hTcxEnc->Q_old_out = 0; move16(); + /* MDCT selector */ - MDCT_selector_reset_fx( st_fx->hTcxEnc ); - st_fx->hTcxEnc->Q_old_out = 0; - move16(); + MDCT_selector_reset_fx( st->hTcxEnc ); /* MDCT classifier */ - MDCT_classifier_reset_fx( st_fx->hTcxEnc ); + MDCT_classifier_reset_fx( st->hTcxEnc ); - IF( ( st_fx->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) + IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } } ELSE { - st_fx->hTcxEnc = NULL; - // st_fx->hTcxCfg = NULL; + st->hTcxEnc = NULL; + st->hTcxCfg = NULL; } /*-----------------------------------------------------------------* * HQ core parameters @@ -961,57 +993,104 @@ ivas_error init_encoder_fx( * IGF *-----------------------------------------------------------------*/ + move16(); + + test(); test(); - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + test(); + IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) && ( st->igf || st->element_mode == EVS_MONO ) ) { - IF( ( st_fx->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) + IF( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); } } ELSE { - st_fx->hIGFEnc = NULL; - move16(); + st->hIGFEnc = NULL; } - IF( EQ_16( st_fx->codec_mode, MODE2 ) ) + + /*-----------------------------------------------------------------* + * FD-CNG encoder + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + test(); + IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - st_fx->igf = getIgfPresent_fx( st_fx->element_mode, st_fx->total_brate, st_fx->bwidth, st_fx->rf_mode ); + createFdCngEnc_fx( &st->hFdCngEnc ); + + initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); + + /* initialization for IVAS modes happens in first frame pre-processing */ + IF( st->element_mode == EVS_MONO ) + { + Word32 total_brate; + + test(); + IF( st->rf_mode && EQ_32( st->total_brate, ACELP_13k20 ) ) + { + total_brate = ACELP_9k60; + move32(); + } + ELSE + { + total_brate = st->total_brate; + move32(); + } + + configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, total_brate ); + } } ELSE { - st_fx->igf = 0; - move16(); + st->hFdCngEnc = NULL; } - /* FD-CNG encoder */ - createFdCngEnc_fx( &st_fx->hFdCngEnc ); - initFdCngEnc_fx( st_fx->hFdCngEnc, st_fx->input_Fs, st_fx->cldfbAnaEnc->scale ); - L_tmp = st_fx->total_brate; - move32(); - test(); - if ( st_fx->rf_mode && EQ_32( st_fx->total_brate, ACELP_13k20 ) ) - { - L_tmp = ACELP_9k60; - move32(); - } - configureFdCngEnc_fx( st_fx->hFdCngEnc, st_fx->bwidth, L_tmp ); st_fx->last_totalNoise_fx = 0; move16(); set16_fx( st_fx->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); st_fx->totalNoise_increase_len = 0; move16(); + st->prevEnergyHF_fx = 0; + move32(); + + IF( st->element_mode == EVS_MONO ) + { + init_coder_ace_plus_fx( st, st->last_total_brate, 0, -10 /*hack*/ ); + } + ELSE + { + /* Initialize Signal Buffers */ + Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); + Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); + st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); + move16(); + shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); + Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); + st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); + move16(); + + init_coder_ace_plus_ivas_fx( st, st->last_total_brate, -1, 0 ); + } + + IF( st->hLPDmem != NULL ) + { + st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; + move16(); + } - init_coder_ace_plus_fx( st_fx, st_fx->last_total_brate, 0, -10 /*hack*/ ); IF( ( st_fx->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } - InitTransientDetection_fx( extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ), NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); + InitTransientDetection_fx( frame_length, NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); st_fx->Q_syn2 = 0; move16(); @@ -1034,31 +1113,30 @@ ivas_error init_encoder_fx( move16(); st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ move16(); - st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */ + st->bits_frame_channel = 0; move16(); - st_fx->element_mode = EVS_MONO; /* element mode */ + st->side_bits_frame_channel = 0; move16(); - st_fx->last_element_mode = st_fx->element_mode; /* element mode */ + + st->Q_syn2 = 0; move16(); - st_fx->element_brate = -1; /* element bitrate */ - move32(); - // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually") - st_fx->low_rate_mode = 0; /* low-rate mode flag */ + st->Q_syn = 0; move16(); - // st_fx->coder_type = GENERIC; /* low-rate mode flag */ - - set16_fx( st_fx->pitch, L_SUBFR, 3 ); - set16_fx( st_fx->voicing_fx, 0, 3 ); - + set16_fx( st->Q_max, Q_MAX, L_Q_MEM ); + set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM ); + st->Q_old = 15; + move16(); + st->old_wsp_max = 0; + move16(); + st->old_wsp_shift = 0; + move16(); + st->sharpFlag = 0; #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ move16(); #endif - st_fx->extl_orig = -1; /* extension layer */ - move16(); - st_fx->extl_brate_orig = 0; /* extension layer bitrate */ - move32(); + return error; } @@ -1684,6 +1762,7 @@ ivas_error init_encoder_ivas_fx( move16(); st->lp_noise_32fx = 0; move16(); + st->flag_noisy_speech_snr = 0; move16(); st->fd_cng_reset_flag = 0; @@ -1782,6 +1861,7 @@ ivas_error init_encoder_ivas_fx( /*-----------------------------------------------------------------* * CLDFB & resampling tools parameters *-----------------------------------------------------------------*/ + test(); test(); test(); @@ -1977,6 +2057,9 @@ ivas_error init_encoder_ivas_fx( st->hBWE_FD = NULL; } + st->prev_Q_shb = 0; + move16(); + /*-----------------------------------------------------------------* * HQ core parameters *-----------------------------------------------------------------*/ @@ -2209,12 +2292,6 @@ ivas_error init_encoder_ivas_fx( set16_fx( st->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); st->totalNoise_increase_len = 0; move16(); - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - IF( hTcxEnc != NULL ) - { - hTcxEnc->L_frameTCX = frame_length; - move16(); - } st->prevEnergyHF_fx = 0; move32(); @@ -2326,6 +2403,10 @@ ivas_error init_encoder_ivas_fx( move16(); st->sharpFlag = 0; move16(); +#ifdef DEBUGGING + st_fx->id_element = -1; /* element ID */ + move16(); +#endif return error; } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 899f12a15..8b3d56e8e 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1234,13 +1234,12 @@ typedef struct enc_core_structure * Common parameters *----------------------------------------------------------------------------------*/ - Word16 idchan; /* channel ID (audio channel number) */ - Word16 id_element; /* element ID */ + Word16 idchan; /* channel ID (audio channel number) */ +#ifdef DEBUGGING + Word16 id_element; /* element ID */ +#endif Word16 element_mode; /* element mode */ - Word16 last_element_mode; /* element mode */ Word32 element_brate; /* element bitrate */ - Word16 extl_orig; /* extension layer */ - Word32 extl_brate_orig; /* extension layer bitrate */ Word16 codec_mode; /* Mode1 or Mode2 */ Word16 last_codec_mode; /* previous frame Mode 1 or 2 */ Word16 last_codec_mode_cng; /* previous inactive frame Mode 1 or 2 */ -- GitLab From 735c8188cf3b8a683a6b0efeb4be4d754fb5e9f2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 9 Sep 2025 18:52:30 +0200 Subject: [PATCH 007/351] update init_encoder_fx() --- lib_enc/init_enc_fx.c | 336 ++++++++++++++++++++----------------- lib_enc/ivas_init_enc_fx.c | 144 ---------------- lib_enc/ivas_sce_enc_fx.c | 12 +- lib_enc/prot_fx_enc.h | 5 +- 4 files changed, 188 insertions(+), 309 deletions(-) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index a53b1f9b7..bc9a72ee7 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -21,15 +21,14 @@ *-----------------------------------------------------------------------*/ ivas_error init_encoder_fx( - Encoder_State *st_fx, /* i/o: Encoder static variables structure */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID /* i : interval for SID update */ + Encoder_State *st_fx, /* i/o: Encoder static variables structure */ + Encoder_Struct *st_ivas /* i/o: encoder state structure */ ) { Word16 i; - - Word16 idchan = 0; /* i : channel ID */ - Word16 vad_only_flag = 0; /* i : channel ID */ + Word32 L_tmp; + Word16 idchan = 0; + Word16 vad_only_flag = 0; move16(); move16(); ISM_MODE ism_mode = ISM_MODE_NONE; @@ -40,9 +39,77 @@ ivas_error init_encoder_fx( Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + /*-----------------------------------------------------------------* + * General parameters + *-----------------------------------------------------------------*/ + + IF( st->Opt_AMR_WB ) + { + st->last_core = AMR_WB_CORE; + } + ELSE + { + st->last_core = -1; + } + move16(); + + st->L_frame = L_FRAME; + move16(); + st->last_coder_type = GENERIC; + move16(); + st->coder_type = GENERIC; + move16(); + st->last_total_brate = st->total_brate; + move32(); + st->last_bits_frame_nominal = -1; + move16(); + st->last_total_brate_cng = -1; + move16(); + st->last_core_brate = st->total_brate; + move32(); + st->dtx_sce_sba = 0; + move16(); + st->extl = -1; + move16(); + st->last_extl = -1; + move16(); + st->last_L_frame = L_FRAME; + move16(); + st->rate_switching_reset = 0; + move16(); + st->rate_switching_reset_16kHz = 0; + move16(); + st->clas = UNVOICED_CLAS; + move16(); + st->low_rate_mode = 0; + move16(); + st->ini_frame = 0; + move16(); + st->inactive_coder_type_flag = 0; + move16(); + st->sba_br_sw_while_no_data = 0; + move16(); + + st->coder_type_raw = VOICED; + move16(); + st->last_coder_type_raw = st->coder_type_raw; + move16(); + + st->flag_ACELP16k = set_ACELP_flag_IVAS( st->element_mode, st->total_brate, st->total_brate, idchan, 0, -1, -1 ); + move16(); + + st->is_ism_format = 0; + move16(); + if ( NE_16( ism_mode, ISM_MODE_NONE ) ) + { + st->is_ism_format = 1; + move16(); + } + /*-----------------------------------------------------------------* * General signal buffers *-----------------------------------------------------------------*/ + IF( !vad_only_flag ) { IF( ( st->hSignalBuf = (SIGNAL_BUFFERS_ENC_HANDLE) malloc( sizeof( SIGNAL_BUFFERS_ENC_DATA ) ) ) == NULL ) @@ -99,18 +166,20 @@ ivas_error init_encoder_fx( move16(); st->q_old_inp32 = Q31; move16(); - st->old_input_signal_fx = st->input_buff_fx; - st->old_input_signal32_fx = st->input_buff32_fx; IF( st->element_mode == EVS_MONO ) { st->input32_fx = st->input_buff32_fx + add( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); - st->input_fx = st->input_buff_fx + add( frame_length, NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + st->input_fx = st->input_buff_fx + add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); ///////////////////// input_Fs + st->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), frame_length ); + st->old_input_signal32_fx = st->input_buff32_fx; } ELSE { st->input32_fx = st->input_buff32_fx + frame_length; st->input_fx = st->input_buff_fx + frame_length; + st->old_input_signal_fx = st->input_buff_fx; + st->old_input_signal32_fx = st->input_buff32_fx; } } ELSE @@ -128,72 +197,6 @@ ivas_error init_encoder_fx( st->input_buff_fx = NULL; } - /*-----------------------------------------------------------------* - * ACELP core parameters - *-----------------------------------------------------------------*/ - - IF( st->Opt_AMR_WB ) - { - st->last_core = AMR_WB_CORE; - } - ELSE - { - st->last_core = -1; - } - move16(); - - st->L_frame = L_FRAME; - move16(); - st->last_coder_type = GENERIC; - move16(); - st->coder_type = GENERIC; - move16(); - st->last_total_brate = st->total_brate; - move32(); - st->last_bits_frame_nominal = -1; - move16(); - st->last_total_brate_cng = -1; - move16(); - st->last_core_brate = st->total_brate; - move32(); - st->dtx_sce_sba = 0; - move16(); - st->extl = -1; - move16(); - st->last_extl = -1; - move16(); - st->last_L_frame = L_FRAME; - move16(); - st->rate_switching_reset = 0; - move16(); - st->rate_switching_reset_16kHz = 0; - move16(); - st->clas = UNVOICED_CLAS; - move16(); - st->low_rate_mode = 0; - move16(); - st->ini_frame = 0; - move16(); - st->inactive_coder_type_flag = 0; - move16(); - st->sba_br_sw_while_no_data = 0; - move16(); - - st->coder_type_raw = VOICED; - move16(); - st->last_coder_type_raw = st->coder_type_raw; - move16(); - - st->flag_ACELP16k = set_ACELP_flag_IVAS( st->element_mode, st->total_brate, st->total_brate, idchan, 0, -1, -1 ); - move16(); - - st->is_ism_format = 0; - move16(); - if ( NE_16( ism_mode, ISM_MODE_NONE ) ) - { - st->is_ism_format = 1; - move16(); - } /*-----------------------------------------------------------------* * Bitstream *-----------------------------------------------------------------*/ @@ -204,33 +207,31 @@ ivas_error init_encoder_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); } + + /* set pointer to the buffer of indices */ + st->hBstr->ind_list = st_ivas->ind_list; + st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; + st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; + st->hBstr->nb_ind_tot = 0; + move16(); + st->hBstr->nb_bits_tot = 0; + move16(); + st->hBstr->st_ivas = st_ivas; } ELSE { st->hBstr = NULL; } - - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); - Copy( GEWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); - init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); - st_fx->next_force_safety_net = 0; - move16(); - st_fx->pstreaklen = 0; - move16(); - st_fx->streaklimit_fx = 32767; - move16(); /*1;//Q15 */ - set16_fx( st_fx->mem_MA_fx, 0, M ); - - init_gp_clip_fx( st_fx->clip_var_fx ); - pitch_ol_init_fx( &st_fx->old_thres_fx, &st_fx->old_pitch, &st_fx->delta_pit, &st_fx->old_corr_fx ); + /*-----------------------------------------------------------------* + * Pre-processing and ACELP core parameters + *-----------------------------------------------------------------*/ Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); Copy( GEWB_Ave_fx, st->lsfoldbfi0_fx, M ); Copy( GEWB_Ave_fx, st->lsfoldbfi1_fx, M ); Copy( GEWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); + init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); st->next_force_safety_net = 0; move16(); @@ -243,6 +244,8 @@ ivas_error init_encoder_fx( init_gp_clip_fx( st->clip_var_fx ); pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx ); + + set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); st->exp_old_wsp = 0; move16(); @@ -287,6 +290,7 @@ ivas_error init_encoder_fx( set32_fx( st->Bin_E_fx, 0, L_FFT ); st->q_Bin_E = Q31; move16(); + set16_fx( st_fx->lgBin_E_fx, 0, L_FFT / 2 ); //////////////////////////////////////// st->ee_old_fx = 640; /* 10.0f in Q6 */ move16(); @@ -298,6 +302,8 @@ ivas_error init_encoder_fx( /* adaptive lag window memory */ st->old_pitch_la = 0; move16(); + st_fx->old_voicing_la = 0; //////////////////////////////////////////////////// + move16(); st->prev_Q_new = 0; move16(); @@ -347,6 +353,8 @@ ivas_error init_encoder_fx( /* TC coder type */ st->tc_cnt = 0; move16(); + st_fx->mCb1_fx = 0; /////////////////////////////////////// + move16(); /* find_uv() parameters */ st->old_dE1_fx = 0; @@ -427,7 +435,6 @@ ivas_error init_encoder_fx( set16_fx( st->pitch, L_SUBFR, 3 ); set16_fx( st->voicing_fx, 0, 3 ); - /*-----------------------------------------------------------------* * AMR-WB IO initialization *-----------------------------------------------------------------*/ @@ -446,7 +453,6 @@ ivas_error init_encoder_fx( st_fx->hAmrwb_IO = NULL; } - /*-----------------------------------------------------------------* * parameters for AC coder type (GSC) *-----------------------------------------------------------------*/ @@ -528,7 +534,6 @@ ivas_error init_encoder_fx( st_fx->hVAD_CLDFB = NULL; } - /*-----------------------------------------------------------------* * Noise estimator *-----------------------------------------------------------------*/ @@ -600,7 +605,6 @@ ivas_error init_encoder_fx( st_fx->last_bwidth_cng = st_fx->bwidth; move16(); - /*-----------------------------------------------------------------* * DTX *-----------------------------------------------------------------*/ @@ -622,7 +626,7 @@ ivas_error init_encoder_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); } - dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); + dtx_enc_init_fx( st, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ); } ELSE { @@ -666,7 +670,6 @@ ivas_error init_encoder_fx( st->hTdCngEnc = NULL; } - /*-----------------------------------------------------------------* * ACELP LPDmem *-----------------------------------------------------------------*/ @@ -694,7 +697,6 @@ ivas_error init_encoder_fx( st->hLPDmem = NULL; } - /*-----------------------------------------------------------------* * CLDFB Analysis *-----------------------------------------------------------------*/ @@ -740,7 +742,6 @@ ivas_error init_encoder_fx( move16(); } - /*-----------------------------------------------------------------* * SC-VBR parameters *-----------------------------------------------------------------*/ @@ -770,6 +771,7 @@ ivas_error init_encoder_fx( { st_fx->hPlcExt = NULL; } + /*-----------------------------------------------------------------* * Temporal Envelope Coding *-----------------------------------------------------------------*/ @@ -825,7 +827,7 @@ ivas_error init_encoder_fx( IF( st->element_mode == EVS_MONO ) { - if ( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) { return error; } @@ -867,22 +869,6 @@ ivas_error init_encoder_fx( st_fx->hRF = NULL; } - - /*-----------------------------------------------------------------* - * HQ core parameters - *-----------------------------------------------------------------*/ - - st_fx->Energy_Old_fx = 0; - move16(); - st_fx->Q_old_wtda = 15; - move16(); - st_fx->EnergyLT_fx = 1; - move32(); - st_fx->EnergyLT_fx_exp = 30; - move16(); /* Set to a High Exponent so it is 1^-30 */ - st_fx->TransientHangOver = 0; - move16(); - /*-----------------------------------------------------------------* * TCX core *-----------------------------------------------------------------*/ @@ -928,6 +914,7 @@ ivas_error init_encoder_fx( st->hTcxEnc = NULL; st->hTcxCfg = NULL; } + /*-----------------------------------------------------------------* * HQ core parameters *-----------------------------------------------------------------*/ @@ -951,11 +938,26 @@ ivas_error init_encoder_fx( st_fx->last_enerBuffer_exp = 0; move16(); + /* init memory for detect_transient(), used by HQ core and swb_bwe_enc */ + st->old_hpfilt_in_fx = 0; + move16(); + st->old_hpfilt_out_fx = 0; + move16(); + st->EnergyLT_fx = 0; + move32(); + st->Energy_Old_fx = 0; + move32(); + st->TransientHangOver = 0; + move16(); + st->EnergyLT_fx_exp = 30; + move16(); + st->last_enerBuffer_exp = 0; + move16(); + /*-----------------------------------------------------------------* * Channel-aware mode *-----------------------------------------------------------------*/ - test(); test(); test(); @@ -983,17 +985,71 @@ ivas_error init_encoder_fx( /* initialize RF indice buffers */ reset_rf_indices_fx( st_fx ); + /*-----------------------------------------------------------------* * MODE2 initialization *-----------------------------------------------------------------*/ st_fx->last_sr_core = i_mult2( st_fx->last_L_frame, 50 ); move16(); + /*-----------------------------------------------------------------* * IGF *-----------------------------------------------------------------*/ - move16(); + Word32 igf_brate = st->total_brate; + move32(); + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) || EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) ) + { + igf_brate = L_sub( st->total_brate, i_mult( ISM_NB_BITS_METADATA_NOMINAL, FRAMES_PER_SEC ) ); + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_FORMAT ) ) ) ) + { +#if 0 + /* use nominal bitrates for DFT Stereo and (O)SBA, same as in stereo_dft_config()/ivas_spar_config() */ + IF( EQ_32( element_brate, IVAS_13k2 ) ) + { + igf_brate = ACELP_9k60; + } + ELSE IF( EQ_32( element_brate, IVAS_16k4 ) ) + { + igf_brate = ACELP_13k20; + } + ELSE IF( EQ_32( element_brate, IVAS_24k4 ) ) + { + igf_brate = ACELP_16k40; + } + ELSE IF( EQ_32( element_brate, IVAS_32k ) ) + { + igf_brate = ACELP_24k40; + } +#endif + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + // igf_brate = element_brate; + } + + IF( EQ_16( st_fx->codec_mode, MODE2 ) ) + { + st_fx->igf = getIgfPresent_fx( st_fx->element_mode, igf_brate, st_fx->bwidth, st_fx->rf_mode ); + } + ELSE + { + st_fx->igf = 0; + move16(); + } test(); test(); @@ -1010,7 +1066,6 @@ ivas_error init_encoder_fx( st->hIGFEnc = NULL; } - /*-----------------------------------------------------------------* * FD-CNG encoder *-----------------------------------------------------------------*/ @@ -1050,7 +1105,6 @@ ivas_error init_encoder_fx( st->hFdCngEnc = NULL; } - st_fx->last_totalNoise_fx = 0; move16(); set16_fx( st_fx->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); @@ -1078,13 +1132,6 @@ ivas_error init_encoder_fx( init_coder_ace_plus_ivas_fx( st, st->last_total_brate, -1, 0 ); } - IF( st->hLPDmem != NULL ) - { - st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; - move16(); - } - - IF( ( st_fx->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); @@ -1092,6 +1139,12 @@ ivas_error init_encoder_fx( InitTransientDetection_fx( frame_length, NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); +#if 1 ////////////////////////////////////////////////////////////////////////////////////////////// + + + set32_fx( st_fx->mem_hp20_in_fx, 0, 5 ); + + st_fx->Q_syn2 = 0; move16(); st_fx->Q_syn = 0; @@ -1104,8 +1157,7 @@ ivas_error init_encoder_fx( move16(); st_fx->old_wsp_shift = 0; move16(); - st_fx->sharpFlag = 0; - move16(); + st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ move16(); @@ -1113,29 +1165,8 @@ ivas_error init_encoder_fx( move16(); st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ move16(); - st->bits_frame_channel = 0; - move16(); - st->side_bits_frame_channel = 0; - move16(); - st->Q_syn2 = 0; - move16(); - st->Q_syn = 0; - move16(); - set16_fx( st->Q_max, Q_MAX, L_Q_MEM ); - set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM ); - st->Q_old = 15; - move16(); - st->old_wsp_max = 0; - move16(); - st->old_wsp_shift = 0; - move16(); - st->sharpFlag = 0; - -#ifdef DEBUGGING - st_fx->id_element = -1; /* element ID */ - move16(); -#endif +#endif ////////////////////////////////////////////////////////////////////////////////////////////// return error; } @@ -1192,12 +1223,14 @@ void LPDmem_enc_init_ivas_fx( set16_fx( hLPDmem->mem_syn2, 0, M ); set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); set16_fx( hLPDmem->mem_syn3, 0, M ); + hLPDmem->q_lpd_old_exc = Q15; move16(); hLPDmem->q_lpd_syn = Q15; move16(); hLPDmem->q_mem_syn = Q15; move16(); + hLPDmem->mem_w0 = 0; move16(); hLPDmem->tilt_code = 0; @@ -1339,6 +1372,7 @@ ivas_error init_encoder_ivas_fx( Copy( GEWB_Ave_fx, st->lsfoldbfi0_fx, M ); Copy( GEWB_Ave_fx, st->lsfoldbfi1_fx, M ); Copy( GEWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); + init_lvq_fx( st->offset_scale1_fx, st->offset_scale2_fx, st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_fx, st->no_scales_p_fx ); st->next_force_safety_net = 0; move16(); diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 1b35b7022..333d010df 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -1188,150 +1188,6 @@ void destroy_core_enc_fx( return; } -void destroy_evs_core_enc_fx( - ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ -) -{ - Word16 i; - - IF( hCoreCoder->hBstr != NULL ) - { - /* reset buffer of indices */ - FOR( i = 0; i < hCoreCoder->hBstr->nb_ind_tot; i++ ) - { - hCoreCoder->hBstr->ind_list[i].nb_bits = -1; - move16(); - } - free( hCoreCoder->hBstr ); - hCoreCoder->hBstr = NULL; - } - - IF( hCoreCoder->hLPDmem != NULL ) - { - free( hCoreCoder->hLPDmem ); - hCoreCoder->hLPDmem = NULL; - } - - IF( hCoreCoder->hTranDet != NULL ) - { - free( hCoreCoder->hTranDet ); - hCoreCoder->hTranDet = NULL; - } - - IF( hCoreCoder->hNoiseEst != NULL ) - { - free( hCoreCoder->hNoiseEst ); - hCoreCoder->hNoiseEst = NULL; - } - - IF( hCoreCoder->hVAD != NULL ) - { - free( hCoreCoder->hVAD ); - hCoreCoder->hVAD = NULL; - } - - IF( hCoreCoder->hVAD_CLDFB != NULL ) - { - /* This is not required as we are not allocating memory dynamically */ - // free( hCoreCoder->hVAD_CLDFB ); - hCoreCoder->hVAD_CLDFB = NULL; - } - - IF( hCoreCoder->hTdCngEnc != NULL ) - { - free( hCoreCoder->hTdCngEnc ); - hCoreCoder->hTdCngEnc = NULL; - } - - IF( hCoreCoder->hDtxEnc != NULL ) - { - free( hCoreCoder->hDtxEnc ); - hCoreCoder->hDtxEnc = NULL; - } - - IF( hCoreCoder->hSpMusClas != NULL ) - { - free( hCoreCoder->hSpMusClas ); - hCoreCoder->hSpMusClas = NULL; - } - - IF( hCoreCoder->hGSCEnc != NULL ) - { - free( hCoreCoder->hGSCEnc ); - hCoreCoder->hGSCEnc = NULL; - } - - IF( hCoreCoder->hSC_VBR != NULL ) - { - free( hCoreCoder->hSC_VBR ); - hCoreCoder->hSC_VBR = NULL; - } - - IF( hCoreCoder->hAmrwb_IO != NULL ) - { - free( hCoreCoder->hAmrwb_IO ); - hCoreCoder->hAmrwb_IO = NULL; - } - - IF( hCoreCoder->hBWE_TD != NULL ) - { - free( hCoreCoder->hBWE_TD ); - hCoreCoder->hBWE_TD = NULL; - } - - IF( hCoreCoder->hBWE_FD != NULL ) - { - free( hCoreCoder->hBWE_FD ); - hCoreCoder->hBWE_FD = NULL; - } - - IF( hCoreCoder->hRF != NULL ) - { - free( hCoreCoder->hRF ); - hCoreCoder->hRF = NULL; - } - - IF( hCoreCoder->hTECEnc != NULL ) - { - free( hCoreCoder->hTECEnc ); - hCoreCoder->hTECEnc = NULL; - } - - IF( hCoreCoder->hTcxEnc != NULL ) - { - free( hCoreCoder->hTcxEnc ); - hCoreCoder->hTcxEnc = NULL; - } - - IF( hCoreCoder->hTcxCfg != NULL ) - { - free( hCoreCoder->hTcxCfg ); - hCoreCoder->hTcxCfg = NULL; - } - - IF( hCoreCoder->hIGFEnc != NULL ) - { - free( hCoreCoder->hIGFEnc ); - hCoreCoder->hIGFEnc = NULL; - } - - IF( hCoreCoder->hPlcExt != NULL ) - { - free( hCoreCoder->hPlcExt ); - hCoreCoder->hPlcExt = NULL; - } - - IF( hCoreCoder->hHQ_core != NULL ) - { - free( hCoreCoder->hHQ_core ); - hCoreCoder->hHQ_core = NULL; - } - - free( hCoreCoder ); - - return; -} - /*------------------------------------------------------------------------- * ivas_destroy_enc_fx() diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 170406b20..9424f7e9b 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -476,20 +476,10 @@ ivas_error create_sce_enc_fx( IF( st->element_mode == EVS_MONO ) { - IF( NE_32( ( error = init_encoder_fx( st, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = init_encoder_fx( st, st_ivas ) ), IVAS_ERR_OK ) ) { return error; } - - /* set pointer to the buffer of indices */ - st->hBstr->ind_list = st_ivas->ind_list; - st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; - st->hBstr->nb_ind_tot = 0; - move16(); - st->hBstr->nb_bits_tot = 0; - move16(); - st->hBstr->st_ivas = st_ivas; } ELSE { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 1842c3252..2399e9d20 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4588,9 +4588,8 @@ void index_lvq_ivas_fx( const Word16 prediction_flag ); ivas_error init_encoder_fx( - Encoder_State *st_fx, /* i/o: Encoder static variables structure */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID /* i : interval for SID update */ + Encoder_State *st_fx, /* i/o: Encoder static variables structure */ + Encoder_Struct *st_ivas /* i/o: encoder state structure */ ); void copy_encoder_config_fx( -- GitLab From a3b9d78244d6fe1e2d0fe2c16f9db2016e7fa9d1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 9 Sep 2025 21:57:06 +0200 Subject: [PATCH 008/351] harmonize LPDmem_enc_init_fx() --- lib_enc/init_enc_fx.c | 73 +++++++------------------- lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 4 -- 3 files changed, 21 insertions(+), 58 deletions(-) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index bc9a72ee7..d8e6f967e 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -26,7 +26,6 @@ ivas_error init_encoder_fx( ) { Word16 i; - Word32 L_tmp; Word16 idchan = 0; Word16 vad_only_flag = 0; move16(); @@ -683,14 +682,7 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - IF( st->element_mode == EVS_MONO ) - { - LPDmem_enc_init_fx( st->hLPDmem ); - } - ELSE - { - LPDmem_enc_init_ivas_fx( st->hLPDmem ); - } + LPDmem_enc_init_fx( st->hLPDmem ); } ELSE { @@ -1144,6 +1136,9 @@ ivas_error init_encoder_fx( set32_fx( st_fx->mem_hp20_in_fx, 0, 5 ); + /*-----------------------------------------------------------------* + * IVAS parameters + *-----------------------------------------------------------------*/ st_fx->Q_syn2 = 0; move16(); @@ -1191,39 +1186,6 @@ void LPDmem_enc_init_fx( set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); set16_fx( hLPDmem->mem_syn3, 0, M ); - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - hLPDmem->dm_fx.prev_state = 0; - move16(); /* This corresponds to st_fx->dispMem in FLP */ - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - - FOR( i = 2; i < 8; i++ ) - { - hLPDmem->dm_fx.prev_gain_pit[i - 2] = 0; - move16(); - } - return; -} - -void LPDmem_enc_init_ivas_fx( - LPD_state_HANDLE hLPDmem /* i/o: LP memories */ -) -{ - Word16 i; - - set16_fx( hLPDmem->syn, 0, 1 + M ); - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn1_fx, 0, M ); - set16_fx( hLPDmem->mem_syn2, 0, M ); - set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); - set16_fx( hLPDmem->mem_syn3, 0, M ); - hLPDmem->q_lpd_old_exc = Q15; move16(); hLPDmem->q_lpd_syn = Q15; @@ -1383,8 +1345,13 @@ ivas_error init_encoder_ivas_fx( move16(); set16_fx( st->mem_MA_fx, 0, M ); + st->mCb1_fx = 0; + move16(); + init_gp_clip_fx( st->clip_var_fx ); + pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx ); + set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); st->exp_old_wsp = 0; move16(); @@ -1429,6 +1396,7 @@ ivas_error init_encoder_ivas_fx( set32_fx( st->Bin_E_fx, 0, L_FFT ); st->q_Bin_E = Q31; move16(); + set16_fx( st->lgBin_E_fx, 0, L_FFT / 2 ); st->ee_old_fx = 640; /* 10.0f in Q6 */ move16(); @@ -1440,6 +1408,8 @@ ivas_error init_encoder_ivas_fx( /* adaptive lag window memory */ st->old_pitch_la = 0; move16(); + st->old_voicing_la = 0; + move16(); st->prev_Q_new = 0; move16(); @@ -1569,6 +1539,8 @@ ivas_error init_encoder_ivas_fx( set16_fx( st->pitch, L_SUBFR, 3 ); set16_fx( st->voicing_fx, 0, 3 ); + set32_fx( st->mem_hp20_in_fx, 0, 5 ); //////////////////////////// + /*-----------------------------------------------------------------* * General signal buffers *-----------------------------------------------------------------*/ @@ -1629,18 +1601,20 @@ ivas_error init_encoder_ivas_fx( move16(); st->q_old_inp32 = Q31; move16(); - st->old_input_signal_fx = st->input_buff_fx; - st->old_input_signal32_fx = st->input_buff32_fx; IF( st->element_mode == EVS_MONO ) { st->input32_fx = st->input_buff32_fx + add( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); - st->input_fx = st->input_buff_fx + add( frame_length, NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + st->input_fx = st->input_buff_fx + add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); ///////////////////// input_Fs + st->old_input_signal_fx = st->input_fx - add( NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), frame_length ); + st->old_input_signal32_fx = st->input_buff32_fx; } ELSE { st->input32_fx = st->input_buff32_fx + frame_length; st->input_fx = st->input_buff_fx + frame_length; + st->old_input_signal_fx = st->input_buff_fx; + st->old_input_signal32_fx = st->input_buff32_fx; } } ELSE @@ -1992,14 +1966,7 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - IF( st->element_mode == EVS_MONO ) - { - LPDmem_enc_init_fx( st->hLPDmem ); - } - ELSE - { - LPDmem_enc_init_ivas_fx( st->hLPDmem ); - } + LPDmem_enc_init_fx( st->hLPDmem ); } ELSE { diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 60215658f..b6690d8c7 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -58,7 +58,7 @@ static ivas_error allocate_CoreCoder_enc_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - LPDmem_enc_init_ivas_fx( st->hLPDmem ); + LPDmem_enc_init_fx( st->hLPDmem ); } IF( st->hGSCEnc == NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2399e9d20..27e508c1a 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -863,10 +863,6 @@ void LPDmem_enc_init_fx( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); -void LPDmem_enc_init_ivas_fx( - LPD_state_HANDLE hLPDmem /* i/o: LP memories */ -); - void lsf_end_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ -- GitLab From 1e5c3936e9f058900131921c239bfc99b83b78ce Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 10 Sep 2025 14:22:40 +0200 Subject: [PATCH 009/351] harmonize init_encoder_fx() --- lib_com/prot_fx.h | 2 +- lib_enc/init_enc_fx.c | 1242 ++---------------------- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 14 +- lib_enc/ivas_spar_encoder_fx.c | 2 +- lib_enc/ivas_stereo_switching_enc_fx.c | 5 +- lib_enc/prot_fx_enc.h | 5 - lib_enc/stat_enc.h | 73 +- 8 files changed, 91 insertions(+), 1254 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 7cf0148eb..7ba036dd4 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -11052,7 +11052,7 @@ void read_next_force( ); #endif -ivas_error init_encoder_ivas_fx( +ivas_error init_encoder_fx( Encoder_State *st, /* i/o: state structure */ Encoder_Struct *st_ivas, /* i/o: encoder state structure */ const Word16 idchan, /* i : channel ID */ diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index d8e6f967e..f55edfc08 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1,1170 +1,56 @@ -/*==================================================================================== - EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 - ====================================================================================*/ - -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_com_fx.h" /* Static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -#include "stl.h" -#include "ivas_cnst.h" -#include "ivas_error.h" -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ -#include "ivas_prot_fx.h" - - -/*-----------------------------------------------------------------------* - * init_encoder_fx() - * - * Initialization of state variables - *-----------------------------------------------------------------------*/ - -ivas_error init_encoder_fx( - Encoder_State *st_fx, /* i/o: Encoder static variables structure */ - Encoder_Struct *st_ivas /* i/o: encoder state structure */ -) -{ - Word16 i; - Word16 idchan = 0; - Word16 vad_only_flag = 0; - move16(); - move16(); - ISM_MODE ism_mode = ISM_MODE_NONE; - ivas_error error; - Encoder_State *st = st_fx; - - error = IVAS_ERR_OK; - - Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - - /*-----------------------------------------------------------------* - * General parameters - *-----------------------------------------------------------------*/ - - IF( st->Opt_AMR_WB ) - { - st->last_core = AMR_WB_CORE; - } - ELSE - { - st->last_core = -1; - } - move16(); - - st->L_frame = L_FRAME; - move16(); - st->last_coder_type = GENERIC; - move16(); - st->coder_type = GENERIC; - move16(); - st->last_total_brate = st->total_brate; - move32(); - st->last_bits_frame_nominal = -1; - move16(); - st->last_total_brate_cng = -1; - move16(); - st->last_core_brate = st->total_brate; - move32(); - st->dtx_sce_sba = 0; - move16(); - st->extl = -1; - move16(); - st->last_extl = -1; - move16(); - st->last_L_frame = L_FRAME; - move16(); - st->rate_switching_reset = 0; - move16(); - st->rate_switching_reset_16kHz = 0; - move16(); - st->clas = UNVOICED_CLAS; - move16(); - st->low_rate_mode = 0; - move16(); - st->ini_frame = 0; - move16(); - st->inactive_coder_type_flag = 0; - move16(); - st->sba_br_sw_while_no_data = 0; - move16(); - - st->coder_type_raw = VOICED; - move16(); - st->last_coder_type_raw = st->coder_type_raw; - move16(); - - st->flag_ACELP16k = set_ACELP_flag_IVAS( st->element_mode, st->total_brate, st->total_brate, idchan, 0, -1, -1 ); - move16(); - - st->is_ism_format = 0; - move16(); - if ( NE_16( ism_mode, ISM_MODE_NONE ) ) - { - st->is_ism_format = 1; - move16(); - } - - /*-----------------------------------------------------------------* - * General signal buffers - *-----------------------------------------------------------------*/ - - IF( !vad_only_flag ) - { - IF( ( st->hSignalBuf = (SIGNAL_BUFFERS_ENC_HANDLE) malloc( sizeof( SIGNAL_BUFFERS_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Signal buffers\n" ) ); - } - - st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx; - st->mem_decim_fx = st->hSignalBuf->mem_decim_fx; - st->mem_decim16k_fx = st->hSignalBuf->mem_decim16k_fx; - st->old_inp_12k8_fx = st->hSignalBuf->old_inp_12k8_fx; - st->old_inp_16k_fx = st->hSignalBuf->old_inp_16k_fx; - st->buf_speech_enc_pe = st->hSignalBuf->buf_speech_enc_pe; - st->buf_synth = st->hSignalBuf->buf_synth; - st->buf_speech_enc = st->hSignalBuf->buf_speech_enc; - st->buf_wspeech_enc = st->hSignalBuf->buf_wspeech_enc; - - set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); - st->q_Bin_E_old = Q31; - move16(); - set16_fx( st->hSignalBuf->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st->exp_buf_speech_enc = 0; - move16(); - set16_fx( st->hSignalBuf->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); - st->exp_buf_wspeech_enc = 0; - move16(); - /* initializations */ - set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); - st->q_Bin_E_old = Q31; - move16(); - set16_fx( st->mem_decim_fx, 0, shl( L_FILT_MAX, 1 ) ); - set16_fx( st->mem_decim_fx_q_inp, 0, shl( L_FILT_MAX, 1 ) ); - set16_fx( st->mem_decim16k_fx, 0, shl( L_FILT_MAX, 1 ) ); - set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM ); - set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); - st->exp_old_inp_16k = 0; - st->exp_old_inp_12k8 = 0; - move16(); - move16(); - - st->input_buff_fx = st->hSignalBuf->input_buff; - st->input_buff32_fx = st->hSignalBuf->input_buff32; - set16_fx( st->input_buff_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); - st->q_inp = Q15; - move16(); - st->mem_preemph_q = Q15; - move16(); - st->mem_q = Q15; - move16(); - st->q_old_inp = Q15; - move16(); - set32_fx( st->input_buff32_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); - st->q_inp32 = Q31; - move16(); - st->q_old_inp32 = Q31; - move16(); - - IF( st->element_mode == EVS_MONO ) - { - st->input32_fx = st->input_buff32_fx + add( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); - st->input_fx = st->input_buff_fx + add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); ///////////////////// input_Fs - st->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), frame_length ); - st->old_input_signal32_fx = st->input_buff32_fx; - } - ELSE - { - st->input32_fx = st->input_buff32_fx + frame_length; - st->input_fx = st->input_buff_fx + frame_length; - st->old_input_signal_fx = st->input_buff_fx; - st->old_input_signal32_fx = st->input_buff32_fx; - } - } - ELSE - { - st->hSignalBuf = NULL; - st->Bin_E_old_fx = NULL; - st->mem_decim_fx = NULL; - st->mem_decim16k_fx = NULL; - st->old_inp_12k8_fx = NULL; - st->old_inp_16k_fx = NULL; - st->buf_speech_enc_pe = NULL; - st->buf_synth = NULL; - st->buf_speech_enc = NULL; - st->buf_wspeech_enc = NULL; - st->input_buff_fx = NULL; - } - - /*-----------------------------------------------------------------* - * Bitstream - *-----------------------------------------------------------------*/ - - IF( !vad_only_flag ) - { - IF( ( st->hBstr = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); - } - - /* set pointer to the buffer of indices */ - st->hBstr->ind_list = st_ivas->ind_list; - st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; - st->hBstr->nb_ind_tot = 0; - move16(); - st->hBstr->nb_bits_tot = 0; - move16(); - st->hBstr->st_ivas = st_ivas; - } - ELSE - { - st->hBstr = NULL; - } - - /*-----------------------------------------------------------------* - * Pre-processing and ACELP core parameters - *-----------------------------------------------------------------*/ - - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - Copy( GEWB_Ave_fx, st->lsfoldbfi0_fx, M ); - Copy( GEWB_Ave_fx, st->lsfoldbfi1_fx, M ); - Copy( GEWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); - init_lvq_fx( st_fx->offset_scale1_fx, st_fx->offset_scale2_fx, st_fx->offset_scale1_p_fx, st_fx->offset_scale2_p_fx, st_fx->no_scales_fx, st_fx->no_scales_p_fx ); - - st->next_force_safety_net = 0; - move16(); - - st->pstreaklen = 0; - move16(); - st->streaklimit_fx = MAX_WORD16; - move16(); - set16_fx( st->mem_MA_fx, 0, M ); - - init_gp_clip_fx( st->clip_var_fx ); - pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx ); - - - set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); - st->exp_old_wsp = 0; - move16(); - set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); - st->Q_old_wsp2 = 0; - move16(); - - st->mem_preemph_fx = 0; - move16(); - st->mem_preemph_fx_q_inp = 0; - move16(); - st->mem_preemph16k_fx = 0; - move16(); - st->mem_preemph_enc = 0; - move16(); - st->exp_mem_preemph_enc = 0; - move16(); - - /* AVQ pre-quantizer memory */ - st->mem_preemp_preQ_fx = 0; - move16(); - st->mem_deemp_preQ_fx = 0; - move16(); - st->last_nq_preQ = 0; - move16(); - st->last_code_preq = 0; - move16(); - st->use_acelp_preq = 0; - move16(); - st->last_harm_flag_acelp = 0; - move16(); - - /* (Decimated) Weighted Speech Memory */ - st->mem_wsp_enc = 0; - move16(); - st->mem_wsp_fx = 0; - move16(); - st->mem_wsp_q = 0; - move16(); - - set16_fx( st->mem_decim2_fx, 0, 3 ); - set32_fx( st->Bin_E_fx, 0, L_FFT ); - st->q_Bin_E = Q31; - move16(); - set16_fx( st_fx->lgBin_E_fx, 0, L_FFT / 2 ); //////////////////////////////////////// - - st->ee_old_fx = 640; /* 10.0f in Q6 */ - move16(); - st->Nb_ACELP_frames = 0; - move16(); - st->audio_frame_cnt = AUDIO_COUNTER_INI; /* Initialization of the audio frame counter mildly into the audio mode */ - move16(); - - /* adaptive lag window memory */ - st->old_pitch_la = 0; - move16(); - st_fx->old_voicing_la = 0; //////////////////////////////////////////////////// - move16(); - - st->prev_Q_new = 0; - move16(); - - IF( EQ_32( st->input_Fs, 8000 ) ) - { - st->min_band = 1; - move16(); - st->max_band = 16; - move16(); - } - ELSE - { - st->min_band = 0; - move16(); - st->max_band = 19; - move16(); - } - - IF( st->Opt_AMR_WB ) - { - Copy( mean_isf_amr_wb_fx, st->lsf_old_fx, M ); - E_LPC_isf_isp_conversion( st->lsf_old_fx, st->lsp_old1_fx, M ); - } - ELSE - { - Copy( GEWB_Ave_fx, st->lsf_old_fx, M ); - lsf2lsp_fx( st->lsf_old_fx, st->lsp_old1_fx, M, INT_FS_12k8 ); - } - - Copy( st->lsf_old_fx, st->lsf_old1_fx, M ); - Copy( st->lsp_old1_fx, st->lsp_old_fx, M ); - Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); - Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); - - st->stab_fac_fx = 0; - move16(); - - /* Bass post-filter memories - encoder side of MODE2 */ - st->bpf_off = 0; - move16(); - st->pst_mem_deemp_err_fx = 0; - move16(); - st->pst_lp_ener_fx = 0; - move16(); - - /* TC coder type */ - st->tc_cnt = 0; - move16(); - st_fx->mCb1_fx = 0; /////////////////////////////////////// - move16(); - - /* find_uv() parameters */ - st->old_dE1_fx = 0; - move16(); - st->old_ind_deltaMax = 0; - move16(); - set32_fx( st->old_enr_ssf_fx, 0, shl( NB_SSF, 1 ) ); - st->spike_hyst = -1; - move16(); - - /* stereo switching memories */ - st->mem_preemph_DFT_fx = 0; - move16(); - st->mem_preemph_DFT_fx_q_inp = 0; - move16(); - set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) ); - st->mem_preemph16k_DFT_fx = 0; - move16(); - set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) ); - - st->sharpFlag = 0; - move16(); - - /* Stationary noise UV modification */ - st->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ - move16(); - st->uv_count = 0; - move16(); - st->act_count = 3; - move16(); - Copy( st->lsp_old_fx, st->lspold_s_fx, M ); - st->noimix_seed = RANDOM_INITSEED; - move16(); - st->min_alpha_fx = 32767; - move16(); - st->exc_pe_fx = 0; - move16(); - st->Q_stat_noise = 15; - move16(); - - /* FEC */ - st->last_clas = UNVOICED_CLAS; - move16(); - st->prev_fmerit = 0; - move16(); - st->fmerit_dt = 0; - move16(); - st->Last_pulse_pos = 0; - move16(); - - FOR( i = 0; i < shl( NB_SUBFR16k, 1 ); i++ ) - { - st->old_pitch_buf_fx[i] = L_SUBFR_Q6; - move16(); - } - - /* mode1 core switching */ - st->old_Es_pred_fx = 0; - move16(); - set16_fx( st->old_Aq_12_8_fx + 1, 0, M ); - st->old_Aq_12_8_fx[0] = ONE_IN_Q12; - move16(); - - /* stable short pitch detection */ - st->voicing0_sm_fx = 0; - move16(); - st->voicing_sm_fx = 0; - move16(); - st->LF_EnergyRatio_sm_fx = 1; - move16(); - st->predecision_flag = 0; - move16(); - st->diff_sm_fx = 0; - move32(); - st->energy_sm_fx = 0; - move32(); - - set16_fx( st->pitch, L_SUBFR, 3 ); - set16_fx( st->voicing_fx, 0, 3 ); - - /*-----------------------------------------------------------------* - * AMR-WB IO initialization - *-----------------------------------------------------------------*/ - test(); - IF( st_fx->Opt_AMR_WB || EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( ( st_fx->hAmrwb_IO = (AMRWB_IO_ENC_HANDLE) malloc( sizeof( AMRWB_IO_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); - } - - amr_wb_enc_init_fx( st_fx->hAmrwb_IO ); - } - ELSE - { - st_fx->hAmrwb_IO = NULL; - } - - /*-----------------------------------------------------------------* - * parameters for AC coder type (GSC) - *-----------------------------------------------------------------*/ - - st_fx->GSC_noisy_speech = 0; - st_fx->GSC_IVAS_mode = 0; - move16(); - test(); - test(); - IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st_fx->hGSCEnc = (GSC_ENC_HANDLE) malloc( sizeof( GSC_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); - } - - GSC_enc_init_fx( st_fx->hGSCEnc ); - } - ELSE - { - st_fx->hGSCEnc = NULL; - } - - st_fx->old_dE1_fx = 0; - move16(); - st_fx->old_ind_deltaMax = 0; - move32(); - set32_fx( st_fx->old_enr_ssf_fx, 0, 2 * NB_SSF ); - st_fx->spike_hyst = -1; - move16(); - st_fx->music_hysteresis_fx = 0; - move16(); /* Counter of frames after AUDIO frame to prevent UC */ - st_fx->last_harm_flag_acelp = 0; - move16(); - st_fx->GSC_noisy_speech = 0; - move16(); - - /*-----------------------------------------------------------------* - * VAD - *-----------------------------------------------------------------*/ - - st_fx->vad_flag = 1; - st_fx->localVAD = 0; - move16(); - move16(); - test(); - test(); - test(); - test(); - IF( ( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) && ( !vad_only_flag ) ) - { - if ( ( st_fx->hVAD = (VAD_HANDLE) malloc( sizeof( VAD_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) ); - } - - wb_vad_init_fx( st_fx->hVAD ); - } - ELSE - { - st_fx->hVAD = NULL; - } - - st_fx->Pos_relE_cnt = 5120; - move16(); /*20.0f*/ - - /* CLDFB-based VAD */ - IF( st_fx->element_mode == EVS_MONO ) - { - if ( ( st_fx->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) ); - } - - vad_init_fx( st_fx->hVAD_CLDFB ); - } - ELSE - { - st_fx->hVAD_CLDFB = NULL; - } - - /*-----------------------------------------------------------------* - * Noise estimator - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( /*idchan == 0 ||*/ EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) - { - if ( ( st_fx->hNoiseEst = (NOISE_EST_HANDLE) malloc( sizeof( NOISE_EST_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Noise estimation\n" ); - } - noise_est_init_fx( st_fx->hNoiseEst ); - } - ELSE - { - st_fx->hNoiseEst = NULL; - } - - /*-----------------------------------------------------------------* - * Speech/music classifier - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hSpMusClas = (SP_MUS_CLAS_HANDLE) malloc( sizeof( SP_MUS_CLAS_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) ); - } - - speech_music_clas_init_fx( st_fx->hSpMusClas ); - - st_fx->sp_aud_decision0 = 0; - st_fx->sp_aud_decision1 = 0; - st_fx->sp_aud_decision2 = 0; - move16(); - move16(); - move16(); - } - ELSE - { - st_fx->hSpMusClas = NULL; - } - - st_fx->bckr_tilt_lt = 0; - move32(); - - /* WB, SWB and FB bandwidth detector */ - st_fx->lt_mean_NB_fx = 0; - move16(); - st_fx->lt_mean_WB_fx = 0; - move16(); - st_fx->lt_mean_SWB_fx = 0; - move16(); - st_fx->count_WB = BWD_COUNT_MAX; - move16(); - st_fx->count_SWB = BWD_COUNT_MAX; - move16(); - st_fx->count_FB = BWD_COUNT_MAX; - move16(); - st_fx->bwidth = st_fx->max_bwidth; - move16(); - st_fx->last_input_bwidth = st_fx->bwidth; - move16(); - st_fx->last_bwidth = st_fx->bwidth; - move16(); - st_fx->last_bwidth_cng = st_fx->bwidth; - move16(); - - /*-----------------------------------------------------------------* - * DTX - *-----------------------------------------------------------------*/ - - st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ - move16(); - st->lp_speech_32fx = 754974720; /*Q24 (45.0) */ /* Initialize the long-term active speech level in dB */ - move32(); - st->lp_noise_fx = 0; - move16(); - st->lp_noise_32fx = 0; - move16(); - - test(); - test(); - IF( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - IF( ( st->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); - } - dtx_enc_init_fx( st, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ); - } - ELSE - { - st_fx->hDtxEnc = NULL; - } - - st_fx->fd_cng_reset_flag = 0; - move16(); - - IF( st_fx->Opt_DTX_ON ) - { - move16(); - } - - st_fx->cng_type = -1; - move16(); - - - /*-----------------------------------------------------------------* - * LP-CNG - *-----------------------------------------------------------------*/ - - IF( ( ( idchan == 0 && st->Opt_DTX_ON && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || st->element_mode == EVS_MONO ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) - { - IF( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); - } - - IF( st->element_mode == EVS_MONO ) - { - td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); - } - ELSE - { - td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); - } - } - ELSE - { - st->hTdCngEnc = NULL; - } - - /*-----------------------------------------------------------------* - * ACELP LPDmem - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); - } - - LPDmem_enc_init_fx( st->hLPDmem ); - } - ELSE - { - st->hLPDmem = NULL; - } - - /*-----------------------------------------------------------------* - * CLDFB Analysis - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - IF( st->element_mode == EVS_MONO ) - { - /* open analysis for input SR */ - IF( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE - { - st->cldfbAnaEnc = NULL; - } - - IF( st->element_mode == EVS_MONO ) - { - st->energyCoreLookahead_Fx = 0; - move32(); - st->sf_energyCoreLookahead_Fx = 0; - move16(); - } - ELSE - { - st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ - move32(); - st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ - move16(); - } - - /*-----------------------------------------------------------------* - * SC-VBR parameters - *-----------------------------------------------------------------*/ - test(); - IF( st_fx->Opt_SC_VBR || st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hSC_VBR = (SC_VBR_ENC_HANDLE) malloc( sizeof( SC_VBR_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); - } - - sc_vbr_enc_init_fx( st_fx->hSC_VBR ); - } - ELSE - { - st_fx->hSC_VBR = NULL; - } - /* PLC encoder */ - IF( st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hPlcExt = (PLC_ENC_EVS_HANDLE) malloc( sizeof( PLC_ENC_EVS ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hPlcExt\n" ) ); - } - } - ELSE - { - st_fx->hPlcExt = NULL; - } - - /*-----------------------------------------------------------------* - * Temporal Envelope Coding - *-----------------------------------------------------------------*/ - - IF( st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hTECEnc = (TEC_ENC_HANDLE) malloc( sizeof( TEC_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); - } - } - ELSE - { - st_fx->hTECEnc = NULL; - } - - /*-----------------------------------------------------------------* - * SWB BWE parameters - *-----------------------------------------------------------------*/ - test(); - IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); - } - - fd_bwe_enc_init_fx( st->hBWE_FD ); - st->Q_old_wtda = 0; - move16(); - } - ELSE - { - st->hBWE_FD = NULL; - } - - st_fx->prev_Q_shb = 0; - move16(); - st_fx->last_Opt_SC_VBR = 0; - move16(); - - /*-----------------------------------------------------------------* - * TBE parameters - *-----------------------------------------------------------------*/ - - test(); - IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); - } - - IF( st->element_mode == EVS_MONO ) - { - IF( ( error = openCldfb( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000 ) ) != IVAS_ERR_OK ) - { - return error; - } - - InitSWBencBuffer_fx( st /*st_fx->hBWE_TD*/ ); - } - ELSE - { - IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) - { - return error; - } - - InitSWBencBuffer_ivas_fx( st ); - } - - ResetSHBbuffer_Enc_fx( st ); - } - ELSE - { - st->hBWE_TD = NULL; - st->cldfbSynTd = NULL; - } - - - test(); - IF( st_fx->Opt_RF_ON || st_fx->element_mode == EVS_MONO ) - { - IF( ( st_fx->hRF = (RF_ENC_HANDLE) malloc( sizeof( RF_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for RF\n" ) ); - } - - /* initialize RF indice buffers */ - reset_rf_indices_fx( st_fx /*->hRF, st_fx->L_frame, &st->rf_target_bits_write*/ ); - } - ELSE - { - st_fx->hRF = NULL; - } - - /*-----------------------------------------------------------------* - * TCX core - *-----------------------------------------------------------------*/ - - // ToDo: reduction possible for MCT_CHAN_MODE_LFE channel - test(); - IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) ); - } - set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); - st->hTcxEnc->spectrum_long_e = 0; - move16(); - - /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ - st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; - st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; - move32(); - move32(); - st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; - move16(); - move16(); - - set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); - st->hTcxEnc->Q_old_out = 0; - move16(); - - /* MDCT selector */ - MDCT_selector_reset_fx( st->hTcxEnc ); - - /* MDCT classifier */ - MDCT_classifier_reset_fx( st->hTcxEnc ); - - IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); - } - } - ELSE - { - st->hTcxEnc = NULL; - st->hTcxCfg = NULL; - } - - /*-----------------------------------------------------------------* - * HQ core parameters - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) - { - IF( ( st_fx->hHQ_core = (HQ_ENC_HANDLE) malloc( sizeof( HQ_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); - } - - HQ_core_enc_init_fx( st_fx->hHQ_core ); - } - ELSE - { - st_fx->hHQ_core = NULL; - } - - st_fx->last_enerBuffer_exp = 0; - move16(); - - /* init memory for detect_transient(), used by HQ core and swb_bwe_enc */ - st->old_hpfilt_in_fx = 0; - move16(); - st->old_hpfilt_out_fx = 0; - move16(); - st->EnergyLT_fx = 0; - move32(); - st->Energy_Old_fx = 0; - move32(); - st->TransientHangOver = 0; - move16(); - st->EnergyLT_fx_exp = 30; - move16(); - st->last_enerBuffer_exp = 0; - move16(); - - /*-----------------------------------------------------------------* - * Channel-aware mode - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( st_fx->Opt_RF_ON == 0 || ( NE_16( st_fx->bwidth, WB ) && NE_16( st_fx->bwidth, SWB ) ) || NE_32( st_fx->total_brate, ACELP_13k20 ) ) - { - IF( EQ_16( st_fx->Opt_RF_ON, 1 ) ) - { - printf( "\nWarning: Channel-aware mode only available for 13.2 kbps WB/SWB\n" ); - printf( " Switched to normal mode!\n" ); - st_fx->Opt_RF_ON = 0; - move16(); - st_fx->rf_fec_offset = 0; - move16(); - } - st_fx->rf_mode = 0; - move16(); - } - ELSE - { - st_fx->rf_mode = st_fx->Opt_RF_ON; - move16(); - } - st_fx->rf_mode_last = st_fx->rf_mode; - move16(); - /* initialize RF indice buffers */ - reset_rf_indices_fx( st_fx ); - - - /*-----------------------------------------------------------------* - * MODE2 initialization - *-----------------------------------------------------------------*/ - - st_fx->last_sr_core = i_mult2( st_fx->last_L_frame, 50 ); - move16(); - - /*-----------------------------------------------------------------* - * IGF - *-----------------------------------------------------------------*/ - - Word32 igf_brate = st->total_brate; - move32(); - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) || EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) ) - { - igf_brate = L_sub( st->total_brate, i_mult( ISM_NB_BITS_METADATA_NOMINAL, FRAMES_PER_SEC ) ); - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_FORMAT ) ) ) ) - { -#if 0 - /* use nominal bitrates for DFT Stereo and (O)SBA, same as in stereo_dft_config()/ivas_spar_config() */ - IF( EQ_32( element_brate, IVAS_13k2 ) ) - { - igf_brate = ACELP_9k60; - } - ELSE IF( EQ_32( element_brate, IVAS_16k4 ) ) - { - igf_brate = ACELP_13k20; - } - ELSE IF( EQ_32( element_brate, IVAS_24k4 ) ) - { - igf_brate = ACELP_16k40; - } - ELSE IF( EQ_32( element_brate, IVAS_32k ) ) - { - igf_brate = ACELP_24k40; - } -#endif - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - // igf_brate = element_brate; - } - - IF( EQ_16( st_fx->codec_mode, MODE2 ) ) - { - st_fx->igf = getIgfPresent_fx( st_fx->element_mode, igf_brate, st_fx->bwidth, st_fx->rf_mode ); - } - ELSE - { - st_fx->igf = 0; - move16(); - } - - test(); - test(); - test(); - IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) && ( st->igf || st->element_mode == EVS_MONO ) ) - { - IF( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); - } - } - ELSE - { - st->hIGFEnc = NULL; - } - - /*-----------------------------------------------------------------* - * FD-CNG encoder - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - createFdCngEnc_fx( &st->hFdCngEnc ); - - initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); - - /* initialization for IVAS modes happens in first frame pre-processing */ - IF( st->element_mode == EVS_MONO ) - { - Word32 total_brate; - - test(); - IF( st->rf_mode && EQ_32( st->total_brate, ACELP_13k20 ) ) - { - total_brate = ACELP_9k60; - move32(); - } - ELSE - { - total_brate = st->total_brate; - move32(); - } - - configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, total_brate ); - } - } - ELSE - { - st->hFdCngEnc = NULL; - } - - st_fx->last_totalNoise_fx = 0; - move16(); - set16_fx( st_fx->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); - st_fx->totalNoise_increase_len = 0; - move16(); - st->prevEnergyHF_fx = 0; - move32(); - - IF( st->element_mode == EVS_MONO ) - { - init_coder_ace_plus_fx( st, st->last_total_brate, 0, -10 /*hack*/ ); - } - ELSE - { - /* Initialize Signal Buffers */ - Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); - Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); - st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); - move16(); - shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); - Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); - st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); - move16(); - - init_coder_ace_plus_ivas_fx( st, st->last_total_brate, -1, 0 ); - } - - IF( ( st_fx->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); - } - - InitTransientDetection_fx( frame_length, NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->hTranDet ); - -#if 1 ////////////////////////////////////////////////////////////////////////////////////////////// - - - set32_fx( st_fx->mem_hp20_in_fx, 0, 5 ); - - /*-----------------------------------------------------------------* - * IVAS parameters - *-----------------------------------------------------------------*/ - - st_fx->Q_syn2 = 0; - move16(); - st_fx->Q_syn = 0; - move16(); - set16_fx( st_fx->Q_max, Q_MAX, L_Q_MEM ); - set16_fx( st_fx->Q_max_16k, Q_MAX, L_Q_MEM ); - st_fx->Q_old = 15; - move16(); - st_fx->old_wsp_max = 0; - move16(); - st_fx->old_wsp_shift = 0; - move16(); +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ +/*==================================================================================== + EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + ====================================================================================*/ - st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ - move16(); - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ - move16(); - st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ - move16(); +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_com_fx.h" /* Static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ +#include "stl.h" +#include "ivas_cnst.h" +#include "ivas_error.h" +#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx_enc.h" /* Function prototypes */ +#include "ivas_prot_fx.h" -#endif ////////////////////////////////////////////////////////////////////////////////////////////// - return error; -} +/*-----------------------------------------------------------------------* + * init_encoder() + * + * Initialization of state variables + *-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------* * LPDmem_enc_init_fx() @@ -1214,7 +100,7 @@ void LPDmem_enc_init_fx( } -ivas_error init_encoder_ivas_fx( +ivas_error init_encoder_fx( Encoder_State *st, /* i/o: state structure */ Encoder_Struct *st_ivas, /* i/o: encoder state structure */ const Word16 idchan, /* i : channel ID */ @@ -1223,15 +109,12 @@ ivas_error init_encoder_ivas_fx( const Word32 element_brate /* i : element bitrate */ ) { - Word16 i, frame_length; + Word16 i, input_frame; ivas_error error; Word32 igf_brate; - error = IVAS_ERR_OK; - move32(); - - /* frame_length = st->input_Fs / FRAMES_PER_SEC */ - frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + /* input_frame = st->input_Fs / FRAMES_PER_SEC */ + input_frame = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /*-----------------------------------------------------------------* * General parameters @@ -1604,15 +487,15 @@ ivas_error init_encoder_ivas_fx( IF( st->element_mode == EVS_MONO ) { - st->input32_fx = st->input_buff32_fx + add( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + st->input32_fx = st->input_buff32_fx + add( input_frame, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); st->input_fx = st->input_buff_fx + add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); ///////////////////// input_Fs - st->old_input_signal_fx = st->input_fx - add( NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), frame_length ); + st->old_input_signal_fx = st->input_fx - add( NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_frame ); st->old_input_signal32_fx = st->input_buff32_fx; } ELSE { - st->input32_fx = st->input_buff32_fx + frame_length; - st->input_fx = st->input_buff_fx + frame_length; + st->input32_fx = st->input_buff32_fx + input_frame; + st->input_fx = st->input_buff_fx + input_frame; st->old_input_signal_fx = st->input_buff_fx; st->old_input_signal32_fx = st->input_buff32_fx; } @@ -2331,7 +1214,10 @@ ivas_error init_encoder_ivas_fx( test(); IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - createFdCngEnc_fx( &st->hFdCngEnc ); + IF( ( error = createFdCngEnc_fx( &st->hFdCngEnc ) ) != IVAS_ERR_OK ) + { + return error; + } initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); @@ -2371,11 +1257,11 @@ ivas_error init_encoder_ivas_fx( IF( GT_16( st->element_mode, EVS_MONO ) ) { - InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); + InitTransientDetection_ivas_fx( input_frame, 0, st->hTranDet, 1 ); } ELSE { - InitTransientDetection_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet ); + InitTransientDetection_fx( input_frame, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet ); } /*-----------------------------------------------------------------* @@ -2409,7 +1295,7 @@ ivas_error init_encoder_ivas_fx( move16(); #endif - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 0d063f5af..239ec7823 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1447,7 +1447,7 @@ ivas_error create_cpe_enc_fx( } st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move16(); - IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, n, 0, ISM_MODE_NONE, hCPE->element_brate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = init_encoder_fx( st, st_ivas, n, 0, ISM_MODE_NONE, hCPE->element_brate ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 9424f7e9b..fa58f2674 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -474,19 +474,9 @@ ivas_error create_sce_enc_fx( st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; st->input_Fs = st_ivas->hEncoderConfig->input_Fs; - IF( st->element_mode == EVS_MONO ) + IF( NE_32( ( error = init_encoder_fx( st, st_ivas, 0, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) { - IF( NE_32( ( error = init_encoder_fx( st, st_ivas ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE - { - IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) - { - return error; - } + return error; } hSCE->hCoreCoder[0] = st; diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 15643b702..89d152677 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -228,7 +228,7 @@ ivas_error ivas_spar_enc_open_fx( hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; move32(); move32(); - IF( NE_32( ( error = init_encoder_ivas_fx( hSpar->hCoreCoderVAD, st_ivas, 0, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = init_encoder_fx( hSpar->hCoreCoderVAD, st_ivas, 0, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index b6690d8c7..abc0d056b 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -603,7 +603,10 @@ ivas_error stereo_memory_enc_fx( IF( st->hFdCngEnc == NULL ) { - createFdCngEnc_fx( &st->hFdCngEnc ); + IF( ( error = createFdCngEnc_fx( &st->hFdCngEnc ) ) != IVAS_ERR_OK ) + { + return error; + } initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); configureFdCngEnc_ivas_fx( st->hFdCngEnc, st->bwidth, st->rf_mode && st->total_brate == ACELP_13k20 ? ACELP_9k60 : st->total_brate ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 27e508c1a..cc55961b1 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4583,11 +4583,6 @@ void index_lvq_ivas_fx( Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ const Word16 prediction_flag ); -ivas_error init_encoder_fx( - Encoder_State *st_fx, /* i/o: Encoder static variables structure */ - Encoder_Struct *st_ivas /* i/o: encoder state structure */ -); - void copy_encoder_config_fx( Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ Encoder_State *st, /* o : encoder state structure */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 8b3d56e8e..d3cb56d79 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1152,20 +1152,16 @@ typedef struct tcx_enc_structure Word16 transform_type[2]; /* TCX20/10/5 mode in each subframe */ /* Core Signal Analysis Outputs */ - Word16 noiseTiltFactor; /* compensation for LPC tilt in noise filling Q15 */ Word16 noiseLevelMemory_cnt; /* counter of consecutive low TCX noise levels */ Word16 ltpGainMemory_fx[N_LTP_GAIN_MEMS]; /* for smoothing noiseTransWidth Q15 */ STnsData tnsData[2]; - // Word16 fUseTns[2]; Word8 fUseTns[2]; Word16 bTnsOnWhithenedSpectra[2]; - // Word16 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word8 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word16 *speech_TCX; Word16 *new_speech_TCX; - // Word16 q_speech_TCX; Word16 tcxltp; Word16 tcxltp_pitch_int; @@ -1219,6 +1215,7 @@ typedef struct tcx_enc_structure Word16 spectrum_long_e; /* MDCT output for a long block. Points to spectrum */ Word16 q_spectrum_long_fx; Word16 spectrum_length; /* corresponds to L_frameTCX, used for scaling of MDCT/MDST buffers */ + } TCX_ENC_DATA, *TCX_ENC_HANDLE; @@ -1289,33 +1286,8 @@ typedef struct enc_core_structure char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ #endif #endif - Word16 nTimeSlots; /* for CLDFB */ - Word16 ini_frame; /* initialization frames counter */ - // Word32 input_Fs_fx; /* input signal sampling frequency in Hz */ - // Word32 total_brate_fx; /* total bitrate in kbps of the codec */ - // Word32 last_total_brate_fx; /* total bitrate in kbps of the codec */ - // Word32 last_total_brate_cng_fx; /* total bitrate in kbps of the last inactive frame */ - // Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ - // Word32 core_brate_fx; /* core bitrate */ - // Word32 last_core_brate_fx; /* previous frame core bitrate */ - // Word16 extl_fx; /* extension layer */ - // Word16 last_extl_fx; /* previous extension layer */ - // Word32 extl_brate_fx; /* extension layer bitrate */ - // Word16 input_bwidth_fx; /* input signal bandwidth */ - // Word16 last_input_bwidth_fx; /* input signal bandwidth in the previous frame */ - // Word16 bwidth_fx; /* encoded bandwidth NB, WB, SWB or FB */ - // Word16 max_bwidth_fx; /* maximum encoded bandwidth */ - // Word16 last_bwidth_fx; /* input signal bandwidth in the previous frame */ - // Word16 last_bwidth_cng_fx; /* input signal bandwidth in the previous inactive frame */ - // Word16 L_frame_fx; /* ACELP core internal frame length */ - // Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - // Word16 Opt_DTX_ON_fx; /* flag indicating DTX operation */ - // Word16 cng_type; /* flag indicating LP or CLDFB based SID/CNG */ - // Word16 Opt_SC_VBR_fx; /* flag indicating SC-VBR mode */ - // Word16 last_Opt_SC_VBR_fx; /* flag indicating SC-VBR mode in the last frame */ - /*----------------------------------------------------------------------------------* * ACELP core parameters *----------------------------------------------------------------------------------*/ @@ -1326,27 +1298,25 @@ typedef struct enc_core_structure Word16 fmerit_dt; /* signal classification score difference Q15 */ Word16 Nb_ACELP_frames; - Word16 pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ - // Word16 pitch_fx[3]; + Word16 pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ Word16 voicing_fx[3]; /* open-loop normalized correlation values for three half-frames Q15 */ LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ - Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ - Word16 q_Bin_E; /* Q_new + Q_SCALE -2 per bin energy of two frames */ - Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame Q15 */ - Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ - Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame Q15 */ - Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ - Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ - Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ - Word16 pstreaklen; /* LSF quantizer */ - Word16 streaklimit_fx; /* LSF quantizer Q15 */ - Word16 stab_fac_fx; /* LSF stability factor Q15 */ - Word16 clip_var_fx[6]; /* pitch gain clipping memory [2.56x,Q14,Q8,Q0,Q14,Q14] */ - Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) Qlog2(2.56) */ - Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) Qlog2(2.56) */ - // Word16 pstreaklen_fx; /* LSF quantizer */ + Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ + Word16 q_Bin_E; /* Q_new + Q_SCALE -2 per bin energy of two frames */ + Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame Q15 */ + Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ + Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame Q15 */ + Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ + Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ + Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ + Word16 pstreaklen; /* LSF quantizer */ + Word16 streaklimit_fx; /* LSF quantizer Q15 */ + Word16 stab_fac_fx; /* LSF stability factor Q15 */ + Word16 clip_var_fx[6]; /* pitch gain clipping memory [2.56x,Q14,Q8,Q0,Q14,Q14] */ + Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) Qlog2(2.56) */ + Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) Qlog2(2.56) */ Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ Word32 offset_scale2_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 2nd 8-dim subvector*/ Word32 offset_scale1_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 1st 8-dim subvector*/ @@ -1362,7 +1332,6 @@ typedef struct enc_core_structure Word16 old_wsp_fx[L_WSP_MEM]; /* old weighted signal vector */ Word16 exp_old_wsp; Word16 Q_old_wsp2; - /*Word16 old_exc_fx[L_EXC_MEM];*/ /* old excitation vector */ Word16 old_wsp2_fx[( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM]; /* old decimated weighted signal vector qwsp */ Word16 mem_wsp_fx; /* weighted signal vector memory */ Word16 mem_wsp_q; @@ -1379,7 +1348,6 @@ typedef struct enc_core_structure Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame Qlog2(2.56) */ Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC Qlog2(2.56) */ Word16 next_force_safety_net; /* FEC - flag to force safety net in next frame */ - // Word16 next_force_safety_net_fx; /* FEC - flag to force safety net in next frame */ Word16 uv_count; /* Stationary noise UV modification - unvoiced counter */ Word16 act_count; /* Stationary noise UV modification - activation counter */ @@ -1475,6 +1443,8 @@ typedef struct enc_core_structure Word16 exp_buf_wspeech_enc; Word16 exp_buf_synth; + Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ + /*----------------------------------------------------------------------------------* * Noise estimation *----------------------------------------------------------------------------------*/ @@ -1487,8 +1457,6 @@ typedef struct enc_core_structure SP_MUS_CLAS_HANDLE hSpMusClas; - Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ - Word16 sp_aud_decision0; /* 1st stage speech/music decision flag */ Word16 sp_aud_decision1; /* 1st stage speech/music classification flag */ Word16 sp_aud_decision2; /* 2nd stage speech/music classification flag */ @@ -1527,9 +1495,6 @@ typedef struct enc_core_structure HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc; /* main analysis filter bank handle */ HANDLE_CLDFB_FILTER_BANK cldfbSynTd; /* synthesis filterbank - used for HB signal generation */ - // HANDLE_CLDFB_FILTER_BANK cldfbAna_Fx; - - // HANDLE_CLDFB_FILTER_BANK cldfbSyn_Fx; /*----------------------------------------------------------------------------------* * FD CNG handle @@ -1560,7 +1525,6 @@ typedef struct enc_core_structure HQ_ENC_HANDLE hHQ_core; /* HQ core encoder handle */ - PVQ_ENC_HANDLE hPVQ; /*----------------------------------------------------------------------------------* * TD BWE parameters *----------------------------------------------------------------------------------*/ @@ -1682,7 +1646,6 @@ typedef struct enc_core_structure Word16 encoderLookahead_FB; /* pitch_ol for adaptive lag window */ - Word16 old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ -- GitLab From d3015a847ccca5f3e24b324998812431d51d2fd0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 10 Sep 2025 17:37:46 +0200 Subject: [PATCH 010/351] revision of core-coder struct members: remove obsolete ones, merge duplicates (hTranDet, hp20 memory), move TD BWE ones under the related sub-struct --- lib_enc/acelp_core_enc_fx.c | 4 +- lib_enc/amr_wb_enc_fx.c | 11 +- lib_enc/core_enc_ol_fx.c | 6 +- lib_enc/core_enc_switch_fx.c | 4 +- lib_enc/core_switching_enc_fx.c | 11 +- lib_enc/evs_enc_fx.c | 2 +- lib_enc/ext_sig_ana_fx.c | 4 +- lib_enc/gs_enc_fx.c | 2 +- lib_enc/igf_enc_fx.c | 2 +- lib_enc/init_enc_fx.c | 99 ++++---------- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_init_enc_fx.c | 3 +- lib_enc/ivas_ism_enc_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 6 +- lib_enc/ivas_stereo_switching_enc_fx.c | 6 +- lib_enc/ivas_stereo_td_enc_fx.c | 4 +- lib_enc/lib_enc_fx.c | 6 +- lib_enc/mdct_selector_fx.c | 4 +- lib_enc/pre_proc_fx.c | 8 +- lib_enc/prot_fx_enc.h | 133 ++++++++++-------- lib_enc/stat_enc.h | 132 +++++------------- lib_enc/swb_tbe_enc_fx.c | 178 +++++++++++-------------- lib_enc/tcx_ltp_enc_fx.c | 73 +++++----- lib_enc/transient_detection_fx.c | 128 +++++++++++------- 24 files changed, 364 insertions(+), 466 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index eec55c1c7..0b3d95a7c 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1509,9 +1509,9 @@ ivas_error acelp_core_enc_ivas_fx( IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) { /* Apply a non linearity to the SHB excitation */ - Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); - Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc } test(); diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 1580a7818..25364e865 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -24,9 +24,10 @@ *--------------------------------------------------------------------*/ void amr_wb_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_sp[], /* i : input signal Q0*/ - const Word16 n_samples /* i : number of input samples Q0*/ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_sp[], /* i : input signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of input samples Q0*/ ) { Word16 i, delay; @@ -109,7 +110,7 @@ void amr_wb_enc_fx( move16(); st->coder_type = GENERIC; move16(); - input_frame = st->input_frame_fx; + input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); move16(); /* frame length of the input signal */ st->extl = -1; move16(); @@ -183,7 +184,7 @@ void amr_wb_enc_fx( st->input_fx[i] = 0; move16(); } - hp20( st->input_fx, 1, input_frame, st->mem_hp20_in_fx, st->input_Fs ); + hp20( st->input_fx, 1, input_frame, mem_hp20_in_fx, st->input_Fs ); /*-----------------------------------------------------------------* * switching from ACELP@16k core to AMR-WB IO mode diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 020af121c..7313a9db7 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -256,7 +256,7 @@ void core_encode_openloop_fx( /* reset TBE buffers previous frame frame wasn't ACELP*/ IF( st->last_core != ACELP_CORE ) { - TBEreset_enc_fx( st, st->bwidth ); + TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); } @@ -700,7 +700,7 @@ void core_encode_openloop_fx( test(); test(); IF( rf_PLC_Mode == 0 && hRF->rf_gain_tcx[1] != 0 && - ( ( st->transientDetection.transientDetector.bIsAttackPresent != 0 && LT_16( hRF->rf_gain_tcx[0], mult_r( hRF->rf_gain_tcx[1], 31785 /*0.97f Q15*/ ) ) ) || + ( ( st->hTranDet->transientDetector.bIsAttackPresent != 0 && LT_16( hRF->rf_gain_tcx[0], mult_r( hRF->rf_gain_tcx[1], 31785 /*0.97f Q15*/ ) ) ) || LT_16( hRF->rf_gain_tcx[0], mult_r( hRF->rf_gain_tcx[1], 29491 /*0.90f Q15*/ ) ) ) ) { TD_mode = 0; @@ -900,7 +900,7 @@ void core_acelp_tcx20_switching_fx( st->pit_fr2, st->pit_max, st->pit_res_max, - &st->transientDetection, + st->hTranDet, 0, A_q_tcx, M ); diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index fb5fd037a..8dafd3b04 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -173,7 +173,7 @@ void core_coder_mode_switch_fx( ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) { /* reset TBE buffers as previous frame wasn't using TBE */ - TBEreset_enc_fx( st, st->bwidth ); + TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); } ELSE { @@ -418,7 +418,7 @@ void core_coder_mode_switch_ivas_fx( ( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) || ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) { - TBEreset_enc_fx( st, st->bwidth ); + TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); } ELSE { diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 5b657e9c5..e0878969c 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -45,8 +45,6 @@ void core_switching_pre_enc_fx( { IF( hLPDmem != NULL ) { - st_fx->mem_deemph_fx = hLPDmem->syn[M]; - move16(); Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); /*hLPDmem->q_mem_syn*/ } @@ -200,7 +198,6 @@ void core_switching_pre_enc_fx( lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } - st_fx->mem_deemph_fx = 0; /* Reset ACELP parameters */ IF( hLPDmem != NULL ) { @@ -485,7 +482,7 @@ void core_switching_post_enc_fx( } ELSE IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) { - TBEreset_enc_fx( st_fx, st_fx->bwidth ); + TBEreset_enc_fx( st_fx->hBWE_TD, st_fx->last_core, st_fx->bwidth ); } test(); test(); @@ -660,8 +657,6 @@ void core_switching_pre_enc_ivas_fx( { IF( hLPDmem != NULL ) { - st_fx->mem_deemph_fx = hLPDmem->syn[M]; - move16(); Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); } @@ -818,8 +813,6 @@ void core_switching_pre_enc_ivas_fx( lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } - st_fx->mem_deemph_fx = 0; - move16(); /* Reset ACELP parameters */ IF( hLPDmem != NULL ) { @@ -1159,7 +1152,7 @@ void core_switching_post_enc_ivas_fx( } ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) { - TBEreset_enc_fx( st, st->bwidth ); + TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); } test(); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 8e9a82378..90d5a7b4b 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -100,7 +100,7 @@ ivas_error evs_enc_fx( * Initializiation *-----------------------------------------------------------------*/ - input_frame = st->input_frame_fx; + input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); move16(); st->core = -1; move16(); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 87fa6a451..42f6dc487 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -118,7 +118,7 @@ void core_signal_analysis_high_bitrate_fx( &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, &hTcxEnc->tcxltp_gain, &hTcxEnc->tcxltp_pitch_int_past, &hTcxEnc->tcxltp_pitch_fr_past, &hTcxEnc->tcxltp_gain_past, &hTcxEnc->tcxltp_norm_corr_past, st->last_core, st->pit_min, st->pit_fr1, - st->pit_fr2, st->pit_max, st->pit_res_max, &st->transientDetection, + st->pit_fr2, st->pit_max, st->pit_res_max, st->hTranDet, tmp8, NULL, M ); } ELSE @@ -130,7 +130,7 @@ void core_signal_analysis_high_bitrate_fx( &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, &hTcxEnc->tcxltp_gain, &hTcxEnc->tcxltp_pitch_int_past, &hTcxEnc->tcxltp_pitch_fr_past, &hTcxEnc->tcxltp_gain_past, &hTcxEnc->tcxltp_norm_corr_past, st->last_core, st->pit_min, st->pit_fr1, - st->pit_fr2, st->pit_max, st->pit_res_max, &st->transientDetection, + st->pit_fr2, st->pit_max, st->pit_res_max, st->hTranDet, tmp8, NULL, M ); } diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index c666840df..30e4385bf 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1000,7 +1000,7 @@ void gsc_enc_fx( highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, - hGSCEnc->last_exc_dct_in_fx, &st_fx->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); exc_dct_in[0] = 0; diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index b6a1c66c2..7481c4c86 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -1802,7 +1802,7 @@ void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in pPowerSpectrumParameterWhitening, /* i: MDCT^2 + MDST^2 spectrum, or estimate */ PowerSpectrum_e, /* i: exponent of powerSpectrum */ igfGridIdx, /* i: IGF grid index */ - ( st->transientDetection.transientDetector.bIsAttackPresent == 1 ), + ( st->hTranDet->transientDetector.bIsAttackPresent == 1 ), last_core_acelp ); /* i: last frame was acelp indicator */ pPowerSpectrumParameter = NULL; diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 0ee479a7c..6d11af682 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -27,7 +27,7 @@ ivas_error init_encoder_fx( const int16_t interval_SID /* i : interval for SID update */ ) { - Word16 i; + Word16 i, input_frame; Word32 L_tmp; @@ -40,6 +40,8 @@ ivas_error init_encoder_fx( error = IVAS_ERR_OK; + input_frame = extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ); + /*-----------------------------------------------------------------* * General signal buffers *-----------------------------------------------------------------*/ @@ -183,8 +185,6 @@ ivas_error init_encoder_fx( move16(); set16_fx( st_fx->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); set16_fx( st_fx->old_wsp_fx, 0, L_WSP_MEM ); - st_fx->mem_deemph_fx = 0; - move16(); st_fx->mem_preemph_fx = 0; move16(); st_fx->mem_preemph16k_fx = 0; @@ -230,7 +230,6 @@ ivas_error init_encoder_fx( move16(); st_fx->old_voicing_la = 0; move16(); - set32_fx( st_fx->mem_hp20_in_fx, 0, 5 ); st_fx->old_hpfilt_in_fx = 0; move16(); @@ -309,9 +308,6 @@ ivas_error init_encoder_fx( st_fx->hGSCEnc = NULL; } - st_fx->last_ener_fx = 0; - move16(); - st_fx->old_dE1_fx = 0; move16(); st_fx->old_ind_deltaMax = 0; @@ -576,7 +572,7 @@ ivas_error init_encoder_fx( *-----------------------------------------------------------------*/ /* open analysis for input SR */ - if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st_fx->input_Fs ), st_fx->input_frame_fx ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &st_fx->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st_fx->input_Fs ), input_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -688,8 +684,8 @@ ivas_error init_encoder_fx( // return error; // } - InitSWBencBuffer_fx( st_fx /*st_fx->hBWE_TD*/ ); - ResetSHBbuffer_Enc_fx( st_fx /*st_fx->hBWE_TD*/ ); + InitSWBencBuffer_fx( st_fx->hBWE_TD ); + ResetSHBbuffer_Enc_fx( st_fx->hBWE_TD ); } ELSE { @@ -720,7 +716,7 @@ ivas_error init_encoder_fx( st_fx->input_fx = st_fx->input_buff_fx + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ); set16_fx( st_fx->input_buff_fx + L_FRAME48k, 0, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ); - st_fx->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), st_fx->input_frame_fx ); + st_fx->old_input_signal_fx = st_fx->input_fx - add( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), input_frame ); st_fx->Energy_Old_fx = 0; @@ -882,10 +878,15 @@ ivas_error init_encoder_fx( st_fx->totalNoise_increase_len = 0; move16(); init_coder_ace_plus_fx( st_fx, st_fx->last_total_brate, 0, -10 /*hack*/ ); - // PMT("Transient detector init needs review, handle hTranDet is missing") + + IF( ( st_fx->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); + } + InitTransientDetection_fx( extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ), NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), - &st_fx->transientDetection ); + st_fx->hTranDet ); st_fx->Q_syn2 = 0; move16(); @@ -904,40 +905,30 @@ ivas_error init_encoder_fx( st_fx->tdm_LRTD_flag = 0; /* LRTD stereo mode flag */ move16(); - st_fx->cna_dirac_flag = 0; /* CNA in DirAC flag */ - move16(); st_fx->cng_sba_flag = 0; /* CNG in SBA flag */ move16(); st_fx->GSC_IVAS_mode = 0; /* CNG in SBA flag */ move16(); st_fx->element_mode = EVS_MONO; /* element mode */ move16(); - st_fx->last_element_mode = st_fx->element_mode; /* element mode */ - move16(); st_fx->element_brate = -1; /* element bitrate */ move32(); - // PMT("element_mode and element_brate should be initialized at a proper place in ivas_dec_init eventually") st_fx->low_rate_mode = 0; /* low-rate mode flag */ move16(); // st_fx->coder_type = GENERIC; /* low-rate mode flag */ set16_fx( st_fx->pitch, L_SUBFR, 3 ); set16_fx( st_fx->voicing_fx, 0, 3 ); - - #ifdef DEBUGGING st_fx->id_element = -1; /* element ID */ move16(); #endif - st_fx->extl_orig = -1; /* extension layer */ - move16(); - st_fx->extl_brate_orig = 0; /* extension layer bitrate */ - move32(); + return error; } /*-----------------------------------------------------------------------* - * LPDmem_enc_init_fx() + * LPDmem_enc_init() * * Initialization of ACELP LPDmem state variables *-----------------------------------------------------------------------*/ @@ -956,44 +947,13 @@ void LPDmem_enc_init_fx( set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); set16_fx( hLPDmem->mem_syn3, 0, M ); - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - hLPDmem->dm_fx.prev_state = 0; - move16(); /* This corresponds to st_fx->dispMem in FLP */ - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - - FOR( i = 2; i < 8; i++ ) - { - hLPDmem->dm_fx.prev_gain_pit[i - 2] = 0; - move16(); - } - return; -} - -void LPDmem_enc_init_ivas_fx( - LPD_state_HANDLE hLPDmem /* i/o: LP memories */ -) -{ - Word16 i; - - set16_fx( hLPDmem->syn, 0, 1 + M ); - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn1_fx, 0, M ); - set16_fx( hLPDmem->mem_syn2, 0, M ); - set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); - set16_fx( hLPDmem->mem_syn3, 0, M ); hLPDmem->q_lpd_old_exc = Q15; move16(); hLPDmem->q_lpd_syn = Q15; move16(); hLPDmem->q_mem_syn = Q15; move16(); + hLPDmem->mem_w0 = 0; move16(); hLPDmem->tilt_code = 0; @@ -1043,13 +1003,15 @@ ivas_error init_encoder_ivas_fx( const Word32 element_brate /* i : element bitrate */ ) { - Word16 i; + Word16 i, input_frame; ivas_error error; Word32 igf_brate; error = IVAS_ERR_OK; move32(); + input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + /*-----------------------------------------------------------------* * General parameters *-----------------------------------------------------------------*/ @@ -1666,9 +1628,7 @@ ivas_error init_encoder_ivas_fx( IF( EQ_16( st->element_mode, EVS_MONO ) ) { /* open analysis for input SR */ - st->input_frame_fx = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); - - if ( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st->input_Fs ), st->input_frame_fx ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &st->cldfbAnaEnc, CLDFB_ANALYSIS, CLDFB_getNumChannels( st->input_Fs ), input_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -1747,7 +1707,7 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - LPDmem_enc_init_ivas_fx( st->hLPDmem ); + LPDmem_enc_init_fx( st->hLPDmem ); } ELSE { @@ -1805,8 +1765,8 @@ ivas_error init_encoder_ivas_fx( return error; } } - InitSWBencBuffer_ivas_fx( st ); - ResetSHBbuffer_Enc_fx( st ); + InitSWBencBuffer_ivas_fx( st->hBWE_TD ); + ResetSHBbuffer_Enc_fx( st->hBWE_TD ); } ELSE { @@ -2144,19 +2104,14 @@ ivas_error init_encoder_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } - Word16 temp; - Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp ); - frame_length = shr( frame_length, sub( 15, temp ) ); IF( GT_16( st->element_mode, EVS_MONO ) ) { - InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); + InitTransientDetection_ivas_fx( input_frame, 0, st->hTranDet, 1 ); } ELSE { - InitTransientDetection_fx( extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ), - NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), - &st->transientDetection ); + InitTransientDetection_fx( input_frame, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet ); } /*-----------------------------------------------------------------* @@ -2183,8 +2138,6 @@ ivas_error init_encoder_ivas_fx( move16(); st->old_wsp_shift = 0; move16(); - st->sharpFlag = 0; - move16(); return error; } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index c9c54c2c6..b73702d21 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -493,7 +493,7 @@ ivas_error ivas_cpe_enc_fx( RunTransientDetection_ivas_fx( sts[n]->input_fx, input_frame, sts[n]->hTranDet, sts[n]->q_inp ); // Note q of sts[n]->input_fx changes inside function } - currFlatness_fx[n] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) sts[n]->hTranDet, NSUBBLOCKS, 0 ); // Q21 + currFlatness_fx[n] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( sts[n]->hTranDet, NSUBBLOCKS, 0 ); // Q21 move32(); } diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 5a3592ad2..f4e88f41c 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -1244,8 +1244,7 @@ void destroy_evs_core_enc_fx( IF( hCoreCoder->hVAD_CLDFB != NULL ) { - /* This is not required as we are not allocating memory dynamically */ - // free( hCoreCoder->hVAD_CLDFB ); + free( hCoreCoder->hVAD_CLDFB ); hCoreCoder->hVAD_CLDFB = NULL; } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index dc41c784d..6b75a6be7 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -217,7 +217,7 @@ ivas_error ivas_ism_enc_fx( RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet, st->q_inp ); - currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, 0 ); // Q21 + currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( st->hTranDet, NSUBBLOCKS, 0 ); // Q21 move16(); /*----------------------------------------------------------------* diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 180e175ec..841f4bea2 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -184,7 +184,7 @@ ivas_error ivas_sce_enc_fx( RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet, q_input ); } - currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, 0 ); // Q21 + currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( st->hTranDet, NSUBBLOCKS, 0 ); // Q21 move32(); /*----------------------------------------------------------------* @@ -472,7 +472,6 @@ ivas_error create_sce_enc_fx( move32(); st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; st->input_Fs = st_ivas->hEncoderConfig->input_Fs; - st->input_frame_fx = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ), IVAS_ERR_OK ) ) { @@ -556,9 +555,6 @@ ivas_error create_evs_sce_enc_fx( st_fx->total_brate = st_ivas->hEncoderConfig->ivas_total_brate; move32(); - st_fx->input_frame_fx = extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ); - move16(); - IF( NE_32( ( error = init_encoder_fx( st_fx, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID ) ), IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 469bf211a..9e1649eb2 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -58,7 +58,7 @@ static ivas_error allocate_CoreCoder_enc_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); } - LPDmem_enc_init_ivas_fx( st->hLPDmem ); + LPDmem_enc_init_fx( st->hLPDmem ); } IF( st->hGSCEnc == NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -435,8 +435,8 @@ ivas_error stereo_memory_enc_fx( } } - InitSWBencBuffer_ivas_fx( st ); - ResetSHBbuffer_Enc_fx( st ); + InitSWBencBuffer_ivas_fx( st->hBWE_TD ); + ResetSHBbuffer_Enc_fx( st->hBWE_TD ); IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) { diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 8f1d2d9c9..1c9a5511e 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -327,8 +327,8 @@ ivas_error stereo_set_tdm_fx( return error; } - InitSWBencBuffer_ivas_fx( st ); - ResetSHBbuffer_Enc_fx( st ); + InitSWBencBuffer_ivas_fx( st->hBWE_TD ); + ResetSHBbuffer_Enc_fx( st->hBWE_TD ); IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) { diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 295608d6f..f64bdfd1e 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1489,16 +1489,14 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( IF( hEncoderConfig->Opt_AMR_WB ) { - amr_wb_enc_fx( hCoreCoder, inputBuffer, inputBufferSize ); + amr_wb_enc_fx( hCoreCoder, inputBuffer, st_ivas->mem_hp20_in_fx[0], inputBufferSize ); } ELSE { #ifdef DEBUG_MODE_INFO dbgwrite( inputBuffer, sizeof( int16_t ), inputBufferSize, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, 1, ENC ), ".pcm" ) ); #endif - hCoreCoder->input_frame_fx = inputBufferSize; - move32(); - IF( NE_32( ( error = evs_enc_fx( hCoreCoder, inputBuffer, hCoreCoder->mem_hp20_in_fx, inputBufferSize ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = evs_enc_fx( hCoreCoder, inputBuffer, st_ivas->mem_hp20_in_fx[0], inputBufferSize ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/mdct_selector_fx.c b/lib_enc/mdct_selector_fx.c index c4cc7d0db..8799806e4 100644 --- a/lib_enc/mdct_selector_fx.c +++ b/lib_enc/mdct_selector_fx.c @@ -315,11 +315,11 @@ void MDCT_selector_fx( test(); prefer_hq_core = ( LT_16( sub( Etot, sp_floor ), sig_lo_level_thr ) ) || /* noise floor is very high */ ( LT_16( cor_map_sum, cor_thr2 ) && LT_16( frame_voicing, voicing_thr2 ) && LT_16( sparseness, sparseness_thr2 ) ) || /* too weak tonal components */ - ( EQ_16( st->mdct_sw_enable, MODE1 ) && prefer_tcx == 0 && EQ_16( st->transientDetection.transientDetector.bIsAttackPresent, 1 ) ); + ( EQ_16( st->mdct_sw_enable, MODE1 ) && prefer_tcx == 0 && EQ_16( st->hTranDet->transientDetector.bIsAttackPresent, 1 ) ); /* Prefer HQ_CORE on transients */ test(); - IF( EQ_16( st->mdct_sw_enable, MODE2 ) && EQ_16( st->transientDetection.transientDetector.bIsAttackPresent, 1 ) ) + IF( EQ_16( st->mdct_sw_enable, MODE2 ) && EQ_16( st->hTranDet->transientDetector.bIsAttackPresent, 1 ) ) { prefer_tcx = 0; move16(); diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 55e7437ee..ea94e6236 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -209,7 +209,7 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -393,8 +393,8 @@ void pre_proc_fx( test(); IF( st->tcx10Enabled || st->tcx20Enabled ) { - RunTransientDetection_fx( signal_in, input_frame, &st->transientDetection ); - currFlatness = GetTCXAvgTemporalFlatnessMeasure_fx( &st->transientDetection, NSUBBLOCKS, 0 ); + RunTransientDetection_fx( signal_in, input_frame, st->hTranDet ); + currFlatness = GetTCXAvgTemporalFlatnessMeasure_fx( st->hTranDet, NSUBBLOCKS, 0 ); } /*----------------------------------------------------------------* @@ -1261,7 +1261,7 @@ void pre_proc_fx( * TCX mode decision *---------------------------------------------------------------*/ - SetTCXModeInfo_fx( st, &st->transientDetection, &st->hTcxCfg->tcx_curr_overlap_mode ); + SetTCXModeInfo_fx( st, st->hTranDet, &st->hTcxCfg->tcx_curr_overlap_mode ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 28389e9e0..9d916f13a 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -863,10 +863,6 @@ void LPDmem_enc_init_fx( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); -void LPDmem_enc_init_ivas_fx( - LPD_state_HANDLE hLPDmem /* i/o: LP memories */ -); - void lsf_end_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ @@ -1044,14 +1040,16 @@ void calculate_hangover_attenuation_gain_fx( * Don't include the delay of the MDCT overlap. * @param pTransientDetection Structure to be initialized. It contains all transient detectors to be used. */ -void InitTransientDetection_fx( Word16 nFrameLength, - Word16 nTCXDelay, - struct TransientDetection *pTransientDetection ); +void InitTransientDetection_fx( + const Word16 nFrameLength, + const Word16 nTCXDelay, + TRAN_DET_HANDLE hTranDet ); -void InitTransientDetection_ivas_fx( Word16 nFrameLength, - Word16 nTCXDelay, - TRAN_DET_HANDLE pTransientDetection, - const Word16 ext_mem_flag ); +void InitTransientDetection_ivas_fx( + const Word16 nFrameLength, + const Word16 nTCXDelay, + TRAN_DET_HANDLE hTranDet, + const Word16 ext_mem_flag ); /** Runs transient detection. * Runs all transient detectors defined in pTransientDetection @@ -1060,7 +1058,10 @@ void InitTransientDetection_ivas_fx( Word16 nFrameLength, * @param nSamplesAvailable Number of new i samples available. * @param pTransientDetection Structure that contains transient detectors to be run. */ -void RunTransientDetection_fx( Word16 const *i, Word16 nSamplesAvailable, struct TransientDetection *pTransientDetection ); +void RunTransientDetection_fx( + Word16 const *i, + const Word16 nSamplesAvailable, + TRAN_DET_HANDLE hTranDet ); void RunTransientDetection_ivas_fx( @@ -1077,8 +1078,15 @@ void RunTransientDetection_ivas_fx( * @param nPrevSubblocks Number of subblocks from the previous frames to use for the calculation. * @return average temporal flatness measure with exponent AVG_FLAT_E */ -Word16 GetTCXAvgTemporalFlatnessMeasure_fx( struct TransientDetection const *pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks ); -Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const *pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks ); +Word16 GetTCXAvgTemporalFlatnessMeasure_fx( + TRAN_DET_HANDLE hTranDet, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); + +Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); /** Get the maximum energy change using subblock energies aligned with the TCX. * @param pTransientDetection Structure that contains transient detectors to be run. @@ -1087,16 +1095,18 @@ Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const * @param nPrevSubblocks Number of subblocks from the previous frames to use for the calculation. * @param maximum energy change with exponent NRG_CHANGE_E */ -Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDetection, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ); +Word16 GetTCXMaxenergyChange_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); -Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ); +Word16 GetTCXMaxenergyChange_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); /** Set TCX window length and overlap configuration * @param prevEnergyHF previous HF energy. Exponent must be the same as for currEnergyHF. @@ -1112,9 +1122,10 @@ void SetTCXModeInfo_ivas_fx( * @param prevEnergyHF previous HF energy. Exponent must be the same as for currEnergyHF. * @param currEnergyHF current HF energy. Exponent must be the same as for prevEnergyHF. */ -void SetTCXModeInfo_fx( Encoder_State *st, - struct TransientDetection const *pTransientDetection, - Word16 *tcxModeOverlap ); +void SetTCXModeInfo_fx( + Encoder_State *st, + TRAN_DET_HANDLE hTranDet, + Word16 *tcxModeOverlap ); void GSC_enc_init_fx( GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */ @@ -2645,34 +2656,35 @@ Word16 vlpc_1st_cod_fx( const Word16 *lsf, /* i : vector to quantize , Word16 rf_mode ); -void tcx_ltp_encode_fx( Word16 tcxltp_on, - Word8 tcxOnly, - Word16 tcxMode, - Word16 L_frame, - Word16 L_subfr, - Word16 *speech, - Word16 *speech_ltp, - Word16 *wsp, - Word16 Top, - Word16 *ltp_param, - Word16 *ltp_bits, - Word16 *pitch_int, - Word16 *pitch_fr, - Word16 *gain, - Word16 *pitch_int_past, - Word16 *pitch_fr_past, - Word16 *gain_past, - Word16 *norm_corr_past, - Word16 last_core, - Word16 pitmin, - Word16 pitfr1, - Word16 pitfr2, - Word16 pitmax, - Word16 pitres, - struct TransientDetection const *pTransientDetection, - Word8 SideInfoOnly, - Word16 *A, - Word16 lpcorder ); +void tcx_ltp_encode_fx( + Word16 tcxltp_on, + Word8 tcxOnly, + Word16 tcxMode, + Word16 L_frame, + Word16 L_subfr, + Word16 *speech, + Word16 *speech_ltp, + Word16 *wsp, + Word16 Top, + Word16 *ltp_param, + Word16 *ltp_bits, + Word16 *pitch_int, + Word16 *pitch_fr, + Word16 *gain, + Word16 *pitch_int_past, + Word16 *pitch_fr_past, + Word16 *gain_past, + Word16 *norm_corr_past, + Word16 last_core, + Word16 pitmin, + Word16 pitfr1, + Word16 pitfr2, + Word16 pitmax, + Word16 pitres, + TRAN_DET_HANDLE hTranDet, + Word8 SideInfoOnly, + Word16 *A, + Word16 lpcorder ); void tcx_ltp_encode_ivas_fx( Encoder_State *st, @@ -3513,8 +3525,9 @@ void re8_cod_fx( ); void TBEreset_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 bandwidth /* i : bandwidth mode */ + TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const int16_t last_core, /* i : last core */ + Word16 bandwidth /* i : bandwidth mode */ ); void acelp_core_switch_enc_fx( @@ -4228,16 +4241,17 @@ void noise_est_init_ivas_fx( ); void InitSWBencBuffer_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); void InitSWBencBuffer_ivas_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); void ResetSHBbuffer_Enc_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ); + Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); void acelp_1t64_fx( @@ -4588,8 +4602,9 @@ void destroy_encoder_fx( ); void amr_wb_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ + Encoder_State *st, /* i/o: encoder state structure */ const Word16 input_sp[], /* i : i signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ const Word16 n_samples /* i : number of i samples Q0*/ ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index fdcff722c..760bbcb87 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -708,8 +708,6 @@ typedef struct sp_mus_clas_structure typedef struct lpd_state_structure { - - /* signal memory */ Word16 syn[1 + M]; /* Synthesis memory (non-pe) */ Word16 q_lpd_syn; @@ -803,7 +801,6 @@ typedef struct hq_enc_structure Word16 last_env_fx[BANDS_MAX]; /* Q1 */ Word16 last_max_pos_pulse; - } HQ_ENC_DATA, *HQ_ENC_HANDLE; /* PVQ range coder state */ @@ -1007,6 +1004,13 @@ typedef struct td_bwe_enc_structure Word16 gain_prec_swb_fx; /* Q14 */ Word16 mem_zero_swb_fx[LPC_SHB_ORDER]; + Word16 prev_lsp_wb_fx[LPC_SHB_ORDER_WB]; + Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; + Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; + + Word16 prev_Q_bwe_exc; + Word16 prev_Q_bwe_syn; + } TD_BWE_ENC_DATA, *TD_BWE_ENC_HANDLE; @@ -1152,20 +1156,17 @@ typedef struct tcx_enc_structure Word16 transform_type[2]; /* TCX20/10/5 mode in each subframe */ /* Core Signal Analysis Outputs */ - Word16 noiseTiltFactor; /* compensation for LPC tilt in noise filling Q15 */ Word16 noiseLevelMemory_cnt; /* counter of consecutive low TCX noise levels */ Word16 ltpGainMemory_fx[N_LTP_GAIN_MEMS]; /* for smoothing noiseTransWidth Q15 */ STnsData tnsData[2]; - // Word16 fUseTns[2]; + Word8 fUseTns[2]; Word16 bTnsOnWhithenedSpectra[2]; - // Word16 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word8 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word16 *speech_TCX; Word16 *new_speech_TCX; - // Word16 q_speech_TCX; Word16 tcxltp; Word16 tcxltp_pitch_int; @@ -1219,17 +1220,9 @@ typedef struct tcx_enc_structure Word16 spectrum_long_e; /* MDCT output for a long block. Points to spectrum */ Word16 q_spectrum_long_fx; Word16 spectrum_length; /* corresponds to L_frameTCX, used for scaling of MDCT/MDST buffers */ + } TCX_ENC_DATA, *TCX_ENC_HANDLE; -typedef struct TransientDetection -{ - /** Transient detector. */ - TransientDetector transientDetector; - /** Delay buffer used by the transient detectors. */ - DelayBuffer delayBuffer; - /** Subblock energies used by the transient detector. */ - SubblockEnergies subblockEnergies; -} TransientDetection; /*----------------------------------------------------------------------------------* * @@ -1246,10 +1239,7 @@ typedef struct enc_core_structure Word16 idchan; /* channel ID (audio channel number) */ Word16 id_element; /* element ID */ Word16 element_mode; /* element mode */ - Word16 last_element_mode; /* element mode */ Word32 element_brate; /* element bitrate */ - Word16 extl_orig; /* extension layer */ - Word32 extl_brate_orig; /* extension layer bitrate */ Word16 codec_mode; /* Mode1 or Mode2 */ Word16 last_codec_mode; /* previous frame Mode 1 or 2 */ Word16 last_codec_mode_cng; /* previous inactive frame Mode 1 or 2 */ @@ -1258,9 +1248,7 @@ typedef struct enc_core_structure Word16 mdct_sw_enable; /* MDCT switching enable flag */ Word16 mdct_sw; /* MDCT switching indicator */ - BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ - Word16 last_enerBuffer_exp; - + BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME) */ Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ @@ -1299,34 +1287,8 @@ typedef struct enc_core_structure char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ #endif #endif - Word16 nTimeSlots; /* for CLDFB */ - Word16 ini_frame; /* initialization frames counter */ - // Word32 input_Fs_fx; /* input signal sampling frequency in Hz */ - // Word32 total_brate_fx; /* total bitrate in kbps of the codec */ - // Word32 last_total_brate_fx; /* total bitrate in kbps of the codec */ - // Word32 last_total_brate_cng_fx; /* total bitrate in kbps of the last inactive frame */ - // Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ - // Word32 core_brate_fx; /* core bitrate */ - // Word32 last_core_brate_fx; /* previous frame core bitrate */ - Word16 input_frame_fx; /* Frame lenght (function of input_Fs) */ - // Word16 extl_fx; /* extension layer */ - // Word16 last_extl_fx; /* previous extension layer */ - // Word32 extl_brate_fx; /* extension layer bitrate */ - // Word16 input_bwidth_fx; /* input signal bandwidth */ - // Word16 last_input_bwidth_fx; /* input signal bandwidth in the previous frame */ - // Word16 bwidth_fx; /* encoded bandwidth NB, WB, SWB or FB */ - // Word16 max_bwidth_fx; /* maximum encoded bandwidth */ - // Word16 last_bwidth_fx; /* input signal bandwidth in the previous frame */ - // Word16 last_bwidth_cng_fx; /* input signal bandwidth in the previous inactive frame */ - // Word16 L_frame_fx; /* ACELP core internal frame length */ - // Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - // Word16 Opt_DTX_ON_fx; /* flag indicating DTX operation */ - // Word16 cng_type; /* flag indicating LP or CLDFB based SID/CNG */ - // Word16 Opt_SC_VBR_fx; /* flag indicating SC-VBR mode */ - // Word16 last_Opt_SC_VBR_fx; /* flag indicating SC-VBR mode in the last frame */ - /*----------------------------------------------------------------------------------* * ACELP core parameters *----------------------------------------------------------------------------------*/ @@ -1337,27 +1299,25 @@ typedef struct enc_core_structure Word16 fmerit_dt; /* signal classification score difference Q15 */ Word16 Nb_ACELP_frames; - Word16 pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ - // Word16 pitch_fx[3]; + Word16 pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ Word16 voicing_fx[3]; /* open-loop normalized correlation values for three half-frames Q15 */ LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ - Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ - Word16 q_Bin_E; /* Q_new + Q_SCALE -2 per bin energy of two frames */ - Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame Q15 */ - Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ - Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame Q15 */ - Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ - Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ - Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ - Word16 pstreaklen; /* LSF quantizer */ - Word16 streaklimit_fx; /* LSF quantizer Q15 */ - Word16 stab_fac_fx; /* LSF stability factor Q15 */ - Word16 clip_var_fx[6]; /* pitch gain clipping memory [2.56x,Q14,Q8,Q0,Q14,Q14] */ - Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) Qlog2(2.56) */ - Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) Qlog2(2.56) */ - // Word16 pstreaklen_fx; /* LSF quantizer */ + Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ + Word16 q_Bin_E; /* Q_new + Q_SCALE -2 per bin energy of two frames */ + Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame Q15 */ + Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ + Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame Q15 */ + Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ + Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ + Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ + Word16 pstreaklen; /* LSF quantizer */ + Word16 streaklimit_fx; /* LSF quantizer Q15 */ + Word16 stab_fac_fx; /* LSF stability factor Q15 */ + Word16 clip_var_fx[6]; /* pitch gain clipping memory [2.56x,Q14,Q8,Q0,Q14,Q14] */ + Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) Qlog2(2.56) */ + Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) Qlog2(2.56) */ Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ Word32 offset_scale2_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 2nd 8-dim subvector*/ Word32 offset_scale1_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 1st 8-dim subvector*/ @@ -1373,15 +1333,12 @@ typedef struct enc_core_structure Word16 old_wsp_fx[L_WSP_MEM]; /* old weighted signal vector */ Word16 exp_old_wsp; Word16 Q_old_wsp2; - /*Word16 old_exc_fx[L_EXC_MEM];*/ /* old excitation vector */ Word16 old_wsp2_fx[( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM]; /* old decimated weighted signal vector qwsp */ Word16 mem_wsp_fx; /* weighted signal vector memory */ Word16 mem_wsp_q; - Word16 mem_decim2_fx[3]; /* weighted signal decimation filter memory qwsp */ - Word16 mem_deemph_fx; /* deemphasis filter memory */ - Word32 mem_hp20_in_fx[5]; /* HP filter memory for AMR-WB IO */ - Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ - Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ + Word16 mem_decim2_fx[3]; /* weighted signal decimation filter memory qwsp */ + Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ + Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ Word16 GSC_IVAS_mode; GSC_ENC_HANDLE hGSCEnc; @@ -1390,7 +1347,6 @@ typedef struct enc_core_structure Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame Qlog2(2.56) */ Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC Qlog2(2.56) */ Word16 next_force_safety_net; /* FEC - flag to force safety net in next frame */ - // Word16 next_force_safety_net_fx; /* FEC - flag to force safety net in next frame */ Word16 uv_count; /* Stationary noise UV modification - unvoiced counter */ Word16 act_count; /* Stationary noise UV modification - activation counter */ @@ -1476,7 +1432,7 @@ typedef struct enc_core_structure Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ + Word16 *buf_synth; /* can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ Word16 *buf_speech_enc; // exp_buf_speech_enc Word16 *buf_wspeech_enc; // exp_buf_wspeech_enc @@ -1487,6 +1443,8 @@ typedef struct enc_core_structure Word16 exp_buf_wspeech_enc; Word16 exp_buf_synth; + Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ + /*----------------------------------------------------------------------------------* * Noise estimation *----------------------------------------------------------------------------------*/ @@ -1499,8 +1457,6 @@ typedef struct enc_core_structure SP_MUS_CLAS_HANDLE hSpMusClas; - Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ - Word16 sp_aud_decision0; /* 1st stage speech/music decision flag */ Word16 sp_aud_decision1; /* 1st stage speech/music classification flag */ Word16 sp_aud_decision2; /* 2nd stage speech/music classification flag */ @@ -1539,9 +1495,6 @@ typedef struct enc_core_structure HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc; /* main analysis filter bank handle */ HANDLE_CLDFB_FILTER_BANK cldfbSynTd; /* synthesis filterbank - used for HB signal generation */ - // HANDLE_CLDFB_FILTER_BANK cldfbAna_Fx; - - // HANDLE_CLDFB_FILTER_BANK cldfbSyn_Fx; /*----------------------------------------------------------------------------------* * FD CNG handle @@ -1572,7 +1525,6 @@ typedef struct enc_core_structure HQ_ENC_HANDLE hHQ_core; /* HQ core encoder handle */ - PVQ_ENC_HANDLE hPVQ; /*----------------------------------------------------------------------------------* * TD BWE parameters *----------------------------------------------------------------------------------*/ @@ -1671,13 +1623,11 @@ typedef struct enc_core_structure Word16 inv_gamma; /* Q14 */ TRAN_DET_HANDLE hTranDet; - TransientDetection transientDetection; - Word16 transient_info[3]; + Word16 acelpFramesCount; Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E Q7 in EVS */ /* Q4 in IVAS */ Word32 prevTempFlatness_32fx; /* Q21 in IVAS */ - // float currEnergyLookAhead; Word32 currEnergyLookAhead_fx; // Q31 Word32 prevEnergyHF_fx; Word32 currEnergyHF_fx; @@ -1696,7 +1646,6 @@ typedef struct enc_core_structure Word16 encoderLookahead_FB; /* pitch_ol for adaptive lag window */ - Word16 old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ @@ -1773,8 +1722,7 @@ typedef struct enc_core_structure * IVAS parameters *---------------------------------------------------------------*/ - Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ - Word16 cna_dirac_flag; /* CNA in DirAC flag */ + Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ /* stereo switching memories */ Word16 mem_preemph_DFT_fx; /* Q(-1) */ @@ -1790,16 +1738,13 @@ typedef struct enc_core_structure Word16 dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ + Word16 sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ + /*----------------------------------------------------------------------------------* * Fixed point only variables *----------------------------------------------------------------------------------*/ - Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ - Word16 Q_exc; - - Word16 prev_Q_bwe_exc; - Word16 prev_Q_bwe_syn; Word16 Q_stat_noise_ge; Word16 Q_stat_noise; Word16 Q_syn2; @@ -1813,13 +1758,8 @@ typedef struct enc_core_structure Word16 prev_Q_new; Word16 prev_Q_shb; Word16 Q_max_enc[2]; - Word16 EnergyLT_fx_exp; - Word16 prev_lsp_wb_fx[LPC_SHB_ORDER_WB]; - Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; - Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; - - Word16 sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ + Word16 last_enerBuffer_exp; } Encoder_State, *ENC_CORE_HANDLE; diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 490d80aae..cd38203e9 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -417,12 +417,12 @@ void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf ) * * Initialize SWB buffers *-------------------------------------------------------------------*/ + void InitSWBencBuffer_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) { Word16 i; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; set16_fx( hBWE_TD->old_bwe_exc_fx, 0, ( PIT16k_MAX * 2 ) ); hBWE_TD->bwe_seed[0] = 23; @@ -446,15 +446,8 @@ void InitSWBencBuffer_fx( set16_fx( hBWE_TD->old_input_fhb_fx, 0, NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2 ); // IVAS_CODE - // set_f(hBWE_TD->mem_shb_res, 0.0f, MAX_LEN_MA_FILTER); - // set_f(hBWE_TD->old_EnvSHBres, 0.0f, L_FRAME4k); - // hBWE_TD->old_mean_EnvSHBres = 0.0f; - // hBWE_TD->prev_enr_EnvSHBres = 1.0f; - // hBWE_TD->prev_shb_env_tilt = 0.0f; - // hBWE_TD->prev_pow_exc16kWhtnd = 1.0f; - // hBWE_TD->prev_mix_factor = 1.0f; - // hBWE_TD->prev_Env_error = 0.0f; - set16_fx( hBWE_TD->prev_lsp_shb_fx, 0, 10 ); + // InitSWBencBufferStates_fx(hBWE_TD, NULL ); + set16_fx( hBWE_TD->prev_lsp_shb_fx, 0, LPC_SHB_ORDER ); hBWE_TD->cldfbHBLT = 8192 /*1.0f Q13*/; move16(); @@ -504,25 +497,29 @@ void InitSWBencBuffer_fx( hBWE_TD->prev_fb_energy_fx_Q = 0; move16(); - - // TV2TV IVAS_CODE -> To be verify if it has to be moved to hBWE_TD - st_fx->prev_Q_bwe_exc = 31; + hBWE_TD->prev_Q_bwe_exc = 31; move16(); - st_fx->prev_Q_bwe_syn = 31; + hBWE_TD->prev_Q_bwe_syn = 31; move16(); - set16_fx( st_fx->prev_lsp_wb_fx, 0, 6 ); - set16_fx( st_fx->prev_lsp_wb_temp_fx, 0, 6 ); - set16_fx( st_fx->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); + set16_fx( hBWE_TD->prev_lsp_wb_fx, 0, 6 ); + set16_fx( hBWE_TD->prev_lsp_wb_temp_fx, 0, 6 ); + set16_fx( hBWE_TD->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); return; } + +/*-------------------------------------------------------------------* + * InitSWBencBufferStates() + * + * Initialize SWB buffer states + *-------------------------------------------------------------------*/ + void InitSWBencBuffer_ivas_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) { Word16 i; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; set16_fx( hBWE_TD->old_bwe_exc_fx, 0, ( PIT16k_MAX * 2 ) ); hBWE_TD->bwe_seed[0] = 23; @@ -599,33 +596,30 @@ void InitSWBencBuffer_ivas_fx( set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, 12 ); set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 ); - hBWE_TD->prev_fb_energy_fx_Q = 0; move16(); - - // TV2TV IVAS_CODE -> To be verify if it has to be moved to hBWE_TD - st_fx->prev_Q_bwe_exc = 15; + hBWE_TD->prev_Q_bwe_exc = 15; move16(); - st_fx->prev_Q_bwe_syn = 15; + hBWE_TD->prev_Q_bwe_syn = 15; move16(); - set16_fx( st_fx->prev_lsp_wb_fx, 0, 6 ); - set16_fx( st_fx->prev_lsp_wb_temp_fx, 0, 6 ); - set16_fx( st_fx->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); + set16_fx( hBWE_TD->prev_lsp_wb_fx, 0, 6 ); + set16_fx( hBWE_TD->prev_lsp_wb_temp_fx, 0, 6 ); + set16_fx( hBWE_TD->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB ); return; } + /*-------------------------------------------------------------------* * ResetSHBbuffer_Enc() * *-------------------------------------------------------------------*/ + void ResetSHBbuffer_Enc_fx( - Encoder_State *st_fx /* i/o: SHB encoder structure */ + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ ) { - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - /* states for the filters used in generating SHB excitation from WB excitation*/ set16_fx( hBWE_TD->mem_genSHBexc_filt_down_shb_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); set32_fx( hBWE_TD->mem_csfilt_fx, 0, 2 ); @@ -656,7 +650,6 @@ void ResetSHBbuffer_Enc_fx( hBWE_TD->tbe_premph_fx = 0; move16(); - return; } @@ -804,11 +797,11 @@ void wb_tbe_enc_fx( move32(); } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, st_fx->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lsp_wb_temp_fx[i] = lsp_wb_temp_fx[i]; + hBWE_TD->prev_lsp_wb_temp_fx[i] = lsp_wb_temp_fx[i]; move16(); } @@ -857,11 +850,11 @@ void wb_tbe_enc_fx( lpc_wb_32_fx[i] = L_negate( L_shr( L_deposit_h( lpc_wb[i] ), 1 ) ); move32(); /*Q27 */ } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, st_fx->prev_lsp_wb_fx, LPC_SHB_ORDER_LBR_WB ); + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, hBWE_TD->prev_lsp_wb_fx, LPC_SHB_ORDER_LBR_WB ); FOR( i = 0; i < LPC_SHB_ORDER_LBR_WB; i++ ) { - st_fx->prev_lsp_wb_fx[i] = lsp_wb[i]; + hBWE_TD->prev_lsp_wb_fx[i] = lsp_wb[i]; move16(); } @@ -881,12 +874,12 @@ void wb_tbe_enc_fx( Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + i * LPC_SHB_ORDER_LBR_WB, lsp_wb, LPC_SHB_ORDER_LBR_WB ); - lsp2lpc_fx( &lpc_wb[1], lsp_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB ); + lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB ); set16_fx( lpc_wb + LPC_SHB_ORDER_LBR_WB + 1, 0, ( LPC_SHB_ORDER_WB - LPC_SHB_ORDER_LBR_WB ) ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; + hBWE_TD->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; move16(); } @@ -917,12 +910,11 @@ void wb_tbe_enc_fx( move32(); /*Q27 */ } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, st_fx->prev_lsp_wb_fx, LPC_SHB_ORDER_WB ); - + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, hBWE_TD->prev_lsp_wb_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lsp_wb_fx[i] = lsp_wb[i]; + hBWE_TD->prev_lsp_wb_fx[i] = lsp_wb[i]; move16(); } @@ -942,12 +934,11 @@ void wb_tbe_enc_fx( } Copy( wb_bwe_lsfvq_cbook_8bit_fx + i * LPC_SHB_ORDER_WB, lsp_wb, LPC_SHB_ORDER_WB ); - lsp2lpc_fx( &lpc_wb[1], lsp_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); - + lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; + hBWE_TD->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; move16(); } FOR( i = 1; i < LPC_SHB_ORDER_WB + 1; i++ ) @@ -1000,9 +991,9 @@ void wb_tbe_enc_fx( find_max_mem_wb_enc( st_fx, &n_mem ); - IF( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) ) + IF( GT_16( sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ), n_mem ) ) { - Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem ); + Q_bwe_exc = add( hBWE_TD->prev_Q_bwe_exc, n_mem ); } IF( uv_flag ) @@ -1018,7 +1009,7 @@ void wb_tbe_enc_fx( move32(); IF( st_fx->element_mode > EVS_MONO ) { - tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); + tmp = sub( shl( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ } FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) @@ -1026,7 +1017,7 @@ void wb_tbe_enc_fx( prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /* Q(2*st_fx->prev_Q_bwe_exc) */ } - rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); + rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ) ); Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET ); sc = sub( Q_bwe_exc, add( Q_new, Q_new ) ); @@ -1037,11 +1028,9 @@ void wb_tbe_enc_fx( } Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET ); - Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 ); Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); - GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, @@ -1064,8 +1053,7 @@ void wb_tbe_enc_fx( curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */ } - Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp ); - + Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ), &exp ); FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { @@ -1146,7 +1134,6 @@ void wb_tbe_enc_fx( move16(); /* Q15 */ } - temp_wb_fac_fx = hBWE_TD->prev_wb_GainShape; move16(); FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) @@ -1185,7 +1172,6 @@ void wb_tbe_enc_fx( EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape, &GainFrame, window_wb_fx, subwin_wb_fx, 0 ); - /* If there's a big difference in the power of gains away from the peak gain */ /* due to poor quantization then suppress energy of the high band. */ @@ -1239,7 +1225,6 @@ void wb_tbe_enc_fx( /*wbbwe_em_factor = add( mult_r( 29491, st_fx->prev_wbbwe_em_factor_fx ), mult_r( 3277, wbbwe_em_factor ) ); */ /* Q15 */ } - /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ L_tmp = L_mult( voice_factors[0], 8192 ); FOR( i = 1; i < NB_SUBFR; i++ ) @@ -1271,7 +1256,7 @@ void wb_tbe_enc_fx( ScaleShapedSHB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame, window_wb_fx, subwin_wb_fx, &Q_bwe_exc_ext, &dummy, dummy, dummy ); - st_fx->prev_Q_bwe_exc = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); return; @@ -1416,11 +1401,11 @@ void wb_tbe_enc_ivas_fx( move32(); } - lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, st_fx->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); + lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lsp_wb_temp_fx[i] = lsp_wb_temp_fx[i]; + hBWE_TD->prev_lsp_wb_temp_fx[i] = lsp_wb_temp_fx[i]; move16(); } @@ -1469,11 +1454,11 @@ void wb_tbe_enc_ivas_fx( lpc_wb_32_fx[i] = L_negate( L_shr( L_deposit_h( lpc_wb[i] ), 1 ) ); move32(); /*Q27 */ } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, st_fx->prev_lsp_wb_fx, LPC_SHB_ORDER_LBR_WB ); + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, hBWE_TD->prev_lsp_wb_fx, LPC_SHB_ORDER_LBR_WB ); FOR( i = 0; i < LPC_SHB_ORDER_LBR_WB; i++ ) { - st_fx->prev_lsp_wb_fx[i] = lsp_wb[i]; + hBWE_TD->prev_lsp_wb_fx[i] = lsp_wb[i]; move16(); } @@ -1493,12 +1478,12 @@ void wb_tbe_enc_ivas_fx( Copy( lbr_wb_bwe_lsfvq_cbook_2bit_fx + i * LPC_SHB_ORDER_LBR_WB, lsp_wb, LPC_SHB_ORDER_LBR_WB ); - lsp2lpc_fx( &lpc_wb[1], lsp_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB ); + lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_LBR_WB ); set16_fx( lpc_wb + LPC_SHB_ORDER_LBR_WB + 1, 0, ( LPC_SHB_ORDER_WB - LPC_SHB_ORDER_LBR_WB ) ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; + hBWE_TD->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; move16(); } @@ -1529,12 +1514,11 @@ void wb_tbe_enc_ivas_fx( move32(); /*Q27 */ } - lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, st_fx->prev_lsp_wb_fx, LPC_SHB_ORDER_WB ); - + lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb, hBWE_TD->prev_lsp_wb_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lsp_wb_fx[i] = lsp_wb[i]; + hBWE_TD->prev_lsp_wb_fx[i] = lsp_wb[i]; move16(); } @@ -1546,11 +1530,11 @@ void wb_tbe_enc_ivas_fx( push_indice( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_WB_LSF ); Copy( wb_bwe_lsfvq_cbook_8bit_fx + i * LPC_SHB_ORDER_WB, lsp_wb, LPC_SHB_ORDER_WB ); - lsp2lpc_fx( &lpc_wb[1], lsp_wb, st_fx->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); + lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_WB ); FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) { - st_fx->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; + hBWE_TD->prev_lpc_wb_fx[i] = lpc_wb[i + 1]; move16(); } FOR( i = 1; i < LPC_SHB_ORDER_WB + 1; i++ ) @@ -1605,9 +1589,9 @@ void wb_tbe_enc_ivas_fx( find_max_mem_wb_enc( st_fx, &n_mem ); - IF( GT_16( sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ), n_mem ) ) + IF( GT_16( sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ), n_mem ) ) { - Q_bwe_exc = add( st_fx->prev_Q_bwe_exc, n_mem ); + Q_bwe_exc = add( hBWE_TD->prev_Q_bwe_exc, n_mem ); } IF( uv_flag ) @@ -1632,7 +1616,7 @@ void wb_tbe_enc_ivas_fx( shaped_wb_exc_scale[i] = shr( hBWE_TD->state_syn_shbexc_fx[i], 3 ); move16(); } - Q_prev_pow = shl_r( sub( sub( st_fx->prev_Q_bwe_exc, 16 ), 3 ), 1 ); + Q_prev_pow = shl_r( sub( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 3 ), 1 ); move16(); } ELSE @@ -1642,7 +1626,7 @@ void wb_tbe_enc_ivas_fx( shaped_wb_exc_scale[i] = hBWE_TD->state_syn_shbexc_fx[i]; move16(); } - Q_prev_pow = shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ); + Q_prev_pow = shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ); move16(); } @@ -1656,7 +1640,7 @@ void wb_tbe_enc_ivas_fx( prev_pow = L_mac0( prev_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q_prev_pow */ } - rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) ); + rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ) ); sc = sub( Q_bwe_exc, add( Q_new, Q_new ) ); FOR( i = 0; i < L_FRAME32k; i++ ) @@ -1795,7 +1779,6 @@ void wb_tbe_enc_ivas_fx( move16(); /* Q15 */ } - temp_wb_fac_fx = hBWE_TD->prev_wb_GainShape; move16(); FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) @@ -1930,7 +1913,6 @@ void wb_tbe_enc_ivas_fx( /* Adjust the subframe and frame gain of the synthesized SHB signal */ /* Scale the shaped excitation*/ - scale_sig( shaped_wb_excitation, ( L_FRAME16k + L_SHB_LAHEAD ) / 4, -1 ); scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, -1 ); Q_bwe_exc_ext = sub( Q_bwe_exc_ext, 1 ); @@ -1938,7 +1920,7 @@ void wb_tbe_enc_ivas_fx( &Q_bwe_exc_ext, &dummy, dummy, dummy ); Scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, 1 ); - st_fx->prev_Q_bwe_exc = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); return; @@ -2437,7 +2419,7 @@ void swb_tbe_enc_fx( /* Account for any outliers in the memories from previous frame for rescaling to avoid saturation */ find_max_mem_enc( st_fx, &n_mem, &n_mem2 ); - tmp2 = add( st_fx->prev_Q_bwe_exc, n_mem ); + tmp2 = add( hBWE_TD->prev_Q_bwe_exc, n_mem ); if ( GT_16( Q_bwe_exc, tmp2 ) ) { Q_bwe_exc = tmp2; @@ -2445,7 +2427,7 @@ void swb_tbe_enc_fx( } /* rescale the memories if Q_bwe_exc is different from previous frame */ - sc = sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ); + sc = sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ); IF( sc != 0 ) { rescale_genSHB_mem_enc( st_fx, sc ); @@ -2466,7 +2448,7 @@ void swb_tbe_enc_fx( Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); /* save the previous Q factor of the buffer */ - st_fx->prev_Q_bwe_exc = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ @@ -2487,7 +2469,7 @@ void swb_tbe_enc_fx( coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, - &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0 ); + &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st_fx->total_brate, 0 ); *Q_white_exc = Q_bwe_exc_fb; move16(); @@ -2520,7 +2502,7 @@ void swb_tbe_enc_fx( FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { - hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st_fx->prev_Q_bwe_syn ) ); + hBWE_TD->mem_stp_swb_fx[i] = shl( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_syn ) ); move16(); } @@ -2528,12 +2510,9 @@ void swb_tbe_enc_fx( { PostShortTerm_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); - /* i: shaped_shb_excitation_fx in Q_bwe_exc */ - /* i: lpc_shb_fx in Q12 */ } Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); - tmp = sub( shl( Q_bwe_exc, 1 ), 31 ); prev_pow_fx = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 2*(Q_bwe_exc) */ curr_pow_fx = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 2*(Q_bwe_exc) */ @@ -2909,7 +2888,7 @@ void swb_tbe_enc_fx( } /* *Q_white_exc = Q_bwe_exc_mod; move16(); output Qwhiteexc_FB from the GenShapedSHB function*/ - st_fx->prev_Q_bwe_syn = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_syn = Q_bwe_exc; move16(); return; @@ -3744,7 +3723,7 @@ void swb_tbe_enc_ivas_fx( /* Account for any outliers in the memories from previous frame for rescaling to avoid saturation */ find_max_mem_enc( st_fx, &n_mem, &n_mem2 ); - tmp2 = add( st_fx->prev_Q_bwe_exc, n_mem ); + tmp2 = add( hBWE_TD->prev_Q_bwe_exc, n_mem ); if ( GT_16( Q_bwe_exc, tmp2 ) ) { Q_bwe_exc = tmp2; @@ -3752,7 +3731,7 @@ void swb_tbe_enc_ivas_fx( } /* rescale the memories if Q_bwe_exc is different from previous frame */ - sc = sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ); + sc = sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ); IF( sc != 0 ) { rescale_genSHB_mem_enc( st_fx, sc ); @@ -3770,7 +3749,7 @@ void swb_tbe_enc_ivas_fx( Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); /* save the previous Q factor of the buffer */ - st_fx->prev_Q_bwe_exc = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc; move16(); Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ @@ -3783,7 +3762,7 @@ void swb_tbe_enc_ivas_fx( hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, - &Q_bwe_exc_fb, Q_shb, n_mem2, st_fx->prev_Q_bwe_syn, st_fx->total_brate, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, + &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st_fx->total_brate, 0, st_fx->element_mode, st_fx->flag_ACELP16k, nlExc16k_fx, nlExc16k_e, mixExc16k_fx, mixExc16k_e, st_fx->extl_brate, MSFlag, EnvSHBres_4k_norm_fx, Q_EnvSHBres_4k_norm, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), &Env_error_fx, Env_error_part_fx ); @@ -3835,7 +3814,7 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { - hBWE_TD->mem_stp_swb_fx[i] = shl_sat( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st_fx->prev_Q_bwe_syn ) ); + hBWE_TD->mem_stp_swb_fx[i] = shl_sat( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_syn ) ); move16(); } @@ -4184,7 +4163,6 @@ void swb_tbe_enc_ivas_fx( } } - hBWE_TD->prev_swb_GainShape_fx = GainShape_fx[3]; move16(); @@ -4200,7 +4178,6 @@ void swb_tbe_enc_ivas_fx( /* Quantization of the gain shape parameter */ QuantizeSHBsubgains_ivas_fx( st_fx, GainShape_fx, st_fx->extl ); - /* o: GainShape_fx in Q15 */ /* Compute the power of gains away from the peak gain after quantization */ IF( st_fx->element_mode > EVS_MONO ) @@ -4568,7 +4545,7 @@ void swb_tbe_enc_ivas_fx( move16(); /* *Q_white_exc = Q_bwe_exc_mod; move16(); output Qwhiteexc_FB from the GenShapedSHB function*/ - st_fx->prev_Q_bwe_syn = Q_bwe_exc; + hBWE_TD->prev_Q_bwe_syn = Q_bwe_exc; move16(); return; @@ -7051,7 +7028,7 @@ static void first_VQstages_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ @@ -7902,22 +7879,23 @@ void tbe_write_bitstream_fx( { push_next_indice( hBstr, hBWE_TD->idxGain, 4 ); } + + return; } void TBEreset_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 bandwidth /* i : bandwidth mode */ + TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const int16_t last_core, /* i : last core */ + Word16 bandwidth /* i : bandwidth mode */ ) { - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - - IF( NE_16( st_fx->last_core, ACELP_CORE ) ) + IF( NE_16( last_core, ACELP_CORE ) ) { set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); move32(); - st_fx->prev_Q_bwe_exc = 31; + hBWE_TD->prev_Q_bwe_exc = 31; move16(); } @@ -7947,6 +7925,8 @@ void TBEreset_enc_fx( fb_tbe_reset_enc_fx( hBWE_TD->elliptic_bpf_2_48k_mem_fx, &hBWE_TD->prev_fb_energy_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &hBWE_TD->prev_fb_energy_fx_Q ); } } + + return; } /*-------------------------------------------------------------------* diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index a3d8620a4..48067948b 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -606,34 +606,35 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec move16(); } -void tcx_ltp_encode_fx( Word16 tcxltp_on, - Word8 tcxOnly, - Word16 tcxMode, - Word16 L_frame, - Word16 L_subfr, - Word16 *speech, - Word16 *speech_ltp, - Word16 *wsp, - Word16 Top, - Word16 *ltp_param, - Word16 *ltp_bits, - Word16 *pitch_int, - Word16 *pitch_fr, - Word16 *gain, - Word16 *pitch_int_past, - Word16 *pitch_fr_past, - Word16 *gain_past, - Word16 *norm_corr_past, - Word16 last_core, - Word16 pitmin, - Word16 pitfr1, - Word16 pitfr2, - Word16 pitmax, - Word16 pitres, - struct TransientDetection const *pTransientDetection, - Word8 SideInfoOnly, - Word16 *A, - Word16 lpcorder ) +void tcx_ltp_encode_fx( + Word16 tcxltp_on, + Word8 tcxOnly, + Word16 tcxMode, + Word16 L_frame, + Word16 L_subfr, + Word16 *speech, + Word16 *speech_ltp, + Word16 *wsp, + Word16 Top, + Word16 *ltp_param, + Word16 *ltp_bits, + Word16 *pitch_int, + Word16 *pitch_fr, + Word16 *gain, + Word16 *pitch_int_past, + Word16 *pitch_fr_past, + Word16 *gain_past, + Word16 *norm_corr_past, + Word16 last_core, + Word16 pitmin, + Word16 pitfr1, + Word16 pitfr2, + Word16 pitmax, + Word16 pitres, + TRAN_DET_HANDLE hTranDet, + Word8 SideInfoOnly, + Word16 *A, + Word16 lpcorder ) { Word16 n; Word16 norm_corr; @@ -687,11 +688,9 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, nPrevSubblocks = extract_h( L_mac( 0x17fff, NSUBBLOCKS, div_s( *pitch_int, L_frame ) ) ); nPrevSubblocks = add( s_min( nPrevSubblocks, NSUBBLOCKS ), 1 ); - tempFlatness = GetTCXAvgTemporalFlatnessMeasure_fx( pTransientDetection, NSUBBLOCKS, nPrevSubblocks ); + tempFlatness = GetTCXAvgTemporalFlatnessMeasure_fx( hTranDet, NSUBBLOCKS, nPrevSubblocks ); - maxEnergyChange = GetTCXMaxenergyChange_fx( pTransientDetection, - (const Word8) isTCX10, - NSUBBLOCKS, nPrevSubblocks ); + maxEnergyChange = GetTCXMaxenergyChange_fx( hTranDet, (const Word8) isTCX10, NSUBBLOCKS, nPrevSubblocks ); /* Switch LTP on */ test(); @@ -1059,15 +1058,13 @@ void tcx_ltp_encode_ivas_fx( IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { - tempFlatness_fx = extract_l( L_shr( GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS - NSUBBLOCKS_SHIFT, add( nPrevSubblocks, NSUBBLOCKS_SHIFT ) ), 14 ) ); // Q7 - maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( st->hTranDet, (const Word8) isTCX10, - NSUBBLOCKS - NSUBBLOCKS_SHIFT, add( nPrevSubblocks, NSUBBLOCKS_SHIFT ) ); // Q3 + tempFlatness_fx = extract_l( L_shr( GetTCXAvgTemporalFlatnessMeasure_ivas_fx( st->hTranDet, NSUBBLOCKS - NSUBBLOCKS_SHIFT, add( nPrevSubblocks, NSUBBLOCKS_SHIFT ) ), 14 ) ); // Q7 + maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( st->hTranDet, (const Word8) isTCX10, NSUBBLOCKS - NSUBBLOCKS_SHIFT, add( nPrevSubblocks, NSUBBLOCKS_SHIFT ) ); // Q3 } ELSE { - tempFlatness_fx = extract_l( L_shr( ( GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, nPrevSubblocks ) ), 14 ) ); // Q7 - maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( st->hTranDet, (const Word8) isTCX10, - NSUBBLOCKS, nPrevSubblocks ); // Q3 + tempFlatness_fx = extract_l( L_shr( ( GetTCXAvgTemporalFlatnessMeasure_ivas_fx( st->hTranDet, NSUBBLOCKS, nPrevSubblocks ) ), 14 ) ); // Q7 + maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( st->hTranDet, (const Word8) isTCX10, NSUBBLOCKS, nPrevSubblocks ); // Q3 } /* Switch LTP on */ diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 1ad69a330..e0fff2da5 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -333,52 +333,68 @@ static void InitTCXTransientDetector( Word16 nDelay, SubblockEnergies *pSubblock /* */ /************************************************/ -void InitTransientDetection_fx( Word16 nFrameLength, - Word16 nTCXDelay, - TransientDetection *pTransientDetection ) +void InitTransientDetection_fx( + const Word16 nFrameLength, + const Word16 nTCXDelay, + TRAN_DET_HANDLE hTranDet ) { /* Init the delay buffer. */ - InitDelayBuffer( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer ); + InitDelayBuffer( nFrameLength, nTCXDelay, &hTranDet->delayBuffer ); + /* Init a subblock energies buffer used for the TCX Short/Long decision. */ - InitSubblockEnergies( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); + InitSubblockEnergies( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies ); + /* Init the TCX Short/Long transient detector. */ - InitTCXTransientDetector( nTCXDelay, &pTransientDetection->subblockEnergies, &pTransientDetection->transientDetector ); + InitTCXTransientDetector( nTCXDelay, &hTranDet->subblockEnergies, &hTranDet->transientDetector ); + /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ - pTransientDetection->transientDetector.pSubblockEnergies->nDelay = - add( pTransientDetection->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); + hTranDet->transientDetector.pSubblockEnergies->nDelay = + add( hTranDet->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); + + return; } -void InitTransientDetection_ivas_fx( Word16 nFrameLength, - Word16 nTCXDelay, - TRAN_DET_HANDLE pTransientDetection, - const Word16 ext_mem_flag ) + +void InitTransientDetection_ivas_fx( + const Word16 nFrameLength, + const Word16 nTCXDelay, + TRAN_DET_HANDLE hTranDet, + const Word16 ext_mem_flag ) { /* Init the delay buffer. */ - InitDelayBuffer( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer ); + InitDelayBuffer( nFrameLength, nTCXDelay, &hTranDet->delayBuffer ); + /* Init a subblock energies buffer used for the TCX Short/Long decision. */ - InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); + InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &hTranDet->delayBuffer, &hTranDet->subblockEnergies ); + /* Init the TCX Short/Long transient detector. */ - InitTransientDetector_ivas_fx( &pTransientDetection->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<transientDetector ); + InitTransientDetector_ivas_fx( &hTranDet->subblockEnergies, nTCXDelay, NSUBBLOCKS, GetAttackForTCXDecision_ivas_fx, 17408 /*8.5f/(1<transientDetector ); + /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ IF( ext_mem_flag ) { - pTransientDetection->transientDetector.pSubblockEnergies->nDelay = - add( pTransientDetection->transientDetector.pSubblockEnergies->nDelay, add( ( NSUBBLOCKS + 1 ), ( NSUBBLOCKS_SHIFT + 1 ) ) ); + hTranDet->transientDetector.pSubblockEnergies->nDelay = + add( hTranDet->transientDetector.pSubblockEnergies->nDelay, add( ( NSUBBLOCKS + 1 ), ( NSUBBLOCKS_SHIFT + 1 ) ) ); move16(); } ELSE { - pTransientDetection->transientDetector.pSubblockEnergies->nDelay = - add( pTransientDetection->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); + hTranDet->transientDetector.pSubblockEnergies->nDelay = + add( hTranDet->transientDetector.pSubblockEnergies->nDelay, NSUBBLOCKS + 1 ); move16(); } + + return; } /** * \brief Calculate average of temporal energy change. * \return average temporal energy change with exponent = 8 */ -Word16 GetTCXAvgTemporalFlatnessMeasure_fx( struct TransientDetection const *pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks ) +Word16 GetTCXAvgTemporalFlatnessMeasure_fx( + TRAN_DET_HANDLE hTranDet, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ) { Word16 i; TransientDetector const *pTransientDetector; @@ -389,9 +405,8 @@ Word16 GetTCXAvgTemporalFlatnessMeasure_fx( struct TransientDetection const *pTr Word32 sumTempFlatness; Word16 nTotBlocks; - /* Initialization */ - pTransientDetector = &pTransientDetection->transientDetector; + pTransientDetector = &hTranDet->transientDetector; pSubblockEnergies = pTransientDetector->pSubblockEnergies; move16(); nDelay = pTransientDetector->nDelay; @@ -419,7 +434,11 @@ Word16 GetTCXAvgTemporalFlatnessMeasure_fx( struct TransientDetection const *pTr return i; } -Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const *pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks ) + +Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ) { Word32 i; TransientDetector const *pTransientDetector; @@ -432,7 +451,7 @@ Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const Word16 nTotBlocks, sumTempFlatness_exp, exp; /* Initialization */ - pTransientDetector = &pTransientDetection->transientDetector; + pTransientDetector = &hTranDet->transientDetector; pSubblockEnergies = pTransientDetector->pSubblockEnergies; nDelay = pTransientDetector->nDelay; move16(); @@ -464,10 +483,11 @@ Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const return i; } -Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDetection, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ) +Word16 GetTCXMaxenergyChange_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ) { Word16 i; TransientDetector const *pTransientDetector; @@ -478,8 +498,7 @@ Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDete Word16 maxEnergyChange; Word16 nTotBlocks; - - pTransientDetector = &pTransientDetection->transientDetector; + pTransientDetector = &hTranDet->transientDetector; pSubblockEnergies = pTransientDetector->pSubblockEnergies; move16(); nDelay = pTransientDetector->nDelay; @@ -543,10 +562,11 @@ Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDete } -Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ) +Word16 GetTCXMaxenergyChange_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ) { Word16 i; TransientDetector const *pTransientDetector; @@ -558,7 +578,6 @@ Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, Word16 maxEnergyChange; Word16 nTotBlocks; - pTransientDetector = &hTranDet->transientDetector; pSubblockEnergies = pTransientDetector->pSubblockEnergies; move16(); @@ -620,13 +639,17 @@ Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, return i; } -void RunTransientDetection_fx( Word16 const *input, Word16 nSamplesAvailable, TransientDetection *pTransientDetection ) + +void RunTransientDetection_fx( + Word16 const *input, + const Word16 nSamplesAvailable, + TRAN_DET_HANDLE hTranDet ) { Word16 filteredInput[L_FRAME48k]; - SubblockEnergies *pSubblockEnergies = &pTransientDetection->subblockEnergies; - TransientDetector *pTransientDetector = &pTransientDetection->transientDetector; + SubblockEnergies *pSubblockEnergies = &hTranDet->subblockEnergies; + TransientDetector *pTransientDetector = &hTranDet->transientDetector; - assert( ( input != NULL ) && ( pTransientDetection != NULL ) && ( pSubblockEnergies != NULL ) && ( pTransientDetector != NULL ) ); + assert( ( input != NULL ) && ( hTranDet != NULL ) && ( pSubblockEnergies != NULL ) && ( pTransientDetector != NULL ) ); HighPassFilter_fx( input, nSamplesAvailable, &pSubblockEnergies->firState1, &pSubblockEnergies->firState2, filteredInput ); @@ -637,7 +660,9 @@ void RunTransientDetection_fx( Word16 const *input, Word16 nSamplesAvailable, Tr RunTransientDetector_fx( pTransientDetector ); /* Update the delay buffer. */ - UpdateDelayBuffer( filteredInput, nSamplesAvailable, &pTransientDetection->delayBuffer ); + UpdateDelayBuffer( filteredInput, nSamplesAvailable, &hTranDet->delayBuffer ); + + return; } @@ -865,7 +890,7 @@ void SetTCXModeInfo_ivas_fx( move16(); } } - tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q21, GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) hTranDet, NSUBBLOCKS, 0 ), &exp_diff ); + tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q21, GetTCXAvgTemporalFlatnessMeasure_ivas_fx( hTranDet, NSUBBLOCKS, 0 ), &exp_diff ); tmp = shl_sat( tmp, exp_diff ); // Q15 test(); IF( isLongTermTransient_fx( L_deposit_h( tmp ), &hTcxEnc->tfm_mem_fx ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -895,7 +920,7 @@ void SetTCXModeInfo_ivas_fx( *tcxModeOverlap = ALDO_WINDOW; move16(); } - tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q21, GetTCXAvgTemporalFlatnessMeasure_ivas_fx( (const TransientDetection *) hTranDet, NSUBBLOCKS, 0 ), &exp_diff ); + tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q21, GetTCXAvgTemporalFlatnessMeasure_ivas_fx( hTranDet, NSUBBLOCKS, 0 ), &exp_diff ); tmp = shl_sat( tmp, exp_diff ); // Q15 test(); IF( isLongTermTransient_fx( L_deposit_h( tmp ), &hTcxEnc->tfm_mem_fx ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -933,13 +958,14 @@ void SetTCXModeInfo_ivas_fx( } -void SetTCXModeInfo_fx( Encoder_State *st, - TransientDetection const *pTransientDetection, - Word16 *tcxModeOverlap ) +void SetTCXModeInfo_fx( + Encoder_State *st, + TRAN_DET_HANDLE hTranDet, + Word16 *tcxModeOverlap ) { TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - assert( pTransientDetection != NULL ); + assert( hTranDet != NULL ); IF( EQ_16( st->codec_mode, MODE2 ) ) { @@ -953,7 +979,7 @@ void SetTCXModeInfo_fx( Encoder_State *st, test(); test(); test(); - IF( ( ( pTransientDetection->transientDetector.bIsAttackPresent != 0 ) || ( GT_32( Mpy_32_16_1( st->currEnergyHF_fx, 840 /*1.0f/39.0f Q15*/ ), st->prevEnergyHF_fx ) ) ) && ( ( NE_16( st->last_core, ACELP_CORE ) ) && ( NE_16( st->last_core, AMR_WB_CORE ) ) ) ) + IF( ( ( hTranDet->transientDetector.bIsAttackPresent != 0 ) || ( GT_32( Mpy_32_16_1( st->currEnergyHF_fx, 840 /*1.0f/39.0f Q15*/ ), st->prevEnergyHF_fx ) ) ) && ( ( NE_16( st->last_core, ACELP_CORE ) ) && ( NE_16( st->last_core, AMR_WB_CORE ) ) ) ) { move16(); hTcxEnc->tcxMode = TCX_10; @@ -1005,7 +1031,7 @@ void SetTCXModeInfo_fx( Encoder_State *st, IF( EQ_16( hTcxEnc->tcxMode, TCX_10 ) ) { - IF( pTransientDetection->transientDetector.attackIndex < 0 ) + IF( hTranDet->transientDetector.attackIndex < 0 ) { move16(); *tcxModeOverlap = HALF_OVERLAP; @@ -1013,7 +1039,7 @@ void SetTCXModeInfo_fx( Encoder_State *st, ELSE { move16(); - *tcxModeOverlap = s_and( pTransientDetection->transientDetector.attackIndex, 3 ); + *tcxModeOverlap = s_and( hTranDet->transientDetector.attackIndex, 3 ); if ( EQ_16( *tcxModeOverlap, 1 ) ) { move16(); @@ -1023,12 +1049,12 @@ void SetTCXModeInfo_fx( Encoder_State *st, } ELSE IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) { - IF( EQ_16( pTransientDetection->transientDetector.attackIndex, 7 ) ) + IF( EQ_16( hTranDet->transientDetector.attackIndex, 7 ) ) { move16(); *tcxModeOverlap = HALF_OVERLAP; } - ELSE IF( EQ_16( pTransientDetection->transientDetector.attackIndex, 6 ) ) + ELSE IF( EQ_16( hTranDet->transientDetector.attackIndex, 6 ) ) { move16(); *tcxModeOverlap = MIN_OVERLAP; -- GitLab From 683b9958baf962a5d718d9d463da2d7bb11552f3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 21 Sep 2025 22:26:11 +0200 Subject: [PATCH 011/351] clang-format --- lib_enc/pre_proc_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 08d225f98..29a0aa229 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -209,7 +209,7 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 734f09e41..927120771 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -6998,7 +6998,7 @@ static void first_VQstages_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ -- GitLab From dc58f48f0005838b3b6e5ce8403852634d0b59d5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 1 Oct 2025 23:33:58 +0200 Subject: [PATCH 012/351] number -> macro --- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/evs_enc_fx.c | 2 +- lib_enc/init_enc_fx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 7159b507d..787e5f701 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -108,7 +108,7 @@ void amr_wb_enc_fx( move16(); st->coder_type = GENERIC; move16(); - input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + input_frame = extract_l( Mpy_32_32_r( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); move16(); /* frame length of the input signal */ st->extl = -1; move16(); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 90d5a7b4b..3380583c0 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -100,7 +100,7 @@ ivas_error evs_enc_fx( * Initializiation *-----------------------------------------------------------------*/ - input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + input_frame = extract_l( Mpy_32_32_r( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); move16(); st->core = -1; move16(); diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 0439a4720..487b42bf7 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -36,7 +36,7 @@ ivas_error init_encoder_fx( error = IVAS_ERR_OK; - input_frame = extract_l( Mult_32_16( st_fx->input_Fs, 0x0290 ) ); + input_frame = extract_l( Mpy_32_32_r( st_fx->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /*-----------------------------------------------------------------* * General signal buffers @@ -1004,7 +1004,7 @@ ivas_error init_encoder_ivas_fx( error = IVAS_ERR_OK; move32(); - input_frame = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); + input_frame = extract_l( Mpy_32_32_r( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /*-----------------------------------------------------------------* * General parameters -- GitLab From 3b69eb8c5f160d97a095fef3c660d3eb77f8e1b9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 2 Oct 2025 11:01:27 +0200 Subject: [PATCH 013/351] clang-format --- lib_com/cldfb_evs_fx.c | 4 ++-- lib_rend/lib_rend_fx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/cldfb_evs_fx.c b/lib_com/cldfb_evs_fx.c index 880300896..53f9846ff 100644 --- a/lib_com/cldfb_evs_fx.c +++ b/lib_com/cldfb_evs_fx.c @@ -1003,12 +1003,12 @@ ivas_error openCldfb( IF( type == CLDFB_ANALYSIS ) { - //buf_len = sub( hs->p_filter_length, hs->no_channels ); + // buf_len = sub( hs->p_filter_length, hs->no_channels ); buf_len = STATE_BUFFER_SIZE * maxCldfbBands; } ELSE { - //buf_len = hs->p_filter_length; + // buf_len = hs->p_filter_length; buf_len = 2 * STATE_BUFFER_SIZE * maxCldfbBands; move16(); } diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index a6dd11fa5..57532acd2 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9150,7 +9150,7 @@ static ivas_error getSamplesInternal( if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const Word16) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const Word16 )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 90515804617f081675cfa1e51224b9ec4ac120a1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 2 Oct 2025 14:35:21 +0200 Subject: [PATCH 014/351] fixes --- lib_enc/core_enc_init_fx.c | 2 ++ lib_enc/init_enc_fx.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index a7ffcc229..2f669f09b 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -234,6 +234,8 @@ void init_coder_ace_plus_fx( set16_fx( st->bpf_T, PIT_MIN_12k8, NB_SUBFR16k ); + st->mem_bpf_fx.lp_error = 0; + move16(); st->mem_bpf_fx.noise_shift_old = 0; move16(); diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 81ce03c66..ea5827bf6 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1238,7 +1238,7 @@ ivas_error init_encoder_fx( st->old_wsp_shift = 0; move16(); #ifdef DEBUGGING - st_fx->id_element = -1; /* element ID */ + st->id_element = -1; /* element ID */ move16(); #endif -- GitLab From 804b662081935f7ffb0469651ff02ed25d9a7a26 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 7 Oct 2025 11:02:30 +0200 Subject: [PATCH 015/351] fix EVS SWB-BWE encoder --- lib_enc/init_enc_fx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index ea5827bf6..8e469a68e 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -882,8 +882,6 @@ ivas_error init_encoder_fx( } fd_bwe_enc_init_fx( st->hBWE_FD ); - st->Q_old_wtda = 0; - move16(); } ELSE { @@ -918,6 +916,15 @@ ivas_error init_encoder_fx( move16(); st->EnergyLT_fx = 0; move32(); + st->Q_old_wtda = 0; + move16(); + IF( st->element_mode == EVS_MONO ) + { + st->EnergyLT_fx = 1; + move32(); + st->Q_old_wtda = 15; + move16(); + } st->Energy_Old_fx = 0; move32(); st->TransientHangOver = 0; -- GitLab From 79cefa6e835e5b5f2ef173f0973a8d5b843f19b2 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Thu, 9 Oct 2025 09:27:00 +0300 Subject: [PATCH 016/351] fix 2082 --- lib_com/options.h | 1 + lib_dec/ivas_omasa_dec_fx.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1adebda25..46e88ab1b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,6 +110,7 @@ #define OPT_TCXLTP_FILTER_LOOP /* FhG: optimize loop in tcx_ltp_synth_filter */ #define FIX_2049_DIFF_IN_DECORR_TAIL /* FhG: correct scale values in ivas_dirac_dec_binaural_process_output_fx() */ #define FIX_2602_NONBE_SAT_IN_SWB_TBE_SCALE /* Dolby/FhG: fix for issue 2026: Saturation in SWB TBE re-scaling function preventing StereoDownmix complexity job to complete */ +#define FIX_2082_FP_LEFTOVERS_OMASA_DEC /* Nokia: fix for issue 2082, cleaning remaining floating point code */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 7278b9968..119fc1a0c 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -46,12 +46,18 @@ * Local constants *------------------------------------------------------------------------*/ - +#ifdef FIX_2082_FP_LEFTOVERS_OMASA_DEC +#define MULT_17_DIV_20_Q15 27853 /* (Word16) ( ( 17.0/20.0 ) * 2^15 + 0.5 ) */ +#define MULT_1_DIV_CLDFB_NO_COL_MAX_Q15 2048 /* (Word16) ( ( 1.0 / CLDFB_NO_COL_MAX ) * 2^15 + 0.5 ) */ +#define ONEMINUX_EXT_RENDER_IIR_FAC_Q31 107374182 /* (Word32) ( ( 1.0 - 0.95 ) * 2^31 + 0.5f ); 0.95 is EXT_RENDER_IIR_FAC */ +#define EXT_RENDER_IIR_FAC_Q31 2040109465 /* (Word32) ( 0.95 * 2^31 + 0.5 ) */ +#else #define EXT_RENDER_IIR_FAC 0.95f #define MULT_17_DIV_20_Q15 ( Word16 )( ( 17.0 / 20.0f ) * pow( 2, 15 ) + 0.5f ) #define MULT_1_DIV_CLDFB_NO_COL_MAX_Q15 ( Word16 )( ( 1.0 / CLDFB_NO_COL_MAX ) * pow( 2, 15 ) + 0.5f ) #define ONEMINUX_EXT_RENDER_IIR_FAC_Q31 ( Word32 )( ( 1.0f - EXT_RENDER_IIR_FAC ) * pow( 2, 31 ) + 0.5f ) #define EXT_RENDER_IIR_FAC_Q31 ( Word32 )( EXT_RENDER_IIR_FAC * pow( 2, 31 ) + 0.5f ) +#endif // Calculated as (Word16)(((1.0f / (50 * MAX_PARAM_SPATIAL_SUBFRAMES)) * pow(2, 15)) + 0.5f) #define OMASA_DELAYFRAMES_PER_SEC_Q15 (Word16) 164 // Q15 -- GitLab From 48681f8c15df4a8de94c2aaf188f9b229ed87021 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 16 Oct 2025 15:04:54 +0200 Subject: [PATCH 017/351] port 2171 from float repo to BASOP main Resolve "Delay alignment in external renderer" and "External renderer crashes when rendering OMASA" --- Workspace_msvc/lib_rend.vcxproj | 3 +- apps/renderer.c | 114 ++-- lib_isar/lib_isar_post_rend.c | 6 +- lib_isar/lib_isar_pre_rend.c | 5 +- lib_rend/ivas_prot_rend_fx.h | 35 + lib_rend/ivas_stat_rend.h | 16 + lib_rend/lib_rend.h | 9 +- lib_rend/lib_rend_fx.c | 1128 ++++++++++++++++++++----------- 8 files changed, 841 insertions(+), 475 deletions(-) diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index c39806d47..5f78402ec 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -175,6 +175,7 @@ + @@ -209,4 +210,4 @@ - \ No newline at end of file + diff --git a/apps/renderer.c b/apps/renderer.c index adf664f97..2d7ba3c8d 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -31,6 +31,7 @@ *******************************************************************************************************/ #include "lib_rend.h" +#include "typedef.h" #include #include #include @@ -797,6 +798,7 @@ int main( SplitFileReadWrite *hSplitRendFileReadWrite; int16_t delayNumSamples_temp; int32_t delayTimeScale_temp; + bool flushRendererLastFrame = false; int16_t numSamplesRead; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig = 0; @@ -842,8 +844,11 @@ int main( CmdlnArgs args = parseCmdlnArgs( argc, argv ); - if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) || - ( args.inConfig.numAudioObjects > 0 && args.inConfig.audioObjects[0].audioConfig == IVAS_AUDIO_CONFIG_OBA && args.inConfig.numAudioObjects == 1 ) ) ) + if ( args.nonDiegeticPan && + !( ( args.inConfig.numAudioObjects == 0 && + args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) || + ( args.inConfig.numAudioObjects > 0 && + args.inConfig.audioObjects[0].audioConfig == IVAS_AUDIO_CONFIG_OBA && args.inConfig.numAudioObjects == 1 ) ) ) { fprintf( stderr, "\ninvalid configuration - non-diegetic panning requires mono or ISM1 input\n" ); goto cleanup; @@ -1173,7 +1178,10 @@ int main( #endif /* sanity check */ - if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) + if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && + ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && + ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && + !is_split_pre_rend_mode( &args ) ) { fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split pre-rendering mode is enabled. Exiting. \n" ); goto cleanup; @@ -1490,7 +1498,7 @@ int main( } Word16 numOutChannels; - if ( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_GetNumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_NumOutChannels(): %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -1505,8 +1513,16 @@ int main( } } - if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { + char *outFile = args.outMetadataFilePath; + + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { + outFile = args.outputFilePath; + audioWriter = NULL; + } + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader(): %s!\n", ivas_error_to_string( error ) ); @@ -1519,36 +1535,15 @@ int main( goto cleanup; } - if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, outFile, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.outputFilePath ); + fprintf( stderr, "\nCould not open split rend metadata file %s\n", outFile ); goto cleanup; } - audioWriter = NULL; } - else - { - if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader(): %s!\n", ivas_error_to_string( error ) ); - goto cleanup; - } - - if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nUnable to get delay of renderer!\n" ); - goto cleanup; - } - - if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.outMetadataFilePath ); - goto cleanup; - } - } + if ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + { if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to open file: %s\n", args.outputFilePath ); @@ -1693,19 +1688,26 @@ int main( if ( numSamplesRead == 0 ) { /* end of input data */ - break; + flushRendererLastFrame = true; } /* Convert from int to float and from interleaved to packed */ - Word16 Q_out; - *outBuffer.pq_fact = 16 - ( gd_bits ); - convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, *outBuffer.pq_fact, inBuffer.config.is_cldfb, cldfbAna, &Q_out ); - *outBuffer.pq_fact = Q_out; + if ( !flushRendererLastFrame ) + { + Word16 Q_out; + *outBuffer.pq_fact = 16 - ( gd_bits ); + convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, *outBuffer.pq_fact, inBuffer.config.is_cldfb, cldfbAna, &Q_out ); + *outBuffer.pq_fact = Q_out; + } + else + { + memset( inBuffer.data_fx, 0, inBuffer.config.numChannels * inBuffer.config.numSamplesPerChannel * sizeof( Word32 ) ); + } int16_t num_subframes, sf_idx; num_subframes = (int16_t) args.render_framesize; - if ( isCurrentFrameMultipleOf20ms ) + if ( isCurrentFrameMultipleOf20ms && !flushRendererLastFrame ) { IsmPositionProvider_getNextFrame( positionProvider, &mtdBuffer ); @@ -1817,7 +1819,7 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.multiChannelBuses[i].inputChannelIndex, numChannels ); - if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, mcIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, mcIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -1831,7 +1833,7 @@ int main( if ( i == 0 ) { IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, args.inConfig.numAudioObjects ); - if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, ismIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -1847,7 +1849,7 @@ int main( else { IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, 1 ); - if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, ismIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -1870,7 +1872,7 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.ambisonicsBuses[i].inputChannelIndex, numChannels ); - if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, sbaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, sbaIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -1887,13 +1889,13 @@ int main( IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.masaBuses[i].inputChannelIndex, numChannels ); - IF( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) + IF( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, masaIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } - if ( isCurrentFrameMultipleOf20ms ) + if ( isCurrentFrameMultipleOf20ms && !flushRendererLastFrame ) { if ( masaReaders[i] != NULL ) { @@ -1956,7 +1958,7 @@ int main( zeroPad = delayNumSamples; } - if ( is_split_pre_rend_mode( &args ) ) + if ( is_split_pre_rend_mode( &args ) && !flushRendererLastFrame ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten ) != IVAS_ERR_OK ) @@ -1966,7 +1968,7 @@ int main( } } - if ( audioWriter != NULL ) + if ( audioWriter != NULL && !flushRendererLastFrame ) { if ( delayNumSamples * num_out_channels < outBufferSize ) { @@ -1987,7 +1989,7 @@ int main( bitsBuffer.config.bitsWritten = 0; /* Write MASA metadata for MASA outputs */ - if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) + if ( !flushRendererLastFrame && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) ) { IVAS_REND_AudioConfigType inputType1; IVAS_REND_AudioConfigType inputType2; @@ -2059,7 +2061,8 @@ int main( } } - if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && args.inConfig.numAudioObjects > 0 ) + if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && + args.inConfig.numAudioObjects > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED; if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) @@ -2075,6 +2078,13 @@ int main( } } + /* no new input was actually read, only delay buffers were flushed + * therefore this is not a real frame */ + if ( flushRendererLastFrame ) + { + break; + } + frame++; if ( !args.quietModeEnabled ) { @@ -2087,12 +2097,13 @@ int main( #endif } - /* add zeros at the end to have equal length of synthesized signals */ + /* add zeros at the end to have equal length of synthesized signals + * the output buffer will contain either leftover input samples from delay aligned inputs + * or zeros for padding */ if ( audioWriter != NULL ) { for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) { - memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); @@ -2100,7 +2111,6 @@ int main( } } - memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); @@ -2110,7 +2120,8 @@ int main( } - if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + if ( args.inConfig.numAudioObjects != 0 && + ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / IVAS_NUM_FRAMES_PER_SEC / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); } @@ -3509,7 +3520,8 @@ static void parseObjectPosition( *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); readNextMetadataChunk( line, "\n" ); - read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6], &meta_prm[7] ); + read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f,%f", + &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6], &meta_prm[7] ); if ( read_values < 2 ) { diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index c64e59339..e59a27a46 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1735,12 +1735,12 @@ ivas_error ISAR_POST_REND_getSamples( } #ifndef DISABLE_LIMITER - Word32 limiter_thresold; + Word32 limiter_threshold; #ifdef DEBUGGING hIvasRend->numClipping += #endif - limiter_thresold = L_shl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); + limiter_threshold = L_shl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_threshold, *outAudio.pq_fact ); #endif return IVAS_ERR_OK; diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index da4f6542f..10adbea2d 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -96,9 +96,8 @@ ivas_error ISAR_PRE_REND_open( isCldfbNeeded = 1; } - hSplitRendWrapper->hCldfbHandles = NULL; - - IF( isCldfbNeeded ) + test(); + IF( isCldfbNeeded && hSplitRendWrapper->hCldfbHandles == NULL ) { IF( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) { diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 512d4fd21..fe2f62ed4 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -33,6 +33,7 @@ #ifndef IVAS_PROT_REND_H #define IVAS_PROT_REND_H +#include "typedef.h" #include #include "options.h" #include "ivas_error.h" @@ -1594,6 +1595,40 @@ void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend ); +/*----------------------------------------------------------------------------------* + * Time domain ring buffer prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_TD_RINGBUF_Open( + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + const UWord32 capacity_per_channel, /* i : Number of samples stored per channel */ + const UWord16 num_channels /* i : Number of channels */ +); + +void ivas_TD_RINGBUF_Close( + TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */ +); + +void ivas_TD_RINGBUF_Push( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ + const UWord32 num_samples_per_channel /* i : Number of samples per channel to store */ +); + +void ivas_TD_RINGBUF_PushZeros( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const UWord32 num_samples_per_channel /* i : Number of zeros per channel to store */ +); + +void ivas_TD_RINGBUF_Pop( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ + const UWord32 num_samples_per_channel /* i : Number of samples per channel to retrieve*/ +); + +uint32_t ivas_TD_RINGBUF_Size( + const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ +); /* clang-format on */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 85c4dedd2..48e3dd349 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -33,6 +33,7 @@ #ifndef IVAS_STAT_REND_H #define IVAS_STAT_REND_H +#include "stl.h" #include #include "options.h" #include "ivas_cnst.h" @@ -1429,6 +1430,21 @@ typedef struct } CLDFB_REND_WRAPPER; +/*----------------------------------------------------------------------------------* + * Time domain ring buffer structure + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + Word32 *data; /* samples in interleaved layout */ + UWord32 capacity; + UWord16 num_channels; + UWord32 write_pos; + UWord32 read_pos; + Word16 is_full; + +} TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE; + /*----------------------------------------------------------------------------------* * Limiter structure *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 1f46ca932..ec447df7a 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -129,7 +129,7 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( /* Functions to be called before/during rendering */ -ivas_error IVAS_REND_NumOutChannels( +ivas_error IVAS_REND_GetNumOutChannels( IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ Word16 *numOutChannels /* o : number of output channels */ ); @@ -213,7 +213,7 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( ); ivas_error IVAS_REND_GetHrtfStatisticsHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ ); @@ -222,7 +222,8 @@ ivas_error IVAS_REND_GetHrtfStatisticsHandle( ivas_error IVAS_REND_FeedInputAudio_fx( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ - const IVAS_REND_ReadOnlyAudioBuffer inputAudio /* i : buffer with input audio */ + const IVAS_REND_ReadOnlyAudioBuffer inputAudio, /* i : buffer with input audio */ + const bool flushInputs /* i : flush input audio */ ); ivas_error IVAS_REND_FeedInputObjectMetadata( @@ -397,7 +398,7 @@ ivas_error IVAS_REND_GetSamples( /* Functions to be called after rendering */ void IVAS_REND_Close( - IVAS_REND_HANDLE* phIvasRend /* i/o: Pointer to renderer handle */ + IVAS_REND_HANDLE *phIvasRend /* i/o: Pointer to renderer handle */ ); /* Split binaural rendering functions */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index edf3231d7..72023e408 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -30,9 +30,14 @@ *******************************************************************************************************/ +#include "basop32.h" #include "basop_util.h" #include "options.h" +#include "cnst.h" +#include "common_api_types.h" +#include "enh32.h" #include "lib_rend.h" +#include "move.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" @@ -42,6 +47,7 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" +#include "stl.h" #include #include #include @@ -90,6 +96,7 @@ typedef struct typedef struct { const Word32 *pOutSampleRate; + const Word32 *pMaxGlobalDelayNs; const AUDIO_CONFIG *pOutConfig; const LSSETUP_CUSTOM_STRUCT *pCustomLsOut; const EFAP_WRAPPER *pEfapOutWrapper; @@ -106,9 +113,11 @@ typedef struct AUDIO_CONFIG inConfig; IVAS_REND_InputId id; IVAS_REND_AudioBuffer inputBuffer; + TD_RINGBUF_HANDLE delayBuffer; Word32 gain_fx; /* Linear, not in dB Q30 */ rendering_context ctx; Word32 numNewSamplesPerChannel; /* Used to keep track how much new audio was fed before rendering current frame */ + Word32 delayNumSamples; } input_base; typedef struct @@ -209,6 +218,7 @@ typedef struct hrtf_handles struct IVAS_REND { Word32 sampleRateOut; + Word32 maxGlobalDelayNs; IVAS_LIMITER_HANDLE hLimiter; input_ism inputsIsm[RENDERER_MAX_ISM_INPUTS]; @@ -221,10 +231,10 @@ struct IVAS_REND EFAP_WRAPPER efapOutWrapper; IVAS_LSSETUP_CUSTOM_STRUCT customLsOut; + Word16 splitRendBFI; SPLIT_REND_WRAPPER *splitRendWrapper; IVAS_REND_AudioBuffer splitRendEncBuffer; IVAS_REND_HeadRotData headRotData; - Word16 splitRendBFI; EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; @@ -267,6 +277,7 @@ static ivas_error allocateInputBaseBufferData_fx( return IVAS_ERR_OK; } + static void freeInputBaseBufferData_fx( Word32 **data /* Qx */ ) { @@ -278,6 +289,17 @@ static void freeInputBaseBufferData_fx( return; } + +static Word16 latencyNsToSamples( + Word32 sampleRate, + Word32 latency_ns ) +{ + Word16 n_samples; + + n_samples = NS2SA_FX2( sampleRate, latency_ns ); + return n_samples; +} + static ivas_error allocateMcLfeDelayBuffer_fx( Word32 **lfeDelayBuffer, /* Qx */ const Word16 data_size ) @@ -290,6 +312,7 @@ static ivas_error allocateMcLfeDelayBuffer_fx( return IVAS_ERR_OK; } + static void freeMcLfeDelayBuffer_fx( Word32 **lfeDelayBuffer /* Qx */ ) { @@ -404,7 +427,7 @@ static void copyBufferToCLDFBarray_fx( static void accumulateCLDFBArrayToBuffer_fx( Word32 re[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 im[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - IVAS_REND_AudioBuffer *buffer ) + const IVAS_REND_AudioBuffer *buffer ) { UWord32 smplIdx, slotIdx; UWord32 numCldfbSamples, num_bands; @@ -1285,6 +1308,9 @@ static void initRendInputBase_fx( inputBase->ctx = rendCtx; inputBase->numNewSamplesPerChannel = 0; move32(); + inputBase->delayNumSamples = 0; + move32(); + inputBase->delayBuffer = NULL; inputBase->inputBuffer.config.numSamplesPerChannel = 0; inputBase->inputBuffer.config.numChannels = 0; @@ -1339,6 +1365,7 @@ static rendering_context getRendCtx( /* Note: when refactoring this, always take the ADDRESS of a member of the * renderer struct, so that the context stores a POINTER to the member, even * if the member is a pointer or handle itself. */ + ctx.pMaxGlobalDelayNs = &hIvasRend->maxGlobalDelayNs; ctx.pOutConfig = &hIvasRend->outputConfig; ctx.pOutSampleRate = &hIvasRend->sampleRateOut; ctx.pCustomLsOut = &hIvasRend->customLsOut; @@ -1383,6 +1410,318 @@ static bool isIoConfigPairSupported( return true; } +static Word32 getRendInputDelayIsm( + const input_ism *inputIsm, + bool splitPreRendCldfb ) +{ + Word32 latency_ns; + latency_ns = 0; + move32(); + (void) ( splitPreRendCldfb ); /* unused */ + + /* set the rendering delay in InputBase */ + latency_ns = L_max( latency_ns, + inputIsm->tdRendWrapper.binaural_latency_ns ); + IF( inputIsm->crendWrapper != NULL ) + { + latency_ns = L_max( latency_ns, + inputIsm->crendWrapper->binaural_latency_ns ); + } + + return latency_ns; +} + + +static void setRendInputDelayIsm( + void *input, + bool splitPreRendCldfb ) +{ + input_ism *inputIsm; + inputIsm = (input_ism *) input; + + inputIsm->base.delayNumSamples = latencyNsToSamples( *inputIsm->base.ctx.pOutSampleRate, + getRendInputDelayIsm( inputIsm, splitPreRendCldfb ) ); +} + + +static Word32 getRendInputDelayMc( + const input_mc *inputMc, + bool splitPreRendCldfb ) +{ + Word32 latency_ns; + latency_ns = 0; + move32(); + (void) ( splitPreRendCldfb ); /* unused */ + + latency_ns = L_max( latency_ns, + inputMc->tdRendWrapper.binaural_latency_ns ); + IF( inputMc->crendWrapper != NULL ) + { + latency_ns = L_max( latency_ns, + inputMc->crendWrapper->binaural_latency_ns ); + } + + return latency_ns; +} + + +static void setRendInputDelayMc( + void *input, + bool splitPreRendCldfb ) +{ + input_mc *inputMc; + inputMc = (input_mc *) input; + + inputMc->base.delayNumSamples = latencyNsToSamples( *inputMc->base.ctx.pOutSampleRate, + getRendInputDelayMc( inputMc, splitPreRendCldfb ) ); +} + + +static Word32 getRendInputDelaySba( + const input_sba *inputSba, + bool splitPreRendCldfb ) +{ + Word32 latency_ns; + + latency_ns = 0; + move32(); + + IF( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) + { + Word32 filterbank_delay; + + filterbank_delay = 0; + move32(); + + IF( EQ_16( splitPreRendCldfb, 0 ) ) + { + filterbank_delay = IVAS_FB_DEC_DELAY_NS; + } + + latency_ns = L_max( latency_ns, + L_add( inputSba->cldfbRendWrapper.binaural_latency_ns, + filterbank_delay ) ); + } + + IF( inputSba->crendWrapper != NULL ) + { + latency_ns = L_max( latency_ns, + inputSba->crendWrapper->binaural_latency_ns ); + } + + return latency_ns; +} + + +static void setRendInputDelaySba( + void *input, + bool splitPreRendCldfb ) +{ + input_sba *inputSba; + inputSba = (input_sba *) input; + + inputSba->base.delayNumSamples = latencyNsToSamples( *inputSba->base.ctx.pOutSampleRate, + getRendInputDelaySba( inputSba, splitPreRendCldfb ) ); +} + + +static Word32 getRendInputDelayMasa( + const input_masa *inputMasa, + bool splitPreRendCldfb ) +{ + Word32 latency_ns; + + latency_ns = 0; + move32(); + + test(); + test(); + test(); + test(); + IF( ( EQ_32( inputMasa->base.inConfig, IVAS_AUDIO_CONFIG_MASA1 ) && + EQ_32( *inputMasa->base.ctx.pOutConfig, IVAS_AUDIO_CONFIG_MONO ) ) || + ( EQ_32( getAudioConfigType( *inputMasa->base.ctx.pOutConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) ) + { + latency_ns = 0; /* no delay */ + } + ELSE + { + Word32 filterbank_delay; + + filterbank_delay = 0; + move32(); + + /* no delay applied for split rendering */ + IF( EQ_16( splitPreRendCldfb, 0 ) ) + { + filterbank_delay = IVAS_FB_DEC_DELAY_NS; + } + latency_ns = L_max( latency_ns, + filterbank_delay ); + } + return latency_ns; +} + + +static void setRendInputDelayMasa( + void *input, + bool splitPreRendCldfb ) +{ + input_masa *inputMasa; + inputMasa = (input_masa *) input; + + inputMasa->base.delayNumSamples = latencyNsToSamples( *inputMasa->base.ctx.pOutSampleRate, + getRendInputDelayMasa( inputMasa, splitPreRendCldfb ) ); +} + + +static Word32 getMaxGlobalDelayNs( IVAS_REND_CONST_HANDLE hIvasRend ) +{ + Word16 i; + Word32 latency_ns; + Word32 max_latency_ns; + bool splitPreRendCldfb; + + max_latency_ns = 0; + /*assumes that input has been added which means codec has been set to either lcld or lc3plus (even if render config specified default)*/ + IF( hIvasRend->hRendererConfig != NULL ) + { + splitPreRendCldfb = ( hIvasRend->hRendererConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LCLD ); + } + ELSE + { + splitPreRendCldfb = false; + } + + /* Compute the maximum delay across all inputs */ + FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ ) + { + IF( NE_32( hIvasRend->inputsIsm[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + { + latency_ns = getRendInputDelayIsm( &hIvasRend->inputsIsm[i], splitPreRendCldfb ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); + } + } + + FOR( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ ) + { + IF( hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + { + latency_ns = getRendInputDelayMc( &hIvasRend->inputsMc[i], splitPreRendCldfb ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); + } + } + + FOR( i = 0; i < RENDERER_MAX_SBA_INPUTS; i++ ) + { + IF( hIvasRend->inputsSba[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + { + latency_ns = getRendInputDelaySba( &hIvasRend->inputsSba[i], splitPreRendCldfb ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); + } + } + + FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) + { + IF( hIvasRend->inputsMasa[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + { + latency_ns = getRendInputDelayMasa( &hIvasRend->inputsMasa[i], splitPreRendCldfb ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); + } + } + + return max_latency_ns; +} + + +static void setMaxGlobalDelayNs( IVAS_REND_HANDLE hIvasRend ) +{ + hIvasRend->maxGlobalDelayNs = getMaxGlobalDelayNs( (IVAS_REND_CONST_HANDLE) hIvasRend ); +} + +static ivas_error alignInputDelay( + input_base *inputBase, + const IVAS_REND_ReadOnlyAudioBuffer inputAudio, + const Word32 maxGlobalDelayNs, + const Word32 sampleRateOut, + const Word16 cldfb2tdSampleFact, + const bool flushInputs ) +{ + ivas_error error; + input_ism *inputIsm; + Word16 maxGlobalDelaySamples; + Word32 numSamplesToPush, numSamplesToPop; + UWord32 ringBufferSize, preDelay; + + maxGlobalDelaySamples = latencyNsToSamples( sampleRateOut, maxGlobalDelayNs ); + maxGlobalDelaySamples = i_mult( maxGlobalDelaySamples, cldfb2tdSampleFact ); + + /* check if we need to open the delay buffer */ + IF( inputBase->delayBuffer == NULL ) + { + /* buffer has to accomodate maxGlobalDelaySamples + 2 * frameSize */ + ringBufferSize = add( maxGlobalDelaySamples, + shl( inputAudio.config.numSamplesPerChannel, 1 ) ); + + /* pre delay for this input is maximum delay - input delay */ + preDelay = maxGlobalDelaySamples - inputBase->delayNumSamples * cldfb2tdSampleFact; + preDelay = sub( maxGlobalDelaySamples, + i_mult( inputBase->delayNumSamples, cldfb2tdSampleFact ) ); + + IF( GT_32( preDelay, 0 ) ) + { + IF( ( error = ivas_TD_RINGBUF_Open( &inputBase->delayBuffer, ringBufferSize, inputAudio.config.numChannels ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* for the first frame we need to push zeros to align the input delay to the global delay + * and then push a frame of actual data */ + ivas_TD_RINGBUF_PushZeros( inputBase->delayBuffer, preDelay ); + + /* for ISM inputs, ensure the metadata sync delay is updated */ + IF( getAudioConfigType( inputBase->inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) + { + inputIsm = (input_ism *) inputBase; + inputIsm->ism_metadata_delay_ms_fx = Mpy_32_32( maxGlobalDelayNs /* Q0 */, 2147 /* (1 / 1e6f) in Q31 */ ); + } + } + } + + IF( inputBase->delayBuffer != NULL ) + { + /* push in the new input data and pop to retrieve a complete input frame + * if we are flushing the inputs, we don't push in any new data */ + IF( NE_16( flushInputs, 0 ) ) + { + numSamplesToPush = 0; + move32(); + + numSamplesToPop = ivas_TD_RINGBUF_Size( inputBase->delayBuffer ); + } + ELSE + { + numSamplesToPush = inputAudio.config.numSamplesPerChannel; + move32(); + + numSamplesToPop = (Word32) inputAudio.config.numSamplesPerChannel; + move32(); + } + + ivas_TD_RINGBUF_Push( inputBase->delayBuffer, inputAudio.data_fx, numSamplesToPush ); + ivas_TD_RINGBUF_Pop( inputBase->delayBuffer, inputBase->inputBuffer.data_fx, numSamplesToPop ); + } + ELSE + { + /* delay buffer isn't open - we don't need it */ + mvl2l( inputAudio.data_fx, + inputBase->inputBuffer.data_fx, + i_mult( inputAudio.config.numSamplesPerChannel, inputAudio.config.numChannels ) ); + } + + return IVAS_ERR_OK; +} + static ivas_error initIsmMasaRendering( input_ism *inputIsm, const Word32 inSampleRate ) @@ -1615,6 +1954,7 @@ static void clearInputIsm( rendCtx = inputIsm->base.ctx; freeInputBaseBufferData_fx( &inputIsm->base.inputBuffer.data_fx ); + ivas_TD_RINGBUF_Close( &inputIsm->base.delayBuffer ); initRendInputBase_fx( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); @@ -2609,12 +2949,7 @@ static ivas_error initMcBinauralRendering( move32(); binauralDelayNs = L_max( binauralDelayNs, inputMc->tdRendWrapper.binaural_latency_ns ); - Word16 exp = 0; - move16(); - Word16 var1 = BASOP_Util_Divide3232_Scale( *inputMc->base.ctx.pOutSampleRate, 1000000000, &exp ); - Word32 var2 = L_shr_r( Mpy_32_32( binauralDelayNs, L_deposit_h( var1 ) ), negate( exp ) ); /* Q0 */ - inputMc->binauralDelaySmp = extract_l( var2 ); - move16(); + inputMc->binauralDelaySmp = latencyNsToSamples( *inputMc->base.ctx.pOutSampleRate, binauralDelayNs ); // inputMc->binauralDelaySmp = (int16_t) roundf( (float) binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f ); IF( GT_16( inputMc->binauralDelaySmp, MAX_BIN_DELAY_SAMPLES ) ) @@ -2820,6 +3155,8 @@ static void clearInputMc( rendCtx = inputMc->base.ctx; freeMcLfeDelayBuffer_fx( &inputMc->lfeDelayBuffer_fx ); freeInputBaseBufferData_fx( &inputMc->bufferData_fx ); + ivas_TD_RINGBUF_Close( &inputMc->base.delayBuffer ); + initRendInputBase_fx( &inputMc->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ @@ -3120,7 +3457,7 @@ static ivas_error setRendInputActiveSba( return error; } - return error; + return IVAS_ERR_OK; } static void clearInputSba( @@ -3131,6 +3468,7 @@ static void clearInputSba( rendCtx = inputSba->base.ctx; freeInputBaseBufferData_fx( &inputSba->bufferData_fx ); + ivas_TD_RINGBUF_Close( &inputSba->base.delayBuffer ); initRendInputBase_fx( &inputSba->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); @@ -3220,6 +3558,7 @@ static void clearInputMasa( rendCtx = inputMasa->base.ctx; freeInputBaseBufferData_fx( &inputMasa->bufferData_fx ); + ivas_TD_RINGBUF_Close( &inputMasa->base.delayBuffer ); masaPrerendClose_fx( &inputMasa->hMasaPrerend ); @@ -3287,7 +3626,7 @@ ivas_error IVAS_REND_Open( hIvasRend->num_subframes = num_subframes; /* Initialize limiter */ - IF( NE_32( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_REND_GetNumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) { return error; } @@ -3345,6 +3684,11 @@ ivas_error IVAS_REND_Open( isar_init_split_rend_handles( hIvasRend->splitRendWrapper ); } + hIvasRend->splitRendEncBuffer.data_fx = NULL; + hIvasRend->splitRendEncBuffer.config.is_cldfb = 0; + hIvasRend->splitRendEncBuffer.config.numChannels = 0; + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = 0; + FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { @@ -3552,7 +3896,7 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( hIvasRend->customLsOut = makeCustomLsSetup( layout ); /* Re-initialize limiter - number of output channels may have changed */ - IF( NE_32( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_REND_GetNumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) { return error; } @@ -3613,7 +3957,7 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( * *-------------------------------------------------------------------*/ -ivas_error IVAS_REND_NumOutChannels( +ivas_error IVAS_REND_GetNumOutChannels( IVAS_REND_CONST_HANDLE hIvasRend, Word16 *numOutChannels ) { @@ -3843,7 +4187,7 @@ static Word16 getCldfbRendFlag( const IVAS_REND_AudioConfigType new_configType ) { Word16 i; - Word16 numMasaInputs = 0, numSbaInputs = 0, numIsmInputs = 0, numMcInputs = 0; + Word16 numMasaInputs = 0, numSbaInputs = 0; Word16 isCldfbRend; move16(); @@ -3854,6 +4198,11 @@ static Word16 getCldfbRendFlag( isCldfbRend = 0; move16(); + /* This function is called during three different phases of renderer processing: + * - IVAS_REND_AddInput() + * - IVAS_REND_FeedRenderConfig() + * - IVAS_REND_GetSplitBinauralBitstream() + * Only the last case can assume all inputs are present for the current frame to be rendered */ IF( hIvasRend->hRendererConfig != NULL ) { FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) @@ -3866,23 +4215,8 @@ static Word16 getCldfbRendFlag( numSbaInputs = add( numSbaInputs, ( hIvasRend->inputsSba[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ? 0 : 1 ); move16(); } - FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) - { - numIsmInputs = add( numIsmInputs, ( hIvasRend->inputsIsm[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) ? 0 : 1 ); - move16(); - } - FOR( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) - { - numMcInputs = add( numMcInputs, ( hIvasRend->inputsMc[i].base.inConfig == IVAS_AUDIO_CONFIG_INVALID && new_configType != IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ? 0 : 1 ); - move16(); - } - IF( GT_16( numIsmInputs, 0 ) || GT_16( numMcInputs, 0 ) ) - { - isCldfbRend = 0; - move16(); - } - ELSE IF( GT_16( numMasaInputs, 0 ) || ( GT_16( numSbaInputs, 0 ) && EQ_32( hIvasRend->hRendererConfig->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) ) + IF( GT_16( numMasaInputs, 0 ) || ( GT_16( numSbaInputs, 0 ) && EQ_32( hIvasRend->hRendererConfig->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) ) { isCldfbRend = 1; move16(); @@ -3894,12 +4228,12 @@ static Word16 getCldfbRendFlag( /*------------------------------------------------------------------------- - * Function ivas_pre_rend_init() + * Function isar_pre_rend_init() * * *------------------------------------------------------------------------*/ -static ivas_error ivas_pre_rend_init( +static ivas_error isar_pre_rend_init( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REND_AudioBuffer *pSplitRendEncBuffer, ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, @@ -3909,11 +4243,21 @@ static ivas_error ivas_pre_rend_init( const Word16 cldfb_in_flag, const Word16 num_subframes ) { + bool realloc; ivas_error error; IVAS_REND_AudioBufferConfig bufConfig; + realloc = false; + + /* only perform init if split rendering output */ test(); - IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + return IVAS_ERR_OK; + } + + /* these functions should only be called once during initial allocation */ + IF( pSplitRendEncBuffer->data_fx == NULL ) { IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) { @@ -3928,41 +4272,51 @@ static ivas_error ivas_pre_rend_init( { return error; } + } - /*allocate for CLDFB in and change to TD during process if needed*/ - bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; - bufConfig.numChannels = i_mult( BINAURAL_CHANNELS, pSplitRendWrapper->multiBinPoseData.num_poses ); - bufConfig.is_cldfb = 1; - pSplitRendEncBuffer->config = bufConfig; + /* We may need to change the allocated buffer size if a new input is added. + * If the cldfb_in_flag is different from what was previously allocated for the buffer, change the size */ + test(); + IF( pSplitRendEncBuffer->data_fx != NULL && ( NE_16( cldfb_in_flag, pSplitRendEncBuffer->config.is_cldfb ) ) ) + { + realloc = true; + } + + test(); + IF( pSplitRendEncBuffer->data_fx == NULL || NE_16( realloc, 0 ) ) + { + /* set buffer config */ + bufConfig.is_cldfb = cldfb_in_flag; move16(); + + bufConfig.numSamplesPerChannel = L_FRAME_MAX; move16(); + IF( NE_16( cldfb_in_flag, 0 ) ) + { + bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; + move16(); + } + + bufConfig.numChannels = i_mult( BINAURAL_CHANNELS, pSplitRendWrapper->multiBinPoseData.num_poses ); move16(); + pSplitRendEncBuffer->config = bufConfig; move32(); + /* allocate memory */ + IF( NE_16( realloc, 0 ) ) + { + free( pSplitRendEncBuffer->data_fx ); + } + IF( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } - pSplitRendEncBuffer->q_factor = 0; - pSplitRendEncBuffer->pq_fact = &pSplitRendEncBuffer->q_factor; - } - ELSE - { - IVAS_REND_AudioBufferConfig bufConfig2; - - bufConfig2.numSamplesPerChannel = 0; - bufConfig2.numChannels = 0; - bufConfig2.is_cldfb = 0; - pSplitRendEncBuffer->config = bufConfig2; - pSplitRendEncBuffer->data_fx = NULL; - pSplitRendEncBuffer->pq_fact = NULL; pSplitRendEncBuffer->q_factor = 0; move16(); + pSplitRendEncBuffer->pq_fact = &pSplitRendEncBuffer->q_factor; move16(); - move16(); - move32(); - move32(); } return IVAS_ERR_OK; @@ -3986,7 +4340,11 @@ ivas_error IVAS_REND_AddInput_fx( void *inputsArray; Word32 inputStructSize; ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, RENDER_CONFIG_DATA *, hrtf_handles *hrtfs ); + void ( *setInputDelay )( void *, bool ); Word32 inputIndex; + bool splitPreRendCldfb; + splitPreRendCldfb = false; + /* Validate function arguments */ test(); @@ -3995,17 +4353,24 @@ ivas_error IVAS_REND_AddInput_fx( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - IF( ( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && hIvasRend->splitRendEncBuffer.data_fx == NULL && hIvasRend->hRendererConfig != NULL ) + IF( hIvasRend->hRendererConfig != NULL ) { Word16 cldfb_in_flag; cldfb_in_flag = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); - IF( ( error = ivas_pre_rend_init( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + IF( ( error = isar_pre_rend_init( hIvasRend->splitRendWrapper, + &hIvasRend->splitRendEncBuffer, + &hIvasRend->hRendererConfig->split_rend_config, + hIvasRend->headRotData, hIvasRend->sampleRateOut, + hIvasRend->outputConfig, cldfb_in_flag, + hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) { return error; } } + /*assumes that input has been added which means codec has been set to either lcld or lc3plus (even if render config specified default)*/ + splitPreRendCldfb = EQ_32( hIvasRend->hRendererConfig->split_rend_config.codec, ISAR_SPLIT_REND_CODEC_LCLD ); SWITCH( getAudioConfigType( inConfig ) ) { @@ -4014,6 +4379,7 @@ ivas_error IVAS_REND_AddInput_fx( inputsArray = hIvasRend->inputsIsm; inputStructSize = sizeof( *hIvasRend->inputsIsm ); activateInput = setRendInputActiveIsm; + setInputDelay = setRendInputDelayIsm; move32(); move32(); BREAK; @@ -4022,6 +4388,7 @@ ivas_error IVAS_REND_AddInput_fx( inputsArray = hIvasRend->inputsMc; inputStructSize = sizeof( *hIvasRend->inputsMc ); activateInput = setRendInputActiveMc; + setInputDelay = setRendInputDelayMc; move32(); move32(); BREAK; @@ -4030,6 +4397,7 @@ ivas_error IVAS_REND_AddInput_fx( inputsArray = hIvasRend->inputsSba; inputStructSize = sizeof( *hIvasRend->inputsSba ); activateInput = setRendInputActiveSba; + setInputDelay = setRendInputDelaySba; move32(); move32(); BREAK; @@ -4038,6 +4406,7 @@ ivas_error IVAS_REND_AddInput_fx( inputsArray = hIvasRend->inputsMasa; inputStructSize = sizeof( *hIvasRend->inputsMasa ); activateInput = setRendInputActiveMasa; + setInputDelay = setRendInputDelayMasa; move32(); move32(); BREAK; @@ -4058,6 +4427,15 @@ ivas_error IVAS_REND_AddInput_fx( return error; } +#ifdef CODE_IMPROVEMENTS + setInputDelay( getInputByIndex( inputsArray, inputIndex, inputType ), splitPreRendCldfb ); +#else + setInputDelay( (Word8 *) inputsArray + inputStructSize * inputIndex, splitPreRendCldfb ); +#endif + + /* set global maximum delay after adding an input */ + setMaxGlobalDelayNs( hIvasRend ); + return IVAS_ERR_OK; } @@ -4373,175 +4751,61 @@ ivas_error IVAS_REND_GetInputNumChannels( * * *-------------------------------------------------------------------*/ -ivas_error IVAS_REND_GetNumAllObjects( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ - Word16 *numChannels /* o : number of all objects */ -) -{ - test(); - IF( hIvasRend == NULL || numChannels == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - test(); - IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) - { - *numChannels = (Word16) hIvasRend->inputsIsm[0].total_num_objects; - move16(); - } - - return IVAS_ERR_OK; -} - - -/*-------------------------------------------------------------------* - * IVAS_REND_GetDelay() - * - * - *-------------------------------------------------------------------*/ - -ivas_error IVAS_REND_GetDelay_fx( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ - Word16 *nSamples, /* o : Renderer delay in samples */ - Word32 *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ -) -{ - /* TODO tmu : this function only returns the maximum delay across all inputs - * Ideally each input has its own delay buffer and everything is aligned (binaural and LFE filtering delays are nonuniform) - */ - Word16 i; - Word32 latency_ns; - Word32 max_latency_ns; - - Word32 timescale_by_ns[7] = { 0, 17180, 34360, 0, 68719, 0, 103079 }; - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - - /* Validate function arguments */ - test(); - test(); - IF( hIvasRend == NULL || nSamples == NULL || timeScale == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - *timeScale = hIvasRend->sampleRateOut; - move32(); - assert( *timeScale == 8000 || *timeScale == 16000 || *timeScale == 32000 || *timeScale == 48000 ); - *nSamples = 0; - move16(); - max_latency_ns = 0; - move32(); - - /* Compute the maximum delay across all inputs */ - FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ ) - { - IF( NE_32( hIvasRend->inputsIsm[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) - { - IF( hIvasRend->inputsIsm[i].crendWrapper != NULL ) - { - latency_ns = hIvasRend->inputsIsm[i].crendWrapper->binaural_latency_ns; - } - ELSE - { - latency_ns = 0; - } - move32(); - - latency_ns = L_max( latency_ns, hIvasRend->inputsIsm[i].tdRendWrapper.binaural_latency_ns ); - max_latency_ns = L_max( max_latency_ns, latency_ns ); - } - } - - FOR( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ ) - { - IF( NE_32( hIvasRend->inputsMc[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) - { - IF( ( hIvasRend->inputsMc[i].crendWrapper != NULL ) ) - { - latency_ns = hIvasRend->inputsMc[i].crendWrapper->binaural_latency_ns; - } - ELSE - { - latency_ns = 0; - } - move32(); - - latency_ns = L_max( latency_ns, hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); - max_latency_ns = L_max( max_latency_ns, latency_ns ); - } - } - - FOR( i = 0; i < RENDERER_MAX_SBA_INPUTS; i++ ) - { - IF( NE_32( hIvasRend->inputsSba[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) - { - test(); - IF( hIvasRend->splitRendWrapper != NULL && hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) - { - IF( EQ_32( hIvasRend->hRendererConfig->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) - { - latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; - move32(); - } - ELSE - { - IF( ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ) - { - latency_ns = hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns; - } - ELSE - { - latency_ns = 0; - } - move32(); - } - max_latency_ns = L_max( max_latency_ns, latency_ns ); - } - ELSE IF( hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend != NULL ) - { - latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; - move32(); - latency_ns = L_add( latency_ns, IVAS_FB_DEC_DELAY_NS ); - max_latency_ns = L_max( max_latency_ns, latency_ns ); - } - ELSE - { - IF( hIvasRend->inputsSba[i].crendWrapper != NULL ) - { - latency_ns = hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns; - } - ELSE - { - latency_ns = 0; - } - move32(); - max_latency_ns = L_max( max_latency_ns, latency_ns ); - } - } +ivas_error IVAS_REND_GetNumAllObjects( + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + Word16 *numChannels /* o : number of all objects */ +) +{ + test(); + IF( hIvasRend == NULL || numChannels == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) + test(); + IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) { - IF( NE_32( hIvasRend->inputsMasa[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) - { - latency_ns = (Word32) ( IVAS_FB_DEC_DELAY_NS ); - move32(); - max_latency_ns = L_max( max_latency_ns, latency_ns ); - } + *numChannels = (Word16) hIvasRend->inputsIsm[0].total_num_objects; + move16(); + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * IVAS_REND_GetDelay() + * + * + *-------------------------------------------------------------------*/ + +ivas_error IVAS_REND_GetDelay_fx( + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + Word16 *nSamples, /* o : Renderer delay in samples */ + Word32 *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ +) +{ + Word32 max_latency_ns; + + /* Validate function arguments */ + test(); + test(); + IF( hIvasRend == NULL || nSamples == NULL || timeScale == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - //*nSamples = (Word16) roundf( (float) max_latency_ns * *timeScale / 1000000000.f ); - Word32 temp = Mpy_32_32( *timeScale, 268436 ); // Q0 + Q31 - Q31 -> Q0, ( 1 / 8000 ) * 2 ^ 31 - *nSamples = extract_l( Mpy_32_32_r( max_latency_ns, timescale_by_ns[temp] ) ); + assert( *timeScale == 8000 || *timeScale == 16000 || *timeScale == 32000 || *timeScale == 48000 ); + + *nSamples = 0; move16(); + *timeScale = hIvasRend->sampleRateOut; + + max_latency_ns = getMaxGlobalDelayNs( hIvasRend ); + + *nSamples = latencyNsToSamples( hIvasRend->sampleRateOut, max_latency_ns ); + return IVAS_ERR_OK; } @@ -4553,14 +4817,16 @@ ivas_error IVAS_REND_GetDelay_fx( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_FeedInputAudio_fx( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const IVAS_REND_InputId inputId, /* i : ID of the input */ - const IVAS_REND_ReadOnlyAudioBuffer inputAudio /* i : buffer with input audio */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ + const IVAS_REND_ReadOnlyAudioBuffer inputAudio, /* i : buffer with input audio */ + const bool flushInputs /* i : flush input audio */ ) { ivas_error error; input_base *inputBase; Word16 numInputChannels; + /* Note: this is called cldfb2tdSampleFact in float */ Word16 cldfb2tdShift; /* Validate function arguments */ @@ -4619,7 +4885,16 @@ ivas_error IVAS_REND_FeedInputAudio_fx( inputBase->inputBuffer.config = inputAudio.config; - MVR2R_WORD32( inputAudio.data_fx, inputBase->inputBuffer.data_fx, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); + if ( ( error = alignInputDelay( + inputBase, + inputAudio, + hIvasRend->maxGlobalDelayNs, + hIvasRend->sampleRateOut, + cldfb2tdShift, + flushInputs ) ) != IVAS_ERR_OK ) + { + return error; + } inputBase->numNewSamplesPerChannel = shr( inputAudio.config.numSamplesPerChannel, cldfb2tdShift ); move32(); @@ -4943,6 +5218,7 @@ Word16 IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hDiracDecBin[0] != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb ); + IF( NE_32( ( error = ivas_binaural_reverb_init_fx( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), *pMasaInput->base.ctx.pOutSampleRate, NULL, NULL, NULL ) ), IVAS_ERR_OK ) ) { return error; @@ -4951,6 +5227,7 @@ Word16 IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &pMasaInput->hMasaExtRend->hReverb ); + IF( NE_32( ( error = ivas_binaural_reverb_init_fx( &pMasaInput->hMasaExtRend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), *pMasaInput->base.ctx.pOutSampleRate, NULL, NULL, NULL ) ), IVAS_ERR_OK ) ) { return error; @@ -4975,6 +5252,7 @@ Word16 IVAS_REND_FeedRenderConfig( return error; } } + if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend[0] && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) { IF( NE_32( ( error = ivas_reverb_open_fx( &pMcInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pMcInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) ) @@ -5021,6 +5299,7 @@ Word16 IVAS_REND_FeedRenderConfig( { Word16 cldfb_in_flag; cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + IF( hIvasRend->splitRendWrapper != NULL ) { ISAR_PRE_REND_close( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); @@ -5028,7 +5307,7 @@ Word16 IVAS_REND_FeedRenderConfig( hIvasRend->splitRendWrapper = NULL; } - IF( ( error = ivas_pre_rend_init( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) + IF( ( error = isar_pre_rend_init( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) { return error; } @@ -6395,8 +6674,10 @@ static ivas_error renderIsmToSplitBinaural( const SPLIT_REND_WRAPPER *pSplitRendWrapper; IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_QUATERNION localHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; - Word16 i; + Word16 i, ch, slot_idx, num_bands; Word32 tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + Word32 tmpBinaural_CldfbRe[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 tmpBinaural_CldfbIm[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word16 output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; Word16 ism_md_subframe_update_ext, exp; @@ -6473,6 +6754,7 @@ static ivas_error renderIsmToSplitBinaural( IF( ismInput->hReverb != NULL ) { + exp = add( exp, 2 ); FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { FOR( Word16 j = 0; j < outAudio.config.numSamplesPerChannel; j++ ) @@ -6482,10 +6764,35 @@ static ivas_error renderIsmToSplitBinaural( } } } - /* Copy rendered audio to tmp storage buffer. Copying directly to output would - * overwrite original audio, which is still needed for rendering next head pose. */ - Copy32( tmpProcessing[0], tmpBinaural[i_mult( 2, pos_idx )], output_frame ); - Copy32( tmpProcessing[1], tmpBinaural[add( i_mult( 2, pos_idx ), 1 )], output_frame ); + + IF( NE_16( outAudio.config.is_cldfb, 0 ) ) + { + /* Perform CLDFB analysis on rendered audio, since the output buffer is CLDFB domain */ + Word16 q_cldfb; + + q_cldfb = exp; + num_bands = extract_l( Mpy_32_32( imult3216( *ismInput->base.ctx.pOutSampleRate, BINAURAL_MAXBANDS ), 44740 /* 1/48000 in Q31 */ ) ); /* Q0 */ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + FOR( slot_idx = 0; slot_idx < IVAS_CLDFB_NO_COL_MAX; slot_idx++ ) + { + cldfbAnalysis_ts_fx( &tmpProcessing[ch][num_bands * slot_idx], + &tmpBinaural_CldfbRe[BINAURAL_CHANNELS * pos_idx + ch][slot_idx][0], + &tmpBinaural_CldfbIm[BINAURAL_CHANNELS * pos_idx + ch][slot_idx][0], + num_bands, + ismInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[pos_idx + ch], + &q_cldfb ); + } + } + } + ELSE + { + + /* Copy rendered audio to tmp storage buffer. Copying directly to output would + * overwrite original audio, which is still needed for rendering next head pose. */ + Copy32( tmpProcessing[0], tmpBinaural[i_mult( 2, pos_idx )], output_frame ); + Copy32( tmpProcessing[1], tmpBinaural[add( i_mult( 2, pos_idx ), 1 )], output_frame ); + } /* Overwrite processing buffer with original input audio again */ copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpProcessing ); @@ -6497,7 +6804,14 @@ static ivas_error renderIsmToSplitBinaural( Copy_Quat_fx( &originalHeadRot[i], &pCombinedOrientationData->Quaternions[i] ); } - accumulate2dArrayToBuffer_fx( tmpBinaural, &outAudio ); + if ( outAudio.config.is_cldfb ) + { + accumulateCLDFBArrayToBuffer_fx( tmpBinaural_CldfbRe, tmpBinaural_CldfbIm, &outAudio ); + } + else + { + accumulate2dArrayToBuffer_fx( tmpBinaural, &outAudio ); + } pop_wmops(); /* Encoding to split rendering bitstream done at a higher level */ @@ -6553,6 +6867,8 @@ static ivas_error renderInputIsm( { ivas_error error; IVAS_REND_AudioBuffer inAudio; + /* Note: in float this is called cldfb2tdSampleFact - it is either 2 or 1, so we handle it as a shift here */ + Word16 cldfb2tdSampleShift; Word16 exp = *outAudio.pq_fact; move16(); @@ -6560,7 +6876,16 @@ static ivas_error renderInputIsm( move32(); inAudio = ismInput->base.inputBuffer; - IF( NE_32( ismInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) + /* Note: in float this is a factor, so it is 1 or 2 there instead of 0 or 1 here */ + cldfb2tdSampleShift = 0; + move16(); + IF( outAudio.config.is_cldfb ) + { + cldfb2tdSampleShift = 1; + move16(); + } + + IF( NE_32( L_shl( ismInput->base.numNewSamplesPerChannel, cldfb2tdSampleShift ), outAudio.config.numSamplesPerChannel ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } @@ -6710,7 +7035,7 @@ static ivas_error renderLfeToBinaural_fx( num_cpy_smpl_cur_frame = sub( frame_size, num_cpy_smpl_prev_frame ); /* Assuming LFE should be delayed by less that the duration of one frame */ - assert( mcInput->binauralDelaySmp < frame_size ); + assert( mcInput->binauralDelaySmp <= MAX_BIN_DELAY_SAMPLES ); /* Get delayed LFE signal from previous frame, apply gain and save in tmp buffer */ v_multc_fixed( mcInput->lfeDelayBuffer_fx, gain_fx, tmpLfeBuffer, num_cpy_smpl_prev_frame ); /* Qx - 1 */ @@ -8684,15 +9009,13 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( *-------------------------------------------------------------------*/ static ivas_error getSamplesInternal( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ - IVAS_REND_BitstreamBuffer *hBits /* i/o: buffer for input/output bitstream. Needed in split rendering */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ ) { ivas_error error; Word16 numOutChannels; Word16 cldfb2tdSampleShift; - IVAS_REND_AudioBuffer outAudioOrig; /* Validate function arguments */ test(); @@ -8797,40 +9120,21 @@ static ivas_error getSamplesInternal( } } - IF( NE_32( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_REND_GetNumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) { return error; } - IF( NE_16( numOutChannels, outAudio.config.numChannels ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( NE_16( numOutChannels, outAudio.config.numChannels ) && + NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && + NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { return IVAS_ERR_WRONG_NUM_CHANNELS; } - /* Clear original output buffer */ + /* Clear output buffer */ set32_fx( outAudio.data_fx, 0, imult1616( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); - outAudioOrig = outAudio; - - /* Use internal buffer if outputting split rendering bitstream */ - test(); - IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - Word16 num_poses_orig; - num_poses_orig = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; - move16(); - outAudio.config = hIvasRend->splitRendEncBuffer.config; - outAudio.data_fx = hIvasRend->splitRendEncBuffer.data_fx; - - ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper->multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); - - assert( num_poses_orig == hIvasRend->splitRendWrapper->multiBinPoseData.num_poses && "number of poses should not change dynamically" ); - - /* Clear output buffer for split rendering bitstream */ - set32_fx( outAudio.data_fx, 0, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); - } - IF( NE_32( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) { return error; @@ -8848,150 +9152,6 @@ static ivas_error getSamplesInternal( return error; } - test(); - IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ISAR_SPLIT_REND_BITS_DATA bits; - Word16 cldfb_in_flag, i, j, k, ch, ro_md_flag; - Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - - FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) - { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) - { - Cldfb_RealBuffer_Binaural[i][j][k] = 0; - Cldfb_ImagBuffer_Binaural[i][j][k] = 0; - move32(); - move32(); - } - } - } - - Word32 *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; - - FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) - { - tmpBinaural[ch] = tmpBinaural_buff[ch]; - move32(); - } - - IF( EQ_16( outAudio.config.is_cldfb, 1 ) ) - { - cldfb_in_flag = 1; - move16(); - copyBufferToCLDFBarray_fx( outAudio, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); - } - ELSE - { - cldfb_in_flag = 0; - move16(); - copyBufferTo2dArray_fx( outAudio, tmpBinaural_buff ); - } - - /* Encode split rendering bitstream */ - convertBitsBufferToInternalBitsBuff( *hBits, &bits ); - - ro_md_flag = 0; - move16(); - FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) - { - IF( NE_32( hIvasRend->inputsIsm[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) - { - ro_md_flag = 1; - move16(); - break; - } - } - - Word16 q1 = 31, q2 = 31, Q_buff; - Word16 Q_out[CLDFB_NO_COL_MAX]; - Q_out[0] = 31; - Word16 num_poses = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; - - for ( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) - { - q1 = s_min( q1, L_norm_arr( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); - q2 = s_min( q2, L_norm_arr( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); - } - } - Q_buff = s_min( q1, q2 ); - for ( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) - { - for ( j = 0; j < CLDFB_NO_COL_MAX; j++ ) - { - scale_sig32( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); - scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); - } - } - Q_buff = Q_buff + *outAudio.pq_fact; - - IF( EQ_16( cldfb_in_flag, 0 ) ) - { - /*TD input*/ - num_poses = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; - - FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) - { - Q_out[0] = s_min( Q_out[0], L_norm_arr( tmpBinaural_buff[i], L_FRAME48k ) ); - } - - FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) - { - scale_sig32( tmpBinaural_buff[i], L_FRAME48k, Q_out[0] ); - } - - Q_out[0] = Q_out[0] + *outAudio.pq_fact; - } - - if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, - hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, - hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, -#ifdef FIX_2083_FLOATING_POINT_LEFTOVERS - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) -#else - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const Word16 )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) -#endif - { - return error; - } - - Word16 pcm_out_flag = ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - IF( NE_16( pcm_out_flag, 0 ) ) - { - FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - scale_sig32( tmpBinaural_buff[j], L_FRAME48k, sub( *outAudio.pq_fact, Q_out[j] ) ); // *outAudio.pq_fact - } - } - - convertInternalBitsBuffToBitsBuffer( hBits, bits ); - - /* reset to outAudioOrig in case of PCM output */ - outAudio.config = outAudioOrig.config; - outAudio.data_fx = outAudioOrig.data_fx; - - IF( NE_16( pcm_out_flag, 0 ) ) - { - accumulate2dArrayToBuffer_fx( tmpBinaural_buff, &outAudio ); - } - } - - if ( outAudio.config.is_cldfb == 0 ) - { - Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); -#ifndef DISABLE_LIMITER - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); -#endif - } - - /* update global cominbed orientation start index */ - ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); - return IVAS_ERR_OK; } @@ -9001,13 +9161,31 @@ static ivas_error getSamplesInternal( * * *-------------------------------------------------------------------*/ - ivas_error IVAS_REND_GetSamples( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ ) { - return getSamplesInternal( hIvasRend, outAudio, NULL ); + ivas_error error; + + IF( ( error = getSamplesInternal( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) + { + return error; + } + + + IF( NE_16( outAudio.config.is_cldfb, 0 ) ) + { + Word32 limiter_threshold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); +#ifndef DISABLE_LIMITER + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_threshold, *outAudio.pq_fact ); +#endif + } + + /* update global cominbed orientation start index */ + ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); + + return IVAS_ERR_OK; } @@ -9023,25 +9201,149 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( IVAS_REND_BitstreamBuffer *hBits /* o : buffer for output bitstream */ ) { + ivas_error error; + Word16 ch; Word16 cldfb_in_flag; + Word16 i, ro_md_flag; + Word16 num_poses_orig; + Word32 *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + IVAS_REND_AudioBufferConfig *pSplitEncBufConfig; + ISAR_SPLIT_REND_CONFIG_HANDLE pSplitRendConfig; + ISAR_SPLIT_REND_BITS_DATA bits; + Word16 max_bands; + Word16 Q_out[2]; + + max_bands = 0; + move16(); + + Q_out[0] = Q31; + move16(); + Q_out[1] = Q31; + move16(); + + FOR( ch = 0; ch < i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS ); ch++ ) + { + tmpBinaural[ch] = tmpBinaural_buff[ch]; + } cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); - hIvasRend->splitRendEncBuffer.config.is_cldfb = cldfb_in_flag; + pSplitEncBufConfig = &hIvasRend->splitRendEncBuffer.config; + pSplitRendConfig = &hIvasRend->hRendererConfig->split_rend_config; + + /* 0 DoF / No pose correction retains frame size */ + pSplitEncBufConfig->is_cldfb = cldfb_in_flag; + move16(); + + test(); + IF( EQ_16( pSplitRendConfig->dof, 0 ) || EQ_32( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + { + pSplitEncBufConfig->numSamplesPerChannel = outAudio.config.numSamplesPerChannel; + move16(); + } + /* Pose correction requires 20ms */ + ELSE + { + pSplitEncBufConfig->numSamplesPerChannel = div_s( hIvasRend->sampleRateOut, FRAMES_PER_SEC ); + } - if ( hIvasRend->hRendererConfig->split_rend_config.dof == 0 || hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) + /* Note: float was "pSplitEncBufConfig->numSamplesPerChannel *= cldfb_in_flag ? 2 : 1;" */ + IF( NE_16( cldfb_in_flag, 0 ) ) { - hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = outAudio.config.numSamplesPerChannel; + pSplitEncBufConfig->numSamplesPerChannel = shl( pSplitEncBufConfig->numSamplesPerChannel, 1 ); } - else + + num_poses_orig = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; + move16(); + + ISAR_PRE_REND_GetMultiBinPoseData( pSplitRendConfig, + &hIvasRend->splitRendWrapper->multiBinPoseData, + hIvasRend->headRotData.sr_pose_pred_axis ); + assert( num_poses_orig == hIvasRend->splitRendWrapper->multiBinPoseData.num_poses && "number of poses should not change dynamically" ); + + /* hIvasRend->splitRendEncBuffer contains multi-pose data for BINAURAL_SPLIT_CODED output + outAudio used later for main pose BINAURAL_SPLIT_PCM output */ + IF( ( error = getSamplesInternal( hIvasRend, hIvasRend->splitRendEncBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* copy outputs */ + IF( NE_16( hIvasRend->splitRendEncBuffer.config.is_cldfb, 1 ) ) + { + cldfb_in_flag = 1; + move16(); + copyBufferToCLDFBarray_fx( hIvasRend->splitRendEncBuffer, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); + } + ELSE + { + cldfb_in_flag = 0; + move16(); + copyBufferTo2dArray_fx( hIvasRend->splitRendEncBuffer, tmpBinaural_buff ); + } + + /* Encode split rendering bitstream */ + convertBitsBufferToInternalBitsBuff( *hBits, &bits ); + + ro_md_flag = 0; + move16(); + FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) + { + IF( NE_32( hIvasRend->inputsIsm[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + { + ro_md_flag = 1; + + break; + } + } + + max_bands = extract_l( Mpy_32_32( imult3216( hIvasRend->sampleRateOut, BINAURAL_MAXBANDS ), 44740 /* 1/48000 in Q31 */ ) ); + IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, + hIvasRend->headRotData.headPositions[0], + pSplitRendConfig->splitRendBitRate, + pSplitRendConfig->codec, + pSplitRendConfig->isar_frame_size_ms, + pSplitRendConfig->codec_frame_size_ms, + &bits, + Cldfb_RealBuffer_Binaural, + Cldfb_ImagBuffer_Binaural, + max_bands, + tmpBinaural, + 1, + cldfb_in_flag, + ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, + ro_md_flag, + hIvasRend->splitRendEncBuffer.q_factor, + Q_out ) ) != IVAS_ERR_OK ) + { + return error; + } + + convertInternalBitsBuffToBitsBuffer( hBits, bits ); + + /* copy over first pose data to outAudio */ + IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + /* set outAudio to zero - getSamplesInternal only cleared splitRendEncBuffer */ + set_zero_fx( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); + accumulate2dArrayToBuffer_fx( tmpBinaural_buff, &outAudio ); + } + + IF( EQ_16( outAudio.config.is_cldfb, 0 ) ) { - hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = (Word16) ( hIvasRend->sampleRateOut / FRAMES_PER_SEC ); +#ifndef DISABLE_LIMITER +#ifdef DEBUGGING + hIvasRend->numClipping += +#endif + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); +#endif } - hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; + /* update global cominbed orientation start index */ + ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); - /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output - outAudio used for BINAURAL_SPLIT_PCM output */ - return getSamplesInternal( hIvasRend, outAudio, hBits ); + return IVAS_ERR_OK; } -- GitLab From 5b3981608a145322782852d7bb155b3f49c81538 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 16 Oct 2025 17:07:51 +0200 Subject: [PATCH 018/351] add ring buffer file --- lib_rend/ivas_td_ring_buffer_fx.c | 346 ++++++++++++++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 lib_rend/ivas_td_ring_buffer_fx.c diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c new file mode 100644 index 000000000..0660bc506 --- /dev/null +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -0,0 +1,346 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "basop32.h" +#include "move.h" +#include "typedef.h" +#include +#include +#include "ivas_error_utils.h" +#include "ivas_prot_rend_fx.h" +#include "wmc_auto.h" + + +/*-----------------------------------------------------------------------* + * Local function prototypes + *-----------------------------------------------------------------------*/ + +static UWord32 ivas_td_ringbuf_total_size( + TD_RINGBUF_HANDLE h ) +{ + UWord32 total_size; + + IF( h->is_full ) + { + total_size = h->capacity; + } + + IF( h->read_pos <= h->write_pos ) + { + total_size = L_sub( h->write_pos, h->read_pos ); + } + /* else wrap around */ + total_size = L_add( h->write_pos, L_sub( h->capacity, h->read_pos ) ); + + return total_size; +} + + +static Word16 ivas_td_ringbuf_has_space_for_num_samples( + TD_RINGBUF_HANDLE h, + const UWord32 num_samples ) +{ + // float was : return (Word16) ( ivas_td_ringbuf_total_size( h ) + num_samples <= h->capacity ); + Word16 has_space; + UWord32 total_size_after; + + move16(); + has_space = 0; + + total_size_after = L_add( ivas_td_ringbuf_total_size( h ), num_samples ); + IF( LE_32( total_size_after, h->capacity ) ) + { + has_space = 1; + } + return has_space; +} + + +/*-----------------------------------------------------------------------* + * Global function definitions + *-----------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Open() + * + * Allocate a ring buffer for TD data with the given capacity of TD samples per channel. + * + * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. + *---------------------------------------------------------------------*/ + +ivas_error ivas_TD_RINGBUF_Open( + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + const UWord32 capacity_per_channel, /* i : Number of samples stored per channel */ + const UWord16 num_channels /* i : Number of channels */ +) +{ + TD_RINGBUF_HANDLE h; + UWord32 capacity; + + // TODO: how to integer multiplication 32 x 16 ? + capacity = L_mult0( capacity_per_channel, num_channels ); + + h = malloc( sizeof( TD_RINGBUF_DATA ) ); + IF( h == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); + } + // TODO: move for pointer assignment? + h->data = NULL; + move32(); + h->capacity = 0; + move16(); + h->num_channels = num_channels; + move32(); + h->write_pos = 0; + move32(); + h->read_pos = 0; + move16(); + h->is_full = 0; + // TODO: move for pointer assignment? + *ph = h; + + h->data = malloc( capacity * sizeof( Word32 ) ); + IF( h->data == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); + } + + move32(); + h->capacity = capacity; + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Close() + * + * Dellocate TD ring buffer. The given handle will be set to NULL. + + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Close( + TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */ +) +{ + TD_RINGBUF_HANDLE h; + + IF( ph == NULL ) + { + return; + } + // TODO: move for pointer assignment? + h = *ph; + + IF( h == NULL ) + { + return; + } + + IF( h->data != NULL ) + { + free( h->data ); + } + + free( h ); + // TODO: move for pointer assignment? + *ph = NULL; + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Push() + * + * Push samples onto the back of the TD ring buffer. + * Returns total number of buffered samples (includes number of channels) + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Push( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ + const UWord32 num_samples_per_channel /* i : Number of samples per channel to store */ +) +{ + UWord32 s; + UWord16 c; + + // TODO: integer multiplication for 32 * 16? + assert( ivas_td_ringbuf_has_space_for_num_samples( h, L_mult0( num_samples_per_channel, h->num_channels ) ) ); + + FOR( s = 0; s < num_samples_per_channel; ++s ) + { + FOR( c = 0; c < h->num_channels; ++c ) + { + UWord32 shift_val; + + /* pointer is advance by c * num_samples_per_channel + s */ + shift_val = L_mult0( c, num_samples_per_channel ); + shift_val = L_add( s, shift_val ); + + // TODO: move for pointer assignment? + h->data[h->write_pos] = *( data + shift_val ); + ++h->write_pos; + + IF( EQ_32( h->write_pos, h->capacity ) ) + { + move32(); + h->write_pos = 0; + } + } + } + + IF( EQ_32( h->read_pos, h->write_pos ) ) + { + move32(); + h->is_full = 1; + } + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushZeros() + * + * Push zero samples onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushZeros( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const UWord32 num_samples_per_channel /* i : Number of zeros per channel to store */ +) +{ + UWord32 s; + UWord16 c; + + // TODO: integer multiplication for 32 * 16? + assert( ivas_td_ringbuf_has_space_for_num_samples( h, L_mult0( num_samples_per_channel, h->num_channels ) ) ); + IF( EQ_32( num_samples_per_channel, 0 ) ) + { + return; + } + + FOR( s = 0; s < num_samples_per_channel; ++s ) + { + FOR( c = 0; c < h->num_channels; ++c ) + { + // TODO: move for pointer assignment? + h->data[h->write_pos] = 0; + ++h->write_pos; + + IF( EQ_32( h->write_pos, h->capacity ) ) + { + move32(); + h->write_pos = 0; + } + } + } + + IF( EQ_32( h->read_pos, h->write_pos ) ) + { + move32(); + h->is_full = 1; + } + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Pop() + * + * Pop samples from the front of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Pop( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ + const UWord32 num_samples_per_channel /* i : Number of samples per channel to retrieve */ +) +{ + UWord32 s; + UWord16 c; + Word32 requested_samples; + + // TODO + requested_samples = L_mult0( num_samples_per_channel, h->num_channels ); + assert( GE_32( ivas_td_ringbuf_total_size( h ), requested_samples ) ); + + FOR( s = 0; s < num_samples_per_channel; ++s ) + { + FOR( c = 0; c < h->num_channels; ++c ) + { + UWord32 shift_val; + + /* pointer is advanced by c * num_samples_per_channel + s */ + shift_val = L_mult0( c, num_samples_per_channel ); + shift_val = L_add( s, shift_val ); + + *( data + shift_val ) = h->data[h->read_pos]; + ++h->read_pos; + + IF( EQ_32( h->write_pos, h->capacity ) ) + { + move32(); + h->write_pos = 0; + } + } + } + + IF( NE_16( h->is_full, 0 ) ) + { + move16(); + h->is_full = 0; + } + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Size() + * + * Returns number of buffered samples per channel. + *---------------------------------------------------------------------*/ + +UWord32 ivas_TD_RINGBUF_Size( + const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ +) +{ + UWord32 size; + + size = div_l( ivas_td_ringbuf_total_size( h ), h->num_channels ); + return size; +} -- GitLab From 958b0ce482b314695e20b8baf34a41aa28f7bb67 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 22 Oct 2025 14:25:08 +0200 Subject: [PATCH 019/351] use edited angles in ISM gain calculation --- lib_com/options.h | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index fefc866d6..3bab55372 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -125,7 +125,7 @@ #define FIX_1217_OBJECT_EDIT_FILE_INTERFACE /* Nokia: issue #1217: add decoder functionality to read object edit instructions from a file */ #define NONBE_1217_OBJ_EDIT_FOA /* VA/Nokia: isse 1217: fix crash in object editing to FOA output in ParamISM */ #define NONBE_FIX_1255_OBJ_EDIT_JBM /* VA: issue 1255: restore object editing in JBM */ - +#define FIX_2193_ISM_GAINS_WITH_OE /* FhG: fix issue 2193: use edited angles in ISM gain calculation */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index d2243feb2..df2f0da61 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1054,8 +1054,13 @@ void ivas_ism_dec_digest_tc_fx( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { /*get HOA gets for direction (ACN/SN3D)*/ +#ifdef FIX_2193_ISM_GAINS_WITH_OE Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 +#else + Word16 azi = shr( extract_h( azimuth_fx ), 22 - 16 ); // Q0 + Word16 ele = shr( extract_h( elevation_fx ), 22 - 16 ); // Q0 +#endif ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); -- GitLab From 85de5fb80900b82496ec96ad626a1b9e55275a75 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 22 Oct 2025 15:16:54 +0200 Subject: [PATCH 020/351] fix Q values of azi and ele --- lib_dec/ivas_ism_param_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index df2f0da61..d22a1fc8c 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1055,11 +1055,11 @@ void ivas_ism_dec_digest_tc_fx( { /*get HOA gets for direction (ACN/SN3D)*/ #ifdef FIX_2193_ISM_GAINS_WITH_OE - Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 - Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 + Word16 azi = azimuth_fx; // Q0 + Word16 ele = elevation_fx; // Q0 #else - Word16 azi = shr( extract_h( azimuth_fx ), 22 - 16 ); // Q0 - Word16 ele = shr( extract_h( elevation_fx ), 22 - 16 ); // Q0 + Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), Q22 ); // Q22 + Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), Q22 ); // Q22 #endif ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); -- GitLab From fbc5bfd1cfe6f903f7fbbb55fa1a71cc4d96cf1f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 22 Oct 2025 15:19:03 +0200 Subject: [PATCH 021/351] fix Q values of azi and ele when FIX_2193_ISM_GAINS_WITH_OE is disabled --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index d22a1fc8c..f14af5798 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1058,8 +1058,8 @@ void ivas_ism_dec_digest_tc_fx( Word16 azi = azimuth_fx; // Q0 Word16 ele = elevation_fx; // Q0 #else - Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), Q22 ); // Q22 - Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), Q22 ); // Q22 + Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q22 + Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q22 #endif ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); -- GitLab From 3ab14358a89115bc0237e2cbcd75a90a828c38c0 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 22 Oct 2025 15:22:47 +0200 Subject: [PATCH 022/351] fix comment in ivas_ism_dec_digest_tc_fx --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index f14af5798..8f03f69f5 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1058,8 +1058,8 @@ void ivas_ism_dec_digest_tc_fx( Word16 azi = azimuth_fx; // Q0 Word16 ele = elevation_fx; // Q0 #else - Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q22 - Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q22 + Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 + Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 #endif ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); -- GitLab From 20aaa2aff9b9e20dcefc483fe451c63933db0cf5 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 22 Oct 2025 15:36:23 +0200 Subject: [PATCH 023/351] fix compiler warning --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 8f03f69f5..5285af596 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1055,8 +1055,8 @@ void ivas_ism_dec_digest_tc_fx( { /*get HOA gets for direction (ACN/SN3D)*/ #ifdef FIX_2193_ISM_GAINS_WITH_OE - Word16 azi = azimuth_fx; // Q0 - Word16 ele = elevation_fx; // Q0 + Word16 azi = (Word16) azimuth_fx; // Q0 + Word16 ele = (Word16) elevation_fx; // Q0 #else Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 -- GitLab From fe73e133ee45dedf417edf5600a649abf1b85607 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 22 Oct 2025 16:07:01 +0200 Subject: [PATCH 024/351] port MR 2302 from float repo --- lib_com/bitstream_fx.c | 3 +- lib_com/fd_cng_com_fx.c | 5 + lib_com/ivas_cnst.h | 5 + lib_com/ivas_prot_fx.h | 2 + lib_com/ivas_rom_com.h | 6 + lib_com/ivas_rom_com_fx.c | 10 + lib_com/options.h | 1 + lib_com/stat_com.h | 9 +- lib_dec/fd_cng_dec_fx.c | 232 ++++++++++++++++++++++- lib_dec/ivas_decision_matrix_dec_fx.c | 9 +- lib_dec/ivas_ism_metadata_dec_fx.c | 31 ++- lib_dec/ivas_ism_param_dec_fx.c | 6 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 4 + lib_enc/fd_cng_enc_fx.c | 133 +++++++++++++ lib_enc/stat_enc.h | 5 + 15 files changed, 450 insertions(+), 11 deletions(-) diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index b1c7a2efd..d2f3a61f6 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -5235,7 +5235,7 @@ void evs_dec_previewFrame( return; } - +#ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG void dtx_read_padding_bits_fx( DEC_CORE_HANDLE st, const Word16 num_bits ) @@ -5253,3 +5253,4 @@ void dtx_read_padding_bits_fx( return; } +#endif diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 47e3df91e..c8f0c31ac 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -2,6 +2,7 @@ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ +#include "ivas_cnst.h" #include #include #include "options.h" @@ -161,8 +162,12 @@ void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) hFdCngCom->exp_cldfb_periodog = 0; move16(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + set16_fx( hFdCngCom->coherence_fx, 16384 /* 0.5 in Q15 */, MDCT_ST_DTX_NUM_COHERENCE_BANDS ); +#else hFdCngCom->coherence_fx = 16384; /* 0.5 in Q15 */ move16(); +#endif set32_fx( hFdCngCom->olapBufferSynth_fx, 0, FFTLEN ); set32_fx( hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index bb61171a8..29a0c2592 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -884,6 +884,11 @@ enum fea_names #define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN 20 #define MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE 3 +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG +#define MDCT_ST_DTX_NUM_COHERENCE_BANDS 5 +#define MDCT_ST_DTX_FIRST_BAND_OFFSET 2 +#endif + typedef enum { NOISE_GEN_MODE_UNDEF = -1, EQUAL_CORES = 0, diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index a88c13583..1ef6abc7e 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1552,11 +1552,13 @@ ivas_error ivas_dirac_config_fx( void *st_ivas, /* i/o: IVAS encoder/decoder state structure */ const Word16 enc_dec /* i : encoder or decoder flag */ ); +#ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG void dtx_read_padding_bits_fx( DEC_CORE_HANDLE st, const Word16 num_bits ); +#endif void FdCngEncodeMDCTStereoSID_fx( CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 5072e385f..2a2a8de63 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -133,6 +133,12 @@ extern const SpectrumWarping sw32000Hz[]; /* PsychLPC */ extern const MDCTStereoBands_config mdctStereoBands_32000_640[]; +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG +extern const Word16 mdct_stereo_dtx_coherence_bandlengths[MDCT_ST_DTX_NUM_COHERENCE_BANDS]; +extern const Word16 get_next_index_4_by_15[16]; +#endif + + /*----------------------------------------------------------------------------------* * Stereo DTX ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 4b14f6d5a..b0de18d94 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -546,6 +546,16 @@ const MDCTStereoBands_config mdctStereoBands_32000_640[] = {33, 29, 26, 18}/*number of bands for frame lengths 480, 320, 256, 160 respectively*/ }}; +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG +const Word16 mdct_stereo_dtx_coherence_bandlengths[MDCT_ST_DTX_NUM_COHERENCE_BANDS] = { + 6, /* 8 - MDCT_ST_DTX_FIRST_BAND_OFFSET */ 8, 16, 16, 80 +}; +/* dequantization table for coherence */ +const Word16 get_next_index_4_by_15[16] = { + 0, 2184, 4369, 6553, 8738, 10922, 13107, 15291, 17476, 19660, 21845, 24029, 26214, 28398, 30583, 32767 +}; +#endif + const Word16 dft_cng_coh_u2i[9] = { 4, 5, 3, 6, 2, 7, 1, 8, 0 }; /* Coherence unary codeword -> residual codeword conversion table */ const Word16 dft_cng_coh_i2u[9] = { 8, 6, 4, 2, 0, 1, 3, 5, 7 }; /* Coherence residual codeword -> unary codeword conversion table */ diff --git a/lib_com/options.h b/lib_com/options.h index fefc866d6..068948b0a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,6 +115,7 @@ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1288_SPLIT_REND_XSAN /* Dlb: Fix asan, msan and usan issues in split rendering mode*/ #define LIB_DEC_REVISION /* VA: cleaning and simplification of lib_dec.c */ +#define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 7b5c9fd10..5309e7ad7 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -38,6 +38,7 @@ #ifndef STAT_COM_H #define STAT_COM_H +#include "ivas_cnst.h" #include #include "options.h" #include "typedef.h" @@ -443,8 +444,12 @@ typedef struct Word16 flag_noisy_speech; Word16 likelihood_noisy_speech; /* Q15 */ - Word16 coherence_fx; /* inter-channel coherence of noise Q15 */ - Word16 no_side_flag; /* indicates whether the side noise shape should be zeroed-out or not */ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + Word16 coherence_fx[MDCT_ST_DTX_NUM_COHERENCE_BANDS]; /* inter-channel coherence of noise Q15 */ +#else + Word16 coherence_fx; /* inter-channel coherence of noise Q15 */ +#endif + Word16 no_side_flag; /* indicates whether the side noise shape should be zeroed-out or not */ } FD_CNG_COM, *HANDLE_FD_CNG_COM; diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index d8805c4f2..f79766af3 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -3,6 +3,13 @@ ====================================================================================*/ +#include "basop32.h" +#include "cnst.h" +#include "enh1632.h" +#include "ivas_cnst.h" +#include "ivas_rom_com.h" +#include "move.h" +#include "wmc_auto.h" #include #include "typedef.h" #include @@ -2924,12 +2931,21 @@ void generate_comfort_noise_dec_ivas_fx( temp = 0; move16(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + c1 = Sqrt16( hFdCngCom->coherence_fx[0], &temp ); /*Q15 - temp*/ +#else c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ - c1 = shl( c1, temp ); /*Q15*/ +#endif + c1 = shl( c1, temp ); /*Q15*/ temp = 0; move16(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + // TODO: float is "sqrt(1 - coherence)". Here MAX_16 is used for 1. coherence_fx is in Q15. Why isn't ONE_IN_Q15 used here? (which is different from MAX_16) + c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx[0] ), &temp ); /*Q15 - temp*/ +#else c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx ), &temp ); /*Q15 - temp*/ - c2 = shl( c2, temp ); /*Q15*/ +#endif + c2 = shl( c2, temp ); /*Q15*/ temp = getScaleFactor32( fftBuffer, FFTLEN ); scale_sig32( fftBuffer, FFTLEN, temp ); /*Q31 - hFdCngCom->fftBuffer_exp + temp*/ @@ -2956,7 +2972,12 @@ void generate_comfort_noise_dec_ivas_fx( { test(); test(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_MDCT && NE_16( nchan_out, 1 ) ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#else IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#endif { rand_gauss_fx( &tmp1, seed, Q15 ); rand_gauss_fx( &tmp2, seed2, Q15 ); @@ -2992,6 +3013,157 @@ void generate_comfort_noise_dec_ivas_fx( } ptr_i = ptr_r + 1; /*Q31 - fftBuffer_exp*/ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( nchan_out, 1 ) ) + { + Word16 band_len_accu, b; + + band_len_accu = 0; + move16(); + i = 0; + move16(); + + FOR( b = 0; b < MDCT_ST_DTX_NUM_COHERENCE_BANDS; b++ ) + { + band_len_accu = add( band_len_accu, mdct_stereo_dtx_coherence_bandlengths[b] ); + + /* First band needs to be shortened. The offset from encoder-side estimation is already in, so add it back here */ + IF( EQ_16( b, 0 ) ) + { + band_len_accu = add( band_len_accu, sub( MDCT_ST_DTX_FIRST_BAND_OFFSET, hFdCngCom->startBand ) ); + } + + /* + * for last band, we need to keep going until the end of the fft section - if there is still any + * this way, the coherence value of the last band is used for eveyrthing above as well + */ + IF( EQ_16( b, sub( MDCT_ST_DTX_NUM_COHERENCE_BANDS, 1 ) ) ) + { + band_len_accu = s_max( band_len_accu, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); + } + + /* mixing values for coherence is now frequency-dependent */ + temp = 0; + move16(); + c1 = Sqrt16( hFdCngCom->coherence_fx[b], &temp ); /*Q15 - temp*/ + c1 = shl( c1, temp ); /*Q15*/ + temp = 0; + move16(); + // TODO: float is "sqrt(1 - coherence)". Here MAX_16 is used for 1. coherence_fx is in Q15. Why isn't ONE_IN_Q15 used here? (which is different from MAX_16) + c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx[b] ), &temp ); /*Q15 - temp*/ + c2 = shl( c2, temp ); /*Q15*/ + + FOR( ; i < band_len_accu; i++ ) + { + sqrtNoiseLevel_exp = sub( cngNoiseLevel_exp, 1 ); + sqrtNoiseLevel = Sqrt32( *ptr_level, &sqrtNoiseLevel_exp ); /*Q31 - sqrtNoiseLevel_exp*/ + + /* Real part in FFT bins */ + rand_gauss_fx( &tmp1, seed, Q15 ); + rand_gauss_fx( &tmp2, seed2, Q15 ); + *ptr_r = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) ); /*Q15*/ + move32(); + fftBuffer_temp_exp[idx] = Q16; + move16(); + ( *ptr_r ) = Mpy_32_32( ( *ptr_r ), sqrtNoiseLevel ); /*Q15 - sqrtNoiseLevel_exp*/ + move32(); + fftBuffer_temp_exp[idx] = add( fftBuffer_temp_exp[idx], sqrtNoiseLevel_exp ); + move16(); + idx = add( idx, 1 ); + + /* Imaginary part in FFT bins */ + rand_gauss_fx( &tmp1, seed, Q15 ); /*Q15*/ + rand_gauss_fx( &tmp2, seed2, Q15 ); /*Q15*/ + *ptr_i = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) ); /*Q15*/ + move32(); + fftBuffer_temp_exp[idx] = Q16; + move16(); + ( *ptr_i ) = Mpy_32_32( ( *ptr_i ), sqrtNoiseLevel ); /*Q15 - sqrtNoiseLevel_exp*/ + move32(); + fftBuffer_temp_exp[idx] = add( fftBuffer_temp_exp[idx], sqrtNoiseLevel_exp ); + move16(); + idx = add( idx, 1 ); + + /* advance all pointers together here */ + ptr_r += 2; + ptr_i += 2; + ptr_level++; + } + } + } + ELSE + { + FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ ) + { + /* Real part in FFT bins */ + test(); + test(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( nchan_out, 1 ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#else + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#endif + { + rand_gauss_fx( &tmp1, seed, Q15 ); /*Q15*/ + rand_gauss_fx( &tmp2, seed2, Q15 ); /*Q15*/ + *ptr_r = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) ); /*Q15*/ + move32(); + fftBuffer_temp_exp[idx] = Q16; + move16(); + } + ELSE + { + rand_gauss_fx( ptr_r, seed, Q15 ); /*Q15*/ + fftBuffer_temp_exp[idx] = Q16; + move16(); + } + + sqrtNoiseLevel_exp = sub( cngNoiseLevel_exp, 1 ); + sqrtNoiseLevel = Sqrt32( *ptr_level, &sqrtNoiseLevel_exp ); /*Q31 - sqrtNoiseLevel_exp*/ + ( *ptr_r ) = Mpy_32_32( ( *ptr_r ), sqrtNoiseLevel ); /*Q15 - sqrtNoiseLevel_exp*/ + move32(); + fftBuffer_temp_exp[idx] = add( fftBuffer_temp_exp[idx], sqrtNoiseLevel_exp ); + move16(); + idx = add( idx, 1 ); + ptr_r += 2; + + /* Imaginary part in FFT bins */ + test(); + test(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( nchan_out, 1 ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#else + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#endif + { + rand_gauss_fx( &tmp1, seed, Q15 ); /*Q15*/ + rand_gauss_fx( &tmp2, seed2, Q15 ); /*Q15*/ + *ptr_i = L_add( Mpy_32_16_1( tmp1, c1 ), Mpy_32_16_1( tmp2, c2 ) ); /*Q15*/ + move32(); + fftBuffer_temp_exp[idx] = Q16; + move16(); + } + ELSE + { + rand_gauss_fx( ptr_i, seed, Q15 ); /*Q15*/ + fftBuffer_temp_exp[idx] = Q16; + move16(); + } + sqrtNoiseLevel_exp = sub( cngNoiseLevel_exp, 1 ); + sqrtNoiseLevel = Sqrt32( *ptr_level, &sqrtNoiseLevel_exp ); /*Q31 - sqrtNoiseLevel_exp*/ + ( *ptr_i ) = Mpy_32_32( ( *ptr_i ), sqrtNoiseLevel ); /*Q15 - sqrtNoiseLevel_exp*/ + move32(); + fftBuffer_temp_exp[idx] = add( fftBuffer_temp_exp[idx], sqrtNoiseLevel_exp ); + move16(); + idx = add( idx, 1 ); + ptr_i += 2; + } + } + +#else FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ ) { /* Real part in FFT bins */ @@ -3049,6 +3221,7 @@ void generate_comfort_noise_dec_ivas_fx( idx = add( idx, 1 ); ptr_i += 2; } +#endif /* Remaining FFT bins are set to zero */ set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); @@ -3159,6 +3332,13 @@ void generate_comfort_noise_dec_ivas_fx( /* Generate Gaussian random noise in real and imaginary parts of the CLDFB bands Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each band */ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + /* + * Note: for the stereo DTX noise mixing, c1 and c2 at this point are set to the value calculated for the last band + * as all the coherence bands are in the FFT region, we do not need the special handling here + */ +#endif + test(); IF( bufferReal != NULL && ( LT_16( hFdCngCom->numCoreBands, hFdCngCom->regularStopBand ) ) ) { @@ -3174,7 +3354,12 @@ void generate_comfort_noise_dec_ivas_fx( FOR( i = 0; i < hFdCngCom->numSlots; i++ ) { /* Real part in CLDFB band */ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( nchan_out, 1 ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#else IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#endif { rand_gauss_fx( &tmp1, seed, Q15 ); /*Q15*/ rand_gauss_fx( &tmp2, seed2, Q15 ); /*Q15*/ @@ -3197,7 +3382,12 @@ void generate_comfort_noise_dec_ivas_fx( move16(); /* Imaginary part in CLDFB band */ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( nchan_out, 1 ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#else IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) +#endif { rand_gauss_fx( &tmp1, seed, Q15 ); /*Q15*/ rand_gauss_fx( &tmp2, seed2, Q15 ); /*Q15*/ @@ -3544,13 +3734,21 @@ void generate_comfort_noise_dec_hf_ivas_fx( s = 0; move16(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + c1 = Sqrt16( hFdCngCom->coherence_fx[sub( MDCT_ST_DTX_NUM_COHERENCE_BANDS, 1 )], &s ); /*Q15 - s*/ +#else c1 = Sqrt16( hFdCngCom->coherence_fx, &s ); /*Q15 - s*/ - c1 = shl( c1, s ); // Q15 +#endif + c1 = shl( c1, s ); // Q15 s = 0; move16(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + c2 = Sqrt16( sub( MAX16B, hFdCngCom->coherence_fx[sub( MDCT_ST_DTX_NUM_COHERENCE_BANDS, 1 )] ), &s ); /*Q15 - s*/ +#else c2 = Sqrt16( sub( MAX16B, hFdCngCom->coherence_fx ), &s ); /*Q15 - s*/ - c2 = shl( c2, s ); // Q15 +#endif + c2 = shl( c2, s ); // Q15 } sn = 0; @@ -5222,7 +5420,22 @@ void FdCngDecodeMDCTStereoSID_fx( Scale_sig32( ms_ptr_fx[ch], N, shift ); // Q20 } +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + tmp32 = sts[1]->total_brate; + sts[1]->total_brate = L_add( sts[1]->total_brate, 800 /* 16 * FRAMES_PER_SEC */ ); + /* read the four additional coherence values */ + FOR( Word16 b = 1; b < MDCT_ST_DTX_NUM_COHERENCE_BANDS; b++ ) + { + UWord16 idx; + + idx = get_next_indice_fx( sts[1], 4 ); + sts[0]->hFdCngDec->hFdCngCom->coherence_fx[b] = get_next_index_4_by_15[idx]; + sts[1]->hFdCngDec->hFdCngCom->coherence_fx[b] = sts[0]->hFdCngDec->hFdCngCom->coherence_fx[b]; + } + sts[1]->total_brate = tmp32; +#else dtx_read_padding_bits_fx( sts[1], mult( sub( IVAS_SID_5k2, 4400 ), ONE_BY_FRAMES_PER_SEC_Q15 ) ); +#endif IF( sts[0]->hFdCngDec->hFdCngCom->no_side_flag ) { @@ -5407,10 +5620,21 @@ void FdCngDecodeDiracMDCTStereoSID_fx( lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); } +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + FOR( i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) + { + sts[0]->hFdCngDec->hFdCngCom->coherence_fx[i] = 0; + move16(); + sts[1]->hFdCngDec->hFdCngCom->coherence_fx[i] = 0; + move16(); + } + +#else sts[0]->hFdCngDec->hFdCngCom->coherence_fx = 0; move16(); sts[1]->hFdCngDec->hFdCngCom->coherence_fx = 0; move16(); +#endif IF( EQ_16( hCPE->nchan_out, 1 ) ) { diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index 717bb3b93..3eac102a3 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "stat_dec.h" -#include "rom_com.h" +#include "ivas_rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" @@ -46,9 +46,11 @@ * Read ACELP signaling bits from the bitstream * Set extension layers *-----------------------------------------------------------------*/ +#ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG static Word16 get_next_index_4_by_15[16] = { 0, 2184, 4369, 6553, 8738, 10922, 13107, 15291, 17476, 19660, 21845, 24029, 26214, 28398, 30583, 32767 }; +#endif void ivas_decision_matrix_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 *sharpFlag, /* o : formant sharpening flag */ @@ -129,10 +131,13 @@ void ivas_decision_matrix_dec_fx( /* read channel coherence */ Word16 index; index = get_next_indice_fx( st, 4 ); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + st->hFdCngDec->hFdCngCom->coherence_fx[0] = get_next_index_4_by_15[index]; +#else st->hFdCngDec->hFdCngCom->coherence_fx = get_next_index_4_by_15[index]; +#endif move16(); - /* read flag for no side noise shape */ st->hFdCngDec->hFdCngCom->no_side_flag = get_next_indice_fx( st, 1 ); move16(); diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 2c13e25c8..3e1883220 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,6 +30,7 @@ *******************************************************************************************************/ +#include "move.h" #include #include "options.h" #include "ivas_cnst.h" @@ -1247,21 +1248,49 @@ void ivas_ism_metadata_sid_dec_fx( { IF( EQ_16( ch, *sce_id_dtx ) ) { +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + FOR( i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) + { + // TODO: why not ONE_IN_Q15 ? (value there is different) + hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[i] = 32767; + } + +#else hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx = 32767; // 1.0f in Q15 move16(); +#endif CONTINUE; } idx = get_next_indice_fx( st0, nBits_coh ); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + // TODO: why is this different from the dequantization in ivas_decision_matrix_dec()? There, a table is used. Is this doing the same thing? + hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0] = div_s( idx, sub( ( shl( 1, nBits_coh ) ), 1 ) ); // Q15 + move16(); + FOR( i = 1; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) + { + hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[i] = hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0]; + move16(); + } +#else hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx = div_s( idx, sub( ( shl( 1, nBits_coh ) ), 1 ) ); // Q15 move16(); +#endif } } - if ( EQ_32( ism_mode, ISM_MODE_PARAM ) ) + IF( EQ_32( ism_mode, ISM_MODE_PARAM ) ) { +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + FOR( i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) + { + hSCE[*sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[i] = hSCE[!*sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[i]; + move16(); + } +#else hSCE[*sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx = hSCE[!*sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx; move16(); +#endif } /*----------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index d2243feb2..b029cdcfa 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1837,8 +1837,12 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( IF( st_ivas->hISMDTX.dtx_flag ) { - Word32 energy_ratio_fx; /* Q30 */ + Word32 energy_ratio_fx; /* Q30 */ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + energy_ratio_fx = L_mult0( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0], st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0] ); /* Q15 + Q15 -> Q30 */ +#else energy_ratio_fx = L_mult0( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx, st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx ); /* Q15 + Q15 -> Q30 */ +#endif hSpatParamRendCom->numSimultaneousDirections = 1; move16(); diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 43dc48edf..efea57f4d 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -634,7 +634,11 @@ void synchonize_channels_mdct_sid_fx( move16(); sts[1]->bwidth = sts[0]->bwidth; move16(); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + sts[0]->hFdCngDec->hFdCngCom->coherence_fx[0] = sts[1]->hFdCngDec->hFdCngCom->coherence_fx[0]; /* coherence is stored in sts[1] - see ivas_decision_matrix_dec() */ +#else sts[0]->hFdCngDec->hFdCngCom->coherence_fx = sts[1]->hFdCngDec->hFdCngCom->coherence_fx; /* coherence is stored in sts[1] - see ivas_decision_matrix_dec() */ +#endif move16(); sts[0]->hFdCngDec->hFdCngCom->no_side_flag = sts[1]->hFdCngDec->hFdCngCom->no_side_flag; move16(); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 6834958d1..1a74fb616 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2,12 +2,17 @@ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ +#include "wmc_auto.h" #include #include "stl.h" #include "options.h" #include "cnst.h" +#include "ivas_cnst.h" #include "stl.h" #include "rom_com.h" +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG +#include "ivas_rom_com.h" +#endif #include "rom_enc.h" #include "prot_fx.h" #include "prot_fx_enc.h" @@ -144,8 +149,16 @@ void initFdCngEnc_fx( hsEnc->msPeriodogBufPtr = 0; move16(); set32_fx( hsEnc->msPsdSecondMoment_fx, 0, NPART ); +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + FOR( Word16 i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) + { + set32_fx( hsEnc->mem_coherence_fx[i], EPSILON_FX, 4 ); + set16_fx( hsEnc->mem_coherence_exp[i], 0, 4 ); + } +#else set32_fx( hsEnc->mem_coherence_fx, EPSILON_FX, 4 ); set16_fx( hsEnc->mem_coherence_exp, 0, 4 ); +#endif return; } @@ -2660,8 +2673,16 @@ void stereoFdCngCoherence_fx( IF( NE_16( last_element_mode, IVAS_CPE_MDCT ) ) { +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + FOR( i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) + { + set32_fx( sts[0]->hFdCngEnc->mem_coherence_fx[i], EPSILON_FX, 4 ); + set16_fx( sts[0]->hFdCngEnc->mem_coherence_exp[i], 0, 4 ); + } +#else set32_fx( sts[0]->hFdCngEnc->mem_coherence_fx, EPSILON_FX, 4 ); set16_fx( sts[0]->hFdCngEnc->mem_coherence_exp, 0, 4 ); +#endif } test(); test(); @@ -2726,8 +2747,96 @@ void stereoFdCngCoherence_fx( pt_fftL = fft_buf_fx[0]; pt_fftR = fft_buf_fx[1]; +#ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG mem = sts[0]->hFdCngEnc->mem_coherence_fx; /* exp(sts[0]->hFdCngEnc->mem_coherence_exp) */ mem_exp = sts[0]->hFdCngEnc->mem_coherence_exp; +#endif + + /* only estimate coherence in inactive frames (or in the first 50 frames to build an initial value) */ + test(); + test(); + // TODO: is there a BASOP for the ! ? + IF( !( LE_32( sts[0]->ini_frame, 50 ) || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) ) ) + { + return; + } + +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + FOR( i_subfr = 0; i_subfr < 2; i_subfr++ ) + { + Word16 band_len_cum; + + band_len_cum = 0; + move16(); + i = MDCT_ST_DTX_FIRST_BAND_OFFSET; + move16(); + + FOR( Word16 b = 0; b < MDCT_ST_DTX_NUM_COHERENCE_BANDS; b++ ) + { + Word16 sqr_inp, temp, sqr_out, sqr_inp_exp; + Word32 sqr_inp32; + band_len_cum += mdct_stereo_dtx_coherence_bandlengths[b]; + move16(); + cr = ci = eL = eR = EPSILON_FX; + move32(); + move32(); + move32(); + move32(); + cr_exp = ci_exp = eL_exp = eR_exp = 0; + move16(); + move16(); + move16(); + move16(); + + mem = sts[0]->hFdCngEnc->mem_coherence_fx[b]; + mem_exp = sts[0]->hFdCngEnc->mem_coherence_exp[b]; + + /* for last band, we need to make adjustments to fit with the FFT buffer layout */ + /* do the calculations for fftbin 0 (not anymore as it is skipped - we only calculate coherence above the 2nd bin) and L_FFT/2 outside the loop - imaginary part is always zero there, but not part of the buffer */ + IF( EQ_16( b, sub( MDCT_ST_DTX_NUM_COHERENCE_BANDS, 1 ) ) ) + { + /* this calculates values for fft bin at L_FFT/2 - no imaginary value there, not even part of the array */ + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ + + /* skip last fft bin (fs/2 Hz) bin in the loop later */ + band_len_cum = sub( band_len_cum, 1 ); + } + + FOR( ; i < band_len_cum; i++ ) + { + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ + } + + mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] ); /* exp(mem_exp[0]) */ + move32(); + mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] ); /* exp(mem_exp[1]) */ + move32(); + mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] ); /* exp(mem_exp[2]) */ + move32(); + mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] ); /* exp(mem_exp[3]) */ + move32(); + + /* could be done outside the loop, as the second assignment overwrites the first, but this would mean a second loop over bands */ + /* For orientation, in float, this is "sts[0]->hFdCngEnc->hFdCngCom->coherence[b] = sqrtf( ( mem[0] * mem[0] + mem[1] * mem[1] ) / ( mem[2] * mem[3] ) );" */ + sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp ); /* exp(sqr_inp_exp) */ + sqr_inp = BASOP_Util_Divide3232_Scale( sqr_inp32, Mpy_32_32( mem[2], mem[3] ), &temp ); + sqr_inp_exp = add( temp, sub( sqr_inp_exp, add( mem_exp[2], mem_exp[3] ) ) ); + sqr_out = Sqrt16( sqr_inp, &sqr_inp_exp ); + + sts[0]->hFdCngEnc->hFdCngCom->coherence_fx[b] = shl_sat( sqr_out, sqr_inp_exp ); // Q15 expected. + move16(); + } + + pt_fftL += L_FFT; + pt_fftR += L_FFT; + } + +#else FOR( i_subfr = 0; i_subfr < 2; i_subfr++ ) { cr = ci = eL = eR = EPSILON_FX; @@ -2769,7 +2878,9 @@ void stereoFdCngCoherence_fx( pt_fftL += L_FFT; pt_fftR += L_FFT; } +#endif +#ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG Word16 sqr_inp, temp, sqr_out, sqr_inp_exp; Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp ); /* exp(sqr_inp_exp) */ sqr_inp = BASOP_Util_Divide3232_Scale( sqr_inp32, Mpy_32_32( mem[2], mem[3] ), &temp ); @@ -2777,6 +2888,7 @@ void stereoFdCngCoherence_fx( sqr_out = Sqrt16( sqr_inp, &sqr_inp_exp ); sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = shl_sat( sqr_out, sqr_inp_exp ); // Q15 expected. move16(); +#endif return; } @@ -3050,7 +3162,11 @@ void FdCngEncodeMDCTStereoSID_fx( } /* quantize channel coherence */ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx[0], 15 ); +#else coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx, 15 ); +#endif coh_idx = s_max( 0, s_min( coh_idx, 15 ) ); /* ---- Write SID bitstream ---- */ @@ -3084,8 +3200,18 @@ void FdCngEncodeMDCTStereoSID_fx( push_indice( sts[ch]->hBstr, IND_ENERGY, gain_idx[ch], 7 ); } +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + /* write the four additional coherence values */ + FOR( Word16 b = 1; b < MDCT_ST_DTX_NUM_COHERENCE_BANDS; b++ ) + { + coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx[b], 15 ); + coh_idx = s_max( 0, s_min( coh_idx, 15 ) ); + push_indice( sts[1]->hBstr, IND_ENERGY, coh_idx, 4 ); + } +#else /* pad with zeros to reach common SID frame size */ push_indice( sts[1]->hBstr, IND_ENERGY, 0, ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC ); +#endif return; } @@ -3289,10 +3415,17 @@ void FdCngEncodeDiracMDCTStereoSID_fx( lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; } +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + sts[0]->hFdCngEnc->hFdCngCom->coherence_fx[0] = 0; + move16(); + sts[1]->hFdCngEnc->hFdCngCom->coherence_fx[0] = 0; + move16(); +#else sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = 0; move16(); sts[1]->hFdCngEnc->hFdCngCom->coherence_fx = 0; move16(); +#endif /* ---- Write SID bitstream ---- */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index e20c06fd4..44125a717 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -397,8 +397,13 @@ typedef struct fd_cng_enc_structure Word16 msLogPeriodog_fx[NPART]; Word16 msLogNoiseEst_fx[NPART]; Word32 msLogNoiseEst_32fx[NPART]; /*IVAS: Q25*/ +#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG + Word32 mem_coherence_fx[MDCT_ST_DTX_NUM_COHERENCE_BANDS][4]; + Word16 mem_coherence_exp[MDCT_ST_DTX_NUM_COHERENCE_BANDS][4]; +#else Word32 mem_coherence_fx[4]; Word16 mem_coherence_exp[4]; +#endif } FD_CNG_ENC, *HANDLE_FD_CNG_ENC; -- GitLab From b041395ab59659487ba88ff677b3052352d19a92 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 22 Oct 2025 16:28:13 +0200 Subject: [PATCH 025/351] use extract_l rather than a cast --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 5285af596..3df9f70e6 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1055,8 +1055,8 @@ void ivas_ism_dec_digest_tc_fx( { /*get HOA gets for direction (ACN/SN3D)*/ #ifdef FIX_2193_ISM_GAINS_WITH_OE - Word16 azi = (Word16) azimuth_fx; // Q0 - Word16 ele = (Word16) elevation_fx; // Q0 + Word16 azi = extract_l( azimuth_fx ); // Q0 + Word16 ele = extract_l( elevation_fx ); // Q0 #else Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 -- GitLab From 93d61051979ff70dbe855791c12a0cea18d152ab Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 20 Oct 2025 14:14:33 +0200 Subject: [PATCH 026/351] Improve documentation comments for TD ring buffer --- lib_rend/ivas_stat_rend.h | 4 ++-- lib_rend/ivas_td_ring_buffer_fx.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 48e3dd349..3c38267b7 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1436,8 +1436,8 @@ typedef struct typedef struct { - Word32 *data; /* samples in interleaved layout */ - UWord32 capacity; + Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ + UWord32 capacity; /* max number of Word32 values that can be stored */ UWord16 num_channels; UWord32 write_pos; UWord32 read_pos; diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 0660bc506..23ef8e323 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -44,6 +44,12 @@ * Local function prototypes *-----------------------------------------------------------------------*/ +/*---------------------------------------------------------------------* + * ivas_td_ringbuf_total_size() + * + * Returns total number of buffered samples (including number of channels) + *---------------------------------------------------------------------*/ + static UWord32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { -- GitLab From 58a65585fc58f3f482905ee9ccdfce86320d36a0 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 23 Oct 2025 11:03:33 +0200 Subject: [PATCH 027/351] apply some review suggestions --- lib_rend/ivas_td_ring_buffer_fx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 23ef8e323..4e82dcb8b 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -113,14 +113,15 @@ ivas_error ivas_TD_RINGBUF_Open( UWord32 capacity; // TODO: how to integer multiplication 32 x 16 ? - capacity = L_mult0( capacity_per_channel, num_channels ); + capacity = Mult_32_16( capacity_per_channel, num_channels ); h = malloc( sizeof( TD_RINGBUF_DATA ) ); IF( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } - // TODO: move for pointer assignment? + + move32(); h->data = NULL; move32(); h->capacity = 0; @@ -132,7 +133,7 @@ ivas_error ivas_TD_RINGBUF_Open( h->read_pos = 0; move16(); h->is_full = 0; - // TODO: move for pointer assignment? + move32(); *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); @@ -165,7 +166,8 @@ void ivas_TD_RINGBUF_Close( { return; } - // TODO: move for pointer assignment? + + move32(); h = *ph; IF( h == NULL ) @@ -202,8 +204,7 @@ void ivas_TD_RINGBUF_Push( UWord32 s; UWord16 c; - // TODO: integer multiplication for 32 * 16? - assert( ivas_td_ringbuf_has_space_for_num_samples( h, L_mult0( num_samples_per_channel, h->num_channels ) ) ); + assert( ivas_td_ringbuf_has_space_for_num_samples( h, Mult_32_16( num_samples_per_channel, h->num_channels ) ) ); FOR( s = 0; s < num_samples_per_channel; ++s ) { @@ -215,7 +216,7 @@ void ivas_TD_RINGBUF_Push( shift_val = L_mult0( c, num_samples_per_channel ); shift_val = L_add( s, shift_val ); - // TODO: move for pointer assignment? + move32(); h->data[h->write_pos] = *( data + shift_val ); ++h->write_pos; @@ -251,8 +252,7 @@ void ivas_TD_RINGBUF_PushZeros( UWord32 s; UWord16 c; - // TODO: integer multiplication for 32 * 16? - assert( ivas_td_ringbuf_has_space_for_num_samples( h, L_mult0( num_samples_per_channel, h->num_channels ) ) ); + assert( ivas_td_ringbuf_has_space_for_num_samples( h, Mult_32_16( num_samples_per_channel, h->num_channels ) ) ); IF( EQ_32( num_samples_per_channel, 0 ) ) { return; @@ -262,7 +262,7 @@ void ivas_TD_RINGBUF_PushZeros( { FOR( c = 0; c < h->num_channels; ++c ) { - // TODO: move for pointer assignment? + move32(); h->data[h->write_pos] = 0; ++h->write_pos; -- GitLab From 9a409126e4b9cf3c2bf9409821d135f00723277b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 23 Oct 2025 11:07:07 +0200 Subject: [PATCH 028/351] apply some more review suggestions --- lib_rend/ivas_td_ring_buffer_fx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 4e82dcb8b..6e34ab31c 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -112,7 +112,6 @@ ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE h; UWord32 capacity; - // TODO: how to integer multiplication 32 x 16 ? capacity = Mult_32_16( capacity_per_channel, num_channels ); h = malloc( sizeof( TD_RINGBUF_DATA ) ); @@ -181,8 +180,8 @@ void ivas_TD_RINGBUF_Close( } free( h ); - // TODO: move for pointer assignment? *ph = NULL; + move32(); return; } @@ -300,8 +299,7 @@ void ivas_TD_RINGBUF_Pop( UWord16 c; Word32 requested_samples; - // TODO - requested_samples = L_mult0( num_samples_per_channel, h->num_channels ); + requested_samples = Mult_32_16( num_samples_per_channel, h->num_channels ); assert( GE_32( ivas_td_ringbuf_total_size( h ), requested_samples ) ); FOR( s = 0; s < num_samples_per_channel; ++s ) -- GitLab From fe30503151ba136db73fa6bd5e03d08ec163d558 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 23 Oct 2025 14:09:27 +0200 Subject: [PATCH 029/351] run clang-format --- lib_dec/fd_cng_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index f79766af3..6759e0145 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2934,7 +2934,7 @@ void generate_comfort_noise_dec_ivas_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG c1 = Sqrt16( hFdCngCom->coherence_fx[0], &temp ); /*Q15 - temp*/ #else - c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ + c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ #endif c1 = shl( c1, temp ); /*Q15*/ temp = 0; @@ -3737,7 +3737,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG c1 = Sqrt16( hFdCngCom->coherence_fx[sub( MDCT_ST_DTX_NUM_COHERENCE_BANDS, 1 )], &s ); /*Q15 - s*/ #else - c1 = Sqrt16( hFdCngCom->coherence_fx, &s ); /*Q15 - s*/ + c1 = Sqrt16( hFdCngCom->coherence_fx, &s ); /*Q15 - s*/ #endif c1 = shl( c1, s ); // Q15 -- GitLab From b88eae79d9c829965cda32a8f0919ff0015d2123 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 23 Oct 2025 17:45:36 +0300 Subject: [PATCH 030/351] Adds missing pieces of port 408 for BASOP main. --- lib_dec/ivas_jbm_dec_fx.c | 17 +++++++ .../ivas_dirac_dec_binaural_functions_fx.c | 48 +++++++++---------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3e171a8de..4b9194c45 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4598,6 +4598,23 @@ void ivas_dec_prepare_renderer_fx( move16(); } +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + test(); + test(); + IF ( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32(st_ivas->renderer_type, RENDERER_DIRAC) ) + { + /* Gain MASA part, if edited */ + IF ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + { + FOR ( n = 0; n < CPE_CHANNELS; n++ ) + { + v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); + Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 + } + } + } +#endif + FOR( n = 0; n < nchan_transport_ism; n++ ) { test(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0539b7b85..53659db0b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5383,7 +5383,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* MASA gaining */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { IF( masaGainEdited ) { @@ -5420,7 +5420,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move16(); /* Use diagonal mixing matrix as the instant mixing matrix, to slowly fade away the editing during dtx */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { ismPreprocMtxNew[ch][ch] = ONE_IN_Q28; move32(); @@ -5462,7 +5462,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move16(); FOR( slot = 0; slot < nSlots; slot++ ) { - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( bin = bin_lo; bin < bin_hi; bin++ ) { @@ -5481,9 +5481,9 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* Get increment value for temporal interpolation */ - FOR( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < BINAURAL_CHANNELS; inCh++ ) { - FOR( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < BINAURAL_CHANNELS; outCh++ ) { temp = L_sub( ismPreprocMtxNew[outCh][inCh], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q28 ismPreprocMtxIncrement[outCh][inCh] = L_shr( temp, 2 ); // Divide by 4 @@ -5501,11 +5501,11 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( hMasaIsmData->preprocEneTarget_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->preprocEneTarget_fx[band_idx], hMasaIsmData->preprocEneTarget_e[band_idx], totalTargetEne, totalTargetEne_e, &hMasaIsmData->preprocEneTarget_e[band_idx] ); // Q = 31-preprocEneTarget_e move32(); - FOR( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < BINAURAL_CHANNELS; outCh++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { - FOR( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < BINAURAL_CHANNELS; inCh++ ) { hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] = L_add( hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx], ismPreprocMtxIncrement[outCh][inCh] ); // Q28 @@ -5564,7 +5564,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); } - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { @@ -5666,7 +5666,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( ELSE { /* When not edited, input and output pan gains are the same */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { panGainsOut[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch]; move16(); @@ -5674,7 +5674,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* Determine pan enes */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { panEnesOut[ismDirIndex][ch] = mult( panGainsOut[ismDirIndex][ch], panGainsOut[ismDirIndex][ch] ); // Q15 move16(); @@ -5704,14 +5704,14 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* Init out array */ - FOR( Word16 k = 0; k < nSlots; k++ ) + FOR( slot = 0; slot < nSlots; slot++ ) { FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - set_zero_fx( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); - set_zero_fx( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( outSlotRe[ch][slot], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( outSlotIm[ch][slot], CLDFB_NO_CHANNELS_MAX ); - norm = s_min( L_norm_arr( inRe_fx[ch][k], nBins ), L_norm_arr( inIm_fx[ch][k], nBins ) ); + norm = s_min( L_norm_arr( inRe_fx[ch][slot], nBins ), L_norm_arr( inIm_fx[ch][slot], nBins ) ); shift = s_min( norm, shift ); } } @@ -5762,7 +5762,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move16(); /* Determine transport normalized energies and subframe energy */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { @@ -5985,7 +5985,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( /* Calculate MASA target energies and add to total target energy estimation */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { /* MASA original energy per channel */ masaEneThisCh[ch] = L_max( masaEneThisCh[ch], 0 ); // Q5 @@ -6167,7 +6167,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } } - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { eneMoveThis = s_max( 0, sub( panEnesIn[ismDirIndex][ch], panEnesOut[ismDirIndex][ch] ) ); // Q15 move16(); @@ -6197,7 +6197,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( remainderNormEne = L_max( 0, temp ); // Q25 /* Normalize */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { temp = L_shr( remainderNormEne, 1 ); // Division by 2, Q25 temp = L_add( normEnes[ch], temp ); // Q25 @@ -6233,7 +6233,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( /* Temporally average energy moving and preserving, and generate the transport signal preprocessing matrix for * gaining objects and moving objects between left and right */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = Mpy_32_16_1( hMasaIsmData->eneMoveIIR_fx[ch][band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = Enemove_Q + 15 + 1 -16 = Enemove_Q move32(); @@ -6320,9 +6320,9 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* Get increment value for temporal interpolation */ - FOR( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < BINAURAL_CHANNELS; inCh++ ) { - FOR( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < BINAURAL_CHANNELS; outCh++ ) { temp = L_sub( ismPreprocMtxNew[outCh][inCh], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q28 ismPreprocMtxIncrement[outCh][inCh] = L_shr( temp, 2 ); // Divide by 4 @@ -6340,11 +6340,11 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( hMasaIsmData->preprocEneTarget_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->preprocEneTarget_fx[band_idx], hMasaIsmData->preprocEneTarget_e[band_idx], totalTargetEne, sub( Q31, subQ ), &hMasaIsmData->preprocEneTarget_e[band_idx] ); // Q = 31-preprocEneTarget_e move32(); - FOR( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < BINAURAL_CHANNELS; outCh++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { - FOR( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < BINAURAL_CHANNELS; inCh++ ) { hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] = L_add( hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx], ismPreprocMtxIncrement[outCh][inCh] ); // Q28 move32(); @@ -6403,7 +6403,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); } - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { -- GitLab From b72b0307f7419b393d5dc6969ac11f39836917fa Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 23 Oct 2025 18:13:03 +0300 Subject: [PATCH 031/351] Add one minor missing bit and format. --- lib_dec/ivas_jbm_dec_fx.c | 6 +++--- lib_dec/ivas_omasa_dec_fx.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 4b9194c45..b67c7478e 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4601,12 +4601,12 @@ void ivas_dec_prepare_renderer_fx( #ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES test(); test(); - IF ( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32(st_ivas->renderer_type, RENDERER_DIRAC) ) + IF( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) { /* Gain MASA part, if edited */ - IF ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + FOR( n = 0; n < CPE_CHANNELS; n++ ) { v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 811935a60..c562d7df6 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1114,7 +1114,7 @@ void ivas_omasa_dirac_rend_jbm_fx( /* Gain MASA part, if edited */ IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { - FOR( n = 0; n < 2; n++ ) + FOR( n = 0; n < CPE_CHANNELS; n++ ) { v_multc_fx_16( output_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_fx[n], *nSamplesRendered ); // Q = 8 Scale_sig32( output_fx[n], *nSamplesRendered, Q3 ); // Q = 11 -- GitLab From 5025ccf806cfa376c90fff55bdf2f2ef739c4cff Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 24 Oct 2025 16:10:21 +0300 Subject: [PATCH 032/351] Port float MR 2246 to BASOP main --- lib_com/options.h | 1 + lib_rend/ivas_dirac_ana_fx.c | 24 +++++++++++------ lib_rend/ivas_masa_merge_fx.c | 26 ++++++++++++++++++ lib_rend/ivas_mcmasa_ana_fx.c | 50 +++++++++++++++++++++++++++++++++++ lib_rend/ivas_omasa_ana_fx.c | 8 ++++++ lib_rend/ivas_prot_rend_fx.h | 11 ++++++++ lib_rend/ivas_stat_rend.h | 5 ++++ lib_rend/lib_rend_fx.c | 11 ++++++++ 8 files changed, 128 insertions(+), 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0e364d2b8..741833851 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -117,6 +117,7 @@ #define FIX_RENDERER_STACK /* VA: issue 1322: reduction of renderers' buffers size */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define NONBE_FIX_1197_OMASA_META_BUFFER /* Nokia: OMASA ISM_MASA_MODE_PARAM_ONE_OBJ history zero in rateswitching - port 251 */ +#define NONBE_1344_REND_MASA_LOW_FS /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 502f4f5ae..37150a6da 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -250,16 +250,24 @@ void ivas_dirac_ana_fx( const Word16 nchan_transport, /* i : Number of transport channels */ const Word16 data_q ) { - Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Estimate MASA parameters from the SBA signals */ - ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame, data_q ); - /* Create MASA metadata buffer from the estimated values */ + ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, input_frame, data_q ); - ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, Q31, Q31, Q31 ); +#ifdef NONBE_1344_REND_MASA_LOW_FS + /* Add zeros to higher bands in case of lower sampling rates */ + IF( LT_16( hDirAC->nbands, MASA_FREQUENCY_BANDS ) ) + { + ivas_masa_zero_high_bands_fx( hDirAC->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx ); + } +#endif + + /* Create MASA metadata buffer from the estimated values */ + ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 ); /* Downmix */ ivas_dirac_dmx_fx( data_fx, input_frame, nchan_transport ); // output Q of data_fx is same as that of input diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 432ed8253..94e0325ae 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -37,6 +37,9 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" +#ifdef NONBE_1344_REND_MASA_LOW_FS +#include "ivas_rom_com.h" +#endif #include "ivas_prot_fx.h" #define INV_UINT8_MAX 8421505 /* 1/UINT8_MAX in Q31 */ @@ -487,6 +490,9 @@ ivas_error masaPrerendOpen_fx( { MASA_PREREND_HANDLE hMasaPrerend; Word16 i; +#ifdef NONBE_1344_REND_MASA_LOW_FS + Word16 maxBin; +#endif ivas_error error; error = IVAS_ERR_OK; @@ -498,6 +504,26 @@ ivas_error masaPrerendOpen_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA prerenderer\n" ) ); } +#ifdef NONBE_1344_REND_MASA_LOW_FS + /* Determine the number of bands and band grouping */ + hMasaPrerend->nbands = MASA_FREQUENCY_BANDS; + move16(); + mvs2s( MASA_band_grouping_24, hMasaPrerend->band_grouping, MASA_FREQUENCY_BANDS + 1 ); + + maxBin = extract_l( Mpy_32_32( input_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ); /* Q0 */ + FOR( i = 1; i < hMasaPrerend->nbands + 1; i++ ) + { + IF( GE_16(hMasaPrerend->band_grouping[i], maxBin) ) + { + hMasaPrerend->band_grouping[i] = maxBin; + move16(); + hMasaPrerend->nbands = i; + move16(); + break; + } + } +#endif + hMasaPrerend->num_Cldfb_instances = numTransports; move16(); FOR( i = 0; i < hMasaPrerend->num_Cldfb_instances; i++ ) diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index dbaf5b7d9..c4c271dcb 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -486,6 +486,14 @@ void ivas_mcmasa_ana_fx( /* Analysis */ ivas_mcmasa_param_est_ana_fx( hMcMasa, data, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, q_data, input_frame, nchan_inp ); +#ifdef NONBE_1344_REND_MASA_LOW_FS + /* Add zeros to higher bands in case of lower sampling rates */ + IF( LT_16( hMcMasa->nbands, MASA_FREQUENCY_BANDS ) ) + { + ivas_masa_zero_high_bands_fx( hMcMasa->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx ); + } +#endif + /* Create MASA metadata buffer from the estimated values */ ivas_create_masa_out_meta_fx( hMcMasa->hMasaOut, hMcMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 ); @@ -1703,3 +1711,45 @@ void ivas_create_masa_out_meta_fx( return; } + + + + +#ifdef NONBE_1344_REND_MASA_LOW_FS +/*------------------------------------------------------------------------- + * ivas_masa_zero_high_bands() + * + * + *------------------------------------------------------------------------*/ + +void ivas_masa_zero_high_bands_fx( + const Word16 nbands, /* i : Number of frequency bands with estimated values */ + Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated elevation */ + Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated azimuth */ + Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated direct-to-total ratio */ + Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated spread coherence */ + Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i/o : Estimated surround coherence */ +) +{ + Word16 sf, band; + + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + FOR( band = nbands; band < MASA_FREQUENCY_BANDS; band++ ) + { + elevation_m_values_fx[sf][band] = 0; + move32(); + azimuth_m_values_fx[sf][band] = 0; + move32(); + energyRatio_fx[sf][band] = 0; + move32(); + spreadCoherence_fx[sf][band] = 0; + move32(); + surroundingCoherence_fx[sf][band] = 0; + move32(); + } + } + + return; +} +#endif diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index e441b3596..898264c8f 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -318,6 +318,14 @@ void ivas_omasa_ana_fx( /* Estimate MASA parameters from the objects */ ivas_omasa_param_est_ana_fx( hOMasa, data_in_f_fx, *data_in_q, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, &energyRatio_q, spreadCoherence_fx, &spreadCoherence_q, surroundingCoherence_fx, &sorroundingCoherence_q, input_frame, nchan_ism ); +#ifdef NONBE_1344_REND_MASA_LOW_FS + /* Add zeros to higher bands in case of lower sampling rates */ + IF( LT_16( hOMasa->nbands, MASA_FREQUENCY_BANDS ) ) + { + ivas_masa_zero_high_bands_fx( hOMasa->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx ); + } +#endif + /* Create MASA metadata buffer from the estimated values */ ivas_create_masa_out_meta_fx( hOMasa->hMasaOut, hOMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 ); diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 250fea751..964977239 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1489,6 +1489,17 @@ void ivas_create_masa_out_meta_fx( Word16 surroundingCoherence_q ); +#ifdef NONBE_1344_REND_MASA_LOW_FS +void ivas_masa_zero_high_bands_fx( + const Word16 nbands, /* i : Number of frequency bands with estimated values */ + Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated elevation */ + Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated azimuth */ + Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated direct-to-total ratio */ + Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated spread coherence */ + Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i/o : Estimated surround coherence */ +); +#endif + ivas_error ivas_dirac_ana_open_fx( DIRAC_ANA_HANDLE *hDirACPtr, /* i/o: DIRAC data handle pointer */ Word32 input_Fs diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index aec8eb3b9..f62bee930 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1681,6 +1681,11 @@ typedef struct ivas_dirac_ana_data_structure typedef struct ivas_masa_prerend_data_structure { +#ifdef NONBE_1344_REND_MASA_LOW_FS + Word16 nbands; + Word16 band_grouping[MASA_FREQUENCY_BANDS + 1]; +#endif + /* CLDFB analysis */ Word16 num_Cldfb_instances; HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[MASA_MAX_TRANSPORT_CHANNELS]; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 5827cc275..ad12c9e9f 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8193,12 +8193,23 @@ static void renderMasaToMasa( Word16 q_add = sub( 31, add( scale_factor, q_cldfb_out ) ); /* Compute channel energy for metadata processing */ +#ifdef NONBE_1344_REND_MASA_LOW_FS + FOR( band_m_idx = 0; band_m_idx < masaInput->hMasaPrerend->nbands; band_m_idx++ ) +#else FOR( band_m_idx = 0; band_m_idx < MASA_FREQUENCY_BANDS; band_m_idx++ ) +#endif { +#ifdef NONBE_1344_REND_MASA_LOW_FS + brange[0] = masaInput->hMasaPrerend->band_grouping[band_m_idx]; + move16(); + brange[1] = masaInput->hMasaPrerend->band_grouping[band_m_idx + 1]; + move16(); +#else brange[0] = MASA_band_grouping_24[band_m_idx]; move16(); brange[1] = MASA_band_grouping_24[band_m_idx + 1]; move16(); +#endif FOR( j = brange[0]; j < brange[1]; j++ ) { FOR( i = 0; i < numAnalysisChannels; i++ ) -- GitLab From db0cb169ab65b15539233812465f6d140fc43692 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 13 Oct 2025 18:26:41 +0200 Subject: [PATCH 033/351] Port some formatting and documentation changes that were omitted in port 171 of float MR 1527 Not all changes from the original MR were ported, which makes porting following MRs more difficult than it should be. This commit ports some of the missing changes in preparation for work on port 391: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/issues/2102 Original float MR: https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/merge_requests/1527 Incomplete port to BASOP main: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/merge_requests/1977 --- lib_isar/isar_prot.h | 320 +++++++++++++++++++++++-------------------- 1 file changed, 168 insertions(+), 152 deletions(-) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index d2db09359..ca02665b4 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -33,7 +33,6 @@ #ifndef ISAR_PROT_H #define ISAR_PROT_H - #include "isar_stat.h" #include #include "options.h" @@ -42,19 +41,59 @@ #include "enh64.h" /* clang-format off */ +/*----------------------------------------------------------------------------------* + * General ISAR prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error isar_splitBinPreRendOpen( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, /* i/o: binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , + const Word32 output_Fs +#endif +); + +ivas_error split_renderer_open_lc3plus( + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const Word32 output_Fs, /* i : output sampling rate */ + const IVAS_RENDER_FRAMESIZE ivas_frame_size /* i : IVAS frame size */ +); + +void isar_splitBinPreRendClose( + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ +); + +void lc3plusTimeAlignCldfbPoseCorr( + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, imag. part */ + Word16 *Q_in +); + +ivas_error splitRendLc3plusEncodeAndWrite( + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const Word32 available_bits, /* i : available bit-budget */ + Word32 *in[], /* i/o: PCM in/out buffer */ + Word16 Q_sig +); +/*! r: parameter value */ Word32 ISAR_SPLIT_REND_BITStream_read_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 bits ); + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const Word32 bits /* i : number of bits to be read */ +); void ISAR_SPLIT_REND_BITStream_write_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 val, - const Word32 bits + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const Word32 val, /* i : parameter value */ + const Word32 bits /* i : number of bits to be written */ ); ivas_error isar_splitBinLCLDEncOpen( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, /* o : ISAR LCLD encoder handle */ const Word32 iSampleRate, const Word16 iChannels, const Word32 iDataRate, @@ -63,15 +102,16 @@ ivas_error isar_splitBinLCLDEncOpen( ); ivas_error isar_splitBinRendPLCOpen( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, - const Word16 iNumSubSets ); + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, /* i/o: ISAR PLC handle */ + const Word16 iNumSubSets +); void isar_splitBinRendPLCClose( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC /* i/o: ISAR PLC handle */ ); ivas_error isar_splitBinLCLDDecOpen( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ const Word32 iSampleRate, const Word16 iChannels, const Word16 iNumBlocks, @@ -79,7 +119,7 @@ ivas_error isar_splitBinLCLDDecOpen( ); void isar_splitBinLCLDDecClose( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec /* o : ISAR LCLD decoder handle */ ); void isar_splitBinRendPLCsaveState( @@ -126,47 +166,38 @@ void isar_log_cldfb2wav_data( const Word16 md_band_idx, const char *filename ); -#endif - -void isar_SplitRenderer_PostRenderer( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - const IVAS_QUATERNION Quaternion_act, - Word16 *Q_in -); +#endif void isar_splitBinLCLDDecProcess( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - Word32 Cldfb_Out_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_Out_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + Word32 Cldfb_Out_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + Word32 Cldfb_Out_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ Word16 *Q_cldfb_final, - const Word16 bfi + const Word16 bfi /* i : BFI flag */ ); void set_fix_rotation_mat_fx( Word32 fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ ); void isar_splitBinLCLDEncClose( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc /* i/o: ISAR LCLD encoder handle */ ); void isar_splitBinLCLDEncProcess( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word32 available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ Word16 *q_final ); void set_pose_types_fx( - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1],/* o : ISAR pose type */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ ); void isar_split_rend_init_huff_cfg( @@ -174,13 +205,13 @@ void isar_split_rend_init_huff_cfg( ); ivas_error isar_splitBinPostRendOpen( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const Word32 output_Fs + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const Word32 output_Fs /* i : output sampling rate */ ); void isar_splitBinPostRendClose( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend /* i/o: binaural post-renderer handle */ ); void isar_SplitRenderer_getdiagdiff( @@ -191,18 +222,6 @@ void isar_SplitRenderer_getdiagdiff( const Word16 max_val ); -void isar_renderSplitGetMultiBinPoseData_fx( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const ISAR_SPLIT_REND_ROT_AXIS rot_axis -); - -void isar_renderSplitGetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const ISAR_SPLIT_REND_ROT_AXIS rot_axis -); - void isar_split_rend_get_quant_params_fx( const Word16 num_md_bands, Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], @@ -219,20 +238,20 @@ void isar_split_rend_get_quant_params_fx( ); void isar_splitBinPostRendMdDec_fx( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , - BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ #endif ); void Quat2EulerDegree( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ ); void isar_mat_mult_2by2_complex_fx( @@ -251,8 +270,8 @@ void isar_mat_mult_2by2_complex_fx( ); void isar_rend_CldfbSplitPostRendProcess( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION QuaternionPost, Word32 Cldfb_RealBuffer_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_ImagBuffer_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -262,14 +281,6 @@ void isar_rend_CldfbSplitPostRendProcess( const Word16 cldfb_in_flag ); -void isar_init_multi_bin_pose_data_fx( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); - -/* Copy for encoder, to be removed */ -void isar_init_multi_bin_pose_data_fx_enc( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData -); - void isar_rend_CldfbSplitPreRendProcess( const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, const IVAS_QUATERNION headPosition, @@ -284,6 +295,32 @@ void isar_rend_CldfbSplitPreRendProcess( const Word16 ro_md_flag ); +ivas_error isar_renderMultiTDBinToSplitBinaural( + SPLIT_REND_WRAPPER *hSplitBin, + const IVAS_QUATERNION headPosition, + const Word32 SplitRendBitRate, + const Word16 isar_frame_size_ms, + const Word16 codec_frame_size_ms, + ISAR_SPLIT_REND_BITS_HANDLE pBits, + const Word16 max_bands, + // float *in[], + Word32 *in_fx[], // Q11 + Word16 Q_sig, + const Word16 low_res_pre_rend_rot, + const Word16 pcm_out_flag, + const Word16 ro_md_flag +); + +void isar_init_multi_bin_pose_data_fx( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); + +void isar_renderSplitGetMultiBinPoseData_fx( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +); + Word16 isar_renderSplitGetRot_axisNumBits( const Word16 dof ); @@ -300,86 +337,56 @@ Word16 isar_renderSplitGetCodeFromRot_axis( ); void isar_init_split_post_rend_handles( - ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ); - -ivas_error isar_splitBinPreRendOpen( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const Word32 output_Fs -#else - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData -#endif -); - -void isar_splitBinPreRendClose( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer post-renderer handle */ ); void isar_set_split_rend_ht_setup_fx( - SPLIT_REND_WRAPPER *hSplitrend, - IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], - Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] + SPLIT_REND_WRAPPER *hSplitrend, /* i/o: Split renderer pre-renderer handle */ + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], /* i/o: External orientation in quaternions */ + Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] /* o : real-space rotation matrix */ ); Word32 isar_get_lc3plus_bitrate( - const Word32 SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const Word32 nChannels, - const Word32 codecFrameDurationUs ); + const Word32 SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const Word32 nChannels, /* i : number of channels */ + const Word32 lc3plus_frame_duration_us /* i : ISAR frame length in us */ +); ivas_error isar_split_rend_validate_config( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const Word16 is_pcm_out + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const Word16 is_pcm_out /* i : flag to indicate PCM output */ ); +/*! r: LCLD codec bitrate */ Word32 isar_get_lcld_bitrate( - const Word32 SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode + const Word32 SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode /* i : ISAR pose correction mode */ ); -ivas_error splitRendLc3plusEncodeAndWrite( - SPLIT_REND_WRAPPER *hSplitBin, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 available_bits, - Word32 *in[], - Word16 Q_sig +/*! r: ISAR MD bitrate */ +Word32 isar_get_split_rend_md_target_brate( + const Word32 SplitRendBitRate, /* i : ISAR bitrate */ + const Word16 pcm_out_flag /* i : flag to indicate PCM output */ ); ivas_error isar_framesize_to_ms( - const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ - Word16 *ms /* o : frame size in ms */ -); - -Word32 isar_get_split_rend_md_target_brate( - const Word32 SplitRendBitRate, - const Word16 pcm_out_flag + const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ + Word16 *ms /* o : frame size in ms */ ); ivas_error isar_split_rend_choose_default_codec( - ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ - Word16 *pIsar_frame_size_ms, /* i/o: pointer to ISAR frame size setting */ - Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ - const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ - const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ - const Word16 num_subframes /* i : number of subframes */ -); - -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 buf_len_bytes, - UWord8 *pbuf -); - -Word16 wrap_a( - Word16 val, - const Word16 min_val, - const Word16 max_val + ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ + Word16 *pIsar_frame_size_ms, /* i/o: pointer to ISAR frame size setting */ + Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ + const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ + const Word16 num_subframes /* i : number of subframes */ ); void isar_renderSplitUpdateNoCorrectionPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ ); Word32 get_bit( @@ -387,44 +394,53 @@ Word32 get_bit( const Word32 bit_id ); -ivas_error split_renderer_open_lc3plus( - SPLIT_REND_WRAPPER *hSplitRendWrapper, - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const Word32 OutSampleRate, - const IVAS_RENDER_FRAMESIZE ivas_frame_size -); - +/*! r: ISAR audio type */ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( - const IVAS_AUDIO_CONFIG config + const IVAS_AUDIO_CONFIG config /* i : audio configuration */ ); void isar_init_split_rend_handles( - SPLIT_REND_WRAPPER *hSplitRendWrapper + SPLIT_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer pre-renderer handle */ ); -ivas_error isar_renderMultiTDBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, - const Word32 SplitRendBitRate, - const Word16 isar_frame_size_ms, - const Word16 codec_frame_size_ms, +// UNUSED +void ISAR_SPLIT_REND_BITStream_init( ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word16 max_bands, - // float *in[], - Word32 *in_fx[], // Q11 - Word16 Q_sig, - const Word16 low_res_pre_rend_rot, - const Word16 pcm_out_flag, - const Word16 ro_md_flag + const Word32 buf_len_bytes, + UWord8 *pbuf ); -void lc3plusTimeAlignCldfbPoseCorr( - SPLIT_REND_WRAPPER *hSplitBin, - Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 *Q_in +/*----------------------------------------------------------------------------------* + * BASOP-only + *----------------------------------------------------------------------------------*/ + +/* Copy for encoder, to be removed */ +void isar_init_multi_bin_pose_data_fx_enc( + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData +); + + +Word16 wrap_a( + Word16 val, + const Word16 min_val, + const Word16 max_val ); +void isar_renderSplitGetMultiBinPoseData( + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_SPLIT_REND_ROT_AXIS rot_axis +); + + +void isar_SplitRenderer_PostRenderer( + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + const IVAS_QUATERNION Quaternion_act, + Word16 *Q_in +); void ivas_cmult_fix( Word32 in1_re_fx, -- GitLab From 9f8fb15fc4f67c95c90fda23a2e6a1540af1c8ee Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 22 Oct 2025 12:58:34 +0200 Subject: [PATCH 034/351] [WIP] Port split rendering support in VoIP mode --- Workspace_msvc/lib_rend.vcxproj | 1 + Workspace_msvc/lib_rend.vcxproj.filters | 3 + apps/decoder.c | 129 ++- apps/isar_post_rend.c | 13 + lib_com/ivas_prot_fx.h | 38 + lib_com/options.h | 4 +- lib_dec/ivas_dirac_dec_fx.c | 16 +- lib_dec/ivas_init_dec_fx.c | 5 + lib_dec/ivas_jbm_dec_fx.c | 17 + lib_dec/ivas_mc_param_dec_fx.c | 8 + lib_dec/ivas_mc_paramupmix_dec_fx.c | 8 + lib_dec/ivas_omasa_dec_fx.c | 11 + lib_dec/ivas_osba_dec_fx.c | 16 +- lib_dec/ivas_output_config_fx.c | 12 + lib_dec/ivas_stat_dec.h | 18 +- lib_dec/lib_dec.h | 20 + lib_dec/lib_dec_fx.c | 740 +++++++++++++++++- lib_isar/isar_prot.h | 34 +- lib_isar/isar_splitRend_lcld_enc.c | 9 +- lib_isar/isar_splitRendererPre.c | 137 +++- lib_isar/isar_stat.h | 12 + lib_isar/lib_isar_pre_rend.c | 55 +- lib_isar/lib_isar_pre_rend.h | 5 + lib_rend/ivas_cldfb_ring_buffer.c | 321 ++++++++ .../ivas_dirac_dec_binaural_functions_fx.c | 16 + lib_rend/ivas_prot_rend_fx.h | 62 ++ lib_rend/ivas_stat_rend.h | 16 + lib_rend/ivas_td_ring_buffer.c | 448 +++++++++++ lib_rend/lib_rend_fx.c | 27 +- 29 files changed, 2121 insertions(+), 80 deletions(-) create mode 100644 lib_rend/ivas_cldfb_ring_buffer.c create mode 100644 lib_rend/ivas_td_ring_buffer.c diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index c39806d47..db791e067 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -138,6 +138,7 @@ + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 2494e2ee2..0892a4dcb 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -109,6 +109,9 @@ rend_c + + rend_c + rend_c diff --git a/apps/decoder.c b/apps/decoder.c index dfebd7392..a04eb819d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -163,7 +163,11 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); #ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#else static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#endif #else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); @@ -655,7 +659,11 @@ int main( if ( arg.voipMode ) { #ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); +#else error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hIvasDec, pcmBuf ); +#endif #else error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); #endif @@ -1755,7 +1763,11 @@ static ivas_error initOnFirstGoodFrame( for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( isSplitRend ) +#else if ( *splitRendWriter != NULL ) +#endif { ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero; splitRendBitsZero.bits_buf = NULL; @@ -1773,7 +1785,12 @@ static ivas_error initOnFirstGoodFrame( return error; } } + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( !isSplitCoded ) +#else else +#endif { if ( *pRemainingDelayNumSamples < *numOutSamples ) { @@ -1984,6 +2001,14 @@ static ivas_error decodeG192( return error; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( !isSplitRend ) + { + /* Ensure split rendering output struct is not used when not outputting to a split rendering output configuration */ + splitRendBits = NULL; + } +#endif + if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); @@ -2245,7 +2270,11 @@ static ivas_error decodeG192( } /* decode transport channels, do TSM and feed to renderer */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2700,6 +2729,9 @@ static ivas_error decodeVoIP( Vector3PairFileReader *referenceVectorReader, #ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE ObjectEditFileReader *objectEditFileReader, +#endif +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, #endif IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ) @@ -2750,6 +2782,29 @@ static ivas_error decodeVoIP( bool parametersAvailableForEditing = false; uint16_t nSamplesRendered; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + SplitFileReadWrite *splitRendWriter = NULL; + int16_t isSplitRend, isSplitCoded; + + 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 ); + return error; + } + + if ( !isSplitRend ) + { + /* Ensure split rendering output struct is not used when not outputting to a split rendering format */ + splitRendBits = NULL; + } + + if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); + return error; + } +#endif + vec_pos_update = 0; if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK ) { @@ -3047,6 +3102,22 @@ static ivas_error decodeVoIP( /* decode and get samples */ while ( nSamplesRendered < nOutSamples ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( isSplitRend ) + { +#ifdef SUPPORT_JBM_TRACEFILE + if ( ( error = IVAS_DEC_VoIP_GetSplitBinauralBitstream( hIvasDec, (void *) pcmBuf, splitRendBits, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSplitBinauralBitstream( hIvasDec, (void *) pcmBuf, splitRendBits, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + else + { +#endif #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else @@ -3056,6 +3127,9 @@ static ivas_error decodeVoIP( fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + } +#endif if ( bitstreamReadDone == true ) { @@ -3143,9 +3217,15 @@ static ivas_error decodeVoIP( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifndef FIX_1119_SPLIT_RENDERING_VOIP SplitFileReadWrite *splitRendWriter = NULL; +#endif +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, +#else if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, +#endif &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) { goto cleanup; @@ -3160,19 +3240,35 @@ static ivas_error decodeVoIP( /* Write current frame */ if ( decodedGoodFrame ) { - if ( delayNumSamples < nOutSamples ) +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( isSplitRend ) { - if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) + if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nOutput audio file writer error\n" ); + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); goto cleanup; } - delayNumSamples = 0; } - else + + if ( !isSplitCoded ) { - delayNumSamples -= nOutSamples; +#endif + if ( delayNumSamples < nOutSamples ) + { + if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + goto cleanup; + } + delayNumSamples = 0; + } + else + { + delayNumSamples -= nOutSamples; + } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP } +#endif /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) @@ -3272,7 +3368,11 @@ static ivas_error decodeVoIP( goto cleanup; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( nSamplesFlushed && !isSplitCoded ) +#else if ( nSamplesFlushed ) +#endif { /* Write current frame */ if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK ) @@ -3343,11 +3443,19 @@ static ivas_error decodeVoIP( *------------------------------------------------------------------------------------------*/ memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( afWriter != NULL ) { - fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); - goto cleanup; +#endif + if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP } +#endif /*------------------------------------------------------------------------------------------* * Printouts after decoding has finished @@ -3392,6 +3500,9 @@ cleanup: EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker ); AudioFileWriter_close( &afWriter ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + split_rend_reader_writer_close( &splitRendWriter ); +#endif JbmOffsetFileWriter_close( &jbmOffsetWriter ); #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriter_close( &jbmTraceWriter ); diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 53417cf15..e56ef760c 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -1127,6 +1127,19 @@ int main( fprintf( stderr, "\nISAR_POST_REND_FeedSplitBinauralBitstream failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + /* Set BFI if frame is empty */ + int16_t frameEmpty = (int16_t) ( bitsBuffer.config.bitsWritten == 0 ); + if ( frameEmpty ) + { + if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, 1 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } + } +#endif } } diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 08e5694d6..9ea4526be 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6733,6 +6733,44 @@ void ivas_binaural_hrtf_close_fx( HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + +/*---------------------------------------------------------------------------------* + * Multi-pose ring buffer Prototypes +*-----------------------------------------------------------------------------------*/ + +ivas_error ivas_CLDFB_RINGBUF_Open( + ISAR_CLDFB_RINGBUF_HANDLE *ph, + const Word16 capacity_columns +); + +void ivas_CLDFB_RINGBUF_Close( + ISAR_CLDFB_RINGBUF_HANDLE *ph +); + +void ivas_CLDFB_RINGBUF_Push( + ISAR_CLDFB_RINGBUF_HANDLE h, + const Word32 *real, + const Word32 *imag, + const Word16 num_bands +); + +void ivas_CLDFB_RINGBUF_Pop( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 *real, + Word32 *imag, + const Word16 num_bands +); + +void ivas_CLDFB_RINGBUF_GetByIdx( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 **p_real, + Word32 **p_imag, + const Word16 idx +); + +#endif + /*----------------------------------------------------------------------------------* * renderer prototypes *----------------------------------------------------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index 0e364d2b8..8ca21eb97 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,6 @@ #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ #define FIX_1377_HANDLE_ERROR_CODE /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */ #define FIX_1053_REVERB_RECONFIGURATION -#define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1113_EXTREND_ISAR /* FhG: issue 1113: fix external renderer asserts for FOA/HOA2 and CLDFB config */ #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 FIX_938_COMPILER_WARNING /* FhG: Fix compiler warning in ivas_mdct_core_reconstruct() */ @@ -132,6 +131,9 @@ #define NONBE_FIX_1305_OMASA_OBJ_EDIT_EXT /* Nokia: issue 1305: Fix OMASA ext output in case of object editing */ #define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ +#define FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add split rendering support to decoder in VoIP mode */ +#define FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF // TODO(sgi): align with port 369, which actually adds the TD ringbuf: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/merge_requests/2412/diffs#d6d51ef63eb9458b72d78958dfd5b73ac4bae1de +#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 6e30bc084..c9d9b2c38 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2189,7 +2189,9 @@ static void binRenderer_split_fx( Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP const Word16 slot_idx_start, +#endif const Word16 num_freq_bands, const Word16 nchan_out ) { @@ -2222,8 +2224,16 @@ static void binRenderer_split_fx( { FOR( ch = 0; ch < nchan_out; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( + hSplitBinRend->hMultiBinCldfbData[pos_idx * BINAURAL_CHANNELS + ch], + Cldfb_RealBuffer_Binaural_loc[pos_idx][ch][slot_idx], + Cldfb_ImagBuffer_Binaural_loc[pos_idx][ch][slot_idx], + num_freq_bands ); +#else Copy32( Cldfb_RealBuffer_Binaural_loc[pos_idx][ch][slot_idx], hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], num_freq_bands ); Copy32( Cldfb_ImagBuffer_Binaural_loc[pos_idx][ch][slot_idx], hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[( pos_idx * BINAURAL_CHANNELS ) + ch][slot_idx_start + slot_idx], num_freq_bands ); +#endif } } } @@ -3867,7 +3877,11 @@ void ivas_dirac_dec_render_sf_fx( } binRenderer_split_fx( st_ivas->hBinRenderer, st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, slot_idx_start, hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out ); + Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + slot_idx_start, +#endif + hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out ); } ELSE { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 00179537e..3f9b7d13f 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1476,6 +1476,11 @@ ivas_error ivas_init_decoder_front( } } +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + st_ivas->flushing = 0; + move16(); +#endif + return error; } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 62a5b5490..fa4c0a919 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2580,13 +2580,30 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP + if ( st_ivas->flushing ) + { + nchan_out_syn_output = BINAURAL_CHANNELS; + } +#endif +#else FOR( i = 0; i < st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; i++ ) { Copy32( p_output_fx[i], st_ivas->hSplitBinRend->hMultiBinCldfbData->output_fx[i], *nSamplesRendered ); } +#endif } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + ELSE + { +#endif nchan_out_syn_output = nchan_out; move16(); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + } +#endif IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 2a5b0020e..156d3ef2e 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2252,8 +2252,16 @@ void ivas_param_mc_dec_render_fx( { FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( + st_ivas->hSplitBinRend->hMultiBinCldfbData[pos_idx * BINAURAL_CHANNELS + ch], + Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], + Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], + hParamMC->num_freq_bands ); +#else Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); +#endif } } } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index d28ba8328..cd789dad1 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -907,8 +907,16 @@ static void ivas_mc_paramupmix_dec_sf( { FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( + st_ivas->hSplitBinRend->hMultiBinCldfbData[pos_idx * BINAURAL_CHANNELS + ch], + Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], + Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], + maxBand ); +#else Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_index_start, slot_idx )], maxBand ); +#endif } } } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 4749fc22d..49317590e 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1184,10 +1184,14 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( ivas_error error; Word32 *p_sepobj_fx[BINAURAL_CHANNELS]; // Q11 Word32 data_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *re, *im; +#else Word16 slot_idx_start; slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; move16(); +#endif FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) { @@ -1246,9 +1250,16 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_RealBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots ); + v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); + v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); +#else /* note: this intentionally differs from OSBA by: no scaling by 0.5 */ v_add_fx( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx], Cldfb_RealBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx], num_cldfb_bands ); v_add_fx( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx], Cldfb_ImagBuffer, st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][slot_idx_start + slot_idx], num_cldfb_bands ); +#endif } } } diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 67908e996..728fdfdb2 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -137,10 +137,14 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Word32 output_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; Word32 *p_sepobj_fx[BINAURAL_CHANNELS]; Word16 channel_offset; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *re, *im; +#else Word16 slot_idx_start; slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; move16(); +#endif FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) { @@ -163,7 +167,10 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - Word16 slot_idx, num_cldfb_bands, b, nchan_transport_orig; + Word16 slot_idx, num_cldfb_bands, nchan_transport_orig; +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + Word16 b; +#endif Word16 cldfb_slots; Word32 Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; @@ -198,6 +205,12 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_RealBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots ); + v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); + v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); +#else FOR( b = 0; b < num_cldfb_bands; b++ ) { st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[n][slot_idx_start + slot_idx][b] = @@ -208,6 +221,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( L_add( st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[n][add( slot_idx_start, slot_idx )][b], Cldfb_ImagBuffer[b] ); move32(); } +#endif } } } diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 284bd0859..53573c7ee 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -626,12 +626,24 @@ RENDERER_TYPE ivas_renderer_secondary_select_fx( test(); test(); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && + ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + ) +#else IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) +#endif { renderer_type = RENDERER_BINAURAL_OBJECTS_TD; move32(); } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) +#else ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) +#endif { renderer_type = RENDERER_BINAURAL_OBJECTS_TD; move32(); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 289b91b77..ad180e6e8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -870,6 +870,7 @@ typedef struct renderer_struct * IVAS decoder specific ISAR wrapper structures *----------------------------------------------------------------------------------*/ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP typedef struct { Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; @@ -878,18 +879,29 @@ typedef struct } ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; +#endif typedef struct { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][2 * CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* Double space to account for TSM */ + Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][2 * CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#else Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#endif IVAS_AUDIO_CONFIG config; } ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA, *ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; typedef struct { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + TD_RINGBUF_HANDLE hMultiBinTdData; + ISAR_CLDFB_RINGBUF_HANDLE hMultiBinCldfbData[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; +#else ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ - ISAR_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ +#endif + ISAR_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ SPLIT_REND_WRAPPER splitrend; ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ Word16 numTdSamplesPerChannelCached; @@ -1189,6 +1201,10 @@ typedef struct Decoder_Struct Word16 ism_extmeta_active; /* Extended metadata active in decoder */ Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + int16_t flushing; +#endif + } Decoder_Struct; /* clang-format on */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 51c359227..006a7487d 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -153,7 +153,9 @@ ivas_error IVAS_DEC_ReadFormat( ivas_error IVAS_DEC_GetSamplesDecoder( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP const Word16 isSplitRend, /* i : split rendering enabled flag */ +#endif ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ); @@ -314,6 +316,24 @@ ivas_error IVAS_DEC_VoIP_GetSamples( const UWord32 systemTimestamp_ms /* i : current system timestamp */ ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*! r: error code */ +ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ +#ifdef SUPPORT_JBM_TRACEFILE + JbmTraceFileWriterFn jbmWriterFn, + void* jbmWriter, +#endif + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ +); +#endif + ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const Word16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index be60b0580..109863787 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -129,7 +129,11 @@ static ivas_error evs_dec_main_fx( Decoder_Struct *st_ivas, const Word16 nOutSam static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, Word16 *bitstream_format_internal, Word16 *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); #ifdef LIB_DEC_REVISION +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +static ivas_error ivas_dec_setup_all( IVAS_DEC_HANDLE hIvasDec, UWord8 *nTransportChannels, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +#else static ivas_error ivas_dec_setup_all( IVAS_DEC_HANDLE hIvasDec, UWord8 *nTransportChannels, const Word16 isSplitRend, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +#endif static ivas_error apa_setup( IVAS_DEC_HANDLE hIvasDec, const bool isInitialized_voip, const UWord16 nTransportChannels ); #else static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const UWord16 nTransportChannels, const UWord16 l_ts ); @@ -140,6 +144,10 @@ static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const U static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, Word16 *nSamplesBuffered ); #endif static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +static Word16 get_render_frame_size_samples( const DECODER_CONFIG_HANDLE hDecoderConfig ); +static Word16 ivas_dec_split_rend_cldfb_in( const RENDERER_TYPE renderer_type ); +#endif static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered ); static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); @@ -818,6 +826,41 @@ ivas_error IVAS_DEC_GetRenderFramesize( } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * get_render_frame_size_samples( ) + * + * + *---------------------------------------------------------------------*/ + +static int16_t get_render_frame_size_samples( + const DECODER_CONFIG_HANDLE hDecoderConfig /* i : configuration structure */ +) +{ + Word16 tmp; + tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); + + /* NOTE(sgi): BASOP special - not in float version */ + IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) + { + /* correct value already in tmp */ + } + ELSE IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_10MS ) ) + { + tmp = shl( tmp, 1 ); + } + ELSE IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) ) + { + tmp = shl( tmp, 2 ); + } + ELSE + { + tmp = 0; + } + return tmp; +} +#endif + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesizeSamples( ) * @@ -829,7 +872,9 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( Word16 *render_framesize /* o : render framesize in samples Q0 */ ) { +#ifndef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ Word16 tmp; +#endif test(); test(); @@ -838,6 +883,9 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + *render_framesize = get_render_frame_size_samples( hIvasDec->st_ivas->hDecoderConfig ); +#else tmp = (Word16) Mpy_32_16_1( hIvasDec->st_ivas->hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) @@ -856,6 +904,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( { *render_framesize = 0; } +#endif move16(); return IVAS_ERR_OK; @@ -1193,6 +1242,299 @@ ivas_error IVAS_DEC_FeedFrame_Serial( return IVAS_ERR_OK; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * isar_get_frame_size( ) + * + * + *---------------------------------------------------------------------*/ + +static Word16 isar_get_frame_size( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +) +{ + Word32 output_Fs; + Word16 nSamplesPerChannel; + + output_Fs = st_ivas->hDecoderConfig->output_Fs; + + if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + { +#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here + nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); + nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); +#else + nSamplesPerChannel = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); + nSamplesPerChannel *= (int16_t) st_ivas->hDecoderConfig->render_framesize; +#endif + } + else + { +#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here + nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC ); +#else + nSamplesPerChannel = output_Fs / FRAMES_PER_SEC; +#endif + } + + return nSamplesPerChannel; +} + + +/*---------------------------------------------------------------------* + * isar_render_poses( ) + * + * + *---------------------------------------------------------------------*/ + +static ivas_error isar_render_poses( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const Word16 nSamplesAsked, /* i : number of samples wanted by the caller */ + Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ +) +{ + // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, + // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference + Word16 pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; + Decoder_Struct *st_ivas; + ivas_error error; + Word16 numPoses; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *needNewFrame = false; + + st_ivas = hIvasDec->st_ivas; + + numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + /* init flush buffer for rate switch if not already initizalized */ + if ( hIvasDec->flushbuffer == NULL ) + { +#if 1 // NOTE(sgi2det): I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. + // Generally I've seen arithmetic within calls to malloc() not ported, so maybe this is ok. + hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); + set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); +#else // NOTE(sgi): originally from det + Word32 tmp; + /* numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) */ + tmp = imult3216( L_deposit_l( numPoses ), hIvasDec->nSamplesFrame ); + /* BINAURAL_CHANNELS=2, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES=4, sizeof (Word16)=2. */ + /* BINAURAL_CHANNELS * sizeof(Word16)/ IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = 4/4 = 1 */ + hIvasDec->flushbuffer = (void *) malloc( tmp ); + if ( hIvasDec->flushbuffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); + } + hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; // NOTE(sgi2det): the BASOP version of this struct has no pcmType member - only 16 bit PCM is supported. + /* hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = tmp/2 */ + tmp = L_shr( tmp, 1); + set_zero( (Word16 *) hIvasDec->flushbuffer, tmp ); +#endif + } + + /* render */ +#ifdef LIB_DEC_REVISION + IF ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) +#else + IF ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + + IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) ) + { +#if 1 /* NOTE(sgi): Workaround for bit width mismatch */ + Word32 pcmBuf32[960 * 16]; + + for (int i = 0; i < *nOutSamples * hIvasDec->st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i) + { + // NOTE(sgi2det): Is this even correct or do we need to adjust the Q-format? + pcmBuf32[i] = pcmBuf[i]; + } +#endif + + // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer... + // The float version of that function has switchable output format (int16 or float) but not in BASOP. + // Any ideas for a better solution than this pcmBuf32? + ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples ); + } + + return error; +} + + +/*---------------------------------------------------------------------* + * isar_generate_metadata_and_bitstream( ) + * + * + *---------------------------------------------------------------------*/ + +static ivas_error isar_generate_metadata_and_bitstream( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ + Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +) +{ + // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, + // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference + ivas_error error; + ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; + Word16 max_band; + Word16 pcm_out_flag; + Word16 cldfb_in_flag; + Word16 ro_md_flag; + IVAS_QUATERNION Quaternion; + Word16 i, j, num_poses, num_cldfb_slots, n_samples_in_cldfb_slot; + Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + + hSplitBinRend = st_ivas->hSplitBinRend; + +#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here. + // I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. Maybe this can just stay here. + max_band = (Word16) ( ( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); // TODO remove division +#else // NOTE(sgi): originally from det + // NOTE(sgi): warning: implicit conversion from 'int' to 'Word16' (aka 'short') changes value from 48000 to -17536 [-Wconstant-conversion] + max_band = divide3216( imult3216( BINAURAL_MAXBANDS, st_ivas->hDecoderConfig->output_Fs ), 48000 ); +#endif + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); + + // NOTE(sgi): BASOP special - not in float version + n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + assert( nSamples % n_samples_in_cldfb_slot == 0 ); +#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here + num_cldfb_slots = extract_l( divide3216( L_deposit_l( nSamples ), n_samples_in_cldfb_slot ) ); +#else + num_cldfb_slots = nSamples / n_samples_in_cldfb_slot; +#endif + + num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + IF( cldfb_in_flag ) + { + FOR( i = 0; i < imult1616( BINAURAL_CHANNELS, num_poses); ++i ) + { + FOR( j = 0; j < num_cldfb_slots; ++j ) + { + /* Save pointers to first CLDFB column in the ring buffer. Allows us to save + * significant amounts of memory by not copying CLDFB values into a separate buffer. */ + ivas_CLDFB_RINGBUF_GetByIdx( hSplitBinRend->hMultiBinCldfbData[i], &p_Cldfb_RealBuffer_Binaural[i][j], &p_Cldfb_ImagBuffer_Binaural[i][j], 0 ); + + /* Pop the CLDFB column we just saved pointers to. This is fine as long as we use + * the saved columns only before any new columns are pushed to the buffer - the new + * columns could potentially overwrite the old columns we wanted to use. + * This requirement is fulfilled in this case. */ + ivas_CLDFB_RINGBUF_Pop( hSplitBinRend->hMultiBinCldfbData[i], NULL, NULL, CLDFB_NO_CHANNELS_MAX ); + } + } + } + ELSE + { + ivas_TD_RINGBUF_PopChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_head_pose_buf, nSamples ); + } + + + IF ( st_ivas->hBinRendererTd != NULL ) + { + ro_md_flag = 1; + } + ELSE + { + ro_md_flag = 0; + } + + IF( st_ivas->hHeadTrackData != NULL ) + { + Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; + } + ELSE + { + Quaternion.w_fx = -12582912; + Quaternion.x_fx = 0; + Quaternion.y_fx = 0; + Quaternion.z_fx = 0; + } + // NOTE(sgi): BASOP special - not in float version + Word16 q1 = 31, q2 = 31, Q_buff = 31; + Word16 Q_out[CLDFB_NO_COL_MAX]; // NOTE(sgi): Seems unnecessarily large. Only indices 0 and 1 are used, value at index 1 is writen but never read. + Q_out[0] = 31; + + IF( EQ_16( cldfb_in_flag, 1 ) ) + { + FOR( i = 0; i < i_mult( BINAURAL_CHANNELS, num_poses ); i++ ) + { + FOR( j = 0; j < num_cldfb_slots; j++ ) + { + q1 = s_min( q1, L_norm_arr( p_Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + q2 = s_min( q2, L_norm_arr( p_Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + } + } + Q_buff = s_min( q1, q2 ); + FOR( i = 0; i < i_mult( BINAURAL_CHANNELS, num_poses ); i++ ) + { + FOR( j = 0; j < num_cldfb_slots; j++ ) + { + scale_sig32( p_Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); + scale_sig32( p_Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); + } + } + Q_buff = add( Q_buff, Q6 ); + } + ELSE + { + /*TD input*/ + /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ + /* local float2fix, to be removed */ + num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + Q_out[0] = s_min( Q_out[0], L_norm_arr( p_head_pose_buf[i], L_FRAME48k ) ); + } + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + scale_sig32( p_head_pose_buf[i], L_FRAME48k, Q_out[0] ); + } + Q_out[0] = add( Q_out[0], Q11 ); + Q_out[1] = Q_out[0]; + } + + IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + p_Cldfb_RealBuffer_Binaural, + p_Cldfb_ImagBuffer_Binaural, + max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} +#endif /* FIX_1119_SPLIT_RENDERING_VOIP */ + /*---------------------------------------------------------------------* * IVAS_DEC_GetSamplesRenderer( ) @@ -1401,6 +1743,70 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi2det): this function still needs to be ported to BASOP + Decoder_Struct *st_ivas; + ivas_error error; + Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; + Word32 *p_head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; + Word16 i; + Word16 pcm_out_flag; + Word16 numSamplesPerChannelToOutput; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; + + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); + + if ( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } + + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + p_head_pose_buf[i] = head_pose_buf[i]; + } + + if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ + if ( pcm_out_flag ) + { + if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); +#endif + } + else + { + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); + } + +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + } +#else Decoder_Struct *st_ivas; AUDIO_CONFIG output_config; Word32 output_Fs; @@ -1657,8 +2063,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (Word16 *) pcmBuf_out ); } -#ifndef TMP_FIX_SPLIT_REND +#ifndef TMP_FIX_SPLIT_REND // TODO(sgi): need to port? free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); +#endif #endif return IVAS_ERR_OK; @@ -1673,9 +2080,11 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( *---------------------------------------------------------------------*/ static ivas_error ivas_dec_setup_all( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord8 *nTransportChannels, /* o : number of decoded transport PCM channels */ - const Word16 isSplitRend, /* i : split rendering enabled flag */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord8 *nTransportChannels, /* o : number of decoded transport PCM channels */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + const Word16 isSplitRend, /* i : split rendering enabled flag */ +#endif ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) #else @@ -1714,7 +2123,11 @@ static ivas_error IVAS_DEC_Setup( #ifdef LIB_DEC_REVISION /* Setup IVAS split rendering */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( splitRendBits != NULL ) +#else IF( isSplitRend ) +#endif { IF( ( error = isar_set_split_rend_setup( st_ivas->hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { @@ -1755,7 +2168,11 @@ static ivas_error IVAS_DEC_Setup( test(); #ifdef LIB_DEC_REVISION +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( st_ivas->ini_frame == 0 && splitRendBits != NULL ) +#else IF( st_ivas->ini_frame == 0 && isSplitRend ) +#endif #else IF( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) #endif @@ -3848,8 +4265,10 @@ ivas_error IVAS_DEC_ReadFormat( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSamplesDecoder( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 isSplitRend, /* i : split rendering enabled flag */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + const Word16 isSplitRend, /* i : split rendering enabled flag */ +#endif ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) { @@ -3889,7 +4308,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder( * Setup all decoder parts (IVAS decoder, ISAR) *-----------------------------------------------------------------*/ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, splitRendBits ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -4662,19 +5085,37 @@ ivas_error IVAS_DEC_PrepareRenderer( } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + +/*---------------------------------------------------------------------* + * ivas_dec_voip_get_samples_common( ) + * + * Main function to output one frame in VoIP. Holds common code for + * regular output configs and split rendering configs. + *---------------------------------------------------------------------*/ + +static ivas_error ivas_dec_voip_get_samples_common + +#else /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) * * Main function to decode one frame in VoIP *---------------------------------------------------------------------*/ - -ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - Word16 *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels Q0 */ +ivas_error IVAS_DEC_VoIP_GetSamples +#endif + ( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word32 **p_head_pose_buf, /* i : PCM buffer with head-pose data */ +#endif #ifdef SUPPORT_JBM_TRACEFILE - JbmTraceFileWriterFn jbmWriterFn, - void *jbmWriter, + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, #endif bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ UWord16 *nSamplesRendered, /* o : number of samples rendered */ @@ -4713,12 +5154,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_WRONG_PARAMS; } -#ifdef TMP_FIX_1119_SPLIT_RENDERING_VOIP +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + test(); test(); - IF( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || - EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) + IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || + EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) && + splitRendBits == NULL ) { - return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Split rendering is not integrated with VoIP mode" ); + return IVAS_ERR_UNEXPECTED_NULL_POINTER; // NOTE(sgi): BASOP special - not in float version } #endif @@ -4922,7 +5365,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifndef LIB_DEC_REVISION uint16_t nSamplesFlushed_ref = hIvasDec->nSamplesFlushed; #endif - IF( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ) != IVAS_ERR_OK ) +#else + IF ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -4952,24 +5400,169 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } } - /* render IVAS frames directly to the output buffer */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( splitRendBits != NULL ) + { + /* Render head poses from time-scaled transport channels */ + IF( ( error = isar_render_poses( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { +#endif + /* render IVAS frames directly to the output buffer */ #ifdef LIB_DEC_REVISION - IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) #else - IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) #endif - { - return error; + { + return error; + } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP } +#endif *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) + { + /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ + IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Synthesise PCM output if split PCM */ + IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + { +#ifndef DISABLE_LIMITER + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); +#endif + } + ELSE + { + ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); + } + +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + } + } +#endif + return IVAS_ERR_OK; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetSamples( ) + * + * Main function to decode one frame in VoIP + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_VoIP_GetSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ +#ifdef SUPPORT_JBM_TRACEFILE + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, +#endif + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ +) +{ + return ivas_dec_voip_get_samples_common( + hIvasDec, + nSamplesPerChannel, + /* pcmType, */ + pcmBuf, + NULL, + NULL, +#ifdef SUPPORT_JBM_TRACEFILE + jbmWriterFn, + jbmWriter, +#endif + bitstreamReadDone, + nSamplesRendered, + parametersAvailableForEditing, + systemTimestamp_ms ); +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetSplitBinauralBitstream( ) + * + * Main function to decode one split-rendering frame in VoIP + *---------------------------------------------------------------------*/ + +/*! r: error code */ +ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ +#ifdef SUPPORT_JBM_TRACEFILE + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, +#endif + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ +) +{ + Word16 i; + Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; + Word32 *pp_head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; + ivas_error error = IVAS_ERR_UNKNOWN; + Word16 nSamplesPerChannel = 0; + + IF( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nSamplesPerChannel ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Set pointers to beginning of head pose buffers */ + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + pp_head_pose_buf[i] = head_pose_buf[i]; + } + + return ivas_dec_voip_get_samples_common( + hIvasDec, + nSamplesPerChannel, + /* IVAS_DEC_PCM_INT16, */ + pcmBuf, + splitRendBits, + pp_head_pose_buf, +#ifdef SUPPORT_JBM_TRACEFILE + jbmWriterFn, + jbmWriter, +#endif + bitstreamReadDone, + nSamplesRendered, + parametersAvailableForEditing, + systemTimestamp_ms ); +} +#endif + + /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) @@ -5040,6 +5633,10 @@ ivas_error IVAS_DEC_Flush( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + hIvasDec->st_ivas->flushing = 1; +#endif + *nSamplesFlushed = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); move16(); @@ -5064,6 +5661,10 @@ ivas_error IVAS_DEC_Flush( *nSamplesFlushed = 0; move16(); } +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR + hIvasDec->st_ivas->flushing = 0; +#endif + return error; } @@ -5925,6 +6526,9 @@ static ivas_error ivas_create_handle_isar( ) { ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word16 i; +#endif IF( ( hSplitBinRend = (ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_WRAPPER ) ) ) == NULL ) { @@ -5933,7 +6537,15 @@ static ivas_error ivas_create_handle_isar( isar_init_split_rend_handles( &hSplitBinRend->splitrend ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + hSplitBinRend->hMultiBinTdData = NULL; + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + hSplitBinRend->hMultiBinCldfbData[i] = NULL; + } +#else hSplitBinRend->hMultiBinCldfbData = NULL; +#endif hSplitBinRend->hCldfbDataOut = NULL; hSplitBinRend->numTdSamplesPerChannelCached = 0; @@ -5953,13 +6565,31 @@ static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend /* i/o: ISAR split binaural rendering handle */ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word16 i; +#endif + IF( *hSplitBinRend != NULL ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + IF( ( *hSplitBinRend )->hMultiBinTdData != NULL ) + { + ivas_TD_RINGBUF_Close( &( *hSplitBinRend )->hMultiBinTdData ); + } + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + IF( ( *hSplitBinRend )->hMultiBinCldfbData[i] != NULL ) + { + ivas_CLDFB_RINGBUF_Close( &( *hSplitBinRend )->hMultiBinCldfbData[i] ); + } + } +#else #ifdef TMP_FIX_SPLIT_REND free( ( *hSplitBinRend )->hMultiBinCldfbData ); ( *hSplitBinRend )->hMultiBinCldfbData = NULL; - #endif +#endif + ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); IF( ( *hSplitBinRend )->hCldfbDataOut != NULL ) @@ -6152,6 +6782,33 @@ static ivas_error ivas_dec_reconfig_split_rend( } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*-------------------------------------------------------------------* + * ivas_dec_split_rend_cldfb_in() + * + * + *-------------------------------------------------------------------*/ + +static Word16 ivas_dec_split_rend_cldfb_in( + const RENDERER_TYPE renderer_type /* i : renderer type */ +) +{ + if ( renderer_type == RENDERER_BINAURAL_FASTCONV || + renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + renderer_type == RENDERER_BINAURAL_PARAMETRIC || + renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + return 1; + } + else + { + return 0; + } +} +#endif + + + /*-------------------------------------------------------------------* * ivas_dec_init_split_rend() * @@ -6165,11 +6822,18 @@ static ivas_error ivas_dec_init_split_rend( ivas_error error; Word16 cldfb_in_flag, pcm_out_flag; Word16 mixed_td_cldfb_flag; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word16 i, num_poses; +#endif pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = 0; move16(); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); +#else + #ifdef TMP_FIX_SPLIT_REND /* note: this is intra-frame heap memory */ IF( ( st_ivas->hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) @@ -6186,9 +6850,37 @@ static ivas_error ivas_dec_init_split_rend( cldfb_in_flag = 1; move16(); } +#endif +#ifdef FIX_1119_SPLIT_RENDERING_VOIP ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + assert( num_poses <= MAX_HEAD_ROT_POSES ); + + IF( cldfb_in_flag ) + { + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + /* note: this is intra-frame heap memory */ + IF( ( error = ivas_CLDFB_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinCldfbData[i], CLDFB_NO_COL_MAX ) ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); + } + } + } + ELSE + { + IF( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), num_poses * BINAURAL_CHANNELS ) ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); + } + } +#else + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); +#endif + IF( EQ_16( cldfb_in_flag, 1 ) && ( EQ_16( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) ) { IF( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index ca02665b4..7d7b16f67 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -67,8 +67,13 @@ void isar_splitBinPreRendClose( void lc3plusTimeAlignCldfbPoseCorr( SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ - Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ - Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, imag. part */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ + Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, imag. part */ +#else + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], +#endif Word16 *Q_in ); @@ -187,11 +192,16 @@ void isar_splitBinLCLDEncClose( ); void isar_splitBinLCLDEncProcess( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_Real_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ + Word32 *Cldfb_In_Imag_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, imag. part */ +#else Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word32 available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ +#endif + const Word32 available_bits, /* i : available bit-budget */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ Word16 *q_final ); @@ -282,12 +292,20 @@ void isar_rend_CldfbSplitPostRendProcess( ); void isar_rend_CldfbSplitPreRendProcess( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32* Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i : Binaural signals, real part */ +#else Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], +#endif Word16 exp_cldfb_re, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32* Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i : Binaural signals, imag. part */ +#else Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], +#endif Word16 exp_cldfb_im, ISAR_SPLIT_REND_BITS_HANDLE pBits, const Word32 target_md_bits, diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c index e6efe1ff2..b1249653f 100644 --- a/lib_isar/isar_splitRend_lcld_enc.c +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -152,10 +152,15 @@ void isar_splitBinLCLDEncClose( *------------------------------------------------------------------------*/ void isar_splitBinLCLDEncProcess( ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_Real_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ + Word32 *Cldfb_In_Imag_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, imag part */ +#else Word32 Cldfb_In_Real_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_Imag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word32 available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits, +#endif + const Word32 available_bits, /* i : available bit-budget */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ Word16 *q_final ) { Word32 iBitsWritten, itr, available_bits_itr, rem_itr, available_bits_local; diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 71e285a9c..ebb07b720 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -50,6 +50,25 @@ #endif #include "basop_util.h" +/*---------------------------------------------------------------------* + * Local function declarations + *---------------------------------------------------------------------*/ + +static void isar_SplitRenderer_GetRotMd_fx( ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_re, + Word32 *Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im, +#else + Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_re, + Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 exp_cldfb_im, +#endif + const Word16 low_res, + const Word16 ro_md_flag ); /*------------------------------------------------------------------------- * Local functions @@ -505,15 +524,29 @@ static void ComputePostPredCov_fx( static void ComputeBandedCrossCov_fx( +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer1_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_re_1, + Word32 *Cldfb_ImagBuffer1_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im_1, +#else Word32 Cldfb_RealBuffer1_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_re_1, Word32 Cldfb_ImagBuffer1_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_im_1, +#endif const Word16 ch_start_idx1, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer2_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_re_2, + Word32 *Cldfb_ImagBuffer2_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im_2, +#else Word32 Cldfb_RealBuffer2_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_re_2, Word32 Cldfb_ImagBuffer2_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_im_2, +#endif const Word16 ch_start_idx2, Word32 out_cov_re_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *exp_out_cov_re, @@ -646,10 +679,17 @@ static void ComputeBandedCrossCov_fx( static void ComputeBandedCov_fx( +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_re, + Word32 *Cldfb_ImagBuffer_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im, +#else Word32 Cldfb_RealBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_re, Word32 Cldfb_ImagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_im, +#endif const Word16 ch_start_idx, Word32 out_cov_re_fx[][BINAURAL_CHANNELS], Word16 *exp_cov_re, @@ -2142,14 +2182,20 @@ static void isar_SplitRenderer_quant_code( * * *------------------------------------------------------------------------*/ - static void isar_SplitRenderer_GetRotMd_fx( ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX], /* o : Reference Binaural signals */ + Word16 exp_cldfb_re, + Word32 *Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX], /* o : Reference Binaural signals */ + Word16 exp_cldfb_im, +#else Word32 Cldfb_RealBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ Word16 exp_cldfb_re, Word32 Cldfb_ImagBuffer_Ref_Binaural_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ Word16 exp_cldfb_im, +#endif const Word16 low_res, const Word16 ro_md_flag ) { @@ -2245,17 +2291,25 @@ static void isar_SplitRenderer_GetRotMd_fx( *------------------------------------------------------------------------*/ void isar_rend_CldfbSplitPreRendProcess( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i : Binaural signals, real part */ + Word16 exp_cldfb_re, + Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], + Word16 exp_cldfb_im, +#else Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_re, Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 exp_cldfb_im, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 target_md_bits, - const Word16 low_res_pre_rend_rot, - const Word16 ro_md_flag ) +#endif + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const Word32 target_md_bits, /* i : ISAR MD bitrate */ + const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const Word16 ro_md_flag /* i : real only metadata for yaw flag */ +) { push_wmops( "isar_rend_CldfbSplitPreRendProcess" ); @@ -2860,6 +2914,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( UWord8 useLc3plus; Word32 *in_delayed_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; Word16 i; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + int16_t j; + Word32 *p_Cldfb_In_BinReal[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + Word32 *p_Cldfb_In_BinImag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; +#endif Word32 num_slots; push_wmops( "isar_renderMultiTDBinToSplitBinaural" ); @@ -2869,6 +2928,17 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( useLc3plus = hSplitBin->hLc3plusEnc != NULL; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + for ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + { + for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + { + p_Cldfb_In_BinReal[i][j] = Cldfb_In_BinReal_fx[i][j]; + p_Cldfb_In_BinImag[i][j] = Cldfb_In_BinImag_fx[i][j]; + } + } +#endif + IF( useLc3plus ) { /*this should always have the time resolution of pose correction MD. Note that this does not change frame size of LC3plus*/ @@ -2989,7 +3059,25 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( q_final = add( q_final, scale_factor ); Word16 exp_cldfb_re = sub( 31, q_final ); Word16 exp_cldfb_im = sub( 31, q_final ); - isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal_fx, exp_cldfb_re, Cldfb_In_BinImag_fx, exp_cldfb_im, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); + isar_rend_CldfbSplitPreRendProcess( + hSplitBin->hBinHrSplitPreRend, + headPosition, + &hSplitBin->multiBinPoseData, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + p_Cldfb_In_BinReal, + exp_cldfb_re, + p_Cldfb_In_BinImag, + exp_cldfb_im, +#else + Cldfb_In_BinReal_fx, + exp_cldfb_re, + Cldfb_In_BinImag_fx, + exp_cldfb_im, +#endif + pBits, + target_md_bits, + low_res_pre_rend_rot, + ro_md_flag ); } IF( EQ_16( pcm_out_flag, 0 ) ) @@ -3009,7 +3097,18 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( move16(); pBits->isar_frame_size_ms = isar_frame_size_ms; move16(); - isar_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal_fx, Cldfb_In_BinImag_fx, available_bits, pBits, &q_final ); + isar_splitBinLCLDEncProcess( + hSplitBin->hSplitBinLCLDEnc, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + p_Cldfb_In_BinReal, + p_Cldfb_In_BinImag, +#else + Cldfb_In_BinReal_fx, + Cldfb_In_BinImag_fx, +#endif + available_bits, + pBits, + &q_final ); } ELSE { @@ -3085,9 +3184,14 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( *------------------------------------------------------------------------*/ void lc3plusTimeAlignCldfbPoseCorr( - SPLIT_REND_WRAPPER *hSplitBin, - Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ + Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, imag. part */ +#else + Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ + Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, imag. part */ +#endif Word16 *Q_in ) { Word32 Cldfb_In_BinReal_tmp_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; @@ -3107,7 +3211,12 @@ void lc3plusTimeAlignCldfbPoseCorr( } ELSE { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version + FOR( Word16 i = 0; i < i_mult( hSplitBin->multiBinPoseData.num_poses, BINAURAL_CHANNELS ); i++ ) +#else FOR( Word16 i = 0; i < CLDFB_NO_COL_MAX; i++ ) +#endif + { for ( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) { diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 351cb4525..4576e7c1d 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -256,5 +256,17 @@ typedef struct Word32 lc3plusDelaySamples; } SPLIT_REND_WRAPPER; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +typedef struct +{ + Word32 *real; + Word32 *imag; + Word16 capacity; + Word16 write_pos; + Word16 read_pos; + Word16 is_full; + +} ISAR_CLDFB_RINGBUF, *ISAR_CLDFB_RINGBUF_HANDLE; +#endif #endif /* ISAR_STAT_H */ diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 1ba5cafc4..20cfc9f4d 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -278,21 +278,26 @@ void ISAR_PRE_REND_GetMultiBinPoseData( *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, - const Word32 SplitRendBitRate, - ISAR_SPLIT_REND_CODEC splitCodec, - const Word16 isar_frame_size_ms, /* i: ISAR framesize */ - Word16 codec_frame_size_ms, + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const Word32 SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + const Word16 isar_frame_size_ms, /* i : ISAR framesize */ + Word16 codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ ISAR_SPLIT_REND_BITS_HANDLE pBits, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */ + Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */ +#else Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word16 max_bands, - Word32 *pOutput_fx[], - const Word16 low_res_pre_rend_rot, - const Word16 cldfb_in_flag, - const Word16 pcm_out_flag, - const Word16 ro_md_flag, +#endif + const Word16 max_bands, /* i : CLDFB bands */ + Word32 *pOutput_fx[], /* i/o: PCM in/out buffer */ + const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time domain input */ + const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ + const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */ Word16 Q_buff, Word16 *Q_out ) { @@ -405,7 +410,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( tmp_e = 0; tmp = BASOP_Util_Divide3232_Scale( L_mult0( CLDFB_NO_COL_MAX, ivas_fs ), 20, &tmp_e ); - num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 + num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 // NOTE(sgi): this could be a macro constant? // num_slots = (Word16) CLDFB_NO_COL_MAX * ivas_fs / 20; /* CLDFB synthesis of main pose */ { @@ -415,7 +420,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + FOR( j = 0; j < num_slots; j++ ) +#else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); @@ -429,7 +438,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + FOR( j = 0; j < num_slots; j++ ) +#else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); @@ -480,7 +493,13 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( } ELSE { - Word16 ch, slot_idx; + Word16 ch, slot_idx, num_slots; +#if 0 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does. + num_slots = shl( isar_frame_size_ms, 3); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */ +#else + num_slots = isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS; +#endif + /* CLDFB synthesis of main pose */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -490,7 +509,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); q2 = 31; move16(); - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version { q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); @@ -499,13 +518,13 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); q_final = sub( q_final, 6 ); // guard bits q_final = s_min( q_final, Q25 ); - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version { Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); } - FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < num_slots; slot_idx++ ) { Cldfb_In_BinReal_p_fx[slot_idx] = Cldfb_In_BinReal_fx[ch][slot_idx]; move32(); @@ -516,7 +535,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 Q_out[ch] = sub( Q_cldfb, 1 ); move16(); hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index 772637db9..9ee1aae86 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -70,8 +70,13 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( const Word16 isar_frame_size_ms, /* i : ISAR framesize */ Word16 codec_frame_size_ms, /* i/o: Split renderer codec framesize */ ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer bitstream handle */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + Word32* Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */ + Word32* Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */ +#else Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ +#endif const Word16 max_bands, /* i : CLDFB bands */ Word32 *pOutput_fx[], /* i : low time resolution pre-renderer flag */ const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c new file mode 100644 index 000000000..eacf7f3fe --- /dev/null +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -0,0 +1,321 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "cnst.h" +#include "prot_fx.h" +#include "ivas_prot_fx.h" +#include +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * CLDFB ring-buffer functions needed in split-rendering outputs + *---------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------* + * ivas_cldfb_ringbuf_IsEmpty() + * + * Returns 1 if the ring buffer is empty, or 0 otherwise. + *---------------------------------------------------------------------*/ + +static Word16 ivas_cldfb_ringbuf_IsEmpty( + ISAR_CLDFB_RINGBUF_HANDLE h ) +{ + test(); + return EQ_16( h->read_pos, h->write_pos ) && !h->is_full; +} + + +/*---------------------------------------------------------------------* + * ivas_cldfb_ringbuf_IsFull() + * + * Returns 1 if the ring buffer is full, or 0 otherwise. + *---------------------------------------------------------------------*/ + +static Word32 ivas_cldfb_ringbuf_IsFull( + ISAR_CLDFB_RINGBUF_HANDLE h ) +{ + return h->is_full; +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_Open() + * + * Allocate a ring buffer for CLDFB data with the given capacity of CLDFB columns. + * Each column is expected to contain at most CLDFB_NO_CHANNELS_MAX frequency bands. + * + * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. + *---------------------------------------------------------------------*/ + +ivas_error ivas_CLDFB_RINGBUF_Open( + ISAR_CLDFB_RINGBUF_HANDLE *ph, + const Word16 capacity_columns ) +{ + ISAR_CLDFB_RINGBUF_HANDLE h; + Word16 capacity; + + capacity = i_mult( capacity_columns, CLDFB_NO_CHANNELS_MAX ); + move16(); + + IF ( ( h = malloc( sizeof( ISAR_CLDFB_RINGBUF ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); + } + h->real = NULL; + h->imag = NULL; + h->capacity = 0; + move16(); + h->write_pos = 0; + move16(); + h->read_pos = 0; + move16(); + h->is_full = 0; + move16(); + *ph = h; + + IF ( ( h->real = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); + } + IF ( ( h->imag = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); + } + h->capacity = capacity; + move16(); + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_Close() + * + * Dellocate CLDFB ring buffer. The given handle will be set to NULL. + *---------------------------------------------------------------------*/ + +void ivas_CLDFB_RINGBUF_Close( + ISAR_CLDFB_RINGBUF_HANDLE *ph ) +{ + ISAR_CLDFB_RINGBUF_HANDLE h; + + IF ( ph == NULL ) + { + return; + } + h = *ph; + + IF ( h == NULL ) + { + return; + } + + IF ( h->real != NULL ) + { + free( h->real ); + } + IF ( h->imag != NULL ) + { + free( h->imag ); + } + + free( h ); + *ph = NULL; + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_Push() + * + * Push a single column onto the back of the CLDFB ring buffer from real and imag arrays. + *---------------------------------------------------------------------*/ + +void ivas_CLDFB_RINGBUF_Push( + ISAR_CLDFB_RINGBUF_HANDLE h, + const Word32 *real, + const Word32 *imag, + const Word16 num_bands ) +{ + assert( num_bands <= CLDFB_NO_CHANNELS_MAX ); + assert( !ivas_cldfb_ringbuf_IsFull( h ) ); + + Copy32( real, &h->real[h->write_pos], num_bands ); + Copy32( imag, &h->imag[h->write_pos], num_bands ); + + h->write_pos = add( h->write_pos, CLDFB_NO_CHANNELS_MAX ); + move16(); + if ( EQ_16( h->write_pos, h->capacity ) ) + { + h->write_pos = 0; + move16(); + } + + if ( EQ_16( h->read_pos, h->write_pos ) ) + { + h->is_full = 1; + move16(); + } + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_Pop() + * + * Pop a single column from the front of the CLDFB ring buffer into real and imag arrays. + *---------------------------------------------------------------------*/ + +void ivas_CLDFB_RINGBUF_Pop( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 *real, + Word32 *imag, + const Word16 num_bands ) +{ + assert( num_bands <= CLDFB_NO_CHANNELS_MAX ); + assert( !ivas_cldfb_ringbuf_IsEmpty( h ) ); + + IF ( real != NULL ) + { + Copy32( &h->real[h->read_pos], real, num_bands ); + } + IF ( imag != NULL ) + { + Copy32( &h->imag[h->read_pos], imag, num_bands ); + } + + h->read_pos = add( h->read_pos, CLDFB_NO_CHANNELS_MAX ); + move16(); + IF ( EQ_16( h->read_pos, h->capacity ) ) + { + h->read_pos = 0; + move16(); + } + + h->is_full = 0; + move16(); + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_cldfb_ringbuf_total_size() + * + * Returns total number of buffered samples (including number of channels) + *---------------------------------------------------------------------*/ + +static uint32_t ivas_cldfb_ringbuf_total_size( + ISAR_CLDFB_RINGBUF_HANDLE h ) +{ + IF ( ivas_cldfb_ringbuf_IsFull( h ) ) + { + return h->capacity; + } + + IF ( LE_16( h->read_pos, h->write_pos ) ) + { + return sub( h->write_pos, h->read_pos ); + } + + /* else wrap around */ + return add( h->write_pos, sub( h->capacity, h->read_pos ) ); +} + + +/*---------------------------------------------------------------------* + * ivas_CLDFB_RINGBUF_GetByIdx() + * + * Get pointers into a specific column in the CLDFB ring buffer based on given index. + * Non-negative indices access from the front of the ring buffer, negative indexes access + * from the back, similar to Python arrays. For example: + * + * - index 0 accesses the front of the buffer, i.e. the oldest CLDFB column in the queue. + * - index -1 accesses the back of the buffer, i.e. the newest (last pushed) CLDFB column in the queue. + *---------------------------------------------------------------------*/ + +void ivas_CLDFB_RINGBUF_GetByIdx( + ISAR_CLDFB_RINGBUF_HANDLE h, + Word32 **p_real, + Word32 **p_imag, + const Word16 col_idx ) +{ + Word16 idx = i_mult( col_idx, CLDFB_NO_CHANNELS_MAX ); + move16(); + Word16 num_floats = ivas_cldfb_ringbuf_total_size( h ); + move16(); + Word16 offset /*, uidx */; // uidx unused in FX code + + assert( -num_floats <= idx && idx <= num_floats ); + + IF ( GE_16( idx, 0 ) ) + { + offset = add( h->read_pos, idx ); + move16(); + if ( LE_16( h->capacity, offset ) ) + { + offset = sub( offset, h->capacity ); + move16(); + } + } + ELSE + { + idx = negate( idx ); + move16(); + IF ( LE_16 ( idx, h->write_pos ) ) + { + offset = sub( h->write_pos, idx ); + move16(); + } + ELSE + { + offset = add( h->write_pos, sub( h->capacity, idx ) ); + move16(); + } + } + + *p_real = &h->real[offset]; + move16(); + *p_imag = &h->imag[offset]; + move16(); + + return; +} +#endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0539b7b85..dae32647a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1111,8 +1111,12 @@ static void ivas_dirac_dec_binaural_internal_fx( { FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( st_ivas->hSplitBinRend->hMultiBinCldfbData[ch], tmp_Cldfb_out_re[ch][i], tmp_Cldfb_out_im[ch][i], CLDFB_NO_CHANNELS_MAX ); +#else Copy32( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); Copy32( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); +#endif } } } @@ -1172,11 +1176,19 @@ static void ivas_dirac_dec_binaural_internal_fx( Copy( st_ivas->hDiracDecBin[0]->ChCrossIm_e, hDiracDecBin->ChCrossIm_e, hSpatParamRendCom->num_freq_bands ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, +#else hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, +#endif subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, st_ivas->hMasaIsmData ); ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, +#else hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, +#endif nchanSeparateChannels, st_ivas->hMasaIsmData ); q_mat = hDiracDecBin->q_processMtx; @@ -1224,8 +1236,12 @@ static void ivas_dirac_dec_binaural_internal_fx( { FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe]; i++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + ivas_CLDFB_RINGBUF_Push( st_ivas->hSplitBinRend->hMultiBinCldfbData[pos_idx * BINAURAL_CHANNELS + ch], tmp_Cldfb_out_re[ch][i], tmp_Cldfb_out_im[ch][i], CLDFB_NO_CHANNELS_MAX ); +#else Copy32( tmp_Cldfb_out_re[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); Copy32( tmp_Cldfb_out_im[ch][i], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[pos_idx * BINAURAL_CHANNELS + ch][hSpatParamRendCom->slots_rendered + i], CLDFB_NO_CHANNELS_MAX ); +#endif } } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 250fea751..d978d9034 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1594,6 +1594,68 @@ void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend ); +#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF +/*----------------------------------------------------------------------------------* + * Time domain ring buffer prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_TD_RINGBUF_Open( + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ + const Word16 num_channels /* i : Number of channels */ +); + +void ivas_TD_RINGBUF_Close( + TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */ +); + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +void ivas_TD_RINGBUF_PushInterleaved( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +); + +void ivas_TD_RINGBUF_PushChannels( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *p_channels[], /* i : Array of pointers to each input channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ +); + +void ivas_TD_RINGBUF_PushConstant( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 value, /* i : Value to push */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +); + +void ivas_TD_RINGBUF_PopChannels( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *p_channels[], /* i : Array of pointers to each output channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ +); +#else +void ivas_TD_RINGBUF_Push( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ +); + +void ivas_TD_RINGBUF_PushZeros( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word16 num_samples_per_channel /* i : Number of zeros per channel to store */ +); + +void ivas_TD_RINGBUF_Pop( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve*/ +); +#endif + +Word16 ivas_TD_RINGBUF_Size( // bit width? + const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ +); +#endif /* clang-format on */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index aec8eb3b9..23489353f 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1432,6 +1432,22 @@ typedef struct } CLDFB_REND_WRAPPER; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF +/*----------------------------------------------------------------------------------* + * Time domain ring buffer structure + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + Word32 *data; /* samples in interleaved layout */ + Word32 capacity; + Word16 num_channels; + Word32 write_pos; + Word32 read_pos; + Word16 is_full; + +} TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE; +#endif /*----------------------------------------------------------------------------------* * Limiter structure diff --git a/lib_rend/ivas_td_ring_buffer.c b/lib_rend/ivas_td_ring_buffer.c new file mode 100644 index 000000000..a79d7b0c7 --- /dev/null +++ b/lib_rend/ivas_td_ring_buffer.c @@ -0,0 +1,448 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include +#include "ivas_error_utils.h" +#include "ivas_prot_rend_fx.h" +#include "options.h" +#include "wmc_auto.h" + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF + +/*-----------------------------------------------------------------------* + * Local function prototypes + *-----------------------------------------------------------------------*/ + +static Word32 ivas_td_ringbuf_total_size( + TD_RINGBUF_HANDLE h ) +{ + if ( h->is_full ) + { + return h->capacity; + } + + if ( LE_32( h->read_pos, h->write_pos ) ) + { + return L_sub( h->write_pos, h->read_pos ); + } + /* else wrap around */ + return L_add( h->write_pos, L_sub( h->capacity, h->read_pos ) ); +} + + +static Word16 ivas_td_ringbuf_has_space_for_num_samples( + TD_RINGBUF_HANDLE h, + const Word32 num_samples ) +{ + return LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ); +} + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +static void ivas_td_ringbuf_push_interleaved( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ + const Word16 num_samples_per_channel, /* i : Number of samples per channel to push */ + const Word16 read_stride /* i: : 1 for normal operation, 0 for reading from a single input value */ +) +{ + Word32 s, read_s; + + assert( h != NULL ); + assert( data != NULL ); + assert( read_stride == 0 || read_stride == 1 ); + assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); + + read_s = 0; + move32(); + FOR ( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels); ++s ) + { + h->data[h->write_pos] = data[read_s]; + move32(); + ++h->write_pos; + + if ( EQ_32( h->write_pos, h->capacity ) ) + { + h->write_pos = 0; + } + read_s = L_add( read_s, L_deposit_l( read_stride ) ); + move32(); + } + + if ( EQ_32( h->read_pos, h->write_pos ) ) + { + h->is_full = 1; + move16(); + } + + return; +} +#endif + + +/*-----------------------------------------------------------------------* + * Global function definitions + *-----------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Open() + * + * Allocate a ring buffer for TD data with the given capacity of TD samples per channel. + * + * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. + *---------------------------------------------------------------------*/ + +ivas_error ivas_TD_RINGBUF_Open( + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ + const Word16 num_channels /* i : Number of channels */ +) +{ + TD_RINGBUF_HANDLE h; + Word32 capacity; + + capacity = L_mult0( capacity_per_channel, num_channels ); + move32(); + + h = malloc( sizeof( TD_RINGBUF_DATA ) ); + IF ( h == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); + } + h->data = NULL; + h->capacity = 0; + move32(); + h->num_channels = num_channels; + move16(); + h->write_pos = 0; + move32(); + h->read_pos = 0; + move32(); + h->is_full = 0; + move16(); + *ph = h; + + h->data = malloc( capacity * sizeof( Word32 ) ); + if ( h->data == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); + } + h->capacity = capacity; + move32(); + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Close() + * + * Dellocate TD ring buffer. The given handle will be set to NULL. + + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Close( + TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */ +) +{ + TD_RINGBUF_HANDLE h; + + IF ( ph == NULL ) + { + return; + } + h = *ph; + + IF ( h == NULL ) + { + return; + } + + IF ( h->data != NULL ) + { + free( h->data ); + } + + free( h ); + *ph = NULL; + + return; +} + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushInterleaved() + * + * Push samples from a buffer with interleaved channel layout onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushInterleaved( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +) +{ + ivas_td_ringbuf_push_interleaved( h, data, num_samples_per_channel, 1 ); + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushChannels() + * + * Push samples from channel pointers onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushChannels( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *p_channels[], /* i : Array of pointers to each input channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +) +#else +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Push() + * + * Push samples onto the back of the TD ring buffer. + * Returns total number of buffered samples (includes number of channels) + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Push( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ +) +#endif +{ + Word32 s; + Word16 c; + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + assert( h != NULL ); + assert( p_channels != NULL ); + for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + { + assert( p_channels[c] != NULL ); + } +#endif + assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); + + FOR ( s = 0; s < num_samples_per_channel; ++s ) + { + FOR ( c = 0; c < h->num_channels; ++c ) + { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + h->data[h->write_pos] = p_channels[c][s]; + move32(); +#else + h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; + move32(); +#endif + ++h->write_pos; + + if ( EQ_32( h->write_pos, h->capacity ) ) + { + h->write_pos = 0; + move32(); + } + } + } + + if ( EQ_32( h->read_pos, h->write_pos ) ) + { + h->is_full = 1; + move16(); + } + + return; +} + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushConstant() + * + * Push samples with a constant value onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushConstant( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 value, /* i : Value to push */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ +) +{ + ivas_td_ringbuf_push_interleaved( h, &value, num_samples_per_channel, 0 ); + + return; +} +#else +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PushZeros() + * + * Push zero samples onto the back of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PushZeros( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word16 num_samples_per_channel /* i : Number of zeros per channel to store */ +) +{ + Word32 s; + Word16 c; + + assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); + if ( !num_samples_per_channel ) + { + return; + } + + FOR ( s = 0; s < num_samples_per_channel; ++s ) + { + FOR ( c = 0; c < h->num_channels; ++c ) + { + h->data[h->write_pos] = 0.f; + move32(); + ++h->write_pos; + + if ( EQ_32 ( h->write_pos == h->capacity ) ) + { + h->write_pos = 0; + move32(); + } + } + } + + if ( EQ_32( h->read_pos == h->write_pos ) ) + { + h->is_full = 1; + move16(); + } + + return; +} +#endif + + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_PopChannels() + * + * Pop samples from the front of the TD ring buffer to an array of channel pointers. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_PopChannels( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *p_channels[], /* i : Array of pointers to each output channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ +) +#else +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Pop() + * + * Pop samples from the front of the TD ring buffer. + *---------------------------------------------------------------------*/ + +void ivas_TD_RINGBUF_Pop( + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve */ +) +#endif +{ + Word32 s; + Word16 c; + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + assert( h != NULL ); + assert( p_channels != NULL ); + for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + { + assert( p_channels[c] != NULL ); + } +#endif + assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); + + FOR ( s = 0; s < num_samples_per_channel; ++s ) + { + FOR ( c = 0; c < h->num_channels; ++c ) + { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + p_channels[c][s] = h->data[h->read_pos]; + move32(); +#else + data[L_add( L_mult0( c, num_samples_per_channel ), s )) = h->data[h->read_pos]; + move32(); +#endif + ++h->read_pos; + + IF ( EQ_32( h->read_pos, h->capacity ) ) + { + h->read_pos = 0; + move32(); + } + } + } + +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + if ( NE_16( num_samples_per_channel, 0 ) ) + { + h->is_full = 0; + move16(); + } +#else + if ( h->is_full ) + { + h->is_full = 0; + move16(); + } +#endif + + return; +} + + +/*---------------------------------------------------------------------* + * ivas_TD_RINGBUF_Size() + * + * Returns number of buffered samples per channel. + *---------------------------------------------------------------------*/ + +Word16 ivas_TD_RINGBUF_Size( + const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ +) +{ + return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; // TODO(sgi): port division +} +#endif diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 5827cc275..52eba4dd1 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8888,6 +8888,20 @@ static ivas_error getSamplesInternal( } Word32 *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + // TODO(sgi): This doesn't match the original MR. BASOP main too far behind. Port later. + Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + { + for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + { + p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; + p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; + } + } +#endif FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { @@ -8965,10 +8979,21 @@ static ivas_error getSamplesInternal( Q_out[0] = Q_out[0] + *outAudio.pq_fact; } +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, + p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) +#else + IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, + hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, + hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, + &bits, + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) +#endif { return error; } -- GitLab From 37809ee34e1ee17b7239fdcae6501eaab88e39c1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 27 Oct 2025 15:43:35 +0100 Subject: [PATCH 035/351] port FIX_1330_JBM_MEMORY --- lib_com/ivas_prot_fx.h | 10 +++++ lib_com/ivas_tools_fx.c | 13 ++++++ lib_com/options.h | 2 +- lib_dec/ivas_init_dec_fx.c | 17 +++++++- lib_dec/ivas_ism_dec_fx.c | 21 +++++++++- lib_dec/ivas_ism_renderer_fx.c | 19 +++++++-- lib_dec/ivas_jbm_dec_fx.c | 41 +++++++++++++++++++ lib_dec/ivas_masa_dec_fx.c | 13 ++++++ lib_dec/ivas_mct_dec_fx.c | 11 +++++- lib_dec/ivas_omasa_dec_fx.c | 38 ++++++++++++++++-- lib_dec/ivas_osba_dec_fx.c | 30 +++++++++++++- lib_dec/ivas_sba_dec_fx.c | 14 ++++++- lib_dec/ivas_stat_dec.h | 4 ++ lib_rend/ivas_output_init_fx.c | 72 +++++++++++++++++++++++++++++++++- 14 files changed, 290 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 652f8ccd0..02088e1e6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1072,8 +1072,12 @@ void ivas_omasa_separate_object_render_jbm_fx( const UWord16 nSamplesRendered, /* i : number of samples rendered */ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal */ Word32 *output_fx[], /* o : rendered time signal */ +#ifdef FIX_1330_JBM_MEMORY + const Word16 subframes_rendered /* i : number of subframes rendered */ +#else const Word16 subframes_rendered, /* i : number of subframes rendered */ const Word16 slots_rendered /* i : number of CLDFB slots rendered */ +#endif ); void get_panning_gain_fx( @@ -4041,8 +4045,14 @@ ivas_error ivas_init_encoder_fx( ivas_error ivas_output_buff_dec_fx( Word32 *p_output_fx[], /* i/o: output audio buffers */ +#ifdef FIX_1330_JBM_MEMORY + const Word16 nchan_out_buff, /* i : number of output channels */ + const Word16 Opt_tsm, /* i : TSM option flag */ + DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ +#else const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */ const Word16 nchan_out_buff /* i : number of output channels */ + #endif ); ivas_error ivas_dec_get_format_fx( diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index dc5c3b4e2..515a10cdb 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -202,12 +202,25 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( ) { Word16 ch, m; +#ifdef FIX_1330_JBM_MEMORY + Word32 buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* temp buffer needed when "*audio[]" and "*audio_out[]" are the same */ + + FOR( ch = 0; ch < n_channels; ch++ ) + { + Copy32( audio[ch], buffer[ch], frame_length ); + } +#endif + FOR( ch = 0; ch < n_channels; ch++ ) { FOR( m = 0; m < frame_length; m++ ) { +#ifdef FIX_1330_JBM_MEMORY + audio_out[m * n_channels + ch] = buffer[ch][m]; +#else audio_out[m * n_channels + ch] = audio[ch][m]; +#endif move32(); } } diff --git a/lib_com/options.h b/lib_com/options.h index f62881bb8..b0d91c86c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,7 @@ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define NONBE_FIX_1197_OMASA_META_BUFFER /* Nokia: OMASA ISM_MASA_MODE_PARAM_ONE_OBJ history zero in rateswitching - port 251 */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ - +#define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 33ea403fe..0ff615a41 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1494,6 +1494,9 @@ ivas_error ivas_init_decoder_fx( Word16 sce_id, cpe_id; Word16 numCldfbAnalyses, numCldfbSyntheses; Word16 granularity, n_channels_transport_jbm; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#endif Word32 output_Fs, ivas_total_brate, tmp_br, tmp32; Word32 delay_ns; AUDIO_CONFIG output_config; @@ -2938,7 +2941,7 @@ ivas_error ivas_init_decoder_fx( test(); test(); - IF( ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && st_ivas->hDecoderConfig->Opt_tsm ) + IF( ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && hDecoderConfig->Opt_tsm ) { IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { @@ -2953,6 +2956,13 @@ ivas_error ivas_init_decoder_fx( * Allocate output audio buffers *-----------------------------------------------------------------*/ +#ifdef FIX_1330_JBM_MEMORY + nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } +#else #ifdef FIX_NCHAN_BUFFERS k = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); FOR( n = 0; n < k; n++ ) @@ -2971,6 +2981,7 @@ ivas_error ivas_init_decoder_fx( { st_ivas->p_output_fx[n] = NULL; } +#endif return error; } @@ -3453,11 +3464,15 @@ void ivas_destroy_dec_fx( /* output audio buffers */ FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { +#ifdef FIX_1330_JBM_MEMORY + st_ivas->p_output_fx[i] = NULL; +#else IF( st_ivas->p_output_fx[i] != NULL ) { free( st_ivas->p_output_fx[i] ); st_ivas->p_output_fx[i] = NULL; } +#endif } /* main IVAS handle */ diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index f225b793f..18de8307b 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -59,7 +59,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Word16 tc_nchan_tc_new; Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff, nchan_out_buff_old; +#endif nCPE_old = st_ivas->nCPE; move16(); @@ -74,7 +78,9 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; move16(); +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#endif IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) ) { @@ -307,6 +313,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( return error; } +#ifndef FIX_1330_JBM_MEMORY /*-----------------------------------------------------------------* * output audio buffers *-----------------------------------------------------------------*/ @@ -317,7 +324,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { return error; } - +#endif /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ @@ -370,6 +377,18 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } +#ifdef FIX_1330_JBM_MEMORY + + /*-----------------------------------------------------------------* + * output audio buffers + *-----------------------------------------------------------------*/ + + nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 64c7f7b08..85d333c94 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -218,6 +218,7 @@ void ivas_ism_render_sf_fx( ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 ); } +#ifndef FIX_1330_JBM_MEMORY IF( st_ivas->hDecoderConfig->Opt_tsm ) { FOR( i = 0; i < num_objects; i++ ) @@ -227,12 +228,15 @@ void ivas_ism_render_sf_fx( } ELSE { +#endif FOR( i = 0; i < num_objects; i++ ) { Copy32( &output_fx[i][tc_offset], tc_local_fx[i], n_samples_to_render ); p_tc_fx[i] = tc_local_fx[i]; } +#ifndef FIX_1330_JBM_MEMORY } +#endif FOR( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { @@ -507,8 +511,12 @@ void ivas_omasa_separate_object_render_jbm_fx( const UWord16 nSamplesRendered, /* i : number of samples rendered */ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal Q11*/ Word32 *output_fx[], /* o : rendered time signal Q11*/ - const Word16 subframes_rendered, /* i : number of subframes rendered */ - const Word16 slots_rendered /* i : number of CLDFB slots rendered */ +#ifdef FIX_1330_JBM_MEMORY + const Word16 subframes_rendered /* i : number of subframes rendered */ +#else + const Word16 subframes_rendered, /* i : number of subframes rendered */ + const Word16 slots_rendered /* i : number of CLDFB slots rendered */ +#endif ) { VBAP_HANDLE hVBAPdata; @@ -557,13 +565,15 @@ void ivas_omasa_separate_object_render_jbm_fx( move16(); } +#ifndef FIX_1330_JBM_MEMORY offsetSamples = i_mult( slots_rendered, hSpatParamRendCom->slot_size ); - +#endif FOR( j = 0; j < nchan_out_woLFE + num_lfe; j++ ) { output_fx_local[j] = output_fx[j]; } +#ifndef FIX_1330_JBM_MEMORY IF( st_ivas->hDecoderConfig->Opt_tsm ) { FOR( obj = 0; obj < num_objects; obj++ ) @@ -574,12 +584,15 @@ void ivas_omasa_separate_object_render_jbm_fx( } ELSE { +#endif FOR( obj = 0; obj < num_objects; obj++ ) { input_fx[obj] = input_fx_in[obj]; move32(); } +#ifndef FIX_1330_JBM_MEMORY } +#endif slots_to_render = idiv1616( nSamplesRendered, hSpatParamRendCom->slot_size ); first_sf = subframes_rendered; diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ba7c429bf..5e5c2f262 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1573,7 +1573,11 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( Word32 *p_data_fx[MAX_CLDFB_DIGEST_CHANNELS]; #endif Word16 n, n_render_timeslots, n_ch_cldfb; +#ifdef FIX_1330_JBM_MEMORY + Word16 ch, offset, len_offset; +#else Word16 ch; +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; @@ -1599,6 +1603,23 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); +#ifdef FIX_1330_JBM_MEMORY + /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': + in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffers + pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */ + len_offset = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ); + IF( LT_16( len_offset, L_FRAME48k ) ) + { + offset = 0; + move16(); + FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch++ ) + { + hTcBuffer->tc_fx[ch] = &hTcBuffer->tc_buffer_fx[offset]; + offset = add( offset, len_offset ); + } + } + +#endif FOR( ch = 0; ch < n_ch_full_copy; ch++ ) { Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); @@ -3633,6 +3654,9 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( IF( Opt_tsm ) { n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS ); +#ifdef FIX_1330_JBM_MEMORY + n_samp_full = s_max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */ +#endif n_samp_residual = add( hTcBuffer->n_samples_granularity, 1 ); } ELSE @@ -3693,6 +3717,10 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( } } +#ifdef FIX_1330_JBM_MEMORY + hTcBuffer->tc_buffer2_fx = NULL; + +#endif return IVAS_ERR_OK; } @@ -3730,6 +3758,14 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; } } +#ifdef FIX_1330_JBM_MEMORY + + IF( hTcBuffer->tc_buffer2_fx != NULL ) + { + free( hTcBuffer->tc_buffer2_fx ); + hTcBuffer->tc_buffer2_fx = NULL; + } +#endif } return; @@ -4077,7 +4113,12 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( FOR( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { +#ifdef FIX_1330_JBM_MEMORY + output_fx[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered; + move32(); +#else Copy32( st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output_fx[ch_idx], *nSamplesRendered ); +#endif } st_ivas->hTcBuffer->subframes_rendered = last_sf; diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index fe3f7fee9..fd12b1fca 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1696,7 +1696,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( UWord32 ivas_total_brate, last_ivas_total_brate; Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; #ifdef FIX_NCHAN_BUFFERS +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff_old, nchan_out_buff; +#endif #endif ivas_error error; Word32 ism_total_brate; @@ -1707,7 +1711,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; move32(); #ifdef FIX_NCHAN_BUFFERS +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#endif #endif test(); @@ -1946,6 +1952,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( ivas_masa_set_elements_fx( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); + /*-----------------------------------------------------------------* + * JBM TC buffers + *-----------------------------------------------------------------*/ { Word16 tc_nchan_to_allocate; Word16 tc_nchan_transport; @@ -2068,7 +2077,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) /* note: switching with OMASA is addressed in ivas_omasa_dec_config() */ { nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 027299b99..5494118c7 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -902,13 +902,19 @@ static ivas_error ivas_mc_dec_reconfig_fx( Word16 tc_nchan_tc_new; Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff_old, nchan_out_buff; +#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); nchan_transport_old = st_ivas->nchan_transport; move16(); +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#endif last_mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ /* temporally set the current mc_mode back to the previous one to make sure the following call to @@ -1643,8 +1649,11 @@ static ivas_error ivas_mc_dec_reconfig_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); - +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 4749fc22d..959554acf 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -491,7 +491,11 @@ ivas_error ivas_omasa_dec_config_fx( Word32 brate_SCE, brate_CPE; ISM_MODE ism_mode_old; IVAS_FORMAT ivas_format_orig; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff, nchan_out_buff_old; +#endif ivas_error error; RENDERER_TYPE old_renderer_type; @@ -512,9 +516,10 @@ ivas_error ivas_omasa_dec_config_fx( st_ivas->ivas_format = st_ivas->last_ivas_format; move16(); ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); move16(); - +#endif st_ivas->ivas_format = ivas_format_orig; move16(); @@ -812,7 +817,11 @@ ivas_error ivas_omasa_dec_config_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -1089,20 +1098,29 @@ void ivas_omasa_dirac_rend_jbm_fx( ) { Word16 subframes_rendered; +#ifndef FIX_1330_JBM_MEMORY Word16 slots_rendered; +#endif Word16 n; Word32 data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; +#ifndef FIX_1330_JBM_MEMORY test(); IF( !st_ivas->hDecoderConfig->Opt_tsm ) { - *nSamplesRendered = min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); +#endif + *nSamplesRendered = s_min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { Copy32( &output_fx[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + +#ifdef FIX_1330_JBM_MEMORY + IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) +#else + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) +#endif { /* Gain separated object, if edited */ FOR( n = 0; n < st_ivas->nchan_ism; n++ ) @@ -1123,7 +1141,11 @@ void ivas_omasa_dirac_rend_jbm_fx( Copy32( &output_fx[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); /* Gain discrete objects, if edited */ - IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#ifdef FIX_1330_JBM_MEMORY + IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#else + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#endif { v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 @@ -1140,12 +1162,16 @@ void ivas_omasa_dirac_rend_jbm_fx( } } } +#ifndef FIX_1330_JBM_MEMORY } +#endif subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; move16(); +#ifndef FIX_1330_JBM_MEMORY slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; move16(); +#endif ivas_dirac_dec_render_fx( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_fx ); @@ -1154,7 +1180,11 @@ void ivas_omasa_dirac_rend_jbm_fx( scale_sig32( st_ivas->hIsmRendererData->prev_gains_fx[ind1], MAX_OUTPUT_CHANNELS, -1 ); // Q30 -> Q29 } +#ifdef FIX_1330_JBM_MEMORY + ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered ); +#else ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered, slots_rendered ); +#endif FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) { diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 67908e996..68ac3ea88 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -282,15 +282,25 @@ ivas_error ivas_osba_render_sf_fx( ) { Word16 n; +#ifdef FIX_1330_JBM_MEMORY + Word32 output_sba[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + Word32 *p_output_sba[MAX_OUTPUT_CHANNELS]; +#else Word32 output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word32 *p_output_ism[MAX_OUTPUT_CHANNELS]; +#endif ivas_error error; FOR( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { +#ifdef FIX_1330_JBM_MEMORY + p_output_sba[n] = output_sba[n]; +#else p_output_ism[n] = &output_ism[n][0]; +#endif } +#ifndef FIX_1330_JBM_MEMORY if ( !st_ivas->hDecoderConfig->Opt_tsm ) { Word16 tc_offset; @@ -300,23 +310,41 @@ ivas_error ivas_osba_render_sf_fx( v_shr( &p_output[n][tc_offset], Q11 - Q11, &output_ism[n][tc_offset], nSamplesAsked ); // Q11 } } - +#endif +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output_sba ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ), IVAS_ERR_OK ) ) +#endif { return error; } IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { +#ifdef FIX_1330_JBM_MEMORY + ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered ); +#else ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered ); +#endif } FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) { IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { +#ifdef FIX_1330_JBM_MEMORY + v_add_fx_no_hdrm( p_output[n], p_output_sba[n], p_output[n], *nSamplesRendered ); +#else v_add_fx_no_hdrm( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered ); +#endif + } +#ifdef FIX_1330_JBM_MEMORY + ELSE + { + Copy32( p_output_sba[n], p_output[n], *nSamplesRendered ); } +#endif } return IVAS_ERR_OK; diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index ea7e100a1..ca44eff33 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -117,8 +117,12 @@ ivas_error ivas_sba_dec_reconfigure_fx( Word32 ivas_total_brate; Word32 last_ivas_total_brate; Word16 num_channels, num_md_sub_frames; +#ifdef FIX_1330_JBM_MEMORY + Word16 nchan_out_buff; +#else Word16 nchan_out_buff, nchan_out_buff_old; Word16 sba_analysis_order_old_flush; +#endif DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; ISM_MODE ism_mode_old; @@ -131,16 +135,19 @@ ivas_error ivas_sba_dec_reconfigure_fx( move32(); last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; move32(); +#ifndef FIX_1330_JBM_MEMORY sba_analysis_order_old_flush = st_ivas->sba_analysis_order; move16(); +#endif /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ +#ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate ); - +#endif ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -749,8 +756,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ - +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) +#else IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index cf8017fb5..e02105fd8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1032,6 +1032,10 @@ typedef struct decoder_tc_buffer_structure Word16 num_slots; Word16 n_samples_discard; /* number of samples to discard from the beginning of the output */ +#ifdef FIX_1330_JBM_MEMORY + Word32 *tc_buffer2_fx; /* non-scaled buffer of output audio - needed only when '*tc_buffer* is not long enough */ + +#endif } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; typedef struct jbm_metadata_structure diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 0e2b264a8..5969fac17 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -566,11 +566,80 @@ Word16 ivas_get_nchan_buffers_dec_fx( *-------------------------------------------------------------------*/ ivas_error ivas_output_buff_dec_fx( - Word32 *p_output_fx[], /* i/o: output audio buffers */ + Word32 *p_output_fx[], /* i/o: output audio buffers */ +#ifdef FIX_1330_JBM_MEMORY + const Word16 nchan_out_buff, /* i : number of output channels */ + const Word16 Opt_tsm, /* i : TSM option flag */ + DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ +#else const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */ const Word16 nchan_out_buff /* i : number of output channels */ +#endif ) { +#ifdef FIX_1330_JBM_MEMORY + Word16 ch, nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset; + + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) + { + p_output_fx[ch] = NULL; + } + + IF( hTcBuffer->tc_buffer2_fx != NULL ) + { + free( hTcBuffer->tc_buffer2_fx ); + hTcBuffer->tc_buffer2_fx = NULL; + } + + nchan_tc_jbm = 0; + move16(); + if ( Opt_tsm ) + { + /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer->tc[]' */ + nchan_tc_jbm = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + } + + test(); + IF( LE_16( nchan_out_buff, nchan_tc_jbm ) && !Opt_tsm ) + { + FOR( ch = 0; ch < nchan_out_buff; ch++ ) + { + p_output_fx[ch] = hTcBuffer->tc_fx[ch]; + } + } + ELSE + { + FOR( ch = 0; ch < nchan_tc_jbm; ch++ ) + { + p_output_fx[ch] = hTcBuffer->tc_fx[ch]; + } + + /* non-JBM decoding: allocate output audio buffers */ + /* JBM decoding: when not enough audio buffers 'hTcBuffer->tc[]', allocate additional buffers */ + n_samp_full = ( 48000 / FRAMES_PER_SEC ); + move16(); + nsamp_to_allocate = imult1616( sub( nchan_out_buff, nchan_tc_jbm ), n_samp_full ); + + IF( GT_16( nsamp_to_allocate, 0 ) ) + { + /* note: these are intra-frame heap memories */ + IF( ( hTcBuffer->tc_buffer2_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output audio buffer!\n" ) ); + } + + set_zero_fx( hTcBuffer->tc_buffer2_fx, nsamp_to_allocate ); + } + + offset = 0; + move16(); + FOR( ; ch < nchan_out_buff; ch++ ) + { + p_output_fx[ch] = &hTcBuffer->tc_buffer2_fx[offset]; + offset = add( offset, n_samp_full ); + } + } +#else Word16 ch; IF( GT_16( nchan_out_buff, nchan_out_buff_old ) ) @@ -600,6 +669,7 @@ ivas_error ivas_output_buff_dec_fx( p_output_fx[ch] = NULL; } } +#endif return IVAS_ERR_OK; } -- GitLab From f14d119d02d7c6911f74d2ee236defecb43d4184 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 27 Oct 2025 12:35:22 -0400 Subject: [PATCH 036/351] possible fix to 2015 --- lib_com/options.h | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index ea5fad27e..1ee92b2ac 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -81,7 +81,7 @@ #define FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING /* FhG: Replace L_shl with L_shl_sat to prevent overflow when calculating scale factors for very small numbers in the logarithmic domain */ #define FIX_APA_EXECS_SCALING /* VA: fix scaling of JBM APA buffer */ #define FIX_2164_ASSERT_IN_OMASA_PREPROC_FOR_EDIT /* Nokia: Issue 2164: Prevent overflow when calculating equalization coefficient for editing before clamping to safe range */ - +#define FIX_2015_PREMPH_SAT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index fff73a248..aaa0c396a 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -231,7 +231,11 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) +#ifndef FIX_2015_PREMPH_SAT Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); +#else + Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 + 1 ) ); +#endif Q_min = s_max( -2, Q_min ); Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min st->q_inp = Q_min; -- GitLab From b8da0931b106f96c8b95f9932356158c53140db3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 27 Oct 2025 21:11:37 +0100 Subject: [PATCH 037/351] fix --- lib_dec/ivas_cpe_dec_fx.c | 100 ++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 743add272..fadd84415 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -1068,7 +1068,11 @@ static ivas_error stereo_dft_dec_main( FOR( n = 0; n < hCPE->nchan_out; n++ ) { - Scale_sig32( output[n], L_FRAME48k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft +#ifdef FIX_1330_JBM_MEMORY + Scale_sig32( output[n], output_frame, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft +#else + Scale_sig32( output[n], L_FRAME48k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft +#endif scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[n] = hCPE->hStereoDft->q_dft; move16(); @@ -1082,7 +1086,11 @@ static ivas_error stereo_dft_dec_main( FOR( n = 0; n < hCPE->nchan_out; n++ ) { - Scale_sig32( output[n], L_FRAME48k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 +#ifdef FIX_1330_JBM_MEMORY + Scale_sig32( output[n], output_frame, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 +#else + Scale_sig32( output[n], L_FRAME48k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 +#endif scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[n] = Q11; move16(); @@ -1094,10 +1102,10 @@ static ivas_error stereo_dft_dec_main( #endif /*------------------------------------------------------------------------- - * create_cpe_dec_fx() - * - * Create, allocate and initialize IVAS decoder CPE handle - *-------------------------------------------------------------------------*/ + * create_cpe_dec_fx() + * + * Create, allocate and initialize IVAS decoder CPE handle + *-------------------------------------------------------------------------*/ ivas_error create_cpe_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -1116,8 +1124,8 @@ ivas_error create_cpe_dec( move32(); /*-----------------------------------------------------------------* - * Allocate CPE handle - *-----------------------------------------------------------------*/ + * Allocate CPE handle + *-----------------------------------------------------------------*/ IF( ( hCPE = (CPE_DEC_HANDLE) malloc( sizeof( CPE_DEC_DATA ) ) ) == NULL ) { @@ -1125,8 +1133,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * Initialization - general parameters - *-----------------------------------------------------------------*/ + * Initialization - general parameters + *-----------------------------------------------------------------*/ output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); @@ -1208,8 +1216,8 @@ ivas_error create_cpe_dec( move32(); /*-----------------------------------------------------------------* - * DFT stereo I/O Buffers: allocate and initialize - *-----------------------------------------------------------------*/ + * DFT stereo I/O Buffers: allocate and initialize + *-----------------------------------------------------------------*/ FOR( i = 0; i < CPE_CHANNELS; i++ ) { @@ -1278,8 +1286,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * CoreCoder, 2 instances: allocate and initialize - *-----------------------------------------------------------------*/ + * CoreCoder, 2 instances: allocate and initialize + *-----------------------------------------------------------------*/ FOR( n = 0; n < CPE_CHANNELS; n++ ) { @@ -1313,8 +1321,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * DFT stereo initialization - *-----------------------------------------------------------------*/ + * DFT stereo initialization + *-----------------------------------------------------------------*/ test(); @@ -1327,8 +1335,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * DFT stereo mono DMX initialization - *-----------------------------------------------------------------*/ + * DFT stereo mono DMX initialization + *-----------------------------------------------------------------*/ test(); IF( NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->nchan_out, 1 ) ) @@ -1342,8 +1350,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * Temporal inter-channel alignment initialization - *-----------------------------------------------------------------*/ + * Temporal inter-channel alignment initialization + *-----------------------------------------------------------------*/ test(); test(); @@ -1359,8 +1367,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * Stereo IC BWE initialization - *-----------------------------------------------------------------*/ + * Stereo IC BWE initialization + *-----------------------------------------------------------------*/ test(); test(); @@ -1375,8 +1383,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * TD stereo initialization - *-----------------------------------------------------------------*/ + * TD stereo initialization + *-----------------------------------------------------------------*/ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) { @@ -1389,8 +1397,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * MDCT stereo initialization - *-----------------------------------------------------------------*/ + * MDCT stereo initialization + *-----------------------------------------------------------------*/ test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_ivas->nCPE, 1 ) ) @@ -1431,8 +1439,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * Stereo CNG initialization - *-----------------------------------------------------------------*/ + * Stereo CNG initialization + *-----------------------------------------------------------------*/ test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) || EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) @@ -1451,10 +1459,10 @@ ivas_error create_cpe_dec( /*------------------------------------------------------------------------- - * destroy_cpe_dec_fx() - * - * Destroy and deallocate IVAS decoder CPE handle - *-------------------------------------------------------------------------*/ + * destroy_cpe_dec_fx() + * + * Destroy and deallocate IVAS decoder CPE handle + *-------------------------------------------------------------------------*/ void destroy_cpe_dec( CPE_DEC_HANDLE hCPE /* i/o: CPE decoder structure */ @@ -1546,10 +1554,10 @@ void destroy_cpe_dec( /*------------------------------------------------------------------------- - * read_stereo_mode_and_bwidth_fx() - * - * Read stereo technology info & audio bandwidth - *-------------------------------------------------------------------------*/ + * read_stereo_mode_and_bwidth_fx() + * + * Read stereo technology info & audio bandwidth + *-------------------------------------------------------------------------*/ static void read_stereo_mode_and_bwidth_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ @@ -1559,8 +1567,8 @@ static void read_stereo_mode_and_bwidth_fx( Decoder_State **sts; /*-----------------------------------------------------------------* - * BFI or NO_DATA frame: Use stereo parameters from last (active) frame - *-----------------------------------------------------------------*/ + * BFI or NO_DATA frame: Use stereo parameters from last (active) frame + *-----------------------------------------------------------------*/ test(); if ( st_ivas->bfi || LT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) @@ -1570,8 +1578,8 @@ static void read_stereo_mode_and_bwidth_fx( } /*-----------------------------------------------------------------* - * SID frame: get element mode from SID side info - *-----------------------------------------------------------------*/ + * SID frame: get element mode from SID side info + *-----------------------------------------------------------------*/ ELSE IF( EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) { @@ -1629,8 +1637,8 @@ static void read_stereo_mode_and_bwidth_fx( } /*-----------------------------------------------------------------* - * active frame: read element mode and audio bandwidth info - *-----------------------------------------------------------------*/ + * active frame: read element mode and audio bandwidth info + *-----------------------------------------------------------------*/ ELSE { @@ -1683,10 +1691,10 @@ static void read_stereo_mode_and_bwidth_fx( /*------------------------------------------------------------------------- - * stereo_mode_combined_format_dec_fx() - * - * Set stereo format in a combined format - *-------------------------------------------------------------------------*/ + * stereo_mode_combined_format_dec_fx() + * + * Set stereo format in a combined format + *-------------------------------------------------------------------------*/ static void stereo_mode_combined_format_dec_fx( const Decoder_Struct *st_ivas, /* i : decoder main structure */ -- GitLab From cddb1368fbfc88f93512794f21a7ca1c9ffbc66b Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 27 Oct 2025 21:38:34 +0100 Subject: [PATCH 038/351] clang-format --- lib_dec/ivas_cpe_dec_fx.c | 88 +++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index fadd84415..cfb6c615b 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -1102,10 +1102,10 @@ static ivas_error stereo_dft_dec_main( #endif /*------------------------------------------------------------------------- - * create_cpe_dec_fx() - * - * Create, allocate and initialize IVAS decoder CPE handle - *-------------------------------------------------------------------------*/ + * create_cpe_dec_fx() + * + * Create, allocate and initialize IVAS decoder CPE handle + *-------------------------------------------------------------------------*/ ivas_error create_cpe_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -1124,8 +1124,8 @@ ivas_error create_cpe_dec( move32(); /*-----------------------------------------------------------------* - * Allocate CPE handle - *-----------------------------------------------------------------*/ + * Allocate CPE handle + *-----------------------------------------------------------------*/ IF( ( hCPE = (CPE_DEC_HANDLE) malloc( sizeof( CPE_DEC_DATA ) ) ) == NULL ) { @@ -1133,8 +1133,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * Initialization - general parameters - *-----------------------------------------------------------------*/ + * Initialization - general parameters + *-----------------------------------------------------------------*/ output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); @@ -1216,8 +1216,8 @@ ivas_error create_cpe_dec( move32(); /*-----------------------------------------------------------------* - * DFT stereo I/O Buffers: allocate and initialize - *-----------------------------------------------------------------*/ + * DFT stereo I/O Buffers: allocate and initialize + *-----------------------------------------------------------------*/ FOR( i = 0; i < CPE_CHANNELS; i++ ) { @@ -1286,8 +1286,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * CoreCoder, 2 instances: allocate and initialize - *-----------------------------------------------------------------*/ + * CoreCoder, 2 instances: allocate and initialize + *-----------------------------------------------------------------*/ FOR( n = 0; n < CPE_CHANNELS; n++ ) { @@ -1321,8 +1321,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * DFT stereo initialization - *-----------------------------------------------------------------*/ + * DFT stereo initialization + *-----------------------------------------------------------------*/ test(); @@ -1335,8 +1335,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * DFT stereo mono DMX initialization - *-----------------------------------------------------------------*/ + * DFT stereo mono DMX initialization + *-----------------------------------------------------------------*/ test(); IF( NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->nchan_out, 1 ) ) @@ -1350,8 +1350,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * Temporal inter-channel alignment initialization - *-----------------------------------------------------------------*/ + * Temporal inter-channel alignment initialization + *-----------------------------------------------------------------*/ test(); test(); @@ -1367,8 +1367,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * Stereo IC BWE initialization - *-----------------------------------------------------------------*/ + * Stereo IC BWE initialization + *-----------------------------------------------------------------*/ test(); test(); @@ -1383,8 +1383,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * TD stereo initialization - *-----------------------------------------------------------------*/ + * TD stereo initialization + *-----------------------------------------------------------------*/ IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) { @@ -1397,8 +1397,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * MDCT stereo initialization - *-----------------------------------------------------------------*/ + * MDCT stereo initialization + *-----------------------------------------------------------------*/ test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_ivas->nCPE, 1 ) ) @@ -1439,8 +1439,8 @@ ivas_error create_cpe_dec( } /*-----------------------------------------------------------------* - * Stereo CNG initialization - *-----------------------------------------------------------------*/ + * Stereo CNG initialization + *-----------------------------------------------------------------*/ test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) || EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) @@ -1459,10 +1459,10 @@ ivas_error create_cpe_dec( /*------------------------------------------------------------------------- - * destroy_cpe_dec_fx() - * - * Destroy and deallocate IVAS decoder CPE handle - *-------------------------------------------------------------------------*/ + * destroy_cpe_dec_fx() + * + * Destroy and deallocate IVAS decoder CPE handle + *-------------------------------------------------------------------------*/ void destroy_cpe_dec( CPE_DEC_HANDLE hCPE /* i/o: CPE decoder structure */ @@ -1554,10 +1554,10 @@ void destroy_cpe_dec( /*------------------------------------------------------------------------- - * read_stereo_mode_and_bwidth_fx() - * - * Read stereo technology info & audio bandwidth - *-------------------------------------------------------------------------*/ + * read_stereo_mode_and_bwidth_fx() + * + * Read stereo technology info & audio bandwidth + *-------------------------------------------------------------------------*/ static void read_stereo_mode_and_bwidth_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ @@ -1567,8 +1567,8 @@ static void read_stereo_mode_and_bwidth_fx( Decoder_State **sts; /*-----------------------------------------------------------------* - * BFI or NO_DATA frame: Use stereo parameters from last (active) frame - *-----------------------------------------------------------------*/ + * BFI or NO_DATA frame: Use stereo parameters from last (active) frame + *-----------------------------------------------------------------*/ test(); if ( st_ivas->bfi || LT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) @@ -1578,8 +1578,8 @@ static void read_stereo_mode_and_bwidth_fx( } /*-----------------------------------------------------------------* - * SID frame: get element mode from SID side info - *-----------------------------------------------------------------*/ + * SID frame: get element mode from SID side info + *-----------------------------------------------------------------*/ ELSE IF( EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) { @@ -1637,8 +1637,8 @@ static void read_stereo_mode_and_bwidth_fx( } /*-----------------------------------------------------------------* - * active frame: read element mode and audio bandwidth info - *-----------------------------------------------------------------*/ + * active frame: read element mode and audio bandwidth info + *-----------------------------------------------------------------*/ ELSE { @@ -1691,10 +1691,10 @@ static void read_stereo_mode_and_bwidth_fx( /*------------------------------------------------------------------------- - * stereo_mode_combined_format_dec_fx() - * - * Set stereo format in a combined format - *-------------------------------------------------------------------------*/ + * stereo_mode_combined_format_dec_fx() + * + * Set stereo format in a combined format + *-------------------------------------------------------------------------*/ static void stereo_mode_combined_format_dec_fx( const Decoder_Struct *st_ivas, /* i : decoder main structure */ -- GitLab From 3d9077858ba6abad1d82de695378bd067b7fb336 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 27 Oct 2025 22:34:11 +0100 Subject: [PATCH 039/351] fix porting --- lib_dec/ivas_omasa_dec_fx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 959554acf..80eadc072 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1153,7 +1153,11 @@ void ivas_omasa_dirac_rend_jbm_fx( } /* Gain MASA part, if edited */ - IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) +#ifdef FIX_1330_JBM_MEMORY + IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->masa_gain_is_edited ) +#else + IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) +#endif { FOR( n = 0; n < 2; n++ ) { -- GitLab From 117cfdb20d017ad2908f3c1c171ccf2dee0cfdbc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 28 Oct 2025 14:20:49 +0100 Subject: [PATCH 040/351] convert outstanding IF --- lib_enc/fd_cng_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 1a74fb616..0bbbdcbd7 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2755,8 +2755,8 @@ void stereoFdCngCoherence_fx( /* only estimate coherence in inactive frames (or in the first 50 frames to build an initial value) */ test(); test(); - // TODO: is there a BASOP for the ! ? - IF( !( LE_32( sts[0]->ini_frame, 50 ) || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) ) ) + test(); + IF( NE_16( ( LE_32( sts[0]->ini_frame, 50 ) || ( EQ_16( sts[0]->vad_flag, 0 ) && EQ_16( sts[1]->vad_flag, 0 ) ) ), 0 ) ) { return; } -- GitLab From 29b183a6918c671e197b65d0ea24ccd51a6dd2b0 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 28 Oct 2025 15:37:14 +0100 Subject: [PATCH 041/351] remove obsolete comments after they were clarified --- lib_dec/fd_cng_dec_fx.c | 6 ++---- lib_dec/ivas_ism_metadata_dec_fx.c | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 6759e0145..e8cf26bd4 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2934,13 +2934,12 @@ void generate_comfort_noise_dec_ivas_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG c1 = Sqrt16( hFdCngCom->coherence_fx[0], &temp ); /*Q15 - temp*/ #else - c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ + c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ #endif c1 = shl( c1, temp ); /*Q15*/ temp = 0; move16(); #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG - // TODO: float is "sqrt(1 - coherence)". Here MAX_16 is used for 1. coherence_fx is in Q15. Why isn't ONE_IN_Q15 used here? (which is different from MAX_16) c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx[0] ), &temp ); /*Q15 - temp*/ #else c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx ), &temp ); /*Q15 - temp*/ @@ -3050,7 +3049,6 @@ void generate_comfort_noise_dec_ivas_fx( c1 = shl( c1, temp ); /*Q15*/ temp = 0; move16(); - // TODO: float is "sqrt(1 - coherence)". Here MAX_16 is used for 1. coherence_fx is in Q15. Why isn't ONE_IN_Q15 used here? (which is different from MAX_16) c2 = Sqrt16( sub( MAX_16, hFdCngCom->coherence_fx[b] ), &temp ); /*Q15 - temp*/ c2 = shl( c2, temp ); /*Q15*/ @@ -3737,7 +3735,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG c1 = Sqrt16( hFdCngCom->coherence_fx[sub( MDCT_ST_DTX_NUM_COHERENCE_BANDS, 1 )], &s ); /*Q15 - s*/ #else - c1 = Sqrt16( hFdCngCom->coherence_fx, &s ); /*Q15 - s*/ + c1 = Sqrt16( hFdCngCom->coherence_fx, &s ); /*Q15 - s*/ #endif c1 = shl( c1, s ); // Q15 diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 3e1883220..449eb51cc 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -1251,7 +1251,6 @@ void ivas_ism_metadata_sid_dec_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG FOR( i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) { - // TODO: why not ONE_IN_Q15 ? (value there is different) hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[i] = 32767; } -- GitLab From daf4c5d67eb5d791bcd21ae2ce8fc113dc306b71 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 28 Oct 2025 15:51:48 +0100 Subject: [PATCH 042/351] align coherence value reading between files --- lib_dec/ivas_ism_metadata_dec_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 449eb51cc..54cc5da15 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -1263,8 +1263,7 @@ void ivas_ism_metadata_sid_dec_fx( idx = get_next_indice_fx( st0, nBits_coh ); #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG - // TODO: why is this different from the dequantization in ivas_decision_matrix_dec()? There, a table is used. Is this doing the same thing? - hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0] = div_s( idx, sub( ( shl( 1, nBits_coh ) ), 1 ) ); // Q15 + hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0] = get_next_index_4_by_15[idx]; // Q15 move16(); FOR( i = 1; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) { -- GitLab From 51ff74c1d2280a7c582468775bc7be6f4638d05d Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 28 Oct 2025 16:11:54 +0100 Subject: [PATCH 043/351] Update LC3plus to v.1.6.1 --- Workspace_msvc/lib_lc3plus.vcxproj | 16 +- lib_isar/isar_lc3plus_common.c | 2 +- lib_isar/isar_lc3plus_common.h | 2 +- lib_isar/isar_lc3plus_dec.c | 2 +- lib_isar/isar_lc3plus_dec.h | 2 +- lib_isar/isar_lc3plus_enc.c | 2 +- lib_isar/isar_lc3plus_enc.h | 2 +- lib_isar/isar_lc3plus_payload.h | 2 +- lib_lc3plus/adjust_global_gain_fx.c | 28 +- lib_lc3plus/al_fec.c | 137 +- lib_lc3plus/apply_global_gain_fx.c | 12 +- lib_lc3plus/ari_codec.c | 182 ++- lib_lc3plus/attack_detector_fx.c | 6 +- lib_lc3plus/basop_mpy_lc3plus.c | 30 +- lib_lc3plus/basop_mpy_lc3plus.h | 14 +- lib_lc3plus/basop_util_lc3plus.c | 216 ++- lib_lc3plus/basop_util_lc3plus.h | 45 +- lib_lc3plus/com_entropy.c | 27 + lib_lc3plus/constants.c | 1094 ++++++++++++++- lib_lc3plus/constants.h | 103 +- lib_lc3plus/cutoff_bandwidth.c | 6 +- lib_lc3plus/dct2_fx.c | 191 ++- lib_lc3plus/dct4_fx.c | 17 +- lib_lc3plus/dec_entropy.c | 861 ++++++++++-- lib_lc3plus/{dec_lc3.c => dec_lc3plus.c} | 204 ++- lib_lc3plus/defines.h | 263 +++- lib_lc3plus/detect_cutoff_warped_fx.c | 29 +- lib_lc3plus/dynmem.c | 2 + lib_lc3plus/enc_entropy.c | 377 ++++- lib_lc3plus/{enc_lc3.c => enc_lc3plus.c} | 225 ++- lib_lc3plus/estimate_global_gain_fx.c | 627 +++++++-- lib_lc3plus/fft_lc3plus.c | 23 +- lib_lc3plus/functions.h | 291 +++- lib_lc3plus/imdct_fx.c | 26 +- lib_lc3plus/{lc3.c => lc3plus.c} | 67 +- lib_lc3plus/{lc3.h => lc3plus.h} | 46 +- lib_lc3plus/levinson_fx.c | 4 +- lib_lc3plus/license.h | 8 +- lib_lc3plus/ltpf_coder_fx.c | 147 +- lib_lc3plus/ltpf_decoder_fx.c | 690 +++++++-- lib_lc3plus/makefile | 180 --- lib_lc3plus/mdct_fx.c | 8 +- lib_lc3plus/mdct_shaping_fx.c | 4 +- lib_lc3plus/near_nyquist_detector_fx.c | 49 +- lib_lc3plus/noise_factor_fx.c | 42 +- lib_lc3plus/noise_filling_fx.c | 24 +- lib_lc3plus/olpa_fx.c | 46 +- lib_lc3plus/pc_apply_fx.c | 18 +- lib_lc3plus/pc_classify_fx.c | 79 +- lib_lc3plus/pc_main_fx.c | 6 +- lib_lc3plus/pc_update_fx.c | 10 +- lib_lc3plus/per_band_energy_fx.c | 44 +- lib_lc3plus/plc_apply_fx.c | 53 +- lib_lc3plus/plc_classify_fx.c | 101 +- lib_lc3plus/plc_damping_scrambling_fx.c | 135 +- lib_lc3plus/plc_lpc_scaling_fx.c | 6 +- lib_lc3plus/plc_main_fx.c | 6 +- lib_lc3plus/plc_noise_substitution_fx.c | 4 +- lib_lc3plus/plc_phecu_f0_refine_first_fx.c | 4 +- lib_lc3plus/plc_phecu_fec_hq_fx.c | 11 +- lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c | 4 +- lib_lc3plus/plc_phecu_peak_locator_fx.c | 4 +- lib_lc3plus/plc_phecu_setf0hz_fx.c | 4 +- lib_lc3plus/plc_phecu_tools_fx.c | 12 +- lib_lc3plus/plc_tdac_fx.c | 10 +- lib_lc3plus/plc_tdc_inverse_odft_fx.c | 23 +- lib_lc3plus/plc_tdc_lagwin_fx.c | 4 +- lib_lc3plus/plc_tdc_main_fx.c | 157 ++- lib_lc3plus/plc_tdc_pre_emphasis_fx.c | 29 +- lib_lc3plus/plc_update_aft_imdct_fx.c | 4 +- lib_lc3plus/plc_update_fx.c | 8 +- lib_lc3plus/plc_xcorr_fx.c | 4 +- lib_lc3plus/pvq_dec_fx.c | 136 +- lib_lc3plus/pvq_enc_fx.c | 718 +++++++++- lib_lc3plus/pvq_index_fx.c | 4 +- lib_lc3plus/quantize_spec_fx.c | 40 +- lib_lc3plus/reorder_bitstream_fx.c | 4 +- lib_lc3plus/resamp12k8_fx.c | 24 +- lib_lc3plus/residual_coding_fx.c | 56 +- lib_lc3plus/residual_decoding_fx.c | 56 +- lib_lc3plus/rom_basop_util_lc3plus.c | 66 +- lib_lc3plus/rom_basop_util_lc3plus.h | 18 +- lib_lc3plus/scale_signal24_fx.c | 4 +- lib_lc3plus/setup_com_lc3plus.c | 39 + .../{setup_dec_lc3.c => setup_dec_lc3plus.c} | 230 ++- .../{setup_dec_lc3.h => setup_dec_lc3plus.h} | 54 +- .../{setup_enc_lc3.c => setup_enc_lc3plus.c} | 319 ++++- .../{setup_enc_lc3.h => setup_enc_lc3plus.h} | 19 +- lib_lc3plus/sns_compute_scf_fx.c | 459 +++++- lib_lc3plus/sns_interpolate_scf_fx.c | 4 +- lib_lc3plus/sns_quantize_scf_fx.c | 1237 ++++++++++++++++- lib_lc3plus/tinywavein_c.h | 603 -------- lib_lc3plus/tinywaveout_c.h | 889 ------------ lib_lc3plus/tns_coder_fx.c | 49 +- lib_lc3plus/tns_decoder_fx.c | 34 +- 95 files changed, 9275 insertions(+), 2908 deletions(-) create mode 100644 lib_lc3plus/com_entropy.c rename lib_lc3plus/{dec_lc3.c => dec_lc3plus.c} (81%) rename lib_lc3plus/{enc_lc3.c => enc_lc3plus.c} (76%) rename lib_lc3plus/{lc3.c => lc3plus.c} (88%) rename lib_lc3plus/{lc3.h => lc3plus.h} (95%) delete mode 100644 lib_lc3plus/makefile mode change 100755 => 100644 lib_lc3plus/rom_basop_util_lc3plus.c create mode 100644 lib_lc3plus/setup_com_lc3plus.c rename lib_lc3plus/{setup_dec_lc3.c => setup_dec_lc3plus.c} (76%) rename lib_lc3plus/{setup_dec_lc3.h => setup_dec_lc3plus.h} (79%) rename lib_lc3plus/{setup_enc_lc3.c => setup_enc_lc3plus.c} (67%) rename lib_lc3plus/{setup_enc_lc3.h => setup_enc_lc3plus.h} (89%) delete mode 100644 lib_lc3plus/tinywavein_c.h delete mode 100644 lib_lc3plus/tinywaveout_c.h diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 71bb8e2a1..4d937cf64 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -113,15 +113,15 @@ - + - + - + @@ -166,8 +166,8 @@ - - + + @@ -181,11 +181,11 @@ - + - - + + diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 78269491c..28435cea9 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -33,7 +33,7 @@ #include "options.h" #include "isar_lc3plus_common.h" #include "ivas_error.h" -#include "lc3.h" +#include "lc3plus.h" /*-----------------------------------------------------------------------------------------* * Function ISAR_LC3PLUS_LC3plusErrToIvasErr() diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index b99348e0e..eb3e7b0ad 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -37,7 +37,7 @@ #include #include "options.h" #include "ivas_error.h" -#include "lc3.h" +#include "lc3plus.h" #include "isar_lc3plus_payload.h" /*! common configuration parameters between encoder and decoder */ diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index 279daee41..f8cbe9582 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -36,7 +36,7 @@ #include "ivas_prot_fx.h" #include "isar_lc3plus_dec.h" #include "isar_lc3plus_common.h" -#include "lc3.h" +#include "lc3plus.h" #include "ivas_error_utils.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h index f3e969940..8328b1fa7 100644 --- a/lib_isar/isar_lc3plus_dec.h +++ b/lib_isar/isar_lc3plus_dec.h @@ -35,7 +35,7 @@ #include #include "options.h" -#include "lc3.h" +#include "lc3plus.h" #include "ivas_error.h" #include "ivas_cnst.h" #include "isar_lc3plus_common.h" diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 2ed3cdb7b..af89213e6 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -32,7 +32,7 @@ #include "isar_lc3plus_enc.h" #include "isar_lc3plus_common.h" -#include "lc3.h" +#include "lc3plus.h" #include "ivas_error_utils.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h index f0c37afc8..6dd08733f 100644 --- a/lib_isar/isar_lc3plus_enc.h +++ b/lib_isar/isar_lc3plus_enc.h @@ -35,7 +35,7 @@ #include #include "ivas_error.h" -#include "lc3.h" +#include "lc3plus.h" #include "isar_lc3plus_common.h" #include "typedef.h" #include "isar_lc3plus_payload.h" diff --git a/lib_isar/isar_lc3plus_payload.h b/lib_isar/isar_lc3plus_payload.h index e95128578..580a58ca6 100644 --- a/lib_isar/isar_lc3plus_payload.h +++ b/lib_isar/isar_lc3plus_payload.h @@ -35,7 +35,7 @@ #include #include -#include "lc3.h" +#include "lc3plus.h" #include "options.h" diff --git a/lib_lc3plus/adjust_global_gain_fx.c b/lib_lc3plus/adjust_global_gain_fx.c index 0c3442061..5edf9b9fc 100644 --- a/lib_lc3plus/adjust_global_gain_fx.c +++ b/lib_lc3plus/adjust_global_gain_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" @@ -20,7 +22,7 @@ void processAdjustGlobalGain_fx(Word16 *gg_idx, Word16 gg_idx_min, Word16 gg_idx Word16 *gain_e, Word16 target, Word16 nBits, Word16 *gainChange, Word16 fs_idx #ifdef ENABLE_HR_MODE - , Word16 hrmode, Word16 frame_dms + , Word16 hrmode, LC3PLUS_FrameDuration frame_dms #endif ) { @@ -53,7 +55,7 @@ void processAdjustGlobalGain_fx(Word16 *gg_idx, Word16 gg_idx_min, Word16 gg_idx #endif /* DYNMEM_COUNT */ #ifdef ENABLE_HR_MODE - IF (sub(frame_dms, 25) == 0) + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_2p5MS) == 0) { IF (sub(target, 520) < 0) { @@ -64,14 +66,14 @@ void processAdjustGlobalGain_fx(Word16 *gg_idx, Word16 gg_idx_min, Word16 gg_idx gg_idx_inc_max = 40; move16(); } } - ELSE IF (sub(frame_dms, 50) == 0) + ELSE IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_5MS) == 0) { factor = 2; move16(); gg_idx_inc_max = 20; move16(); } - ELSE IF (sub(frame_dms, 75) == 0) + ELSE IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_7p5MS) == 0) { - factor = 40265318; move16(); // factor = 1.2 * 2^25 + factor = 40265318; move16(); /* factor = 1.2 * 2^25 */ gg_idx_inc_max = 12 ; move16(); } ELSE @@ -116,17 +118,17 @@ void processAdjustGlobalGain_fx(Word16 *gg_idx, Word16 gg_idx_min, Word16 gg_idx IF (sub(nBits, target) > 0) { gg_idx_inc = sub(nBits, target); - IF (sub(frame_dms, 75) == 0) + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_7p5MS) == 0) { - gg_idx_inc = extract_l(L_shr_pos(Mpy_32_16_lc3plus(factor, gg_idx_inc), 10)); // Mpy_32_16_lc3plus(1.2*2^25, gg_idx_inc), 25 - 15) - gg_idx_inc = BASOP_Util_Divide1616_Scale_lc3plus(gg_idx_inc, delta, &gg_idx_inc_s); + gg_idx_inc = extract_l(L_shr_pos(Mpy_32_16_lc3plus(factor, gg_idx_inc), 10)); + gg_idx_inc = BASOP_Util_Divide1616_Scale(gg_idx_inc, delta, &gg_idx_inc_s); gg_idx_inc = shr_sat(gg_idx_inc, sub(15, gg_idx_inc_s)); - gg_idx_inc = add(gg_idx_inc, 1); // adding 1 instead of 1.2 + gg_idx_inc = add(gg_idx_inc, 1); } ELSE { gg_idx_inc = extract_l(L_mult0(gg_idx_inc, factor)); - gg_idx_inc = BASOP_Util_Divide1616_Scale_lc3plus(gg_idx_inc, delta, &gg_idx_inc_s); + gg_idx_inc = BASOP_Util_Divide1616_Scale(gg_idx_inc, delta, &gg_idx_inc_s); gg_idx_inc = shr_sat(gg_idx_inc, sub(15, gg_idx_inc_s)); gg_idx_inc = add(gg_idx_inc, factor); } @@ -164,9 +166,9 @@ void processAdjustGlobalGain_fx(Word16 *gg_idx, Word16 gg_idx_min, Word16 gg_idx #endif *gain_e = add(extract_l(L_shr_pos(L_tmp, 25)), 1); /* get exponent */ #ifdef ENABLE_HR_MODE - *gain = BASOP_Util_InvLog2_lc3plus(L_or(L_tmp, (Word32)0xFE000000)); + *gain = BASOP_Util_InvLog2(L_or(L_tmp, (Word32)0xFE000000)); #else - *gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(L_tmp, (Word32)0xFE000000))); + *gain = round_fx(BASOP_Util_InvLog2(L_or(L_tmp, (Word32)0xFE000000))); #endif *gainChange = 1; move16(); } diff --git a/lib_lc3plus/al_fec.c b/lib_lc3plus/al_fec.c index efd1ed063..f8f1ee3b8 100644 --- a/lib_lc3plus/al_fec.c +++ b/lib_lc3plus/al_fec.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" @@ -43,7 +45,7 @@ #define ERROR_REPORT_EP1_OK ((0x1000)>>1) #define ERROR_REPORT_EP2_OK ((0x2000)>>1) #define ERROR_REPORT_EP3_OK ((0x4000)>>1) -#define ERROR_REPORT_EP4_OK ((0x8000)>>1) +#define ERROR_REPORT_EP4_OK ((0x8000)>>1) #define ERROR_REPORT_ALL_OK (ERROR_REPORT_EP1_OK | ERROR_REPORT_EP2_OK | ERROR_REPORT_EP3_OK | ERROR_REPORT_EP4_OK) /* debugging switches */ @@ -271,7 +273,7 @@ FEC_STATIC Word16 get_codeword_length(Word16 n_codewords, Word16 slot_nibbles, W ); slot_nibbles = sub(slot_nibbles, add(codeword_index, 1)); - slot_nibbles = sub(slot_nibbles, DEPR_i_mult(n_codewords, 13)); + slot_nibbles = sub(slot_nibbles, i_mult(n_codewords, 13)); FOR (i = 12; slot_nibbles >= 0; i++) { @@ -304,7 +306,7 @@ Word16 fec_get_data_size(Word16 fec_mode, Word16 ccc_flag, Word16 slot_bytes) } ELSE { - payload_size = sub(payload_size, DEPR_i_mult(sub(fec_mode, 1), n_codewords)); + payload_size = sub(payload_size, i_mult(sub(fec_mode, 1), n_codewords)); } IF (slot_bytes == 40) { @@ -336,7 +338,7 @@ Word16 fec_get_n_pc(Word16 fec_mode, Word16 n_pccw, Word16 slot_bytes) n_codewords = get_n_codewords(slot_bytes); assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); - pc_split = DEPR_i_mult(DEPR_i_mult(n_pccw, -2), sub(fec_mode, 1)); + pc_split = i_mult(i_mult(n_pccw, -2), sub(fec_mode, 1)); IF (fec_mode == 1 || slot_bytes < 80) { @@ -499,9 +501,9 @@ void fec_encoder(Word16 mode, Word16 epmr, UWord8 *iobuf, Word16 data_bytes, Wor int tmp = slot_bytes; assert((slot_bytes >= FEC_SLOT_BYTES_MIN && slot_bytes <= FEC_SLOT_BYTES_MAX) && "fec_encoder: slot_bytes out of range"); - tmp -= mode == 1 ? 1 : n_codewords * (mode - 1); // reed solomon redundancy - tmp -= slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode]; // crc1 - tmp -= (n_pccw > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0; // crc2 + tmp -= mode == 1 ? 1 : n_codewords * (mode - 1); /* reed solomon redundancy */ + tmp -= slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode]; /* crc1 */ + tmp -= (n_pccw > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0; /* crc2 */ assert(data_bytes == tmp && "fec_encoder: inconsistent payload size"); assert(n_codewords - n_pccw >= 6); } @@ -631,7 +633,7 @@ FEC_STATIC void fec_interleave_pack(UWord8 *out, UWord8 *in, Word16 n_nibbles, W assert(codeword_length == (n_nibbles - i - 1) / n_codewords + 1); FOR (j = 0; j < codeword_length; j++) { - out_offset = add(DEPR_i_mult(j, n_codewords), i); + out_offset = add(i_mult(j, n_codewords), i); out_offset = sub(n_nibbles, add(out_offset, 1)); out[out_offset >> 1] = (UWord8)s_or(out[out_offset >> 1], shl(in[cw_offset], shl(s_and(out_offset, 1), 2))); move16(); @@ -781,7 +783,7 @@ int fec_decoder(UWord8 *iobuf, Word16 slot_bytes, int *data_bytes, Word16 *epmr, } } #endif - + IF (sub(*bfi, 1) == 0) { *data_bytes = 0; move16(); @@ -794,6 +796,7 @@ int fec_decoder(UWord8 *iobuf, Word16 slot_bytes, int *data_bytes, Word16 *epmr, *data_bytes = fec_get_data_size(mode, ccc_flag, slot_bytes); move32(); pc_split = fec_get_n_pc(mode, *n_pccw, slot_bytes); n_crc = get_total_crc_size(slot_bytes, mode, pc_split); + UNUSED(n_crc); /* decoding of first code word */ redundancy_nibbles = sub(hamming_distance_by_mode0[mode], 1); @@ -897,7 +900,7 @@ FEC_STATIC void fec_deinterleave_unpack(UWord8 *out, UWord8 *in, Word16 n_nibble codeword_length = get_codeword_length(n_codewords, n_nibbles, i); FOR (j = 0; j < codeword_length; (j++, out_offset++)) { - in_offset = add(DEPR_i_mult(j, n_codewords), i); + in_offset = add(i_mult(j, n_codewords), i); in_offset = sub(n_nibbles, add(in_offset, 1)); out[out_offset] = (UWord8)s_and(shr(in[in_offset >> 1], shl(s_and(in_offset, 1), 2)), 15); move16(); } @@ -1060,7 +1063,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword n_mode_candidates = 0; move16(); risk_min_f.mantissa = SIMPLE_FLOAT_1_MANTISSA; move16(); risk_min_f.exponent = 0; move16(); - + IF (n_symb <= 80) { ep_risk_thresh.mantissa = EP_RISK_THRESH_NS_M; move16(); @@ -1071,16 +1074,16 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword ep_risk_thresh.mantissa = EP_RISK_THRESH_OS_M; move16(); ep_risk_thresh.exponent = EP_RISK_THRESH_OS_E; move16(); } - + syndr_calc[0] = &rs16_calculate_two_syndromes; syndr_calc[1] = &rs16_calculate_four_syndromes; syndr_calc[2] = &rs16_calculate_six_syndromes; - + FOR (i = 0; i < FEC_N_MODES; i++) { t[i] = (Word8)shr(sub(hamming_distance[i], 1), 1); move16(); } - + syndromes = my_scratch; my_scratch += FEC_TOTAL_SYNDROME_SIZE; elp = my_scratch; @@ -1091,25 +1094,25 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword my_scratch += FEC_TOTAL_ERROR_SIZE; deg_elp = (Word8 *)my_scratch; my_scratch += FEC_TOTAL_DEG_ELP_SIZE; - + *error_report = 0; move16(); *bfi = 0; move32(); - + /* mode detection (stage 1) */ codeword_length = get_codeword_length(n_codewords, n_symb, 0); - + epmr_position = sub(codeword_length, 1); - + rs16_calculate_two_syndromes(syndromes + SYNDROME_IDX(0, 0), iobuf, sub(codeword_length, 1)); - + IF (s_or(syndromes[0 + SYNDROME_IDX(0, 0)], syndromes[1 + SYNDROME_IDX(0, 0)]) == 0) { - + /* data validation for fec mode 1 */ *epmr = cw0_get_epmr(iobuf, epmr_position); - + dw0_bitswap(iobuf + 2, 1, n_symb / 2); - + IF (!crc1(iobuf + 8, sub(n_symb, 8), *epmr, iobuf + 2, 3, 1)) { mode = 0; move16(); @@ -1121,27 +1124,27 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword { /* reverse bit swap */ dw0_bitswap(iobuf + 2, 1, n_symb / 2); - + *epmr = add(*epmr, 4); move16(); } } - + blacklist[0] = 1; move16(); - + /* mode detection (stage 2) */ - + /* calculate syndromes of code words 0 to 5 and modes 1 to 3 */ cw_offset = 0; move16(); - + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) { codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - + rs16_calculate_six_syndromes(syndromes + SYNDROME_IDX(1, cw_counter), iobuf + cw_offset, sub(codeword_length, 1)); - + cw_offset = add(cw_offset, codeword_length); - + FOR (mode_counter = FEC_N_MODES - 1; mode_counter >= 1; mode_counter--) { FOR (i = 0; i < sub(hamming_distance[mode_counter], 1); i++) @@ -1168,14 +1171,14 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword n_broken_cw = add(n_broken_cw, 1); } } - + IF (n_broken_cw == 0) { mode = mode_counter; move16(); cw_offset = 0; move16(); - + *epmr = cw0_get_epmr(iobuf, epmr_position); - + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) { codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); @@ -1187,7 +1190,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword } } } - + IF (mode < 0) /* mode hasn't been detected so far -> errors occurred in transmission */ { /* calculate error locator polynomials for code words 0 to 5 */ @@ -1205,13 +1208,13 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword } } } - + /* risk analysis for mode candidate selection */ FOR (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) { dec_risk_f[mode_counter].mantissa = SIMPLE_FLOAT_1_MANTISSA; move16(); dec_risk_f[mode_counter].exponent = 0; move16(); - + IF (blacklist[mode_counter] == 0) { FOR (cw_counter = 0; cw_counter < 6; cw_counter++) @@ -1220,26 +1223,26 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword dec_risk_f[mode_counter], risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)]]); move16(); } - + IF (simple_float_cmp(dec_risk_f[mode_counter], ep_risk_thresh) <= 0) { mode_candidates[n_mode_candidates++] = mode_counter; move16(); } - + IF (simple_float_cmp(dec_risk_f[mode_counter], risk_min_f) < 0) { risk_min_f = dec_risk_f[mode_counter]; move16(); } } } - assert(n_mode_candidates <= 4); // suppress false gcc warning when OPTIM=3 - + assert(n_mode_candidates <= 4); /* suppress false gcc warning when OPTIM=3 */ + /* sort mode candidates by risk */ FOR (i = 0; i < n_mode_candidates; i++) { idx_min = i; move16(); val_min_f = dec_risk_f[mode_candidates[i]]; move16(); - + FOR (j = i + 1; j < n_mode_candidates; j++) { IF (simple_float_cmp(dec_risk_f[mode_candidates[j]], val_min_f) < 0) @@ -1248,24 +1251,24 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword idx_min = j; move16(); } } - + IF (sub(idx_min, i) > 0) - { + { tmp = mode_candidates[i]; move16(); mode_candidates[i] = mode_candidates[idx_min]; move16(); mode_candidates[idx_min] = tmp; move16(); } } - + /* try out candidate modes */ FOR (i = 0; i < n_mode_candidates; i++) { mode = mode_candidates[i]; move16(); - + FOR (cw_counter = 0; cw_counter < 6; cw_counter++) { codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - + IF (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) { IF (rs16_factorize_elp(err_pos + ERR_POS_IDX(mode, cw_counter), elp + ELP_IDX(mode, cw_counter), @@ -1283,34 +1286,34 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword BREAK; } } - + IF (mode < 0) { /* no decodable mode has been found */ *error_report = ERROR_REPORT_BEC_MASK; move16(); *bfi = 1; move32(); mode = -1; move16(); - + *epmr = fec_estimate_epmr_from_cw0(iobuf, t, syndromes, elp, deg_elp, err_pos, err_symb, n_codewords, n_symb); - + Dyn_Mem_Deluxe_Out(); return mode; } - + /* perform error correction */ cw_offset = 0; move16(); *error_report = 0; move16(); FOR (cw_counter = 0; cw_counter < 6; cw_counter++) { codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - + IF (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) { rs16_calculate_errors( err_symb + ERR_SYMB_IDX(mode, cw_counter), err_pos + ERR_POS_IDX(mode, cw_counter), syndromes + SYNDROME_IDX(mode, cw_counter), deg_elp[DEG_ELP_IDX(mode, cw_counter)], t[mode]); - + /* correct errors and sum up number of corrected bits */ FOR (i = 0; i < deg_elp[DEG_ELP_IDX(mode, cw_counter)]; i++) { @@ -1329,17 +1332,17 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword } } } - + FOR (i = 0; i <= EP_SIG_POLY_DEG; i++) { iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); } cw_offset = add(cw_offset, codeword_length); } - + /* set epmr according to risk value of cw0 */ epmr_dec_fail_increment = 8; - + IF (add(risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent, 8) <= 0) { epmr_dec_fail_increment = sub(epmr_dec_fail_increment, 4); @@ -1348,10 +1351,10 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword { epmr_dec_fail_increment = sub(epmr_dec_fail_increment, 4); } - + *epmr = cw0_get_epmr(iobuf, epmr_position) + epmr_dec_fail_increment; } - + /* mode has been successfully detected -> now check and try to correct remaining code words*/ *n_pccw = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); IF (ccc_flag == 0) @@ -1363,15 +1366,15 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword { n_pccw0 = 0; } - + FOR (cw_counter = 6; cw_counter < n_codewords; cw_counter++) { /* usual error correction scheme: syndromes -> elp's, errors, etc. */ codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); array_of_trust[n_codewords - 1 - cw_counter] = 1; move16(); - + syndr_calc[sub(t[mode], 1)](syndromes, iobuf + cw_offset, sub(codeword_length, 1)); - + deg_elp[0] = rs16_calculate_elp(elp, syndromes, t[mode]); move16(); FOR (i = 0; i < mode; i ++) @@ -1393,7 +1396,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword *error_report = ERROR_REPORT_BEC_MASK; move16(); mode = -1; move16(); *bfi = 1; move32(); - + BREAK; } ELSE @@ -1403,7 +1406,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword CONTINUE; } } - + IF (deg_elp[0]) { IF (rs16_factorize_elp(err_pos, elp, deg_elp[0], sub(codeword_length, 1))) @@ -1418,7 +1421,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword *error_report = ERROR_REPORT_BEC_MASK; move16(); mode = -1; move16(); *bfi = 1; move32(); - + BREAK; } ELSE @@ -1428,9 +1431,9 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword CONTINUE; } } - + rs16_calculate_errors(err_symb, err_pos, syndromes, deg_elp[0], t[mode]); - + /* correct errors and sum up number of corrected bits */ FOR (i = 0; i < deg_elp[0]; i++) { @@ -1459,7 +1462,7 @@ FEC_STATIC int rs16_detect_and_correct(UWord8 *iobuf, int n_symb, int n_codeword { return add(mode, 1); } - + return -1; } diff --git a/lib_lc3plus/apply_global_gain_fx.c b/lib_lc3plus/apply_global_gain_fx.c index 14b75f5c7..7fa960267 100644 --- a/lib_lc3plus/apply_global_gain_fx.c +++ b/lib_lc3plus/apply_global_gain_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,11 +7,13 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void processApplyGlobalGain_fx(Word32 x[], Word16 *x_e, Word16 xLen, Word16 global_gain_idx, Word16 global_gain_off) { - Word32 i; + Counter i; #ifdef ENABLE_HR_MODE Word32 global_gain; #else @@ -31,7 +33,7 @@ void processApplyGlobalGain_fx(Word32 x[], Word16 *x_e, Word16 xLen, Word16 glob #ifdef ENABLE_HR_MODE /* 1 / (28 * log 2) is 0x797D in Q18, L_shl_pos by 7 results in Q25 tmp32 */ /* round(2^31 / (28 * log10(2))) = 254778081 */ - //tmp32 = L_shl_pos(Mpy_32_16_lc3plus(254778081, add(global_gain_idx, global_gain_off)), 9); + Word32 mh; UWord16 ml; @@ -39,11 +41,11 @@ void processApplyGlobalGain_fx(Word32 x[], Word16 *x_e, Word16 xLen, Word16 glob tmp32 = L_shl_pos(mh, 9) | L_deposit_l((shr((Word16)ml, 7)) & 0x1ff); move16(); /* Uses an argument in Q25 */ - global_gain = BASOP_Util_InvLog2_lc3plus(L_or(tmp32, (Word32)0xFE000000)); + global_gain = BASOP_Util_InvLog2(L_or(tmp32, (Word32)0xFE000000)); #else tmp32 = L_shl_pos(L_mult0(add(global_gain_idx, global_gain_off), 0x797D), 7); /* Uses an argument in Q25 */ - global_gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32, (Word32)0xFE000000))); + global_gain = round_fx(BASOP_Util_InvLog2(L_or(tmp32, (Word32)0xFE000000))); #endif global_gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); diff --git a/lib_lc3plus/ari_codec.c b/lib_lc3plus/ari_codec.c index 72e5f0b12..05055122d 100644 --- a/lib_lc3plus/ari_codec.c +++ b/lib_lc3plus/ari_codec.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.5 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" @@ -73,7 +75,16 @@ static Word16 ac_enc_finish_fx(UWord8 *ptr, Word16 *bp, Encoder_State_fx *st_fx static Word16 ac_decode_fx( /* o : Decoded cumulative frequency */ Decoder_State_fx *st_fx, /* i/o: Decoder State */ - Word16 pki); + Word16 pki +#ifdef CR13_B_FIX_PC_BINS + , + Word16 *bp, + Word16 *bp_side, + Word16 *mask_side, + Word16 cur_bin, + Word16 from_left +#endif + ); static Word16 ac_decode_tns_order( /* o : Decoded cumulative frequency */ Decoder_State_fx *st_fx, /* i/o: Decoder State */ Word16 enable_lpc_weighting); @@ -99,7 +110,7 @@ Word16 processAriEncoder_fx(UWord8 *bytes, Word16 bp_side_in, Word16 mask_side_i Dyn_Mem_Deluxe_In(Encoder_State_fx st; Word16 bp, bp_side, mask_side, extra_bits; Word32 a1, b1, a1_i, b1_i, a1_msb, b1_msb; Word16 lev1; Word16 nbits_side; Word16 tmp; - Word16 fill_bits; UWord8 * ptr; Word16 numResBitsEnc; Word16 * lsb, nlsbs; Word32 i, n, k, lev;); + Word16 fill_bits; UWord8 * ptr; Word16 numResBitsEnc; Word16 * lsb, nlsbs; Counter i, n, k, lev;); lsb = (Word16 *)scratchAlign(scratchBuffer, 0); /* size = 2 * lastnz */ @@ -743,7 +754,7 @@ Word16 processAriEncoder_fx(UWord8 *bytes, Word16 bp_side_in, Word16 mask_side_i void processAriDecoder_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 L_spec, Word16 fs_idx, Word16 enable_lpc_weighting, Word16 tns_numfilters, Word16 lsbMode, Word16 lastnz, Word16 *bfi, Word16 *tns_order, Word16 fac_ns_idx, Word16 gg_idx, - Word16 frame_dms, + LC3PLUS_FrameDuration frame_dms, Word16 n_pc, Word16 be_bp_left, Word16 be_bp_right, Word16 mode, Word16 *spec_inv_idx, Word16 *b_left, Word16 *resBits, @@ -777,8 +788,8 @@ void processAriDecoder_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Wor Word16 lsb_ind_c; Word16 * lsb_ind; Word16 tmp; - Word32 n, k, lev; - Word32 i; + Counter n, k, lev; + Counter i; Word16 max_lev = 14; #ifdef DYNMEM_COUNT @@ -825,7 +836,7 @@ Decoder_State_fx st; if (fs_idx != 5) /* Don't update rateFlag for 96000 Hz */ #endif { - if (sub(nbbits, add(160, DEPR_i_mult(fs_idx, 160))) > 0) + if (sub(nbbits, add(160, i_mult(fs_idx, 160))) > 0) { rateFlag = 2 << NBITS_CONTEXT; move16(); @@ -865,11 +876,11 @@ ac_dec_init_fx(ptr, &bp, bp_side, mask_side, &st); /* Decode TNS data */ tmp = MAXLAG; -IF (sub(frame_dms, 25) == 0) +IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_2p5MS) == 0) { tmp = shr_pos(tmp, 1); } -IF (sub(frame_dms, 50) == 0) +IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_5MS) == 0) { tmp = shr_pos(tmp, 1); } @@ -928,7 +939,16 @@ if (sub(k, nt_half) > 0) t = add(t, 1 << NBITS_CONTEXT); } - r = ac_decode_fx(&st, ari_spec_lookup[t]); + r = ac_decode_fx(&st, ari_spec_lookup[t] +#ifdef CR13_B_FIX_PC_BINS + , + &bp, + bp_side, + mask_side, + k, + 1 +#endif + ); if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, ari_spec_cumfreq[ari_spec_lookup[t]][r], ari_spec_freq[ari_spec_lookup[t]][r]) != 0) { @@ -987,7 +1007,16 @@ if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) GOTO ber_detect; } b = read_bit(ptr, bp_side, mask_side); - r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[1]]); + r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[1]] +#ifdef CR13_B_FIX_PC_BINS + , + &bp, + bp_side, + mask_side, + k, + 1 +#endif + ); if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, ari_spec_cumfreq[ari_spec_lookup[t + Tab_esc_nb[1]]][r], ari_spec_freq[ari_spec_lookup[t + Tab_esc_nb[1]]][r]) != 0) @@ -1043,7 +1072,16 @@ if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) FOR (lev = 2; lev < max_lev; lev++) { esc_nb = s_min(lev, 3); - r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[esc_nb]]); + r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[esc_nb]] +#ifdef CR13_B_FIX_PC_BINS + , + &bp, + bp_side, + mask_side, + k, + 1 +#endif + ); if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, ari_spec_cumfreq[ari_spec_lookup[t + Tab_esc_nb[esc_nb]]][r], ari_spec_freq[ari_spec_lookup[t + Tab_esc_nb[esc_nb]]][r]) != 0) @@ -1153,7 +1191,16 @@ if (sub(k, nt_half) > 0) t = add(t, 1 << NBITS_CONTEXT); } - r = ac_decode_fx(&st, ari_spec_lookup[t]); + r = ac_decode_fx(&st, ari_spec_lookup[t] +#ifdef CR13_B_FIX_PC_BINS + , + &bp, + bp_side, + mask_side, + k, + 1 +#endif + ); if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, ari_spec_cumfreq[ari_spec_lookup[t]][r], ari_spec_freq[ari_spec_lookup[t]][r]) != 0) { @@ -1202,7 +1249,16 @@ if (check_pc_bytes(&bp, bp_side, mask_side, b1_i, 0, &st.pc) != 0) } ELSE { - r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[1]]); + r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[1]] +#ifdef CR13_B_FIX_PC_BINS + , + &bp, + bp_side, + mask_side, + k, + 1 +#endif + ); if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, ari_spec_cumfreq[ari_spec_lookup[t + Tab_esc_nb[1]]][r], ari_spec_freq[ari_spec_lookup[t + Tab_esc_nb[1]]][r]) != 0) @@ -1260,7 +1316,16 @@ if (check_pc_bytes(&bp, bp_side, mask_side, a1_i, 0, &st.pc) != 0) FOR (lev = 2; lev < max_lev; lev++) { esc_nb = s_min(lev, 3); - r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[esc_nb]]); + r = ac_decode_fx(&st, ari_spec_lookup[t + Tab_esc_nb[esc_nb]] +#ifdef CR13_B_FIX_PC_BINS + , + &bp, + bp_side, + mask_side, + k, + 1 +#endif + ); if (ac_dec_update_fx(ptr, &bp, bp_side, mask_side, k, &st, ari_spec_cumfreq[ari_spec_lookup[t + Tab_esc_nb[esc_nb]]][r], ari_spec_freq[ari_spec_lookup[t + Tab_esc_nb[esc_nb]]][r]) != 0) @@ -1397,6 +1462,14 @@ GOTO ber_detect; move16(); i=0; +#ifdef CR9_C_ADD_1p25MS + Counter l, lMax = 1; + if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) { + lMax = 3; + } + FOR (l = 0; l < lMax; l++) + { +#endif #ifdef ENABLE_HR_MODE FOR (k = 0; k < L_spec; k++) { @@ -1443,7 +1516,9 @@ GOTO ber_detect; } } #endif - +#ifdef CR9_C_ADD_1p25MS + } +#endif #ifdef ENABLE_HR_MODE if (hrmode) { @@ -1711,7 +1786,7 @@ void processAriDecoderScaling_fx( #endif Word16 dataLen, Word32 *data32, Word16 *data_e) { - Word32 i; + Counter i; #ifdef ENABLE_HR_MODE Dyn_Mem_Deluxe_In(Word16 shift; Word32 tmp, x_min, x_max;); @@ -1802,7 +1877,7 @@ Word16 find_last_nz_pair(const Word32 x[], Word16 length) Word16 find_last_nz_pair(const Word16 x[], Word16 length) #endif { - Dyn_Mem_Deluxe_In(Word16 last_nz, lobs[4]; Word32 stage, i;); + Dyn_Mem_Deluxe_In(Word16 last_nz, lobs[4]; Counter stage, i;); lobs[0] = 4; move16(); @@ -1866,7 +1941,7 @@ void write_bit_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 bit) void write_indice_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 indice, Word16 numbits) { - Dyn_Mem_Deluxe_In(Word32 k; Word16 bit;); + Dyn_Mem_Deluxe_In(Counter k; Word16 bit;); FOR (k = 0; k < numbits; k++) { @@ -1881,7 +1956,7 @@ void write_indice_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 indice, static __forceinline void write_indice_forward(UWord8 *ptr, Word16 bp, Word16 indice, Word16 numbits) { - Dyn_Mem_Deluxe_In(Word32 k; Word16 bit, mask, tmp;); + Dyn_Mem_Deluxe_In(Counter k; Word16 bit, mask, tmp;); tmp = (Word16)ptr[bp]; move16(); @@ -2093,7 +2168,7 @@ __forceinline Word16 read_bit(UWord8 *ptr, Word16 *bp, Word16 *mask) static __forceinline void ac_dec_init_fx(UWord8 *ptr, Word16 *bp, Word16 *bp_side, Word16 *mask_side, Decoder_State_fx *st_fx) /* i/o: Decoder State */ { - Dyn_Mem_Deluxe_In(Word32 i;); + Dyn_Mem_Deluxe_In(Counter i;); st_fx->ac_low_fx = L_deposit_l(0); @@ -2119,11 +2194,74 @@ static __forceinline void ac_dec_init_fx(UWord8 *ptr, Word16 *bp, Word16 *bp_sid Dyn_Mem_Deluxe_Out(); } +#ifdef CR13_B_FIX_PC_BINS +static Word16 pc_check_bytes_ac_decode_fx( + Word16 *bp, + Word16 *bp_side, + Word16 *mask_side, + Word16 cur_bin, + Word16 from_left, + Pc_State_fx *pc +) +{ + Word16 bp_local, bp_side_local; + + if (pc->bytes > 0) + { + bp_local = *bp; + bp_side_local = *bp_side; + + if (from_left) + { + if (*mask_side == 1) + { + bp_side_local = add(bp_side_local, 1); + } + } + else + { + bp_local = sub(bp_local, 1); + } + + if (!pc->enc && pc->b_right > -1) + { + if (pc->bfi == 2) + { + if (pc->c_bp && bp_local > pc->be_bp_left) + { + pc->inv_bin = cur_bin; + return 1; + } + } + } + } + + return 0; +} +#endif + /* o : Decoded cumulative frequency */ static __forceinline Word16 ac_decode_fx(Decoder_State_fx *st_fx, /* i/o: Decoder State */ - Word16 pki) + Word16 pki +#ifdef CR13_B_FIX_PC_BINS + , + Word16 *bp, + Word16 *bp_side, + Word16 *mask_side, + Word16 cur_bin, + Word16 from_left +#endif + ) { Dyn_Mem_Deluxe_In(UWord16 sgn; Word16 val, r;); + +#ifdef CR13_B_FIX_PC_BINS + IF (pc_check_bytes_ac_decode_fx(bp, bp_side, mask_side, cur_bin, from_left, &st_fx->pc)) + { + st_fx->BER_detect = 1; + return 0; + } +#endif st_fx->ac_help_fx = UL_lshr_pos(st_fx->ac_range_fx, 10); move32(); diff --git a/lib_lc3plus/attack_detector_fx.c b/lib_lc3plus/attack_detector_fx.c index fad58543b..dd2541fd6 100644 --- a/lib_lc3plus/attack_detector_fx.c +++ b/lib_lc3plus/attack_detector_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void attack_detector_fx(LC3PLUS_Enc *enc, EncSetup *setup, Word16 *input, Word16 input_scaling, void *scratch) @@ -21,7 +23,7 @@ void attack_detector_fx(LC3PLUS_Enc *enc, EncSetup *setup, Word16 *input, Word16 block_energy = scratchAlign(scratch, 0); input_16k = scratchAlign(block_energy, 4 * 4 + 4); - frame_length_16k = DEPR_i_mult(enc->attdec_nblocks, 40); + frame_length_16k = i_mult(enc->attdec_nblocks, 40); IF (setup->attack_handling) { diff --git a/lib_lc3plus/basop_mpy_lc3plus.c b/lib_lc3plus/basop_mpy_lc3plus.c index aa29bf209..b570b9358 100644 --- a/lib_lc3plus/basop_mpy_lc3plus.c +++ b/lib_lc3plus/basop_mpy_lc3plus.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -31,6 +33,32 @@ Word32 Mpy_32_16_0(Word32 x, Word16 y) } #endif +/* Is this port necessary ? */ +#ifdef CR9_C_ADD_1p25MS_LRSNS +#if !defined(__arm__) && !defined(__hexagon__) +/*#define Mpy_32_16_0_DEFINED */ +/* +Word32 Mpy_32_16_0(Word32 x, Word16 y) +{ + Word32 z; + + z = L_shr(L_add(Mpy_32_16_lc3plus(x, y), 1), 1); + + return (z); +} +*/ + + + +Word32 Mpy_32_16_0_0(Word32 x, Word16 y) +{ + Word32 z; + z = L_shr_pos(Mpy_32_16_lc3plus(x, y), 1); /* stay downshifted, no rounding, to exactly match a single SMULWB */ + return (z); +} +#endif +#endif + Word32 Mpy_32_16_lc3plus(Word32 x, Word16 y) { Word32 mh; diff --git a/lib_lc3plus/basop_mpy_lc3plus.h b/lib_lc3plus/basop_mpy_lc3plus.h index 055a27fd1..7d45f6fff 100644 --- a/lib_lc3plus/basop_mpy_lc3plus.h +++ b/lib_lc3plus/basop_mpy_lc3plus.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,10 +7,12 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" -#ifndef __BASOP_MPY_LC3PLUS_H -#define __BASOP_MPY_LC3PLUS_H +#ifndef __BASOP_MPY_H +#define __BASOP_MPY_H #include "functions.h" @@ -24,6 +26,10 @@ Word32 Mac_32_32_0(Word32 z, Word32 x, Word32 y); Word32 Msu_32_16_0(Word32 z, Word32 x, Word16 y); Word32 Msu_32_32_0(Word32 z, Word32 x, Word32 y); +#ifdef CR9_C_ADD_1p25MS_LRSNS +Word32 Mpy_32_16_0_0(Word32 x, Word16 y); /* non-rounding, no upshift */ +#endif + /** * \brief 32*16 Bit fractional Multiplication using 40 bit OPS * Performs a multiplication of a 32-bit variable x by @@ -69,4 +75,4 @@ void cplxMpy_32_16(Word32 *c_Re, Word32 *c_Im, const Word32 a_Re, const Word32 a void cplxMpy_32_32(Word32 *c_Re, Word32 *c_Im, const Word32 a_Re, const Word32 a_Im, const Word32 b_Re, const Word32 b_Im); -#endif /* __BASOP_MPY_LC3PLUS_H */ +#endif /* __BASOP_MPY_H */ diff --git a/lib_lc3plus/basop_util_lc3plus.c b/lib_lc3plus/basop_util_lc3plus.c index bb2c0413a..bb7f572d3 100644 --- a/lib_lc3plus/basop_util_lc3plus.c +++ b/lib_lc3plus/basop_util_lc3plus.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,21 +7,23 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" #include "rom_basop_util_lc3plus.h" #include "basop_util_lc3plus.h" -extern const Word32 SqrtTable_lc3plus[32]; -extern const Word16 SqrtDiffTable_lc3plus[32]; +extern const Word32 SqrtTable[32]; +extern const Word16 SqrtDiffTable[32]; -extern const Word32 ISqrtTable_lc3plus[32]; -extern const Word16 ISqrtDiffTable_lc3plus[32]; +extern const Word32 ISqrtTable[32]; +extern const Word16 ISqrtDiffTable[32]; -extern const Word32 InvTable_lc3plus[32]; -extern const Word16 InvDiffTable_lc3plus[32]; +extern const Word32 InvTable[32]; +extern const Word16 InvDiffTable[32]; -Word32 BASOP_Util_Log2_lc3plus(Word32 x) +Word32 BASOP_Util_Log2(Word32 x) { Word32 exp; Word16 exp_e; @@ -48,31 +50,31 @@ Word32 BASOP_Util_Log2_lc3plus(Word32 x) /* approximate ln() for fractional part (nIn *c0 + nIn^2*c1 + nIn^3*c2 + ... + nIn^8 *c7) */ /* iteration 1, no need for accumulation */ - accuRes = L_mult(nIn, ldCoeff_lc3plus[0]); /* nIn^i * coeff[0] */ + accuRes = L_mult(nIn, ldCoeff[0]); /* nIn^i * coeff[0] */ accuSqr = mult(nIn, nIn); /* nIn^2, nIn^3 .... */ /* iteration 2 */ - accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[1]); /* nIn^i * coeff[1] */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff[1]); /* nIn^i * coeff[1] */ accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ /* iteration 3 */ - accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[2]); /* nIn^i * coeff[2] */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff[2]); /* nIn^i * coeff[2] */ accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ /* iteration 4 */ - accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[3]); /* nIn^i * coeff[3] */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff[3]); /* nIn^i * coeff[3] */ accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ /* iteration 5 */ - accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[4]); /* nIn^i * coeff[4] */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff[4]); /* nIn^i * coeff[4] */ accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ /* iteration 6 */ - accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[5]); /* nIn^i * coeff[5] */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff[5]); /* nIn^i * coeff[5] */ accuSqr = mult(accuSqr, nIn); /* nIn^2, nIn^3 .... */ /* iteration 7, no need to calculate accuSqr any more */ - accuRes = L_mac(accuRes, accuSqr, ldCoeff_lc3plus[6]); /* nIn^i * coeff[6] */ + accuRes = L_mac(accuRes, accuSqr, ldCoeff[6]); /* nIn^i * coeff[6] */ /* ld(fractional part) = ln(fractional part)/ln(2), 1/ln(2) = (1 + 0.44269504) */ accuRes = L_mac0(L_shr(accuRes, 1), extract_h(accuRes), 14506); @@ -84,7 +86,152 @@ Word32 BASOP_Util_Log2_lc3plus(Word32 x) return (accuRes); } -Word32 BASOP_Util_InvLog2_lc3plus(Word32 x) + + +#ifdef LOG2_LC_APPROX +/* LC log2 with 16 segment piecewise 2nd order minmax optimized approximation */ + +Word32 BASOP_Util_Log2_LC(Word32 L_x) +{ + Word16 exp_e0; + Word32 L_accuRes; + +#define L2LC_TABSIZE_BITS 4 /* 16 segments */ +#define L2LC_TABWIDTH 2 +#define L2LC_TABLENGTH (1<> 6/*0.044*/ , 277633165 >> 6, 449797678 >> 6, 612896598 >> 6, + 767837083 >> 6, 915396590 >> 6, 1056246482 >> 6, 1190970490 >> 6, + 1320079339 >> 6, 1444022426 >> 6, 1563197273 >> 6, 1677957208 >> 6, + 1788617686 >> 6, 1895461516 >> 6, 1998743213 >> 6, 2098692655 >> 6 /*0.9773*/ + }; + + Word32 L_pow2Const[31] = + { /* The Table implements L_shl_pos( L_deposit_l(add(exp_e0,1)), 25)) */ + ((0L + 1) << 25), /* orig exp_e0==0 */ + ((0L + 2) << 25), + ((0L + 3) << 25), + ((0L + 4) << 25), + ((0L + 5) << 25), + ((0L + 6) << 25), + ((0L + 7) << 25), + ((0L + 8) << 25), + ((0L + 9) << 25), + ((0L + 10) << 25), + + ((0L + 11) << 25), + ((0L + 12) << 25), + ((0L + 13) << 25), + ((0L + 14) << 25), + ((0L + 15) << 25), + ((0L + 16) << 25), + ((0L + 17) << 25), + ((0L + 18) << 25), + ((0L + 19) << 25), + ((0L + 20) << 25), + + ((0L + 21) << 25), + ((0L + 22) << 25), + ((0L + 23) << 25), + ((0L + 24) << 25), + ((0L + 25) << 25), + ((0L + 26) << 25), + ((0L + 27) << 25), + ((0L + 28) << 25), + ((0L + 29) << 25), + ((0L + 30) << 25), + ((0L + 31) << 25), /* orig exp_e0==30 */ + }; + + Word32 L_x_up; + Word16 dx; + Word32 L_segm_ind; + Word32 L_tail_frac_indQ32; + Word16* cXPtr; /* C1C2 row pointer */ + Word32 L_tmp; + + + cXPtr = &(log2_LC_TabValC1C2_Qx[0][0]); /* C1C2 table init */ + assert(L_x >= 0); + + if (L_x == 0) /* logic kept from non LC version */ + { /* do not call this function with 0 */ + return ((Word32)MIN_32); + } + + /* start of actual BASOP approximation */ + exp_e0 = norm_l(L_x); /* exp_e0 = number of upshifts for L_x to get into 0.5 to 1.0 */ + L_x_up = L_shl_pos(L_x, exp_e0); /* max upshift to a get a mantissa fractional value range .5 to 1.0 */ + + /* apply total_frac=(2*x-1) to move to region 1.0 to 2.0 , and extract tail fraction to approximation ox log2(1+x/16) )*/ + + L_segm_ind = L_shr_pos_pos(L_and(L_x_up, 0x3c000000), 30 - 4); /* 2 ops to pick segment */ + + /* use 16 bits after the segment index, and put them it in a Q16 short variable as in segment range -.5 to .5 */ + L_tail_frac_indQ32 = L_and(L_x_up, 0x03ffffff); /* mask away to a positive value in Q26 */ + L_tail_frac_indQ32 = L_sub(L_tail_frac_indQ32, 1L << (26 - 1)); /* subtract 0.5 at Q26 */ + L_tail_frac_indQ32 = L_shl_pos(L_tail_frac_indQ32, 6); /* shift up to Q32 */ + dx = extract_h(L_tail_frac_indQ32); /* 4 ops to get a the signed tail fraction into a Word16 */ + + + ASSERT(L_segm_ind >= 0 && L_segm_ind <= L2LC_TABLENGTH); + /* Table ptr init to [segm_ind][0,1,2] */ + cXPtr += (L_segm_ind*L2LC_TABWIDTH); /* allows for ptr increment , for the Word16 table segment adressing */ + + /* ops pre = 8 , mid = 6 , tail = 1, sum= 15 (25-15)/25 = 40% reduction */ + /* Horners rule ((C2*x+ C1)*x) + C0 , maintains precision until final summation */ + + L_tmp = L_mult0(cXPtr[1], dx); /* Q23*Q16 -> Q39 C2*x */ + L_tmp = L_shr_pos(L_tmp, 39 - 34); /* Q39 to -> Q34 */ + + L_tmp = L_msu(L_tmp, cXPtr[0], SHRT_MIN); /* add C1, with L_msu , no extra cycle cost for C1 Word16 storage in Q18 , Q34=18+15+1 */ + + L_tmp = Mpy_32_16_lc3plus(L_tmp, dx); /*Q34*Q16 to -> Q50-16+1 = Q35 , (x*c2+c1)x*/ + L_tmp = L_shr_pos(L_tmp, 35 - 25); /*Q34+1 to -> Q25 */ /* fractional to final Q25 */ + + L_tmp = L_add(L_tmp, L_log2_LC_TabValC0Q25[L_segm_ind]); /* Q25 to -> Q25 */ + + /* back to 0..1 from log2(1+x/16) range */ + ASSERT(exp_e0 >= 0 && exp_e0 <= 30); + L_accuRes = L_sub(L_tmp, L_pow2Const[exp_e0]); /* result = integer_partQ25*2^-1 + fractional partQ25 */ + + return (L_accuRes); +} +#endif + + +Word32 BASOP_Util_InvLog2(Word32 x) { #ifdef ENABLE_HR_MODE /* Original code was used for negative x and hence the exp was always 0, which is assumed */ @@ -129,8 +276,8 @@ Word32 BASOP_Util_InvLog2_lc3plus(Word32 x) exp = negate(exp); } - lookup3f = L_add(exp2x_tab_long_lc3plus[index3], L_shr_pos(Mpy_32_16_lc3plus(0x0016302F, frac), 1)); - lookup12 = Mpy_32_32_lc3plus(exp2_tab_long_lc3plus[index1], exp2w_tab_long_lc3plus[index2]); + lookup3f = L_add(exp2x_tab_long[index3], L_shr_pos(Mpy_32_16_lc3plus(0x0016302F, frac), 1)); + lookup12 = Mpy_32_32_lc3plus(exp2_tab_long[index1], exp2w_tab_long[index2]); lookup = Mpy_32_32_lc3plus(lookup12, lookup3f); retVal = L_shr(lookup, sub(exp, 3)); @@ -171,9 +318,14 @@ Word32 BASOP_Util_InvLog2_pos(Word32 x, Word16 *exp) } ELSE IF(x == 0) { +#ifdef LRSNS_ALLZERO_FIX + *exp = 2; move16(); + return (1L << 29); /* 2^29/(2^(31-(+2)) = 1.0 exactly */ +#else *exp = -1; move16(); return 0x10000000; +#endif } frac = extract_l(L_and(x, 0x3FF)); @@ -182,8 +334,8 @@ Word32 BASOP_Util_InvLog2_pos(Word32 x, Word16 *exp) index2 = L_and(L_shr(x, 15), 0x1F); index1 = L_and(L_shr(x, 20), 0x1F); - lookup3f = L_add(exp2x_tab_long_lc3plus[index3], L_shr(Mpy_32_16_lc3plus(0x0016302F, frac), 1)); - lookup12 = Mpy_32_32_lc3plus(exp2_tab_long_lc3plus[index1], exp2w_tab_long_lc3plus[index2]); + lookup3f = L_add(exp2x_tab_long[index3], L_shr(Mpy_32_16_lc3plus(0x0016302F, frac), 1)); + lookup12 = Mpy_32_32_lc3plus(exp2_tab_long[index1], exp2w_tab_long[index2]); lookup = Mpy_32_32_lc3plus(lookup12, lookup3f); IF (x > 0) @@ -204,7 +356,7 @@ Word32 BASOP_Util_InvLog2_pos(Word32 x, Word16 *exp) } #endif -/* local function for Sqrt16_lc3plus and Sqrt16norm */ +/* local function for Sqrt16 and Sqrt16norm */ static Word16 Sqrt16_common(Word16 m, Word16 e) { Word16 index, frac; @@ -221,7 +373,7 @@ static Word16 Sqrt16_common(Word16 m, Word16 e) /* interpolate */ if (m != 0) { - m = mac_r(SqrtTable_lc3plus[index], SqrtDiffTable_lc3plus[index], frac); + m = mac_r(SqrtTable[index], SqrtDiffTable[index], frac); } /* handle odd exponents */ @@ -246,7 +398,7 @@ static Word16 ISqrt16_common(Word16 m, Word16 e) frac = s_and(m, 0x1FF); /* Q9 */ /* interpolate */ - m = msu_r(ISqrtTable_lc3plus[index], ISqrtDiffTable_lc3plus[index], frac); + m = msu_r(ISqrtTable[index], ISqrtDiffTable[index], frac); /* handle even exponents */ if (s_and(e, 1) == 0) @@ -255,7 +407,7 @@ static Word16 ISqrt16_common(Word16 m, Word16 e) return m; } -Word16 Sqrt16_lc3plus( /*!< output mantissa */ +Word16 Sqrt16( /*!< output mantissa */ Word16 mantissa, /*!< input mantissa */ Word16 *exponent /*!< pointer to exponent */ ) @@ -303,7 +455,7 @@ Word16 ISqrt16( /*!< output mantissa */ return mantissa; } -Word16 Inv16_lc3plus( /*!< output mantissa */ +Word16 Inv16( /*!< output mantissa */ Word16 mantissa, /*!< input mantissa */ Word16 *exponent /*!< pointer to exponent */ ) @@ -331,7 +483,7 @@ Word16 Inv16_lc3plus( /*!< output mantissa */ frac = shl(s_and(m, 0x1FF), 1); /* Q10 */ /* interpolate */ - m = msu_r(InvTable_lc3plus[index], InvDiffTable_lc3plus[index], frac); + m = msu_r(InvTable[index], InvDiffTable[index], frac); /* restore sign */ if (mantissa < 0) @@ -437,7 +589,7 @@ Word16 getScaleFactor16_0( /* o: measured headroom in range [ and -2147483648 <= x <= -1073741824 for negative x */ -Word16 getScaleFactor32_lc3plus( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ +Word16 getScaleFactor32( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ const Word32 *x, /* i: array containing 32-bit data */ const Word16 len_x) /* i: length of the array to scan */ { @@ -511,7 +663,7 @@ Word16 getScaleFactor32_0( /* o: measured headroom in range [ return i; } -Word16 BASOP_Util_Divide3216_Scale_lc3plus( /* o: result of division x/y, not normalized */ +Word16 BASOP_Util_Divide3216_Scale( /* o: result of division x/y, not normalized */ Word32 x, /* i: numerator, signed */ Word16 y, /* i: denominator, signed */ Word16 *s) /* o: scaling, 0, if x==0 */ @@ -551,7 +703,7 @@ Word16 BASOP_Util_Divide3216_Scale_lc3plus( /* o: result of division x return z; } -Word16 BASOP_Util_Divide1616_Scale_lc3plus(Word16 x, Word16 y, Word16 *s) +Word16 BASOP_Util_Divide1616_Scale(Word16 x, Word16 y, Word16 *s) { Word16 z; Word16 sx; @@ -695,7 +847,7 @@ void Copy_Scale_sig(const Word16 x[], /* i : signal to scale input Qx } } -Word32 BASOP_Util_Add_Mant32Exp_lc3plus /*!< o: normalized result mantissa */ +Word32 BASOP_Util_Add_Mant32Exp /*!< o: normalized result mantissa */ (Word32 a_m, /*!< i: Mantissa of 1st operand a */ Word16 a_e, /*!< i: Exponent of 1st operand a */ Word32 b_m, /*!< i: Mantissa of 2nd operand b */ @@ -745,7 +897,7 @@ Word32 BASOP_Util_Add_Mant32Exp_lc3plus /*!< o: normalized result mantissa */ return (L_tmp); } -Word16 BASOP_Util_Cmp_Mant32Exp_lc3plus /*!< o: flag: result of comparison */ +Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of comparison */ /* 0, if a == b */ /* 1, if a > b */ /* -1, if a < b */ @@ -835,7 +987,7 @@ Word16 BASOP_Util_Cmp_Mant32Exp_lc3plus /*!< o: flag: result of comparison */ } /*----------------------------------------------------------------------------------* - * Function: Isqrt + * Function: Isqrt_lc3plus * * Description: * diff --git a/lib_lc3plus/basop_util_lc3plus.h b/lib_lc3plus/basop_util_lc3plus.h index 577c65f54..c8eb0b25f 100644 --- a/lib_lc3plus/basop_util_lc3plus.h +++ b/lib_lc3plus/basop_util_lc3plus.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -10,6 +10,8 @@ #ifndef __BASOP_UTIL_LC3PLUS_H__ #define __BASOP_UTIL_LC3PLUS_H__ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" #include @@ -79,7 +81,7 @@ typedef struct The exponent is addressed via pointers and will be overwritten with the result. */ -Word16 Sqrt16_lc3plus( /*!< output mantissa */ +Word16 Sqrt16( /*!< output mantissa */ Word16 mantissa, /*!< input mantissa */ Word16 *exponent /*!< pointer to exponent */ ); @@ -99,7 +101,7 @@ Word16 ISqrt16( /*!< output mantissa */ The function uses a table lookup and a newton iteration. */ -Word16 Inv16_lc3plus( /*!< output mantissa */ +Word16 Inv16( /*!< output mantissa */ Word16 mantissa, /*!< input mantissa */ Word16 *exponent /*!< pointer to exponent */ ); @@ -142,7 +144,7 @@ Word16 getScaleFactor16_0( /* o: measured headroom in range and -2147483648 <= x <= -1073741824 for negative x */ -Word16 getScaleFactor32_lc3plus( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ +Word16 getScaleFactor32( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */ const Word32 *x, /* i: array containing 32-bit data */ const Word16 len_x); /* i: length of the array to scan */ @@ -167,7 +169,7 @@ Word16 getScaleFactor32_0( /* o: measured headroom in range \return fractional Word16 integer z = arg1(32bits)/arg2(16bits) , z not normalized */ -Word16 BASOP_Util_Divide3216_Scale_lc3plus(Word32 x, /*!< i : Numerator */ +Word16 BASOP_Util_Divide3216_Scale(Word32 x, /*!< i : Numerator */ Word16 y, /*!< i : Denominator*/ Word16 *s); /*!< o : Additional scalefactor difference*/ @@ -178,7 +180,7 @@ Word16 BASOP_Util_Divide3216_Scale_lc3plus(Word32 x, /*!< i : Numerator */ \return fractional Q15 Word16 z = arg1(Q15)/arg2(Q15) with scaling s */ -Word16 BASOP_Util_Divide1616_Scale_lc3plus(Word16 x, /*!< i : Numerator*/ +Word16 BASOP_Util_Divide1616_Scale(Word16 x, /*!< i : Numerator*/ Word16 y, /*!< i : Denominator*/ Word16 *s); /*!< o : Additional scalefactor difference*/ @@ -191,7 +193,20 @@ Word16 BASOP_Util_Divide1616_Scale_lc3plus(Word16 x, /*!< i : Numerator*/ \return log2(x)/64 */ /************************************************************************/ -Word32 BASOP_Util_Log2_lc3plus(Word32 x); +Word32 BASOP_Util_Log2(Word32 x); + +#ifdef LOG2_LC_APPROX +/************************************************************************/ +/*! + \brief Low Complex Binary logarithm with 16 sections and 2nd order polynom + + \param x + + \return log2(x)/64 + */ + /************************************************************************/ +Word32 BASOP_Util_Log2_LC(Word32 L_x); +#endif /************************************************************************/ /*! @@ -213,9 +228,9 @@ Word32 BASOP_Util_Log2_lc3plus(Word32 x); Due to the fact, that all lookup values contain a factor 0.5 the result has to be shifted by 3 to the right also. - Table exp2_tab_long_lc3plus contains the log2 for 0 to 1.0 in steps - of 1/32, table exp2w_tab_long_lc3plus the log2 for 0 to 1/32 in steps - of 1/1024, table exp2x_tab_long_lc3plus the log2 for 0 to 1/1024 in + Table exp2_tab_long contains the log2 for 0 to 1.0 in steps + of 1/32, table exp2w_tab_long the log2 for 0 to 1/32 in steps + of 1/1024, table exp2x_tab_long the log2 for 0 to 1/1024 in steps of 1/32768. Since the 2-logarithm of very very small negative value is rather linear, we can use interpolation. @@ -232,10 +247,10 @@ Word32 BASOP_Util_Log2_lc3plus(Word32 x); \return pow(2,(x/64)) */ /************************************************************************/ -Word32 BASOP_Util_InvLog2_lc3plus(Word32 x); +Word32 BASOP_Util_InvLog2(Word32 x); #ifdef ENABLE_HR_MODE -/* New function which works with positive x, BASOP_Util_InvLog2_lc3plus does not give +/* New function which works with positive x, BASOP_Util_InvLog2 does not give accurate results for x > 0 */ Word32 BASOP_Util_InvLog2_pos(Word32 x, Word16 *exp); #endif @@ -257,7 +272,7 @@ Word32 Norm32Norm(const Word32 *x, const Word16 headroom, const Word16 length, W The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
************************************************************************/ -Word32 BASOP_Util_Add_Mant32Exp_lc3plus /*!< o: normalized result mantissa */ +Word32 BASOP_Util_Add_Mant32Exp /*!< o: normalized result mantissa */ (Word32 a_m, /*!< i: Mantissa of 1st operand a */ Word16 a_e, /*!< i: Exponent of 1st operand a */ Word32 b_m, /*!< i: Mantissa of 2nd operand b */ @@ -271,7 +286,7 @@ Word32 BASOP_Util_Add_Mant32Exp_lc3plus /*!< o: normalized result mantissa */ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
************************************************************************/ -Word16 BASOP_Util_Cmp_Mant32Exp_lc3plus /*!< o: flag: result of comparison */ +Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of comparison */ (Word32 a_m, /*!< i: Mantissa of 1st operand a */ Word16 a_e, /*!< i: Exponent of 1st operand a */ Word32 b_m, /*!< i: Mantissa of 2nd operand b */ @@ -312,7 +327,7 @@ Word32 invFixp(Word32 op_m, Word16 *op_e); #endif #define BASOP_CFFT_MAX_LENGTH 480 -void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 sizeOfFft, Word16 s, Word16 *scale, Word32 *x); +void BASOP_cfft(Word32 *re, Word32 *im, Word16 sizeOfFft, Word16 s, Word16 *scale, Word32 *x); void BASOP_rfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); void BASOP_irfftN(Word32 *re, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffer); diff --git a/lib_lc3plus/com_entropy.c b/lib_lc3plus/com_entropy.c new file mode 100644 index 000000000..6d8cb89b9 --- /dev/null +++ b/lib_lc3plus/com_entropy.c @@ -0,0 +1,27 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.6.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +Word16 getLastNzBits_fx (Word16 N) +{ + Dyn_Mem_Deluxe_In( Word16 minBits;); + minBits = sub(14, norm_s(negate(N))); +#ifdef CR9_C_ADD_1p25MS + /* minimum of 2 spare bits */ + if (sub(sub(shl(1,minBits),shr(N,1)),2) < 0) + { + minBits = add(minBits,1); + } +#endif + Dyn_Mem_Deluxe_Out(); + return minBits; +} diff --git a/lib_lc3plus/constants.c b/lib_lc3plus/constants.c index 9f1992bf7..1d00d56e0 100644 --- a/lib_lc3plus/constants.c +++ b/lib_lc3plus/constants.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,10 +7,548 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "basop_util_lc3plus.h" #include "constants.h" #include "defines.h" +#ifdef LTPF_ADAPTIVE_GAIN +RAM_ALIGN const Word16 adaptive_gain_step = 328; +RAM_ALIGN const Word16 max_adaptive_gain[4] = { 19661, 18022, 16384, 14746 }; +RAM_ALIGN const Word16 max_adaptive_gain_step[4] = { 983, 901, 819, 737 }; +#endif + +#ifdef LTPF_ADAPTIVE_GAIN +RAM_ALIGN const Word16 tilt_filter_1p25ms[5][4][11] = { + { {19343, 13480, -605}, {19251, 13480, -512}, {19164, 13480, -425}, {19083, 13480, -344} }, + { {19343, 13480, -605}, {19251, 13480, -512}, {19164, 13480, -425}, {19083, 13480, -344} }, + { {12812, 16514, 3225, -411, -50}, + {12680, 16454, 3350, -351, -43}, + {12556, 16397, 3468, -294, -36}, + {12438, 16343, 3579, -239, -30} }, + { {9577, 14941, 6763, 1210, -326, -81, -10}, + {9453, 14834, 6838, 1306, -279, -70, -9}, + {9337, 14732, 6909, 1397, -234, -59, -7}, + {9226, 14634, 6975, 1484, -191, -48, -6} }, + { {6363, 11318, 8072, 4573, 1832, 298, -232, -102, -36, -9, -1}, + {6264, 11190, 8060, 4628, 1904, 356, -199, -88, -31, -8, -1}, + {6171, 11069, 8048, 4679, 1972, 411, -167, -74, -26, -7, -1}, + {6084, 10954, 8036, 4727, 2037, 463, -137, -60, -22, -6, -1} } +}; +#endif + +RAM_ALIGN const Word16 lpc_warp_pre_adapt_emphasis_64_48000[64] = +{ + 0x0000, 0x0334, 0x074e, 0x0c81, 0x1308, 0x1b27, 0x2532, 0x18c6, 0x2056, 0x298c, 0x34bd, 0x4247, 0x52a0, 0x3326, 0x3ef7, 0x4d21, + 0x5e12, 0x724e, 0x4537, 0x5395, 0x64aa, 0x78f3, 0x4883, 0x56c6, 0x67aa, 0x7ba5, 0x49a1, 0x5794, 0x680a, 0x7b75, 0x492c, 0x56a8, + 0x6688, 0x7937, 0x4798, 0x5484, 0x63b2, 0x7589, 0x453d, 0x5189, 0x5ff6, 0x70e3, 0x425f, 0x4e02, 0x5ba6, 0x6ba2, 0x7e5c, 0x4a25, + 0x56fd, 0x6607, 0x77a0, 0x461d, 0x522a, 0x6044, 0x70c2, 0x4207, 0x4d4e, 0x5a7f, 0x69ea, 0x7bf0, 0x4881, 0x54d0, 0x6333, 0x7402 +}; + +RAM_ALIGN const Word16 lpc_warp_pre_adapt_emphasis_64_32000[64] = +{ + 0x0000, 0x02ba, 0x061d, 0x0a48, 0x0f5f, 0x158b, 0x1cff, 0x25f1, 0x1853, 0x1eb3, 0x2646, 0x2f3f, 0x39d9, 0x4658, 0x550b, 0x3326, + 0x3d43, 0x4919, 0x56ee, 0x6712, 0x79e2, 0x47e5, 0x54a1, 0x636e, 0x749c, 0x4445, 0x4fd1, 0x5d31, 0x6cab, 0x7e92, 0x49a1, 0x5595, + 0x6361, 0x734e, 0x42d6, 0x4d6d, 0x59a0, 0x67af, 0x77df, 0x4541, 0x4ff9, 0x5c4e, 0x6a7d, 0x7acb, 0x46c5, 0x5189, 0x5de7, 0x6c1c, + 0x7c6b, 0x4792, 0x5251, 0x5ea5, 0x6cca, 0x7d04, 0x47d0, 0x527b, 0x5eb7, 0x6cbc, 0x7ccf, 0x479d, 0x522a, 0x5e41, 0x6c1b, 0x7bf8 +}; + +RAM_ALIGN const Word8 lpc_warp_pre_adapt_emphasis_64_e_32000[64] = +{ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, + 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c +}; + +RAM_ALIGN const Word16 *const lpc_pre_adapt_emphasis[NUM_SAMP_FREQ] = {NULL, + NULL, + NULL, + lpc_warp_pre_adapt_emphasis_64_32000, + lpc_warp_pre_adapt_emphasis_64_48000, + NULL}; + +RAM_ALIGN const Word8 lpc_warp_pre_adapt_emphasis_64_e_48000[64] = +{ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, + 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0c, 0x0c, 0x0c, 0x0c, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e +}; + +RAM_ALIGN const Word8 *const lpc_pre_adapt_emphasis_e[NUM_SAMP_FREQ] = {NULL, + NULL, + NULL, + lpc_warp_pre_adapt_emphasis_64_e_32000, + lpc_warp_pre_adapt_emphasis_64_e_48000, + NULL}; + +#ifdef CR9_C_ADD_1p25MS +#ifdef ENABLE_HR_MODE +const Word16 LowDelayShapes_n960_len_1_25ms[6] = {20, 40, 60, 80, 120, 240}; +#else +const Word16 LowDelayShapes_n960_len_1_25ms[5] = {20, 40, 60, 80, 120}; +#endif + +#ifdef ENABLE_HR_MODE +const Word32 MDCT_WINDOW_FS_8000_frame_ms_1_25[20] = { + 150701702, 448394330, 735046002, 1003598401, 1247438878, 1460563269, 1637723745, + 1774558027, 1867696801, 1914846681, -1914846681, -1867696801, -1774558027, -1637723745, + -1460563269, -1247438878, -1003598401, -735046002, -448394330, -150701702 + }; + +const Word32 MDCT_WINDOW_FS_16000_frame_ms_1_25[40] = { + 53322207, 159637873, 264969317, 368667138, 470092003, 568618595, 663639464, + 754568775, 840845919, 921938968, 997347957, 1066607963, 1129291978, 1185013531, + 1233429082, 1274240133, 1307195069, 1332090713, 1348773575, 1357140799, -1357140799, + -1348773575, -1332090713, -1307195069, -1274240133, -1233429082, -1185013531, -1129291978, + -1066607963, -997347957, -921938968, -840845919, -754568775, -663639464, -568618595, + -470092003, -368667138, -264969317, -159637873, -53322207 + }; + +const Word32 MDCT_WINDOW_FS_24000_frame_ms_1_25[60] = { + 29029078, 87007668, 144747776, 202091141, 258880587, 314960460, 370177048, + 424379007, 477417772, 529147969, 579427807, 628119474, 675089510, 720209172, + 763354790, 804408107, 843256596, 879793778, 913919506, 945540245, 974569323, + 1000927175, 1024541554, 1045347737, 1063288694, 1078315251, 1090386220, 1099468517, + 1105537247, 1108575776, -1108575776, -1105537247, -1099468517, -1090386220, -1078315251, + -1063288694, -1045347737, -1024541554, -1000927175, -974569323, -945540245, -913919506, + -879793778, -843256596, -804408107, -763354790, -720209172, -675089510, -628119474, + -579427807, -529147969, -477417772, -424379007, -370177048, -314960460, -258880587, + -202091141, -144747776, -87007668, -29029078 + }; + +const Word32 MDCT_WINDOW_FS_32000_frame_ms_1_25[80] = { + 37711764, 113077142, 188268164, 263168890, 337663828, 411638113, 484977683, + 557569451, 629301488, 700063188, 769745441, 838240803, 905443658, 971250384, + 1035559513, 1098271884, 1159290799, 1218522172, 1275874672, 1331259866, 1384592353, + 1435789900, 1484773562, 1531467812, 1575800649, 1617703715, 1657112400, 1693965938, + 1728207502, 1759784297, 1788647631, 1814753000, 1838060152, 1858533148, 1876140421, + 1890854821, 1902653660, 1911518745, 1917436407, 1920397521, -1920397521, -1917436407, + -1911518745, -1902653660, -1890854821, -1876140421, -1858533148, -1838060152, -1814753000, + -1788647631, -1759784297, -1728207502, -1693965938, -1657112400, -1617703715, -1575800649, + -1531467812, -1484773562, -1435789900, -1384592353, -1331259866, -1275874672, -1218522172, + -1159290799, -1098271884, -1035559513, -971250384, -905443658, -838240803, -769745441, + -700063188, -629301488, -557569451, -484977683, -411638113, -337663828, -263168890, + -188268164, -113077142, -37711764 + }; + +const Word32 MDCT_WINDOW_FS_48000_frame_ms_1_25[120] = { + 20528417, 61571181, 102571748, 143502017, 184333937, 225039524, 265590880, + 305960213, 346119857, 386042287, 425700143, 465066245, 504113615, 542815489, + 581145346, 619076914, 656584198, 693641492, 730223399, 766304847, 801861108, + 836867813, 871300971, 905136983, 938352659, 970925235, 1002832388, 1034052249, + 1064563423, 1094344998, 1123376563, 1151638223, 1179110607, 1205774887, 1231612790, + 1256606606, 1280739208, 1303994054, 1326355209, 1347807345, 1368335762, 1387926390, + 1406565803, 1424241225, 1440940544, 1456652314, 1471365767, 1485070820, 1497758079, + 1509418850, 1520045141, 1529629668, 1538165864, 1545647877, 1552070581, 1557429573, + 1561721181, 1564942463, 1567091212, 1568165954, -1568165954, -1567091212, -1564942463, + -1561721181, -1557429573, -1552070581, -1545647877, -1538165864, -1529629668, -1520045141, + -1509418850, -1497758079, -1485070820, -1471365767, -1456652314, -1440940544, -1424241225, + -1406565803, -1387926390, -1368335762, -1347807345, -1326355209, -1303994054, -1280739208, + -1256606606, -1231612790, -1205774887, -1179110607, -1151638223, -1123376563, -1094344998, + -1064563423, -1034052249, -1002832388, -970925235, -938352659, -905136983, -871300971, + -836867813, -801861108, -766304847, -730223399, -693641492, -656584198, -619076914, + -581145346, -542815489, -504113615, -465066245, -425700143, -386042287, -346119857, + -305960213, -265590880, -225039524, -184333937, -143502017, -102571748, -61571181, + -20528417 +}; + +#else /* ENABLE_HR_MODE */ + +const Word16 MDCT_WINDOW_FS_8000_frame_ms_1_25[20] = { + 2300, + 6842, + 11216, + 15314, + 19034, + 22286, + 24990, + 27078, + 28499, + 29218, + -29218, + -28499, + -27078, + -24990, + -22286, + -19034, + -15314, + -11216, + -6842, + -2300 + }; + +const Word16 MDCT_WINDOW_FS_16000_frame_ms_1_25[40] = { + 814, + 2436, + 4043, + 5625, + 7173, + 8676, + 10126, + 11514, + 12830, + 14068, + 15218, + 16275, + 17232, + 18082, + 18821, + 19443, + 19946, + 20326, + 20581, + 20708, + -20708, + -20581, + -20326, + -19946, + -19443, + -18821, + -18082, + -17232, + -16275, + -15218, + -14068, + -12830, + -11514, + -10126, + -8676, + -7173, + -5625, + -4043, + -2436, + -814 + }; + +const Word16 MDCT_WINDOW_FS_24000_frame_ms_1_25[60] = { + 443, + 1328, + 2209, + 3084, + 3950, + 4806, + 5648, + 6476, + 7285, + 8074, + 8841, + 9584, + 10301, + 10990, + 11648, + 12274, + 12867, + 13425, + 13945, + 14428, + 14871, + 15273, + 15633, + 15951, + 16224, + 16454, + 16638, + 16777, + 16869, + 16916, + -16916, + -16869, + -16777, + -16638, + -16454, + -16224, + -15951, + -15633, + -15273, + -14871, + -14428, + -13945, + -13425, + -12867, + -12274, + -11648, + -10990, + -10301, + -9584, + -8841, + -8074, + -7285, + -6476, + -5648, + -4806, + -3950, + -3084, + -2209, + -1328, + -443 + }; + +const Word16 MDCT_WINDOW_FS_32000_frame_ms_1_25[80] = { + 575, + 1725, + 2873, + 4016, + 5152, + 6281, + 7400, + 8508, + 9602, + 10682, + 11745, + 12791, + 13816, + 14820, + 15801, + 16758, + 17689, + 18593, + 19468, + 20313, + 21127, + 21908, + 22656, + 23368, + 24045, + 24684, + 25286, + 25848, + 26370, + 26852, + 27293, + 27691, + 28047, + 28359, + 28628, + 28852, + 29032, + 29167, + 29258, + 29303, + -29303, + -29258, + -29167, + -29032, + -28852, + -28628, + -28359, + -28047, + -27691, + -27293, + -26852, + -26370, + -25848, + -25286, + -24684, + -24045, + -23368, + -22656, + -21908, + -21127, + -20313, + -19468, + -18593, + -17689, + -16758, + -15801, + -14820, + -13816, + -12791, + -11745, + -10682, + -9602, + -8508, + -7400, + -6281, + -5152, + -4016, + -2873, + -1725, + -575 + }; + +const Word16 MDCT_WINDOW_FS_48000_frame_ms_1_25[120] = { + 313, + 940, + 1565, + 2190, + 2813, + 3434, + 4053, + 4669, + 5281, + 5891, + 6496, + 7096, + 7692, + 8283, + 8868, + 9446, + 10019, + 10584, + 11142, + 11693, + 12235, + 12770, + 13295, + 13811, + 14318, + 14815, + 15302, + 15778, + 16244, + 16698, + 17141, + 17573, + 17992, + 18399, + 18793, + 19174, + 19543, + 19897, + 20239, + 20566, + 20879, + 21178, + 21462, + 21732, + 21987, + 22227, + 22451, + 22660, + 22854, + 23032, + 23194, + 23340, + 23471, + 23585, + 23683, + 23764, + 23830, + 23879, + 23912, + 23928, + -23928, + -23912, + -23879, + -23830, + -23764, + -23683, + -23585, + -23471, + -23340, + -23194, + -23032, + -22854, + -22660, + -22451, + -22227, + -21987, + -21732, + -21462, + -21178, + -20879, + -20566, + -20239, + -19897, + -19543, + -19174, + -18793, + -18399, + -17992, + -17573, + -17141, + -16698, + -16244, + -15778, + -15302, + -14815, + -14318, + -13811, + -13295, + -12770, + -12235, + -11693, + -11142, + -10584, + -10019, + -9446, + -8868, + -8283, + -7692, + -7096, + -6496, + -5891, + -5281, + -4669, + -4053, + -3434, + -2813, + -2190, + -1565, + -940, + -313 +}; +#endif /* ENABLE_HR_MODE */ + +#ifdef ENABLE_HR_MODE +const Word32 *const LowDelayShapes_n960_1_25ms[6] = { + MDCT_WINDOW_FS_8000_frame_ms_1_25, MDCT_WINDOW_FS_16000_frame_ms_1_25, MDCT_WINDOW_FS_24000_frame_ms_1_25, MDCT_WINDOW_FS_32000_frame_ms_1_25, MDCT_WINDOW_FS_48000_frame_ms_1_25, NULL }; +#else +const Word16 *const LowDelayShapes_n960_1_25ms[6] = { + MDCT_WINDOW_FS_8000_frame_ms_1_25, MDCT_WINDOW_FS_16000_frame_ms_1_25, MDCT_WINDOW_FS_24000_frame_ms_1_25, MDCT_WINDOW_FS_32000_frame_ms_1_25, MDCT_WINDOW_FS_48000_frame_ms_1_25, NULL }; +#endif + +const Word16 bands_offset_16000_lpc_warp_1_25ms[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20}; + +const Word16 bands_offset_24000_lpc_warp_1_25ms[28] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30}; + +const Word16 bands_offset_32000_lpc_warp_1_25ms[32] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 31, 33, 35, 37, 40}; + +const Word16 bands_offset_48000_lpc_warp_1_25ms[34] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 43, 46, 50}; + +const Word16 *const bands_offset_1_25ms[6] = { + NULL, bands_offset_16000_lpc_warp_1_25ms, bands_offset_24000_lpc_warp_1_25ms, + bands_offset_32000_lpc_warp_1_25ms, bands_offset_48000_lpc_warp_1_25ms, NULL}; + +#ifdef ENABLE_HR_MODE +/* RAM_ALIGN const Word16 bands_number_1_25ms_HR[] = NULL; */ +const Word16 bands_number_1_25ms [] = {-1, 20, 27, 31, 33, 0}; +#else +const Word16 bands_number_1_25ms [] = {-1, 20, 27, 31, 33}; +#endif +#ifdef FIX_PLC_CONFORM_ISSUES +const Word16 bands_offset_with_one_max_1_25ms[NUM_OFFSETS] = {-1, 20, 20, 23, 20 +#ifdef ENABLE_HR_MODE + , -1, -1 +#endif +}; + +const Word16 bands_offset_with_two_max_1_25ms[NUM_OFFSETS] = {-1, 20, 20, 30, 30 +#ifdef ENABLE_HR_MODE + , -1, -1 +#endif +}; +#endif +#ifdef FIX_PLC_CONFORM_ISSUES +const Word16 bands_offset_with_one_max_lin_1_25ms[NUM_SAMP_FREQ] = {-1, 20, 30, 40, 50 +#ifdef ENABLE_HR_MODE + , 0 +#endif + }; +const Word16 bands_offset_with_two_max_lin_1_25ms[NUM_SAMP_FREQ] = {0, 0, 0, 0, 0 +#ifdef ENABLE_HR_MODE + , 0 +#endif + }; +#endif +#endif /* CR9_C_ADD_1p25MS */ + #ifdef ENABLE_HR_MODE const Word32 LowDelayShapes_n960_N480_HRA_7_5ms_IP[720] = { @@ -1410,7 +1948,7 @@ RAM_ALIGN const Word16 PhECU_whr16ms_ssWB_Q15[Lprot_hamm_len2_24k] = 23463, 24065, 24655, 25231, 25794, 26340, 26871, 27384, 27878, 28353, 28808, 29242, 29653, 30042, 30407, 30749, 31065, 31356, 31621, 31859, 32070, 32254, 32411, 32539, 32639, 32711, 32754}; #else -#define PhECU_whr16ms_sWB_Q15 NULL +#define PhECU_whr16ms_ssWB_Q15 NULL #endif #ifdef SUBSET_SWB RAM_ALIGN const Word16 PhECU_whr16ms_SWB_Q15[Lprot_hamm_len2_32k] = @@ -1553,7 +2091,7 @@ RAM_ALIGN const Word16 PhECU_preTdaFx16ms_ssWB_Q14[384] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #else -#define PhECU_preTdaFx16ms_sWB_Q14 NULL +#define PhECU_preTdaFx16ms_ssWB_Q14 NULL #endif #ifdef SUBSET_SWB RAM_ALIGN const Word16 PhECU_preTdaFx16ms_SWB_Q14[512] = { @@ -3386,7 +3924,7 @@ RAM_ALIGN const UWord16 ari_spec_bits[64][17] = { {4202, 5716, 9733, 13138, 5598, 6099, 9437, 12683, 9300, 9168, 11485, 13988, 12479, 12109, 13988, 15725, 7804}, {4400, 5965, 9508, 12479, 6009, 6360, 9105, 11781, 9300, 8982, 10970, 13138, 12109, 11629, 13138, 14731, 6994}}; -RAM_ALIGN const Word32 tnsAcfWindow_lc3plus[MAXLAG] = {0x7FBF61E2, 0x7EFE4B00, 0x7DBF01E8, 0x7C0544D0, +RAM_ALIGN const Word32 tnsAcfWindow[MAXLAG] = {0x7FBF61E2, 0x7EFE4B00, 0x7DBF01E8, 0x7C0544D0, 0x79D636E9, 0x773846E0, 0x74330F61, 0x70CF3251}; RAM_ALIGN const Word16 tnsQuantPts[TNS_COEF_RES] = {-32628, -31517, -29333, -26149, -22076, -17250, -11837, -6021, 0, 6021, 11837, 17250, 22076, 26149, 29333, 31517, 32628}; @@ -3605,6 +4143,17 @@ RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_8000[80] = { #endif #ifdef SUBSET_WB +#ifdef FIX_PLC_CONFORM_ISSUES +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_20_16000[20] = { + 0x54d4, 0x7906, 0x6043, 0x4a65, 0x6c65, 0x4aa6, 0x620c, 0x7bd2, 0x4baa, 0x59f2, 0x6869, 0x76b1, 0x4239, 0x48aa, 0x4e84, 0x53a1, + 0x57e1, 0x5b29, 0x5d65, 0x5e87 +}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_20_e_16000[20] = { + (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002 +}; +#endif RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_16000[40] = { 0x516b, 0x5a81, 0x6c9d, 0x43d2, 0x55b6, 0x6bdd, 0x4313, 0x5233, 0x6336, 0x7602, 0x453d, 0x503e, 0x5bf4, 0x684b, 0x7530, 0x4148, 0x4829, 0x4f33, 0x5658, 0x5d8f, 0x64cc, 0x6c03, 0x7328, 0x7a32, 0x408a, 0x43e1, 0x471b, 0x4a31, @@ -3644,6 +4193,18 @@ RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_16000[80] = { #endif #ifdef SUBSET_SSWB +#ifdef FIX_PLC_CONFORM_ISSUES +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_30_24000[30] = { + 0x46f5, 0x6bb5, 0x5a67, 0x485c, 0x6c1c, 0x4c07, 0x65dc, 0x41a2, 0x51f6, 0x63bd, 0x76c4, 0x456b, 0x4fde, 0x5a9d, 0x658a, 0x7087, + 0x7b74, 0x431a, 0x4853, 0x4d58, 0x5219, 0x568b, 0x5aa0, 0x5e4d, 0x6188, 0x6447, 0x6683, 0x6835, 0x695a, 0x69ed +}; +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_30_e_24000[30] = { + (Word16)0xfffc, (Word16)0xfffc, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, + (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002 +}; +#endif RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_24000[40] = { 0x44f2, 0x59a3, 0x4172, 0x603b, 0x447d, 0x5db8, 0x7ba7, 0x4f0d, 0x626d, 0x77d6, 0x4793, 0x541b, 0x6171, 0x6f7f, 0x7e2f, 0x46b5, 0x4e8b, 0x568f, 0x5eb2, 0x66ea, 0x6f28, 0x775f, 0x7f83, 0x43c3, 0x47ae, 0x4b7d, 0x4f29, 0x52ac, @@ -3703,6 +4264,22 @@ RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_e_24000[80] = { #endif #ifdef SUBSET_SWB +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_32000[40] = +{ + 0x400d, 0x4e74, 0x5584, 0x4d4b, 0x7b03, 0x59d0, 0x7b65, 0x5106, 0x66c3, 0x7ec8, 0x4c78, 0x5a88, 0x697e, 0x7942, 0x44de, 0x4d69, + 0x5634, 0x5f32, 0x6854, 0x718c, 0x7acb, 0x4201, 0x4692, 0x4b11, 0x4f77, 0x53bc, 0x57db, 0x5bcc, 0x5f89, 0x630d, 0x6652, 0x6953, + 0x6c0b, 0x6e75, 0x708e, 0x7253, 0x73c1, 0x74d5, 0x758f, 0x75eb +}; + +RAM_ALIGN const Word16 lpc_lin_pre_emphasis_40_e_32000[40] = +{ + (Word16)0xfffa, (Word16)0xfffb, (Word16)0xfffc, (Word16)0xfffd, (Word16)0xfffd, (Word16)0xfffe, (Word16)0xfffe, (Word16)0xffff, + (Word16)0xffff, (Word16)0xffff, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0000, (Word16)0x0001, (Word16)0x0001, + (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0001, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, + (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002, (Word16)0x0002 +}; + RAM_ALIGN const Word16 lpc_lin_pre_emphasis_80_32000[80] = { 0x6eab, 0x4e92, 0x7d03, 0x614a, 0x47cb, 0x64a9, 0x439a, 0x57af, 0x6e8c, 0x4414, 0x523c, 0x61b9, 0x7284, 0x424c, 0x4bf6, 0x563d, 0x611c, 0x6c8f, 0x7892, 0x4290, 0x491a, 0x4fe5, 0x56ed, 0x5e31, 0x65ac, 0x6d5d, 0x753f, 0x7d51, @@ -3846,6 +4423,25 @@ RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e_2_5ms[NUM_SAMP_FREQ] = { #endif }; +#ifdef FIX_PLC_CONFORM_ISSUES +RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_1_25ms[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_20_8000, lpc_lin_pre_emphasis_20_16000, lpc_lin_pre_emphasis_30_24000, + lpc_lin_pre_emphasis_40_32000, lpc_lin_pre_emphasis_60_48000 +#ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_0_92 +#endif +}; + +RAM_ALIGN const Word16* const lpc_lin_pre_emphasis_e_1_25ms[NUM_SAMP_FREQ] = { + lpc_lin_pre_emphasis_20_e_8000, lpc_lin_pre_emphasis_20_e_16000, lpc_lin_pre_emphasis_30_e_24000, + lpc_lin_pre_emphasis_40_e_32000, lpc_lin_pre_emphasis_60_e_48000 +#ifdef ENABLE_HR_MODE + , lpc_lin_pre_emphasis_80_e_0_92 +#endif +}; +#endif + + RAM_ALIGN const Word16 lpc_lin_pre_emphasis_60_0_62[60] = { 0x4a26, 0x4be4, 0x4f5d, 0x5490, 0x5b79, 0x6414, 0x6e59, 0x7a43, 0x43e4, 0x4b6f, 0x53bf, 0x5ccc, 0x6690, 0x7106, 0x7c25, 0x43f3, 0x4a1f, 0x5095, 0x574e, 0x5e46, 0x6578, 0x6cdf, 0x7477, 0x7c39, 0x4210, 0x4613, 0x4a24, 0x4e3e, @@ -4402,6 +4998,16 @@ RAM_ALIGN const Word16 *const bands_offset_lin_2_5ms[NUM_SAMP_FREQ] = {bands_off #endif }; +#ifdef FIX_PLC_CONFORM_ISSUES +RAM_ALIGN const Word16 *const bands_offset_lin_1_25ms[NUM_SAMP_FREQ] = {bands_offset_8000_lpc_lin, bands_offset_8000_lpc_lin, + bands_offset_8000_lpc_lin, bands_offset_8000_lpc_lin, + bands_offset_8000_lpc_lin +#ifdef ENABLE_HR_MODE + , bands_offset_24000_lpc_lin +#endif + }; +#endif + RAM_ALIGN const Word16 bands_offset_with_one_max_lin[NUM_SAMP_FREQ] = {80, 0, 0, 0, 0 #ifdef ENABLE_HR_MODE , 0 @@ -4519,6 +5125,18 @@ RAM_ALIGN const Word32 inv_odft_twiddle_40_im[16] = { 0x05067734, 0x0a0af299, 0x0f0b7727, 0x14060b68, 0x18f8b83c, 0x1de189a6, 0x22be8f87, 0x278dde6e, 0x2c4d9050, 0x30fbc54d, 0x3596a46c, 0x3a1c5c57, 0x3e8b240e, 0x42e13ba4, 0x471cece7, 0x4b3c8c12}; +#ifdef FIX_PLC_CONFORM_ISSUES +RAM_ALIGN const Word32 inv_odft_twiddle_30_re[16] = { + 0x7fd317b4, 0x7f4c7e54, 0x7e6c9251, 0x7d33f0ca, 0x7ba3751d, 0x79bc384d, 0x777f903c, 0x74ef0ebc, + 0x720c8075, 0x6ed9eba1, 0x6b598ea3, 0x678dde6e, 0x637984d4, 0x5f1f5ea1, 0x5a82799a, 0x55a6125c +}; + +RAM_ALIGN const Word32 inv_odft_twiddle_30_im[16] = { + 0x06b2f1d2, 0x0d61304e, 0x14060b68, 0x1a9cd9ac, 0x2120fb83, 0x278dde6e, 0x2ddf0040, 0x340ff242, + 0x3a1c5c57, 0x40000000, 0x45b6bb5e, 0x4b3c8c12, 0x508d9211, 0x55a6125c, 0x5a82799a, 0x5f1f5ea1 +}; +#endif + RAM_ALIGN const Word32 inv_odft_twiddle_20_re[16] = { 0x7f9afcb9, 0x7e6c9251, 0x7c769e18, 0x79bc384d, 0x7641af3d, 0x720c8075, 0x6d23501b, 0x678dde6e, 0x6154fb91, 0x5a82799a, 0x53211d18, 0x4b3c8c12, 0x42e13ba4, 0x3a1c5c57, 0x30fbc54d, 0x278dde6e}; @@ -4773,6 +5391,19 @@ RAM_ALIGN const Word16 sns_Kval[4][2] = {{10, 1}, {10, 0}, {8, 0}, {6, RAM_ALIGN const UWord32 sns_MPVQ_Sz[4][2] = { {4780008U >> 1, (2U * 6U)}, {4780008U >> 1, (2U)}, {30316544U >> 1, 0U}, {MPVQ_SZ_OUTL_FAR, 0U}}; +#ifdef NEW_SIGNALLING_SCHEME_1p25 +RAM_ALIGN const Word16 lrsns_ltp_bits_fx[8] = { + 2, /*00(x=0) , ltp=0 ltpf=0 x is next param */ + 2, /*00(x=1) x is next param */ + 3 + 4, /*010 ltp=1 ltpf=0, phaseA or PhaseB(phaseB with reduced resolution) */ + 3 + 4, /*011 ltp=1 ltpf=0, PhaseB(phaseB with reduced resolution) */ + 2 + 4, /*10(x=0) ltp=1 ltpf=1, phase A, +extra bit */ + 2 + 4, /*10(x=1) */ + 2 + 5, /*11(x=0) ltp=1 ltpf=1, phase B , +extra bit */ + 2 + 5 /*11(x=1) */ +}; +#endif + #ifdef ENABLE_HR_MODE RAM_ALIGN const Word32 st1SCF0_7_base5_32x8_Q27[256] = { 303712392, 109160791, -71161366, -182086260, -214684177, -193406093, -153520450, -101361734, 395293327, @@ -4836,7 +5467,12 @@ RAM_ALIGN const Word32 st1SCF8_15_base5_32x8_Q27[256] = { 350549113, 357744389, 322261535, 236116337 }; #endif -RAM_ALIGN const Word16 st1SCF0_7_base5_32x8_Q11[256] = { +#ifdef CR9_C_ADD_1p25MS_LRSNS +RAM_ALIGN const Word16 st1SCF0_7_base5_32x8_Q11[32 * 8 * 2] = +#else +RAM_ALIGN const Word16 st1SCF0_7_base5_32x8_Q11[256] = +#endif +{ 4634, 1666, -1086, -2778, -3276, -2951, -2343, -1547, 6032, 4939, 1967, -908, -2517, -3186, -3066, -2287, -4477, -4038, -3660, -3929, -3674, -2780, -1445, -98, 1421, 1957, 1178, -235, -1323, -1950, -2200, -1553, -2657, -1516, -707, -642, -825, -762, -160, 199, 1873, 3570, 3910, 3162, 2239, 1326, 74, -608, @@ -4852,9 +5488,50 @@ RAM_ALIGN const Word16 st1SCF0_7_base5_32x8_Q11[256] = { 5188, 4327, 2586, 1560, 1069, 243, -926, -1434, 8190, 8354, 5781, 3535, 1325, -678, -1811, -2308, 1040, 3253, 3541, 2062, 772, 976, 2227, 2227, 6489, 6673, 4961, 3675, 3117, 2400, 1002, -128, 3879, 2562, 1209, 1246, 1798, 2292, 2086, 1271, 1943, 4367, 5578, 5673, 5208, 4138, 1700, -56, - -3851, -2589, 638, 3762, 4621, 4195, 4496, 4150, 505, 1957, 3114, 4048, 3974, 4575, 4072, 2606}; + -3851, -2589, 638, 3762, 4621, 4195, 4496, 4150, 505, 1957, 3114, 4048, 3974, 4575, 4072, 2606 + #ifdef CR9_C_ADD_1p25MS_LRSNS + /* negated part */ + , -4634, -1666, 1086, 2778, 3276, 2951, 2343, 1547, + -6032, -4939, -1967, 908, 2517, 3186, 3066, 2287, + 4477, 4038, 3660, 3929, 3674, 2780, 1445, 98, + -1421, -1957, -1178, 235, 1323, 1950, 2200, 1553, + 2657, 1516, 707, 642, 825, 762, 160, -199, + -1873, -3570, -3910, -3162, -2239, -1326, -74, 608, + 5149, 5922, 4105, 1538, -904, -2462, -2719, -2500, + 1889, -1295, -2227, -1246, -269, 607, 424, -276, + -1619, -1287, -805, -983, -917, -430, -13, 176, + -2965, -5579, -4733, -1915, 563, 1847, 1927, 1298, + -1625, -29, 1163, 1341, 982, 356, -139, -604, + -5579, -6061, -3788, -1154, -287, -737, -1412, -1310, + 1087, 436, -12, -870, -969, -1759, -2439, -2040, + -3456, -4989, -4772, -3645, -2958, -3113, -3015, -2002, + 6045, 3264, 225, -796, -1050, -1286, -1685, -1794, + -209, -1208, -1268, -2595, -4955, -4612, -1078, 812, + -5494, -2718, -267, 693, 754, 393, 317, 480, + -9886, -6389, -2857, -513, 806, 1318, 1316, 1481, + -180, 1167, 2345, 3420, 3779, 3204, 2289, 1094, + -2849, -4058, -2279, 451, 1587, 1217, -280, -1676, + -788, 329, 1105, 1084, -390, -5244, -5773, -1345, + -3957, -6165, -6278, -5122, -3954, -1172, 1662, 2409, + -359, 1537, 2129, 2326, 2134, 31, -4240, -7024, + 2433, -751, -2682, -3447, -2562, -1930, -1692, -901, + -5188, -4327, -2586, -1560, -1069, -243, 926, 1434, + -8190, -8354, -5781, -3535, -1325, 678, 1811, 2308, + -1040, -3253, -3541, -2062, -772, -976, -2227, -2227, + -6489, -6673, -4961, -3675, -3117, -2400, -1002, 128, + -3879, -2562, -1209, -1246, -1798, -2292, -2086, -1271, + -1943, -4367, -5578, -5673, -5208, -4138, -1700, 56, + 3851, 2589, -638, -3762, -4621, -4195, -4496, -4150, + -505, -1957, -3114, -4048, -3974, -4575, -4072, -2606 +#endif +}; -RAM_ALIGN const Word16 st1SCF8_15_base5_32x8_Q11[256] = { +#ifdef CR9_C_ADD_1p25MS_LRSNS +RAM_ALIGN const Word16 st1SCF8_15_base5_32x8_Q11[8 * 32 * 2] = +#else +RAM_ALIGN const Word16 st1SCF8_15_base5_32x8_Q11[256] = +#endif +{ 475, -2066, -4387, -4865, -4568, -4456, -4691, -5187, -2652, -3685, -3865, -3707, -3611, -3756, -3696, -3557, 285, -529, -1333, -2188, -3316, -4480, -5402, -6101, -648, -978, -1129, -993, -488, -293, 140, 181, 1801, 611, -1875, -4519, -5614, -5860, -5915, -6045, -608, -1997, -2782, -2015, -1337, -2027, -3307, -4930, @@ -4870,7 +5547,43 @@ RAM_ALIGN const Word16 st1SCF8_15_base5_32x8_Q11[256] = { 7679, 3120, -937, -1636, -792, -770, -1347, -2625, -2361, -2269, -1152, -452, -716, -1543, -2025, -2638, 2106, 2248, 1574, 422, -702, -1546, -2134, -3079, 264, 1412, 2301, 2682, 2775, 2915, 2370, 832, 2745, 2847, 2140, 1302, -563, -3173, -5002, -6194, 4380, 8698, 5934, 1910, -600, -1660, -1616, -1916, - 1157, 3260, 4911, 6220, 5456, 2853, 827, -1344, -865, 668, 2850, 4570, 5349, 5459, 4917, 3603}; + 1157, 3260, 4911, 6220, 5456, 2853, 827, -1344, -865, 668, 2850, 4570, 5349, 5459, 4917, 3603 + #ifdef CR9_C_ADD_1p25MS_LRSNS + /* negated part */ + , -475, 2066, 4387, 4865, 4568, 4456, 4691, 5187, + 2652, 3685, 3865, 3707, 3611, 3756, 3696, 3557, + -285, 529, 1333, 2188, 3316, 4480, 5402, 6101, + 648, 978, 1129, 993, 488, 293, -140, -181, + -1801, -611, 1875, 4519, 5614, 5860, 5915, 6045, + 608, 1997, 2782, 2015, 1337, 2027, 3307, 4930, + -698, -551, -115, -102, 195, 1557, 4767, 7724, + 2892, 3042, 2429, 1280, -315, -1180, -1628, -1222, + 469, 683, 1657, 3350, 3860, 3369, 2878, 3004, + 2194, 2903, 3172, 2976, 2113, 1414, 878, 1014, + 1210, 146, -708, -616, 2291, 4999, 4564, 3881, + 1738, 1194, -184, -1731, -2183, -1511, -525, 1008, + -2336, -1974, -781, 989, 3720, 5740, 6623, 7084, + 771, -87, -1058, -516, 443, 1094, 1312, 1781, + -1362, -2249, -2833, -2751, -1685, -442, 829, 2192, + 1692, 1375, 468, -1063, -2800, -4465, -5194, -4508, + -2888, -1545, 2674, 3832, 2540, 2595, 4171, 5933, + -740, 45, 1187, 1801, 1742, 1596, 1500, 1819, + -896, -626, 15, 1015, 1652, 2507, 3485, 4598, + -1327, -1397, -519, -151, -644, -481, -296, 140, + -2292, -2529, -1207, 2810, 4856, 4112, 3414, 3945, + -291, 227, 579, 14, -586, -94, 1234, 4640, + -1032, -1694, -2293, -2415, -2212, -1429, 1869, 7325, + 1026, 667, -58, -537, -738, -1302, -1964, -2678, + -7679, -3120, 937, 1636, 792, 770, 1347, 2625, + 2361, 2269, 1152, 452, 716, 1543, 2025, 2638, + -2106, -2248, -1574, -422, 702, 1546, 2134, 3079, + -264, -1412, -2301, -2682, -2775, -2915, -2370, -832, + -2745, -2847, -2140, -1302, 563, 3173, 5002, 6194, + -4380, -8698, -5934, -1910, 600, 1660, 1616, 1916, + -1157, -3260, -4911, -6220, -5456, -2853, -827, 1344, + 865, -668, -2850, -4570, -5349, -5459, -4917, -3603 + #endif +}; /* tables for MPVQ pulse enumeration */ @@ -4920,14 +5633,30 @@ RAM_ALIGN const UWord32 h_memN10K22[22 + 2] = {0U, RAM_ALIGN const UWord32 h_memN6K2[2 + 2] = {0U, 1U, 11U, /*U*/ 30U}; /*N=6,K=1, h_memN6K1={0U,1U, 5U,}; */ -RAM_ALIGN const UWord32 *const MPVQ_offs_ptr[M + 1] = {NULL /*0*/, NULL, NULL, NULL, NULL, NULL, - h_memN6K2, NULL, NULL, NULL, h_memN10K22, NULL, - NULL, NULL, NULL, NULL, h_memN16K12}; +#ifdef CR9_C_ADD_1p25MS_LRSNS +RAM_ALIGN const UWord32 h_memN5K8[8 + 2] = { 0U, 1U, 9U, 41U, 129U, 321U, 681U, 1289U, 2241U, /*U*/ 1824U }; +RAM_ALIGN const UWord32 h_memN8K2[2 + 2] = { 0U, 1U, 15U, /*U*/ 56U }; +RAM_ALIGN const UWord32 h_memN15K5[5 + 2] = { 0U, 1U, 29U, 421U, 4089U, 29961U, /*U*/ 88522U }; + +RAM_ALIGN const UWord32* const MPVQ_offs_ptr[M + 1] = { NULL /*0*/, NULL, NULL, NULL, NULL, h_memN5K8, + h_memN6K2, NULL, h_memN8K2, NULL, h_memN10K22, NULL, + NULL, NULL, NULL, h_memN15K5 , h_memN16K12 }; +#else +RAM_ALIGN const UWord32* const MPVQ_offs_ptr[M + 1] = { NULL /*0*/, NULL, NULL, NULL, NULL, NULL, + h_memN6K2, NULL, NULL, NULL, h_memN10K22, NULL, + NULL, NULL, NULL, NULL, h_memN16K12 }; +#endif /*maxK coefficents for MPVQ de-indexing lookup */ +#ifdef CR9_C_ADD_1p25MS_LRSNS +RAM_ALIGN const Word16 tabledKMAX[M + 1] = { + 0, 0, 0, 0, 0, 8/*N=5 LR*/, 2 /*N=6*/, 0, 2 /*N=8 LR*/, 0, 22 /*N=10*/, 0, 0, 0, 0, 5/*N==15 LR*/, 12 /*N=16*/ +}; +#else RAM_ALIGN const Word16 tabledKMAX[M + 1] = { 0, 0, 0, 0, 0, 0, 2 /*N=6*/, 0, 0, 0, 22 /*N=10*/, 0, 0, 0, 0, 0, 12 /*N=16*/ }; +#endif RAM_ALIGN const Word16 isqrt_Q16tab[1 + 64] = {/*table generated using ISqrt16 function + shift to Q16 */ 32767, 32767, 32767, 32767, 32766, 29308, 26754, 24770, 23169, 21844, @@ -4938,7 +5667,7 @@ RAM_ALIGN const Word16 isqrt_Q16tab[1 + 64] = {/*table generated using ISqrt16 f 9268, 9176, 9088, 9001, 8918, 8836, 8757, 8680, 8605, 8532, 8460, 8390, 8323, 8256, 8191}; -#ifdef ENABLE_HR_MODE +#if defined(ENABLE_HR_MODE) || defined (CR9_C_ADD_1p25MS_LRSNS) RAM_ALIGN const Word32 isqrt_Q31tab[1 + 64] = {/* 2^31 / sqrt(idx) */ 2147483647, 2147483647, 1518500249, 1239850262, 1073741824, 960383883, 876706528, 811672525, 759250124, 715827882, 679093956, 647490682, @@ -4969,3 +5698,344 @@ RAM_ALIGN const Word16 adjust_global_gain_tables[5][NUM_SAMP_FREQ] = {{80, 230, const Word16 plc_fadeout_param_maxlen[4] = {800, 400, 266, 200}; const Word16 plc_fadeout_param_maxbytes[4] = {27, 14, 9, 7}; + +#ifdef CR9_C_ADD_1p25MS_LRSNS +RAM_ALIGN const Word16 lrsns_vq_gain_lvls_fx[SNSLR_MAX_PVQ_SEARCH_CAND] = { 4,8,8 }; + +/* BASOP gains stored in Q12 to be aligned with the 38-bit SNS-VQ BASOP gain tables */ +/* Cfloat values wer Q11 quantizd */ +RAM_ALIGN const Word16 lrsns_vq_split_gainsQ12_fx[4] = { 7424 , 10240 , 13568 , 17664 }; +/* q_gains5Q11_shape0_4[4] = { +1.8125 , +2.5000 , +3.3125 , +4.3125 }; */ +RAM_ALIGN const Word16 lrsns_vq_full_gainsQ12_fx[8] = { 5888 , 7424 , 8704 , 10240 , 12032 , 14336 , 16640 , 20224 }; +/* q_gains5Q11_shape1_8[8] = { +1.4375 , +1.8125 , +2.125 , +2.500 , +2.9375 , +3.5000 , +4.0625 , +4.9375 }; */ +RAM_ALIGN const Word16 lrsns_vq_fixenv_gainsQ12_fx[8] = { 5632 , 7168 , 8192 , 9472 , 10752 , 12544 , 14592 , 18176 }; +/* q_gains5Q11_shape2_8[8] = { ++1.375, +1.75, +2.0 , +2.3125 , +2.625 , +3.0625 , +3.5625 , +4.4375 }; */ + +RAM_ALIGN const Word16 *const lrsns_vq_gainsQ12_fx[SNSLR_MAX_PVQ_SEARCH_CAND] = +{ lrsns_vq_split_gainsQ12_fx, lrsns_vq_full_gainsQ12_fx, lrsns_vq_fixenv_gainsQ12_fx }; + +RAM_ALIGN const Word16 lrsns_cbA_fx[2 * 16] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -0, + 2431, 2077, 1592, 824, 16, -540, -560, -536, + -154, 385, 927, 1129, 455, -760, -2567, -4719 +}; + +#endif + +#ifdef CR9_C_ADD_1p25MS_LRSNS + +/*LRSNS tables to construct the 170x16 st1B from legacy st1(LF,HF) tables */ +/* each index point to two vector in the split 2x32 stage 1 cb , lower 12 bits in use [1][5][1][5] */ +/* ff,fr,rf,rr , handled by counting the absoulte idx */ +RAM_ALIGN const Word16 lrsns_st1B_merged170orderSortedSegmCnt_fx[4] = { /*ff,fr,rf,rr */ + 88, 42, 24, 16 +}; +RAM_ALIGN const Word16 lrsns_st1B_merged170orderSortedSegmCum_fx[5] = { /*ff,fr,rf,rr */ + 0, 88, 130, 154, 170 +}; +RAM_ALIGN const Word16 lrsns_st1B_merged170orderSort12bitIdx_fx[170] = { /* actually 14 bit index can also be saved */ + 15, 19, 119, 162, 177, 185, 227, 296, 297, 353, 357, 369, 370, 372, 377, 416, 418, + 420, 515, 529, 561, 569, 603, 625, 627, 673, 680, 754, 756, 777, 786, 801, 809, 834, + 837, 848, 849, 850, 852, 864, 865, 866, 872, 904, 908, 913, 914, 924, 928, 978, 996, + 1041, 1082, 1088, 1089, 1090, 1139, 1651, 1751, 1982, 1999, 2066, 2120, 2194, 2247, 2391, 2495, 2579, + 2626, 2632, 2649, 2959, 3071, 3107, 3223, 3331, 3395, 3415, 3548, 3641, 3675, 3703, 3820, 3825, 3849, + 3853, 3865, 3916, 45, 107, 110, 151, 168, 169, 247, 305, 313, 323, 357, 361, 777, 785, + 841, 1096, 1123, 1347, 1427, 1498, 1555, 1617, 1643, 1646, 1651, 1774, 2051, 2087, 2265, 2296, 2371, + 2971, 3022, 3241, 3287, 3319, 3331, 3543, 3601, 3683, 3689, 3697, 122, 259, 274, 387, 401, 496, + 657, 707, 739, 850, 857, 928, 929, 932, 996, 1123, 1270, 1303, 1609, 2151, 2193, 2371, 2632, + 2633, 55, 119, 291, 299, 343, 681, 1001, 1307, 1427, 1609, 1646, 1683, 2157, 2222, 3331, 4060 +}; + +RAM_ALIGN const Word32 lrsns_st1B_enBy2TabW32_fx[2 * 32] = { + /*LF part*/ + 30234814, 48294454, 44252960, 10048319, 5798194, 24342955, 50660188, 6227077, + 3474389, 37555746, 3633757, 43938502, 8136036, 52215414, 28346960, 28744396, + 19588476, 76644956, 24786264, 18434221, 32956728, 72443234, 42151630, 19760916, + 29437456, 96801748, 19960876, 70624637, 19538794, 66641198, 56240496, 45131948, + + /*HF part*/ + 68520493, 51375963, 52197680, 2006716, 82469877, 28647435, 42830587, 15395581, + 29105630, 20211225, 34248538, 7908398, 75887420, 4137010, 15516815, 40589204, + 49172712, 8171368, 22263062, 2379007, 44354878, 11938118, 39554253, 7529063, + 41090552, 13103632, 14530709, 18529070, 47842888, 71549086, 57585190, 62886415, +}; + +const RAM_ALIGN Word16 lrsns_st1C_pitch0_mp0Q11_fx[16] = { + 2293, 2602, 1960, 1161, 880, 417, 34, -169, + -368, -541, -604, -318, -287, -958, -2341, -3759 +}; +const RAM_ALIGN Word16 lrsns_st1C_pitch1_mp1Q11_fx[16] = { + 258, 805, 789, 533, 507, 123, 183, 155, + 88, 151, 535, 1019, 1023, 58, -2013, -4211 +}; +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY +const RAM_ALIGN Word16* lrsns_st1CTrainedMapMeans_fx[2] = { lrsns_st1C_pitch0_mp0Q11_fx ,lrsns_st1C_pitch1_mp1Q11_fx }; +#else +const RAM_ALIGN Word16 lrsns_st1C_pitch2_mp2Q11_fx[16] = { + -421, 206, 399, 323, 383, 25, 233, 263, + 240, 381, 914, 1464, 1460, 397, -1904, -4361 +}; +const RAM_ALIGN Word16* lrsns_st1CTrainedMapMeans_fx[3] = { lrsns_st1C_pitch0_mp0Q11_fx ,lrsns_st1C_pitch1_mp1Q11_fx,lrsns_st1C_pitch2_mp2Q11_fx }; +#endif +/* BE representable in Q11 after Q4*Q7 multiplcation */ +const RAM_ALIGN Word16 lrsns_st1C_Both_scaleQ4_7p4bits_fx[2] = { +-1, 86 /* exact BASOP Q4 value, used in synthesis */ }; +const RAM_ALIGN Word16 lrsns_st1C_Both_inv_scaleQ15_7p4bits_fx[2] = { +-1 , 6096 /* BASOP Q15 value, invScale used in encoder side target creation */ }; + +/* Word8 storage of ST1 codebook to save ROM in BASOP */ +const RAM_ALIGN Word8 lrsns_st1C_Both_Word8_fx[170 * 16] = { + -88, -78, -57, -39, -27, -15, -6, 3, 11, 17, 20, 23, 32, 47, 69, 88, + -86, -40, -7, 4, 1, 5, 10, 10, 0, -5, -5, 4, 9, 23, 38, 39, + -71, -69, -65, -49, -29, -5, 16, 30, 21, -8, -3, 15, 27, 40, 63, 87, + -71, -36, -10, -5, 2, 17, 15, 18, 24, 24, 13, 7, 11, 2, -6, -7, + -70, -23, 13, 12, 0, 7, 19, 14, 1, -1, 6, 3, -2, 1, 9, 13, + -68, -79, -67, -42, -26, -17, 8, 29, 38, 34, 32, 33, 32, 36, 36, 21, + -62, -66, -56, -41, -33, -13, 11, 17, 16, 17, 28, 39, 40, 41, 40, 23, + -61, -62, -51, -31, -26, -25, -23, -15, -3, 12, 24, 30, 33, 43, 68, 85, + -60, -63, -47, -28, -17, -9, 13, 30, 36, 31, 25, 24, 27, 28, 17, -6, + -57, -47, -25, -11, -17, -12, -1, -7, -4, -1, -7, 1, 23, 44, 58, 60, + -54, -59, -61, -50, -22, -1, 25, 37, 37, 31, 21, 13, 21, 31, 27, 4, + -53, -36, -14, 3, 13, 12, 14, 19, 26, 31, 30, 22, 3, -12, -21, -36, + -53, -52, -39, -24, -12, 2, 23, 34, 32, 27, 16, 8, 11, 21, 14, -9, + -45, -46, -31, -16, -8, -5, 6, 21, 31, 32, 26, 22, 18, 11, 1, -17, + -40, -11, 7, 11, 4, 13, 5, -13, -28, -20, -10, 0, 8, 19, 23, 32, + -40, -32, -18, -2, 6, 12, 8, 1, 2, 4, 9, 15, 20, 13, 3, -1, + -40, -9, 11, 7, 6, 6, 0, -13, -13, -1, 7, 12, 8, 4, 6, 9, + -39, 5, 19, 12, 13, 9, 4, 3, -2, -6, -4, 2, 3, -2, -6, -13, + -38, -13, 1, 1, 4, 17, 16, 12, 8, 0, -9, -23, -20, 0, 18, 24, + -38, -25, -13, -12, -24, -17, -6, 4, 10, 6, -17, -13, 6, 35, 51, 53, + -38, -34, -30, -24, -9, 7, 17, 18, 14, 9, 11, 14, 18, 18, 12, -3, + -38, -36, -19, 2, 20, 28, 28, 33, 31, 16, 6, 4, -4, -12, -23, -36, + -38, -46, -38, -22, -17, -22, -11, 18, 35, 34, 27, 25, 24, 22, 12, -3, + -37, 3, 34, 16, -8, -30, -54, -45, -23, -9, -3, 14, 12, 15, 42, 72, + -35, -55, -53, -38, -30, -20, -5, 6, 13, 16, 21, 25, 29, 41, 48, 36, + -35, -45, -50, -47, -48, -41, -31, -16, -1, 9, 20, 21, 29, 51, 81, 104, + -35, -46, -46, -35, -24, -11, 9, 27, 34, 33, 27, 25, 21, 17, 9, -6, + -34, -24, -20, -13, -11, -7, 2, 2, -13, -4, 23, 31, 21, 16, 16, 16, + -33, -54, -66, -58, -43, -23, -16, -10, 1, 18, 23, 18, 28, 51, 74, 89, + -31, 16, 51, 48, 30, 18, 12, 2, -7, -17, -23, -26, -29, -26, -17, -1, + -31, -20, -18, -20, -13, -8, 1, 13, 20, 2, -13, -8, 12, 27, 31, 25, + -30, -33, -40, -36, -30, -11, 3, 10, 14, 15, 24, 29, 31, 27, 20, 8, + -30, -45, -40, -20, -14, -21, -31, -23, -10, 1, 12, 15, 22, 39, 64, 83, + -29, -15, 0, 4, 8, 16, 17, 11, 5, 4, 2, 1, 11, 7, -13, -29, + -29, -29, -20, -3, 15, 27, 27, 18, 17, 29, 31, 19, -3, -19, -35, -44, + -28, -21, -26, -26, 2, 22, 30, 37, 34, 18, 8, 2, 0, -9, -18, -25, + -28, -19, -11, -7, -1, 8, 13, 17, 21, 25, 30, 23, 5, -9, -26, -42, + -27, -9, 3, 2, 3, 11, -7, -14, 9, 25, 14, -6, -4, -1, 0, 2, + -27, -27, -25, -17, -18, -10, -8, -16, -18, 1, 16, 20, 29, 35, 38, 27, + -26, -44, -8, 8, -12, -5, -6, -9, 1, 13, 17, 15, 35, 42, 6, -29, + -24, -22, -16, -13, -12, 0, 10, 15, 19, 8, 5, 13, 26, 18, -5, -21, + -24, -42, -47, -33, -31, -32, -19, 2, 13, 13, 9, 4, 16, 35, 58, 80, + -24, -16, -7, -4, -7, -6, -8, -9, -3, 5, 11, 15, 23, 22, 12, -2, + -23, -13, 1, 1, -19, -17, 7, 21, 29, 29, 20, 12, 0, -9, -15, -26, + -23, -39, -40, -26, -19, -13, -4, -10, -21, -20, 0, 18, 26, 39, 57, 73, + -22, -26, -25, -25, -28, -21, -3, 23, 35, 38, 31, 20, 10, 5, 2, -13, + -21, 3, 27, 20, -9, -8, 4, 3, -3, -10, -18, -16, -4, 8, 11, 13, + -21, -13, -5, 1, 15, 22, 23, 27, 31, 25, 13, -1, -18, -28, -33, -40, + -20, -15, 0, 10, 9, 13, 12, 0, -15, -8, 7, 9, 4, 0, -2, -6, + -20, -15, -9, -6, -2, -14, -40, -5, 34, 49, 45, 29, -7, -16, -7, -18, + -19, 13, 24, 22, 27, 17, 2, -1, -8, -17, -26, -16, 0, 1, -4, -15, + -18, -14, -7, 6, 19, 21, 20, 22, 20, 16, 17, 14, -5, -27, -39, -44, + -17, 30, 76, 76, 57, 44, 11, -23, -43, -54, -57, -58, -53, -33, 5, 40, + -17, -19, -22, -34, -39, -15, 12, 23, 21, 17, 18, 22, 20, 13, 6, -7, + -17, -12, -8, 6, 19, 4, -15, 0, 21, 32, 30, 8, -9, -15, -20, -24, + -16, 33, 77, 82, 55, 23, -2, -11, -20, -39, -58, -65, -58, -33, 0, 32, + -16, -21, -26, -21, -7, 7, 10, 8, 11, 16, 22, 20, 12, 3, -4, -16, + -15, 8, 29, 23, 11, -9, -29, -23, -14, -5, -2, -2, 4, 10, 9, 3, + -14, -17, -19, -22, -11, 2, 15, 27, 33, 27, 20, 14, 3, -10, -20, -27, + -13, -2, 6, 3, -7, -7, 4, 26, 31, 19, 13, 12, -4, -23, -29, -32, + -13, -6, 6, 18, 21, 18, 12, 7, 5, 5, 5, -1, -7, -15, -23, -33, + -12, -7, 0, 3, 5, 0, -5, 4, 18, 24, 25, 16, 1, -13, -25, -34, + -12, -3, 0, -4, -3, 10, 9, -3, -5, -6, -6, -3, 14, 20, 5, -14, + -12, -11, -15, -14, -7, 2, 12, 6, -10, -21, -4, 11, 22, 22, 15, 4, + -11, -12, -13, -5, 11, 16, 11, 6, 5, 15, 22, 20, 3, -12, -23, -33, + -11, -10, -8, -11, -3, 13, 19, 18, 11, -1, -12, -8, 6, 7, 0, -12, + -11, -17, -20, -20, -16, -9, -2, 7, 24, 32, 32, 26, 14, 0, -14, -27, + -10, -11, -11, -20, -26, -25, -7, 7, 20, 29, 19, 6, 5, 15, 9, 0, + -10, -5, -7, -9, -4, 9, 10, 0, -17, -28, -21, -7, 12, 28, 29, 22, + -8, -20, -30, -25, -28, -26, -18, -9, 7, 15, 24, 26, 30, 33, 24, 5, + -8, -17, -19, -17, -16, -7, -7, -7, 3, 4, 4, 6, 21, 28, 22, 10, + -8, 35, 62, 60, 43, 21, 6, -4, -21, -34, -37, -42, -43, -32, -12, 6, + -8, -6, -3, -1, 1, 0, -5, -5, 2, 11, 23, 21, 8, -2, -11, -24, + -7, -21, -21, -13, 1, 18, 28, 30, 30, 34, 33, 18, 0, -21, -52, -57, + -6, -31, -40, -39, -36, -27, -20, -22, -19, -4, 10, 12, 19, 38, 69, 95, + -6, -38, -48, -42, -37, -27, -13, 2, 7, 9, 17, 23, 33, 45, 46, 28, + -6, -18, -39, -58, -59, -34, -15, -6, 0, 4, 15, 22, 24, 38, 59, 71, + -4, 6, 6, 11, 15, 9, 1, -7, 2, 11, 16, 10, -5, -14, -26, -31, + -4, 2, 7, -6, -59, -49, -4, -1, 1, 15, 9, -19, -19, 11, 52, 64, + -2, 31, 53, 43, 20, 8, -2, -17, -24, -21, -22, -25, -22, -14, -8, 1, + 1, -3, -3, 4, 6, 9, -4, -31, -39, -17, -5, -1, 6, 16, 27, 34, + 1, 10, 15, 12, -5, -20, -21, -10, 12, 27, 23, 10, -4, -12, -17, -23, + 3, 13, 23, 25, 20, 14, 3, 7, 11, -4, -31, -43, -35, -21, -1, 19, + 3, -3, -9, -16, -19, -7, 1, 7, 11, -2, -5, 5, 23, 20, 2, -10, + 4, -22, -27, -23, -23, -11, 7, 14, 15, 15, 6, -3, -9, -6, 19, 44, + 5, -5, -9, -8, -9, -7, 0, 17, 29, 22, 12, 12, 6, -8, -23, -32, + 6, -31, -58, -64, -41, -12, -1, 3, 2, 0, 3, 6, 21, 37, 55, 74, + 7, 12, 10, 1, 2, 6, 2, -5, -7, -3, -2, 0, 1, 1, -6, -19, + 9, 1, 2, 12, 15, 11, -11, -33, -17, 13, 20, 9, 0, -7, -11, -13, + 10, 21, 26, 24, 18, 4, -5, -13, -14, -6, 4, 7, -7, -19, -25, -25, + 11, 1, -4, -7, -17, -28, -18, 4, 19, 27, 21, 12, 6, 2, -8, -20, + 11, 4, -17, -36, -48, -39, -18, 0, 3, 1, 3, 6, 15, 27, 39, 49, + 11, 3, -12, -26, -20, -2, 11, 16, 14, 9, 18, 19, 6, -7, -15, -25, + 12, 0, -12, -7, -5, -15, -21, -14, -5, 4, 13, 22, 22, 13, 3, -8, + 14, 17, 19, 17, 17, 16, 1, -9, -8, -5, -13, -11, -6, -7, -14, -27, + 14, 33, 52, 50, 32, 12, -1, -6, -8, -14, -23, -30, -36, -35, -26, -13, + 16, 11, 10, 15, 21, 13, 13, 10, 8, 4, 6, 6, -6, -25, -50, -52, + 17, 9, 9, 23, 23, 10, 5, 16, 20, 13, 2, -18, -35, -39, -30, -23, + 17, 31, 47, 49, 42, 32, 22, 8, -7, -21, -31, -30, -43, -53, -42, -21, + 19, 37, 50, 42, 28, 24, 15, -8, -22, -22, -19, -28, -39, -39, -26, -12, + 19, 39, 47, 31, 10, 0, 1, 1, -6, -15, -21, -23, -26, -25, -18, -13, + 19, 12, 0, -7, -3, 1, -2, -12, -19, -19, -11, -1, 9, 14, 12, 5, + 19, 33, 47, 55, 47, 23, -6, -18, -23, -24, -14, -9, -22, -34, -42, -33, + 19, 13, -1, -20, -24, -13, -6, -6, -11, -16, -21, -24, -15, 9, 45, 71, + 21, 15, 8, 4, 5, 6, 3, 4, -2, -17, -20, -8, 12, 9, -12, -28, + 22, 10, 9, 20, 18, -4, -6, 1, 5, 9, 16, 18, -1, -22, -47, -48, + 22, 22, 27, 42, 41, 33, 21, 0, -17, -27, -28, -37, -39, -32, -19, -8, + 23, 4, -28, -27, -16, -5, 9, 28, 28, 0, -52, -61, -12, 18, 35, 56, + 23, -6, -26, -22, -18, -18, -20, -28, -23, -3, 9, 3, 1, 17, 44, 66, + 23, 21, 12, 10, 6, -5, 3, 8, 4, -1, 8, 11, -2, -16, -40, -43, + 24, 11, -4, -9, -8, -10, -21, -37, -44, -26, 0, 8, 17, 29, 36, 35, + 25, 11, 3, 7, 13, 14, 9, 2, -7, -13, -17, -12, -10, -10, -7, -8, + 25, 24, 17, 12, 20, 7, -11, -10, -15, -16, -16, -5, 3, -4, -11, -21, + 27, 26, 17, 6, -5, -16, -12, 2, -1, -9, -16, -7, 3, 3, -2, -15, + 28, 15, -10, -29, -30, -17, 4, 16, 33, 29, 15, 6, -5, -18, -18, -18, + 28, 12, 4, 16, 23, 12, 6, -1, -6, -7, 2, 8, -2, -19, -38, -37, + 29, 16, -1, -15, -25, -15, -12, -9, 18, 29, 23, 12, -1, -13, -16, -20, + 29, 28, 25, 33, 32, 6, -13, -20, -8, 4, 7, 0, -14, -25, -43, -40, + 29, 25, 19, 17, 20, 8, -12, -34, -34, -19, -14, -6, 2, 4, 3, -9, + 30, 28, 22, 14, 17, 16, 15, 8, -5, -19, -13, -4, -7, -20, -40, -41, + 30, 1, -20, -4, -6, -32, -37, -28, -18, -11, -7, -3, 8, 21, 44, 63, + 30, 42, 57, 45, 22, 6, 8, 2, -10, -27, -43, -50, -45, -33, -13, 9, + 32, 25, 20, 24, 23, 6, 3, -2, -10, -8, 4, 8, -8, -27, -47, -45, + 32, 40, 44, 29, 12, 0, -10, -18, -24, -20, -18, -23, -25, -19, -5, 4, + 34, 45, 56, 51, 33, 16, 10, 6, -8, -21, -25, -42, -55, -52, -33, -16, + 34, 53, 63, 61, 58, 44, 12, -26, -62, -68, -60, -61, -47, -18, 9, 9, + 34, 28, 22, 17, 16, 16, 9, 0, -6, -12, -26, -31, -21, -13, -13, -19, + 34, 23, 10, -15, -33, -24, -17, -15, -7, 0, -5, -10, -4, 5, 23, 35, + 35, 23, 12, 0, -16, -22, -17, 0, 17, 19, 14, 7, -5, -16, -24, -27, + 35, 32, -23, -51, -12, 33, 23, 0, -10, 1, -12, -29, -13, 9, 17, 0, + 36, 69, 78, 62, 30, -9, -40, -49, -49, -44, -48, -51, -37, -10, 19, 44, + 36, 21, 8, 11, 18, 8, 9, 8, 7, 3, 2, 1, -13, -28, -46, -44, + 37, 27, 11, 6, 14, 5, -6, -1, -9, -26, -37, -18, 3, 5, 0, -11, + 39, 31, 20, 13, 12, 6, -8, -12, -16, -16, -22, -18, -9, -6, -5, -10, + 39, 33, 25, 21, 22, 18, 7, -4, -24, -33, -33, -20, -9, -8, -14, -22, + 39, 52, 61, 57, 40, 27, 9, -12, -27, -37, -46, -50, -48, -40, -23, -2, + 40, 31, 20, 18, 14, -8, -5, 4, 8, 4, -1, -2, -14, -28, -42, -38, + 40, 29, 17, 19, 15, -9, -20, -18, -7, 1, 10, 9, -5, -15, -33, -33, + 41, 33, 23, 18, 20, 2, -13, -6, -6, -9, -16, -13, -12, -18, -21, -21, + 41, 58, 71, 51, 33, 19, -13, -42, -56, -58, -65, -67, -53, -17, 32, 65, + 41, 31, 15, 10, 4, -16, -7, 5, 7, 8, 12, 8, -7, -26, -44, -40, + 43, 40, 28, 23, 23, 6, -13, -20, -26, -18, -2, 3, -2, -13, -34, -36, + 43, 23, -11, -15, 2, 3, 6, 5, 3, 4, 11, 11, -2, -17, -33, -32, + 43, 54, 61, 49, 24, -1, -8, -3, -8, -21, -32, -43, -46, -39, -21, -9, + 43, 30, 9, -8, -2, 0, -10, -12, -14, -12, -12, -2, 4, 2, -3, -14, + 43, 35, 23, 15, 12, -8, -33, -27, -16, -12, -14, -4, 5, 0, -6, -13, + 44, 31, 19, 12, 4, -5, 1, -1, -10, -14, -1, 5, -3, -15, -33, -34, + 44, 28, 8, 8, 18, 13, 7, -3, -10, -8, -3, -3, -13, -23, -33, -31, + 46, 40, 9, -22, -17, 6, 18, 19, 6, -11, -14, -5, 5, -9, -35, -35, + 47, 47, 53, 51, 27, -3, -46, -65, -46, -33, -32, -29, -28, -17, 17, 56, + 47, 43, 27, 25, 24, 2, -2, -1, -17, -19, -1, 6, -11, -33, -50, -40, + 48, 50, 47, 34, 9, -7, -10, -9, -10, -12, -17, -28, -33, -30, -19, -12, + 48, 51, 51, 41, 25, 7, -18, -39, -47, -47, -44, -36, -21, -2, 14, 17, + 48, 23, -3, 10, 21, -2, -9, -6, -4, -2, 8, 15, 0, -23, -40, -36, + 50, 25, 2, -3, 4, 16, 13, -4, -21, -30, -30, -29, -20, -2, 13, 17, + 59, 44, 18, 13, 23, 18, 8, -7, -28, -26, -8, -3, -10, -24, -42, -35, + 61, 47, 30, 22, 25, 21, 8, -2, -16, -25, -14, -5, -15, -39, -56, -43, + 62, 46, 31, 37, 38, 16, -13, -33, -25, -7, -1, -3, -20, -39, -51, -38, + 63, 47, 23, 9, 5, -2, -13, -12, -8, -7, -14, -20, -26, -25, -15, -6, + 63, 42, 20, 9, 7, 0, -10, -18, -21, -22, -24, -24, -22, -16, 0, 17, + 64, 54, 43, 22, -17, -38, -42, -38, -37, -23, -17, -20, -15, -2, 22, 42, + 64, 51, 36, 34, 35, 21, 6, -9, -34, -41, -20, -7, -18, -35, -48, -36, + 66, 66, 65, 55, 35, 8, -9, -18, -29, -35, -39, -45, -47, -39, -24, -9, + 67, 38, -11, -47, -53, -27, -14, -19, -21, -21, 0, 6, 9, 19, 31, 45, + 70, 60, 50, 45, 32, 3, -17, -33, -34, -24, -10, -9, -22, -36, -44, -30, + 75, 57, 34, 30, 34, 20, -7, -29, -42, -36, -21, -15, -19, -28, -32, -20, + 76, 61, 27, -11, -30, -32, -29, -24, -24, -22, -18, -21, -16, 1, 22, 42, + 96, 77, 40, 5, -17, -27, -30, -28, -25, -24, -22, -23, -23, -16, 1, 16, + 99, 86, 61, 28, -5, -26, -39, -35, -34, -20, -5, -15, -34, -40, -22, 2, + 127, 101, 43, -12, -35, -34, -40, -42, -40, -40, -41, -40, -31, -6, 28, 61 +}; + +const RAM_ALIGN Word16 lrsns_st1C_Both_EnBy2Tab_fx[170] = /* 2*170 words = 340 bytes st1C vector energiesBy2 for BASOP optimized st1C search */ +{ + 18337, 6464, 16528, 4442, 3325, 13879, 11473, 14799, + 8649, 8092, 10092, 5046, 6178, 4902, 2766, 2051, + 1326, 1302, 2147, 5282, 3107, 4708, 5827, 8414, + 8739, 17452, 6318, 2682, 16210, 5422, 2792, 5004, + 10256, 1519, 5041, 3956, 3440, 1079, 4168, 3788, + 2020, 9834, 1334, 2524, 8456, 4251, 1404, 4078, + 797, 4834, 2070, 3822, 17739, 3451, 2423, 16332, + 1881, 1833, 3031, 2527, 1746, 2000, 646, 1403, + 1949, 914, 3011, 2055, 2134, 3985, 1646, 9429, + 1011, 6486, 11620, 7391, 10705, 1452, 6977, 4626, + 2571, 1958, 3481, 1012, 2781, 1940, 10326, 412, + 1532, 2142, 1890, 5401, 1814, 1322, 1576, 6375, + 3799, 3481, 9205, 6809, 4090, 1001, 7829, 5257, + 1371, 3563, 6407, 7621, 5384, 2630, 4548, 1109, + 1827, 1397, 3300, 2621, 2531, 4684, 2870, 3750, + 5722, 8534, 4237, 4413, 10184, 18130, 3132, 3079, + 2704, 4383, 16988, 3762, 2559, 2501, 4264, 12450, + 3930, 3390, 3062, 19816, 3948, 4767, 2736, 9537, + 1928, 3348, 3123, 3165, 4113, 13238, 5997, 6146, + 10143, 3619, 3770, 6037, 8141, 8949, 4701, 4897, + 9675, 9684, 13828, 8352, 10983, 9836, 9009, 11364, + 15100, 23026 +}; +#endif + +#ifdef CR9_C_ADD_1p25MS_LRSNS +RAM_ALIGN const Word16 isqrt_Q15tab[1 + 6] = { + /* onepulse_search_tab based search , Q15 table generated using isqrt_Q16tab table for idx=[8(4*2),16(4*4), 20(4*5),24(4*6) ] */ + /*this slighly suboptimal inv_sqrt(x) table is used to enable optional exact use of the ROM saving BASOP ISqrt16() function */ + + 32767/*0*/, 32766/*1*/, 23169 /*2*/, 18918 /*3*/ , 16384/*4*/ , 14654 /*5*/, 13377/*6*/ + + /* i.e. value in isqrt_Q15tab[n=0..6] == isqrt_Q16tab[4*n] */ +}; + + +RAM_ALIGN const Word16 lrsns_signs_fix_fx[SNSLR_N_FIXENV] = { 12, 12, 12, 10 }; +RAM_ALIGN const Word16 long_bell_fx[M - 1 + 4] = { /* --> constants.c ROM */ + 6, 6, 7, 7, 8 , + 8, 8, 7, 7, 6 , + 6, 5, 5, 5, 5 , + 5, 5, 5, 5 }; + +RAM_ALIGN const Word16 decay_fx[M - 1] = +{ /* floor((25:-1:11 -i)/2)*/ + 12,12,11,11,10, + 10, 9, 9, 8, 8, + 7, 7, 6, 6, 5 +}; + +RAM_ALIGN const Word16 *lrsns_fix_env_fx[SNSLR_N_FIXENV] = { &(long_bell_fx[4]), decay_fx, &(long_bell_fx[2]), long_bell_fx }; + + +RAM_ALIGN const Word16 lrsns_fixenv_enQ0[SNSLR_N_FIXENV * SNSLR_N_FIXENV_SHIFTS] = /* offline pre-computed from fixenv[0..3] + shifts */ +{ 487, 448, 409, 370, 1118, 1010, 902, 806, 535, 511, 487, 448, 496, 496, 485, 461 +}; + +RAM_ALIGN const Word16 lrsns_fixenv_enNormQ19[SNSLR_N_FIXENV * SNSLR_N_FIXENV_SHIFTS] = /*Q15+4 => Q19 */ +{ /* round(2.^19 ./ sqrt(fixenv_en) , for search loop */ + 23758, 24770, 25924, 27256, /*fixenv 0*/ + 15680, 16497, 17457, 18467, /*fixenv 1*/ + 22667, 23193, 23758, 24770, /*fixenv 2*/ + 23541, 23541, 23807, 24419 /*fixenv 3*/ +}; +RAM_ALIGN const Word32 L_lrsns_fixenv_enNormQ35[SNSLR_N_FIXENV * SNSLR_N_FIXENV_SHIFTS] = /*Q15+4 +16=> Q35 */ +{ /* fixenv_enQ0= [487, 448, 409, 370, 1118, 1010, 902, 806, 535, 511, 487, 448, 496, 496, 485, 461] */ + /* int32(round(2.^35 ./ sqrt(fixenv_enQ0))), "for synthesis" */ + 1556988367L, 1623345051L, 1698979717L, 1786277740L,/*fixenv 0*/ + 1027611478L, 1081157988L, 1144054146L, 1210270165L,/*fixenv 1*/ + 1485501030L, 1519985336L, 1556988367L, 1623345051L,/*fixenv 2*/ + 1542797797L, 1542797797L, 1560195349L, 1600292558L /*fixenv 3*/ +}; + +RAM_ALIGN const Word16 lrsns_norm_factorQ_L[N_SCF_SEARCH_SHAPES_ST2_LR] = { 31, 31, 19 + 16 }; /* split, full, fixenv */ +/*maxamps = [8, 5, 12]; 8*2^11 = 2^14 =16384 , 5*2^12 = 20480, 12*2^11= 24576 */ +RAM_ALIGN const Word16 lrsns_y_up_bits[N_SCF_SEARCH_SHAPES_ST2_LR] = { 11, 12, 11 }; /* split, full, fixenv, max uphifts for normaliztion */ + +#endif diff --git a/lib_lc3plus/constants.h b/lib_lc3plus/constants.h index a367939a9..2ecc1ad24 100644 --- a/lib_lc3plus/constants.h +++ b/lib_lc3plus/constants.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -10,10 +10,50 @@ #ifndef CONSTANTS_H #define CONSTANTS_H +#include "options.h" +#include "wmc_auto.h" #include "defines.h" - #include "basop_util_lc3plus.h" +#ifdef LTPF_ADAPTIVE_GAIN +extern RAM_ALIGN const Word16 tilt_filter_1p25ms[5][4][11]; +extern RAM_ALIGN const Word16 adaptive_gain_step; +extern RAM_ALIGN const Word16 max_adaptive_gain[4]; +extern RAM_ALIGN const Word16 max_adaptive_gain_step[4]; +#endif + +extern RAM_ALIGN const Word16 *const lpc_pre_adapt_emphasis[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word8 *const lpc_pre_adapt_emphasis_e[NUM_SAMP_FREQ]; + +#ifdef CR9_C_ADD_1p25MS +#ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len_1_25ms[6]; +#else +extern RAM_ALIGN const Word16 LowDelayShapes_n960_len_1_25ms[5]; +#endif + +#ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word32 *const LowDelayShapes_n960_1_25ms[6]; +#else +extern RAM_ALIGN const Word16 *const LowDelayShapes_n960_1_25ms[6]; +#endif + +extern RAM_ALIGN const Word16 bands_number_1_25ms[]; +extern RAM_ALIGN const Word16 *const bands_offset_1_25ms[6]; + +#ifdef ENABLE_HR_MODE +extern RAM_ALIGN const Word16 bands_number_1_25ms_HR[]; +extern RAM_ALIGN const Word16 *const bands_offset_1_25ms_HR[2]; +#endif + +extern RAM_ALIGN const Word16 bands_offset_with_one_max_1_25ms[NUM_OFFSETS]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_1_25ms[NUM_OFFSETS]; + +extern RAM_ALIGN const Word16 *const bands_offset_lin_1_25ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_one_max_lin_1_25ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16 bands_offset_with_two_max_lin_1_25ms[NUM_SAMP_FREQ]; + +#endif /* CR9_C_ADD_1p25MS */ #ifdef ENABLE_HR_MODE extern RAM_ALIGN const Word16 BW_cutoff_bin_all_HR[]; @@ -137,7 +177,7 @@ extern RAM_ALIGN const UWord16 ari_spec_cumfreq[64][17]; extern RAM_ALIGN const UWord16 ari_spec_freq[64][17]; extern RAM_ALIGN const UWord16 ari_spec_bits[64][17]; -extern RAM_ALIGN const Word32 tnsAcfWindow_lc3plus[MAXLAG]; +extern RAM_ALIGN const Word32 tnsAcfWindow[MAXLAG]; extern RAM_ALIGN const Word16 ac_tns_order_bits[2][MAXLAG]; extern RAM_ALIGN const Word16 ac_tns_order_freq[2][MAXLAG]; extern RAM_ALIGN const Word16 ac_tns_order_cumfreq[2][MAXLAG]; @@ -162,6 +202,10 @@ extern RAM_ALIGN const Word16 *const lpc_warp_dee_emphasis_e[NUM_SAMP_FREQ]; extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_7_5ms[NUM_SAMP_FREQ]; extern RAM_ALIGN const Word16 *const lpc_lin_pre_emphasis_e_7_5ms[NUM_SAMP_FREQ]; +#ifdef FIX_PLC_CONFORM_ISSUES +extern RAM_ALIGN const Word16* const lpc_lin_pre_emphasis_1_25ms[NUM_SAMP_FREQ]; +extern RAM_ALIGN const Word16* const lpc_lin_pre_emphasis_e_1_25ms[NUM_SAMP_FREQ]; +#endif extern RAM_ALIGN const Word16 bands_nrg_scale[32]; @@ -227,6 +271,10 @@ extern RAM_ALIGN const Word32 inv_odft_twiddle_60_re[M]; extern RAM_ALIGN const Word32 inv_odft_twiddle_60_im[M]; extern RAM_ALIGN const Word32 inv_odft_twiddle_40_re[M]; extern RAM_ALIGN const Word32 inv_odft_twiddle_40_im[M]; +#ifdef FIX_PLC_CONFORM_ISSUES +extern RAM_ALIGN const Word32 inv_odft_twiddle_30_re[M]; +extern RAM_ALIGN const Word32 inv_odft_twiddle_30_im[M]; +#endif extern RAM_ALIGN const Word32 inv_odft_twiddle_20_re[M]; extern RAM_ALIGN const Word32 inv_odft_twiddle_20_im[M]; @@ -280,8 +328,39 @@ extern RAM_ALIGN const Word16 sns_gainLSBbits[4]; extern RAM_ALIGN const Word16 sns_Kval[4][2]; extern RAM_ALIGN const UWord32 sns_MPVQ_Sz[4][2]; +#ifdef CR9_C_ADD_1p25MS_LRSNS +extern RAM_ALIGN const Word16 st1SCF0_7_base5_32x8_Q11[256 * 2]; +extern RAM_ALIGN const Word16 st1SCF8_15_base5_32x8_Q11[256 * 2]; +#else extern RAM_ALIGN const Word16 st1SCF0_7_base5_32x8_Q11[256]; extern RAM_ALIGN const Word16 st1SCF8_15_base5_32x8_Q11[256]; +#endif + +#ifdef CR9_C_ADD_1p25MS_LRSNS +extern RAM_ALIGN const Word16 lrsns_ltp_bits_fx[8]; +extern RAM_ALIGN const Word16 *const lrsns_vq_gainsQ12_fx[SNSLR_MAX_PVQ_SEARCH_CAND]; +extern RAM_ALIGN const Word16 lrsns_vq_gain_lvls_fx[SNSLR_MAX_PVQ_SEARCH_CAND]; + +extern RAM_ALIGN const Word16 lrsns_cbA_fx[2 * 16]; + +/*LRSNS tables to construct st1B from legacy st1(LF,HF) Q11 tables */ +extern RAM_ALIGN const Word16 lrsns_st1B_merged170orderSortedSegmCnt_fx[4]; +extern RAM_ALIGN const Word16 lrsns_st1B_merged170orderSortedSegmCum_fx[5]; +extern RAM_ALIGN const Word16 lrsns_st1B_merged170orderSort12bitIdx_fx[170]; +extern RAM_ALIGN const Word32 lrsns_st1B_enBy2TabW32_fx[2 * 32]; + +/*LRSNS tables to construct st1C from Word8in Q7 and a Q4 scalefactor */ +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY +extern RAM_ALIGN const Word16 * lrsns_st1CTrainedMapMeans_fx[2]; +#else +extern RAM_ALIGN const Word16 * lrsns_st1CTrainedMapMeans_fx[3]; +#endif +extern RAM_ALIGN const Word16 lrsns_st1C_Both_EnBy2Tab_fx[170]; +extern RAM_ALIGN const Word16 lrsns_st1C_Both_scaleQ4_7p4bits_fx[2]; +extern RAM_ALIGN const Word16 lrsns_st1C_Both_inv_scaleQ15_7p4bits_fx[2]; +extern RAM_ALIGN const Word8 lrsns_st1C_Both_Word8_fx[170 * 16]; + +#endif #ifdef ENABLE_HR_MODE extern RAM_ALIGN const Word32 st1SCF0_7_base5_32x8_Q27[256]; @@ -296,9 +375,27 @@ extern RAM_ALIGN const Word16 tabledKMAX[16 + 1]; extern RAM_ALIGN const UWord32 *const MPVQ_offs_ptr[16 + 1]; extern RAM_ALIGN const Word16 isqrt_Q16tab[1 + SQRT_EN_MAX_FX]; + +#ifdef CR9_C_ADD_1p25MS_LRSNS +extern RAM_ALIGN const Word16 isqrt_Q15tab[1 + 6]; +extern RAM_ALIGN const Word32 isqrt_Q31tab[1 + SQRT_EN_MAX_FX]; +#else #ifdef ENABLE_HR_MODE extern RAM_ALIGN const Word32 isqrt_Q31tab[1 + SQRT_EN_MAX_FX]; #endif +#endif + +#ifdef CR9_C_ADD_1p25MS_LRSNS +extern RAM_ALIGN const Word16 lrsns_signs_fix_fx[SNSLR_N_FIXENV]; +extern RAM_ALIGN const Word16 *lrsns_fix_env_fx[SNSLR_N_FIXENV]; + +extern RAM_ALIGN const Word16 lrsns_fixenv_enQ0[SNSLR_N_FIXENV * SNSLR_N_FIXENV_SHIFTS]; +extern RAM_ALIGN const Word16 lrsns_fixenv_enNormQ19[SNSLR_N_FIXENV * SNSLR_N_FIXENV_SHIFTS]; +extern RAM_ALIGN const Word32 L_lrsns_fixenv_enNormQ35[SNSLR_N_FIXENV * SNSLR_N_FIXENV_SHIFTS]; + +extern RAM_ALIGN const Word16 lrsns_norm_factorQ_L[N_SCF_SEARCH_SHAPES_ST2_LR]; +extern RAM_ALIGN const Word16 lrsns_y_up_bits[N_SCF_SEARCH_SHAPES_ST2_LR]; +#endif extern RAM_ALIGN const Word16 adjust_global_gain_tables[5][NUM_SAMP_FREQ]; diff --git a/lib_lc3plus/cutoff_bandwidth.c b/lib_lc3plus/cutoff_bandwidth.c index e00aa7a22..5225cd0e8 100644 --- a/lib_lc3plus/cutoff_bandwidth.c +++ b/lib_lc3plus/cutoff_bandwidth.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,11 +7,13 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void process_cutoff_bandwidth(Word32 d_fx[], Word16 len, Word16 bw_bin) { - Word32 i = 0; + Counter i = 0; if (len > bw_bin){ /* roll off */ for (i = -1; i < 3; i++) { diff --git a/lib_lc3plus/dct2_fx.c b/lib_lc3plus/dct2_fx.c index ec7f09c23..6d428cdc5 100644 --- a/lib_lc3plus/dct2_fx.c +++ b/lib_lc3plus/dct2_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,8 +7,16 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" +#ifdef CR9_C_ADD_1p25MS_LRSNS +#ifndef USE_LC3_OPERATORS +#include "enh40.h" +#endif +#endif + void idct16_fx(const Word16 *in, Word16 *out) { Dyn_Mem_Deluxe_In( @@ -463,3 +471,184 @@ void idct32_32_fx(const Word32 *in, Word32 *out) Dyn_Mem_Deluxe_Out(); } + +#ifdef CR9_C_ADD_1p25MS_LRSNS +void dct16_W32int_fx(const Word16 *in, + Word16 *out) /* for now same Q as input . later potetially reduce Q for output */ +{ + + +#define Mpy_32_16op(Lx,y) Mpy_32_16_lc3plus(Lx, y ) /* two-three cycle count as in existing STL */ +#define Mpy_32_16_0op(Lx,y) Mpy_32_16_0_0(Lx,y ) /* no rounding , STL shift cost still there */ + + + Dyn_Mem_Deluxe_In( + /* Counter i; */ + Word32 L_a0, L_a1, L_a2, L_a3, L_a4, L_a5, L_a6, L_a7, L_a8, L_a9, L_a10, L_a11, L_a12, L_a13, L_a14, L_a15; + Word32 L_b0, L_b1, L_b2, L_b3, L_b4, L_b5, L_b6, L_b7, L_b8, L_b9, L_b10, L_b11, L_b12, L_b13, L_b14, L_b15; + ); +#ifdef WMOPS + push_wmops("dct16_W32int_fx"); +#endif + +#define INMARGIN 0 +#if INMARGIN > 0 +#define INSCALE (1<<(15-INMARGIN) ) +#endif + +#if INMARGIN == 0 + L_a0 = L_deposit_h(add(in[15], in[0])); /* Word16 Q11 deposited 16 levels up, becomes Q27, NB add can still potentially saturate ! */ + L_a1 = L_deposit_h(add(in[14], in[1])); + L_a2 = L_deposit_h(add(in[13], in[2])); + L_a3 = L_deposit_h(add(in[12], in[3])); + L_a4 = L_deposit_h(add(in[11], in[4])); + L_a5 = L_deposit_h(add(in[10], in[5])); + L_a6 = L_deposit_h(add(in[9], in[6])); + L_a7 = L_deposit_h(add(in[8], in[7])); + + L_a10 = L_deposit_h(sub(in[5], in[10])); + L_a11 = L_deposit_h(sub(in[4], in[11])); + L_a12 = L_deposit_h(sub(in[3], in[12])); + L_a13 = L_deposit_h(sub(in[2], in[13])); +#else + /* create higher internal margin */ + /* Q11 deposited 16 levels up, becomes lower than Q27, internal L_aX, L_bx signals becomes Q26, or lower */ + L_a0 = L_mult0(add(in[15], in[0]), INSCALE); + L_a1 = L_mult0(add(in[14], in[1]), INSCALE); + L_a2 = L_mult0(add(in[13], in[2]), INSCALE); + L_a3 = L_mult0(add(in[12], in[3]), INSCALE); + L_a4 = L_mult0(add(in[11], in[4]), INSCALE); + L_a5 = L_mult0(add(in[10], in[5]), INSCALE); + L_a6 = L_mult0(add(in[9], in[6]), INSCALE); + L_a7 = L_mult0(add(in[8], in[7]), INSCALE); + + L_a10 = L_mult0(sub(in[5], in[10]), INSCALE); + L_a11 = L_mult0(sub(in[4], in[11]), INSCALE); + L_a12 = L_mult0(sub(in[3], in[12]), INSCALE); + L_a13 = L_mult0(sub(in[2], in[13]), INSCALE); +#endif + + L_b0 = L_add(L_a7, L_a0); + L_b1 = L_add(L_a6, L_a1); + L_b2 = L_add(L_a5, L_a2); + L_b3 = L_add(L_a4, L_a3); + L_b4 = L_sub(L_a3, L_a4); + L_b5 = L_sub(L_a2, L_a5); + L_b6 = L_sub(L_a1, L_a6); + L_b7 = L_sub(L_a0, L_a7); + +#if INMARGIN == 0 + L_b8 = L_deposit_h(sub(in[7], in[8])); + L_b9 = L_deposit_h(sub(in[6], in[9])); +#else + L_b8 = L_mult0(sub(in[7], in[8]), INSCALE); + L_b9 = L_mult0(sub(in[6], in[9]), INSCALE); +#endif + L_b10 = L_add(Mpy_32_16op(L_a10, -23170), Mpy_32_16op(L_a13, 23170));/* -CÏ€/4 CÏ€/4 */ + //L_b10 = L_add(L_b10, L_b10); /* scale up due to previous use of L_Mpy_32_16_0op() */ + + L_b11 = L_add(Mpy_32_16op(L_a11, -23170), Mpy_32_16op(L_a12, 23170)); /* -CÏ€/4 CÏ€/4 */ + //L_b11 = L_add(L_b11, L_b11);/* scale up due to previous use of L_Mpy_32_16_0op() */ + + L_b12 = L_add(Mpy_32_16op(L_a12, 23170), Mpy_32_16op(L_a11, 23170)); /* CÏ€/4 CÏ€/4 */ + //L_b12 = L_add(L_b12, L_b12);/* scale up due to previous use of L_Mpy_32_16_0op() */ + + L_b13 = L_add(Mpy_32_16op(L_a13, 23170), Mpy_32_16op(L_a10, 23170)); /* CÏ€/4 CÏ€/4 */ + //L_b13 = L_add(L_b13, L_b13);/* scale up due to previous use of L_Mpy_32_16_0op() */ + +#if INMARGIN == 0 + L_b14 = L_deposit_h(sub(in[1], in[14])); + L_b15 = L_deposit_h(sub(in[0], in[15])); +#else + L_b14 = L_mult0(sub(in[1], in[14]), INSCALE); + L_b15 = L_mult0(sub(in[0], in[15]), INSCALE); +#endif + + /* all inputs processed */ + L_a0 = L_add_sat(L_b3, L_b0); /*saturation was required in dct32_fx()*/ + L_a1 = L_add(L_b2, L_b1); + L_a2 = L_sub(L_b1, L_b2); + L_a3 = L_sub_sat(L_b0, L_b3); /*saturation was required in dct32_fx()*/ + + L_a4 = L_add(L_b4, 0L); + + L_a5 = L_add(Mpy_32_16op(L_b5, -23170), Mpy_32_16op(L_b6, 23170)); /* -CÏ€/4 CÏ€/4 */ + //L_a5 = L_add(L_a5, L_a5);/* scale up due to previous use of L_Mpy_32_16_0op() */ + L_a6 = L_add(Mpy_32_16op(L_b6, 23170), Mpy_32_16op(L_b5, 23170)); /* CÏ€/4 CÏ€/4 */ + //L_a6 = L_add(L_a6, L_a6);/* scale up due to previous use of L_Mpy_32_16_0op() */ + + L_a7 = L_add(L_b7, 0L); + L_a8 = L_add(L_b11, L_b8); + L_a9 = L_add(L_b10, L_b9); + + L_a10 = L_sub(L_b9, L_b10); + L_a11 = L_sub(L_b8, L_b11); + + L_a12 = L_sub(L_b15, L_b12); + L_a13 = L_sub(L_b14, L_b13); + + L_a14 = L_add(L_b13, L_b14); + L_a15 = L_add(L_b12, L_b15); + + /* upscaling done by constant doubling */ + out[0] = round_fx(L_add(Mpy_32_16_0op(L_a0, 8192 * 2), Mpy_32_16_0op(L_a1, 8192 * 2))); move16(); /* CÏ€/4/√8 CÏ€/4/√8 */ + out[8] = round_fx(L_add(Mpy_32_16_0op(L_a1, -8192 * 2), Mpy_32_16_0op(L_a0, 8192 * 2))); move16(); /* -CÏ€/4/√8 CÏ€/4/√8 */ + out[4] = round_fx(L_add(Mpy_32_16_0op(L_a2, 4433 * 2), Mpy_32_16_0op(L_a3, 10703 * 2))); move16(); /* SÏ€/8/√8 CÏ€/8/√8 */ + out[12] = round_fx(L_add(Mpy_32_16_0op(L_a3, 4433 * 2), Mpy_32_16_0op(L_a2, -10703 * 2))); move16(); /* C3Ï€/8/√8 -S3Ï€/8/√8 */ + + L_b4 = L_add(L_a5, L_a4); + L_b5 = L_sub_sat(L_a4, L_a5); /*saturation was required in dct32_fx()*/ + L_b6 = L_sub_sat(L_a7, L_a6); /*saturation was required in dct32_fx()*/ + L_b7 = L_add(L_a6, L_a7); + L_b8 = L_add(L_a8, 0L); ; + + L_b9 = L_add(Mpy_32_16op(L_a9, -30274), Mpy_32_16op(L_a14, 12540)); /* -CÏ€/8 SÏ€/8 */ + L_b10 = L_add(Mpy_32_16op(L_a10, -12540), Mpy_32_16op(L_a13, -30274)); /* -SÏ€/8 -CÏ€/8 */ + L_b11 = L_add(L_a11, 0L); + L_b12 = L_add(L_a12, 0L); + + L_b13 = L_add(Mpy_32_16op(L_a13, 12540), Mpy_32_16op(L_a10, -30274)); /* C3Ï€/8 -S3Ï€/8 */ + L_b14 = L_add(Mpy_32_16op(L_a14, 30274), Mpy_32_16op(L_a9, 12540)); /* S3Ï€/8 C3Ï€/8 */ + L_b15 = L_add(L_a15, 0L); + + + /* upscaling done by constant doubling */ + out[2] = round_fx(L_add(Mpy_32_16_0op(L_b4, 2260 * 2), Mpy_32_16_0op(L_b7, 11363 * 2))); move16(); /* SÏ€/16/√8 CÏ€/16/√8 */ + out[10] = round_fx(L_add(Mpy_32_16_0op(L_b5, 9633 * 2), Mpy_32_16_0op(L_b6, 6436 * 2))); move16(); /* S5Ï€/16/√8 C5Ï€/16/√8 */ + out[6] = round_fx(L_add(Mpy_32_16_0op(L_b6, 9633 * 2), Mpy_32_16_0op(L_b5, -6436 * 2))); move16(); /* C3Ï€/16/√8 -S3Ï€/16/√8 */ + out[14] = round_fx(L_add(Mpy_32_16_0op(L_b7, 2260 * 2), Mpy_32_16_0op(L_b4, -11363 * 2))); move16(); /* C7Ï€/16/√8 -S7Ï€/16/√8 */ + + L_a8 = L_add_sat(L_b9, L_b8); /*saturation was required in dct32_fx()*/ + L_a9 = L_sub_sat(L_b8, L_b9); + L_a10 = L_sub_sat(L_b11, L_b10); + L_a11 = L_add_sat(L_b10, L_b11); + L_a12 = L_add_sat(L_b13, L_b12); + L_a13 = L_sub_sat(L_b12, L_b13); + L_a14 = L_sub_sat(L_b15, L_b14); + L_a15 = L_add_sat(L_b14, L_b15); + + /* upscaling done by constant doubling */ + out[1] = round_fx(L_add(Mpy_32_16_0op(L_a8, 1136 * 2), Mpy_32_16_0op(L_a15, 11529 * 2))); move16(); /* SÏ€/32/√8 CÏ€/32/√8 */ + out[9] = round_fx(L_add(Mpy_32_16_0op(L_a9, 8956 * 2), Mpy_32_16_0op(L_a14, 7350 * 2))); move16(); /* S9Ï€/32/√8 C9Ï€/32/√8 */ + out[5] = round_fx(L_add(Mpy_32_16_0op(L_a10, 5461 * 2), Mpy_32_16_0op(L_a13, 10217 * 2))); move16(); /* S5Ï€/32/√8 C5Ï€/32/√8 */ + out[13] = round_fx(L_add(Mpy_32_16_0op(L_a11, 11086 * 2), Mpy_32_16_0op(L_a12, 3363 * 2))); move16(); /* S13Ï€/32/√8 C13Ï€/32/√8 */ + out[3] = round_fx(L_add(Mpy_32_16_0op(L_a12, 11086 * 2), Mpy_32_16_0op(L_a11, -3363 * 2))); move16(); /* C3Ï€/32/√8 -S3Ï€/32/√8 */ + out[11] = round_fx(L_add(Mpy_32_16_0op(L_a13, 5461 * 2), Mpy_32_16_0op(L_a10, -10217 * 2))); move16();/* C11Ï€/32/√8 -S11Ï€/32/√8 */ + out[7] = round_fx(L_add(Mpy_32_16_0op(L_a14, 8956 * 2), Mpy_32_16_0op(L_a9, -7350 * 2))); move16(); /* C7Ï€/32/√8 -S7Ï€/32/√8 */ + out[15] = round_fx(L_add(Mpy_32_16_0op(L_a15, 1136 * 2), Mpy_32_16_0op(L_a8, -11529 * 2))); move16(); /* C15Ï€/32/√8 -S15/32/√8 */ + + + +#ifdef Mpy_32_16op +#undef Mpy_32_16op +#endif + +#ifdef Mpy_32_16_0op +#undef Mpy_32_16_0op +#endif +#ifdef WMOPS + pop_wmops(); +#endif + Dyn_Mem_Deluxe_Out(); +} +#endif diff --git a/lib_lc3plus/dct4_fx.c b/lib_lc3plus/dct4_fx.c index 0e5957c86..e5f1ed189 100644 --- a/lib_lc3plus/dct4_fx.c +++ b/lib_lc3plus/dct4_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" #include "rom_basop_util_lc3plus.h" @@ -33,7 +35,7 @@ void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ Word32 accu3; Word32 accu4; - Word32 i; + Counter i; #ifdef ENABLE_HR_MODE const PWord32 *twiddle; @@ -98,7 +100,7 @@ void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ pDat_0 = &pDat[0]; pDat_1 = &pDat[L - 2]; - FOR (i = 0; i < M2; i += 2) + FOR (i = 0; i < M_var; i += 2) { #ifdef ENABLE_HR_MODE if (hrmode) { @@ -113,10 +115,11 @@ void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ cplxMpy32_32_16_2(accu3, accu4, pDat_1[0], pDat_0[1], twiddle[i + 1].v.re, twiddle[i + 1].v.im); #endif - pDat_0[0] = accu2; move32(); - pDat_0[1] = accu1; move32(); + /* The order of writing the coefficients is not important unless the length is odd, as then the two pointers pDat_0 and pDat_1 would overlap. The order here should be correct as such that the incorrectly calculated coefficient is overwritten with the correctly calculated coefficient. This is happens e.g. for the FFT15, 30 Samples, 1.25 ms @ 24 kHz */ pDat_1[0] = accu4; move32(); pDat_1[1] = L_negate(accu3); move32(); + pDat_0[0] = accu2; move32(); + pDat_0[1] = accu1; move32(); pDat_0 = pDat_0 + 2; pDat_1 = pDat_1 - 2; @@ -126,7 +129,7 @@ void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ if (hrmode) { - scale = s_max(getScaleFactor32_lc3plus(pDat, L), 0); move16(); + scale = s_max(getScaleFactor32(pDat, L), 0); move16(); FOR (i = 0; i < L; i++) { @@ -137,7 +140,7 @@ void dct_IV(Word32 *pDat, /* i/o: pointer to data buffer */ } #endif - BASOP_cfft_lc3plus(&pDat[0], &pDat[1], M_var, 2, pDat_e, workBuffer); + BASOP_cfft(&pDat[0], &pDat[1], M_var, 2, pDat_e, workBuffer); pDat_0 = &pDat[0]; pDat_1 = &pDat[L - 2]; diff --git a/lib_lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c index dddbc4851..a1773f92b 100644 --- a/lib_lc3plus/dec_entropy.c +++ b/lib_lc3plus/dec_entropy.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,9 +7,42 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" -static Word16 read_indice(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 numbits); + + +#ifdef CR9_C_ADD_1p25MS_LRSNS + +static void readSNSData_fx(UWord8* ptr, + Word16* bfiPtr, + Word16* mask_side, + Word16* bp_side, + Word16* ltpf_idx_2_lrsns, + Word32* L_scf_idx, + LC3PLUS_FrameDuration frame_dms); + +#endif + +static Word16 read_indice(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 numbits) +{ + Dyn_Mem_Deluxe_In( + Word16 indice, bit; + Counter i; + ); + + indice = read_bit(ptr, bp, mask); + + FOR (i = 1; i < numbits; i++) + { + bit = read_bit(ptr, bp, mask); + indice = add(indice, lshl_pos(bit, i)); + } + + Dyn_Mem_Deluxe_Out(); + return indice; +} static Word16 ac_dec_split_st2VQ_CW( /* local BER flag */ const Word32 L_cwRx, /* max 25 bits */ @@ -20,15 +53,38 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 L_spec, Word16 fs_idx, Word16 BW_cutoff_bits, Word16 *tns_numfilters, Word16 *lsbMode, Word16 *lastnz, Word16 *bfi, Word16 *tns_order, Word16 *fac_ns_idx, Word16 *gg_idx, Word16 *BW_cutoff_idx, Word16 *ltpf_idx, Word32 *L_scf_idx, - Word16 frame_dms) + LC3PLUS_FrameDuration frame_dms +#ifdef CR9_C_ADD_1p25MS + , Word16 rx_status[2], Word16* mem_continuation +#ifdef NEW_SIGNALLING_SCHEME_1p25 + ,Word16 *ltpfinfo_frame_cntr_fx /* set here , but also increased outside by bfi for the channel */ +#endif +#endif + + ) { +#ifdef CR9_C_ADD_1p25MS_LRSNS Dyn_Mem_Deluxe_In( - Word16 L, submodeLSB; - Word32 tmp32, tmp32lim; - Word16 gain_e, gain, submodeMSB, BER_detect; - Word32 n; - UWord8 *ptr; + Word16 L; + Word32 tmp32; + Word16 gain_e, gain; + Counter n; + UWord8 * ptr; + Word16 ltpf_idx_2_lrsns[3]; + Word16 bfiSNS; ); +#else + Dyn_Mem_Deluxe_In( + Word16 L, submodeLSB; + Word32 tmp32, tmp32lim; + Word16 gain_e, gain, submodeMSB, BER_detect; + Counter n; + UWord8 * ptr; ); +#endif + +#if !defined(LRSNS_PC_SIGNAL_FIX) && defined(CR9_C_ADD_1p25MS_LRSNS) + UNUSED(bfiSNS); +#endif ptr = bytes; *bp_side = shr_pos(sub(nbbits, 1), 3); @@ -53,17 +109,28 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, } /* Number of TNS filters */ - IF (sub(*BW_cutoff_idx, 3) >= 0 && frame_dms >= 50) - { - *tns_numfilters = 2; move16(); - } - ELSE +#ifdef CR9_C_ADD_1p25MS + IF (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) { + *tns_numfilters = 0; + } ELSE +#ifdef CR9_C_ADD_1p25MS_LRSNS { - *tns_numfilters = 1; move16(); +#endif +#endif + IF (sub(*BW_cutoff_idx, 3) >= 0 && frame_dms >= LC3PLUS_FRAME_DURATION_5MS) + { + *tns_numfilters = 2; move16(); + } + ELSE + { + *tns_numfilters = 1; move16(); + } +#ifdef CR9_C_ADD_1p25MS_LRSNS } +#endif /* Decode number of ntuples */ - L = sub(14, norm_s(negate(L_spec))); + L = getLastNzBits_fx(L_spec); n = read_indice(ptr, bp_side, mask_side, L); n = add(n, 1); *lastnz = shl_pos(n, 1); @@ -81,7 +148,7 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, *gg_idx = read_indice(ptr, bp_side, mask_side, 8); move16(); tmp32 = L_shl_pos(L_mult0(*gg_idx, 0x797D), 7); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); /* get exponent */ - gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32, 0xFE000000))); + gain = round_fx(BASOP_Util_InvLog2(L_or(tmp32, 0xFE000000))); assert(gain >= 0); /* JSv, check if shr_pos(gain,1) is more appropriate) */ gain = shr_r(gain, 1); gain_e = add(gain_e, 1); @@ -94,13 +161,58 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, } /* LTPF on/off */ -#ifdef ENABLE_HR_MODE - ltpf_idx[0] = read_bit(ptr, bp_side, mask_side); move16(); +#ifdef NEW_SIGNALLING_SCHEME_1p25 + IF(sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) != 0) + { + ltpf_idx[0] = read_bit(ptr, bp_side, mask_side); move16(); + } + ELSE + { /* read one of {2, 6, 7} bits into ltp/ltpf/lag variable ltpf_idx[ 0 ... 2] */ + readLtpData_fx(ptr, bfi, mask_side, bp_side, ltpf_idx, rx_status, ltpfinfo_frame_cntr_fx, mem_continuation); + } #else ltpf_idx[0] = read_indice(ptr, bp_side, mask_side, 1); move16(); #endif - /* Decode SNS VQ parameters - 1st stage (10 bits) */ + +/* Decode SNS VQ parameters - 1st stage (10 bits) */ +#ifdef CR9_C_ADD_1p25MS_LRSNS + ltpf_idx_2_lrsns[0] = ltpf_idx[0]; move16(); + ltpf_idx_2_lrsns[1] = ltpf_idx[1]; move16(); +#ifdef LRSNS_PC_SIGNAL_FIX + bfiSNS = 0; move16(); /* Local BFI flag for Errors SNS bit area */ + + readSNSData_fx(ptr, &bfiSNS, mask_side, bp_side, ltpf_idx_2_lrsns, L_scf_idx, frame_dms); + IF ( bfiSNS != 0 ) + { /* corrupt SNSbits triggers PLC through global PLC flag *bfi==1. + *bfi==2 and bfiSNS == 0 maintains bfi==2 for PC(Partial Concealmnet) + */ + *bfi = 1; + Dyn_Mem_Deluxe_Out(); + return; + } + IF ( sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS ) == 0 ) + { /* for 1.25ms and previously detected bit errors --> handle frame as a completely corrupt bad frame */ + IF( sub(*bfi, 2) == 0) + { + *bfi = 1; + Dyn_Mem_Deluxe_Out(); + return; + } + } + +#else + readSNSData_fx(ptr, bfi, mask_side, bp_side, ltpf_idx_2_lrsns, L_scf_idx, frame_dms); + + IF(*bfi != 0) + { + *bfi = 1; + Dyn_Mem_Deluxe_Out(); + return; + } +#endif +#else + #ifdef ENABLE_HR_MODE L = read_indice(ptr, bp_side, mask_side, 5 + 5); L_scf_idx[0] = L_deposit_l(s_and(L, 0x1F)); /* stage1 LF 5 bits */ @@ -145,43 +257,114 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, ASSERT(submodeMSB == 1); /* outlier mode shape index total 23.8536 + 19.5637 (19.5637 < (log2(2.^24 -2.^23.8537)) bits MPVQ * codeword */ - tmp32 = L_deposit_l(read_indice(ptr, bp_side, mask_side, 12)); - tmp32 = L_or(tmp32, L_shl_pos(read_indice(ptr, bp_side, mask_side, 12), 12)); - L_scf_idx[5] = tmp32; move32(); /*shape outl_near or outl_far */ - submodeLSB = 0; move16(); - BER_detect = 0; move16(); - tmp32lim = L_add(sns_MPVQ_Sz[2][0], L_shl_pos(sns_MPVQ_Sz[3][0], 1)); - IF (L_sub(tmp32, tmp32lim) >= 0) + + tmp32 = L_deposit_l( read_indice( ptr, bp_side, mask_side, 12 ) ); + tmp32 = L_or( tmp32, L_shl_pos( read_indice( ptr, bp_side, mask_side, 12 ), 12 ) ); + + L_scf_idx[5] = tmp32; + move32(); /*shape outl_near or outl_far */ + submodeLSB = 0; + move16(); + BER_detect = 0; + move16(); + tmp32lim = L_add( sns_MPVQ_Sz[2][0], L_shl_pos( sns_MPVQ_Sz[3][0], 1 ) ); + IF( L_sub( tmp32, tmp32lim ) >= 0 ) { - BER_detect = 1; move16(); + BER_detect = 1; + move16(); } ELSE { - tmp32 = L_sub(tmp32, sns_MPVQ_Sz[2][0]); /* a potential high index is computed */ - IF (tmp32 >= 0) + tmp32 = L_sub( tmp32, sns_MPVQ_Sz[2][0] ); /* a potential high index is computed */ + IF( tmp32 >= 0 ) { - submodeLSB = 1; move16(); - ASSERT(tmp32 >= 0 && tmp32 < (Word32)(2 * sns_MPVQ_Sz[3][0])); - L_scf_idx[3] = L_add(L_shl_pos(L_scf_idx[3], 1), L_and(tmp32, 0x1)); /* add LSB_gain bit to gain MSBs */ - L_scf_idx[5] = L_shr_pos(tmp32, 1); /* MPVQ index with offset and gainLSB removed */ - L_scf_idx[6] = -2L; move32(); + submodeLSB = 1; + move16(); + ASSERT( tmp32 >= 0 && tmp32 < (Word32) ( 2 * sns_MPVQ_Sz[3][0] ) ); + L_scf_idx[3] = L_add( L_shl_pos( L_scf_idx[3], 1 ), L_and( tmp32, 0x1 ) ); /* add LSB_gain bit to gain MSBs */ + L_scf_idx[5] = L_shr_pos( tmp32, 1 ); /* MPVQ index with offset and gainLSB removed */ + L_scf_idx[6] = -2L; + move32(); } ELSE { - L_scf_idx[6] = -1L; move32(); + L_scf_idx[6] = -1L; + move32(); } } } L_scf_idx[2] = - L_add(L_scf_idx[2], L_deposit_l(submodeLSB)); /* decoder internal signal shape_j = submode 0..3 to VQ */ + L_add( L_scf_idx[2], L_deposit_l( submodeLSB ) ); /* decoder internal signal shape_j = submode 0..3 to VQ */ - IF (BER_detect > 0) + IF( BER_detect > 0 ) { - *bfi = 1; move16(); + *bfi = 1; move16(); Dyn_Mem_Deluxe_Out(); return; } +#endif + +#ifdef CR9_C_ADD_1p25MS +#ifdef NEW_SIGNALLING_SCHEME_1p25 + IF( sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) != 0 ) + { + ltpf_idx[1] = 0; move16(); + ltpf_idx[2] = 0; move16(); + + test(); + IF( ltpf_idx[0] != 0 ) + { + L = read_indice(ptr, bp_side, mask_side, 1 + 9); + ltpf_idx[1] = s_and(L, 1); move16(); + ltpf_idx[2] = shr_pos(L, 1); move16(); + } + } +#else + IF (ltpf_idx[0] == 1) { + if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) { + Word32 rx_current_status = read_bit(ptr, bp_side, mask_side); + IF (rx_current_status == rx_status[0]) { + IF (rx_current_status == 0) { + rx_status[0] = 1; move16(); + rx_status[1] = read_indice(ptr, bp_side, mask_side, 5); move16(); + if (*mem_continuation == 0) + { + *mem_continuation = 1; + } + } ELSE { + /* rx current status 1 */ + rx_status[0] = 0; move16(); + ltpf_idx[1] = shr_pos (rx_status[1],4); + ltpf_idx[2] = read_indice(ptr, bp_side, mask_side, 5); + ltpf_idx[2] = add(ltpf_idx[2], shl_pos(s_and(rx_status[1],15), 5)); + rx_status[1] = 0; move16(); + *mem_continuation = 0; + } + } ELSE { /* frame loss condtion */ + rx_status[0] = 0; +#ifdef FIX_PLC_CONFORM_ISSUES + rx_status[1] = read_indice( ptr, bp_side, mask_side, 5 ); +#else + rx_status[1] = 0; +#endif + } + } ELSE { + L = read_indice(ptr, bp_side, mask_side, 1+9); move16(); + ltpf_idx[1] = s_and(L, 1); move16(); + ltpf_idx[2] = shr_pos(L, 1); move16(); + } + } + ELSE + { + ltpf_idx[1] = 0; move16(); + ltpf_idx[2] = 0; move16(); + rx_status[0] = 0; + rx_status[1] = 0; + *mem_continuation = 0; + } +#endif +#else /* CR9_C_ADD_1p25MS */ /* LTPF data */ IF (ltpf_idx[0] != 0) { @@ -197,191 +380,619 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, } ELSE { - ltpf_idx[1] = 0; move16(); - ltpf_idx[2] = 0; move16(); + ltpf_idx[1] = 0; move16(); + ltpf_idx[2] = 0; move16(); } +#endif /* new signalling */ /* Decode noise-fac */ - *fac_ns_idx = read_indice(ptr, bp_side, mask_side, 3); move16(); + *fac_ns_idx = read_indice( ptr, bp_side, mask_side, 3 ); move16(); Dyn_Mem_Deluxe_Out(); } + #ifdef ENABLE_PADDING -int paddingDec_fx(UWord8 *bytes, Word16 nbbits, Word16 L_spec, Word16 BW_cutoff_bits, Word16 ep_enabled, - Word16 *total_padding, Word16 *np_zero) +Word32 paddingDec_fx( UWord8* bytes, Word16 nbbits, Word16 L_spec, Word16 BW_cutoff_bits, Word16 ep_enabled, Word16* total_padding, Word16* np_zero ) { Word16 lastnz_threshold; Word16 padding_len_bits, padding_len; Word16 bp_side; - Word16 nbbytes = shr(nbbits,3); + Word16 nbbytes = shr( nbbits, 3 ); - Word16 mask_side; - UWord8 *ptr = bytes; + Word16 mask_side; + UWord8* ptr = bytes; Word16 lastnz; - Word16 nbits = sub(14, norm_s(negate(L_spec))); - if (sub(nbbits, nbits) < 0) + Word16 nbits = getLastNzBits_fx( L_spec ); + if ( sub( nbbits, nbits ) < 0 ) { return 1; } - *np_zero = 0; + *np_zero = 0; *total_padding = 0; - bp_side = shr_pos(sub(nbbits, 1), 3); - mask_side = shl(1, sub(8, sub(nbbits, shl_pos(bp_side, 3)))); + bp_side = shr_pos( sub( nbbits, 1 ), 3 ); + mask_side = shl( 1, sub( 8, sub( nbbits, shl_pos( bp_side, 3 ) ) ) ); test(); - IF (sub(bp_side, 19) < 0 || sub(bp_side, LC3PLUS_MAX_BYTES ) >= 0) { + IF( sub( bp_side, 19 ) < 0 || sub( bp_side, LC3PLUS_MAX_BYTES ) >= 0 ) + { return 1; } ptr = bytes; - IF (BW_cutoff_bits > 0) + IF( BW_cutoff_bits > 0 ) { - read_indice(ptr, &bp_side, &mask_side, BW_cutoff_bits); + read_indice( ptr, &bp_side, &mask_side, BW_cutoff_bits ); move16(); } - lastnz = read_indice(ptr, &bp_side, &mask_side, nbits); + lastnz = read_indice( ptr, &bp_side, &mask_side, nbits ); move16(); - lastnz_threshold = sub(shl(1, nbits), 2); + lastnz_threshold = sub( shl( 1, nbits ), 2 ); - WHILE (lastnz == lastnz_threshold) + WHILE( lastnz == lastnz_threshold ) { - padding_len_bits = sub(sub(12, nbits), BW_cutoff_bits); + padding_len_bits = sub( sub( 12, nbits ), BW_cutoff_bits ); /*Read padding length*/ - padding_len = read_indice(ptr, &bp_side, &mask_side, padding_len_bits); + padding_len = read_indice( ptr, &bp_side, &mask_side, padding_len_bits ); move16(); /* Read 4 reserved bits */ - read_indice(ptr, &bp_side, &mask_side, 4); + read_indice( ptr, &bp_side, &mask_side, 4 ); move16(); - IF (ep_enabled == 0) + IF( ep_enabled == 0 ) { /* Discard padding length bytes */ - bp_side = sub(bp_side, padding_len); - *total_padding = add(add(*total_padding, padding_len), 2); move16(); + bp_side = sub( bp_side, padding_len ); + *total_padding = add( add( *total_padding, padding_len ), 2 ); + move16(); } ELSE { - *total_padding = add(*total_padding, 2); move16(); - *np_zero = add(*np_zero, padding_len); move16(); + *total_padding = add( *total_padding, 2 ); + move16(); + *np_zero = add( *np_zero, padding_len ); + move16(); } - + /* test if we have less than 20 bytes left; if so frame is broken */ - IF (sub(sub(nbbytes,add(*total_padding,*np_zero)),20) < 0) { + IF( sub( sub( nbbytes, add( *total_padding, *np_zero ) ), 20 ) < 0 ) + { return 1; } /* Read bandwidth bits */ - IF (BW_cutoff_bits > 0) + IF( BW_cutoff_bits > 0 ) { - read_indice(ptr, &bp_side, &mask_side, BW_cutoff_bits); + read_indice( ptr, &bp_side, &mask_side, BW_cutoff_bits ); move16(); } - lastnz = read_indice(ptr, &bp_side, &mask_side, nbits); + lastnz = read_indice( ptr, &bp_side, &mask_side, nbits ); move16(); } - IF (ep_enabled != 0) + IF( ep_enabled != 0 ) { - *total_padding = add(*total_padding, *np_zero); move16(); + *total_padding = add( *total_padding, *np_zero ); + move16(); } return 0; } #endif -static __forceinline Word16 read_indice(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 numbits) -{ - Dyn_Mem_Deluxe_In( - Word16 indice, bit; - Counter i; - ); - - indice = read_bit(ptr, bp, mask); - - FOR (i = 1; i < numbits; i++) - { - bit = read_bit(ptr, bp, mask); - indice = add(indice, lshl_pos(bit, i)); - } - - Dyn_Mem_Deluxe_Out(); - return indice; -} - -static __forceinline Word16 ac_dec_split_st2VQ_CW( /* local BER flag */ - const Word32 L_cwRx, /* max 25 bits */ - const Word32 L_szA, const Word32 L_szB, Word32 *L_cwA, Word32 *L_cwB, - Word16 *submodeLSB) +static Word16 ac_dec_split_st2VQ_CW( /* local BER flag */ + const Word32 L_cwRx, /* max 25 bits */ + const Word32 L_szA, + const Word32 L_szB, + Word32* L_cwA, + Word32* L_cwB, + Word16* submodeLSB ) { /* demultiplex: L_cwRx = L_cwB(21.z bits) * L_szA(3.y bits) + L_cwA(21.x bits)); */ - Word16 start, fin, ind; - Word32 L_tmp, L_max_size; + Word16 start, fin, ind; + Word32 L_tmp, L_max_size; Counter i; - L_max_size = (Word32)UL_Mpy_32_32((UWord32)L_szB, (UWord32)L_szA); /* may be tabled */ + L_max_size = (Word32) UL_Mpy_32_32( (UWord32) L_szB, (UWord32) L_szA ); /* may be tabled */ /* section B ind larger than 13 out of the possible 14 = 0..13 */ - IF (L_sub(L_cwRx, L_max_size) >= 0) + IF( L_sub( L_cwRx, L_max_size ) >= 0 ) { - *L_cwA = L_deposit_l(0); - *L_cwB = L_deposit_l(0); - *submodeLSB = 0; move16(); - return (Word16)1; /* set berFlag and exit */ + *L_cwA = L_deposit_l( 0 ); + *L_cwB = L_deposit_l( 0 ); + *submodeLSB = 0; + move16(); + return (Word16) 1; /* set berFlag and exit */ } /*initial binary split of cw, select top or low half */ - start = 0; move16(); + start = 0; + move16(); - ASSERT((L_szB & 0x1L) == 0); /* this middle split only works if L_szB is even */ - if (L_sub(L_cwRx, L_shr_pos(L_max_size, 1)) >= 0) + ASSERT( ( L_szB & 0x1L ) == 0 ); /* this middle split only works if L_szB is even */ + if ( L_sub( L_cwRx, L_shr_pos( L_max_size, 1 ) ) >= 0 ) { - start = L_shr_pos(L_szB, 1); /* top half start index */ + start = L_shr_pos( L_szB, 1 ); /* top half start index */ } /*linear loop over a low or a high section */ - ind = start; move16(); - L_tmp = L_negate(L_cwRx); /* search from negative side */ + ind = start; + move16(); + L_tmp = L_negate( L_cwRx ); /* search from negative side */ - L_tmp = L_add(L_tmp, (Word32)UL_Mpy_32_32(UL_deposit_l((UWord16)start), (UWord32)L_szA)); + L_tmp = L_add( L_tmp, (Word32) UL_Mpy_32_32( UL_deposit_l( (UWord16) start ), (UWord32) L_szA ) ); /* start is 0 or 7 */ /*non-fractional mult is (int)start * L_szA */ /* a short linear run over ceil(szB/2) = 7 values */ - fin = add(start, shr_pos(L_szB, 1)); - FOR (i = start; i < fin; i++) + fin = add( start, shr_pos( L_szB, 1 ) ); + FOR( i = start; i < fin; i++ ) { - ind = add(ind, 1); - L_tmp = L_add(L_tmp, L_szA); - if (L_tmp > 0) + ind = add( ind, 1 ); + L_tmp = L_add( L_tmp, L_szA ); + if ( L_tmp > 0 ) { - ind = sub(ind, 1); /* passed criteria point, keep index */ + ind = sub( ind, 1 ); /* passed criteria point, keep index */ } } - *L_cwB = L_deposit_l(ind); - *L_cwA = L_sub(L_cwRx, (Word32)UL_Mpy_32_32(UL_deposit_l((UWord16)ind), - (UWord32)L_szA)); /* non-fractional mult; (int)ind * L_szA */ + *L_cwB = L_deposit_l( ind ); + *L_cwA = L_sub( L_cwRx, (Word32) UL_Mpy_32_32( UL_deposit_l( (UWord16) ind ), + (UWord32) L_szA ) ); /* non-fractional mult; (int)ind * L_szA */ - ASSERT(*L_cwA >= 0 && *L_cwA < L_szA); - ASSERT(*L_cwB >= 0 && *L_cwB < L_szB); + ASSERT( *L_cwA >= 0 && *L_cwA < L_szA ); + ASSERT( *L_cwB >= 0 && *L_cwB < L_szB ); *submodeLSB = 0; - *L_cwB = L_sub(*L_cwB, 2); - if (*L_cwB < 0) + *L_cwB = L_sub( *L_cwB, 2 ); + if ( *L_cwB < 0 ) { - *submodeLSB = 1; move16(); + *submodeLSB = 1; + move16(); } - *L_cwB = L_mac0(*L_cwB, 2, *submodeLSB); /* add back gain ind if needed */ + *L_cwB = L_mac0( *L_cwB, 2, *submodeLSB ); /* add back gain ind if needed */ return 0; /* no BER */ } + +#ifdef CR9_C_ADD_1p25MS_LRSNS + +void readSNSData_fx(UWord8* ptr, + Word16* bfiPtr, + Word16* mask_side, + Word16* bp_side, + Word16* ltpf_idx_2_lrsns, + Word32* L_scf_idx, + LC3PLUS_FrameDuration frame_dms) +{ + Dyn_Mem_Deluxe_In( + Word32 i, tmp32, tmp32lim; + Word16 submodeMSB, submodeLSB; + Word16 L, BER_detect; + Word16 read_legacy_sns_vq_bits_fx; + Word16 shape_idx, gain_idx, aux_idx, tmp_shape, stop_bit; + Word16 plc_trigger_SNS1, plc_trigger_SNS2; + + ); + + BER_detect = 0; move16(); + plc_trigger_SNS1 = 1; move16(); +#ifdef LRSNS_10MS_BFISIGNAL_FIX + plc_trigger_SNS2 = 1; move16(); +#else + plc_trigger_SNS2 = 2; move16(); +#endif + read_legacy_sns_vq_bits_fx = 1; move16(); + IF(sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + read_legacy_sns_vq_bits_fx = 0; move16(); /* decode 9, 10, or 29/30 bits */ + } + + IF(read_legacy_sns_vq_bits_fx != 0) + { + /* Decode SNS VQ parameters - 1st stage (10 bits) */ + L = read_indice(ptr, bp_side, mask_side, 5 + 5); + L_scf_idx[0] = L_deposit_l(s_and(L, 0x1F)); /* stage1 LF 5 bits */ + L_scf_idx[1] = L_deposit_l(shr_pos(L, 5)); /* stage1 HF 5 bits */ + + + /* Decode SNS VQ parameters - 2nd stage side-info (3-4 bits) */ + submodeMSB = read_bit(ptr, bp_side, mask_side); /* submodeMSB 1 bit */ + L_scf_idx[2] = L_deposit_l(shl_pos(submodeMSB, 1)); + ASSERT(sns_gainMSBbits[L_scf_idx[2]] > 0); + L_scf_idx[3] = L_deposit_l( + read_indice(ptr, bp_side, mask_side, sns_gainMSBbits[L_scf_idx[2]])); /* gains or gain MSBs 1-2 bits */ + L_scf_idx[4] = read_bit(ptr, bp_side, mask_side); /* shape LS 1 bit */ + + /* Decode SNS VQ parameters - 2nd stage data (24-25 bits) */ + IF(submodeMSB == 0) + { /* shape_j = 0, or 1 */ + /* regular mode A,B indexes integer multiplexed, total 24.x bits MPVQ codeword section A and codeword for + * section B */ + /* regular mode mode shape index total 24.9999 bits MPVQ codeword */ + + tmp32 = L_deposit_l(read_indice(ptr, bp_side, mask_side, 13)); + tmp32 = L_or(tmp32, L_shl_pos(read_indice(ptr, bp_side, mask_side, 12), 13)); + move16(); /*for ber state */ + BER_detect = + ac_dec_split_st2VQ_CW( /* local BER flag */ + tmp32, /* L_cwRx max 25 bits */ + sns_MPVQ_Sz[0][0], UL_addNsD(sns_MPVQ_Sz[0][1], sns_MPVQ_Sz[1][1]), /* 12+2 = 14 */ + (&L_scf_idx[5]), /* shape A */ + (&L_scf_idx[6]), /* shape B or gain LSB */ + &submodeLSB /* total submode update below */ + ); + IF(submodeLSB != 0) + { /* add gainLSB bit */ + L_scf_idx[3] = L_add(L_shl_pos(L_scf_idx[3], 1), L_scf_idx[6]); + L_scf_idx[6] = -2L; + } + } + ELSE + { /* shape_j = 2 or 3 */ + ASSERT(submodeMSB == 1); + /* outlier mode shape index total 23.8536 + 19.5637 (19.5637 < (log2(2.^24 -2.^23.8537)) bits MPVQ + * codeword */ + tmp32 = L_deposit_l(read_indice(ptr, bp_side, mask_side, 12)); + tmp32 = L_or(tmp32, L_shl_pos(read_indice(ptr, bp_side, mask_side, 12), 12)); + + L_scf_idx[5] = tmp32; move32(); /*shape outl_near or outl_far */ + submodeLSB = 0; move16(); + BER_detect = 0; move16(); + tmp32lim = L_add(sns_MPVQ_Sz[2][0], L_shl_pos(sns_MPVQ_Sz[3][0], 1)); + + IF (L_sub(tmp32, tmp32lim) >= 0) + { + BER_detect = 1; move16(); + } + ELSE + { + tmp32 = L_sub(tmp32, sns_MPVQ_Sz[2][0]); /* a potential high index is computed */ + IF (tmp32 >= 0) + { + submodeLSB = 1; move16(); + ASSERT(tmp32 >= 0 && tmp32 < (Word32)(2 * sns_MPVQ_Sz[3][0])); + L_scf_idx[3] = L_add(L_shl_pos(L_scf_idx[3], 1), L_and(tmp32, 0x1)); /* add LSB_gain bit to gain MSBs */ + L_scf_idx[5] = L_shr_pos(tmp32, 1); /* MPVQ index with offset and gainLSB removed */ + L_scf_idx[6] = -2L; move32(); + } + ELSE + { + L_scf_idx[6] = -1L; move32(); + } + } + } + L_scf_idx[2] = + L_add(L_scf_idx[2], L_deposit_l(submodeLSB)); /* decoder internal signal shape_j = submode 0..3 to VQ */ + + +#ifdef LRSNS_10MS_BFISIGNAL_FIX + IF( BER_detect > 0) + { + *bfiPtr = 1; move16(); + Dyn_Mem_Deluxe_Out(); + return; + } +#else + *bfiPtr = BER_detect; move16(); + IF(*bfiPtr != 0) + { + Dyn_Mem_Deluxe_Out(); + return; + } +#endif + } + ELSE + { + ASSERT(read_legacy_sns_vq_bits_fx == 0 ); + /* lrsns 9/10/29/30 */ + /* init auxiliary demuxing variabls */ + shape_idx = -1; move16(); + gain_idx = -1; move16(); + aux_idx = -1; move16(); + tmp_shape = -1; move16(); + stop_bit = -1; move16(); + + FOR(i = 0; i < SCF_MAX_PARAM; i++) + { + L_scf_idx[i] = L_sub(-32000, i); move32(); /* init parameters to be fwded to LRSNS VQ demultiplexor */ + } + + /* start actual Q-mode and fractional bits demultiplexing */ + + /* SNS-VQ 1st stage , 3 sections of 7.4 bits is stored in the first 9 bits */ + L_scf_idx[0] = L_deposit_l(read_indice(ptr, bp_side, mask_side, 9)); + + IF(L_sub(L_scf_idx[0], 510) >= 0) + { + ASSERT(L_scf_idx[0] < 512); + L_scf_idx[0] -= 510; move32(); /* sent only idx 0,1 */ + shape_idx = -9; move16(); + L_scf_idx[2] = shape_idx; move32(); /* actual signal to LRSNS decoder vector reconstruction */ + } + ELSE + { + /* read stop bit, 10th bit */ + stop_bit = read_indice(ptr, bp_side, mask_side, 1); + + test(); test(); + IF((L_sub(L_scf_idx[0] , (2 * 170)) < 0) && (stop_bit != 0)) + { + /*keep values 0...339 in sns_vq_idx[0] , so that B vs C can be determined later in DecLR_fx function */ + L_scf_idx[2] = -10L; move32(); + L_scf_idx[3] = L_deposit_l(ltpf_idx_2_lrsns[0]); /*LTP active flag */ + L_scf_idx[4] = L_deposit_l(ltpf_idx_2_lrsns[1]); /*LTPF active flag */ + } + ELSE + { /* stage1B* + stage2*/ + /*0...169 in sns_vq_idx[0]*/ + test(); test(); + IF((L_sub(L_scf_idx[0], (2 * 170)) < 0) && (stop_bit == 0)) + { + aux_idx = 0; move16(); /* typically a leading or first sign is stored in aux_idx */ + + IF(L_sub(L_scf_idx[0], 170) >= 0) + { + aux_idx = 1; move16(); + L_scf_idx[0] = L_sub(L_scf_idx[0], 170); move32(); + } + L_scf_idx[1] = aux_idx; move32(); /* forward aux bit for , LR_Split_LF, 29 bits */ + + shape_idx = 0; move16(); /* point to splitLF parsing */ + L_scf_idx[2] = L_deposit_l(shape_idx); move32(); + + gain_idx = read_indice(ptr, bp_side, mask_side, 2); + L_scf_idx[3] = L_deposit_l(gain_idx); move32(); + + /* stage2 shape demux for LR_splitLF */ + + L_scf_idx[4] = L_deposit_l(read_indice(ptr, bp_side, mask_side, 10));/* 10bits mPVQ(N=5,K=6) */ + + IF(L_sub(L_scf_idx[4] , (SNSLR_NPVQ_L5K6 >> 1) + (1 << 5)) >= 0) /* some limited bit error detection possible here */ + { + *bfiPtr = plc_trigger_SNS1; move16(); + IF(*bfiPtr != 0) + { +#ifdef LRSNS_10MS_BFISIGNAL_FIX + ASSERT(*bfiPtr == 1); +#endif + Dyn_Mem_Deluxe_Out(); + return; + } + } + + /* determine section of splitLF mpvq(5,6)+P(8,2)+P(2,0) or mpvq(5,8)+P(10,0) */ + IF(L_sub(L_scf_idx[4] , (SNSLR_NPVQ_L5K6 >> 1)) < 0) + { + tmp_shape = read_indice(ptr, bp_side, mask_side, 1);/* LS (8,2) */ + L_scf_idx[5] = L_deposit_l(read_indice(ptr, bp_side, mask_side, 6)); move32(); /* mPVQ(8,2) */ + L_scf_idx[5] = L_mac0(L_shl_pos(L_scf_idx[5], 1), 1, tmp_shape); move32(); /* P(8,2) LS put as lsb */ + } + ELSE + { + L_scf_idx[4] = L_sub(L_scf_idx[4], (SNSLR_NPVQ_L5K6 >> 1)); move32(); /* 5 lsbs of mpvq (5,8) */ + + L_scf_idx[5] = L_deposit_l(read_indice(ptr, bp_side, mask_side, 7)); move32();/* 7 msbs of mPVQ(5,8) */ + + L_scf_idx[4] = L_or(L_shl_pos(L_scf_idx[5], 5), L_scf_idx[4]); move32(); /* binary merge MSB's and LSBs */ + L_scf_idx[5] = -8L; move32(); /* signal to sns_decoder split_LF subshape to decode 8 lf pulses, and no hf pulses */ + + IF(L_sub(L_scf_idx[4] , (SNSLR_NPVQ_L5K8 >> 1)) >= 0) + { + *bfiPtr = plc_trigger_SNS2; move16(); + IF( *bfiPtr != 0 ) + { +#ifdef LRSNS_10MS_BFISIGNAL_FIX + ASSERT(*bfiPtr == 1); +#endif + Dyn_Mem_Deluxe_Out(); + return; + } + } + } + } + ELSE IF(L_sub(L_scf_idx[0], 2 * 170) >= 0) + { + aux_idx = stop_bit; move16(); + L_scf_idx[0] = L_sub(L_scf_idx[0], 2 * 170); move32(); + L_scf_idx[1] = L_deposit_l(aux_idx); move32(); + + + shape_idx = 1; move16();/* point to full parsing */ + L_scf_idx[2] = shape_idx; move32();/* LR_full , 30 bits */ + + gain_idx = read_indice(ptr, bp_side, mask_side, 3); + L_scf_idx[3] = gain_idx; move32(); + + /* stage2 shape demux for LR_full */ + tmp32 = L_deposit_l(read_indice(ptr, bp_side, mask_side, 10)); /* 10 LSBs. total 16.666 bits mPVQ(N=15,K=5) */ + tmp32 = L_or(tmp32, L_shl_pos(read_indice(ptr, bp_side, mask_side, 7), 10)); /*7 MSBs */ + L_scf_idx[4] = tmp32; move32(); + IF(L_sub(L_scf_idx[4], (SNSLR_NPVQ_L15K5 >> 1)) >= 0) + { /* fixenv shapes demultiplexing */ + L_scf_idx[5] = L_sub(L_scf_idx[4], (SNSLR_NPVQ_L15K5 >> 1)); move32(); + + IF(L_sub(L_scf_idx[5] , 3 * (1 << 13)) < 0) + { /*fix_env's "0,1,2" with 2 shiftbits and 11 remaining sign bits s1..s11 */ + L_scf_idx[4] = 0L; move32(); + WHILE(L_sub(L_scf_idx[5], (1 << 13)) >= 0) + { + L_scf_idx[5] = L_mac0(L_scf_idx[5], -1, (1 << 13)); move32(); + L_scf_idx[4] = L_add(L_scf_idx[4], 1); move32(); + } + assert(L_scf_idx[4] >= 0 && L_scf_idx[4] <= 3); + assert(L_scf_idx[5] >= 0 && L_scf_idx[5] < (1 << 13)); + } + ELSE IF(L_sub(L_scf_idx[5], 3 * (1 << 13) + (1 << 11)) < 0) + { + L_scf_idx[4] = 3L; move32(); /*smaller fix_env "3" with 2 shiftbits and 9 remaining sign bits s1..s9 */ + L_scf_idx[5] = L_mac0(L_scf_idx[5] , -1, 3 * (1 << 13)); move32(); + assert(L_scf_idx[5] >= 0 && L_scf_idx[5] < (1 << 11)); + } + ELSE + { + /* unused section indicate bit error */ + *bfiPtr = plc_trigger_SNS2; move16(); + test(); + IF( *bfiPtr != 0 ) + { + Dyn_Mem_Deluxe_Out(); + return; + } + } + shape_idx = add(extract_l(L_scf_idx[4]), 2); move32(); + L_scf_idx[2] = L_deposit_l(shape_idx); move32(); + } /* fixenv */ + } /*full*/ + } /*stage1B* + stage2 */ + } /*10+ bits*/ + } +#ifdef LRSNS_PC_SIGNAL_FIX + assert(*bfiPtr == 0 || *bfiPtr == 1); /* local SNS BFI-flag output check */ +#endif + Dyn_Mem_Deluxe_Out(); +} /*read SNS*/ +#endif /* LRSNS */ + + + +#ifdef NEW_SIGNALLING_SCHEME_1p25 + +void readLtpData_fx( + UWord8* ptr, + Word16* bfiPtr, + Word16* mask_side, + Word16* bp_side, + Word16* ltpf_idx, + Word16* rx_status, + Word16* ltpfinfo_frame_cntr_fx, + Word16* mem_continuation +) +{ + Word16 rx_current_status = -1; + Word16 tmp, MSBs, LSBs; + + ltpf_idx[2] = -1; move16(); /* -1 indicates incomplete lag, conditionally decoded if phase is B , and consecutive A/B has arrived */ + + tmp = read_indice(ptr, bp_side, mask_side, 2); + + test(); + IF(tmp == 0) + { + ltpf_idx[0] = 0; move16(); /* ltp ltpf/lag was not transmitted */ + ltpf_idx[1] = 0; move16(); /* ltpf activation bit zeroed */ + + /* *ltp_bits_fx = 2; */ /* note: ltpbits bitbudget not really used in decoder */ + + rx_status[0] = -32768; move16(); /* set unknown phase A , due to rxLTP==0 */ + rx_status[1] = -1; move16(); /* set unknown phase A MSBs content */ + *ltpfinfo_frame_cntr_fx = -32768; move16(); + ASSERT(ltpf_idx[2] < 0); /* ltpf_idx[2] = -1; , no ready lag available */ +#ifdef FIX_LTPF_1p25 + *mem_continuation = 0; move16(); /* also kill lag continuation state */ +#endif + } + ELSE IF(sub(tmp, 1) == 0) + { + ltpf_idx[0] = 1; + ltpf_idx[1] = 0; /* LTP=1, LTPF=0, inactive ltpf */ + rx_current_status = read_bit(ptr, bp_side, mask_side); + + test(); + IF(rx_current_status == 0) + { + rx_status[0] = 0; move16(); /* phaseA */ + rx_status[1] = read_indice(ptr, bp_side, mask_side, 4); /* read four MSBs, and store in rx_status[1] */ +#ifdef FIX_LTPF_1p25 + test(); + if (*mem_continuation == 0) + { + *mem_continuation = 1; + } +#endif + *ltpfinfo_frame_cntr_fx = 0; /* handle longer loss bursts */ + } + ELSE + { /* LSB part of delta coded lag information */ + ASSERT(rx_current_status == 1); + LSBs = shl(read_indice(ptr, bp_side, mask_side, 4), 1); /* NB LSB is on purpose always zero, truncation on encoder side */ + IF ( rx_status[1] < 0 ) + { + *bfiPtr = 1; move16(); + return; + } + ltpf_idx[2] = s_or(shl(rx_status[1], 5), LSBs); + + /* check frame cntr info to not combine oldA with a newB */ + IF(sub(*ltpfinfo_frame_cntr_fx, 1) != 0) + { + ltpf_idx[1] = 0; move16(); /*turn of LTPF, even number of bfi frames may have happened */ + ltpf_idx[2] = -1; move16(); /* indicate bfi burst and corrupt lagLSBs to PLC and ltpf_decoder_fx */ + } +#ifdef FIX_LTPF_MEM_CONTINUATION + else + { + *mem_continuation = 0; move16(); + } + # endif + rx_status[0] = -32768; move16(); + *ltpfinfo_frame_cntr_fx = -32678; move16(); + } + } + ELSE + { /*2 or 3*/ + ltpf_idx[0] = 1; move16(); + ltpf_idx[1] = 1; move16(); /* active ltpf */ + + IF(sub(tmp, 2) == 0) + { + /* phaseA */ + MSBs = read_indice(ptr, bp_side, mask_side, 4); + rx_status[0] = 0; move16(); + rx_status[1] = MSBs; move16();/* remember the four MSBs */ +#ifdef FIX_LTPF_1p25 + test(); + if (*mem_continuation == 0) + { + *mem_continuation = 1; move16(); + } +#endif + *ltpfinfo_frame_cntr_fx = 0; move16(); + } + ELSE + { + ASSERT(tmp == 3); /* phaseB */ + LSBs = read_indice(ptr, bp_side, mask_side, 5); /* all 5 LSBs available*/ + IF ( rx_status[1] < 0 ) + { + *bfiPtr = 1; move16(); + return; + } + ltpf_idx[2] = s_or(shl(rx_status[1], 5), LSBs); + + /* check frame cntr info to not combine oldA MSBs with a newB LSBs */ + IF(sub(*ltpfinfo_frame_cntr_fx, 1) != 0) + { + ltpf_idx[1] = 0; move16(); /* turn off LTPF activation, ltpf_idx[2] is not read */ + ltpf_idx[2] = -1; move16(); /* indicate bfi burst and corrupt lagLSBs to PLC and ltpf_decoder_fx */ + } + *ltpfinfo_frame_cntr_fx = -32678; move16(); /*cntr init in phaseA*/ + rx_status[0] = -32768; move16(); /* phase init in phaseA*/ + +#ifdef FIX_LTPF_MEM_CONTINUATION + *mem_continuation = 0; move16(); +#endif + } + } +} + +#endif diff --git a/lib_lc3plus/dec_lc3.c b/lib_lc3plus/dec_lc3plus.c similarity index 81% rename from lib_lc3plus/dec_lc3.c rename to lib_lc3plus/dec_lc3plus.c index fc01373d5..525edc74f 100644 --- a/lib_lc3plus/dec_lc3.c +++ b/lib_lc3plus/dec_lc3plus.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_sample, UWord8 *bs_in, void *s_out, Word16 bfi, @@ -22,13 +24,14 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #ifdef ENABLE_RFRAME Word16 rframe = 0; #endif - Word16 ltpf_idx[3]; + Word16 ltpf_idx[3] = {0}; Word16 spec_inv_idx = 0; Counter i; /* Buffers */ Word16 *int_scf_fx_exp, tns_order[TNS_NUMFILTERS_MAX]; UWord8 *resBitBuf; + Word16 resBitBufLen; #ifdef ENABLE_HR_MODE Word32 *sqQdec; #else @@ -41,11 +44,26 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s Word32 * q_d_fx; Word8 * currentScratch; DecSetup *h_DecSetup = decoder->channel_setup[channel]; + +#ifdef CR9_C_ADD_1p25MS_LRSNS + Word16 pitch_rx_fx; + Word16 ltpf_rx_fx; +#endif + +#ifdef CR9_C_ADD_1p25MS_LRSNS + Word32 scf_q_ip[M]; +#ifdef ENABLE_HR_MODE + //Counter i; + Word32* x_fx_ip; + Word32 *int_scf_fx_ip; +#endif +#else #ifdef ENABLE_HR_MODE Word32 *x_fx_ip; Word32 *int_scf_fx_ip; Word32 scf_q_ip[M]; #endif +#endif /* CR9_C_ADD_1p25MS_LRSNS */ #ifdef DYNMEM_COUNT struct _dynmem @@ -73,6 +91,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s Word16 *sqQdec; #endif Word16 *int_scf_fx, *x_fx, *indexes; + Word16 resBitBufLen; Word32 *L_scf_idx; Word32 *q_d_fx; Word8 * currentScratch; @@ -91,12 +110,35 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s /* BUFFER INITIALISATION. Some buffers may overlap since they are not used in the whole decoding process */ q_d_fx = scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LEN bytes */ + +#ifdef CR9_C_ADD_1p25MS + IF (decoder->frame_dms==LC3PLUS_FRAME_DURATION_1p25MS) + { + resBitBufLen = 3; + } + ELSE { +#endif + resBitBufLen = 2; +#ifdef CR9_C_ADD_1p25MS + } +#endif + #ifdef ENABLE_HR_MODE /* allocate memory for residual bits */ if (decoder->hrmode) { - resBitBuf = scratchAlign(q_d_fx, sizeof(*q_d_fx) * +#ifdef CR9_C_ADD_1p25MS + IF (decoder->frame_dms==LC3PLUS_FRAME_DURATION_1p25MS) + { + resBitBuf = scratchAlign(q_d_fx, sizeof(*q_d_fx) * + decoder->frame_length * 3); + } + ELSE +#endif + { + resBitBuf = scratchAlign(q_d_fx, sizeof(*q_d_fx) * decoder->frame_length); + } basop_memset(resBitBuf, 0, sizeof(*resBitBuf) * MAX_RESBITS_LEN); } else @@ -105,13 +147,14 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s resBitBuf = scratchAlign(q_d_fx, sizeof(*q_d_fx) * decoder->frame_length); /* Size = 2 * NPRM_RESQ = 2 * MAX_LEN bytes for normal case and 2*MAX_RESBITS_LEN for hrmode */ - basop_memset(resBitBuf, 0, sizeof(*resBitBuf) * 2 * decoder->frame_length); + + basop_memset(resBitBuf, 0, sizeof(*resBitBuf) * resBitBufLen * decoder->frame_length); } - + #ifdef ENABLE_HR_MODE indexes = scratchAlign(resBitBuf, sizeof(*resBitBuf) * MAX_RESBITS_LEN); #else - indexes = scratchAlign(resBitBuf, sizeof(*resBitBuf) * 2 * decoder->frame_length); + indexes = scratchAlign(resBitBuf, sizeof(*resBitBuf) * resBitBufLen * decoder->frame_length); #endif memset(indexes, 0, sizeof(*indexes) * TNS_NUMFILTERS_MAX * MAXLAG); @@ -134,11 +177,11 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s scratchAlign(q_d_fx, sizeof(*q_d_fx) * decoder->frame_length); /* Size = 2 * (MAX_LEN + MDCT_MEM_LEN_MAX) = 2 * MAX_LEN + 1.25 * MAX_LEN = 3.25 * MAX_LEN */ #endif - + #ifdef ENABLE_HR_MODE x_fx_ip = scratchAlign(x_fx, sizeof(*x_fx) * (decoder->frame_length + decoder->stDec_ola_mem_fx_len)); int_scf_fx_ip = scratchAlign(x_fx_ip, sizeof(*x_fx_ip) * (decoder->frame_length + decoder->stDec_ola_mem_fx_len)); - + currentScratch = scratchAlign(int_scf_fx_ip, sizeof(*int_scf_fx_ip) * 2 * MAX_BANDS_NUMBER); /* Size = 4 * MAX_LEN */ #else currentScratch = scratchAlign(x_fx, sizeof(*x_fx) * 4 * MAX_LEN); /* Size = 4 * MAX_LEN */ @@ -178,11 +221,29 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #ifdef WMOPS push_wmops("Entropy dec"); #endif +#ifdef NEW_SIGNALLING_SCHEME_1p25 + h_DecSetup->ltpfinfo_frame_cntr_fx = add_sat(h_DecSetup->ltpfinfo_frame_cntr_fx, 1); + /*ltpfinfo_frame_cntr_fx increased always, also for bfi=1 */ /* set or reset inside dec_entropy_fx() */ +#endif + IF (sub(bfi, 1) != 0) { processDecoderEntropy_fx(bs_in, &bp_side, &mask_side, h_DecSetup->total_bits, decoder->yLen, decoder->fs_idx, decoder->BW_cutoff_bits, &tns_numfilters, &lsbMode, &lastnz, &bfi, tns_order, - &fac_ns_idx, &gg_idx, &BW_cutoff_idx, ltpf_idx, L_scf_idx, decoder->frame_dms); + &fac_ns_idx, &gg_idx, &BW_cutoff_idx, ltpf_idx, L_scf_idx, decoder->frame_dms +#ifdef CR9_C_ADD_1p25MS +#ifdef FIX_TX_RX_STRUCT_STEREO + , h_DecSetup->ltpf_rx_status, &h_DecSetup->ltpf_mem_continuation +#else + , decoder->ltpf_rx_status, &decoder->ltpf_mem_continuation +#endif +#ifdef NEW_SIGNALLING_SCHEME_1p25 + , + &h_DecSetup->ltpfinfo_frame_cntr_fx +#endif +#endif + ); + BW_cutoff_idx_nf = BW_cutoff_idx; move16(); } @@ -204,7 +265,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->hrmode #endif ); - + #ifdef ENABLE_RFRAME test();test(); IF (sub(rframe, 1) == 0 && zero_frame == 0 && sub(bfi, 1) != 0) @@ -214,24 +275,31 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s Word16 max_bw_stopband = BW_cutoff_bin_all[BW_cutoff_idx]; SWITCH (decoder->frame_dms) { - case 25: - max_bw_stopband = shr_pos(max_bw_stopband, 2); - BREAK; - case 50: - max_bw_stopband = shr_pos(max_bw_stopband, 1); - BREAK; - case 75: - max_bw_stopband = add(shr_pos(max_bw_stopband, 2), add(shr_pos(max_bw_stopband, 2), shr_pos(max_bw_stopband, 2))); - BREAK; - case 100: - BREAK; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + max_bw_stopband = shr_pos(max_bw_stopband, 3); + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: + max_bw_stopband = shr_pos(max_bw_stopband, 2); + BREAK; + case LC3PLUS_FRAME_DURATION_5MS: + max_bw_stopband = shr_pos(max_bw_stopband, 1); + BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: + max_bw_stopband = add(shr_pos(max_bw_stopband, 2), add(shr_pos(max_bw_stopband, 2), shr_pos(max_bw_stopband, 2))); + BREAK; + case LC3PLUS_FRAME_DURATION_10MS: + BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: + assert(0); } - + spec_inv_idx = s_max(lastnz, max_bw_stopband); move16(); } #endif - + IF (bfi == 0) { processAriDecoderScaling_fx(sqQdec, decoder->yLen, q_d_fx, &q_fx_exp); @@ -244,8 +312,27 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #ifdef WMOPS push_wmops("SnsQuantScfDec"); #endif + IF (sub(bfi, 1) != 0) +#ifdef CR9_C_ADD_1p25MS_LRSNS { + IF(sub(decoder->frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + pitch_rx_fx = ltpf_idx[0]; move16(); + +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY + ltpf_rx_fx = 0; move16(); /* CB_C with binary means , not dependent on LTPF activation */ +#else + ltpf_rx_fx = ltpf_idx[1]; move16();/* CB_C, with ternary means dependent on LTPF activation */ +#endif + snsQuantScfDecLR_fx(L_scf_idx, scf_q_ip, scf_q, pitch_rx_fx, ltpf_rx_fx, currentScratch); /* 9,12,29,30, bits decoding and 2 pitch info bits */ +#ifdef ENABLE_HR_MODE + downshift_w32_arr(scf_q_ip /* Q26 */, scf_q/* Q11 */, 26 - 11, M); /* W16Q11 version required for PLC */ +#endif + } + ELSE +#endif /* CR9_C_ADD_1p25MS_LRSNS */ + { /* currentScratch Size = 96 bytes */ #ifdef ENABLE_HR_MODE processSnsQuantizeScfDecoder_fx(L_scf_idx, scf_q_ip, currentScratch); @@ -254,6 +341,9 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processSnsQuantizeScfDecoder_fx(L_scf_idx, scf_q, currentScratch); #endif } +#ifdef CR9_C_ADD_1p25MS_LRSNS +} +#endif #ifdef WMOPS pop_wmops(); #endif @@ -293,6 +383,22 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s pop_wmops(); #endif +#ifdef FIX_PLC_CONFORM_ISSUES +#ifdef CR9_C_ADD_1p25MS + IF( sub( bfi, 1 ) == 0 ) + { +#ifdef FIX_TX_RX_STRUCT_STEREO + h_DecSetup->ltpf_rx_status[0] = 0; + h_DecSetup->ltpf_rx_status[1] = 0; +#else + decoder->ltpf_rx_status[0] = 0; + decoder->ltpf_rx_status[1] = 0; +#endif + } +#endif +#endif + + IF (sub(bfi, 1) != 0) { #ifdef WMOPS @@ -301,6 +407,9 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processResidualDecoding_fx(q_d_fx, q_fx_exp, decoder->yLen, resBitBuf, fill_bits #ifdef ENABLE_HR_MODE , decoder->hrmode +#endif +#if defined (CR9_C_ADD_1p25MS) + , decoder->frame_dms #endif ); #ifdef WMOPS @@ -311,11 +420,15 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s push_wmops("Noisefill"); #endif /* currentScratch Size = 2 * MAX_LEN bytes */ +#ifdef CR9_C_ADD_1p25MS IF (zero_frame == 0) +#else + IF (zero_frame == 0) +#endif { processNoiseFilling_fx(q_d_fx, nf_seed, q_fx_exp, fac_ns_idx, BW_cutoff_idx_nf, decoder->frame_dms, h_DecSetup->prev_fac_ns_fx, spec_inv_idx, currentScratch -#ifdef ENABLE_HR_MODE +#ifdef ENABLE_HR_MODE , decoder->hrmode #endif ); @@ -332,6 +445,9 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s pop_wmops(); #endif +#ifdef CR9_C_ADD_1p25MS + if (tns_numfilters > 0) { +#endif #ifdef WMOPS push_wmops("Tns_dec"); #endif @@ -345,6 +461,9 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #ifdef WMOPS pop_wmops(); #endif +#ifdef CR9_C_ADD_1p25MS + } +#endif #ifdef ENABLE_HR_MODE #ifdef WMOPS @@ -386,7 +505,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s /* end int_scf_fx */ #endif /* ENABLE_HR_MODE */ } - + /* x_fx_ip will be used to store h_DecSetup->stDec_ola_mem_fx returned by PLCmain_fx*/ /* This will be upshifted to 32 bit overlap buffer outside of the PLCmain function */ #ifdef ENABLE_HR_MODE @@ -425,7 +544,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #ifdef WMOPS pop_wmops(); #endif - + #ifdef ENABLE_HR_MODE IF(sub(bfi, 1) == 0) { @@ -447,7 +566,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s h_DecSetup->ltpf_mem_pitch_int, ltpf_idx[0], q_d_fx, &q_fx_exp, h_DecSetup->q_old_d_fx, &h_DecSetup->q_old_fx_exp, decoder->yLen, h_DecSetup->plcAd->stab_fac, decoder->frame_dms, &h_DecSetup->plcAd->cum_fading_slow, &h_DecSetup->plcAd->cum_fading_fast, spec_inv_idx - , h_DecSetup->plcAd->plc_fadeout_type + , h_DecSetup->plcAd->plc_fadeout_type ); } #ifdef WMOPS @@ -472,7 +591,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s , decoder->hrmode #endif ); - + #ifdef ENABLE_HR_MODE IF(sub(bfi, 1) != 0 || sub(h_DecSetup->concealMethod, LC3_CON_TEC_NS_STD) == 0 || sub(h_DecSetup->concealMethod, LC3_CON_TEC_NS_ADV) == 0 || sub(h_DecSetup->concealMethod, LC3_CON_TEC_FREQ_MUTING) == 0) { @@ -516,13 +635,25 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s &h_DecSetup->ltpf_mem_pitch_int, &h_DecSetup->ltpf_mem_pitch_fr, &h_DecSetup->ltpf_mem_gain, &h_DecSetup->ltpf_mem_active, h_DecSetup->ltpf_scale_fac_idx, bfi, h_DecSetup->concealMethod, - h_DecSetup->plc_damping, &h_DecSetup->ltpf_mem_scale_fac_idx, + h_DecSetup->plc_damping, &h_DecSetup->ltpf_mem_scale_fac_idx, &h_DecSetup->rel_pitch_change, decoder->hrmode, decoder->frame_dms, - currentScratch); + currentScratch +#ifdef CR9_C_ADD_1p25MS +#ifdef FIX_TX_RX_STRUCT_STEREO + ,&h_DecSetup->ltpf_mem_continuation, &h_DecSetup->ltpf_mem_pitch_int_prev, + &h_DecSetup->ltpf_mem_pitch_fr_prev, &h_DecSetup->ltpf_mem_beta_idx_prev, &h_DecSetup->ltpf_mem_gain_prev, + &h_DecSetup->ltpf_mem_active_prev, &h_DecSetup->ltpf_pitch_stability_counter +#else + , &decoder->ltpf_mem_continuation, &decoder->ltpf_mem_pitch_int_prev, + &decoder->ltpf_mem_pitch_fr_prev, &decoder->ltpf_mem_beta_idx_prev, &decoder->ltpf_mem_gain_prev, + &decoder->ltpf_mem_active_prev, &decoder->ltpf_pitch_stability_counter +#endif +#endif + ); #ifdef WMOPS pop_wmops(); #endif - + #ifdef ENABLE_HR_MODE IF (!(decoder->hrmode)) { @@ -532,7 +663,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s } } #endif - + #ifdef WMOPS push_wmops("Output scaling"); #endif @@ -652,6 +783,7 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo { decoder->epmr = 12; out_bfi = 0; + decoder->error_report = 0; for (ch = 0; ch < decoder->channels; ch++) { @@ -663,10 +795,16 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int num_bytes, vo channel_bfi = bfi; - decoder->error_report = + Word32 chan_error_report = fec_decoder(input, fec_num_bytes, &lc3_num_bytes, &channel_epmr, decoder->combined_channel_coding, &decoder->n_pccw, &channel_bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec, scratch); + + if (chan_error_report < 0 || decoder->error_report < 0) { + decoder->error_report = -1; move16(); + } else { + decoder->error_report = add(decoder->error_report, chan_error_report); + } #ifdef WMOPS pop_wmops(); diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h index f21d5cf37..24da69b87 100644 --- a/lib_lc3plus/defines.h +++ b/lib_lc3plus/defines.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -90,9 +90,129 @@ #ifndef NO_POST_REL_CHANGES /* Post-release non-bitexact changes */ +#define CR13_B_FIX_PC_BINS +#define CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + +#define CR12_B_STOP_DC_RINGING +#define CR12_D_FIX_BITRATE_LIMITS + +#define CR9_C_ADD_1p25MS + +#ifdef CR9_C_ADD_1p25MS + +#define CR9_C_ADD_1p25MS_LRSNS +#define ENABLE_12p5_DMS_MODE +#define NOISEFILLWIDTH_1_25MS 1 +#define NOISEFILLSTART_1_25MS 6 + +#define CR9_C_ADD_1p25MS_NOISEFILLING +#define CR9_1p25MS_SNS_TILT +#define CR9_1p25MS_SNS_TILT_FIX_DELTA_AD_LINE + +#define PLC34_ATTEN_FAC_125_FX 32752 + +#define LTPF_ADAPTIVE_GAIN + +#ifdef LTPF_ADAPTIVE_GAIN +#define LTPF_PITCH_STABILITY_THRESHOLD 5 /* Number of frames for which the pitch must be constant for adaptive gain and pitch correction to be applied */ +#define LTPF_ADAPTIVE_GAIN_RATE 20 /* Number of frames it must take to reach maximum beta from the default value, provided the pitch remains constant */ + +#define LTPF_ADAPTIVE_GAIN_WITH_NORM_CORR +#endif + +/* master integration fixes for 1p25 */ +#ifdef CR9_C_ADD_1p25MS +#define FIX_BASOP_ENC_QUANTIZE_1P25MS_512KBPS /* add two last MDCT coeffs into the last quadruple for global_gain _xmax_ and energy analysis */ + + +#define FIX_BOTH_1p25_WB_GLOBGAINOFFSET_NONBE /* 1p25 curve tilt calulation corrected and made into BASOP, WB had a loss of of HF in the range 211-260 kbps */ +#define FIX_BOTH_1p25_WB_GLOBGAINOFFSET_LOWLIM_NONBE -135 /* 1p25 curve tilt calulation limited to value -135 kbps */ + +#define FIX_BOTH_1p25_TEST_NEW_GG_EST2 /* GG_EST2_will use bands with two coeffs in each instead of four, for 1p25 WB and 1p25 SSWB , note only active for regular, hrmode==0 */ + +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#define FIX_BASOP_1p25_NEW_GG_EST3 /* GG_EST3 , GG_EST2 with optimized code for better BASOP code reuse , less changes to non 1p25ms */ +#define FIX_BOTH_1p25_GG_EST_SWB_FB /* 1.25ms GG_EST update for SWB/FB, better RD curve float and BASOP , active for hrmode==0 */ +#endif + +/* defines to activate 2 or 3 tuple 1.25ms loops for WB,SSWB,SWB,FB */ +#define FIX_1p25_GG_EST_TUPLES /* 1.25 ms GG_EST2_will use 2,3 or 4 , note only active for regular, hrmode==0 */ +#ifdef FIX_1p25_GG_EST_TUPLES +#define GG_1p25_WB_TUPLES 2 +#define GG_1p25_SSWB_TUPLES 2 +#define GG_1p25_SWB_TUPLES 2 +#define GG_1p25_FB_TUPLES 3 +#define GG_1p25_MAX_TUPLES MAX(MAX(GG_1p25_WB_TUPLES ,GG_1p25_SSWB_TUPLES ), MAX(GG_1p25_SWB_TUPLES ,GG_1p25_FB_TUPLES)) /* used to control common energy loop */ +#define FIX_1p25_32kHz_CLANG_WARNING_EST_GAIN + +#ifndef FIX_BOTH_1p25_ALLOC_SPECTRUM +#define FIX_BOTH_1p25_ALLOC_SPECTRUM +#endif + +#define FIX_1p25_FLEX_ITER_TUPLE_LOOP /* energy loop part optimized BASOP only */ +#define LOG2_LC_APPROX /* log2_LC(energy) call BASOP only */ /* only applied to 1p25 ms global gain estimation loop */ +#define FIX_1p25_FLEX_BISECT_LOOP /* bisect optimization BASOP only !! */ + +#endif + +#define FIX_LTPFDEC_BASOP /* added saturation and apply L_max() */ + +/* all 1p25ms precision optimizations */ + +#define FIX_BASOP_ENC_LRSNS_CBC_MSE /* recalculate CB_C MSE to better match CFL cbC vs st2 decision */ +#define FIX_BASOP_ENC_LRSNS_ST2FULL_PROJ /* less optimistic pre-projection for Y_FULL , better match CFL */ + +#define FIX_BASOP_LT_NORMCORR_AR1 /* better exact representation of 0.8 LT normcorr limit */ +#define FIX_BASOP_PREEMPH_CALC /* only1p25ms higher precision in adaptive preemphasis addition , average increase by ~6dB, minSNR increased by ~1dB */ + +#define FIX_SNS_BASOP_MEAN64_CALC /* norm for all energy bands to reduce SCF target variations before log2 domain */ +#ifdef FIX_SNS_BASOP_MEAN64_CALC +#define FIX_SNS_BASOP_NF_APPL /* apply noisefill 1/10000 in the W32*exp energy domain, not in the inexact 1/9998 W16Q9 log2 domain */ +#endif +#define FIX_SNS_BASOP_MEAN16_APPLY /* norm for all 16 scg log2 bands to reduce SCF target variations */ + +#endif + +#ifdef CR9_C_ADD_1p25MS_LRSNS + /*NB CR9_C_ADD_1p25MS_LRSNS requires NEW_SIGNALLING_SCHEME_1p25 */ +#define LRSNS_PC_SIGNAL_FIX /*correct handling of incoming bfi==2 to DEC_ENTROPY for conformance */ +/* #define USE_LC3_OPERATORS */ + +#define LRSNS_10MS_BFISIGNAL_FIX /* correct signaling of detected BER in both 10ms SNS/and in 1.25ms LRSNS */ + +#define LRSNS_ALLZERO_FIX /* BASOP_Util_InvLog2_pos(), incorrect exponent for 2^0, became appearant for an all zero vector in LRSNS CB_A */ +#define LRSNS_MORE_SCRATCH /* set BASOP SCRATCH to max values */ +/* #define LRSNS_CBC_NO_LTPF_DEPENDENCY */ /* turn off LRSNS CB_C dependency on LTPF activation flag */ + +#define SNSLR_N_FIXENV 4 /* 4 fix envelopes multiplexed inside the full codeword */ +#define SNSLR_N_FIXENV_SHIFTS 4 /* 2 bits */ +#define SNSLR_MAX_PVQ_CAND 6 /* splitLF(0), full(1), fixed_env 2+{0,1,2,3 }, */ +#define SNSLR_MAX_PVQ_SEARCH_CAND (SNSLR_MAX_PVQ_CAND-SNSLR_N_FIXENV+1) /* 3 = splitLF(0), full(1), fixed_envs(2), */ +#define SNS_IDX_SHAPEJ 2 /* shape index location */ + +#endif + + +#define FIX_LTPF_PITCH_1p25 +#define FIX_LTPF_MEM_CONTINUATION +#define FIX_LTPF_PITCH_MEM_LEN +#define FIX_PLC_CONFORM_ISSUES +#define FIX_TDC_BURST_ERROR +#define FIX_LTPF_DEC_FLFX_MISMATCH +#define FIX_TX_RX_STRUCT_STEREO +#define NEW_SIGNALLING_SCHEME_1p25 +#define FIX_LTPF_1p25 + +#endif /* CR9_C_ADD_1p25MS */ #endif /* NO_POST_REL_CHANGES Post-release changes */ +#ifdef CR9_C_ADD_1p25MS +#define LEN_MEM_NORMCORR 5 +#else +#define LEN_MEM_NORMCORR 2 +#endif + #define THRESH_100_DMS_TDC_CNT 9 #define THRESH_100_DMS_NS_CNT 7 #define THRESH_100_DMS_TDC_NS_CNT 73 @@ -129,14 +249,14 @@ #define G192_ONE 0x0081 #define READ_G192FER /* allow C executable to also read G192 formatted FER files */ -#ifdef DEBUG +#ifdef DEBUG #ifdef READ_G192FER -#define READ_G192_FER_BYTE /* Allow C executable to also read G192 byte formatted FER files 0x20=BAD , 0x21=Good */ -#endif -#endif +#define READ_G192_FER_BYTE /* Allow C executable to also read G192 byte formatted FER files 0x20=BAD , 0x21=Good */ +#endif +#endif -// #define DYNMEM_COUNT +// #define DYNMEM_COUNT /* conflicts with WMC tool */ #define STAMEM_COUNT @@ -181,6 +301,11 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger #define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ #endif +#ifdef CR9_C_ADD_1p25MS +#define MIN_BR_0125DMS 128000 /* 20 * 800 * 100/ 12.5 */ +#define MAX_BR_0125DMS 512000 +#endif + #define MIN_BR_075DMS_48KHZ_HR ((int)124800/ 800/2)* 800 #define MIN_BR_075DMS_96KHZ_HR ((int)149600/ 800/2)* 800 #define MIN_BR_075DMS 21334 /* ceil( 20 * 800 * 100/ 75) */ @@ -220,7 +345,7 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger #else /* ENABLE_HR_MODE */ #define MAX_RESBITS MAX_LEN #endif /* ENABLE_HR_MODE */ - + /* BW Cutoff-Detection */ #define MAX_BW_BANDS_NUMBER 5 @@ -258,6 +383,18 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger #define MAX_BW_BIN 400 #define FEC_SLOT_BYTES_MIN 40 #define FEC_SLOT_BYTES_MAX 400 +#ifdef CR12_D_FIX_BITRATE_LIMITS +#ifdef ENABLE_HR_MODE +#define FEC_SLOT_BYTES_MIN_025DMS_48KHZ_HR 54 +#define FEC_SLOT_BYTES_MIN_025DMS_96KHZ_HR 61 +#define FEC_SLOT_BYTES_MIN_050DMS_48KHZ_HR 87 +#define FEC_SLOT_BYTES_MIN_050DMS_96KHZ_HR 101 +#define FEC_SLOT_BYTES_MIN_075DMS_48KHZ_HR 110 +#define FEC_SLOT_BYTES_MIN_075DMS_96KHZ_HR 126 +#define FEC_SLOT_BYTES_MIN_100DMS_48KHZ_HR 140 +#define FEC_SLOT_BYTES_MIN_100DMS_96KHZ_HR 164 +#endif +#endif #if MAX_BW_BIN > MAX_LEN #define MAX_BW MAX_LEN #else @@ -289,6 +426,37 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger #define SNS_DAMPING_HRMODE_UB_2_5MS 4915 /* 0.15 in Q15 */ #endif +#ifdef CR9_C_ADD_1p25MS_LRSNS +#define N_SCF_SEARCH_SHAPES_ST2_LR SNSLR_MAX_PVQ_SEARCH_CAND /* {split, full, fix} */ +#define NA_LR 5 +#define NB_LR 8 +#define NC_LR 2 /* the 2 remaining positions also coded by full*/ +#define NFULL_LR (NA_LR+NB_LR+NC_LR) + +#define PULSES_SPLIT_A_LR 6 +#define PULSES_SPLIT_B_LR 2 +#define PULSES_FULL_LR 5 /* 'full'== ABC region */ + +#define N_CANDS_FIX_LR SNSLR_N_FIXENV +#define NSIGNS_FIX_012 12 /* 15-4+1 */ +#define N_SHIFT_FIX SNSLR_N_FIXENV_SHIFTS +#define NSIGNS_FIX_3 (NSIGNS_FIX_012 -2) +#define N_SHIFT_FIX_3 SNSLR_N_FIXENV_SHIFTS + + + +#define SNSLR_NST1 170 /*, 3*170 + 2 = 512 */ +#define SNSLR_NPVQ_L5K6 1970 /* mux into 11 bits 2048 pos , 78 slots remaining, 6 whole bits */ +#define SNSLR_NPVQ_L5K8 5890 /* additional split LF part muxed into 13 bits, log2(5980)= 12.5241 */ +#define SNSLR_NPVQ_L8K2 128 /* 1+6 = 7 bits */ +#define SNSLR_NPVQ_L15K5 207006L /* 1+ 16.6593 bits , */ + +#define SNSLR_A_CNST_WEIGHT 28672 /* 0.875 */ + +#define SNS_VQ_MAX_IDX 8 + +#endif /* CR9_C_ADD_LRSNS */ + /* PVQ VQ setup */ #define VQMODES26 \ ((0 << 4) + (1 << 3) + (1 << 2) + (1 << 1) + \ @@ -355,14 +523,14 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger /* PLC */ #define PLC_FADEOUT_TYPE_1_IN_MS 200 -#define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ +#define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ /* table settings */ #define PLC2_FADEOUT_IN_MS_MIN 30 /* table min */ #define PLC2_FADEOUT_IN_MS_MAX 140 /* table max */ #define PLC2_FADEOUT_RES 10 /* 10 ms steps used in fade tables */ /* current settings */ -#define PLC2_FADEOUT_LONG_IN_MS 120 +#define PLC2_FADEOUT_LONG_IN_MS 120 #define PLC2_FADEOUT_IN_MS 30 /* 0 uses original constants for PLC2 -1 uses TDC::PLC_FADEOUT_IN_MS as basis for a PLC2 macro-re-calculation 30..140 will use a separate settings for PLC2 fadeout @@ -655,35 +823,58 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger #define scratchAlign(ptr, offset) (void *)(((uintptr_t)(ptr) + (offset) + 0x3) & ~0x3) + /* some configurations leave empty translation units. */ extern int fix_empty_translation_unit_warning; #define FIX_IVAS_LC3PLUS_DUPLICATES #ifdef FIX_IVAS_LC3PLUS_DUPLICATES -#define Tab_esc_nb Tab_esc_nb_lc3plus -#define POW_ATT_TABLE0 POW_ATT_TABLE0_lc3plus -#define POW_ATT_TABLE1 POW_ATT_TABLE1_lc3plus -#define InvIntTable InvIntTable_lc3plus -#define SineTable320 SineTable320_lc3plus -#define RotVector_320 RotVector_320_lc3plus -#define RotVector_480 RotVector_480_lc3plus -#define SineWindow20 SineWindow20_lc3plus -#define SineWindow40 SineWindow40_lc3plus -#define SineWindow60 SineWindow60_lc3plus -#define SineWindow80 SineWindow80_lc3plus -#define SineWindow120 SineWindow120_lc3plus -#define SineWindow160 SineWindow160_lc3plus -#define SineWindow180 SineWindow180_lc3plus -#define SineWindow320 SineWindow320_lc3plus -#define BASOP_getTables BASOP_getTables_lc3plus -#define ISqrt16 ISqrt16_lc3plus -#define getScaleFactor16 getScaleFactor16_lc3plus -#define Norm32Norm Norm32Norm_lc3plus -#define Scale_sig Scale_sig_lc3plus -#define Copy_Scale_sig Copy_Scale_sig_lc3plus -#define get_size_mpvq_calc_offset_fx get_size_mpvq_calc_offset_fx_lc3plus -#endif - -#define FIX_IVAS_LC3PLUS_WARNINGS - -#endif +#define abs_s_sat abs_s +#define BASOP_cfft BASOP_cfft_lc3plus +#define BASOP_getTables BASOP_getTables_lc3plus +#define BASOP_Util_Add_Mant32Exp BASOP_Util_Add_Mant32Exp_lc3plus +#define BASOP_Util_Cmp_Mant32Exp BASOP_Util_Cmp_Mant32Exp_lc3plus +#define BASOP_Util_Divide1616_Scale BASOP_Util_Divide1616_Scale_lc3plus +#define BASOP_Util_Divide3216_Scale BASOP_Util_Divide3216_Scale_lc3plus +#define BASOP_Util_InvLog2 BASOP_Util_InvLog2_lc3plus +#define BASOP_Util_Log2 BASOP_Util_Log2_lc3plus +#define Copy_Scale_sig Copy_Scale_sig_lc3plus +#define exp2_tab_long exp2_tab_long_lc3plus +#define exp2w_tab_long exp2w_tab_long_lc3plus +#define exp2x_tab_long exp2x_tab_long_lc3plus +#define get_size_mpvq_calc_offset_fx get_size_mpvq_calc_offset_fx_lc3plus +#define getScaleFactor16 getScaleFactor16_lc3plus +#define getScaleFactor32 getScaleFactor32_lc3plus +#define i_mult DEPR_i_mult +#define Inv16 Inv16_lc3plus +#define InvDiffTable InvDiffTable_lc3plus +#define InvIntTable InvIntTable_lc3plus +#define InvTable InvTable_lc3plus +#define ISqrt16 ISqrt16_lc3plus +#define ISqrtDiffTable ISqrtDiffTable_lc3plus +#define ISqrtTable ISqrtTable_lc3plus +#define L_abs_sat L_abs +#define ldCoeff ldCoeff_lc3plus +#define Norm32Norm Norm32Norm_lc3plus +#define POW_ATT_TABLE0 POW_ATT_TABLE0_lc3plus +#define POW_ATT_TABLE1 POW_ATT_TABLE1_lc3plus +#define RotVector_320 RotVector_320_lc3plus +#define RotVector_480 RotVector_480_lc3plus +#define Scale_sig Scale_sig_lc3plus +#define SineTable320 SineTable320_lc3plus +#define SineWindow120 SineWindow120_lc3plus +#define SineWindow160 SineWindow160_lc3plus +#define SineWindow180 SineWindow180_lc3plus +#define SineWindow20 SineWindow20_lc3plus +#define SineWindow30 SineWindow30_lc3plus +#define SineWindow320 SineWindow320_lc3plus +#define SineWindow40 SineWindow40_lc3plus +#define SineWindow60 SineWindow60_lc3plus +#define SineWindow80 SineWindow80_lc3plus +#define Sqrt16 Sqrt16_lc3plus +#define SqrtDiffTable SqrtDiffTable_lc3plus +#define SqrtTable SqrtTable_lc3plus +#define Tab_esc_nb Tab_esc_nb_lc3plus +#define tnsAcfWindow tnsAcfWindow_lc3plus +#endif /* FIX_IVAS_LC3PLUS_DUPLICATES */ +#endif /* DEFINES_H */ diff --git a/lib_lc3plus/detect_cutoff_warped_fx.c b/lib_lc3plus/detect_cutoff_warped_fx.c index a329a48f6..e57723f7b 100644 --- a/lib_lc3plus/detect_cutoff_warped_fx.c +++ b/lib_lc3plus/detect_cutoff_warped_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,10 +7,12 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" #include "rom_basop_util_lc3plus.h" -void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 frame_dms) +void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, LC3PLUS_FrameDuration frame_dms) { Dyn_Mem_Deluxe_In( @@ -28,28 +30,39 @@ void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_ex const Word16 *warp_idx_start, *warp_idx_stop, *bw_brickwall_dist; ); + warp_idx_start = 0; + warp_idx_stop = 0; + bw_brickwall_dist = 0; + SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + *bw_idx = fs_idx; move16(); + Dyn_Mem_Deluxe_Out(); + return; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: warp_idx_start = BW_warp_idx_start_all_2_5ms[fs_idx - 1]; move16(); warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; move16(); bw_brickwall_dist = BW_brickwall_dist_2_5ms; BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: warp_idx_start = BW_warp_idx_start_all_5ms[fs_idx - 1]; move16(); warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; move16(); bw_brickwall_dist = BW_brickwall_dist_5ms; BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: warp_idx_start = BW_warp_idx_start_all_7_5ms[fs_idx - 1]; move16(); warp_idx_stop = BW_warp_idx_stop_all_7_5ms[fs_idx - 1]; move16(); bw_brickwall_dist = BW_brickwall_dist_7_5ms; BREAK; - default: /* 100 */ + case LC3PLUS_FRAME_DURATION_10MS: warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; move16(); warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; move16(); bw_brickwall_dist = BW_brickwall_dist; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } counter = fs_idx; @@ -75,14 +88,14 @@ void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_ex iBand++; FOR (; iBand <= warp_idx_stop[counter]; iBand++) { - d2_fx_sum = BASOP_Util_Add_Mant32Exp_lc3plus(d2_fx[iBand], d2_fx_exp, d2_fx_sum, d2_fx_sum_exp, &d2_fx_sum_exp); + d2_fx_sum = BASOP_Util_Add_Mant32Exp(d2_fx[iBand], d2_fx_exp, d2_fx_sum, d2_fx_sum_exp, &d2_fx_sum_exp); } /* Energy-sum */ d2_fx_mean = Mpy_32_16_lc3plus(d2_fx_sum, InvIntTable[add(sub(warp_idx_stop[counter], warp_idx_start[counter]), 1)]); d2_fx_mean_exp = d2_fx_sum_exp; move16(); /* check if above threshold */ - nrg_below_thresh = BASOP_Util_Cmp_Mant32Exp_lc3plus(BW_thresh_quiet[counter], BW_thresh_quiet_exp, d2_fx_mean, + nrg_below_thresh = BASOP_Util_Cmp_Mant32Exp(BW_thresh_quiet[counter], BW_thresh_quiet_exp, d2_fx_mean, d2_fx_mean_exp); /* true if firstNumber > secondNumber */ } WHILE (nrg_below_thresh > 0) diff --git a/lib_lc3plus/dynmem.c b/lib_lc3plus/dynmem.c index 9756b123b..9cdac738d 100644 --- a/lib_lc3plus/dynmem.c +++ b/lib_lc3plus/dynmem.c @@ -19,6 +19,8 @@ #define _CRT_SECURE_NO_WARNINGS #endif +#include "options.h" +#include "wmc_auto.h" #include #include #include diff --git a/lib_lc3plus/enc_entropy.c b/lib_lc3plus/enc_entropy.c index c4930fd16..4afac13a4 100644 --- a/lib_lc3plus/enc_entropy.c +++ b/lib_lc3plus/enc_entropy.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" static Word32 ac_enc_mux_st2VQ_cws( /* o: max 25 bits total codeword */ @@ -17,7 +19,11 @@ static Word32 ac_enc_mux_st2VQ_cws( /* o: max 25 bits total void processEncoderEntropy(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 targetBytes, Word16 L_spec, Word16 BW_cutoff_bits, Word16 tns_numfilters, Word16 lsbMode, Word16 lastnz, Word16 *tns_order, Word16 fac_ns_idx, Word16 gg_idx, - Word16 BW_cutoff_idx, Word16 *ltpf_idx, Word32 *L_scf_idx, Word16 bfi_ext, Word16 fs_idx) + Word16 BW_cutoff_idx, Word16 *ltpf_idx, Word32 *L_scf_idx, Word16 bfi_ext, Word16 fs_idx +#ifdef CR9_C_ADD_1p25MS + , LC3PLUS_FrameDuration frame_dms, Word16* Tx_ltpf +#endif + ) { Word16 tmp; Word32 L_tmp; @@ -42,6 +48,8 @@ void processEncoderEntropy(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Wo Dyn_Mem_In("processEncoderEntropy", sizeof(struct _dynmem)); #endif + UNUSED(L_gain_LSB); UNUSED(gain_MSBs); UNUSED(submode_MSB); UNUSED(submode_LSB); UNUSED(L_tmp); + /* Init */ *bp_side = shr_pos(sub(nbbits, 1), 3); *mask_side = shl(1, sub(8, sub(nbbits, shl_pos(*bp_side, 3)))); @@ -56,7 +64,7 @@ void processEncoderEntropy(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Wo } /* Encode last non-zero tuple */ - tmp = sub(14, norm_s(negate(L_spec))); + tmp = getLastNzBits_fx(L_spec); IF (sub(bfi_ext, 1) == 0) { @@ -80,8 +88,25 @@ void processEncoderEntropy(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Wo } /* LTPF on/off*/ +#ifdef CR9_C_ADD_1p25MS +#ifdef NEW_SIGNALLING_SCHEME_1p25 + IF( sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0 ) + { + writeLtpData_fx(ptr, bp_side, mask_side, ltpf_idx, Tx_ltpf); /* LTP-flag and LTPFflag and interleaved lag */ + } + ELSE + { + write_bit_backward(ptr, bp_side, mask_side, ltpf_idx[0]); /* LTP-flag only */ + } +#endif +#else write_indice_backward(ptr, bp_side, mask_side, ltpf_idx[0], 1); +#endif +#ifdef CR9_C_ADD_1p25MS_LRSNS + /* Encode SCF VQ parameters */ + writeSNSData_fx(bytes, bp_side, mask_side, frame_dms, L_scf_idx); +#else /* Encode SCF VQ parameters - 1st stage (10 bits) */ write_indice_backward(ptr, bp_side, mask_side, extract_l(L_scf_idx[0]), 5); /* stage1 LF 5 bits */ write_indice_backward(ptr, bp_side, mask_side, extract_l(L_scf_idx[1]), 5); /* stage1 HF 5 bits */ @@ -135,14 +160,22 @@ void processEncoderEntropy(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Wo write_indice_backward(ptr, bp_side, mask_side, extract_l(L_tmp), 12); /* multiplex 12 bits LSB*/ write_indice_backward(ptr, bp_side, mask_side, extract_l(L_shr(L_tmp, 12)), 12); /* multiplex 12 bits MSBs */ } +#endif /* LTPF data */ - IF (ltpf_idx[0] != 0) +#ifdef NEW_SIGNALLING_SCHEME_1p25 + test(); test(); + IF( (sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) != 0) && (ltpf_idx[0] != 0) ) +#else + test(); + IF( ltpf_idx[0] != 0 ) +#endif { - write_indice_backward(ptr, bp_side, mask_side, ltpf_idx[1], 1); - write_indice_backward(ptr, bp_side, mask_side, ltpf_idx[2], 9); + write_indice_backward(ptr, bp_side, mask_side, ltpf_idx[1], 1); + write_indice_backward(ptr, bp_side, mask_side, ltpf_idx[2], 9); } + /* Encoder noise-fac */ write_indice_backward(ptr, bp_side, mask_side, fac_ns_idx, 3); @@ -171,3 +204,335 @@ ac_enc_mux_st2VQ_cws( /* o: max 25 bits total codeword */ return L_cwTx; } + +#ifdef NEW_SIGNALLING_SCHEME_1p25 +void writeLtpData_fx( + UWord8 *ptr, + Word16 *bp_side, + Word16 *mask_side, + Word16* ltpf_idx, + Word16* Tx_ltpf +) +{ + Dyn_Mem_Deluxe_In( + Word16 tmp; + Word16 bitsTx;); + + tmp = s_min(*Tx_ltpf, 1); /*phaseA==0, phaseB==1*/ + test(); + IF(ltpf_idx[0] == 0) + { + write_indice_backward(ptr, bp_side, mask_side, 0, 2); /* "00" */ + + *Tx_ltpf = 0; + /* *Tx_ltpf A/B state forced to zero or kept at zero */ + /* decoder will discard any sofar in phase received phaseA MSB bits */ + } + ELSE IF(ltpf_idx[1] == 0) + { + /* no current LTPF activation, + lag transmitted for PLC, or for next frame LTPF activation */ + ASSERT(ltpf_idx[0] != 0); + + /* A "010" 3 bits Hdr transmitted */ + /* B "011" 3 bits Hdr transmitted*/ + + write_indice_backward(ptr, bp_side, mask_side, 1, 2); /* "01"*/ + write_indice_backward(ptr, bp_side, mask_side, tmp, 1); /* phase A or phaseB */ + + test(); + IF(*Tx_ltpf == 0) + { /* phase A transmission */ + ASSERT(tmp == 0); + ASSERT((ltpf_idx[2] & ~(0x01ff)) == 0); /* only 9 bits info allowed within ltpf_idx[2] */ + tmp = shr_pos(ltpf_idx[2], 5); /* shift_out LSBS, send 4 MSBs */ + *Tx_ltpf = s_or(0x200, ltpf_idx[2]); move16(); /* remember full lag, as phaseB sentinel in bit 10, */ + } + ELSE + { /* phase B */ + ASSERT(tmp == 1); + ASSERT(*Tx_ltpf > 511); /*sentinel in b10 should have been set in previous phaseA frame */ + tmp = shr_pos(s_and(*Tx_ltpf, 0x001f), 1); /* B send 4* LSBs, 1 bit truncated */ + *Tx_ltpf = 0; move16(); /* clear sentinel in b10 and the old remebered lag value */ + } + write_indice_backward(ptr, bp_side, mask_side, tmp, 4); /* 4 bits lag info Tx, when LTPF is deactivated */ + } + ELSE + { /* LTPF activated */ + /* A "10" 2 bits Hdr */ + /* B "11" 2 bits Hdr */ + ASSERT(ltpf_idx[0] != 0 && ltpf_idx[1] != 0); + + tmp = s_or(0x02, tmp); + write_indice_backward(ptr, bp_side, mask_side, tmp, 2); + test(); + IF(*Tx_ltpf == 0) + { + bitsTx = 4; move16(); + ASSERT((ltpf_idx[2] & ~(0x01ff)) == 0); /* only 9 bits info allowed within ltpf_idx[2] */ + tmp = shr_pos(ltpf_idx[2], 5); /* shift away 5 LBS, LTPF active, send phaseA 4 MSBs */ + + *Tx_ltpf = s_or(0x0200, ltpf_idx[2]); /* remember full lag in state *Tx_ltpf, add phaseB Tx state sentinel in bit 10 */ + } + ELSE + { + bitsTx = 5; move16(); + tmp = s_and(*Tx_ltpf, 0x001f); /* LTPF active B send 5 LSBs , full regular resolution */ + *Tx_ltpf = 0; move16(); /* clear sentinel in b10 and also the old remebered lag value */ + } + + write_indice_backward(ptr, bp_side, mask_side, tmp, bitsTx); /* ltp==1 , ltpf==1, 4(A,MSBs) or 5(b, LSBs) bits */ + } + Dyn_Mem_Deluxe_Out(); +} + + +void writeSNSData_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, LC3PLUS_FrameDuration frame_dms, Word32* L_scf_idx) +{ + Dyn_Mem_Deluxe_In( + Word16 submode_LSB, submode_MSB, gain_MSBs; + Word32 L_gain_LSB; + Word16 write_legacy_sns_vq_bits; + Word16 tmp; + Word32 L_tmp; + Word16 aux_idx; /* aux value: location the LS, or the s0 sign bit */ + Word16 shape_idx; /* st2 shape 0 .. 5 , where [2.3.4.5] are fixed FESS shapes */ + Word16 fixenv_shape_idx; + Word16 gain_idx; /* idx of 2-3 bits valued gains */ + Word16 n5k; /* number of unit pulses k for the width N=5 LF region of splitLF */ + ); + + write_legacy_sns_vq_bits = 1; + if (sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) /* 9,10,29/30 */ + { + write_legacy_sns_vq_bits = 0; + } + + test(); + IF(write_legacy_sns_vq_bits != 0) /* 10 bits (5+5) for stage1 + a total of 28 bits for stage2 */ + { + /* Encode SCF VQ parameters - 1st stage (10 bits) */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_scf_idx[0]), 5); /* stage1 LF 5 bits */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_scf_idx[1]), 5); /* stage1 HF 5 bits */ + + /* Encode SCF VQ parameters - 2nd stage side-info (3-4 bits) */ + submode_MSB = shr_pos(extract_l(L_scf_idx[2]), 1); /* explicit tx */ + write_bit_backward(bytes, bp_side, mask_side, submode_MSB); /* submode MSB 1 explicit bit */ + submode_LSB = s_and(extract_l(L_scf_idx[2]), 0x1); /* for joint coding with shapeCw */ + gain_MSBs = extract_l(L_scf_idx[3]); /* all gain bits */ + L_gain_LSB = L_and(L_scf_idx[3], 0x1L); + gain_MSBs = shr(gain_MSBs, sns_gainLSBbits[L_scf_idx[2]]); + + ASSERT(gain_MSBs >= 0 && gain_MSBs < (1 << sns_gainMSBbits[L_scf_idx[2]])); /* ASSERT max 2 MSB(s) in gain bits */ + + write_indice_backward(bytes, bp_side, mask_side, gain_MSBs, + sns_gainMSBbits[L_scf_idx[2]]); /* adjgain or MSBs of adjGains 1-2 bits */ + write_bit_backward(bytes, bp_side, mask_side, extract_l(L_scf_idx[4])); /* shape LS 1 bit */ + + /* Encode SCF VQ parameters - 2nd stage data (24-25 bits) */ + test(); + IF(submode_MSB == 0) + { /* regular,regular_lf*/ + ASSERT(submode_MSB == 0); + + L_tmp = L_add(L_gain_LSB, 0); /* gain-LSB 0,1 for regular_lf, offset is 0 */ + if (submode_LSB == 0) + { + L_tmp = L_add(L_scf_idx[6], + sns_MPVQ_Sz[1][1]); /* shape B pos offset is 2 , upshifted two positions , 0..11 -> 2..13 */ + } + /* regular mode A,B indexes multiplexed, total 24.x bits MPVQ codeword section A + codeword for section B */ + L_tmp = ac_enc_mux_st2VQ_cws(sns_MPVQ_Sz[0][0], /* max 21.3 bits*/ + UL_addNsD(sns_MPVQ_Sz[0][1], sns_MPVQ_Sz[1][1]), /* max log2(14) bits */ + L_scf_idx[5] /* shapeA */, L_tmp /* shapeB joint with adjGainLSB */); + /* regular mode mode shape index total 1+23.9999 bits MPVQ codeword */ + ASSERT(L_tmp < (1L << 25)); + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_tmp), 13); /* multiplex 13 bits */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_shr_pos(L_tmp, 13)), 12); /* multiplex 12 bits */ + } + ELSE + { /* outlier near, outlier far */ + ASSERT(submode_MSB == 1); + L_tmp = L_scf_idx[5]; + move32(); /* outlier near section assumed */ + if (submode_LSB != 0) + { /* outl_far */ + L_tmp = L_add(L_shl_pos(L_tmp, 1), L_gain_LSB); /* add lsb bit of Gain */ + L_tmp = L_add(L_tmp, sns_MPVQ_Sz[2][0]); /* outlier far section offset added */ + } + + ASSERT(L_tmp < (1L << 24)); + /* outlier mode shape index total 23.8536 ( + ~.14 ) bits as MPVQ codeword */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_tmp), 12); /* multiplex 12 bits LSB*/ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_shr(L_tmp, 12)), 12); /* multiplex 12 bits MSBs */ + } + } + + test(); + IF(write_legacy_sns_vq_bits == 0) /* 9 or 10 bits for stage1, 19-20 bits for stage2 */ + { + /* SNS-VQ 1st stage is jointly multiplexed into 9 bits or 10 bits */ + /* input scf_idx[0], has the stage1 index for one of BCA , if B+stage 1 only */ + tmp = extract_l(L_scf_idx[0]); + aux_idx = extract_l(L_scf_idx[1]); /* aux value: we have the LS, or the s0 sign bit */ + shape_idx = extract_l(L_scf_idx[2]); /* st2 shape 0 .. 5 , where [2.3.4.5] are fixed FESS shapes */ + gain_idx = extract_l(L_scf_idx[3]); /* idx of 2-3 bits valued gains */ + +#ifdef DEBUG + if (shape_idx == 0 && L_scf_idx[0] >= 0) + { /*aux==2 --> split mode st1B (aux==2), + a 2 bit gain + P(5,6)10.96b + P(8,2)7b */ + ASSERT(shape_idx == 0 && gain_idx < 4); + } + if ((shape_idx == 1) && L_scf_idx[0] >= 0) + { /* regular mode st1B , + a 3 bit gain + P(15,5) */ + ASSERT(shape_idx == 1 && gain_idx >= 0 && gain_idx < 8); + } + + if ((shape_idx >= 2) && L_scf_idx[0] >= 0) + { /* regular mode st1B , + a 3 bit gain + fixenv */ + ASSERT(shape_idx >= 2 && shape_idx <= 5 && gain_idx >= 0 && gain_idx < 8); + } +#endif + /* b0-b8 b9 + segm , idx9b , stop bit, comment use + -----+--------+--------- + A | 510,511| n/a, 2 entries, 9 bit total + ------+--------+-------- + B | 0--169 | 1 , 170 entries, 10 bit total + ------+--------+-------- + C | 170-339| 1 , 170 entries, 10 bit total + ------+--------+--------+------------*/ + + test(); test(); test(); test(); + IF(L_sub(L_scf_idx[0], 510) >= 0) + { /* stage1A */ + ASSERT(L_scf_idx[0] < (1 << 9)); + write_indice_backward(bytes, bp_side, mask_side, tmp, 9); /* writes values 510 or 511 */ + shape_idx = -9; move16(); /* use only the coarse stage 1A , no more bits to send */ + } + ELSE IF((sub(tmp, 2 * 170) < 0) && (shape_idx < 0)) + { + write_indice_backward(bytes, bp_side, mask_side, tmp, 9); /* 1B [ 0..169] or 1C [ 170 ... 339 ] */ + + /* write the stop bit sentinel value "1", so that the demux dec_entropy_fx) can stop already at (9+1)=10 bits */ + write_indice_backward(bytes, bp_side, mask_side, 1, 1); /* dec_entropy_fx() will read this a 1 "stop" bit */ + shape_idx = -10; move16(); + } + ELSE IF(shape_idx == 0) { + /* aux info as a part of (9+1) 10 initial bits */ + /* b0-b8 b9 + segm , idx9b , stop bit, comment use + -----+--------+--------- + B* | 0--169 | 0 , --> aux=0, 170, 2b+17b for stage2 'LR_SplitLF', 29 bit total + ------+--------+--------+------- + B* | 170-339| 0 , --> aux=1, 170, 2b+17b for stage2 'LR_SplitLF', 29 bit total + ------+--------+--------+------- + */ + /* 29 bit total LR_splitLF */ +#ifdef DEBUG + ASSERT(L_scf_idx[0] >= 0 && L_scf_idx[0] < 170); /* st1B range */ + ASSERT(aux_idx >= 0 && aux_idx <= 1); /* aux_bit can only be 1 or 0 */ +#endif + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_mac0(L_scf_idx[0], aux_idx, 170)), 9); /* aux_bit defined by region 0.169 or 170..339 in decoder */ + write_indice_backward(bytes, bp_side, mask_side, 0, 1); /* "stop" bit. always zero for 'LR_splitLF' path */ + + write_indice_backward(bytes, bp_side, mask_side, gain_idx, 2); /* always 2bits == 4 gain levels for the splitLF mode */ + + n5k = 6; move16(); + test(); + if (L_scf_idx[5] < 0) + { + ASSERT(L_scf_idx[5] == -8); + n5k = 8; move16(); /* 8 LF pulses , no HF pulses */ + } + + test(); + IF(sub(n5k, 6) == 0) + { /* multiplex remaining 10 + 1+6 bit */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_scf_idx[4]), 10); /* P(5,6)=10.94 in LS+10 bits, */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_and(L_scf_idx[5], 0x1)), 1); /* LS for P(8,2)=7 */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_shr_pos(L_scf_idx[5], 1)), 6); /* mPVQ(8,2) in 6 */ + } + ELSE + { /* LF is PVQ(N=5,K=8), HF is all zero , multiplexed as top section in stage2 10b , + 7b */ + /* scf_idx[4] is in the range [0 ... (SNSLR_NPVQ_L5K8 >>1)[, [0 .. 2945[ , 11.52 bits */ + /* 985 - 1024 = 39 entries where we now use 32 (5 bits) */ + /* index_to_send = (SNSLR_NPVQ_L5K6 >> 1) + (scf_idx[4] & 0x001f) , range [985 .. 1017[ , i.e. 7 values are not sent:[1018 ... 1023] */ + ASSERT(L_scf_idx[4] < (SNSLR_NPVQ_L5K8 >> 1)); + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_add((SNSLR_NPVQ_L5K6 >> 1), L_and(L_scf_idx[4], 0x001f))), 10); /* 5 lsb's as top in the 10b block*/ + ASSERT((L_scf_idx[4] >> 5) < (1 << 7)); + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_shr_pos(L_scf_idx[4], 5)), 7); /* 7 msb's of mpvq(5,8)*/ + /* unused region of 7*2^7 = 1792= 10.8 bits may be used for BER detection */ + } + } + ELSE IF(shape_idx == 1) + { + /* b0-b8 b9 + segm , idx9b , stop bit, comment/use + ------+--------+--------+------------ + B* | 340-509| 1 --> aux=1, 170, 3b+17b for stage2 'LR_full', 30 bit total + ------+--------+--------+------- + B* | 340-509| 0 --> aux=0, 170, 3b+17b for stage2 'LR_full', 30 bit total + ------+--------+--------+------- + */ + ASSERT(L_scf_idx[0] >= 0 && L_scf_idx[0] < 170); /* validate st1B* range */ + + write_indice_backward(bytes, bp_side, mask_side, add(tmp, 2 * 170), 9); /* stage1B* signal */ + write_indice_backward(bytes, bp_side, mask_side, aux_idx, 1); /* auxbit value transmitted in the stop bit location */ + + write_indice_backward(bytes, bp_side, mask_side, gain_idx, 3); /* 30b always 8 gain levels in 3 bits for the full mode */ + /* the next 17 bit index is used to decode submode 1==full or one of submode 2,3,4,5 == fix */ + ASSERT(L_scf_idx[4] >= 0 && L_scf_idx[4] < ((SNSLR_NPVQ_L15K5 >> 1))); + + L_tmp = L_scf_idx[4]; move32(); /* full 17 bit index */ + /* typically P(15,5) without the leading sign, 16.6593 bits, written */ + /* subset of 7 lsb's written first to match Cflt writing of all 17 bits at once */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_tmp), 17 - 10); + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_shr_pos(L_tmp, 7)), 10); + } + ELSE + { /* Fixed shapes 2(fixenv0) and 3(fixenv1) , 4(fixenv2), 5(fixenv3) */ + ASSERT(shape_idx >= 2 && shape_idx <= 5); + /* fixenv 0,1,2, : s0(in aux) + shift(2bits)+ 11 signs , section size 8192 + fixenv 3 : s0(in aux) + shift(2bits)+ 9 signs , section size 2048 + */ + fixenv_shape_idx = extract_l(L_scf_idx[4]); + ASSERT(fixenv_shape_idx == (shape_idx - 2)); /* scf_idx[4] has the fixed env index*/ + ASSERT(L_scf_idx[0] >= 0 && L_scf_idx[0] < 170); /* validate st1B* range */ + + write_indice_backward(bytes, bp_side, mask_side, add(tmp, 2 * 170), 9); /* stage1B* signal */ + write_indice_backward(bytes, bp_side, mask_side, aux_idx, 1); /* auxbit transmitted in the stop bit location */ + + write_indice_backward(bytes, bp_side, mask_side, gain_idx, 3); /* for this 30bit path it is always 3 gain bits */ + + IF(sub(shape_idx, 5) < 0) /* 2,3,4 */ + { + ASSERT(L_scf_idx[5] >= 0 && L_scf_idx[5] < (1 << 13)); + ASSERT((SNSLR_NPVQ_L15K5 >> 1) + fixenv_shape_idx * (1 << 13) + L_scf_idx[5] < (1 << 17)); + /* offset is PVQ(15,5) without leading sign */ + /* int32_t tmp_idx = (SNSLR_NPVQ_L15K5 >> 1) + env_shape_idx * (1 << 13) + scf_idx[5]; */ + L_tmp = L_add(L_mac0((SNSLR_NPVQ_L15K5 >> 1), fixenv_shape_idx, 1 << 13), L_scf_idx[5]); /* full 17 bits*/ + } + ELSE + { + ASSERT(shape_idx == 5); /* 5*/ + ASSERT(fixenv_shape_idx == 3); + ASSERT(L_scf_idx[5] < (1 << 11)); + ASSERT(((SNSLR_NPVQ_L15K5 >> 1) + 3 * (1 << 13) + L_scf_idx[5]) < (1 << 17)); + /* offset is PVQ(15,5) without leading sign */ + L_tmp = L_add((SNSLR_NPVQ_L15K5 >> 1) + 3 * (1 << 13), L_scf_idx[5]); /* full 17 bits*/ + } + /* subset of 7 lsb's written first to match Cflt writing of all 17 bits at once */ + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_tmp), 17 - 10); + write_indice_backward(bytes, bp_side, mask_side, extract_l(L_shr_pos(L_tmp, 7)), 10); + } + } + Dyn_Mem_Deluxe_Out(); +} +#endif /* CR9_C_ADD_1p25MS_LRSNS */ + + + +#ifdef __cplusplus +} /* NAMESPACE_VERSION */ +#endif diff --git a/lib_lc3plus/enc_lc3.c b/lib_lc3plus/enc_lc3plus.c similarity index 76% rename from lib_lc3plus/enc_lc3.c rename to lib_lc3plus/enc_lc3plus.c index a5b8fabfd..2658ac6bb 100644 --- a/lib_lc3plus/enc_lc3.c +++ b/lib_lc3plus/enc_lc3plus.c @@ -1,14 +1,15 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * * estoppel or otherwise. * ******************************************************************************/ - +#include "options.h" +#include "wmc_auto.h" +#include #include "functions.h" -#include // ToDo: probably to be removed static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_sample, Word32 *s_in, UWord8 *bytes, Word8 *scratchBuffer, int bfi_ext) @@ -36,7 +37,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ Word32 * s_in_scaled; Word16 * s_in_scaled_lp; UWord8 * resBits; - Word16 ltpf_idx[3]; + Word16 ltpf_idx[3]; EncSetup * h_EncSetup; Word8 * currentScratch; Word16 hrmode; @@ -52,13 +53,54 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ Word16 * scf, *scf_q; Word16 * codingdata; Word16 * s_in_scaled; UWord8 * resBits; Word8 * currentScratch; Word16 ltpf_idx[3]; EncSetup * h_EncSetup;); #endif /* ENABLE_HR_MODE */ - + +#ifdef CR9_C_ADD_1p25MS_LRSNS + Word16 envelope_bits_fx; + Word16 pitch_rx_fx; + Word16 ltpf_rx_fx; + Word16 lrsns_st1C_in_use ; + Word16 ltptx_lowest_bit_lim; +#endif + +#ifdef CR9_C_ADD_1p25MS_LRSNS + envelope_bits_fx = -1; /*later move up to Dynmem() struct area */ +#endif h_EncSetup = encoder->channel_setup[channel]; - -#ifdef ENABLE_HR_MODE + +#ifdef ENABLE_HR_MODE hrmode = encoder->hrmode; #endif + +#ifndef FIX_1p25_GG_EST_TUPLES + +#if defined (FIX_BASOP_ENC_QUANTIZE_1P25MS_512KBPS) + /* make sure the initial allocated d_fx buffer size is a multiple of 4 */ + /* ms_mode Fs frame_length frame_ylen misc */ + /* 1.25ms 16 kHz 20/2=10 same 2-tuples */ + /* 1.25ms 24kHz 30/2=15 same 2-tuples action in estimate_global_gain() */ + /* 1.25ms 32kHz 40/2=10 same 2-tuples */ + /* 1.25ms 48kHz 60/3=20 50/3=16.66 3-tuples, 60/3 =15 allocated , separate action in estimate_global_gain(), 50==60*40/48 */ + /* 2.5 ms 8 kHz 20/4=5 same 4-tuples */ + + Word16 lg_4 = shr(encoder->frame_length, 2); + Word16 rem_4 = sub(encoder->frame_length, shl(lg_4, 2)); + if (rem_4 != 0 && sub(encoder->frame_length, encoder->yLen) == 0) + { + lg_4 = add(lg_4, 1); /* add one quadruple */ + ASSERT(encoder->frame_dms == LC3PLUS_FRAME_DURATION_1p25MS); + ASSERT(MAX_LEN >= lg_4 * 4 ); /* "en" size in estimate_global_gain_fx() */ + } +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + if(encoder->frame_dms == LC3PLUS_FRAME_DURATION_1p25MS && (sub(encoder->frame_length, 30) <= 0)) /* WB and SSWB */ + { + ASSERT(MAX_LEN >= 2 + lg_4 * 4); /*make sure that there are 2 extra tail coeffs in d_fx*/ + } +#endif +#endif +#endif + + #ifdef WMOPS push_wmops("Encoder"); #endif @@ -67,6 +109,14 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ d_fx = scratchAlign(scratchBuffer, 0); /* Size = 4 * MAX_LEN bytes */ L_scf_idx = scratchAlign( d_fx, sizeof(*d_fx) * s_max(80, encoder->frame_length)); /* Size = 4 * SCF_MAX_PARAM -> aligned to 32 bytes */ + +#ifdef FIX_1p25_GG_EST_TUPLES + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + ASSERT(MAX(80, encoder->frame_length) >= ((GG_1p25_MAX_TUPLES - 1) + encoder->yLen)); + /*make sure that there are extra tail coeffs in d_fx for Global gain estimation routine */ + } +#endif indexes = scratchAlign(L_scf_idx, sizeof(*L_scf_idx) * SCF_MAX_PARAM); /* Size = 2 * TNS_NUMFILTERS_MAX * MAXLAG = 32 bytes */ @@ -75,7 +125,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #else q_d_fx16 = scratchAlign(indexes, sizeof(*indexes) * (TNS_NUMFILTERS_MAX * MAXLAG)); /* Size = 2 * MAX_LEN bytes */ #endif /* ENABLE_HR_MODE */ - + #ifdef ENABLE_HR_MODE codingdata = scratchAlign(q_d_fx24, sizeof(*q_d_fx24) * s_max(80, encoder->frame_length)); /* Size = 3 * MAX_LEN bytes */ @@ -83,7 +133,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ codingdata = scratchAlign(q_d_fx16, sizeof(*q_d_fx16) * s_max(80, encoder->frame_length)); /* Size = 3 * MAX_LEN bytes */ #endif - + #ifdef ENABLE_HR_MODE ener_fx = scratchAlign(q_d_fx24, 0); /* Size = 4 * MAX_BANDS_NUMBER = 256 bytes */ s_in_scaled = scratchAlign(q_d_fx24, 0); /* Size = 2 * MAX_LEN bytes */ @@ -91,7 +141,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ ener_fx = scratchAlign(q_d_fx16, 0); /* Size = 4 * MAX_BANDS_NUMBER = 256 bytes */ s_in_scaled = scratchAlign(q_d_fx16, 0); /* Size = 2 * MAX_LEN bytes */ #endif - + #ifdef ENABLE_HR_MODE s_in_scaled_lp = (Word16 *)s_in_scaled; #endif @@ -166,7 +216,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* currentScratch Size = 4 * MAX_LEN */ processMdct_fx(s_in_scaled, h_EncSetup->x_exp, encoder->frame_length, #ifdef ENABLE_HR_MODE - hrmode, + hrmode, #endif encoder->W_fx, encoder->W_size, h_EncSetup->stEnc_mdct_mem, encoder->stEnc_mdct_mem_len, d_fx, &d_fx_exp, currentScratch); @@ -181,7 +231,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* currentScratch Size = 2.25 * MAX_LEN bytes */ #ifdef ENABLE_HR_MODE downshift_w32_arr(s_in_scaled, s_in_scaled_lp, 16, encoder->frame_length); /* s_in_scaled is no longer required */ - + process_resamp12k8_fx(s_in_scaled_lp, encoder->frame_length, h_EncSetup->r12k8_mem_in, encoder->r12k8_mem_in_len, h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, encoder->r12k8_mem_out_len, s_12k8, &s_12k8_len, encoder->fs_idx, encoder->frame_dms, currentScratch @@ -203,7 +253,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif /* currentScratch Size = 392 bytes */ process_olpa_fx(&h_EncSetup->olpa_mem_s6k4_exp, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, &pitch, - s_12k8, s_12k8_len, &normcorr, &h_EncSetup->olpa_mem_pitch, + s_12k8, s_12k8_len, &normcorr, &h_EncSetup->olpa_mem_pitch, &h_EncSetup->pitch_flag, h_EncSetup->resamp_exp, encoder->frame_dms, currentScratch); #ifdef WMOPS @@ -216,10 +266,22 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* currentScratch Size = 512 bytes */ process_ltpf_coder_fx(<pf_bits, pitch, h_EncSetup->ltpf_enable, &h_EncSetup->ltpf_mem_in_exp, h_EncSetup->ltpf_mem_in, encoder->ltpf_mem_in_len, ltpf_idx, s_12k8, s_12k8_len, - &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_mem_normcorr, normcorr, + h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_mem_normcorr, normcorr, &h_EncSetup->ltpf_mem_ltpf_on, &h_EncSetup->ltpf_mem_pitch, h_EncSetup->resamp_exp, - encoder->frame_dms, currentScratch, - encoder->hrmode + encoder->frame_dms, currentScratch + , encoder->hrmode + +#ifdef CR9_C_ADD_1p25MS +#ifdef FIX_TX_RX_STRUCT_STEREO +#ifdef NEW_SIGNALLING_SCHEME_1p25 + ,&h_EncSetup->Tx_ltpf +#else + ,h_EncSetup->Tx_ltpf +#endif +#else + , encoder->Tx_ltpf +#endif +#endif ); #ifdef WMOPS pop_wmops(); @@ -238,7 +300,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #ifdef WMOPS pop_wmops(); #endif - + /* begin ener_fx */ #ifdef WMOPS push_wmops("PerBandEnergy"); @@ -311,20 +373,57 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* currentScratch Size = 512 bytes */ processSnsComputeScf_fx(ener_fx, ener_fx_exp, encoder->fs_idx, encoder->bands_number, scf, h_EncSetup->attdec_detected, encoder->attdec_damping, currentScratch, encoder->sns_damping +#ifdef CR9_C_ADD_1p25MS + , encoder->frame_dms, normcorr, &encoder->LT_normcorr +#endif ); + #ifdef WMOPS pop_wmops(); #endif + +#ifdef CR9_C_ADD_1p25MS_LRSNS + IF(sub(encoder->frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + pitch_rx_fx = ltpf_idx[0]; /* pitch_rx status flag */ + ltpf_rx_fx = ltpf_idx[1]; /* ltpf_activation used in snslr_st1C mode */ + + +#ifdef WMOPS + push_wmops("EncLC3_SnsQuantScfEncLR_fx"); +#endif + envelope_bits_fx = snsQuantScfEncLR_fx( + scf, /* input scf is always Word16 Q11 (both for ENABLE_HR and DISABLE_HR) */ + L_scf_idx, /* output: to send to enc_entropy_fx() */ + scf_q, /* output: Word32(for ENABLE_HR) or Word16 (for DISABLE_HR ) */ + pitch_rx_fx, ltpf_rx_fx, /* input: pitch information to st1C */ + currentScratch); +#ifdef WMOPS + pop_wmops(); +#endif + + } + ELSE + { +#ifdef WMOPS + push_wmops("SnsQuantScfEnc38bit"); +#endif + processSnsQuantizeScfEncoder_fx(scf, L_scf_idx, scf_q, currentScratch); +#ifdef WMOPS + pop_wmops(); +#endif + } +#else #ifdef WMOPS push_wmops("SnsQuantScfEnc"); #endif /* currentScratch Size = 500 bytes */ - processSnsQuantizeScfEncoder_fx(scf, L_scf_idx, scf_q, currentScratch); #ifdef WMOPS pop_wmops(); #endif +#endif /* CR9_C_ADD_1p25MS_LRSNS */ #ifdef WMOPS push_wmops("SnsInterpScfEnc"); @@ -360,7 +459,11 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif /* currentScratch Size = 2 * MAX_LEN + 220 */ +#ifdef CR9_C_ADD_1p25MS + IF (h_EncSetup->lfe == 0 && encoder->frame_dms > LC3PLUS_FRAME_DURATION_1p25MS) +#else IF (h_EncSetup->lfe == 0) +#endif { processTnsCoder_fx(&(h_EncSetup->tns_bits), indexes, d_fx, BW_cutoff_idx, tns_order, &tns_numfilters, h_EncSetup->enable_lpc_weighting, encoder->nSubdivisions, encoder->frame_dms, @@ -368,13 +471,18 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #ifdef ENABLE_HR_MODE , encoder->hrmode #endif - , encoder->near_nyquist_flag + , encoder->near_nyquist_flag ); } ELSE { tns_numfilters = 1; move16(); +#ifdef CR9_C_ADD_1p25MS + IF (encoder->frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) { + tns_numfilters = 0; move16(); + } +#endif tns_order[0] = 0; move16(); h_EncSetup->tns_bits = tns_numfilters; @@ -390,20 +498,59 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* currentScratch Size = 4 * MAX_LEN bytes */ h_EncSetup->targetBitsQuant = sub(h_EncSetup->targetBitsInit, add(h_EncSetup->tns_bits, ltpf_bits)); +#ifdef CR9_C_ADD_1p25MS_LRSNS + IF( sub(encoder->frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0 ) + { /* adjust(==reduce) target bits based on the selected LRSNS-VQ bitrate */ + + h_EncSetup->targetBitsQuant = add(h_EncSetup->targetBitsQuant, 38); /* legacy 38bits was already pre-subtracted in h_EncSetup->targetBitsInit setup */ + ASSERT(envelope_bits_fx >= 9 && envelope_bits_fx <= 30); + h_EncSetup->targetBitsQuant = sub(h_EncSetup->targetBitsQuant, envelope_bits_fx); /* 9,10, 29,30, subtract actual LRSNS bitrate */ + } +#endif + test(); +#ifdef CR9_C_ADD_1p25MS_LRSNS + /* incoming (state based) ltpf_bits for tranmission set in function ltpf_coder_fx() */ + test(); test(); + lrsns_st1C_in_use = 0; move16(); + /* LRSNS stage1C use 10 bits and ltp/ltpf active flags , i.e. one can thus not always disable/steal the ltp/ltpf flags */ + if ( (sub(encoder->frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) && (sub(envelope_bits_fx, 10) == 0) && (L_sub(L_scf_idx[0], 170L) > 0) ) + { + ASSERT(L_scf_idx[0] < (2 * 170) && (L_scf_idx[1] != 0) ); + lrsns_st1C_in_use = 1; move16(); + } + + ltptx_lowest_bit_lim = 1; move16(); + if ( sub(encoder->frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0 ) + { + ltptx_lowest_bit_lim = lrsns_ltp_bits_fx[0]; move16(); + } + test(); test(); test(); test(); + + /* allow cut away of LTP-active, ltpf-active, lag-index (including phase A, B) info when possible and not actually in use by LRSNS-VQ */ + + IF((h_EncSetup->targetBitsQuant < 0) && (sub(ltpf_bits, ltptx_lowest_bit_lim) > 0) && (lrsns_st1C_in_use == 0)) +#else IF (h_EncSetup->targetBitsQuant < 0 && sub(ltpf_bits, 1) > 0) +#endif { /* Disable LTPF */ h_EncSetup->ltpf_mem_ltpf_on = 0; move16(); ltpf_idx[1] = 0; move16(); +#ifdef CR9_C_ADD_1p25MS_LRSNS + ASSERT( (ltpf_bits-ltptx_lowest_bit_lim) > 0 ); + h_EncSetup->targetBitsQuant = add(h_EncSetup->targetBitsQuant, sub(ltpf_bits, ltptx_lowest_bit_lim)); move16(); /* subtract saving */ + ltpf_bits = ltptx_lowest_bit_lim; move16(); +#else ltpf_bits = 1; move16(); h_EncSetup->targetBitsQuant = sub(h_EncSetup->targetBitsInit, add(h_EncSetup->tns_bits, ltpf_bits)); +#endif } - + #ifdef ENABLE_HR_MODE Word32 gain32; #endif - + processEstimateGlobalGain_fx(d_fx, d_fx_exp, encoder->yLen, h_EncSetup->targetBitsQuant, #ifdef ENABLE_HR_MODE &gain32, @@ -416,13 +563,17 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ currentScratch #ifdef ENABLE_HR_MODE , encoder->hrmode, h_EncSetup->regBits, encoder->frame_dms +#else +#if defined(FIX_BOTH_1p25_TEST_NEW_GG_EST2) || defined (FIX_1p25_GG_EST_TUPLES) + , encoder->frame_dms +#endif #endif ); #ifdef WMOPS pop_wmops(); #endif /* begin q_d_fx16 */ - + #ifdef WMOPS push_wmops("Quant. 1"); #endif @@ -430,7 +581,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ processQuantizeSpec_fx(d_fx, d_fx_exp, gain32, gain_e, q_d_fx24, encoder->yLen, h_EncSetup->targetBitsQuant, h_EncSetup->targetBitsAri, &h_EncSetup->mem_specBits, &nBits, encoder->fs_idx, &lastnz, codingdata, &lsbMode, -1, encoder->hrmode); - + #else processQuantizeSpec_fx(d_fx, d_fx_exp, gain, gain_e, q_d_fx16, encoder->yLen, h_EncSetup->targetBitsQuant, h_EncSetup->targetBitsAri, &h_EncSetup->mem_specBits, &nBits, encoder->fs_idx, &lastnz, @@ -496,6 +647,9 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ gain_e, encoder->yLen, h_EncSetup->targetBitsQuant, nBits, resBits, &numResBits #ifdef ENABLE_HR_MODE , encoder->hrmode +#endif +#if defined (CR9_C_ADD_1p25MS) + , encoder->frame_dms #endif ); } @@ -534,13 +688,21 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #ifdef WMOPS pop_wmops(); #endif - + #ifdef WMOPS push_wmops("Entropy cod"); #endif processEncoderEntropy(bytes, &bp_side, &mask_side, h_EncSetup->targetBitsAri, h_EncSetup->targetBytes, encoder->yLen, encoder->BW_cutoff_bits, tns_numfilters, lsbMode, lastnz, tns_order, - fac_ns_idx, quantizedGain, BW_cutoff_idx, ltpf_idx, L_scf_idx, bfi_ext, encoder->fs_idx); + fac_ns_idx, quantizedGain, BW_cutoff_idx, ltpf_idx, L_scf_idx, bfi_ext, encoder->fs_idx +#ifdef CR9_C_ADD_1p25MS +#ifdef FIX_TX_RX_STRUCT_STEREO + , encoder->frame_dms, &h_EncSetup->Tx_ltpf +#else + , encoder->frame_dms, &encoder->Tx_ltpf +#endif +#endif + ); #ifdef WMOPS pop_wmops(); #endif @@ -569,31 +731,31 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #ifdef WMOPS push_wmops("Reorder Ari dec"); #endif - + #ifdef ENABLE_HR_MODE Word32 *xbuf = (Word32 *) scratchAlign(scratchBuffer, 0); - + processAriDecoder_fx(bytes, &bp_side, &mask_side, h_EncSetup->total_bits, encoder->yLen, encoder->fs_idx, h_EncSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &gain, tns_order, fac_ns_idx, quantizedGain, encoder->frame_dms, h_EncSetup->n_pc, 0, shr_pos(h_EncSetup->total_bits, 3), 1, &gain, &b_left, &gain, xbuf, - &gain, resBits, indexes, &gain, + &gain, resBits, indexes, &gain, currentScratch , encoder->hrmode ); #else - + processAriDecoder_fx(bytes, &bp_side, &mask_side, h_EncSetup->total_bits, encoder->yLen, encoder->fs_idx, h_EncSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &gain, tns_order, fac_ns_idx, quantizedGain, encoder->frame_dms, h_EncSetup->n_pc, 0, shr_pos(h_EncSetup->total_bits, 3), 1, &gain, &b_left, &gain, codingdata, - &gain, resBits, indexes, &gain, + &gain, resBits, indexes, &gain, currentScratch ); #endif - + #ifdef WMOPS pop_wmops(); /* Ari dec */ #endif @@ -665,4 +827,3 @@ int Enc_LC3PLUS(LC3PLUS_Enc *encoder, void **input, int bits_per_sample, UWord8 return output_size; } - diff --git a/lib_lc3plus/estimate_global_gain_fx.c b/lib_lc3plus/estimate_global_gain_fx.c index 8d0c54ded..ec4e8cd1a 100644 --- a/lib_lc3plus/estimate_global_gain_fx.c +++ b/lib_lc3plus/estimate_global_gain_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbitsSQ, @@ -20,7 +22,11 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit Word32 *targetBitsOff, Word16 *old_targetBits, Word16 old_specBits, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE - , Word16 hrmode, Word16 regBits, Word16 frame_dms + , Word16 hrmode, Word16 regBits, LC3PLUS_FrameDuration frame_dms +#else +#if defined(FIX_BOTH_1p25_TEST_NEW_GG_EST2) ||defined (FIX_1p25_GG_EST_TUPLES) + , LC3PLUS_FrameDuration frame_dms +#endif #endif ) { @@ -35,7 +41,31 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit Word16 *en_exp = NULL; Word32 M0, M1; #endif - +#ifdef FIX_1p25_GG_EST_TUPLES + /* NB (-1) WB(20), SSWB(30), SWB(40), FB(50) */ + Word16 nCoeffTab1p25[5] = { -1/*NB*/, GG_1p25_WB_TUPLES, GG_1p25_SSWB_TUPLES, GG_1p25_SWB_TUPLES, GG_1p25_FB_TUPLES }; + Word16 bwIdx; + Word16 divTabQ15[5] = { 0, -32768, 16384, 10923, 8192 }; +#endif +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 + Word16 nCoeffPerBand = 4; /* 4 coeff per band */ + Word16 twoCoeffFlag = 0; /* boolean */ +#endif +#if defined( FIX_1p25_FLEX_ITER_TUPLE_LOOP ) || defined( FIX_1p25_FLEX_BISECT_LOOP ) + Word16 twoCoeffOutShiftA; + Word16 twoCoeffOutShiftB; + Word32 L_twoCoeffSuppressMaskA; + Word32 L_twoCoeffSuppressMaskB; + Word32 L_dB_scale_offset, L_dB_scale_offset2, L_dB_scale_offset3; + + Word16 twoCoeffOutShift; + Word32 L_twoCoeffSuppressMask; + +#elif defined( FIX_BASOP_1p25_NEW_GG_EST3) + Word16 twoCoeffOutShift; + Word32 L_twoCoeffSuppressMask; + Word32 L_dB_scale_offset, L_dB_scale_offset2, L_dB_scale_offset3; +#endif #ifdef DYNMEM_COUNT Dyn_Mem_In("processEstimateGlobalGain_fx", sizeof(struct { Word16 lg_4, s, tmp16, iszero; @@ -46,9 +76,95 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit Word32 diff, diff2; })); #endif + UNUSED(iszero); + +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP + UNUSED(twoCoeffOutShift); + UNUSED(L_twoCoeffSuppressMask); +#endif +#ifdef FIX_1p25_FLEX_BISECT_LOOP + UNUSED(twoCoeffOutShiftA); + UNUSED(L_twoCoeffSuppressMaskA); + UNUSED(twoCoeffOutShiftB); + UNUSED(L_twoCoeffSuppressMaskB); +#endif + +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP + UNUSED(twoCoeffOutShiftA); + UNUSED(L_twoCoeffSuppressMaskA); + UNUSED(twoCoeffOutShiftB); + UNUSED(L_twoCoeffSuppressMaskB); +#endif + +#ifndef FIX_1p25_GG_EST_TUPLES +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 + IF(frame_dms == LC3PLUS_FRAME_DURATION_1p25MS && (sub(lg, 30) <= 0)) /* WB and SSWB */ + { + nCoeffPerBand = 2; move16(); /* 2 coeff per band */ + twoCoeffFlag = 1; move16(); + } +#endif +#endif + + +#ifdef FIX_1p25_GG_EST_TUPLES + twoCoeffFlag = 0; move16(); + nCoeffPerBand = 4; move16(); /* default assume 4 coeff per band(4-tuples block) */ + lg_4 = shr_pos_pos(lg, 2); + + test(); + IF(frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + bwIdx = mult(lg, 3276); + assert(bwIdx == ((lg - 1) / 10)); + nCoeffPerBand = nCoeffTab1p25[bwIdx]; move16(); + + if (sub(nCoeffPerBand, 2) == 0) + { + twoCoeffFlag = 1; move16(); + } + s = mult(add(lg, sub(nCoeffPerBand, 1)), divTabQ15[nCoeffPerBand]); + + tmp16 = i_mult(s, nCoeffPerBand); + +#ifdef FIX_1p25_32kHz_CLANG_WARNING_EST_GAIN + /* common 2,3,4 tuple energy loop may access tail values in blocks of GG_1p25_MAX_TUPLES */ + /* even if they are actually unused as values and shifted out, they should not be accessed uninitialized */ + tmp16 = add(tmp16, sub(GG_1p25_MAX_TUPLES,nCoeffPerBand)); +#endif + + FOR(i = lg; i < tmp16; i++) + { + x[i] = L_deposit_l(0); /* zero the top virtual MDCT lines in the spectrum signal x */ + } + assert(MAX_LEN >= s); + lg_4 = s; /* lg_4 also used for 3_tuples, 2 tuples*/ + } + +#elif defined( FIX_BASOP_ENC_QUANTIZE_1P25MS_512KBPS) + /* handle non-eaxactly quadruple lengths, in case frame_length is (e.g 1p25ms 24kHz --> 30 = 7*4 + 2 ) */ + /* e.g 1p25ms 48kHz --> 50 = 12*4 + 2 ) */ + /* quadruple extension is needed provide a correct x_max analysis as req. for scaling analysis */ + lg_4 = shr_pos(lg, 2); /*1/4*/ + + IF(frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + tmp16 = sub(lg, shl_pos(lg_4, 2)); + test(); + if (tmp16 != 0) + { + lg_4 = add(lg_4, 1); + } + FOR(i = lg; i < lg_4 * 4; i++) + { + x[i] = L_deposit_l(0); /* zero these top virtual MDCT lines */ + } + } +#endif + + + en = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = MAX_LEN bytes */ - en = (Word32 *)scratchAlign(scratchBuffer, - 0); /* Size = MAX_LEN bytes */ #ifdef ENABLE_HR_MODE if (hrmode) @@ -71,13 +187,14 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit move16(); } - *old_targetBits = nbitsSQ; - move16(); + *old_targetBits = nbitsSQ; move16(); nbitsSQ = add(nbitsSQ, round_fx(*targetBitsOff)); +#ifndef FIX_BASOP_ENC_QUANTIZE_1P25MS_512KBPS lg_4 = shr_pos(lg, 2); - x_max = 0; - move32(); +#endif + + x_max = 0; move32(); /* energy of quadruples with 9dB offset */ #ifdef ENABLE_HR_MODE @@ -155,7 +272,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit ELSE { /* log */ - tmp32 = L_add(BASOP_Util_Log2_lc3plus(ener), L_shl_pos(L_deposit_l(s), 25)); /* log2, 6Q25 */ + tmp32 = L_add(BASOP_Util_Log2(ener), L_shl_pos(L_deposit_l(s), 25)); /* log2, 6Q25 */ tmp32 = L_add(L_shr_pos(Mpy_32_16_lc3plus(tmp32, 0x436E), 7), 0x4E666); /* -> (28/20)*(7+10*tmp32/log2(10)), 16Q15 */ en[i] = tmp32; @@ -167,23 +284,179 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit } ELSE #endif - { + { /* regular hrmode==0 */ +#if defined ( FIX_1p25_FLEX_ITER_TUPLE_LOOP ) + if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + /* 4 or 2 tuples */ + L_dB_scale_offset = L_shr_pos(0x9CCCD, twoCoeffFlag); /* S15Q16 7.5(4 tuples) or 3.75(2_tuples) offset */ + L_dB_scale_offset2 = L_shr_pos(0x460000, twoCoeffFlag); + L_dB_scale_offset3 = L_shr_pos(0x3C7AE, twoCoeffFlag); + + /* set up constants for blocks of 4 (or block of 3 or 2)*/ + + /*init for 2-tuples energy loop */ + twoCoeffOutShiftA = 31; move16(); /* shift out */ + twoCoeffOutShiftB = 31; move16(); /* shift out */ + L_twoCoeffSuppressMaskA = 0; move32(); /* suppress value*/ + L_twoCoeffSuppressMaskB = 0; move32(); /* suppress value*/ + + +#if GG_1p25_MAX_TUPLES>=3 + IF(sub(nCoeffPerBand, 3) == 0) + { + L_dB_scale_offset = L_add(Mpy_32_16_lc3plus(0x9CCCD, 24576), 1L); /* S15Q16/ round(7.5 * 3/4), 481689.75 -> 481690 */ + L_dB_scale_offset2 = Mpy_32_16_lc3plus(0x460000, 24576); /*3440640.0 */ + L_dB_scale_offset3 = Mpy_32_16_lc3plus(0x3C7AE, 24576); /* 185794.5*/ + + twoCoeffOutShiftA = 0; move16(); /* do not shift out */ + L_twoCoeffSuppressMaskA = -1L; move32(); /* all ones, do not suppress*/ + twoCoeffOutShiftB = 31; move16(); /* shift out x[3] */ + L_twoCoeffSuppressMaskB = 0; move32(); /* suppress value*/ + } +#endif + +#if GG_1p25_MAX_TUPLES>=4 + IF(sub(nCoeffPerBand, 4) == 0) + { + twoCoeffOutShiftA = 0; move16(); /* do not shift out */ + twoCoeffOutShiftB = 0; move16(); /* do not shift out */ + L_twoCoeffSuppressMaskA = -1L; move32(); /* all ones, do not suppress*/ + L_twoCoeffSuppressMaskB = -1L; move32(); /* all ones, do not suppress*/ + } +#endif +#endif + +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP + + FOR(i = 0; i < lg_4; i++) /* 1.25 ms energy loop used for all N/4 , (N)/3 and N/2 */ + { + /* normalization */ + s = 31; move16(); + + tmp32 = L_abs(x[0]); + tmp32 = L_max(tmp32, L_abs(x[1])); + + /* 0 or 31 shift, 0 for blocks of 4, 31 to accumulate a 0 value (for block #2,#3) for blocks of 2 or blocks of 3 */ +#if GG_1p25_MAX_TUPLES>=3 + tmp32 = L_max(tmp32, L_shr_pos_pos(L_abs(x[2]), twoCoeffOutShiftA)); +#endif +#if GG_1p25_MAX_TUPLES>=4 + tmp32 = L_max(tmp32, L_shr_pos_pos(L_abs(x[3]), twoCoeffOutShiftB)); +#endif + x_max = L_max(x_max, tmp32); /* global x_max */ + + + if (tmp32 != 0) + { + s = norm_l(tmp32); + } + + s = sub(s, 2); /* 2 bits headroom . for up to four values accumulation */ + /* NB only 1 bit headroom needed with L_mac0 */ + /* NB only 2tuples will only need 1 bit even with L_mac */ + /* calc quadruple or , triple or tuple energy */ + ener = L_deposit_l(1); + + + tmp16 = round_fx(L_shl(x[0], s)); /* s is in range [29...-2], i.e. can become a downshift of two */ + ener = L_mac(ener, tmp16, tmp16); + + tmp16 = round_fx(L_shl(x[1], s)); + ener = L_mac(ener, tmp16, tmp16); + +#if GG_1p25_MAX_TUPLES >= 3 + tmp32 = L_and(x[2], L_twoCoeffSuppressMaskA); /* mask is 0 for 2blocks, all ones for 3 or 4 blocks */ + tmp16 = round_fx(L_shl(tmp32, s)); + ener = L_mac(ener, tmp16, tmp16); +#endif + +#if GG_1p25_MAX_TUPLES >= 4 + tmp32 = L_and(x[3], L_twoCoeffSuppressMaskB); /* 0 for 2 or 3 blocks, all ones for 4 blocks */ + tmp16 = round_fx(L_shl(tmp32, s)); + ener = L_mac(ener, tmp16, tmp16); +#endif + s = shl_pos(sub(x_e, s), 1); + +#ifdef NONBE_GAIN_EST_FIX + test(); test(); + if ((L_sub(ener, 1L) == 0) && (s < 0)) + { + s = 0; move16(); + } +#endif + +#ifndef LOG2_LC_APPROX + /* log2 */ + tmp32 = L_add_sat(BASOP_Util_Log2(ener), L_shl_sat(L_deposit_l(s), 25)); /* log2, 6Q25 */ +#endif +#ifdef LOG2_LC_APPROX + tmp32 = L_add_sat(BASOP_Util_Log2_LC(ener), L_shl_sat(L_deposit_l(s), 25)); /* log2LC , 6Q25 */ +#endif + tmp32 = L_add(L_shr_pos(Mpy_32_16_lc3plus(tmp32, 0x436E), 6), L_dB_scale_offset); /* -> (28/20)*( (7or5.25or3.5 ) + 10*tmp32/log2(10)), 15Q16 */ + + en[i] = tmp32; move32(); + + x += nCoeffPerBand; + /* N/4 or N/3 or N/2 */ + } /* for loop*/ + } /* end of IF 1p25 */ + else + { /* 4 or 2 merged loop for non-1p25ms */ +#endif + +#ifndef FIX_1p25_GG_EST_TUPLES + # ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 + test(); + if (twoCoeffFlag != 0) + { + lg_4 = add(lg_4, lg_4); /*lg_4(extended) for N/4 doubled and used as "lg_2" for N/2 */ + } +#endif +#endif + + #ifdef FIX_BASOP_1p25_NEW_GG_EST3 + /*set up constants for blocks of two (or block of 4)*/ + L_dB_scale_offset = L_shr_pos(0x9CCCD, twoCoeffFlag); /* S15Q16/ 7.5 or 3.5 offset */ +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP + Word16 twoCoeffOutShift; + Word32 L_twoCoeffSuppressMask; +#endif + twoCoeffOutShift = 0; move16(); /* do not shift out */ + L_twoCoeffSuppressMask = -1L; move32(); /* all ones-mask, do not suppress*/ + + IF(twoCoeffFlag != 0) + { + twoCoeffOutShift = 31; move16(); + L_twoCoeffSuppressMask = 0; move16();/* supress value*/ + x[lg_4 * 2] = 0; move32(); /*make sure extra two coeffs at tail are zeroed */ + x[lg_4 * 2 + 1] = 0; move32(); + }; +#endif + FOR (i = 0; i < lg_4; i++) { /* normalization */ - s = 31; - move16(); + s = 31; move16(); tmp32 = L_abs(x[0]); tmp32 = L_max(tmp32, L_abs(x[1])); +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + /* 0 or 31 shift, 0 for blocks of 4, 31 to accumulate a 0 value (for block #2,#3) for blocks of 2 */ + tmp32 = L_max(tmp32, L_shr_pos(L_abs(x[2]), twoCoeffOutShift)); + tmp32 = L_max(tmp32, L_shr_pos(L_abs(x[3]), twoCoeffOutShift)); +#endif +#else tmp32 = L_max(tmp32, L_abs(x[2])); tmp32 = L_max(tmp32, L_abs(x[3])); +#endif x_max = L_max(x_max, tmp32); - if (tmp32 != 0) + if (tmp32 != 0) { s = norm_l(tmp32); - - s = sub(s, 2); /* 2 bits headroom */ + } + s = sub(s, 2); /* 2 bits headroom */ /* note: slightly suboptimal 2 bit headroom kept for pairs */ /* calc quadruple energy */ ener = L_deposit_l(1); @@ -194,34 +467,55 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit tmp16 = round_fx(L_shl(x[1], s)); ener = L_mac(ener, tmp16, tmp16); +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + tmp32 = L_and(x[2], L_twoCoeffSuppressMask); /* 0 for 2blocks, all ones for 4 blocks */ + tmp16 = round_fx(L_shl(tmp32, s)); + ener = L_mac(ener, tmp16, tmp16); + + tmp32 = L_and(x[3], L_twoCoeffSuppressMask); /* 0 for 2blocks, all ones for 4 blocks */ + tmp16 = round_fx(L_shl(tmp32, s)); + ener = L_mac(ener, tmp16, tmp16); +#endif +#else tmp16 = round_fx(L_shl(x[2], s)); ener = L_mac(ener, tmp16, tmp16); tmp16 = round_fx(L_shl(x[3], s)); ener = L_mac(ener, tmp16, tmp16); - +#endif s = shl_pos(sub(x_e, s), 1); - if (ener == 1 && s < 0) + if (ener == 1 && s < 0) { s = 0; + } /* log */ - tmp32 = L_add_sat(BASOP_Util_Log2_lc3plus(ener), L_shl_sat(L_deposit_l(s), 25)); /* log2, 6Q25 */ - tmp32 = - L_add(L_shr_pos(Mpy_32_16_lc3plus(tmp32, 0x436E), 6), 0x9CCCD); /* -> (28/20)*(7+10*tmp32/log2(10)), 15Q16 */ - en[i] = tmp32; - move32(); + tmp32 = L_add_sat(BASOP_Util_Log2(ener), L_shl_sat(L_deposit_l(s), 25)); /* log2, 6Q25 */ +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + tmp32 = L_add(L_shr_pos(Mpy_32_16_lc3plus(tmp32, 0x436E), 6), L_dB_scale_offset); /* -> (28/20)*( (7or3.5) + 10*tmp32/log2(10)), 15Q16 */ +#endif +#else + tmp32 = L_add(L_shr_pos(Mpy_32_16_lc3plus(tmp32, 0x436E), 6), 0x9CCCD); /* -> (28/20)*(7+10*tmp32/log2(10)), 15Q16 */ +#endif + en[i] = tmp32; move32(); + +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 + x += nCoeffPerBand; +#else x += 4; - } - } +#endif + } /* N/4 or N/2 energy loop */ +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP + } /* end of non-1.25ms 4 or 2 tuple energy loop */ +#endif + }/* hrmode==0 */ IF (x_max == 0) { - *quantizedGainMin = quantizedGainOff; - move16(); - *quantizedGain = 0; - move16(); - *old_targetBits = -1; - move16(); + *quantizedGainMin = quantizedGainOff; move16(); + *quantizedGain = 0; move16(); + *old_targetBits = -1; move16(); } ELSE { @@ -244,7 +538,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit if (M0 <= 0x7fff) { - Word16 inv_M0 = Inv16_lc3plus(M0, &ratio_exp); /* Inverse in Q(15 - ratio_exp) */ + Word16 inv_M0 = Inv16(M0, &ratio_exp); /* Inverse in Q(15 - ratio_exp) */ ratio = L_shr(Mpy_32_16_lc3plus(M1, inv_M0), 15 - ratio_exp); /* Integer ratio */ } else @@ -252,7 +546,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit Word16 M0_h = L_shr(M0, 15); Word32 M1_h = L_shr(M1, 15); - Word16 inv_M0 = Inv16_lc3plus(M0_h, &ratio_exp); /* Inverse in Q(15 - ratio_exp) */ + Word16 inv_M0 = Inv16(M0_h, &ratio_exp); /* Inverse in Q(15 - ratio_exp) */ ratio = extract_l(L_shr(Mpy_32_16_lc3plus(M1_h, inv_M0), 15 - ratio_exp)); /* Integer ratio */ } @@ -264,16 +558,33 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit ratio_prod = L_mult(ratio, 5); - if (ratio_prod < frame_dms) + int frame_dms_val = 0; + SWITCH (frame_dms) /* 1 / frame_dms in Q15 */ + { +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: assert(0); frame_dms_val = 13; BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: frame_dms_val = 25; BREAK; + case LC3PLUS_FRAME_DURATION_5MS: frame_dms_val = 50; BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: frame_dms_val = 75; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: frame_dms_val = 100; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); + } + + if (ratio_prod < frame_dms_val) { Word16 mult_factor = 0; SWITCH (frame_dms) /* 1 / frame_dms in Q15 */ { - case 25: mult_factor = 1311; break; - case 50: mult_factor = 655; break; - case 75: mult_factor = 437; break; - case 100: mult_factor = 328; break; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: mult_factor = 15721; BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: mult_factor = 1311; BREAK; + case LC3PLUS_FRAME_DURATION_5MS: mult_factor = 655; BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: mult_factor = 437; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: mult_factor = 328; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } /* ratio_prod < frame_dms. Hence Word16 can be used */ @@ -294,7 +605,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit IF(rB_offset > 0) { Word32 reg_exp = L_negate(L_add(L_shl(regBits, 25), L_shr(rB_offset, 3))); - reg_val = Mpy_32_32_lc3plus(x_max, BASOP_Util_InvLog2_lc3plus(reg_exp)); /* Product is in Q31 */ + reg_val = Mpy_32_32_lc3plus(x_max, BASOP_Util_InvLog2(reg_exp)); /* Product is in Q31 */ /* reg_val is in Q(31-x_e) */ } ELSE @@ -303,8 +614,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit reg_val_e = sub(x_e, regBits); } - sub_val = 0x183BA045; - move16(); + sub_val = 0x183BA045; move16(); /*28 * log10(32768*256 - 2) in Q21 */ /* @@ -320,10 +630,8 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit FOR (i = 0; i < lg_4; i++) { - ener = en[i]; - move16(); - s = en_exp[i]; - move16(); + ener = en[i]; move16(); + s = en_exp[i]; move16(); Word16 shift_val = sub(reg_val_e, s); @@ -347,21 +655,20 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit s = reg_val_e; } - tmp32 = L_add(BASOP_Util_Log2_lc3plus(ener), L_shl_pos(L_deposit_l(s), 25)); /* log2, 6Q25 */ + tmp32 = L_add(BASOP_Util_Log2(ener), L_shl_pos(L_deposit_l(s), 25)); /* log2, 6Q25 */ tmp32 = L_add(L_shr_pos(Mpy_32_32_lc3plus(tmp32, 0x436E439A), 7), 0x4E666); /* -> (28/20)*(7+10*tmp32/log2(10)), 15Q16 */ - en[i] = tmp32; - move32(); + en[i] = tmp32; move32(); } } #endif - x_max = BASOP_Util_Log2_lc3plus(x_max); + x_max = BASOP_Util_Log2(x_max); /* Minimum gain */ x_max = L_add(x_max, L_shl_pos(L_deposit_l(x_e), 25)); /* log2(x_max) in 6Q25 */ x_max = L_sub( Mpy_32_32_lc3plus(x_max, 0x436E439A), sub_val); /* 28*log10(x_max/(32768-0.375)) = log2(x_max)*(28/log2(10))-28*log10(32768-0.375) in 10Q21 */ /* 28/log1(10) is in Q27 - Mpy_32_32_lc3plus : Q25(x_max) + Q27 + Q1(Mpy_32_32_ss) - Q32 = Q21 */ + Mpy_32_32 : Q25(x_max) + Q27 + Q1(Mpy_32_32_ss) - Q32 = Q21 */ *quantizedGainMin = extract_l(L_shr_pos(L_add(x_max, (1 << 21) + (1 << 11)), 21)); move16(); ASSERT(*quantizedGainMin <= 255 + quantizedGainOff); @@ -401,8 +708,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit else { ener = L_add(ener, tmp32); - iszero = 0; - move16(); + iszero = 0; move16(); diff2 = L_sub(tmp32, 0x118000); /* 0x230000 -> (28/20)*(50) */ if (diff2 >= 0) @@ -422,79 +728,208 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit tmp16 = extract_h(L_shl(offset, 2)); } ELSE -#endif +#endif + /* regular mode */ + /* SQ scale: 4 bits / 6 dB per quadruple */ { - /* SQ scale: 4 bits / 6 dB per quadruple */ + + #ifndef FIX_1p25_FLEX_BISECT_LOOP +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + /*these limits were constant for blocks of 4 , now we adaptively adjust them for blocks of two */ + L_dB_scale_offset = L_shr_pos(0x9CCCD, twoCoeffFlag); + L_dB_scale_offset2 = L_shr_pos(0x460000, twoCoeffFlag); + L_dB_scale_offset3 = L_shr_pos(0x3C7AE, twoCoeffFlag); +#endif +#endif target = L_shl_pos(L_mult(0x7D71, nbitsSQ), 1); /* -> (28/20) * (1.4) * nbitsSQ */ fac = L_add(0x1000000, 0); /* -> 256 */ - /* find offset (0 to 127) */ - FOR (iter = 0; iter < 8; iter++) +#ifdef FIX_1p25_FLEX_BISECT_LOOP + + /* 1p25 iteration code, for 4-tuples 3-tuples and 2 tuples */ + test(); + IF((frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) && (sub(nCoeffPerBand, 4) <= 0)) { - fac = L_shr_pos(fac, 1); - offset = L_sub(offset, fac); + Word16 idx; /* 0, 1, 2 , section index */ + Word32 L_tmp32; + Word32 L_offset2; - ener = L_deposit_l(0); - iszero = 1; - move16(); - FOR (i = lg_4 - 1; i >= 0; i--) + Word16 shiftl_fac[3] = { -31, 0, 1 }; /* ROM float mult_fact[3] = { 0.0, 1.0, 2.0 }; */ /* -31 shifts out all energy in an signed Word32 */ + + /* 4 or 2 tuples */ + L_dB_scale_offset = L_shr_pos(0x9CCCD, twoCoeffFlag); /* S15Q16 7.5(4 tuples) or 3.75(2_tuples) offset */ + L_dB_scale_offset2 = L_shr_pos(0x460000, twoCoeffFlag); + L_dB_scale_offset3 = L_shr_pos(0x3C7AE, twoCoeffFlag); + + /* set up constants for blocks of 4 (or block of 3 or 2)*/ +#if GG_1p25_MAX_TUPLES>=3 + IF(sub(nCoeffPerBand, 3) == 0) { - tmp32 = L_sub(en[i], offset); - diff = L_sub(tmp32, 0x9CCCD); /* 0x9CCCD -> (28/20)*(7) in Q16 */ - if (diff < 0) + L_dB_scale_offset = L_add(Mpy_32_16_lc3plus(0x9CCCD, 24576), 1L); /* S15Q16/ round(7.5 * 3/4), 481689.75 -> 481690 */ + L_dB_scale_offset2 = Mpy_32_16_lc3plus(0x460000, 24576); /*3440640.0 */ + L_dB_scale_offset3 = Mpy_32_16_lc3plus(0x3C7AE, 24576); /* 185794.5*/ + } +#endif + /* tuple-size dynamic constant tables, treated as registers */ + Word32 L_en_lim[2]; + Word32 L_add_fac[3]; + + L_en_lim[0] = L_add(L_dB_scale_offset, 0); /*28/20*7.0*/; + L_en_lim[1] = L_add(L_dB_scale_offset2, 0); /*28/20*50.0*/ + + L_add_fac[0] = L_add(L_dB_scale_offset3, 0); + L_add_fac[1] = L_add(0, 0); + L_add_fac[2] = L_negate(L_dB_scale_offset2); + + + /* find offset (0 to 255) */ + FOR(iter = 0; iter < 8; iter++) + { + fac = L_shr_pos_pos(fac, 1); + offset = L_sub(offset, fac); + iszero = 1; move16(); + ener = L_deposit_l(0); + /* skip iszero section, go to first band with enough energy */ + /* find first index where we start summing up adding bits. */ + + L_offset2 = L_add(offset, L_dB_scale_offset); + FOR(i = sub(lg_4, 1); i >= 0; i--) { - if (iszero == 0) + L_tmp32 = L_sub(en[i], L_offset2); + IF(L_tmp32 > 0) { - ener = L_add_sat(ener, 0x3C7AE); /* 0x3C7AE -> (28/20)*(2.7) in Q16 */ + iszero = 0; move16(); /* now also allow upward update */ + BREAK; } } - else + /* exiting counter value "i" is remembered , for the next FOR loop initialization */ + + + /* Equations realized acc = { 0*d_en + 2.7 , 1*dEn + 0.0, 2*dEn + (-50.0) }; */ + FOR(; i >= 0; i--) { - ener = L_add_sat(ener, tmp32); - iszero = 0; - move16(); + L_tmp32 = L_sub(en[i], offset); - diff2 = L_sub(tmp32, 0x460000); /* 0x460000 -> (28/20)*(50) in Q16 */ - if (diff2 >= 0) + /* pre_quantize energy "L_tmp32" into a idx 0, 1, 2; to address tabled acc. values */ + idx = 0; move16(); /* "ptr" init to low section */ + if (L_sub(L_tmp32, L_en_lim[0]) > 0) { - ener = L_add_sat(ener, diff2); + idx = add(idx, 1); /* single op */ /* middle section */ } + + if (L_sub(L_tmp32, L_en_lim[1]) > 0) + { + idx = add(idx, 1); /* single op */ /* high section*/ + } + + ener = L_add_sat(ener, L_shl_sat(L_tmp32, shiftl_fac[idx])); /* *0.0, *1.0, *2.0 */ /* NB! this shifts L_tmp32, (the ener contribution) both up and down */ + ener = L_add_sat(ener, L_add_fac[idx]); /* 2.7, 0, -50 */ } - - } + - /* if ener is above target -> increase offset */ - test(); - if (L_sub(ener, target) > 0 && iszero == 0) - { - offset = L_add(offset, fac); - } + /* if ener is above target -> increase offset */ + /* if only low level signal , iszero was never set to 0 --> offset not moved */ + assert(target > 0); + test(); test(); + if (L_sub(ener, target) > 0 && iszero == 0) + { + offset = L_add(offset, fac); + } + } /* iter 1--8 ,1p25 loop */ } + /* if 1p25 */ + ELSE + { + #endif /* FLEX BISECT*/ + /* find offset (0 to 127) */ +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + /* 4 ,or 2 tuples */ + L_dB_scale_offset = L_shr_pos(0x9CCCD, twoCoeffFlag); + /* S15Q16 7.5(4 tuples) or 3.75(2_tuples) offset */ + L_dB_scale_offset2 = L_shr_pos(0x460000, twoCoeffFlag); + L_dB_scale_offset3 = L_shr_pos(0x3C7AE, twoCoeffFlag); +#endif + FOR(iter = 0; iter < 8; iter++) + { + fac = L_shr_pos(fac, 1); + offset = L_sub(offset, fac); + + ener = L_deposit_l(0); + iszero = 1; move16(); + + + FOR(i = lg_4 - 1; i >= 0; i--) + { + tmp32 = L_sub(en[i], offset); +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + diff = L_sub(tmp32, L_dB_scale_offset); /* 0x9CCCD -> (28/20)*( 7or3.5) in Q16 */ +#endif +#else + diff = L_sub(tmp32, 0x9CCCD); /* 0x9CCCD -> (28/20)*(7) in Q16 */ +#endif + if (diff < 0) + { + if (iszero == 0) + { +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + ener = L_add_sat(ener, L_dB_scale_offset3); /* 0x3C7AE -> (28/20)*(2.7or 3.5) in Q16 */ +#endif +#else + ener = L_add_sat(ener, 0x3C7AE); /* 0x3C7AE -> (28/20)*(2.7) in Q16 */ +#endif + } + } + else + { + ener = L_add_sat(ener, tmp32); + iszero = 0; move16(); +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 + diff2 = L_sub(tmp32, L_dB_scale_offset2); /* 0x460000 -> (28/20)*(50or25) in Q16 */ +#endif +#else + diff2 = L_sub(tmp32, 0x460000); /* 0x460000 -> (28/20)*(50) in Q16 */ +#endif + if (diff2 >= 0) + { + ener = L_add_sat(ener, diff2); + } + } + + } + + /* if ener is above target -> increase offset */ + test(); + if (L_sub(ener, target) > 0 && iszero == 0) + { + offset = L_add(offset, fac); + } + } /* legacy 1-8 iter loop , FOR */ +#ifdef FIX_1p25_FLEX_BISECT_LOOP + } /* 1p25, non 1p25*/ +#endif tmp16 = extract_h(offset); - } - if (sub(tmp16, *quantizedGainMin) < 0) - { - *old_targetBits = -1; - move16(); - } - *quantizedGain = sub(s_max(*quantizedGainMin, tmp16), quantizedGainOff); - move16(); + if (sub(tmp16, *quantizedGainMin) < 0) + { + *old_targetBits = -1; move16(); + } + *quantizedGain = sub(s_max(*quantizedGainMin, tmp16), quantizedGainOff); move16(); } #ifdef ENABLE_HR_MODE - tmp32 = - Mpy_32_16_lc3plus(0x797CD707, L_shl_pos(add(*quantizedGain, quantizedGainOff), 6)); + tmp32 = Mpy_32_16_lc3plus(0x797CD707, L_shl_pos(add(*quantizedGain, quantizedGainOff), 6)); #else - tmp32 = - L_shl_pos(L_mult0(add(*quantizedGain, quantizedGainOff), 0x797D), 7); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ + tmp32 = L_shl_pos(L_mult0(add(*quantizedGain, quantizedGainOff), 0x797D), 7); /* 6Q25; 0x797D -> log2(10)/28 (Q18) */ #endif *gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); /* get exponent */ #ifdef ENABLE_HR_MODE - *gain = BASOP_Util_InvLog2_lc3plus(L_or(tmp32, (Word32)0xFE000000)); + *gain = BASOP_Util_InvLog2(L_or(tmp32, (Word32)0xFE000000)); #else - *gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32,(Word32) 0xFE000000))); + *gain = round_fx(BASOP_Util_InvLog2(L_or(tmp32,(Word32) 0xFE000000))); #endif #ifdef DYNMEM_COUNT diff --git a/lib_lc3plus/fft_lc3plus.c b/lib_lc3plus/fft_lc3plus.c index 56dd33156..e7a71d5b1 100644 --- a/lib_lc3plus/fft_lc3plus.c +++ b/lib_lc3plus/fft_lc3plus.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" #include "rom_basop_util_lc3plus.h" @@ -27,9 +29,9 @@ #define SCALEFACTOR32_2 1 #ifdef ENABLE_HR_MODE -#define Mpy_32_xx Mpy_32_32_lc3plus +#define Mpy_32_xx Mpy_32_32 #else -#define Mpy_32_xx Mpy_32_16_lc3plus +#define Mpy_32_xx Mpy_32_16 #endif #define SCALEFACTOR6 4 @@ -3649,7 +3651,7 @@ static void fftN2(Word32 *re, Word32 *im, #ifdef ENABLE_FFT_RESCALE IF (scale) { - *scale = s_max(sub(getScaleFactor32_lc3plus(x, dim1 * dim2 * 2), FFT_RESCALE_HR), 0); move16(); + *scale = s_max(sub(getScaleFactor32(x, dim1 * dim2 * 2), FFT_RESCALE_HR), 0); move16(); #if defined(FUNCTION_scaleValues_32) scaleValues_32(x, dim1 * dim2, *scale); @@ -3987,7 +3989,7 @@ static void fftN2(Word32 *re, Word32 *im, /* x is the scratch buffer */ -void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 length, Word16 s, Word16 *scale, Word32 *x) +void BASOP_cfft(Word32 *re, Word32 *im, Word16 length, Word16 s, Word16 *scale, Word32 *x) { #if (defined ENABLE_FFT_RESCALE) && ((defined LC3_FFT30) || (defined ENABLE_HR_MODE)) Word16 fftN2scale = 0; @@ -4007,6 +4009,13 @@ void BASOP_cfft_lc3plus(Word32 *re, Word32 *im, Word16 length, Word16 s, Word16 *scale = add(*scale, SCALEFACTOR10); move16(); BREAK; +#ifdef CR9_C_ADD_1p25MS + case 15: + fft15(re, im, s); + *scale = add(*scale, SCALEFACTOR15); + move16(); + BREAK; +#endif case 16: fft16(re, im, s); *scale = add(*scale, SCALEFACTOR16); @@ -4250,7 +4259,7 @@ void BASOP_rfftN(Word32 *x, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuffe sizeOfFft4 = shr_pos(sizeOfFft, 2); sizeOfFft8 = shr_pos(sizeOfFft, 3); - BASOP_cfft_lc3plus(&x[0], &x[1], sizeOfFft2, 2, scale, workBuffer); + BASOP_cfft(&x[0], &x[1], sizeOfFft2, 2, scale, workBuffer); xb0 = L_shr_pos(x[0], 1); xb1 = L_shr_pos(x[1], 1); @@ -4351,7 +4360,7 @@ void BASOP_irfftN(Word32 *x, Word16 sizeOfFft, Word16 *scale, Word8 *scratchBuff x[sizeOfFft - 2 * i + 1] = L_shr_pos(x[2 * i + 1], 1); move32(); - BASOP_cfft_lc3plus(&x[0], &x[1], sizeOfFft2, 2, scale, workBuffer); + BASOP_cfft(&x[0], &x[1], sizeOfFft2, 2, scale, workBuffer); /* If you want BASOP_irfft to be inverse to BASOP_rfft then the result needs * to be normalised by sizeOfFft */ diff --git a/lib_lc3plus/functions.h b/lib_lc3plus/functions.h index b557ca38f..5146ca05c 100644 --- a/lib_lc3plus/functions.h +++ b/lib_lc3plus/functions.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -10,6 +10,8 @@ #ifndef FUNCTIONS_H #define FUNCTIONS_H +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "stl.h" @@ -18,11 +20,10 @@ #endif #include "basop_util_lc3plus.h" -#include "basop32.h" #include "constants.h" -#include "lc3.h" -#include "setup_dec_lc3.h" /* for decoder state handle ptr */ -#include "setup_enc_lc3.h" /* for encoder state handle ptr */ +#include "lc3plus.h" +#include "setup_dec_lc3plus.h" /* for decoder state handle ptr */ +#include "setup_enc_lc3plus.h" /* for encoder state handle ptr */ #include "basop_mpy_lc3plus.h" #include @@ -54,15 +55,18 @@ void WarnMsg(char *msg); void ExitMsg(char *msg); void AssertMsg(int true_flag, char *msg); +Word16 getLastNzBits_fx (Word16 N); +void dct16_W32int_fx(const Word16 *in, Word16 *out); + void processTnsDecoder_fx(Word16 rc_idx[], Word32 x[], Word16 xLen, Word16 order[], Word16 *x_e, Word16 BW_stopband_idx, - Word16 frame_dms, Word8 *scratchBuffer + LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode #endif ); void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cutoff_idx, Word16 order[], - Word16 *numfilters, Word16 enable_lpc_weighting, Word16 nSubdivisions, Word16 frame_dms, + Word16 *numfilters, Word16 enable_lpc_weighting, Word16 nSubdivisions, LC3PLUS_FrameDuration frame_dms, Word16 max_len, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -77,12 +81,15 @@ void processResidualDecoding_fx(Word32 spectrum[], Word16 spectrum_e, Word16 L_s #ifdef ENABLE_HR_MODE , Word16 hrmode #endif +#ifdef CR9_C_ADD_1p25MS + , LC3PLUS_FrameDuration frame_dms +#endif ); void processPreemph_fx(Word16 *x, Word16 len, Word16 mem[], Word16 memLen, Word16 out[], Word16 *outLen, Word16 mu); void processNoiseFilling_fx(Word32 xq[], Word16 nfseed, Word16 xq_e, Word16 fac_ns_idx, Word16 BW_cutoff_idx, - Word16 frame_dms, Word16 fac_ns_pc, Word16 spec_inv_idx, Word8 *scratchBuffer + LC3PLUS_FrameDuration frame_dms, Word16 fac_ns_pc, Word16 spec_inv_idx, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode #endif @@ -94,7 +101,7 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], #else Word16 xq[], #endif - Word16 gg, Word16 gg_e, Word16 BW_cutoff_idx, Word16 frame_dms, Word16 target_bytes, + Word16 gg, Word16 gg_e, Word16 BW_cutoff_idx, LC3PLUS_FrameDuration frame_dms, Word16 target_bytes, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -103,7 +110,7 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], void processMdctShaping_fx(Word32 x[], #ifdef ENABLE_HR_MODE - Word32 scf[], + Word32 scf[], #else Word16 scf[], #endif @@ -154,7 +161,7 @@ void ProcessingIMDCT(Word32 y[], Word16 *y_e, Word16 x[], /* o: time signal out */ #endif Word16 wLen, - Word16 N, Word16 memLen, Word16 frame_dms, + Word16 N, Word16 memLen, LC3PLUS_FrameDuration frame_dms, Word16 concealMethod, Word16 bfi, Word16 prev_bfi, Word16 nbLostFramesInRow, AplcSetup *plcAd, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE @@ -206,7 +213,7 @@ void pvq_dec_en1_norm_fx( /* */ Word32 * xq, /* o: en1 normalized decoded vector (Q14) */ #else Word16 * xq, /* o: en1 normalized decoded vector (Q14) */ -#endif +#endif const Word16 *y, /* i: decoded vector (non-scaled int) */ const Word16 kval_max, /* i: max possible K in Q0 kO or kA */ const Word16 dim, /* i: Length of vector */ @@ -237,6 +244,118 @@ void pvq_dec_scale_vec_fx(const Word32 *inQ29, Word16 adjGainQ13, Word32 *outQ); void pvq_dec_scale_vec_fx(const Word16 *inQ14, Word16 adjGainQ13, Word16 *outQ14); #endif +#ifdef CR9_C_ADD_1p25MS_LRSNS + +/* LRSNS functions needed in both encoder and decoder */ +Word16 snslr_remove_st1_DC_fQ11_fx( /* o : dc in Q11 */ + Word16 *scfq, /* i/o: b vector in Q11 */ + Word16 len /* i : length Q0*/); + +void lrsns_pvq_dec_scale_W16vec_fx( + const Word16 *inQ14, Word16 adjGainQ12, Word16 *inoutQ11 +); + +void snslr_st1B_vector_dec_fx( + Word16 idx, const Word16* LFCB, const Word16 *HFCB, const Word16* seg_cnt_cum, const Word16* idx12b_cb, Word16 *st1B_vectorQ11 +); +void snslr_st1C_vector_dec_fx( + Word16 idx, const Word8* CBW8, Word16 scaleQ4, Word16 inv_scaleQ15, Word16 v_len, Word16 cb_len, Word16 *st1C_vector +); + +#ifdef ENABLE_HR_MODE +void lrsns_pvq_dec_scale_W32vec_fx( + const Word32 *inQ27, Word16 adjGainQ12, Word32 *inQ27outQ26, Word16 *outQ11 +); +#endif /* ENABLE_HR_MODE*/ + +/* enc_dec common lrsns PVQ_FESS function */ +void pvq_fess_dec_en1_normQ30andQ14_fx( + const Word16 *y /*Q0*/, + Word16 y_up_bits, /*constant max upshift for each Q0 shape 0,1, 2(3,4,5) */ + Word32 L_norm_factor, + Word16 norm_factorQ, /*Q of L_norm_factor */ + Word16 len, + Word32* L_y_norm, /* Q30 */ + Word16 *y_norm); /* Q14 */ + + +void FESSdeenum_fx(Word16 dim_in_fx, /* i : dimension of vec_out typically (M-1 == 15) */ + Word16 n_env_fx, /* i : number of envelopes */ + Word16 n_shift_fx, /* i : number shifts */ + Word16 n_signs_fx, /* i : number signs */ + Word16 env_ind_fx, /* i:indx */ + Word16 shift_ind_fx, /* i:indx */ + Word16 sign_ind_fx, /* i:indx */ + Word16* vec_out_fx /* o : FESS integer pulse train , with signs applied */ +); + +Word16 snsQuantScfDecLR_fx( /* BER_flag */ + Word32* L_sns_vq_idx_fx, + Word32* L_scf_q_fx, + Word16* scf_q_fx, + Word16 pitch_rx_fx, + Word16 ltpf_rx_fx, + Word8 * scratch); + + +Word16 MSEsearchCbBIdxMap_fx( + const Word16 *scf, const Word16 *LFCB, const Word16 *HFCB, const Word16 *seg_cnt_cum, const Word16* idx12b_cb, Word16 v_len, Word16 cb_len, Word32* min_mse +); +Word16 MSEsearchGenericScaledW8_fx( + Word16 *scf, const Word8 *sns_CBW8, Word16 scaleQ4, Word16 inv_scaleQ15, Word16 v_len, Word16 cb_len, Word32* L_min_mse +); +Word16 MSEsearchGeneric_fx( + Word16 *scf, const Word16 *sns_CB, Word16 v_len, Word16 cb_len, Word32* L_min_mse +); + +void pvq_fess_enc_search_fx( + const Word16 *x_in, /* i: target vector to quantize Qin 0...M-1 */ + Word16 * y_Q0, /* o: raw integer pulses (non-scaled short) Q0 , length 3*M */ + Word16 * y_normQ14, /* o: normlized integer pulses (non-scaled short) Q14 , length 3*M */ + Word32 * L_y_normQ30, + Word16 * s_idx, /* o: quantized shape index, 0,1,2 */ + Word16 * g_idx, /* o: quantized gain index, 0..3, or 0..7 */ + Word16 * g_valQ12Ptr, /* o: quantized gain value, in Q12 -32767 == 7.99975 for best shape */ + Word16 * fixShapeNb, /* o: idx for the selected fix shape y_fix 0...3, relevant in the case s_idx==2 */ + Word16 * fixShiftIdxPtr, + Word32 * L_MSEQ22Ptr, /* o: 1 Q11+Q0+1 --> Q22 */ + Word8 * scratch +); + +Word32 snsQuantScfEncLRSt1ABC_fx(Word16* env, Word32* L_index, Word32 *L_min_mse_saveBCA_ptr_fx, + Word16* ind_saveB_ptr, Word16* st1_vectors, + Word16 pitch_rx, Word16 ltpf_rx, Word8* scratch); + +Word16 snsQuantScfEncLR_fx( /* o: bits spent on LRSNS-VQ envelope */ + Word16 scf_fx[], /* i: input scf M W16Q11 */ + Word32 *L_index_fx, /* o: SNS indeces . */ +#ifdef ENABLE_HR_MODE + Word32 *L_scf_q_fx, /* o: quantizefl_env scf M W16Q11 */ +#else + Word16 *scf_q_fx, /* o: quantizefl_env scf M W16Q11 */ +#endif + Word16 pitch_rx_fx, /*i: 0 or 1 */ + Word16 ltpf_rx_fx, /*i: 0 or 1 */ + Word8 * scratch); + + + +void dct16_fx(const Word16 *in, Word16 *out); +void dct16_updated_fx(const Word16 *in, Word16 *out); +void dct16_W32int_fx(const Word16 *in, Word16 *out); + +void writeSNSData_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, LC3PLUS_FrameDuration frame_dms, Word32* L_scf_idx); + +#endif /* CR9_C_ADD_1p25MS_LRSNS */ + + +#ifdef NEW_SIGNALLING_SCHEME_1p25 +void writeLtpData_fx(UWord8 *ptr, Word16 *bp_side, Word16 *mask_side, Word16* ltpf_idx, Word16* Tx_ltpf); +#endif + + + + Word16 processAriEncoder_fx(UWord8 *bytes, Word16 bp_side, Word16 mask_side, Word16 nbbits, #ifdef ENABLE_HR_MODE Word32 xq[], @@ -250,7 +369,7 @@ Word16 processAriEncoder_fx(UWord8 *bytes, Word16 bp_side, Word16 mask_side, Wor void processAriDecoder_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 L_spec, Word16 fs_idx, Word16 enable_lpc_weighting, Word16 tns_numfilters, Word16 lsbMode, Word16 lastnz, Word16 *bfi, Word16 *tns_order, Word16 fac_ns_idx, Word16 gg_idx, - Word16 frame_dms, + LC3PLUS_FrameDuration frame_dms, Word16 n_pc, Word16 be_bp_left, Word16 be_bp_right, Word16 mode, Word16 *spec_inv_idx, Word16 *b_left, Word16 *resBits, @@ -276,7 +395,7 @@ void processAriDecoderScaling_fx( void processApplyGlobalGain_fx(Word32 x[], Word16 *x_e, Word16 xLen, Word16 global_gain_idx, Word16 global_gain_off); void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Word16 d_fx_exp, - const Word16 *band_offsets, Word16 fs_idx, Word16 n_bands, Word16 linear, Word16 frame_dms, + const Word16 *band_offsets, Word16 fs_idx, Word16 n_bands, Word16 linear, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -286,28 +405,35 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_idx, const Word16 near_nyquist_index, const Word16 bands_number, const Word32 *ener_fx, const Word16 ener_fx_exp #ifdef ENABLE_HR_MODE - , Word16 frame_dms , Word16 hrmode); -#else - ); + , LC3PLUS_FrameDuration frame_dms , Word16 hrmode #endif -void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 frame_dms); + ); + +void processDetectCutoffWarped_fx(Word16 *bw_idx, Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, LC3PLUS_FrameDuration frame_dms); void process_resamp12k8_fx(Word16 x[], Word16 x_len, Word16 mem_in[], Word16 mem_in_len, Word32 mem_50[], Word16 mem_out[], Word16 mem_out_len, Word16 y[], Word16 *y_len, Word16 fs_idx, - Word16 frame_dms, Word8 *scratchBuffer + LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer , Word16 bps ); void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[], Word16 *pitch, Word16 *s12k8, - Word16 len, Word16 *normcorr, Word16 *mem_pitch, + Word16 len, Word16 *normcorr, Word16 *mem_pitch, Word16 *pitch_flag, - Word16 s12k8_exp, Word16 frame_dms, Word8 *scratchBuffer); + Word16 s12k8_exp, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer); void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Word16 *old_wsp_exp, Word16 *old_wsp, Word16 old_wsplen, Word16 *param, Word16 *wsp, Word16 len, Word16 *mem_normcorr, Word16 *mem_mem_normcorr, Word16 ol_normcorr, Word16 *mem_ltpf_on, Word16 *mem_ltpf_pitch, - Word16 wsp_exp, Word16 frame_dms, Word8 *scratchBuffer - , Word16 hrmode + Word16 wsp_exp, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer + , Word16 hrmode +#ifdef CR9_C_ADD_1p25MS +#ifdef NEW_SIGNALLING_SCHEME_1p25 + , Word16* Tx_ltpf +#else + , Word16 Tx_ltpf +#endif +#endif ); void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word16 fs_idx, Word16 old_y_len, @@ -315,14 +441,22 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word Word16 ltpf_active, Word16 pitch_index, Word16 *old_pitch_int, Word16 *old_pitch_fr, Word16 *old_gain, Word16 *mem_ltpf_active, Word16 scale_fac_idx, Word16 bfi, Word16 concealMethod, - Word16 damping, Word16 *old_scale_fac_idx, - Word32 *rel_pitch_change, Word16 hrmode, Word16 frame_dms, - Word8 *scratchBuffer); + Word16 damping, Word16 *old_scale_fac_idx, + Word32 *rel_pitch_change, Word16 hrmode, LC3PLUS_FrameDuration frame_dms, + Word8 *scratchBuffer +#ifdef CR9_C_ADD_1p25MS + , Word16* mem_continuation, Word16* mem_pitch_int_prev, + Word16* mem_pitch_fr_prev, Word16* mem_beta_idx_prev, Word16* mem_gain_prev, Word16 *mem_ltpf_active_prev, Word16* pitch_stability_counter +#endif + ); void attack_detector_fx(LC3PLUS_Enc *enc, EncSetup *setup, Word16 *input, Word16 input_scaling, void *scratch); void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 *scf, Word16 scf_smoothing_enabled, Word16 attdec_damping_factor, Word8 *scratchBuffer, Word16 sns_damping +#ifdef CR9_C_ADD_1p25MS + , LC3PLUS_FrameDuration frame_dms, Word16 norm_corr, Word16 *LT_normcorr +#endif ); void processSnsQuantizeScfEncoder_fx(Word16 scf[], /* i: input scf M */ @@ -338,7 +472,7 @@ Word16 processSnsQuantizeScfDecoder_fx( /* Word32 *L_prm_idx, /* i: indeces */ #ifdef ENABLE_HR_MODE Word32 scf_q[], -#else +#else Word16 scf_q[], #endif Word8 *scratchBuffer); /* o: M */ @@ -366,7 +500,7 @@ void processPLCmain_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLostFram Word16 *ola_mem_exp, Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], Word16 *q_fx_exp, Word16 yLen, Word16 fs_idx, const Word16 *band_offsets, Word16 bands_number, Word16 *damping, Word16 old_pitch_int, Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, - AplcSetup *plcAd, Word16 frame_dms, Word8 *scratchBuffer, Word16 *pc_nbLostFramesInRow + AplcSetup *plcAd, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer, Word16 *pc_nbLostFramesInRow #ifdef ENABLE_HR_MODE , Word16 hrmode #endif @@ -395,7 +529,7 @@ void processPLCUpdateAfterIMDCT_fx(Word16 x_fx[], Word16 q_fx_exp, Word16 concea Word16 scf_q[], Word16 *ns_cum_alpha, AplcSetup *plcAd); void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLostFramesInRow, Word16 bfi, - Word16 ltpf_mem_pitch_int, Word16 frame_length, Word16 frame_dms, Word16 fs_idx, Word16 yLen, + Word16 ltpf_mem_pitch_int, Word16 frame_length, LC3PLUS_FrameDuration frame_dms, Word16 fs_idx, Word16 yLen, Word16 q_old_d_fx[], const Word16 *band_offsets, Word16 bands_number, AplcSetup *plcAd, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -403,7 +537,7 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost ); void processPLCapply_fx( - Word16 *concealMethod, + Word16 *concealMethod, Word16 nbLostFramesInRow, Word16 bfi, Word16 prev_bfi, Word16 frame_length, Word16 la_zeroes, #ifdef ENABLE_HR_MODE @@ -414,7 +548,7 @@ void processPLCapply_fx( Word16 x_fx[], Word16 ola_mem[], Word16 *ola_mem_exp, Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], Word16 *q_fx_exp, Word16 yLen, Word16 fs_idx, Word16 *damping, Word16 old_pitch_int, - Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, Word16 frame_dms, AplcSetup *plcAd, + Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, LC3PLUS_FrameDuration frame_dms, AplcSetup *plcAd, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -427,15 +561,15 @@ void processPLCNoiseSubstitution_fx(Word32 spec[], Word16 spec_prev[], Word16 L_ void processPLCDampingScrambling_main_fx(Word16 bfi, Word16 concealMethod, Word16 ns_nbLostFramesInRow, Word16 *cum_fflcAtten, Word16 pc_nbLostFramesInRow, Word16 *ns_seed, Word16 *pc_seed, Word16 pitch_present_bfi1, Word16 pitch_present_bfi2, Word32 spec[], Word16 *q_fx_exp, Word16 *q_old_d_fx, - Word16 *q_old_fx_exp, Word16 L_spec, Word16 stabFac, Word16 frame_dms, + Word16 *q_old_fx_exp, Word16 L_spec, Word16 stabFac, LC3PLUS_FrameDuration frame_dms, Word16 *cum_fading_slow, Word16 *cum_fading_fast, Word16 spec_inv_idx - , UWord8 plc_fadeout_type + , UWord8 plc_fadeout_type ); void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostFramesInRow, Word16 stabFac, Word16 processDampScramb, - Word16 *cum_fflcAtten, Word16 pitch_present, Word16 frame_dms, Word16 *cum_fading_slow, + Word16 *cum_fflcAtten, Word16 pitch_present, LC3PLUS_FrameDuration frame_dms, Word16 *cum_fading_slow, Word16 *cum_fading_fast, Word16 *seed, Word16 spec_inv_idx - , UWord8 plc_fadeout_type + , UWord8 plc_fadeout_type ); void processLagwin_fx(Word32 r[], const Word32 w[], Word16 m); @@ -443,7 +577,7 @@ void processLagwin_fx(Word32 r[], const Word32 w[], Word16 m); void processInverseODFT_fx(Word32 *r_fx, Word16 *r_fx_exp, Word32 *d2_fx, Word16 d2_fx_exp, Word16 n_bands, Word16 lpc_order, Word8 *scratchBuffer); -void processPreEmphasis_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 frame_dms, +void processPreEmphasis_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word16 fs_idx, Word16 n_bands, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer); void processPLCLpcScaling_fx(Word32 tdc_A_32[], Word16 tdc_A_16[], Word16 m); @@ -451,24 +585,24 @@ void processPLCLpcScaling_fx(Word32 tdc_A_32[], Word16 tdc_A_16[], Word16 m); void processPLCcomputeStabFac_main(Word16 scf_q[], Word16 old_scf_q[], Word16 old_old_scf_q[], Word16 bfi, Word16 prev_bfi, Word16 prev_prev_bfi, Word16 *stab_fac); -void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, - Word16 *xfp_fx, Word16 xfp_exp_fx,Word16 margin_xfp, - Word16 fs_idx, - Word32 *L_oold_xfp_w_E_fx, Word16 *oold_xfp_w_E_exp_fx, - Word32 *L_old_xfp_w_E_fx, Word16 *old_xfp_w_E_exp_fx, - Word16 *oold_Ltot_exp_fx, Word16 *old_Ltot_exp_fx); +void processPLCUpdateXFP_w_E_hist_fx(Word16 prev_bfi, Word16 bfi, + Word16 *xfp_fx, Word16 xfp_exp_fx,Word16 margin_xfp, + Word16 fs_idx, + Word32 *L_oold_xfp_w_E_fx, Word16 *oold_xfp_w_E_exp_fx, + Word32 *L_old_xfp_w_E_fx, Word16 *old_xfp_w_E_exp_fx, + Word16 *oold_Ltot_exp_fx, Word16 *old_Ltot_exp_fx); void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 preemphFac_fx, const Word16 *A_fx, const Word16 lpc_order, const Word16 *pcmbufHist_fx, - const Word16 frame_length, const Word16 frame_dms, const Word16 fs_idx, + const Word16 frame_length, const LC3PLUS_FrameDuration frame_dms, const Word16 fs_idx, const Word16 nbLostFramesInRow, const Word16 overlap, - const Word16 stabFac_fx, Word16 *fract, Word16 *seed_fx, + const Word16 stabFac_fx, Word16 *fract, Word16 *seed_fx, Word32 *gain_c_fx, Word16 *synth_fx, Word16 *Q_syn, Word16 *alpha, Word16 max_len_pcm_plc, Word16 harmonicBuf_fx[MAX_PITCH], Word16 synthHist_fx[M], Word16 *const harmonicBuf_Q, Word8 *scratchBuffer , UWord8 plc_fadeout_type - , Word16 *alpha_type_2_table + ,Word16 *alpha_type_2_table ); void processTdac_fx(Word16 *ola_mem, Word16 *ola_mem_exp, const Word16 *synth, const Word16 synth_exp, @@ -530,8 +664,8 @@ void trans_burst_ana_fx(const Word16 *xfp, /* i : Input signal Word16 * Xavg, /* o : Frequency group average gain to fade to */ Word16 Q_spec, Word32 L_oold_xfp_w_E_fx, Word16 oold_xfp_w_E_exp_fx, Word16 oold_Ltot_exp_fx, Word16 *oold_grp_shape_fx, Word32 L_old_xfp_w_E_fx, Word16 old_xfp_w_E_exp_fx, - Word16 old_Ltot_exp_fx, Word16 *old_grp_shape_fx, - Word16 fadeout, + Word16 old_Ltot_exp_fx, Word16 *old_grp_shape_fx, + Word16 fadeout, Word32 *L_Xavg, /* full scale average band amplitudes */ Word8 *scratchBuffer); @@ -540,9 +674,9 @@ void spec_ana_fx(Word16 *xfp, Word16 *, Word32 *, Word16 *, Word16 *, const Word void subst_spec_fx(const Word16 *, const Word32 *, Word16 *, const Word16, Word16 *, const Word16 *, const Word16, const Word16 *, const Word16, Word16 *, const Word16 *, const Word16 *, const Word16 *, const Word16 - ,const Word16, + ,const Word16, Word16*, - const Word32 * + const Word32 * ); void rec_frame_fx(Word16 * X, /* i : FFT spectrum */ @@ -595,8 +729,8 @@ void hq_phase_ecu_fx(const Word16 *prevsynth, /* i : buffer of previously synth Word8 *scratchBuffer /* Size = 2 * MAX_LGW + 8 * MAX_LPROT + 12 * MAX_L_FRAME */ ); -Word16 -plc_xcorr_lc_fx(/* o: quantized output xcorr in Q15 [ 0 ..32767 ] = [0. 1.0[ */ + +Word16 plc_xcorr_lc_fx(/* o: quantized output xcorr in Q15 [ 0 ..32767 ] = [0. 1.0[ */ Word16 * pcmbuf_fx, /* NB should be an already dynamically upscaled buffer with about 0...1 bits margin */ Word16 max_len_pcm_plc, /* Q0 size of pcmbuf_fx */ @@ -614,7 +748,7 @@ Word16 initQV(Word16 SR_idx, Word32 BR); void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 sqTargetBits, #ifdef ENABLE_HR_MODE Word32 *gain, -#else +#else Word16 *gain, #endif Word16 *gain_e, @@ -622,7 +756,11 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 sqTa Word32 *targetBitsOff, Word16 *old_targetBits, Word16 old_specBits, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE - , Word16 hrmode, Word16 regBits, Word16 frame_dms + , Word16 hrmode, Word16 regBits, LC3PLUS_FrameDuration frame_dms +#else +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 + , LC3PLUS_FrameDuration frame_dms +#endif #endif ); @@ -635,7 +773,7 @@ void processAdjustGlobalGain_fx(Word16 *gg_idx, Word16 gg_idx_min, Word16 gg_idx Word16 *gain_e, Word16 target, Word16 nBits, Word16 *gainChange, Word16 fs_idx #ifdef ENABLE_HR_MODE - , Word16 hrmode, Word16 frame_dms + , Word16 hrmode, LC3PLUS_FrameDuration frame_dms #endif ); @@ -645,8 +783,8 @@ void processScalarQuant_fx(Word32 x[], Word16 x_e, Word16 xq[], Word16 L_frame, void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word32 gain, Word16 gain_e, Word32 xq[], Word16 nt, Word16 target, Word16 totalBits, Word16 *nBits, Word16 *nBits2, Word16 fs_idx, Word16 *lastnz, Word16 *codingdata, Word16 *lsbMode, Word16 mode, Word16 hrmode); -#else -void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word16 gain, Word16 gain_e, Word16 xq[], Word16 nt, +#else +void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word16 gain, Word16 gain_e, Word16 xq[], Word16 nt, Word16 target, Word16 totalBits, Word16 *nBits, Word16 *nBits2, Word16 fs_idx, Word16 *lastnz, Word16 *codingdata, Word16 *lsbMode, Word16 mode); @@ -664,6 +802,9 @@ void processResidualCoding_fx(Word16 x_e, Word32 x[], #ifdef ENABLE_HR_MODE , Word16 hrmode #endif +#if defined (CR9_C_ADD_1p25MS) + , LC3PLUS_FrameDuration frame_dms +#endif ); void scale_signal24_fx(Word32 x[], /* i: time input signal */ @@ -696,8 +837,8 @@ void fec_encoder(Word16 mode, Word16 epmr, UWord8 *iobuf, Word16 data_bytes, Wor int fec_decoder(UWord8 *iobuf, Word16 slot_bytes, int *data_bytes, Word16 *epmr, Word16 ccc_flag, Word16 *n_pccw, int *bfi, Word16 *be_bp_left, Word16 *be_bp_right, Word16 *n_pc, Word16 *m_fec, void *scratch); -void processPCmain_fx(Word16 rframe, Word16 *bfi, Word16 yLen, Word16 frame_dms, Word16 q_old_res_fx[], - Word16 *q_old_res_fx_exp, +void processPCmain_fx(Word16 rframe, Word16 *bfi, Word16 yLen, LC3PLUS_FrameDuration frame_dms, Word16 q_old_res_fx[], + Word16 *q_old_res_fx_exp, #ifdef ENABLE_HR_MODE Word32 q_res_fx[], #else @@ -707,7 +848,7 @@ void processPCmain_fx(Word16 rframe, Word16 *bfi, Word16 yLen, Word16 frame_dms, Word16 pitch_present, Word16 stab_fac, Word32 q_d_fx[], Word16 *q_fx_exp, Word16 gg_idx, Word16 gg_idx_off, Word16 *prev_gg, Word16 *prev_gg_e, Word16 *BW_cutoff_idx_nf, Word16 *prev_BW_cutoff_idx_nf, Word16 fac_ns_idx, Word16 *prev_fac_ns_fx, Word16 *pc_nbLostFramesInRow); -void processPCclassify_fx(Word16 pitch_present, Word16 frame_dms, Word16 q_old_d_fx[], Word16 q_old_res_fx[], +void processPCclassify_fx(Word16 pitch_present, LC3PLUS_FrameDuration frame_dms, Word16 q_old_d_fx[], Word16 q_old_res_fx[], Word16 yLen, Word16 spec_inv_idx, Word16 stab_fac, Word16 *bfi); void processPCapply_fx(Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_exp, #ifdef ENABLE_HR_MODE @@ -745,12 +886,28 @@ void write_indice_backward(UWord8 *ptr, Word16 *bp, Word16 *mask, Word16 indice, void processEncoderEntropy(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 targetBytes, Word16 L_spec, Word16 BW_cutoff_bits, Word16 tns_numfilters, Word16 lsbMode, Word16 lastnz, Word16 *tns_order, Word16 fac_ns_idx, Word16 gg_idx, Word16 BW_cutoff_idx, Word16 *ltpf_idx, - Word32 *L_scf_idx, Word16 bfi_ext, Word16 fs_idx); + Word32 *L_scf_idx, Word16 bfi_ext, Word16 fs_idx +#ifdef CR9_C_ADD_1p25MS + , LC3PLUS_FrameDuration frame_dms, Word16* Tx_ltpf +#endif + ); void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, Word16 nbbits, Word16 L_spec, Word16 fs_idx, Word16 BW_cutoff_bits, Word16 *tns_numfilters, Word16 *lsbMode, Word16 *lastnz, Word16 *bfi, Word16 *tns_order, Word16 *fac_ns_idx, Word16 *gg_idx, - Word16 *BW_cutoff_idx, Word16 *ltpf_idx, Word32 *L_scf_idx, Word16 frame_dms); + Word16 *BW_cutoff_idx, Word16 *ltpf_idx, Word32 *L_scf_idx, LC3PLUS_FrameDuration frame_dms +#ifdef CR9_C_ADD_1p25MS + , Word16 rx_status[2], Word16* mem_continuation +#ifdef NEW_SIGNALLING_SCHEME_1p25 + , Word16 *ltpfinfo_frame_cntr_fx +#endif +#endif + ); + +#ifdef NEW_SIGNALLING_SCHEME_1p25 +void readLtpData_fx(UWord8* ptr, Word16* bfiPtr, Word16* mask_side, Word16* bp_side, Word16* ltpf_idx, Word16* rx_status, + Word16* ltpfinfo_frame_cntr_fx, Word16* mem_continuation); +#endif #ifdef ENABLE_PADDING int paddingDec_fx(UWord8 *bytes, Word16 nbbits, Word16 L_spec, Word16 BW_cutoff_bits, Word16 ep_enabled, @@ -759,7 +916,7 @@ int paddingDec_fx(UWord8 *bytes, Word16 nbbits, Word16 L_spec, Word16 BW_cuto Word16 read_bit(UWord8 *ptr, Word16 *bp, Word16 *mask); -/* setup_enc_lc3.c */ +/* setup_enc_lc3plus.c */ int alloc_encoder(LC3PLUS_Enc *encoder, int samplerate, int channels); void set_enc_frame_params(LC3PLUS_Enc *encoder); LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate); @@ -770,7 +927,7 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc *encoder, int samplerate, int channels , int32_t lfe_channel_array[] ); -/* setup_dec_lc3.c */ +/* setup_dec_lc3plus.c */ int alloc_decoder(LC3PLUS_Dec *decoder, int samplerate, int channels); void set_dec_frame_params(LC3PLUS_Dec *decoder); LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec *decoder, int ch, Word16 nBytes); @@ -786,6 +943,10 @@ LC3PLUS_Error Dec_LC3PLUS(LC3PLUS_Dec *decoder, UWord8 *input, int input_bytes, void *balloc(void *base, size_t *base_size, size_t size); -Word16 type_2_fadeout_fx(Word16 nbLostFramesInRow, Word16 frame_dms); +#ifdef FIX_BOTH_1p25_WB_GLOBGAINOFFSET_NONBE +Word16 calc_GGainOffset_1p25_fx(Word16 total_bits, Word16 fs_idx); +#endif -#endif +Word16 type_2_fadeout_fx(Word16 nbLostFramesInRow, LC3PLUS_FrameDuration frame_dms); + +#endif /* FUNCTIONS_H */ diff --git a/lib_lc3plus/imdct_fx.c b/lib_lc3plus/imdct_fx.c index 8fdf06671..70e76c8c5 100644 --- a/lib_lc3plus/imdct_fx.c +++ b/lib_lc3plus/imdct_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void ProcessingIMDCT( @@ -28,7 +30,7 @@ void ProcessingIMDCT( Word16 wLen, /* i: window length */ Word16 N, /* i: block size */ Word16 memLen, /* i: overlap add buffer size */ - Word16 frame_dms, /* i: frame size in ms */ + LC3PLUS_FrameDuration frame_dms, /* i: frame size in ms */ Word16 concealMethod, /* i: concealment method */ Word16 bfi, /* i: bad frame indicator */ Word16 prev_bfi, /* i: previous bad frame indicator */ @@ -82,18 +84,24 @@ void ProcessingIMDCT( { SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + max_bw = MAX_BW >> 3; move16(); + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: max_bw = MAX_BW >> 2; move16(); BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: max_bw = MAX_BW >> 1; move16(); BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: max_bw = (MAX_BW >> 2) * 3; move16(); BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: max_bw = MAX_BW; move16(); BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } } @@ -116,11 +124,11 @@ void ProcessingIMDCT( #else dct_IV(y, y_e, N, workBuffer); #endif - y_s = getScaleFactor32_lc3plus(y, N); + y_s = getScaleFactor32(y, N); y_s = sub(y_s, 1); *y_e = sub(*y_e, y_s + 3); /* mdct window is scaled by pow(2,x) */ /* N<=20 only happens for 2.5ms frames in NB */ - if (sub(N, 20) <= 0) + if (sub(N, 30) <= 0) { *y_e = add(*y_e, 2); } @@ -300,7 +308,7 @@ void Processing_ITDA_WIN_OLA( L_y = L_x_tda; /* use same variables naming as in IMDCT for DCT-IV output signal y */ - y_s = getScaleFactor32_lc3plus(L_y, N); + y_s = getScaleFactor32(L_y, N); y_s = sub(y_s, 1); /* add 1 bit margin , y_s is now initial tda upscaling factor */ diff --git a/lib_lc3plus/lc3.c b/lib_lc3plus/lc3plus.c similarity index 88% rename from lib_lc3plus/lc3.c rename to lib_lc3plus/lc3plus.c index e8a73aec8..aed8e029b 100644 --- a/lib_lc3plus/lc3.c +++ b/lib_lc3plus/lc3plus.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,35 +7,35 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" -#include "lc3.h" -#include "setup_dec_lc3.h" -#include "setup_enc_lc3.h" +#include "lc3plus.h" +#include "setup_dec_lc3plus.h" +#include "setup_enc_lc3plus.h" #define RETURN_IF(cond, error) \ if (cond) \ return (error) -#ifndef FIX_IVAS_LC3PLUS_WARNINGS #ifdef SUBSET_NB -#pragma message("- SUBSET_NB") +// #pragma message("- SUBSET_NB") #endif #ifdef SUBSET_WB -#pragma message("- SUBSET_WB") +// #pragma message("- SUBSET_WB") #endif #ifdef SUBSET_SSWB -#pragma message("- SUBSET_SSWB") +// #pragma message("- SUBSET_SSWB") #endif #ifdef SUBSET_SWB -#pragma message("- SUBSET_SWB") +// #pragma message("- SUBSET_SWB") #endif #ifdef SUBSET_FB -#pragma message("- SUBSET_FB") +// #pragma message("- SUBSET_FB") #endif #ifdef SUBSET_UB -#pragma message("- SUBSET_UB") -#endif +// #pragma message("- SUBSET_UB") #endif /* ensure api header constants are up to date */ @@ -86,6 +86,7 @@ int lc3plus_samplerate_supported(int samplerate) #endif default: return 0; } + return 0; } static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) @@ -96,19 +97,24 @@ static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) return 1; default: return 0; } + return 0; } -static int lc3plus_frame_size_supported(int frame_dms) +static int lc3plus_frame_size_supported(LC3PLUS_FrameDuration frame_dms) { switch (frame_dms) { - case 25: /* fallthru */ - case 50: /* fallthru */ - case 75: /* fallthru */ - case 100: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: /* fallthru */ +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: /* fallthru */ + case LC3PLUS_FRAME_DURATION_5MS: /* fallthru */ + case LC3PLUS_FRAME_DURATION_7p5MS: /* fallthru */ + case LC3PLUS_FRAME_DURATION_10MS: return 1; default: return 0; } + return 0; } static int null_in_list(void **list, int n) @@ -121,9 +127,9 @@ static int null_in_list(void **list, int n) /* return pointer to aligned base + base_size, *base_size += size + 4 bytes align */ void *balloc(void *base, size_t *base_size, size_t size) { - uintptr_t ptr = ((uintptr_t)base + *base_size + 3) & (uintptr_t)(~3); + uintptr_t ptr = ((uintptr_t)base + *base_size + 3) & ~3; assert((uintptr_t)base % 4 == 0); /* base must be 4-byte aligned */ - *base_size = (*base_size + size + 3) & (uintptr_t)(~3); + *base_size = (*base_size + size + 3) & ~3; return (void *)ptr; } @@ -213,9 +219,13 @@ int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc *encoder) { totalBytes += encoder->channel_setup[ch]->targetBytes; } - +#ifdef CR9_C_ADD_1p25MS + int frame_ns = (int)(1250L*(encoder->frame_dms)); + int bitrate = (long long int)((totalBytes * 8L) * 1000000L + (frame_ns - 1L)) / (frame_ns); +#else int bitrate = (totalBytes * 80000.0 + encoder->frame_dms - 1) / encoder->frame_dms; - +#endif + if (encoder->fs_in == 44100) { int rem = bitrate % 480; @@ -254,11 +264,15 @@ LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpMo return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_dms) +LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, LC3PLUS_FrameDuration frame_dms) { RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); RETURN_IF(!lc3plus_frame_size_supported(frame_dms), LC3PLUS_FRAMEMS_ERROR); RETURN_IF(encoder->lc3_br_set, LC3PLUS_BITRATE_SET_ERROR); +#ifdef CR9_C_ADD_1p25MS + RETURN_IF(encoder->fs == 8000 && frame_dms == LC3PLUS_FRAME_DURATION_1p25MS, LC3PLUS_SAMPLERATE_ERROR); +#endif + encoder->frame_dms = frame_dms; set_enc_frame_params(encoder); return LC3PLUS_OK; @@ -385,12 +399,15 @@ LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder return (LC3PLUS_EpModeRequest)decoder->epmr; } -LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_dms) +LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, LC3PLUS_FrameDuration frame_dms) { RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); RETURN_IF(!lc3plus_frame_size_supported(frame_dms), LC3PLUS_FRAMEMS_ERROR); - RETURN_IF(decoder->plcMeth == 2 && frame_dms != 100, LC3PLUS_FRAMEMS_ERROR); - + RETURN_IF(decoder->plcMeth == 2 && frame_dms != LC3PLUS_FRAME_DURATION_10MS, LC3PLUS_FRAMEMS_ERROR); +#ifdef CR9_C_ADD_1p25MS + RETURN_IF(decoder->fs == 8000 && frame_dms == LC3PLUS_FRAME_DURATION_1p25MS, LC3PLUS_SAMPLERATE_ERROR); +#endif + decoder->frame_dms = frame_dms; set_dec_frame_params(decoder); return LC3PLUS_OK; diff --git a/lib_lc3plus/lc3.h b/lib_lc3plus/lc3plus.h similarity index 95% rename from lib_lc3plus/lc3.h rename to lib_lc3plus/lc3plus.h index 1021afa14..2ac69c9a9 100644 --- a/lib_lc3plus/lc3.h +++ b/lib_lc3plus/lc3plus.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,7 +7,7 @@ * estoppel or otherwise. * ******************************************************************************/ -/*! \file lc3.h +/*! \file lc3plus.h * This header provides the API for LC3plus. * * This library is targeting devices with extreme memory limitations, so memory management @@ -23,11 +23,12 @@ */ #ifndef LC3PLUS_H -#define LC3PLUS_H - +#define LC3PLUS_H #define ENABLE_HR_MODE #ifndef _MSC_VER +#include "options.h" +#include "wmc_auto.h" #include #else typedef __int16 int16_t; @@ -38,7 +39,7 @@ typedef __int32 int32_t; #define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro)) /*! Version number to ensure header and binary are matching. */ -#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 7, 4) +#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 8, 0) /*! Maximum number of supported channels. The actual binary might support * less, use lc3plus_channels_supported() to check. */ @@ -58,6 +59,9 @@ typedef __int32 int32_t; #define LC3PLUS_MAX_BYTES 870 #endif + + + /*! Maximum size needed to store encoder state. */ #ifdef ENABLE_HR_MODE #define LC3PLUS_ENC_MAX_SIZE 12628 @@ -72,6 +76,18 @@ typedef __int32 int32_t; #define LC3PLUS_DEC_MAX_SIZE 28446 #endif +#ifdef LRSNS_MORE_SCRATCH + +#ifdef ENABLE_HR_MODE +#define LC3PLUS_ENC_MAX_SCRATCH_SIZE (2*32767) +#define LC3PLUS_DEC_MAX_SCRATCH_SIZE (2*32767) +#else +#define LC3PLUS_ENC_MAX_SCRATCH_SIZE (2*32767) +#define LC3PLUS_DEC_MAX_SCRATCH_SIZE (2*32767) +#endif + +#else + /*! Maximum scratch size needed by lc3plus_enc16() or lc3plus_enc24().*/ #ifdef ENABLE_HR_MODE #define LC3PLUS_ENC_MAX_SCRATCH_SIZE 45624 @@ -85,6 +101,20 @@ typedef __int32 int32_t; #else #define LC3PLUS_DEC_MAX_SCRATCH_SIZE 27474 #endif + +#endif + +typedef enum { + LC3PLUS_FRAME_DURATION_UNDEFINED = 0, /* Invalid */ +#ifdef CR9_C_ADD_1p25MS + LC3PLUS_FRAME_DURATION_1p25MS = 1, /* 1.25 ms */ +#endif + LC3PLUS_FRAME_DURATION_2p5MS = 2, /* 2.5 ms */ + LC3PLUS_FRAME_DURATION_5MS = 4, /* 5 ms */ + LC3PLUS_FRAME_DURATION_7p5MS = 6, /* 7.5 ms */ + LC3PLUS_FRAME_DURATION_10MS = 8, /* 10 ms */ +} LC3PLUS_FrameDuration; + /*! Decoder packet loss concealment mode */ typedef enum { @@ -321,7 +351,7 @@ int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder); * \param[in] frame_ms Frame length in ms. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_ms); +LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, LC3PLUS_FrameDuration frame_ms); /*! Set error protection mode. The default is LC3PLUS_EP_OFF. It is possible to switch between * different modees during encoding. Dynamic switching is only allowed between LC3PLUS_EP_ZERO, @@ -465,7 +495,7 @@ int lc3plus_dec_get_delay(const LC3PLUS_Dec *decoder); * \param[in] frame_ms Frame length in ms. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_ms); +LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, LC3PLUS_FrameDuration frame_ms); /*! Enable or disable error protection. Default value is 0 (disabled). If error protection is * enabled, the decoder expects that the frames were encoded with error protection mode @@ -519,4 +549,4 @@ int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder); int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder); /*! \} */ -#endif /* LC3plus */ +#endif /* LC3PLUS_H */ diff --git a/lib_lc3plus/levinson_fx.c b/lib_lc3plus/levinson_fx.c index 0aa4b2e2c..3cb547439 100644 --- a/lib_lc3plus/levinson_fx.c +++ b/lib_lc3plus/levinson_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void processLevinson_fx(Word32 *lpc, Word32 *ac, Word16 N, Word16 *rc, Word32 *pred_err, Word8 *scratchBuffer) diff --git a/lib_lc3plus/license.h b/lib_lc3plus/license.h index 684166bf4..a692e0ed4 100644 --- a/lib_lc3plus/license.h +++ b/lib_lc3plus/license.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,13 +7,15 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" static const char *const LICENSE = "*******************************************************************************\n" - "* ETSI TS 103 634 V1.5.1 *\n" + "* ETSI TS 103 634 V1.6.1 *\n" "* Low Complexity Communication Codec Plus (LC3plus) *\n" - "* Fixed Point Software V%i.%i.%iETSI, " __DATE__ " *\n" + "* Fixed Point Software V%i.%i.%iETSI, " __DATE__ " *\n" "* Copyright licence is solely granted through ETSI Intellectual Property *\n" "* Rights Policy, 3rd April 2019. No patent licence is granted by implication, *\n" "* estoppel or otherwise. *\n" diff --git a/lib_lc3plus/ltpf_coder_fx.c b/lib_lc3plus/ltpf_coder_fx.c index e5ae9c5f2..bf2ea18ab 100644 --- a/lib_lc3plus/ltpf_coder_fx.c +++ b/lib_lc3plus/ltpf_coder_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,16 +7,29 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" +#ifdef CR9_C_ADD_1p25MS_LRSNS +#include "constants.h" +#endif + /*************************************************************************/ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Word16 *mem_in_exp, Word16 mem_in[], Word16 mem_in_len, Word16 param[], Word16 *xin, Word16 len, Word16 *mem_normcorr, Word16 *mem_mem_normcorr, Word16 ol_normcorr, Word16 *mem_ltpf_on, Word16 *mem_ltpf_pitch, - Word16 xin_exp, Word16 frame_dms, Word8 *scratchBuffer - , Word16 hrmode + Word16 xin_exp, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer + , Word16 hrmode +#ifdef CR9_C_ADD_1p25MS +#ifdef NEW_SIGNALLING_SCHEME_1p25 + , Word16* Tx_ltpf +#else + , Word16 Tx_ltpf +#endif +#endif ) { Word16 pitch_index, scale0, scale1, scale2, *x, x_exp, shift, prod_exp, ltpf_pitch; @@ -27,6 +40,9 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo Word16 pitch, pitch_res, min_pitch_fr, pitch_int, pitch_fr, norm_corr, ltpf_active; Counter n, m, fr; Word16 tmp, acflen; +#if defined (CR9_C_ADD_1p25MS) + Word16 activation_due_to_past_corr, activation_due_to_stable_pitch, activation; +#endif #ifdef DYNMEM_COUNT Dyn_Mem_In("process_ltpf_coder_fx", sizeof(struct { @@ -41,7 +57,7 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo })); #endif - + UNUSED(mem_mem_normcorr); ac32 = (Word32 *)scratchAlign(scratchBuffer, 0); /* Size = 4 * 17 = 68 bytes; */ ac = (Word16 *)scratchAlign(ac32, sizeof(*ac32) * 17); /* Size = 2 * 17 = 34 bytes */ @@ -78,7 +94,7 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo *mem_in_exp = x_exp; move16(); } - Word32 normCorrTh = 0; + Word32 normCorrTh = 0; if (hrmode) { normCorrTh = 13107; } else { @@ -95,12 +111,38 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo ac_min_pitch = sub(min_pitch, 4); ac_max_pitch = add(max_pitch, 4); acflen = len; move16(); - if (sub(frame_dms, 25) == 0) + +#ifndef FIX_LTPF_PITCH_MEM_LEN + IF ( sub( frame_dms, LC3PLUS_FRAME_DURATION_2p5MS ) == 0 ) { - acflen = shl(len, 1); - x = x - len; + acflen = shl( len, 1 ); + x = x - len; } +#ifdef CR9_C_ADD_1p25MS + IF ( sub( frame_dms, LC3PLUS_FRAME_DURATION_1p25MS ) == 0 ) + { + acflen = shl( len, 2 ); + x = x - 80; + } +#endif +#else + if (sub(frame_dms, LC3PLUS_FRAME_DURATION_5MS) == 0) + { + acflen = shl(len, 1); + } + if (sub(frame_dms, LC3PLUS_FRAME_DURATION_2p5MS) == 0) + { + acflen = shl(len, 2); + } +#ifdef CR9_C_ADD_1p25MS + if (sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + acflen = shl(len, 3); + } +#endif + x = x - (mem_in_len - LTPF_MEMIN_LEN); +#endif /* Compute norm */ sum1 = L_mac0(1, x[0], x[0]); sum2 = L_mac0(1, x[-ac_min_pitch], x[-ac_min_pitch]); @@ -150,9 +192,11 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo /* Find maximum */ ac_max = ac[min_pitch - ac_min_pitch]; move16(); pitch = min_pitch; move16(); + FOR (n = min_pitch + 1; n <= max_pitch; n++) { tmp = sub_sat(ac[n - ac_min_pitch], ac_max); + if (tmp > 0) { pitch = n; move16(); @@ -272,11 +316,34 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo { test(); test(); test(); test(); /* Decision if lptf active */ - IF ((*mem_ltpf_on == 0 && sub(*mem_normcorr, 30802) > 0 && sub(norm_corr, 30802) > 0 && - (sub(frame_dms, 100) == 0 || sub(*mem_mem_normcorr, 30802) > 0)) || - (sub(*mem_ltpf_on, 1) == 0 && sub(norm_corr, 29491) > 0) || - (sub(*mem_ltpf_on, 1) == 0 && sub(abs_s(sub(ltpf_pitch, *mem_ltpf_pitch)), 8) < 0 && - add(sub(norm_corr, *mem_normcorr), 3277) > 0 && sub(norm_corr, 27525) > 0)) +#if defined (CR9_C_ADD_1p25MS) + activation_due_to_past_corr = sub(mem_normcorr[1], 30802) > 0; + activation_due_to_stable_pitch = 1; + IF (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + activation_due_to_past_corr &= sub(mem_normcorr[2], 30802) > 0; + activation_due_to_past_corr &= sub(mem_normcorr[3], 30802) > 0; + activation_due_to_past_corr &= sub(mem_normcorr[4], 30802) > 0; + + /* 0.7 * max(pitch,mem.pitch(1)) < min(pitch,mem.pitch(1)); */ + Word16 tmp_max = s_max(ltpf_pitch, *mem_ltpf_pitch); + Word16 tmp_min = s_min(ltpf_pitch, *mem_ltpf_pitch); + activation_due_to_stable_pitch = shr(mult(shl(tmp_max,5),22938),5) < tmp_min; + } + activation = activation_due_to_past_corr && activation_due_to_stable_pitch; + + IF( ( *mem_ltpf_on == 0 && sub( *mem_normcorr, 30802 ) > 0 && sub( norm_corr, 30802 ) > 0 && + ( sub( frame_dms, LC3PLUS_FRAME_DURATION_10MS ) == 0 || activation ) ) || + ( sub( *mem_ltpf_on, 1 ) == 0 && sub( norm_corr, 29491 ) > 0 ) & activation_due_to_stable_pitch || + ( sub( *mem_ltpf_on, 1 ) == 0 && sub( abs_s( sub( ltpf_pitch, *mem_ltpf_pitch ) ), 8 ) < 0 && + add( sub( norm_corr, *mem_normcorr ), 3277 ) > 0 && sub( norm_corr, 27525 ) > 0 ) ) +#else + IF( ( *mem_ltpf_on == 0 && sub( mem_normcorr[0], 30802 ) > 0 && sub( norm_corr, 30802 ) > 0 && + ( sub( frame_dms, LC3PLUS_FRAME_DURATION_10MS ) == 0 || sub( mem_normcorr[1], 30802 ) > 0 ) ) || + ( sub( *mem_ltpf_on, 1 ) == 0 && sub( norm_corr, 29491 ) > 0 ) || + ( sub( *mem_ltpf_on, 1 ) == 0 && sub( abs_s( sub( ltpf_pitch, *mem_ltpf_pitch ) ), 8 ) < 0 && + add( sub( norm_corr, mem_normcorr[0] ), 3277 ) > 0 && sub( norm_corr, 27525 ) > 0 ) ) +#endif { ltpf_active = 1; move16(); } @@ -285,7 +352,7 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo param[0] = 1; move16(); param[1] = ltpf_active; move16(); param[2] = pitch_index; move16(); - *bits = 11; move16(); + *bits = 11; move16(); } ELSE { @@ -297,13 +364,62 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo ltpf_pitch = 0; move16(); } +#ifdef CR9_C_ADD_1p25MS + if ( sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0 ) + { +#ifdef NEW_SIGNALLING_SCHEME_1p25 + tmp = s_min(*Tx_ltpf, 1); /* tmp == 0 == phaseA, tmp==1==PhaseB ) */ + test(); test(); test(); + if (param[0] == 0 && tmp != 0) + { + /* pitch correlation dropped from high(ltpf_active) to low(no ltp info at all ), + we select to NOT send the remaining phaseB laginfo for use in a possible low corr PLC frame */ + *Tx_ltpf = 0; move16(); /* kill the lag transmission state at encoder side */ + } + + /* 00 (ltp=0, ltpf=0, no Phase, 2b), + 010yyyy (ltp=1, ltpf=0, phaseA, 7b), + 011zzzz (ltp=1, ltpf=0, phaseB , 7b), "zzzz=lowered lag res for PLC use" + 10yyyy (ltp=1, ltpf=1) phaseA 6b) + 11ZZZZZ (ltp=1, ltpf=1) phaseB 7b) "ZZZZZ= full lag resolution for LTPF use" + */ + test(); + IF(param[0] != 0) + { + test(); + IF(param[1] == 0) + { /* ltpf inactive */ + tmp = s_or(shl(param[0], 1), tmp); /* LTP in b1 phase in LSB b0 , tmp becomes 2 or 3 */ + ASSERT(tmp==2 || tmp == 3 ); + } + ELSE + { /* ltpf active */ + ASSERT(param[2] >= 0 && param[2] <= 511); + tmp = s_or(0x04, shl(tmp, 1)); /* LTPF in b2, phase b1, always zero in b0 , tmp becomes 4 or 6 */ + ASSERT(tmp == 4 || tmp == 6); + } + } + *bits = lrsns_ltp_bits_fx[tmp]; move16(); /* one of { 2,2, 7,7 , 6,6, 7,7} */ + /* tmp as idx is 0,1 2,3 4,5, 6,7 */ + ASSERT(*bits >= 2 && *bits <= 7); +#else + ASSERT(*bits == 1 || *bits == 11 ); +#endif + } +#else + ASSERT(*bits == 1 || *bits == 11 ); +#endif /* CR9_C_ADD_1p25MS */ + /* Update memory */ FOR (n = 0; n < mem_in_len; n++) { mem_in[n] = mem_in[n + len]; move16(); } - *mem_mem_normcorr = *mem_normcorr; move16(); + FOR (n = LEN_MEM_NORMCORR-2; n>=0; n--) { + mem_normcorr[n+1] = mem_normcorr[n]; move16(); + } + *mem_normcorr = norm_corr; move16(); *mem_ltpf_on = ltpf_active; move16(); *mem_ltpf_pitch = ltpf_pitch; move16(); @@ -312,4 +428,3 @@ void process_ltpf_coder_fx(Word16 *bits, Word16 ol_pitch, Word16 ltpf_enable, Wo Dyn_Mem_Out(); #endif } - diff --git a/lib_lc3plus/ltpf_decoder_fx.c b/lib_lc3plus/ltpf_decoder_fx.c index 31da1dbbb..084b7738b 100644 --- a/lib_lc3plus/ltpf_decoder_fx.c +++ b/lib_lc3plus/ltpf_decoder_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,14 +7,156 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" static void ltpf_synth_filter(Word16 *synth_ltp, Word16 *synth, Word16 length, Word16 pitch_int, Word16 pitch_fr, Word16 gain, Word16 scale_fac_idx, Word16 fs_idx, - Word16 fade /* 0=normal, +1=fade-in, -1=fade-out */); + Word16 fade /* 0=normal, +1=fade-in, -1=fade-out */ + , Word16 continuation, Word16 splitFading +#ifdef LTPF_ADAPTIVE_GAIN + , LC3PLUS_FrameDuration frame_dms +#endif + ); + /*************************************************************************/ +#ifdef CR9_C_ADD_1p25MS +static void get_continuation (Word16 fading_case, LC3PLUS_FrameDuration frame_dms, Word16 *continuation) +{ + if (frame_dms != LC3PLUS_FRAME_DURATION_1p25MS) { + *continuation = 0; + } + else + { + if ( *continuation > 0 ) + { + *continuation = 0; + } + else + { + *continuation = fading_case; + } + } +} +#endif + +#ifdef LTPF_ADAPTIVE_GAIN_WITH_NORM_CORR +static Word16 compare_normalized_corrs(Word16 *sig, Word16 len, Word16 pitch_int, Word16 old_pitch_int) +{ + Word32 sum0, sum1, sum2, prod, inv; + Word32 sum0_prev, sum2_prev, prod_prev; + Word16 scale0, scale1, scale2, shift, prod_exp, prod_exp_prev; + Word32 norm_corr, norm_corr_prev; + + sum0 = L_mult0( sig[0], sig[-pitch_int] ); + sum1 = L_mac0( 1, sig[0], sig[0] ); + sum2 = L_mac0( 1, sig[-pitch_int], sig[-pitch_int] ); + + sum0_prev = L_mult0( sig[0], sig[-old_pitch_int] ); + sum2_prev = L_mac0( 1, sig[-old_pitch_int], sig[-old_pitch_int] ); + + FOR (int i=1; i < len; i++) + { + sum0 = L_mac0( sum0, sig[i], sig[i - pitch_int] ); + sum1 = L_mac0( sum1, sig[i], sig[i] ); + sum2 = L_mac0( sum2, sig[i - pitch_int], sig[i - pitch_int] ); + + sum0_prev = L_mac0( sum0_prev, sig[i], sig[i - old_pitch_int] ); + sum2_prev = L_mac0( sum2_prev, sig[i - old_pitch_int], sig[i - old_pitch_int] ); + } + + scale1 = norm_l( sum1 ); + scale2 = norm_l( sum2 ); + sum1 = L_shl_pos( sum1, scale1 ); + sum2 = L_shl_pos( sum2, scale2 ); + prod = Mpy_32_32_lc3plus( sum1, sum2 ); + shift = norm_l( prod ); + prod = L_shl_pos( prod, shift ); + prod_exp = sub( 62, add( add( scale1, scale2 ), shift ) ); + inv = Isqrt_lc3plus( prod, &prod_exp ); + scale0 = norm_l( sum0 ); + sum0 = L_shl_pos( sum0, scale0 ); + prod = Mpy_32_32_lc3plus( sum0, inv ); + prod_exp = add( sub( 31, scale0 ), prod_exp ); + +#ifdef FIX_LTPFDEC_BASOP + norm_corr = INT_MAX; move32(); + test(); + if(prod == 0 || sub(norm_l(prod), prod_exp) >= 0) + { + norm_corr = L_shl_sat(prod, prod_exp); + } + norm_corr = L_max(0, norm_corr); +#else + test(); + IF( prod == 0 || sub( norm_l( prod ), prod_exp ) >= 0 ) + { + norm_corr = L_max( 0, L_shl_sat( prod, prod_exp ) ); + } + ELSE + { + norm_corr = 2147483647; move32(); + } + + if ( norm_corr < 0 ) + { + norm_corr = 0; move32(); + } +#endif + + + scale2 = norm_l( sum2_prev ); + sum2_prev = L_shl_pos( sum2_prev, scale2 ); + prod_prev = Mpy_32_32_lc3plus( sum1, sum2_prev ); + shift = norm_l( prod_prev ); + prod_prev = L_shl_pos( prod_prev, shift ); + prod_exp_prev = sub( 62, add( add( scale1, scale2 ), shift ) ); + inv = Isqrt_lc3plus( prod_prev, &prod_exp_prev ); + scale0 = norm_l( sum0_prev ); + sum0_prev = L_shl_pos( sum0_prev, scale0 ); + prod_prev = Mpy_32_32_lc3plus( sum0_prev, inv ); + prod_exp_prev = add( sub( 31, scale0 ), prod_exp_prev ); + +#ifdef FIX_LTPFDEC_BASOP + norm_corr_prev = INT_MAX; move32(); + test(); + if( prod_prev == 0 || sub( norm_l( prod_prev ), prod_exp_prev ) >= 0 ) + { + norm_corr_prev = L_shl_sat( prod_prev, prod_exp_prev ); + } + norm_corr_prev = L_max( 0L, norm_corr_prev); +#else + test(); + IF( prod_prev == 0 || sub(norm_l(prod_prev), prod_exp_prev) >= 0) + { + norm_corr_prev = L_max(0, L_shl_sat(prod_prev, prod_exp_prev)); move32(); + } + ELSE + { + norm_corr_prev = 2147483647; move32(); + } + + IF(norm_corr_prev < 0) + { + norm_corr_prev = 0; + } +#endif + +#ifdef FIX_LTPFDEC_BASOP + IF(L_sub_sat(L_sub(norm_corr_prev, norm_corr), 1073742L) > 0) +#else + IF( L_sub(L_sub(norm_corr_prev, norm_corr), 1073742L ) > 0) +#endif + { + return 1; + } + + return 0; +} +#endif void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word16 fs_idx, Word16 old_y_len, Word16 *old_e, Word16 *x_in, Word16 *old_x, Word16 *y_out, Word16 *old_y, Word16 ltpf, @@ -22,27 +164,76 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word Word16 *old_gain, Word16 *mem_ltpf_active, Word16 scale_fac_idx, Word16 bfi, Word16 concealMethod, Word16 damping, Word16 *old_scale_fac_idx, - Word32 *rel_pitch_change, Word16 hrmode, Word16 frame_dms, - Word8 *scratchBuffer) + Word32 *rel_pitch_change, Word16 hrmode, LC3PLUS_FrameDuration frame_dms, + Word8 *scratchBuffer +#ifdef CR9_C_ADD_1p25MS + , Word16* mem_continuation, Word16* mem_pitch_int_prev, + Word16* mem_pitch_fr_prev, Word16* mem_beta_idx_prev, Word16* mem_gain_prev, Word16 *ltpf_mem_active_prev, Word16* pitch_stability_counter +#endif + ) { Counter i; - Word16 gain, s, s0, s1, pitch, pitch_int, pitch_fr, N4, N34; + Word16 gain, s, s0, s1, pitch, pitch_int, pitch_fr, N4, N34, fading_case, split_fading; Word16 *x, *y; - Word16 *z; + Word16* z; Word32 tmp32, pitch_delta; + +#ifdef LTPF_ADAPTIVE_GAIN + Word16 bkp_ltpf_active = 0; + Word16 bkp_pitch_int = 0, bkp_pitch_fr = 0; + Word16 bkp_gain = 0; +#endif + #ifdef DYNMEM_COUNT +#ifndef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + Dyn_Mem_In( "process_ltpf_decoder_fx", sizeof( struct { + Counter i; + Word16 gain, s, s0, s1, pitch, pitch_int, pitch_fr, N4, N34; + Word16 *x, *y; + Word16* z; + } ) ); +#else Dyn_Mem_In("process_ltpf_decoder_fx", sizeof(struct { - Counter i; - Word16 gain, s, s0, s1, pitch, pitch_int, pitch_fr, N4, N34; - Word16 *x, *y; - Word16 *z; - Word32 tmp32, pitch_delta; - })); + Counter i; + Word16 gain, s, s0, s1, pitch, pitch_int, pitch_fr, N4, N34; + Word16 *x, *y; + Word16* z; + Word32 tmp32, pitch_delta; + })); +#endif + #endif z = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = MAX_LEN / 4 + 10 */ +#ifdef CR9_C_ADD_1p25MS + UNUSED( frame_dms ); + UNUSED( mem_continuation ); + UNUSED( mem_pitch_int_prev ); + UNUSED( mem_pitch_fr_prev ); + UNUSED( mem_beta_idx_prev ); + UNUSED( mem_gain_prev ); +#else + Word16 mem_cont = 0; + Word16* mem_continuation = &mem_cont; +#ifndef FIX_LTPF_MEM_CONTINUATION + fading_case = 0; +#endif + UNUSED( mem_continuation ); +#endif + +#ifdef FIX_LTPF_MEM_CONTINUATION + fading_case = 0; +#endif + + split_fading = 0; +#ifdef CR9_C_ADD_1p25MS + if ( frame_dms == LC3PLUS_FRAME_DURATION_1p25MS ) + { + split_fading = 1; + } +#endif test(); IF ((sub(bfi, 1) == 0) && (sub(concealMethod, LC3_CON_TEC_NS_STD) == 0)) { @@ -53,6 +244,13 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word gain = 0; move16(); } +#ifdef FIX_LTPF_1p25 + IF (pitch_index == -1) { + ltpf = 0; + ltpf_active = 0; + } +#endif + /* Filter parameters */ IF (sub(bfi, 1) != 0) { @@ -110,7 +308,12 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word gain = gain_scale_fac[scale_fac_idx]; move16(); } } +#ifdef CR9_C_ADD_1p25MS + ELSE IF ( (sub(concealMethod, LC3_CON_TEC_NS_STD) != 0) + && (*mem_continuation == 0) ) +#else ELSE IF (sub(concealMethod, LC3_CON_TEC_NS_STD) != 0) +#endif { /* fix to avoid not initialized filtering for concelament might be necessary in case of bit errors or rate switching */ @@ -120,7 +323,7 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word scale_fac_idx = *old_scale_fac_idx; } } - + ltpf_active = *mem_ltpf_active; move16(); if ((sub(concealMethod, LC3_CON_TEC_PHASE_ECU) == 0)) @@ -133,13 +336,189 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word pitch_fr = *old_pitch_fr; gain = mult_r(*old_gain, damping); } + +#ifdef CR9_C_ADD_1p25MS + IF (*mem_continuation > 0) + { +#ifdef LTPF_ADAPTIVE_GAIN + /* Backup LTPF parameters */ + bkp_ltpf_active = ltpf_active; + bkp_pitch_int = pitch_int; + bkp_pitch_fr = pitch_fr; + bkp_gain = gain; +#endif - test(); test(); - IF (ltpf_active == 0 && *mem_ltpf_active == 0) + fading_case = *mem_continuation; + ltpf_active = *mem_ltpf_active; + pitch_int = *old_pitch_int; + pitch_fr = *old_pitch_fr; + gain = *old_gain; +#ifdef FIX_LTPF_1p25 + scale_fac_idx = *old_scale_fac_idx; +#endif + *mem_ltpf_active = *ltpf_mem_active_prev; + *old_pitch_int = *mem_pitch_int_prev; + *old_pitch_fr = *mem_pitch_fr_prev; + *old_gain = *mem_gain_prev; +#ifdef FIX_LTPF_1p25 + *old_scale_fac_idx = *mem_beta_idx_prev; +#endif + } +#endif + +#ifdef LTPF_ADAPTIVE_GAIN + IF (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) { - /* LTPF inactive */ +#ifdef FIX_LTPF_DEC_FLFX_MISMATCH + /* Control variables */ + Word8 ltpf_active_ctrl = ltpf_active; + Word8 ltpf_active_prev_ctrl = *mem_ltpf_active; +#endif + Word8 pitch_changed = !( ( pitch_int == *old_pitch_int ) && ( pitch_fr == *old_pitch_fr ) ); + Word8 pitch_was_stable = ( ( *pitch_stability_counter >= LTPF_PITCH_STABILITY_THRESHOLD ) ); + +#ifdef CR9_C_ADD_1p25MS + IF ( *mem_continuation == 0 ) + { +#endif + +#ifdef LTPF_ADAPTIVE_GAIN_WITH_NORM_CORR + Word16 tmp_y[LTPF_MEM_Y_LEN] = {0}; + basop_memmove( tmp_y, old_y, ( old_y_len ) * sizeof( Word16 ) ); + basop_memmove( tmp_y + old_y_len, x_in, ( L_frame ) * sizeof( Word16 ) ); + + Word16 scale1 = sub( getScaleFactor16_0( tmp_y, old_y_len + L_frame ), 3 ); + Scale_sig( tmp_y, old_y_len + L_frame, scale1 ); + + IF ( !pitch_was_stable && pitch_changed && pitch_int != 0 && *old_pitch_int != 0 ) + { + pitch_was_stable = compare_normalized_corrs(tmp_y + old_y_len, L_frame, pitch_int, *old_pitch_int); + } +#endif + +#ifdef FIX_LTPF_DEC_FLFX_MISMATCH + IF ( ltpf_active_ctrl && !pitch_changed ) +#else + IF ( ltpf_active && !pitch_changed ) +#endif + { + /* increment gain and increment pitch stability counter */ + gain = pitch_was_stable ? MIN( max_adaptive_gain[scale_fac_idx], MAX( gain, *old_gain ) + adaptive_gain_step ) : MAX( gain, *old_gain ); + (*pitch_stability_counter)++; + } +#ifdef FIX_LTPF_DEC_FLFX_MISMATCH + ELSE IF ( ltpf_active_ctrl && pitch_changed && !pitch_was_stable ) +#else + ELSE IF ( ltpf_active && pitch_changed && !pitch_was_stable ) +#endif + { + /* decrement gain and reset pitch stability counter */ + gain = ( *old_gain > gain) ? MAX( gain, *old_gain - max_adaptive_gain_step[scale_fac_idx] ) : gain; + *pitch_stability_counter = 0; + } +#ifdef FIX_LTPF_DEC_FLFX_MISMATCH + ELSE IF ( !ltpf_active_ctrl && !pitch_was_stable && ltpf_active_prev_ctrl && pitch_changed ) +#else + ELSE IF ( !ltpf_active && !pitch_was_stable && *mem_ltpf_active && pitch_changed ) +#endif + { + /* decrement gain, use previous pitch and reset pitch stability counter */ + gain = *old_gain - adaptive_gain_step; + + if (scale_fac_idx>=0 && (gain-gain_scale_fac[scale_fac_idx]) > -20) + { + ltpf_active = *mem_ltpf_active; + pitch_int = *old_pitch_int; + pitch_fr = *old_pitch_fr; + } + else + { + gain = 0; + } + *pitch_stability_counter = 0; + } +#ifdef FIX_LTPF_DEC_FLFX_MISMATCH + ELSE IF ( ( ltpf_active_ctrl && pitch_changed && pitch_was_stable ) || ( !ltpf_active_ctrl && pitch_was_stable ) || ( !ltpf_active_ctrl && !pitch_was_stable && ltpf_active_prev_ctrl && !pitch_changed ) ) +#else + ELSE IF ( ( ltpf_active && pitch_changed && pitch_was_stable ) || ( !ltpf_active && pitch_was_stable ) || ( !ltpf_active && !pitch_was_stable && *mem_ltpf_active && !pitch_changed ) ) +#endif + { + /* use previous pitch and gain and reset pitch stability counter */ + ltpf_active = *mem_ltpf_active; + pitch_int = *old_pitch_int; + pitch_fr = *old_pitch_fr; + gain = *old_gain; + *pitch_stability_counter = 0; + } +#ifdef CR9_C_ADD_1p25MS /* This preprocessor is added here for the future when adaptive gain will be enabled for other frame sizes. */ + } +#ifdef FIX_PLC_CONFORM_ISSUES + ELSE IF ( *mem_continuation != 0 && bkp_ltpf_active == 1 && bfi == 0 ) +#else + ELSE IF ( *mem_continuation != 0 && bkp_ltpf_active == 1 ) +#endif + { + /* Code enters this block if LTPF is reenabled when adaptive gain is being applied. */ + /* In this case, use new LTPF parameters but with a smaller gain than in the prev frame. */ + fading_case = 0; + *mem_continuation = 0; + + *ltpf_mem_active_prev = *mem_ltpf_active; + *mem_pitch_int_prev = *old_pitch_int; + *mem_pitch_fr_prev = *old_pitch_fr; + *mem_gain_prev = *old_gain; + + *mem_ltpf_active = ltpf_active; + *old_pitch_int = pitch_int; + *old_pitch_fr = pitch_fr; + *old_gain = gain; + + ltpf_active = bkp_ltpf_active; + pitch_int = bkp_pitch_int; + pitch_fr = bkp_pitch_fr; + gain = bkp_gain; + + /* if prev gain > curr gain, then decrease gain slowly.*/ + gain = ( *old_gain > gain) ? MAX( gain, *old_gain - max_adaptive_gain_step[scale_fac_idx] ) : gain; + + *pitch_stability_counter = 0; + } +#endif + } +#endif /* LTPF_ADAPTIVE_GAIN */ + +#ifdef FIX_LTPF_1p25 + if ( *mem_ltpf_active && *old_scale_fac_idx < 0 ) + { + *mem_ltpf_active = 0; + } + + if ( ltpf_active && scale_fac_idx < 0 ) + { + ltpf_active = 0; + } +#endif + + IF( sub( fs_idx, 5 ) < 0 ) + { + test(); + test(); + +#ifdef FIX_LTPF_MEM_CONTINUATION + IF( ( ltpf_active == 0 && *mem_ltpf_active == 0 ) || fading_case == 1 ) +#else + IF( ltpf_active == 0 && *mem_ltpf_active == 0 && *mem_continuation == 0 ) +#endif + { + /* LTPF inactive */ + basop_memmove( y_out, x_in, L_frame * sizeof( Word16 ) ); +#ifdef FIX_LTPF_MEM_CONTINUATION +#ifdef CR9_C_ADD_1p25MS + fading_case = 1; + get_continuation( fading_case, frame_dms, mem_continuation ); +#endif +#endif - basop_memmove(y_out, x_in, L_frame * sizeof(Word16)); /* Update */ s = sub(*old_e, *x_e); @@ -183,32 +562,31 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word basop_memmove(old_x, &x_in[L_frame - old_x_len], (old_x_len) * sizeof(Word16)); - *old_e = *x_e; move16(); + *old_e = *x_e; + move16(); + } + *old_gain = 0; + move16(); + *mem_ltpf_active = 0; + move16(); } + ELSE + { + /* Input/Output buffers */ + x = old_x + old_x_len; + y = old_y + old_y_len; - if (bfi == 0 && sub(hrmode,1) == 0 && (sub(frame_dms,50) == 0 || sub(frame_dms,25) == 0)){ - pitch_delta = abs_s(add(sub(*old_pitch_int,pitch_int) , shr_pos(sub(*old_pitch_fr, pitch_fr),2))); //int_old -int_new + (fr_old-fr_new) / 4.0)); - tmp32 = BASOP_Util_Divide3216_Scale_lc3plus(pitch_delta, MAX(add(*old_pitch_int, shr_pos(*old_pitch_fr,2)), 1),&s0);// = pitch_delta *2^15 / MAX(pitch_fl_c_old, 1); - *rel_pitch_change = L_shl_pos(tmp32,s0+16); - } - - *old_pitch_int = pitch_int; move16(); - *old_pitch_fr = pitch_fr; move16(); - *old_gain = 0; move16(); - *mem_ltpf_active = 0; move16(); - } - ELSE - { - /* Input/Output buffers */ - x = old_x + old_x_len; - y = old_y + old_y_len; - #ifdef ENABLE_HR_MODE - assert(fs_idx < 5 && "Ltpf not supported for 96kHz!\n"); + assert( fs_idx < 5 && "Ltpf not supported for 96kHz!\n" ); #endif - - N4 = ltpf_overlap_len[fs_idx]; move16(); - N34 = sub(L_frame, N4); move16(); + + N4 = ltpf_overlap_len[fs_idx]; + move16(); +#ifdef CR9_C_ADD_1p25MS + N4 = N4 >> split_fading; +#endif + N34 = sub( L_frame, N4 ); + move16(); /* Input */ basop_memmove(x, x_in, (L_frame) * sizeof(Word16)); @@ -234,53 +612,179 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word *old_e = *x_e; move16(); } - /* Filtering */ - IF (ltpf_active == 0) - { - ltpf_synth_filter(y, x, N4, *old_pitch_int, *old_pitch_fr, *old_gain, *old_scale_fac_idx, fs_idx, - -1); - } - ELSE IF (*mem_ltpf_active == 0) - { - ltpf_synth_filter(y, x, N4, pitch_int, pitch_fr, gain, scale_fac_idx, fs_idx, 1); + test(); +#ifndef FIX_LTPF_1p25 + IF (sub(*mem_ltpf_active, 1) == 0 && *old_scale_fac_idx < 0) + { + *mem_ltpf_active = 0; + } +#endif +#ifdef CR9_C_ADD_1p25MS + IF (*mem_continuation == 0) + { +#endif + /* fading case */ + IF (ltpf_active == 0) + { + fading_case = 3; + } + ELSE IF (*mem_ltpf_active == 0) + { + fading_case = 2; + } + ELSE IF (sub(pitch_int, *old_pitch_int) == 0 && sub(*old_pitch_fr, pitch_fr) == 0) + { + fading_case = 4; + } + ELSE + { + fading_case = 5; + } +#ifdef CR9_C_ADD_1p25MS + } +#endif + + /* Filtering */ + IF( sub( fading_case, 3 ) == 0 ) + { + ltpf_synth_filter( y, x, N4, *old_pitch_int, *old_pitch_fr, *old_gain, *old_scale_fac_idx, fs_idx, -1, *mem_continuation, split_fading +#ifdef LTPF_ADAPTIVE_GAIN + , + frame_dms +#endif + ); + } + ELSE IF( sub( fading_case, 2 ) == 0 ) + { + ltpf_synth_filter( y, x, N4, pitch_int, pitch_fr, gain, scale_fac_idx, fs_idx, 1, *mem_continuation, split_fading +#ifdef LTPF_ADAPTIVE_GAIN + , + frame_dms +#endif + ); + } + ELSE IF( sub( fading_case, 4 ) == 0 ) + { + ltpf_synth_filter( y, x, N4, pitch_int, pitch_fr, gain, scale_fac_idx, fs_idx, 0, *mem_continuation, split_fading +#ifdef LTPF_ADAPTIVE_GAIN + , + frame_dms +#endif + ); + } + ELSE + { + ltpf_synth_filter( y, x, N4, *old_pitch_int, *old_pitch_fr, *old_gain, *old_scale_fac_idx, fs_idx, + -1, *mem_continuation, split_fading +#ifdef LTPF_ADAPTIVE_GAIN + , + frame_dms +#endif + ); + + basop_memmove( z, y - tilt_filter_len[fs_idx], ( N4 + tilt_filter_len[fs_idx] ) * sizeof( Word16 ) ); + + ltpf_synth_filter( y, z + tilt_filter_len[fs_idx], N4, pitch_int, pitch_fr, gain, scale_fac_idx, + fs_idx, 1, *mem_continuation, split_fading +#ifdef LTPF_ADAPTIVE_GAIN + , + frame_dms +#endif + ); + } +#ifdef CR9_C_ADD_1p25MS + IF( sub( fading_case, 1 ) > 0 ) + { + get_continuation( fading_case, frame_dms, mem_continuation ); + } +#endif + +#ifdef CR9_C_ADD_1p25MS + IF( ltpf_active > 0 && frame_dms > LC3PLUS_FRAME_DURATION_1p25MS ) +#else + IF( ltpf_active > 0 ) +#endif + { + ltpf_synth_filter( y + N4, x + N4, N34, pitch_int, pitch_fr, gain, + scale_fac_idx, fs_idx, 0, 0, 0 +#ifdef LTPF_ADAPTIVE_GAIN + , + frame_dms +#endif + ); + } + ELSE + { + basop_memmove( &y[N4], &x[N4], N34 * sizeof( Word16 ) ); + } + + /* Output */ + basop_memmove( y_out, y, ( L_frame ) * sizeof( Word16 ) ); + + /* Update */ + basop_memmove( old_x, &old_x[L_frame], ( old_x_len ) * sizeof( Word16 ) ); + basop_memmove( old_y, &old_y[L_frame], ( old_y_len ) * sizeof( Word16 ) ); + +#ifndef FIX_LTPF_DEC_FLFX_MISMATCH +#ifdef CR9_C_ADD_1p25MS + if ( frame_dms == LC3PLUS_FRAME_DURATION_1p25MS ) + { + *mem_pitch_int_prev = *old_pitch_int; + *mem_pitch_fr_prev = *old_pitch_fr; + *mem_gain_prev = *old_gain; + *ltpf_mem_active_prev = *mem_ltpf_active; + } +#endif + + *old_gain = gain; + move16(); + *mem_ltpf_active = ltpf_active; + move16(); +#endif } - ELSE IF (sub(pitch_int, *old_pitch_int) == 0 && sub(*old_pitch_fr, pitch_fr) == 0) + } + + + + + IF( bfi == 0 && sub( hrmode, 1 ) == 0 && ( sub( frame_dms, LC3PLUS_FRAME_DURATION_5MS ) == 0 || sub( frame_dms, LC3PLUS_FRAME_DURATION_2p5MS ) == 0 ) ) + { + pitch_delta = abs_s( add( sub( *old_pitch_int, pitch_int ), shr_pos( sub( *old_pitch_fr, pitch_fr ), 2 ) ) ); + tmp32 = BASOP_Util_Divide3216_Scale( pitch_delta, MAX( add( *old_pitch_int, shr_pos( *old_pitch_fr, 2 ) ), 1 ), &s0 ); + IF( s0 + 16 < 0 ) { - ltpf_synth_filter(y, x, N4, pitch_int, pitch_fr, gain, scale_fac_idx, fs_idx, 0); + *rel_pitch_change = L_shr_pos( tmp32, -( s0 + 16 ) ); } ELSE { - ltpf_synth_filter(y, x, N4, *old_pitch_int, *old_pitch_fr, *old_gain, *old_scale_fac_idx, fs_idx, - -1); - basop_memmove(z, y - tilt_filter_len[fs_idx], (N4 + tilt_filter_len[fs_idx]) * sizeof(Word16)); - ltpf_synth_filter(y, z + tilt_filter_len[fs_idx], N4, pitch_int, pitch_fr, gain, scale_fac_idx, - fs_idx, 1); - } - IF (ltpf_active > 0) - { - ltpf_synth_filter(y + N4, x + N4, N34, pitch_int, pitch_fr, gain, - scale_fac_idx, fs_idx, 0); + *rel_pitch_change = L_shl_pos( tmp32, s0 + 16 ); } - ELSE + } + +#ifdef FIX_LTPF_DEC_FLFX_MISMATCH +#ifdef CR9_C_ADD_1p25MS + if ( frame_dms == LC3PLUS_FRAME_DURATION_1p25MS ) { - basop_memmove(&y[N4], &x[N4], N34 * sizeof(Word16)); + *mem_pitch_int_prev = *old_pitch_int; + *mem_pitch_fr_prev = *old_pitch_fr; + *mem_gain_prev = *old_gain; + *ltpf_mem_active_prev = *mem_ltpf_active; + *mem_beta_idx_prev = *old_scale_fac_idx; } +#endif - /* Output */ - basop_memmove(y_out, y, (L_frame) * sizeof(Word16)); - - /* Update */ - basop_memmove(old_x, &old_x[L_frame], (old_x_len) * sizeof(Word16)); - - basop_memmove(old_y, &old_y[L_frame], (old_y_len) * sizeof(Word16)); - - *old_pitch_int = pitch_int; move16(); - *old_pitch_fr = pitch_fr; move16(); - *old_gain = gain; move16(); - *mem_ltpf_active = ltpf_active; move16(); - } + *old_gain = gain; + move16(); + *mem_ltpf_active = ltpf_active; + move16(); +#endif - *old_scale_fac_idx = scale_fac_idx; move16(); + *old_pitch_int = pitch_int; + move16(); + *old_pitch_fr = pitch_fr; + move16(); + *old_scale_fac_idx = scale_fac_idx; + move16(); #ifdef DYNMEM_COUNT Dyn_Mem_Out(); @@ -290,7 +794,12 @@ void process_ltpf_decoder_fx(Word16 *x_e, Word16 L_frame, Word16 old_x_len, Word static void ltpf_synth_filter(Word16 *synth_ltp, Word16 *synth, Word16 length, Word16 pitch_int, Word16 pitch_fr, Word16 gain, Word16 scale_fac_idx, Word16 fs_idx, - Word16 fade /* 0=normal, +1=fade-in, -1=fade-out */) + Word16 fade /* 0=normal, +1=fade-in, -1=fade-out */ + ,Word16 continuation, Word16 splitFading +#ifdef LTPF_ADAPTIVE_GAIN + , LC3PLUS_FrameDuration frame_dms +#endif + ) { Word16 *x0; Word16 *y0; @@ -318,18 +827,26 @@ static void ltpf_synth_filter(Word16 *synth_ltp, Word16 *synth, Word16 length, W y0 = synth; alpha = 0; move16(); + IF (fade != 0) { if (fade < 0) { alpha = 0x7FFF; move16(); } + if (continuation > 0) { + alpha = shr(0x7FFF,1); + } /* step = 1.f/(float)(length); */ if (sub(length, 20) == 0) { step = 1638 /*1.f/20.f Q15*/; move16(); } + if (sub(length, 30) == 0) + { + step = 1092 /*1.f/30.f Q15*/; move16(); + } if (sub(length, 40) == 0) { step = 819 /*1.f/40.f Q15*/; move16(); @@ -349,21 +866,32 @@ static void ltpf_synth_filter(Word16 *synth_ltp, Word16 *synth, Word16 length, W if (fade < 0) step = negate(step); + + if (splitFading != 0) + step = shr(step,1); } FOR (j = 0; j < length; j++) { - s = L_mult(x0[0], inter_filter[fs_idx][pitch_fr][0]); - FOR (l = 1; l < inter_filter_len[fs_idx]; l++) + const Word16* tilt_filter_ptr = tilt_filter[fs_idx][scale_fac_idx]; +#ifdef LTPF_ADAPTIVE_GAIN + IF ( frame_dms == LC3PLUS_FRAME_DURATION_1p25MS ) + { + tilt_filter_ptr = tilt_filter_1p25ms[fs_idx][scale_fac_idx]; + } +#endif + + s = L_mult( x0[0], inter_filter[fs_idx][pitch_fr][0] ); + FOR( l = 1; l < inter_filter_len[fs_idx]; l++ ) { s = L_mac(s, x0[-l], inter_filter[fs_idx][pitch_fr][l]); } FOR (l = 0; l < tilt_filter_len[fs_idx]; l++) { - s = L_msu(s, y0[-l], tilt_filter[fs_idx][scale_fac_idx][l]); + s = L_msu( s, y0[-l], tilt_filter_ptr[l] ); } - i = msu_r(s, y0[-l], tilt_filter[fs_idx][scale_fac_idx][l]); + i = msu_r( s, y0[-l], tilt_filter_ptr[l] ); k = mult_r(gain, i); diff --git a/lib_lc3plus/makefile b/lib_lc3plus/makefile deleted file mode 100644 index ccf8514af..000000000 --- a/lib_lc3plus/makefile +++ /dev/null @@ -1,180 +0,0 @@ -#****************************************************************************** -# ETSI TS 103 634 V1.5.1 * -# Low Complexity Communication Codec Plus (LC3plus) * -# * -# Copyright licence is solely granted through ETSI Intellectual Property * -# Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -# estoppel or otherwise. * -#*****************************************************************************/ - -# Options -AFL = 0 -GCOV = 0 -NO_POST_REL_CHANGES_TEST = 0 -OPTIM = 0 -SUBSET = ALL -WMOPS = 1 -HR = 1 -CLANG = 0 -SHORT_PLC_FADEOUT = 0 - -# Paths -VPATH = . basic_op -BUILD = build -CC = gcc -LINK = $(CC) - -# Binary Name -NAME_LC3 = LC3plus -# Shared Library Name -LIB_LC3 = libLC3plus.so - -# Default tool settings -RM = rm -f - -ifndef VERBOSE -QUIET_CC = @echo ' ' Compiling $<; -QUIET_LINK= @echo ' ' Linking $@; -QUIET = @ -endif - -# C compiler flags -# Preprocessor(-I/-D) / Compiler / Linker flags -CPPFLAGS += -Ibasic_op -DSUBSET_$(SUBSET) -CFLAGS += -std=c99 -fPIC \ - -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \ - -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ - -Werror-implicit-function-declaration - -ifneq "$(DEBUG)" "0" -CFLAGS += -g3 -LDFLAGS += -g3 -endif - -ifeq "$(HR)" "0" -CFLAGS += -DDISABLE_HR_MODE -endif - -ifeq "$(SHORT_PLC_FADEOUT)" "1" -CFLAGS += -DPLC_TUNING_SHORT_FADEOUT -endif - -# memory sanitizer, find use of uninitialized memory -ifeq "$(CLANG)" "1" - CC = clang - CFLAGS += -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer - LDFLAGS += -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer - OPTIM = 2 -endif - -# address sanitizer, find buffer overflows -ifeq "$(CLANG)" "2" - CC = clang - CFLAGS += -fsanitize=address -fno-omit-frame-pointer - LDFLAGS += -fsanitize=address -fno-omit-frame-pointer - OPTIM = 2 -endif - -# undefined behavior sanitizer, find bugs like integer overflows -ifeq "$(CLANG)" "3" - CC = clang - CFLAGS += -fsanitize=undefined - LDFLAGS += -fsanitize=undefined - OPTIM = 2 -endif - -LDFLAGS += -lm - -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD)/$*.Td - -ifeq "$(GCOV)" "1" -CFLAGS += -fprofile-arcs -ftest-coverage -LDFLAGS += -fprofile-arcs -ftest-coverage -endif - -OPTIM ?= 0 -CFLAGS += -O$(OPTIM) - -CFLAGS += $(foreach DIR,$(SRC_DIRS),-I$(DIR)) - -ifeq "$(NO_POST_REL_CHANGES_TEST)" "1" -CFLAGS += -DNO_POST_REL_CHANGES -endif - -# disable wmops instrumentation -ifeq "$(WMOPS)" "0" - CPPFLAGS += -DWMOPS=0 -DDONT_COUNT_MEM -endif - -# dependency magic -CC_FLAGS = '$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)' -POSTCOMPILE = mv -f $(BUILD)/$*.Td $(BUILD)/$*.d && touch $@ - -############################################################################### - -SRCS := $(notdir $(foreach DIR, $(VPATH), $(wildcard $(DIR)/*.c))) - -EXCL := ccConvert.c -SRCS := $(notdir $(foreach DIR, $(VPATH), $(wildcard $(DIR)/*.c))) -SRCS := $(filter-out $(EXCL), $(SRCS)) - -EXCL_CCC := $(BUILD)/codec_exe.o -OBJS_CCC_UNF := $(addprefix $(BUILD)/, $(SRCS:.c=.o)) -OBJS_CCC := $(filter-out $(EXCL_CCC), $(OBJS_CCC_UNF)) - -OBJS := $(addprefix $(BUILD)/, $(SRCS:.c=.o)) - -LIBSRCS := $(filter-out $(DIR)/ccConvert.c $(DIR)/codec_exe.c, $(SRCS)) -LIBOBJS := $(addprefix $(BUILD)/, $(LIBSRCS:.c=.o)) - -############################################################################### - -.PHONY: all clean help force - -all: $(NAME_LC3) - -help: - @echo 'Targets:' - @echo ' $(NAME_LC3) (default)' - @echo ' $(LIB_LC3)' - @echo ' ccConvert' - @echo 'Syntax: make [OPTION=VALUE ...]' - @echo 'Build options:' - @echo ' NO_POST_REL_CHANGES_TEST $(NO_POST_REL_CHANGES_TEST) [0,1]' - @echo ' OPTIM $(OPTIM) [0-3]' - @echo ' SUBSET $(SUBSET) [NB,WB,SSWB,SWB,FB,UB,ALL]' - @echo ' WMOPS $(WMOPS) [0,1]' - @echo ' SHORT_PLC_FADEOUT $(SHORT_PLC_FADEOUT) [0,1]' - @echo 'Debug options:' - @echo ' AFL $(AFL) [0,1]' - @echo ' CLANG $(CLANG) [0-3]' - @echo ' GCOV $(GCOV) [0,1]' - -$(NAME_LC3): $(OBJS) - @echo 'Linking' $@ - $(QUIET) $(LINK) $(OBJS) -o $@ $(LDFLAGS) - -$(LIB_LC3): $(LIBOBJS) - @echo 'Linking' $@ - $(QUIET) $(LINK) --shared $(OBJS) -o $@ $(LDFLAGS) - -ccConvert: $(BUILD)/ccConvert.o $(OBJS_CCC) - @echo 'Linking' $@ - $(QUIET) $(LINK) $? -o $@ $(LDFLAGS) - -clean: - $(QUIET) rm -rf $(NAME_LC3) $(LIB_LC3) $(BUILD) ccConvert - -$(BUILD)/%.o : %.c $(BUILD)/cc_flags - @echo 'Compiling' $< - $(QUIET) $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< - $(QUIET) $(POSTCOMPILE) - -# force rebuild if compilation flags changed -$(BUILD)/cc_flags: force - $(QUIET) mkdir -p $(BUILD) - $(QUIET) echo $(CC_FLAGS) | cmp -s - $@ || echo $(CC_FLAGS) > $@ - -# force rebuild if include dependency changed -$(BUILD)/%.d: ; -include $(wildcard $(patsubst %, $(BUILD)/%.d, $(basename $(SRCS)))) diff --git a/lib_lc3plus/mdct_fx.c b/lib_lc3plus/mdct_fx.c index 1953b6d68..b2cde56ab 100644 --- a/lib_lc3plus/mdct_fx.c +++ b/lib_lc3plus/mdct_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" /* Union holding buffers to conserve stack memory. */ @@ -134,7 +136,7 @@ void processMdct_fx( } #endif - s = s_max(0, getScaleFactor32_lc3plus(y, N)); + s = s_max(0, getScaleFactor32(y, N)); FOR (i = 0; i < N; i++) { y[i] = L_shl(y[i], s); move32(); @@ -144,7 +146,7 @@ void processMdct_fx( /* N=20 only for 2.5ms possible */ /* maybe implement this a pre init of shift */ - if (sub(N, 20) <= 0) + if (sub(N, 30) <= 0) { *y_e = add(*y_e, 2); } diff --git a/lib_lc3plus/mdct_shaping_fx.c b/lib_lc3plus/mdct_shaping_fx.c index 1637a5275..90e29aa36 100644 --- a/lib_lc3plus/mdct_shaping_fx.c +++ b/lib_lc3plus/mdct_shaping_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void processMdctShaping_fx(Word32 x[], diff --git a/lib_lc3plus/near_nyquist_detector_fx.c b/lib_lc3plus/near_nyquist_detector_fx.c index 595ff435c..c88a7fc9f 100644 --- a/lib_lc3plus/near_nyquist_detector_fx.c +++ b/lib_lc3plus/near_nyquist_detector_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,15 +7,16 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_idx, const Word16 near_nyquist_index, const Word16 bands_number, const Word32 *ener_fx, const Word16 ener_fx_exp #ifdef ENABLE_HR_MODE - , Word16 frame_dms, Word16 hrmode) -#else - ) + ,LC3PLUS_FrameDuration frame_dms, Word16 hrmode #endif + ) { *near_nyquist_flag = 0; #ifdef ENABLE_HR_MODE @@ -38,20 +39,20 @@ void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_id ener_low_exp = 0; move16(); FOR (i = 0; i < near_nyquist_index; i++) { - ener_low = BASOP_Util_Add_Mant32Exp_lc3plus(ener_fx[i], ener_fx_exp, ener_low, ener_low_exp, &ener_low_exp); + ener_low = BASOP_Util_Add_Mant32Exp(ener_fx[i], ener_fx_exp, ener_low, ener_low_exp, &ener_low_exp); } ener_high = 0; move32(); ener_high_exp = 0; move16(); FOR (i = near_nyquist_index; i < bands_number; i++) { - ener_high = BASOP_Util_Add_Mant32Exp_lc3plus(ener_fx[i], ener_fx_exp, ener_high, ener_high_exp, &ener_high_exp); + ener_high = BASOP_Util_Add_Mant32Exp(ener_fx[i], ener_fx_exp, ener_high, ener_high_exp, &ener_high_exp); } - comp_energy = Mpy_32_16_lc3plus(ener_low, NN_thresh); /* Mpy_32_16_lc3plus -> 32Q15 */ + comp_energy = Mpy_32_16_lc3plus(ener_low, NN_thresh); /* Mpy_32_16 -> 32Q15 */ comp_energy_exp = add(add(ener_low_exp, NN_thresh_exp),15); - nrg_above_thresh = BASOP_Util_Cmp_Mant32Exp_lc3plus(ener_high, ener_high_exp, comp_energy, comp_energy_exp); /* 1 if firstNumber > secondNumber */ + nrg_above_thresh = BASOP_Util_Cmp_Mant32Exp(ener_high, ener_high_exp, comp_energy, comp_energy_exp); /* 1 if firstNumber > secondNumber */ if (sub(nrg_above_thresh, 1) == 0) { @@ -62,25 +63,31 @@ void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_id } #ifdef ENABLE_HR_MODE } - ELSE // hrmode == 1 + ELSE /* hrmode == 1 */ { - // inverse spectral flatness = mean(energy) ./ 2^(mean(log2(energy))); - Word32 td_thresh; + /* inverse spectral flatness = mean(energy) ./ 2^(mean(log2(energy))); */ + Word32 td_thresh = 0; SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + assert(0); + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: td_thresh = TD_HR_thresh_2_5ms; BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: td_thresh = TD_HR_thresh_5ms; BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: td_thresh = TD_HR_thresh_7_5ms; BREAK; - default: /* 100 */ + case LC3PLUS_FRAME_DURATION_10MS: td_thresh = TD_HR_thresh_10ms; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } Word16 mean_ener_exp = 0; @@ -89,15 +96,15 @@ void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_id Word16 sum_ener_exp = 0; move16(); FOR (Word16 i = 0; i < bands_number; i++) { - sum_ener = BASOP_Util_Add_Mant32Exp_lc3plus(ener_fx[i], ener_fx_exp, sum_ener, sum_ener_exp, &sum_ener_exp); + sum_ener = BASOP_Util_Add_Mant32Exp(ener_fx[i], ener_fx_exp, sum_ener, sum_ener_exp, &sum_ener_exp); } Word16 denom = sub(14,norm_s(bands_number)); - IF (sub(frame_dms, 50) == 0){ + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_5MS) == 0){ denom = sub(15,norm_s(bands_number)); move16(); } - Word32 mean_ener = L_shr(sum_ener, denom); move32(); // = sum_ener / bands_number + Word32 mean_ener = L_shr(sum_ener, denom); move32(); mean_ener_exp = sum_ener_exp; move16(); Word32 sum_ener_log2 = 0;move32(); @@ -107,10 +114,10 @@ void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_id FOR (Word16 i = 0; i < bands_number; i++) { IF (ener_fx[i] != 0) { - Word32 log2Value = L_add(BASOP_Util_Log2_lc3plus(ener_fx[i]), L_shl_pos(L_deposit_l(ener_fx_exp), 25)); + Word32 log2Value = L_add(BASOP_Util_Log2(ener_fx[i]), L_shl_pos(L_deposit_l(ener_fx_exp), 25)); /* input argument is in Q7.25 , returns pow(2,(x/64) floatingpoint value log2_fl = log2Value/pow(2,31-6) */ - sum_ener_log2 = BASOP_Util_Add_Mant32Exp_lc3plus(log2Value, 6, sum_ener_log2, sum_ener_log2_exp, &sum_ener_log2_exp); move32(); + sum_ener_log2 = BASOP_Util_Add_Mant32Exp(log2Value, 6, sum_ener_log2, sum_ener_log2_exp, &sum_ener_log2_exp); move32(); } } mean_ener_log2 = L_shr(sum_ener_log2, denom); move32(); //mean_ener_log2 = sum_ener_log2 / bands_number @@ -127,5 +134,5 @@ void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_id *near_nyquist_flag = 1; move16(); } } - #endif // ENABLE_HR_MODE + #endif /* ENABLE_HR_MODE */ } diff --git a/lib_lc3plus/noise_factor_fx.c b/lib_lc3plus/noise_factor_fx.c index c6b5aa87b..c73eef56e 100644 --- a/lib_lc3plus/noise_factor_fx.c +++ b/lib_lc3plus/noise_factor_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" @@ -16,7 +18,7 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], #else Word16 xq[], #endif - Word16 gg, Word16 gg_e, Word16 BW_cutoff_idx, Word16 frame_dms, Word16 target_bytes, + Word16 gg, Word16 gg_e, Word16 BW_cutoff_idx, LC3PLUS_FrameDuration frame_dms, Word16 target_bytes, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE ,Word16 hrmode @@ -50,25 +52,33 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + N = shr_pos(N, 3); + noisefillwidth = NOISEFILLWIDTH_1_25MS; + noisefillstart = NOISEFILLSTART_1_25MS; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: N = shr_pos(N, 2); noisefillwidth = NOISEFILLWIDTH_2_5MS; noisefillstart = NOISEFILLSTART_2_5MS; BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: N = shr_pos(N, 1); noisefillwidth = NOISEFILLWIDTH_5MS; noisefillstart = NOISEFILLSTART_5MS; BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: N = add(shr_pos(N, 2), add(shr_pos(N, 2), shr_pos(N, 2))); noisefillwidth = NOISEFILLWIDTH_7_5MS; noisefillstart = NOISEFILLSTART_7_5MS; BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: noisefillwidth = NOISEFILLWIDTH; noisefillstart = NOISEFILLSTART; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } nzeros = -2 * noisefillwidth - 1; @@ -123,7 +133,7 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], ELSE { - IF (target_bytes <= 20 && frame_dms == 100) + IF (target_bytes <= 20 && frame_dms == LC3PLUS_FRAME_DURATION_10MS) { Word32 ind_sum; Word16 mean_ind; @@ -138,7 +148,7 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], ind_sum = L_add(ind_sum, ind[k]); } - mean_ind = BASOP_Util_Divide3216_Scale_lc3plus(ind_sum, c, &s2); + mean_ind = BASOP_Util_Divide3216_Scale(ind_sum, c, &s2); mean_ind = shl(mean_ind, s2 + 1); assert(0 <= mean_ind && mean_ind <= ind[c - 1]); @@ -148,7 +158,7 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], if (sub(mean_ind, ind[0]) > 0) { /* calculate scale to ensure that Lsum does not overflow */ - s2 = s_max(sub(sub(14, norm_s(c)), getScaleFactor32_lc3plus(&x[ind[0]], sub(mean_ind, ind[0]))), 0); + s2 = s_max(sub(sub(14, norm_s(c)), getScaleFactor32(&x[ind[0]], sub(mean_ind, ind[0]))), 0); } Lsum = L_shr_pos_pos(L_abs(x[ind[0]]), s2); @@ -157,10 +167,10 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], /* scale before adding to Lsum */ Lsum = L_add(Lsum, L_shr_pos_pos(L_abs(x[ind[k]]), s2)); } - fac_unq1 = BASOP_Util_Divide3216_Scale_lc3plus(Lsum, k, &s1); + fac_unq1 = BASOP_Util_Divide3216_Scale(Lsum, k, &s1); /* add scale applied during summing */ s1 = add(s1, s2); - fac_unq1 = BASOP_Util_Divide1616_Scale_lc3plus(fac_unq1, gg, &s2); + fac_unq1 = BASOP_Util_Divide1616_Scale(fac_unq1, gg, &s2); s3 = sub(15, add(x_e, add(s1, sub(s2, gg_e)))); s2 = norm_s(fac_unq1); test(); @@ -183,8 +193,8 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], { Lsum = L_add(Lsum, L_abs(x[ind[k]])); } - fac_unq2 = BASOP_Util_Divide3216_Scale_lc3plus(Lsum, idx, &s1); - fac_unq2 = BASOP_Util_Divide1616_Scale_lc3plus(fac_unq2, gg, &s2); + fac_unq2 = BASOP_Util_Divide3216_Scale(Lsum, idx, &s1); + fac_unq2 = BASOP_Util_Divide1616_Scale(fac_unq2, gg, &s2); s3 = sub(15, add(x_e, add(s1, sub(s2, gg_e)))); s2 = norm_s(fac_unq1); test(); @@ -205,17 +215,17 @@ void processNoiseFactor_fx(Word16 *fac_ns_idx, Word16 x_e, Word32 x[], ELSE { /* calculate scale to ensure that Lsum does not overflow */ - s2 = s_max(sub(sub(14, norm_s(c)), getScaleFactor32_lc3plus(&x[ind[0]], sub(N,ind[0]))), 0); + s2 = s_max(sub(sub(14, norm_s(c)), getScaleFactor32(&x[ind[0]], sub(N,ind[0]))), 0); Lsum = L_abs(x[ind[0]]); FOR (k = 1; k < c; k++) { /* scale before adding to Lsum */ Lsum = L_add(Lsum, L_shr_pos_pos(L_abs(x[ind[k]]), s2)); } - fac_unq = BASOP_Util_Divide3216_Scale_lc3plus(Lsum, c, &s1); + fac_unq = BASOP_Util_Divide3216_Scale(Lsum, c, &s1); /* add scale applied during summing */ s1 = add(s1, s2); - fac_unq = BASOP_Util_Divide1616_Scale_lc3plus(fac_unq, gg, &s2); + fac_unq = BASOP_Util_Divide1616_Scale(fac_unq, gg, &s2); s3 = sub(15, add(x_e, add(s1, sub(s2, gg_e)))); s2 = norm_s(fac_unq); test(); diff --git a/lib_lc3plus/noise_filling_fx.c b/lib_lc3plus/noise_filling_fx.c index 5b22983d8..0be080f6f 100644 --- a/lib_lc3plus/noise_filling_fx.c +++ b/lib_lc3plus/noise_filling_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" /*************************************************************************/ @@ -14,7 +16,7 @@ void processNoiseFilling_fx(Word32 xq[], Word16 nfseed, Word16 xq_e, Word16 fac_ns_idx, Word16 BW_cutoff_idx, - Word16 frame_dms, Word16 fac_ns_pc, Word16 spec_inv_idx, Word8 *scratchBuffer + LC3PLUS_FrameDuration frame_dms, Word16 fac_ns_pc, Word16 spec_inv_idx, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode #endif @@ -27,6 +29,8 @@ void processNoiseFilling_fx(Word32 xq[], Word16 nfseed, Word16 xq_e, Word16 fac_ Word32 L_tmp, L_tmp_neg, L_tmp_pc, L_tmp_neg_pc; ); + noisefillwidth = 0; move16(); + noisefillstart = 0; move16(); ind = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_LEN bytes */ c = 0; move16(); @@ -46,25 +50,33 @@ void processNoiseFilling_fx(Word32 xq[], Word16 nfseed, Word16 xq_e, Word16 fac_ SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + N = shr_pos(N, 3); + noisefillwidth = NOISEFILLWIDTH_1_25MS; + noisefillstart = NOISEFILLSTART_1_25MS; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: N = shr_pos(N, 2); noisefillwidth = NOISEFILLWIDTH_2_5MS; noisefillstart = NOISEFILLSTART_2_5MS; BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: N = shr_pos(N, 1); noisefillwidth = NOISEFILLWIDTH_5MS; noisefillstart = NOISEFILLSTART_5MS; BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: N = add(shr_pos(N, 2), add(shr_pos(N, 2), shr_pos(N, 2))); noisefillwidth = NOISEFILLWIDTH_7_5MS; noisefillstart = NOISEFILLSTART_7_5MS; BREAK; - default: /* 100 */ + case LC3PLUS_FRAME_DURATION_10MS: noisefillwidth = NOISEFILLWIDTH; noisefillstart = NOISEFILLSTART; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } nzeros = -2 * noisefillwidth - 1; move16(); diff --git a/lib_lc3plus/olpa_fx.c b/lib_lc3plus/olpa_fx.c index 53f15ca9b..813182609 100644 --- a/lib_lc3plus/olpa_fx.c +++ b/lib_lc3plus/olpa_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" /*************************************************************************/ @@ -15,7 +17,7 @@ void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[], Word16 *pitch, Word16 *s12k8, Word16 len, Word16 *normcorr, Word16 *mem_pitch, Word16 *pitch_flag, - Word16 s12k8_exp, Word16 frame_dms, Word8 *scratchBuffer) + Word16 s12k8_exp, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer) { Word32 sum, sum0, sum1, sum2, prod, inv; Word16 shift, s6k4_exp, prod_exp, min_pitch, max_pitch; @@ -54,15 +56,24 @@ void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[] SWITCH(frame_dms) { - case 50: + case LC3PLUS_FRAME_DURATION_10MS: break; + case LC3PLUS_FRAME_DURATION_7p5MS: break; + case LC3PLUS_FRAME_DURATION_5MS: mem_in_len = add(mem_in_len, 32); acflen = add(acflen, 32); break; - case 25: + case LC3PLUS_FRAME_DURATION_2p5MS: mem_in_len = add(mem_in_len, 48); acflen = add(acflen, 48); break; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + mem_in_len = add(mem_in_len, 56); + acflen = add(acflen, 56); + break; +#endif } s6k4 = mem_s6k4 + mem_in_len; @@ -103,13 +114,21 @@ void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[] SWITCH(frame_dms) { - case 50: + case LC3PLUS_FRAME_DURATION_10MS: break; + case LC3PLUS_FRAME_DURATION_7p5MS: break; + case LC3PLUS_FRAME_DURATION_5MS: s6k4 = s6k4 - 32; break; - case 25: + case LC3PLUS_FRAME_DURATION_2p5MS: s6k4 = s6k4 - 48; break; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + s6k4 = s6k4 - 56; + break; +#endif + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } Scale_sig(mem_s6k4, mem_in_len, shift); @@ -229,7 +248,7 @@ void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[] SWITCH(frame_dms) { - case 50: + case LC3PLUS_FRAME_DURATION_5MS: if(*pitch_flag == 1) { *mem_pitch = *pitch; move16(); *pitch_flag = 0; @@ -239,7 +258,7 @@ void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[] } break; - case 25: + case LC3PLUS_FRAME_DURATION_2p5MS: if (*pitch_flag == 3) { *mem_pitch = *pitch; move16(); *pitch_flag = 0; @@ -248,6 +267,17 @@ void process_olpa_fx(Word16 *mem_s6k4_exp, Word16 mem_s12k8[], Word16 mem_s6k4[] *pitch_flag += 1; } break; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + if (*pitch_flag == 7) { + *mem_pitch = *pitch; move16(); + *pitch_flag = 0; + } + else { + *pitch_flag += 1; + } + break; +#endif default: diff --git a/lib_lc3plus/pc_apply_fx.c b/lib_lc3plus/pc_apply_fx.c index cac9e1735..c34c83e14 100644 --- a/lib_lc3plus/pc_apply_fx.c +++ b/lib_lc3plus/pc_apply_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "constants.h" #include "functions.h" @@ -54,7 +56,7 @@ void processPCapply_fx(Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_ tmp32 = L_shl_pos(L_mult0(add(gg_idx, gg_idx_off), 0x797D), 7); global_gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); - global_gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32, 0xFE000000))); + global_gain = round_fx(BASOP_Util_InvLog2(L_or(tmp32, 0xFE000000))); /** Calculate rescaling factor **/ @@ -103,7 +105,7 @@ void processPCapply_fx(Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_ move32(); #ifdef ENABLE_HR_MODE - s2 = getScaleFactor32_lc3plus(q_res_fx, spec_inv_idx); + s2 = getScaleFactor32(q_res_fx, spec_inv_idx); FOR (i = 0; i < spec_inv_idx; i++) { tmp16 = extract_h(L_shl_sat(q_res_fx[i], sub(s2, 4))); @@ -132,8 +134,8 @@ void processPCapply_fx(Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_ IF ( ener_prev > 0 ) { /* fac = sqrt(ener_curr/ener_prev); */ - s = getScaleFactor32_lc3plus(&ener_prev, 1); - s2 = getScaleFactor32_lc3plus(&ener_curr, 1); + s = getScaleFactor32(&ener_prev, 1); + s2 = getScaleFactor32(&ener_curr, 1); s3 = s_min(s, s2); tmp16 = extract_h(L_shl_sat(ener_curr, s3)); tmp16_2 = extract_h(L_shl_sat(ener_prev, s3)); @@ -143,14 +145,14 @@ void processPCapply_fx(Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_ tmp16_2 = 32767; move16(); *fac_e = 15; move16(); } else { - tmp16_2 = Inv16_lc3plus(tmp16_2, fac_e); + tmp16_2 = Inv16(tmp16_2, fac_e); } *fac = mult(tmp16, tmp16_2); IF (sub(*fac, 32767) < 0) { - *fac = Sqrt16_lc3plus(*fac, fac_e); move16(); + *fac = Sqrt16(*fac, fac_e); move16(); } } @@ -177,7 +179,7 @@ void processPCapply_fx(Word16 yLen, Word16 q_old_res_fx[], Word16 *q_old_res_fx_ { /* fac = prev_gg/gg; */ s = global_gain_e; move16(); - inv_gain = Inv16_lc3plus(global_gain, &s); + inv_gain = Inv16(global_gain, &s); fac_local = mult(prev_gg, inv_gain); fac_local_e = add(s, prev_gg_e); } diff --git a/lib_lc3plus/pc_classify_fx.c b/lib_lc3plus/pc_classify_fx.c index 97d62d9f9..a9736b9b9 100644 --- a/lib_lc3plus/pc_classify_fx.c +++ b/lib_lc3plus/pc_classify_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "constants.h" #include "functions.h" @@ -17,7 +19,7 @@ void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover); -void processPCclassify_fx(Word16 pitch_present, Word16 frame_dms, Word16 q_old_d_fx[], Word16 q_old_res_fx[], +void processPCclassify_fx(Word16 pitch_present, LC3PLUS_FrameDuration frame_dms, Word16 q_old_d_fx[], Word16 q_old_res_fx[], Word16 yLen, Word16 spec_inv_idx, Word16 stab_fac, Word16 *bfi) { Dyn_Mem_Deluxe_In( @@ -26,9 +28,28 @@ void processPCclassify_fx(Word16 pitch_present, Word16 frame_dms, Word16 q_old_d Word16 s, tmp16, full_nrg16, part_nrg16; Word32 full_nrg, part_nrg; ); + + int frame_dms_val = 0; + SWITCH (frame_dms) + { +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + assert(0); frame_dms_val = 125; BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: + frame_dms_val = 250; BREAK; + case LC3PLUS_FRAME_DURATION_5MS: + frame_dms_val = 500; BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: + frame_dms_val = 750; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: + frame_dms_val = 1000; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: + assert(0); + } /* Apply classifier only if lower than 2kHz signal */ - IF (sub(DEPR_i_mult(spec_inv_idx, 10), shl_pos(frame_dms, 2)) < 0 ) + IF (sub(i_mult(spec_inv_idx, 10), shl_pos(frame_dms_val/10, 2)) < 0 ) { IF (sub(stab_fac, 16384 /* 0.5 */) < 0) { @@ -37,7 +58,7 @@ void processPCclassify_fx(Word16 pitch_present, Word16 frame_dms, Word16 q_old_d ELSE IF (sub(pitch_present, 1) == 0) { maxPitchBin = 8; move16(); - IF (sub(frame_dms, 50) == 0) + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_5MS) == 0) { maxPitchBin = 4; move16(); } @@ -68,7 +89,7 @@ void processPCclassify_fx(Word16 pitch_present, Word16 frame_dms, Word16 q_old_d full_nrg = L_mac0(full_nrg, tmp16, tmp16); /* exp = 2s - 8 */ } - s = getScaleFactor32_lc3plus(&full_nrg, 1); + s = getScaleFactor32(&full_nrg, 1); full_nrg16 = extract_h(L_shl(full_nrg, s)); part_nrg16 = extract_h(L_shl(part_nrg, s)); @@ -114,7 +135,7 @@ void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover) c = sub(yLen, 2 * BLOCK_SIZE); test(); - IF (abs_s(in_sig[0]) >= abs_s(in_sig[1])) + IF (abs_s_sat(in_sig[0]) >= abs_s_sat(in_sig[1])) { block_cent = 0; move32(); FOR (j = 0; j <= 1; j++) @@ -126,12 +147,12 @@ void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover) IF (L_sub(block_cent, mean_block_nrg) > 0) { - cur_max = abs_s(in_sig[0]); - cur_max = MAX(abs_s(in_sig[1]), cur_max); + cur_max = abs_s_sat(in_sig[0]); + cur_max = MAX(abs_s_sat(in_sig[1]), cur_max); - next_max = abs_s(in_sig[-1 + BLOCK_SIZE]); - next_max = MAX(abs_s(in_sig[-1 + BLOCK_SIZE + 1]), next_max); - next_max = MAX(abs_s(in_sig[-1 + BLOCK_SIZE + 2]), next_max); + next_max = abs_s_sat(in_sig[-1 + BLOCK_SIZE]); + next_max = MAX(abs_s_sat(in_sig[-1 + BLOCK_SIZE + 1]), next_max); + next_max = MAX(abs_s_sat(in_sig[-1 + BLOCK_SIZE + 2]), next_max); IF (sub(cur_max, next_max) > 0) { @@ -144,7 +165,7 @@ void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover) FOR (i = 0; i < BLOCK_SIZE; i++) { test(); - IF (abs_s(in_sig[i + 1]) >= abs_s(in_sig[i]) && abs_s(in_sig[i + 1]) >= abs_s(in_sig[i + 2])) + IF (abs_s_sat(in_sig[i + 1]) >= abs_s_sat(in_sig[i]) && abs_s_sat(in_sig[i + 1]) >= abs_s_sat(in_sig[i + 2])) { block_cent = 0; move32(); FOR (j = 0; j < BLOCK_SIZE; j++) @@ -156,22 +177,22 @@ void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover) IF (L_sub(block_cent, mean_block_nrg) > 0) { - cur_max = abs_s(in_sig[i]); - cur_max = MAX(abs_s(in_sig[i + 1]), cur_max); - cur_max = MAX(abs_s(in_sig[i + 2]), cur_max); + cur_max = abs_s_sat(in_sig[i]); + cur_max = MAX(abs_s_sat(in_sig[i + 1]), cur_max); + cur_max = MAX(abs_s_sat(in_sig[i + 2]), cur_max); prev_max = 0; move16(); FOR (j = i - BLOCK_SIZE; j <= i - 1; j++) { IF (j > 0) { - prev_max = MAX(abs_s(in_sig[j]), prev_max); + prev_max = MAX(abs_s_sat(in_sig[j]), prev_max); } } - next_max = abs_s(in_sig[i + BLOCK_SIZE]); - next_max = MAX(abs_s(in_sig[i + BLOCK_SIZE + 1]), next_max); - next_max = MAX(abs_s(in_sig[i + BLOCK_SIZE + 2]), next_max); + next_max = abs_s_sat(in_sig[i + BLOCK_SIZE]); + next_max = MAX(abs_s_sat(in_sig[i + BLOCK_SIZE + 1]), next_max); + next_max = MAX(abs_s_sat(in_sig[i + BLOCK_SIZE + 2]), next_max); test(); IF (sub(cur_max, prev_max) >= 0 && sub(cur_max, next_max) > 0) @@ -203,7 +224,7 @@ void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover) FOR (i = BLOCK_SIZE; i <= c; i++) { test(); - IF (abs_s(in_sig[i + 1]) >= abs_s(in_sig[i]) && abs_s(in_sig[i + 1]) >= abs_s(in_sig[i + 2])) + IF (abs_s_sat(in_sig[i + 1]) >= abs_s_sat(in_sig[i]) && abs_s_sat(in_sig[i + 1]) >= abs_s_sat(in_sig[i + 2])) { block_cent = 0; move32(); FOR (j = 0; j < BLOCK_SIZE; j++) @@ -215,17 +236,17 @@ void peakDetector_fx(Word16 in_sig[], Word16 yLen, Word16 *xover) IF (L_sub(block_cent, mean_block_nrg) > 0) { - cur_max = abs_s(in_sig[i]); - cur_max = MAX(abs_s(in_sig[i + 1]), cur_max); - cur_max = MAX(abs_s(in_sig[i + 2]), cur_max); + cur_max = abs_s_sat(in_sig[i]); + cur_max = MAX(abs_s_sat(in_sig[i + 1]), cur_max); + cur_max = MAX(abs_s_sat(in_sig[i + 2]), cur_max); - prev_max = abs_s(in_sig[i - BLOCK_SIZE]); - prev_max = MAX(abs_s(in_sig[i - BLOCK_SIZE + 1]), prev_max); - prev_max = MAX(abs_s(in_sig[i - BLOCK_SIZE + 2]), prev_max); + prev_max = abs_s_sat(in_sig[i - BLOCK_SIZE]); + prev_max = MAX(abs_s_sat(in_sig[i - BLOCK_SIZE + 1]), prev_max); + prev_max = MAX(abs_s_sat(in_sig[i - BLOCK_SIZE + 2]), prev_max); - next_max = abs_s(in_sig[i + BLOCK_SIZE]); - next_max = MAX(abs_s(in_sig[i + BLOCK_SIZE + 1]), next_max); - next_max = MAX(abs_s(in_sig[i + BLOCK_SIZE + 2]), next_max); + next_max = abs_s_sat(in_sig[i + BLOCK_SIZE]); + next_max = MAX(abs_s_sat(in_sig[i + BLOCK_SIZE + 1]), next_max); + next_max = MAX(abs_s_sat(in_sig[i + BLOCK_SIZE + 2]), next_max); test(); IF (sub(cur_max, prev_max) >= 0 && sub(cur_max, next_max) > 0) diff --git a/lib_lc3plus/pc_main_fx.c b/lib_lc3plus/pc_main_fx.c index de598b4d8..3e159b301 100644 --- a/lib_lc3plus/pc_main_fx.c +++ b/lib_lc3plus/pc_main_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,11 +7,13 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "constants.h" #include "functions.h" -void processPCmain_fx(Word16 rframe, Word16 *bfi, Word16 yLen, Word16 frame_dms, Word16 q_old_res_fx[], +void processPCmain_fx(Word16 rframe, Word16 *bfi, Word16 yLen, LC3PLUS_FrameDuration frame_dms, Word16 q_old_res_fx[], Word16 *q_old_res_fx_exp, #ifdef ENABLE_HR_MODE Word32 q_res_fx[], diff --git a/lib_lc3plus/pc_update_fx.c b/lib_lc3plus/pc_update_fx.c index e17dc1186..6823a320f 100644 --- a/lib_lc3plus/pc_update_fx.c +++ b/lib_lc3plus/pc_update_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "constants.h" #include "functions.h" @@ -67,13 +69,13 @@ void processPCupdate_fx(Word16 bfi, Word16 yLen, Word16 q_old_res_fx[], Word16 * tmp32 = L_shl_pos(L_mult0(add(gg_idx, gg_idx_off), 0x797D), 7); global_gain_e = add(extract_l(L_shr_pos(tmp32, 25)), 1); - global_gain = round_fx(BASOP_Util_InvLog2_lc3plus(L_or(tmp32, 0xFE000000))); + global_gain = round_fx(BASOP_Util_InvLog2(L_or(tmp32, 0xFE000000))); *prev_gg = global_gain; move16(); *prev_gg_e = global_gain_e; move16(); #ifdef ENABLE_HR_MODE - s = getScaleFactor32_lc3plus(q_res_fx, spec_inv_idx); /* exp = 0 */ + s = getScaleFactor32(q_res_fx, spec_inv_idx); /* exp = 0 */ #else s = getScaleFactor16(q_res_fx, spec_inv_idx); /* exp = 0 */ #endif @@ -91,7 +93,7 @@ void processPCupdate_fx(Word16 bfi, Word16 yLen, Word16 q_old_res_fx[], Word16 * ELSE { #ifdef ENABLE_HR_MODE - s2 = getScaleFactor32_lc3plus(&q_res_fx[spec_inv_idx], sub(yLen, spec_inv_idx)); /* exp = q_old_res_fx_exp */ + s2 = getScaleFactor32(&q_res_fx[spec_inv_idx], sub(yLen, spec_inv_idx)); /* exp = q_old_res_fx_exp */ IF (s2 == 0) s2 = 16; s3 = add(s, *q_old_res_fx_exp); diff --git a/lib_lc3plus/per_band_energy_fx.c b/lib_lc3plus/per_band_energy_fx.c index a8b9bcac9..86c848c01 100644 --- a/lib_lc3plus/per_band_energy_fx.c +++ b/lib_lc3plus/per_band_energy_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,11 +7,13 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" #include "rom_basop_util_lc3plus.h" void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Word16 d_fx_exp, - const Word16 *band_offsets, Word16 fs_idx, Word16 n_bands, Word16 linear, Word16 frame_dms, + const Word16 *band_offsets, Word16 fs_idx, Word16 n_bands, Word16 linear, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -24,6 +26,8 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor d2_band_fx_exp = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * MAX_BANDS_NUMBER_PLC bytes */ + bandsOffsetOne = 0; move16(); + bandsOffsetTwo = 0; move16(); #ifdef ENABLE_HR_MODE if (hrmode) @@ -41,7 +45,17 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor SWITCH (frame_dms) { - case 25: maxBwBin = maxBwBin >> 2; move16(); +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: maxBwBin = maxBwBin >> 3; move16(); + { + bandsOffsetOne = bands_offset_with_one_max_1_25ms[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_1_25ms[fs_idx]; + move16(); + } + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: maxBwBin = maxBwBin >> 2; move16(); { bandsOffsetOne = bands_offset_with_one_max_2_5ms[fs_idx]; move16(); @@ -49,7 +63,7 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor move16(); } BREAK; - case 50: maxBwBin = maxBwBin >> 1; move16(); + case LC3PLUS_FRAME_DURATION_5MS: maxBwBin = maxBwBin >> 1; move16(); { bandsOffsetOne = bands_offset_with_one_max_5ms[fs_idx]; move16(); @@ -57,14 +71,14 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor move16(); } BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: maxBwBin = (maxBwBin >> 2) * 3; move16(); bandsOffsetOne = bands_offset_with_one_max_7_5ms[fs_idx]; move16(); bandsOffsetTwo = bands_offset_with_two_max_7_5ms[fs_idx]; move16(); BREAK; - default: /* 100 */ + case LC3PLUS_FRAME_DURATION_10MS: { bandsOffsetOne = bands_offset_with_one_max[fs_idx]; move16(); @@ -72,6 +86,7 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor move16(); } BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } IF (sub(linear, 1) == 0) @@ -86,30 +101,39 @@ void processPerBandEnergy_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word32 *d_fx, Wor SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + bandsOffsetOne = bands_offset_with_one_max_lin_1_25ms[fs_idx]; + move16(); + bandsOffsetTwo = bands_offset_with_two_max_lin_1_25ms[fs_idx]; + move16(); + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: bandsOffsetOne = bands_offset_with_one_max_lin_2_5ms[fs_idx]; move16(); bandsOffsetTwo = bands_offset_with_two_max_lin_2_5ms[fs_idx]; move16(); BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: bandsOffsetOne = bands_offset_with_one_max_lin_5ms[fs_idx]; move16(); bandsOffsetTwo = bands_offset_with_two_max_lin_5ms[fs_idx]; move16(); BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: bandsOffsetOne = bands_offset_with_one_max_lin_7_5ms[fs_idx]; move16(); bandsOffsetTwo = bands_offset_with_two_max_lin_7_5ms[fs_idx]; move16(); BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: bandsOffsetOne = bands_offset_with_one_max_lin[fs_idx]; move16(); bandsOffsetTwo = bands_offset_with_two_max_lin[fs_idx]; move16(); BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } } diff --git a/lib_lc3plus/plc_apply_fx.c b/lib_lc3plus/plc_apply_fx.c index d08957fda..ca07b5d81 100644 --- a/lib_lc3plus/plc_apply_fx.c +++ b/lib_lc3plus/plc_apply_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "constants.h" #include "functions.h" @@ -23,7 +25,7 @@ void processPLCapply_fx( Word16 x_fx[], Word16 ola_mem[], Word16 *ola_mem_exp, Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], Word16 *q_fx_exp, Word16 yLen, Word16 fs_idx, Word16 *damping, Word16 old_pitch_int, - Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, Word16 frame_dms, AplcSetup *plcAd, + Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, LC3PLUS_FrameDuration frame_dms, AplcSetup *plcAd, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -58,9 +60,9 @@ void processPLCapply_fx( UNUSED(rel_pitch_change); #endif - Word16 thresh_tdc_cnt; - Word16 thresh_ns_cnt; - Word16 thresh_tdc_ns_cnt; + Word16 thresh_tdc_cnt = 0; + Word16 thresh_ns_cnt = 0; + Word16 thresh_tdc_ns_cnt = 0; band_offsets = NULL; @@ -91,23 +93,31 @@ void processPLCapply_fx( { SWITCH(frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + consecutiveLostThreshold = 32; + thresh_tdc_cnt = THRESH_025_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_025_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_025_DMS_TDC_NS_CNT; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: consecutiveLostThreshold = 16; thresh_tdc_cnt = THRESH_025_DMS_TDC_CNT; thresh_ns_cnt = THRESH_025_DMS_NS_CNT; thresh_tdc_ns_cnt = THRESH_025_DMS_TDC_NS_CNT; break; - case 50: consecutiveLostThreshold = 8; + case LC3PLUS_FRAME_DURATION_5MS: consecutiveLostThreshold = 8; thresh_tdc_cnt = THRESH_050_DMS_TDC_CNT; thresh_ns_cnt = THRESH_050_DMS_NS_CNT; thresh_tdc_ns_cnt = THRESH_050_DMS_TDC_NS_CNT; break; - case 75: consecutiveLostThreshold = 6; + case LC3PLUS_FRAME_DURATION_7p5MS: consecutiveLostThreshold = 6; thresh_tdc_cnt = THRESH_075_DMS_TDC_CNT; thresh_ns_cnt = THRESH_075_DMS_NS_CNT; thresh_tdc_ns_cnt = THRESH_075_DMS_TDC_NS_CNT; break; - case 100: consecutiveLostThreshold = 4; + case LC3PLUS_FRAME_DURATION_10MS: consecutiveLostThreshold = 4; thresh_tdc_cnt = THRESH_100_DMS_TDC_CNT; thresh_ns_cnt = THRESH_100_DMS_NS_CNT; thresh_tdc_ns_cnt = THRESH_100_DMS_TDC_NS_CNT; @@ -135,8 +145,9 @@ void processPLCapply_fx( { plcAd->plc_fadeout_type = 0; } + #ifdef ENABLE_HR_MODE - IF (L_sub(rel_pitch_change,REL_PITCH_THRESH) > 0 && sub(hrmode,1) == 0 && (sub(frame_dms,50) == 0 || sub(frame_dms,25) == 0)){ + IF (L_sub(rel_pitch_change,REL_PITCH_THRESH) > 0 && sub(hrmode,1) == 0 && (sub(frame_dms, LC3PLUS_FRAME_DURATION_5MS) == 0 || sub(frame_dms, LC3PLUS_FRAME_DURATION_2p5MS) == 0)){ plcAd->plc_fadeout_type = 2;move16(); } ELSE #endif @@ -151,7 +162,7 @@ void processPLCapply_fx( SWITCH (*concealMethod) { case LC3_CON_TEC_PHASE_ECU: - ASSERT(frame_dms == 100); + ASSERT(frame_dms == LC3PLUS_FRAME_DURATION_10MS); /* call phaseEcu */ env_stab = 32767; move16(); /* 1.0=stable , 0.0=dynamic Q15*/ tmp_is_trans[0] = plcAd->PhECU_short_flag_prev; move16(); @@ -254,21 +265,32 @@ void processPLCapply_fx( n_bands = s_min(frame_length, MAX_BANDS_NUMBER_PLC); SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: +#ifdef FIX_PLC_CONFORM_ISSUES + band_offsets = bands_offset_lin_1_25ms[fs_idx]; move16(); +#endif + IF (sub(fs_idx, 4) == 0) + { + n_bands = 60; move16(); + } + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: band_offsets = bands_offset_lin_2_5ms[fs_idx]; move16(); IF (sub(fs_idx, 4) == 0) { n_bands = 60; move16(); } BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: band_offsets = bands_offset_lin_5ms[fs_idx]; move16(); IF (sub(fs_idx, 2) == 0) { n_bands = 40; move16(); } BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: band_offsets = bands_offset_lin_7_5ms[fs_idx]; move16(); #ifdef ENABLE_HR_MODE IF (sub(fs_idx, 5) != 0) @@ -282,9 +304,10 @@ void processPLCapply_fx( } #endif BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: band_offsets = bands_offset_lin[fs_idx]; move16(); BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } FOR (i = 0; i < yLen; i++) diff --git a/lib_lc3plus/plc_classify_fx.c b/lib_lc3plus/plc_classify_fx.c index 24775f6f5..6779ca925 100644 --- a/lib_lc3plus/plc_classify_fx.c +++ b/lib_lc3plus/plc_classify_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -104,7 +106,7 @@ static Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_off ); void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLostFramesInRow, Word16 bfi, - Word16 ltpf_mem_pitch_int, Word16 frame_length, Word16 frame_dms, Word16 fs_idx, Word16 yLen, + Word16 ltpf_mem_pitch_int, Word16 frame_length, LC3PLUS_FrameDuration frame_dms, Word16 fs_idx, Word16 yLen, Word16 q_old_d_fx[], const Word16 *band_offsets, Word16 bands_number, AplcSetup *plcAd, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -128,6 +130,40 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost plcAd->norm_corrQ15_fx = 0; move16(); } +#ifdef CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + Word16 resetClassifierThreshold = 0; + Word16 updateStatistics = 0; + + SWITCH (frame_dms) + { +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + resetClassifierThreshold = 16; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: + resetClassifierThreshold = 8; + BREAK; + case LC3PLUS_FRAME_DURATION_5MS: + resetClassifierThreshold = 4; + BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: + resetClassifierThreshold = 3; + BREAK; + case LC3PLUS_FRAME_DURATION_10MS: + resetClassifierThreshold = 2; + BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); + } + + IF (sub(plcAd->numberOfGoodFrames, resetClassifierThreshold) > 0) + { + updateStatistics = 1; + } ELSE { + updateStatistics = 0; + } +#endif + /* assert(bfi != 2 && "Error bfi flag value, state of fadeout cntr is affected by PartialConcealment here "); */ /* Save statistics for 24 kHz, 48 kHz and 96 kHz */ IF((sub(bfi, 1) == 0) || (((bfi >= 0) && (sub(bfi, 2) <= 0)) && ((sub(fs_idx, 2) == 0) || (sub(fs_idx, 4) == 0) || (sub(fs_idx, 5) == 0)))) /* note for PC bfi==2 is possible */ @@ -167,39 +203,75 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost IF(class <= 0) { #ifdef ENABLE_HR_MODE - IF((frame_dms == 100) && (hrmode == 0)) + IF((frame_dms == LC3PLUS_FRAME_DURATION_10MS) && (hrmode == 0)) #else - IF(frame_dms == 100) + IF(frame_dms == LC3PLUS_FRAME_DURATION_10MS) #endif { *concealMethod = LC3_CON_TEC_PHASE_ECU; move16(); /* Phase ECU selected */ - array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); - array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + +#ifdef CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + IF (sub(updateStatistics, 1) == 0) +#endif + { + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + } } ELSE { - array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); - array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#ifdef CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + IF (sub(updateStatistics, 1) == 0) +#endif + { + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + } } } ELSE { - array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 1, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); - array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#ifdef CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + IF (sub(updateStatistics, 1) == 0) +#endif + { + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 1, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + } } } ELSE { *concealMethod = LC3_CON_TEC_NS_ADV; move16(); /* Noise Substitution */ - array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); - array_insert_and_shift(plcAd->plc_longterm_advc_ns, 1, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + +#ifdef CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + IF (sub(updateStatistics, 1) == 0) +#endif + { + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 1, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + } } - array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, plcAd->longterm_analysis_counter_max); - update_bit_and_byte_positions(plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#ifdef CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + IF (sub(updateStatistics, 1) == 0) +#endif + { + array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, plcAd->longterm_analysis_counter_max); + update_bit_and_byte_positions(plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + } } } } + +#ifdef CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + IF (sub(bfi, 1) == 0) + { + plcAd->numberOfGoodFrames = 0; + } ELSE { + plcAd->numberOfGoodFrames = add(plcAd->numberOfGoodFrames, 1); + } +#endif Dyn_Mem_Deluxe_Out(); #ifdef WMOPS @@ -207,7 +279,6 @@ void processPLCclassify_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLost #endif } - Word16 spectral_centroid_fx_lc(Word16 old_scf_q[], const Word16 *band_offsets, Word16 bands_number, Word16 frame_length, Word16 fs_idx, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE diff --git a/lib_lc3plus/plc_damping_scrambling_fx.c b/lib_lc3plus/plc_damping_scrambling_fx.c index ea56ead1d..89c079202 100644 --- a/lib_lc3plus/plc_damping_scrambling_fx.c +++ b/lib_lc3plus/plc_damping_scrambling_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,13 +7,15 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" void processPLCDampingScrambling_main_fx(Word16 bfi, Word16 concealMethod, Word16 ns_nbLostFramesInRow, Word16 *cum_fflcAtten, Word16 pc_nbLostFramesInRow, Word16 *ns_seed, Word16 *pc_seed, Word16 pitch_present_bfi1, Word16 pitch_present_bfi2, Word32 spec[], Word16 *q_fx_exp, Word16 *q_old_d_fx, - Word16 *q_old_fx_exp, Word16 L_spec, Word16 stabFac, Word16 frame_dms, + Word16 *q_old_fx_exp, Word16 L_spec, Word16 stabFac, LC3PLUS_FrameDuration frame_dms, Word16 *cum_fading_slow, Word16 *cum_fading_fast, Word16 spec_inv_idx , UWord8 plc_fadeout_type ) @@ -63,15 +65,15 @@ void processPLCDampingScrambling_main_fx(Word16 bfi, Word16 concealMethod, Word1 } void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostFramesInRow, Word16 stabFac, Word16 processDampScramb, - Word16 *cum_fflcAtten, Word16 pitch_present, Word16 frame_dms, Word16 *cum_fading_slow, + Word16 *cum_fflcAtten, Word16 pitch_present, LC3PLUS_FrameDuration frame_dms, Word16 *cum_fading_slow, Word16 *cum_fading_fast, Word16 *seed, Word16 spec_inv_idx , UWord8 plc_fadeout_type ) { Counter i; Word16 lossDuration_dms, slow, fast, tmp16; - Word16 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, linFuncStartStop; - Word16 randThreshold, ad_threshFac, energThreshold, s, s2, s3, mean_energy16; + Word16 plc_start_inFrames = 0, plc_end_inFrames = 0, plc_duration_inFrames, linFuncStartStop; + Word16 randThreshold = 0, ad_threshFac, energThreshold, s, s2, s3, mean_energy16; Word32 frame_energy, mean_nrg, fac; Word16 fflcAtten, cum_fading_slow_local, cum_fading_fast_local; @@ -96,47 +98,76 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: +#ifdef FIX_PLC_CONFORM_ISSUES + for ( i = 0; i < 3; i++ ) +#else + for ( i = 0; i < 8; i++ ) +#endif + { + IF (sub(slow, 32767) < 0) + { + tmp16 = 0; + slow = Sqrt16(slow, &tmp16); move16(); + slow = shl(slow, tmp16); + } + } +#ifdef FIX_PLC_CONFORM_ISSUES + for ( i = 0; i < 3; i++ ) + { + IF( sub( fast, 32767 ) < 0 ) + { + tmp16 = 0; + fast = Sqrt16( fast, &tmp16 ); + move16(); + fast = shl( fast, tmp16 ); + } + } +#endif + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: IF (sub(slow, 32767) < 0) { tmp16 = 0; - slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = Sqrt16(slow, &tmp16); move16(); slow = shl(slow, tmp16); } IF (sub(slow, 32767) < 0) { tmp16 = 0; - slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = Sqrt16(slow, &tmp16); move16(); slow = shl(slow, tmp16); } IF (sub(fast, 32767) < 0) { tmp16 = 0; - fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = Sqrt16(fast, &tmp16); move16(); fast = shl(fast, tmp16); } IF (sub(fast, 32767) < 0) { tmp16 = 0; - fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = Sqrt16(fast, &tmp16); move16(); fast = shl(fast, tmp16); } BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: IF (sub(slow, 32767) < 0) { tmp16 = 0; - slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = Sqrt16(slow, &tmp16); move16(); slow = shl(slow, tmp16); } IF (sub(fast, 32767) < 0) { tmp16 = 0; - fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = Sqrt16(fast, &tmp16); move16(); fast = shl(fast, tmp16); } BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: IF (sub(slow, 32767) < 0) { slow = mult(slow, mult(slow, slow)); @@ -144,13 +175,13 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF IF (sub(slow, 32767) < 0) { tmp16 = 0; - slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = Sqrt16(slow, &tmp16); move16(); slow = shl(slow, tmp16); } IF (sub(slow, 32767) < 0) { tmp16 = 0; - slow = Sqrt16_lc3plus(slow, &tmp16); move16(); + slow = Sqrt16(slow, &tmp16); move16(); slow = shl(slow, tmp16); } IF (sub(fast, 32767) < 0) @@ -160,16 +191,18 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF IF (sub(fast, 32767) < 0) { tmp16 = 0; - fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = Sqrt16(fast, &tmp16); move16(); fast = shl(fast, tmp16); } IF (sub(fast, 32767) < 0) { tmp16 = 0; - fast = Sqrt16_lc3plus(fast, &tmp16); move16(); + fast = Sqrt16(fast, &tmp16); move16(); fast = shl(fast, tmp16); } BREAK; + case LC3PLUS_FRAME_DURATION_10MS: BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } if (plc_fadeout_type == 0) @@ -187,17 +220,26 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + lost_frame_thr1 = 32; + lost_frame_thr2 = 64; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: lost_frame_thr1 = 16; lost_frame_thr2 = 32; BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: lost_frame_thr1 = 8; lost_frame_thr2 = 16; BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: lost_frame_thr1 = 6; lost_frame_thr2 = 11; + BREAK; + case LC3PLUS_FRAME_DURATION_10MS: BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } IF (sub(nbLostFramesInRow, lost_frame_thr1) < 0) { @@ -222,7 +264,20 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF IF (spec_inv_idx == 0) { - lossDuration_dms = DEPR_i_mult(nbLostFramesInRow, frame_dms); + int frame_dms_val = 0; + SWITCH (frame_dms) /* 1 / frame_dms in Q15 */ + { +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: frame_dms_val = 125; BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: frame_dms_val = 250; BREAK; + case LC3PLUS_FRAME_DURATION_5MS: frame_dms_val = 500; BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: frame_dms_val = 750; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: frame_dms_val = 1000; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); + } + + lossDuration_dms = i_mult(nbLostFramesInRow, frame_dms_val/10); IF (sub(lossDuration_dms, PLC_FADEOUT_IN_MS*10) > 0) { *cum_fflcAtten = 0; move16(); @@ -232,10 +287,14 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF { SWITCH (frame_dms) { - case 25: fflcAtten = PLC34_ATTEN_FAC_025_FX; BREAK; - case 50: fflcAtten = PLC34_ATTEN_FAC_050_FX; BREAK; - case 75: fflcAtten = PLC34_ATTEN_FAC_075_FX; BREAK; - case 100: fflcAtten = PLC34_ATTEN_FAC_100_FX; BREAK; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: fflcAtten = PLC34_ATTEN_FAC_125_FX; BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: fflcAtten = PLC34_ATTEN_FAC_025_FX; BREAK; + case LC3PLUS_FRAME_DURATION_5MS: fflcAtten = PLC34_ATTEN_FAC_050_FX; BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: fflcAtten = PLC34_ATTEN_FAC_075_FX; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: fflcAtten = PLC34_ATTEN_FAC_100_FX; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } } IF ( sub(fflcAtten, 32767) < 0 ) @@ -251,21 +310,29 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF plc_end_inFrames; decreasing linearly in between */ SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + plc_start_inFrames = (100 * PLC4_TRANSIT_START_IN_MS) / 125; move16(); + plc_end_inFrames = (100 * PLC4_TRANSIT_END_IN_MS) / 125; move16(); + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: plc_start_inFrames = (10*PLC4_TRANSIT_START_IN_MS) / 25; move16(); plc_end_inFrames = (10*PLC4_TRANSIT_END_IN_MS) / 25; move16(); BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: plc_start_inFrames = (10*PLC4_TRANSIT_START_IN_MS) / 50; move16(); plc_end_inFrames = (10*PLC4_TRANSIT_END_IN_MS) / 50; move16(); BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: plc_start_inFrames = (10*PLC4_TRANSIT_START_IN_MS) / 75; move16(); plc_end_inFrames = (10*PLC4_TRANSIT_END_IN_MS) / 75; move16(); BREAK; - default: + case LC3PLUS_FRAME_DURATION_10MS: plc_start_inFrames = (10*PLC4_TRANSIT_START_IN_MS) / 100; move16(); plc_end_inFrames = (10*PLC4_TRANSIT_END_IN_MS) / 100; move16(); + BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } if (pitch_present == 0) @@ -320,21 +387,21 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF tmp16 = mult(18022 /* 10 - 1.2 */, linFuncStartStop); ad_threshFac = add(shr(tmp16, 1), 1228 /* 1.2 >> 1 */); /* exp = 5 */ - s = getScaleFactor32_lc3plus(&spec[spec_inv_idx], sub(L_spec, spec_inv_idx)); + s = getScaleFactor32(&spec[spec_inv_idx], sub(L_spec, spec_inv_idx)); frame_energy = 0; move32(); FOR (i = spec_inv_idx; i < L_spec; i++) { tmp16 = extract_h(L_shl_sat(spec[i], sub(s, 4))); frame_energy = L_mac0(frame_energy, tmp16, tmp16); /* exp = -(2*(s-16) - 8) */ } - mean_energy16 = BASOP_Util_Divide3216_Scale_lc3plus(frame_energy, sub(L_spec, spec_inv_idx), &s2); /* exp = -(2*(s-16) - 8) + 16 - (15-s2) */ + mean_energy16 = BASOP_Util_Divide3216_Scale(frame_energy, sub(L_spec, spec_inv_idx), &s2); /* exp = -(2*(s-16) - 8) + 16 - (15-s2) */ energThreshold = mult(ad_threshFac, mean_energy16); /* exp = -(2*(s-16) - 8) + 16 - (15-s2) + 5 */ s3 = add(sub(29, shl(sub(s, 16), 1)), s2); IF (sub(energThreshold, 32767) < 0) { - energThreshold = Sqrt16_lc3plus(energThreshold, &s3); + energThreshold = Sqrt16(energThreshold, &s3); } s3 = sub(s3, 15); @@ -345,7 +412,7 @@ void processPLCDampingScrambling_fx(Word32 spec[], Word16 L_spec, Word16 nbLostF FOR (i = spec_inv_idx; i < L_spec; i++) { - if ( ( plc_fadeout_type != 0 ) || (L_sub(L_abs(spec[i]), mean_nrg) < 0) ) + if ( ( plc_fadeout_type != 0 ) || (L_sub(L_abs_sat(spec[i]), mean_nrg) < 0) ) { spec[i] = Mpy_32_16_lc3plus(spec[i], cum_fading_slow_local); } diff --git a/lib_lc3plus/plc_lpc_scaling_fx.c b/lib_lc3plus/plc_lpc_scaling_fx.c index 15d753342..945f583a1 100644 --- a/lib_lc3plus/plc_lpc_scaling_fx.c +++ b/lib_lc3plus/plc_lpc_scaling_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -22,7 +24,7 @@ void processPLCLpcScaling_fx(Word32 tdc_A_32[], Word16 tdc_A_16[], Word16 m) })); #endif - s = getScaleFactor32_lc3plus(tdc_A_32, m); + s = getScaleFactor32(tdc_A_32, m); FOR (i = 0; i < m; i++) { tdc_A_16[i] = round_fx_sat(L_shl_sat(tdc_A_32[i], s)); move16(); diff --git a/lib_lc3plus/plc_main_fx.c b/lib_lc3plus/plc_main_fx.c index 87cfb59d4..9f12d15a0 100644 --- a/lib_lc3plus/plc_main_fx.c +++ b/lib_lc3plus/plc_main_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -21,7 +23,7 @@ void processPLCmain_fx(Word16 plcMeth, Word16 *concealMethod, Word16 *nbLostFram Word16 *ola_mem_exp, Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q_d_fx[], Word16 *q_fx_exp, Word16 yLen, Word16 fs_idx, const Word16 *band_offsets, Word16 bands_number, Word16 *damping, Word16 old_pitch_int, Word16 old_pitch_fr, Word16 *ns_cum_alpha, Word16 *ns_seed, - AplcSetup *plcAd, Word16 frame_dms, Word8 *scratchBuffer, Word16 *pc_nbLostFramesInRow + AplcSetup *plcAd, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer, Word16 *pc_nbLostFramesInRow #ifdef ENABLE_HR_MODE , Word16 hrmode #endif diff --git a/lib_lc3plus/plc_noise_substitution_fx.c b/lib_lc3plus/plc_noise_substitution_fx.c index 0b227edae..5bf71258a 100644 --- a/lib_lc3plus/plc_noise_substitution_fx.c +++ b/lib_lc3plus/plc_noise_substitution_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" diff --git a/lib_lc3plus/plc_phecu_f0_refine_first_fx.c b/lib_lc3plus/plc_phecu_f0_refine_first_fx.c index 5a37b4149..4c4f26b00 100644 --- a/lib_lc3plus/plc_phecu_f0_refine_first_fx.c +++ b/lib_lc3plus/plc_phecu_f0_refine_first_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" diff --git a/lib_lc3plus/plc_phecu_fec_hq_fx.c b/lib_lc3plus/plc_phecu_fec_hq_fx.c index 5686920de..37711a6bc 100644 --- a/lib_lc3plus/plc_phecu_fec_hq_fx.c +++ b/lib_lc3plus/plc_phecu_fec_hq_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" #include "math.h" /*dbg*/ @@ -558,7 +560,7 @@ void trans_burst_ana_fx( /* beta[k] = beta_pre[k]* *beta_mute;*/ /* (1.0-alpha.^2), in exp 1 due to L_mult0; */ - L_acc = L_sub((INT32_MAX >> 1) + 1, L_mult0(alpha[k], alpha[k])); + L_acc = L_sub((INT_MAX >> 1) + 1, L_mult0(alpha[k], alpha[k])); { /* use lower complex(WMOPS/ROM) 2nd-order sqrt approximation */ @@ -862,7 +864,7 @@ static Word16 imax_fx( /* o: The location, relative to the Lprot = LprotSzPtr[bwidth_fx]; move16(); - hamm_len2 = DEPR_i_mult(3, mult(output_frame, (Word16)(3277) /* divBy10 + floor */)); /* 3 ms */ + hamm_len2 = i_mult(3, mult(output_frame, (Word16)(3277) /* divBy10 + floor */)); /* 3 ms */ fft_scale = PhEcuFftScale[bwidth_fx]; move16(); /* 32,16,8 kHz all have fft scale 0, 24 has 8, 48 has 4 */ Lprot2 = shr_pos(Lprot, 1); @@ -1873,7 +1875,6 @@ static Word16 imax_fx( /* o: The location, relative to the Word16 prevsynth_man_upshift; Word16 Q_prevsynthMinus1; Word8 *buffer; - // ToDO Word32 L_Xavg[MAX_LGW]; })); #endif @@ -2922,7 +2923,7 @@ static Word16 imax_fx( /* o: The location, relative to the /* log2(Upshifted Word32) */ /* maximize precision in BASOP Log2 function */ - L_XavgL2_fx[i] = BASOP_Util_Log2_lc3plus(L_tmp); /* L_input 1.0 or lower --> output always negative */ + L_XavgL2_fx[i] = BASOP_Util_Log2(L_tmp); /* L_input 1.0 or lower --> output always negative */ /* add 31.0 to store as fractional bits of an upscaled positive Word32 integer input ) */ L_XavgL2_fx[i] = L_add(31L << 25, L_XavgL2_fx[i]); /* only diffs added so 31.0 is cancelled out later , in total only values between +/- 2^6 = [-64 ... -64[ are possible */ } /* band i for L_Xavg calc*/ diff --git a/lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c b/lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c index b32c61b66..cdd082c31 100644 --- a/lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c +++ b/lib_lc3plus/plc_phecu_lf_peak_analysis_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" diff --git a/lib_lc3plus/plc_phecu_peak_locator_fx.c b/lib_lc3plus/plc_phecu_peak_locator_fx.c index ddb348666..e1342a486 100644 --- a/lib_lc3plus/plc_phecu_peak_locator_fx.c +++ b/lib_lc3plus/plc_phecu_peak_locator_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" diff --git a/lib_lc3plus/plc_phecu_setf0hz_fx.c b/lib_lc3plus/plc_phecu_setf0hz_fx.c index 6b2322f00..b21488af4 100644 --- a/lib_lc3plus/plc_phecu_setf0hz_fx.c +++ b/lib_lc3plus/plc_phecu_setf0hz_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" diff --git a/lib_lc3plus/plc_phecu_tools_fx.c b/lib_lc3plus/plc_phecu_tools_fx.c index c37d6ba32..c9eb49e02 100644 --- a/lib_lc3plus/plc_phecu_tools_fx.c +++ b/lib_lc3plus/plc_phecu_tools_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -171,7 +173,7 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ push_wmops("PhECU::winEnCalc"); #endif - L_tot = INT32_MAX; move32(); /*acc is on negative side , but as all accumulation is positive, we make use of one extra bit */ + L_tot = INT_MAX; move32(); /*acc is on negative side , but as all accumulation is positive, we make use of one extra bit */ pX = x; pW = win; @@ -210,7 +212,7 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ /* handle wrap on zero point */ IF( L_tot >= 0 ) { /* L_tot positive --> less than 32 bits needed, */ - L_tot = L_add(L_tot,(INT32_MIN+1)); + L_tot = L_add(L_tot,(INT_MIN+1)); if( L_tot == 0 ) { *exp = LTOT_MIN_EXP; /* WC is actually (-(15+4)*2 + 1 +1 -31) */ ; move16(); @@ -221,12 +223,12 @@ Word32 winEnCalc( /* o: output summed energy Ltot */ { /* L_tot negative --> more than 31 bits needed for sum , scale 32 bit sum within 31 bits and adjust exp */ L_tot = L_shr_pos(L_add(L_tot,1),1); /* rnd by adding 1, then use 50% contribution from negative side */ - L_tot = L_add(L_tot, INT32_MIN>>1); /* add 50% contribution from positive side */ + L_tot = L_add(L_tot, INT_MIN>>1); /* add 50% contribution from positive side */ *exp = add(*exp, 1); move16(); } - L_tot = L_max( -(INT32_MAX), L_tot); /* guard against max accumulation on the negative side , should only occur for rectangle windows */ + L_tot = L_max( -(INT_MAX), L_tot); /* guard against max accumulation on the negative side , should only occur for rectangle windows */ L_tot = L_negate(L_tot); /* no saturation here */ /* activate when xfp_exp is not used any longer */ diff --git a/lib_lc3plus/plc_tdac_fx.c b/lib_lc3plus/plc_tdac_fx.c index e419abfe6..43b85be6d 100644 --- a/lib_lc3plus/plc_tdac_fx.c +++ b/lib_lc3plus/plc_tdac_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -118,6 +120,12 @@ void processTdac_fx(Word16 *ola_mem, Word16 *ola_mem_exp, const Word16 *synth_in { INV_NORM_E = add(INV_NORM_E, 2); } +#ifdef FIX_PLC_CONFORM_ISSUES + if (sub(frame_len, 30) == 0) + { + INV_NORM_E = add(INV_NORM_E, 2); + } +#endif } /* Scale input */ diff --git a/lib_lc3plus/plc_tdc_inverse_odft_fx.c b/lib_lc3plus/plc_tdc_inverse_odft_fx.c index 753268489..3eb4cdc6a 100644 --- a/lib_lc3plus/plc_tdc_inverse_odft_fx.c +++ b/lib_lc3plus/plc_tdc_inverse_odft_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -39,12 +41,20 @@ void processInverseODFT_fx(Word32 *r_fx, Word16 *r_fx_exp, Word32 *d2_fx, Word16 buffer_BASOP_rfftN = scratchAlign(x, sizeof(*x) * (MAX_BANDS_NUMBER_PLC + MAX_BANDS_NUMBER_PLC/2)); /* Size = 480 bytes */ ASSERT(lpc_order <= M); +#ifdef FIX_PLC_CONFORM_ISSUES + ASSERT(n_bands == 80 || n_bands == 60 || n_bands == 40 || n_bands == 30 || n_bands == 20); +#else ASSERT(n_bands == 80 || n_bands == 60 || n_bands == 40 || n_bands == 20); +#endif n_bands2 = shr_pos_pos(n_bands, 1); test(); - IF (sub(n_bands, 20) == 0 || sub(n_bands, 60) == 0) +#ifdef FIX_PLC_CONFORM_ISSUES + IF( sub(n_bands, 20) == 0 || sub( n_bands, 30) == 0 || sub( n_bands, 60) == 0 ) +#else + IF( sub(n_bands, 20) == 0 || sub( n_bands, 60) == 0 ) +#endif { /* sort input samples */ FOR (i = 0; i < n_bands2; i++) @@ -54,7 +64,7 @@ void processInverseODFT_fx(Word32 *r_fx, Word16 *r_fx_exp, Word32 *d2_fx, Word16 x[n_bands + 2*i] = d2_fx[n_bands - 1 - 2 * i]; move32(); x[n_bands + 2*i + 1] = 0; move32(); } - BASOP_cfft_lc3plus(&x[0], &x[1], n_bands, 2, &d2_fx_exp, (Word32*)buffer_BASOP_rfftN); + BASOP_cfft(&x[0], &x[1], n_bands, 2, &d2_fx_exp, (Word32*)buffer_BASOP_rfftN); } ELSE { @@ -75,6 +85,13 @@ void processInverseODFT_fx(Word32 *r_fx, Word16 *r_fx_exp, Word32 *d2_fx, Word16 inv_odft_twiddle_re = inv_odft_twiddle_20_re; inv_odft_twiddle_im = inv_odft_twiddle_20_im; } +#ifdef FIX_PLC_CONFORM_ISSUES + ELSE IF(sub(n_bands, 30) == 0 ) + { + inv_odft_twiddle_re = inv_odft_twiddle_30_re; + inv_odft_twiddle_im = inv_odft_twiddle_30_im; + } +#endif ELSE IF (sub(n_bands, 40) == 0) { inv_odft_twiddle_re = inv_odft_twiddle_40_re; diff --git a/lib_lc3plus/plc_tdc_lagwin_fx.c b/lib_lc3plus/plc_tdc_lagwin_fx.c index 4fb8cd6c5..2de348eb2 100644 --- a/lib_lc3plus/plc_tdc_lagwin_fx.c +++ b/lib_lc3plus/plc_tdc_lagwin_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" diff --git a/lib_lc3plus/plc_tdc_main_fx.c b/lib_lc3plus/plc_tdc_main_fx.c index 4867342cd..56e62f21b 100644 --- a/lib_lc3plus/plc_tdc_main_fx.c +++ b/lib_lc3plus/plc_tdc_main_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -17,7 +19,7 @@ static Word32 TDC_L_Dot_product(const Word16 x[], const Word16 y[], const Word16 static void TDC_highPassFiltering_fx(const Word16 L_buffer, Word16 exc2[], const Word16 l_fir_fer, const Word16 *hp_filt); static Word32 TDC_calcGainp(Word16 x[], Word16 y[], Word16 lg); -static void TDC_calcGainc(Word16 *exc, Word16 Q_exc, Word16 old_fpitch, Word16 lg, Word16 frame_dms, Word16 lp_gainp, Word32 *lp_gainc); +static void TDC_calcGainc(Word16 *exc, Word16 Q_exc, Word16 old_fpitch, Word16 lg, LC3PLUS_FrameDuration frame_dms, Word16 lp_gainp, Word32 *lp_gainc); static void TDC_random_fx(Word16 *seed, Word16 lg, Word16 *y); static Word16 TDC_preemph(Word16 *x, const Word16 fac, const Word16 lg); static void TDC_LPC_residu_fx(const Word16 *a, Word16 *x, Word16 *y, Word16 lg, Word16 m); @@ -25,7 +27,23 @@ static void TDC_deemph_fx(const Word16 *x, Word16 *y, const Word16 fac, const static void TDC_LPC_synthesis_fx(const Word16 sh, const Word16 a[], const Word16 x[], Word16 y[], const Word16 lg, const Word16 m); static void TDC_normalize_energy_fx(Word16 *gain, Word16 *gain_exp, const Word16 *x, const Word16 lg); - + +#ifdef FIX_TDC_BURST_ERROR +const Word16 beforeNextIncArray_fx[5][8] = { + { 0, 0, 0, 0, 0, 0, 0, 1 }, + { 0, 0, 0, 1, 0, 0, 0, 1 }, + { 0, 1, 0, 1, 0, 1, 0, 1 }, + { 0, 1, 1, 1, 0, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1 } +}; +const Word16 nextIncArray_fx[5][8] = { + { 1, 0, 0, 0, 0, 0, 0, 0 }, + { 1, 0, 0, 0, 1, 0, 0, 0 }, + { 1, 0, 1, 0, 1, 0, 1, 0 }, + { 1, 0, 1, 1, 1, 0, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1 } +}; +#else const Word16 beforeNextIncArray_fx[4][4] = {{0,0,0,1}, {0,1,0,1}, {0,1,1,1}, @@ -34,7 +52,9 @@ const Word16 nextIncArray_fx[4][4] = {{1,0,0,0}, {1,0,1,0}, {1,0,1,1}, {1,1,1,1}}; -static Word16 type_2_alpha_long(Word16 nbLostFramesInRow, Word16 frame_dms); +#endif + +static Word16 type_2_alpha_long(Word16 nbLostFramesInRow, LC3PLUS_FrameDuration frame_dms); static Word16 powWord16rest(Word16 base, Word16 exp, Word16 rest); /*****************************************************************************/ @@ -70,14 +90,14 @@ static Word16 powWord16rest(Word16 base, Word16 exp, Word16 rest); */ void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 preemphFac_fx, const Word16 *A_fx, const Word16 lpc_order, const Word16 *pcmbufHist_fx, const Word16 frame_length, - const Word16 frame_dms, const Word16 fs_idx, const Word16 nbLostFramesInRow, + const LC3PLUS_FrameDuration frame_dms, const Word16 fs_idx, const Word16 nbLostFramesInRow, const Word16 overlap, const Word16 stabFac_fx, Word16 *fract, Word16 *seed_fx, Word32 *gain_c_fx, Word16 *synth_fx, Word16 *Q_syn, Word16 *alpha, Word16 max_len_pcm_plc, Word16 harmonicBuf_fx[MAX_PITCH], Word16 synthHist_fx[M], Word16 *const harmonicBuf_Q, Word8 *scratchBuffer , UWord8 plc_fadeout_type - , Word16 * alpha_type_2_table + ,Word16 * alpha_type_2_table ) { Counter i; @@ -126,14 +146,54 @@ void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 /* len of output signal */ len = add(frame_length, overlap); + + int frame_dms_val = 0; + SWITCH (frame_dms) + { +#ifdef FIX_TDC_BURST_ERROR +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: frame_dms_val = 1; break; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: frame_dms_val = 2; break; + case LC3PLUS_FRAME_DURATION_5MS: frame_dms_val = 4; break; + case LC3PLUS_FRAME_DURATION_7p5MS: frame_dms_val = 6; break; + case LC3PLUS_FRAME_DURATION_10MS: frame_dms_val = 8; break; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); + default: assert( 0 ); +#else +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: frame_dms_val = 125; break; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: frame_dms_val = 250; break; + case LC3PLUS_FRAME_DURATION_5MS: frame_dms_val = 500; break; + case LC3PLUS_FRAME_DURATION_7p5MS: frame_dms_val = 750; break; + case LC3PLUS_FRAME_DURATION_10MS: frame_dms_val = 1000; break; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); +#endif + } +#ifdef FIX_TDC_BURST_ERROR + nbLostFramesInRow_mod = sub( nbLostFramesInRow, 1 ) & 0x0007; + nbLostCmpt_loc = L_add(L_shr(L_mult0(frame_dms_val, sub(nbLostFramesInRow, 1)), 3), 1); + if (sub(frame_dms_val, 1) == 0) + { + frame_dms_idx = 0; + } + else + { + frame_dms_idx = shr(frame_dms, 1); + } + beforeNextInc = beforeNextIncArray_fx[frame_dms_idx][nbLostFramesInRow_mod]; + nextInc = nextIncArray_fx[frame_dms_idx][nbLostFramesInRow_mod]; +#else nbLostFramesInRow_mod = sub(nbLostFramesInRow, 1) & 0x0003; - frame_dms_idx = mult(frame_dms, 0x051F); + frame_dms_idx = mult(frame_dms_val/10, 0x051F); nbLostCmpt_loc = add(shr(L_mult0(frame_dms_idx, sub(nbLostFramesInRow, 1)), 2), 1); frame_dms_idx = sub(frame_dms_idx, 1); beforeNextInc = beforeNextIncArray_fx[frame_dms_idx][nbLostFramesInRow_mod]; move16(); nextInc = nextIncArray_fx [frame_dms_idx][nbLostFramesInRow_mod]; move16(); +#endif IF (sub(nbLostCmpt_loc, plc_fadeout_len / 10) > 0) { @@ -281,7 +341,7 @@ void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 ELSE { exp_scale = 0; - *alpha = Sqrt16_lc3plus(gain_p_fx, &exp_scale); move16(); + *alpha = Sqrt16(gain_p_fx, &exp_scale); move16(); *alpha = shl(*alpha, exp_scale); } } @@ -327,10 +387,14 @@ void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 { SWITCH (frame_dms) { - case 25: *alpha = mult(*alpha, PLC34_ATTEN_FAC_025_FX); BREAK; - case 50: *alpha = mult(*alpha, PLC34_ATTEN_FAC_025_FX); BREAK; - case 75: *alpha = mult(*alpha, PLC34_ATTEN_FAC_075_FX); BREAK; - case 100: *alpha = mult(*alpha, PLC34_ATTEN_FAC_100_FX); BREAK; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: *alpha = mult(*alpha, PLC34_ATTEN_FAC_125_FX); BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: *alpha = mult(*alpha, PLC34_ATTEN_FAC_025_FX); BREAK; + case LC3PLUS_FRAME_DURATION_5MS: *alpha = mult(*alpha, PLC34_ATTEN_FAC_025_FX); BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: *alpha = mult(*alpha, PLC34_ATTEN_FAC_075_FX); BREAK; + case LC3PLUS_FRAME_DURATION_10MS: *alpha = mult(*alpha, PLC34_ATTEN_FAC_100_FX); BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } } if (sub(nbLostCmpt_loc, 5) > 0) @@ -423,9 +487,9 @@ void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 /* update steps */ if (frame_length == 720) { - ilen = BASOP_Util_Divide1616_Scale_lc3plus((Word16)1, 960, &ilen_exp); + ilen = BASOP_Util_Divide1616_Scale((Word16)1, 960, &ilen_exp); } else { - ilen = BASOP_Util_Divide1616_Scale_lc3plus((Word16)1, frame_length, &ilen_exp); + ilen = BASOP_Util_Divide1616_Scale((Word16)1, frame_length, &ilen_exp); } step_fx = round_fx(L_shl(L_mult(sub(gain_h_fx, *alpha), ilen), ilen_exp)); @@ -500,6 +564,15 @@ void processTimeDomainConcealment_Apply_fx(const Word16 pitch_int, const Word16 mem_deemph = shl_sat(pcmbufHist_fx[max_len_pcm_plc - 1], *Q_syn); TDC_deemph_fx(synth_tmp_fx, synth_fx, preemphFac_fx, len, mem_deemph); +#ifdef CR12_B_STOP_DC_RINGING_NO + if ((gain_h_fx == 0) && (g_fx == 0)) + { + for (i = 0; i < len; i++) + { + synth_fx[i] = 0; + } + } +#endif /*----------------------------------------------------------* * Fade to zero * *----------------------------------------------------------*/ @@ -666,7 +739,7 @@ static void TDC_highPassFiltering_fx(const Word16 L_buffer, Word16 exc2[], const * Returns: * void */ -static void TDC_calcGainc(Word16 *exc, Word16 Q_exc, Word16 old_fpitch, Word16 lg, Word16 frame_dms, Word16 lp_gainp, Word32 *lp_gainc) +static void TDC_calcGainc(Word16 *exc, Word16 Q_exc, Word16 old_fpitch, Word16 lg, LC3PLUS_FrameDuration frame_dms, Word16 lp_gainp, Word32 *lp_gainc) { Dyn_Mem_Deluxe_In( Word16 tmp16, tmp_e, tmp2_e; @@ -683,7 +756,7 @@ static void TDC_calcGainc(Word16 *exc, Word16 Q_exc, Word16 old_fpitch, Word16 l L_tmp = L_mac0_sat(L_tmp, tmp16, tmp16); /*Q3*/ } - IF (sub(frame_dms, 100) < 0) + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_10MS) < 0) { L_tmp_max = L_deposit_l(0); FOR (i = 0; i < lg; i++) @@ -696,12 +769,12 @@ static void TDC_calcGainc(Word16 *exc, Word16 Q_exc, Word16 old_fpitch, Word16 l tmp_e = norm_l(L_tmp); L_tmp = L_shl(L_tmp, tmp_e); tmp_e = sub(sub(31, shl_pos(Q_exc, 1)), tmp_e); /*L_tmp is Q31, now*/ - tmp16 = BASOP_Util_Divide3216_Scale_lc3plus(L_tmp /*Q31,norm,tmp_e*/, lg /*Q15,15*/, &tmp2_e) /*Q15,tmp2_e+tmp_e-15*/; + tmp16 = BASOP_Util_Divide3216_Scale(L_tmp /*Q31,norm,tmp_e*/, lg /*Q15,15*/, &tmp2_e) /*Q15,tmp2_e+tmp_e-15*/; tmp_e = sub(add(tmp2_e, tmp_e), 15); IF (tmp16 != 0) { - tmp16 = Sqrt16_lc3plus(tmp16, &tmp_e); /*Q15,norm,tmp_e*/ + tmp16 = Sqrt16(tmp16, &tmp_e); /*Q15,norm,tmp_e*/ tmp_e = L_min(tmp_e, 15); *lp_gainc = L_shl_pos(L_deposit_l(tmp16), add(tmp_e, 1)); /*15Q16*/ move32(); @@ -743,7 +816,14 @@ static Word32 TDC_calcGainp(Word16 x[], Word16 y[], Word16 lg) FOR (i = 0; i < lg; i += 2) { L_tmp1 = L_mac0_sat(L_tmp1, x[i], y[i]); +#ifdef FIX_PLC_CONFORM_ISSUES + IF (i + 1 < lg) + { +#endif L_tmp2 = L_mac0_sat(L_tmp2, x[i + 1], y[i + 1]); +#ifdef FIX_PLC_CONFORM_ISSUES + } +#endif } tcorr = L_add(L_shr_pos(L_tmp1, 1), L_shr_pos(L_tmp2, 1)); Q_corr = norm_l(tcorr); @@ -755,7 +835,14 @@ static Word32 TDC_calcGainp(Word16 x[], Word16 y[], Word16 lg) FOR (i = 0; i < lg; i += 2) { L_tmp1 = L_mac0_sat(L_tmp1, y[i], y[i]); +#ifdef FIX_PLC_CONFORM_ISSUES + IF (i + 1 < lg) + { +#endif L_tmp2 = L_mac0_sat(L_tmp2, y[i + 1], y[i + 1]); +#ifdef FIX_PLC_CONFORM_ISSUES + } +#endif } tener = L_add(L_shr_pos(L_tmp1, 1), L_shr_pos(L_tmp2, 1)); Q_ener = norm_l(tener); @@ -768,7 +855,7 @@ static Word32 TDC_calcGainp(Word16 x[], Word16 y[], Word16 lg) { negative = 1; move16(); } - tcorr = L_abs(tcorr); + tcorr = L_abs_sat(tcorr); m_corr = extract_h(tcorr); @@ -1072,7 +1159,7 @@ static void TDC_normalize_energy_fx(Word16 *gain, Word16 *gain_exp, const Word16 e = norm_l(tmp); tmp = L_shl_pos(tmp, e); e1 = sub(sub(30, e), -8); move16(); - tmp16 = BASOP_Util_Divide3216_Scale_lc3plus(tmp, lg, &e2); + tmp16 = BASOP_Util_Divide3216_Scale(tmp, lg, &e2); e = 0; move16(); if (tmp16 != 0) @@ -1101,40 +1188,40 @@ static void TDC_normalize_energy_fx(Word16 *gain, Word16 *gain_exp, const Word16 tmp16 = add(shr_pos(tmp16, e2), shr_pos(c, e2)); e = add(e, e2); - tmp16 = Sqrt16_lc3plus(tmp16, &e); + tmp16 = Sqrt16(tmp16, &e); - *gain = BASOP_Util_Divide1616_Scale_lc3plus((Word16)0x7FFF, tmp16, &e1); move16(); + *gain = BASOP_Util_Divide1616_Scale((Word16)0x7FFF, tmp16, &e1); move16(); *gain_exp = sub(e1, e); move16(); Dyn_Mem_Deluxe_Out(); } -static Word16 type_2_alpha_long(Word16 nbLostFramesInRow, Word16 frame_dms) +static Word16 type_2_alpha_long(Word16 nbLostFramesInRow, LC3PLUS_FrameDuration frame_dms) { Word16 n_help; Word32 n_shift; - if (nbLostFramesInRow <= 3*(100.0/frame_dms)){ - n_help = (nbLostFramesInRow + (100/frame_dms) - 1) * frame_dms; + if (nbLostFramesInRow <= 3*(100.0/(frame_dms*1.25*10))){ + n_help = (nbLostFramesInRow + (100/(frame_dms*1.25*10)) - 1) * (frame_dms*1.25*10); return powWord16rest(31129,n_help/100,n_help%100); } else { - n_shift = (nbLostFramesInRow - 3*(100/frame_dms)) * 50/frame_dms; - n_help = (n_shift + (100/frame_dms) - 1) * frame_dms; + n_shift = (nbLostFramesInRow - 3*(100/(frame_dms*1.25*10))) * 50/(frame_dms*1.25*10); + n_help = (n_shift + (100/(frame_dms*1.25*10)) - 1) * (frame_dms*1.25*10); return powWord16rest(22937,n_help/100,n_help%100); } } -Word16 type_2_fadeout_fx(Word16 nbLostFramesInRow, Word16 frame_dms) +Word16 type_2_fadeout_fx(Word16 nbLostFramesInRow, LC3PLUS_FrameDuration frame_dms) { Word16 n_help; - Word16 selector = PLC_FADEOUT_TYPE_2_SELECTOR * 2 * (100/frame_dms); + Word16 selector = PLC_FADEOUT_TYPE_2_SELECTOR * 2 * (100/(frame_dms*1.25*10)); if (selector >= nbLostFramesInRow){ return type_2_alpha_long(nbLostFramesInRow, frame_dms); } else { - n_help = (nbLostFramesInRow + (100/frame_dms) - 1) * frame_dms; + n_help = (nbLostFramesInRow + (100/(frame_dms*1.25*10)) - 1) * (frame_dms*1.25*10); return powWord16rest(16383,n_help/100, n_help%100); } } @@ -1154,23 +1241,23 @@ static Word16 powWord16rest(Word16 base, Word16 exp, Word16 rest) { SWITCH (rest) { case 50: - root = Sqrt16_lc3plus(base, &exp2); + root = Sqrt16(base, &exp2); shr(root,exp2); exp_result = L_shr(exp_result * root,15); /* 0.5^1.5 = 0.5^(3/2) = 0.5^3*sqrt(0.5) */ BREAK; case 25: - root = Sqrt16_lc3plus(base, &exp2); + root = Sqrt16(base, &exp2); shr(root,exp2); exp2 = 0; - root = Sqrt16_lc3plus(root, &exp2); + root = Sqrt16(root, &exp2); shr(root,exp2); exp_result = L_shr(exp_result * root,15); /* 0.5^(1/4) = 0.5^sqrt(sqrt(0.5)) */ BREAK; case 75: - root = Sqrt16_lc3plus(base, &exp2); + root = Sqrt16(base, &exp2); shr(root,exp2); exp2 = 0; - root = Sqrt16_lc3plus(root, &exp2); + root = Sqrt16(root, &exp2); shr(root,exp2); tmp_result = powWord16rest(root, 3, 0); exp_result = L_shr( exp_result * tmp_result,15); diff --git a/lib_lc3plus/plc_tdc_pre_emphasis_fx.c b/lib_lc3plus/plc_tdc_pre_emphasis_fx.c index bd587d088..401bb061b 100644 --- a/lib_lc3plus/plc_tdc_pre_emphasis_fx.c +++ b/lib_lc3plus/plc_tdc_pre_emphasis_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,10 +7,12 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" -void processPreEmphasis_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 frame_dms, Word8 *scratchBuffer) +void processPreEmphasis_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word16 fs_idx, Word16 n_bands, LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer) { Word16 s; Word32 nrg; @@ -38,21 +40,36 @@ void processPreEmphasis_fx(Word32 *d2_fx, Word16 *d2_fx_exp, Word16 fs_idx, Word pre_emph_e = lpc_lin_pre_emphasis_e[fs_idx]; SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: +#ifdef FIX_PLC_CONFORM_ISSUES + pre_emph = lpc_lin_pre_emphasis_1_25ms[fs_idx]; + pre_emph_e = lpc_lin_pre_emphasis_e_1_25ms[fs_idx]; +#endif + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: pre_emph = lpc_lin_pre_emphasis_2_5ms[fs_idx]; pre_emph_e = lpc_lin_pre_emphasis_e_2_5ms[fs_idx]; BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: pre_emph = lpc_lin_pre_emphasis_5ms[fs_idx]; pre_emph_e = lpc_lin_pre_emphasis_e_5ms[fs_idx]; BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: pre_emph = lpc_lin_pre_emphasis_7_5ms[fs_idx]; pre_emph_e = lpc_lin_pre_emphasis_e_7_5ms[fs_idx]; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: + BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } - ASSERT(n_bands==20 || n_bands==40 || n_bands==60 || n_bands ==80); +#ifdef FIX_PLC_CONFORM_ISSUES + ASSERT(n_bands == 20 || n_bands == 30 || n_bands == 40 || n_bands == 60 || n_bands == 80); +#else + ASSERT(n_bands == 20 || n_bands == 40 || n_bands == 60 || n_bands == 80); +#endif /* start processing */ smax = -31; move16(); diff --git a/lib_lc3plus/plc_update_aft_imdct_fx.c b/lib_lc3plus/plc_update_aft_imdct_fx.c index e1653f3af..18685f5b4 100644 --- a/lib_lc3plus/plc_update_aft_imdct_fx.c +++ b/lib_lc3plus/plc_update_aft_imdct_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" diff --git a/lib_lc3plus/plc_update_fx.c b/lib_lc3plus/plc_update_fx.c index ad0fbcf95..9cb2b02e4 100644 --- a/lib_lc3plus/plc_update_fx.c +++ b/lib_lc3plus/plc_update_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" @@ -44,7 +46,7 @@ void processPLCupdateSpec_fx(Word16 q_old_d_fx[], Word16 *q_old_fx_exp, Word32 q ); /* save spectrum and the corresponding exponent */ - s = getScaleFactor32_lc3plus(q_d_fx, yLen); + s = getScaleFactor32(q_d_fx, yLen); *q_old_fx_exp = sub(*q_fx_exp, s); @@ -163,7 +165,7 @@ void processPLCspec2shape_fx(Word16 prev_bfi, Word16 bfi, Word16 q_old_d_fx[], W L_tot = L_add(L_tot, L_acc); /* two negative numbers added */ - L_tot = L_max( -(INT32_MAX), L_tot); /* conditionally add 1 to negative side, to avoid possible saturation in L_negate */ + L_tot = L_max( -(INT_MAX), L_tot); /* conditionally add 1 to negative side, to avoid possible saturation in L_negate */ L_tot = L_negate(L_tot); /* no saturation here as L_tot is != INT_MIN */ diff --git a/lib_lc3plus/plc_xcorr_fx.c b/lib_lc3plus/plc_xcorr_fx.c index 360fb8d3f..0c3dbb0cf 100644 --- a/lib_lc3plus/plc_xcorr_fx.c +++ b/lib_lc3plus/plc_xcorr_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "functions.h" diff --git a/lib_lc3plus/pvq_dec_fx.c b/lib_lc3plus/pvq_dec_fx.c index ce2cff9cd..2eb1a76a4 100644 --- a/lib_lc3plus/pvq_dec_fx.c +++ b/lib_lc3plus/pvq_dec_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" Word16 pvq_dec_deidx_fx( /* out BER detected 1 , ok==0 */ @@ -71,6 +73,138 @@ void pvq_dec_scale_vec_fx(const Word16 *inQ14, Word16 adjGainQ13, Word16 *outQ14 Dyn_Mem_Deluxe_Out(); } +#ifdef CR9_C_ADD_1p25MS_LRSNS +void lrsns_pvq_dec_scale_W16vec_fx( + const Word16 *inQ14, + Word16 adjGainQ12, + Word16 *inQ11outQ11 +) +{ + Dyn_Mem_Deluxe_In( + Counter i; + ); + FOR(i = 0; i < M; i++) + { /* Q12*Q14 +1 -16 => Q11 */ + inQ11outQ11[i] = add(inQ11outQ11[i], mult_r(adjGainQ12, inQ14[i])); move16(); + /* Q11 = Q11 + adjGainQ12 *inQ14 +1-16 , note 12+14+1-16=11 */ + } + Dyn_Mem_Deluxe_Out(); +} + +#ifdef ENABLE_HR_MODE +void lrsns_pvq_dec_scale_W32vec_fx( + const Word32 *inQ30, + Word16 adjGainQ12, + Word32 *inQ27outQ26, + Word16 *outQ11 +) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word32 L_tmp; + ); + FOR(i = 0; i < M; i++) + { + L_tmp = L_shr_pos(L_add(inQ27outQ26[i], Mpy_32_16_lc3plus(inQ30[i], adjGainQ12)), 1); + /* Q26 = ( Q27 + inQ30*adjGainQ12 * +1-16 ) >>1 , note 30+12+1-16 =43-16 = 27 */ + inQ27outQ26[i] = L_tmp; move32(); + L_tmp = L_add(L_tmp, 1 << 14); /* manual round + 0.5*2^15 */ + L_tmp = L_min(16383L << 16, L_tmp); /* pre_saturate, to not exceed 32767 , for extract_l() below */ + L_tmp = L_max(-(16384L << 16), L_tmp); /* pre_saturate, to not exceed -32768. for extract_l() below */ + outQ11[i] = extract_h(L_shl_pos(L_tmp, 1)); move16(); /*26-16 +1= 26-15 = 11 --> Q26 to Q11*/ + + /* the effect of this Word32 to Word16 rounding does not result in exactly the same W16Q11 vector as DISABLE_HR */ + } + Dyn_Mem_Deluxe_Out(); +} +#endif /* ENABLE_HR_MODE */ + +void pvq_fess_dec_en1_normQ30andQ14_fx( + const Word16 *y /*Q0*/, + Word16 y_up_bits, + Word32 L_norm_factor, + Word16 norm_factorQ, + Word16 len, + Word32* L_y_norm, + Word16 *y_norm) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word32 L_tmp; + Word16 shift_tot; + ); + +#ifdef WMOPS + push_wmops("pvq_fess_dec_en1_normQ30andQ14_fx"); +#endif + + /* lrsns_norm_factorQ_L[N_SCF_SEARCH_SHAPES_ST2_LR] = { 31, 31, 19 + 16 }; */ /* 0_split, 1_full, 2_fixenv */ + /* maxamps = [8, 5, 12 ]; 8*2^11 = 2^14 =16384 , 5*2^12 = 20480, 12*2^11= 24576 */ + /* lrsns_y_up_bits[N_SCF_SEARCH_SHAPES_ST2_LR] = { 11, 12, 11 };*/ + + shift_tot = sub((30 + 16), add(norm_factorQ, y_up_bits)); + /* 0: lf_split (30+16) - (31+11) = 4 */ + /* 1: full (30+16) - (31+12) = 3 */ + /* 2: fixenv (30+16) - (35+11) = 0 */ + ASSERT(shift_tot >= 0); + FOR(i = 0; i < len; i++) + { + L_tmp = Mpy_32_16_0_0(L_norm_factor, shl_pos(y[i], y_up_bits)); /* Qfactor*Q_y_up => Qfactor*Qyup + 0 - 16 . e.g. Q31*Q11-16 = Q26 */ + L_y_norm[i] = L_shl_pos(L_tmp, shift_tot); move32(); /* shift up the target to Q30 */ + + y_norm[i] = round_fx(L_y_norm[i]); move16(); /* 30-16=> Q14, used in enc side gainQ loop, and for DISABLE_HR synthesis */ + + } +#ifdef WMOPS + pop_wmops(); /* pvq_fess_dec_en1_normQ30andQ14_fx*/ +#endif + Dyn_Mem_Deluxe_Out(); +} + +void FESSdeenum_fx(Word16 dim_in_fx, /* i : dimension of vec_out typically (M-1 == 15) */ + Word16 n_env_fx, /* i : number of envelopes */ + Word16 n_shift_fx, /* i : number shifts */ + Word16 n_signs_fx, /* i : number signs */ + Word16 env_ind_fx, /* i:indx */ + Word16 shift_ind_fx, /* i:indx */ + Word16 sign_ind_fx, /* i:indx */ + Word16* vec_out_fx /* o : FESS integer pulse train , with signs applied */) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word16 sign_val_fx; + ); + assert(n_env_fx >= 1 && n_env_fx <= 4); + assert(env_ind_fx >= 0 && env_ind_fx < n_env_fx); + assert(shift_ind_fx >= 0 && shift_ind_fx < n_shift_fx); + + UNUSED(n_env_fx); + UNUSED(n_shift_fx); + +#ifdef WMOPS + push_wmops("FESSdeenum_fx"); +#endif + + basop_memset(vec_out_fx, 0, sizeof(*vec_out_fx)*dim_in_fx); + + FOR(i = (shift_ind_fx + n_signs_fx - 1); i >= shift_ind_fx; i--) + { + /* low numbered coeff signs are in the msb's */ + /* high numbered coeff signs are in the lsb's */ + ASSERT(i < dim_in_fx); + + sign_val_fx = sub(1, shl_pos(s_and(sign_ind_fx, 0x01), 1)); /* 1 - 2*signbit_value */ + sign_ind_fx = shr_pos_pos(sign_ind_fx, 1); + + vec_out_fx[i] = extract_l(L_mult0(sign_val_fx, lrsns_fix_env_fx[env_ind_fx][i])); + } + +#ifdef WMOPS + pop_wmops(); /* */ +#endif + Dyn_Mem_Deluxe_Out(); +} +#endif void pvq_dec_en1_normQ14_fx(/* Have to be used EXACTLY the same way in both both encoder and decoder */ #ifdef ENABLE_HR_MODE diff --git a/lib_lc3plus/pvq_enc_fx.c b/lib_lc3plus/pvq_enc_fx.c index 87bc3009f..9351cbcc2 100644 --- a/lib_lc3plus/pvq_enc_fx.c +++ b/lib_lc3plus/pvq_enc_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,8 +7,118 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" #include "functions.h" +#ifdef CR9_C_ADD_1p25MS_LRSNS + static void pvq_pyr_project_lrsns_adv(const Word16 dim_proj, /* vector dimension */ + const Word16 *xabs, /* absolute vector values */ + Word32 L_xsum, /* absolute vector sum over dim_proj */ + Word16 num, /* start/safe target number of pulses for projection to a pyramid e.g. KMAX-1 */ + Word16 num_max, /* max number of pulses allowed , typically K_MAX */ + Word16 * y, /* projected integer output vector */ + Word16 *pulse_tot_ptr, Word32 *L_xy_ptr, /* accumulated correlation Q(in+0+1) = Qin+1 */ + Word32 *L_yy_ptr, /* accumulated energy Q0 */ + Word8 * scratch + ) + { + Dyn_Mem_Deluxe_In( + Counter i; + Word32 L_tmp, L_num; + Word16 den, shift_num, shift_den, shift_delta, proj_fac; + Word16 *y_r, *y_r_soft; + Word16 pulse_tot_r, pulse_tot_r_soft; + ); + +#ifdef FIX_BASOP_ENC_LRSNS_ST2FULL_PROJ + Word16 skip_rnd_flag = 0; +#endif + + y_r = (Word16 *)scratchAlign(scratch, 0); + y_r_soft = (Word16 *)scratchAlign(y_r, M * sizeof(*y_r)); /* y_r = M */ + /* y_r_soft = M */ + + *pulse_tot_ptr = 0; move16(); + pulse_tot_r = 0; move16(); + pulse_tot_r_soft = 0; move16(); + + shift_den = norm_l(L_xsum); /* x_sum input Qin */ + den = extract_h(L_shl_pos(L_xsum, shift_den)); /* now in Qin+shift_den */ + +#ifdef FIX_BASOP_ENC_LRSNS_ST2FULL_PROJ + IF(num_max == 0 ) { + num_max = num; move16(); /* use projection value num as num_max limit*/ + skip_rnd_flag = 1; move16(); + } +#endif + + L_num = L_deposit_l(num); + shift_num = sub(norm_l(L_num), 1); + L_num = L_shl_pos(L_num, shift_num); /* now in Q0 +shift_num -1 */ + + proj_fac = div_l(L_num, den); /* L_num always has to be less than den<<16 , norm_l-1 makes that happen */ + + shift_delta = sub(shift_num, shift_den); + + /* we are here using a single proj factor, but different rounding offsets 0(==trunc=safe), .25(soft), .5(==round=risky) */ + + FOR(i = 0; i < dim_proj; i++) + { + L_tmp = L_mult(proj_fac, xabs[i]); /* Q shift_delta + PVQ_SEARCH_QIN */ + L_tmp = L_shr(L_tmp, shift_delta); + + y[i] = extract_h(L_tmp); move16(); /* to Q0 with floor */ + *pulse_tot_ptr = add(*pulse_tot_ptr, y[i]); /* Q0 */ + + y_r[i] = extract_h(L_add(L_tmp, (Word32)0x00008000L)); /* regular round i.e. +.5 and truncate */ + pulse_tot_r = add(pulse_tot_r, y_r[i]); /* Q0 */ + + y_r_soft[i] = extract_h(L_add(L_tmp, (Word32)0x00004000L)); /* softer round i.e. +.25 and truncate */ + pulse_tot_r_soft = add(pulse_tot_r_soft, y_r_soft[i]); /* Q0 */ + } + + /* now analyze which rounding is valid and closest to num_max */ + +#ifdef FIX_BASOP_ENC_LRSNS_ST2FULL_PROJ + IF (skip_rnd_flag != 0 ) + { + pulse_tot_r = 32767; /*disable most optimistic rounding */ + pulse_tot_r_soft = 32767; /*disable soft optimistic rounding */ + } +#endif + + /* if y_r is successful and does not overshoot, let us use that */ + IF(sub(pulse_tot_r, num_max) <= 0) + { + basop_memcpy(y, y_r, dim_proj * sizeof(*y)); + *pulse_tot_ptr = pulse_tot_r; + pulse_tot_r_soft = 32767; /* exclude r_soft */ + } + + /* if y_r_soft is successful and does not overshoot, use that */ + IF(sub(pulse_tot_r_soft, num_max) <= 0) + { + basop_memcpy(y, y_r_soft, dim_proj * sizeof(*y)); + *pulse_tot_ptr = pulse_tot_r_soft; + pulse_tot_r = 32767; + } + + /*sum up correlation and energy */ + *L_xy_ptr = L_deposit_l(0); + *L_yy_ptr = L_deposit_l(0); + FOR(i = 0; i < dim_proj; i++) + { + *L_yy_ptr = L_mac0(*L_yy_ptr, y[i], y[i]); /* Energy, Q0 */ + *L_xy_ptr = L_mac(*L_xy_ptr, xabs[i], y[i]); /* Corr, Q11*Q0 +1 --> Q12 */ + } + ASSERT(*pulse_tot_ptr <= num_max); + + Dyn_Mem_Deluxe_Out(); + } +#endif + static void pvq_pyr_project(const Word16 dim_proj, /* end vector dimension+1 */ const Word16 *xabs, /* absolute vector values */ Word32 L_xsum, /* absolute vector sum over dim */ @@ -112,6 +222,69 @@ static __forceinline Word16 one_pulse_search(const Word16 dim_start, /* start v return imax; } +#ifdef CR9_C_ADD_1p25MS_LRSNS + +/* evaluate corr/sqrt(en) = corr*inv_sqrt_tab[en], as CorrSq/en ratio cross-multiplication may cost more */ + +static __forceinline Word16 one_pulse_search_tab_isqrt( + const Word16 dim_start, /* start vector dimension */ + const Word16 dim_end, /* end vector dimension+1 */ + const Word16 *x_abs, /* absolute vector values */ + Word16 * y, /* output vector */ + Word16 * pulse_tot_ptr, + Word32 * L_xy_ptr, /* accumulated correlation Q(12+0+1) = Q13 */ + Word32 * L_yy_ptr, /* accumulated energy Q0 */ + Word16 max_xabs) /* current max amplitude for target */ +{ + Dyn_Mem_Deluxe_In( + Counter i; + + Word32 L_cand_en_lc, L_cand_corr; + Word16 corr_up_shift, imax; + Word32 L_cand_norm_ratio, L_max_norm_ratio; + ); + + /* maximize correlation precision, prior to every unit pulse addition in the vector */ + corr_up_shift = norm_l(L_mac0(*L_xy_ptr, 2, max_xabs)); /* pre analyze worst case L_xy update in the dim loop */ + imax = -1; /* init not needed for this search, only added to avoid MSVC compiler warning */ + + /* select isqrt table for this pulse addition loop , based on current energy */ + const Word16* isqrt_QxTab = isqrt_Q16tab; move32(); /* Q16 table valid for energies 4...64 */ + if (L_sub(*L_yy_ptr, 3L) <= 0) /* +1 for the inloop value of L_yy was preadded outside to *L_yy_ptr */ + { + isqrt_QxTab = isqrt_Q15tab; move32(); /* energies: 1...6 */ + } + + { + L_max_norm_ratio = L_deposit_l(-1); /* req. to force a 1st update for n==dim_start */ + + FOR(i = dim_start; i < dim_end; i++) + { + L_cand_corr = L_shl_pos(L_mac0(*L_xy_ptr, 2, x_abs[i]), corr_up_shift); /* actual in-loop target value */ + L_cand_en_lc = L_mac0(*L_yy_ptr, 2, y[i]); /*Q0 y^2+ 2y +1, "+1" added once before loop outside */ + + L_cand_norm_ratio = Mpy_32_16_0_0(L_cand_corr, isqrt_QxTab[L_cand_en_lc]); /* energy normalized ratio, non-saturating operation */ + + /* 32 bit comparison WC (1 +1 +1 = 2 */ + if (L_sub(L_cand_norm_ratio, L_max_norm_ratio) >= 0) + { + imax = i; move16(); /* conditional move single basop */ + } + L_max_norm_ratio = L_max(L_max_norm_ratio, L_cand_norm_ratio); /* always update */ + } /* dim */ + } + + /* finally add found unit pulse contribution to past L_xy, L_yy, for next pulse loop */ + *L_xy_ptr = L_mac0(*L_xy_ptr, x_abs[imax], 2); /* Qin*Q0+1 */ + *L_yy_ptr = L_mac0(*L_yy_ptr, 2, y[imax]); /* en = en + 2*y + 1 , 1 was preadded outside */ + + y[imax] = add(y[imax], 1); move16(); /* Q0 added pulse */ + (*pulse_tot_ptr) = add((*pulse_tot_ptr), 1); /* increment total pulse sum */ + + Dyn_Mem_Deluxe_Out(); + return imax; +} +#endif void pvq_enc_search_fx( const Word16 *x, /* i: target vector to quantize Qin */ @@ -367,3 +540,546 @@ void pvq_enc_search_fx( #endif } +#ifdef CR9_C_ADD_1p25MS_LRSNS + +/* 29/30 bits optimized search functions for PVQ and FESS */ +/* stage 2 submode shape 0: "splitLF" (N=5,K=6)(N=8,K=2)(N=2,K=0), or (N=5,K=8)(N=10,K=0) , 4 gains */ +/* stage 2 submode shape 1: "full" FB (N=15,K=5), , 8 gains */ +/* stage 2 submode shape 2-5: "fixed env " (N=13-15,K=10-12), 4xfixed , 8 gains */ + +#define SC 1 /* starting coeff for LRSNS VQ searches, as DC is zero in the DCT-II domain target */ +void pvq_fess_enc_search_fx( + const Word16 *x_in, /* i: target vector to quantize Qin (=Q11) 0...M-1 */ + + Word16 * y_Q0, /* o: raw integer pulses (non-scaled short) Q0 , length 3*M */ + Word16 * y_normQ14, /* o: normalized integer pulses (non-scaled short) Q14 , length 3*M */ + Word32 * L_y_normQ30, /* o: normalized integer pulses (non-scaled short) Q30 , length 3*M */ + Word16 * s_idxPtr, /* o: quantized shape index, 0,1,2 */ + Word16 * g_idxPtr, /* o: quantized gain index, 0..3, or 0..7 */ + Word16 * g_qvalQ12Ptr, /* o: quantized gain value, in Q12 -32767 == 7.99975 for best shape */ + Word16 * fixShapeNbPtr, /* o: idx for the selected fix shape y_fix 0...3, only relevant in the case s_idx==2 */ + Word16 * fixShiftIdxPtr, /* o: idx for the selected fix shift 0...3, only relevant in the case s_idx==2 */ + Word32 * L_MSEQ22Ptr, /* o: 1 Q11+Q0+1 --> Q22 */ + Word8 * scratch +) +{ + + Dyn_Mem_Deluxe_In( + Counter i, k, n; + Word16 pulse_tot; + Word16 max_xabs, max_xabsA, max_xabsB, max_xabsAB, max_xabsC; + Word32 L_xsum, L_xsumA, L_xsumB, L_xsumAB; + Word32 L_yy, L_xy; + + Word16 imax; + Word16 *y_split, *y_full, *y_fix; + Word16 *y_splitAB; + + Word16 *y_splitA0; + Word16 best_env_ind; + Word16 best_shift_ind; + Word32 L_targetEnNeg; + + Word16 shift_ind, fix_ind; + Word16* xabs1; + const Word16* envPtr; + Word32 L_corr; + + + Word16 *y, *y_norm, tmp; + Word32 *L_y_norm; + Word32 L_tmp; + Word32 L_min_mse_opt; + + Word16 gain_idx_opt, shape_idx_opt; + Word16 best_ind; + Word16 gidx; + Word32 L_g_q_tmp; + const Word16 *gTabPtr; + Word32 L_mse; + Word32 L_xy_a6_mem; + Word32 L_MSEQ22_recalc; + Word32 L_normcorrQy; + Word16 norm_factors[N_SCF_SEARCH_SHAPES_ST2_LR]; + Word32 L_norm_factors[N_SCF_SEARCH_SHAPES_ST2_LR]; + + Word32 *L_search_corr; + Word32 *L_search_en; + Word16 *xabs; + Word8* scratch_top_proj; + Word32 *L_corr_fixenv; + Word32 *L_normcorr_fixenv; + Word16 *gain_idx_opt_save; + Word32 *L_min_mse_opt_save; + ); + UNUSED(imax); /* avoid gcc compiler warning */ + UNUSED(tmp); + + L_search_corr = (Word32 *)scratchAlign(scratch, 0); + L_search_en = (Word32 *)scratchAlign(L_search_corr , N_SCF_SEARCH_SHAPES_ST2_LR * sizeof(*L_search_corr)); + xabs = (Word16 *)scratchAlign(L_search_en , N_SCF_SEARCH_SHAPES_ST2_LR * sizeof(*L_search_en)); + scratch_top_proj = (Word8 *)scratchAlign(xabs, PVQ_MAX_VEC_SIZE * sizeof(*xabs) ); + + L_corr_fixenv = (Word32 *)scratch_top_proj ; + L_normcorr_fixenv = (Word32 *)scratchAlign(L_corr_fixenv , SNSLR_N_FIXENV*SNSLR_N_FIXENV_SHIFTS * sizeof(*L_corr_fixenv)); + gain_idx_opt_save = (Word16 *)scratchAlign(L_normcorr_fixenv, SNSLR_N_FIXENV*SNSLR_N_FIXENV_SHIFTS * sizeof(*L_normcorr_fixenv)); + L_min_mse_opt_save = (Word32 *)scratchAlign(gain_idx_opt_save, N_SCF_SEARCH_SHAPES_ST2_LR * sizeof(*gain_idx_opt_save)); + /* scratch_top = (Word8 *)scratchAlign(L_min_mse_opt_save, N_SCF_SEARCH_SHAPES_ST2_LR *sizeof(L_min_mse_opt_save)); */ + +#ifdef WMOPS + push_wmops("pvq_fess_enc_search_fx"); +#endif + + best_env_ind = -1; + best_shift_ind = -1; + gain_idx_opt = 0; + + y_split = &(y_Q0[0]); move32(); + y_full = &(y_Q0[1 * M]); move32(); + y_fix = &(y_Q0[2 * M]); move32(); + + + /* init */ + basop_memset(L_search_corr, 0, N_SCF_SEARCH_SHAPES_ST2_LR * sizeof(Word32)); + basop_memset(L_search_en, 0, N_SCF_SEARCH_SHAPES_ST2_LR * sizeof(Word32)); + + max_xabs = -1; move16(); + max_xabsC = -1; move16(); + + basop_memset(y_split, 0, PVQ_MAX_VEC_SIZE * sizeof(Word16)); + basop_memset(y_full, 0, PVQ_MAX_VEC_SIZE * sizeof(Word16)); + basop_memset(y_fix, 0, PVQ_MAX_VEC_SIZE * sizeof(Word16)); + + y_splitAB = y_split; /* ptr init */ + y_splitA0 = y_fix; /* ptr init */ /* y_fix temporarlily used for splitA0 */ + + xabs[0] = 0; move16(); /* always no DC in LRSNS scheme */ + FOR(i = SC; i < PVQ_MAX_VEC_SIZE; i++) + { + xabs[i] = abs_s(x_in[i]); move16(); /* input Qx */ + } + + /* A section */ + max_xabsA = -1; move16(); + L_xsumA = L_deposit_h(0); + FOR(i = SC; i < SC + NA_LR; i++) + { + max_xabsA = s_max(max_xabsA, xabs[i]); /* max value used for near optimal search correlation scaling */ + L_xsumA = L_mac0(L_xsumA, 1, xabs[i]); /* stay in Qx */ + } + /* B section */ + max_xabsB = -1; move16(); + L_xsumB = L_deposit_h(0); + FOR(i = SC + NA_LR; i < SC + NA_LR + NB_LR; i++) + { + max_xabsB = s_max(max_xabsB, xabs[i]); /* later used for near optimal search correlation scaling */ + L_xsumB = L_mac0(L_xsumB, 1, xabs[i]); /* stay in Qx */ + } + L_xsumAB = L_add(L_xsumA, L_xsumB); + + /* "C" section, 2 coeffs, not coded by split shapes {A,B}, {A,0} , but potentially coded by full and fix shapes */ + max_xabsC = s_max(xabs[PVQ_MAX_VEC_SIZE - 2], xabs[PVQ_MAX_VEC_SIZE - 1]); + L_xsum = L_mac0(L_xsumAB, 1, xabs[PVQ_MAX_VEC_SIZE - 2]); + L_xsum = L_mac0(L_xsum, 1, xabs[PVQ_MAX_VEC_SIZE - 1]); + + /*globalMax abs , for split and full search and projection */ + max_xabsAB = s_max(max_xabsA, max_xabsB); + max_xabs = s_max(max_xabsAB, max_xabsC); /* global max abs value over all M-1 coeffs */ + + L_targetEnNeg = L_deposit_l(0); + FOR(i = SC; i < PVQ_MAX_VEC_SIZE; i++) + { + /*target MSE part for final winning stage 2 MSE shape */ + L_targetEnNeg = L_msu0(L_targetEnNeg, x_in[i], x_in[i]); /* for final MSE output calculation */ + } + + IF(L_xsum == 0) + { /* no shape in any section, projection, A, AB, ABC not possible:: --> search is meaningless */ + y_split[SC] = PULSES_SPLIT_A_LR; move16(); + y_split[SC + NA_LR] = PULSES_SPLIT_B_LR; move16(); + + y_full[SC] = PULSES_FULL_LR; move16(); + + FOR(i = SC; i < SC + NSIGNS_FIX_3; i++) + { + y_fix[i] = 1; move16(); + } + *fixShapeNbPtr = 3; move16(); + + /* L_search_corr[], [0,1,2] all stays zero valued */ + ASSERT(L_search_corr[0] == 0 && L_search_corr[1] == 0 && L_search_corr[2] == 0); + L_search_en[0] = PULSES_SPLIT_A_LR * PULSES_SPLIT_A_LR + PULSES_SPLIT_B_LR * PULSES_SPLIT_B_LR; move32(); + L_search_en[1] = PULSES_FULL_LR * PULSES_FULL_LR; move32(); + L_search_en[2] = NSIGNS_FIX_3; move32(); /* read from table as shape is not all ones */ + } + ELSE + { /* projection, to a valid pyramid or sub-pyramid */ + /* use the most optimistic projection */ +#ifdef FIX_BASOP_ENC_LRSNS_ST2FULL_PROJ + /* always use at least one loop of single pulse optimization */ + pvq_pyr_project_lrsns_adv(SC + NFULL_LR, xabs, L_xsum, (PULSES_FULL_LR - 1), 0, y_full, &pulse_tot, &L_xy, &L_yy, scratch_top_proj); /* 0 --> old floor( 1/( K-1) ) */ +#else + pvq_pyr_project_lrsns_adv(SC + NFULL_LR, xabs, L_xsum, (PULSES_FULL_LR), PULSES_FULL_LR, y_full, &pulse_tot, &L_xy, &L_yy, scratch_top_proj); +#endif + + FOR(k = pulse_tot; k < PULSES_FULL_LR; k++) + { + L_yy = L_add(L_yy, 1); /* pre add 1 in Q0 in L_yyQ0 = (x^2 + 2*x + 1) */ + imax = one_pulse_search_tab_isqrt(SC, PVQ_MAX_VEC_SIZE, xabs, y_full, &pulse_tot, &L_xy, &L_yy, max_xabs); + } + ASSERT(pulse_tot == PULSES_FULL_LR); + + /* full subshape result vector in y_full[0...15] */ + /* L_mac result from splitAB search loop */ + L_search_corr[1] = L_shr_pos(L_xy,1); /* Q11*Q0 */ + L_search_en[1] = L_yy; move32(); /*Q0*/ + + + IF( L_xsumA == 0 ) + { /* no shape in A section, search is meaningless */ + y_split[SC] = PULSES_SPLIT_A_LR; move16(); /*splitAB A-shape set */ + y_split[SC + NA_LR] = PULSES_SPLIT_B_LR; move16(); /*splitAB B-shape set */ + L_search_corr[0] = L_deposit_h(0); + L_search_en[0] = (PULSES_SPLIT_A_LR*PULSES_SPLIT_A_LR + PULSES_SPLIT_B_LR + PULSES_SPLIT_B_LR); move32(); /*Q0*/ + } + ELSE + { /* recalculate A section from the partially available full result ( to remove section B pulses influence in corr^2/en ) */ + pulse_tot = 0; move16(); + L_xy = L_deposit_l(0); + L_yy = L_deposit_l(0); + + basop_memmove(y_splitAB, y_full, (SC + NA_LR) * sizeof(Word16)); /* copy full(15) -> y_splitAB(5+8) (5 first here only) */ + + FOR(i = SC; i < (SC + NA_LR); i++) + { + pulse_tot = add(pulse_tot, y_splitAB[i]); /* Q0 */ + L_xy = L_mac(L_xy, xabs[i], y_splitAB[i]); /* Corr, Q0*Qx +1 --> Qx+1 */ + L_yy = L_mac0(L_yy, y_splitAB[i], y_splitAB[i]); /* Energy, Q(0+0)+1)= Q0 */ + } + + /* search any remaining unit pulses in section A */ + /* (continue up to 6 LF section A pulses) */ + + FOR(k = pulse_tot; k < PULSES_SPLIT_A_LR; k++) + { + L_yy = L_add(L_yy, 1); /* 1 added in Q0 */ + imax = one_pulse_search_tab_isqrt(SC, SC + NA_LR, xabs, y_splitAB, &pulse_tot, &L_xy, &L_yy, max_xabsA); + } + + /* L_mac result from splitAB search loop */ + L_xy_a6_mem = L_xy; move32(); + L_search_corr[0] = L_shr_pos(L_xy,1); /* A-part of AB temporarily saved */ + L_search_en[0] = L_yy; move32(); /* A-part of AB temporarily saved */ + + ASSERT(pulse_tot == PULSES_SPLIT_A_LR); + + basop_memmove(y_splitA0, y_splitAB, (SC + NA_LR) * sizeof(Word16)); /* copy_splitAB(5 first) -> y_splitA (5) */ + + /* search any remaining unit pulses in sectionA for the PVQ(n=5,k=8)+PVQ(n=9,k=0) alternative */ + /* (i.e. add 2 LF pulses, up to 8) */ + + FOR(k = pulse_tot; k < (PULSES_SPLIT_A_LR + PULSES_SPLIT_B_LR); k++) + { + L_yy = L_add(L_yy, 1); /* 1 added in Q0 */ + imax = one_pulse_search_tab_isqrt(SC, SC + NA_LR, xabs, y_splitA0, &pulse_tot, &L_xy, &L_yy, max_xabsA); + } + + + /* note: a local temporary use of the fixed env location "2" for corr and energy memory*/ + L_search_corr[2] = L_xy; move32(); /* A-part of A,0 saved temporarily */ + L_search_en[2] = L_yy; move32(); /* A-part of A,0 saved */ + + /* search B section of splitAB (add 2 HF pulses) */ + L_xy = L_xy_a6_mem; move32(); + L_yy = L_search_en[0]; move32(); + pulse_tot = PULSES_SPLIT_A_LR; move16(); + + IF(L_xsumB != 0) + { + FOR(k = 0; k < PULSES_SPLIT_B_LR; k++) + { + L_yy = L_add(L_yy, 1); /* 1 added in Q0 */ + imax = one_pulse_search_tab_isqrt(SC + NA_LR, SC + NA_LR + NB_LR, xabs, y_splitAB, &pulse_tot, &L_xy, &L_yy, max_xabsB); + } + } + ELSE + { + y_splitAB[SC + NA_LR] = PULSES_SPLIT_B_LR; /* correlation L_xy not increased as x is zero */ + L_yy = L_add(L_yy, PULSES_SPLIT_B_LR * PULSES_SPLIT_B_LR); /* y_splitAB energy increased by 2^2 */ + } + + /* compare the best split shape out of (splitAB), vs (splitA,0) */ + /* if corrAB^2/enAB > corrA^2/enA, then choose AB else A,0 */ + /* energy in L_yy can at most be 64 , and low value is 8 */ + /* however as energy can only take on ~64 values [8 ... 64] */ + /* we use :. if corrAB*sqrt(1/enAB) > corrA* sqrt(1/enA), then choose AB else A,0 */ + { + Word32 L_tmpA0, L_tmpAB; + Word16 tmp_shift; + + /* maximize precision in corr values */ + tmp_shift = s_min(norm_l(L_search_corr[2]), norm_l(L_xy)); + + ASSERT(tmp_shift >= 0); + + ASSERT(L_yy >= 4 && L_search_en[2] > 4 && "isqrt_Q16tab requires energy >=4 "); + L_tmpA0 = Mpy_32_16_0_0(L_shl_pos(L_search_corr[2], tmp_shift), isqrt_Q16tab[L_search_en[2]]); /* nonsaturating Mpy32_16_0_0 used for ARM-SMULWB reuse */ + L_tmpAB = Mpy_32_16_0_0(L_shl_pos(L_xy, tmp_shift), isqrt_Q16tab[L_yy]); + + L_search_corr[0] = L_shr_pos_pos(L_xy, 1); /* assume AB corr as winner */ + L_search_en[0] = L_yy; move32(); /* assume AB energy as winner */ + + IF(L_sub(L_tmpA0, L_tmpAB) > 0) + { + basop_memcpy(y_split, y_splitA0, M * sizeof(Word16)); /* cpy complete LFonly A,0 as the final splitLF output */ + L_search_corr[0] = L_shr_pos_pos(L_search_corr[2], 1); /* set A,0 as winner */ + L_search_en[0] = L_search_en[2]; move32(); /* set A,0 as winner */ + } + } + } /* L_xsumA!=0 */ + } /* L_xsum != 0 */ + + { + /* Fixed envelope signband coding, including sign coding of a shifted block */ + /* subshape idx 2,3,4 , "1"/env 1(s0)+ 2(shift)+ 11bits(s1..s11) + always a 3 bits gain */ + /* subshape idx 5 , "1"/env 1(s0)+ 2(shift)+ 9bits(s1..s9) + always a 3 bits gain */ + /* + 2, init_bell_12signs , [ 8,8,8, 7,7 ... ] + 3, decaying envelope 12 signs, [ 12,12,11,11, ... ] + 4, start_bell_12signs , [ 7,7,8,8,8, 7,... ] + 5, early_bell_10signs, [ 6,6, 7,7,8,8,8,7,... ]*/ + + /* find the minimum shape error across all possible 4 envelopes and all 4 shifts */ + /* maximise normalized cross correlation target*y /sqrt(en(y)) to minimize shape error */ + + basop_memset(y_fix, 0, PVQ_MAX_VEC_SIZE * sizeof(Word16)); /* y_fix buffer was used for y_splitA0 above, reset needed */ + + FOR(fix_ind = 0; fix_ind < SNSLR_N_FIXENV; fix_ind++) + { + FOR(shift_ind = 0; shift_ind < SNSLR_N_FIXENV_SHIFTS; shift_ind++) + { + L_corr = L_deposit_l(0); + envPtr = &(lrsns_fix_env_fx[fix_ind][shift_ind]); /* ptr init to start of the selected Q0 unit pulses */ + xabs1 = &(xabs[SC + shift_ind]); /* ptr init */ + FOR(n = 0; n < lrsns_signs_fix_fx[fix_ind]; n++) + { + ASSERT(envPtr[n] >= 0 && xabs1[n] >= 0); + L_corr = L_mac0(L_corr, xabs1[n], envPtr[n]); /* runtime first octant correlation calc */ + } + + tmp = add(shl_pos(fix_ind, 2), shift_ind); /* fix_ind * 4 + shift_ind */ + L_corr_fixenv[tmp] = L_corr; move32(); + L_corr = L_shl_pos(L_corr, 9); /* always 100% safe to shift up by 9 , tested with input M* 32767*/ + /* energy normalize, for the specific shift and env, + otherwise it is not possible to compare among the fixed shape envelopes */ + L_normcorr_fixenv[tmp] = Mpy_32_16_0_0(L_corr, lrsns_fixenv_enNormQ19[tmp]); + } + } + + /* now actually pick the fixenv[0,1,2,3] and env shift[0,1,2,3] option which maximizes the normcorr + . (also minimizes shape MSE as all fixed envelopes later use the very same 8 level gain quantizer) */ + + Word32 *pL = &(L_normcorr_fixenv[0]); /* ptr init */ + + best_ind = 0; move16(); + FOR(n = 1; n < (SNSLR_N_FIXENV * SNSLR_N_FIXENV_SHIFTS); n++) + { + if (L_sub(pL[n], pL[best_ind]) > 0) + { + best_ind = n; move16(); /* conditional move single BASOP */ + } + } + + /* decompose index */ + best_env_ind = shr_pos_pos(best_ind, 2); + best_shift_ind = sub(best_ind, i_mult(best_env_ind, 4)); + + ASSERT(best_env_ind >= 0 && best_env_ind < SNSLR_N_FIXENV); + ASSERT(best_shift_ind >= 0 && best_shift_ind < SNSLR_N_FIXENV_SHIFTS); + + + *fixShapeNbPtr = best_env_ind; move16(); + *fixShiftIdxPtr = best_shift_ind; move16(); + + basop_memcpy(&(y_fix[add(SC, best_shift_ind)]), &(lrsns_fix_env_fx[best_env_ind][best_shift_ind]), lrsns_signs_fix_fx[best_env_ind] * sizeof(Word16)); /* cpy complete fixed envelope to output */ + + tmp = add(shl_pos(best_env_ind, 2), best_shift_ind); + L_search_corr[2] = L_corr_fixenv[tmp]; move32(); /* L_mac0 result from fixenv normcorr search loop*/ + L_search_en[2] = L_deposit_l(lrsns_fixenv_enQ0[tmp]); /* tabled energy */ + } + + /* sign application for all three shape options */ + /* apply sign of (x_in) to first orthant result in Q0 */ + + FOR(i = SC; i < (SC + NA_LR + NB_LR); i++) + { + if (x_in[i] < 0) + { + y_split[i] = negate(y_split[i]); move16(); /* apply sign for split (AB or A0) */ + } + } + + FOR(i = SC; i < (SC + NFULL_LR); i++) + { + if (x_in[i] < 0) + { + y_full[i] = negate(y_full[i]); move16(); /* apply sign for full */ + } + } + + FOR(i = SC; i < (SC + NFULL_LR); i++) + { + if (x_in[i] < 0) + { + y_fix[i] = negate(y_fix[i]); move16(); /* apply sign for fixed env */ + } + } + + /* prepare Q14 normalized values and run the gain quantization with all remaining 3 shape options */ + /* and prepare Q30 normalized values for HR mode */ + { + + /* calculate each normalized envelope y_Q0[0...M-1]/sqrt(en) and provide result in Q14 */ + + /* make sure Word16 inv_sqrt table lookup is ok */ + ASSERT(L_search_en[0] <= SQRT_EN_MAX_FX && L_search_en[1] <= SQRT_EN_MAX_FX); + ASSERT(L_search_en[0] > 4 && L_search_en[1] > 4); /* inv_sqrt table only valid from energy value 5 */ + + + norm_factors[0] = isqrt_Q16tab[L_search_en[0]]; move16(); move16(); /* Q16 */ + norm_factors[1] = isqrt_Q16tab[L_search_en[1]]; move16(); move16(); /* Q16 */ + tmp = add(shl_pos(best_env_ind, 2), best_shift_ind); + norm_factors[2] = lrsns_fixenv_enNormQ19[tmp]; move16(); /* Q19 */ + + L_norm_factors[0] = isqrt_Q31tab[L_search_en[0]]; move32(); move32(); /* Q31 */ + L_norm_factors[1] = isqrt_Q31tab[L_search_en[1]]; move32(); move32(); /* Q31 */ + L_norm_factors[2] = L_lrsns_fixenv_enNormQ35[tmp]; move32(); + + FOR(n = 0; n < (N_SCF_SEARCH_SHAPES_ST2_LR); n++) + { + /* PVQ and FESS unit energy normalization */ + /* some precomputed norm factor and pre-known normalization shift */ + y = &(y_Q0[n*M]); /* ptr init */ + L_y_norm = &(L_y_normQ30[n*M]); /* ptr init */ + y_norm = &(y_normQ14[n*M]); /* ptr init to signed seq Q14 */ + + ASSERT(y[0] == 0); + pvq_fess_dec_en1_normQ30andQ14_fx( + y /*Q0*/, + lrsns_y_up_bits[n], + L_norm_factors[n], + lrsns_norm_factorQ_L[n], + M, /*M==16 always used to enable simple unroll into 4 */ + L_y_norm, /* for MSEQ22 estimation, and for ENABLE_HR */ + y_norm); /* for gain Q*/ + ASSERT(L_y_norm[0] == 0 && y_norm[0] == 0); + + L_y_norm[0] = 0; move32(); /* DC is always zero in LRSNS stage2 */ + y_norm[0] = 0; move16(); + + + /* establish normalized correlation to target */ + + Word32 L_normcorr_pre_fx = Mpy_32_16_lc3plus(L_search_corr[n], norm_factors[n]); + /* no need to recalc correlation, simply scale with factor */ + /*here Mpy_32_16 shifts left by 1 and maintains maximum precision */ + /*For ARM the somewhat better/native 32_16_0_0() without saturation, however not used here */ + + Word16 g_shiftright_opt[3] = { 0 , 0 , 3 }; /* down_shift(right) to get result as "g_opt*2" in Q11 */ + Word32 L_normcorrX2_opt_fx = L_shr_pos_pos(L_normcorr_pre_fx, g_shiftright_opt[n]); /* -2*g_opt for MSE calc , in Q11 */ + + /* MSE= t_2 + g^2*1.0 -(2*g_opt)*g , with g_opt = corr(t_2,x_n) */ + + gTabPtr = (const Word16 *)lrsns_vq_gainsQ12_fx[n]; move32(); /* q gains in Q12, n-adaptive ptr init */ + L_mse = L_deposit_l(0); + L_min_mse_opt = L_add(MAX_32, 0); /* min_MSE w/o target energy gain loop */ + + FOR(gidx = 0; gidx < lrsns_vq_gain_lvls_fx[n]; gidx++) + { + /* adding at the same Q required, we use Q22 in search loop for now */ + /* g_q*(g_q - 2*g_opt)/ */ + /* (-2*g_opt)*g_q + g_q*g_q = g_q*(g_q-2*g_opt) , Q11*Q11->Q22 */ + + L_g_q_tmp = L_shr_pos(L_deposit_h(gTabPtr[gidx]), 2); /* from Q12 to 12+16-2-> Q26 */ + L_tmp = L_shl_pos(L_normcorrX2_opt_fx, 15); /*11+15 -> 26 */ + ASSERT(L_normcorrX2_opt_fx <= 32767 && "L_normcorrX2_opt_fx <= 32767 "); /* should fit in Word16 */ + + L_tmp = L_sub(L_g_q_tmp, L_tmp); /* Q26-Q26 --> Q26 */ + + L_mse = Mpy_32_16_0_0(L_tmp, gTabPtr[gidx]); /* Q26+Q12 - 16 => 22 */ + + L_min_mse_opt = L_min(L_min_mse_opt, L_mse); + if (L_sub(L_mse, L_min_mse_opt) == 0) + { + gain_idx_opt = gidx; move16(); /* single BASOP, conditional move */ + } + } + gain_idx_opt_save[n] = gain_idx_opt; move16(); + L_min_mse_opt_save[n] = L_min_mse_opt; move32(); + + } /* shape n */ + + /* get the best min(MSE) among the 3 shapes */ + shape_idx_opt = 0; move16(); + L_min_mse_opt = L_min_mse_opt_save[shape_idx_opt]; move32(); + FOR(n = 1; n < (N_SCF_SEARCH_SHAPES_ST2_LR); n++) + { + L_min_mse_opt = L_min(L_min_mse_opt_save[n], L_min_mse_opt); + if (L_sub(L_min_mse_opt, L_min_mse_opt_save[n]) == 0) + { + shape_idx_opt = n; move16(); /* single basop */ + } + } + /* provide function output */ + *s_idxPtr = shape_idx_opt; move16(); + *g_idxPtr = gain_idx_opt_save[*s_idxPtr]; move16(); + *L_MSEQ22Ptr = L_sub(L_min_mse_opt, L_targetEnNeg); /* search based MSE, add target energy to gain part of MSE (sum t*2) */ + *g_qvalQ12Ptr = lrsns_vq_gainsQ12_fx[*s_idxPtr][*g_idxPtr]; + + ASSERT(L_min_mse_opt == L_min_mse_opt_save[*s_idxPtr]); + + + + /** Recalculate winning stage2 MSE with high precision **/ + L_MSEQ22_recalc = 0; + L_normcorrQy = 0; /* INT32_MIN; */ + + /* shift up input signal to the max with a margin of 4 bits. */ + Word16 x_in_upshift = norm_s(max_xabs); + + /* accumulate 15 values, would typically require ~4 bits margin , however we know only 12 can have a non-zero value */ + x_in_upshift = s_max(sub(x_in_upshift, 4), 0); + + FOR(i = 1; i < M; i++) + { + L_tmp = Mpy_32_16_0_0(L_y_normQ30[*s_idxPtr*M + i], shl_pos(x_in[i], x_in_upshift)); /* signed*signed */ + L_normcorrQy = L_add(L_normcorrQy, L_tmp); + } + L_normcorrQy = L_shr_pos(L_normcorrQy, x_in_upshift); /* back to Q25 */ + + + /* x_in^2 + gq^2*1 - 2*gq*gopt */ + L_MSEQ22_recalc = L_negate(L_targetEnNeg); + L_tmp = L_shr_pos(L_mult0(*g_qvalQ12Ptr, *g_qvalQ12Ptr), 2); + L_MSEQ22_recalc = L_add(L_MSEQ22_recalc, L_tmp); + L_tmp = L_shl_pos(Mpy_32_16_0_0(L_normcorrQy, *g_qvalQ12Ptr), (26 + 1) - 25); /* Qy+12-16+lshift = 22, --> lshift = 26-Qy , 2.0 factor -> add 1 leftshift*/ + + L_MSEQ22_recalc = L_sub(L_MSEQ22_recalc, L_tmp); + + *L_MSEQ22Ptr = L_max(L_MSEQ22_recalc, 0L); move32(); /*use high precision result recalculated MSE for winner */ + + + + ASSERT(*L_MSEQ22Ptr >= 0 && " warning negative total MSE "); + + + } /* shape norm and gain calc , and shape decision */ + +#ifdef WMOPS + pop_wmops(); +#endif + + Dyn_Mem_Deluxe_Out(); +} +#endif + diff --git a/lib_lc3plus/pvq_index_fx.c b/lib_lc3plus/pvq_index_fx.c index 948d85233..5d216df5e 100644 --- a/lib_lc3plus/pvq_index_fx.c +++ b/lib_lc3plus/pvq_index_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" #define SIGNBIT_FX 0x80000000u diff --git a/lib_lc3plus/quantize_spec_fx.c b/lib_lc3plus/quantize_spec_fx.c index 3b080db08..147000186 100644 --- a/lib_lc3plus/quantize_spec_fx.c +++ b/lib_lc3plus/quantize_spec_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" #ifdef ENABLE_HR_MODE @@ -107,22 +109,22 @@ void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word32 gain, Word16 gain_e, #else FOR (i = 0; i < nt; i++) { - offs32 = Mpy_32_32_lc3plus(L_abs(x[i]), gain); /* multiply */ - offs32 = L_shl(offs32, s); /* convert to 15Q16 */ - tmp16 = mac_r(offs32, -4096, 1); /* add offset and truncate */ - if (x[i] < 0) - tmp16 = negate(tmp16); /* restore sign */ + offs32 = Mpy_32_32_lc3plus(L_abs(x[i]), gain); /* multiply */ + offs32 = L_shl( offs32, s ); /* convert to 15Q16 */ + tmp16 = mac_r(offs32, -4096, 1); /* add offset and truncate */ + if (x[i] < 0) + tmp16 = negate(tmp16); /* restore sign */ - /* Normal quantization: xq[i] = x[i] / gg + sign(x[i]) * 0.375 - quant_offset is -0.125 in Q15 and round adds 0.5 in Q16. Hence - mac_r results in abs(x[i])/gain - 0.125 + 0.5 = abs(x[i])/gain + 0.375. - Due to the abs and negate combination this achieves the same result - as spec. - */ + /* Normal quantization: xq[i] = x[i] / gg + sign(x[i]) * 0.375 + quant_offset is -0.125 in Q15 and round adds 0.5 in Q16. Hence + mac_r results in abs(x[i])/gain - 0.125 + 0.5 = abs(x[i])/gain + 0.375. + Due to the abs and negate combination this achieves the same result + as spec. + */ - xq[i] = tmp16; - move16(); + xq[i] = tmp16; + move16(); } #endif /* FUNCTION_quantizeSpec_func1 */ } @@ -131,7 +133,7 @@ void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word32 gain, Word16 gain_e, move16(); if (fs_idx != 5) { - if (sub(totalBits, add(160, DEPR_i_mult(fs_idx, 160))) > 0) + if (sub(totalBits, add(160, i_mult(fs_idx, 160))) > 0) { rateFlag = 2 << NBITS_CONTEXT; move16(); @@ -157,7 +159,7 @@ void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word32 gain, Word16 gain_e, if (fs_idx != 5) { - IF (mode == 0 && sub(totalBits, add(480, DEPR_i_mult(fs_idx, 160))) >= 0) + IF (mode == 0 && sub(totalBits, add(480, i_mult(fs_idx, 160))) >= 0) { mode = 1; move16(); @@ -667,7 +669,7 @@ void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word16 gain, Word16 gain_e, #endif /* Quantization */ - gain = Inv16_lc3plus(gain, &gain_e); + gain = Inv16(gain, &gain_e); s = sub(add(x_e, gain_e), 15); s = s_max(s_min(s, 15), -15); @@ -688,7 +690,7 @@ void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word16 gain, Word16 gain_e, /* Rate flag */ rateFlag = 0; move16(); - if (sub(totalBits, add(160, DEPR_i_mult(fs_idx, 160))) > 0) + if (sub(totalBits, add(160, i_mult(fs_idx, 160))) > 0) { rateFlag = 2 << NBITS_CONTEXT; move16(); @@ -710,7 +712,7 @@ void processQuantizeSpec_fx(Word32 x[], Word16 x_e, Word16 gain, Word16 gain_e, move32(); nbits_lsb = 0; move16(); - IF (mode == 0 && sub(totalBits, add(480, DEPR_i_mult(fs_idx, 160))) >= 0) + IF (mode == 0 && sub(totalBits, add(480, i_mult(fs_idx, 160))) >= 0) { mode = 1; move16(); diff --git a/lib_lc3plus/reorder_bitstream_fx.c b/lib_lc3plus/reorder_bitstream_fx.c index 949fdc8f8..657abffc1 100644 --- a/lib_lc3plus/reorder_bitstream_fx.c +++ b/lib_lc3plus/reorder_bitstream_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "defines.h" #include "constants.h" diff --git a/lib_lc3plus/resamp12k8_fx.c b/lib_lc3plus/resamp12k8_fx.c index d59f11ec1..ebfa42502 100644 --- a/lib_lc3plus/resamp12k8_fx.c +++ b/lib_lc3plus/resamp12k8_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,11 +7,13 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void process_resamp12k8_fx(Word16 x[], Word16 x_len, Word16 mem_in[], Word16 mem_in_len, Word32 mem_50[], Word16 mem_out[], Word16 mem_out_len, Word16 y[], Word16 *y_len, Word16 fs_idx, - Word16 frame_dms, Word8 *scratchBuffer + LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer , Word16 bps ) { @@ -28,7 +30,8 @@ void process_resamp12k8_fx(Word16 x[], Word16 x_len, Word16 mem_in[], Word16 mem ); buf = (Word16 *)scratchAlign(scratchBuffer, 0); /* Size = 2 * (MAX_LEN + MAX_LEN / 8) bytes */ - + len_12k8 = 0; + /* resamp parameters : {upsample-factor, 120 / upsample-factor, down_sample_int_part, down_sample_frac_part } upsample is to 384 kHz. upsample-facor = 192000 / samp-freq Fractional downsample parameters are calculated from : downsample samp-freq to 128000 @@ -44,8 +47,19 @@ void process_resamp12k8_fx(Word16 x[], Word16 x_len, Word16 mem_in[], Word16 mem resamp_off_int = resamp_params[fs_idx][2]; move16(); resamp_off_frac = resamp_params[fs_idx][3]; move16(); resamp_filt = resamp_filts[fs_idx]; move16(); - - len_12k8 = LEN_12K8 / 4 * (frame_dms / 25); move16(); + + SWITCH (frame_dms) + { +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: len_12k8 = 16; BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: len_12k8 = 32; BREAK; + case LC3PLUS_FRAME_DURATION_5MS: len_12k8 = 64; BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: len_12k8 = 96; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: len_12k8 = 128; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); + } + *y_len = len_12k8; move16(); /* Init Input Buffer */ diff --git a/lib_lc3plus/residual_coding_fx.c b/lib_lc3plus/residual_coding_fx.c index 2787f06c4..bec0636b7 100644 --- a/lib_lc3plus/residual_coding_fx.c +++ b/lib_lc3plus/residual_coding_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" #ifdef ENABLE_HR_MODE @@ -16,13 +18,18 @@ void processResidualCoding_fx(Word16 x_e, Word32 x[], Word16 gain_e, Word16 L_spec, Word16 targetBits, Word16 nBits, UWord8 *resBits, Word16 *numResBits , Word16 hrmode +#if defined (CR9_C_ADD_1p25MS) + , LC3PLUS_FrameDuration frame_dms +#endif ) { Counter i; Word16 s, n, m; Word32 L_tmp; +#if defined (CR9_C_ADD_1p25MS) || defined (ENABLE_HR_MODE) Word16 iter = 0; +#endif Counter idx; Word16 N_nz = 0; Word16 n1, n2; @@ -143,6 +150,18 @@ void processResidualCoding_fx(Word16 x_e, Word32 x[], s = add(s, 16); gain = round_fx(gain); +#if defined (CR9_C_ADD_1p25MS) + Word16 iter_exit, exit_iter = 0; + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + iter_exit = 3; move16(); + } ELSE { + iter_exit = 1; move16(); + } + + FOR (iter = 0; iter < iter_exit; iter++) + { +#endif FOR (i = 0; i < L_spec; i++) { IF (xq[i] != 0) @@ -158,10 +177,20 @@ void processResidualCoding_fx(Word16 x_e, Word32 x[], n = add(n, 1); IF (sub(n, m) == 0) { +#if defined (CR9_C_ADD_1p25MS) + exit_iter = 1; +#endif BREAK; } } } +#if defined (CR9_C_ADD_1p25MS) + IF (exit_iter) + { + BREAK; + } + } +#endif } *numResBits = n; move16(); @@ -177,6 +206,9 @@ void processResidualCoding_fx(Word16 x_e, Word32 x[], Word16 xq[], Word16 gain, Word16 gain_e, Word16 L_spec, Word16 targetBits, Word16 nBits, UWord8 *resBits, Word16 *numResBits +#if defined (CR9_C_ADD_1p25MS) + , LC3PLUS_FrameDuration frame_dms +#endif ) { @@ -204,6 +236,18 @@ void processResidualCoding_fx(Word16 x_e, Word32 x[], s = sub(add(15, gain_e), x_e); { +#if defined (CR9_C_ADD_1p25MS) + Word16 iter_exit, exit_iter = 0, iter = 0; + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + iter_exit = 3; move16(); + } ELSE { + iter_exit = 1; move16(); + } + + FOR (iter = 0; iter < iter_exit; iter++) + { +#endif FOR (i = 0; i < L_spec; i++) { IF (xq[i] != 0) @@ -222,10 +266,20 @@ void processResidualCoding_fx(Word16 x_e, Word32 x[], n = add(n, 1); IF (sub(n, m) == 0) { +#if defined (CR9_C_ADD_1p25MS) + exit_iter = 1; +#endif BREAK; } } } +#if defined (CR9_C_ADD_1p25MS) + IF (exit_iter) + { + BREAK; + } + } +#endif } *numResBits = n; move16(); diff --git a/lib_lc3plus/residual_decoding_fx.c b/lib_lc3plus/residual_decoding_fx.c index 243f7baba..158c5f454 100644 --- a/lib_lc3plus/residual_decoding_fx.c +++ b/lib_lc3plus/residual_decoding_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" #ifdef ENABLE_HR_MODE /* HRMODE enables packing of residual bits */ @@ -15,6 +17,9 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr #ifdef ENABLE_HR_MODE , Word16 hrmode #endif +#ifdef CR9_C_ADD_1p25MS + , LC3PLUS_FrameDuration frame_dms +#endif ) { @@ -24,7 +29,11 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr Word32 tmp; Counter idx; Word16 N_nz = 0; - Word16 iter; +#if defined (CR9_C_ADD_1p25MS) || defined (ENABLE_HR_MODE) + Word16 iter = 0; move16(); + Word16 maxIter = 1; move16(); + UNUSED(maxIter); +#endif Word32 fac_hr; #ifdef DYNMEM_COUNT @@ -52,6 +61,13 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr { fac_m = L_shr(0xC000000, s); /* 0.1875 in 1Q30 */ fac_p = L_shr(0x14000000, s); /* 0.3125 in 1Q30 */ + +#if defined (CR9_C_ADD_1p25MS) + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + maxIter = 3; + } +#endif } bits = 0; @@ -100,6 +116,10 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr } } ELSE + { + #if defined (CR9_C_ADD_1p25MS) + WHILE (iter < maxIter) + #endif { FOR (i = 0; i < L_spec; i++) { @@ -129,6 +149,12 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr bits = add(bits, 1); } } + #if defined (CR9_C_ADD_1p25MS) + iter++; + fac_p = L_shr(fac_p, 1); + fac_m = L_shr(fac_m, 1); + #endif + } } #ifdef DYNMEM_COUNT @@ -139,6 +165,9 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr #else void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 prm[], Word16 resQBits +#ifdef CR9_C_ADD_1p25MS + , LC3PLUS_FrameDuration frame_dms +#endif ) { @@ -156,6 +185,12 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr })); #endif +#if defined (CR9_C_ADD_1p25MS) + Word16 iter = 0; move16(); + Word16 maxIter = 1; move16(); + UNUSED(maxIter); +#endif + tmp = 0; s = sub(x_e, 1); s = s_min(s, 31); @@ -164,10 +199,20 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr fac_m = L_shr(0xC000000, s); /* 0.1875 in 1Q30 */ fac_p = L_shr(0x14000000, s); /* 0.3125 in 1Q30 */ } + +#if defined (CR9_C_ADD_1p25MS) + IF (sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + maxIter = 3; + } +#endif bits = 0; move16(); - + + #if defined (CR9_C_ADD_1p25MS) + WHILE (iter < maxIter) + #endif { FOR (i = 0; i < L_spec; i++) { @@ -197,6 +242,11 @@ void processResidualDecoding_fx(Word32 x[], Word16 x_e, Word16 L_spec, UWord8 pr bits = add(bits, 1); } } + #if defined (CR9_C_ADD_1p25MS) + iter++; + fac_p = L_shr(fac_p, 1); + fac_m = L_shr(fac_m, 1); + #endif } #ifdef DYNMEM_COUNT diff --git a/lib_lc3plus/rom_basop_util_lc3plus.c b/lib_lc3plus/rom_basop_util_lc3plus.c old mode 100755 new mode 100644 index 6e53895e1..f47c818f6 --- a/lib_lc3plus/rom_basop_util_lc3plus.c +++ b/lib_lc3plus/rom_basop_util_lc3plus.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "rom_basop_util_lc3plus.h" #include "basop_util_lc3plus.h" #include "functions.h" @@ -29,7 +31,7 @@ /** * \brief Lookup-Table for binary logarithm */ -RAM_ALIGN const Word16 ldCoeff_lc3plus[7] = {-32768, -16384, -10923, -8192, -6554, -5461, -4681}; +RAM_ALIGN const Word16 ldCoeff[7] = {-32768, -16384, -10923, -8192, -6554, -5461, -4681}; /** \brief Lookup-Table for binary power algorithm @@ -37,7 +39,7 @@ RAM_ALIGN const Word16 ldCoeff_lc3plus[7] = {-32768, -16384, -10923, -8192, -655 This table is used for lookup 2^x with x in range [0...1.0[ in steps of 1/32 */ -const UWord32 exp2_tab_long_lc3plus[32] = { +const UWord32 exp2_tab_long[32] = { 0x40000000, 0x4166C34C, 0x42D561B4, 0x444C0740, 0x45CAE0F2, 0x47521CC6, 0x48E1E9BA, 0x4A7A77D4, 0x4C1BF829, 0x4DC69CDD, 0x4F7A9930, 0x51382182, 0x52FF6B55, 0x54D0AD5A, 0x56AC1F75, 0x5891FAC1, 0x5A82799A, 0x5C7DD7A4, 0x5E8451D0, 0x60962665, 0x62B39509, 0x64DCDEC3, 0x6712460B, 0x69540EC9, @@ -50,7 +52,7 @@ const UWord32 exp2_tab_long_lc3plus[32] = { This table is used for lookup 2^x with x in range [0...1/32[ in steps of 1/1024 */ -const UWord32 exp2w_tab_long_lc3plus[32] = { +const UWord32 exp2w_tab_long[32] = { 0x40000000, 0x400B1818, 0x4016321B, 0x40214E0C, 0x402C6BE9, 0x40378BB4, 0x4042AD6D, 0x404DD113, 0x4058F6A8, 0x40641E2B, 0x406F479E, 0x407A7300, 0x4085A051, 0x4090CF92, 0x409C00C4, 0x40A733E6, 0x40B268FA, 0x40BD9FFF, 0x40C8D8F5, 0x40D413DD, 0x40DF50B8, 0x40EA8F86, 0x40F5D046, 0x410112FA, @@ -63,7 +65,7 @@ const UWord32 exp2w_tab_long_lc3plus[32] = { This table is used for lookup 2^x with x in range [0...1/1024[ in steps of 1/32768 */ -const UWord32 exp2x_tab_long_lc3plus[32] = { +const UWord32 exp2x_tab_long[32] = { 0x40000000, 0x400058B9, 0x4000B173, 0x40010A2D, 0x400162E8, 0x4001BBA3, 0x4002145F, 0x40026D1B, 0x4002C5D8, 0x40031E95, 0x40037752, 0x4003D011, 0x400428CF, 0x4004818E, 0x4004DA4E, 0x4005330E, 0x40058BCE, 0x4005E48F, 0x40063D51, 0x40069613, 0x4006EED5, 0x40074798, 0x4007A05B, 0x4007F91F, @@ -71,7 +73,7 @@ const UWord32 exp2x_tab_long_lc3plus[32] = { }; /* square root tables */ -const Word32 SqrtTable_lc3plus[32] = { +const Word32 SqrtTable[32] = { /* Q31 */ 0x5A82D429, 0x5BEA10FE, 0x5D4BE6E5, 0x5EA89270, 0x60004BE2, 0x615347A1, 0x62A1B68C, 0x63EBC651, 0x6531A1B5, 0x667370D4, 0x67B1595F, 0x68EB7EC8, 0x6A220277, 0x6B5503F0, 0x6C84A0F9, 0x6DB0F5BD, @@ -79,14 +81,14 @@ const Word32 SqrtTable_lc3plus[32] = { 0x77BBCF60, 0x78CC4545, 0x79DA5A00, 0x7AE61D3E, 0x7BEF9E07, 0x7CF6EAC2, 0x7DFC113F, 0x7EFF1EC0, }; -const Word16 SqrtDiffTable_lc3plus[32] = { +const Word16 SqrtDiffTable[32] = { /* Q21 */ 0x59CF, 0x5875, 0x572B, 0x55EE, 0x54BF, 0x539C, 0x5284, 0x5177, 0x5074, 0x4F7A, 0x4E89, 0x4DA1, 0x4CC0, 0x4BE7, 0x4B15, 0x4A4A, 0x4985, 0x48C6, 0x480C, 0x4758, 0x46AA, 0x4600, 0x455B, 0x44BA, 0x441D, 0x4385, 0x42F1, 0x4260, 0x41D3, 0x414A, 0x40C3, 0x4040, }; -const Word32 ISqrtTable_lc3plus[32] = { +const Word32 ISqrtTable[32] = { /* Q31 */ 0x7FFE7F85, 0x7E0A4E25, 0x7C2C56C7, 0x7A63002C, 0x78ACD922, 0x7708939D, 0x75750088, 0x73F10C2D, 0x727BBB1A, 0x71142774, 0x6FB97EA5, 0x6E6AFF54, 0x6D27F79D, 0x6BEFC388, 0x6AC1CBA4, 0x699D83DA, @@ -94,7 +96,7 @@ const Word32 ISqrtTable_lc3plus[32] = { 0x60C1E8C8, 0x5FE7AE45, 0x5F131EBE, 0x5E43FC76, 0x5D7A0D4F, 0x5CB51A81, 0x5BF4F061, 0x5B395E26, }; -const Word16 ISqrtDiffTable_lc3plus[32] = { +const Word16 ISqrtDiffTable[32] = { /* Q21 */ 0x7D0C, 0x777E, 0x7256, 0x6D8A, 0x6911, 0x64E5, 0x60FD, 0x5D54, 0x59E5, 0x56AA, 0x53A0, 0x50C2, 0x4E0D, 0x4B7E, 0x4912, 0x46C6, 0x4499, 0x4288, 0x4090, 0x3EB1, 0x3CE9, 0x3B36, @@ -102,7 +104,7 @@ const Word16 ISqrtDiffTable_lc3plus[32] = { }; /* 1/x tables */ -const Word32 InvTable_lc3plus[32] = { +const Word32 InvTable[32] = { /* Q31 */ 0x7FFBFE40, 0x7C1B608E, 0x78752176, 0x750440BA, 0x71C44C49, 0x6EB14D0A, 0x6BC7B6B4, 0x69045A19, 0x6664598A, 0x63E51EE2, 0x61845308, 0x5F3FD698, 0x5D15BB8E, 0x5B043FD0, 0x5909C861, 0x5724DD3C, @@ -126,7 +128,7 @@ const Word16 InvIntTable[32] = { }; #endif -const Word16 InvDiffTable_lc3plus[32] = { +const Word16 InvDiffTable[32] = { /* Q20 */ 0x7C14, 0x74C8, 0x6E1C, 0x67FF, 0x6260, 0x5D33, 0x586C, 0x5400, 0x4FE7, 0x4C19, 0x4890, 0x4543, 0x422F, 0x3F4F, 0x3C9D, 0x3A17, 0x37B8, 0x357E, 0x3365, 0x316B, 0x2F8D, 0x2DCB, @@ -659,6 +661,20 @@ const PWord16 SineWindow20[10] = { WTCP(0x6fadf2fb, 0x3e8b240e), WTCP(0x6a6d98a3, 0x471cece6), WTCP(0x648543e3, 0x4f3e7874), WTCP(0x5dfe47ad, 0x56e2f15d), }; + +#if (defined CR9_C_ADD_1p25MS) +#ifdef ENABLE_HR_MODE +const PWord32 SineWindow30[] = { +#else +const PWord16 SineWindow30[] = { +#endif + WTCP(0x7ff4c56f, 0x0359c428), WTCP(0x7f9afcb9, 0x0a0af299), WTCP(0x7ee7aa4c, 0x10b5150f), WTCP(0x7ddb4bfc, 0x17537e63), + WTCP(0x7c769e18, 0x1de189a6), WTCP(0x7aba9ae6, 0x245a9d65), WTCP(0x78a879f4, 0x2aba2ee4), WTCP(0x7641af3d, 0x30fbc54d), + WTCP(0x7387ea23, 0x371afcd5), WTCP(0x707d1443, 0x3d1389cb), WTCP(0x6d23501b, 0x42e13ba4), WTCP(0x697cf78a, 0x487fffe4), + WTCP(0x658c9a2d, 0x4debe4fe), WTCP(0x6154fb91, 0x53211d18), WTCP(0x5cd91140, 0x581c00b3), WTCP(0x5cd91140, 0x581c00b3), + +}; +#endif #ifdef ENABLE_HR_MODE const PWord32 SineWindow40[20] = { @@ -1360,13 +1376,14 @@ const PWord32 SineWindow960[480] = { }; #endif -// fs 48 32 24 16 8 -// ms +-------------------- -// 10.0 | 480 320 240 160 80 -// 7.5 | 360 240 180 120 60 -// 5.0 | 240 160 120 80 40 -// 2.5 | 120 80 60 40 20 - +/* + fs 48 32 24 16 8 + ms +-------------------- + 10.0 | 480 320 240 160 80 + 7.5 | 360 240 180 120 60 + 5.0 | 240 160 120 80 40 + 2.5 | 120 80 60 40 20 +*/ void BASOP_getTables( #ifdef ENABLE_HR_MODE const PWord32 **twiddle, const PWord32 **sin, @@ -1385,6 +1402,17 @@ void BASOP_getTables( *twiddle = SineWindow20; move16(); BREAK; +#ifdef CR9_C_ADD_1p25MS + /* 24 kHz 1.25 ms */ + case 30: + *sin = SineTable360; + move16(); + *sin_step = 24; + move16(); + *twiddle = SineWindow30; + move16(); + BREAK; +#endif case 40: *sin = SineTable320; move16(); @@ -2782,7 +2810,7 @@ const Word16 RotVector_32_12[2 * (384 - 32)] = { Implicit exponent is 1 - Example: 0x5A82799A = Isqrt(0x40000000), exponent=1 + Example: 0x5A82799A = Isqrt_lc3plus(0x40000000), exponent=1 */ const Word32 isqrt_table[128 + 2] = { 0x5A827999, 0x5A287E03, 0x59CF8CBC, 0x5977A0AC, 0x5920B4DF, 0x58CAC480, 0x5875CADE, 0x5821C364, 0x57CEA99D, diff --git a/lib_lc3plus/rom_basop_util_lc3plus.h b/lib_lc3plus/rom_basop_util_lc3plus.h index b75637bc5..bde04fad3 100644 --- a/lib_lc3plus/rom_basop_util_lc3plus.h +++ b/lib_lc3plus/rom_basop_util_lc3plus.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,9 +7,11 @@ * estoppel or otherwise. * ******************************************************************************/ -#ifndef __ROM_BASOP_UTIL_LC3PLUS_H__ -#define __ROM_BASOP_UTIL_LC3PLUS_H__ +#ifndef __BASOP_UTIL_ROM_LC3PLUS_H__ +#define __BASOP_UTIL_ROM_LC3PLUS_H__ +#include "options.h" +#include "wmc_auto.h" #include "basop_util_lc3plus.h" #include "functions.h" @@ -33,22 +35,22 @@ /** * \brief Lookup-Table for binary logarithm */ -extern const Word16 ldCoeff_lc3plus[7]; +extern const Word16 ldCoeff[7]; /** \brief Lookup-Table for binary power algorithm */ -extern const UWord32 exp2_tab_long_lc3plus[32]; +extern const UWord32 exp2_tab_long[32]; /** \brief Lookup-Table for binary power algorithm */ -extern const UWord32 exp2w_tab_long_lc3plus[32]; +extern const UWord32 exp2w_tab_long[32]; /** \brief Lookup-Table for binary power algorithm */ -extern const UWord32 exp2x_tab_long_lc3plus[32]; +extern const UWord32 exp2x_tab_long[32]; /** * \brief 1/x, x=[0,1,2,3...] table @@ -167,4 +169,4 @@ extern const UWord16 rs16_elp_deg3_table[256]; extern const Word32 invSqrtTab[(128 + 2)]; #endif -#endif +#endif /* __BASOP_UTIL_ROM_LC3PLUS_H__ */ diff --git a/lib_lc3plus/scale_signal24_fx.c b/lib_lc3plus/scale_signal24_fx.c index e22b7c3f2..1cabd2bbf 100644 --- a/lib_lc3plus/scale_signal24_fx.c +++ b/lib_lc3plus/scale_signal24_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void scale_signal24_fx(Word32 x[], /* i: time input signal */ diff --git a/lib_lc3plus/setup_com_lc3plus.c b/lib_lc3plus/setup_com_lc3plus.c new file mode 100644 index 000000000..ce8a9ac66 --- /dev/null +++ b/lib_lc3plus/setup_com_lc3plus.c @@ -0,0 +1,39 @@ +/****************************************************************************** +* ETSI TS 103 634 V1.6.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + +#include "options.h" +#include "wmc_auto.h" +#include "functions.h" + +#ifdef FIX_BOTH_1p25_WB_GLOBGAINOFFSET_NONBE +/* tilt factor in gainOffset quantized and adjusted for low Fs and 1p25ms framing */ +Word16 calc_GGainOffset_1p25_fx(Word16 total_bits, Word16 fs_idx) +{ + Word16 gain_off_tilt_1p25_Q19[6] = { 20480, 17408, 17476, 13107, 10486, 8738 }; /* vector for NB to UB */ + /* Corresponding FLT = gain_off_tilt_1p25 = {0.039062500000000 0.033203125000000 0.033333333333333 0.025000000000000 0.020000000000000 0.016666666666667 }*/ + + Word16 tmp1 = extract_h(L_shr_pos(L_mult0(total_bits, gain_off_tilt_1p25_Q19[fs_idx]), 3)); /* extract bits in Q0 , no rounding for interop*/ + Word16 tmp2 = extract_l(L_mac0(105L, 5, add(fs_idx, 1))); + + tmp2 = negate(add(s_min(115, tmp1), tmp2)); move16(); + + +#ifdef FIX_BOTH_1p25_WB_GLOBGAINOFFSET_LOWLIM_NONBE + if (sub(fs_idx, 1) <= 0) + { /* only NB and WB additionally limited to -135 */ + tmp2 = s_max(tmp2, FIX_BOTH_1p25_WB_GLOBGAINOFFSET_LOWLIM_NONBE); + } +#endif + + + return tmp2; +} +#endif + + diff --git a/lib_lc3plus/setup_dec_lc3.c b/lib_lc3plus/setup_dec_lc3plus.c similarity index 76% rename from lib_lc3plus/setup_dec_lc3.c rename to lib_lc3plus/setup_dec_lc3plus.c index 0435da50a..43512a4ea 100644 --- a/lib_lc3plus/setup_dec_lc3.c +++ b/lib_lc3plus/setup_dec_lc3plus.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,8 +7,10 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" -#include "setup_dec_lc3.h" +#include "setup_dec_lc3plus.h" /* if decoder is null only size is reported */ /*assume 10ms for memory allocation for now */ @@ -78,14 +80,7 @@ int alloc_decoder(LC3PLUS_Dec *decoder, int samplerate, int channels) #else q_old_res_fx = balloc(decoder, &size, sizeof(*setup->q_old_res_fx) * MIN(max_len, MAX_BW)); #endif - -/* longterm_analysis_counter_max = PLC_LONGTERM_ANALYSIS_MS * (100.0f / 25.0f);*/ -/* assert(longterm_analysis_counter_max == (PLC_LONGTERM_ANALYSIS_MS * (100 /25))); */ /* test integer division for compatibility */ -/* longterm_analysis_counter_max_bytebuffer = floor(longterm_analysis_counter_max / 30.0); */ -/* assert(longterm_analysis_counter_max_bytebuffer == (longterm_analysis_counter_max / 30)); */ /* test integer division for compatibility */ -/* longterm_analysis_counter_max = (longterm_analysis_counter_max_bytebuffer+1) * 30; */ - longterm_analysis_counter_max = plc_fadeout_param_maxlen[0]; longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[0]; @@ -151,7 +146,7 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec *decoder, int samplerate, int channels, L decoder->fs_out = samplerate; decoder->fs_idx = FS2FS_IDX(decoder->fs); decoder->channels = channels; - decoder->frame_dms = 100; + decoder->frame_dms = LC3PLUS_FRAME_DURATION_10MS; decoder->plcMeth = plc_mode; { decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; @@ -168,11 +163,32 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec *decoder, int samplerate, int channels, L setup->plc_damping = 32767; setup->ltpf_mem_scale_fac_idx = -1; move16(); + +#ifdef CR9_C_ADD_1p25MS +#ifdef CR9_C_ADD_1p25MS_LRSNS + setup->ltpfinfo_frame_cntr_fx = -32768; move16(); +#endif +#endif + + # ifdef CR9_C_ADD_1p25MS + # if 0 + /* @FhG @alex ToAddhere channel dependent :: setup->ltpf_mem_continuation = 0; */ + # endif + # ifdef CR9_C_ADD_1p25MS_LRSNS + setup->ltpfinfo_frame_cntr_fx = -32768; move16(); + # endif + # endif setup->pc_seed = 24607; setup->ns_seed = 24607; setup->ns_cum_alpha = 32767; +#ifdef CR9_C_ADD_1p25MS +#ifdef NEW_SIGNALLING_SCHEME_1p25 + setup->ltpfinfo_frame_cntr_fx = -32768; move16(); +#endif +#endif + int i = 0; /* 0 = 0kHz 1= 8kHz, 2= 16 kHz 3= 24 , 4 = 32 5=40 6=48kHz */ #if (PHECU_XFP_LA == 0) @@ -194,13 +210,12 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec *decoder, int samplerate, int channels, L mult(decoder->frame_length, (Word16)(32768.0 / 99.0)); /* truncation needed , i.e no rounding can be applied here */ /* idx=frame/80, 0=8kHZ, 1=16kHz, 2=24 kHz, 3=32 kHz 5=*, 4=48 */ - setup->plcAd->max_len_pcm_plc = DYN_MAX_LEN_PCM_PLC(decoder->fs); if ((decoder->hrmode == 0) && (samplerate <= 48000)) { setup->plcAd->PhECU_frame_ms = (Word16)( - decoder->frame_dms * 0.1); /* needed in PLCUpdate and PLC main functions, adjusted in first frame */ + decoder->frame_dms * 1.25 * 10 * 0.1); /* needed in PLCUpdate and PLC main functions, adjusted in first frame */ setup->plcAd->PhECU_seed_fx = 21845; setup->plcAd->PhECU_LprotOrg_fx = shl_pos(oneMsTab[setup->plcAd->PhECU_fs_idx_fx], 4); /* 16 *1ms = 1.6 *framelength */ @@ -250,6 +265,15 @@ void set_dec_frame_params(LC3PLUS_Dec *decoder) { Word16 tmp = 0; Word16 n; + +#ifndef FIX_TX_RX_STRUCT_STEREO +#ifdef CR9_C_ADD_1p25MS + decoder->ltpf_rx_status[0] = 0; + decoder->ltpf_rx_status[1] = 0; + decoder->ltpf_mem_continuation = 0; + decoder->ltpf_mem_active_prev = 0; +#endif +#endif decoder->frame_length = extract_l(L_shr_pos(Mpy_32_16_lc3plus(decoder->fs, 20972), 6)); /* fs * 0.01*2^6 */ @@ -262,7 +286,61 @@ void set_dec_frame_params(LC3PLUS_Dec *decoder) SWITCH (decoder->frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + decoder->frame_length = shr_pos(decoder->frame_length, 3); + decoder->la_zeroes = 0; + decoder->stDec_ola_mem_fx_len = sub(decoder->frame_length, decoder->la_zeroes); + decoder->BW_cutoff_bits = 0; +#ifdef ENABLE_HR_MODE + if (decoder->hrmode) + { + assert(0); + } + else +#endif + { + decoder->bands_number = bands_number_1_25ms[decoder->fs_idx]; + decoder->bands_offset = bands_offset_1_25ms[decoder->fs_idx]; + decoder->W_fx = LowDelayShapes_n960_1_25ms[decoder->fs_idx]; + decoder->W_size = LowDelayShapes_n960_len_1_25ms[decoder->fs_idx]; + decoder->yLen = s_min(MAX_BW >> 3, decoder->frame_length); + } + +#ifdef ENABLE_HR_MODE + if (decoder->hrmode) + { + assert(0); + } + else +#endif + { + decoder->bands_number = bands_number_1_25ms[decoder->fs_idx]; + decoder->bands_offset = bands_offset_1_25ms[decoder->fs_idx]; + decoder->W_fx = LowDelayShapes_n960_1_25ms[decoder->fs_idx]; + decoder->W_size = LowDelayShapes_n960_len_1_25ms[decoder->fs_idx]; + decoder->yLen = s_min(MAX_BW >> 3, decoder->frame_length); + decoder->BW_cutoff_bits = -1; + } +#ifdef FIX_PLC_CONFORM_ISSUES + if (decoder->fs_idx == 0 || decoder->frame_length <= 20) +#else + if (decoder->fs_idx == 0) +#endif + { + int ch; + for (ch = 0; ch < decoder->channels; ch++) + { + DecSetup *setup = decoder->channel_setup[ch]; + if (setup->plcAd != NULL) + { + setup->plcAd->tdc_lpc_order = 8; + } + } + } + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: decoder->frame_length = shr_pos(decoder->frame_length, 2); decoder->la_zeroes = LowDelayShapes_n960_la_zeroes_2_5ms[decoder->fs_idx]; decoder->stDec_ola_mem_fx_len = sub(decoder->frame_length, decoder->la_zeroes); @@ -286,7 +364,11 @@ void set_dec_frame_params(LC3PLUS_Dec *decoder) decoder->yLen = s_min(MAX_BW >> 2, decoder->frame_length); } +#ifdef FIX_PLC_CONFORM_ISSUES + if (decoder->fs_idx == 0 || decoder->frame_length <= 20) +#else if (decoder->fs_idx == 0) +#endif { int ch; for (ch = 0; ch < decoder->channels; ch++) @@ -299,7 +381,7 @@ void set_dec_frame_params(LC3PLUS_Dec *decoder) } } BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: decoder->frame_length = shr_pos(decoder->frame_length, 1); decoder->la_zeroes = LowDelayShapes_n960_la_zeroes_5ms[decoder->fs_idx]; decoder->stDec_ola_mem_fx_len = sub(decoder->frame_length, decoder->la_zeroes); @@ -324,7 +406,7 @@ void set_dec_frame_params(LC3PLUS_Dec *decoder) } BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: tmp = shr_pos(decoder->frame_length, 2); decoder->frame_length = add(tmp, add(tmp, tmp)); decoder->la_zeroes = LowDelayShapes_n960_la_zeroes_7_5ms[decoder->fs_idx]; @@ -349,7 +431,7 @@ void set_dec_frame_params(LC3PLUS_Dec *decoder) } BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: decoder->la_zeroes = LowDelayShapes_n960_la_zeroes[decoder->fs_idx]; decoder->stDec_ola_mem_fx_len = sub(decoder->frame_length, decoder->la_zeroes); decoder->bands_number = 64; @@ -371,6 +453,8 @@ void set_dec_frame_params(LC3PLUS_Dec *decoder) decoder->yLen = s_min(MAX_BW, decoder->frame_length); } BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: + assert(0); } { @@ -380,15 +464,17 @@ void set_dec_frame_params(LC3PLUS_Dec *decoder) DecSetup *setup = decoder->channel_setup[ch]; if (setup->plcAd != NULL) { /*only set if plcAd was actually allocated */ - setup->plcAd->longterm_analysis_counter_max = plc_fadeout_param_maxlen[(decoder->frame_dms / 25) - 1]; - setup->plcAd->longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[(decoder->frame_dms / 25) - 1]; + int idx = (decoder->frame_dms * 1.25 * 10 / 25) - 1; + setup->plcAd->longterm_analysis_counter_max = plc_fadeout_param_maxlen[idx]; + setup->plcAd->longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[idx]; + setup->plcAd->PhECU_frame_ms = (Word16)( - decoder->frame_dms * + decoder->frame_dms * 1.25 * 10 * 0.1); /* needed in processPLCupdate_fx(), now set properly set in first frame /second time */ } } } - FOR (n=0; n < PLC_FADEOUT_TYPE_1_IN_MS*10/decoder->frame_dms;n++){ + FOR (n=0; n < PLC_FADEOUT_TYPE_1_IN_MS*10/(decoder->frame_dms*1.25*10);n++){ decoder->alpha_type_2_table[n] = type_2_fadeout_fx(n, decoder->frame_dms); } } @@ -397,7 +483,7 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec *decoder, int ch, Word16 nBytes) { int tmp = 0, totalBits = 0; int channel_bytes = 0; - int minBytes, maxBytes; + int minBytes = 0, maxBytes = 0; DecSetup *setup = decoder->channel_setup[ch]; channel_bytes = nBytes; @@ -407,23 +493,29 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec *decoder, int ch, Word16 nBytes) { SWITCH (decoder->frame_dms) { - case 25: - maxBytes = 210; - minBytes = MIN_NBYTES; - BREAK; - case 50: - maxBytes = 375; - minBytes = MIN_NBYTES; - BREAK; - case 75: - maxBytes = 625; - minBytes = MIN_NBYTES; - BREAK; - case 100: - maxBytes = 625; - minBytes = MIN_NBYTES; - BREAK; - default: return LC3PLUS_HRMODE_ERROR; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + maxBytes = 210; + minBytes = MIN_NBYTES; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: + maxBytes = 210; + minBytes = MIN_NBYTES; + BREAK; + case LC3PLUS_FRAME_DURATION_5MS: + maxBytes = 375; + minBytes = MIN_NBYTES; + BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: + maxBytes = 625; + minBytes = MIN_NBYTES; + BREAK; + case LC3PLUS_FRAME_DURATION_10MS: + maxBytes = 625; + minBytes = MIN_NBYTES; + BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: return LC3PLUS_HRMODE_ERROR; } } else @@ -442,9 +534,24 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec *decoder, int ch, Word16 nBytes) move16(); setup->total_bits = shl(setup->targetBytes, 3); setup->enable_lpc_weighting = (setup->total_bits < 480); + + +#ifdef FIX_BOTH_1p25_WB_GLOBGAINOFFSET_NONBE + IF(decoder->frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + setup->quantizedGainOff = calc_GGainOffset_1p25_fx(setup->total_bits, decoder->fs_idx); /* enc/dec common function */ + } + ELSE + { + setup->quantizedGainOff = + -(s_min(115, setup->total_bits / (10 * (decoder->fs_idx + 1))) + 105 + 5 * (decoder->fs_idx + 1)); + } +#else setup->quantizedGainOff = -(s_min(115, setup->total_bits / (10 * (decoder->fs_idx + 1))) + 105 + 5 * (decoder->fs_idx + 1)); - tmp = DEPR_i_mult(80, decoder->fs_idx); +#endif + + #ifdef ENABLE_HR_MODE if (decoder->hrmode && decoder->fs_idx == 5) @@ -452,30 +559,39 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec *decoder, int ch, Word16 nBytes) setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); } #endif - - totalBits = setup->total_bits; + tmp = i_mult(80, decoder->fs_idx); + + totalBits = setup->total_bits; SWITCH (decoder->frame_dms) { - case 25: - setup->enable_lpc_weighting = 0; - /* total_bits * 2.4 */ - totalBits = extract_l(L_shr(L_mult0(19661, setup->total_bits), 13)); - BREAK; - case 50: - setup->enable_lpc_weighting = setup->total_bits < 240; - totalBits = sub(DEPR_i_mult(setup->total_bits, 2), 160); - BREAK; - case 75: - setup->enable_lpc_weighting = setup->total_bits < 360; - totalBits = L_shr(L_mult0(10923, setup->total_bits), 13); - BREAK; - case 100: - BREAK; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + setup->enable_lpc_weighting = 0; + /* total_bits * 3.36 */ + totalBits = extract_l(L_shr(L_mult0(27526, setup->total_bits), 13)); + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: + setup->enable_lpc_weighting = 0; + /* total_bits * 2.4 */ + totalBits = extract_l(L_shr(L_mult0(19661, setup->total_bits), 13)); + BREAK; + case LC3PLUS_FRAME_DURATION_5MS: + setup->enable_lpc_weighting = setup->total_bits < 240; + totalBits = sub(i_mult(setup->total_bits, 2), 160); + BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: + setup->enable_lpc_weighting = setup->total_bits < 360; + totalBits = L_shr(L_mult0(10923, setup->total_bits), 13); + BREAK; + case LC3PLUS_FRAME_DURATION_10MS: + BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: + assert(0); } - if (sub(totalBits, add(320, tmp)) < 0) { setup->ltpf_scale_fac_idx = 0; diff --git a/lib_lc3plus/setup_dec_lc3.h b/lib_lc3plus/setup_dec_lc3plus.h similarity index 79% rename from lib_lc3plus/setup_dec_lc3.h rename to lib_lc3plus/setup_dec_lc3plus.h index c1c556f5d..e2c35ec45 100644 --- a/lib_lc3plus/setup_dec_lc3.h +++ b/lib_lc3plus/setup_dec_lc3plus.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -10,6 +10,8 @@ #ifndef SETUP_DEC_LC3_H #define SETUP_DEC_LC3_H +#include "options.h" +#include "wmc_auto.h" #include "constants.h" typedef struct @@ -36,7 +38,7 @@ typedef struct Word16 PhECU_LprotOrg_fx; /* needed to change the Prot size adaptively */ Word16 PhECU_Lprot_fx; Word16 PhECU_fs_idx_fx; - Word16 PhECU_frame_ms; /* needed in PLC_Update and PLCMain functons*/ + Word16 PhECU_frame_ms; /* needed in PLC_Update and PLCMain functons*/ Word16 PhECU_seed_fx; Word16 PhECU_xfp_exp_fx; Word16 PhECU_time_offs; @@ -55,17 +57,17 @@ typedef struct Word16 max_len_pcm_plc; Word16 max_lprot; Word16 max_plocs; - - /* Word32 L_tot W_energy sum exponent */ - Word16 PhECU_oold_Ltot_exp_fx; + + /* Word32 L_tot W_energy sum exponent */ + Word16 PhECU_oold_Ltot_exp_fx; Word16 PhECU_old_Ltot_exp_fx; Word32 PhECU_L_oold_xfp_w_E_fx; Word32 PhECU_L_old_xfp_w_E_fx; Word16 PhECU_oold_xfp_w_E_exp_fx; /* input Word16 xfp exponnet */ - Word16 PhECU_old_xfp_w_E_exp_fx; + Word16 PhECU_old_xfp_w_E_exp_fx; Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; Word16 PhECU_old_grp_shape_fx[MAX_LGW]; - Word16 PhECU_margin_xfp; + Word16 PhECU_margin_xfp; Word16 PhECU_nonpure_tone_flag; /* non-pure single tone indicator state */ Word16 PhECU_mag_chg_1st[MAX_LGW]; Word16 PhECU_Xavg[MAX_LGW]; @@ -73,7 +75,7 @@ typedef struct Word16 old_old_scf_q[M]; Word16 tdc_A[M + 1]; /* for now 20 ms saved Q14 or ptr to a combined ifft win and MDCT preTDA synthesis window 16 ms */ - + Word16 longterm_counter_plcTdc; Word16 longterm_counter_plcNsAdv; Word16 longterm_analysis_counter_max; /* Maximum longterm frames number */ @@ -84,6 +86,9 @@ typedef struct Word16 overall_counter; Word8 longterm_counter_byte_position; Word8 longterm_counter_bit_position; +#ifdef CR13_C_RESET_CLASSIFIER_AFTER_BAD_FRAMES + Word16 numberOfGoodFrames; +#endif } AplcSetup; /* Channel state and bitrate-derived values go in this struct */ @@ -128,6 +133,21 @@ typedef struct Word16 plc_damping; Word16 last_size; Word32 rel_pitch_change; +#ifdef CR9_C_ADD_1p25MS +#ifdef FIX_TX_RX_STRUCT_STEREO + Word16 ltpf_rx_status[2]; +#endif + Word16 ltpf_mem_continuation; + Word16 ltpf_mem_active_prev; + Word16 ltpf_mem_pitch_int_prev; + Word16 ltpf_mem_pitch_fr_prev; + Word16 ltpf_mem_beta_idx_prev; + Word16 ltpf_mem_gain_prev; + Word16 ltpf_pitch_stability_counter; +#ifdef NEW_SIGNALLING_SCHEME_1p25 + Word16 ltpfinfo_frame_cntr_fx; /* individual cntr for each channel*/ +#endif +#endif } DecSetup; /* Constants and sampling rate derived values go in this struct */ @@ -146,7 +166,7 @@ struct LC3PLUS_Dec Word16 frame_length; /* sampling rate index */ Word16 channels; /* number of channels */ Word16 plcMeth; /* PLC method for all channels */ - Word16 frame_dms; /* frame length in dms (decimilliseconds, 10^-4)*/ + LC3PLUS_FrameDuration frame_dms; /* frame length in dms (decimilliseconds, 10^-4)*/ Word16 last_size; /* size of last frame, without error protection */ Word16 ep_enabled; /* error protection enabled */ Word16 error_report; /* corrected errors in last frame or -1 on error */ @@ -168,7 +188,19 @@ struct LC3PLUS_Dec Word16 ltpf_mem_y_len; Word16 BW_cutoff_bits; Word16 hrmode; - Word16 alpha_type_2_table[80];/* PLC_FADEOUT_TYPE_1_IN_MS*10/25 */ + Word16 alpha_type_2_table[160];/* PLC_FADEOUT_TYPE_1_IN_MS*100/125 */ +#ifndef FIX_TX_RX_STRUCT_STEREO +#ifdef CR9_C_ADD_1p25MS + Word16 ltpf_rx_status[2]; + Word16 ltpf_mem_continuation; + Word16 ltpf_mem_active_prev; + Word16 ltpf_mem_pitch_int_prev; + Word16 ltpf_mem_pitch_fr_prev; + Word16 ltpf_mem_beta_idx_prev; + Word16 ltpf_mem_gain_prev; + Word16 ltpf_pitch_stability_counter; +#endif +#endif }; -#endif +#endif /* SETUP_DEC_LC3_H */ diff --git a/lib_lc3plus/setup_enc_lc3.c b/lib_lc3plus/setup_enc_lc3plus.c similarity index 67% rename from lib_lc3plus/setup_enc_lc3.c rename to lib_lc3plus/setup_enc_lc3plus.c index 563734358..92c668912 100644 --- a/lib_lc3plus/setup_enc_lc3.c +++ b/lib_lc3plus/setup_enc_lc3plus.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,8 +7,10 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" -#include "setup_enc_lc3.h" +#include "setup_enc_lc3plus.h" /* if encoder is null only size is reported */ int alloc_encoder(LC3PLUS_Enc *encoder, int samplerate, int channels) @@ -58,8 +60,11 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc *encoder, int samplerate, int channels #endif encoder->channels = channels; - encoder->frame_dms = 100; + encoder->frame_dms = LC3PLUS_FRAME_DURATION_10MS; encoder->envelope_bits = 38; + #ifdef CR9_C_ADD_1p25MS_LRSNS + /* "38" SNS bit constant kept here, final LR-SNS bitrate adjusted in enc_lc3() after LR-SNSVQ */ +#endif /* CR9_C_ADD_1p25MS_LRSNS */ encoder->global_gain_bits = 8; encoder->noise_fac_bits = 3; encoder->r12k8_mem_in_len = extract_l(L_shr_pos(Mpy_32_16_lc3plus(encoder->fs, 20972), 9)); @@ -92,6 +97,12 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc *encoder, int samplerate, int channels void set_enc_frame_params(LC3PLUS_Enc *encoder) { Word16 tmp; +#ifdef CR9_C_ADD_1p25MS +#ifndef FIX_TX_RX_STRUCT_STEREO + encoder->Tx_ltpf = 0; +#endif + encoder->LT_normcorr = 0xFFFF >> 2; +#endif encoder->frame_length = extract_l(L_shr_pos(Mpy_32_16_lc3plus(encoder->fs, 20972), 6)); /* fs * 0.01*2^6 */ @@ -108,12 +119,50 @@ void set_enc_frame_params(LC3PLUS_Enc *encoder) SWITCH (encoder->frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + encoder->BW_cutoff_bits = 0; + encoder->frame_length = shr_pos(encoder->frame_length, 3); + encoder->la_zeroes = 0; + encoder->stEnc_mdct_mem_len = sub(encoder->frame_length, encoder->la_zeroes); + encoder->nSubdivisions = 0; +#ifdef FIX_LTPF_PITCH_MEM_LEN + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + 112; +#else + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + ( LEN_12K8 >> 1 ) + 16; +#endif + encoder->r12k8_mem_out_len = 8; +#ifndef CR9_C_ADD_1p25MS_NOISEFILLING + encoder->noise_fac_bits = 0; +#endif +#ifdef ENABLE_HR_MODE + if (encoder->hrmode) + { + assert(0); + } + else +#endif + { + encoder->yLen = s_min(MAX_BW >> 3, encoder->frame_length); + encoder->W_fx = LowDelayShapes_n960_1_25ms[encoder->fs_idx]; + encoder->W_size = LowDelayShapes_n960_len_1_25ms[encoder->fs_idx]; + encoder->bands_number = bands_number_1_25ms[encoder->fs_idx]; + encoder->bands_offset = bands_offset_1_25ms[encoder->fs_idx]; + encoder->near_nyquist_index = encoder->bands_number - 2; + encoder->near_nyquist_flag = 0; + } + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: encoder->frame_length = shr_pos(encoder->frame_length, 2); encoder->la_zeroes = LowDelayShapes_n960_la_zeroes_2_5ms[encoder->fs_idx]; encoder->stEnc_mdct_mem_len = sub(encoder->frame_length, encoder->la_zeroes); encoder->nSubdivisions = 2; - encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + (LEN_12K8 >> 2); +#ifdef FIX_LTPF_PITCH_MEM_LEN + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + 96; +#else + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + ( LEN_12K8 >> 2 ); +#endif #ifdef ENABLE_HR_MODE if (encoder->hrmode) @@ -137,12 +186,16 @@ void set_enc_frame_params(LC3PLUS_Enc *encoder) } BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: encoder->frame_length = shr_pos(encoder->frame_length, 1); encoder->la_zeroes = LowDelayShapes_n960_la_zeroes_5ms[encoder->fs_idx]; encoder->stEnc_mdct_mem_len = sub(encoder->frame_length, encoder->la_zeroes); encoder->nSubdivisions = 2; - encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + (LEN_12K8 >> 1); +#ifdef FIX_LTPF_PITCH_MEM_LEN + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + 64; +#else + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + ( LEN_12K8 >> 1 ); +#endif #ifdef ENABLE_HR_MODE if (encoder->hrmode) @@ -164,10 +217,9 @@ void set_enc_frame_params(LC3PLUS_Enc *encoder) encoder->near_nyquist_index = encoder->bands_number - 3; encoder->near_nyquist_flag = 0; } - encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: tmp = shr_pos(encoder->frame_length, 2); encoder->frame_length = add(tmp, add(tmp, tmp)); encoder->la_zeroes = LowDelayShapes_n960_la_zeroes_7_5ms[encoder->fs_idx]; @@ -201,7 +253,7 @@ void set_enc_frame_params(LC3PLUS_Enc *encoder) } BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: encoder->la_zeroes = LowDelayShapes_n960_la_zeroes[encoder->fs_idx]; encoder->stEnc_mdct_mem_len = sub(encoder->frame_length, encoder->la_zeroes); encoder->bands_number = 64; @@ -230,6 +282,8 @@ void set_enc_frame_params(LC3PLUS_Enc *encoder) encoder->bands_offset = bands_offset[encoder->fs_idx]; } BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: + assert(0); } } @@ -240,12 +294,17 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) int totalBytes = 0, maxBR = 0, minBR = 0, max_bytes = 0; int channel_bytes = 0; +#ifdef CR12_D_FIX_BITRATE_LIMITS + int fec_slot_bytes_min = 0, check_bytes = 0; +#endif #ifdef ENABLE_HR_MODE if (encoder->hrmode) { - switch (encoder->frame_dms) + SWITCH (encoder->frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + assert(0); maxBR = 672000; if (encoder->fs == 48000) { @@ -260,7 +319,23 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) return LC3PLUS_HRMODE_ERROR; } break; - case 50: +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: + maxBR = 672000; + if (encoder->fs == 48000) + { + minBR = MIN_BR_25MS_48KHZ_HR; + } + else if (encoder->fs == 96000) + { + minBR = MIN_BR_25MS_96KHZ_HR; + } + else + { + return LC3PLUS_HRMODE_ERROR; + } + break; + case LC3PLUS_FRAME_DURATION_5MS: maxBR = 600000; if (encoder->fs == 48000) { @@ -275,13 +350,13 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) return LC3PLUS_HRMODE_ERROR; } break; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: maxBR = 500000; if (encoder->fs == 48000) {minBR = MIN_BR_075DMS_48KHZ_HR;} else if (encoder->fs == 96000) {minBR = MIN_BR_075DMS_96KHZ_HR;} else {return LC3PLUS_HRMODE_ERROR;} BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: maxBR = 500000; if (encoder->fs == 48000) { @@ -296,7 +371,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) return LC3PLUS_HRMODE_ERROR; } break; - default: return LC3PLUS_HRMODE_ERROR; + case LC3PLUS_FRAME_DURATION_UNDEFINED: return LC3PLUS_HRMODE_ERROR; } } else @@ -304,13 +379,19 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) minBR = (MIN_NBYTES << 3); maxBR = MAX_BR; - switch (encoder->frame_dms) + SWITCH (encoder->frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + minBR = MIN_BR_0125DMS; + maxBR = MAX_BR_0125DMS; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: minBR = MIN_BR_025DMS; maxBR = MAX_BR; BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: minBR = MIN_BR_050DMS; maxBR = MAX_BR; /* have additional limitations for 5.0ms */ @@ -322,7 +403,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) default: BREAK; } BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: minBR = MIN_BR_075DMS; maxBR = MAX_BR_075DMS; // special value for maxBR @ 7.5ms /* have additional limitations for 7.5ms */ @@ -340,7 +421,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) default: BREAK; } BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: /* have additional limitations for 10ms */ minBR = MIN_BR_100DMS; maxBR = MAX_BR; @@ -358,7 +439,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) default: maxBR = MAX_BR; BREAK; } BREAK; - default: return LC3PLUS_FRAMEMS_ERROR; + case LC3PLUS_FRAME_DURATION_UNDEFINED: return LC3PLUS_FRAMEMS_ERROR; } /* 441/480 in Q31 and 1000/75 in Q23 */ @@ -372,13 +453,19 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) minBR = (MIN_NBYTES << 3); maxBR = MAX_BR; - switch (encoder->frame_dms) + SWITCH (encoder->frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + minBR = MIN_BR_0125DMS; + maxBR = MAX_BR_0125DMS; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: minBR = MIN_BR_025DMS; maxBR = MAX_BR; BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: minBR = MIN_BR_050DMS; maxBR = MAX_BR; /* have additional limitations for 5.0ms */ @@ -390,7 +477,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) default: BREAK; } BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: minBR = MIN_BR_075DMS; maxBR = MAX_BR_075DMS; // special value for maxBR @ 7.5ms /* have additional limitations for 7.5ms */ @@ -408,7 +495,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) default: BREAK; } BREAK; - case 100: + case LC3PLUS_FRAME_DURATION_10MS: /* have additional limitations for 10ms */ minBR = MIN_BR_100DMS; maxBR = MAX_BR; @@ -426,7 +513,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) default: maxBR = MAX_BR; BREAK; } BREAK; - default: return LC3PLUS_FRAMEMS_ERROR; + case LC3PLUS_FRAME_DURATION_UNDEFINED: return LC3PLUS_FRAMEMS_ERROR; } /* 441/480 in Q31 and 1000/75 in Q23 */ @@ -461,9 +548,56 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) if (encoder->epmode > 0) { - max_bytes = bitrate * encoder->frame_length / (8 * encoder->fs_in * encoder->channels); +#ifdef CR12_D_FIX_BITRATE_LIMITS +#ifdef ENABLE_HR_MODE + if (encoder->hrmode){ + SWITCH( encoder->frame_dms ) + { + case LC3PLUS_FRAME_DURATION_2p5MS: + IF( encoder->fs_in == 48000){ + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN_025DMS_48KHZ_HR; + } ELSE { + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN_025DMS_96KHZ_HR; + } + BREAK; + case LC3PLUS_FRAME_DURATION_5MS: + IF( encoder->fs_in == 48000){ + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN_050DMS_48KHZ_HR; + } ELSE { + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN_050DMS_96KHZ_HR; + } + BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: + IF( encoder->fs_in == 48000){ + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN_075DMS_48KHZ_HR; + } ELSE { + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN_075DMS_96KHZ_HR; + } + BREAK; + case LC3PLUS_FRAME_DURATION_10MS: + IF( encoder->fs_in == 48000){ + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN_100DMS_48KHZ_HR; + } ELSE { + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN_100DMS_96KHZ_HR; + } + BREAK; + default: + return LC3PLUS_FRAMEMS_ERROR; + } + } + else +#endif + { + fec_slot_bytes_min = FEC_SLOT_BYTES_MIN; + } + check_bytes = bitrate * encoder->frame_length / ( 8 * encoder->fs_in * encoder->channels ); + maxBR = FEC_SLOT_BYTES_MAX * ( 8 * encoder->fs_in * encoder->channels ) / encoder->frame_length; + if ( check_bytes < fec_slot_bytes_min || bitrate > maxBR ) +#else + max_bytes = bitrate * encoder->frame_length / (8 * encoder->fs_in * encoder->channels); if (max_bytes < FEC_SLOT_BYTES_MIN || max_bytes > FEC_SLOT_BYTES_MAX) +#endif /* CR12_D_FIX_BITRATE_LIMITS */ { return LC3PLUS_BITRATE_ERROR; } @@ -502,7 +636,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) setup->n_pc = fec_get_n_pc(encoder->epmode, setup->n_pccw, channel_bytes); } /* reduce bandwith to 12kHz if bitrate is low */ - if (sub(encoder->frame_dms, 100) == 0 && + if (sub(encoder->frame_dms, LC3PLUS_FRAME_DURATION_10MS) == 0 && ((sub(setup->targetBytes, 40) < 0 && L_sub(encoder->fs, 48000) == 0) || (sub(setup->targetBytes, 36) < 0 && L_sub(encoder->fs, 32000) == 0))) { @@ -516,26 +650,34 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) } { - Word16 tmp; + Word16 tmp = 0; SWITCH(encoder->frame_dms) { - case 25: tmp = 1; BREAK; - case 50: tmp = 2; BREAK; - case 75: tmp = 3; BREAK; - default : tmp = 4; BREAK; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: tmp = 1; BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: tmp = 2; BREAK; + case LC3PLUS_FRAME_DURATION_5MS: tmp = 4; BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: tmp = 6; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: tmp = 8; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } - encoder->bw_ctrl_cutoff_bin = L_mult0(Mpy_32_32_lc3plus(encoder->bandwidth, 10737419), tmp); /* bandwidth * frame_dms / 5000 */ + encoder->bw_ctrl_cutoff_bin = L_mult0(Mpy_32_32_lc3plus(encoder->bandwidth, 10737420>>1), tmp); /* bandwidth * frame_dms / 5000 */ } encoder->bw_index = sub( Mpy_32_32_lc3plus(encoder->bandwidth, 536871), 1); /* (bandwidth / 4000 ) - 1 */ - switch (encoder->frame_dms) + SWITCH (encoder->frame_dms) { - case 25: max_bytes = MAX_NBYTES_025; break; - case 50: max_bytes = MAX_NBYTES_050; break; - case 75: max_bytes = MAX_NBYTES_075; BREAK; - case 100: max_bytes = MAX_NBYTES_100; break; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: max_bytes = MAX_NBYTES_025; break; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: max_bytes = MAX_NBYTES_025; break; + case LC3PLUS_FRAME_DURATION_5MS: max_bytes = MAX_NBYTES_050; break; + case LC3PLUS_FRAME_DURATION_7p5MS: max_bytes = MAX_NBYTES_075; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: max_bytes = MAX_NBYTES_100; break; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } #ifdef ENABLE_HR_MODE if (encoder->hrmode) @@ -553,7 +695,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) sub(setup->total_bits, add(encoder->envelope_bits, add(encoder->global_gain_bits, add(encoder->noise_fac_bits, encoder->BW_cutoff_bits)))); - setup->targetBitsInit = sub(setup->targetBitsInit, sub(17, norm_s(sub(encoder->yLen, 1)))); + setup->targetBitsInit = sub(setup->targetBitsInit, getLastNzBits_fx (encoder->frame_length) + 3); if (setup->total_bits > 1280) { setup->targetBitsInit = sub(setup->targetBitsInit, 1); @@ -574,29 +716,52 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) SWITCH (encoder->frame_dms) { - case 25: - /* 9830 = 2.4 * 2^12 */ - setup->ltpf_enable = - sub(extract_l(L_shr(L_mult0(9830, setup->total_bits), 12)), add(560, DEPR_i_mult(80, encoder->fs_idx))) < 0; - setup->enable_lpc_weighting = 0; - BREAK; - case 50: - setup->ltpf_enable = sub(sub(DEPR_i_mult(setup->total_bits, 2), 160), add(560, DEPR_i_mult(80, encoder->fs_idx))) < 0; - setup->enable_lpc_weighting = setup->total_bits < 240; - BREAK; - case 75: - setup->ltpf_enable = sub(L_shr(L_mult0(10923, setup->total_bits), 13), add(560, DEPR_i_mult(80, encoder->fs_idx))) < 0; - setup->enable_lpc_weighting = setup->total_bits < 360; - BREAK; - case 100: - setup->enable_lpc_weighting = setup->total_bits < 480; - setup->ltpf_enable = sub(setup->total_bits, add(560, DEPR_i_mult(80, encoder->fs_idx))) < 0; - BREAK; - } +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + /* 13763 = 3.36 * 2^12 */ + setup->ltpf_enable = + sub(extract_l(L_shr(L_mult0(13763, setup->total_bits), 12)), add(560, i_mult(80, encoder->fs_idx))) < 0; + setup->enable_lpc_weighting = 0; + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: + /* 9830 = 2.4 * 2^12 */ + setup->ltpf_enable = + sub(extract_l(L_shr(L_mult0(9830, setup->total_bits), 12)), add(560, i_mult(80, encoder->fs_idx))) < 0; + setup->enable_lpc_weighting = 0; + BREAK; + case LC3PLUS_FRAME_DURATION_5MS: + setup->ltpf_enable = sub(sub(i_mult(setup->total_bits, 2), 160), add(560, i_mult(80, encoder->fs_idx))) < 0; + setup->enable_lpc_weighting = setup->total_bits < 240; + BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: + setup->ltpf_enable = sub(L_shr(L_mult0(10923, setup->total_bits), 13), add(560, i_mult(80, encoder->fs_idx))) < 0; + setup->enable_lpc_weighting = setup->total_bits < 360; + BREAK; + case LC3PLUS_FRAME_DURATION_10MS: + setup->enable_lpc_weighting = setup->total_bits < 480; + setup->ltpf_enable = sub(setup->total_bits, add(560, i_mult(80, encoder->fs_idx))) < 0; + BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: + assert(0); + } + +#ifdef FIX_BOTH_1p25_WB_GLOBGAINOFFSET_NONBE + IF(encoder->frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + setup->quantizedGainOff = calc_GGainOffset_1p25_fx(setup->total_bits, encoder->fs_idx); /* enc/dec common function */ + } + ELSE + { + setup->quantizedGainOff = + -(s_min(115, setup->total_bits / (10 * (encoder->fs_idx + 1))) + 105 + 5 * (encoder->fs_idx + 1)); + } +#else setup->quantizedGainOff = -(s_min(115, setup->total_bits / (10 * (encoder->fs_idx + 1))) + 105 + 5 * (encoder->fs_idx + 1)); - +#endif + #ifdef ENABLE_HR_MODE if (encoder->hrmode && encoder->fs_idx == 5) { @@ -605,13 +770,13 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) #endif #ifdef ENABLE_HR_MODE - if (encoder->frame_dms == 100 && + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_10MS && ((encoder->fs_in >= 44100 && setup->targetBytes >= 100) || (encoder->fs_in == 32000 && setup->targetBytes >= 81)) && setup->targetBytes < 340 && (encoder->hrmode == 0)) #else - if (encoder->frame_dms == 100 && + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_10MS && ((encoder->fs_in >= 44100 && setup->targetBytes >= 100) || (encoder->fs_in == 32000 && setup->targetBytes >= 81)) && setup->targetBytes < 340 @@ -620,7 +785,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) { setup->attack_handling = 1; } - else if (encoder->frame_dms == 75 && ((encoder->fs_in >= 44100 && setup->targetBytes >= 75) || + else if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_7p5MS && ((encoder->fs_in >= 44100 && setup->targetBytes >= 75) || (encoder->fs_in == 32000 && setup->targetBytes >= 61)) && setup->targetBytes < 150 #ifdef ENABLE_HR_MODE && encoder->hrmode == 0 @@ -655,19 +820,19 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) encoder->sns_damping = SNS_DAMPING_HRMODE; IF (encoder->fs_idx >= 4) { - IF ((encoder->frame_dms == 100) & (setup->total_bits > 4400)) + IF ((encoder->frame_dms == LC3PLUS_FRAME_DURATION_10MS) & (setup->total_bits > 4400)) { encoder->sns_damping = SNS_DAMPING_HRMODE_UB_10MS; } - IF ((encoder->frame_dms == 75) & (setup->total_bits > 3300)) + IF ((encoder->frame_dms == LC3PLUS_FRAME_DURATION_7p5MS) & (setup->total_bits > 3300)) { encoder->sns_damping = SNS_DAMPING_HRMODE_UB_7_5MS; } - IF ((encoder->frame_dms == 50) & (setup->total_bits > 2300)) + IF ((encoder->frame_dms == LC3PLUS_FRAME_DURATION_5MS) & (setup->total_bits > 2300)) { encoder->sns_damping = SNS_DAMPING_HRMODE_UB_5MS; } - IF ((encoder->frame_dms == 25) & (setup->total_bits > 1150)) + IF ((encoder->frame_dms == LC3PLUS_FRAME_DURATION_2p5MS) & (setup->total_bits > 1150)) { encoder->sns_damping = SNS_DAMPING_HRMODE_UB_2_5MS; } @@ -676,39 +841,39 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) if (encoder->hrmode && encoder->fs_idx >= 4) { - int real_rate = setup->targetBytes * 8 * 10000 / encoder->frame_dms; + int real_rate = setup->targetBytes * 8 * 10000 / (encoder->frame_dms * 1.25 * 10); setup->regBits = real_rate / 12500; if (encoder->fs_idx == 5) { - if (encoder->frame_dms == 100) + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_10MS) { setup->regBits += 2; } - if (encoder->frame_dms == 75) + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_7p5MS) { setup->regBits +=1; } - if (encoder->frame_dms == 25) + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_2p5MS) { setup->regBits -= 6; } } else { - if (encoder->frame_dms == 25) + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_2p5MS) { setup->regBits -= 6; } - else if (encoder->frame_dms == 50) + else if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_5MS) { setup->regBits += 0; } - if (encoder->frame_dms == 75) + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_7p5MS) { setup->regBits +=2; } - if (encoder->frame_dms == 100) + if (encoder->frame_dms == LC3PLUS_FRAME_DURATION_10MS) { setup->regBits += 5; } diff --git a/lib_lc3plus/setup_enc_lc3.h b/lib_lc3plus/setup_enc_lc3plus.h similarity index 89% rename from lib_lc3plus/setup_enc_lc3.h rename to lib_lc3plus/setup_enc_lc3plus.h index c9a1076a3..6fa08039d 100644 --- a/lib_lc3plus/setup_enc_lc3.h +++ b/lib_lc3plus/setup_enc_lc3plus.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -10,6 +10,8 @@ #ifndef SETUP_ENC_LC3_H #define SETUP_ENC_LC3_H +#include "options.h" +#include "wmc_auto.h" #include "constants.h" /* Channel state and bitrate-derived values go in this struct */ @@ -35,10 +37,13 @@ typedef struct Word16 olpa_mem_pitch; Word16 pitch_flag; Word16 ltpf_mem_in_exp; - Word16 ltpf_mem_normcorr; + Word16 ltpf_mem_normcorr[LEN_MEM_NORMCORR]; Word16 ltpf_mem_mem_normcorr; Word16 ltpf_mem_ltpf_on; Word16 ltpf_mem_pitch; +#ifdef FIX_TX_RX_STRUCT_STEREO + Word16 Tx_ltpf; +#endif Word16 mem_targetBits; Word16 mem_specBits; Word16 x_exp; @@ -89,7 +94,7 @@ struct LC3PLUS_Enc Word16 frame_length; /* audio samples / frame */ Word16 channels; /* number of channels */ Word16 epmode; /* error protection mode */ - Word16 frame_dms; /* frame length in dms (decimilliseconds, 10^-4)*/ + LC3PLUS_FrameDuration frame_dms; /* enum for frame length in steps of 12.5 dms */ Word8 lc3_br_set; /* indicate if bitrate has been set */ Word16 yLen; @@ -120,6 +125,12 @@ struct LC3PLUS_Enc Word16 attdec_hangover_thresh; Word16 hrmode; Word16 sns_damping; +#ifdef CR9_C_ADD_1p25MS +#ifndef FIX_TX_RX_STRUCT_STEREO + Word16 Tx_ltpf; +#endif + Word16 LT_normcorr; +#endif }; -#endif +#endif /* SETUP_ENC_LC3_H */ diff --git a/lib_lc3plus/sns_compute_scf_fx.c b/lib_lc3plus/sns_compute_scf_fx.c index cc3338b77..8acfe52bb 100644 --- a/lib_lc3plus/sns_compute_scf_fx.c +++ b/lib_lc3plus/sns_compute_scf_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,10 +7,88 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" +#ifdef CR9_C_ADD_1p25MS +static Word32 limitShaping (Word32* d3_fx) { + Word32 score = L_shl_pos(L_sub(d3_fx[0], d3_fx[1]), 1); + score = L_add(score, L_sub(d3_fx[0], d3_fx[2])); + score = L_shr_pos(score, 1); + + score = L_max(L_min(score, 536870912), 335544320); /* 5*2^26 and 8*2^26 */ + + score = L_sub(536870912, score); /* 8 - score */ + + score = L_shr_pos(Mpy_32_16_lc3plus(score, 7646), 0); /* 7646 = 0.7/3 * 2^15 */ + + score = L_add(score, 20132660); /* +0.3*2^26 */ + + score = L_shl_sat(score, 5); /* Bring score into Q31 Format for Mpy32_16() */ + /* Alex: Changed from L_shl_pos to L_shl_sat */ + + return score; +} +#endif + + +#ifdef FIX_SNS_BASOP_MEAN64_CALC +/*improved precision in mean64 accumulation will increase min SNR by 15 dB */ +/* output is max energy band location [0 ... 63] */ +static Word16 sns_compute_mean64_ip(Word32 *en_fx_m, Word16 * en_fx_exp, Word32 *L_mean64_fx, Word16* mean64_fx_exp, Word32* L_en_upd_fx, Word16* en_upd_fx_exp ) +{ + Word32 i,L_tmp; + Word16 tmp, max_exp; + + /* maximize all exponents and mantissas , except for zero mantissas */ + max_exp = -128; move16(); + FOR (i = 0; i < 64; i++) + { + tmp = norm_l(en_fx_m[i]); + + L_en_upd_fx[i] = L_shl_pos(en_fx_m[i], tmp); /* factor 1/64 __NOT__ applied here */ + en_upd_fx_exp[i] = sub(en_fx_exp[i], tmp); + + if (L_en_upd_fx[i] == 0) + { + en_upd_fx_exp[i] = 0; move16();/* all zero mantissa --> correct max_exp */ + } + + max_exp = s_max(max_exp, en_upd_fx_exp[i]); + + } + + L_tmp = L_deposit_l(0); + + /* sum up at max_exp + 6 for 1/64 */ + Word16 glob_shift = add(max_exp, 6); /* add div by 64 , as margin */ + + glob_shift = s_max(glob_shift, -31); + + for (i = 0; i < 64; i++) + { + tmp = s_min(31, sub(glob_shift, en_upd_fx_exp[i])); /* right shift including 1/64 can become larger than 31 */ + L_tmp = L_add(L_tmp, L_shr(L_en_upd_fx[i], tmp)); + } + + //double mean64_m = round(mean64 * pow(2.0, 31.0-(double)max_exp)); /* dbg */ + //double mean64_new = (double)L_tmp * pow(2.0, (double)max_exp - 31.0); + + *L_mean64_fx = L_tmp; + *mean64_fx_exp = max_exp; + + return -1; + +} +#endif + + void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Word16 n_bands, Word16 *scf, Word16 scf_smoothing_enabled, Word16 attdec_damping_factor, Word8 *scratchBuffer, Word16 sns_damping +#ifdef CR9_C_ADD_1p25MS + , LC3PLUS_FrameDuration frame_dms, Word16 norm_corr, Word16 *LT_normcorr +#endif ) { Dyn_Mem_Deluxe_In( @@ -28,6 +106,26 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor d3_fx_exp = scratchAlign(d3_fx, sizeof(*d3_fx) * MAX_BANDS_NUMBER); /* Size = 2 * MAX_BANDS_NUMBER = 128 bytes */ d4_fx = scratchAlign(d3_fx_exp, sizeof(*d3_fx_exp) * MAX_BANDS_NUMBER); /* Size = 2 * MAX_BANDS_NUMBER = 128bytes */ scf_smooth = scratchAlign(d4_fx, sizeof(*d4_fx) * MAX_BANDS_NUMBER); /* Size = 2 * 16 */ + + const Word16 *preemp; + const Word16 *preemp_e; +#ifdef CR9_C_ADD_1p25MS + Word16 *pre_em_buf; + Word16 *pre_em_buf_e; + + if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) { + pre_em_buf = scratchAlign(scf_smooth, sizeof(*pre_em_buf) * MAX_BANDS_NUMBER); + pre_em_buf_e = scratchAlign(pre_em_buf, sizeof(*pre_em_buf_e) * MAX_BANDS_NUMBER); + } + + Word32 limiterGain = 0x7FFFFFFF; /* 1.0f */ + Word16 ncorr_fac = 0; + +#ifdef FIX_SNS_BASOP_MEAN64_CALC + Word32 L_d5_fx[64], L_mean_ip = 1; + Word16 d5_fx_exp[64], mean_ip_exp = 0; +#endif +#endif /* Smoothing and Pre-emphasis */ IF (sub(n_bands, 32) < 0) @@ -63,18 +161,96 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor n_bands = 64; move16(); } +#ifdef CR9_C_ADD_1p25MS + /* calc long termn normcorr */ + if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS && lpc_pre_adapt_emphasis[fs_idx] != NULL) { +#ifdef FIX_BASOP_LT_NORMCORR_AR1 + #ifdef ER_DEBUG + Word16 LT_normcorr_mem = *LT_normcorr; + #endif + L_tmp = L_mult0(1, norm_corr); /* 1/8 */ + L_tmp = L_mac0(L_tmp, 7, *LT_normcorr); /* 7/8 */ + *LT_normcorr = round_fx(L_shl_pos(L_tmp, 16 - 3) ); + assert(*LT_normcorr >= 0); + + /* ncorr_fac = max(*LT_normcorr - 0.8, 0) * 5 */ + /* improved precision of n_corr_fac esp. close to the 0.8 border */ + L_tmp = L_mult0(*LT_normcorr, 5 * (1L << (15 - 3))); /* work in the 5 * upscaled domain from start */ + L_tmp = L_sub(L_tmp, 4 * (1L << ((15 - 3) + 15))); /* sub by 0.8 , limit now exactly 0.8 */ + L_tmp = L_max(L_tmp, 0L); + ncorr_fac = round_fx(L_shl(L_tmp, 4)); /* extract in Q15 */ + + #ifdef ER_DEBUG + LT_normcorr_mem = add(mult(LT_normcorr_mem, 28672), mult(norm_corr, 4096)); + Word16 ncorr_fac_orig = i_mult(s_max(sub(LT_normcorr_mem, 26214), 0), 5); + UNUSED(ncorr_fac_orig); + #endif +#else + /* LT_normcorr * (1-0.125) + normcorr * 0.125 */ + *LT_normcorr = add(mult(*LT_normcorr,28672), mult(norm_corr,4096)); + /* ncorr_fac = max(LT_normcorr - 0.8, 0) * 5 */ + ncorr_fac = i_mult(s_max(sub(*LT_normcorr, 26214), 0), 5); +#endif + + if (ncorr_fac == 0) + { + preemp = lpc_pre_emphasis[fs_idx]; + preemp_e = lpc_pre_emphasis_e[fs_idx]; + } else { + FOR (i = 0; i < n_bands; i++) { + assert (lpc_pre_adapt_emphasis_e[fs_idx][i]>= lpc_pre_emphasis_e[fs_idx][i]); + assert((((Word16)lpc_pre_adapt_emphasis_e[fs_idx][i]) + 1) <= 255); /*check Word8 storage */ + assert((((Word16)lpc_pre_adapt_emphasis_e[fs_idx][i]) + 1) >= -256); /*check Word8 storage */ +#ifdef FIX_BASOP_PREEMPH_CALC + /* FLT sns_preemph_new[i] = (sns_preemph[i] + fac * sns_preemph_adapt[i]); */ + /* BASOP MantNew[i]*2^expNew[i] = (Mant16A[i]*2^expA[i] + facQ15 * Mant16B^expB[i]); */ + /*determine downscaling factor for the base part */ + Word16 tmp_shift = sub(lpc_pre_adapt_emphasis_e[fs_idx][i], lpc_pre_emphasis_e[fs_idx][i]); + Word16 shift_factor = shr_pos(-32768, tmp_shift); /* mantissa downshift impl. as multiplication on the negative side */ + + /*Add scaled mantissas in the same Q but 1 bit rightshifted(for 1 bit WC addition margin) */ + L_tmp = L_mult0(lpc_pre_adapt_emphasis[fs_idx][i], ncorr_fac); /* Qx*Q15 --> Qx, 1 additional bit margin created with Mult0 */ + L_tmp = L_msu0(L_tmp, lpc_pre_emphasis[fs_idx][i], shift_factor ); /* shift_dactor is negative, Msu0 will lead to addition */ + + tmp = norm_l(L_tmp); + pre_em_buf[i] = round_fx_sat(L_shl_pos(L_tmp, tmp)); /* maximize mantissa and apply round */ /* sat needed due to warning due to RND additio of 0.5 */ + + tmp = sub(tmp, add(tmp_shift, 1)); ; + pre_em_buf_e[i] = sub(lpc_pre_emphasis_e[fs_idx][i], tmp); /* adjust final exponent due to mantissa upshift and addition margin */ + + /* sum ~10 ops, but increased precision, and a maintained maximized mantissa */ + +#else + pre_em_buf_e[i] = lpc_pre_adapt_emphasis_e[fs_idx][i] + 1; + Word16 tmp_s = lpc_pre_adapt_emphasis_e[fs_idx][i] - lpc_pre_emphasis_e[fs_idx][i]; + Word16 tmp_v = mult(lpc_pre_adapt_emphasis[fs_idx][i], ncorr_fac); + pre_em_buf[i] = add(shr(lpc_pre_emphasis[fs_idx][i], (tmp_s+1)), shr(tmp_v,1)); +#endif + } + preemp = pre_em_buf; + preemp_e = pre_em_buf_e; + } + } else { + preemp = lpc_pre_emphasis[fs_idx]; + preemp_e = lpc_pre_emphasis_e[fs_idx]; + } +#else + preemp = lpc_pre_emphasis[fs_idx]; + preemp_e = lpc_pre_emphasis_e[fs_idx]; +#endif + L_tmp = L_add(Mpy_32_16_lc3plus(d2_fx[0], 24576), L_shr_pos(d2_fx[1], 2)); - d3_fx[0] = Mpy_32_16_lc3plus(L_tmp, lpc_pre_emphasis[fs_idx][0]); move32(); - d3_fx_exp[0] = add(d2_fx_exp, lpc_pre_emphasis_e[fs_idx][0]); move16(); + d3_fx[0] = Mpy_32_16_lc3plus(L_tmp, preemp[0]); move32(); + d3_fx_exp[0] = add(d2_fx_exp, preemp_e[0]); move16(); FOR (i = 1; i < n_bands - 1; i++) { L_tmp = L_add(L_shr_pos(d2_fx[i], 1), L_add(L_shr_pos(d2_fx[i - 1], 2), L_shr_pos(d2_fx[i + 1], 2))); - d3_fx[i] = Mpy_32_16_lc3plus(L_tmp, lpc_pre_emphasis[fs_idx][i]); move32(); - d3_fx_exp[i] = add(d2_fx_exp, lpc_pre_emphasis_e[fs_idx][i]); move16(); + d3_fx[i] = Mpy_32_16_lc3plus(L_tmp, preemp[i]); move32(); + d3_fx_exp[i] = add(d2_fx_exp, preemp_e[i]); move16(); } L_tmp = L_add(Mpy_32_16_lc3plus(d2_fx[n_bands - 1], 24576), L_shr_pos(d2_fx[n_bands - 2], 2)); - d3_fx[n_bands - 1] = Mpy_32_16_lc3plus(L_tmp, lpc_pre_emphasis[fs_idx][n_bands - 1]); move32(); - d3_fx_exp[n_bands - 1] = add(d2_fx_exp, lpc_pre_emphasis_e[fs_idx][n_bands - 1]); move16(); + d3_fx[n_bands - 1] = Mpy_32_16_lc3plus(L_tmp, preemp[n_bands - 1]); move32(); + d3_fx_exp[n_bands - 1] = add(d2_fx_exp, preemp_e[n_bands - 1]); move16(); /* Mean */ s = d3_fx_exp[MAX_BANDS_NUMBER - 1]; @@ -86,9 +262,161 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor L_mean = L_add(L_mean, L_shr(d3_fx[i], sub(s2, d3_fx_exp[i]))); } - /* Noise floor at -40dB */ +#ifdef FIX_SNS_BASOP_MEAN64_CALC + IF(frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + /* improved precision in mean64 accumulation will increase minimum SNR vs FLT by 15 dB */ + Word16 max_loc = sns_compute_mean64_ip(&d3_fx[0], &d3_fx_exp[0], &L_mean_ip, &mean_ip_exp, &L_d5_fx[0], &d5_fx_exp[0]); /*ToDo::inplace update d3_fx, d3_fx_exp */ + /* high precision accumluation , divides all entries in d_fx by 1/64 */ + UNUSED(max_loc); + +#ifdef ER_DEBUG + //float mean64new_fx_fl = (((double)L_mean_ip))*pow(2.0, (double)mean_ip_exp - 31); + Word16 d3_max_log2 = BASOP_Util_Log2_16(d3_fx[max_loc], d3_fx_exp[max_loc]); + double d3_maxlog2_dbl = (double)d3_max_log2 / 512.0; + UNUSED(d3_maxlog2_dbl); +#endif + +#ifdef ER_DEBUG + if (d3_fx[max_loc] != 0) /* max_loc is -1 when not debugging */ +#endif + { /* maximize the q in the coming log2 function call */ + + basop_memcpy(d3_fx, L_d5_fx, 64 * sizeof(Word32)); /* use upscaled mantissa values */ + + basop_memcpy(d3_fx_exp, d5_fx_exp, 64 * sizeof(Word16)); /* use corresponding exponents values */ + +#ifdef ER_DEBUG + /* s,s2 are no longer valid in relation to the previous d3_fx */ + s = d3_fx_exp[max_loc]; + s2 = add(s, 6); /* div by 64 */ + + /* debug:: redo L_mean calc using new s, s2 and upscaled mantissa parameters */ + tmp = s_min(31, sub(s2, d3_fx_exp[0])); + L_mean = L_shr_pos(d3_fx[0], tmp); + FOR(i = 1; i < MAX_BANDS_NUMBER; i++) + { + tmp = s_min(31, sub(s2, d3_fx_exp[i])); + L_mean = L_add(L_mean, L_shr_pos(d3_fx[i], tmp)); + } +#endif + } + } +#endif + +#ifdef ER_DEBUG + if ((dbgflag("r") || dbgflag("ru")) && scratch->max_scratch_calculation_only == 0) + { + double sns64_fx_fl_all[64]; + double sns64_fx_fl_all_log2[64]; /* find range of smoothed input signal */ + + double sns64_fx_fl_opt_all[64]; + double sns64_fx_fl_opt_all_log2[64]; /* find range of smoothed input signal */ + + Word32 d3_opt_fx[64]; + Word16 d3_opt_fx_exp[64]; + float fl_mean64, fl_mean64_m, fl_mean64_e; + float L_mean_fx_fl; + float fl_mean64_recalc; + + UNUSED(sns64_fx_fl_opt_all); + UNUSED(sns64_fx_fl_opt_all_log2); + UNUSED(sns64_fx_fl_all_log2); + UNUSED(sns64_fx_fl_all); + + + UNUSED(fl_mean64_m); + UNUSED(fl_mean64_e); + + dbgread(&fl_mean64, sizeof(fl_mean64), 1, "..//..//..//fl_x_mean64.float.1.dat"); + +#ifdef FIX_SNS_BASOP_MEAN64_CALC + float mean64new_fx_fl = (((double)L_mean_ip))*pow(2.0, (double)mean_ip_exp - 31); + + snr_diff(&mean64new_fx_fl, &fl_mean64, 1, 0, "SNRc4b_x_mean64ip_FXvsFL"); + +#endif + + fl_mean64_e = s; + fl_mean64_m = fl_mean64 * pow(2.0, 31.0 -(double)fl_mean64_e ); + + + fl_mean64_recalc = 0.0; + for (int i = 0; i < 64; i++) + { + sns64_fx_fl_all[i] = (double)d3_fx[i] * pow(2.0, (double)d3_fx_exp[i] - 31.0); + sns64_fx_fl_all_log2[i] = log2(sns64_fx_fl_all[i]); + fl_mean64_recalc += sns64_fx_fl_all[i]; + + int tmp_up = norm_l(d3_fx[i]); + d3_opt_fx[i] = L_shl_pos(d3_fx[i], tmp_up); + d3_opt_fx_exp[i] = sub(d3_fx_exp[i], tmp_up); + + sns64_fx_fl_opt_all[i] = (double)d3_opt_fx[i] * pow(2.0, (double)d3_opt_fx_exp[i] - 31.0); + sns64_fx_fl_opt_all_log2[i] = log2(sns64_fx_fl_all[i]); + } + + + + fl_mean64_recalc /= 64.0; /* downscaling by 1/64 already applied */ + + L_mean_fx_fl = (((double)L_mean))*pow(2.0, (double)s - 31.0); + snr_diff(&L_mean_fx_fl, &fl_mean64, 1, 0, "SNRc4b_x_mean64_FXvsFL"); + + snr_diff(&fl_mean64_recalc, &fl_mean64, 1, 0, "SNRc4b_x_mean64recalc_FXvsFL"); /* 15 dB better !! */ + + + if (dbgflag("ru")) + { +#ifdef FIX_SNS_BASOP_MEAN64_CALC + L_mean = round(fl_mean64*pow(2.0, 31 - mean_ip_exp)); + assert(fabs(fl_mean64*pow(2.0, 31 - mean_ip_exp)) <= (double)INT32_MAX); +#else + L_mean = round(fl_mean64*pow(2.0, 31 - s)); + assert(fabs(fl_mean64*pow(2.0, 31 - s)) <= (double)INT32_MAX); +#endif + + } + } +#endif + +#ifdef FIX_SNS_BASOP_NF_APPL + IF(frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { +#ifdef ER_DEBUG + Word16 nf_post = BASOP_Util_Log2_16(L_mean_ip, mean_ip_exp); + nf_post = sub(s_max(nf_post, -25965), 6803); /* log2(-25965)- log2(6803) --> -50.7 -13.28 => -64.00 in Q9 */ + /*if nf > -50.7 nf is applied by subtracting 2^-13.28 9996 */ +#endif + + /* calulate the nf level in W32 before going to the less exact log2() W16 domain */ + Word16 tmp_nf = norm_l(L_mean_ip); + Word32 L_nf_fx = L_shl_pos(L_mean_ip, tmp_nf); /* shift up 1/64 to maximize mantissa */ + + L_nf_fx = Mpy_32_16_lc3plus(L_nf_fx, 26844); /* 26844=round(2^13/10000) */ + Word16 nf_fx_exp = sub(mean_ip_exp, add(13, tmp_nf)); /* division by 10000.0 as L_mant = L_mant*(2^13/10000), nf_exp=mean_exp-13 */ + + nf = BASOP_Util_Log2_16(L_nf_fx, nf_fx_exp); /* log2_16 function ouput is in Q9 , range is values [-64.xxx to 63.xxxx] */ + +#ifdef ER_DEBUG + /* all zero input will get nf of -32768 */ + if (L_mean_ip == 0) + { + assert(nf == -32768); + } +#endif + + } + ELSE + { /* 2.5ms ... 10ms (nf is at approximated at 1/9998 below mean) */ + nf = BASOP_Util_Log2_16(L_mean, s); + nf = sub(s_max(nf, -25965), 6803); + } +#else nf = BASOP_Util_Log2_16(L_mean, s); nf = sub(s_max(nf, -25965), 6803); +#endif + /* Log-domain */ FOR (i = 0; i < MAX_BANDS_NUMBER; i++) @@ -116,6 +444,13 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor L_tmp = L_mac(L_tmp, d4_fx[61], 8192); L_tmp = L_mac(L_tmp, d4_fx[62], 8192); d3_fx[M - 1] = L_mac(L_tmp, d4_fx[63], 8192); move32(); + +#if defined (CR9_C_ADD_1p25MS) + /* limit shaping */ + IF (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) { + limiterGain = limitShaping(d3_fx); + } +#endif /* Remove mean and scaling */ L_mean = L_shr_pos(d3_fx[0], 4); @@ -124,15 +459,99 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor L_mean = L_add(L_mean, L_shr_pos(d3_fx[i], 4)); } +#ifdef FIX_SNS_BASOP_MEAN16_APPLY + Word16 limGainDamping = 0; + Word16 up_shift = 0, dn_shift = 0; + + IF(frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { + up_shift = 31; move16(); + + FOR(i = 0; i < M; i++) + { + L_tmp = L_sub(d3_fx[i], L_mean); + up_shift = s_min(norm_l(L_tmp), up_shift); + d3_fx[i + M] = L_tmp; move32(); /* store mean removed variable */ + } + dn_shift = s_max(0, sub(up_shift, 1)); /* conditional downshift from q10 to Q11, to maintain precision */ + + limGainDamping = round_fx(Mpy_32_16_lc3plus(limiterGain, sns_damping)); + } +#endif + FOR (i = 0; i < M; i++) { +#if defined (CR9_C_ADD_1p25MS) + if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) + { +#ifdef FIX_SNS_BASOP_MEAN16_APPLY + /* maximize precision */ + L_tmp = Mpy_32_16_lc3plus(L_shl_pos(d3_fx[i + M], up_shift), limGainDamping ); + scf[i] = round_fx(L_shr_pos(L_tmp, dn_shift)); +#else + scf[i] = mult_r(extract_h(Mpy_32_16_lc3plus(limiterGain, sns_damping)), round_fx(L_shl_pos(L_sub(d3_fx[i], L_mean), 1))); +#endif + move16(); + } else { + scf[i] = mult_r(sns_damping, round_fx(L_shl_pos(L_sub(d3_fx[i], L_mean), 1))); + move16(); + } +#else scf[i] = mult_r(sns_damping, round_fx(L_shl_pos(L_sub(d3_fx[i], L_mean), 1))); move16(); +#endif } /* scale factor smoothing */ + #ifdef CR9_C_ADD_1p25MS_LRSNS + test(); test(); + IF( (scf_smoothing_enabled != 0 ) || (sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) ) + #else IF (scf_smoothing_enabled) + #endif { + #ifdef CR9_C_ADD_1p25MS_LRSNS + IF(sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + +#define A0Q15 6144 /* 0.1875 */ +#define A1Q15 (32768 - 2 * A0Q15) /* 0.675 */ +#define A2Q15 A0Q15 /* 0.1875 */ + + L_tmp = L_mult0(scf[0], A0Q15 >> 1); + L_tmp = L_mac0(L_tmp, scf[1], A0Q15 >> 1);/*incl a mult by 0.5)*/ /* a virtual scf[-1]*.1875 created */ + L_tmp = L_mac0(L_tmp, scf[0], A1Q15); /*scf[0] * .675 */ + L_tmp = L_mac0(L_tmp, scf[1], A2Q15); /*scf[1] * .1875 */ + L_tmp = L_add(L_tmp, L_tmp); /* added to realize one upshift due to margin created by mac0 */ + + scf_smooth[0] = round_fx(L_tmp); + L_mean = L_deposit_l(scf_smooth[0]); + + FOR(i = 1; i < M - 1; i++) + { /* normal unity gain three tap FIR filter */ + L_tmp = L_mult0(scf[i - 1], A0Q15); /*Q(11+16+1) Q26 */ + L_tmp = L_mac0(L_tmp, scf[i], A1Q15); + L_tmp = L_mac0(L_tmp, scf[i + 1], A2Q15); + L_tmp = L_add(L_tmp, L_tmp); /* added to realize one upshift due to margin created by mac0 */ + scf_smooth[i] = round_fx(L_tmp); /* back to Q11 */ + L_mean = L_add(L_mean, L_deposit_l(scf_smooth[i])); /* mean accumulated on the low side */ + } + + /* final coeff */ + L_tmp = L_mult0(scf[M - 2], A2Q15); /* .1875*/ + L_tmp = L_mac0(L_tmp, scf[M - 1], A1Q15); /* .675 */ + L_tmp = L_mac0(L_tmp, scf[M - 2], A0Q15 >> 1); /* now the final virtual scf[M]*.1875 */ + L_tmp = L_mac0(L_tmp, scf[M - 1], A0Q15 >> 1); + L_tmp = L_add(L_tmp, L_tmp); /* added to realize one upshift due to margin created by mac0 */ + scf_smooth[M - 1] = round_fx(L_tmp); + + L_mean = L_add(L_mean, L_deposit_l(scf_smooth[M - 1])); + + L_mean = L_shr(L_add(L_mean, 1L << (4 - 1)), 4); /* excplicit rounding in the 1/M = 0.1625 application */ + } + ELSE IF(sub(scf_smoothing_enabled, 1) == 0) + { /* legacy smoothing logic */ +#endif scf_smooth[0] = L_shr(L_mult0(L_add(L_add(scf[0], scf[1]), scf[2]), 10923), 15); L_mean = scf_smooth[0]; move16(); scf_smooth[1] = L_shr(L_add(L_add(L_add(scf[0], scf[1]), scf[2]), scf[3]), 2); @@ -154,11 +573,35 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor L_mean = L_add(L_mean, scf_smooth[M - 1]); L_mean = L_shr(L_mean, 4); + + #ifdef CR9_C_ADD_1p25MS_LRSNS + } + #endif + + #ifdef CR9_C_ADD_1p25MS_LRSNS + IF(sub(frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) + { + ASSERT(L_mean <= 32767L && L_mean >= -32768L); + Word16 mean = extract_l(L_mean); + FOR(i = 0; i < M; i++) + { + scf[i] = sub(scf_smooth[i], mean); /* only mean subtraction required, no damping/scaling */ + } + } + ELSE + { + FOR(i = 0; i < M; i++) + { + scf[i] = mult_r(attdec_damping_factor, sub(scf_smooth[i], L_mean)); + } + } +#else FOR (i = 0; i < M; i++) { scf[i] = mult_r(attdec_damping_factor, sub(scf_smooth[i], L_mean)); } + #endif } Dyn_Mem_Deluxe_Out(); diff --git a/lib_lc3plus/sns_interpolate_scf_fx.c b/lib_lc3plus/sns_interpolate_scf_fx.c index 65e4b1c16..89718af52 100644 --- a/lib_lc3plus/sns_interpolate_scf_fx.c +++ b/lib_lc3plus/sns_interpolate_scf_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" void processSnsInterpolateScf_fx( diff --git a/lib_lc3plus/sns_quantize_scf_fx.c b/lib_lc3plus/sns_quantize_scf_fx.c index baa33a1c1..d16a90b34 100644 --- a/lib_lc3plus/sns_quantize_scf_fx.c +++ b/lib_lc3plus/sns_quantize_scf_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,7 +7,14 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" +#include "defines.h" #include "functions.h" +#ifdef CR9_C_ADD_1p25MS_LRSNS +#include "constants.h" +#include /* req for INT32_MAX in msvc */ +#endif static Word16 stage1_base( /* o : idx */ const Word16 *t, /* i : target SCFs */ @@ -361,7 +368,7 @@ static void pvq_enc_find_best_submode_pre_post_fx( /* start actual search loop */ /* basic raw MSE loop, */ - L_mse_min = INT32_MAX; move32(); + L_mse_min = INT_MAX; move32(); L_idx = L_deposit_l(-1); /* section in low 2 bits* gain idx above */ FOR (L_section = 0; L_section < N_SCF_SHAPES_ST2; L_section++) @@ -832,3 +839,1229 @@ Word16 processSnsQuantizeScfDecoder_fx( /* return BER_flag; } +#ifdef CR9_C_ADD_1p25MS_LRSNS +Word16 snsQuantScfDecLR_fx(Word32* L_sns_vq_idx_fx, + Word32* L_scf_q_fx, /* o: Q26 */ + Word16* scf_q_fx, /* o: Q11 */ + Word16 pitch_rx_fx, Word16 ltpf_rx_fx, Word8 * scratch) +{ + + + + Dyn_Mem_Deluxe_In( + Counter i; + Word32 L_mPVQ_ind_fx; /* can be up to 17 bits */ + Word16 shape_idx_fx, gain_idx_fx, cb_idx_fx, aux_idx_fx, LS_ind_fx; + Word16 env_ind_fx, shift_ind_fx, sign_ind_fx, n_signs_fx; + + Word16 *Y_shape_j_fx; /* Q0 */ + Word16 *Xq_shape_j_fx; /* Q14 */ + Word32 *L_Xq_shape_j_fx; + const Word16 *cb_fx; + Word16 * st1_scf_q_fx; + Word16 CBCmeanp_ind_fx; + const Word16 *gainTab_fx; + Word16 gainValQ12_fx; + Word16 BER_dec; + Word32 L_y_en, L_norm_factor; + Word16 norm_factorQ, y_upshift; + ); + + st1_scf_q_fx = (Word16*)scratchAlign(scratch, 0); + Y_shape_j_fx = (Word16*)scratchAlign(st1_scf_q_fx, sizeof(*st1_scf_q_fx) * M); /*1*16*/ + L_Xq_shape_j_fx = (Word32*)scratchAlign(Y_shape_j_fx, sizeof(*Y_shape_j_fx) * M); /*1*16*/ + Xq_shape_j_fx = (Word16*)scratchAlign(L_Xq_shape_j_fx, sizeof(*L_Xq_shape_j_fx) * M); /*1*16*/ + /*1*16*/ + +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY + UNUSED(ltpf_rx_fx); +#endif + BER_dec = 0; /* no BER detected in PVQ indeces */ + basop_memset(Y_shape_j_fx, 0, sizeof(Word16) * M); + + gainTab_fx = lrsns_vq_gainsQ12_fx[0]; move16(); /* gcc warning init */ + gain_idx_fx = 0; move16();/* gcc warning init */ + shift_ind_fx = 0; move16(); + env_ind_fx = 0; move16(); + + /* get indices from dec_entropy_dx */ + cb_idx_fx = extract_l(L_sns_vq_idx_fx[0]); move16(); /* stage1 idx */ + aux_idx_fx = extract_l(L_sns_vq_idx_fx[1]); move16(); /* mPVQ LS-bit or the FESS s0 bit */ + shape_idx_fx = extract_l(L_sns_vq_idx_fx[2]); move16(); /* analysis order shape idx -9,-10 0,1, 2,3,4,5 */ + gain_idx_fx = extract_l(L_sns_vq_idx_fx[3]); move16(); /* stage 2 gain index */ + + /* Stage1 cand */ + IF(sub(shape_idx_fx, -9) == 0) + { + /* minimal 2*16 SNS codebook, no DC */ + cb_fx = lrsns_cbA_fx; /* ptr init */ + basop_memcpy(scf_q_fx, &(cb_fx[shl_pos(cb_idx_fx, 4)]), sizeof(Word16) * M); /* cb_idx_fx * M */ + } + ELSE IF(sub(shape_idx_fx, -10) == 0) + { /* 0..339 */ /* stage 1B or 1C only, transmitted in 9+1= 10 bits */ + IF(sub(cb_idx_fx, 170) < 0) + { /* Stage 1B */ + snslr_st1B_vector_dec_fx(cb_idx_fx, st1SCF0_7_base5_32x8_Q11, st1SCF8_15_base5_32x8_Q11, + lrsns_st1B_merged170orderSortedSegmCum_fx, lrsns_st1B_merged170orderSort12bitIdx_fx, scf_q_fx); + + snslr_remove_st1_DC_fQ11_fx(scf_q_fx, M); + } + ELSE + { + cb_idx_fx = sub(cb_idx_fx, 170); + /* Stage 1C harmonic outlier CB with pitch dependent mean vector */ + /* Q11 values , so that BASOP and float is always BE in synthesis*/ + ASSERT(cb_idx_fx >= 0 && cb_idx_fx < 170); + + snslr_st1C_vector_dec_fx(cb_idx_fx, lrsns_st1C_Both_Word8_fx, lrsns_st1C_Both_scaleQ4_7p4bits_fx[1], + lrsns_st1C_Both_inv_scaleQ15_7p4bits_fx[1], M, 170, scf_q_fx); + /* add harmonic mean , based on pitch_info availability */ + + pitch_rx_fx = extract_l(L_sns_vq_idx_fx[3]); /* LTP active flag directly from dec_entropy */ +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY + ltpf_rx_fx = 0; /* CB_C has no dependency on LTPF active flag */ +#else + ltpf_rx_fx = extract_l(L_sns_vq_idx_fx[4]); /* LTPF active flag directly from dec_entropy */ +#endif + CBCmeanp_ind_fx = pitch_rx_fx; move16(); /* 0 or 1 */ +#ifndef LRSNS_CBC_NO_LTPF_DEPENDENCY + test(); test(); test(); + if (pitch_rx_fx != 0 && ltpf_rx_fx != 0) + { + CBCmeanp_ind_fx = add(CBCmeanp_ind_fx, 1); /* high corr ltpf_rx is also active */ + } +#endif + const Word16 *mean_cb_fx = lrsns_st1CTrainedMapMeans_fx[CBCmeanp_ind_fx]; /* point to pitch dependent mean */ + for (i = 0; i < M; i++) + { + scf_q_fx[i] = add(scf_q_fx[i], mean_cb_fx[i]); + } + /* remove_DC() call is not required for section C */ + } + } + ELSE + { /* 0..169 */ /* st1B* used with a stage 2 shape submode */ + ASSERT(shape_idx_fx >= 0 && shape_idx_fx <= 5); + snslr_st1B_vector_dec_fx(cb_idx_fx, st1SCF0_7_base5_32x8_Q11, st1SCF8_15_base5_32x8_Q11, lrsns_st1B_merged170orderSortedSegmCum_fx, lrsns_st1B_merged170orderSort12bitIdx_fx, scf_q_fx); + snslr_remove_st1_DC_fQ11_fx(scf_q_fx, M); /* inplace */ /* DC needs removal for st1 part B */ + } + + basop_memcpy(st1_scf_q_fx, scf_q_fx, sizeof(Word16) * M); /* keep track of stage1 (A,B or C) contribution */ + + IF(shape_idx_fx >= 0) /* stage 2 shapes 0,1, 2,3,4,5 ( negative idx used for stage1 only */ + { + /* stage 2 SNS VQ decoding */ + /* Decode shape_j */ + Y_shape_j_fx[0] = 0; /* no DCT-II DC-coeff decoded */ + + SWITCH(shape_idx_fx) + { + case 0: /* splitLF 29 bits total */ + LS_ind_fx = aux_idx_fx; move16(); + L_mPVQ_ind_fx = L_sns_vq_idx_fx[4]; move32(); /* mPVQ(5,6) or mPVQ(5,8) */ + + test(); + IF(L_sns_vq_idx_fx[5] >= 0) + { + /* CFLT: MPVQdeenum_fx(5, 6, LS_ind_fx, L_mPVQ_ind_fx, &Y_shape_j_fx[1]); */ + BER_dec = pvq_dec_deidx_fx(&Y_shape_j_fx[1], PULSES_SPLIT_A_LR, NA_LR, LS_ind_fx, (UWord32)L_mPVQ_ind_fx); + + LS_ind_fx = extract_l(L_and(L_sns_vq_idx_fx[5], 0x1)); + L_mPVQ_ind_fx = L_shr_pos(L_sns_vq_idx_fx[5], 1); + + /* CFLT: MPVQdeenum_fx(8, 2, LS_ind_fx, L_mPVQ_ind_fx, &Y_shape_j_fx[1 + 5]); */ + BER_dec = s_or(BER_dec, pvq_dec_deidx_fx(&Y_shape_j_fx[1 + NA_LR], PULSES_SPLIT_B_LR, NB_LR, LS_ind_fx, (UWord32)L_mPVQ_ind_fx)); + } + ELSE + { + /* CFLT: MPVQdeenum_fx(5, 8, LS_ind_fx, L_mPVQ_ind_fx, &Y_shape_j_fx[1]); */ + BER_dec = pvq_dec_deidx_fx(&Y_shape_j_fx[1], (PULSES_SPLIT_A_LR + PULSES_SPLIT_B_LR), NA_LR, LS_ind_fx, (UWord32)L_mPVQ_ind_fx); + } + gainTab_fx = lrsns_vq_gainsQ12_fx[0]; move32(); /* 4 levels in 2 bits */ + break; + case 1: /* full (N=15,K=5) 30 bits total */ + LS_ind_fx = aux_idx_fx; move16(); + L_mPVQ_ind_fx = L_sns_vq_idx_fx[4]; move32(); + + /* CFLT: MPVQdeenum_fx(15, 5, LS_ind_fx, L_mPVQ_ind_fx, &Y_shape_j_fx[1]); */ + BER_dec = pvq_dec_deidx_fx(&Y_shape_j_fx[1], PULSES_FULL_LR, NFULL_LR, LS_ind_fx, (UWord32)L_mPVQ_ind_fx); + gainTab_fx = lrsns_vq_gainsQ12_fx[1]; move16(); /* 8 levels in 3 bits */ + + break; + case 2: /* fix env 0 , init_bell 12 signs */ + case 3: /* fix env 1 , decay 12-->6 12 signs */ + case 4: /* fix env 2 , start bell 12 signs */ + case 5: /* fix env 3 , early bell 10 signs */ + LS_ind_fx = aux_idx_fx; /* s0 */ move16(); + env_ind_fx = extract_l(L_sns_vq_idx_fx[4]); move16(); + ASSERT(env_ind_fx == (shape_idx_fx - 2)); + Word16 sign_mask_fx = 0x07ff; move16(); /* mask for 11 remaining signs */ + n_signs_fx = NSIGNS_FIX_012; move16(); /* number of signs including s0 */ + if (sub(env_ind_fx, 3) == 0) + { + n_signs_fx = NSIGNS_FIX_3; move16(); + } + sign_mask_fx = shr_pos_pos(sign_mask_fx, sub(NSIGNS_FIX_012, n_signs_fx)); + + shift_ind_fx = extract_l(L_shr_pos(L_sns_vq_idx_fx[5], sub(n_signs_fx, 1))); + sign_ind_fx = s_and(extract_l(L_sns_vq_idx_fx[5]), sign_mask_fx); + + /* put sign s0 , right next to s1 , to make the subsequent sign decoding loop straight fwd */ + sign_ind_fx = add(shl_pos(LS_ind_fx, sub(n_signs_fx, 1)), sign_ind_fx); /* s0 put as MSB at 12th position */ + + /*FixEnvShiftedSigns deenumeration */ + /* part of 30b total, 4xenv,4xshifts, 10 or12 signs , spread over 15 positions,*/ + FESSdeenum_fx(NFULL_LR, N_CANDS_FIX_LR, N_SHIFT_FIX, n_signs_fx, env_ind_fx, shift_ind_fx, sign_ind_fx, &Y_shape_j_fx[1]); + + gainTab_fx = lrsns_vq_gainsQ12_fx[2]; move16(); /* 8 levels in 3 bits */ + /* fix_envshift_nb_fx = env_ind_fx * 4 + shift_ind_fx; */ /* index for fast normalization lookup */ + break; + default: + ASSERT(0 && " LRSNS stage2 demux bad shape shape_idx_fx received from dec_entropy_fx "); + break; + } + + gainValQ12_fx = gainTab_fx[gain_idx_fx]; + + + /* enc/dec common Word32Q30 and Word16Q14 Unit energy normalization of the received shapes mPVQ or FESS */ + IF(sub(shape_idx_fx, 2) < 0) + { /* 0,1,2 :: PVQ(N,K) shape with up to 8 unit pulses */ + L_y_en = L_deposit_l(0); + FOR(i = 1; i < M; i++) + { + L_y_en = L_mac0(L_y_en, Y_shape_j_fx[i], Y_shape_j_fx[i]); + } + L_norm_factor = isqrt_Q31tab[L_y_en]; move32(); /* Q31 inv_sqrt value */ + norm_factorQ = lrsns_norm_factorQ_L[shape_idx_fx]; move16(); + y_upshift = lrsns_y_up_bits[shape_idx_fx]; move16(); + } + ELSE + { /* 2,3,4,5 :: FESS shapes with up to unit pulses */ + /* no energy calc required, only 16 different energies are possible */ + L_norm_factor = L_lrsns_fixenv_enNormQ35[add(shl_pos(env_ind_fx , 2), shift_ind_fx)]; move32(); /* Q19+16=Q35 */ + norm_factorQ = lrsns_norm_factorQ_L[2]; move16(); + y_upshift = lrsns_y_up_bits[2]; move16(); + } + + /* reuse common encoder/decoder unit energy normalization routine */ + ASSERT(Y_shape_j_fx[0] == 0); + pvq_fess_dec_en1_normQ30andQ14_fx(Y_shape_j_fx, y_upshift, L_norm_factor, norm_factorQ, M, L_Xq_shape_j_fx, Xq_shape_j_fx); + ASSERT(L_Xq_shape_j_fx[0] == 0 && Xq_shape_j_fx[0] == 0); + + /* Reconstruction of the quantized SNS scale factors */ +#ifdef ENABLE_HR_MODE + L_Xq_shape_j_fx[0] = 0; move32(); /* enforce no DC */ + idct32_32_fx(L_Xq_shape_j_fx, L_Xq_shape_j_fx); /* inplace idct */ + + /* move stage1 W16Q11 to W32Q27 */ + FOR(i = 0; i < M; i++) + { + L_scf_q_fx[i] = L_deposit_h(st1_scf_q_fx[i]); move32();/* stage1 W16Q11 to W32Q27 */ + } + lrsns_pvq_dec_scale_W32vec_fx(L_Xq_shape_j_fx, gainValQ12_fx, L_scf_q_fx /* W32Q27 in, W32Q26 out */, scf_q_fx /* out Q11*/); + +#else + /* DISABLE_HR */ + Xq_shape_j_fx[0] = 0; move16(); /* no DC */ + idct16_fx(Xq_shape_j_fx, Xq_shape_j_fx); /* inplace idct */ /* fwd in unscaled unit energy domain */ + + /* move stage1B into a W16 vector for accumulation in Q11 */ + basop_memcpy(scf_q_fx, st1_scf_q_fx, sizeof(*scf_q_fx)*M); + + /* scf_q_fx contains stage1 in Q11 */ + lrsns_pvq_dec_scale_W16vec_fx(Xq_shape_j_fx/* Q14 */, gainValQ12_fx, scf_q_fx /* Q11in, Q11out */); + + /* scf_q_fx is the final result incl. stage2 in Q11 */ +#endif /* DISABLE_HR */ + + } + ELSE + { /* -9, -10 */ + /* LRSNS stage 1 A,B,C */ + basop_memcpy(scf_q_fx, st1_scf_q_fx, sizeof(Word16) * M); /* Q11*/ + + FOR(i = 0; i < M; i++) + { + L_scf_q_fx[i] = L_shr_pos(L_deposit_h(scf_q_fx[i]), 1); /* 11+16-1 => Q26 */ + } + } + Dyn_Mem_Deluxe_Out(); + + return BER_dec; +} + +/* split out of LRSNS stage 1 functionality */ +Word32 snsQuantScfEncLRSt1ABC_fx(Word16* env, Word32* L_index, Word32 *L_min_mse_saveBCA_ptr_fx, + Word16* ind_saveB_ptr, Word16* st1_vectors, + Word16 pitch_rx, Word16 ltpf_rx, Word8 * scratch) +{ + + Dyn_Mem_Deluxe_In( + Counter i; + Word16 *st1_vector_fx, *st1_vectorA_fx, *st1_vectorB_fx, *st1_vectorC_fx, *target_fx; + Word32 L_min_mse_saveA_fx, L_min_mse_saveB_fx, L_min_mse_saveC_fx, L_min_mse_saveBC_fx; + Word16 ind_saveA_fx, ind_saveC_fx; + Word16 meanC_ind; + Word16 stage1_mode; /*0=A, 1=B, 2=C. -1==fail*/ + Word32 L_min_mse_saveB_fxlike_fx; + Word16 ind_saveB_fxlike_fx; + Word16 dc_fx; + Word32 L_tmp; + Word16 *st1_vectorB_idx_fx; + ); + + stage1_mode = -1; /* output */ + + st1_vectorB_idx_fx = scratchAlign(scratch, 0); + target_fx = scratchAlign(scratch, sizeof(*st1_vectorB_idx_fx) * M); + +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY + UNUSED(ltpf_rx); +#endif + st1_vectorA_fx = &(st1_vectors[0]); + st1_vectorB_fx = &(st1_vectors[1 * M]); + st1_vectorC_fx = &(st1_vectors[2 * M]); + st1_vector_fx = &(st1_vectors[3 * M]); /*selected winner */ + +#ifdef WMOPS + push_wmops("snsQuantScfEncLRSt1ABC_fx"); +#endif + + /* snslr stage1 B(170) and C(170), A(2) evaluation */ + /* + segm idx9b + + ------+--------+--------+------- + B | 0--169 | aux==0 , 170 entries + ------+--------+-------- + C | 170-339| aux==1 , 170 entries, + ------+--------+--------+ + * | 341-509| aux==2 , 170 entries (later decided to be B + aux bit) + ------+--------+--------- + A | 510,511| 2 entries, 9 bit total + ------+--------+-------- + */ +#ifdef WMOPS + push_wmops("MSEsearchCbA_fx"); +#endif + + + { /* stage 1 section A(2), a very small 2xM entry cb */ + /* two crude vector MSE_calculations needed */ + + basop_memcpy(target_fx, env, sizeof(Word16)*M); + + ind_saveA_fx = MSEsearchGeneric_fx(target_fx, lrsns_cbA_fx, M, 2, &L_min_mse_saveA_fx); + + basop_memcpy(st1_vectorA_fx, &(lrsns_cbA_fx[ind_saveA_fx*M]), sizeof(Word16)*M); + } +#ifdef WMOPS + pop_wmops(); +#endif + + +#ifdef WMOPS + push_wmops("MSEsearchCbB_fx"); +#endif + { /* stage1 section B(170) MSE analysis */ + basop_memcpy(target_fx, env, sizeof(Word16)*M); + *ind_saveB_ptr = -1; move16(); + + ind_saveB_fxlike_fx = MSEsearchCbBIdxMap_fx(target_fx, st1SCF0_7_base5_32x8_Q11, st1SCF8_15_base5_32x8_Q11, + lrsns_st1B_merged170orderSortedSegmCum_fx, lrsns_st1B_merged170orderSort12bitIdx_fx, M, 170, &L_min_mse_saveB_fxlike_fx); /*st1B LF,HF idx lookup search 170 ,170 Word16s , 0.34kB ROM */ + + snslr_st1B_vector_dec_fx(ind_saveB_fxlike_fx, st1SCF0_7_base5_32x8_Q11, st1SCF8_15_base5_32x8_Q11, lrsns_st1B_merged170orderSortedSegmCum_fx, lrsns_st1B_merged170orderSort12bitIdx_fx, + st1_vectorB_idx_fx); + + *ind_saveB_ptr = ind_saveB_fxlike_fx; move16(); + L_min_mse_saveB_fx = L_min_mse_saveB_fxlike_fx; move32(); + basop_memcpy(st1_vectorB_fx, st1_vectorB_idx_fx, sizeof(Word16)*M); /*use low ROM version */ + + { + /* remove the DC that can remain in the LF,HF index stored stage cbB structure */ + /* a very slight off-line decrease in perf 0.001 dB in AveSD when searching with DC above, + but it allows much better stage1 ROM-reuse performance */ + + dc_fx = snslr_remove_st1_DC_fQ11_fx(st1_vectorB_fx, M); /* in-place removal of dc in st1_vectorB */ + + ASSERT(L_min_mse_saveB_fx >= 0L); + + dc_fx = shl_pos(dc_fx, 2); /* mult dc_fx with sqrt(M) */ + L_tmp = L_msu0(L_min_mse_saveB_fx, dc_fx, dc_fx); + + /* force the MSE B to be zero or larger*/ + /* may happen due to imperfect(truncation) DC removal */ + L_min_mse_saveB_fx = L_max(L_tmp, 0L); + } + } /* end of stage 1 section B , search */ +#ifdef WMOPS + pop_wmops(); +#endif + +#ifdef WMOPS + push_wmops("MSEsearchCbC_fx"); +#endif + meanC_ind = pitch_rx; move16(); +#ifndef LRSNS_CBC_NO_LTPF_DEPENDENCY + if (ltpf_rx != 0) + { + meanC_ind = add(meanC_ind, 1); + } +#else + /* CbC only dependent on LTP transmission on/off */ +#endif + Word32 L_mse_tmpQ22 = L_min(Mpy_32_16_lc3plus(L_min_mse_saveA_fx, SNSLR_A_CNST_WEIGHT), L_min_mse_saveB_fx); + + /* apply skipC threshold of 3.97 in Q22 */ + IF(L_sub(L_mse_tmpQ22, 16651387L) < 0) /* to skip C search if SD is already low enough < 1.5dB (msesum=3.97)) to save average WMOPS */ + { + /* search stage1C */ /* made adaptive on stage1 BA MSE sofar */ + L_min_mse_saveC_fx = (23404216L << 1); move32();/* disable C selection in consecutive logic */ + ind_saveC_fx = 0; move16();/* a valid index that will not be used */ + } + ELSE + { + /* search another set (pitch dependent section C) of 170 mean residual vectors */ + /* pitch_info rx used to selects a mean and then a trained residual 1x170W8 based harmonic outlier table */ + /* float means were based on Word16 S16Q11 values, so that BASOP and float always may become BE in synthesis*/ + FOR(i = 0; i < M; i++) { + target_fx[i] = sub(env[i], lrsns_st1CTrainedMapMeans_fx[meanC_ind][i]); + } + + + Word32 ind_saveC_ScaledW8_fx; + Word32 L_min_mse_saveC_ScaledW8_fx; + + ind_saveC_ScaledW8_fx = MSEsearchGenericScaledW8_fx(target_fx, lrsns_st1C_Both_Word8_fx, + lrsns_st1C_Both_scaleQ4_7p4bits_fx[1], lrsns_st1C_Both_inv_scaleQ15_7p4bits_fx[1], + M, 170, &(L_min_mse_saveC_ScaledW8_fx)); + + snslr_st1C_vector_dec_fx(ind_saveC_ScaledW8_fx, lrsns_st1C_Both_Word8_fx, lrsns_st1C_Both_scaleQ4_7p4bits_fx[1], lrsns_st1C_Both_inv_scaleQ15_7p4bits_fx[1], + M, 170, + st1_vectorC_fx + ); + + ind_saveC_fx = ind_saveC_ScaledW8_fx; + L_min_mse_saveC_fx = L_min_mse_saveC_ScaledW8_fx; + + FOR(i = 0; i < M; i++) + { + st1_vectorC_fx[i] = add(st1_vectorC_fx[i], lrsns_st1CTrainedMapMeans_fx[meanC_ind][i]); /* Q11 means*/ + } + +#ifdef FIX_BASOP_ENC_LRSNS_CBC_MSE + /* CB_C MSE search loop in BASOP is using lower resolution, than and the best possible calculation */ + /* recalc CB_C MSE with Q22 precision for a best possible CB decision */ + MSEsearchGeneric_fx(env, st1_vectorC_fx, M, 1, &L_min_mse_saveC_fx); /* reuse of search to get MSE for 1 vector */ +#endif + + } +#ifdef WMOPS + pop_wmops(); +#endif + + + /* BC stage1 comparison */ + /* initially assume B as stage 1 winner */ + L_min_mse_saveBC_fx = L_min_mse_saveB_fx; move32(); + L_index[0] = L_deposit_l(*ind_saveB_ptr); /* 0...169 */ + + basop_memcpy(st1_vector_fx, st1_vectorB_fx, sizeof(Word16)*M); /* stage 1 segmentB result without DC copied as base for st2 */ + + { + IF(L_sub(L_min_mse_saveC_fx, L_min_mse_saveBC_fx) < 0) + { /* C better than B */ + L_min_mse_saveBC_fx = L_min_mse_saveC_fx; move32(); + L_index[0] = L_add(170L, L_deposit_l(ind_saveC_fx)); /* [2x 170] (9+3)b [ 0..169], [170-339] , ">=170" is a signal to multiplexor */ + basop_memcpy(st1_vector_fx, st1_vectorC_fx, sizeof(Word16)*M); + } + L_index[1] = -10; move32(); + ASSERT(L_min_mse_saveBC_fx >= 0.0); + + /* (9(A)<->10(BC) bit weighted comparison */ + *L_min_mse_saveBCA_ptr_fx = L_min_mse_saveBC_fx; move32(); + IF(L_sub(Mpy_32_16_lc3plus(L_min_mse_saveA_fx, SNSLR_A_CNST_WEIGHT), L_min_mse_saveBC_fx) < 0) /* a minor favouring of the 9b vector results sqrt(0.875) => approx 0.6dB level domain */ + { + L_index[0] = L_add(510L, L_deposit_l(ind_saveA_fx)); /* only [510,511] possible */ + L_index[1] = -9; + + basop_memcpy(st1_vectorA_fx, &(lrsns_cbA_fx[ind_saveA_fx*M]), sizeof(Word16)*M); + basop_memcpy(st1_vector_fx, st1_vectorA_fx, sizeof(Word16)*M); + + *L_min_mse_saveBCA_ptr_fx = Mpy_32_16_lc3plus(L_min_mse_saveA_fx, SNSLR_A_CNST_WEIGHT); /* Q22 */ + } + } + + /* index0_saveBCA = index[0];*/ /* 0...511 */ + /* index1_saveBCA = index[1];*/ /* -9 or -10 */ + + stage1_mode = 2; move16(); /* cbC */ + if (L_sub(L_index[0], 510L) >= 0) { + stage1_mode = 0; move16(); /* cbA */ + } + if (L_sub(L_index[0], 169L) <= 0) { + stage1_mode = 1; move16();/* cbB */ + } + +#ifdef WMOPS + pop_wmops(); +#endif + + Dyn_Mem_Deluxe_Out(); + + return stage1_mode; /* return best mode */ +} + +/* top level lrsns BASOP code calling both st1 and st2 */ +Word16 snsQuantScfEncLR_fx( /* o: bits spent on LRSNS-VQ envelope */ + Word16 scf_fx[], /* i: input scf M W16Q11 */ + Word32 *L_index_fx, /* o: SNS indeces . */ +#ifdef ENABLE_HR_MODE + Word32 *L_scf_q_fx, /* o: quantizefl_env scf M ? W32Q11 or W32Q27 */ +#else + Word16 *scf_q_fx, /* o: quantizefl_env scf M W16Q11 */ +#endif + Word16 pitch_rx_fx, /*i: 0 or 1 */ + Word16 ltpf_rx_fx, /*i: o or 1 */ + Word8 * scratch) +{ + + Dyn_Mem_Deluxe_In( + Counter col; + + Word16 *st1_vectorA_fx, *st1_vectorB_fx, *st1_vectorC_fx, *st1_vector_fx; + Word16 ind_saveB_fx; + Word16 st1_mode_fx; + Word16 envelope_bits_fx; /* output */ + Word32 L_min_mse_saveBCA_Q22_fx; + + Word16 gain_idx_fx; /* gain index 0..3, 0..7, 0..7 */ + Word16 s_idx_fx; /* shape index 0 =split, 1 = full, 2= fix*/ + Word16 shape_idx_fx; /* expanded shape index 0 ..5 */ + Word32 L_mse_st1B_st2_Q22_fx; + Word16 *y_split_fx, *y_full_fx, *y_fix_fx; + Word16 gainValQ12_fx; /* output from PVQ search */ + Word16 fixShapeNb; + Word16 fixShiftIdx; + + /* scratch ptrs */ + Word16 *st1_vectors_fx; + Word16 *target_st2_fx; + Word8 *scratch_ABC_fx; + Word32 *L_target_st2_fx; /* req. for dct32 use */ + Word16 *pvq_target_fx; + Word32 *L_pvq_target_fx; + Word16 *y_Q0; + Word16 *y_normQ14_fx; + Word32 *L_y_normQ30_fx; + Word8 *scratch_pvq_fess_fx; + ); + + +#ifdef ENABLE_HR_MODE + Word16 scf_q_fx[M]; /* W16Q11 always in use also for HR_MODE */ + UNUSED(scf_q_fx); +#endif + UNUSED(st1_mode_fx); + UNUSED(st1_vectorA_fx); + UNUSED(st1_vectorC_fx); + + st1_mode_fx = -1; move16(); + envelope_bits_fx = -1; move16(); /* output information */ + shape_idx_fx = 0; move16(); + + st1_vectors_fx = (Word16*)scratchAlign(scratch, 0); + scratch_ABC_fx = (Word8*)scratchAlign(st1_vectors_fx, sizeof(*st1_vector_fx) * M * 4); + target_st2_fx = (Word16*)scratch_ABC_fx; + L_target_st2_fx = (Word32*)scratchAlign(target_st2_fx, sizeof(*target_st2_fx) * M); + + pvq_target_fx = (Word16*)scratchAlign(L_target_st2_fx, sizeof(*L_target_st2_fx) * M); + L_pvq_target_fx = (Word32*)scratchAlign(pvq_target_fx, sizeof(*pvq_target_fx) * M); + y_Q0 = (Word16*)scratchAlign(L_pvq_target_fx, sizeof(*L_pvq_target_fx) * M); + y_normQ14_fx = (Word16*)scratchAlign(y_Q0, sizeof(*y_Q0) *SNSLR_MAX_PVQ_SEARCH_CAND*M); + L_y_normQ30_fx = (Word32*)scratchAlign(y_normQ14_fx, sizeof(*y_normQ14_fx) *SNSLR_MAX_PVQ_SEARCH_CAND*M); + scratch_pvq_fess_fx = (Word8*)scratchAlign(L_y_normQ30_fx, sizeof(*L_y_normQ30_fx) * SNSLR_MAX_PVQ_SEARCH_CAND * M ); + + y_split_fx = &(y_Q0[0 * M]); /* ptr init */ + y_full_fx = &(y_Q0[1 * M]); /* ptr init */ + y_fix_fx = &(y_Q0[2 * M]); /* ptr init */ + + st1_vectorA_fx = &(st1_vectors_fx[0]); /* ptr init */ + st1_vectorB_fx = &(st1_vectors_fx[1 * M]); + st1_vectorC_fx = &(st1_vectors_fx[2 * M]); + st1_vector_fx = &(st1_vectors_fx[3 * M]); /* best vector */ + + FOR(col = 0; col < SCF_MAX_PARAM; col++) + { + L_index_fx[col] = L_sub(-32000, col); move32(); /* safety init parameters to be fwd'ed to LRSNS VQ multiplexor */ + } + + /* Stage 1 Cb's A,B,C */ + ind_saveB_fx = -1; + L_min_mse_saveBCA_Q22_fx = M * 32 * 32; move32(); + + st1_mode_fx = snsQuantScfEncLRSt1ABC_fx( + scf_fx, L_index_fx, &L_min_mse_saveBCA_Q22_fx, &ind_saveB_fx, st1_vectors_fx, + pitch_rx_fx, ltpf_rx_fx, scratch_ABC_fx); + + Word32 L_mse_lim_smooth_Q22_fx = 22691185L; /* round(5.41*pow(2.0, 22.0))*//* 1.75 dB */ + + /* mse_st1B_st2_fl = 2.0* min_mse_saveBCA + 1.0;*/ /* safety indicate that st1B+st2 is not used by setting a higher MSE than st1BCA */ + L_mse_st1B_st2_Q22_fx = L_add(L_shl_pos(L_min_mse_saveBCA_Q22_fx, 1), (1L << 22)); /* set st1B+st2 to a safety bad MSE value */ + + + IF((L_sub(L_min_mse_saveBCA_Q22_fx, L_mse_lim_smooth_Q22_fx) > 0)) + { /* stage 2 analysis */ + /* prepare stage2 W16 target */ + FOR(col = 0; col < M; col++) + { + target_st2_fx[col] = sub(scf_fx[col], st1_vectorB_fx[col]); /* Q11 */ + } + + /* both ENABLE_HR and DISABLE_HR runs the same analysis DCT-II(16) */ + /* for analysis use 16 bit i/o Word16 constants, but Word32 internal states in DCT-II(M=16) */ + basop_memcpy(pvq_target_fx, target_st2_fx, M * sizeof(*pvq_target_fx)); + + dct16_W32int_fx(pvq_target_fx, pvq_target_fx); /* Q11 to Q11, enc-side analysis with W16 i/o internally W32 precision */ + + pvq_target_fx[0] = 0; move16(); + + /* PVQ FESS search, include norm , shape search and Q gain search */ + /* NB IDCT-II __not__ run in stage2 shape and gain search */ + pvq_fess_enc_search_fx( + pvq_target_fx, + y_Q0, + y_normQ14_fx, /* normally calculated for DISABLE_HR_MODE */ + L_y_normQ30_fx, /* calculated for both DISABLE_HR_MODE and ENABLE_HR_MODE */ + &s_idx_fx/*[0,1,2]*/, + &gain_idx_fx/* [0...7]*/, + &gainValQ12_fx, + &fixShapeNb, /* 0,1,2,3, [-1] */ + &fixShiftIdx, /* 0,1,2,3, [-1] */ + &L_mse_st1B_st2_Q22_fx, + scratch_pvq_fess_fx); + + + /* update to shape idx to one of 0...5 ] */ + shape_idx_fx = s_idx_fx; move16(); + if (sub(shape_idx_fx, 2) == 0) + { + shape_idx_fx = add(shape_idx_fx, fixShapeNb); /* [0..5] */ + } + } + ELSE + { /* indicate complete skipping of stage2 search, stage1 is good enough */ + L_mse_st1B_st2_Q22_fx = INT32_MAX; move32(); + /*copy of best stage 1 to proper output , done below */ + } + + IF(L_sub(L_mse_st1B_st2_Q22_fx, L_min_mse_saveBCA_Q22_fx) > 0) + { + /* skip IDCT, as stage2 will not be used */ + //L_mse_st1B_st2_Q22_fx = L_mse_st1B_st2_Q22_fx; /* dummy op */ + } + ELSE + { +#ifdef ENABLE_HR_MODE + /* apply IDCT-II on the Q30 unit energy normalized vector */ + Word32 L_tmp_vec_fx[M]; + Word32* L_y_norm_fx = &(L_y_normQ30_fx[s_idx_fx*M]); move32(); + + ASSERT(L_y_norm_fx[0] == 0); + /* 32x32 bit dec IDCT-II analysis, with W32 internal constants */ + idct32_32_fx(L_y_norm_fx, L_tmp_vec_fx); /* currently Q30 to Q30 , can also be inplace */ + /* idct32_32_fx:: 162.712 dBSegSNR, minSNR = 157.979, WMOPS 0.26 */ +#else + Word16 tmp_vec_fx[M]; + /* apply IDCT-II on the Q14 unit energy normalized vector */ + + Word16* y_norm_fx = &(y_normQ14_fx[s_idx_fx*M]); move32(); + ASSERT(y_norm_fx[0] == 0); + idct16_fx(y_norm_fx, tmp_vec_fx); /* idct16_fx:: segsnr 73.7 /minsnr 67.65 , 0.118 WMOPS using mult_r) */ +#endif /* HR_MODE*/ + +#ifdef ENABLE_HR_MODE + /* move stage1 W16Q11 to W32Q27 */ + FOR(col = 0; col < M; col++) + { + L_scf_q_fx[col] = L_deposit_h(st1_vectorB_fx[col]); /* W16Q11 to W32Q27 */ + } + lrsns_pvq_dec_scale_W32vec_fx(L_tmp_vec_fx, gainValQ12_fx, L_scf_q_fx /* W32Q27 in, W32Q26 out */, scf_q_fx /* W16Q11 out */); +#else + /* non HR */ + /* move stage1B into a W16 vector for accumulation in Q11 */ + basop_memcpy(scf_q_fx, st1_vectorB_fx, sizeof(*scf_q_fx)*M); + + /* scf_q_fx contains stage1 in Q11*/ + lrsns_pvq_dec_scale_W16vec_fx(tmp_vec_fx/*Q14*/, gainValQ12_fx, scf_q_fx /* Q11 */); /* scf_q_fx is the final result incl. stage2 in Q11 */ + +#endif /* ENABLE_HR_MODE */ + } + + + /* post-evaluate if one of (st1B, st1C, st1A) was actually better than st1B+stage2 */ + + IF(L_sub(L_mse_st1B_st2_Q22_fx, L_min_mse_saveBCA_Q22_fx) <= 0) + { + /* use stage1B + st2 at 29b or 30b bits total cost */ + L_index_fx[0] = L_deposit_l(ind_saveB_fx); move32(); + L_index_fx[1] = L_deposit_l(2930); move32(); /* later stage2 aux value LS_splitLF or LS_full or s0, put here as a 0 or 1 */ + L_index_fx[2] = L_deposit_l(shape_idx_fx); move32(); /* 0=splitLF, 1=full, ( 2=fixEnv0, 3=fixEnv1, 4: fixEnv2, 5: fixEnv3 ) */ + L_index_fx[3] = L_deposit_l(gain_idx_fx); move32(); /* gain idx with a shape dependent number of levels (4 or 8 levels ) */ + + basop_memcpy(st1_vector_fx, st1_vectorB_fx, sizeof(*st1_vectorB_fx)*M); + /* final result st1 in combination with stage 2, kept now for verification at decoder */ + + envelope_bits_fx = 29; move16(); /* 'LR_splitLF' bitrate */ + test(); + if (shape_idx_fx > 0) { + envelope_bits_fx = add(envelope_bits_fx, 1); /*30 'LR_full/LR_fixenv' */ + } + + { + /* DBG check values */ + ASSERT(shape_idx_fx >= 0); + ASSERT(envelope_bits_fx >= 29); + ASSERT(L_index_fx[0] <= 170); /*only B allowed */ + ASSERT(L_index_fx[1] >= 0); + + ASSERT(gain_idx_fx >= 0); /*gain index*/ + ASSERT(gainValQ12_fx > 0); /* gain value */ + } + } + ELSE + { /*stick to stage1(best of BCA) at 9 or 10 bits */ + ASSERT(L_index_fx[1] < 0 && L_index_fx[0] >= 0 && L_index_fx[0] < 512); + envelope_bits_fx = ((L_index_fx[0] >= 510) ? 9 : 10); + shape_idx_fx = -envelope_bits_fx; /* signal an invalid stage2 shape number to enc-entropy */ +#ifdef ENABLE_HR_MODE + FOR(col = 0; col < M; col++) + { + L_scf_q_fx[col] = L_shl_pos(st1_vector_fx[col], 16 - 1); move32(); /* W16Q11 to W32Q26 */ + } +#else + basop_memcpy(scf_q_fx, st1_vector_fx, M * sizeof(*scf_q_fx)); /* output */ +#endif + + gainValQ12_fx = 0; move16(); + + gain_idx_fx = -1; move16(); /* L_index sentinel */ + L_index_fx[2] = shape_idx_fx; move32(); + } + + /******************************************************************/ + /* signal to enc_entropy_fx for LRSNS semi-fractional multiplexing */ + /******************************************************************/ + /* integer multiplexing 29/30 bit modes into intermediate unmuxed integer indeces 0...7 */ + /* a bit of fractional multiplexing for the L_index_fx 0...7 is done later, in function enc_entropy_fx() */ + test(); + IF(shape_idx_fx >= 0) + { /* stage 2 multiplexing manipulations */ + Word16 fix_end_sign_fx; + + PvqEntry_fx enc_PVQ_A, enc_PVQ_B; + + test(); + IF(shape_idx_fx == 0) + { /* splitLF shape */ + Word16 n5k = 0; + FOR(col = 1; col < 6; col++) + { + n5k += abs_s(y_split_fx[col]); + } + + IF(sub(n5k, PULSES_SPLIT_A_LR) == 0) + { + /* this (6+2) pulses over NA+NB=5+8, is expected to be more frequent than 8 pulses over NA=5 */ + enc_PVQ_A = mpvq_index_fx(&(y_split_fx[1]), NA_LR, PULSES_SPLIT_A_LR); /* P(N=5,K=6) (10)=10 bit L_index */ + L_index_fx[4] = (Word32)enc_PVQ_A.index; move32(); + L_index_fx[1] = L_deposit_l(enc_PVQ_A.lead_sign_ind); /* aux bit for the splitLF path , we plant the first LS there */ + + enc_PVQ_B = mpvq_index_fx(&(y_split_fx[1 + NA_LR]), NB_LR, PULSES_SPLIT_B_LR); + L_index_fx[5] = L_mac0(L_shl_pos((Word32)enc_PVQ_B.index, 1), 1, enc_PVQ_B.lead_sign_ind); move32(); /* A full PVQ 7 bit index for the P(N=8,K=2) B config*/ + + assert(L_index_fx[5] >= 0); + } + ELSE + { + ASSERT(n5k == (PULSES_SPLIT_A_LR + PULSES_SPLIT_B_LR));/* PVQ(N=5,K=8) (12.x in total, i.e. LS+ 11.x ) */ + enc_PVQ_A = mpvq_index_fx(&(y_split_fx[1]), NA_LR, PULSES_SPLIT_A_LR + PULSES_SPLIT_B_LR); + L_index_fx[4] = (Word32)enc_PVQ_A.index; + L_index_fx[1] = L_deposit_l(enc_PVQ_A.lead_sign_ind); /* aux bit for the splitLF path , we plant the first LS there */ + L_index_fx[5] = L_deposit_l(-8); /* signal LF PVQ(5,k=8) and zeroed HF(10,0) apart */ + } + } + IF(sub(shape_idx_fx, 1) == 0) + { /* full (15,5), LS kept separated */ + enc_PVQ_A = mpvq_index_fx(&(y_full_fx[1]), NFULL_LR, PULSES_FULL_LR);/* mPVQ 16.66 bits in index[4], and LS 1 bit in index[1] */ + L_index_fx[4] = (Word32)enc_PVQ_A.index; move32(); + L_index_fx[1] = L_deposit_l(enc_PVQ_A.lead_sign_ind); + } + + IF(sub(shape_idx_fx, 2) >= 0) + { /* fixEnv0, fixEnv1, fixEnv2, fixEnv3 */ + ASSERT(shape_idx_fx <= 5); + /* send the fixed env subshape mode to enc_entropy */ + L_index_fx[4] = L_deposit_l(sub(shape_idx_fx, 2)); /* env shape, 0-->"1" , 1--> "env1" */ /* L_index[2] has original shape 0...5 */ + + ASSERT(fixShapeNb == L_index_fx[4]); + ASSERT(fixShiftIdx < (1 << 2)); + + Word16 tmp1 = add(1, fixShiftIdx); + + /* aux_bit : 0 (or 1) , will indicate the s0 sign in the FESS fix shape */ + L_index_fx[1] = 0L; move32(); /* s0 positive */ + test(); + if (y_fix_fx[tmp1] < 0) + { + L_index_fx[1] = 1L; move32(); /* s0 negative*/ + } + + fix_end_sign_fx = 12; move16(); + if (sub(shape_idx_fx, 5) == 0) + { + ASSERT(L_index_fx[4] == 3L); /* final fix_envelope only has 10 signs */ + fix_end_sign_fx = 10; move16(); /* shape 5 has 2 bits shift and a total of 10 signs =2^10*2^2 = 2^12 = 4096 */ + } + + Word16 tmp = fixShiftIdx; move16(); /* the two shift bits will be pushed up to b11,b12, for 11 signs s1-s11 */ + + /* sign loop */ + FOR(int sign_ind_fx = 1; sign_ind_fx < fix_end_sign_fx; sign_ind_fx++) /* push the remaining sequential signs s1-s11(or s1-s9), into a single idx */ + { /* s1 is in the MSB, and s11 is in the LSB*/ + tmp = shl_pos(tmp, 1); /* shift in a zero */ + test(); + if (y_fix_fx[add(tmp1, sign_ind_fx)] < 0) /* "1" indicates negative, "0" means positive */ + { + tmp = add(tmp, 1); + } + } + L_index_fx[5] = L_deposit_l(tmp); + + ASSERT(L_index_fx[5] >= 0 && L_index_fx[5] < (1 << (2 + (fix_end_sign_fx - 1)))); + } + } /* end of stage2 premultiplexing , fractional packing aspects done within enc_entropy_fx() */ + + ASSERT(envelope_bits_fx == 9 || envelope_bits_fx == 10 || envelope_bits_fx == 29 || envelope_bits_fx == 30); + + Dyn_Mem_Deluxe_Out(); + return envelope_bits_fx; +} + +/* LRSNS function needed in both encoder and decoder */ +Word16 snslr_remove_st1_DC_fQ11_fx( /* o : dc in Q11 */ + Word16 *scfq, /* i/o: stage1B vector in Q11 */ + Word16 len /* i : length Q0 */ +) +{ + Dyn_Mem_Deluxe_In( + Counter i; + Word32 L_dcQ11; + Word16 dcQ11; + ); + assert(len == 16); +#ifdef WMOPS + push_wmops("snslr_remove_st1_DC_fQ11_fx"); +#endif + + L_dcQ11 = 0; move32(); + + for (i = 0; i < len; i++) { + L_dcQ11 = L_mac0(L_dcQ11, scfq[i], 2048); + } + dcQ11 = extract_h(L_shl_pos(L_dcQ11, 1)); /*NB ! same truncation needed in both CFL and in basop */ + + for (i = 0; i < len; i++) + { + scfq[i] = sub(scfq[i], dcQ11); move16(); /* result update */ + } + +#ifdef WMOPS + pop_wmops(); +#endif + Dyn_Mem_Deluxe_Out(); + + return dcQ11; /* output used for encoder side mse update*/ +} + + +void snslr_st1B_vector_dec_fx(Word16 idx, const Word16* LFCB, const Word16 *HFCB, const Word16* seg_cnt_cum, const Word16* idx12b_cb, Word16 *st1B_vectorQ11) +{ + /* decompose the received 0... 169 index , into the correct integer and float st1B vector */ + Dyn_Mem_Deluxe_In( + Counter i; + const Word16 *lf_cb, *hf_cb; + + Word16 seg_fx; + Word16 idx_12b_fx, lf_sign_fx; + Word16 hf_sign_fx; + Word16 idx_HF_fx; + Word16 idx_LF_fx; + Word16 st1B_W16Q11_fx[M]; + Word16 buf[M]; + ); + +#ifdef WMOPS + push_wmops("snslr_st1B_vector_dec_fx"); +#endif + assert(idx >= 0 && idx < 170); + + + seg_fx = 0; move16(); + WHILE(sub(seg_cnt_cum[add(seg_fx, 1)], idx) <= 0) + { + seg_fx = add(seg_fx, 1); + } + + assert(seg_fx >= 0 && seg_fx < 4); + + idx_12b_fx = idx12b_cb[idx]; /* indirect lookup from sequential value to a coded 12b index*/ + + lf_sign_fx = 1; move16(); /* assume a 0 bit -> "+" */ + if (s_and(0x0800, idx_12b_fx) != 0) { + lf_sign_fx = -1; move16(); /* assume a 1 bit -> " -" */ + } + + hf_sign_fx = 1; move16(); /* assume a 0 bit -> "+" */ + if ((s_and(0x0400, idx_12b_fx)) != 0) { + hf_sign_fx = -1; move16(); /* assume a 1 bit -> "-" */ + } + idx_LF_fx = shr_pos(s_and(0x03e0, idx_12b_fx), 5); + idx_HF_fx = s_and(0x001f, idx_12b_fx); + + /* extseg0 f,f */ + lf_cb = &(LFCB[idx_LF_fx*(M / 2)]); L_mult(0, 0); /* mult and pointer init */ + hf_cb = &(HFCB[idx_HF_fx*(M / 2)]); L_mult(0, 0); /* mult and pointer init */ + + FOR(i = 0; i < (M / 2); i++) + { + st1B_W16Q11_fx[i] = i_mult(lf_sign_fx, lf_cb[i]); /* imult() to switch sign without changing dynamics*/ + st1B_W16Q11_fx[M / 2 + i] = i_mult(hf_sign_fx, hf_cb[i]); + } + + basop_memcpy(buf, st1B_W16Q11_fx, sizeof(*buf)*M); /* buffer cpy needed for reversal sections */ + + IF(s_and(seg_fx, 0x0002) != 0) + { /* r,* */ /* flip LF */ + FOR(i = 0; i < (M / 2); i++) + { + st1B_W16Q11_fx[i] = buf[(M / 2 - 1) - i]; move16(); + } + } + + IF(s_and(seg_fx, 0x0001) != 0) + { /* *,r */ /* flip HF */ + FOR(i = 0; i < (M / 2); i++) + { + st1B_W16Q11_fx[(M / 2) + i] = buf[(M - 1) - i]; move16(); + } + } + + basop_memcpy(st1B_vectorQ11, st1B_W16Q11_fx, M * sizeof(*st1B_vectorQ11)); + +#ifdef WMOPS + pop_wmops(); +#endif + Dyn_Mem_Deluxe_Out(); +} + +Word16 MSEsearchCbBIdxMap_fx(const Word16 *scf, const Word16 *LFCB, const Word16 *HFCB, const Word16 *seg_cnt_cum, const Word16* idx12b_cb, Word16 v_len, Word16 cb_len, Word32* min_mse) +{ + Dyn_Mem_Deluxe_In( + + Counter seg, i, j; /*counters */ + + Word16 scfLF_Q11[M]; + + Word16* scfHF_Q11; + const Word16 *lf_cb, *hf_cb; + Word16 idx_12b, signbitLF, signbitHF, idx_LF, idx_HF; + Word32 L_mse_best_fx; + Word16 best_ind; + ); + UNUSED(v_len); + UNUSED(cb_len); + Word32 L_tEnBy2; + Word32 L_cbEnBy2; + Word32 L_mseBy2; /* sum( t_i^2 + cbB_i^2 - 2*t_i*cbB_i )/2 */ + + + + + /* MSE separated into targetEn + vectorB_en - 2 *correlation t*cbB */ + /* vectorBenergy is obtained from addition of two Word32 lookup tables LFen and HFen */ + + +#ifdef WMOPS + push_wmops("MSEsearchCbBIdxMap_fx"); +#endif + + L_mse_best_fx = INT_MAX; move32(); + best_ind = -1; /*for debug*/ + + assert(v_len == M); + + L_tEnBy2 = L_mult0(scf[0], scf[0]); + FOR(i = 1; i < M; i++) + { + L_tEnBy2 = L_mac0(L_tEnBy2, scf[i], scf[i]); /* calc target Energy part of MSE */ + } + L_tEnBy2 = L_shr_pos_pos(L_tEnBy2, 1); + + + scfHF_Q11 = (&scfLF_Q11[M / 2]); /* ptr init */ + + FOR(seg = 0; seg < 4; seg++) + { + basop_memcpy(scfLF_Q11, scf, M * sizeof(*scfLF_Q11)); + /*seg==0: fwd, fwd *//*seg==1: fwd, rev *//*seg==2: fwd, fwd */ /*seg==3: rev, rev */ + + IF(s_and(seg, 0x0002) != 0) + { /* {r,*} */ /* flip LF */ + FOR(i = 0; i < (M / 2); i++) + { + scfLF_Q11[i] = scf[(M / 2 - 1) - i]; move16(); + } + } + IF(s_and(seg, 0x0001) != 0) + { /* {*,r} */ /* flip HF */ + FOR(i = 0; i < (M / 2); i++) + { + scfHF_Q11[i] = scf[(M - 1) - i]; move16(); + } + } + + FOR(i = seg_cnt_cum[seg]; i < seg_cnt_cum[add(seg, 1)]; i++) + { + /* Note: these 4 subindex extractions can be in parallel */ + idx_12b = idx12b_cb[i]; /* tmp variable, indirect adressing lookup of 12b index pointing to LF and HF + individual sign swaps */ + + idx_LF = shr_pos_pos(s_and(0x03e0, idx_12b), 5); /* b9...b5 */ + idx_HF = s_and(0x001f, idx_12b); /* b4...b0 lowest 5 bits */ + + L_cbEnBy2 = L_add(lrsns_st1B_enBy2TabW32_fx[idx_LF], lrsns_st1B_enBy2TabW32_fx[32 + idx_HF]); /* ptr init to HF tab*/ + + signbitLF = s_and(0x0800, idx_12b); /* b11 logical 0 or 2048 */ + signbitHF = s_and(0x0400, idx_12b); /* b10 logical 0 or 1024 */ + + /* conditional update of signed section offsets */ + if (signbitLF != 0) + { + idx_LF = add(idx_LF, 32); /* point to negated part of lf_cb */ + } + if (signbitHF != 0) + { + idx_HF = add(idx_HF, 32); /* point to negated part of hf_cb */ + } + + lf_cb = &(LFCB[idx_LF * M / 2]); /* adaptive ptr init */ + hf_cb = &(HFCB[idx_HF * M / 2]); /* adaptive ptr init */ + + L_mseBy2 = L_add(L_tEnBy2, L_cbEnBy2); /* in ARM one op per cbB idx [0..169] can likely be saved by adding targetEnergyBy2 last */ + + /* mse/2 = tEn^2/2 + cbEn^2/2 - corr(target_v, (sign)*cb_v ) */ + FOR(j = 0; j < (M / 2); j++) + { + /* cycles saved by extending the LF and HF tables with negated versions */ + L_mseBy2 = L_msu0(L_mseBy2, scfLF_Q11[j], lf_cb[j]); /* acc with -1 * t*c , cb sign set by lf_cb */ + L_mseBy2 = L_msu0(L_mseBy2, scfHF_Q11[j], hf_cb[j]); /* acc -1* t*c with cb sign set by hf_cb ptr */ + } + ASSERT(L_mseBy2 >= 0); + /* always update best case */ + L_mse_best_fx = L_min(L_mseBy2, L_mse_best_fx); /* 1 cycle BASOP update */ + + if (L_sub(L_mseBy2, L_mse_best_fx) == 0) + { + best_ind = ((Word16)i); move16(); /* update winner, cond move , single BASOP */ + } + } /* one segment seg*/ + } /* all segms */ + + *min_mse = L_add(L_mse_best_fx, L_mse_best_fx); /* multiply halved MSEby2 to get final MSE */ + + assert(best_ind >= 0 && best_ind < cb_len); + +#ifdef WMOPS + pop_wmops(); /* func */ +#endif + Dyn_Mem_Deluxe_Out(); + + return best_ind; +} + +void snslr_st1C_vector_dec_fx(Word16 idx, const Word8* CBW8, Word16 scaleQ4, Word16 inv_scaleQ15, Word16 v_len, Word16 cb_len, Word16 *st1C_vector) +{ + /* decompose the received 0... 169 index , into the correct (integer and) float st1C vector */ + /* even in C-float the st1C coeffs are put into a S16Q11 final integers domain */ + /* Enables BE compatibility between {BASOP, float, double} arithmetic implmentations */ + Dyn_Mem_Deluxe_In( + Counter i; + const Word8 *cb; + Word32 L_tmp; + Word16 s_tmp; + ); + UNUSED(v_len); + UNUSED(cb_len); + UNUSED(inv_scaleQ15); /* req for debugging only */ + +#ifdef WMOPS + push_wmops("snslr_st1C_vector_dec_fx"); +#endif + + assert(idx >= 0 && idx < cb_len); + assert(v_len == M); + + cb = &(CBW8[idx*M]); move16(); /* pointer init */ + FOR(i = 0; i < M; i++) + { + L_tmp = L_mult0((Word16)cb[i], scaleQ4); /*S8Q7 * S15Q4 */ /*sign+7bit, sign+4 bits --> sign+11bit .lt sign+23 bits*/ + s_tmp = extract_l(L_tmp); + assert(L_tmp >= -32768L && L_tmp <= 32767L); /* INT16 domain check*/ + st1C_vector[i] = s_tmp; + } + +#ifdef WMOPS + pop_wmops(); +#endif + Dyn_Mem_Deluxe_Out(); +} + +Word16 MSEsearchGenericScaledW8_fx(Word16 *scf, const Word8 *sns_CBW8, Word16 scaleQ4, Word16 inv_scaleQ15, Word16 v_len, Word16 cb_len, Word32* L_min_mse) +{ + /* scf float input values are typically in the range +12.0 to -12.0. + rom table stored in Word8 [+127,-128], format corresponding to ]+1.0 .. -1.0 ] + inv_scaleQ15, [downscaling value in Q15] applied before search + scaleQ12 upscaling value quantized in Q12, used in the mse calulation and in the common float and BASOP synthesis routines + + */ + Dyn_Mem_Deluxe_In( + Counter i, n; + Word32 best_ind; + Word32 L_mse, L_mse_best; + Word16 targetW16[M]; + const Word8 * cbW8; + Word16 shift_mse; + Word16 tmp; + ); + +#ifdef WMOPS + push_wmops("MSEsearchGenericScaledW8_fx"); +#endif + FOR(i = 0; i < v_len; i++) + { + targetW16[i] = shr_pos(mult(scf[i], inv_scaleQ15), 4); /* target from W16Q11 to W8Q7 domain , and floor */ + }; + + best_ind = -1; /* needed to avoid compiler warning */ + + /* use use S1.15 wise multiplication operations QSUB16 for two coeffs correlation */ + /* L_msu0 can use 16 bit input only e.g. SMLSLD */ + + /* MSE_i = sum(i=0,15, (t_i-c_i)*(t_i-c_i) ) = sum(i=0,15, (t_i)^2 + c_i^2 - 2*(t_i*c_i) ) */ + /* store EnC_i = sum(1,16) c_i^2 , in a Word32 ROM entry , 170 entries , or potentially in Word16 */ + /* calculate MSE_i = EnT+EnC - sum (2*t_i*c_i) */ + /* or even calculate MSE_i/2 = enT/2 + EnC/2 - sum( t_i*c_i) , as an approximation of MSE */ + + /* commmon target contribution to MSE */ + + Word32 L_targetEn = 0; move32(); + if (v_len > 0) { + L_targetEn = L_mult0(targetW16[0], targetW16[0]); + FOR (i = 1; i < v_len; i++) + { + L_targetEn = L_mac0(L_targetEn, targetW16[i], targetW16[i]); + } + } + L_mse_best = INT32_MAX; move32(); /* largest possible positive number in INT32 */ + + FOR(i = 0; i < cb_len; i++) + { + cbW8 = &(sns_CBW8[i*M]); /* ptr init += i*16 */ + assert(v_len == M); + + L_mse = L_deposit_l(lrsns_st1C_Both_EnBy2Tab_fx[i]); /* scaled down CB energy by 2 from ROM to allow use of L_msu0 for best ARM ops */ + L_mse = L_add(L_mse, L_shr_pos_pos(L_targetEn, 1)); /* scale down target energy by 2 to allow use of L_msu0 for best ARM ops */ + + FOR(n = 0; n < v_len; n++) + { /* correlate is fast in most ARM cases, as SIMD or as blocks of 4 */ + L_mse = L_msu0(L_mse, targetW16[n], (Word16)(cbW8[n])); /* no upscaling included in L_msu0() */ + } + + assert(L_mse >= 0); /* check that error is always positive, otherwise we might get overflow in the subtraction below */ + if (L_sub(L_mse, L_mse_best) <= 0) + { + best_ind = i; move16(); /* single BASOP, conditional move, for best_ind update */ + } + L_mse_best = L_min(L_mse, L_mse_best); /* always update best MSE using L_min() in the idx loop, reduces WC WMOPS */ + } + L_mse_best = L_add(L_mse_best, L_mse_best); /* scale up by two from the BASOP/ARM optimized search mse domain */ + + + assert(best_ind >= 0 && best_ind < cb_len); + + *L_min_mse = L_mse_best; move32(); + + tmp = i_mult(scaleQ4, scaleQ4); /* non fractional square --> Q4 to Q8 */ + tmp = shl_pos(tmp, 2); /* a Q10 const */ + + shift_mse = norm_l(*L_min_mse); + + *L_min_mse = L_shl(*L_min_mse, shift_mse); + *L_min_mse = Mpy_32_16_lc3plus(*L_min_mse, tmp); /* still use max upshifting Mpy_32_16, here for this final Word32 L_mse output calculation */ + *L_min_mse = L_shr(*L_min_mse, add(shift_mse, 2 - 15)); + +#ifdef WMOPS + pop_wmops(); +#endif + Dyn_Mem_Deluxe_Out(); + + return best_ind; +} + +Word16 MSEsearchGeneric_fx(Word16 *scf, const Word16 *sns_CB, Word16 v_len, Word16 cb_len, Word32* L_min_mse) +{ + Dyn_Mem_Deluxe_In( + Counter i, n; + Word16 ind; + Word32 L_mse_best_fx, L_mse_fx; + Word16 tmp; + Word16 const *cb_ptr; + Word16 const *scf_ptr; + ); + +#ifdef WMOPS + push_wmops("MSEsearchGeneric_fx"); +#endif + ind = -1; /* avoid compiler warning */ + L_mse_best_fx = INT_MAX; move32(); + + FOR(i = 0; i < cb_len; i++) + { + L_mse_fx = L_deposit_l(0); + cb_ptr = &(sns_CB[i*v_len]); /* pointer init */ + scf_ptr = &(scf[0]); /* pointer init */ + FOR(n = 0; n < v_len; n++) + { + tmp = sub(*scf_ptr++, *cb_ptr++); + L_mse_fx = L_mac0(L_mse_fx, tmp, tmp); + } + + L_mse_best_fx = L_min(L_mse_fx, L_mse_best_fx); + if (L_sub(L_mse_fx, L_mse_best_fx) == 0) + { + ind = i; move16(); + } + } + + *L_min_mse = L_mse_best_fx; move32(); + + assert(ind >= 0 && ind < cb_len); +#ifdef WMOPS + pop_wmops(); +#endif + Dyn_Mem_Deluxe_Out(); + return ind; +} + +#endif diff --git a/lib_lc3plus/tinywavein_c.h b/lib_lc3plus/tinywavein_c.h deleted file mode 100644 index ff7e17ca4..000000000 --- a/lib_lc3plus/tinywavein_c.h +++ /dev/null @@ -1,603 +0,0 @@ -/****************************************************************************** -* ETSI TS 103 634 V1.5.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - -#ifndef __TINYWAVEIN_C_H__ -#define __TINYWAVEIN_C_H__ - -/*#define SUPPORT_BWF*/ - -#include -#include -#include - -#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) || defined(__arm__) || \ - defined(__aarch64__) -#define __TWI_LE /* _T_iny _W_ave _I_n _L_ittle _E_ndian */ -#endif - -#if defined(__POWERPC__) -#define __TWI_BE /* _T_iny _W_ave _I_n _B_ig _E_ndian */ -#endif - -#if !defined(__TWI_LE) && !defined(__TWI_BE) -#error unknown processor -#endif - -#define __TWI_SUCCESS (0) -#define __TWI_ERROR (-1) - -#ifdef SUPPORT_BWF -typedef struct -{ - float loudnessVal; - float loudnessRange; - float maxTruePeakLevel; - float maxMomentaryLoudnes; - float maxShortTermLoudness; -} WAVEIN_LOUDNESSINFO; -#endif - -typedef struct __tinyWaveInHandle -{ - FILE * theFile; - fpos_t dataChunkPos; - unsigned int position; - unsigned int length; - unsigned int bps; -#ifdef SUPPORT_BWF - WAVEIN_LOUDNESSINFO *loudnessInfo; -#endif -} __tinyWaveInHandle, WAVEFILEIN; - -typedef struct -{ - short compressionCode; - short numberOfChannels; - unsigned int sampleRate; - unsigned int averageBytesPerSecond; - short blockAlign; - short bitsPerSample; - /* short extraFormatBytes ; */ -} SWavInfo; - -#ifdef SUPPORT_BWF -typedef struct -{ - unsigned char description[256]; - unsigned char originator[32]; - unsigned char originatorReference[32]; - unsigned char originatorDate[10]; /* ASCII: <> */ - unsigned char originationTime[8]; /* ASCII: <> */ - unsigned int timeReferenceLow; - unsigned int timeReferenceHigh; - unsigned short version; - unsigned char UMID[64]; /* Binary Bytes of SMPTE UMID */ - - signed short loudnessVal; - signed short loudnessRange; - signed short maxTruePeakLevel; - signed short maxMomentaryLoudnes; - signed short maxShortTermLoudness; - - unsigned char Reserved[180]; - - unsigned char codingHistory; /* ASCII: <> */ -} SBwfWav; -#endif - -typedef struct -{ - char chunkID[4]; - unsigned int chunkSize; - /* long dataOffset ; */ /* never used */ -} SChunk; - -/* local wrapper, always returns correct endian */ -static size_t fread_LE(void *ptr, size_t size, size_t nmemb, FILE *stream); - -#ifdef __TWI_BE -static short BigEndian16(short v); -static int BigEndian32(int v); -#endif - -/*! - * \brief Read header from a WAVEfile. Host endianess is handled accordingly. - * \fp filepointer of type FILE*. - * \wavinfo SWavInfo struct where the decoded header info is stored into. - * \return 0 on success and non-zero on failure. - * - */ -static WAVEFILEIN *OpenWav(const char *filename, unsigned int *samplerate, short *channels, unsigned int *samplesInFile, - short *bps) -{ - WAVEFILEIN *self; - - SChunk fmt_chunk, data_chunk; - int offset; - unsigned int tmpSize; - char tmpFormat[4]; - SWavInfo wavinfo = {0, 0, 0, 0, 0, 0}; - - self = (WAVEFILEIN *)calloc(1, sizeof(WAVEFILEIN)); - if (!self) - goto bail; /* return NULL; */ - - if (!filename) - goto bail; - if (!samplerate) - goto bail; - if (!channels) - goto bail; - if (!samplesInFile) - goto bail; - if (!bps) - goto bail; - - self->theFile = fopen(filename, "rb"); - if (!self->theFile) - goto bail; - - /* read RIFF-chunk */ - if (fread(tmpFormat, 1, 4, self->theFile) != 4) - { - goto bail; - } - - if (strncmp("RIFF", tmpFormat, 4)) - { - goto bail; - } - - /* Read RIFF size. Ignored. */ - fread_LE(&tmpSize, 4, 1, self->theFile); - - /* read WAVE-chunk */ - if (fread(tmpFormat, 1, 4, self->theFile) != 4) - { - goto bail; - } - - if (strncmp("WAVE", tmpFormat, 4)) - { - goto bail; - } - - /* read format/bext-chunk */ - if (fread(fmt_chunk.chunkID, 1, 4, self->theFile) != 4) - { - goto bail; - } - -#ifdef SUPPORT_BWF - /* test for bext-chunk */ - if (!strncmp("bext", fmt_chunk.chunkID, 4)) - { - /*unsigned int i;*/ - unsigned int bextSize = 0; - - if (fread_LE(&bextSize, 1, 4, self->theFile) != 4) - { - goto bail; - } - - self->loudnessInfo = (WAVEIN_LOUDNESSINFO *)calloc(1, sizeof(WAVEIN_LOUDNESSINFO)); - - if (bextSize >= 602) - { /* minimum size bext-data, w/o 'CodingHistory' */ - int i; - signed short readBuf = 0; - signed int nulbuf = 0; - - /* first skip all descriptive data */ - for (i = 0; i < 412; i++) - { - if (fread_LE(&nulbuf, 1, 1, self->theFile) != 1) - { - goto bail; - } - bextSize -= 1; - } - /* second, read loudness data */ - fread_LE(&readBuf, 2, 1, self->theFile); - bextSize -= 2; - self->loudnessInfo->loudnessVal = (float)readBuf * 0.01f; - - fread_LE(&readBuf, 2, 1, self->theFile); - bextSize -= 2; - self->loudnessInfo->loudnessRange = (float)readBuf * 0.01f; - - fread_LE(&readBuf, 2, 1, self->theFile); - bextSize -= 2; - self->loudnessInfo->maxTruePeakLevel = (float)readBuf * 0.01f; - - fread_LE(&readBuf, 2, 1, self->theFile); - bextSize -= 2; - self->loudnessInfo->maxMomentaryLoudnes = (float)readBuf * 0.01f; - - fread_LE(&readBuf, 2, 1, self->theFile); - bextSize -= 2; - self->loudnessInfo->maxShortTermLoudness = (float)readBuf * 0.01f; - - /* skip reserved data */ - for (i = 0; i < 180; i++) - { - if (fread_LE(&nulbuf, 1, 1, self->theFile) != 1) - { - goto bail; - } - bextSize -= 1; - } - } - - /* skip remaining data */ - while (bextSize) - { - int nulbuf; - if (fread_LE(&nulbuf, 1, 1, self->theFile) != 1) - { - goto bail; - } - bextSize -= 1; - } - - /* read next chunk header */ - if (fread(fmt_chunk.chunkID, 1, 4, self->theFile) != 4) - { - goto bail; - } - } -#endif - - /* skip some potential chunks up to fmt chunk */ - - while (strncmp("fmt ", fmt_chunk.chunkID, 4) != 0) - { - unsigned int chunkSize = 0; - - if (fread_LE(&chunkSize, 1, 4, self->theFile) != 4) - { - goto bail; - } - - /* skip chunk data */ - while (chunkSize) - { - int nulbuf; - if (fread_LE(&nulbuf, 1, 1, self->theFile) != 1) - { - goto bail; - } - chunkSize -= 1; - } - - /* read next chunk header */ - if (fread(fmt_chunk.chunkID, 1, 4, self->theFile) != 4) - { - goto bail; - } - } - - /* go on with fmt-chunk */ - if (strncmp("fmt ", fmt_chunk.chunkID, 4)) - { - goto bail; - } - - if (fread_LE(&fmt_chunk.chunkSize, 4, 1, self->theFile) != 1) - { /* should be 16 for PCM-format (uncompressed) */ - goto bail; - } - - - /* read info */ - fread_LE(&(wavinfo.compressionCode), 2, 1, self->theFile); - fread_LE(&(wavinfo.numberOfChannels), 2, 1, self->theFile); - fread_LE(&(wavinfo.sampleRate), 4, 1, self->theFile); - fread_LE(&(wavinfo.averageBytesPerSecond), 4, 1, self->theFile); - fread_LE(&(wavinfo.blockAlign), 2, 1, self->theFile); - fread_LE(&(wavinfo.bitsPerSample), 2, 1, self->theFile); - - if (wavinfo.compressionCode == -2) - { - fseek(self->theFile, 8, SEEK_CUR); // skip channel mask - fread_LE(&(wavinfo.compressionCode), 2, 1, self->theFile); // part of GUID - fseek(self->theFile, 14, SEEK_CUR); // skip rest of GUID - offset = fmt_chunk.chunkSize - 40; - } - else - offset = fmt_chunk.chunkSize - 16; - - if (wavinfo.compressionCode == 0x01) - { - if ((wavinfo.bitsPerSample != 16) && (wavinfo.bitsPerSample != 24) && (wavinfo.bitsPerSample != 32)) - /* we do only support 16,24 and 32 bit PCM audio */ - goto bail; - } - else - { - /* if(wavinfo.bitsPerSample != 32) */ - printf("compressioncode: %02x\n", wavinfo.compressionCode); - puts("Error! We only support 16,24 and 32 bit PCM audio"); - exit(1); - goto bail; - } - - /* Skip rest of fmt header if any. */ - for (; offset > 0; offset--) - { - fread(&tmpSize, 1, 1, self->theFile); - } - - do - { - - /* Read data chunk ID */ - if (fread(data_chunk.chunkID, 1, 4, self->theFile) != 4) - { - goto bail; - } - - /* Read chunk length. */ - - if (fread_LE(&offset, 4, 1, self->theFile) != 1) - { - goto bail; - } - - /* Check for data chunk signature. */ - if (strncmp("data", data_chunk.chunkID, 4) == 0) - { - data_chunk.chunkSize = offset; - break; - } - - /* unused 1 byte present, if size is odd */ - /* see https://www.daubnet.com/en/file-format-riff */ - if (offset % 2) - { - offset++; - } - - /* Jump over non data chunk. */ - for (; offset > 0; offset--) - { - fread(&tmpSize, 1, 1, self->theFile); - } - - } while (!feof(self->theFile)); - - /* success so far */ - *samplerate = wavinfo.sampleRate; - *channels = wavinfo.numberOfChannels; - *samplesInFile = data_chunk.chunkSize / wavinfo.numberOfChannels; - *samplesInFile /= ((wavinfo.bitsPerSample + 7) / 8); - *bps = wavinfo.bitsPerSample; - - self->position = 0; - self->bps = wavinfo.bitsPerSample; - self->length = *samplesInFile * wavinfo.numberOfChannels; - - fgetpos(self->theFile, &self->dataChunkPos); - - return self; - -bail: - free(self); - return NULL; -} - -#ifdef SUPPORT_BWF -static void ReadBWF(WAVEFILEIN *self, WAVEIN_LOUDNESSINFO **wavInLoudness) -{ - *wavInLoudness = self->loudnessInfo; -} -#endif - -static int __ReadSample16(WAVEFILEIN *self, int *sample) -{ - size_t cnt; - short v = 0; - - cnt = fread(&v, 2, 1, self->theFile); - - if (cnt != 1) - { - return __TWI_ERROR; - } - - self->position += 1; - -#ifdef __TWI_BE - v = BigEndian16(v); -#endif - *sample = v; - return __TWI_SUCCESS; -} - -static int __ReadSample24(WAVEFILEIN *self, int *sample) -{ - size_t cnt; - int v = 0; - - cnt = fread(&v, 3, 1, self->theFile); - - if (cnt != 1) - { - return __TWI_ERROR; - } - - self->position += 1; - -#ifdef __TWI_BE - v = BigEndian32(v); -#endif - - if (v >= 0x800000) - { - v |= 0xff000000; - } - - *sample = v; - - return __TWI_SUCCESS; -} - -static int __ReadSample32(WAVEFILEIN *self, int *sample) -{ - size_t cnt; - int v = 0; - - cnt = fread(&v, 4, 1, self->theFile); - - if (cnt != 1) - { - return __TWI_ERROR; - } - - self->position += 1; - -#ifdef __TWI_BE - v = BigEndian32(v); -#endif - - *sample = v >> 8; - - return __TWI_SUCCESS; -} - -static int __ReadSampleInternal(WAVEFILEIN *self, int *sample, int scale) -{ - int err; - - if (!self) - { - return __TWI_ERROR; - } - - switch (scale) - { - - case 16: err = __ReadSample16(self, sample); break; - - case 24: err = __ReadSample24(self, sample); break; - - case 32: err = __ReadSample32(self, sample); break; - - default: err = __TWI_ERROR; break; - } - - return err; -} - -/* this function returns normalized values in the range +8388607..-8388608 */ -static int ReadWavInt(WAVEFILEIN *self, int sampleBuffer[], unsigned int nSamplesToRead, unsigned int *nSamplesRead) -{ - unsigned int i; - int err = __TWI_SUCCESS; - *nSamplesRead = 0; - - if (!sampleBuffer) - { - return __TWI_ERROR; - } - - /* check if we have enough samples left, if not, - set nSamplesToRead to number of samples left. */ - if (self->position + nSamplesToRead > self->length) - { - nSamplesToRead = self->length - self->position; - } - - for (i = 0; i < nSamplesToRead; i++) - { - - int tmp; - err = __ReadSampleInternal(self, &tmp, self->bps); - if (err != __TWI_SUCCESS) - { - return err; - } - sampleBuffer[i] = tmp; - *nSamplesRead += 1; - } - - return __TWI_SUCCESS; -} - -static int CloseWavIn(WAVEFILEIN *self) -{ - if (self) - { - if (self->theFile) - { - fclose(self->theFile); - } - } - free(self); - - return __TWI_SUCCESS; -} -/* -static int ResetWavIn(WAVEFILEIN* self) -{ - if (self) { - if (self->theFile) { - fsetpos(self->theFile, &self->dataChunkPos); - self->position = 0; - } - } - return __TWI_SUCCESS; -} -*/ -/*------------- local subs ----------------*/ - -static size_t fread_LE(void *ptr, size_t size, size_t nmemb, FILE *stream) -{ -#ifdef __TWI_LE - return fread(ptr, size, nmemb, stream); -#endif -#ifdef __TWI_BE - - unsigned char x[sizeof(int)]; - unsigned char *y = (unsigned char *)ptr; - int i; - int len; - - len = fread(x, size, nmemb, stream); - - for (i = 0; i < size * nmemb; i++) - { - *y++ = x[size * nmemb - i - 1]; - } - - return len; -#endif -} - -#ifdef __TWI_BE -static short BigEndian16(short v) -{ - short a = (v & 0x0ff); - short b = (v & 0x0ff00) >> 8; - - return a << 8 | b; -} - -static int BigEndian32(int v) -{ - int a = (v & 0x0ff); - int b = (v & 0x0ff00) >> 8; - int c = (v & 0x0ff0000) >> 16; - int d = (v & 0xff000000) >> 24; - - return a << 24 | b << 16 | c << 8 | d; -} -#endif - -#endif /* __TINYWAVEIN_C_H__ */ diff --git a/lib_lc3plus/tinywaveout_c.h b/lib_lc3plus/tinywaveout_c.h deleted file mode 100644 index 2f64a659f..000000000 --- a/lib_lc3plus/tinywaveout_c.h +++ /dev/null @@ -1,889 +0,0 @@ -/****************************************************************************** -* ETSI TS 103 634 V1.5.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - -#ifndef __TINYWAVEOUT_C_H__ -#define __TINYWAVEOUT_C_H__ - -/*#define TWO_SUPPORT_BWF*/ - -#include -#include -#include -#include -#ifdef TWO_SUPPORT_BWF -#include -#endif - -/***** Interface *********************************************************/ - -#ifndef TWO_UINT64 - #if !(defined(WIN32)) - #include - #define TWO_UINT64 uint64_t - #else - #define TWO_UINT64 unsigned __int64 - #endif -#endif - -typedef struct WAVEFILEOUT WAVEFILEOUT; -#ifdef TWO_SUPPORT_BWF -typedef struct WAVEOUT_LOUDNESSINFO WAVEOUT_LOUDNESSINFO; -#endif - -#define __TWO_SUCCESS (0) -#define __TWO_ERROR (-1) - -static WAVEFILEOUT* CreateWav( - const char *fileName, - const unsigned int sampleRate, - const unsigned int numChannels, - const unsigned int bps - ); - -#ifdef TWO_SUPPORT_BWF -static WAVEFILEOUT* CreateWavBWF( - const char *fileName, - const unsigned int sampleRate, - const unsigned int numChannels, - const unsigned int bps, - const WAVEOUT_LOUDNESSINFO *hBwfData - ); -#endif - -/* this function expects values in the 16 bit range +32767..-32768 */ -static int WriteWavShort( - WAVEFILEOUT* self, - short sampleBuffer[], - unsigned int nSamples - ); - -/* this function expects values in the 24 bit range +8388607..-8388608 */ -static int WriteWavLong( - WAVEFILEOUT* self, - int sampleBuffer[], - unsigned int nSamples - ); - -/* this function expects normalized values in the range +-1.0f */ -static int WriteWavFloat( - WAVEFILEOUT* self, - float sampleBuffer[], - unsigned int nSamples - ); - -static int CloseWav(WAVEFILEOUT* self); -#ifdef TWO_SUPPORT_BWF -static int CloseWavBWF(WAVEFILEOUT* self, WAVEOUT_LOUDNESSINFO bextData); -#endif - -/***** Implementation *********************************************************/ - -#if defined (__i386__) || defined (_M_IX86) || defined (_M_X64) || defined (__x86_64__) || defined (__arm__) || defined (__xtensa__) || defined (__aarch64__) || defined (__EMSCRIPTEN__) -#define __TWO_LE /* _T_iny _W_ave _O_ut _L_ittle _E_ndian */ -#endif - -#if defined (__POWERPC__) -#define __TWO_BE /* _T_iny _W_ave _O_ut _B_ig _E_ndian */ -#endif - -#if defined (__sparc__) -#define __TWO_BE /* _T_iny _W_ave _O_ut _B_ig _E_ndian */ -#endif - -#if ! defined (__TWO_LE) && ! defined (__TWO_BE) -#error unknown processor -#endif - -/*--- local types/structs ----------------------------------*/ - -#if defined(_MSC_VER) - #pragma pack(push, 1) -#else - #pragma pack(1) -#endif - - -#ifdef TWO_SUPPORT_BWF -struct WAVEOUT_LOUDNESSINFO { - float loudnessVal; - float loudnessRange; - float maxTruePeakLevel; - float maxMomentaryLoudnes; - float maxShortTermLoudness; -}; -#endif - - -typedef struct __tinyWaveOutHeader -{ - unsigned int riffType; /* 'RIFF/RF64' */ - unsigned int riffSize; /* file size/-1 */ - unsigned int waveType; /* 'WAVE' */ -} __tinyWaveOutHeader; - -typedef struct __tinyWaveOutDs64Chunk -{ - unsigned int formatType; /* = 'JUNK/ds64' */ - unsigned int formatSize; /* size info */ - TWO_UINT64 riffSize64; - TWO_UINT64 dataSize64; - TWO_UINT64 sampleCount64; - unsigned int tableLength; /* optional tables, always 0 for tinywaveout */ - /* here: optional tables */ -} __tinyWaveOutDs64Chunk; - -#ifdef TWO_SUPPORT_BWF -typedef struct __tinyWaveOutBextChunk -{ - unsigned int formatType; /* = 'bext' */ - unsigned int formatSize; /* size info */ - - unsigned char description[256]; - unsigned char originator[32]; - unsigned char originatorReference[32]; - unsigned char originatorDate[10]; /* ASCII: <> */ - unsigned char originationTime[8]; /* ASCII: <> */ - unsigned int timeReferenceLow; - unsigned int timeReferenceHigh; - unsigned short version; - unsigned char UMID[64]; /* Binary Bytes of SMPTE UMID */ - - signed short loudnessVal; - signed short loudnessRange; - signed short maxTruePeakLevel; - signed short maxMomentaryLoudnes; - signed short maxShortTermLoudness; - - unsigned char Reserved[180]; - - unsigned char codingHistory; /* ASCII: <> - undefined length! */ - /* for variable length, mve this out of this struct */ -} __tinyWaveOutBextChunk; -#endif - -typedef struct __tinyWaveOutFmtChunk -{ - unsigned int formatType; - unsigned int formatSize; - - unsigned short formatTag; - unsigned short numChannels; - unsigned int sampleRate; - unsigned int bytesPerSecond; - unsigned short blockAlignment; - unsigned short bitsPerSample; - - /* wav fmt ext hdr here */ -} __tinyWaveOutFmtChunk; - -typedef struct __tinyWaveOutDataChunk -{ - unsigned int dataType; - unsigned int dataSize; - -} __tinyWaveOutDataChunk; - - -struct WAVEFILEOUT { - /* for reasons of memory alignment, have 64 bit data types first */ - TWO_UINT64 dataSize; - TWO_UINT64 dataSizeLimit; /* maximum size for data chunk for 4 GB files */ - TWO_UINT64 dataSizeLimit64; /* maximum size for data chunk for 2^64 B addressable files */ - TWO_UINT64 clipCount; - FILE* theFile; - unsigned int junkChunkOffset; - unsigned int fmtChunkOffset; -#ifdef TWO_SUPPORT_BWF - unsigned int bextChunkOffset; -#endif - unsigned int dataChunkOffset; - unsigned int bps; - - /* only needed for RF64: */ - unsigned int blockAlign; /* only needed for close() of ds64 chunk */ -}; - - -/*--- local protos --------------------------------------------------*/ -static __inline unsigned int BigEndian32(char, char, char, char); -static __inline unsigned int LittleEndian32(unsigned int); -static __inline unsigned int LittleEndian32s(int); -static __inline short LittleEndian16(short); -static __inline TWO_UINT64 LittleEndian64(TWO_UINT64); -#ifdef TWO_SUPPORT_BWF -static unsigned int EncodeLoudness(float); -#endif -static __inline int __dataSizeChk( WAVEFILEOUT* self, int newbytes ); - -#if defined(_MSC_VER) - #pragma pack(pop) -#else - #pragma pack() -#endif - - -#ifdef TWO_SUPPORT_BWF -static void setDefaultLoudness(WAVEOUT_LOUDNESSINFO *x) -{ - x->loudnessVal = 1.0f; - x->loudnessRange = 2.0f; - x->maxTruePeakLevel = 3.0f; - x->maxMomentaryLoudnes = 4.0f; - x->maxShortTermLoudness = 5.0f; -} -#endif - -static WAVEFILEOUT* __CreateWavInternal( - const char *fileName, - const unsigned int sampleRate, - const unsigned int numChannels, - const unsigned int bps -#ifdef TWO_SUPPORT_BWF - , - const WAVEOUT_LOUDNESSINFO *hBwfData -#endif - ) -{ - WAVEFILEOUT* self = NULL; - __tinyWaveOutHeader whdr; - __tinyWaveOutDs64Chunk ds64ch; -#ifdef TWO_SUPPORT_BWF - __tinyWaveOutBextChunk wbextch; -#endif - __tinyWaveOutFmtChunk wfch; - __tinyWaveOutDataChunk wdch; - unsigned int blockAlignment = 0; - unsigned int ByteCnt = 0; /* Byte counter for fwrite */ - - /* pseudo use to avoid unused symbols */ - (void)WriteWavShort; - (void)WriteWavLong; - (void)WriteWavFloat; -#ifdef TWI_SUPPORT_BWF - (void)CreateWavBWF; - (void)CloseWavBWF; - (void)setDefaultLoudness; -#endif - - /* param check */ - if (!fileName) goto bail; - if (sampleRate == 0) goto bail; - if (sampleRate > 768000) goto bail; - if (numChannels == 0) goto bail; - if (numChannels > 64) goto bail; - if (bps != 16 && bps != 24 && bps != 32) goto bail; - - self = (WAVEFILEOUT*)calloc(1, sizeof(WAVEFILEOUT)); - if (!self) goto bail; /* return NULL; */ - - self->theFile = fopen(fileName, "wb+"); - if (!self->theFile) goto bail; - - /* WAV-Header */ - whdr.riffType = BigEndian32('R','I','F','F'); - whdr.riffSize = LittleEndian32(0xffffffff); /* set to maximum, if fseek() doesn't work later */ - whdr.waveType = BigEndian32('W','A','V','E'); - /* write to file */ - ByteCnt = 0; - ByteCnt += fwrite(&whdr, 1, sizeof(whdr), self->theFile); - - /* ds64/JUNK-Chunk */ - ds64ch.formatType = BigEndian32('J','U','N','K'); - ds64ch.formatSize = LittleEndian32(sizeof(__tinyWaveOutDs64Chunk) - 8); - ds64ch.riffSize64 = (TWO_UINT64) -1; - ds64ch.dataSize64 = (TWO_UINT64) -1; - ds64ch.sampleCount64 = (TWO_UINT64) -1; - ds64ch.tableLength = 0; - self->junkChunkOffset = ByteCnt; - ByteCnt += fwrite(&ds64ch, 1, sizeof(ds64ch), self->theFile); - -#ifdef TWO_SUPPORT_BWF - /* BEXT-Chunk */ - if (hBwfData) { - memset(&wbextch, 0, sizeof(__tinyWaveOutBextChunk)); - wbextch.formatType = BigEndian32('b','e','x','t'); - wbextch.formatSize = LittleEndian32(sizeof(__tinyWaveOutBextChunk) - 8); - wbextch.version = 0x0002; - wbextch.loudnessVal = EncodeLoudness(hBwfData->loudnessVal); - wbextch.loudnessRange = EncodeLoudness(hBwfData->loudnessRange); - wbextch.maxTruePeakLevel = EncodeLoudness(hBwfData->maxTruePeakLevel); - wbextch.maxMomentaryLoudnes = EncodeLoudness(hBwfData->maxMomentaryLoudnes); - wbextch.maxShortTermLoudness = EncodeLoudness(hBwfData->maxShortTermLoudness); - /* t.b.d.: more values */ - - /* write to file */ - self->bextChunkOffset = ByteCnt; - ByteCnt += fwrite(&wbextch, 1, sizeof(wbextch), self->theFile); - } -#endif - - /* FMT-Chunk */ - wfch.formatType = BigEndian32('f','m','t',' '); - wfch.formatSize = LittleEndian32(16); - switch (bps) { - case 16: - case 24: - wfch.formatTag = LittleEndian16(0x0001); /* WAVE_FORMAT_PCM */ - break; - case 32: - wfch.formatTag = LittleEndian16(0x0003); /* WAVE_FORMAT_IEEE_FLOAT */ - break; - default: - goto bail; - } - self->bps = bps; - wfch.bitsPerSample = LittleEndian16(bps); - wfch.numChannels = LittleEndian16(numChannels); - blockAlignment = numChannels * (bps >> 3); - wfch.blockAlignment = LittleEndian16(blockAlignment); - wfch.sampleRate = LittleEndian32(sampleRate); - wfch.bytesPerSecond = LittleEndian32(sampleRate * blockAlignment); - /* tbd: wavfmt ext hdr here */ - /* write to file */ - self->fmtChunkOffset = ByteCnt; - ByteCnt += fwrite(&wfch, 1, sizeof(wfch), self->theFile); - - /* DATA-Chunk */ - self->dataChunkOffset = ByteCnt; - wdch.dataType = BigEndian32('d','a','t','a'); - wdch.dataSize = LittleEndian32(0xffffffff - ByteCnt); /* yet unknown. set to maximum of 4 GB file */ - /* write to file */ - ByteCnt += fwrite(&wdch, 1, sizeof(wdch), self->theFile); - - self->dataSize = 0; - - /* self->dataSizeLimit = 0x7fffffff - ByteCnt; */ /* maximum size for data chunk for 2 GB files */ - self->dataSizeLimit = 0xffffffff - ByteCnt; /* maximum size for data chunk for 4 GB files */ - self->dataSizeLimit64 = 0xffffffffffffffff - ByteCnt; /* maximum size for data chunk for 64 bit addressable files */ - - self->clipCount = 0; - self->blockAlign = blockAlignment; - - return self; - - bail: - if ( NULL != self) { - free(self); - } - - return NULL; -} - -static WAVEFILEOUT* CreateWav( - const char* fileName, - const unsigned int sampleRate, - const unsigned int numChannels, - const unsigned int bps - ) -{ -#ifdef TWO_SUPPORT_BWF - return __CreateWavInternal(fileName, sampleRate, numChannels, bps, NULL); -#else - return __CreateWavInternal(fileName, sampleRate, numChannels, bps); -#endif -} - -#ifdef TWO_SUPPORT_BWF -static WAVEFILEOUT* CreateWavBWF( - const char *fileName, - const unsigned int sampleRate, - const unsigned int numChannels, - const unsigned int bps, - const WAVEOUT_LOUDNESSINFO *hBwfData - ) -{ - return __CreateWavInternal(fileName, sampleRate, numChannels, bps, hBwfData); -} -#endif - -#define MAX_PCM16 (+32767) -#define MIN_PCM16 (-32768) -static __inline int CLIP_PCM16(int sample, TWO_UINT64* clipcount) -{ - int tmp = sample; - - if (sample >= MAX_PCM16) { - tmp = MAX_PCM16; - (*clipcount)++; - } else { - if (sample <= MIN_PCM16) { - tmp = MIN_PCM16; - (*clipcount)++; - } - } - - return tmp; -} - -#define MAX_PCM24 (+8388607) -#define MIN_PCM24 (-8388608) -static __inline int CLIP_PCM24(int sample, TWO_UINT64* clipcount) -{ - int tmp = sample; - - if (sample >= MAX_PCM24) { - tmp = MAX_PCM24; - (*clipcount)++; - } else { - if (sample <= MIN_PCM24) { - tmp = MIN_PCM24; - (*clipcount)++; - } - } - - return tmp; -} - -#define MAX_FLOAT32 (+1.0f) -#define MIN_FLOAT32 (-1.0f) -static __inline float CLIP_FLOAT32(float sample, TWO_UINT64* clipcount) -{ - float tmp = sample; - - if (sample >= MAX_FLOAT32) { - tmp = MAX_FLOAT32; - (*clipcount)++; - } else { - if (sample <= MIN_FLOAT32) { - tmp = MIN_FLOAT32; - (*clipcount)++; - } - } - - return tmp; -} - - - -static int __WriteSample16( - WAVEFILEOUT* self, - int sample, - int scale - ) -{ - size_t cnt; - short v; - - if ((scale - 16) > 0) - sample = sample >> (scale - 16); - else - sample = (int) ((uint32_t) sample << (16 - scale)); - - v = (short)CLIP_PCM16(sample, &(self->clipCount)); -#ifdef __TWO_BE - v = LittleEndian16(v); -#endif - - cnt = fwrite(&v, sizeof(short), 1, self->theFile); - - if (cnt == 1) { - self->dataSize += 2; - return __TWO_SUCCESS; - } - - return __TWO_ERROR; -} - - -static int __WriteSample24( - WAVEFILEOUT* self, - int sample, - int scale - ) -{ - size_t cnt; - int v; - - if ((scale - 24) > 0) - sample = sample >> (scale - 24); - else - sample = (int) (((unsigned int)sample) << (24 - scale)); - - v = (int)CLIP_PCM24(sample, &(self->clipCount)); -#ifdef __TWO_BE - v = LittleEndian32s(v); -#endif - cnt = fwrite(&v, 3, 1, self->theFile); - - if (cnt == 1) { - self->dataSize += 3; - return __TWO_SUCCESS; - } - - return __TWO_ERROR; -} - - -static int __WriteSample32( - WAVEFILEOUT* self, - float sample - ) -{ - size_t cnt; - union fl_int { - float v_float; - int v_int; - }; - union fl_int v; - -#if CLIP_FLOAT - v.v_float = CLIP_FLOAT32(sample, &(self->clipCount)); -#else - v.v_float = sample; - if((sample > 1.0f) || (sample <-1.0f)) - self->clipCount++; -#endif - -#ifdef __TWO_BE - v.v_int = LittleEndian32s(v.v_int); -#endif - cnt = fwrite(&v, 4, 1, self->theFile); - - if (cnt == 1) { - self->dataSize += 4; - return __TWO_SUCCESS; - } - - return __TWO_ERROR; -} - - -static int __WriteSampleInt( - WAVEFILEOUT* self, - int sample, - int scale - ) -{ - int err; - - if (!self) return __TWO_ERROR; - - - switch (self->bps) { - - case 16: - err = __WriteSample16(self, sample, scale); - break; - - case 24: - err = __WriteSample24(self, sample, scale); - break; - - default: - err = __TWO_ERROR; - break; - } - - return err; -} - - -/* this function expects values in the 16 bit range +-32767/8 */ -static int WriteWavShort( - WAVEFILEOUT* self, - short sampleBuffer[], - unsigned int nSamples - ) -{ - unsigned long i; - int err = __TWO_SUCCESS; - - if (!self) return __TWO_ERROR; - if (!sampleBuffer) return __TWO_ERROR; - if (__dataSizeChk(self, nSamples * sizeof(short))) return __TWO_ERROR; - - for (i=0; i< nSamples; i++) { - if (self->bps == 32) - { - err = __WriteSample32(self, sampleBuffer[i] / 32768.0f); - } - else - { - err = __WriteSampleInt(self, (int)sampleBuffer[i], 16); - } - if (err != __TWO_SUCCESS) return err; - } - - return __TWO_SUCCESS; -} - - -/* this function expects values in the 24 bit range +-8388607/8 */ -static int WriteWavLong( - WAVEFILEOUT* self, - int sampleBuffer[], - unsigned int nSamples - ) -{ - unsigned long i; - int err = __TWO_SUCCESS; - - if (!self) return __TWO_ERROR; - if (!sampleBuffer) return __TWO_ERROR; - if (__dataSizeChk(self, nSamples * sizeof(int))) return __TWO_ERROR; - - for (i = 0; i < nSamples; i++) { - if (self->bps == 32) - { - err = __WriteSample32(self, sampleBuffer[i] / 8388608.0f); - } - else - { - err = __WriteSampleInt(self, sampleBuffer[i], 24); - } - if (err != __TWO_SUCCESS) return err; - } - - return __TWO_SUCCESS; -} - - -/* this function expects normalized values in the range +-1.0 */ -#define MAX_FL (+2.0f * 8388608.0f ) -#define MIN_FL (-2.0f * 8388608.0f ) -#define CLIP_FL(x) ( ((x) >= MAX_FL) ? MAX_FL : (((x) <= MIN_FL) ? MIN_FL : (x)) ) -static int WriteWavFloat( - WAVEFILEOUT* self, - float sampleBuffer[], - unsigned int nSamples - ) -{ - unsigned int i; - int err = __TWO_SUCCESS; - - if (!self) return __TWO_ERROR; - if (!sampleBuffer) return __TWO_ERROR; - if (__dataSizeChk(self, nSamples * sizeof(float))) return __TWO_ERROR; - - for (i=0; ibps == 32) - { - err = __WriteSample32(self, sampleBuffer[i]); - } - else - { - float tmp = CLIP_FL(sampleBuffer[i] * 8388608.0f); /* CLIP_FL is just to avoid an INT overrun before the actual cast to int, real clipping and counting is done below */ - err = __WriteSampleInt(self, (int) tmp, 24); - } - if (err != __TWO_SUCCESS) return err; - } - - return __TWO_SUCCESS; -} - - -static int CloseWav(WAVEFILEOUT* self) -{ - unsigned int riffSize_le = 0; - unsigned int dataSize_le = 0; - TWO_UINT64 riffSize64 = 0; - TWO_UINT64 dataSize64 = 0; - TWO_UINT64 sampleCount64 = 0; /* nr of samples in the WAVE sense: 1 sample are all pcm samples of all channels of one time slice */ - int mustWriteRF64 = 0; - - if (!self) return __TWO_ERROR; - - /* check for 4 GB (switch to RF64) */ - if ( self->dataSize > self->dataSizeLimit ) { - /* when we exceed 4 GB: switch from std wave header to RF64 header */ - mustWriteRF64 = 1; - } - - /* calc header values */ - if (mustWriteRF64 == 0) { - /* write padding byte if dataSize is uneven */ - int pad = 0; - if (self->dataSize % 2 > 0) { - char tmp= 0x00; - fwrite(&tmp, sizeof(char), 1, self->theFile); - pad = 1; - } - riffSize_le = LittleEndian32(self->dataChunkOffset - 8 + 8 + (unsigned int)self->dataSize + pad); /* sizeof(hdr) - (8 bytes of riff chunk header) + (8 bytes data chunk header) + sizeof(raw-pcm-data) + padding Byte */ - dataSize_le = LittleEndian32((unsigned int)self->dataSize); - } else { - riffSize_le = 0xffffffff; - dataSize_le = 0xffffffff; - riffSize64 = LittleEndian64( self->dataSize + (TWO_UINT64)self->dataChunkOffset ); - dataSize64 = LittleEndian64( self->dataSize ); - sampleCount64 = LittleEndian64( self->dataSize / (TWO_UINT64)self->blockAlign ); - } - - /* now overwrite length/size values in header with the actual/real ones */ - if (mustWriteRF64 == 0) { - /* riffsize32 */ - fseek(self->theFile, 4, SEEK_SET); - fwrite(&riffSize_le, sizeof(riffSize_le), 1, self->theFile); - /* datasize32 */ - fseek(self->theFile, self->dataChunkOffset + 4, SEEK_SET); - fwrite(&dataSize_le, sizeof(dataSize_le), 1, self->theFile); - } else { - unsigned int rf64sig = BigEndian32('R','F','6','4'); - unsigned int ds64sig = BigEndian32('d','s','6','4'); - - /* replace RIFF->RF64 */ - fseek(self->theFile, 0, SEEK_SET); - fwrite(&rf64sig, sizeof(rf64sig), 1, self->theFile); - - /* riffsize32 */ - fseek(self->theFile, 4, SEEK_SET); - fwrite(&riffSize_le, sizeof(riffSize_le), 1, self->theFile); - - /* replace JUNK->ds64 */ - fseek(self->theFile, self->junkChunkOffset, SEEK_SET); - fwrite(&ds64sig, sizeof(ds64sig), 1, self->theFile); - - /* riffSize64, dataSize64, sampleCount64 */ - fseek(self->theFile, self->junkChunkOffset + 8, SEEK_SET); - fwrite(&riffSize64, sizeof(riffSize64), 1, self->theFile); - fwrite(&dataSize64, sizeof(dataSize64), 1, self->theFile); - fwrite(&sampleCount64, sizeof(sampleCount64), 1, self->theFile); - - /* datasize32 */ - fseek(self->theFile, self->dataChunkOffset + 4, SEEK_SET); - fwrite(&dataSize_le, sizeof(dataSize_le), 1, self->theFile); - } - - fclose(self->theFile); - free(self); - - return __TWO_SUCCESS; -} - -#ifdef TWO_SUPPORT_BWF -static int CloseWavBWF( - WAVEFILEOUT* self, - WAVEOUT_LOUDNESSINFO bextData - ) -{ - int wordData; - - if (!self) return __TWO_ERROR; - - if (self->bextChunkOffset) { - /* Offset for Loudness Data in bext-chunk: 8: Chunk-Header, 412:prev.Data */ - fseek(self->theFile, self->bextChunkOffset+8+412, SEEK_SET); - - wordData = LittleEndian32(EncodeLoudness(bextData.loudnessVal)); - fwrite(&wordData, 2, 1, self->theFile); - - wordData = LittleEndian32(EncodeLoudness(bextData.loudnessRange)); - fwrite(&wordData, 2, 1, self->theFile); - - wordData = LittleEndian32(EncodeLoudness(bextData.maxTruePeakLevel)); - fwrite(&wordData, 2, 1, self->theFile); - - wordData = LittleEndian32(EncodeLoudness(bextData.maxMomentaryLoudnes)); - fwrite(&wordData, 2, 1, self->theFile); - - wordData = LittleEndian32(EncodeLoudness(bextData.maxShortTermLoudness)); - fwrite(&wordData, 2, 1, self->theFile); - } - - return CloseWav(self); -} -#endif - -/*------------- local subs ----------------*/ - -static __inline unsigned int BigEndian32(char a, char b, char c, char d) -{ -#ifdef __TWO_LE - return - (unsigned int) d << 24 | - (unsigned int) c << 16 | - (unsigned int) b << 8 | - (unsigned int) a ; -#else - return - (unsigned int) a << 24 | - (unsigned int) b << 16 | - (unsigned int) c << 8 | - (unsigned int) d ; -#endif -} - - -static __inline unsigned int LittleEndian32(unsigned int v) -{ -#ifdef __TWO_LE - return v; -#else - return - (v & 0x000000FF) << 24 | - (v & 0x0000FF00) << 8 | - (v & 0x00FF0000) >> 8 | - (v & 0xFF000000) >> 24 ; -#endif -} - - -/* signed version of the above */ -static __inline unsigned int LittleEndian32s(int v) -{ -#ifdef __TWO_LE - return v; -#else - return - (v & 0x000000FF) << 24 | - (v & 0x0000FF00) << 8 | - (v & 0x00FF0000) >> 8 | - (v & 0xFF000000) >> 24 ; -#endif -} - - -static __inline short LittleEndian16(short v) -{ -#ifdef __TWO_LE - return v; -#else - return ((v << 8) & 0xFF00) | ((v >> 8) & 0x00FF); -#endif -} - -static __inline TWO_UINT64 LittleEndian64(TWO_UINT64 v) -{ -#ifdef __TWO_LE - return v; -#else - return - (v & 0x00000000000000FF) << 56 | - (v & 0x000000000000FF00) << 40 | - (v & 0x0000000000FF0000) << 24 | - (v & 0x00000000FF000000) << 8 | - (v & 0x000000FF00000000) >> 8 | - (v & 0x0000FF0000000000) >> 24 | - (v & 0x00FF000000000000) >> 40 | - (v & 0xFF00000000000000) >> 56 ; -#endif -} - -#ifdef TWO_SUPPORT_BWF -static unsigned int EncodeLoudness(float x) -{ - int s = (x>0)-(x<0); - return (int)( x*100.0f + s*0.5f ); -} -#endif - -static __inline int __dataSizeChk( WAVEFILEOUT* self, int newbytes ) -{ - if (!self) return __TWO_ERROR; - - if ( (self->dataSize + ((TWO_UINT64)newbytes) ) > self->dataSizeLimit64 ) { - return __TWO_ERROR; - } - - return __TWO_SUCCESS; -} - -#endif /* __TINYWAVEOUT_C_H__ */ - - - diff --git a/lib_lc3plus/tns_coder_fx.c b/lib_lc3plus/tns_coder_fx.c index 738f4e95b..e012abd0f 100644 --- a/lib_lc3plus/tns_coder_fx.c +++ b/lib_lc3plus/tns_coder_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" static void Parcor2Index(const Word16 parCoeff[] /*Q15*/, Word16 index[], Word16 order); @@ -16,7 +18,7 @@ static Word32 FIRLattice(Word16 order, const Word16 *parCoeff /*Q15*/, Word32 *s /*************************************************************************/ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cutoff_idx, Word16 order[], - Word16 *numfilters, Word16 enable_lpc_weighting, Word16 nSubdivisions, Word16 frame_dms, + Word16 *numfilters, Word16 enable_lpc_weighting, Word16 nSubdivisions, LC3PLUS_FrameDuration frame_dms, Word16 maxLen, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode @@ -49,6 +51,10 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu move16(); *numfilters = 1; move16(); + subdiv_startfreq = 0; + move16(); + subdiv_stopfreq = 0; + move16(); #ifdef ENABLE_HR_MODE if (hrmode) @@ -64,7 +70,15 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + *bits = 0; + order[0] = 0; + order[1] = 0; + *numfilters = 0; + goto tns_exit; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: startfreq[0] = 3; move16(); @@ -88,7 +102,7 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu maxOrder = 4; move16(); BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: startfreq[0] = 6; move16(); @@ -111,7 +125,7 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu xLen = shr_pos(xLen, 1); maxOrder = 4; BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: startfreq[0] = 9; move16(); subdiv_startfreq = tns_subdiv_startfreq_7_5ms[BW_cutoff_idx]; @@ -122,7 +136,7 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu xLen = add(tmp, add(tmp, tmp)); maxOrder = 8; BREAK; - default: /* 100 */ + case LC3PLUS_FRAME_DURATION_10MS: startfreq[0] = 12; move16(); @@ -143,9 +157,10 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu move16(); } BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } - IF (sub(BW_cutoff_idx, 3) >= 0 && frame_dms >= 50) + IF (sub(BW_cutoff_idx, 3) >= 0 && frame_dms >= LC3PLUS_FRAME_DURATION_5MS) { *numfilters = 2; startfreq[1] = shr_pos(xLen, 1); @@ -163,7 +178,7 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu subdiv_startfreq[nSubdivisions * j + iSubdivisions]); /*norms[iFilter][iSubdivisions] = norm2FLOAT(pSpectrum+iStartLine, iEndLine-iStartLine);*/ - headroom = getScaleFactor32_lc3plus(x + subdiv_startfreq[nSubdivisions * j + iSubdivisions], n); + headroom = getScaleFactor32(x + subdiv_startfreq[nSubdivisions * j + iSubdivisions], n); /* Calculate norm of spectrum band */ L_tmp = Norm32Norm(x + subdiv_startfreq[nSubdivisions * j + iSubdivisions], headroom, n, &shift); @@ -193,10 +208,14 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu SWITCH (frame_dms) { - case 25: facs_e = add(facs_e, 1); BREAK; - case 50: facs_e = add(facs_e, 1); BREAK; - case 75: BREAK; - case 100: BREAK; +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: assert(0); +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: facs_e = add(facs_e, 1); BREAK; + case LC3PLUS_FRAME_DURATION_5MS: facs_e = add(facs_e, 1); BREAK; + case LC3PLUS_FRAME_DURATION_7p5MS: BREAK; + case LC3PLUS_FRAME_DURATION_10MS: BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } tmp = sub(1, shl_pos(tmp, 1)); /* exponent of autocorrelation */ @@ -219,7 +238,7 @@ void processTnsCoder_fx(Word16 *bits, Word16 indexes[], Word32 x[], Word16 BW_cu L_tmp = L_mac0(L_tmp, tmpbuf[i], tmpbuf[i + lag]); } if (lag != 0) - L_tmp = Mpy_32_32_lc3plus(L_tmp, tnsAcfWindow_lc3plus[lag - 1]); + L_tmp = Mpy_32_32_lc3plus(L_tmp, tnsAcfWindow[lag - 1]); L_tmp = Mpy_32_16_lc3plus(L_tmp, facs); L_tmp = L_shl(L_tmp, facs_e); @@ -311,6 +330,10 @@ tns_disabled: order[j] = 0; } } + +#ifdef CR9_C_ADD_1p25MS +tns_exit: +#endif Dyn_Mem_Deluxe_Out(); } diff --git a/lib_lc3plus/tns_decoder_fx.c b/lib_lc3plus/tns_decoder_fx.c index aad24424c..7b9575f2d 100644 --- a/lib_lc3plus/tns_decoder_fx.c +++ b/lib_lc3plus/tns_decoder_fx.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.5.1 * +* ETSI TS 103 634 V1.6.1 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,6 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ +#include "options.h" +#include "wmc_auto.h" #include "functions.h" static Word32 IIRLattice(Word16 order, const Word16 *parCoeff, Word32 *state, Word32 x); @@ -14,7 +16,7 @@ static Word32 IIRLattice(Word16 order, const Word16 *parCoeff, Word32 *state, Wo /*************************************************************************/ void processTnsDecoder_fx(Word16 rc_idx[], Word32 x[], Word16 xLen, Word16 order[], Word16 *x_e, Word16 BW_stopband_idx, - Word16 frame_dms, Word8 *scratchBuffer + LC3PLUS_FrameDuration frame_dms, Word8 *scratchBuffer #ifdef ENABLE_HR_MODE , Word16 hrmode #endif @@ -45,26 +47,40 @@ void processTnsDecoder_fx(Word16 rc_idx[], Word32 x[], Word16 xLen, Word16 order SWITCH (frame_dms) { - case 25: +#ifdef CR9_C_ADD_1p25MS + case LC3PLUS_FRAME_DURATION_1p25MS: + startfreq[0] = 3; move16(); + BW_stopband = shr_pos(BW_stopband, 3); + BREAK; +#endif + case LC3PLUS_FRAME_DURATION_2p5MS: startfreq[0] = 3; move16(); BW_stopband = shr_pos(BW_stopband, 2); BREAK; - case 50: + case LC3PLUS_FRAME_DURATION_5MS: startfreq[0] = 6; move16(); BW_stopband = shr_pos(BW_stopband, 1); BREAK; - case 75: + case LC3PLUS_FRAME_DURATION_7p5MS: startfreq[0] = 9; move16(); BW_stopband = add(shr_pos(BW_stopband, 2), add(shr_pos(BW_stopband, 2), shr_pos(BW_stopband, 2))); BREAK; - case 100: startfreq[0] = 12; BREAK; + case LC3PLUS_FRAME_DURATION_10MS: startfreq[0] = 12; BREAK; + case LC3PLUS_FRAME_DURATION_UNDEFINED: assert(0); } - IF (sub(BW_stopband_idx, 3) >= 0 && frame_dms >= 50) + IF (sub(BW_stopband_idx, 3) >= 0 && frame_dms >= LC3PLUS_FRAME_DURATION_5MS) { numfilters = 2; startfreq[1] = shr_pos(BW_stopband, 1); } + +#ifdef CR9_C_ADD_1p25MS + IF (frame_dms <= LC3PLUS_FRAME_DURATION_1p25MS) { + numfilters = 0; + } +#endif + stopfreq = 0; test(); test(); @@ -77,8 +93,8 @@ void processTnsDecoder_fx(Word16 rc_idx[], Word32 x[], Word16 xLen, Word16 order { f = startfreq[1]; move16(); } - s1 = getScaleFactor32_lc3plus(x, f); - s2 = getScaleFactor32_lc3plus(x + f, sub(xLen, f)); + s1 = getScaleFactor32(x, f); + s2 = getScaleFactor32(x + f, sub(xLen, f)); s = s_min(s1, sub(s2, 7)); /* 7 bits of headroom for IIR filtering */ *x_e = sub(*x_e, s); -- GitLab From 26fb5a3d19df93c3514c5d0924d30e0e761c40ff Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 28 Oct 2025 13:48:37 -0400 Subject: [PATCH 044/351] alternative fix to 2015 --- lib_com/options.h | 5 ++++- lib_com/preemph_fx.c | 29 ++++++++++++++++++++++++++- lib_com/prot_fx.h | 15 +++++++++++++- lib_enc/ivas_core_pre_proc_front_fx.c | 6 ++++-- lib_enc/ivas_core_pre_proc_fx.c | 6 ++++-- 5 files changed, 54 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c0c815697..2d722bee1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,10 @@ #define FIX_2164_ASSERT_IN_OMASA_PREPROC_FOR_EDIT /* Nokia: Issue 2164: Prevent overflow when calculating equalization coefficient for editing before clamping to safe range */ #define FIX_BASOP_ASSERT_IN_TONAL_MDCT_PLC /* FhG: fix for issue 2165 - using saturating addition in tonal MDCT PLC function */ -#define FIX_2015_PREMPH_SAT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor */ +/*#define FIX_2015_PREMPH_SAT*/ /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor */ +#ifndef FIX_2015_PREMPH_SAT +#define FIX_2015_PREMPH_SAT_ALT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, alternative fix where only preemphis gets 1 more bit headroom */ +#endif /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c index 0184a4aa3..e8dfb4018 100644 --- a/lib_com/preemph_fx.c +++ b/lib_com/preemph_fx.c @@ -39,7 +39,7 @@ void preemph_copy_fx( return; } - +#ifndef FIX_2015_PREMPH_SAT_ALT void preemph_copy_32fx( const Word16 x[], /* i : input signal Qx */ Word32 y[], /* o : output signal Qx */ @@ -66,7 +66,34 @@ void preemph_copy_32fx( return; } +#else +void preemph_copy_32fx2( + const Word16 x[], /* i : input signal Qx */ + Word32 y[], /* o : output signal Qx-1*/ + const Word16 mu, /* i : preemphasis coefficient Q15 */ + const Word16 lg, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (x[-1]) Qx */ +) +{ + Word16 i, temp; + + temp = x[lg - 1]; /* Qx */ + move16(); + FOR( i = lg - 1; i > 0; i-- ) + { + y[i] = L_msu0_sat( L_mult( x[i], 16384 ), x[i - 1], mu ); /* Qx+16 */ + move16(); + } + y[0] = L_msu0_sat( L_mult( x[0], 16384 ), *mem, mu ); /* Qx+16 */ + move16(); + + *mem = temp; /* Qx */ + move16(); + + return; +} +#endif /*-------------------------------------------------------------* * preemph_ivas_fx() * diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 32b8a00ee..8202b5548 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2754,8 +2754,11 @@ void lag_wind_32( // preemp_fx.c #define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) ) +#ifndef FIX_2015_PREMPH_SAT_ALT #define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) ) - +#else +#define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx2( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) ) +#endif void preemph_copy_fx( const Word16 x[], /* i : i signal Qx */ Word16 y[], /* o : output signal Qx */ @@ -2764,6 +2767,7 @@ void preemph_copy_fx( Word16 *mem /* i/o: memory (x[-1]) Qx */ ); +#ifndef FIX_2015_PREMPH_SAT_ALT void preemph_copy_32fx( const Word16 x[], /* i : i signal Qx */ Word32 y[], /* o : output signal Qx */ @@ -2771,6 +2775,15 @@ void preemph_copy_32fx( const Word16 lg, /* i : vector size Q0 */ Word16 *mem /* i/o: memory (x[-1]) Qx */ ); +#else +void preemph_copy_32fx2( + const Word16 x[], /* i : i signal Qx */ + Word32 y[], /* o : output signal Qx */ + const Word16 mu, /* i : preemphasis coefficient Q15 */ + const Word16 lg, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (x[-1]) Qx */ +); +#endif void E_UTIL_f_preemph2( Word16 shift, /* Q0 */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index aaa0c396a..0711b778d 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -718,9 +718,11 @@ ivas_error pre_proc_front_ivas_fx( *Q_new = add( *Q_new, Q_inp_const ); move16(); - +#ifndef FIX_2015_PREMPH_SAT_ALT Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( *Q_new, st->q_inp ) ); /* Q_new */ - +#else + Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( add( *Q_new, 1 ), st->q_inp ) ); /* Q_new */ +#endif Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), sub( *Q_new, st->q_inp ) ); /* Q_new */ cldfbScale.hb_scale = cldfbScale.lb_scale; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 623b38e68..5246e2026 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1071,9 +1071,11 @@ ivas_error ivas_compute_core_buffers_fx( } st->Q_max_16k[i] = shift; move16(); - +#ifndef FIX_2015_PREMPH_SAT_ALT Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new ); - +#else + Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) ); +#endif Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new ); } ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */ -- GitLab From 411c2f3627dc51c08b1458f74dfff148a8b21ac7 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 28 Oct 2025 18:51:40 +0100 Subject: [PATCH 045/351] add new file com_entropy.c and setup_com_lc3plus.c to MSVC solution --- Workspace_msvc/lib_lc3plus.vcxproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 4d937cf64..64a966e29 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -109,6 +109,7 @@ + @@ -166,6 +167,7 @@ + @@ -192,4 +194,4 @@ - \ No newline at end of file + -- GitLab From a51c49619841707dd6def5e6ad36fe65cd71c157 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 28 Oct 2025 13:56:58 -0400 Subject: [PATCH 046/351] fix clang format --- lib_com/prot_fx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8202b5548..1f373c285 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2753,7 +2753,7 @@ void lag_wind_32( ); // preemp_fx.c -#define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) ) +#define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) ) #ifndef FIX_2015_PREMPH_SAT_ALT #define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) ) #else -- GitLab From 35a5238402d02a1dc28a8668045be506d8e0d35c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 29 Oct 2025 09:15:01 +0100 Subject: [PATCH 047/351] simplify if condition by removing irrelevant part --- lib_dec/fd_cng_dec_fx.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index e8cf26bd4..8e20941f9 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -3096,13 +3096,7 @@ void generate_comfort_noise_dec_ivas_fx( { /* Real part in FFT bins */ test(); - test(); -#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( nchan_out, 1 ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) -#else - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) -#endif + IF( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) { rand_gauss_fx( &tmp1, seed, Q15 ); /*Q15*/ rand_gauss_fx( &tmp2, seed2, Q15 ); /*Q15*/ @@ -3129,13 +3123,7 @@ void generate_comfort_noise_dec_ivas_fx( /* Imaginary part in FFT bins */ test(); - test(); -#ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( nchan_out, 1 ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) -#else - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) ) -#endif + IF( EQ_16( st->element_mode, IVAS_SCE ) && st->cng_ism_flag ) { rand_gauss_fx( &tmp1, seed, Q15 ); /*Q15*/ rand_gauss_fx( &tmp2, seed2, Q15 ); /*Q15*/ -- GitLab From 2ae89b033f0a4a4996330a34cb4c44f6f2c2e03f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 29 Oct 2025 09:21:25 +0100 Subject: [PATCH 048/351] apply clang-format --- lib_dec/fd_cng_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 8e20941f9..756a39e9b 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2934,7 +2934,7 @@ void generate_comfort_noise_dec_ivas_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG c1 = Sqrt16( hFdCngCom->coherence_fx[0], &temp ); /*Q15 - temp*/ #else - c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ + c1 = Sqrt16( hFdCngCom->coherence_fx, &temp ); /*Q15 - temp*/ #endif c1 = shl( c1, temp ); /*Q15*/ temp = 0; @@ -3723,7 +3723,7 @@ void generate_comfort_noise_dec_hf_ivas_fx( #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG c1 = Sqrt16( hFdCngCom->coherence_fx[sub( MDCT_ST_DTX_NUM_COHERENCE_BANDS, 1 )], &s ); /*Q15 - s*/ #else - c1 = Sqrt16( hFdCngCom->coherence_fx, &s ); /*Q15 - s*/ + c1 = Sqrt16( hFdCngCom->coherence_fx, &s ); /*Q15 - s*/ #endif c1 = shl( c1, s ); // Q15 -- GitLab From 13fa1b7cf7a74acc24d8183c49096f8df58bb434 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Oct 2025 11:28:30 +0100 Subject: [PATCH 049/351] [fix] IVAS LC3plus unit test; add new helper function to translate integer framesize to newly introduced enum --- lib_isar/isar_lc3plus_common.c | 36 ++++++++++++++++++++++++++++++++++ lib_isar/isar_lc3plus_common.h | 3 +++ lib_isar/isar_lc3plus_dec.c | 2 +- lib_isar/isar_lc3plus_enc.c | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 28435cea9..d7d5bf025 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -58,6 +58,12 @@ ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( } +/*-----------------------------------------------------------------------------------------* + * Function IVAS_LC3PLUS_LC3plusRtpErrToIvasErr() + * + * + *-----------------------------------------------------------------------------------------*/ + ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ) { @@ -86,3 +92,33 @@ ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( return IVAS_ERR_UNKNOWN; } + +/*-----------------------------------------------------------------------------------------* + * Function IVAS_LC3PLUS_UsToLC3plusFrameDuration() + * + * + *-----------------------------------------------------------------------------------------*/ + +LC3PLUS_FrameDuration IVAS_LC3PLUS_UsToLC3plusFrameDuration( + const int16_t lc3PlusFrameDurationUs ) +{ + switch ( lc3PlusFrameDurationUs ) + { +#ifdef CR9_C_ADD_1p25MS /* TODO LC3plus: verify switch stripping on update */ + case 1250: + return LC3PLUS_FRAME_DURATION_1p25MS; +#endif + case 2500: + return LC3PLUS_FRAME_DURATION_2p5MS; + case 5000: + return LC3PLUS_FRAME_DURATION_5MS; + case 7500: + return LC3PLUS_FRAME_DURATION_7p5MS; + case 10000: + return LC3PLUS_FRAME_DURATION_10MS; + default: + break; + } + + return LC3PLUS_FRAME_DURATION_UNDEFINED; +} diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index eb3e7b0ad..3b52e5b3f 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -61,4 +61,7 @@ ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( const LC3PLUS_Error lc3PlusError ); /*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ); +/*! utility function to convert a value in microseconds to an LC3PLUS_FrameDuration */ +LC3PLUS_FrameDuration IVAS_LC3PLUS_UsToLC3plusFrameDuration( const int16_t lc3PlusFrameDuration ); + #endif /* ISAR_LC3PLUS_COM_H */ diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index f8cbe9582..2ac21e4d3 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -137,7 +137,7 @@ ivas_error ISAR_LC3PLUS_DEC_Open( return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_dec_init failed\n" ); } - err = lc3plus_dec_set_frame_dms( ( *handle )->handles[iCh], config.lc3plus_frame_duration_us / 100 ); + err = lc3plus_dec_set_frame_dms( ( *handle )->handles[iCh], IVAS_LC3PLUS_UsToLC3plusFrameDuration( config.lc3plus_frame_duration_us ) ); if ( LC3PLUS_OK != err ) { ISAR_LC3PLUS_DEC_Close( handle ); diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index af89213e6..60121a11f 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -163,7 +163,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_init failed\n" ); } - err = lc3plus_enc_set_frame_dms( ( *handle )->handles[iCh], config.lc3plus_frame_duration_us / 100 ); + err = lc3plus_enc_set_frame_dms( ( *handle )->handles[iCh], IVAS_LC3PLUS_UsToLC3plusFrameDuration( config.lc3plus_frame_duration_us ) ); if ( err != LC3PLUS_OK ) { ISAR_LC3PLUS_ENC_Close( handle ); -- GitLab From c0e93b0b20924ad491c1e44f9cdf2e363f54da25 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Oct 2025 14:05:43 +0100 Subject: [PATCH 050/351] remove unsupported frame durations from helper func --- lib_isar/isar_lc3plus_common.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index d7d5bf025..03f31cf8e 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -104,16 +104,8 @@ LC3PLUS_FrameDuration IVAS_LC3PLUS_UsToLC3plusFrameDuration( { switch ( lc3PlusFrameDurationUs ) { -#ifdef CR9_C_ADD_1p25MS /* TODO LC3plus: verify switch stripping on update */ - case 1250: - return LC3PLUS_FRAME_DURATION_1p25MS; -#endif - case 2500: - return LC3PLUS_FRAME_DURATION_2p5MS; case 5000: return LC3PLUS_FRAME_DURATION_5MS; - case 7500: - return LC3PLUS_FRAME_DURATION_7p5MS; case 10000: return LC3PLUS_FRAME_DURATION_10MS; default: -- GitLab From 57ec6a477cb63b55cd97df66cf810647270730b1 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Oct 2025 16:14:01 +0100 Subject: [PATCH 051/351] update LC3plus code resulting from modifications to integration script --- lib_lc3plus/basop_util_lc3plus.c | 4 +- lib_lc3plus/constants.c | 6 +-- lib_lc3plus/dct2_fx.c | 14 +++--- lib_lc3plus/dec_entropy.c | 14 +++--- lib_lc3plus/dec_lc3plus.c | 8 +-- lib_lc3plus/defines.h | 30 +++++------ lib_lc3plus/enc_lc3plus.c | 6 +-- lib_lc3plus/estimate_global_gain_fx.c | 70 +++++++++++++------------- lib_lc3plus/fft_lc3plus.c | 2 +- lib_lc3plus/functions.h | 4 +- lib_lc3plus/near_nyquist_detector_fx.c | 6 +-- lib_lc3plus/plc_phecu_fec_hq_fx.c | 4 +- lib_lc3plus/pvq_dec_fx.c | 2 +- lib_lc3plus/pvq_enc_fx.c | 2 +- lib_lc3plus/rom_basop_util_lc3plus.h | 2 +- lib_lc3plus/setup_com_lc3plus.c | 2 +- lib_lc3plus/setup_enc_lc3plus.c | 4 +- lib_lc3plus/sns_compute_scf_fx.c | 8 +-- lib_lc3plus/sns_quantize_scf_fx.c | 14 +++--- 19 files changed, 101 insertions(+), 101 deletions(-) diff --git a/lib_lc3plus/basop_util_lc3plus.c b/lib_lc3plus/basop_util_lc3plus.c index bb7f572d3..348e11b24 100644 --- a/lib_lc3plus/basop_util_lc3plus.c +++ b/lib_lc3plus/basop_util_lc3plus.c @@ -88,7 +88,7 @@ Word32 BASOP_Util_Log2(Word32 x) -#ifdef LOG2_LC_APPROX +#ifdef LOG2_LC_APPROX /* LC log2 with 16 segment piecewise 2nd order minmax optimized approximation */ Word32 BASOP_Util_Log2_LC(Word32 L_x) @@ -318,7 +318,7 @@ Word32 BASOP_Util_InvLog2_pos(Word32 x, Word16 *exp) } ELSE IF(x == 0) { -#ifdef LRSNS_ALLZERO_FIX +#ifdef LRSNS_ALLZERO_FIX *exp = 2; move16(); return (1L << 29); /* 2^29/(2^(31-(+2)) = 1.0 exactly */ #else diff --git a/lib_lc3plus/constants.c b/lib_lc3plus/constants.c index 1d00d56e0..c8aa477ef 100644 --- a/lib_lc3plus/constants.c +++ b/lib_lc3plus/constants.c @@ -544,7 +544,7 @@ const Word16 bands_offset_with_one_max_lin_1_25ms[NUM_SAMP_FREQ] = {-1, 20, 30, const Word16 bands_offset_with_two_max_lin_1_25ms[NUM_SAMP_FREQ] = {0, 0, 0, 0, 0 #ifdef ENABLE_HR_MODE , 0 -#endif +#endif }; #endif #endif /* CR9_C_ADD_1p25MS */ @@ -1798,7 +1798,7 @@ RAM_ALIGN const Word16 POW_ATT_TABLE1[OFF_FRAMES_LIMIT + 1] = { #ifdef PLC2_FADEOUT_IN_MS #if PLC2_FADEOUT_IN_MS == 0 -#else /* PLC2_FADEOUT_IN_MS == 0 */ +#else /* PLC2_FADEOUT_IN_MS == 0 */ RAM_ALIGN const Word16 POW_ATT_TABLE_p3x9_14_7[OFF_FRAMES_LIMIT + 1] = { 32767, @@ -1880,7 +1880,7 @@ RAM_ALIGN const Word16 fade_scheme_tab_fx[24 / 2][3] = { #endif /* PLC2_FADEOUT_IN_MS == 0 */ -#else /* PLC2_FADEOUT_IN_MS */ +#else /* PLC2_FADEOUT_IN_MS */ RAM_ALIGN const Word16 *const POW_ATT_TABLES[1 + 2] = { NULL, POW_ATT_TABLE1 /*1 .3dB steps */, diff --git a/lib_lc3plus/dct2_fx.c b/lib_lc3plus/dct2_fx.c index 6d428cdc5..63d513219 100644 --- a/lib_lc3plus/dct2_fx.c +++ b/lib_lc3plus/dct2_fx.c @@ -478,8 +478,8 @@ void dct16_W32int_fx(const Word16 *in, { -#define Mpy_32_16op(Lx,y) Mpy_32_16_lc3plus(Lx, y ) /* two-three cycle count as in existing STL */ -#define Mpy_32_16_0op(Lx,y) Mpy_32_16_0_0(Lx,y ) /* no rounding , STL shift cost still there */ +#define Mpy_32_16op(Lx,y) Mpy_32_16_lc3plus(Lx, y ) /* two-three cycle count as in existing STL */ +#define Mpy_32_16_0op(Lx,y) Mpy_32_16_0_0(Lx,y ) /* no rounding , STL shift cost still there */ Dyn_Mem_Deluxe_In( @@ -496,7 +496,7 @@ void dct16_W32int_fx(const Word16 *in, #define INSCALE (1<<(15-INMARGIN) ) #endif -#if INMARGIN == 0 +#if INMARGIN == 0 L_a0 = L_deposit_h(add(in[15], in[0])); /* Word16 Q11 deposited 16 levels up, becomes Q27, NB add can still potentially saturate ! */ L_a1 = L_deposit_h(add(in[14], in[1])); L_a2 = L_deposit_h(add(in[13], in[2])); @@ -537,7 +537,7 @@ void dct16_W32int_fx(const Word16 *in, L_b6 = L_sub(L_a1, L_a6); L_b7 = L_sub(L_a0, L_a7); -#if INMARGIN == 0 +#if INMARGIN == 0 L_b8 = L_deposit_h(sub(in[7], in[8])); L_b9 = L_deposit_h(sub(in[6], in[9])); #else @@ -556,7 +556,7 @@ void dct16_W32int_fx(const Word16 *in, L_b13 = L_add(Mpy_32_16op(L_a13, 23170), Mpy_32_16op(L_a10, 23170)); /* CÏ€/4 CÏ€/4 */ //L_b13 = L_add(L_b13, L_b13);/* scale up due to previous use of L_Mpy_32_16_0op() */ -#if INMARGIN == 0 +#if INMARGIN == 0 L_b14 = L_deposit_h(sub(in[1], in[14])); L_b15 = L_deposit_h(sub(in[0], in[15])); #else @@ -640,11 +640,11 @@ void dct16_W32int_fx(const Word16 *in, #ifdef Mpy_32_16op -#undef Mpy_32_16op +#undef Mpy_32_16op #endif #ifdef Mpy_32_16_0op -#undef Mpy_32_16_0op +#undef Mpy_32_16_0op #endif #ifdef WMOPS pop_wmops(); diff --git a/lib_lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c index a1773f92b..20582f47b 100644 --- a/lib_lc3plus/dec_entropy.c +++ b/lib_lc3plus/dec_entropy.c @@ -347,7 +347,7 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, rx_status[1] = read_indice( ptr, bp_side, mask_side, 5 ); #else rx_status[1] = 0; -#endif +#endif } } ELSE { L = read_indice(ptr, bp_side, mask_side, 1+9); move16(); @@ -383,7 +383,7 @@ void processDecoderEntropy_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, ltpf_idx[1] = 0; move16(); ltpf_idx[2] = 0; move16(); } -#endif /* new signalling */ +#endif /* new signalling */ /* Decode noise-fac */ *fac_ns_idx = read_indice( ptr, bp_side, mask_side, 3 ); move16(); @@ -586,7 +586,7 @@ void readSNSData_fx(UWord8* ptr, BER_detect = 0; move16(); plc_trigger_SNS1 = 1; move16(); -#ifdef LRSNS_10MS_BFISIGNAL_FIX +#ifdef LRSNS_10MS_BFISIGNAL_FIX plc_trigger_SNS2 = 1; move16(); #else plc_trigger_SNS2 = 2; move16(); @@ -675,7 +675,7 @@ void readSNSData_fx(UWord8* ptr, L_add(L_scf_idx[2], L_deposit_l(submodeLSB)); /* decoder internal signal shape_j = submode 0..3 to VQ */ -#ifdef LRSNS_10MS_BFISIGNAL_FIX +#ifdef LRSNS_10MS_BFISIGNAL_FIX IF( BER_detect > 0) { *bfiPtr = 1; move16(); @@ -762,7 +762,7 @@ void readSNSData_fx(UWord8* ptr, *bfiPtr = plc_trigger_SNS1; move16(); IF(*bfiPtr != 0) { -#ifdef LRSNS_10MS_BFISIGNAL_FIX +#ifdef LRSNS_10MS_BFISIGNAL_FIX ASSERT(*bfiPtr == 1); #endif Dyn_Mem_Deluxe_Out(); @@ -791,7 +791,7 @@ void readSNSData_fx(UWord8* ptr, *bfiPtr = plc_trigger_SNS2; move16(); IF( *bfiPtr != 0 ) { -#ifdef LRSNS_10MS_BFISIGNAL_FIX +#ifdef LRSNS_10MS_BFISIGNAL_FIX ASSERT(*bfiPtr == 1); #endif Dyn_Mem_Deluxe_Out(); @@ -856,7 +856,7 @@ void readSNSData_fx(UWord8* ptr, } /*stage1B* + stage2 */ } /*10+ bits*/ } -#ifdef LRSNS_PC_SIGNAL_FIX +#ifdef LRSNS_PC_SIGNAL_FIX assert(*bfiPtr == 0 || *bfiPtr == 1); /* local SNS BFI-flag output check */ #endif Dyn_Mem_Deluxe_Out(); diff --git a/lib_lc3plus/dec_lc3plus.c b/lib_lc3plus/dec_lc3plus.c index 525edc74f..ba9a2b39a 100644 --- a/lib_lc3plus/dec_lc3plus.c +++ b/lib_lc3plus/dec_lc3plus.c @@ -314,13 +314,13 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif IF (sub(bfi, 1) != 0) -#ifdef CR9_C_ADD_1p25MS_LRSNS +#ifdef CR9_C_ADD_1p25MS_LRSNS { IF(sub(decoder->frame_dms, LC3PLUS_FRAME_DURATION_1p25MS) == 0) { pitch_rx_fx = ltpf_idx[0]; move16(); -#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY ltpf_rx_fx = 0; move16(); /* CB_C with binary means , not dependent on LTPF activation */ #else ltpf_rx_fx = ltpf_idx[1]; move16();/* CB_C, with ternary means dependent on LTPF activation */ @@ -331,7 +331,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s #endif } ELSE -#endif /* CR9_C_ADD_1p25MS_LRSNS */ +#endif /* CR9_C_ADD_1p25MS_LRSNS */ { /* currentScratch Size = 96 bytes */ #ifdef ENABLE_HR_MODE @@ -341,7 +341,7 @@ static int Dec_LC3PLUS_Channel(LC3PLUS_Dec *decoder, int channel, int bits_per_s processSnsQuantizeScfDecoder_fx(L_scf_idx, scf_q, currentScratch); #endif } -#ifdef CR9_C_ADD_1p25MS_LRSNS +#ifdef CR9_C_ADD_1p25MS_LRSNS } #endif #ifdef WMOPS diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h index 24da69b87..746521471 100644 --- a/lib_lc3plus/defines.h +++ b/lib_lc3plus/defines.h @@ -128,30 +128,30 @@ #define FIX_BOTH_1p25_WB_GLOBGAINOFFSET_NONBE /* 1p25 curve tilt calulation corrected and made into BASOP, WB had a loss of of HF in the range 211-260 kbps */ #define FIX_BOTH_1p25_WB_GLOBGAINOFFSET_LOWLIM_NONBE -135 /* 1p25 curve tilt calulation limited to value -135 kbps */ -#define FIX_BOTH_1p25_TEST_NEW_GG_EST2 /* GG_EST2_will use bands with two coeffs in each instead of four, for 1p25 WB and 1p25 SSWB , note only active for regular, hrmode==0 */ +#define FIX_BOTH_1p25_TEST_NEW_GG_EST2 /* GG_EST2_will use bands with two coeffs in each instead of four, for 1p25 WB and 1p25 SSWB , note only active for regular, hrmode==0 */ #ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 -#define FIX_BASOP_1p25_NEW_GG_EST3 /* GG_EST3 , GG_EST2 with optimized code for better BASOP code reuse , less changes to non 1p25ms */ -#define FIX_BOTH_1p25_GG_EST_SWB_FB /* 1.25ms GG_EST update for SWB/FB, better RD curve float and BASOP , active for hrmode==0 */ +#define FIX_BASOP_1p25_NEW_GG_EST3 /* GG_EST3 , GG_EST2 with optimized code for better BASOP code reuse , less changes to non 1p25ms */ +#define FIX_BOTH_1p25_GG_EST_SWB_FB /* 1.25ms GG_EST update for SWB/FB, better RD curve float and BASOP , active for hrmode==0 */ #endif /* defines to activate 2 or 3 tuple 1.25ms loops for WB,SSWB,SWB,FB */ #define FIX_1p25_GG_EST_TUPLES /* 1.25 ms GG_EST2_will use 2,3 or 4 , note only active for regular, hrmode==0 */ #ifdef FIX_1p25_GG_EST_TUPLES -#define GG_1p25_WB_TUPLES 2 -#define GG_1p25_SSWB_TUPLES 2 -#define GG_1p25_SWB_TUPLES 2 -#define GG_1p25_FB_TUPLES 3 -#define GG_1p25_MAX_TUPLES MAX(MAX(GG_1p25_WB_TUPLES ,GG_1p25_SSWB_TUPLES ), MAX(GG_1p25_SWB_TUPLES ,GG_1p25_FB_TUPLES)) /* used to control common energy loop */ +#define GG_1p25_WB_TUPLES 2 +#define GG_1p25_SSWB_TUPLES 2 +#define GG_1p25_SWB_TUPLES 2 +#define GG_1p25_FB_TUPLES 3 +#define GG_1p25_MAX_TUPLES MAX(MAX(GG_1p25_WB_TUPLES ,GG_1p25_SSWB_TUPLES ), MAX(GG_1p25_SWB_TUPLES ,GG_1p25_FB_TUPLES)) /* used to control common energy loop */ #define FIX_1p25_32kHz_CLANG_WARNING_EST_GAIN -#ifndef FIX_BOTH_1p25_ALLOC_SPECTRUM -#define FIX_BOTH_1p25_ALLOC_SPECTRUM +#ifndef FIX_BOTH_1p25_ALLOC_SPECTRUM +#define FIX_BOTH_1p25_ALLOC_SPECTRUM #endif -#define FIX_1p25_FLEX_ITER_TUPLE_LOOP /* energy loop part optimized BASOP only */ -#define LOG2_LC_APPROX /* log2_LC(energy) call BASOP only */ /* only applied to 1p25 ms global gain estimation loop */ -#define FIX_1p25_FLEX_BISECT_LOOP /* bisect optimization BASOP only !! */ +#define FIX_1p25_FLEX_ITER_TUPLE_LOOP /* energy loop part optimized BASOP only */ +#define LOG2_LC_APPROX /* log2_LC(energy) call BASOP only */ /* only applied to 1p25 ms global gain estimation loop */ +#define FIX_1p25_FLEX_BISECT_LOOP /* bisect optimization BASOP only !! */ #endif @@ -251,7 +251,7 @@ #ifdef DEBUG #ifdef READ_G192FER -#define READ_G192_FER_BYTE /* Allow C executable to also read G192 byte formatted FER files 0x20=BAD , 0x21=Good */ +#define READ_G192_FER_BYTE /* Allow C executable to also read G192 byte formatted FER files 0x20=BAD , 0x21=Good */ #endif #endif @@ -453,7 +453,7 @@ do not change __forceinline for mex compilation using gcc6.3.0 or larger #define SNSLR_A_CNST_WEIGHT 28672 /* 0.875 */ -#define SNS_VQ_MAX_IDX 8 +#define SNS_VQ_MAX_IDX 8 #endif /* CR9_C_ADD_LRSNS */ diff --git a/lib_lc3plus/enc_lc3plus.c b/lib_lc3plus/enc_lc3plus.c index 2658ac6bb..0c34a8d48 100644 --- a/lib_lc3plus/enc_lc3plus.c +++ b/lib_lc3plus/enc_lc3plus.c @@ -91,7 +91,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ ASSERT(encoder->frame_dms == LC3PLUS_FRAME_DURATION_1p25MS); ASSERT(MAX_LEN >= lg_4 * 4 ); /* "en" size in estimate_global_gain_fx() */ } -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 if(encoder->frame_dms == LC3PLUS_FRAME_DURATION_1p25MS && (sub(encoder->frame_length, 30) <= 0)) /* WB and SSWB */ { ASSERT(MAX_LEN >= 2 + lg_4 * 4); /*make sure that there are 2 extra tail coeffs in d_fx*/ @@ -345,7 +345,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ /* No BW Cutoff for 8 kHz and 96 kHz */ IF (encoder->fs_idx > 0 && encoder->hrmode == 0 && encoder->bw_ctrl_active == 0) { -#else /* ENABLE_HR_MODE */ +#else /* ENABLE_HR_MODE */ IF (encoder->fs_idx > 0 && encoder->bw_ctrl_active == 0) { #endif /* ENABLE_HR_MODE */ @@ -509,7 +509,7 @@ static void Enc_LC3PLUS_Channel(LC3PLUS_Enc *encoder, int channel, int bits_per_ #endif test(); -#ifdef CR9_C_ADD_1p25MS_LRSNS +#ifdef CR9_C_ADD_1p25MS_LRSNS /* incoming (state based) ltpf_bits for tranmission set in function ltpf_coder_fx() */ test(); test(); lrsns_st1C_in_use = 0; move16(); diff --git a/lib_lc3plus/estimate_global_gain_fx.c b/lib_lc3plus/estimate_global_gain_fx.c index ec4e8cd1a..21b0d7d16 100644 --- a/lib_lc3plus/estimate_global_gain_fx.c +++ b/lib_lc3plus/estimate_global_gain_fx.c @@ -41,13 +41,13 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit Word16 *en_exp = NULL; Word32 M0, M1; #endif -#ifdef FIX_1p25_GG_EST_TUPLES +#ifdef FIX_1p25_GG_EST_TUPLES /* NB (-1) WB(20), SSWB(30), SWB(40), FB(50) */ Word16 nCoeffTab1p25[5] = { -1/*NB*/, GG_1p25_WB_TUPLES, GG_1p25_SSWB_TUPLES, GG_1p25_SWB_TUPLES, GG_1p25_FB_TUPLES }; Word16 bwIdx; Word16 divTabQ15[5] = { 0, -32768, 16384, 10923, 8192 }; #endif -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 Word16 nCoeffPerBand = 4; /* 4 coeff per band */ Word16 twoCoeffFlag = 0; /* boolean */ #endif @@ -89,15 +89,15 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit UNUSED(L_twoCoeffSuppressMaskB); #endif -#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP UNUSED(twoCoeffOutShiftA); UNUSED(L_twoCoeffSuppressMaskA); UNUSED(twoCoeffOutShiftB); UNUSED(L_twoCoeffSuppressMaskB); #endif -#ifndef FIX_1p25_GG_EST_TUPLES -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifndef FIX_1p25_GG_EST_TUPLES +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 IF(frame_dms == LC3PLUS_FRAME_DURATION_1p25MS && (sub(lg, 30) <= 0)) /* WB and SSWB */ { nCoeffPerBand = 2; move16(); /* 2 coeff per band */ @@ -107,7 +107,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit #endif -#ifdef FIX_1p25_GG_EST_TUPLES +#ifdef FIX_1p25_GG_EST_TUPLES twoCoeffFlag = 0; move16(); nCoeffPerBand = 4; move16(); /* default assume 4 coeff per band(4-tuples block) */ lg_4 = shr_pos_pos(lg, 2); @@ -141,7 +141,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit lg_4 = s; /* lg_4 also used for 3_tuples, 2 tuples*/ } -#elif defined( FIX_BASOP_ENC_QUANTIZE_1P25MS_512KBPS) +#elif defined( FIX_BASOP_ENC_QUANTIZE_1P25MS_512KBPS) /* handle non-eaxactly quadruple lengths, in case frame_length is (e.g 1p25ms 24kHz --> 30 = 7*4 + 2 ) */ /* e.g 1p25ms 48kHz --> 50 = 12*4 + 2 ) */ /* quadruple extension is needed provide a correct x_max analysis as req. for scaling analysis */ @@ -190,7 +190,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit *old_targetBits = nbitsSQ; move16(); nbitsSQ = add(nbitsSQ, round_fx(*targetBitsOff)); -#ifndef FIX_BASOP_ENC_QUANTIZE_1P25MS_512KBPS +#ifndef FIX_BASOP_ENC_QUANTIZE_1P25MS_512KBPS lg_4 = shr_pos(lg, 2); #endif @@ -302,7 +302,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit L_twoCoeffSuppressMaskB = 0; move32(); /* suppress value*/ -#if GG_1p25_MAX_TUPLES>=3 +#if GG_1p25_MAX_TUPLES>=3 IF(sub(nCoeffPerBand, 3) == 0) { L_dB_scale_offset = L_add(Mpy_32_16_lc3plus(0x9CCCD, 24576), 1L); /* S15Q16/ round(7.5 * 3/4), 481689.75 -> 481690 */ @@ -316,7 +316,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit } #endif -#if GG_1p25_MAX_TUPLES>=4 +#if GG_1p25_MAX_TUPLES>=4 IF(sub(nCoeffPerBand, 4) == 0) { twoCoeffOutShiftA = 0; move16(); /* do not shift out */ @@ -327,7 +327,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit #endif #endif -#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP FOR(i = 0; i < lg_4; i++) /* 1.25 ms energy loop used for all N/4 , (N)/3 and N/2 */ { @@ -338,10 +338,10 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit tmp32 = L_max(tmp32, L_abs(x[1])); /* 0 or 31 shift, 0 for blocks of 4, 31 to accumulate a 0 value (for block #2,#3) for blocks of 2 or blocks of 3 */ -#if GG_1p25_MAX_TUPLES>=3 +#if GG_1p25_MAX_TUPLES>=3 tmp32 = L_max(tmp32, L_shr_pos_pos(L_abs(x[2]), twoCoeffOutShiftA)); #endif -#if GG_1p25_MAX_TUPLES>=4 +#if GG_1p25_MAX_TUPLES>=4 tmp32 = L_max(tmp32, L_shr_pos_pos(L_abs(x[3]), twoCoeffOutShiftB)); #endif x_max = L_max(x_max, tmp32); /* global x_max */ @@ -365,13 +365,13 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit tmp16 = round_fx(L_shl(x[1], s)); ener = L_mac(ener, tmp16, tmp16); -#if GG_1p25_MAX_TUPLES >= 3 +#if GG_1p25_MAX_TUPLES >= 3 tmp32 = L_and(x[2], L_twoCoeffSuppressMaskA); /* mask is 0 for 2blocks, all ones for 3 or 4 blocks */ tmp16 = round_fx(L_shl(tmp32, s)); ener = L_mac(ener, tmp16, tmp16); #endif -#if GG_1p25_MAX_TUPLES >= 4 +#if GG_1p25_MAX_TUPLES >= 4 tmp32 = L_and(x[3], L_twoCoeffSuppressMaskB); /* 0 for 2 or 3 blocks, all ones for 4 blocks */ tmp16 = round_fx(L_shl(tmp32, s)); ener = L_mac(ener, tmp16, tmp16); @@ -386,7 +386,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit } #endif -#ifndef LOG2_LC_APPROX +#ifndef LOG2_LC_APPROX /* log2 */ tmp32 = L_add_sat(BASOP_Util_Log2(ener), L_shl_sat(L_deposit_l(s), 25)); /* log2, 6Q25 */ #endif @@ -405,7 +405,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit { /* 4 or 2 merged loop for non-1p25ms */ #endif -#ifndef FIX_1p25_GG_EST_TUPLES +#ifndef FIX_1p25_GG_EST_TUPLES # ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 test(); if (twoCoeffFlag != 0) @@ -418,7 +418,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit #ifdef FIX_BASOP_1p25_NEW_GG_EST3 /*set up constants for blocks of two (or block of 4)*/ L_dB_scale_offset = L_shr_pos(0x9CCCD, twoCoeffFlag); /* S15Q16/ 7.5 or 3.5 offset */ -#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP Word16 twoCoeffOutShift; Word32 L_twoCoeffSuppressMask; #endif @@ -441,8 +441,8 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit tmp32 = L_abs(x[0]); tmp32 = L_max(tmp32, L_abs(x[1])); -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 /* 0 or 31 shift, 0 for blocks of 4, 31 to accumulate a 0 value (for block #2,#3) for blocks of 2 */ tmp32 = L_max(tmp32, L_shr_pos(L_abs(x[2]), twoCoeffOutShift)); tmp32 = L_max(tmp32, L_shr_pos(L_abs(x[3]), twoCoeffOutShift)); @@ -467,8 +467,8 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit tmp16 = round_fx(L_shl(x[1], s)); ener = L_mac(ener, tmp16, tmp16); -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 tmp32 = L_and(x[2], L_twoCoeffSuppressMask); /* 0 for 2blocks, all ones for 4 blocks */ tmp16 = round_fx(L_shl(tmp32, s)); ener = L_mac(ener, tmp16, tmp16); @@ -491,8 +491,8 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit /* log */ tmp32 = L_add_sat(BASOP_Util_Log2(ener), L_shl_sat(L_deposit_l(s), 25)); /* log2, 6Q25 */ -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 tmp32 = L_add(L_shr_pos(Mpy_32_16_lc3plus(tmp32, 0x436E), 6), L_dB_scale_offset); /* -> (28/20)*( (7or3.5) + 10*tmp32/log2(10)), 15Q16 */ #endif #else @@ -500,13 +500,13 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit #endif en[i] = tmp32; move32(); -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 x += nCoeffPerBand; #else x += 4; #endif } /* N/4 or N/2 energy loop */ -#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP +#ifdef FIX_1p25_FLEX_ITER_TUPLE_LOOP } /* end of non-1.25ms 4 or 2 tuple energy loop */ #endif }/* hrmode==0 */ @@ -734,7 +734,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit { #ifndef FIX_1p25_FLEX_BISECT_LOOP -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 /*these limits were constant for blocks of 4 , now we adaptively adjust them for blocks of two */ L_dB_scale_offset = L_shr_pos(0x9CCCD, twoCoeffFlag); L_dB_scale_offset2 = L_shr_pos(0x460000, twoCoeffFlag); @@ -762,7 +762,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit L_dB_scale_offset3 = L_shr_pos(0x3C7AE, twoCoeffFlag); /* set up constants for blocks of 4 (or block of 3 or 2)*/ -#if GG_1p25_MAX_TUPLES>=3 +#if GG_1p25_MAX_TUPLES>=3 IF(sub(nCoeffPerBand, 3) == 0) { L_dB_scale_offset = L_add(Mpy_32_16_lc3plus(0x9CCCD, 24576), 1L); /* S15Q16/ round(7.5 * 3/4), 481689.75 -> 481690 */ @@ -842,7 +842,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit { #endif /* FLEX BISECT*/ /* find offset (0 to 127) */ -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 /* 4 ,or 2 tuples */ L_dB_scale_offset = L_shr_pos(0x9CCCD, twoCoeffFlag); /* S15Q16 7.5(4 tuples) or 3.75(2_tuples) offset */ @@ -861,8 +861,8 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit FOR(i = lg_4 - 1; i >= 0; i--) { tmp32 = L_sub(en[i], offset); -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 diff = L_sub(tmp32, L_dB_scale_offset); /* 0x9CCCD -> (28/20)*( 7or3.5) in Q16 */ #endif #else @@ -872,8 +872,8 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit { if (iszero == 0) { -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 ener = L_add_sat(ener, L_dB_scale_offset3); /* 0x3C7AE -> (28/20)*(2.7or 3.5) in Q16 */ #endif #else @@ -885,8 +885,8 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 nbit { ener = L_add_sat(ener, tmp32); iszero = 0; move16(); -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 -#ifdef FIX_BASOP_1p25_NEW_GG_EST3 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BASOP_1p25_NEW_GG_EST3 diff2 = L_sub(tmp32, L_dB_scale_offset2); /* 0x460000 -> (28/20)*(50or25) in Q16 */ #endif #else diff --git a/lib_lc3plus/fft_lc3plus.c b/lib_lc3plus/fft_lc3plus.c index e7a71d5b1..1f727bcd4 100644 --- a/lib_lc3plus/fft_lc3plus.c +++ b/lib_lc3plus/fft_lc3plus.c @@ -68,7 +68,7 @@ #endif #ifdef ENABLE_HR_MODE -#undef L_shr_pos +#undef L_shr_pos #define L_shr_pos(x, y) (L_shr(L_add(L_shr((x), ((y)-1)),1),1)) #endif diff --git a/lib_lc3plus/functions.h b/lib_lc3plus/functions.h index 5146ca05c..38b32769d 100644 --- a/lib_lc3plus/functions.h +++ b/lib_lc3plus/functions.h @@ -346,7 +346,7 @@ void dct16_W32int_fx(const Word16 *in, Word16 *out); void writeSNSData_fx(UWord8 *bytes, Word16 *bp_side, Word16 *mask_side, LC3PLUS_FrameDuration frame_dms, Word32* L_scf_idx); -#endif /* CR9_C_ADD_1p25MS_LRSNS */ +#endif /* CR9_C_ADD_1p25MS_LRSNS */ #ifdef NEW_SIGNALLING_SCHEME_1p25 @@ -758,7 +758,7 @@ void processEstimateGlobalGain_fx(Word32 x[], Word16 x_e, Word16 lg, Word16 sqTa #ifdef ENABLE_HR_MODE , Word16 hrmode, Word16 regBits, LC3PLUS_FrameDuration frame_dms #else -#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 +#ifdef FIX_BOTH_1p25_TEST_NEW_GG_EST2 , LC3PLUS_FrameDuration frame_dms #endif #endif diff --git a/lib_lc3plus/near_nyquist_detector_fx.c b/lib_lc3plus/near_nyquist_detector_fx.c index c88a7fc9f..5e83af0b1 100644 --- a/lib_lc3plus/near_nyquist_detector_fx.c +++ b/lib_lc3plus/near_nyquist_detector_fx.c @@ -15,13 +15,13 @@ void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_id const Word16 bands_number, const Word32 *ener_fx, const Word16 ener_fx_exp #ifdef ENABLE_HR_MODE ,LC3PLUS_FrameDuration frame_dms, Word16 hrmode -#endif +#endif ) { *near_nyquist_flag = 0; #ifdef ENABLE_HR_MODE IF (hrmode == 0){ -#endif +#endif IF (sub(fs_idx, 4) < 0) { Dyn_Mem_Deluxe_In( @@ -74,7 +74,7 @@ void processNearNyquistdetector_fx(Word16 *near_nyquist_flag, const Word16 fs_id case LC3PLUS_FRAME_DURATION_1p25MS: assert(0); BREAK; -#endif +#endif case LC3PLUS_FRAME_DURATION_2p5MS: td_thresh = TD_HR_thresh_2_5ms; BREAK; diff --git a/lib_lc3plus/plc_phecu_fec_hq_fx.c b/lib_lc3plus/plc_phecu_fec_hq_fx.c index 37711a6bc..0d94b3718 100644 --- a/lib_lc3plus/plc_phecu_fec_hq_fx.c +++ b/lib_lc3plus/plc_phecu_fec_hq_fx.c @@ -289,7 +289,7 @@ void trans_burst_ana_fx( /* band gain muting can take place earlier due to a band transient */ beta_mute_thr = fade_scheme_tab_fx[fade_ms_ind][2]; /* faster muting of added noise starts when slow main signal fadeout is over */ -#ifdef PLC_FADEOUT_IN_MS +#ifdef PLC_FADEOUT_IN_MS ASSERT(att_per_frame >= 1 && att_per_frame <= 12); /* table based lookup restriction */ #else ASSERT(att_per_frame == 1 || att_per_frame == 2); /* table based lookup restriction */ @@ -1239,7 +1239,7 @@ static Word16 imax_fx( /* o: The location, relative to the /* in the first lost frame analyze spectra and spectral bands to possibly reverse an initial pure sine assumption */ *nonpure_tone_flag_ptr = plc_phEcu_nonpure_tone_ana_fx(plocs, *num_plocs, X, L_Xavg, Lprot, fs_idx); -#ifdef LOCAL_PLC2_TON_ANA_DEACTIVATE +#ifdef LOCAL_PLC2_TON_ANA_DEACTIVATE *nonpure_tone_flag_ptr = 0; /* dbg of inactive tone analysis */ #endif } diff --git a/lib_lc3plus/pvq_dec_fx.c b/lib_lc3plus/pvq_dec_fx.c index 2eb1a76a4..25ec3e539 100644 --- a/lib_lc3plus/pvq_dec_fx.c +++ b/lib_lc3plus/pvq_dec_fx.c @@ -117,7 +117,7 @@ void lrsns_pvq_dec_scale_W32vec_fx( } Dyn_Mem_Deluxe_Out(); } -#endif /* ENABLE_HR_MODE */ +#endif /* ENABLE_HR_MODE */ void pvq_fess_dec_en1_normQ30andQ14_fx( const Word16 *y /*Q0*/, diff --git a/lib_lc3plus/pvq_enc_fx.c b/lib_lc3plus/pvq_enc_fx.c index 9351cbcc2..9933419bb 100644 --- a/lib_lc3plus/pvq_enc_fx.c +++ b/lib_lc3plus/pvq_enc_fx.c @@ -12,7 +12,7 @@ #include "defines.h" #include "functions.h" -#ifdef CR9_C_ADD_1p25MS_LRSNS +#ifdef CR9_C_ADD_1p25MS_LRSNS static void pvq_pyr_project_lrsns_adv(const Word16 dim_proj, /* vector dimension */ const Word16 *xabs, /* absolute vector values */ Word32 L_xsum, /* absolute vector sum over dim_proj */ diff --git a/lib_lc3plus/rom_basop_util_lc3plus.h b/lib_lc3plus/rom_basop_util_lc3plus.h index bde04fad3..ac088fa1d 100644 --- a/lib_lc3plus/rom_basop_util_lc3plus.h +++ b/lib_lc3plus/rom_basop_util_lc3plus.h @@ -71,7 +71,7 @@ void BASOP_getTables( #else const PWord16 **ptwiddle, const PWord16 **sin_twiddle, -#endif +#endif Word16 *sin_step, Word16 length); diff --git a/lib_lc3plus/setup_com_lc3plus.c b/lib_lc3plus/setup_com_lc3plus.c index ce8a9ac66..1121d1905 100644 --- a/lib_lc3plus/setup_com_lc3plus.c +++ b/lib_lc3plus/setup_com_lc3plus.c @@ -24,7 +24,7 @@ Word16 calc_GGainOffset_1p25_fx(Word16 total_bits, Word16 fs_idx) tmp2 = negate(add(s_min(115, tmp1), tmp2)); move16(); -#ifdef FIX_BOTH_1p25_WB_GLOBGAINOFFSET_LOWLIM_NONBE +#ifdef FIX_BOTH_1p25_WB_GLOBGAINOFFSET_LOWLIM_NONBE if (sub(fs_idx, 1) <= 0) { /* only NB and WB additionally limited to -135 */ tmp2 = s_max(tmp2, FIX_BOTH_1p25_WB_GLOBGAINOFFSET_LOWLIM_NONBE); diff --git a/lib_lc3plus/setup_enc_lc3plus.c b/lib_lc3plus/setup_enc_lc3plus.c index 92c668912..6005f1521 100644 --- a/lib_lc3plus/setup_enc_lc3plus.c +++ b/lib_lc3plus/setup_enc_lc3plus.c @@ -586,7 +586,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) } } else -#endif +#endif { fec_slot_bytes_min = FEC_SLOT_BYTES_MIN; } @@ -594,7 +594,7 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc *encoder, int bitrate) check_bytes = bitrate * encoder->frame_length / ( 8 * encoder->fs_in * encoder->channels ); maxBR = FEC_SLOT_BYTES_MAX * ( 8 * encoder->fs_in * encoder->channels ) / encoder->frame_length; if ( check_bytes < fec_slot_bytes_min || bitrate > maxBR ) -#else +#else max_bytes = bitrate * encoder->frame_length / (8 * encoder->fs_in * encoder->channels); if (max_bytes < FEC_SLOT_BYTES_MIN || max_bytes > FEC_SLOT_BYTES_MAX) #endif /* CR12_D_FIX_BITRATE_LIMITS */ diff --git a/lib_lc3plus/sns_compute_scf_fx.c b/lib_lc3plus/sns_compute_scf_fx.c index 8acfe52bb..a95e3e772 100644 --- a/lib_lc3plus/sns_compute_scf_fx.c +++ b/lib_lc3plus/sns_compute_scf_fx.c @@ -185,12 +185,12 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor Word16 ncorr_fac_orig = i_mult(s_max(sub(LT_normcorr_mem, 26214), 0), 5); UNUSED(ncorr_fac_orig); #endif -#else +#else /* LT_normcorr * (1-0.125) + normcorr * 0.125 */ *LT_normcorr = add(mult(*LT_normcorr,28672), mult(norm_corr,4096)); /* ncorr_fac = max(LT_normcorr - 0.8, 0) * 5 */ ncorr_fac = i_mult(s_max(sub(*LT_normcorr, 26214), 0), 5); -#endif +#endif if (ncorr_fac == 0) { @@ -459,7 +459,7 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor L_mean = L_add(L_mean, L_shr_pos(d3_fx[i], 4)); } -#ifdef FIX_SNS_BASOP_MEAN16_APPLY +#ifdef FIX_SNS_BASOP_MEAN16_APPLY Word16 limGainDamping = 0; Word16 up_shift = 0, dn_shift = 0; @@ -484,7 +484,7 @@ void processSnsComputeScf_fx(Word32 *d2_fx, Word16 d2_fx_exp, Word16 fs_idx, Wor #if defined (CR9_C_ADD_1p25MS) if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) { -#ifdef FIX_SNS_BASOP_MEAN16_APPLY +#ifdef FIX_SNS_BASOP_MEAN16_APPLY /* maximize precision */ L_tmp = Mpy_32_16_lc3plus(L_shl_pos(d3_fx[i + M], up_shift), limGainDamping ); scf[i] = round_fx(L_shr_pos(L_tmp, dn_shift)); diff --git a/lib_lc3plus/sns_quantize_scf_fx.c b/lib_lc3plus/sns_quantize_scf_fx.c index d16a90b34..d4d3d3aa2 100644 --- a/lib_lc3plus/sns_quantize_scf_fx.c +++ b/lib_lc3plus/sns_quantize_scf_fx.c @@ -389,7 +389,7 @@ static void pvq_enc_find_best_submode_pre_post_fx( tmp = mult_r(search_gainTab[L_section][idx], search_en1shape[L_section][i]); /* Q15+14+1-16= Q14 */ err = sub(target_w[i], tmp); /* both in Q14 */ L_mse = L_mac0(L_mse, err, err); /* Q14+14 = Q28 */ -#endif /* Q14+14 = Q28 */ +#endif /* Q14+14 = Q28 */ } IF (L_sub(L_mse, L_mse_min) < 0) /* OPT: always update L_mse_min) */ @@ -873,7 +873,7 @@ Word16 snsQuantScfDecLR_fx(Word32* L_sns_vq_idx_fx, Xq_shape_j_fx = (Word16*)scratchAlign(L_Xq_shape_j_fx, sizeof(*L_Xq_shape_j_fx) * M); /*1*16*/ /*1*16*/ -#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY UNUSED(ltpf_rx_fx); #endif BER_dec = 0; /* no BER detected in PVQ indeces */ @@ -918,13 +918,13 @@ Word16 snsQuantScfDecLR_fx(Word32* L_sns_vq_idx_fx, /* add harmonic mean , based on pitch_info availability */ pitch_rx_fx = extract_l(L_sns_vq_idx_fx[3]); /* LTP active flag directly from dec_entropy */ -#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY ltpf_rx_fx = 0; /* CB_C has no dependency on LTPF active flag */ #else ltpf_rx_fx = extract_l(L_sns_vq_idx_fx[4]); /* LTPF active flag directly from dec_entropy */ #endif CBCmeanp_ind_fx = pitch_rx_fx; move16(); /* 0 or 1 */ -#ifndef LRSNS_CBC_NO_LTPF_DEPENDENCY +#ifndef LRSNS_CBC_NO_LTPF_DEPENDENCY test(); test(); test(); if (pitch_rx_fx != 0 && ltpf_rx_fx != 0) { @@ -1116,7 +1116,7 @@ Word32 snsQuantScfEncLRSt1ABC_fx(Word16* env, Word32* L_index, Word32 *L_min_mse st1_vectorB_idx_fx = scratchAlign(scratch, 0); target_fx = scratchAlign(scratch, sizeof(*st1_vectorB_idx_fx) * M); -#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY +#ifdef LRSNS_CBC_NO_LTPF_DEPENDENCY UNUSED(ltpf_rx); #endif st1_vectorA_fx = &(st1_vectors[0]); @@ -1203,7 +1203,7 @@ Word32 snsQuantScfEncLRSt1ABC_fx(Word16* env, Word32* L_index, Word32 *L_min_mse push_wmops("MSEsearchCbC_fx"); #endif meanC_ind = pitch_rx; move16(); -#ifndef LRSNS_CBC_NO_LTPF_DEPENDENCY +#ifndef LRSNS_CBC_NO_LTPF_DEPENDENCY if (ltpf_rx != 0) { meanC_ind = add(meanC_ind, 1); @@ -1359,7 +1359,7 @@ Word16 snsQuantScfEncLR_fx( /* o: bits spent on LRSNS-VQ envelope */ ); -#ifdef ENABLE_HR_MODE +#ifdef ENABLE_HR_MODE Word16 scf_q_fx[M]; /* W16Q11 always in use also for HR_MODE */ UNUSED(scf_q_fx); #endif -- GitLab From ccebcd94942d06058035df4ba0f901d2ded0e712 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 29 Oct 2025 16:35:21 +0100 Subject: [PATCH 052/351] update BASOP_CI_BRANCH_PC_REPO to update-basop-ci-branch-lc3plus-v161 --- .gitlab-ci/variables.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 817be6f79..d8db25d33 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -1,4 +1,5 @@ variables: + BASOP_CI_BRANCH_PC_REPO: "update-basop-ci-branch-lc3plus-v161" TESTV_DIR: "/usr/local/testv" LTV_DIR: "/usr/local/ltv" EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" @@ -81,8 +82,6 @@ variables: RUNNER_TAG: "ivas-basop-linux" LOGS_BACKUP_SOURCE_DIR: "" LOGS_BACKUP_TARGET_DIR: "" - # set this to true to skip the external HRTF testcases in pytest calls - DISABLE_HRTF: "false" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -104,4 +103,3 @@ variables: - 'peaq-enc-passthrough' - 'long-term-logs' - 'backup-long-term-logs' - - 'test-long-self-test' -- GitLab From 3812c58083641d8b1c66d4ff46687eacea396ca1 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 29 Oct 2025 16:50:21 +0100 Subject: [PATCH 053/351] Fixed scaling issues when outputting to SPLIT_BINAURAL_PCM from CLDFB split rendering --- lib_dec/lib_dec_fx.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 109863787..900c386e7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1388,7 +1388,8 @@ static ivas_error isar_generate_metadata_and_bitstream( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits,/* o : output split rendering bits */ + Word16* td_q /* o : Q-format of the TD output if rendering from CLDFB */ ) { // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, @@ -1473,7 +1474,7 @@ static ivas_error isar_generate_metadata_and_bitstream( } // NOTE(sgi): BASOP special - not in float version Word16 q1 = 31, q2 = 31, Q_buff = 31; - Word16 Q_out[CLDFB_NO_COL_MAX]; // NOTE(sgi): Seems unnecessarily large. Only indices 0 and 1 are used, value at index 1 is writen but never read. + Word16 Q_out[CLDFB_NO_COL_MAX]; Q_out[0] = 31; IF( EQ_16( cldfb_in_flag, 1 ) ) @@ -1530,6 +1531,7 @@ static ivas_error isar_generate_metadata_and_bitstream( { return error; } + *td_q = Q_out[0]; return IVAS_ERR_OK; } @@ -1751,6 +1753,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 i; Word16 pcm_out_flag; Word16 numSamplesPerChannelToOutput; + Word16 td_q; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -1782,7 +1785,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( p_head_pose_buf[i] = head_pose_buf[i]; } - if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits ) ) != IVAS_ERR_OK ) + if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) { return error; } @@ -1804,7 +1807,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + ivas_syn_output_fx( p_head_pose_buf, td_q, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } #else Decoder_Struct *st_ivas; @@ -5433,8 +5436,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) { + Word16 td_q; + /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ - IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits ) ) != IVAS_ERR_OK ) + IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) { return error; } @@ -5456,7 +5461,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + ivas_syn_output_fx( p_head_pose_buf, td_q, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); } } #endif -- GitLab From 8c67d5ab8974352bc2d70e0ee3fe06106aa368c6 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 29 Oct 2025 17:07:46 +0100 Subject: [PATCH 054/351] Fix Q-factor for TD signal synthesis --- lib_dec/lib_dec_fx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 900c386e7..babd4f715 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1531,7 +1531,11 @@ static ivas_error isar_generate_metadata_and_bitstream( { return error; } - *td_q = Q_out[0]; + + IF( EQ_16( cldfb_in_flag, 1 ) ) + { + *td_q = Q_out[0]; + } return IVAS_ERR_OK; } @@ -1753,7 +1757,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 i; Word16 pcm_out_flag; Word16 numSamplesPerChannelToOutput; - Word16 td_q; + Word16 td_q = 11; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -5436,7 +5440,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) { - Word16 td_q; + Word16 td_q = 11;; /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) -- GitLab From eb72f4e633dd8a15477d08ce9aa44d14d1a750f9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 29 Oct 2025 18:11:05 +0100 Subject: [PATCH 055/351] align with float + conversion from nano to mili --- apps/renderer.c | 8 ++++---- lib_rend/lib_rend_fx.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 7f9744c82..29ac7499a 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -191,7 +191,7 @@ typedef struct float lfeConfigElevation; bool lfeCustomRoutingEnabled; char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH]; - float syncMdDelay; + int16_t syncMdDelay; IVAS_RENDER_FRAMESIZE render_framesize; uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; AcousticEnvironmentSequence aeSequence; @@ -1278,7 +1278,7 @@ int main( fprintf( stderr, "\nError in IVAS_REND_SetTotalNumberOfObjects(): %s\n", ivas_error_to_string( error ) ); goto cleanup; } - Word32 var1 = (Word32) ( args.syncMdDelay ); + Word16 var1 = (Word16) ( args.syncMdDelay ); IF( ( error = IVAS_REND_SetIsmMetadataDelay( hIvasRend, var1 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_SetIsmMetadataDelay(): %s\n", ivas_error_to_string( error ) ); @@ -2123,7 +2123,7 @@ int main( if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / IVAS_NUM_FRAMES_PER_SEC / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( float BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ); } if ( !args.quietModeEnabled && args.delayCompensationEnabled ) @@ -3023,7 +3023,7 @@ static void parseOption( case CmdLnOptionId_syncMdDelay: assert( numOptionValues == 1 ); /* Metadata Delay to sync with audio delay in ms */ - args->syncMdDelay = strtof( optionValues[0], NULL ); + args->syncMdDelay = (int16_t) strtol( optionValues[0], NULL, 10 ); break; default: assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index bd5a19c8b..4bf358a58 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -48,6 +48,7 @@ #include "ivas_rom_com.h" #include "ivas_rom_rend.h" #include "stl.h" +#include "typedef.h" #include #include #include @@ -137,7 +138,7 @@ typedef struct #ifdef NONBE_1377_REND_DIRATT_CONF Word16 object_id; #endif - Word32 ism_metadata_delay_ms_fx; /* Q0 */ + Word16 ism_metadata_delay_ms_fx; /* Q0 */ } input_ism; typedef struct @@ -1674,8 +1675,11 @@ static ivas_error alignInputDelay( /* for ISM inputs, ensure the metadata sync delay is updated */ IF( getAudioConfigType( inputBase->inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) { + Word64 tmp; inputIsm = (input_ism *) inputBase; - inputIsm->ism_metadata_delay_ms_fx = Mpy_32_32( maxGlobalDelayNs /* Q0 */, 2147 /* (1 / 1e6f) in Q31 */ ); + + tmp = W_mult0_32_32( L_add( maxGlobalDelayNs, 500000 ) /* + 0.5ms for rounding */, /* Q0 */, 2147 /* (1 / 1e6f) in Q31 */ ); // Q31 + inputIsm->ism_metadata_delay_ms_fx = add( inputIsm->ism_metadata_delay_ms_fx, extract_h( W_extract_h( tmp ) ) ); } } } @@ -9053,7 +9057,7 @@ ivas_error IVAS_REND_SetTotalNumberOfObjects( ivas_error IVAS_REND_SetIsmMetadataDelay( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - const Word32 sync_md_delay /* i : ISM Metadata Delay in ms to sync with audio delay */ + const Word16 sync_md_delay /* i : ISM Metadata Delay in ms to sync with audio delay */ ) { Word16 i; @@ -9065,7 +9069,7 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { hIvasRend->inputsIsm[i].ism_metadata_delay_ms_fx = sync_md_delay; - move32(); + move16(); } return IVAS_ERR_OK; -- GitLab From bd805e86e15fe94b48bf7dfa6bc8e83b7a996778 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 29 Oct 2025 18:24:18 +0100 Subject: [PATCH 056/351] fix compilation errors --- apps/renderer.c | 5 ++--- lib_rend/lib_rend.h | 2 +- lib_rend/lib_rend_fx.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 29ac7499a..691bc178c 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1278,8 +1278,7 @@ int main( fprintf( stderr, "\nError in IVAS_REND_SetTotalNumberOfObjects(): %s\n", ivas_error_to_string( error ) ); goto cleanup; } - Word16 var1 = (Word16) ( args.syncMdDelay ); - IF( ( error = IVAS_REND_SetIsmMetadataDelay( hIvasRend, var1 ) ) != IVAS_ERR_OK ) + IF( ( error = IVAS_REND_SetIsmMetadataDelay( hIvasRend, args.syncMdDelay ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_SetIsmMetadataDelay(): %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -2123,7 +2122,7 @@ int main( if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( float BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ); + fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( (float) BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ); } if ( !args.quietModeEnabled && args.delayCompensationEnabled ) diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index a45fce272..f5f1d86cb 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -379,7 +379,7 @@ ivas_error IVAS_REND_SetTotalNumberOfObjects( ivas_error IVAS_REND_SetIsmMetadataDelay( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - const Word32 sync_md_delay /* i : Metadata Delay in ms to sync with audio delay */ + const Word16 sync_md_delay /* i : Metadata Delay in ms to sync with audio delay */ ); ivas_error IVAS_REND_GetNumAllObjects( diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 4bf358a58..0bbad7269 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1678,7 +1678,7 @@ static ivas_error alignInputDelay( Word64 tmp; inputIsm = (input_ism *) inputBase; - tmp = W_mult0_32_32( L_add( maxGlobalDelayNs, 500000 ) /* + 0.5ms for rounding */, /* Q0 */, 2147 /* (1 / 1e6f) in Q31 */ ); // Q31 + tmp = W_mult0_32_32( L_add( maxGlobalDelayNs, 500000 /* + 0.5ms for rounding */ ) /* Q0 */, 2147 /* (1 / 1e6f) in Q31 */ ); // Q31 inputIsm->ism_metadata_delay_ms_fx = add( inputIsm->ism_metadata_delay_ms_fx, extract_h( W_extract_h( tmp ) ) ); } } @@ -4486,7 +4486,7 @@ ivas_error IVAS_REND_AddInput_fx( } #ifdef CODE_IMPROVEMENTS - setInputDelay( getInputByIndex( inputsArray, inputIndex, inputType ), splitPreRendCldfb ); + setInputDelay( getInputByIndex_fx( inputsArray, inputIndex, inputType ), splitPreRendCldfb ); #else setInputDelay( (Word8 *) inputsArray + inputStructSize * inputIndex, splitPreRendCldfb ); #endif -- GitLab From 8676830aa68255ea32d0d2938130d46663b37aac Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 29 Oct 2025 18:47:30 +0100 Subject: [PATCH 057/351] align data type between field and function returns --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 0bbad7269..0234fc6f5 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -114,7 +114,7 @@ typedef struct Word32 gain_fx; /* Linear, not in dB Q30 */ rendering_context ctx; Word32 numNewSamplesPerChannel; /* Used to keep track how much new audio was fed before rendering current frame */ - Word32 delayNumSamples; + Word16 delayNumSamples; } input_base; typedef struct -- GitLab From c627de43ef60bb915bc3471ae737e1788db10516 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 29 Oct 2025 19:01:01 +0100 Subject: [PATCH 058/351] port MR 2297 from float Fix crash with IGF and bandwidth switching when DTX is enabled --- lib_com/options.h | 2 +- lib_enc/ivas_cpe_enc_fx.c | 85 ++++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 885e75e65..ed95f5ae3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,7 @@ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ #define CODE_IMPROVEMENTS - +#define FIX_1411_IGF_CRASH_BW_SWITCHING /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index d050e9459..496611ce9 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -988,68 +988,77 @@ ivas_error ivas_cpe_enc_fx( * Core codec configuration *----------------------------------------------------------------*/ +#ifdef FIX_1411_IGF_CRASH_BW_SWITCHING test(); - IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && st_ivas->hMCT == NULL ) + test(); + IF( NE_16( ( EQ_16( sts[0]->core_brate, SID_2k40 ) || EQ_16( sts[0]->core_brate, FRAME_NO_DATA ) ), 0 ) ) /* Reconfigurations not needed with DTX*/ { - /* set coded BW for MDCT stereo */ - set_bw_stereo_fx( hCPE ); - - /* reconfiguration of MDCT stereo */ - test(); - test(); +#endif test(); - 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 ) ) + IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && st_ivas->hMCT == NULL ) { - initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 ); + /* set coded BW for MDCT stereo */ + set_bw_stereo_fx( hCPE ); + /* reconfiguration of MDCT stereo */ test(); test(); test(); - hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && ( EQ_16( st_ivas->nchan_transport, 2 ) ) ); /* Q0 */ - - test(); - IF( LE_32( hCPE->element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) ) + 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 ) ) { - IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK ) + initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 ); + + test(); + test(); + test(); + hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && ( EQ_16( st_ivas->nchan_transport, 2 ) ) ); /* Q0 */ + + test(); + IF( LE_32( hCPE->element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) ) { - return error; + IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } } } } - } - /* IGF reconfiguration */ - FOR( n = 0; n < n_CoreChannels; n++ ) - { - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) ) && ( n == 0 || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) + /* IGF reconfiguration */ + FOR( n = 0; n < n_CoreChannels; n++ ) { - Word16 igf; - Word16 bw; - - /* float uses ternary operator for this: bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth; */ - bw = max_bwidth; - IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) ) && ( n == 0 || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) { - bw = sts[n]->bwidth; - } - igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->rf_mode ); /* Q0 */ + Word16 igf; + Word16 bw; + + /* float uses ternary operator for this: bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth; */ + bw = max_bwidth; + IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) + { + bw = sts[n]->bwidth; + } + igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->rf_mode ); /* Q0 */ #ifdef FIX_1413_IGF_INIT_PRINTOUT - IF( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) + IF( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) #else IF( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) #endif - { - return error; + { + return error; + } } } +#ifdef FIX_1411_IGF_CRASH_BW_SWITCHING } +#endif /* set ACELP@12k8 / ACELP@16k flag for flexible ACELP core */ FOR( n = 0; n < n_CoreChannels; n++ ) -- GitLab From 574e8b0857314e21c418f652be1fb12113bc859d Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 30 Oct 2025 08:22:50 +0100 Subject: [PATCH 059/351] try to fix linker error --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45cda9e37..e975df2b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,7 +184,7 @@ target_include_directories(lib_util PRIVATE lib_lc3plus lib_isar) if(NOT WMOPS) add_executable(ivas_lc3plus_unit_test ${CMAKE_SOURCE_DIR}/scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test.c) - target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_basop lib_com lib_debug lib_isar) + target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_com lib_basop lib_debug lib_isar) endif() file(GLOB libISARSrcs "lib_isar/*.c") -- GitLab From 38c93851925f6faf0bac35f6c4ac602546beb3f5 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 30 Oct 2025 08:51:21 +0100 Subject: [PATCH 060/351] fix LC3plus unit test - add missing case in switch --- lib_isar/isar_lc3plus_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 03f31cf8e..f7fe0db32 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -104,6 +104,8 @@ LC3PLUS_FrameDuration IVAS_LC3PLUS_UsToLC3plusFrameDuration( { switch ( lc3PlusFrameDurationUs ) { + case 2500: + return LC3PLUS_FRAME_DURATION_2p5MS; case 5000: return LC3PLUS_FRAME_DURATION_5MS; case 10000: -- GitLab From e88727095706ae0ba7dda47d5f2b3e665fd1997f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 09:23:14 +0100 Subject: [PATCH 061/351] add missing part of fix + some missing move16's --- lib_enc/ivas_cpe_enc_fx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 496611ce9..f8d53dd85 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1033,16 +1033,25 @@ ivas_error ivas_cpe_enc_fx( test(); test(); test(); - IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) ) && ( n == 0 || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) + test(); + test(); + IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) +#ifdef FIX_1411_IGF_CRASH_BW_SWITCHING + || EQ_16( sts[n]->last_core_brate, SID_2k40) || EQ_16(sts[n]->last_core_brate, FRAME_NO_DATA) ) +#endif + ) && + ( EQ_16(n, 0) || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) { Word16 igf; Word16 bw; /* float uses ternary operator for this: bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth; */ bw = max_bwidth; + move16(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) { bw = sts[n]->bwidth; + move16(); } igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->rf_mode ); /* Q0 */ #ifdef FIX_1413_IGF_INIT_PRINTOUT -- GitLab From 5b62e732f3000353fc20adcef69c652e152b84ad Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 09:43:44 +0100 Subject: [PATCH 062/351] fix build --- lib_enc/ivas_cpe_enc_fx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index f8d53dd85..144069a22 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1033,14 +1033,13 @@ ivas_error ivas_cpe_enc_fx( test(); test(); test(); +#ifdef FIX_1411_IGF_CRASH_BW_SWITCHING test(); test(); - IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) -#ifdef FIX_1411_IGF_CRASH_BW_SWITCHING - || EQ_16( sts[n]->last_core_brate, SID_2k40) || EQ_16(sts[n]->last_core_brate, FRAME_NO_DATA) ) + IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) || EQ_16( sts[n]->last_core_brate, SID_2k40 ) || EQ_16( sts[n]->last_core_brate, FRAME_NO_DATA ) ) && ( EQ_16( n, 0 ) || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) +#else + IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) ) && ( n == 0 || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) #endif - ) && - ( EQ_16(n, 0) || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) { Word16 igf; Word16 bw; -- GitLab From 409201ea89a4d231fe4da06f74a2afc62de43907 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 09:47:40 +0100 Subject: [PATCH 063/351] EQ_16 -> EQ_32 for core_brate comparisons --- lib_enc/ivas_cpe_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 144069a22..faad00109 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -991,7 +991,7 @@ ivas_error ivas_cpe_enc_fx( #ifdef FIX_1411_IGF_CRASH_BW_SWITCHING test(); test(); - IF( NE_16( ( EQ_16( sts[0]->core_brate, SID_2k40 ) || EQ_16( sts[0]->core_brate, FRAME_NO_DATA ) ), 0 ) ) /* Reconfigurations not needed with DTX*/ + IF( NE_16( ( EQ_32( sts[0]->core_brate, SID_2k40 ) || EQ_32( sts[0]->core_brate, FRAME_NO_DATA ) ), 0 ) ) /* Reconfigurations not needed with DTX*/ { #endif test(); @@ -1036,7 +1036,7 @@ ivas_error ivas_cpe_enc_fx( #ifdef FIX_1411_IGF_CRASH_BW_SWITCHING test(); test(); - IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) || EQ_16( sts[n]->last_core_brate, SID_2k40 ) || EQ_16( sts[n]->last_core_brate, FRAME_NO_DATA ) ) && ( EQ_16( n, 0 ) || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) + IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) || EQ_32( sts[n]->last_core_brate, SID_2k40 ) || EQ_32( sts[n]->last_core_brate, FRAME_NO_DATA ) ) && ( EQ_16( n, 0 ) || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) #else IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) ) && ( n == 0 || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) ) #endif -- GitLab From 1db0efae17f8bb71d2796afc71914fb89451e978 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 29 Oct 2025 12:55:52 +0100 Subject: [PATCH 064/351] basop operators; align with float --- lib_dec/ivas_jbm_dec_fx.c | 8 ++++---- lib_dec/lib_dec_fx.c | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index efd212eda..db23b9673 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2549,7 +2549,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { /* move it at the beginning of the TC buffer with zero padding */ Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); - set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); + set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) ); } #else /* render what is still there with zero padding */ @@ -3369,7 +3369,7 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( move16(); } - nsamp_to_allocate = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; + nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ), n_samp_full ); IF( Opt_tsm ) { @@ -3382,7 +3382,7 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( offset = 0; move16(); - FOR( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) + FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) { hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; offset = add( offset, n_samp_full ); @@ -3462,6 +3462,7 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( return; } + #endif /*--------------------------------------------------------------------------* @@ -3470,7 +3471,6 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ - ivas_error ivas_jbm_dec_tc_buffer_open_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 248b8846b..28417c137 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1217,7 +1217,11 @@ ivas_error IVAS_DEC_GetSamplesRenderer( hIvasDec->hasBeenFedFrame = false; /* check for possible flushed samples from a rate switch */ +#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP + IF( GT_16( hIvasDec->nSamplesFlushed, 0 ) ) +#else IF( GE_16( hIvasDec->nSamplesFlushed, 0 ) ) +#endif { /* note: offset (rendered samples) is always 0 */ Copy( hIvasDec->flushbuffer, pcmBuf, imult1616( hIvasDec->nSamplesFlushed, nOutChannels ) ); -- GitLab From b853be0b10bc7bdf4ac989e3263020f0f2390fc3 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 30 Oct 2025 11:13:48 +0200 Subject: [PATCH 065/351] Add switches --- lib_com/options.h | 2 ++ lib_dec/ivas_jbm_dec_fx.c | 13 ++++++++++++- lib_dec/lib_dec_fx.c | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 885e75e65..755af8894 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,8 @@ #define FIX_2166_ASSERT_OSBA_PLC_STEREO_OUT /* FhG: fix for issue 2166 - add missing averaging factor 0.5 in for the sum of energies in function stereo_dft_dmx_swb_nrg_fx()*/ #define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */ +#define FIX_2174_JBM_BASOP_ALIGNMENT /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index db23b9673..fa893c549 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2549,7 +2549,11 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { /* move it at the beginning of the TC buffer with zero padding */ Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) ); +#else + set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); +#endif } #else /* render what is still there with zero padding */ @@ -3369,7 +3373,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( move16(); } +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ), n_samp_full ); +#else + nsamp_to_allocate = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; +#endif IF( Opt_tsm ) { @@ -3382,7 +3390,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( offset = 0; move16(); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) +#else + FOR( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) +#endif { hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; offset = add( offset, n_samp_full ); @@ -3462,7 +3474,6 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( return; } - #endif /*--------------------------------------------------------------------------* diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 28417c137..176d3427a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1217,7 +1217,7 @@ ivas_error IVAS_DEC_GetSamplesRenderer( hIvasDec->hasBeenFedFrame = false; /* check for possible flushed samples from a rate switch */ -#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT IF( GT_16( hIvasDec->nSamplesFlushed, 0 ) ) #else IF( GE_16( hIvasDec->nSamplesFlushed, 0 ) ) -- GitLab From 1ca09d327c98bc28d47775faba80b42b375c47f8 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 30 Oct 2025 12:34:07 +0100 Subject: [PATCH 066/351] Add missing manual instrumentation --- lib_dec/lib_dec_fx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index babd4f715..a4bd04aa8 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1455,10 +1455,12 @@ static ivas_error isar_generate_metadata_and_bitstream( IF ( st_ivas->hBinRendererTd != NULL ) { ro_md_flag = 1; + move16(); } ELSE { ro_md_flag = 0; + move16(); } IF( st_ivas->hHeadTrackData != NULL ) @@ -1759,6 +1761,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 numSamplesPerChannelToOutput; Word16 td_q = 11; + test(); if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; -- GitLab From fb4ba1a9aad474ba1f89cbec78ca3670ee8a837d Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 30 Oct 2025 14:23:17 +0200 Subject: [PATCH 067/351] Add switch NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES back. --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index 676b3d674..344f3b451 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,6 +129,7 @@ #define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ #define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ +#define NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES /* Nokia: Fix for issues 1399: obj edit broken with MC/SBA output in VOIP, and 1400: negative energy estimate used for gaining. */ /* #################### End BASOP porting switches ############################ */ -- GitLab From d433c626514059143e0ab9e527def313018e4184 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 30 Oct 2025 14:32:07 +0200 Subject: [PATCH 068/351] Revert "Add switch NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES back." This reverts commit fb4ba1a9aad474ba1f89cbec78ca3670ee8a837d. --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 344f3b451..676b3d674 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,7 +129,6 @@ #define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ #define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ -#define NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES /* Nokia: Fix for issues 1399: obj edit broken with MC/SBA output in VOIP, and 1400: negative energy estimate used for gaining. */ /* #################### End BASOP porting switches ############################ */ -- GitLab From b2e65be4de6f12fc46d46c8380c13354822e5099 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Oct 2025 13:32:41 +0100 Subject: [PATCH 069/351] one more fix under FIX_2174_JBM_BASOP_ALIGNMENT --- lib_dec/ivas_jbm_dec_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index fa893c549..76f77b353 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -3364,7 +3364,11 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( IF( Opt_tsm ) { n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS ); +#ifdef FIX_2174_JBM_BASOP_ALIGNMENT + n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); +#else n_samp_residual = add( hTcBuffer->n_samples_granularity, 1 ); +#endif } ELSE { -- GitLab From 9f39d1a808cb535677d23c960c34b4a3f7e0ff5c Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 30 Oct 2025 10:26:13 +0100 Subject: [PATCH 070/351] Fix TD processing in split rendering --- lib_dec/ivas_jbm_dec_fx.c | 13 +++++++++ lib_dec/lib_dec_fx.c | 60 ++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index fa4c0a919..c0c129f13 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2581,7 +2581,20 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ + const Word32* p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + + /* Save TD signals for pose correction if they are to be used */ + if ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) + { + FOR( i = 0; i < nchan_out_syn_output; i++ ) + { + p_output_fx_const[i] = p_output_fx[i]; + } + ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); // TODO(sgi): change num_samples_per_channel to unsigned + } + #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP if ( st_ivas->flushing ) { diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a4bd04aa8..4c4d959ef 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1356,23 +1356,8 @@ static ivas_error isar_render_poses( } #endif - IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) ) - { -#if 1 /* NOTE(sgi): Workaround for bit width mismatch */ - Word32 pcmBuf32[960 * 16]; - - for (int i = 0; i < *nOutSamples * hIvasDec->st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i) - { - // NOTE(sgi2det): Is this even correct or do we need to adjust the Q-format? - pcmBuf32[i] = pcmBuf[i]; - } -#endif - - // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer... - // The float version of that function has switchable output format (int16 or float) but not in BASOP. - // Any ideas for a better solution than this pcmBuf32? - ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples ); - } +// NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. +// To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. return error; } @@ -1385,11 +1370,11 @@ static ivas_error isar_render_poses( *---------------------------------------------------------------------*/ static ivas_error isar_generate_metadata_and_bitstream( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ - Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits,/* o : output split rendering bits */ - Word16* td_q /* o : Q-format of the TD output if rendering from CLDFB */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ + Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS] /* o : Q-format of each channel of p_head_pose_buf */ ) { // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, @@ -1475,8 +1460,7 @@ static ivas_error isar_generate_metadata_and_bitstream( Quaternion.z_fx = 0; } // NOTE(sgi): BASOP special - not in float version - Word16 q1 = 31, q2 = 31, Q_buff = 31; - Word16 Q_out[CLDFB_NO_COL_MAX]; + Word16 q1 = 31, q2 = 31, Q_buff; Q_out[0] = 31; IF( EQ_16( cldfb_in_flag, 1 ) ) @@ -1518,6 +1502,7 @@ static ivas_error isar_generate_metadata_and_bitstream( } Q_out[0] = add( Q_out[0], Q11 ); Q_out[1] = Q_out[0]; + Q_buff = Q31 + Q6; // TODO(sgi): likely unneeded } IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, @@ -1534,11 +1519,6 @@ static ivas_error isar_generate_metadata_and_bitstream( return error; } - IF( EQ_16( cldfb_in_flag, 1 ) ) - { - *td_q = Q_out[0]; - } - return IVAS_ERR_OK; } #endif /* FIX_1119_SPLIT_RENDERING_VOIP */ @@ -1759,7 +1739,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 i; Word16 pcm_out_flag; Word16 numSamplesPerChannelToOutput; - Word16 td_q = 11; + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; test(); if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -1792,7 +1772,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( p_head_pose_buf[i] = head_pose_buf[i]; } - if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) + if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) { return error; } @@ -1800,6 +1780,10 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ if ( pcm_out_flag ) { + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 + } if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { #ifndef DISABLE_LIMITER @@ -1814,7 +1798,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output_fx( p_head_pose_buf, td_q, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } #else Decoder_Struct *st_ivas; @@ -5443,10 +5427,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( hIvasDec->hasDecodedFirstGoodFrame && splitRendBits != NULL ) { - Word16 td_q = 11;; + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; + Word16 i; /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ - IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, &td_q ) ) != IVAS_ERR_OK ) + IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) { return error; } @@ -5454,6 +5439,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples /* Synthesise PCM output if split PCM */ IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 + } + IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { #ifndef DISABLE_LIMITER @@ -5468,7 +5458,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output_fx( p_head_pose_buf, td_q, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); } } #endif -- GitLab From 1d9b752a270b61353216b8e59f40512acc48cb22 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Thu, 30 Oct 2025 13:56:49 +0100 Subject: [PATCH 071/351] lib_isar_pre_rend.c and lib_dec_fx.c called the wrong functions for divisons. --- lib_dec/lib_dec_fx.c | 20 +++++++++++--------- lib_isar/lib_isar_pre_rend.c | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index babd4f715..b874f0e48 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1262,8 +1262,8 @@ static Word16 isar_get_frame_size( ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { -#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here - nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); +#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216 + nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); #else nSamplesPerChannel = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1272,8 +1272,8 @@ static Word16 isar_get_frame_size( } else { -#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here - nSamplesPerChannel = divide3216( output_Fs, FRAMES_PER_SEC ); +#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216 + nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC ); #else nSamplesPerChannel = output_Fs / FRAMES_PER_SEC; #endif @@ -1319,7 +1319,8 @@ static ivas_error isar_render_poses( { #if 1 // NOTE(sgi2det): I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. // Generally I've seen arithmetic within calls to malloc() not ported, so maybe this is ok. - hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); + // NOTE(det2sgi): D'accord. But was the sizeof(float) correct? + hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); #else // NOTE(sgi): originally from det Word32 tmp; @@ -1371,6 +1372,7 @@ static ivas_error isar_render_poses( // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer... // The float version of that function has switchable output format (int16 or float) but not in BASOP. // Any ideas for a better solution than this pcmBuf32? + // NOTE(det2sgi): Was the requirement for the TD_Ringbuf a 32 Bit Datatype? A 16 Bit would make more sense. ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples ); } @@ -1407,9 +1409,9 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; -#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here. +#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here.// NOTE(det2sgi): ar_div() is a better fit than divide3216 // I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. Maybe this can just stay here. - max_band = (Word16) ( ( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); // TODO remove division + max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); // TODO remove division #else // NOTE(sgi): originally from det // NOTE(sgi): warning: implicit conversion from 'int' to 'Word16' (aka 'short') changes value from 48000 to -17536 [-Wconstant-conversion] max_band = divide3216( imult3216( BINAURAL_MAXBANDS, st_ivas->hDecoderConfig->output_Fs ), 48000 ); @@ -1420,8 +1422,8 @@ static ivas_error isar_generate_metadata_and_bitstream( // NOTE(sgi): BASOP special - not in float version n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); -#if 0 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here - num_cldfb_slots = extract_l( divide3216( L_deposit_l( nSamples ), n_samples_in_cldfb_slot ) ); +#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here// NOTE(det2sgi): int_div_s_x() is a better fit for a 16x16->16 bit division + num_cldfb_slots = int_div_s_x( nSamples , n_samples_in_cldfb_slot ); #else num_cldfb_slots = nSamples / n_samples_in_cldfb_slot; #endif diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 20cfc9f4d..f5b2a800b 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -494,8 +494,8 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( ELSE { Word16 ch, slot_idx, num_slots; -#if 0 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does. - num_slots = shl( isar_frame_size_ms, 3); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */ +#if 1 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does.// NOTE(det2sgi): Missing Division by 10 added + num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */ #else num_slots = isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS; #endif -- GitLab From e0f293c617571a41428bf055a374a8f49be26e6c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 15:52:21 +0100 Subject: [PATCH 072/351] port data type changes from float branch --- lib_rend/ivas_prot_rend_fx.h | 10 +++++----- lib_rend/ivas_td_ring_buffer_fx.c | 31 ++++++++++++++----------------- lib_rend/lib_rend_fx.c | 9 ++++----- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 54d6d10fa..783798f0d 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1601,7 +1601,7 @@ void ivas_rend_closeCldfbRend( ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ - const UWord32 capacity_per_channel, /* i : Number of samples stored per channel */ + const UWord16 capacity_per_channel, /* i : Number of samples stored per channel */ const UWord16 num_channels /* i : Number of channels */ ); @@ -1612,21 +1612,21 @@ void ivas_TD_RINGBUF_Close( void ivas_TD_RINGBUF_Push( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const Word32 *data, /* i : Input data */ - const UWord32 num_samples_per_channel /* i : Number of samples per channel to store */ + const UWord16 num_samples_per_channel /* i : Number of samples per channel to store */ ); void ivas_TD_RINGBUF_PushZeros( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const UWord32 num_samples_per_channel /* i : Number of zeros per channel to store */ + const UWord16 num_samples_per_channel /* i : Number of zeros per channel to store */ ); void ivas_TD_RINGBUF_Pop( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ Word32 *data, /* i : Output data */ - const UWord32 num_samples_per_channel /* i : Number of samples per channel to retrieve*/ + const UWord16 num_samples_per_channel /* i : Number of samples per channel to retrieve*/ ); -uint32_t ivas_TD_RINGBUF_Size( +uint16_t ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ); diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 6e34ab31c..024208e0c 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -105,14 +105,14 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ - const UWord32 capacity_per_channel, /* i : Number of samples stored per channel */ + const UWord16 capacity_per_channel, /* i : Number of samples stored per channel */ const UWord16 num_channels /* i : Number of channels */ ) { TD_RINGBUF_HANDLE h; UWord32 capacity; - capacity = Mult_32_16( capacity_per_channel, num_channels ); + capacity = L_mult0( capacity_per_channel, num_channels ); // Q0 x Q0 -> Q0 h = malloc( sizeof( TD_RINGBUF_DATA ) ); IF( h == NULL ) @@ -197,13 +197,12 @@ void ivas_TD_RINGBUF_Close( void ivas_TD_RINGBUF_Push( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const Word32 *data, /* i : Input data */ - const UWord32 num_samples_per_channel /* i : Number of samples per channel to store */ + const UWord16 num_samples_per_channel /* i : Number of samples per channel to store */ ) { - UWord32 s; - UWord16 c; + UWord16 c, s; - assert( ivas_td_ringbuf_has_space_for_num_samples( h, Mult_32_16( num_samples_per_channel, h->num_channels ) ) ); + assert( ivas_td_ringbuf_has_space_for_num_samples( h, L_mult0( num_samples_per_channel, h->num_channels ) ) ); FOR( s = 0; s < num_samples_per_channel; ++s ) { @@ -245,14 +244,13 @@ void ivas_TD_RINGBUF_Push( void ivas_TD_RINGBUF_PushZeros( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const UWord32 num_samples_per_channel /* i : Number of zeros per channel to store */ + const UWord16 num_samples_per_channel /* i : Number of zeros per channel to store */ ) { - UWord32 s; - UWord16 c; + UWord16 c, s; - assert( ivas_td_ringbuf_has_space_for_num_samples( h, Mult_32_16( num_samples_per_channel, h->num_channels ) ) ); - IF( EQ_32( num_samples_per_channel, 0 ) ) + assert( ivas_td_ringbuf_has_space_for_num_samples( h, L_mult0( num_samples_per_channel, h->num_channels ) ) ); + IF( EQ_16( num_samples_per_channel, 0 ) ) { return; } @@ -292,14 +290,13 @@ void ivas_TD_RINGBUF_PushZeros( void ivas_TD_RINGBUF_Pop( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ Word32 *data, /* i : Output data */ - const UWord32 num_samples_per_channel /* i : Number of samples per channel to retrieve */ + const UWord16 num_samples_per_channel /* i : Number of samples per channel to retrieve */ ) { - UWord32 s; - UWord16 c; + UWord16 c, s; Word32 requested_samples; - requested_samples = Mult_32_16( num_samples_per_channel, h->num_channels ); + requested_samples = L_mult0( num_samples_per_channel, h->num_channels ); assert( GE_32( ivas_td_ringbuf_total_size( h ), requested_samples ) ); FOR( s = 0; s < num_samples_per_channel; ++s ) @@ -339,11 +336,11 @@ void ivas_TD_RINGBUF_Pop( * Returns number of buffered samples per channel. *---------------------------------------------------------------------*/ -UWord32 ivas_TD_RINGBUF_Size( +UWord16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { - UWord32 size; + UWord16 size; size = div_l( ivas_td_ringbuf_total_size( h ), h->num_channels ); return size; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 0234fc6f5..f9c900897 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1642,9 +1642,8 @@ static ivas_error alignInputDelay( { ivas_error error; input_ism *inputIsm; - Word16 maxGlobalDelaySamples; - Word32 numSamplesToPush, numSamplesToPop; - UWord32 ringBufferSize, preDelay; + Word16 maxGlobalDelaySamples, numSamplesToPush, numSamplesToPop; + UWord16 ringBufferSize, preDelay; maxGlobalDelaySamples = latencyNsToSamples( sampleRateOut, maxGlobalDelayNs ); maxGlobalDelaySamples = i_mult( maxGlobalDelaySamples, cldfb2tdSampleFact ); @@ -1691,7 +1690,7 @@ static ivas_error alignInputDelay( IF( NE_16( flushInputs, 0 ) ) { numSamplesToPush = 0; - move32(); + move16(); numSamplesToPop = ivas_TD_RINGBUF_Size( inputBase->delayBuffer ); } @@ -1700,7 +1699,7 @@ static ivas_error alignInputDelay( numSamplesToPush = inputAudio.config.numSamplesPerChannel; move32(); - numSamplesToPop = (Word32) inputAudio.config.numSamplesPerChannel; + numSamplesToPop = inputAudio.config.numSamplesPerChannel; move32(); } -- GitLab From 52404c50b0ccacf1bdba6d198a95a0293ae0ffee Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 16:06:27 +0100 Subject: [PATCH 073/351] fix build with DEBUGGING active --- lib_rend/lib_rend_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index f9c900897..cbec31651 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -233,6 +233,10 @@ struct IVAS_REND Word8 rendererConfigEnabled; RENDER_CONFIG_DATA *hRendererConfig; /* Renderer config pointer */ +#ifdef DEBUGGING + Word32 numClipping; /* Counter of clipped output samples */ +#endif + Word16 num_subframes; hrtf_handles hHrtfs; }; -- GitLab From 08217b00fccb8b3cb3ab2cfa105d2d141e4cfea6 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 16:17:36 +0100 Subject: [PATCH 074/351] fix division --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index cbec31651..a61a321cc 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9326,7 +9326,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( /* Pose correction requires 20ms */ ELSE { - pSplitEncBufConfig->numSamplesPerChannel = div_s( hIvasRend->sampleRateOut, FRAMES_PER_SEC ); + pSplitEncBufConfig->numSamplesPerChannel = shl( div_l( hIvasRend->sampleRateOut, FRAMES_PER_SEC ), 1 ); } /* Note: float was "pSplitEncBufConfig->numSamplesPerChannel *= cldfb_in_flag ? 2 : 1;" */ -- GitLab From 01ec33995e7b21fc8020b7d0f94e1277b8ceecc5 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 16:57:07 +0100 Subject: [PATCH 075/351] fix misplaced code whcih caused segfault --- lib_rend/lib_rend_fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index a61a321cc..06ced5168 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4407,10 +4407,11 @@ ivas_error IVAS_REND_AddInput_fx( { return error; } + + /*assumes that input has been added which means codec has been set to either lcld or lc3plus (even if render config specified default)*/ + splitPreRendCldfb = EQ_32( hIvasRend->hRendererConfig->split_rend_config.codec, ISAR_SPLIT_REND_CODEC_LCLD ); } - /*assumes that input has been added which means codec has been set to either lcld or lc3plus (even if render config specified default)*/ - splitPreRendCldfb = EQ_32( hIvasRend->hRendererConfig->split_rend_config.codec, ISAR_SPLIT_REND_CODEC_LCLD ); #ifdef CODE_IMPROVEMENTS inputType = getAudioConfigType( inConfig ); -- GitLab From 843c8462eb299320fc6a083c6d2979c93172c13b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 17:10:24 +0100 Subject: [PATCH 076/351] remove spurious assert --- lib_rend/lib_rend_fx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 06ced5168..2ad411fcc 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4868,13 +4868,11 @@ ivas_error IVAS_REND_GetDelay_fx( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - assert( *timeScale == 8000 || *timeScale == 16000 || *timeScale == 32000 || *timeScale == 48000 ); - *nSamples = 0; move16(); *timeScale = hIvasRend->sampleRateOut; - + move32(); max_latency_ns = getMaxGlobalDelayNs( hIvasRend ); *nSamples = latencyNsToSamples( hIvasRend->sampleRateOut, max_latency_ns ); -- GitLab From 3056cb80b81222880b80eff705e1d46f0f947646 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 17:57:29 +0100 Subject: [PATCH 077/351] fix pre delay calculation + add some missing move's --- lib_rend/lib_rend_fx.c | 47 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 2ad411fcc..910c95654 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1660,7 +1660,6 @@ static ivas_error alignInputDelay( shl( inputAudio.config.numSamplesPerChannel, 1 ) ); /* pre delay for this input is maximum delay - input delay */ - preDelay = maxGlobalDelaySamples - inputBase->delayNumSamples * cldfb2tdSampleFact; preDelay = sub( maxGlobalDelaySamples, i_mult( inputBase->delayNumSamples, cldfb2tdSampleFact ) ); @@ -1701,10 +1700,10 @@ static ivas_error alignInputDelay( ELSE { numSamplesToPush = inputAudio.config.numSamplesPerChannel; - move32(); + move16(); numSamplesToPop = inputAudio.config.numSamplesPerChannel; - move32(); + move16(); } ivas_TD_RINGBUF_Push( inputBase->delayBuffer, inputAudio.data_fx, numSamplesToPush ); @@ -3607,13 +3606,20 @@ ivas_error IVAS_REND_Open( } hIvasRend = *phIvasRend; + move32(); hIvasRend->sampleRateOut = outputSampleRate; + move32(); hIvasRend->outputConfig = outConfig; + move32(); hIvasRend->customLsOut = defaultCustomLs(); hIvasRend->hLimiter = NULL; + move32(); hIvasRend->efapOutWrapper.hEfap = NULL; + move32(); hIvasRend->efapOutWrapper.pCustomLsSetup = NULL; + move32(); hIvasRend->num_subframes = num_subframes; + move16(); /* Initialize limiter */ IF( NE_32( ( error = IVAS_REND_GetNumOutChannels( hIvasRend, &numOutChannels ) ), IVAS_ERR_OK ) ) @@ -3675,27 +3681,38 @@ ivas_error IVAS_REND_Open( isar_init_split_rend_handles( hIvasRend->splitRendWrapper ); } hIvasRend->splitRendEncBuffer.data_fx = NULL; + move32(); hIvasRend->splitRendEncBuffer.config.is_cldfb = 0; + move16(); hIvasRend->splitRendEncBuffer.config.numChannels = 0; + move16(); hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = 0; + move16(); FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { initRendInputBase_fx( &hIvasRend->inputsIsm[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsIsm[i].crendWrapper = NULL; + move32(); hIvasRend->inputsIsm[i].hReverb = NULL; + move32(); hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL; + move32(); FOR( j = 0; j < MAX_HEAD_ROT_POSES - 1; ++j ) { hIvasRend->inputsIsm[i].splitTdRendWrappers[j].hBinRendererTd = NULL; + move32(); hIvasRend->inputsIsm[i].splitTdRendWrappers[j].hHrtfTD = NULL; + move32(); } hIvasRend->inputsIsm[i].nonDiegeticPan = nonDiegeticPan; move16(); hIvasRend->inputsIsm[i].nonDiegeticPanGain_fx = nonDiegeticPanGain; move32(); hIvasRend->inputsIsm[i].hOMasa = NULL; + move32(); hIvasRend->inputsIsm[i].bufferData_fx = NULL; + move32(); } FOR( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) @@ -3703,20 +3720,29 @@ ivas_error IVAS_REND_Open( initRendInputBase_fx( &hIvasRend->inputsMc[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsMc[i].efapInWrapper.hEfap = NULL; + move32(); hIvasRend->inputsMc[i].crendWrapper = NULL; + move32(); hIvasRend->inputsMc[i].hReverb = NULL; + move32(); hIvasRend->inputsMc[i].tdRendWrapper.hBinRendererTd = NULL; + move32(); hIvasRend->inputsMc[i].bufferData_fx = NULL; + move32(); hIvasRend->inputsMc[i].lfeDelayBuffer_fx = NULL; + move32(); hIvasRend->inputsMc[i].nonDiegeticPan = nonDiegeticPan; move16(); hIvasRend->inputsMc[i].nonDiegeticPanGain_fx = nonDiegeticPanGain; move32(); hIvasRend->inputsMc[i].hMcMasa = NULL; + move32(); FOR( j = 0; j < MAX_HEAD_ROT_POSES - 1; ++j ) { hIvasRend->inputsMc[i].splitTdRendWrappers[j].hBinRendererTd = NULL; + move32(); hIvasRend->inputsMc[i].splitTdRendWrappers[j].hHrtfTD = NULL; + move32(); } } @@ -3725,10 +3751,15 @@ ivas_error IVAS_REND_Open( initRendInputBase_fx( &hIvasRend->inputsSba[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsSba[i].crendWrapper = NULL; + move32(); hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend = NULL; + move32(); hIvasRend->inputsSba[i].cldfbRendWrapper.hHrtfFastConv = NULL; + move32(); hIvasRend->inputsSba[i].bufferData_fx = NULL; + move32(); hIvasRend->inputsSba[i].hDirAC = NULL; + move32(); } FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) @@ -3736,17 +3767,25 @@ ivas_error IVAS_REND_Open( initRendInputBase_fx( &hIvasRend->inputsMasa[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsMasa[i].metadataHasBeenFed = false; + move16(); hIvasRend->inputsMasa[i].bufferData_fx = NULL; + move32(); hIvasRend->inputsMasa[i].hMasaPrerend = NULL; + move32(); hIvasRend->inputsMasa[i].hMasaExtRend = NULL; - move16(); + move32(); } hIvasRend->hHrtfs.hHrtfFastConv = NULL; + move32(); hIvasRend->hHrtfs.hHrtfParambin = NULL; + move32(); hIvasRend->hHrtfs.hHrtfTD = NULL; + move32(); hIvasRend->hHrtfs.hHrtfCrend = NULL; + move32(); hIvasRend->hHrtfs.hHrtfStatistics = NULL; + move32(); IF( asHrtfBinary ) { -- GitLab From e453a4f4d1e5046fe8dbf806d1aaac95bd6520ea Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 30 Oct 2025 13:21:10 -0400 Subject: [PATCH 078/351] Keep the fix that has a minimal impact --- lib_com/options.h | 5 +---- lib_enc/ivas_core_pre_proc_front_fx.c | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 251456f2f..02e8d48a5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,10 +84,7 @@ #define FIX_BASOP_ASSERT_IN_TONAL_MDCT_PLC /* FhG: fix for issue 2165 - using saturating addition in tonal MDCT PLC function */ #define OPT_2146_BASOP_UTIL_ADD_MANT32EXP /* Dlb: optimized version of BASOP_Util_Add_Mant32Exp() */ -/*#define FIX_2015_PREMPH_SAT*/ /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor */ -#ifndef FIX_2015_PREMPH_SAT -#define FIX_2015_PREMPH_SAT_ALT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, alternative fix where only preemphis gets 1 more bit headroom */ -#endif +#define FIX_2015_PREMPH_SAT_ALT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 0711b778d..0a12c05ea 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -231,11 +231,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) -#ifndef FIX_2015_PREMPH_SAT Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); -#else - Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 + 1 ) ); -#endif Q_min = s_max( -2, Q_min ); Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min st->q_inp = Q_min; -- GitLab From 725f34872403eacec3ff8b6f8a4948c3924d3e39 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 18:26:49 +0100 Subject: [PATCH 079/351] fix td ring buffer total size function port went wrong somehow --- lib_rend/ivas_td_ring_buffer_fx.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 024208e0c..c90b7e15f 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -53,21 +53,17 @@ static UWord32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { - UWord32 total_size; - IF( h->is_full ) { - total_size = h->capacity; + return h->capacity; } IF( h->read_pos <= h->write_pos ) { - total_size = L_sub( h->write_pos, h->read_pos ); + return L_sub( h->write_pos, h->read_pos ); } /* else wrap around */ - total_size = L_add( h->write_pos, L_sub( h->capacity, h->read_pos ) ); - - return total_size; + return L_add( h->write_pos, L_sub( h->capacity, h->read_pos ) ); } -- GitLab From 9e6fcf0636dd0a0521524596a5ff6e9e366e2a01 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 18:45:44 +0100 Subject: [PATCH 080/351] use constant instead of magic number --- lib_rend/lib_rend_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 910c95654..3975b046c 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6273,7 +6273,7 @@ static ivas_error renderIsmToBinaural( push_wmops( "renderIsmToBinaural" ); /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ - ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, 429496730 /* 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES in Q31 */ ) ); + ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpTDRendBuffer ); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) @@ -6543,7 +6543,7 @@ static ivas_error renderIsmToBinauralReverb( push_wmops( "renderIsmToBinauralRoom" ); /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ - ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, 429496730 /* 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES in Q31 */ ) ); + ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx ); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -- GitLab From d871f85996272c4fdceb52d8e6895fe52521edd8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 18:47:58 +0100 Subject: [PATCH 081/351] fix logic error --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 3975b046c..6853acb27 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9389,7 +9389,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( } /* copy outputs */ - IF( NE_16( hIvasRend->splitRendEncBuffer.config.is_cldfb, 1 ) ) + IF( EQ_16( hIvasRend->splitRendEncBuffer.config.is_cldfb, 1 ) ) { cldfb_in_flag = 1; move16(); -- GitLab From fe0e9ff93068c8f89c8992a12c70fa088f87b15d Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 30 Oct 2025 21:43:44 +0100 Subject: [PATCH 082/351] Remove unused function ISAR_SPLIT_REND_BITStream_init --- lib_isar/isar_prot.h | 7 ------ lib_isar/isar_splitRenderer_utils.c | 23 ------------------- ...ring_buffer.c => ivas_td_ring_buffer_fx.c} | 0 3 files changed, 30 deletions(-) rename lib_rend/{ivas_td_ring_buffer.c => ivas_td_ring_buffer_fx.c} (100%) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 7d7b16f67..e1b173e02 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -421,13 +421,6 @@ void isar_init_split_rend_handles( SPLIT_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer pre-renderer handle */ ); -// UNUSED -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 buf_len_bytes, - UWord8 *pbuf -); - /*----------------------------------------------------------------------------------* * BASOP-only *----------------------------------------------------------------------------------*/ diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 54e0ec79c..6f72ce651 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -212,29 +212,6 @@ void isar_mat_mult_2by2_complex_fx( } -/*------------------------------------------------------------------------- - * Function ISAR_SPLIT_REND_BITStream_init() - * - * - *------------------------------------------------------------------------*/ - -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const Word32 buf_len_bytes, - UWord8 *pbuf ) -{ - pBits->bits_buf = pbuf; - pBits->buf_len = buf_len_bytes; - move32(); - pBits->bits_read = 0; - move32(); - pBits->bits_written = 0; - move32(); - - return; -} - - /*------------------------------------------------------------------------- * Function isar_split_rend_huffman_dec_init_min_max_len() * diff --git a/lib_rend/ivas_td_ring_buffer.c b/lib_rend/ivas_td_ring_buffer_fx.c similarity index 100% rename from lib_rend/ivas_td_ring_buffer.c rename to lib_rend/ivas_td_ring_buffer_fx.c -- GitLab From 1c468f073062fc44a4c70a465cae01bcb65d6bd3 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:12:23 +0100 Subject: [PATCH 083/351] Remove leftover switch --- lib_dec/lib_dec_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f0d71f3a9..214f65d02 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1271,12 +1271,10 @@ static ivas_error isar_render_poses( return error; } -#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) { return IVAS_ERR_OK; } -#endif IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) ) -- GitLab From ac1f33955f435f795f80ee908666babd286aabfe Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:12:54 +0100 Subject: [PATCH 084/351] Fix incorrect conflict resolution --- lib_dec/lib_dec_fx.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 214f65d02..a5e6bdc4f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1276,25 +1276,6 @@ static ivas_error isar_render_poses( return IVAS_ERR_OK; } - - IF ( !ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ) ) - { -#if 1 /* NOTE(sgi): Workaround for bit width mismatch */ - Word32 pcmBuf32[960 * 16]; - - for (int i = 0; i < *nOutSamples * hIvasDec->st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i) - { - // NOTE(sgi2det): Is this even correct or do we need to adjust the Q-format? - pcmBuf32[i] = pcmBuf[i]; - } -#endif - - // NOTE(sgi2det): We need signal in 32 bit here, but get only 16 bit from IVAS_DEC_GetSamplesRenderer... - // The float version of that function has switchable output format (int16 or float) but not in BASOP. - // Any ideas for a better solution than this pcmBuf32? - // NOTE(det2sgi): Was the requirement for the TD_Ringbuf a 32 Bit Datatype? A 16 Bit would make more sense. - ivas_TD_RINGBUF_PushInterleaved( st_ivas->hSplitBinRend->hMultiBinTdData, pcmBuf32, *nOutSamples ); - } // NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. // To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. -- GitLab From 9dad84917b1aeff512122206f88a37613bf86973 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:35:15 +0100 Subject: [PATCH 085/351] Update with changes from the float branch --- Workspace_msvc/lib_rend.vcxproj | 3 ++- lib_com/options.h | 1 - lib_rend/ivas_cldfb_ring_buffer.c | 12 ++++++------ lib_rend/ivas_prot_rend_fx.h | 24 +++++++++++------------- lib_rend/ivas_stat_rend.h | 7 +++---- lib_rend/ivas_td_ring_buffer_fx.c | 13 ++++++++----- lib_rend/lib_rend_fx.c | 19 +++++++++---------- 7 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index db791e067..b76f3211c 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -176,6 +176,7 @@ + @@ -210,4 +211,4 @@ - \ No newline at end of file + diff --git a/lib_com/options.h b/lib_com/options.h index bf6ed9456..c2c673ca5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,7 +100,6 @@ #define FIX_1377_HANDLE_ERROR_CODE /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */ #define FIX_1053_REVERB_RECONFIGURATION #define FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add split rendering support to decoder in VoIP mode */ -#define FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF // TODO(sgi): align with port 369, which actually adds the TD ringbuf: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/merge_requests/2412/diffs#d6d51ef63eb9458b72d78958dfd5b73ac4bae1de #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #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 FIX_938_COMPILER_WARNING /* FhG: Fix compiler warning in ivas_mdct_core_reconstruct() */ diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index eacf7f3fe..d5a78ef68 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -66,7 +66,7 @@ static Word16 ivas_cldfb_ringbuf_IsEmpty( * Returns 1 if the ring buffer is full, or 0 otherwise. *---------------------------------------------------------------------*/ -static Word32 ivas_cldfb_ringbuf_IsFull( +static Word16 ivas_cldfb_ringbuf_IsFull( ISAR_CLDFB_RINGBUF_HANDLE h ) { return h->is_full; @@ -76,7 +76,7 @@ static Word32 ivas_cldfb_ringbuf_IsFull( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_Open() * - * Allocate a ring buffer for CLDFB data with the given capacity of CLDFB columns. + * Allocates a ring buffer for CLDFB data with the given capacity of CLDFB columns. * Each column is expected to contain at most CLDFB_NO_CHANNELS_MAX frequency bands. * * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. @@ -126,7 +126,7 @@ ivas_error ivas_CLDFB_RINGBUF_Open( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_Close() * - * Dellocate CLDFB ring buffer. The given handle will be set to NULL. + * Dellocates CLDFB ring buffer. The given handle will be set to NULL. *---------------------------------------------------------------------*/ void ivas_CLDFB_RINGBUF_Close( @@ -164,7 +164,7 @@ void ivas_CLDFB_RINGBUF_Close( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_Push() * - * Push a single column onto the back of the CLDFB ring buffer from real and imag arrays. + * Pushes a single column onto the back of the CLDFB ring buffer from real and imag arrays. *---------------------------------------------------------------------*/ void ivas_CLDFB_RINGBUF_Push( @@ -200,7 +200,7 @@ void ivas_CLDFB_RINGBUF_Push( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_Pop() * - * Pop a single column from the front of the CLDFB ring buffer into real and imag arrays. + * Pops a single column from the front of the CLDFB ring buffer into real and imag arrays. *---------------------------------------------------------------------*/ void ivas_CLDFB_RINGBUF_Pop( @@ -263,7 +263,7 @@ static uint32_t ivas_cldfb_ringbuf_total_size( /*---------------------------------------------------------------------* * ivas_CLDFB_RINGBUF_GetByIdx() * - * Get pointers into a specific column in the CLDFB ring buffer based on given index. + * Gets pointers into a specific column in the CLDFB ring buffer based on given index. * Non-negative indices access from the front of the ring buffer, negative indexes access * from the back, similar to Python arrays. For example: * diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index d978d9034..c2274202e 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1594,15 +1594,14 @@ void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend ); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF /*----------------------------------------------------------------------------------* * Time domain ring buffer prototypes *----------------------------------------------------------------------------------*/ ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ - const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ - const Word16 num_channels /* i : Number of channels */ + const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ + const Word16 num_channels /* i : Number of channels */ ); void ivas_TD_RINGBUF_Close( @@ -1612,26 +1611,26 @@ void ivas_TD_RINGBUF_Close( #ifdef FIX_1119_SPLIT_RENDERING_VOIP void ivas_TD_RINGBUF_PushInterleaved( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input audio in interleaved channels layout */ - const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ); void ivas_TD_RINGBUF_PushChannels( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *p_channels[], /* i : Array of pointers to each input channel */ - const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ + const Word32 *p_channels[], /* i : Array of pointers to each input channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ ); void ivas_TD_RINGBUF_PushConstant( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 value, /* i : Value to push */ - const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ + const Word32 value, /* i : Value to push */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ); void ivas_TD_RINGBUF_PopChannels( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - Word32 *p_channels[], /* i : Array of pointers to each output channel */ - const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ + Word32 *p_channels[], /* i : Array of pointers to each output channel */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ ); #else void ivas_TD_RINGBUF_Push( @@ -1652,10 +1651,9 @@ void ivas_TD_RINGBUF_Pop( ); #endif -Word16 ivas_TD_RINGBUF_Size( // bit width? +Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ); -#endif /* clang-format on */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 23489353f..398d28350 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1432,22 +1432,21 @@ typedef struct } CLDFB_REND_WRAPPER; -#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF + /*----------------------------------------------------------------------------------* * Time domain ring buffer structure *----------------------------------------------------------------------------------*/ typedef struct { - Word32 *data; /* samples in interleaved layout */ - Word32 capacity; + Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ + Word32 capacity; /* max number of Word32 values that can be stored */ Word16 num_channels; Word32 write_pos; Word32 read_pos; Word16 is_full; } TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE; -#endif /*----------------------------------------------------------------------------------* * Limiter structure diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index a79d7b0c7..497bed224 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -38,21 +38,25 @@ #include "wmc_auto.h" -#ifdef FIX_1119_SPLIT_RENDERING_VOIP_TD_RINGBUF - /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ +/*---------------------------------------------------------------------* + * ivas_td_ringbuf_total_size() + * + * Returns total number of buffered samples (including number of channels) + *---------------------------------------------------------------------*/ + static Word32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { - if ( h->is_full ) + IF( h->is_full ) { return h->capacity; } - if ( LE_32( h->read_pos, h->write_pos ) ) + IF ( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -445,4 +449,3 @@ Word16 ivas_TD_RINGBUF_Size( { return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; // TODO(sgi): port division } -#endif diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 80d87712a..f9765c821 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8952,19 +8952,18 @@ static ivas_error getSamplesInternal( } Word32 *tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS], tmpBinaural_buff[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; -#ifdef FIX_1119_SPLIT_RENDERING_VOIP - // TODO(sgi): This doesn't match the original MR. BASOP main too far behind. Port later. - Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; - Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; +#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* Temporary fix. Proper implementation of port 391 can only be added once port 369 is complete. */ + Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; + Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) - { - for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { - p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; - p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; + for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + { + p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; + p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; + } } - } #endif FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) -- GitLab From 87bf98647c9f4b4bbf620c385d92f6050565ff5d Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:53:43 +0100 Subject: [PATCH 086/351] Clean up TODO and NOTE comments --- lib_dec/ivas_jbm_dec_fx.c | 2 +- lib_dec/lib_dec_fx.c | 62 +++++++------------------------ lib_isar/lib_isar_pre_rend.c | 20 ++++++---- lib_rend/ivas_td_ring_buffer_fx.c | 3 +- 4 files changed, 29 insertions(+), 58 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3a43d4181..363283022 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2472,7 +2472,7 @@ ivas_error ivas_jbm_dec_render_fx( { p_output_fx_const[i] = p_output_fx[i]; } - ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); // TODO(sgi): change num_samples_per_channel to unsigned + ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a5e6bdc4f..af4368e32 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1187,21 +1187,12 @@ static Word16 isar_get_frame_size( ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { -#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216 nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); -#else - nSamplesPerChannel = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); - nSamplesPerChannel *= (int16_t) st_ivas->hDecoderConfig->render_framesize; -#endif } else { -#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here // NOTE(det2sgi): ar_div() is a better fit than divide3216 nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC ); -#else - nSamplesPerChannel = output_Fs / FRAMES_PER_SEC; -#endif } return nSamplesPerChannel; @@ -1221,8 +1212,10 @@ static ivas_error isar_render_poses( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { - // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, - // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + // Note for reviewers: Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, + // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference +#endif Word16 pcmBuf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES * L_FRAME48k]; Decoder_Struct *st_ivas; ivas_error error; @@ -1242,27 +1235,8 @@ static ivas_error isar_render_poses( /* init flush buffer for rate switch if not already initizalized */ if ( hIvasDec->flushbuffer == NULL ) { -#if 1 // NOTE(sgi2det): I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. - // Generally I've seen arithmetic within calls to malloc() not ported, so maybe this is ok. - // NOTE(det2sgi): D'accord. But was the sizeof(float) correct? - hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); -#else // NOTE(sgi): originally from det - Word32 tmp; - /* numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 ) */ - tmp = imult3216( L_deposit_l( numPoses ), hIvasDec->nSamplesFrame ); - /* BINAURAL_CHANNELS=2, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES=4, sizeof (Word16)=2. */ - /* BINAURAL_CHANNELS * sizeof(Word16)/ IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = 4/4 = 1 */ - hIvasDec->flushbuffer = (void *) malloc( tmp ); - if ( hIvasDec->flushbuffer == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); - } - hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; // NOTE(sgi2det): the BASOP version of this struct has no pcmType member - only 16 bit PCM is supported. - /* hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES = tmp/2 */ - tmp = L_shr( tmp, 1); - set_zero( (Word16 *) hIvasDec->flushbuffer, tmp ); -#endif } /* render */ @@ -1297,8 +1271,10 @@ static ivas_error isar_generate_metadata_and_bitstream( Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS] /* o : Q-format of each channel of p_head_pose_buf */ ) { - // NOTE(sgi2det): Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, - // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference +#ifndef FIX_1119_SPLIT_RENDERING_VOIP + // Note for reviewers: Code in this function was moved and adapted from IVAS_DEC_GetSplitBinauralBitstream, + // see #else branch of FIX_1119_SPLIT_RENDERING_VOIP there for reference +#endif ivas_error error; ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; Word16 max_band; @@ -1312,24 +1288,14 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; -#if 1 // NOTE(sgi2det): The divide function includes a right shift so the result ends up 2x too small here.// NOTE(det2sgi): ar_div() is a better fit than divide3216 - // I copied this from previously ported version of IVAS_DEC_GetSplitBinauralBitstream. Maybe this can just stay here. - max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); // TODO remove division -#else // NOTE(sgi): originally from det - // NOTE(sgi): warning: implicit conversion from 'int' to 'Word16' (aka 'short') changes value from 48000 to -17536 [-Wconstant-conversion] - max_band = divide3216( imult3216( BINAURAL_MAXBANDS, st_ivas->hDecoderConfig->output_Fs ), 48000 ); -#endif + max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); // NOTE(sgi): BASOP special - not in float version n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); -#if 1 // NOTE(sgi2det): the divide function includes a right shift so the result ends up 2x too small here// NOTE(det2sgi): int_div_s_x() is a better fit for a 16x16->16 bit division - num_cldfb_slots = int_div_s_x( nSamples , n_samples_in_cldfb_slot ); -#else - num_cldfb_slots = nSamples / n_samples_in_cldfb_slot; -#endif + num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -1422,7 +1388,7 @@ static ivas_error isar_generate_metadata_and_bitstream( } Q_out[0] = add( Q_out[0], Q11 ); Q_out[1] = Q_out[0]; - Q_buff = Q31 + Q6; // TODO(sgi): likely unneeded + Q_buff = Q31 + Q6; // likely unneeded } IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, @@ -1596,7 +1562,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi2det): this function still needs to be ported to BASOP +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // TODO(sgi): this function still needs to be ported to BASOP Decoder_Struct *st_ivas; ivas_error error; Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; @@ -1916,7 +1882,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (Word16 *) pcmBuf_out ); } -#ifndef TMP_FIX_SPLIT_REND // TODO(sgi): need to port? +#ifndef TMP_FIX_SPLIT_REND free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); #endif #endif diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index f5b2a800b..82077791a 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -410,7 +410,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( tmp_e = 0; tmp = BASOP_Util_Divide3232_Scale( L_mult0( CLDFB_NO_COL_MAX, ivas_fs ), 20, &tmp_e ); - num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 // NOTE(sgi): this could be a macro constant? + num_slots = shr( tmp, sub( 15, tmp_e ) ); // Q0 // num_slots = (Word16) CLDFB_NO_COL_MAX * ivas_fs / 20; /* CLDFB synthesis of main pose */ { @@ -494,11 +494,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( ELSE { Word16 ch, slot_idx, num_slots; -#if 1 // NOTE(sgi2det): This shift left here doesn't correspond to what the original code does.// NOTE(det2sgi): Missing Division by 10 added - num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); /* ( isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS ); */ -#else - num_slots = isar_frame_size_ms * 1000000 / CLDFB_SLOT_NS; -#endif + num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); /* CLDFB synthesis of main pose */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -509,7 +505,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); q2 = 31; move16(); - FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version + FOR( j = 0; j < num_slots; j++ ) +#else + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { q1 = s_min( getScaleFactor32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q1 ); q2 = s_min( getScaleFactor32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX ), q2 ); @@ -518,7 +518,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); q_final = sub( q_final, 6 ); // guard bits q_final = s_min( q_final, Q25 ); - FOR( j = 0; j < num_slots; j++ ) // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version + FOR( j = 0; j < num_slots; j++ ) +#else + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { Scale_sig32( Cldfb_In_BinReal_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); Scale_sig32( Cldfb_In_BinImag_fx[ch][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 497bed224..0f1a72c47 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -36,6 +36,7 @@ #include "ivas_prot_rend_fx.h" #include "options.h" #include "wmc_auto.h" +#include "prot_fx.h" /*-----------------------------------------------------------------------* @@ -447,5 +448,5 @@ Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { - return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; // TODO(sgi): port division + return extract_l( ar_div( ivas_td_ringbuf_total_size( h ), L_deposit_l( h->num_channels ) ) ); } -- GitLab From 1ab8a5a1169c49f095f7869c9b2ad6cda2ab1966 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:56:57 +0100 Subject: [PATCH 087/351] Fix formatting --- apps/decoder.c | 10 ++-- lib_dec/ivas_jbm_dec_fx.c | 8 +-- lib_dec/ivas_output_config_fx.c | 3 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec_fx.c | 84 +++++++++++++++---------------- lib_isar/lib_isar_pre_rend.c | 2 +- lib_rend/ivas_cldfb_ring_buffer.c | 34 ++++++------- lib_rend/ivas_stat_rend.h | 4 +- lib_rend/ivas_td_ring_buffer_fx.c | 64 +++++++++++------------ lib_rend/lib_rend_fx.c | 4 +- 10 files changed, 106 insertions(+), 109 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index e0c0ad73e..03f09be6d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3034,14 +3034,14 @@ static ivas_error decodeVoIP( { #endif #ifdef SUPPORT_JBM_TRACEFILE - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, &bitstreamReadDone, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #endif - { - fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } #ifdef FIX_1119_SPLIT_RENDERING_VOIP } #endif diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 363283022..81bd0ea6d 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2461,7 +2461,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ - const Word32* p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; + const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -2475,7 +2475,7 @@ ivas_error ivas_jbm_dec_render_fx( ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); } -#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP if ( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; @@ -2492,8 +2492,8 @@ ivas_error ivas_jbm_dec_render_fx( ELSE { #endif - nchan_out_syn_output = nchan_out; - move16(); + nchan_out_syn_output = nchan_out; + move16(); #ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ } #endif diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 53573c7ee..c71431e5c 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -630,8 +630,7 @@ RENDERER_TYPE ivas_renderer_secondary_select_fx( test(); test(); IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && - ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - ) + ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) #else IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 46c1710c1..53d73c7c9 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1024,7 +1024,7 @@ typedef struct decoder_tc_buffer_structure #ifdef JBM_MEMORY_OPT Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ #else - Word32 *tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc Q11 for ivas */ + Word32 *tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc Q11 for ivas */ #endif Word16 no_channels; /*Stores no of channels in tc_fx with values*/ Word16 q_tc_fx; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index af4368e32..fef1711e6 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -783,7 +783,7 @@ static int16_t get_render_frame_size_samples( Word16 tmp; tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); - /* NOTE(sgi): BASOP special - not in float version */ + /* NOTE(sgi): BASOP special - not in float version */ IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { /* correct value already in tmp */ @@ -1206,10 +1206,10 @@ static Word16 isar_get_frame_size( *---------------------------------------------------------------------*/ static ivas_error isar_render_poses( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked, /* i : number of samples wanted by the caller */ - Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : indication that the decoder needs a new frame */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const Word16 nSamplesAsked, /* i : number of samples wanted by the caller */ + Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { #ifndef FIX_1119_SPLIT_RENDERING_VOIP @@ -1240,18 +1240,18 @@ static ivas_error isar_render_poses( } /* render */ - IF ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } - IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) { return IVAS_ERR_OK; } -// NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. -// To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. + // NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. + // To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. return error; } @@ -1264,11 +1264,11 @@ static ivas_error isar_render_poses( *---------------------------------------------------------------------*/ static ivas_error isar_generate_metadata_and_bitstream( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ - Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS] /* o : Q-format of each channel of p_head_pose_buf */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 **p_head_pose_buf, /* i/o: PCM buffer with head-pose data */ + Word16 nSamples, /* i : duration of audio (in samples per channel) for which metadata should be generated */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS] /* o : Q-format of each channel of p_head_pose_buf */ ) { #ifndef FIX_1119_SPLIT_RENDERING_VOIP @@ -1288,7 +1288,7 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; - max_band = (Word16)ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); + max_band = (Word16) ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); @@ -1301,7 +1301,7 @@ static ivas_error isar_generate_metadata_and_bitstream( IF( cldfb_in_flag ) { - FOR( i = 0; i < imult1616( BINAURAL_CHANNELS, num_poses); ++i ) + FOR( i = 0; i < imult1616( BINAURAL_CHANNELS, num_poses ); ++i ) { FOR( j = 0; j < num_cldfb_slots; ++j ) { @@ -1323,7 +1323,7 @@ static ivas_error isar_generate_metadata_and_bitstream( } - IF ( st_ivas->hBinRendererTd != NULL ) + IF( st_ivas->hBinRendererTd != NULL ) { ro_md_flag = 1; move16(); @@ -1392,15 +1392,15 @@ static ivas_error isar_generate_metadata_and_bitstream( } IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, - Quaternion, - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, - st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, - st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - splitRendBits, - p_Cldfb_RealBuffer_Binaural, - p_Cldfb_ImagBuffer_Binaural, - max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + p_Cldfb_RealBuffer_Binaural, + p_Cldfb_ImagBuffer_Binaural, + max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -4549,23 +4549,23 @@ static ivas_error ivas_dec_voip_get_samples_common ivas_error IVAS_DEC_VoIP_GetSamples #endif ( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ - Word16 *pcmBuf, /* o : output synthesis signal */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ #ifdef FIX_1119_SPLIT_RENDERING_VOIP ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - Word32 **p_head_pose_buf, /* i : PCM buffer with head-pose data */ + Word32 **p_head_pose_buf, /* i : PCM buffer with head-pose data */ #endif #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter, #endif - bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ - UWord16 *nSamplesRendered, /* o : number of samples rendered */ - bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ - const UWord32 systemTimestamp_ms /* i : current system timestamp */ -) + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ + ) { Decoder_Struct *st_ivas; DECODER_CONFIG_HANDLE hDecoderConfig; @@ -4603,7 +4603,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples test(); IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) && - splitRendBits == NULL ) + splitRendBits == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; // NOTE(sgi): BASOP special - not in float version } @@ -4885,10 +4885,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ - Word16 *pcmBuf, /* o : output synthesis signal */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter, @@ -4975,7 +4975,6 @@ ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( #endif - /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * @@ -6134,7 +6133,6 @@ static Word16 ivas_dec_split_rend_cldfb_in( #endif - /*-------------------------------------------------------------------* * ivas_dec_init_split_rend() * diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 82077791a..2b1220154 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -494,7 +494,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( ELSE { Word16 ch, slot_idx, num_slots; - num_slots = int_div_s_x( shl( isar_frame_size_ms, 3), 10); + num_slots = int_div_s_x( shl( isar_frame_size_ms, 3 ), 10 ); /* CLDFB synthesis of main pose */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index d5a78ef68..d23490255 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -56,7 +56,7 @@ static Word16 ivas_cldfb_ringbuf_IsEmpty( ISAR_CLDFB_RINGBUF_HANDLE h ) { test(); - return EQ_16( h->read_pos, h->write_pos ) && !h->is_full; + return EQ_16( h->read_pos, h->write_pos ) && !h->is_full; } @@ -92,7 +92,7 @@ ivas_error ivas_CLDFB_RINGBUF_Open( capacity = i_mult( capacity_columns, CLDFB_NO_CHANNELS_MAX ); move16(); - IF ( ( h = malloc( sizeof( ISAR_CLDFB_RINGBUF ) ) ) == NULL ) + IF( ( h = malloc( sizeof( ISAR_CLDFB_RINGBUF ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); } @@ -108,11 +108,11 @@ ivas_error ivas_CLDFB_RINGBUF_Open( move16(); *ph = h; - IF ( ( h->real = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) + IF( ( h->real = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); } - IF ( ( h->imag = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) + IF( ( h->imag = malloc( capacity * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for CLDFB ring buffer\n" ); } @@ -134,22 +134,22 @@ void ivas_CLDFB_RINGBUF_Close( { ISAR_CLDFB_RINGBUF_HANDLE h; - IF ( ph == NULL ) + IF( ph == NULL ) { return; } h = *ph; - IF ( h == NULL ) + IF( h == NULL ) { return; } - IF ( h->real != NULL ) + IF( h->real != NULL ) { free( h->real ); } - IF ( h->imag != NULL ) + IF( h->imag != NULL ) { free( h->imag ); } @@ -181,13 +181,13 @@ void ivas_CLDFB_RINGBUF_Push( h->write_pos = add( h->write_pos, CLDFB_NO_CHANNELS_MAX ); move16(); - if ( EQ_16( h->write_pos, h->capacity ) ) + if ( EQ_16( h->write_pos, h->capacity ) ) { h->write_pos = 0; move16(); } - if ( EQ_16( h->read_pos, h->write_pos ) ) + if ( EQ_16( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -212,18 +212,18 @@ void ivas_CLDFB_RINGBUF_Pop( assert( num_bands <= CLDFB_NO_CHANNELS_MAX ); assert( !ivas_cldfb_ringbuf_IsEmpty( h ) ); - IF ( real != NULL ) + IF( real != NULL ) { Copy32( &h->real[h->read_pos], real, num_bands ); } - IF ( imag != NULL ) + IF( imag != NULL ) { Copy32( &h->imag[h->read_pos], imag, num_bands ); } h->read_pos = add( h->read_pos, CLDFB_NO_CHANNELS_MAX ); move16(); - IF ( EQ_16( h->read_pos, h->capacity ) ) + IF( EQ_16( h->read_pos, h->capacity ) ) { h->read_pos = 0; move16(); @@ -245,12 +245,12 @@ void ivas_CLDFB_RINGBUF_Pop( static uint32_t ivas_cldfb_ringbuf_total_size( ISAR_CLDFB_RINGBUF_HANDLE h ) { - IF ( ivas_cldfb_ringbuf_IsFull( h ) ) + IF( ivas_cldfb_ringbuf_IsFull( h ) ) { return h->capacity; } - IF ( LE_16( h->read_pos, h->write_pos ) ) + IF( LE_16( h->read_pos, h->write_pos ) ) { return sub( h->write_pos, h->read_pos ); } @@ -285,7 +285,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( assert( -num_floats <= idx && idx <= num_floats ); - IF ( GE_16( idx, 0 ) ) + IF( GE_16( idx, 0 ) ) { offset = add( h->read_pos, idx ); move16(); @@ -299,7 +299,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( { idx = negate( idx ); move16(); - IF ( LE_16 ( idx, h->write_pos ) ) + IF( LE_16( idx, h->write_pos ) ) { offset = sub( h->write_pos, idx ); move16(); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 398d28350..7fe2f3af7 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1439,8 +1439,8 @@ typedef struct typedef struct { - Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ - Word32 capacity; /* max number of Word32 values that can be stored */ + Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ + Word32 capacity; /* max number of Word32 values that can be stored */ Word16 num_channels; Word32 write_pos; Word32 read_pos; diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 0f1a72c47..9d26bbd2d 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -57,7 +57,7 @@ static Word32 ivas_td_ringbuf_total_size( return h->capacity; } - IF ( LE_32( h->read_pos, h->write_pos ) ) + IF( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -70,14 +70,14 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - return LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ); + return LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ); } #ifdef FIX_1119_SPLIT_RENDERING_VOIP static void ivas_td_ringbuf_push_interleaved( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input audio in interleaved channels layout */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ const Word16 num_samples_per_channel, /* i : Number of samples per channel to push */ const Word16 read_stride /* i: : 1 for normal operation, 0 for reading from a single input value */ ) @@ -91,7 +91,7 @@ static void ivas_td_ringbuf_push_interleaved( read_s = 0; move32(); - FOR ( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels); ++s ) + FOR( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) { h->data[h->write_pos] = data[read_s]; move32(); @@ -105,7 +105,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); } - if ( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -129,7 +129,7 @@ static void ivas_td_ringbuf_push_interleaved( *---------------------------------------------------------------------*/ ivas_error ivas_TD_RINGBUF_Open( - TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ const Word16 num_channels /* i : Number of channels */ ) @@ -141,7 +141,7 @@ ivas_error ivas_TD_RINGBUF_Open( move32(); h = malloc( sizeof( TD_RINGBUF_DATA ) ); - IF ( h == NULL ) + IF( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -183,18 +183,18 @@ void ivas_TD_RINGBUF_Close( { TD_RINGBUF_HANDLE h; - IF ( ph == NULL ) + IF( ph == NULL ) { return; } h = *ph; - IF ( h == NULL ) + IF( h == NULL ) { return; } - IF ( h->data != NULL ) + IF( h->data != NULL ) { free( h->data ); } @@ -214,8 +214,8 @@ void ivas_TD_RINGBUF_Close( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushInterleaved( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input audio in interleaved channels layout */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input audio in interleaved channels layout */ const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ) { @@ -232,8 +232,8 @@ void ivas_TD_RINGBUF_PushInterleaved( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushChannels( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *p_channels[], /* i : Array of pointers to each input channel */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *p_channels[], /* i : Array of pointers to each input channel */ const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ) #else @@ -245,8 +245,8 @@ void ivas_TD_RINGBUF_PushChannels( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_Push( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input data */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ ) #endif @@ -264,9 +264,9 @@ void ivas_TD_RINGBUF_Push( #endif assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP h->data[h->write_pos] = p_channels[c][s]; @@ -303,8 +303,8 @@ void ivas_TD_RINGBUF_Push( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushConstant( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 value, /* i : Value to push */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 value, /* i : Value to push */ const Word16 num_samples_per_channel /* i : Number of samples per channel to push */ ) { @@ -320,7 +320,7 @@ void ivas_TD_RINGBUF_PushConstant( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushZeros( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const Word16 num_samples_per_channel /* i : Number of zeros per channel to store */ ) { @@ -333,15 +333,15 @@ void ivas_TD_RINGBUF_PushZeros( return; } - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { h->data[h->write_pos] = 0.f; move32(); ++h->write_pos; - if ( EQ_32 ( h->write_pos == h->capacity ) ) + if ( EQ_32( h->write_pos == h->capacity ) ) { h->write_pos = 0; move32(); @@ -368,8 +368,8 @@ void ivas_TD_RINGBUF_PushZeros( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PopChannels( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - Word32 *p_channels[], /* i : Array of pointers to each output channel */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *p_channels[], /* i : Array of pointers to each output channel */ const Word16 num_samples_per_channel /* i : Number of samples per channel to pop */ ) #else @@ -380,8 +380,8 @@ void ivas_TD_RINGBUF_PopChannels( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_Pop( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - Word32 *data, /* i : Output data */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve */ ) #endif @@ -399,9 +399,9 @@ void ivas_TD_RINGBUF_Pop( #endif assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP p_channels[c][s] = h->data[h->read_pos]; @@ -412,7 +412,7 @@ void ivas_TD_RINGBUF_Pop( #endif ++h->read_pos; - IF ( EQ_32( h->read_pos, h->capacity ) ) + IF( EQ_32( h->read_pos, h->capacity ) ) { h->read_pos = 0; move32(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index f9765c821..e01a93347 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9047,14 +9047,14 @@ static ivas_error getSamplesInternal( hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, - p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, + p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) #else IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) #endif { -- GitLab From 183b90372a173f19f60718498ff89a584ddd801a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 00:59:44 +0100 Subject: [PATCH 088/351] Fix build with DEBUGGING enabled --- lib_dec/lib_dec_fx.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index fef1711e6..4882dd11d 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1626,10 +1626,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); } -#ifdef DEBUGGING - st_ivas->noClipping += -#endif - ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } #else Decoder_Struct *st_ivas; @@ -4865,10 +4862,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); } -#ifdef DEBUGGING - st_ivas->noClipping += -#endif - ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); } } #endif -- GitLab From 012af922bb678cefd064e59c40f0f688e6a99fb4 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 01:04:54 +0100 Subject: [PATCH 089/351] Fix MSVC warnings --- lib_rend/ivas_cldfb_ring_buffer.c | 4 ++-- lib_rend/ivas_td_ring_buffer_fx.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index d23490255..93f3d9927 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -242,7 +242,7 @@ void ivas_CLDFB_RINGBUF_Pop( * Returns total number of buffered samples (including number of channels) *---------------------------------------------------------------------*/ -static uint32_t ivas_cldfb_ringbuf_total_size( +static Word32 ivas_cldfb_ringbuf_total_size( ISAR_CLDFB_RINGBUF_HANDLE h ) { IF( ivas_cldfb_ringbuf_IsFull( h ) ) @@ -279,7 +279,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( { Word16 idx = i_mult( col_idx, CLDFB_NO_CHANNELS_MAX ); move16(); - Word16 num_floats = ivas_cldfb_ringbuf_total_size( h ); + Word16 num_floats = extract_l( ivas_cldfb_ringbuf_total_size( h ) ); move16(); Word16 offset /*, uidx */; // uidx unused in FX code diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 9d26bbd2d..e8ce8bd2e 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -70,7 +70,11 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - return LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ); + if ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + { + return 1; + } + return 0; } -- GitLab From 18bfc9c9f21dc6e9dd5bc9bbd454f40ca38bf29a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 01:07:52 +0100 Subject: [PATCH 090/351] Fix more MSVC warnigs --- lib_dec/lib_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4882dd11d..3cf66caec 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1187,12 +1187,12 @@ static Word16 isar_get_frame_size( ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { - nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ); + nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); } else { - nSamplesPerChannel = ar_div( output_Fs, FRAMES_PER_SEC ); + nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC ) ); } return nSamplesPerChannel; -- GitLab From ada2ff18338fcf9d019d900346cda318fd9f7fad Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 01:46:18 +0100 Subject: [PATCH 091/351] Fix missing bits of porting --- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- lib_dec/lib_dec_fx.c | 37 ++++++++++++++++++------------- lib_isar/isar_splitRendererPre.c | 4 ++-- lib_rend/ivas_cldfb_ring_buffer.c | 6 ++--- lib_rend/ivas_td_ring_buffer_fx.c | 26 +++++++++++----------- lib_rend/lib_rend_fx.c | 4 ++-- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 81bd0ea6d..e68fe934b 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2466,7 +2466,7 @@ ivas_error ivas_jbm_dec_render_fx( nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; /* Save TD signals for pose correction if they are to be used */ - if ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) + IF ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) { FOR( i = 0; i < nchan_out_syn_output; i++ ) { @@ -2476,7 +2476,7 @@ ivas_error ivas_jbm_dec_render_fx( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP - if ( st_ivas->flushing ) + IF ( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 3cf66caec..2ba0d3e26 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1183,14 +1183,16 @@ static Word16 isar_get_frame_size( output_Fs = st_ivas->hDecoderConfig->output_Fs; - if ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + test(); + test(); + IF ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); } - else + ELSE { nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC ) ); } @@ -1221,7 +1223,7 @@ static ivas_error isar_render_poses( ivas_error error; Word16 numPoses; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1233,7 +1235,7 @@ static ivas_error isar_render_poses( numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; /* init flush buffer for rate switch if not already initizalized */ - if ( hIvasDec->flushbuffer == NULL ) + IF ( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1562,7 +1564,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // TODO(sgi): this function still needs to be ported to BASOP +#ifdef FIX_1119_SPLIT_RENDERING_VOIP Decoder_Struct *st_ivas; ivas_error error; Word32 head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k]; @@ -1573,49 +1575,51 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; test(); - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } st_ivas = hIvasDec->st_ivas; - if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + IF ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { return IVAS_ERR_WRONG_PARAMS; } pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + move16(); numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); + move16(); - if ( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF ( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } - if ( !hIvasDec->hasBeenFedFirstGoodFrame ) + IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) { return IVAS_ERR_OK; } - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { p_head_pose_buf[i] = head_pose_buf[i]; } - if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) + IF ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) { return error; } /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ - if ( pcm_out_flag ) + IF ( pcm_out_flag ) { FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } - if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + IF ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); @@ -6112,14 +6116,17 @@ static Word16 ivas_dec_split_rend_cldfb_in( const RENDERER_TYPE renderer_type /* i : renderer type */ ) { - if ( renderer_type == RENDERER_BINAURAL_FASTCONV || + test(); + test(); + test(); + IF ( renderer_type == RENDERER_BINAURAL_FASTCONV || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || renderer_type == RENDERER_BINAURAL_PARAMETRIC || renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { return 1; } - else + ELSE { return 0; } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index ebb07b720..455eeff3f 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2929,9 +2929,9 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( useLc3plus = hSplitBin->hLc3plusEnc != NULL; #ifdef FIX_1119_SPLIT_RENDERING_VOIP - for ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + FOR ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) { - for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_In_BinReal[i][j] = Cldfb_In_BinReal_fx[i][j]; p_Cldfb_In_BinImag[i][j] = Cldfb_In_BinImag_fx[i][j]; diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 93f3d9927..87929a0b5 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -181,13 +181,13 @@ void ivas_CLDFB_RINGBUF_Push( h->write_pos = add( h->write_pos, CLDFB_NO_CHANNELS_MAX ); move16(); - if ( EQ_16( h->write_pos, h->capacity ) ) + IF ( EQ_16( h->write_pos, h->capacity ) ) { h->write_pos = 0; move16(); } - if ( EQ_16( h->read_pos, h->write_pos ) ) + IF ( EQ_16( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -289,7 +289,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( { offset = add( h->read_pos, idx ); move16(); - if ( LE_16( h->capacity, offset ) ) + IF ( LE_16( h->capacity, offset ) ) { offset = sub( offset, h->capacity ); move16(); diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index e8ce8bd2e..215500d37 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - if ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -101,7 +101,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); ++h->write_pos; - if ( EQ_32( h->write_pos, h->capacity ) ) + IF ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; } @@ -109,7 +109,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); } - if ( EQ_32( h->read_pos, h->write_pos ) ) + IF ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -163,7 +163,7 @@ ivas_error ivas_TD_RINGBUF_Open( *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - if ( h->data == NULL ) + IF ( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -261,7 +261,7 @@ void ivas_TD_RINGBUF_Push( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + FOR ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } @@ -281,7 +281,7 @@ void ivas_TD_RINGBUF_Push( #endif ++h->write_pos; - if ( EQ_32( h->write_pos, h->capacity ) ) + IF ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -289,7 +289,7 @@ void ivas_TD_RINGBUF_Push( } } - if ( EQ_32( h->read_pos, h->write_pos ) ) + IF ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -332,7 +332,7 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - if ( !num_samples_per_channel ) + IF ( !num_samples_per_channel ) { return; } @@ -345,7 +345,7 @@ void ivas_TD_RINGBUF_PushZeros( move32(); ++h->write_pos; - if ( EQ_32( h->write_pos == h->capacity ) ) + IF ( EQ_32( h->write_pos == h->capacity ) ) { h->write_pos = 0; move32(); @@ -353,7 +353,7 @@ void ivas_TD_RINGBUF_PushZeros( } } - if ( EQ_32( h->read_pos == h->write_pos ) ) + IF ( EQ_32( h->read_pos == h->write_pos ) ) { h->is_full = 1; move16(); @@ -396,7 +396,7 @@ void ivas_TD_RINGBUF_Pop( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + FOR ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } @@ -425,13 +425,13 @@ void ivas_TD_RINGBUF_Pop( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - if ( NE_16( num_samples_per_channel, 0 ) ) + IF ( NE_16( num_samples_per_channel, 0 ) ) { h->is_full = 0; move16(); } #else - if ( h->is_full ) + IF ( h->is_full ) { h->is_full = 0; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e01a93347..76ecb0c87 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8956,9 +8956,9 @@ static ivas_error getSamplesInternal( Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { - for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; -- GitLab From cbe5b09535fea0eac37fd6e74cbb20a4817d9719 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 01:52:15 +0100 Subject: [PATCH 092/351] Remove NOTE comments --- lib_dec/ivas_jbm_dec_fx.c | 8 ++++---- lib_dec/lib_dec_fx.c | 9 +++------ lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/lib_isar_pre_rend.c | 8 ++++---- lib_rend/lib_rend_fx.c | 2 +- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index e68fe934b..56dcc3dfe 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2460,7 +2460,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -2475,7 +2475,7 @@ ivas_error ivas_jbm_dec_render_fx( ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered ); } -#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR // TODO(sgi): verify if this is needed in BASOP +#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR IF ( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; @@ -2488,13 +2488,13 @@ ivas_error ivas_jbm_dec_render_fx( } #endif } -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP ELSE { #endif nchan_out_syn_output = nchan_out; move16(); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP } #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2ba0d3e26..a4b595e55 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -783,7 +783,6 @@ static int16_t get_render_frame_size_samples( Word16 tmp; tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); - /* NOTE(sgi): BASOP special - not in float version */ IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { /* correct value already in tmp */ @@ -815,7 +814,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( Word16 *render_framesize /* o : render framesize in samples Q0 */ ) { -#ifndef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifndef FIX_1119_SPLIT_RENDERING_VOIP Word16 tmp; #endif @@ -1294,7 +1293,6 @@ static ivas_error isar_generate_metadata_and_bitstream( pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); - // NOTE(sgi): BASOP special - not in float version n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); @@ -1347,7 +1345,6 @@ static ivas_error isar_generate_metadata_and_bitstream( Quaternion.y_fx = 0; Quaternion.z_fx = 0; } - // NOTE(sgi): BASOP special - not in float version Word16 q1 = 31, q2 = 31, Q_buff; Q_out[0] = 31; @@ -1625,7 +1622,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); #endif } - else + ELSE { ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); } @@ -4606,7 +4603,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) && splitRendBits == NULL ) { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; // NOTE(sgi): BASOP special - not in float version + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } #endif diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 455eeff3f..d08d69221 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -3211,7 +3211,7 @@ void lc3plusTimeAlignCldfbPoseCorr( } ELSE { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( Word16 i = 0; i < i_mult( hSplitBin->multiBinPoseData.num_poses, BINAURAL_CHANNELS ); i++ ) #else FOR( Word16 i = 0; i < CLDFB_NO_COL_MAX; i++ ) diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 2b1220154..5a6668b2e 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -420,7 +420,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( j = 0; j < num_slots; j++ ) #else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) @@ -438,7 +438,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( j = 0; j < num_slots; j++ ) #else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) @@ -505,7 +505,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); q2 = 31; move16(); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( j = 0; j < num_slots; j++ ) #else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) @@ -518,7 +518,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); q_final = sub( q_final, 6 ); // guard bits q_final = s_min( q_final, Q25 ); -#ifdef FIX_1119_SPLIT_RENDERING_VOIP // NOTE(sgi): BASOP special - not in float version +#ifdef FIX_1119_SPLIT_RENDERING_VOIP FOR( j = 0; j < num_slots; j++ ) #else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 76ecb0c87..230652e41 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9042,7 +9042,7 @@ static ivas_error getSamplesInternal( Q_out[0] = Q_out[0] + *outAudio.pq_fact; } -#ifdef FIX_1119_SPLIT_RENDERING_VOIP /* NOTE(sgi): BASOP special - not in float version */ +#ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, -- GitLab From ff40d61c01f90c23c6afc44fcf9c75e7f1749e10 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 31 Oct 2025 07:24:50 +0100 Subject: [PATCH 093/351] Added _sat in fft3_fx within FIX_2170_ASSERT_IN_FFT3 --- lib_com/fft_fx_evs.c | 259 ++++++++++++++++++++++++---------- lib_com/options.h | 1 + lib_dec/FEC_HQ_phase_ecu_fx.c | 4 + 3 files changed, 193 insertions(+), 71 deletions(-) diff --git a/lib_com/fft_fx_evs.c b/lib_com/fft_fx_evs.c index cf27583ae..41a70b20c 100644 --- a/lib_com/fft_fx_evs.c +++ b/lib_com/fft_fx_evs.c @@ -2322,20 +2322,36 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) l = sub( shr( n, 3 ), 1 ); /* (3*m/8) - 1 = (n/8) - 1 */ FOR( i = 0; i < l; i++ ) { - acc = L_shl( *RZ0++, 15 ); /* Align with the following non-fractional mode so as to gain 1 more bit headroom. Q15 + Qx*/ - acc = L_mac0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ - acc = L_mac0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx - acc = L_mac0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - acc = L_mac0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx - *RY++ = round_fx( acc ); /* bit growth = 1 (compensated by non-fractional mode MAC). Qx - 1*/ - move16(); - +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0++, 15 ); /* Align with the following non-fractional mode so as to gain 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0++, 15 ); /* Align with the following non-fractional mode so as to gain 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_mac0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#endif + *RY++ = round_fx( acc ); /* bit growth = 1 (compensated by non-fractional mode MAC). Qx - 1*/ + move16(); + +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *IZ0--, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx +#else acc = L_shl( *IZ0--, 15 ); // Q15 + Qx acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx acc = L_mac0( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx acc = L_msu0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx acc = L_mac0( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx - *IY-- = round_fx( acc ); // Qx - 1 +#endif + *IY-- = round_fx( acc ); // Qx - 1 move16(); c1_ind = add( c1_ind, c1_step ); @@ -2348,20 +2364,36 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) l = shr( m, 3 ); /* (4*m/8) - (3*m/8) = m/8 */ FOR( i = 0; i < l; i++ ) { - acc = L_shl( *RZ0++, 15 ); // Q15 + Qx - acc = L_mac0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ - acc = L_mac0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx - acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - acc = L_mac0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx - *RY++ = round_fx( acc ); // Qx - 1 - move16(); - +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0++, 15 ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0++, 15 ); // Q15 + Qx + acc = L_mac0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_mac0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#endif + *RY++ = round_fx( acc ); // Qx - 1 + move16(); + +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *IZ0--, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx +#else acc = L_shl( *IZ0--, 15 ); // Q15 + Qx acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx acc = L_mac0( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx acc = L_msu0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx acc = L_msu0( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx - *IY-- = round_fx( acc ); // Qx - 1 +#endif + *IY-- = round_fx( acc ); // Qx - 1 move16(); c1_ind = add( c1_ind, c1_step ); @@ -2371,10 +2403,16 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) } /* special case: i = m/2 i.e. 1/3 */ - acc = L_shl( *RZ0--, 15 ); // Q15 + Qx - acc = L_mac0( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx - acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - *RY++ = round_fx( acc ); // Qx - 1 +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0--, 15 ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0--, 15 ); // Q15 + Qx + acc = L_mac0( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx + acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx +#endif + *RY++ = round_fx( acc ); // Qx - 1 move16(); acc = 0; @@ -2396,20 +2434,35 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) l = sub( shr( m, 2 ), 1 ); /* (6*m/8) - ((m/2)+1) = m/4 - 1 */ FOR( i = 0; i < l; i++ ) { - acc = L_shl( *RZ0--, 15 ); // Q15 + Qx - acc = L_mac0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ - acc = L_msu0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx - acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - acc = L_msu0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx - *RY++ = round_fx( acc ); // Qx - 1 - move16(); - - acc = L_mult0( *IZ0++, -32768 ); // Q15 + Qx +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0--, 15 ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_msu0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0--, 15 ); // Q15 + Qx + acc = L_mac0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_msu0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_msu0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#endif + *RY++ = round_fx( acc ); // Qx - 1 + move16(); + + acc = L_mult0( *IZ0++, -32768 ); // Q15 + Qx +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_msu0_sat( acc, *RZ1--, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *IZ1++, t_sin[c1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2--, t_sin[s2_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ2++, t_sin[c2_ind] ); // Q15 + Qx +#else acc = L_msu0( acc, *RZ1--, t_sin[s1_ind] ); // Q15 + Qx acc = L_msu0( acc, *IZ1++, t_sin[c1_ind] ); // Q15 + Qx acc = L_msu0( acc, *RZ2--, t_sin[s2_ind] ); // Q15 + Qx acc = L_mac0( acc, *IZ2++, t_sin[c2_ind] ); // Q15 + Qx - *IY-- = round_fx( acc ); // Qx - 1 +#endif + *IY-- = round_fx( acc ); // Qx - 1 move16(); c1_ind = add( c1_ind, c1_step ); @@ -2423,20 +2476,35 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) l = shr( m, 2 ); FOR( i = 0; i < l; i++ ) { - acc = L_shl( *RZ0--, 15 ); // Q15 + Qx - acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ - acc = L_msu0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx - acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - acc = L_mac0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx - *RY++ = round_fx( acc ); // Qx - 1 - move16(); - - acc = L_mult0( *IZ0++, -32768 ); // Q15 + Qx +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0--, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_msu0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0--, 15 ); // Q15 + Qx + acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_msu0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_mac0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#endif + *RY++ = round_fx( acc ); // Qx - 1 + move16(); + + acc = L_mult0( *IZ0++, -32768 ); // Q15 + Qx +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_msu0_sat( acc, *RZ1--, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ1++, t_sin[c1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ2--, t_sin[s2_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ2++, t_sin[c2_ind] ); // Q15 + Qx +#else acc = L_msu0( acc, *RZ1--, t_sin[s1_ind] ); // Q15 + Qx acc = L_mac0( acc, *IZ1++, t_sin[c1_ind] ); // Q15 + Qx acc = L_mac0( acc, *RZ2--, t_sin[s2_ind] ); // Q15 + Qx acc = L_mac0( acc, *IZ2++, t_sin[c2_ind] ); // Q15 + Qx - *IY-- = round_fx( acc ); // Qx - 1 +#endif + *IY-- = round_fx( acc ); // Qx - 1 move16(); c1_ind = sub( c1_ind, c1_step ); @@ -2446,16 +2514,27 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) } /* special case: i = m, i.e 2/3 */ - acc = L_shl( *RZ0++, 15 ); // Q15 + Qx - acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx - acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - *RY++ = round_fx( acc ); // Qx - 1 +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0++, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0++, 15 ); // Q15 + Qx + acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx + acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx +#endif + *RY++ = round_fx( acc ); // Qx - 1 move16(); acc = L_deposit_l( 0 ); - acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx - acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx - *IY-- = round_fx( acc ); // Qx - 1 +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx +#else + acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx +#endif + *IY-- = round_fx( acc ); // Qx - 1 move16(); IZ0--; /* Just decrement the address counter */ IZ1--; @@ -2470,20 +2549,36 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) l = sub( shr( m, 3 ), 1 ); /* (9*m/8) - (m +1) = m/8 - 1 */ FOR( i = 0; i < l; i++ ) { - acc = L_shl( *RZ0++, 15 ); // Q15 + Qx - acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ - acc = L_mac0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx - acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - acc = L_msu0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx - *RY++ = round_fx( acc ); // Qx - 1 - move16(); - +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0++, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0++, 15 ); // Q15 + Qx + acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_msu0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#endif + *RY++ = round_fx( acc ); // Qx - 1 + move16(); + +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *IZ0--, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx +#else acc = L_shl( *IZ0--, 15 ); // Q15 + Qx acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx acc = L_msu0( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx acc = L_msu0( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx - *IY-- = round_fx( acc ); // Qx - 1 +#endif + *IY-- = round_fx( acc ); // Qx - 1 move16(); c1_ind = sub( c1_ind, c1_step ); @@ -2496,20 +2591,36 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) l = shr( n, 3 ); /* (12*m/8) - (9*m/8) = 3*m/8 = n/8 */ FOR( i = 0; i < l; i++ ) { - acc = L_shl( *RZ0++, 15 ); // Q15 + Qx - acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ - acc = L_mac0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx - acc = L_mac0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - acc = L_msu0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx - *RY++ = round_fx( acc ); // Qx - 1 - move16(); - +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0++, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0_sat( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0++, 15 ); // Q15 + Qx + acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); /* Non-fractional mode gains 1 more bit headroom. Q15 + Qx*/ + acc = L_mac0( acc, *IZ1, t_sin[s1_ind] ); // Q15 + Qx + acc = L_mac0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx + acc = L_msu0( acc, *IZ2, t_sin[s2_ind] ); // Q15 + Qx +#endif + *RY++ = round_fx( acc ); // Qx - 1 + move16(); + +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *IZ0--, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx + acc = L_msu0_sat( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx +#else acc = L_shl( *IZ0--, 15 ); // Q15 + Qx acc = L_msu0( acc, *RZ1++, t_sin[s1_ind] ); // Q15 + Qx acc = L_msu0( acc, *IZ1--, t_sin[c1_ind] ); // Q15 + Qx acc = L_mac0( acc, *RZ2++, t_sin[s2_ind] ); // Q15 + Qx acc = L_mac0( acc, *IZ2--, t_sin[c2_ind] ); // Q15 + Qx - *IY-- = round_fx( acc ); // Qx - 1 +#endif + *IY-- = round_fx( acc ); // Qx - 1 move16(); c1_ind = sub( c1_ind, c1_step ); @@ -2519,10 +2630,16 @@ void fft3_fx( const Word16 X[] /*Qx*/, Word16 Y[] /*Qx*/, const Word16 n ) } /* special case: i = 3*m/2 */ - acc = L_shl( *RZ0, 15 ); // Q15 + Qx - acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx - acc = L_mac0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx - *RY = round_fx( acc ); // Qx - 1 +#ifdef FIX_2170_ASSERT_IN_FFT3 + acc = L_shl_sat( *RZ0, 15 ); // Q15 + Qx + acc = L_msu0_sat( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx + acc = L_mac0_sat( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx +#else + acc = L_shl( *RZ0, 15 ); // Q15 + Qx + acc = L_msu0( acc, *RZ1, t_sin[c1_ind] ); // Q15 + Qx + acc = L_mac0( acc, *RZ2, t_sin[c2_ind] ); // Q15 + Qx +#endif + *RY = round_fx( acc ); // Qx - 1 move16(); return; diff --git a/lib_com/options.h b/lib_com/options.h index 676b3d674..7bad5527e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,7 @@ #define FIX_2166_ASSERT_OSBA_PLC_STEREO_OUT /* FhG: fix for issue 2166 - add missing averaging factor 0.5 in for the sum of energies in function stereo_dft_dmx_swb_nrg_fx()*/ #define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */ +#define FIX_2170_ASSERT_IN_FFT3 /* Eri: Assert in fft3_fx from EVS, adding _sat */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index dd44f50b9..4ad39acf0 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -2142,7 +2142,11 @@ static void ivas_subst_spec_fx( im = *pImX; move16(); tmp = sub_sat( mult_r( re, cos_F ), mult_r( im, sin_F ) ); +#ifdef FIX_2170_ASSERT_IN_FFT3 + im = add_sat( mult_r( re, sin_F ), mult_r( im, cos_F ) ); +#else im = add( mult_r( re, sin_F ), mult_r( im, cos_F ) ); +#endif IF( LT_16( alpha[k], 32766 ) ) { alpha_local = mag_chg_local; -- GitLab From 278986f14089996c0f7d5bbef37083f7320e3686 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 31 Oct 2025 09:29:08 +0100 Subject: [PATCH 094/351] Enable hp20_fx_32_opt() for Encoder --- lib_com/options.h | 2 +- lib_enc/ivas_enc_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 676b3d674..60b12c414 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,7 @@ #define FIX_BASOP_ASSERT_IN_TONAL_MDCT_PLC /* FhG: fix for issue 2165 - using saturating addition in tonal MDCT PLC function */ #define OPT_2146_BASOP_UTIL_ADD_MANT32EXP /* Dlb: optimized version of BASOP_Util_Add_Mant32Exp() */ #define FIX_2166_ASSERT_OSBA_PLC_STEREO_OUT /* FhG: fix for issue 2166 - add missing averaging factor 0.5 in for the sum of energies in function stereo_dft_dmx_swb_nrg_fx()*/ - +#define FIX_2086_ENABLE_HP20_OPT_FOR_ENC /* FhG: Enable hp20_fx_32_opt() for Encoder */ #define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */ /* ################### End FIXES switches ########################### */ diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index 095d4c2cf..4d8f99650 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -158,11 +158,19 @@ ivas_error ivas_enc_fx( test(); IF( ( EQ_32( ivas_format, SBA_FORMAT ) ) && !( GT_16( st_ivas->sba_analysis_order, 1 ) ) ) { +#ifdef FIX_2086_ENABLE_HP20_OPT_FOR_ENC + hp20_fx_32_opt( data_fx[HOA_keep_ind[st_ivas->hSpar->hMdEnc->HOA_md_ind[i]]], input_frame, st_ivas->mem_hp20_in_fx[i], input_Fs ); +#else hp20_fx_32( data_fx[HOA_keep_ind[st_ivas->hSpar->hMdEnc->HOA_md_ind[i]]], input_frame, st_ivas->mem_hp20_in_fx[i], input_Fs ); +#endif } ELSE IF( !( EQ_32( ivas_format, MC_FORMAT ) && EQ_16( i, LFE_CHANNEL ) ) ) { +#ifdef FIX_2086_ENABLE_HP20_OPT_FOR_ENC + hp20_fx_32_opt( data_fx[i], input_frame, st_ivas->mem_hp20_in_fx[i], input_Fs ); +#else hp20_fx_32( data_fx[i], input_frame, st_ivas->mem_hp20_in_fx[i], input_Fs ); +#endif } } -- GitLab From 0c098005471aa60fdd68005648ac3efcce30c083 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 31 Oct 2025 09:33:06 +0100 Subject: [PATCH 095/351] fix if condition --- lib_enc/ivas_cpe_enc_fx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index faad00109..28c2992ff 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -991,7 +991,7 @@ ivas_error ivas_cpe_enc_fx( #ifdef FIX_1411_IGF_CRASH_BW_SWITCHING test(); test(); - IF( NE_16( ( EQ_32( sts[0]->core_brate, SID_2k40 ) || EQ_32( sts[0]->core_brate, FRAME_NO_DATA ) ), 0 ) ) /* Reconfigurations not needed with DTX*/ + IF( NE_32( sts[0]->core_brate, SID_2k40 ) && NE_32( sts[0]->core_brate, FRAME_NO_DATA ) ) /* Reconfigurations not needed with DTX*/ { #endif test(); @@ -1012,6 +1012,7 @@ ivas_error ivas_cpe_enc_fx( test(); test(); hCPE->hStereoMdct->isSBAStereoMode = ( ( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) && ( EQ_16( st_ivas->nchan_transport, 2 ) ) ); /* Q0 */ + move16(); test(); IF( LE_32( hCPE->element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) ) @@ -1053,6 +1054,7 @@ ivas_error ivas_cpe_enc_fx( move16(); } igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->rf_mode ); /* Q0 */ + move16(); #ifdef FIX_1413_IGF_INIT_PRINTOUT IF( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) #else -- GitLab From 3658bd6d60e368618a49a06cc65e45090882ded8 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 09:37:11 +0100 Subject: [PATCH 096/351] Fix build with switch FIX_1119_SPLIT_RENDERING_VOIP disabled --- lib_rend/ivas_td_ring_buffer_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 215500d37..3f56b0b9e 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -345,7 +345,7 @@ void ivas_TD_RINGBUF_PushZeros( move32(); ++h->write_pos; - IF ( EQ_32( h->write_pos == h->capacity ) ) + IF ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -353,7 +353,7 @@ void ivas_TD_RINGBUF_PushZeros( } } - IF ( EQ_32( h->read_pos == h->write_pos ) ) + IF ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -411,7 +411,7 @@ void ivas_TD_RINGBUF_Pop( p_channels[c][s] = h->data[h->read_pos]; move32(); #else - data[L_add( L_mult0( c, num_samples_per_channel ), s )) = h->data[h->read_pos]; + data[L_add( L_mult0( c, num_samples_per_channel ), s ) ] = h->data[h->read_pos]; move32(); #endif ++h->read_pos; -- GitLab From 42b0cc5acaacef8875487590a56967d3c210cb15 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 09:48:25 +0100 Subject: [PATCH 097/351] Fix formatting --- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- lib_dec/lib_dec_fx.c | 34 +++++++++++++++---------------- lib_isar/isar_splitRendererPre.c | 4 ++-- lib_rend/ivas_cldfb_ring_buffer.c | 6 +++--- lib_rend/ivas_td_ring_buffer_fx.c | 28 ++++++++++++------------- lib_rend/lib_rend_fx.c | 4 ++-- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 56dcc3dfe..162be9100 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2466,7 +2466,7 @@ ivas_error ivas_jbm_dec_render_fx( nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; /* Save TD signals for pose correction if they are to be used */ - IF ( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) + IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) { FOR( i = 0; i < nchan_out_syn_output; i++ ) { @@ -2476,7 +2476,7 @@ ivas_error ivas_jbm_dec_render_fx( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - IF ( st_ivas->flushing ) + IF( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a4b595e55..12abb15ec 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1184,9 +1184,9 @@ static Word16 isar_get_frame_size( test(); test(); - IF ( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && - ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + IF( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && + ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); @@ -1222,7 +1222,7 @@ static ivas_error isar_render_poses( ivas_error error; Word16 numPoses; - IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1234,7 +1234,7 @@ static ivas_error isar_render_poses( numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; /* init flush buffer for rate switch if not already initizalized */ - IF ( hIvasDec->flushbuffer == NULL ) + IF( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1572,14 +1572,14 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Word16 Q_out[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; test(); - IF ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } st_ivas = hIvasDec->st_ivas; - IF ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { return IVAS_ERR_WRONG_PARAMS; } @@ -1589,34 +1589,34 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); move16(); - IF ( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } - IF ( !hIvasDec->hasBeenFedFirstGoodFrame ) + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) { return IVAS_ERR_OK; } - FOR ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { p_head_pose_buf[i] = head_pose_buf[i]; } - IF ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) + IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) { return error; } /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ - IF ( pcm_out_flag ) + IF( pcm_out_flag ) { FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } - IF ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); @@ -6116,10 +6116,10 @@ static Word16 ivas_dec_split_rend_cldfb_in( test(); test(); test(); - IF ( renderer_type == RENDERER_BINAURAL_FASTCONV || - renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - renderer_type == RENDERER_BINAURAL_PARAMETRIC || - renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF( renderer_type == RENDERER_BINAURAL_FASTCONV || + renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + renderer_type == RENDERER_BINAURAL_PARAMETRIC || + renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { return 1; } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index d08d69221..fe4965993 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2929,9 +2929,9 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( useLc3plus = hSplitBin->hLc3plusEnc != NULL; #ifdef FIX_1119_SPLIT_RENDERING_VOIP - FOR ( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) { - FOR ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_In_BinReal[i][j] = Cldfb_In_BinReal_fx[i][j]; p_Cldfb_In_BinImag[i][j] = Cldfb_In_BinImag_fx[i][j]; diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 87929a0b5..49d88e8f3 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -181,13 +181,13 @@ void ivas_CLDFB_RINGBUF_Push( h->write_pos = add( h->write_pos, CLDFB_NO_CHANNELS_MAX ); move16(); - IF ( EQ_16( h->write_pos, h->capacity ) ) + IF( EQ_16( h->write_pos, h->capacity ) ) { h->write_pos = 0; move16(); } - IF ( EQ_16( h->read_pos, h->write_pos ) ) + IF( EQ_16( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -289,7 +289,7 @@ void ivas_CLDFB_RINGBUF_GetByIdx( { offset = add( h->read_pos, idx ); move16(); - IF ( LE_16( h->capacity, offset ) ) + IF( LE_16( h->capacity, offset ) ) { offset = sub( offset, h->capacity ); move16(); diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 3f56b0b9e..4036e6011 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - IF ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -101,7 +101,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); ++h->write_pos; - IF ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; } @@ -109,7 +109,7 @@ static void ivas_td_ringbuf_push_interleaved( move32(); } - IF ( EQ_32( h->read_pos, h->write_pos ) ) + IF( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -163,7 +163,7 @@ ivas_error ivas_TD_RINGBUF_Open( *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - IF ( h->data == NULL ) + IF( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -261,7 +261,7 @@ void ivas_TD_RINGBUF_Push( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - FOR ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + FOR( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } @@ -281,7 +281,7 @@ void ivas_TD_RINGBUF_Push( #endif ++h->write_pos; - IF ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -289,7 +289,7 @@ void ivas_TD_RINGBUF_Push( } } - IF ( EQ_32( h->read_pos, h->write_pos ) ) + IF( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -332,7 +332,7 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - IF ( !num_samples_per_channel ) + IF( !num_samples_per_channel ) { return; } @@ -345,7 +345,7 @@ void ivas_TD_RINGBUF_PushZeros( move32(); ++h->write_pos; - IF ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -353,7 +353,7 @@ void ivas_TD_RINGBUF_PushZeros( } } - IF ( EQ_32( h->read_pos, h->write_pos ) ) + IF( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -396,7 +396,7 @@ void ivas_TD_RINGBUF_Pop( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - FOR ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + FOR( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } @@ -411,7 +411,7 @@ void ivas_TD_RINGBUF_Pop( p_channels[c][s] = h->data[h->read_pos]; move32(); #else - data[L_add( L_mult0( c, num_samples_per_channel ), s ) ] = h->data[h->read_pos]; + data[L_add( L_mult0( c, num_samples_per_channel ), s )] = h->data[h->read_pos]; move32(); #endif ++h->read_pos; @@ -425,13 +425,13 @@ void ivas_TD_RINGBUF_Pop( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF ( NE_16( num_samples_per_channel, 0 ) ) + IF( NE_16( num_samples_per_channel, 0 ) ) { h->is_full = 0; move16(); } #else - IF ( h->is_full ) + IF( h->is_full ) { h->is_full = 0; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 230652e41..f32dee8b8 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8956,9 +8956,9 @@ static ivas_error getSamplesInternal( Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; - FOR ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { - FOR ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; -- GitLab From faa2953f82a06cdef0402c05890e56ce55197999 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 31 Oct 2025 09:51:13 +0100 Subject: [PATCH 098/351] align with parallel port for later MR --- lib_rend/ivas_prot_rend_fx.h | 16 ++-- lib_rend/ivas_td_ring_buffer_fx.c | 140 ++++++++++++------------------ 2 files changed, 63 insertions(+), 93 deletions(-) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 783798f0d..84dcc6072 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -33,7 +33,6 @@ #ifndef IVAS_PROT_REND_H #define IVAS_PROT_REND_H -#include "typedef.h" #include #include "options.h" #include "ivas_error.h" @@ -1601,8 +1600,8 @@ void ivas_rend_closeCldfbRend( ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ - const UWord16 capacity_per_channel, /* i : Number of samples stored per channel */ - const UWord16 num_channels /* i : Number of channels */ + const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ + const Word16 num_channels /* i : Number of channels */ ); void ivas_TD_RINGBUF_Close( @@ -1612,24 +1611,23 @@ void ivas_TD_RINGBUF_Close( void ivas_TD_RINGBUF_Push( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const Word32 *data, /* i : Input data */ - const UWord16 num_samples_per_channel /* i : Number of samples per channel to store */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ ); void ivas_TD_RINGBUF_PushZeros( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const UWord16 num_samples_per_channel /* i : Number of zeros per channel to store */ + const Word16 num_samples_per_channel /* i : Number of zeros per channel to store */ ); void ivas_TD_RINGBUF_Pop( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ Word32 *data, /* i : Output data */ - const UWord16 num_samples_per_channel /* i : Number of samples per channel to retrieve*/ + const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve*/ ); +#endif -uint16_t ivas_TD_RINGBUF_Size( +Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ); /* clang-format on */ - -#endif /* IVAS_PROT_REND_H */ diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index c90b7e15f..2492d30b4 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -30,14 +30,13 @@ *******************************************************************************************************/ -#include "basop32.h" -#include "move.h" -#include "typedef.h" #include #include #include "ivas_error_utils.h" #include "ivas_prot_rend_fx.h" +#include "options.h" #include "wmc_auto.h" +#include "prot_fx.h" /*-----------------------------------------------------------------------* @@ -50,7 +49,7 @@ * Returns total number of buffered samples (including number of channels) *---------------------------------------------------------------------*/ -static UWord32 ivas_td_ringbuf_total_size( +static Word32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { IF( h->is_full ) @@ -58,7 +57,7 @@ static UWord32 ivas_td_ringbuf_total_size( return h->capacity; } - IF( h->read_pos <= h->write_pos ) + IF( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -69,21 +68,13 @@ static UWord32 ivas_td_ringbuf_total_size( static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, - const UWord32 num_samples ) + const Word32 num_samples ) { - // float was : return (Word16) ( ivas_td_ringbuf_total_size( h ) + num_samples <= h->capacity ); - Word16 has_space; - UWord32 total_size_after; - - move16(); - has_space = 0; - - total_size_after = L_add( ivas_td_ringbuf_total_size( h ), num_samples ); - IF( LE_32( total_size_after, h->capacity ) ) + if ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { - has_space = 1; + return 1; } - return has_space; + return 0; } @@ -100,45 +91,42 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( *---------------------------------------------------------------------*/ ivas_error ivas_TD_RINGBUF_Open( - TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ - const UWord16 capacity_per_channel, /* i : Number of samples stored per channel */ - const UWord16 num_channels /* i : Number of channels */ + TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ + const Word16 capacity_per_channel, /* i : Number of samples stored per channel */ + const Word16 num_channels /* i : Number of channels */ ) { TD_RINGBUF_HANDLE h; - UWord32 capacity; + Word32 capacity; - capacity = L_mult0( capacity_per_channel, num_channels ); // Q0 x Q0 -> Q0 + capacity = L_mult0( capacity_per_channel, num_channels ); + move32(); h = malloc( sizeof( TD_RINGBUF_DATA ) ); IF( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } - - move32(); h->data = NULL; - move32(); h->capacity = 0; - move16(); - h->num_channels = num_channels; move32(); + h->num_channels = num_channels; + move16(); h->write_pos = 0; move32(); h->read_pos = 0; - move16(); - h->is_full = 0; move32(); + h->is_full = 0; + move16(); *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - IF( h->data == NULL ) + if ( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } - - move32(); h->capacity = capacity; + move32(); return IVAS_ERR_OK; } @@ -161,8 +149,6 @@ void ivas_TD_RINGBUF_Close( { return; } - - move32(); h = *ph; IF( h == NULL ) @@ -177,7 +163,6 @@ void ivas_TD_RINGBUF_Close( free( h ); *ph = NULL; - move32(); return; } @@ -191,41 +176,36 @@ void ivas_TD_RINGBUF_Close( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_Push( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const Word32 *data, /* i : Input data */ - const UWord16 num_samples_per_channel /* i : Number of samples per channel to store */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word32 *data, /* i : Input data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to store */ ) { - UWord16 c, s; + Word32 s; + Word16 c; - assert( ivas_td_ringbuf_has_space_for_num_samples( h, L_mult0( num_samples_per_channel, h->num_channels ) ) ); + assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); FOR( s = 0; s < num_samples_per_channel; ++s ) { FOR( c = 0; c < h->num_channels; ++c ) { - UWord32 shift_val; - - /* pointer is advance by c * num_samples_per_channel + s */ - shift_val = L_mult0( c, num_samples_per_channel ); - shift_val = L_add( s, shift_val ); - + h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; move32(); - h->data[h->write_pos] = *( data + shift_val ); ++h->write_pos; - IF( EQ_32( h->write_pos, h->capacity ) ) + if ( EQ_32( h->write_pos, h->capacity ) ) { - move32(); h->write_pos = 0; + move32(); } } } - IF( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { - move32(); h->is_full = 1; + move16(); } return; @@ -239,14 +219,15 @@ void ivas_TD_RINGBUF_Push( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_PushZeros( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - const UWord16 num_samples_per_channel /* i : Number of zeros per channel to store */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + const Word16 num_samples_per_channel /* i : Number of zeros per channel to store */ ) { - UWord16 c, s; + Word32 s; + Word16 c; - assert( ivas_td_ringbuf_has_space_for_num_samples( h, L_mult0( num_samples_per_channel, h->num_channels ) ) ); - IF( EQ_16( num_samples_per_channel, 0 ) ) + assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); + if ( !num_samples_per_channel ) { return; } @@ -255,22 +236,22 @@ void ivas_TD_RINGBUF_PushZeros( { FOR( c = 0; c < h->num_channels; ++c ) { + h->data[h->write_pos] = 0.f; move32(); - h->data[h->write_pos] = 0; ++h->write_pos; - IF( EQ_32( h->write_pos, h->capacity ) ) + if ( EQ_32( h->write_pos, h->capacity ) ) { - move32(); h->write_pos = 0; + move32(); } } } - IF( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { - move32(); h->is_full = 1; + move16(); } return; @@ -284,42 +265,36 @@ void ivas_TD_RINGBUF_PushZeros( *---------------------------------------------------------------------*/ void ivas_TD_RINGBUF_Pop( - TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ - Word32 *data, /* i : Output data */ - const UWord16 num_samples_per_channel /* i : Number of samples per channel to retrieve */ + TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ + Word32 *data, /* i : Output data */ + const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve */ ) { - UWord16 c, s; - Word32 requested_samples; + Word32 s; + Word16 c; - requested_samples = L_mult0( num_samples_per_channel, h->num_channels ); - assert( GE_32( ivas_td_ringbuf_total_size( h ), requested_samples ) ); + assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); FOR( s = 0; s < num_samples_per_channel; ++s ) { FOR( c = 0; c < h->num_channels; ++c ) { - UWord32 shift_val; - - /* pointer is advanced by c * num_samples_per_channel + s */ - shift_val = L_mult0( c, num_samples_per_channel ); - shift_val = L_add( s, shift_val ); - - *( data + shift_val ) = h->data[h->read_pos]; + data[L_add( L_mult0( c, num_samples_per_channel ), s )] = h->data[h->read_pos]; + move32(); ++h->read_pos; - IF( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->read_pos, h->capacity ) ) { + h->read_pos = 0; move32(); - h->write_pos = 0; } } } - IF( NE_16( h->is_full, 0 ) ) + if ( h->is_full ) { - move16(); h->is_full = 0; + move16(); } return; @@ -332,12 +307,9 @@ void ivas_TD_RINGBUF_Pop( * Returns number of buffered samples per channel. *---------------------------------------------------------------------*/ -UWord16 ivas_TD_RINGBUF_Size( +Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { - UWord16 size; - - size = div_l( ivas_td_ringbuf_total_size( h ), h->num_channels ); - return size; + return extract_l( ar_div( ivas_td_ringbuf_total_size( h ), L_deposit_l( h->num_channels ) ) ); } -- GitLab From 9ba3dbdb1f9f1c92729c609b1f49365a0f42c427 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 31 Oct 2025 10:40:02 +0100 Subject: [PATCH 099/351] add missing moves --- lib_rend/ivas_td_ring_buffer_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 2492d30b4..cfb3f3e8d 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -108,6 +108,7 @@ ivas_error ivas_TD_RINGBUF_Open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } h->data = NULL; + move32(); h->capacity = 0; move32(); h->num_channels = num_channels; @@ -119,6 +120,7 @@ ivas_error ivas_TD_RINGBUF_Open( h->is_full = 0; move16(); *ph = h; + move32(); h->data = malloc( capacity * sizeof( Word32 ) ); if ( h->data == NULL ) @@ -150,6 +152,7 @@ void ivas_TD_RINGBUF_Close( return; } h = *ph; + move32(); IF( h == NULL ) { @@ -163,6 +166,7 @@ void ivas_TD_RINGBUF_Close( free( h ); *ph = NULL; + move32(); return; } -- GitLab From 600419c345ca4647d19a4c456f6dcc6f800475c4 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 31 Oct 2025 12:10:15 +0100 Subject: [PATCH 100/351] [ci] revert override of BASOP_CI_BRANCH_PC_REPO --- .gitlab-ci/variables.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index d8db25d33..31d69a643 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -1,5 +1,4 @@ variables: - BASOP_CI_BRANCH_PC_REPO: "update-basop-ci-branch-lc3plus-v161" TESTV_DIR: "/usr/local/testv" LTV_DIR: "/usr/local/ltv" EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" -- GitLab From 625952bcef418e38b194975f8b416c5d8adb3f3b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 31 Oct 2025 12:47:09 +0100 Subject: [PATCH 101/351] remove deleted files from MSVC solution --- Workspace_msvc/lib_lc3plus.vcxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 64a966e29..ad5139c35 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -188,8 +188,6 @@ - - -- GitLab From 7fa270c5e2c339b0ea94bd82e88474aefcbc252a Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 31 Oct 2025 12:47:30 +0100 Subject: [PATCH 102/351] [ci] revert changes in variables.yml --- .gitlab-ci/variables.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 31d69a643..817be6f79 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -81,6 +81,8 @@ variables: RUNNER_TAG: "ivas-basop-linux" LOGS_BACKUP_SOURCE_DIR: "" LOGS_BACKUP_TARGET_DIR: "" + # set this to true to skip the external HRTF testcases in pytest calls + DISABLE_HRTF: "false" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -102,3 +104,4 @@ variables: - 'peaq-enc-passthrough' - 'long-term-logs' - 'backup-long-term-logs' + - 'test-long-self-test' -- GitLab From b977e505cac80a67645ab5cd1a56d649d6ea9fda Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 31 Oct 2025 13:07:29 +0100 Subject: [PATCH 103/351] use saturating add to fix crash -equivalent spot in encoder code uses that too -also remove two excessive tests()'s --- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/lib_rend_fx.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index dbaf5b7d9..ab41810b8 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -1051,7 +1051,7 @@ void ivas_mcmasa_param_est_ana_fx( cohPanCoh_e = tempCoh2_e; move16(); } - cohPanCoh_fx = L_shl( cohPanCoh_fx, cohPanCoh_e ); /*Q31*/ + cohPanCoh_fx = L_shl_sat( cohPanCoh_fx, cohPanCoh_e ); /*Q31*/ cohPanCoh_e = 0; move16(); lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( lsEnergy_fx[i2], L_add( lsEnergy_fx[i1], EPSILON_FX ), &lsEnergyRelation_e ); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 6853acb27..64082179f 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1531,8 +1531,6 @@ static Word32 getRendInputDelayMasa( latency_ns = 0; move32(); - test(); - test(); test(); test(); IF( ( EQ_32( inputMasa->base.inConfig, IVAS_AUDIO_CONFIG_MASA1 ) && -- GitLab From 66e50578f1a78564b3b4f70830fa1b3726b66388 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 31 Oct 2025 13:21:28 +0100 Subject: [PATCH 104/351] Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation --- lib_com/options.h | 2 +- lib_dec/ivas_stereo_dft_dec_fx.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0f0fb78dc..2eb595739 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,7 @@ #define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */ #define FIX_2082_FP_LEFTOVERS_OMASA_DEC /* Nokia: fix for issue 2082, cleaning remaining floating point code */ - +#define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index aa8d428c7..186306209 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -220,7 +220,11 @@ void stereo_dft_dec_reset_fx( { set32_fx( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); } +#ifdef FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO + hStereoDft->q_smooth_buf_fx = Q6; +#else hStereoDft->q_smooth_buf_fx = Q7; +#endif move16(); set16_fx( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); set16_fx( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); -- GitLab From 6ced9a2ab94083a8808cf459f2282f72b03e7699 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 31 Oct 2025 13:43:56 +0100 Subject: [PATCH 105/351] fix data type of constant --- lib_rend/ivas_td_ring_buffer_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index cfb3f3e8d..e640f9501 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -240,7 +240,7 @@ void ivas_TD_RINGBUF_PushZeros( { FOR( c = 0; c < h->num_channels; ++c ) { - h->data[h->write_pos] = 0.f; + h->data[h->write_pos] = 0; move32(); ++h->write_pos; -- GitLab From 4eea9cefa605d8d6d6ad26c58ef026ece83c982c Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 13:49:24 +0100 Subject: [PATCH 106/351] Apply review suggestions - batch 1 --- lib_dec/ivas_jbm_dec_fx.c | 5 +++-- lib_dec/ivas_omasa_dec_fx.c | 2 +- lib_dec/ivas_osba_dec_fx.c | 2 +- lib_dec/ivas_output_config_fx.c | 5 +++++ lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.h | 16 +++++++------- lib_dec/lib_dec_fx.c | 35 +++++++++++++++++++++++-------- lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/lib_isar_pre_rend.c | 2 +- lib_rend/ivas_td_ring_buffer_fx.c | 17 ++++++++------- 10 files changed, 56 insertions(+), 32 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 162be9100..0e25388f2 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2463,7 +2463,7 @@ ivas_error ivas_jbm_dec_render_fx( #ifdef FIX_1119_SPLIT_RENDERING_VOIP const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; - nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); /* Save TD signals for pose correction if they are to be used */ IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) @@ -2476,9 +2476,10 @@ ivas_error ivas_jbm_dec_render_fx( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - IF( st_ivas->flushing ) + if( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; + move16(); } #endif #else diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index af2b33158..1f3eb6314 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1250,7 +1250,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); #ifdef FIX_1119_SPLIT_RENDERING_VOIP - ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots ); + ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, sub( slot_idx, cldfb_slots ) ); v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); #else diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 5f174034c..c4e0fc8a7 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -207,7 +207,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); #ifdef FIX_1119_SPLIT_RENDERING_VOIP - ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots ); + ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, sub( slot_idx, cldfb_slots ) ); v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); #else diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index c71431e5c..1958cea41 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -626,7 +626,12 @@ RENDERER_TYPE ivas_renderer_secondary_select_fx( test(); test(); + test(); + test(); + test(); #ifdef FIX_1119_SPLIT_RENDERING_VOIP + test(); + test(); test(); test(); IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 53d73c7c9..16354439e 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1209,7 +1209,7 @@ typedef struct Decoder_Struct Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - int16_t flushing; + Word16 flushing; #endif } Decoder_Struct; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 945e0526f..e911a5fca 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -310,18 +310,18 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef FIX_1119_SPLIT_RENDERING_VOIP /*! r: error code */ ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ - Word16 *pcmBuf, /* o : output synthesis signal */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + /* const IVAS_DEC_PCM_TYPE pcmType, */ /* i : type for the decoded PCM resolution */ + Word16 *pcmBuf, /* o : output synthesis signal */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriterFn jbmWriterFn, void* jbmWriter, #endif - bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ - UWord16 *nSamplesRendered, /* o : number of samples rendered */ - bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ - const UWord32 systemTimestamp_ms /* i : current system timestamp */ + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ + const UWord32 systemTimestamp_ms /* i : current system timestamp */ ); #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 12abb15ec..8184452e7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -776,7 +776,7 @@ ivas_error IVAS_DEC_GetRenderFramesize( * *---------------------------------------------------------------------*/ -static int16_t get_render_frame_size_samples( +static Word16 get_render_frame_size_samples( const DECODER_CONFIG_HANDLE hDecoderConfig /* i : configuration structure */ ) { @@ -1184,9 +1184,9 @@ static Word16 isar_get_frame_size( test(); test(); - IF( st_ivas->hDecoderConfig->render_framesize != IVAS_RENDER_FRAMESIZE_20MS && - ( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + IF( NE_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) && + ( EQ_32( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) || + EQ_32( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) { nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); @@ -1222,16 +1222,19 @@ static ivas_error isar_render_poses( ivas_error error; Word16 numPoses; + test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } *needNewFrame = false; + move16(); st_ivas = hIvasDec->st_ivas; numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); /* init flush buffer for rate switch if not already initizalized */ IF( hIvasDec->flushbuffer == NULL ) @@ -1298,6 +1301,7 @@ static ivas_error isar_generate_metadata_and_bitstream( num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); IF( cldfb_in_flag ) { @@ -1341,12 +1345,19 @@ static ivas_error isar_generate_metadata_and_bitstream( ELSE { Quaternion.w_fx = -12582912; + move32(); Quaternion.x_fx = 0; + move32(); Quaternion.y_fx = 0; + move32(); Quaternion.z_fx = 0; + move32(); } Word16 q1 = 31, q2 = 31, Q_buff; + move32(); + move32(); Q_out[0] = 31; + move32(); IF( EQ_16( cldfb_in_flag, 1 ) ) { @@ -1375,6 +1386,7 @@ static ivas_error isar_generate_metadata_and_bitstream( /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ /* local float2fix, to be removed */ num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { @@ -1387,7 +1399,9 @@ static ivas_error isar_generate_metadata_and_bitstream( } Q_out[0] = add( Q_out[0], Q11 ); Q_out[1] = Q_out[0]; + move16(); Q_buff = Q31 + Q6; // likely unneeded + move16(); } IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, @@ -5029,6 +5043,7 @@ ivas_error IVAS_DEC_Flush( #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR hIvasDec->st_ivas->flushing = 1; + move16(); #endif *nSamplesFlushed = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); @@ -5053,6 +5068,7 @@ ivas_error IVAS_DEC_Flush( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR hIvasDec->st_ivas->flushing = 0; + move16(); #endif @@ -6116,10 +6132,10 @@ static Word16 ivas_dec_split_rend_cldfb_in( test(); test(); test(); - IF( renderer_type == RENDERER_BINAURAL_FASTCONV || - renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - renderer_type == RENDERER_BINAURAL_PARAMETRIC || - renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || + EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || + EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || + EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { return 1; } @@ -6178,6 +6194,7 @@ static ivas_error ivas_dec_init_split_rend( ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); assert( num_poses <= MAX_HEAD_ROT_POSES ); IF( cldfb_in_flag ) @@ -6193,7 +6210,7 @@ static ivas_error ivas_dec_init_split_rend( } ELSE { - IF( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), num_poses * BINAURAL_CHANNELS ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), i_mult( num_poses, BINAURAL_CHANNELS ) ) ) != IVAS_ERR_OK ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index fe4965993..dacb1777f 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2915,7 +2915,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( Word32 *in_delayed_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; Word16 i; #ifdef FIX_1119_SPLIT_RENDERING_VOIP - int16_t j; + Word16 j; Word32 *p_Cldfb_In_BinReal[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; Word32 *p_Cldfb_In_BinImag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; #endif diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 5a6668b2e..49f2f4964 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -539,7 +539,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], i_mult( hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels, num_slots ), 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 Q_out[ch] = sub( Q_cldfb, 1 ); move16(); hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 4036e6011..a67143dbb 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -99,17 +99,18 @@ static void ivas_td_ringbuf_push_interleaved( { h->data[h->write_pos] = data[read_s]; move32(); - ++h->write_pos; + h->write_pos = L_add( h->write_pos, 1 ); - IF( EQ_32( h->write_pos, h->capacity ) ) + if ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; + move16(); } read_s = L_add( read_s, L_deposit_l( read_stride ) ); move32(); } - IF( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -279,9 +280,9 @@ void ivas_TD_RINGBUF_Push( h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; move32(); #endif - ++h->write_pos; + h->write_pos = L_add( h->write_pos, 1 ); - IF( EQ_32( h->write_pos, h->capacity ) ) + if ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -289,7 +290,7 @@ void ivas_TD_RINGBUF_Push( } } - IF( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); @@ -343,7 +344,7 @@ void ivas_TD_RINGBUF_PushZeros( { h->data[h->write_pos] = 0.f; move32(); - ++h->write_pos; + h->write_pos = L_add( h->write_pos, 1 ); IF( EQ_32( h->write_pos, h->capacity ) ) { @@ -353,7 +354,7 @@ void ivas_TD_RINGBUF_PushZeros( } } - IF( EQ_32( h->read_pos, h->write_pos ) ) + if ( EQ_32( h->read_pos, h->write_pos ) ) { h->is_full = 1; move16(); -- GitLab From 93085e53af8ae561a62f29ccd55f73fa43bd6927 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 14:00:41 +0100 Subject: [PATCH 107/351] Fix formatting --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 0e25388f2..92b65f7a7 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2476,7 +2476,7 @@ ivas_error ivas_jbm_dec_render_fx( } #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR - if( st_ivas->flushing ) + if ( st_ivas->flushing ) { nchan_out_syn_output = BINAURAL_CHANNELS; move16(); -- GitLab From ed749e0bf79ceaba3f67f7f8a26830daa5e711e9 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 14:31:41 +0100 Subject: [PATCH 108/351] Fix missing BASOPs part 1 --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 8184452e7..c0d3b4344 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1292,7 +1292,7 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; - max_band = (Word16) ar_div( BINAURAL_MAXBANDS * st_ivas->hDecoderConfig->output_Fs, 48000 ); + max_band = extract_l( ar_div( imult3216( st_ivas->hDecoderConfig->output_Fs, BINAURAL_MAXBANDS ), 48000 ) ); pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); -- GitLab From 941443a00281aaa57b1f6c823cb81400b6e37521 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 14:36:53 +0100 Subject: [PATCH 109/351] Improve comments about differences between BASOP and float versions --- lib_dec/ivas_jbm_dec_fx.c | 4 +++- lib_dec/lib_dec_fx.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 92b65f7a7..097027872 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2465,7 +2465,9 @@ ivas_error ivas_jbm_dec_render_fx( nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); - /* Save TD signals for pose correction if they are to be used */ + /* Save TD signals for pose correction if they are to be used. + * + * NOTE: Here BASOP differs from the float version. In float, we push samples to TD ring buffer in lib_dec.c function isar_render_poses. */ IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL ) { FOR( i = 0; i < nchan_out_syn_output; i++ ) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c0d3b4344..9ff0c9e50 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1254,8 +1254,8 @@ static ivas_error isar_render_poses( return IVAS_ERR_OK; } - // NOTE: Here BASOP differs from float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. - // To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. + /* NOTE: Here BASOP differs from the float version. In float, we push samples to TD ring buffer here. In BASOP, TD signals are only available in 16 bit here. + * To save TD signals in 32-bit precision, samples are pushed via ivas_TD_RINGBUF_PushChannels in ivas_jbm_dec_render_fx within IVAS_DEC_GetSamplesRenderer. */ return error; } -- GitLab From dc89328bcd8bdb905b002d419215afea5e46c28a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:01:00 +0100 Subject: [PATCH 110/351] Fix missing BASOPs part 2 --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9ff0c9e50..aa0a9d721 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1293,7 +1293,7 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; max_band = extract_l( ar_div( imult3216( st_ivas->hDecoderConfig->output_Fs, BINAURAL_MAXBANDS ), 48000 ) ); - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); -- GitLab From 86a28a5d6e93adf9dab8ddc877b4c442d6a481fa Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:02:08 +0100 Subject: [PATCH 111/351] Fix missing BASOPs part 3 --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index aa0a9d721..9bca6d7d0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1296,7 +1296,7 @@ static ivas_error isar_generate_metadata_and_bitstream( pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); - n_samples_in_cldfb_slot = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + n_samples_in_cldfb_slot = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); -- GitLab From d0233ecac8fed33e02ada2bbcc4f698b2b96f777 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:05:20 +0100 Subject: [PATCH 112/351] Fix missing BASOPs part 4 --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9bca6d7d0..ea65c382a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1598,7 +1598,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return IVAS_ERR_WRONG_PARAMS; } - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); move16(); numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); move16(); -- GitLab From 4020bf719a6c3c2546ca11db206fe5b3576b48c9 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:11:06 +0100 Subject: [PATCH 113/351] Fix BASOPs part 5 --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index f32dee8b8..dcdea6dca 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9048,7 +9048,7 @@ static ivas_error getSamplesInternal( hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ), ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) #else IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, -- GitLab From 70582ac193b6c5418beb282dff2b78363e9f9a23 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:22:05 +0100 Subject: [PATCH 114/351] Fix MSVC warning --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index dcdea6dca..431e4d693 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9048,7 +9048,7 @@ static ivas_error getSamplesInternal( hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ), ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) #else IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, -- GitLab From 41aaabf7b244e38e788df96d342a8798a5b3500a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 15:27:01 +0100 Subject: [PATCH 115/351] Fix more conversion errors --- lib_dec/lib_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ea65c382a..e942efd7f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1293,7 +1293,7 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; max_band = extract_l( ar_div( imult3216( st_ivas->hDecoderConfig->output_Fs, BINAURAL_MAXBANDS ), 48000 ) ); - pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); + pcm_out_flag = extract_l( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ); cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); n_samples_in_cldfb_slot = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -1598,7 +1598,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return IVAS_ERR_WRONG_PARAMS; } - pcm_out_flag = EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); + pcm_out_flag = extract_l( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ); move16(); numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); move16(); -- GitLab From 65607ba9cf8d5dfac035f00df04910465439b738 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Fri, 31 Oct 2025 17:00:04 +0100 Subject: [PATCH 116/351] Trigger CI -- GitLab From 59aa4423a30ca2c3295b86b18b79494b06b924e4 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 31 Oct 2025 17:18:26 +0100 Subject: [PATCH 117/351] set q factor of splitRendEncBuffer from outAudio buffer --- lib_rend/lib_rend_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 64082179f..e537eb71c 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9349,6 +9349,11 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( pSplitEncBufConfig = &hIvasRend->splitRendEncBuffer.config; pSplitRendConfig = &hIvasRend->hRendererConfig->split_rend_config; + *hIvasRend->splitRendEncBuffer.pq_fact = *outAudio.pq_fact; + move16(); + hIvasRend->splitRendEncBuffer.q_factor = outAudio.q_factor; + move16(); + /* 0 DoF / No pose correction retains frame size */ pSplitEncBufConfig->is_cldfb = cldfb_in_flag; move16(); -- GitLab From 2e39f6ded4365f4df62853d6b18fb48fcf712b72 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 31 Oct 2025 17:34:11 +0100 Subject: [PATCH 118/351] saturating sub to fix crash in final renderer pseudo frame --- lib_isar/isar_lcld_encoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 915e2a5e4..927932c1b 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -1426,7 +1426,7 @@ static void QuantizeSpectrumDPCM_Opt( ppiQImag[iBlockOffset][iFBOffset] = L_shr( ppiQImag_fx, 21 ); ppiQReal_fx = L_shl( ppiQReal[iBlockOffset][iFBOffset], 21 ); - fPrevReal_fx = L_sub( L_shl( UnQuantize_fx( ppiQReal_fx, + fPrevReal_fx = L_sub_sat( L_shl( UnQuantize_fx( ppiQReal_fx, fInvSCFGain_fx, ppiSignReal[iBlockOffset][iFBOffset] ), 9 ), @@ -1434,7 +1434,7 @@ static void QuantizeSpectrumDPCM_Opt( /* add prediction to quantized residual = reconstructed sample */ ppiQImag_fx = L_shl( ppiQImag[iBlockOffset][iFBOffset], 21 ); - fPrevImag_fx = L_sub( L_shl( UnQuantize_fx( ppiQImag_fx, + fPrevImag_fx = L_sub_sat( L_shl( UnQuantize_fx( ppiQImag_fx, fInvSCFGain_fx, ppiSignImag[iBlockOffset][iFBOffset] ), 9 ), -- GitLab From 8f7b175b0b224483f1f169275dce1e0e92293049 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 31 Oct 2025 17:45:07 +0100 Subject: [PATCH 119/351] clang-format --- lib_isar/isar_lcld_encoder.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 927932c1b..16e370c64 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -1427,18 +1427,18 @@ static void QuantizeSpectrumDPCM_Opt( ppiQReal_fx = L_shl( ppiQReal[iBlockOffset][iFBOffset], 21 ); fPrevReal_fx = L_sub_sat( L_shl( UnQuantize_fx( ppiQReal_fx, - fInvSCFGain_fx, - ppiSignReal[iBlockOffset][iFBOffset] ), - 9 ), - fReal_fx ); + fInvSCFGain_fx, + ppiSignReal[iBlockOffset][iFBOffset] ), + 9 ), + fReal_fx ); /* add prediction to quantized residual = reconstructed sample */ ppiQImag_fx = L_shl( ppiQImag[iBlockOffset][iFBOffset], 21 ); fPrevImag_fx = L_sub_sat( L_shl( UnQuantize_fx( ppiQImag_fx, - fInvSCFGain_fx, - ppiSignImag[iBlockOffset][iFBOffset] ), - 9 ), - fImag_fx ); + fInvSCFGain_fx, + ppiSignImag[iBlockOffset][iFBOffset] ), + 9 ), + fImag_fx ); iBlockOffset++; } /* group length */ } /* groups */ -- GitLab From c405bf59ff9fac8b89f7994bffc9086058e21c05 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 31 Oct 2025 17:57:07 +0100 Subject: [PATCH 120/351] add another saturating operator --- lib_isar/isar_lcld_encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 16e370c64..87e4f39cc 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -1411,7 +1411,7 @@ static void QuantizeSpectrumDPCM_Opt( FOR( k = 0; k < piGroupLengths[n]; k++ ) { /* prediction */ - fReal_fx = L_sub( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevReal_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevImag_fx ) ); + fReal_fx = L_sub_sat( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevReal_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevImag_fx ) ); fImag_fx = L_add( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevImag_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevReal_fx ) ); ppiQReal_fx = Quantize_fx( L_add_sat( L_shr_r_sat( ppfReal_fx[iBlockOffset][iFBOffset], sub( q_final, Q28 ) ), fReal_fx ), /* quantize residual */ fSCFGain_fx, -- GitLab From 9197b08b7fc9183252c6233a79b67dc211936c67 Mon Sep 17 00:00:00 2001 From: lintervo Date: Mon, 3 Nov 2025 11:04:48 +0200 Subject: [PATCH 121/351] Fix fl to fx conversion with obj edit file interface --- apps/decoder.c | 28 ++++++++++++++++++++++++++++ lib_com/options.h | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 5221ec628..84299cf34 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3337,7 +3337,11 @@ static void do_object_editing_fx( if ( readInfo->bg_gain_edited ) { +#ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE + editableParameters->gain_bed_fx = (Word32) ( readInfo->bg_gain * 536870912 ); /* Q29 */ +#else editableParameters->gain_bed_fx = (Word32) readInfo->bg_gain * 536870912; /* Q29 */ +#endif } for ( obj_idx = 0; obj_idx < editableParameters->num_obj; obj_idx++ ) @@ -3350,11 +3354,19 @@ static void do_object_editing_fx( if ( readInfo->obj_azi_relative[obj_idx] ) { /* azimuth: apply relative edit + wrap */ +#ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE + editableParameters->ism_metadata[obj_idx].azimuth_fx = ( ( editableParameters->ism_metadata[obj_idx].azimuth_fx + (Word32) ( readInfo->obj_azi[obj_idx] * 4194304 ) + 2264924160 ) % 1509949440 ) - 754974720; /* Q22 */ +#else editableParameters->ism_metadata[obj_idx].azimuth_fx = ( ( editableParameters->ism_metadata[obj_idx].azimuth_fx + (Word32) readInfo->obj_azi[obj_idx] * 4194304 + 2264924160 ) % 1509949440 ) - 754974720; /* Q22 */ +#endif } else { +#ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE + editableParameters->ism_metadata[obj_idx].azimuth_fx = (Word32) ( readInfo->obj_azi[obj_idx] * 4194304 ); /* Q22 */ +#else editableParameters->ism_metadata[obj_idx].azimuth_fx = (Word32) readInfo->obj_azi[obj_idx] * 4194304; /* Q22 */ +#endif } } if ( readInfo->obj_ele_edited[obj_idx] ) @@ -3362,11 +3374,19 @@ static void do_object_editing_fx( if ( readInfo->obj_ele_relative[obj_idx] ) { /* elevation: apply relative edit + saturation */ +#ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE + editableParameters->ism_metadata[obj_idx].elevation_fx = L_max( L_min( editableParameters->ism_metadata[obj_idx].elevation_fx + (Word32) ( readInfo->obj_ele[obj_idx] * 4194304 ), 377487360 ), -377487360 ); /* Q22 */ +#else editableParameters->ism_metadata[obj_idx].elevation_fx = L_max( L_min( editableParameters->ism_metadata[obj_idx].elevation_fx + (Word32) readInfo->obj_ele[obj_idx] * 4194304, 377487360 ), -377487360 ); /* Q22 */ +#endif } else { +#ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE + editableParameters->ism_metadata[obj_idx].elevation_fx = (Word32) ( readInfo->obj_ele[obj_idx] * 4194304 ); /* Q22 */ +#else editableParameters->ism_metadata[obj_idx].elevation_fx = (Word32) readInfo->obj_ele[obj_idx] * 4194304; /* Q22 */ +#endif } } } @@ -3378,14 +3398,22 @@ static void do_object_editing_fx( { /* gain: apply relative edit + saturation */ #ifdef FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES +#ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE + editableParameters->ism_metadata[obj_idx].gain_fx = L_max( L_min( L_shl_sat( Mpy_32_32( editableParameters->ism_metadata[obj_idx].gain_fx, (Word32) ( readInfo->obj_gain[obj_idx] * 536870912 ) ), 2 ), OBJ_EDIT_GAIN_MAX_FX ), OBJ_EDIT_GAIN_MIN_FX ); /* Q29*Q29 -> Q27 shift back to Q29 */ +#else editableParameters->ism_metadata[obj_idx].gain_fx = L_max( L_min( L_shl_sat( Mpy_32_32( editableParameters->ism_metadata[obj_idx].gain_fx, (Word32) readInfo->obj_gain[obj_idx] * 536870912 ), 2 ), OBJ_EDIT_GAIN_MAX_FX ), OBJ_EDIT_GAIN_MIN_FX ); /* Q29*Q29 -> Q27 shift back to Q29 */ +#endif #else editableParameters->ism_metadata[obj_idx].gain_fx = L_max( L_min( editableParameters->ism_metadata[obj_idx].gain_fx * (Word32) readInfo->obj_gain[obj_idx] * 536870912, OBJ_EDIT_GAIN_MAX_FX ), OBJ_EDIT_GAIN_MIN_FX ); /* Q29 */ #endif } else { +#ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE + editableParameters->ism_metadata[obj_idx].gain_fx = (Word32) ( readInfo->obj_gain[obj_idx] * 536870912 ); /* Q29 */ +#else editableParameters->ism_metadata[obj_idx].gain_fx = (Word32) readInfo->obj_gain[obj_idx] * 536870912; /* Q29 */ +#endif } } } diff --git a/lib_com/options.h b/lib_com/options.h index 37fffd13e..7b963ca4d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,7 @@ #define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */ #define FIX_2082_FP_LEFTOVERS_OMASA_DEC /* Nokia: fix for issue 2082, cleaning remaining floating point code */ #define FIX_2174_JBM_BASOP_ALIGNMENT /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */ - +#define FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE /* Nokia: Fixes float to fx conversion in decoder app with object edit file interface */ /* ################### End FIXES switches ########################### */ -- GitLab From 0cfaec541a82a77283d7344503bbbb186a635da4 Mon Sep 17 00:00:00 2001 From: lintervo Date: Mon, 3 Nov 2025 11:12:37 +0200 Subject: [PATCH 122/351] Fix formatting --- apps/decoder.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 84299cf34..bb5dfa5a6 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3340,7 +3340,7 @@ static void do_object_editing_fx( #ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE editableParameters->gain_bed_fx = (Word32) ( readInfo->bg_gain * 536870912 ); /* Q29 */ #else - editableParameters->gain_bed_fx = (Word32) readInfo->bg_gain * 536870912; /* Q29 */ + editableParameters->gain_bed_fx = (Word32) readInfo->bg_gain * 536870912; /* Q29 */ #endif } @@ -3355,9 +3355,9 @@ static void do_object_editing_fx( { /* azimuth: apply relative edit + wrap */ #ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE - editableParameters->ism_metadata[obj_idx].azimuth_fx = ( ( editableParameters->ism_metadata[obj_idx].azimuth_fx + (Word32) ( readInfo->obj_azi[obj_idx] * 4194304 ) + 2264924160 ) % 1509949440 ) - 754974720; /* Q22 */ + editableParameters->ism_metadata[obj_idx].azimuth_fx = ( ( editableParameters->ism_metadata[obj_idx].azimuth_fx + (Word32) ( readInfo->obj_azi[obj_idx] * 4194304 ) + 2264924160 ) % 1509949440 ) - 754974720; /* Q22 */ #else - editableParameters->ism_metadata[obj_idx].azimuth_fx = ( ( editableParameters->ism_metadata[obj_idx].azimuth_fx + (Word32) readInfo->obj_azi[obj_idx] * 4194304 + 2264924160 ) % 1509949440 ) - 754974720; /* Q22 */ + editableParameters->ism_metadata[obj_idx].azimuth_fx = ( ( editableParameters->ism_metadata[obj_idx].azimuth_fx + (Word32) readInfo->obj_azi[obj_idx] * 4194304 + 2264924160 ) % 1509949440 ) - 754974720; /* Q22 */ #endif } else @@ -3365,7 +3365,7 @@ static void do_object_editing_fx( #ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE editableParameters->ism_metadata[obj_idx].azimuth_fx = (Word32) ( readInfo->obj_azi[obj_idx] * 4194304 ); /* Q22 */ #else - editableParameters->ism_metadata[obj_idx].azimuth_fx = (Word32) readInfo->obj_azi[obj_idx] * 4194304; /* Q22 */ + editableParameters->ism_metadata[obj_idx].azimuth_fx = (Word32) readInfo->obj_azi[obj_idx] * 4194304; /* Q22 */ #endif } } @@ -3377,7 +3377,7 @@ static void do_object_editing_fx( #ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE editableParameters->ism_metadata[obj_idx].elevation_fx = L_max( L_min( editableParameters->ism_metadata[obj_idx].elevation_fx + (Word32) ( readInfo->obj_ele[obj_idx] * 4194304 ), 377487360 ), -377487360 ); /* Q22 */ #else - editableParameters->ism_metadata[obj_idx].elevation_fx = L_max( L_min( editableParameters->ism_metadata[obj_idx].elevation_fx + (Word32) readInfo->obj_ele[obj_idx] * 4194304, 377487360 ), -377487360 ); /* Q22 */ + editableParameters->ism_metadata[obj_idx].elevation_fx = L_max( L_min( editableParameters->ism_metadata[obj_idx].elevation_fx + (Word32) readInfo->obj_ele[obj_idx] * 4194304, 377487360 ), -377487360 ); /* Q22 */ #endif } else @@ -3385,7 +3385,7 @@ static void do_object_editing_fx( #ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE editableParameters->ism_metadata[obj_idx].elevation_fx = (Word32) ( readInfo->obj_ele[obj_idx] * 4194304 ); /* Q22 */ #else - editableParameters->ism_metadata[obj_idx].elevation_fx = (Word32) readInfo->obj_ele[obj_idx] * 4194304; /* Q22 */ + editableParameters->ism_metadata[obj_idx].elevation_fx = (Word32) readInfo->obj_ele[obj_idx] * 4194304; /* Q22 */ #endif } } @@ -3412,7 +3412,7 @@ static void do_object_editing_fx( #ifdef FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE editableParameters->ism_metadata[obj_idx].gain_fx = (Word32) ( readInfo->obj_gain[obj_idx] * 536870912 ); /* Q29 */ #else - editableParameters->ism_metadata[obj_idx].gain_fx = (Word32) readInfo->obj_gain[obj_idx] * 536870912; /* Q29 */ + editableParameters->ism_metadata[obj_idx].gain_fx = (Word32) readInfo->obj_gain[obj_idx] * 536870912; /* Q29 */ #endif } } -- GitLab From 87b1a7531792f5bb1726b45975f2992c395fa629 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 11:42:56 +0200 Subject: [PATCH 123/351] Initial rtpdump port - Add rtpdump related files to lib_util - Add flags IVAS_RTPDUMP and RTP_S4_251135_CR26253_0016_REV1 - Port changes to rtpdump.c, g192.c/.h, ivas_error.h - Add functionality to encoder.c and decoder.c --- apps/decoder.c | 75 ++ apps/encoder.c | 233 ++++- lib_com/ivas_error.h | 24 + lib_com/options.h | 4 + lib_util/g192.c | 4 + lib_util/g192.h | 4 + lib_util/ivas_bpool.c | 153 +++ lib_util/ivas_bpool.h | 57 ++ lib_util/ivas_queue.c | 137 +++ lib_util/ivas_queue.h | 68 ++ lib_util/ivas_rtp_api.h | 591 +++++++++++ lib_util/ivas_rtp_file.c | 612 +++++++++++ lib_util/ivas_rtp_file.h | 79 ++ lib_util/ivas_rtp_internal.h | 140 +++ lib_util/ivas_rtp_payload.c | 1854 ++++++++++++++++++++++++++++++++++ lib_util/ivas_rtp_pi_data.c | 850 ++++++++++++++++ lib_util/ivas_rtp_pi_data.h | 471 +++++++++ lib_util/mutex.h | 104 ++ lib_util/rtpdump.c | 13 + readme.txt | 12 +- 20 files changed, 5474 insertions(+), 11 deletions(-) create mode 100644 lib_util/ivas_bpool.c create mode 100644 lib_util/ivas_bpool.h create mode 100644 lib_util/ivas_queue.c create mode 100644 lib_util/ivas_queue.h create mode 100644 lib_util/ivas_rtp_api.h create mode 100644 lib_util/ivas_rtp_file.c create mode 100644 lib_util/ivas_rtp_file.h create mode 100644 lib_util/ivas_rtp_internal.h create mode 100644 lib_util/ivas_rtp_payload.c create mode 100644 lib_util/ivas_rtp_pi_data.c create mode 100644 lib_util/ivas_rtp_pi_data.h create mode 100644 lib_util/mutex.h diff --git a/apps/decoder.c b/apps/decoder.c index 5221ec628..0e7931fe8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -52,6 +52,9 @@ #include "wmc_auto.h" #include "options.h" #include "stl.h" +#ifdef IVAS_RTPDUMP +#include "ivas_rtp_file.h" +#endif #define WMC_TOOL_SKIP @@ -129,6 +132,9 @@ typedef struct uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; bool objEditEnabled; char *objEditFileName; +#ifdef IVAS_RTPDUMP + char *piOutputFilename; +#endif } DecArguments; @@ -840,6 +846,9 @@ static bool parseCmdlIVAS_dec( arg->referenceVectorTrajFileName = NULL; arg->enableExternalOrientation = false; arg->externalOrientationTrajFileName = NULL; +#ifdef IVAS_RTPDUMP + arg->piOutputFilename = NULL; +#endif #ifdef SUPPORT_JBM_TRACEFILE arg->jbmTraceFilename = NULL; @@ -918,6 +927,20 @@ static bool parseCmdlIVAS_dec( arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF; i++; } +#ifdef IVAS_RTPDUMP + else if ( strcmp( argv_to_upper, "-PIDATAFILE" ) == 0 ) + { + i++; + if ( argc - i <= 3 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: PI Data Output file name not specified!\n\n" ); + usage_dec(); + return false; + } + + arg->piOutputFilename = argv[i++]; + } +#endif #ifdef SUPPORT_JBM_TRACEFILE else if ( strcmp( argv_to_upper, "-TRACEFILE" ) == 0 ) { @@ -1511,10 +1534,19 @@ static void usage_dec( void ) fprintf( stdout, "--------\n" ); fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); +#ifdef IVAS_RTPDUMP + fprintf( stdout, "-VOIP_hf_only=1 : VoIP mode: EVS or IVAS RTP Payload Format hf_only=1 in rtpdump\n" ); + fprintf( stdout, " The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" ); + fprintf( stdout, " EVS RTP Payload Format or rtpdump files containing TS26.253 Annex A\n" ); + fprintf( stdout, " IVAS RTP Payload Format. The SDP parameter hf_only is required.\n" ); + fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" ); + fprintf( stdout, "-PiDataFile PF Log the timestampped PI data.\n" ); +#else fprintf( stdout, "-VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" ); fprintf( stdout, " The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" ); fprintf( stdout, " EVS RTP Payload Format. The SDP parameter hf_only is required.\n" ); fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" ); +#endif #ifdef SUPPORT_JBM_TRACEFILE fprintf( stdout, "-Tracefile TF : VoIP mode: Generate trace file named TF. Requires -no_delay_cmp to\n" ); fprintf( stdout, " be enabled so that trace contents remain in sync with audio output.\n" ); @@ -2654,12 +2686,18 @@ static ivas_error decodeVoIP( int16_t delayNumSamples = -1; int32_t delayTimeScale = -1; int16_t i; +#ifdef IVAS_RTPDUMP + IVAS_RTP ivasRtp = { 0 }; +#else FILE *f_rtpstream = NULL; EVS_RTPDUMP_DEPACKER rtpdumpDepacker; EVS_RTPDUMP_DEPACKER_ERROR rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_NO_ERROR; +#endif uint8_t *auPtr = NULL; +#ifndef IVAS_RTPDUMP bool isAMRWB_IOmode; uint16_t frameTypeIndex; +#endif bool qBit; IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; @@ -2695,11 +2733,20 @@ static ivas_error decodeVoIP( delayNumSamples_orig[0] = -1; +#ifndef IVAS_RTPDUMP rtpdumpDepacker.rtpdump = NULL; +#endif switch ( arg.inputFormat ) { case IVAS_DEC_INPUT_FORMAT_RTPDUMP: case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF: +#ifdef IVAS_RTPDUMP + if ( ( error = IVAS_RTP_READER_Init( &ivasRtp, arg.inputBitstreamFilename, arg.piOutputFilename ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "error in IVAS_RTP_READER_Init(): %d\n", error ); + goto cleanup; + } +#else f_rtpstream = fopen( arg.inputBitstreamFilename, "r" ); if ( f_rtpstream == NULL ) @@ -2714,6 +2761,7 @@ static ivas_error decodeVoIP( fprintf( stderr, "error in EVS_RTPDUMP_DEPACKER_open(): %d\n", rtpdumpDepackerError ); goto cleanup; } +#endif break; case IVAS_DEC_INPUT_FORMAT_G192: auPtr = au; @@ -2755,12 +2803,20 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ +#ifdef IVAS_RTPDUMP + error = IVAS_RTP_ReadNextFrame( &ivasRtp, auPtr, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &qBit ); +#else rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); +#endif /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } +#ifdef IVAS_RTPDUMP + if ( error != IVAS_ERR_OK ) +#else if ( error != IVAS_ERR_OK || rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR ) +#endif { fprintf( stderr, "failed to read first RTP packet\n" ); goto cleanup; @@ -2931,19 +2987,34 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ +#ifdef IVAS_RTPDUMP + error = IVAS_RTP_ReadNextFrame( &ivasRtp, au, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &qBit ); + + /* IVAS RTP payload format has timescale 16000, JBM uses 1000 internally */ + rtpTimeStamp = rtpTimeStamp / 16; +#else rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; +#endif } +#ifdef IVAS_RTPDUMP + if ( error == IVAS_ERR_END_OF_FILE ) +#else if ( error == IVAS_ERR_END_OF_FILE || rtpdumpDepackerError == EVS_RTPDUMP_DEPACKER_EOF ) +#endif { /* finished reading */ nextPacketRcvTime_ms = (uint32_t) -1; } +#ifdef IVAS_RTPDUMP + else if ( error != IVAS_ERR_OK ) +#else else if ( error != IVAS_ERR_OK || rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR ) +#endif { fprintf( stderr, "\nError in BS_Reader_ReadVoipFrame_compact, error code: %d\n", error ); goto cleanup; @@ -3285,7 +3356,11 @@ static ivas_error decodeVoIP( cleanup: +#ifdef IVAS_RTPDUMP + IVAS_RTP_Term( &ivasRtp ); +#else EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker ); +#endif AudioFileWriter_close( &afWriter ); JbmOffsetFileWriter_close( &jbmOffsetWriter ); #ifdef SUPPORT_JBM_TRACEFILE diff --git a/apps/encoder.c b/apps/encoder.c index 2a8ef469f..122875635 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -44,6 +44,10 @@ #include "jbm_file_reader.h" #include "masa_file_reader.h" #include "wmc_auto.h" +#ifdef IVAS_RTPDUMP +#include "rotation_file_reader.h" +#include "ivas_rtp_file.h" +#endif #ifdef DEBUG_FORCE_DIR /* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. @@ -155,6 +159,12 @@ typedef struct #endif bool pca; bool ism_extended_metadata; +#ifdef IVAS_RTPDUMP + bool rtpdumpOutput; + uint32_t numFramesPerPacket; + char *sceneOrientationTrajFileName; + char *deviceOrientationTrajFileName; +#endif } EncArguments; @@ -198,6 +208,10 @@ int main( MasaFileReader *masaReader = NULL; IsmFileReader *ismReaders[IVAS_MAX_NUM_OBJECTS] = { NULL, NULL, NULL, NULL }; int16_t *pcmBuf = NULL; +#ifdef IVAS_RTPDUMP + RotFileReader *sceneOrientationFileReader = NULL; + RotFileReader *deviceOrientationFileReader = NULL; +#endif #ifdef DEBUGGING FILE *f_forcedModeProfile = NULL; #endif @@ -207,6 +221,11 @@ int main( reset_mem( USE_BYTES ); #endif +#ifdef IVAS_RTPDUMP + uint8_t au[IVAS_MAX_BITS_PER_FRAME / 8]; + IVAS_RTP ivasRtp = { 0 }; +#endif + /*------------------------------------------------------------------------------------------* * Parse command-line arguments *------------------------------------------------------------------------------------------*/ @@ -233,7 +252,11 @@ int main( const BS_WRITER_FORMAT bsWriterFormat = arg.mimeOutput ? BS_WRITER_FORMAT_MIME : BS_WRITER_FORMAT_G192; +#ifdef IVAS_RTPDUMP + if ( !arg.rtpdumpOutput && BS_Writer_Open_filename( &hBsWriter, arg.outputBitstreamFilename, bsWriterFormat ) != IVAS_ERR_OK ) +#else if ( BS_Writer_Open_filename( &hBsWriter, arg.outputBitstreamFilename, bsWriterFormat ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nCan't open %s\n\n", arg.outputBitstreamFilename ); goto cleanup; @@ -591,6 +614,47 @@ int main( } } +#ifdef IVAS_RTPDUMP + /*------------------------------------------------------------------------------------------* + * RTPDump + *------------------------------------------------------------------------------------------*/ + + if ( arg.rtpdumpOutput ) + { + if ( ( error = IVAS_RTP_WRITER_Init( &ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open output bitstream file for RTP output %s \n\n", arg.outputBitstreamFilename ); + goto cleanup; + } + } + + /*------------------------------------------------------------------------------------------* + * Open scene orientation file + *------------------------------------------------------------------------------------------*/ + + if ( arg.sceneOrientationTrajFileName != NULL ) + { + if ( ( error = RotationFileReader_open( arg.sceneOrientationTrajFileName, &sceneOrientationFileReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open scene orientation file %s \n\n", arg.sceneOrientationTrajFileName ); + goto cleanup; + } + } + + /*------------------------------------------------------------------------------------------* + * Open device orientation file + *------------------------------------------------------------------------------------------*/ + + if ( arg.deviceOrientationTrajFileName != NULL ) + { + if ( ( error = RotationFileReader_open( arg.deviceOrientationTrajFileName, &deviceOrientationFileReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open device orientation file %s \n\n", arg.deviceOrientationTrajFileName ); + goto cleanup; + } + } +#endif + int16_t numSamplesRead = 0; uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME]; uint16_t numBits = 0; @@ -755,18 +819,78 @@ int main( } /* *** Encode one frame *** */ - if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits ) ) != IVAS_ERR_OK ) +#ifdef IVAS_RTPDUMP + if ( ivasRtp.hPack ) { - fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } + bool isMono = ( arg.inputFormat == IVAS_ENC_INPUT_MONO ); + bool forcePacket = ( numSamplesRead < pcmBufSize ); /* If EoF force Packet generation */ + + ivasRtp.nWrittenPiData = 0; + + /* scene orientation */ + if ( sceneOrientationFileReader ) + { + PIDATA_TS *piDataTs = &ivasRtp.piData[ivasRtp.nWrittenPiData++]; + IVAS_PIDATA_ORIENTATION *scene = &piDataTs->data.scene; + + memset( piDataTs, 0, sizeof( PIDATA_TS ) ); + scene->size = sizeof( IVAS_PIDATA_ORIENTATION ); + scene->piDataType = IVAS_PI_SCENE_ORIENTATION; + + if ( ( error = HeadRotationFileReading( sceneOrientationFileReader, &scene->orientation, NULL ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading scene orientation from %s\n", IVAS_ENC_GetErrorMessage( error ), RotationFileReader_getFilePath( sceneOrientationFileReader ) ); + goto cleanup; + } + } + + /* device orientation */ + if ( deviceOrientationFileReader ) + { + PIDATA_TS *piDataTs = &ivasRtp.piData[ivasRtp.nWrittenPiData++]; + IVAS_PIDATA_ORIENTATION *device = &piDataTs->data.deviceUnCompensated; + + memset( piDataTs, 0, sizeof( PIDATA_TS ) ); + device->size = sizeof( IVAS_PIDATA_ORIENTATION ); + device->piDataType = IVAS_PI_DEVICE_ORIENTATION_COMPENSATED; - /* write bitstream */ - if ( ( error = BS_Writer_WriteFrame_short( hBsWriter, bitStream, numBits, totalBitrate ) ) != IVAS_ERR_OK ) + if ( ( error = HeadRotationFileReading( deviceOrientationFileReader, &device->orientation, NULL ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading device orientation from %s\n", IVAS_ENC_GetErrorMessage( error ), RotationFileReader_getFilePath( deviceOrientationFileReader ) ); + goto cleanup; + } + } + + if ( ( error = IVAS_ENC_EncodeFrameToCompact( hIvasEnc, pcmBuf, pcmBufSize, au, &numBits ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = IVAS_RTP_WriteNextFrame( &ivasRtp, au, numBits, isMono, forcePacket ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while pushing audio frame to RTP pack\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + else { - fprintf( stderr, "\nBS_Writer_WriteFrame_short failed, error code %d\n\n", error ); - goto cleanup; +#endif + if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + + /* write bitstream */ + if ( ( error = BS_Writer_WriteFrame_short( hBsWriter, bitStream, numBits, totalBitrate ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nBS_Writer_WriteFrame_short failed, error code %d\n\n", error ); + goto cleanup; + } +#ifdef IVAS_RTPDUMP } +#endif frame++; if ( !arg.quietModeEnabled ) @@ -835,6 +959,20 @@ cleanup: fclose( f_bitrateProfile ); } +#ifdef IVAS_RTPDUMP + if ( sceneOrientationFileReader ) + { + RotationFileReader_close( &sceneOrientationFileReader ); + } + + if ( deviceOrientationFileReader ) + { + RotationFileReader_close( &deviceOrientationFileReader ); + } + + IVAS_RTP_Term( &ivasRtp ); +#endif + IVAS_ENC_Close( &hIvasEnc ); #ifdef WMOPS @@ -890,6 +1028,11 @@ static bool parseCmdlIVAS_enc( arg->mimeOutput = false; arg->ism_extended_metadata = false; arg->complexityLevel = IVAS_ENC_COMPLEXITY_LEVEL_THREE; +#ifdef IVAS_RTPDUMP + arg->rtpdumpOutput = false; + arg->sceneOrientationTrajFileName = NULL; + arg->deviceOrientationTrajFileName = NULL; +#endif #ifdef DEBUGGING arg->forcedMode = IVAS_ENC_FORCE_UNFORCED; arg->forcedModeFile = NULL; @@ -1668,6 +1811,72 @@ static bool parseCmdlIVAS_enc( i++; } +#ifdef IVAS_RTPDUMP + /*-----------------------------------------------------------------* + * RTPDump output + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-RTPDUMP" ) == 0 ) + { + i++; + arg->rtpdumpOutput = true; + if ( i < argc - 4 ) + { + if ( !is_digits_only( argv[i] ) ) + { + arg->numFramesPerPacket = 1; /* Default to 1 frame per packet */ + } + else + { + arg->numFramesPerPacket = atoi( argv[i++] ); + if ( arg->numFramesPerPacket > IVAS_MAX_FRAMES_PER_RTP_PACKET ) + { + fprintf( stderr, "numFramesPerPacket(%d) exceeds max frames per packet (%d) \n", arg->numFramesPerPacket, IVAS_MAX_FRAMES_PER_RTP_PACKET ); + arg->numFramesPerPacket = 1; + } + } + } + fprintf( stdout, "Output format: RTPDump using %d frames/packet \n", arg->numFramesPerPacket ); + } + + /*-----------------------------------------------------------------* + * Scene orientation + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-SCENE_ORIENTATION" ) == 0 ) + { + i++; + if ( argc - i <= 4 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: Scene orientation file name not specified!\n\n" ); + usage_enc(); + return false; + } + + arg->sceneOrientationTrajFileName = argv[i]; + i++; + } + + /*-----------------------------------------------------------------* + * Device orientation + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-DEVICE_ORIENTATION" ) == 0 ) + { + i++; + if ( argc - i <= 4 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: Device orientation file name not specified!\n\n" ); + usage_enc(); + return false; + } + + arg->deviceOrientationTrajFileName = argv[i]; + i++; + } + +#endif + /*-----------------------------------------------------------------* * Option not recognized *-----------------------------------------------------------------*/ @@ -1880,6 +2089,14 @@ static void usage_enc( void ) #endif fprintf( stdout, "-q : Quiet mode, no frame counters\n" ); fprintf( stdout, " default is deactivated\n" ); +#ifdef IVAS_RTPDUMP + fprintf( stdout, "-rtpdump : RTPDump output, hf_only=1 by default. The encoder will packetize the \n" ); + fprintf( stdout, " bitstream frames into TS26.253 Annex A IVAS RTP Payload Format packets and \n" ); + fprintf( stdout, " writes those to the output file. In EVS mono operating mode, TS26.445 Annex A.2.2 \n" ); + fprintf( stdout, " EVS RTP Payload Format is used. Optional N represents number of frames per RTP packet\n" ); + fprintf( stdout, "-scene_orientation : Scene orientation trajectory file. Only used with rtpdump output.\n" ); + fprintf( stdout, "-device_orientation : Device orientation trajectory file. Only used with rtpdump output.\n" ); +#endif fprintf( stdout, "\n" ); return; diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 1ba3b52ae..3b49667d4 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -147,6 +147,14 @@ typedef enum IVAS_ERR_LC3PLUS_INVALID_BITRATE, IVAS_ERR_INVALID_SPLIT_REND_CONFIG, + /*----------------------------------------* + * rtp errors * + *----------------------------------------*/ + IVAS_ERR_RTP_UNDERFLOW = 0x7000, + IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, + IVAS_ERR_RTP_UNPACK_PI_DATA, + IVAS_ERR_RTP_UNSUPPORTED_FRAME, + /*----------------------------------------* * unknown error * *----------------------------------------*/ @@ -286,6 +294,22 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) { return "data error"; } + if ( ( error_code & 0x7000 ) == 0x7000 ) + { + switch ( error_code ) + { + case IVAS_ERR_RTP_UNDERFLOW: + return "RTP Undeflow in reading frame/packet"; + case IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE: + return "Output buffer size is insufficient"; + case IVAS_ERR_RTP_UNPACK_PI_DATA: + return "Unpacking PI data failure"; + case IVAS_ERR_RTP_UNSUPPORTED_FRAME: + return "Unsupported RTP frame"; + default: + return "rtp error"; + } + } return "Unknown error"; } diff --git a/lib_com/options.h b/lib_com/options.h index 37fffd13e..58e866a18 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -135,6 +135,10 @@ #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ #define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ +// RTPDUMP porting +#define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ +#define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ + /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_util/g192.c b/lib_util/g192.c index 898e9753d..99c0b84dc 100644 --- a/lib_util/g192.c +++ b/lib_util/g192.c @@ -482,7 +482,11 @@ G192_ERROR G192_WriteVoipFrame_short( const uint16_t *serial, const int16_t numBits, uint16_t const rtpSequenceNumber, +#ifdef IVAS_RTPDUMP + uint32_t const rtpTimeStamp, +#else uint16_t const rtpTimeStamp, +#endif uint32_t const rcvTime_ms ) { int16_t G192_HEADER[2], G192_DATA[IVAS_MAX_BITS_PER_FRAME]; diff --git a/lib_util/g192.h b/lib_util/g192.h index 62eeaae8f..e2f28a0f6 100644 --- a/lib_util/g192.h +++ b/lib_util/g192.h @@ -93,7 +93,11 @@ G192_ERROR G192_Writer_Open_filename( G192_HANDLE *phG192, const char *filename G192_ERROR G192_WriteFrame( G192_HANDLE const hG192, const uint16_t *serial, const int16_t numBits ); +#ifdef IVAS_RTPDUMP +G192_ERROR G192_WriteVoipFrame_short( G192_HANDLE const hG192, const uint16_t *serial, const int16_t num_bits, uint16_t const rtpSequenceNumber, uint32_t const rtpTimeStamp, uint32_t const rcvTime_ms ); +#else G192_ERROR G192_WriteVoipFrame_short( G192_HANDLE const hG192, const uint16_t *serial, const int16_t num_bits, uint16_t const rtpSequenceNumber, uint16_t const rtpTimeStamp, uint32_t const rcvTime_ms ); +#endif G192_ERROR G192_Writer_Close( G192_HANDLE *phG192 ); diff --git a/lib_util/ivas_bpool.c b/lib_util/ivas_bpool.c new file mode 100644 index 000000000..9db909f53 --- /dev/null +++ b/lib_util/ivas_bpool.c @@ -0,0 +1,153 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ +#include +#include +#include "ivas_bpool.h" +#include "ivas_error_utils.h" +#include "mutex.h" + +struct BPOOL +{ + mtx_t lock; + uint32_t bufferSize; + uint32_t numBuffers; + uint32_t numFreeBuffers; + void **freeBuffers; +}; + +ivas_error BPOOL_Create( BPOOL_HANDLE *pHandle, size_t bufferSize, uint32_t numBuffers ) +{ + uint32_t n; + uint8_t *base = NULL; + BPOOL_HANDLE handle; + size_t allocSize = sizeof( struct BPOOL ); + + if ( pHandle == NULL ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid pointer to Buffer Pool Handle" ); + } + + *pHandle = NULL; + + allocSize += bufferSize * numBuffers; /* pool memory */ + allocSize += sizeof( void * ) * numBuffers; /* free buffers stack */ + + base = calloc( allocSize, sizeof( uint8_t ) ); + if ( base == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Couldn't allocate Buffer pool" ); + } + + handle = (BPOOL_HANDLE) base; + base += sizeof( struct BPOOL ); + + mtx_init( &handle->lock, 0 ); + handle->bufferSize = bufferSize; + handle->numBuffers = numBuffers; + handle->numFreeBuffers = numBuffers; + handle->freeBuffers = (void **) base; + base += ( sizeof( void * ) * numBuffers ); + for ( n = 0; n < numBuffers; n++ ) + { + handle->freeBuffers[n] = base; + base += bufferSize; + } + + *pHandle = handle; + return IVAS_ERR_OK; +} + +void BPOOL_Destroy( BPOOL_HANDLE *pHandle ) +{ + if ( ( pHandle != NULL ) && ( *pHandle != NULL ) ) + { + mtx_destroy( &( *pHandle )->lock ); + free( *pHandle ); + *pHandle = NULL; + } +} + +ivas_error BPOOL_GetBuffer( BPOOL_HANDLE handle, void **dataPtr ) +{ + uint32_t idx = 0; + bool isFree = false; + + if ( handle == NULL || dataPtr == NULL ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid pointer args in GetBuffer" ); + } + + mtx_lock( &handle->lock ); + isFree = ( handle->numFreeBuffers > 0 ); + if ( isFree ) + { + idx = --handle->numFreeBuffers; + } + mtx_unlock( &handle->lock ); + + if ( !isFree ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Underflow, no free buffers in pool" ); + } + + *dataPtr = handle->freeBuffers[idx]; + return IVAS_ERR_OK; +} + +/* return the buffer back to pool */ +ivas_error BPOOL_FreeBuffer( BPOOL_HANDLE handle, void *dataPtr ) +{ + uint32_t idx; + + if ( handle == NULL || dataPtr == NULL ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid pointer args in GetBuffer" ); + } + + mtx_lock( &handle->lock ); + idx = handle->numFreeBuffers++; + mtx_unlock( &handle->lock ); + + handle->freeBuffers[idx] = dataPtr; + + return IVAS_ERR_OK; +} + +/* return the number of free buffers available atm in the pool */ +uint32_t BPOOL_AvailableBuffers( BPOOL_HANDLE handle ) +{ + uint32_t numFreeBuffers; + mtx_lock( &handle->lock ); + numFreeBuffers = handle->numFreeBuffers; + mtx_unlock( &handle->lock ); + return numFreeBuffers; +} diff --git a/lib_util/ivas_bpool.h b/lib_util/ivas_bpool.h new file mode 100644 index 000000000..30cf4962b --- /dev/null +++ b/lib_util/ivas_bpool.h @@ -0,0 +1,57 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_BPOOL_H +#define IVAS_BPOOL_H + +#include +#include "common_api_types.h" + +/* Forward declaraiton of opaque buffer pool handle */ +typedef struct BPOOL *BPOOL_HANDLE; + +/* Create a buffer pool with given element size and max number of buffers */ +ivas_error BPOOL_Create( BPOOL_HANDLE *pHandle, size_t bufferSize, uint32_t numBuffers ); + +/* Destroy the buffer pool and all free-up all allocated memory */ +void BPOOL_Destroy( BPOOL_HANDLE *pHandle ); + +/* request a buffer from the pool */ +ivas_error BPOOL_GetBuffer( BPOOL_HANDLE handle, void **dataPtr ); + +/* return the buffer back to pool */ +ivas_error BPOOL_FreeBuffer( BPOOL_HANDLE handle, void *dataPtr ); + +/* return the number of free buffers available atm in the pool */ +uint32_t BPOOL_AvailableBuffers( BPOOL_HANDLE handle ); + +#endif /* IVAS_BPOOL_H */ diff --git a/lib_util/ivas_queue.c b/lib_util/ivas_queue.c new file mode 100644 index 000000000..b17cf3e21 --- /dev/null +++ b/lib_util/ivas_queue.c @@ -0,0 +1,137 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "ivas_queue.h" +#include "ivas_error_utils.h" +#include "mutex.h" + +struct QUEUE +{ + mtx_t lock; + NODE *front; + NODE *back; + uint32_t size; +}; + +ivas_error QUEUE_Create( QUEUE_HANDLE *pHandle ) +{ + QUEUE_HANDLE handle = NULL; + *pHandle = NULL; + + if ( pHandle == NULL ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid pointer to Buffer Pool Handle" ); + } + + handle = calloc( 1, sizeof( struct QUEUE ) ); + if ( handle != NULL ) + { + mtx_init( &handle->lock, 0 ); + } + + *pHandle = handle; + return IVAS_ERR_OK; +} + +/* Destroy the queue and free-up all allocated memory */ +void QUEUE_Destroy( QUEUE_HANDLE *pHandle ) +{ + if ( ( pHandle != NULL ) && ( *pHandle != NULL ) ) + { + mtx_destroy( &( *pHandle )->lock ); + free( *pHandle ); + *pHandle = NULL; + } +} + +void QUEUE_Push( QUEUE_HANDLE handle, NODE *node ) +{ + mtx_lock( &handle->lock ); + if ( handle->back == NULL ) + { + handle->front = node; + } + else + { + handle->back->next = node; + } + handle->back = node; + handle->size++; + mtx_unlock( &handle->lock ); +} + +/* return the buffer back to pool */ +NODE *QUEUE_Pop( QUEUE_HANDLE handle ) +{ + NODE *node; + mtx_lock( &handle->lock ); + node = handle->front; + handle->front = handle->front->next; + if ( NULL == handle->front ) + { + handle->back = NULL; + } + handle->size--; + mtx_unlock( &handle->lock ); + return node; +} + +/* returns the first element in the queue */ +NODE *QUEUE_Front( QUEUE_HANDLE handle ) +{ + NODE *node; + mtx_lock( &handle->lock ); + node = handle->front; + mtx_unlock( &handle->lock ); + return node; +} + +/* returns the last element in the queue */ +NODE *QUEUE_Back( QUEUE_HANDLE handle ) +{ + NODE *node; + mtx_lock( &handle->lock ); + node = handle->back; + mtx_unlock( &handle->lock ); + return node; +} + +/* return the number of elements in the queue */ +size_t QUEUE_Size( QUEUE_HANDLE handle ) +{ + uint32_t numNodes; + mtx_lock( &handle->lock ); + numNodes = handle->size; + mtx_unlock( &handle->lock ); + return numNodes; +} diff --git a/lib_util/ivas_queue.h b/lib_util/ivas_queue.h new file mode 100644 index 000000000..1c6b77504 --- /dev/null +++ b/lib_util/ivas_queue.h @@ -0,0 +1,68 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_QUEUE_H +#define IVAS_QUEUE_H + +#include +#include "common_api_types.h" + +typedef struct NODE +{ + struct NODE *next; +} NODE; + +/* Forward declaraiton of opaque queue handle */ +typedef struct QUEUE *QUEUE_HANDLE; + +/* Create a queue with given element size and max number of buffers */ +ivas_error QUEUE_Create( QUEUE_HANDLE *pHandle ); + +/* Destroy the queue and all free-up all allocated memory */ +void QUEUE_Destroy( QUEUE_HANDLE *pHandle ); + +/* push a buffer to a queue */ +void QUEUE_Push( QUEUE_HANDLE handle, NODE *data ); + +/* pop the buffer from the front */ +NODE *QUEUE_Pop( QUEUE_HANDLE handle ); + +/* returns the first element from the front */ +NODE *QUEUE_Front( QUEUE_HANDLE handle ); + +/* returns the last element from the back */ +NODE *QUEUE_Back( QUEUE_HANDLE handle ); + +/* return the number of elements in the queue */ +size_t QUEUE_Size( QUEUE_HANDLE handle ); + +#endif /* IVAS_QUEUE_H */ diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h new file mode 100644 index 000000000..06c56cd70 --- /dev/null +++ b/lib_util/ivas_rtp_api.h @@ -0,0 +1,591 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_RTP_API_H +#define IVAS_RTP_API_H + +#include +#include +#include "common_api_types.h" + +/* + * +-----------------------+---------------------+--------------------+----------+ + * | RTP Header (+ HDREXT) | payload header | frame data | PI data | + * +-----------------------+---------------------+--------------------+----------+ + * \--------------------\ /------------------------------/ + * IVAS payload + * + * This api provides a mechanism to generate/unpack the IVAS payload. The RTP Header + * and header extension fields must be handled by caller. + * + * IVAS General Payload structure + * =============================== + * + * 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 + * H H H H F H + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |1| T | D |1| ET1 |x x x x|1| ET2 |x x x x|0|1|0 1| BR |1| ET3 |x x x x|… + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * \--------------/\--------------/\--------------/\--------------/\--------------/ + * Initial E byte Subsqnt Ebyte1 Subsqnt Ebyte2 ToC1 Subsqnt Ebyte3 + * + * H F + * +-+-+-+-+-+-+-+-+-------------------------- ---+-------------------- ---+-------+ + * …|0|0|0 1| BR | IVAS frame 1 ... | IVAS frame 2 ... |PI data| + * +-+-+-+-+-+-+-+-+-------------------------- ---+-------------------- ---+-------+ + * \--------------/ + * ToC2 + * + */ + +#define IVAS_MAX_FRAMES_PER_RTP_PACKET ( 8 ) /* Max supported frames per RTP packet */ + +/* It is difficult to decide the RTP Payload buffer's capacity intrinsically however computing + * using the maximum frame size and all currently supported PI data present gives a crude + * estimate or RTP packet size per frame. The additional PI data is assumed to add upto a 20% + * overhead in bitrate for the computation. + */ +#define NOMINAL_BUFFER_SIZE( numFramesPerPacket ) ( ( IVAS_MAX_BITS_PER_FRAME + ( IVAS_MAX_BITS_PER_FRAME / 5 ) ) * ( numFramesPerPacket ) / 8 ) + +#define DEFAULT_MAX_PACKET_BYTES ( 1400 ) /* Typical MTU size of 4G/5G Cellular Interfaces */ + +#define NO_BITRATE_REQ ( 0u ) /* If no bitrate is requested from remote */ + +/* IVAS Codec Types */ +typedef enum +{ + IVAS_RTP_EVS, /* EVS */ + IVAS_RTP_IVAS /* IVAS */ +} IVAS_RTP_CODEC; + +/* IVAS Bandwidth Requests */ +typedef enum +{ + IVAS_BANDWIDTH_NB, /* Narrowband */ + IVAS_BANDWIDTH_WB, /* Wideband*/ + IVAS_BANDWIDTH_SWB, /* SuperWideband*/ + IVAS_BANDWIDTH_FB, /* Fullband */ + IVAS_BANDWIDTH_NO_REQ, /* No Preference */ +} IVAS_RTP_BANDWIDTH; + +/* Channel Aware Coding */ +typedef enum +{ + IVAS_RTP_CA_LO_O2, /* FER=LO, OFFSET=2 */ + IVAS_RTP_CA_LO_O3, /* FER=LO, OFFSET=3 */ + IVAS_RTP_CA_LO_O5, /* FER=LO, OFFSET=5 */ + IVAS_RTP_CA_LO_O7, /* FER=LO, OFFSET=7 */ + IVAS_RTP_CA_HI_O2, /* FER=HI, OFFSET=2 */ + IVAS_RTP_CA_HI_O3, /* FER=HI, OFFSET=3 */ + IVAS_RTP_CA_HI_O5, /* FER=HI, OFFSET=5 */ + IVAS_RTP_CA_HI_O7, /* FER=HI, OFFSET=7 */ + IVAS_RTP_CA_NO_REQ /* No request */ +} IVAS_RTP_CA_MODE; + +/* Coded Format Requests */ +typedef enum +{ + IVAS_FMT_STEREO, /* Stereo */ + IVAS_FMT_SBA, /* Scene Based Audio */ + IVAS_FMT_MASA, /* Metadata Assisted Spatial Audio */ + IVAS_FMT_ISM, /* Object Based Audio */ + IVAS_FMT_MC, /* Multichannel Audio */ + IVAS_FMT_OMASA, /* Object + MASA */ + IVAS_FMT_OSBA, /* Object + SBA */ + IVAS_FMT_NO_REQ, /* No preference */ +} IVAS_RTP_FORMAT; + +#ifdef RTP_S4_251135_CR26253_0016_REV1 +/* Coded Subformat Requests */ +typedef enum +{ + IVAS_SUBFMT_FOA_PLANAR, + IVAS_SUBFMT_HOA2_PLANAR, + IVAS_SUBFMT_HOA3_PLANAR, + IVAS_SUBFMT_FOA, + IVAS_SUBFMT_HOA2, + IVAS_SUBFMT_HOA3, + IVAS_SUBFMT_MASA1, + IVAS_SUBFMT_MASA2, + IVAS_SUBFMT_ISM1, + IVAS_SUBFMT_ISM2, + IVAS_SUBFMT_ISM3, + IVAS_SUBFMT_ISM4, + IVAS_SUBFMT_ISM1_EXTENDED_METADATA, + IVAS_SUBFMT_ISM2_EXTENDED_METADATA, + IVAS_SUBFMT_ISM3_EXTENDED_METADATA, + IVAS_SUBFMT_ISM4_EXTENDED_METADATA, + IVAS_SUBFMT_MC_5_1, + IVAS_SUBFMT_MC_7_1, + IVAS_SUBFMT_MC_5_1_2, + IVAS_SUBFMT_MC_5_1_4, + IVAS_SUBFMT_MC_7_1_4, + IVAS_SUBFMT_RESERVED_21, + IVAS_SUBFMT_RESERVED_22, + IVAS_SUBFMT_RESERVED_23, + IVAS_SUBFMT_RESERVED_24, + IVAS_SUBFMT_RESERVED_25, + IVAS_SUBFMT_RESERVED_26, + IVAS_SUBFMT_RESERVED_27, + IVAS_SUBFMT_RESERVED_28, + IVAS_SUBFMT_RESERVED_29, + IVAS_SUBFMT_RESERVED_30, + IVAS_SUBFMT_RESERVED_31, + IVAS_SUBFMT_OMASA_ISM1_1TC, + IVAS_SUBFMT_OMASA_ISM2_1TC, + IVAS_SUBFMT_OMASA_ISM3_1TC, + IVAS_SUBFMT_OMASA_ISM4_1TC, + IVAS_SUBFMT_OMASA_ISM1_2TC, + IVAS_SUBFMT_OMASA_ISM2_2TC, + IVAS_SUBFMT_OMASA_ISM3_2TC, + IVAS_SUBFMT_OMASA_ISM4_2TC, + IVAS_SUBFMT_OSBA_ISM1_FOA_PLANAR, + IVAS_SUBFMT_OSBA_ISM2_FOA_PLANAR, + IVAS_SUBFMT_OSBA_ISM3_FOA_PLANAR, + IVAS_SUBFMT_OSBA_ISM4_FOA_PLANAR, + IVAS_SUBFMT_OSBA_ISM1_FOA, + IVAS_SUBFMT_OSBA_ISM2_FOA, + IVAS_SUBFMT_OSBA_ISM3_FOA, + IVAS_SUBFMT_OSBA_ISM4_FOA, + IVAS_SUBFMT_OSBA_ISM1_HOA2_PLANAR, + IVAS_SUBFMT_OSBA_ISM2_HOA2_PLANAR, + IVAS_SUBFMT_OSBA_ISM3_HOA2_PLANAR, + IVAS_SUBFMT_OSBA_ISM4_HOA2_PLANAR, + IVAS_SUBFMT_OSBA_ISM1_HOA2, + IVAS_SUBFMT_OSBA_ISM2_HOA2, + IVAS_SUBFMT_OSBA_ISM3_HOA2, + IVAS_SUBFMT_OSBA_ISM4_HOA2, + IVAS_SUBFMT_OSBA_ISM1_HOA3_PLANAR, + IVAS_SUBFMT_OSBA_ISM2_HOA3_PLANAR, + IVAS_SUBFMT_OSBA_ISM3_HOA3_PLANAR, + IVAS_SUBFMT_OSBA_ISM4_HOA3_PLANAR, + IVAS_SUBFMT_OSBA_ISM1_HOA3, + IVAS_SUBFMT_OSBA_ISM2_HOA3, + IVAS_SUBFMT_OSBA_ISM3_HOA3, + IVAS_SUBFMT_OSBA_ISM4_HOA3, + IVAS_SUBFMT_NO_REQ +} IVAS_RTP_SUBFORMAT; + +/* Split Rendering Requests */ +typedef struct +{ + uint32_t valid : 1; /* is split rendering request valid */ + uint32_t diegetic : 1; /* enabling diegetic support for Split Rendering */ + uint32_t yaw : 1; /* transmission metadata for correction around yaw axis */ + uint32_t pitch : 1; /* transmission metadata for correction around pitch axis */ + uint32_t roll : 1; /* transmission metadata for correction around roll axis */ + uint32_t reserved : 27; /* reserved */ +} IVAS_RTP_SPLITRENDER; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + +/* Remote Requests Types (Keys) */ +typedef enum +{ + IVAS_REQUEST_CODEC, /* Request codec type, value of type IVAS_RTP_CODEC */ + IVAS_REQUEST_BITRATE, /* Request bitrate, value of type uint32_t in kbps */ + IVAS_REQUEST_BANDWIDTH, /* Request bandwidth, value of type IVAS_RTP_BANDWIDTH */ + IVAS_REQUEST_FORMAT, /* Request format, value of type IVAS_RTP_FORMAT */ + IVAS_REQUEST_CA_MODE, /* Request channel awareness, value of type IVAS_RTP_CA_MODE */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_REQUEST_SUBFORMAT, /* Request subFormat, value of type IVAS_RTP_SUBFORMAT */ + IVAS_REQUEST_SR_CONFIG, /* Request spit rendering, value of type IVAS_RTP_SPLITRENDER */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_REQUEST_MAX /* Max number of requests */ +} IVAS_RTP_REQUEST_TYPE; + +/* Remote Request Values */ +typedef union +{ + uint32_t bitrate; /* bitrate in kbps when request type is IVAS_REQUEST_BITRATE */ + IVAS_RTP_CODEC codec; /* codec id when request type is IVAS_REQUEST_CODEC */ + IVAS_RTP_BANDWIDTH bandwidth; /* badwidth when request type is IVAS_REQUEST_BANDWIDTH */ + IVAS_RTP_FORMAT formatType; /* format type when request type is IVAS_REQUEST_FORMAT */ + IVAS_RTP_CA_MODE caMode; /* channel aware mode when request type is IVAS_REQUEST_CA_MODE */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SUBFORMAT subFormatType; /* sub-format type when request type is IVAS_REQUEST_SUBFORMAT */ + IVAS_RTP_SPLITRENDER srConfig; /* split rendering config when request type is IVAS_REQUEST_SR_CONFIG */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ +} IVAS_RTP_REQUEST_VALUE; + +/* Template for pi data types, all defined pi data follow this template + * for example scene orientation pi data can be represented as :- + * + * typedef struct { + * size_t size; // sizeof(IVAS_PIDATA_SCENE_ORIENTATION) + * uint32_t piDataType; // IVAS_PI_SCENE_ORIENTATION + * float w, x, y, z; // pi data of scene orientation in quaternions + * } IVAS_PIDATA_SCENE_ORIENTATION; + * + */ +typedef struct +{ + size_t size; /* size of this structure */ + uint32_t piDataType; /* IVAS PI data type */ + uint8_t data[1]; /* Variable length array */ +} IVAS_PIDATA_GENERIC; + +/* Generic data buffer for sending/receiving coded frames / rtp payloads + * data buffer is owned and initialized by caller, rtp api will ensure + * buffer write does not exceed capacity. + */ +typedef struct +{ + size_t capacity; /* allocated size of the data buffer */ + size_t length; /* length of the initialized data in the buffer */ + uint8_t *buffer; /* pointer to the payload buffer */ +} IVAS_DATA_BUFFER; + +#ifdef RTP_S4_251135_CR26253_0016_REV1 +typedef enum +{ + IVAS_SR_TRANSPORT_LCLD, + IVAS_SR_TRANSPORT_LC3PLUS +} IVAS_RTP_SR_TRANSPORT; + +typedef struct +{ + bool valid; /* Valid Split Rendering Info for/in the ToC */ + bool diegetic; /* SR content digetic */ + IVAS_RTP_SR_TRANSPORT codec; /* SR Transport Codec used*/ +} IVAS_RTP_SR_INFO; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + +/**********************************************/ +/* IVAS RTP PACKER API */ +/**********************************************/ + +/* Forward declaration of rtp pack/unpack handle types */ +typedef struct IVAS_RTP_PACK *IVAS_RTP_PACK_HANDLE; /* rtp packer handle type */ + +/* Initial configuration for rtp packer + * - maxFramesPerPacket is used to define if more than one frame should be packed + * in the same rtp packet. If zero, will use IVAS_MAX_FRAMES_PER_RTP_PACKET. + */ +typedef struct +{ + uint32_t maxFramesPerPacket; /* maximum no of frame per packet desired during the session */ +} IVAS_RTP_PACK_CONFIG; + +/* Open an instance of the RTP packer and return a handle to rtp packer on success + * error code is retured on failure and handle is set to NULL + */ +ivas_error IVAS_RTP_PACK_Open( + IVAS_RTP_PACK_HANDLE *phIvasPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + const IVAS_RTP_PACK_CONFIG *config /* i : pointer to initial config for RTP Packer */ +); + +/* Close and free an existing instance of rtp packer */ +void IVAS_RTP_PACK_Close( + IVAS_RTP_PACK_HANDLE *phIvasPack /* i/o : pointer to an IVAS rtp packer handle to be closed */ +); + +/* Update the RTP Header structure */ +ivas_error IVAS_RTP_PACK_UpdateHeader( + IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ + uint8_t numCC, /* i : numCC indicates no. of contributing sources */ + uint32_t *csrc, /* i : SSRCs of contributing Sources for a mixed stream */ + uint16_t extHeaderId, /* i : extension header ID */ + uint16_t numExtensionBytes, /* i : length of the extension data */ + uint8_t *extData /* i : extension data pointer */ +); + +/* Add requests for remote sender using a key value pair api + * each key must be provided with a corresponding value type + * + * Cross validation of some key,value pairs will not be done + * in this API. E.g. Codec ID and supported bitrates/bandwidths + * will not be performed at this level. + */ +ivas_error IVAS_RTP_PACK_PushRemoteRequest( + IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o : IVAS rtp packer handle */ + IVAS_RTP_REQUEST_TYPE reqType, /* i : remote request type */ + IVAS_RTP_REQUEST_VALUE reqValue /* i : value of the requested type */ +); + +/* Push a single IVAS/EVS frame to rtp packer + * + * If multiple frames per RTP packet are desired, multiple frames must be explicitly + * pushed before a call to IVAS_RTP_PACK_GetPayload to generate a rtp payload. + * + * It is possible to have variable frames per packet until maxFramesPerPacket frames + * if IVAS_RTP_PACK_GetPayload is invoked asyncronously w.r.t this api. + * + */ +ivas_error IVAS_RTP_PACK_PushFrame( + IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o : IVAS rtp packer handle */ + IVAS_RTP_CODEC codecId, /* i : Codec type (IVAS/EVS) */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info (NULL if absent) */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + const IVAS_DATA_BUFFER *frameBuffer /* i : packed frame bitstream for IVAS/EVS */ +); + +/* Get the number of frames in the FiFo currently */ +uint32_t IVAS_RTP_PACK_GetNumFrames( + IVAS_RTP_PACK_HANDLE hIvasPack /* i/o : IVAS rtp packer handle */ +); + +/* Push single PI data to rtp packer + * + * Provide PI data for a current RTP packet. All PI data is locally cached in the packer + * and set to the rtp payload with policy defined in initial configuration during call to + * IVAS_RTP_PACK_GetPayload. + * + */ +ivas_error IVAS_RTP_PACK_PushPiData( + IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o : IVAS rtp packer handle */ + const IVAS_PIDATA_GENERIC *data /* i : pointer to the PIData stucture */ +); + +/* Generate a rtp payload using available pushed frames + * + * Available remote requests, pi data and frames will be packed into a rtp payload. The + * capacity field of payload is used to limits the maximum RTP packet size. + * + */ +ivas_error IVAS_RTP_PACK_GetPayload( + IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o : IVAS rtp packer handle */ + IVAS_DATA_BUFFER *payload, /* o : encapsulated rtp payload */ + uint32_t *numFramesInPayload /* o : no. of frames in payload */ +); + +/* Generate a rtp packet using available pushed frames + * + * Available remote requests, pi data and frames will be packed into a rtp packet. If no + * frame is pushed before call to this api, NO_DATA_FRAME will be generated + * Takes care of updates to the RTP Header + * + */ +ivas_error IVAS_RTP_PACK_GetPacket( + IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o : IVAS rtp packer handle */ + IVAS_DATA_BUFFER *packet, /* o : encapsulated rtp packet */ + uint32_t *numFramesInPacket /* o : no. of frames in packet */ +); + +/**********************************************/ +/* IVAS RTP UNPACKER API */ +/**********************************************/ + +/* Forward declaration of rtp unpack handle types */ +typedef struct IVAS_RTP_UNPACK *IVAS_RTP_UNPACK_HANDLE; /* rtp unpacker handle type */ + +/* Initial configuration for rtp unpacker + * - maxFramesPerPacket is used to define maximum supported frames per rtp packet + * to allow for internal memory allocaton, if zero, will use IVAS_MAX_FRAMES_PER_RTP_PACKET + */ + +typedef struct +{ + uint32_t maxFramesPerPacket; /* maximum no of frame per packet expected during the session */ +} IVAS_RTP_UNPACK_CONFIG; + +/* Open an instance of the RTP unpacker and return a handle to rtp unpacker on success + * error code is retured on failure and handle is set to NULL + */ +ivas_error IVAS_RTP_UNPACK_Open( + IVAS_RTP_UNPACK_HANDLE *phIvasUnpack, /* i/o : rtp unpacker handle */ + const IVAS_RTP_UNPACK_CONFIG *config /* i : initial configuration for rtp unpacker */ +); + +/* Close and free an existing instance of rtp unpacker */ +void IVAS_RTP_UNPACK_Close( + IVAS_RTP_UNPACK_HANDLE *phIvasUnpack /* i/o : IVAS rtp unpacker handle */ +); + +/* Push a received rtp Ivas Payload to unpacker to extract number of frames, pi data and + * any remote request present in the payload. Caller must extract RTP header and header + * extension and feed Ivas Payload alongwith RTP Timestamp and sequence number. + * + * In case of DTX transmission modes, the number of frames in packet will be reduced by + * the number of NO_DATA frame received. All PullFrame calls for non NO_DATA frames shall + * be reported with timestamp jump indicating missing/NO_DATA IVAS frames. + * + * It is important to ensure IVAS_RTP_UNPACK_PushPayload, IVAS_RTP_UNPACK_PullFrame and + * IVAS_RTP_UNPACK_PullNextPiData API are invoked in same thread context or in a thread + * safe manner else a race condition can arise if new packet is pushed while frames/pidata + * are still being pulled out. The IVAS_RTP_UNPACK_PushPayload will gererate an error if + * new paylod is pushed before all frames/pidata are pulled out. + * + * Example usage : - + * ================== + * err = IVAS_RTP_UNPACK_PushPayload(hIvasUnpack, payload, rtpTs, seqNum, + * &nFrames, &nPiData, &reqBitmap); + * if (err != IVAS_ERR_OK) { return err; } + * + * // Read the frames in payload and feed to decoder + * while (nFrames-- > 0) { + * err = IVAS_RTP_UNPACK_PullFrame(hIvasUnpack, &recCodecId, &srInfo, &frame, &frameTs, &seqNum, &SpeechLostIndicated); + * if (err != IVAS_ERR_OK) { return err; } + * err = IVAS_DEC_VoIP_FeedFrame(hIvasDec, frame.buffer, frame.length, seqNum, frameTs, rcvTime, isGoodFrame); + * if (err != IVAS_ERR_OK) { return err; } + * } + * + * // Read PI Data + * while (nPiData-- > 0) { + * err = IVAS_RTP_UNPACK_PullNextPiData(hIvasUnpack, &piData, &piTs); + * if (err != IVAS_ERR_OK) { return err; } + * // handle pi data based on fwd/rev pi data types + * handlePIData(&piData, piTs) + * } + * + * // Read remote requests + * for (req = 0; req < IVAS_REQUEST_MAX; req++) { + * if (reqBitmap & (1u << req)) { + * err = IVAS_RTP_UNPACK_GetRequest(hIvasUnpack, req, &value); + * if (err != IVAS_ERR_OK) { return err; } + * switch(req) { + * case IVAS_REQUEST_CODEC : handleCodec(value.codec); break; + * case IVAS_REQUEST_BITRATE : handleBitrate(value.bitrate); break; + * case IVAS_REQUEST_BANDWIDTH : handleBandwidth(value.bandwidth); break; + * case IVAS_REQUEST_FORMAT : handleFormat(value.formatType); break; + * case IVAS_REQUEST_SUBFORMAT : handleSubFormat(value.subFormatType); break; + * case IVAS_REQUEST_CA_MODE : handleCAModevalue.caMode); break; + * case IVAS_REQUEST_SR_CONFIG : handleSRConfig(value.srConfig); break; + * } + * } + * } + * + */ +ivas_error IVAS_RTP_UNPACK_PushPayload( + IVAS_RTP_UNPACK_HANDLE hIvasUnpack, /* i/o : IVAS rtp unpacker handle */ + const IVAS_DATA_BUFFER *payload, /* i : received rtp payload */ + uint32_t timestamp, /* i : timestamp in RTP Clock @ 16KHz from rtp header */ + uint16_t sequenceNumber, /* i : sequence number from rtp header */ + uint32_t *numFramesInPacket, /* o : number of IVAS/EVS frames in rtp packet */ + uint32_t *numPiDataInPacket, /* o : number of PI data received in rtp packet */ + uint32_t *remoteRequestBitmap /* o : bitmap of available request in this packet */ +); + +/* Push a received rtp Ivas Packet to unpacker to extract number of frames, pi data and + * any remote request present in the Packet. + * + * In case of DTX transmission modes, the number of frames in packet will be reduced by + * the number of NO_DATA frame received. All PullFrame calls for non NO_DATA frames shall + * be reported with timestamp jump indicating missing/NO_DATA IVAS frames. + * + * It is important to ensure IVAS_RTP_UNPACK_PushPacket, IVAS_RTP_UNPACK_PullFrame and + * IVAS_RTP_UNPACK_PullNextPiData API are invoked in same thread context or in a thread + * safe manner else a race condition can arise if new packet is pushed while frames/pidata + * are still being pulled out. The IVAS_RTP_UNPACK_PushPacket will gererate an error if + * new packet is pushed before all frames/pidata are pulled out. + * + * Example usage : - + * ================== + * err = IVAS_RTP_UNPACK_PushPacket(hIvasUnpack, packet, &nFrames, &nPiData, &reqBitmap); + * if (err != IVAS_ERR_OK) { return err; } + * + * // Read the frames in packet and feed to decoder + * while (nFrames-- > 0) { + * err = IVAS_RTP_UNPACK_PullFrame(hIvasUnpack, &recCodecId, &srInfo, &frame, &frameTs, &seqNum, &SpeechLostIndicated); + * if (err != IVAS_ERR_OK) { return err; } + * err = IVAS_DEC_VoIP_FeedFrame(hIvasDec, frame.buffer, frame.length, seqNum, frameTs, rcvTime, isGoodFrame); + * if (err != IVAS_ERR_OK) { return err; } + * } + * + * // Read PI Data + * while (nPiData-- > 0) { + * err = IVAS_RTP_UNPACK_PullNextPiData(hIvasUnpack, &piData, &piTs); + * if (err != IVAS_ERR_OK) { return err; } + * // handle pi data based on fwd/rev pi data types + * handlePIData(&piData, piTs) + * } + * + * // Read remote requests + * for (req = 0; req < IVAS_REQUEST_MAX; req++) { + * if (reqBitmap & (1u << req)) { + * err = IVAS_RTP_UNPACK_GetRequest(hIvasUnpack, req, &value); + * if (err != IVAS_ERR_OK) { return err; } + * switch(req) { + * case IVAS_REQUEST_CODEC : handleCodec(value.codec); break; + * case IVAS_REQUEST_BITRATE : handleBitrate(value.bitrate); break; + * case IVAS_REQUEST_BANDWIDTH : handleBandwidth(value.bandwidth); break; + * case IVAS_REQUEST_FORMAT : handleFormat(value.formatType); break; + * case IVAS_REQUEST_SUBFORMAT : handleSubFormat(value.subFormatType); break; + * case IVAS_REQUEST_CA_MODE : handleCAModevalue.caMode); break; + * case IVAS_REQUEST_SR_CONFIG : handleSRConfig(value.srConfig); break; + * } + * } + * } + */ +ivas_error IVAS_RTP_UNPACK_PushPacket( + IVAS_RTP_UNPACK_HANDLE hIvasUnpack, /* i/o : IVAS rtp unpacker handle */ + const IVAS_DATA_BUFFER *packet, /* i : received rtp Packet */ + uint32_t *numFramesInPacket, /* o : number of IVAS/EVS frames in rtp packet */ + uint32_t *numPiDataInPacket, /* o : number of PI data received in rtp packet */ + uint32_t *remoteRequestBitmap /* o : bitmap of available request in this packet */ +); + +/* Fetch requests from sender using a key value pair api + * each key must be provided with a corresponding value storage type + * + * On call to IVAS_RTP_UNPACK_PushPayload(), remoteRequestBitmap can be used + * an indicator of new request available this frame + * + */ +ivas_error IVAS_RTP_UNPACK_GetRequest( + IVAS_RTP_UNPACK_HANDLE hIvasUnpack, /* i/o : IVAS rtp packer handle */ + IVAS_RTP_REQUEST_TYPE type, /* i : remote request type */ + IVAS_RTP_REQUEST_VALUE *value /* o : pointer of the requested type */ +); + +/* Extract a single IVAS/EVS frame from provided rtp payload alongwith rtp timestamp + * and sequence number + * + * If multiple frames per RTP packet are available, multiple calls to IVAS_RTP_UNPACK_PullFrame + * are needed. + */ +ivas_error IVAS_RTP_UNPACK_PullFrame( + IVAS_RTP_UNPACK_HANDLE hIvasUnpack, /* i/o : IVAS rtp unpacker handle */ + IVAS_RTP_CODEC *receivedCodecId, /* o : Codec type (IVAS/EVS) */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SR_INFO *srInfo, /* o : Split Rendering Info */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_DATA_BUFFER *frameBuffer, /* o : packed frame bitstream for IVAS/EVS */ + int16_t *frameSizeInBits, /* o : exact frame size in bits (AMRWB IO) */ + uint32_t *timestamp, /* o : timestamp in RTP Clock @ 16KHz */ + uint16_t *sequenceNumber, /* o : sequence number from rtp header */ + bool *speechLostIndicated, /* o : Is current frame indicated as Lost */ + bool *isAMRWB_IOmode /* o : Is AMRWB_IO mode EVS frame */ +); + +/* Pull a single PI data from rtp unpacker instance for current packet + * Each Pi data is accompanied with a corresponding timestamp + */ +ivas_error IVAS_RTP_UNPACK_PullNextPiData( + IVAS_RTP_UNPACK_HANDLE hIvasUnpack, /* i/o : IVAS rtp unpacker handle */ + IVAS_PIDATA_GENERIC *data, /* o : output data buffer for the Pi data */ + size_t capacity, /* i : capacity of pi data buffer in bytes */ + uint32_t *timestamp /* o : timestamp in RTP Clock @ 16KHz */ +); + +#endif /* IVAS_RTP_API_H */ diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c new file mode 100644 index 000000000..8555480ef --- /dev/null +++ b/lib_util/ivas_rtp_file.c @@ -0,0 +1,612 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ +#include +#include +#include "ivas_rtp_file.h" +#include "ivas_error_utils.h" + +struct IVAS_RTP_FILE +{ + bool isFileWriter; + FILE *f_rtpstream; +}; + +static ivas_error IvasRtpFile_Open( + const char *filePath, /* i : path to CA config file */ + bool isFileWriter, /* i : instance is a file writer else reader */ + IVAS_RTP_FILE_HANDLE *phRtpFile /* o : pointer to an IVAS file reader handle */ +) +{ + const char *mode = isFileWriter ? "wb" : "rb"; + FILE *f_rtpstream = fopen( filePath, mode ); + if ( f_rtpstream == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_FILE_OPEN, "could not open: %s\n", filePath ); + } + + *phRtpFile = calloc( 1, sizeof( struct IVAS_RTP_FILE ) ); + if ( *phRtpFile != NULL ) + { + ( *phRtpFile )->isFileWriter = isFileWriter; + ( *phRtpFile )->f_rtpstream = f_rtpstream; + } + + return IVAS_ERR_OK; +} + +static ivas_error IvasRtpFile_Close( + IVAS_RTP_FILE_HANDLE *phReader /* i : pointer to an IVAS file reader handle */ +) +{ + if ( phReader != NULL && *phReader != NULL ) + { + if ( ( *phReader )->f_rtpstream != NULL ) + { + fclose( ( *phReader )->f_rtpstream ); + ( *phReader )->f_rtpstream = NULL; + } + free( *phReader ); + *phReader = NULL; + } + + return IVAS_ERR_OK; +} + +static ivas_error IvasRtpFile_Write( + IVAS_RTP_FILE_HANDLE hRtpFile, /* i : pointer to an IVAS file writer handle */ + const uint8_t *packet, /* i : rtp packet to be written to rtpdump file */ + size_t numBytes ) /* i : size in bytes of the rtp packet */ +{ + ivas_error error = IVAS_ERR_OK; + if ( hRtpFile->isFileWriter ) + { + uint32_t length = (uint32_t) numBytes; /* Max packet length is < 32 bits*/ + fwrite( &length, sizeof( uint32_t ), 1, hRtpFile->f_rtpstream ); + fwrite( packet, sizeof( uint8_t ), numBytes, hRtpFile->f_rtpstream ); + } + else + { + error = IVAS_ERR_WRONG_PARAMS; + } + return error; +} + +static ivas_error IvasRtpFile_Read( + IVAS_RTP_FILE_HANDLE hRtpFile, /* i : pointer to an IVAS file reader handle */ + uint8_t *packet, /* o : read rtp packet */ + size_t *numBytes, /* o : no of bytes in packet */ + size_t capacity /* i : max capacity of the packet buffer */ +) +{ + size_t nread = 0; + uint32_t length = 0; + if ( hRtpFile->isFileWriter ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "File open for writing cannot be read" ); + } + + nread = fread( &length, sizeof( uint32_t ), 1, hRtpFile->f_rtpstream ); /* Read Packet Length */ + if ( nread == 0 ) + { + return IVAS_ERR_END_OF_FILE; + } + + *numBytes = length; + if ( ( *numBytes ) > capacity ) + { + fprintf( stderr, "RTP packet > buffer capacity %lu bytes\n", capacity ); + return IVAS_ERR_INVALID_OUTPUT_BUFFER_SIZE; + } + + nread = fread( packet, sizeof( uint8_t ), ( *numBytes ), hRtpFile->f_rtpstream ); /* Read Packet */ + if ( nread < ( *numBytes ) ) + { + return IVAS_ERR_END_OF_FILE; + } + + return IVAS_ERR_OK; +} + +static const char *const PiDataNames[IVAS_PI_MAX_ID] = { + "SCENE_ORIENTATION", "DEVICE_ORIENTATION_COMPENSATED", "DEVICE_ORIENTATION_UNCOMPENSATED", + "ACOUSTIC_ENVIRONMENT", "AUDIO_DESCRIPTION", "ISM_NUM", "ISM_ID", "ISM_GAIN", "ISM_ORIENTATION", + "ISM_POSITION", "ISM_DISTANCE_ATTENUATION", "ISM_DIRECTIVITY", "DIEGETIC_TYPE", "RESERVED13", + "AUDIO_FOCUS_INDICATION", "RESERVED15", "PLAYBACK_DEVICE_ORIENTATION", "HEAD_ORIENTATION", "LISTENER_POSITION", + "DYNAMIC_AUDIO_SUPPRESSION", "AUDIO_FOCUS_REQUEST", "PI_LATENCY", "R_ISM_ID", "R_ISM_GAIN", + "R_ISM_ORIENTATION", "R_ISM_POSITION", "R_ISM_DIRECTION", "RESERVED27", "RESERVED28", "RESERVED29", + "RESERVED30", "NO_DATA" +}; + +void IVAS_RTP_LogPiData( + FILE *f_piDataOut, /* i/o : Output json file handle to dump PI data for debug/test */ + const PIDATA_TS *piData, /* i : PI Data + Timestamp array containing all PI data in current packet */ + uint32_t nPiDataPresent /* i : Number of valid elements in the piData array */ +) +{ + uint32_t timestamp = ~0u; + if ( f_piDataOut == NULL || piData == NULL || nPiDataPresent == 0 ) + { + return; + } + + if ( ftell( f_piDataOut ) > 2 ) + { + fprintf( f_piDataOut, ",\n" ); + } + + while ( nPiDataPresent-- > 0 ) + { + const PIDATA_TS *cur = piData++; + + if ( timestamp != ( ~0u ) && timestamp != cur->timestamp ) + { + fprintf( f_piDataOut, "\n\t},\n\t\"%d\": {\n", cur->timestamp ); + } + else if ( timestamp != cur->timestamp ) + { + fprintf( f_piDataOut, "\t\"%d\": {\n", cur->timestamp ); + } + else + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\"%s\" : ", PiDataNames[cur->data.noPiData.piDataType] ); + switch ( cur->data.noPiData.piDataType ) + { + case IVAS_PI_SCENE_ORIENTATION: + case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: + case IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED: +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: + case IVAS_PI_HEAD_ORIENTATION: + case IVAS_PI_R_ISM_ORIENTATION: +#endif + { + fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", + cur->data.scene.orientation.w, cur->data.scene.orientation.x, cur->data.scene.orientation.y, cur->data.scene.orientation.z ); + } + break; + + case IVAS_PI_ACOUSTIC_ENVIRONMENT: + { + fprintf( f_piDataOut, "{\n\t\t\t\"aeid\": %d", cur->data.acousticEnv.aeid ); + if ( cur->data.acousticEnv.availLateReverb ) + { + fprintf( f_piDataOut, ",\n\t\t\t\"rt60\": [ %f, %f, %f ],\n", cur->data.acousticEnv.rt60[0], cur->data.acousticEnv.rt60[1], cur->data.acousticEnv.rt60[2] ); + fprintf( f_piDataOut, "\t\t\t\"dsr\": [ %f, %f, %f ]", cur->data.acousticEnv.dsr[0], cur->data.acousticEnv.dsr[1], cur->data.acousticEnv.dsr[2] ); + } + if ( cur->data.acousticEnv.availEarlyReflections ) + { + fprintf( f_piDataOut, ",\n\t\t\t\"dim\": [ %f, %f, %f ],\n", cur->data.acousticEnv.roomDimensions.x, cur->data.acousticEnv.roomDimensions.y, cur->data.acousticEnv.roomDimensions.z ); + fprintf( f_piDataOut, "\t\t\t\"abscoeff\": [ %f, %f, %f, %f, %f, %f ]", cur->data.acousticEnv.absorbCoeffs[0], cur->data.acousticEnv.absorbCoeffs[1], cur->data.acousticEnv.absorbCoeffs[2], cur->data.acousticEnv.absorbCoeffs[3], cur->data.acousticEnv.absorbCoeffs[4], cur->data.acousticEnv.absorbCoeffs[5] ); + } + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case IVAS_PI_LISTENER_POSITION: + case IVAS_PI_R_ISM_POSITION: + { + fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", + cur->data.listnerPosition.position.x, cur->data.listnerPosition.position.y, cur->data.listnerPosition.position.z ); + } + break; + case IVAS_PI_AUDIO_DESCRIPTION: + { + uint32_t nEntries = cur->data.audioDesc.nValidEntries; + const IVAS_AUDIO_ID *audioId = cur->data.audioDesc.audioId; + + fprintf( f_piDataOut, "[\n" ); + while ( nEntries-- > 0 ) + { + fprintf( f_piDataOut, "\t\t\t{\n" ); + fprintf( f_piDataOut, "\t\t\t\t\"isSpeech\": %s,\n", audioId->speech ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t\"isMusic\": %s,\n", audioId->music ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t\"isAmbiance\": %s,\n", audioId->ambiance ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t\"isEditable\": %s,\n", audioId->editable ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t\"isBinaural\": %s\n", audioId->binaural ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t}%c\n", ( nEntries == 0 ) ? ' ' : ',' ); + audioId++; + } + fprintf( f_piDataOut, "\t\t]" ); + } + break; + case IVAS_PI_DIEGETIC_TYPE: + { + const bool *isDiegetic = cur->data.digeticIndicator.isDiegetic; + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"isDigetic\": [\n" ); + fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[0] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[1] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[2] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[3] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t%s\n", isDiegetic[4] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t]\n\t\t}" ); + } + break; + case IVAS_PI_AUDIO_FOCUS_INDICATION: + { + fprintf( f_piDataOut, "{" ); + if ( cur->data.focusIndication.availDirection ) + { + fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); + fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", + cur->data.focusIndication.direction.w, cur->data.focusIndication.direction.x, cur->data.focusIndication.direction.y, cur->data.focusIndication.direction.z ); + if ( cur->data.focusIndication.availLevel ) + { + fprintf( f_piDataOut, "," ); + } + } + if ( cur->data.focusIndication.availLevel ) + { + fprintf( f_piDataOut, "\n\t\t\t\"level\": %d", cur->data.focusIndication.flvl ); + } + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION: + { + const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppression; + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"preferSpeech\": %s,\n", das->speech ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"preferMusic\": %s,\n", das->music ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"preferAmbiance\": %s,\n", das->ambiance ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"level\": %d", das->sli ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_RESERVED13: + case IVAS_PI_AUDIO_FOCUS_REQUEST: + { + fprintf( f_piDataOut, "{" ); + if ( cur->data.focusRequest.availDirection ) + { + fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); + fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", + cur->data.focusRequest.direction.w, cur->data.focusRequest.direction.x, cur->data.focusRequest.direction.y, cur->data.focusRequest.direction.z ); + if ( cur->data.focusRequest.availLevel ) + { + fprintf( f_piDataOut, "," ); + } + } + if ( cur->data.focusRequest.availLevel ) + { + fprintf( f_piDataOut, "\n\t\t\t\"level\": %d", cur->data.focusRequest.flvl ); + } + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_RESERVED15: + case IVAS_PI_RESERVED27: + case IVAS_PI_RESERVED28: + case IVAS_PI_RESERVED29: + case IVAS_PI_RESERVED30: + { + fprintf( f_piDataOut, "{}" ); + } + break; + case IVAS_PI_ISM_NUM: + case IVAS_PI_ISM_ID: + case IVAS_PI_ISM_GAIN: + case IVAS_PI_ISM_ORIENTATION: + case IVAS_PI_ISM_POSITION: + case IVAS_PI_ISM_DISTANCE_ATTENUATION: + case IVAS_PI_ISM_DIRECTIVITY: + case IVAS_PI_PI_LATENCY: + case IVAS_PI_R_ISM_ID: + case IVAS_PI_R_ISM_GAIN: + case IVAS_PI_R_ISM_DIRECTION: +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + case IVAS_PI_NO_DATA: + { + fprintf( f_piDataOut, "{}" ); + } + break; + } + timestamp = cur->timestamp; + } + fprintf( f_piDataOut, "\n\t}" ); +} + +void IVAS_RTP_Term( + IVAS_RTP *rtp /* i/o : IVAS RTP File reader/writer handle */ +) +{ + if ( NULL != rtp ) + { + if ( rtp->hPack != NULL ) + { + /* Complete the last packet */ + if ( IVAS_RTP_PACK_GetNumFrames( rtp->hPack ) != 0 ) + { + ivas_error error = IVAS_ERR_OK; + uint32_t numFramesInPayload = 0; + + if ( ( error = IVAS_RTP_PACK_GetPacket( rtp->hPack, &rtp->rtpPacket, &numFramesInPayload ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while packing RTP Packet\n", ivas_error_to_string( error ) ); + } + else if ( numFramesInPayload > 0 ) + { + if ( ( error = IvasRtpFile_Write( rtp->hRtpFile, rtp->rtpPacket.buffer, rtp->rtpPacket.length ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while writing RTP packet\n", ivas_error_to_string( error ) ); + } + } + } + IVAS_RTP_PACK_Close( &rtp->hPack ); + } + + if ( rtp->hUnpack != NULL ) + { + IVAS_RTP_UNPACK_Close( &rtp->hUnpack ); + } + + if ( rtp->f_piDataOut != NULL ) + { + fprintf( rtp->f_piDataOut, "\n}\n" ); + fclose( rtp->f_piDataOut ); + rtp->f_piDataOut = NULL; + } + + if ( rtp->hRtpFile != NULL ) + { + IvasRtpFile_Close( &rtp->hRtpFile ); + } + } +} + +ivas_error IVAS_RTP_WRITER_Init( + IVAS_RTP *rtp, /* i/o : IVAS RTP File writer handle */ + const char *outputBitstreamFilename, /* i : RTP Dump filename */ + uint32_t numFramesPerPacket /* i : No. of frames per packet desired */ +) +{ + uint32_t SSRC = ( rand() & 0xFFFF ) | ( (uint32_t) rand() << 16 ); + ivas_error error = IVAS_ERR_OK; + + memset( rtp, 0, sizeof( IVAS_RTP ) ); + + rtp->packCfg.maxFramesPerPacket = numFramesPerPacket; + rtp->rtpPacket.buffer = rtp->packet; + rtp->rtpPacket.capacity = sizeof( rtp->packet ); + + error = IVAS_RTP_PACK_Open( &rtp->hPack, &rtp->packCfg ); + if ( error == IVAS_ERR_OK ) + { + /* Open the output file for RTPDump writing */ + error = IvasRtpFile_Open( outputBitstreamFilename, true, &rtp->hRtpFile ); + if ( error != IVAS_ERR_OK ) + { + return error; + } + + error = IVAS_RTP_PACK_UpdateHeader( rtp->hPack, SSRC, 0, NULL, 0, 0, NULL ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "error in IVAS_RTP_PACK_UpdateHeader(): %d\n", error ); + } + } + + return error; +} + +ivas_error IVAS_RTP_READER_Init( + IVAS_RTP *rtp, /* i/o : IVAS RTP File reader handle */ + const char *inputBitstreamFilename, /* i : Input rtpdump filename */ + const char *piOutputFilename /* i : Output PI data json filename */ +) +{ + ivas_error error = IVAS_ERR_OK; + + memset( rtp, 0, sizeof( IVAS_RTP ) ); + + rtp->unpackCfg.maxFramesPerPacket = IVAS_MAX_FRAMES_PER_RTP_PACKET; + rtp->rtpPacket.buffer = rtp->packet; + rtp->rtpPacket.capacity = sizeof( rtp->packet ); + + error = IVAS_RTP_UNPACK_Open( &rtp->hUnpack, &rtp->unpackCfg ); + if ( error == IVAS_ERR_OK ) + { + error = IvasRtpFile_Open( inputBitstreamFilename, false, &rtp->hRtpFile ); + if ( error != IVAS_ERR_OK ) + { + return error; + } + + if ( piOutputFilename != NULL ) + { + rtp->f_piDataOut = fopen( piOutputFilename, "w" ); + if ( rtp->f_piDataOut == NULL ) + { + fprintf( stderr, "could not open: %s\n", piOutputFilename ); + return IVAS_ERR_FAILED_FILE_OPEN; + } + fprintf( rtp->f_piDataOut, "{\n" ); + } + } + + return error; +} + +ivas_error IVAS_RTP_WriteNextFrame( + IVAS_RTP *rtp, /* i/o : IVAS RTP File writer handle */ + uint8_t *au, /* i : IVAS Compressed AU (Packed frame) */ + int16_t auSizeBits, /* i : Frame size in bits */ + bool isMono, /* i : input was evs(true) or ivas(false) */ + bool forcePacket /* i : force packets with whatever frames pushed so far */ +) +{ + ivas_error error = IVAS_ERR_OK; + uint32_t nProcPiData = 0; + IVAS_DATA_BUFFER packedFrame = { 0, 0, NULL }; + + packedFrame.capacity = ( auSizeBits + 7 ) / 8; + packedFrame.length = ( auSizeBits + 7 ) / 8; + packedFrame.buffer = (uint8_t *) au; + rtp->rtpPacket.length = 0; + + /* Push Encoded Stream to */ + error = IVAS_RTP_PACK_PushFrame( rtp->hPack, + isMono ? IVAS_RTP_EVS : IVAS_RTP_IVAS, +#ifdef RTP_S4_251135_CR26253_0016_REV1 + NULL, +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + &packedFrame ); + if ( error != IVAS_ERR_OK ) + { + return error; + } + + while ( rtp->nWrittenPiData-- > 0 ) + { + PIDATA_TS *piDataTs = &rtp->piData[nProcPiData++]; + if ( ( error = IVAS_RTP_PACK_PushPiData( rtp->hPack, (const IVAS_PIDATA_GENERIC *) &piDataTs->data ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while pushing scene orientation\n", ivas_error_to_string( error ) ); + return error; + } + } + + if ( forcePacket || IVAS_RTP_PACK_GetNumFrames( rtp->hPack ) == rtp->packCfg.maxFramesPerPacket ) + { + uint32_t numFramesInPayload = 0; + + /* Generate RTP Packet */ + if ( ( error = IVAS_RTP_PACK_GetPacket( rtp->hPack, &rtp->rtpPacket, &numFramesInPayload ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while packing RTP Header\n", ivas_error_to_string( error ) ); + return error; + } + + if ( ( error = IvasRtpFile_Write( rtp->hRtpFile, rtp->rtpPacket.buffer, rtp->rtpPacket.length ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while writing RTP packet\n", ivas_error_to_string( error ) ); + return error; + } + } + + return error; +} + +ivas_error IVAS_RTP_ReadNextFrame( + IVAS_RTP *rtp, /* i/o : IVAS RTP File reader handle */ + uint8_t *au, /* o : Read next IVAS Compressed AU (Packed frame) */ + int16_t *auSizeBits, /* o : Reported Frame size in bits */ + uint32_t *rtpTimeStamp, /* o : RTP Timestamp for this frame */ + uint16_t *rtpSequenceNumber, /* o : RTP sequence number for this packet */ + uint32_t *nextPacketRcvTime_ms, /* i/o : Clock indicating packet receive times need in JBM */ + bool *qBit /* o : AMRWB Q bite as indicated in the RTP packet */ +) +{ + ivas_error error = IVAS_ERR_OK; + IVAS_DATA_BUFFER packedFrame; + IVAS_RTP_CODEC codecId = IVAS_RTP_IVAS; + bool isAMRWB_IOmode = false; + + packedFrame.length = 0; + packedFrame.buffer = au; + packedFrame.capacity = ( IVAS_MAX_BITS_PER_FRAME / 8 ); + if ( rtp->numFramesInPacket == 0 ) + { + rtp->rtpPacket.length = 0; + if ( ( error = IvasRtpFile_Read( rtp->hRtpFile, rtp->rtpPacket.buffer, &rtp->rtpPacket.length, rtp->rtpPacket.capacity ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = IVAS_RTP_UNPACK_PushPacket( rtp->hUnpack, &rtp->rtpPacket, + &rtp->numFramesInPacket, &rtp->numPiDataInPacket, + &rtp->remoteRequestBitmap ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "failed to unpack RTP packet error = %s\n", ivas_error_to_string( error ) ); + return error; + } + + rtp->nReadPiData = 0; + rtp->nProcPiData = 0; + + /* Pre-read all PI data */ + while ( rtp->numPiDataInPacket != 0 ) + { + PIDATA_TS *piData = &rtp->piData[rtp->nReadPiData]; + if ( ( error = IVAS_RTP_UNPACK_PullNextPiData( rtp->hUnpack, (IVAS_PIDATA_GENERIC *) &piData->data, sizeof( piData->data ), &piData->timestamp ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "failed to pull PI Data, error = %s\n", ivas_error_to_string( error ) ); + return error; + } + rtp->nReadPiData++; + rtp->numPiDataInPacket--; + } + IVAS_RTP_LogPiData( rtp->f_piDataOut, rtp->piData, rtp->nReadPiData ); + } + +#ifdef RTP_S4_251135_CR26253_0016_REV1 + error = IVAS_RTP_UNPACK_PullFrame( rtp->hUnpack, &codecId, &rtp->srInfo, &packedFrame, auSizeBits, rtpTimeStamp, rtpSequenceNumber, &rtp->speechLostIndicated, &isAMRWB_IOmode ); +#else + error = IVAS_RTP_UNPACK_PullFrame( rtp->hUnpack, &codecId, &packedFrame, auSizeBits, rtpTimeStamp, rtpSequenceNumber, &rtp->speechLostIndicated, &isAMRWB_IOmode ); +#endif + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "failed to pull frame after unpack\n" ); + return error; + } + + rtp->restartNeeded = false; + if ( *auSizeBits == 0 ) + { + /* NO_DATA_FRAME/SPEECH_LOST for IVAS and EVS is indicated by same bits + Do not restart decoder on codec/amrwb mode change in this case */ + } + else + { + rtp->restartNeeded = ( rtp->codecId != codecId ) || + ( codecId == IVAS_RTP_EVS && ( rtp->isAMRWB_IOmode != isAMRWB_IOmode ) ); + + if ( rtp->restartNeeded ) + { + fprintf( stdout, "\nRTP packet codec changed %s -> %s\n", + ( rtp->codecId == IVAS_RTP_EVS ) ? ( rtp->isAMRWB_IOmode ? "AMRWB_IO" : "EVS" ) : "IVAS", + ( codecId == IVAS_RTP_EVS ) ? ( isAMRWB_IOmode ? "AMRWB_IO" : "EVS" ) : "IVAS" ); + } + + rtp->codecId = codecId; + rtp->isAMRWB_IOmode = isAMRWB_IOmode; + } + + *qBit = !rtp->speechLostIndicated; + rtp->numFramesInPacket--; + rtp->numFramesProduced++; + *nextPacketRcvTime_ms += 20; + + return IVAS_ERR_OK; +} diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h new file mode 100644 index 000000000..2a58dc1c9 --- /dev/null +++ b/lib_util/ivas_rtp_file.h @@ -0,0 +1,79 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_RTP_FILE_H +#define IVAS_RTP_FILE_H + +#include "common_api_types.h" +#include "ivas_rtp_api.h" +#include "ivas_rtp_pi_data.h" + +typedef struct IVAS_RTP_FILE *IVAS_RTP_FILE_HANDLE; + +typedef struct +{ + uint8_t packet[NOMINAL_BUFFER_SIZE( IVAS_MAX_FRAMES_PER_RTP_PACKET )]; + PIDATA_TS piData[IVAS_PI_MAX_ID * IVAS_MAX_FRAMES_PER_RTP_PACKET]; + + IVAS_RTP_FILE_HANDLE hRtpFile; + FILE *f_piDataOut; + IVAS_RTP_CODEC codecId; + uint32_t nWrittenPiData; + uint32_t nReadPiData; + uint32_t nProcPiData; + uint32_t numFramesInPacket; + uint32_t numPiDataInPacket; + uint32_t remoteRequestBitmap; + bool speechLostIndicated; + bool restartNeeded; + bool isAMRWB_IOmode; + size_t numFramesProduced; + + IVAS_DATA_BUFFER rtpPacket; + IVAS_RTP_PACK_HANDLE hPack; + IVAS_RTP_UNPACK_HANDLE hUnpack; + IVAS_RTP_PACK_CONFIG packCfg; + IVAS_RTP_UNPACK_CONFIG unpackCfg; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SR_INFO srInfo; +#endif +} IVAS_RTP; + +ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, const char *outputBitstreamFilename, uint32_t numFramesPerPacket ); +ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, const char *inputBitstreamFilename, const char *piOutputFilename ); +void IVAS_RTP_Term( IVAS_RTP *rtp ); +ivas_error IVAS_RTP_WriteNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t auSizeBits, bool isMono, bool forcePacket ); +ivas_error IVAS_RTP_ReadNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t *auSizeBits, uint32_t *rtpTimeStamp, uint16_t *rtpSequenceNumber, uint32_t *nextPacketRcvTime_ms, bool *qBit ); +void IVAS_RTP_LogPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent ); + + +#endif /* IVAS_RTP_FILE_H */ diff --git a/lib_util/ivas_rtp_internal.h b/lib_util/ivas_rtp_internal.h new file mode 100644 index 000000000..f3569ca03 --- /dev/null +++ b/lib_util/ivas_rtp_internal.h @@ -0,0 +1,140 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_RTP_INTERNAL_H +#define IVAS_RTP_INTERNAL_H + +#include "ivas_rtp_api.h" +#include "ivas_rtp_pi_data.h" + +#ifdef IVAS_RTPDUMP + +enum MASK_BITS +{ + MASK_1BIT = 0x1, + MASK_2BIT = 0x3, + MASK_3BIT = 0x7, + MASK_4BIT = 0xF, + MASK_5BIT = 0x1F, + MASK_6BIT = 0x3F, + MASK_7BIT = 0x7F, + MASK_8BIT = 0xFF, + +}; + +/* tables */ +#define NBITS_AEID ( 7 ) +#define NBITS_RT60 ( 5 ) +#define NBITS_DSR ( 6 ) +#define NBITS_DIM ( 4 ) +#define NBITS_ABS ( 2 ) + +#define MASK_AEID ( ( 1u << NBITS_AEID ) - 1 ) +#define MASK_RT60 ( ( 1u << NBITS_RT60 ) - 1 ) +#define MASK_DSR ( ( 1u << NBITS_DSR ) - 1 ) +#define MASK_DIM ( ( 1u << NBITS_DIM ) - 1 ) +#define MASK_ABS ( ( 1u << NBITS_ABS ) - 1 ) + +#define MAX_PI_POSITION_METERS ( 327.68f ) +#define FLOAT_FROM_Q15( q15Val ) ( (float) ( q15Val ) / 32768.0f ) + +extern const float mapDSR[1u << NBITS_DSR]; +extern const float mapRT60[1u << NBITS_RT60]; +extern const float mapRoomDims[1u << NBITS_DIM]; +extern const float mapAbsorbtion[1u << NBITS_ABS]; + +enum IVAS_RTP_HEADER_BITS +{ + + EBYTE_TOC_HEADER_BIT = 0x80, /* Ebyte/ToC indicator H bit, 1 = EByte, 0 = ToC */ + + TOC_HEADER_FOLLOWS = 0x40, /* ToC header byte is followed by another header byte */ + TOC_INDICATE_NO_DATA_AMRWB = 0x3F, /* ToC byte indicates NO_DATA in DTX mode for AMRWB */ + TOC_INDICATE_NO_DATA = 0x0F, /* ToC header byte indicates NO_DATA in DTX mode */ + TOC_INDICATE_IVAS = 0x10, /* ToC header byte indicates IVAS data */ + TOC_INDICATE_EVS = 0x00, /* ToC header byte indicates EVS data */ + TOC_INDICATE_AMRWB = 0x30, /* ToC header byte indicates AMR-WB IO data */ + TOC_INDICATE_ARMWB_Q = 0x20, /* ToC header byte indicates AMR-WB IO lost frame */ + TOC_INDICATE_SR = 0x1E, /* Indicate Split Rendering in ToC bytes */ + + EBYTE_CMR_T_EVS_NB = 0x80, /* Initial E-byte indicating EVS NarrowBand modes */ + EBYTE_CMR_T_EVS_IO = 0x90, /* Initial E-byte indicating EVS AMRWB IO modes */ + EBYTE_CMR_T_EVS_WB = 0xA0, /* Initial E-byte indicating EVS WideBand modes */ + EBYTE_CMR_T_EVS_SWB = 0xB0, /* Initial E-byte indicating EVS SuperWideBand modes */ + EBYTE_CMR_T_EVS_FB = 0xC0, /* Initial E-byte indicating EVS FullBand modes */ + EBYTE_CMR_T_EVS_CA_WB = 0xD0, /* Initial E-byte indicating EVS CA WideBand modes */ + EBYTE_CMR_T_EVS_CA_SWB = 0xE0, /* Initial E-byte indicating EVS CA SuperWideBand modes */ + EBYTE_CMR_T_IVAS = 0xF0, /* Initial E-byte indicating IVAS modes */ + EBYTE_CMR_T_NO_REQ = 0xFF, /* If no bitrate and no CA mode requested for IVAS/EVS */ + + EBYTE_BANDWIDTH_REQUEST = 0x80, /* Subsequent E-byte for Bandwidth Request */ + EBYTE_FORMAT_REQUEST = 0x90, /* Subsequent E-byte for Format Request */ + EBYTE_SUBFORMAT_REQUEST = 0x9F, /* Subsequent E-byte for SubFormat Request */ + EBYTE_PI_INDICATOR = 0xA0, /* Subsequent E-byte for PI Indicator */ + EBYTE_SR_REQUEST = 0xB0, /* Subsequent E-byte for Split Rendering Request */ + + PI_HEADER_PF_LAST = 0x00, /* Last PI header of the Payload in PI Header */ + PI_HEADER_PF_NOT_LAST = 0x80, /* Another PI header follows after this in PI Header */ + PI_HEADER_PM_NOT_LAST = 0x20, /* PI Frame Marker, not the last PI Header in current frame */ + PI_HEADER_PM_LAST = 0x40, /* PI Frame Marker, the last PI Header in current frame */ + PI_HEADER_PM_GENERIC = 0x60, /* PI Frame Marker, Generic applied to all frames */ + + PI_AD_SPEECH_INDICATED = 0x80, /* Audio Description indicate Speech in Audio data */ + PI_AD_MUSIC_INDICATED = 0x40, /* Audio Description indicate Misuc in Audio data */ + PI_AD_AMBIANCE_INDICATED = 0x20, /* Audio Description indicate Ambiance in Audio data */ + PI_AD_EDITABLE_INDICATED = 0x10, /* Audio Description indicate metadata is editable */ + PI_AD_BINAURAL_INDICATED = 0x8, /* Audio Description indicate Stereo stream in Binaural */ + +}; + + +#define ERR_CHECK_RETURN( err ) \ + { \ + if ( ( err ) != IVAS_ERR_OK ) \ + { \ + return ( err ); \ + } \ + } + + +typedef struct +{ + uint32_t size; + uint8_t data[IVAS_PI_MAX_DATA_SIZE]; +} PIDATA_PACKED; + +ivas_error PI_PackData( const IVAS_PIDATA_GENERIC *piData, PIDATA_PACKED *packed, uint8_t pmBits ); +ivas_error PI_UnPackData( uint8_t piDataType, uint32_t piSize, const uint8_t *piDataBuffer, IVAS_PIDATA_GENERIC *piData ); + +#endif /* IVAS_RTPDUMP */ + +#endif /* IVAS_RTP_INTERNAL_H */ diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c new file mode 100644 index 000000000..4e4b11f2a --- /dev/null +++ b/lib_util/ivas_rtp_payload.c @@ -0,0 +1,1854 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ +#include +#include +#include +#include +#include "common_api_types.h" + +#ifdef IVAS_RTPDUMP + +#include "ivas_rtp_internal.h" +#include "ivas_bpool.h" +#include "ivas_queue.h" +#include "ivas_error_utils.h" +#include "mutex.h" + +#define IVAS_MAX_BYTES_PER_FRAME ( ( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3 ) +#define MAX_TOC_PER_FRAME ( 2u ) /* Main ToC Byte + SR-ToC byte */ + +/* Generic RTP Header + Header Extension data structure */ +typedef struct +{ + uint32_t ssrc; /* synchronization source id as negotiated in SDP */ + uint8_t version; /* version of RTP protocol, currently 2 */ + bool padding; /* false = no padding, true = zeoo padded payload (last byte = padding count) */ + bool extension; /* true = extension header is present before payload */ + uint8_t CC; /* if some streams mixed together, CC indicates no. of contributing sources (4 bits) */ + bool marker; /* Marker bit field */ + uint8_t payloadType; /* 7-bit payload type field indicating IVAS */ + uint16_t seqNumber; /* 16-bit sequence number for RTP packets */ + uint32_t timestamp; /* timer ticks @ 16KHz clock corrsponding to 1st frame in the Payload */ + uint32_t CSRC[15]; /* SSRC of contributing Sources for a mixed stream */ + uint16_t extHeaderId; /* extension header ID */ + uint16_t numExtUnits; /* length of the extension data in 32-bit words */ + uint8_t *extData; /* Extension data pointer */ +} RTP_HEADER; + +typedef struct +{ + PIDATA_PACKED piData[IVAS_PI_MAX_ID]; /* pi data per frame */ + uint32_t piDataBitmap; /* bitmap showing available pi */ + uint32_t numPiDataAvailable; /* number of pi data available */ +} PIDATA_FRAME; + +static void initRequests( IVAS_RTP_REQUEST_VALUE *requests ) +{ + requests[IVAS_REQUEST_CODEC].codec = IVAS_RTP_IVAS; + requests[IVAS_REQUEST_BITRATE].bitrate = 0; + requests[IVAS_REQUEST_BANDWIDTH].bandwidth = IVAS_BANDWIDTH_NO_REQ; + requests[IVAS_REQUEST_FORMAT].formatType = IVAS_FMT_NO_REQ; + requests[IVAS_REQUEST_CA_MODE].caMode = IVAS_RTP_CA_NO_REQ; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + requests[IVAS_REQUEST_SUBFORMAT].subFormatType = IVAS_SUBFMT_NO_REQ; + requests[IVAS_REQUEST_SR_CONFIG].srConfig.valid = false; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ +} + +static void initPiDataFrame( PIDATA_FRAME *piDataFrm ) +{ + /* Add NO_PI_DATA by default */ + piDataFrm->numPiDataAvailable = 1; + piDataFrm->piDataBitmap = ( 1u << IVAS_PI_NO_DATA ); + piDataFrm->piData[IVAS_PI_NO_DATA].size = 2; + piDataFrm->piData[IVAS_PI_NO_DATA].data[0] = ( IVAS_PI_NO_DATA ); /* PF/PM populated during final packing */ + piDataFrm->piData[IVAS_PI_NO_DATA].data[1] = 0; /* NO_PI_DATA is 0 bytes */ +} + +typedef struct FRAME_NODE +{ + struct FRAME_NODE *next; /* next node */ + PIDATA_FRAME piDataFrame; /* PI data for this frame */ + uint8_t au[IVAS_MAX_BYTES_PER_FRAME]; /* ivas/evs packed frame (AU) */ + uint8_t toc[MAX_TOC_PER_FRAME]; /* ToC bytes for this frame */ + uint32_t auNumBits; /* Actual frame size in bits */ + uint32_t tocNumBytes; /* valid ToC bytes (1 or 2) */ +} FRAME_NODE; + +static void initFrameNode( FRAME_NODE *node ) +{ + node->next = NULL; + initPiDataFrame( &node->piDataFrame ); + node->auNumBits = 0; + node->tocNumBytes = 0; +} + +struct IVAS_RTP_PACK +{ + mtx_t apilock; /* Lock to handle concurrent API invocation */ + bool amrwbIOMode; /* If EVS is an AMRWB-IO mode frame */ + RTP_HEADER header; /* RTP Header Params */ + BPOOL_HANDLE packNodePool; /* Buffer pool to allocate FRAME_NODEs */ + PIDATA_FRAME piDataCache; /* temporary cache for PI data pushed before any frame is available in Queue */ + IVAS_RTP_PACK_CONFIG initConfig; /* Initial Configuration for Unpacker */ + IVAS_RTP_REQUEST_VALUE requests[IVAS_REQUEST_MAX]; /* Requests Storage */ + QUEUE_HANDLE frameQ; /* frames queue for FRAME_NODEs */ +}; + +typedef struct +{ + IVAS_RTP_CODEC codecId; /* Coded frame type (IVAS/EVS) */ + uint32_t auNumBits; /* Actual frame size in bits */ + bool speechLostIndicated; /* Speech Lost indicated */ + bool isAMRWB_IOmode; /* EVS frame is AMRWB_IO */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SR_INFO srInfo; /* Split Rendering Info */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ +} TOC_INFO; + +typedef struct PIDATA_NODE +{ + struct PIDATA_NODE *next; /* next node is first element */ + PIDATA data; /* unpacked pi data per frame */ + uint32_t timestamp; /* rtp timestamp of this frame */ +} PIDATA_NODE; + +typedef struct UNPACK_NODE +{ + struct UNPACK_NODE *next; /* next node is first element */ + uint8_t au[IVAS_MAX_BYTES_PER_FRAME]; /* ivas/evs packed frame (AU) */ + TOC_INFO toc; /* unpacked ToC information */ + uint32_t timestamp; /* timestamp of this frame */ + uint16_t seqNumber; /* sequence number of the packet */ +} UNPACK_NODE; + +struct IVAS_RTP_UNPACK +{ + mtx_t apilock; /* Lock to handle concurrent API invocation */ + size_t maxNumberOfFrames; + size_t maxNumberOfPiData; + RTP_HEADER header; + BPOOL_HANDLE unpackNodePool; + BPOOL_HANDLE piDataPool; + IVAS_RTP_UNPACK_CONFIG initConfig; + IVAS_RTP_REQUEST_VALUE requests[IVAS_REQUEST_MAX]; + uint32_t numPiDataAvailable; /* number of pi data available */ + QUEUE_HANDLE frameQ; /* frame queue */ + QUEUE_HANDLE piDataQ; /* pi data queue */ +}; + +static const uint32_t ivasFrameSizeInBits[] = { + 264, 328, 488, 640, 960, 1280, 1600, 1920, 2560, 3200, 3840, 5120, 7680, 10240, 0, 104 +}; + +static const uint32_t evsFrameSizeInBits[] = { + 56, 144, 160, 192, 264, 328, 488, 640, 960, 1280, 1920, 2560, 48 +}; + +static const uint32_t amrWBIOFrameSizeInBits[] = { + 132, 177, 253, 285, 317, 365, 397, 461, 477, 35 +}; + + +/* Update the RTP Header structure */ +ivas_error IVAS_RTP_PACK_UpdateHeader( + IVAS_RTP_PACK_HANDLE hPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ + uint8_t numCC, /* i : numCC indicates no. of contributing sources */ + uint32_t *csrc, /* i : SSRCs of contributing Sources for a mixed stream */ + uint16_t extHeaderId, /* i : extension header ID */ + uint16_t numExtensionBytes, /* i : length of the extension data */ + uint8_t *extData /* i : extension data pointer */ +) +{ + RTP_HEADER *header = &hPack->header; + + if ( numCC > 15 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "CC must be less than 16" ); + } + + header->ssrc = ssrc; + header->CC = numCC; + memcpy( header->CSRC, csrc, numCC & 0xF ); + + if ( ( numExtensionBytes > 0 ) && ( extData != NULL ) ) + { + header->extHeaderId = extHeaderId; + header->extData = realloc( header->extData, numExtensionBytes ); + if ( header->extData == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "failed to allocate extdata" ); + } + memcpy( header->extData, extData, numExtensionBytes ); + header->extension = true; + header->numExtUnits = numExtensionBytes / sizeof( uint32_t ); + } + else + { + header->numExtUnits = 0; + header->extension = false; + } + + return IVAS_ERR_OK; +} + +static void InitRtpHeader( + RTP_HEADER *header /* RTP header structure */ +) +{ + time_t t; + memset( header, 0, sizeof( *header ) ); + srand( (uint32_t) time( &t ) ); + header->version = 2; + header->seqNumber = rand() & 0xFFFF; +} + +static ivas_error PackRtpHeader( + RTP_HEADER *header, + IVAS_DATA_BUFFER *buf ) +{ + uint32_t nBytes = 0; + uint8_t CC = header->CC & MASK_4BIT; + uint32_t *CSRC = header->CSRC; + bool extension = header->extension && ( NULL != header->extData ); + uint32_t extensionLength = header->extension ? ( 1 + header->numExtUnits ) : 0; /* in u32 words */ + uint32_t packedLength = 12 + ( 4 * CC ) + ( 4 * extensionLength ); + + buf->length = 0; + if ( packedLength > buf->capacity ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient output buffer for RTP header packing" ); + } + + /* + +---+---+---+---+---+---+---+---+ + | V | V | P | X | CC (4 - bits) | + +---+---+---+---+---+---+---+---+ + */ + buf->buffer[nBytes++] = ( header->version << 6 ) | + ( (uint8_t) header->padding << 5 ) | + ( (uint8_t) extension << 4 ) | + CC; + /* + +---+---+---+---+---+---+---+---+ + | M | PT (7 - bits) | + +---+---+---+---+---+---+---+---+ + */ + buf->buffer[nBytes++] = ( (uint8_t) header->marker << 7 ) | + ( header->payloadType & MASK_7BIT ); + /* + +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + | SEQUENCE NUMBER (16 bit) | + +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + */ + buf->buffer[nBytes++] = (uint8_t) ( header->seqNumber >> 8 ); + buf->buffer[nBytes++] = (uint8_t) ( header->seqNumber ); + + /* Timestamp (32-bit) */ + buf->buffer[nBytes++] = (uint8_t) ( header->timestamp >> 24 ); + buf->buffer[nBytes++] = (uint8_t) ( header->timestamp >> 16 ); + buf->buffer[nBytes++] = (uint8_t) ( header->timestamp >> 8 ); + buf->buffer[nBytes++] = (uint8_t) ( header->timestamp >> 0 ); + + /* SSRC (32-bit) */ + buf->buffer[nBytes++] = (uint8_t) ( header->ssrc >> 24 ); + buf->buffer[nBytes++] = (uint8_t) ( header->ssrc >> 16 ); + buf->buffer[nBytes++] = (uint8_t) ( header->ssrc >> 8 ); + buf->buffer[nBytes++] = (uint8_t) ( header->ssrc >> 0 ); + + /* CSRC Identifiers */ + while ( CC ) + { + /* CSRC[n] (32-bit) */ + uint32_t id = *CSRC++; + buf->buffer[nBytes++] = (uint8_t) ( id >> 24 ); + buf->buffer[nBytes++] = (uint8_t) ( id >> 16 ); + buf->buffer[nBytes++] = (uint8_t) ( id >> 8 ); + buf->buffer[nBytes++] = (uint8_t) ( id >> 0 ); + CC--; + } + + if ( extension ) + { + buf->buffer[nBytes++] = (uint8_t) ( header->extHeaderId >> 8 ); + buf->buffer[nBytes++] = (uint8_t) ( header->extHeaderId >> 0 ); + buf->buffer[nBytes++] = (uint8_t) ( header->numExtUnits >> 8 ); + buf->buffer[nBytes++] = (uint8_t) ( header->numExtUnits >> 0 ); + + memcpy( &buf->buffer[nBytes], header->extData, header->numExtUnits * 4 ); + nBytes += header->numExtUnits; + } + + buf->length = nBytes; + return IVAS_ERR_OK; +} + +static void UpdateRtpHeader( + RTP_HEADER *header, /* RTP header structure */ + uint32_t timestampOffset /* Timestamp offset @ 16KHz clock for next frame */ +) +{ + header->seqNumber++; + header->timestamp += timestampOffset; +} + +static ivas_error UnpackRtpPacket( + const IVAS_DATA_BUFFER *packet, /* Input buffer with RTP Packet */ + RTP_HEADER *header, /* RTP header structure */ + uint32_t *numHeaderBytes /* No. of rtp header bytes */ +) +{ + uint32_t n = 0, nByte = 0, expectedSize = 12; + uint8_t byte; + + if ( packet->length < expectedSize ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Insufficient input buffer for RTP header unpacking" ); + } + + /* + +---+---+---+---+---+---+---+---+ + | V | V | P | X | CC (4 - bits) | + +---+---+---+---+---+---+---+---+ + */ + byte = packet->buffer[nByte++]; + header->version = ( byte >> 6 ) & MASK_2BIT; + header->padding = ( byte >> 5 ) & MASK_1BIT; + header->extension = ( byte >> 4 ) & MASK_1BIT; + header->CC = ( byte & MASK_4BIT ); + + /* + +---+---+---+---+---+---+---+---+ + | M | PT (7 - bits) | + +---+---+---+---+---+---+---+---+ + */ + byte = packet->buffer[nByte++]; + header->marker = ( byte >> 7 ) & MASK_1BIT; + header->payloadType = byte & MASK_7BIT; + + /* + +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + | SEQUENCE NUMBER (16 bit) | + +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + */ + header->seqNumber = (uint16_t) packet->buffer[nByte++] << 8; + header->seqNumber |= (uint16_t) packet->buffer[nByte++] << 8; + + /* Timestamp (32-bit) */ + header->timestamp = ( (uint32_t) packet->buffer[nByte++] << 24 ); + header->timestamp |= ( (uint32_t) packet->buffer[nByte++] << 16 ); + header->timestamp |= ( (uint32_t) packet->buffer[nByte++] << 8 ); + header->timestamp |= ( (uint32_t) packet->buffer[nByte++] ); + + /* SSRC (32-bit) */ + header->ssrc = ( (uint32_t) packet->buffer[nByte++] << 24 ); + header->ssrc |= ( (uint32_t) packet->buffer[nByte++] << 16 ); + header->ssrc |= ( (uint32_t) packet->buffer[nByte++] << 8 ); + header->ssrc |= ( (uint32_t) packet->buffer[nByte++] ); + + expectedSize += ( header->CC ) * 4 + ( header->extension ? 4 : 0 ); + if ( packet->length < expectedSize ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "CC indicated but insufficient input buffer" ); + } + + /* CSRC Identifiers */ + for ( n = 0; n < header->CC; n++ ) + { + /* CSRC[n] (32-bit) */ + header->CSRC[n] = ( (uint32_t) packet->buffer[nByte++] << 24 ); + header->CSRC[n] |= ( (uint32_t) packet->buffer[nByte++] << 16 ); + header->CSRC[n] |= ( (uint32_t) packet->buffer[nByte++] << 8 ); + header->CSRC[n] |= ( (uint32_t) packet->buffer[nByte++] ); + } + + if ( header->extension ) + { + header->extHeaderId = ( (uint32_t) packet->buffer[nByte++] << 8 ); + header->extHeaderId |= ( (uint32_t) packet->buffer[nByte++] ); + header->numExtUnits = ( (uint32_t) packet->buffer[nByte++] << 8 ); + header->numExtUnits |= ( (uint32_t) packet->buffer[nByte++] ); + + expectedSize += header->numExtUnits * 4; + if ( packet->length < expectedSize ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Extension Header indicated but insufficient input buffer" ); + } + + header->extData = realloc( header->extData, header->numExtUnits * 4 ); + if ( header->extData == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "failed to allocate extdata" ); + } + memcpy( header->extData, &packet->buffer[nByte], header->numExtUnits * 4 ); + nByte += header->numExtUnits * 4; + } + + *numHeaderBytes = nByte; + return IVAS_ERR_OK; +} + +static ivas_error getBitrateFromCodecAndFrameSize( + IVAS_RTP_CODEC codecId, + uint32_t frameLengthBytes, + uint32_t *bitrateKbps, + uint32_t *frameLenInBits, + uint8_t *tocByte, + bool *isAmrwbIOMode ) +{ + size_t n; + *bitrateKbps = 0; + *frameLenInBits = 0; + if ( codecId == IVAS_RTP_IVAS ) + { + /* Validate the framelength is supported for ivas frame */ + for ( n = 0; n < sizeof( ivasFrameSizeInBits ) / sizeof( ivasFrameSizeInBits[0] ); n++ ) + { + if ( ivasFrameSizeInBits[n] == frameLengthBytes * 8 ) + { + *bitrateKbps = ( frameLengthBytes * IVAS_NUM_FRAMES_PER_SEC * 8 ); /* bitrate in kbps */ + *frameLenInBits = frameLengthBytes * 8; /* frame length in bits */ + *tocByte = TOC_INDICATE_IVAS | ( n & MASK_4BIT ); /* bitrate index */ + return IVAS_ERR_OK; + } + } + return IVAS_ERR_INVALID_BITRATE; + } + else + { + /* Try if frameLength is a supported EVS frame length */ + for ( n = 0; n < sizeof( evsFrameSizeInBits ) / sizeof( evsFrameSizeInBits[0] ); n++ ) + { + if ( evsFrameSizeInBits[n] == frameLengthBytes * 8 ) + { + *bitrateKbps = ( frameLengthBytes * IVAS_NUM_FRAMES_PER_SEC * 8 ); /* bitrate in kbps */ + *frameLenInBits = frameLengthBytes * 8; /* frame length in bits */ + *tocByte = TOC_INDICATE_EVS | ( n & MASK_4BIT ); /* bitrate index */ + return IVAS_ERR_OK; + } + } + /* Try if frameLength is a supported AMRWB-IO frame length */ + for ( n = 0; n < sizeof( amrWBIOFrameSizeInBits ) / sizeof( amrWBIOFrameSizeInBits[0] ); n++ ) + { + uint32_t lengthInBits = amrWBIOFrameSizeInBits[n]; + if ( ( ( lengthInBits + 7 ) / 8 ) == frameLengthBytes ) + { + *isAmrwbIOMode = true; + *bitrateKbps = ( lengthInBits * IVAS_NUM_FRAMES_PER_SEC ); /* bitrate in kbps */ + *frameLenInBits = lengthInBits; /* frame length in bits */ + *tocByte = TOC_INDICATE_AMRWB | ( n & MASK_4BIT ); /* bitrate index */ + return IVAS_ERR_OK; + } + } + return IVAS_ERR_INVALID_BITRATE; + } +} + +ivas_error IVAS_RTP_PACK_Open( + IVAS_RTP_PACK_HANDLE *phPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + const IVAS_RTP_PACK_CONFIG *config /* i : pointer to initial config for RTP Packer */ +) +{ + ivas_error error; + IVAS_RTP_PACK_HANDLE hPack; + uint32_t numFramesPerPacket = ( config->maxFramesPerPacket == 0 ) ? IVAS_MAX_FRAMES_PER_RTP_PACKET : config->maxFramesPerPacket; + + if ( phPack == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( numFramesPerPacket > IVAS_MAX_FRAMES_PER_RTP_PACKET ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Max frame per packet exeeds %d", IVAS_MAX_FRAMES_PER_RTP_PACKET ); + } + + *phPack = NULL; + if ( ( hPack = (IVAS_RTP_PACK_HANDLE) calloc( 1, sizeof( struct IVAS_RTP_PACK ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS rtppack handle" ); + } + + error = BPOOL_Create( &hPack->packNodePool, sizeof( FRAME_NODE ), numFramesPerPacket * 4 ); + ERR_CHECK_RETURN( error ); + + error = QUEUE_Create( &hPack->frameQ ); + ERR_CHECK_RETURN( error ); + + mtx_init( &hPack->apilock, 0 ); + hPack->initConfig = *config; + initRequests( hPack->requests ); + InitRtpHeader( &hPack->header ); + initPiDataFrame( &hPack->piDataCache ); + *phPack = hPack; + return IVAS_ERR_OK; +} + +/* Close and free an existing instance of rtp packer */ +void IVAS_RTP_PACK_Close( + IVAS_RTP_PACK_HANDLE *phPack /* i/o : pointer to an IVAS rtp packer handle to be closed */ +) +{ + IVAS_RTP_PACK_HANDLE hPack; + + /* Free all memory */ + if ( phPack == NULL || *phPack == NULL ) + { + return; + } + + hPack = *phPack; + QUEUE_Destroy( &hPack->frameQ ); + mtx_destroy( &hPack->apilock ); + BPOOL_Destroy( &hPack->packNodePool ); + free( hPack->header.extData ); + free( hPack ); + *phPack = NULL; +} + +ivas_error IVAS_RTP_PACK_PushRemoteRequest( + IVAS_RTP_PACK_HANDLE hPack, /* i/o : IVAS rtp packer handle */ + IVAS_RTP_REQUEST_TYPE reqType, /* i : remote request type */ + IVAS_RTP_REQUEST_VALUE reqValue /* i : value of the requested type */ +) +{ + if ( reqType < 0 || reqType >= IVAS_REQUEST_MAX ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid request key provided" ); + } + + /* Sanity on API */ + switch ( reqType ) + { + case IVAS_REQUEST_CODEC: + { + uint32_t codec = reqValue.codec; + if ( codec != IVAS_RTP_IVAS && codec != IVAS_RTP_EVS ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported codec id provided" ); + } + } + break; + case IVAS_REQUEST_BITRATE: + { + uint32_t bitrate = reqValue.bitrate; + if ( bitrate < 5900 || bitrate > 512000 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported bitrate provided" ); + } + } + break; + case IVAS_REQUEST_BANDWIDTH: + { + uint32_t bandwidth = reqValue.bandwidth; + if ( bandwidth > IVAS_BANDWIDTH_NO_REQ ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported bandwidth provided" ); + } + } + break; + case IVAS_REQUEST_FORMAT: + { + uint32_t format = reqValue.formatType; + if ( format > IVAS_FMT_NO_REQ ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported format provided" ); + } + } + break; + case IVAS_REQUEST_CA_MODE: + { + uint32_t caMode = reqValue.caMode; + if ( caMode > IVAS_RTP_CA_NO_REQ ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported channel aware mode provided" ); + } + } + break; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case IVAS_REQUEST_SUBFORMAT: + { + uint32_t subFormat = reqValue.subFormatType; + if ( subFormat > IVAS_SUBFMT_NO_REQ ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported subformat provided" ); + } + } + break; + case IVAS_REQUEST_SR_CONFIG: + { + IVAS_RTP_SPLITRENDER srConfig = reqValue.srConfig; + if ( srConfig.reserved != 0 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported reserved bits in SR config provided" ); + } + } + break; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + default: + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported request type" ); + } + + hPack->requests[reqType] = reqValue; + + return IVAS_ERR_OK; +} + +static bool isAmrWBIOMode( uint32_t bitrate, uint32_t *idx ) +{ + size_t n; + *idx = 0; + for ( n = 0; n < sizeof( amrWBIOFrameSizeInBits ) / sizeof( amrWBIOFrameSizeInBits[0] ); n++ ) + { + if ( bitrate == ( amrWBIOFrameSizeInBits[n] * IVAS_NUM_FRAMES_PER_SEC ) ) + { + *idx = n; + return true; + } + } + return false; +} + +static uint32_t getBitrateIdx( const uint32_t *table, uint32_t tableLen, uint32_t bitrate ) +{ + size_t n, idx = 0; + + for ( n = 0; n < tableLen; n++ ) + { + if ( bitrate > ( table[n] * IVAS_NUM_FRAMES_PER_SEC ) ) + { + idx = n; + } + else + { + return idx; + } + } + return idx; +} + +static void packEBytes( + IVAS_RTP_PACK_HANDLE hPack, /* i/o : IVAS rtp packer handle */ + bool piDataPresent, /* i : Signals if PI data present */ + size_t maxNumEBytes, /* i : max capacity of eByte buffer */ + uint8_t *eByte, /* o : output buffer for E-Bytes */ + size_t *nBytesWritten /* o : max capacity of eByte buffer */ +) +{ + /* Initial E-byte structure + * 0 1 2 3 4 5 6 7 + * +-+-+-+-+-+-+-+-+ + * |H|T|T|T| BR | + * +-+-+-+-+-+-+-+-+ + */ + uint32_t nByte = 0; + uint8_t T = EBYTE_CMR_T_IVAS; /* IVAS */ + uint8_t BR = 0; + + IVAS_RTP_CODEC codec = hPack->requests[IVAS_REQUEST_CODEC].codec; + IVAS_RTP_BANDWIDTH bandwidth = hPack->requests[IVAS_REQUEST_BANDWIDTH].bandwidth; + uint32_t bitrate = hPack->requests[IVAS_REQUEST_BITRATE].bitrate; + uint32_t bitrateIdx = 0; + + *nBytesWritten = 0; + + if ( codec == IVAS_RTP_EVS ) + { + /* If requesting EVS/AMRWB IO from farend, only Initial E-byte present */ + IVAS_RTP_CA_MODE caMode = hPack->requests[IVAS_REQUEST_CA_MODE].caMode; + + if ( caMode != IVAS_RTP_CA_NO_REQ ) + { + T = ( bandwidth == IVAS_BANDWIDTH_SWB ) ? EBYTE_CMR_T_EVS_CA_SWB : EBYTE_CMR_T_EVS_CA_WB; + BR = caMode & MASK_3BIT; /* only 8 valid values */ + if ( nByte < maxNumEBytes ) + { + eByte[nByte++] = ( T | BR ); + } + } + else if ( bitrate > 0 && isAmrWBIOMode( bitrate, &bitrateIdx ) ) + { + /* AMR WB IO Mode */ + T = EBYTE_CMR_T_EVS_IO; + BR = (uint8_t) bitrateIdx & MASK_4BIT; + if ( nByte < maxNumEBytes ) + { + eByte[nByte++] = ( T | BR ); + } + } + else if ( bitrate > 0 ) + { + /* EVS Modes */ + bitrate = ( bitrate > 128000 ) ? 128000 : bitrate; + bitrate = ( bitrate < 5900 ) ? 5900 : bitrate; + bitrateIdx = getBitrateIdx( evsFrameSizeInBits, sizeof( evsFrameSizeInBits ) / sizeof( evsFrameSizeInBits[0] ), bitrate ); + BR = (uint8_t) bitrateIdx & MASK_4BIT; + + /* If a bandwidth choice cannot be signalled for a given bitrate + preference is given to bitrate choice, bandwidth req is modified */ + switch ( bandwidth ) + { + case IVAS_BANDWIDTH_NB: + T = ( bitrate <= 24400u ) ? EBYTE_CMR_T_EVS_NB : EBYTE_CMR_T_EVS_SWB; + break; + case IVAS_BANDWIDTH_WB: + T = EBYTE_CMR_T_EVS_WB; + break; + case IVAS_BANDWIDTH_SWB: + T = ( bitrate >= 9600u ) ? EBYTE_CMR_T_EVS_SWB : EBYTE_CMR_T_EVS_WB; + break; + case IVAS_BANDWIDTH_FB: + T = ( bitrate >= 16400u ) ? EBYTE_CMR_T_EVS_FB : EBYTE_CMR_T_EVS_WB; + break; + default: /*IVAS_BANDWIDTH_NO_REQ */ + T = ( bitrate >= 9600u ) ? EBYTE_CMR_T_EVS_SWB : EBYTE_CMR_T_EVS_WB; + break; + } + if ( nByte < maxNumEBytes ) + { + eByte[nByte++] = ( T | BR ); + } + } + else if ( piDataPresent ) + { + /* Send an initial E-byte to allow for subsequent PI indication E-byte */ + if ( nByte < maxNumEBytes ) + { + eByte[nByte++] = EBYTE_CMR_T_NO_REQ; + } + } + } + else + { + /* Requesting IVAS from farend, Subsequent E-byte indicate BW, CFR, SR */ + IVAS_RTP_FORMAT format = hPack->requests[IVAS_REQUEST_FORMAT].formatType; + bool isBandwidthProvided = ( bandwidth != IVAS_BANDWIDTH_NO_REQ && bandwidth != IVAS_BANDWIDTH_NB ); + bool isFormatProvided = ( format != IVAS_FMT_NO_REQ ); + bool isSubFormatProvided = false; + bool isSRConfigProvided = false; + +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SUBFORMAT subFormat = hPack->requests[IVAS_REQUEST_SUBFORMAT].subFormatType; + IVAS_RTP_SPLITRENDER srConfig = hPack->requests[IVAS_REQUEST_SR_CONFIG].srConfig; + + isSubFormatProvided = ( subFormat != IVAS_SUBFMT_NO_REQ ); + isSRConfigProvided = srConfig.valid; +#endif + + /* Initial E-Byte only sent if either bitrate requested or subsequent E-byte is requested */ + if ( !( ( bitrate > 0 ) || isBandwidthProvided || isFormatProvided || + isSubFormatProvided || isSRConfigProvided || piDataPresent ) ) + { + return; + } + + if ( bitrate > 0 ) + { + /* Initial E-Byte */ + bitrate = ( bitrate > 512000 ) ? 512000 : bitrate; + bitrate = ( bitrate < 13200 ) ? 13200 : bitrate; + bitrateIdx = getBitrateIdx( ivasFrameSizeInBits, sizeof( ivasFrameSizeInBits ) / sizeof( ivasFrameSizeInBits[0] ), bitrate ); + BR = (uint8_t) bitrateIdx & MASK_4BIT; + if ( nByte < maxNumEBytes ) + { + eByte[nByte++] = ( EBYTE_CMR_T_IVAS | BR ); + } + } + else + { + if ( nByte < maxNumEBytes ) + { + eByte[nByte++] = EBYTE_CMR_T_NO_REQ; + } + } + + /* Subsequent E-bytes - Bandwidth Request */ + if ( isBandwidthProvided && nByte < maxNumEBytes ) + { + uint8_t bw = ( bandwidth - IVAS_BANDWIDTH_WB ) & MASK_2BIT; + eByte[nByte++] = ( EBYTE_BANDWIDTH_REQUEST | bw ); + } + + /* Subsequent E-bytes - Coded Format Request */ + if ( ( isFormatProvided || isSubFormatProvided ) && nByte < maxNumEBytes ) + { + uint8_t fmtEByte = ( EBYTE_FORMAT_REQUEST | ( (uint8_t) format & MASK_3BIT ) ); + eByte[nByte++] = isSubFormatProvided ? EBYTE_SUBFORMAT_REQUEST : fmtEByte; + } +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( isSubFormatProvided && nByte < maxNumEBytes ) + { + eByte[nByte++] = ( (uint8_t) subFormat & MASK_6BIT ); /* Requested Coded subFormat */ + } + /* Subsequent E-bytes - Split Renderer Configuration Request */ + if ( isSRConfigProvided && nByte < maxNumEBytes ) + { + eByte[nByte++] = EBYTE_SR_REQUEST | + ( (uint8_t) srConfig.diegetic << 3 ) | ( (uint8_t) srConfig.yaw << 2 ) | + ( (uint8_t) srConfig.pitch << 1 ) | ( (uint8_t) srConfig.roll << 0 ); + } +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + } + + /* Final E-byte is the PI Indicator E-Byte */ + if ( piDataPresent && ( nByte < maxNumEBytes ) ) + { + eByte[nByte++] = EBYTE_PI_INDICATOR; /* PI Indication */ + } + + *nBytesWritten = nByte; +} + + +#ifdef RTP_S4_251135_CR26253_0016_REV1 +static ivas_error getSRToCByte( + IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info */ + uint32_t bitrateKbps, /* i : Bitrate in kbps */ + uint8_t *tocByte /* o : toc byte 2 */ +) +{ + uint8_t bitIdx, codecId, digetic; + if ( bitrateKbps < 256000 || bitrateKbps > 512000 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported bitrate for SR" ); + } + + bitIdx = ( ( bitrateKbps / 128000u ) - 1 ) & MASK_2BIT; + codecId = (uint8_t) srInfo->codec; + digetic = srInfo->diegetic ? 1 : 0; + + *tocByte = ( digetic << 6 ) | ( codecId << 5 ) | ( bitIdx << 3 ); + + return IVAS_ERR_OK; +} +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + +static void addPackedPiDataToFrame( PIDATA_FRAME *piDataFrm, const PIDATA_PACKED *packedPiData, uint32_t piDataType ) +{ + piDataFrm->piData[piDataType].size = packedPiData->size; + memcpy( piDataFrm->piData[piDataType].data, packedPiData->data, packedPiData->size ); + + /* Indicate th PI data type presense in bitmap, If the same pi data type is + already pushed for this frame, it is overwritten with the newer data */ + if ( !( piDataFrm->piDataBitmap & ( 1u << piDataType ) ) ) + { + piDataFrm->piDataBitmap |= ( 1u << piDataType ); + piDataFrm->numPiDataAvailable++; + } + + /* Atleast one valid PI data is now pushed for this frame, clear No PI data + for this frame */ + if ( piDataFrm->piDataBitmap & ( 1u << IVAS_PI_NO_DATA ) ) + { + piDataFrm->piDataBitmap &= ~( 1u << IVAS_PI_NO_DATA ); + piDataFrm->numPiDataAvailable--; + } +} + +ivas_error IVAS_RTP_PACK_PushFrame( + IVAS_RTP_PACK_HANDLE hPack, /* i/o : IVAS rtp packer handle */ + IVAS_RTP_CODEC codecId, /* i : Codec type (IVAS/EVS) */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + const IVAS_DATA_BUFFER *frameBuffer /* i : packed frame bitstream for IVAS/EVS */ +) +{ + ivas_error error = IVAS_ERR_OK; + uint32_t bitrate = 0; + uint32_t frameLengthInBits = 0; + uint8_t tocByte = 0; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + uint8_t tocByte1 = 0; +#endif + FRAME_NODE *node = NULL; + PIDATA_FRAME *piDataFrame = &hPack->piDataCache; + uint32_t piDataType = 0; + + if ( frameBuffer == NULL || frameBuffer->length == 0 ) + { + /* Indicates a NO_DATA_FRAME in case of DTX mode */ + tocByte = ( hPack->amrwbIOMode ) ? TOC_INDICATE_NO_DATA_AMRWB : TOC_INDICATE_NO_DATA; + } +#ifdef RTP_S4_251135_CR26253_0016_REV1 + else if ( srInfo != NULL && srInfo->valid ) + { + tocByte = TOC_INDICATE_SR; + error = getSRToCByte( srInfo, bitrate, &tocByte1 ); + ERR_CHECK_RETURN( error ); + } +#endif + else + { + error = getBitrateFromCodecAndFrameSize( codecId, frameBuffer->length, &bitrate, &frameLengthInBits, &tocByte, &hPack->amrwbIOMode ); + ERR_CHECK_RETURN( error ); + } + + /* Allocate a new frame node for this frame */ + error = BPOOL_GetBuffer( hPack->packNodePool, (void **) &node ); + ERR_CHECK_RETURN( error ); + + initFrameNode( node ); + + /* Set ToC byte & frame */ + node->toc[node->tocNumBytes++] = tocByte; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( srInfo != NULL && srInfo->valid ) + { + node->toc[node->tocNumBytes++] = tocByte1; + } +#endif + + node->auNumBits = frameLengthInBits; + if ( frameBuffer != NULL ) + { + memcpy( node->au, frameBuffer->buffer, frameBuffer->length ); + } + + /* If some Pi data is is Cache add to Frame Node's associated Pi Data */ + mtx_lock( &hPack->apilock ); /* Lock to prevent access to shared cache */ + if ( piDataFrame->numPiDataAvailable ) + { + uint32_t bitmap = piDataFrame->piDataBitmap; + for ( piDataType = 0; piDataType < 32 && ( bitmap != 0 ); piDataType++ ) + { + uint32_t mask = ( 1u << piDataType ); + if ( bitmap & mask ) + { + bitmap &= ~mask; /* Mask out this pi type to indicate processed */ + addPackedPiDataToFrame( &node->piDataFrame, &piDataFrame->piData[piDataType], piDataType ); + } + } + initPiDataFrame( piDataFrame ); /* Reset Cache */ + } + mtx_unlock( &hPack->apilock ); + + /* Add to frames FiFo */ + QUEUE_Push( hPack->frameQ, (NODE *) node ); + + return IVAS_ERR_OK; +} + +uint32_t IVAS_RTP_PACK_GetNumFrames( + IVAS_RTP_PACK_HANDLE hPack /* i/o : IVAS rtp packer handle */ +) +{ + uint32_t nFrames = 0; + if ( hPack ) + { + nFrames = QUEUE_Size( hPack->frameQ ); + } + return nFrames; +} + +/* Push single PI data to rtp packer + * + * Provide PI data for a current RTP Payload. All PI data is locally cached in the packer + * and set to the rtp packet with policy defined in initial configuration during call to + * IVAS_RTP_PACK_GetPacket. + * + */ +ivas_error IVAS_RTP_PACK_PushPiData( + IVAS_RTP_PACK_HANDLE hPack, /* i/o : IVAS rtp packer handle */ + const IVAS_PIDATA_GENERIC *data /* i : pointer to the PIData stucture */ +) +{ + ivas_error error = IVAS_ERR_OK; + PIDATA_PACKED packedPiData; + + if ( data == NULL || + data->piDataType >= IVAS_PI_NO_DATA || /* NO_PI_DATA cannot be provided by user, it is generated in packing */ + data->size > sizeof( PIDATA ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Wrong PI Data provided" ); + } + + error = PI_PackData( data, &packedPiData, 0 ); + ERR_CHECK_RETURN( error ); + + mtx_lock( &hPack->apilock ); /* Lock to prevent access to shared cache */ + { + FRAME_NODE *node = (FRAME_NODE *) QUEUE_Back( hPack->frameQ ); + /* use cache if no frame in Queue to associate PI data */ + PIDATA_FRAME *piDataFrm = ( node != NULL ) ? &node->piDataFrame : &hPack->piDataCache; + addPackedPiDataToFrame( piDataFrm, &packedPiData, data->piDataType ); + } + mtx_unlock( &hPack->apilock ); + + return IVAS_ERR_OK; +} + +#define WRITE_BYTE_PAYLOAD_OR_EXIT( payload, byte ) \ + if ( payload->length < payload->capacity ) \ + { \ + uint8_t _byte = ( byte ); \ + payload->buffer[payload->length++] = _byte; \ + } \ + else \ + { \ + error = IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient memory to write RTP Payload" ); \ + goto err_exit; \ + } + +ivas_error IVAS_RTP_PACK_GetPayload( + IVAS_RTP_PACK_HANDLE hPack, /* i/o : IVAS rtp packer handle */ + IVAS_DATA_BUFFER *payload, /* o : encapsulated rtp payload */ + uint32_t *numFramesInPayload /* o : no. of frames in payload */ +) +{ + uint32_t n = 0, numFrame = 0; + ivas_error error = IVAS_ERR_OK; + uint32_t numPiDataPresent = 0; + FRAME_NODE *availableFrameNodes[IVAS_MAX_FRAMES_PER_RTP_PACKET]; + size_t numEBytes = 0; + + if ( payload == NULL ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Output data buffer is NULL" ); + } + + /* Calculate number of frames to pack in this payload */ + numFrame = QUEUE_Size( hPack->frameQ ); + numFrame = ( numFrame > hPack->initConfig.maxFramesPerPacket ) ? hPack->initConfig.maxFramesPerPacket : numFrame; + *numFramesInPayload = numFrame; /* numFrames in Packet */ + + /* Collect all the frame nodes from FiFo */ + for ( n = 0; n < numFrame; n++ ) + { + FRAME_NODE *node = (FRAME_NODE *) QUEUE_Pop( hPack->frameQ ); + if ( node == NULL ) + { + assert( 0 ); /* catastrophic error, implementation issue somewhere */ + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "NULL found in frame nodes" ); + } + /* Calculate number of PI data present in total */ + numPiDataPresent += node->piDataFrame.numPiDataAvailable; + availableFrameNodes[n] = node; + } + + /* IVAS Payload starts with E-Bytes */ + packEBytes( hPack, ( numPiDataPresent > 0 ), payload->capacity, &payload->buffer[payload->length], &numEBytes ); + payload->length += numEBytes; + + /* ToC bytes (atleast 1 byte per frame, 2 if SR )*/ + for ( n = 0; n < numFrame; n++ ) + { + FRAME_NODE *node = availableFrameNodes[n]; + uint8_t fBit = ( n != ( numFrame - 1 ) ) ? TOC_HEADER_FOLLOWS : 0; /* Next ToC present */ + + WRITE_BYTE_PAYLOAD_OR_EXIT( payload, ( node->toc[0] | fBit ) ); +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( node->tocNumBytes == 2 ) + { + WRITE_BYTE_PAYLOAD_OR_EXIT( payload, node->toc[1] ); + } +#endif + } + + /* Frame Data */ + for ( n = 0; n < numFrame; n++ ) + { + FRAME_NODE *node = availableFrameNodes[n]; + size_t frameLength = ( node->auNumBits + 7 ) >> 3; /* zero padded length in bytes */ + if ( payload->length + frameLength <= payload->capacity ) + { + memcpy( &payload->buffer[payload->length], node->au, frameLength ); + } + else + { + error = IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient memory to write RTP Payload" ); + goto err_exit; + } + payload->length += frameLength; + } + + /* PI Data */ + if ( numPiDataPresent > 0 ) + { + bool skipPiData = false; + size_t nBytes = payload->length; + uint32_t numPiDataWritten = 0; + + for ( n = 0; n < numFrame; n++ ) + { + uint32_t piDataType = 0; + FRAME_NODE *node = availableFrameNodes[n]; + PIDATA_FRAME *piDataFrame = &node->piDataFrame; + uint32_t bitmap = piDataFrame->piDataBitmap; + uint8_t PM = 0, PF = 0; + + for ( piDataType = 0; piDataType < 32 && ( bitmap != 0 ); piDataType++ ) + { + uint32_t mask = ( 1u << piDataType ); + if ( bitmap & mask ) + { + bitmap &= ~mask; /* Mask out this pi type to indicate processing */ + /* Check if last PI data this frame */ + PM = piDataFrame->piData[piDataType].data[0] & 0x60; + PM = (uint8_t) ( ( bitmap == 0 && PM != PI_HEADER_PM_GENERIC ) ? PI_HEADER_PM_LAST : PM ); + /* Check if last PI data all frames */ + PF = (uint8_t) ( ( bitmap == 0 && ( numPiDataWritten + 1 == numPiDataPresent ) ) ? PI_HEADER_PF_LAST : PI_HEADER_PF_NOT_LAST ); /* Last PI in Payload */ + /* Update the first byte of PI Header with PF/PM */ + piDataFrame->piData[piDataType].data[0] |= ( PF | PM ); + if ( nBytes + piDataFrame->piData[piDataType].size < payload->capacity ) + { + memcpy( &payload->buffer[nBytes], piDataFrame->piData[piDataType].data, piDataFrame->piData[piDataType].size ); + nBytes += piDataFrame->piData[piDataType].size; + } + else + { + skipPiData = true; /* Not enough bytes in output for PI data */ + } + numPiDataWritten++; + } + } + } + if ( !skipPiData ) + { + payload->length = nBytes; /* update payload length after PI packing */ + } + } + +err_exit: + /* Pop frames from Queue */ + for ( n = 0; n < numFrame; n++ ) + { + if ( BPOOL_FreeBuffer( hPack->packNodePool, availableFrameNodes[n] ) != IVAS_ERR_OK ) + { + assert( 0 ); /* catastrophic error if this fails */ + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "frame node could not be freed" ); + } + availableFrameNodes[n] = NULL; + } + + return error; +} + +ivas_error IVAS_RTP_PACK_GetPacket( + IVAS_RTP_PACK_HANDLE hPack, /* i/o : IVAS rtp packer handle */ + IVAS_DATA_BUFFER *packet, /* o : encapsulated rtp packet */ + uint32_t *numFramesInPacket /* o : no. of frames in packet */ +) +{ + ivas_error error = PackRtpHeader( &hPack->header, packet ); + ERR_CHECK_RETURN( error ); + + error = IVAS_RTP_PACK_GetPayload( hPack, packet, numFramesInPacket ); + ERR_CHECK_RETURN( error ); + + UpdateRtpHeader( &hPack->header, ( *numFramesInPacket ) * 320 ); + + return IVAS_ERR_OK; +} + +ivas_error IVAS_RTP_UNPACK_Open( + IVAS_RTP_UNPACK_HANDLE *phUnpack, /* i/o : rtp unpacker handle */ + const IVAS_RTP_UNPACK_CONFIG *config /* i : initial configuration for rtp unpacker */ +) +{ + ivas_error error = IVAS_ERR_OK; + IVAS_RTP_UNPACK_HANDLE hUnpack; + + if ( phUnpack == NULL || config == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *phUnpack = NULL; + if ( ( hUnpack = (IVAS_RTP_UNPACK_HANDLE) calloc( 1, sizeof( struct IVAS_RTP_UNPACK ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS rtp unpack handle" ); + } + + if ( config->maxFramesPerPacket > IVAS_MAX_FRAMES_PER_RTP_PACKET ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Max frame per packet exeeds %d", IVAS_MAX_FRAMES_PER_RTP_PACKET ); + } + + hUnpack->maxNumberOfFrames = ( config->maxFramesPerPacket == 0 ) ? IVAS_MAX_FRAMES_PER_RTP_PACKET : config->maxFramesPerPacket; + hUnpack->maxNumberOfPiData = hUnpack->maxNumberOfFrames * IVAS_PI_MAX_ID; + + error = BPOOL_Create( &hUnpack->unpackNodePool, sizeof( UNPACK_NODE ), hUnpack->maxNumberOfFrames ); + ERR_CHECK_RETURN( error ); + + error = BPOOL_Create( &hUnpack->piDataPool, sizeof( PIDATA_NODE ), hUnpack->maxNumberOfPiData ); + ERR_CHECK_RETURN( error ); + + error = QUEUE_Create( &hUnpack->frameQ ); + ERR_CHECK_RETURN( error ); + + error = QUEUE_Create( &hUnpack->piDataQ ); + ERR_CHECK_RETURN( error ); + + hUnpack->initConfig = *config; + mtx_init( &hUnpack->apilock, 0 ); + + initRequests( hUnpack->requests ); + + *phUnpack = hUnpack; + return IVAS_ERR_OK; +} + +/* Close and free an existing instance of rtp unpacker */ +void IVAS_RTP_UNPACK_Close( + IVAS_RTP_UNPACK_HANDLE *phUnpack /* i/o : IVAS rtp unpacker handle */ +) +{ + IVAS_RTP_UNPACK_HANDLE hUnpack; + + /* Free all memory */ + if ( phUnpack == NULL || *phUnpack == NULL ) + { + return; + } + + hUnpack = *phUnpack; + mtx_destroy( &hUnpack->apilock ); + QUEUE_Destroy( &hUnpack->frameQ ); + QUEUE_Destroy( &hUnpack->piDataQ ); + BPOOL_Destroy( &hUnpack->piDataPool ); + BPOOL_Destroy( &hUnpack->unpackNodePool ); + free( hUnpack->header.extData ); + free( hUnpack ); + *phUnpack = NULL; +} + +static void setEVSRequests( IVAS_RTP_BANDWIDTH bandwidth, uint32_t bitrate, IVAS_RTP_CA_MODE caMode, IVAS_RTP_REQUEST_VALUE *requests ) +{ + requests[IVAS_REQUEST_CODEC].codec = IVAS_RTP_EVS; + requests[IVAS_REQUEST_CA_MODE].caMode = caMode; + requests[IVAS_REQUEST_BITRATE].bitrate = bitrate; + requests[IVAS_REQUEST_BANDWIDTH].bandwidth = bandwidth; +} + +static uint32_t parseInitialEByte( const IVAS_DATA_BUFFER *payload, uint32_t nBytes, IVAS_RTP_REQUEST_VALUE *requests ) +{ + if ( nBytes < payload->length ) + { + uint8_t byte = payload->buffer[nBytes]; + uint8_t EvsIvasIndicator = ( byte & ( ~MASK_4BIT ) ); + uint8_t BR = ( byte & MASK_4BIT ); + + if ( ( byte & EBYTE_TOC_HEADER_BIT ) == 0 ) + { + return nBytes; + } + + nBytes++; /* Consume this e-byte */ + + switch ( EvsIvasIndicator ) + { + case EBYTE_CMR_T_EVS_NB: + if ( BR < 7 ) + { + uint32_t bitrate = evsFrameSizeInBits[BR] * IVAS_NUM_FRAMES_PER_SEC; + setEVSRequests( IVAS_BANDWIDTH_NB, bitrate, IVAS_RTP_CA_NO_REQ, requests ); + } + break; + case EBYTE_CMR_T_EVS_IO: /* AMRWB-IO */ + if ( BR < 9 ) + { + uint32_t bitrate = amrWBIOFrameSizeInBits[BR] * IVAS_NUM_FRAMES_PER_SEC; + setEVSRequests( IVAS_BANDWIDTH_NO_REQ, bitrate, IVAS_RTP_CA_NO_REQ, requests ); + } + break; + case EBYTE_CMR_T_EVS_CA_WB: + if ( BR < 8 ) + { + uint32_t bitrate = 13200; /* Fixed in CA Mode */ + setEVSRequests( IVAS_BANDWIDTH_WB, bitrate, BR, requests ); + } + break; + case EBYTE_CMR_T_EVS_CA_SWB: + if ( BR < 8 ) + { + uint32_t bitrate = 13200; /* Fixed in CA Mode */ + setEVSRequests( IVAS_BANDWIDTH_SWB, bitrate, BR, requests ); + } + break; + case EBYTE_CMR_T_EVS_WB: + if ( BR < 12 ) + { + uint32_t bitrate = evsFrameSizeInBits[BR] * IVAS_NUM_FRAMES_PER_SEC; + setEVSRequests( IVAS_BANDWIDTH_WB, bitrate, IVAS_RTP_CA_NO_REQ, requests ); + } + break; + case EBYTE_CMR_T_EVS_SWB: /* Intentional fall through */ + if ( BR < 12 && BR > 2 ) + { + uint32_t bitrate = evsFrameSizeInBits[BR] * IVAS_NUM_FRAMES_PER_SEC; + setEVSRequests( IVAS_BANDWIDTH_SWB, bitrate, IVAS_RTP_CA_NO_REQ, requests ); + } + break; + case EBYTE_CMR_T_EVS_FB: + if ( BR < 12 && BR > 4 ) + { + uint32_t bitrate = evsFrameSizeInBits[BR] * IVAS_NUM_FRAMES_PER_SEC; + setEVSRequests( IVAS_BANDWIDTH_FB, bitrate, IVAS_RTP_CA_NO_REQ, requests ); + } + break; + case EBYTE_CMR_T_IVAS: /* IVAS */ + if ( BR != 14 ) + { + requests[IVAS_REQUEST_CODEC].codec = IVAS_RTP_IVAS; + requests[IVAS_REQUEST_BITRATE].bitrate = ( BR == 0xF ) ? 0 : ivasFrameSizeInBits[BR] * IVAS_NUM_FRAMES_PER_SEC; + requests[IVAS_REQUEST_CA_MODE].caMode = IVAS_RTP_CA_NO_REQ; + } + break; + } + } + + return nBytes; +} + +static uint32_t parseSubsequentEByte( const IVAS_DATA_BUFFER *payload, uint32_t nBytes, IVAS_RTP_REQUEST_VALUE *requests, bool *piDataIndicated ) +{ + while ( nBytes < payload->length ) + { + uint8_t byte = payload->buffer[nBytes]; + uint8_t ET = ( byte & ( ~MASK_4BIT ) ); + + if ( ( byte & EBYTE_TOC_HEADER_BIT ) == 0 ) + { + return nBytes; + } + + nBytes++; /* Consume this e-byte */ + + switch ( ET ) + { + case EBYTE_BANDWIDTH_REQUEST: /* Bandwidth Request */ + { + requests[IVAS_REQUEST_BANDWIDTH].bandwidth = IVAS_BANDWIDTH_WB + ( byte & MASK_2BIT ); + } + break; + case EBYTE_FORMAT_REQUEST: /* Format Request */ + { +#ifdef RTP_S4_251135_CR26253_0016_REV1 + bool S = ( byte >> 3 ) & MASK_1BIT; + if ( S ) + { + /* Use the next byte to extract SubFormat */ + if ( nBytes < payload->length ) + { + byte = payload->buffer[nBytes++]; + requests[IVAS_REQUEST_SUBFORMAT].subFormatType = byte & MASK_6BIT; + } + } +#endif + requests[IVAS_REQUEST_FORMAT].formatType = byte & MASK_3BIT; + } + break; + case EBYTE_PI_INDICATOR: /* PI Indication */ + *piDataIndicated = true; + break; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case EBYTE_SR_REQUEST: /* Split Rendering Request */ + { + IVAS_RTP_SPLITRENDER *srConfig = &requests[IVAS_REQUEST_SR_CONFIG].srConfig; + srConfig->diegetic = ( byte >> 3 ) & MASK_1BIT; + srConfig->yaw = ( byte >> 2 ) & MASK_1BIT; + srConfig->pitch = ( byte >> 1 ) & MASK_1BIT; + srConfig->roll = byte & MASK_1BIT; + srConfig->valid = true; + } + break; +#endif + default: /* Reserved for future use - unhandled atm */ + assert( 0 ); + } + } + + return nBytes; +} + +static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBytes, uint32_t *numFrames, TOC_INFO *toc, uint32_t maxNumberOfToCBytes ) +{ + bool headerFollows = true; + uint32_t nBytes = *numBytes; + + *numFrames = 0; + while ( nBytes < payload->length && headerFollows ) + { + uint8_t byte = payload->buffer[nBytes]; + uint8_t BR = byte & MASK_4BIT; + uint8_t FT = byte & ( ( ~MASK_4BIT ) & MASK_6BIT ); + + headerFollows = ( byte & ( ~MASK_6BIT ) ) == TOC_HEADER_FOLLOWS; + + if ( ( byte & EBYTE_TOC_HEADER_BIT ) != 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNSUPPORTED_FRAME, "Expected ToC byte missing" ); + } + + nBytes++; /* Consume this e-byte */ + + if ( *numFrames == maxNumberOfToCBytes ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "No of frames in packet exceed max defined" ); + } + + *numFrames += 1; + memset( toc, 0, sizeof( *toc ) ); + + if ( FT == TOC_INDICATE_ARMWB_Q || FT == TOC_INDICATE_AMRWB ) + { + toc->codecId = IVAS_RTP_EVS; + toc->isAMRWB_IOmode = true; + toc->speechLostIndicated = ( FT == TOC_INDICATE_ARMWB_Q ) ? true : false; /* Q bit = 0 for AMRWB, BR is valid */ + if ( BR <= 9 ) + { + toc->auNumBits = amrWBIOFrameSizeInBits[BR]; + } + else if ( BR < 14 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNSUPPORTED_FRAME, "Reserved bitrate provided in AMRWB ToC" ); + } + else + { + toc->speechLostIndicated = ( BR == 14 ); /* SPEECH_LOST */ + toc->auNumBits = 0; + } + } + else if ( FT == TOC_INDICATE_IVAS ) + { + toc->codecId = IVAS_RTP_IVAS; + if ( BR == 14 ) + { +#ifdef RTP_S4_251135_CR26253_0016_REV1 + /* Read Unconditional SR-ToC byte */ + if ( nBytes < payload->length ) + { + uint8_t SR_BR; + byte = payload->buffer[nBytes++]; + SR_BR = ( byte >> 3 ) & MASK_2BIT; + if ( SR_BR == 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNSUPPORTED_FRAME, "Reserved bitrate provided in SR ToC" ); + } + toc->srInfo.valid = true; + toc->srInfo.diegetic = ( byte >> 6 ) & MASK_1BIT; + toc->srInfo.codec = IVAS_SR_TRANSPORT_LCLD + ( ( byte >> 5 ) & MASK_1BIT ); + toc->auNumBits = ( SR_BR + 1 ) * 128000u / IVAS_NUM_FRAMES_PER_SEC; + } + else + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Underflow during ToC SR byte" ); + } +#else + /* Reserved bit not expected */ + return IVAS_ERROR( IVAS_ERR_RTP_UNSUPPORTED_FRAME, "Reserved BR idx reported in ToC" ); +#endif + } + else + { + toc->auNumBits = ivasFrameSizeInBits[BR]; + } + } + else /* EVS */ + { + toc->codecId = IVAS_RTP_EVS; + toc->speechLostIndicated = ( FT == TOC_INDICATE_ARMWB_Q ) ? true : false; /* Q bit = 0 for AMRWB, BR is valid */ + if ( BR < 13 ) + { + toc->auNumBits = evsFrameSizeInBits[BR]; + } + else if ( BR == 13 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNSUPPORTED_FRAME, "Reserved bitrate provided in EVS ToC" ); + } + else + { + toc->speechLostIndicated = ( BR == 14 ); /* SPEECH_LOST */ + toc->auNumBits = 0; + } + } + + toc++; + + /* Handle any frame specific E-Bytes here currently there are none, so we skip any E-Bytes here after */ + if ( headerFollows ) + { + while ( nBytes < payload->length ) + { + byte = payload->buffer[nBytes]; + if ( ( byte & EBYTE_TOC_HEADER_BIT ) == 0 ) + { + break; + } + nBytes++; + } + } + } + + *numBytes = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error parsePIData( IVAS_RTP_UNPACK_HANDLE hUnpack, uint32_t rtpTimestamp, const IVAS_DATA_BUFFER *payload, uint32_t *numBytes, uint32_t *numPiDataInPacket ) +{ + bool PF = true; + uint32_t nBytes = *numBytes; + + while ( PF ) + { + uint8_t piHeader0, PM, piDataType, byte = 0; + uint32_t piSize = 0; + + if ( nBytes + 1 >= payload->length ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Underflow during expected PI Header read" ); + } + + piHeader0 = payload->buffer[nBytes++]; + + PF = ( piHeader0 >> 7 ) & MASK_1BIT; /* New PI header follows this PI Data Frame */ + PM = ( piHeader0 & ( ~MASK_5BIT ) ) & MASK_7BIT; /* PI Marker Bits */ + piDataType = ( piHeader0 & MASK_5BIT ); + + do + { + byte = payload->buffer[nBytes++]; + piSize += byte; + if ( nBytes >= payload->length ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Underflow during reading piSize" ); + } + } while ( byte == 255 ); + + if ( piDataType == IVAS_PI_NO_DATA ) + { + if ( piSize > 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "NO_PI_DATA should be 0 sized" ); + } + + /* Do not add a node for NO_DATA */ + } + else if ( nBytes + piSize <= payload->length ) + { + PIDATA_NODE *node = NULL; + ivas_error error = BPOOL_GetBuffer( hUnpack->piDataPool, (void **) &node ); + ERR_CHECK_RETURN( error ); + + node->next = NULL; + + error = PI_UnPackData( piDataType, piSize, &payload->buffer[nBytes], (IVAS_PIDATA_GENERIC *) &node->data ); + ERR_CHECK_RETURN( error ); + + node->timestamp = rtpTimestamp; + + nBytes += piSize; + *numPiDataInPacket += 1; + + QUEUE_Push( hUnpack->piDataQ, (NODE *) node ); + } + else + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Underflow during reading pi data" ); + } + + if ( PM == PI_HEADER_PM_LAST ) + { + rtpTimestamp += 16000 / IVAS_NUM_FRAMES_PER_SEC; + } + } + + *numBytes = nBytes; + return IVAS_ERR_OK; +} + +ivas_error IVAS_RTP_UNPACK_PushPayload( + IVAS_RTP_UNPACK_HANDLE hUnpack, /* i/o : IVAS rtp unpacker handle */ + const IVAS_DATA_BUFFER *payload, /* i : received rtp payload */ + uint32_t timestamp, /* i : timestamp in RTP Clock @ 16KHz from rtp header */ + uint16_t sequenceNumber, /* i : sequence number from rtp header */ + uint32_t *numFramesInPacket, /* o : number of IVAS/EVS frames in rtp packet */ + uint32_t *numPiDataInPacket, /* o : number of PI data received in rtp packet */ + uint32_t *remoteRequestBitmap /* o : bitmap of available request in this packet */ +) +{ + ivas_error error = IVAS_ERR_OK; + uint32_t nBytes = 0, numFrames = 0, numPiData = 0, n; + bool piDataIndicated = false; + TOC_INFO toc[IVAS_MAX_FRAMES_PER_RTP_PACKET]; + + IVAS_RTP_REQUEST_VALUE oldRequests[IVAS_REQUEST_MAX]; + + if ( hUnpack == NULL || payload == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( remoteRequestBitmap != NULL ) + { + *remoteRequestBitmap = 0; + } + + if ( numFramesInPacket != NULL ) + { + *numFramesInPacket = 0; + } + + if ( numPiDataInPacket != NULL ) + { + *numPiDataInPacket = 0; + } + + /* Sanity check if any frame or PI data from last packet is still not pulled */ + if ( QUEUE_Size( hUnpack->frameQ ) > 0 || QUEUE_Size( hUnpack->piDataQ ) > 0 ) + { + assert( 0 ); + return IVAS_ERROR( IVAS_ERR_INTERNAL, "Previous packet data should be consumed before next packet is pushed" ); + } + + memcpy( oldRequests, hUnpack->requests, sizeof( oldRequests ) ); + + /* Unpack IVAS Payload, starting with the E-Bytes */ + nBytes = parseInitialEByte( payload, nBytes, hUnpack->requests ); + + /* Unpack any subsequent E-bytes */ + nBytes = parseSubsequentEByte( payload, nBytes, hUnpack->requests, &piDataIndicated ); + + /* Unpack the ToC Bytes => Extract number of frames in packet */ + error = parseToCByte( payload, &nBytes, &numFrames, toc, sizeof( toc ) / sizeof( toc[0] ) ); + ERR_CHECK_RETURN( error ); + + /* Read frame bits */ + for ( n = 0; n < numFrames; n++ ) + { + uint32_t frameSizeBytes; + UNPACK_NODE *node = NULL; + + /* Get a new node */ + error = BPOOL_GetBuffer( hUnpack->unpackNodePool, (void **) &node ); + ERR_CHECK_RETURN( error ); + + node->next = NULL; + node->timestamp = timestamp + ( n * 320 ); + node->seqNumber = sequenceNumber; + node->toc = toc[n]; + + frameSizeBytes = ( node->toc.auNumBits + 7 ) / 8; + if ( nBytes + frameSizeBytes <= payload->length ) + { + memcpy( node->au, &payload->buffer[nBytes], frameSizeBytes ); + nBytes += frameSizeBytes; + } + else + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "Underflow during expected frame bits" ); + } + + /* Add to frames FiFo */ + QUEUE_Push( hUnpack->frameQ, (NODE *) node ); + } + + if ( piDataIndicated ) + { + error = parsePIData( hUnpack, timestamp, payload, &nBytes, &numPiData ); + if ( error != IVAS_ERR_OK ) + { + /* PI Parsing errors are not fatal => indicate no PI data in packet as workaround */ + numPiData = 0; + } + } + + if ( numFramesInPacket != NULL ) + { + *numFramesInPacket = numFrames; + } + + if ( numPiDataInPacket ) + { + *numPiDataInPacket = numPiData; + } + + if ( remoteRequestBitmap ) + { + for ( n = 0; n < IVAS_REQUEST_MAX; n++ ) + { + bool changed = ( memcmp( &hUnpack->requests[n], &oldRequests[n], sizeof( IVAS_RTP_REQUEST_VALUE ) ) != 0 ); + *remoteRequestBitmap |= changed ? ( 1u << n ) : 0; + } + } + + return IVAS_ERR_OK; +} + +ivas_error IVAS_RTP_UNPACK_PushPacket( + IVAS_RTP_UNPACK_HANDLE hUnpack, /* i/o : IVAS rtp unpacker handle */ + const IVAS_DATA_BUFFER *packet, /* i : received rtp Packet */ + uint32_t *numFramesInPacket, /* o : number of IVAS/EVS frames in rtp packet */ + uint32_t *numPiDataInPacket, /* o : number of PI data received in rtp packet */ + uint32_t *remoteRequestBitmap /* o : bitmap of available request in this packet */ +) +{ + ivas_error error = IVAS_ERR_OK; + uint32_t numHeaderBytes = 0; + IVAS_DATA_BUFFER payload; + + error = UnpackRtpPacket( packet, &hUnpack->header, &numHeaderBytes ); + ERR_CHECK_RETURN( error ); + + /* Offset to RTP Payload */ + payload.capacity = packet->capacity; + payload.buffer = packet->buffer + numHeaderBytes; + payload.length = packet->length - numHeaderBytes; + + return IVAS_RTP_UNPACK_PushPayload( + hUnpack, + &payload, + hUnpack->header.timestamp, + hUnpack->header.seqNumber, + numFramesInPacket, + numPiDataInPacket, + remoteRequestBitmap ); +} + +ivas_error IVAS_RTP_UNPACK_GetRequest( + IVAS_RTP_UNPACK_HANDLE hUnpack, /* i/o : IVAS rtp packer handle */ + IVAS_RTP_REQUEST_TYPE type, /* i : remote request type */ + IVAS_RTP_REQUEST_VALUE *value /* o : pointer of the requested type */ +) +{ + if ( type < 0 || type >= IVAS_REQUEST_MAX ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid request key provided" ); + } + *value = hUnpack->requests[type]; + return IVAS_ERR_OK; +} + +ivas_error IVAS_RTP_UNPACK_PullFrame( + IVAS_RTP_UNPACK_HANDLE hUnpack, /* i/o : IVAS rtp unpacker handle */ + IVAS_RTP_CODEC *receivedCodecId, /* o : Codec type (IVAS/EVS) */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SR_INFO *srInfo, /* o : Split Rendering Info */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_DATA_BUFFER *frameBuffer, /* o : packed frame bitstream for IVAS/EVS */ + int16_t *frameSizeInBits, /* o : exact frame size in bits (AMRWB IO) */ + uint32_t *timestamp, /* o : timestamp in RTP Clock @ 16KHz */ + uint16_t *sequenceNumber, /* o : sequence number from rtp header */ + bool *speechLostIndicated, /* o : Is current frame indicated as Lost */ + bool *isAMRWB_IOmode /* o : Is AMRWB_IO mode EVS frame */ +) +{ + size_t length = 0; + UNPACK_NODE *node = (UNPACK_NODE *) QUEUE_Pop( hUnpack->frameQ ); + + /* Check if a node is available in FiFo */ + if ( node == NULL ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "No more frames in unpack fifo" ); + } + + length = ( node->toc.auNumBits + 7 ) / 8; + if ( frameBuffer != NULL && ( length <= frameBuffer->capacity ) ) + { + memcpy( frameBuffer->buffer, node->au, length ); + frameBuffer->length = length; + } + + if ( frameSizeInBits != NULL ) + { + *frameSizeInBits = (int16_t) node->toc.auNumBits; + } + + if ( receivedCodecId != NULL ) + { + *receivedCodecId = node->toc.codecId; + } + +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( srInfo != NULL ) + { + *srInfo = node->toc.srInfo; + } +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + + if ( timestamp != NULL ) + { + *timestamp = node->timestamp; + } + + if ( sequenceNumber != NULL ) + { + *sequenceNumber = node->seqNumber; + } + + if ( speechLostIndicated != NULL ) + { + *speechLostIndicated = node->toc.speechLostIndicated; + } + + if ( isAMRWB_IOmode != NULL ) + { + *isAMRWB_IOmode = node->toc.isAMRWB_IOmode; + } + + return BPOOL_FreeBuffer( hUnpack->unpackNodePool, node ); +} + +ivas_error IVAS_RTP_UNPACK_PullNextPiData( + IVAS_RTP_UNPACK_HANDLE hUnpack, /* i/o : IVAS rtp unpacker handle */ + IVAS_PIDATA_GENERIC *data, /* o : output data buffer for the Pi data */ + size_t capacity, /* i : capacity of pi data buffer in bytes */ + uint32_t *timestamp /* o : timestamp in RTP Clock @ 16KHz */ +) +{ + IVAS_PIDATA_GENERIC *pi = NULL; + PIDATA_NODE *node = (PIDATA_NODE *) QUEUE_Pop( hUnpack->piDataQ ); + + /* Check if a node is available in FiFo */ + if ( node == NULL ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNDERFLOW, "No more pi data in unpack fifo" ); + } + + pi = (IVAS_PIDATA_GENERIC *) &node->data; + + if ( data != NULL && ( pi->size <= capacity ) ) + { + memcpy( data, pi, pi->size ); + } + + if ( timestamp != NULL ) + { + *timestamp = node->timestamp; + } + + return BPOOL_FreeBuffer( hUnpack->piDataPool, node ); +} + +#endif /* IVAS_RTPDUMP */ diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c new file mode 100644 index 000000000..7150cfe4a --- /dev/null +++ b/lib_util/ivas_rtp_pi_data.c @@ -0,0 +1,850 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "ivas_error_utils.h" +#include "ivas_rtp_internal.h" + +#ifdef IVAS_RTPDUMP + +/* Generic PI data packing/unpacking functions */ +typedef ivas_error ( *PACK_PI_FN )( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ); +typedef ivas_error ( *UNPACK_PI_FN )( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ); + +static __inline uint32_t writeInt16( uint8_t *buffer, uint32_t idx, int16_t val ) +{ + buffer[idx++] = (uint8_t) ( val >> 8 ); + buffer[idx++] = (uint8_t) ( val & 0x00FF ); + return idx; +} + +static __inline int16_t readInt16( const uint8_t *buffer ) +{ + return (int16_t) ( (uint16_t) buffer[0] << 8 ) | ( (uint16_t) buffer[1] ); +} + +/*-----------------------------------------------------------------------* + * ivasPayload_convertToQ15() + * + * Convert a float value into a Q15 encoded value. + *-----------------------------------------------------------------------*/ +static int16_t ivasPayload_convertToQ15( float value ) +{ + value = ( value * 32768.0f ); + value = value > +32767.0f ? +32767.0f : value; + value = value < -32768.0f ? -32768.0f : value; + return (int16_t) ( value ); +} + +static ivas_error packUnsupportedData( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + (void) piData; + (void) buffer; + (void) maxDataBytes; + /* Skip packing */ + *nBytesWritten = 0; + return IVAS_ERR_OK; +} + +static ivas_error unpackUnsupportedData( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + (void) piData; + (void) buffer; + (void) numDataBytes; + /* Skip unpacking */ + return IVAS_ERR_OK; +} + +static ivas_error packNoPiData( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + (void) piData; + + *nBytesWritten = 0; + + /* NO_PI_DATA is just PI header with no data */ + if ( maxDataBytes < 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space in PI data buffer for NO_PI_DATA" ); + } + + buffer[nBytes++] = ( IVAS_PI_NO_DATA ); /* PF/PM populated during final packing */ + buffer[nBytes++] = 0; /* NO_PI_DATA is 0 bytes */ + + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackNoPiData( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + (void) buffer; + + if ( numDataBytes != 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "NO_PI_DATA must be 0 byte" ); + } + + piData->size = sizeof( IVAS_PIDATA_NO_DATA ); + return IVAS_ERR_OK; +} + +static ivas_error packOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + const IVAS_PIDATA_ORIENTATION *orientation = (const IVAS_PIDATA_ORIENTATION *) piData; + + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_ORIENTATION ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in Orientation PI data" ); + } + + if ( ( piData->piDataType != IVAS_PI_SCENE_ORIENTATION ) && ( piData->piDataType != IVAS_PI_DEVICE_ORIENTATION_COMPENSATED ) && ( piData->piDataType != IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED ) +#ifdef RTP_S4_251135_CR26253_0016_REV1 + && ( piData->piDataType != IVAS_PI_PLAYBACK_DEVICE_ORIENTATION ) && ( piData->piDataType != IVAS_PI_HEAD_ORIENTATION ) +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in Orientation PI data" ); + } + + /* Orientation data is 8 bytes, header is 2 bytes */ + if ( maxDataBytes < 8 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack Orientation PI data" ); + } + + buffer[nBytes++] = ( orientation->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = 8; + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( orientation->orientation.w ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( orientation->orientation.x ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( orientation->orientation.y ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( orientation->orientation.z ) ); + + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackOrientation( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_ORIENTATION *orientation = (IVAS_PIDATA_ORIENTATION *) piData; + + /* Orientation data is 8 bytes */ + if ( numDataBytes != 8 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack Orientation PI data" ); + } + + piData->size = sizeof( IVAS_PIDATA_ORIENTATION ); + orientation->orientation.w = FLOAT_FROM_Q15( readInt16( &buffer[0] ) ); + orientation->orientation.x = FLOAT_FROM_Q15( readInt16( &buffer[2] ) ); + orientation->orientation.y = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ); + orientation->orientation.z = FLOAT_FROM_Q15( readInt16( &buffer[6] ) ); + + return IVAS_ERR_OK; +} + +static uint32_t getIndexTable( const float *table, uint32_t tableLength, float value ) +{ + uint32_t idx = 0; + if ( value <= table[0] ) + { + return 0; + } + + for ( idx = 1; idx < tableLength; idx++ ) + { + if ( value < table[idx] ) + { + break; + } + } + return idx - 1; +} + +#define GET_IDX( table, nBits, value ) getIndexTable( table, ( 1u << ( nBits ) ), ( value ) ) + +static ivas_error packAcousticEnvironment( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + uint8_t packedSize = 1; + const IVAS_PIDATA_ACOUSTIC_ENV *aeEnv = (const IVAS_PIDATA_ACOUSTIC_ENV *) piData; + + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_ACOUSTIC_ENV ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in PI data of type Acoustic Environment" ); + } + + if ( aeEnv->availEarlyReflections ) + { + packedSize = 8; + } + else if ( aeEnv->availLateReverb ) + { + packedSize = 5; + } + + /* Acoustic Env data is packedSize bytes, header is 2 bytes */ + if ( maxDataBytes < (uint32_t) packedSize + 2 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Insufficient space to pack Orientation PI data" ); + } + + buffer[nBytes++] = ( IVAS_PI_ACOUSTIC_ENVIRONMENT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = packedSize; + + if ( packedSize == 1 ) + { + buffer[nBytes++] = aeEnv->aeid & 0x7F; + } + else + { + uint64_t dWord = (uint64_t) aeEnv->aeid << 57; + + dWord |= (uint64_t) GET_IDX( mapRT60, NBITS_RT60, aeEnv->rt60[IVAS_PI_AE_LOW] ) << 52; + dWord |= (uint64_t) GET_IDX( mapDSR, NBITS_DSR, aeEnv->dsr[IVAS_PI_AE_LOW] ) << 46; + dWord |= (uint64_t) GET_IDX( mapRT60, NBITS_RT60, aeEnv->rt60[IVAS_PI_AE_MID] ) << 41; + dWord |= (uint64_t) GET_IDX( mapDSR, NBITS_DSR, aeEnv->dsr[IVAS_PI_AE_MID] ) << 35; + dWord |= (uint64_t) GET_IDX( mapRT60, NBITS_RT60, aeEnv->rt60[IVAS_PI_AE_HIGH] ) << 30; + dWord |= (uint64_t) GET_IDX( mapDSR, NBITS_DSR, aeEnv->dsr[IVAS_PI_AE_HIGH] ) << 24; + + buffer[nBytes++] = (uint8_t) ( dWord >> 56 ); + buffer[nBytes++] = (uint8_t) ( dWord >> 48 ); + buffer[nBytes++] = (uint8_t) ( dWord >> 40 ); + buffer[nBytes++] = (uint8_t) ( dWord >> 32 ); + buffer[nBytes++] = (uint8_t) ( dWord >> 24 ); + + if ( packedSize > 5 ) + { + dWord |= (uint64_t) GET_IDX( mapRoomDims, NBITS_DIM, aeEnv->roomDimensions.x ) << 20; + dWord |= (uint64_t) GET_IDX( mapRoomDims, NBITS_DIM, aeEnv->roomDimensions.y ) << 16; + dWord |= (uint64_t) GET_IDX( mapRoomDims, NBITS_DIM, aeEnv->roomDimensions.z ) << 12; + dWord |= (uint64_t) GET_IDX( mapAbsorbtion, NBITS_ABS, aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] ) << 10; + dWord |= (uint64_t) GET_IDX( mapAbsorbtion, NBITS_ABS, aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] ) << 8; + dWord |= (uint64_t) GET_IDX( mapAbsorbtion, NBITS_ABS, aeEnv->absorbCoeffs[IVAS_PI_AE_LEFT] ) << 6; + dWord |= (uint64_t) GET_IDX( mapAbsorbtion, NBITS_ABS, aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] ) << 4; + dWord |= (uint64_t) GET_IDX( mapAbsorbtion, NBITS_ABS, aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] ) << 2; + dWord |= (uint64_t) GET_IDX( mapAbsorbtion, NBITS_ABS, aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] ); + + buffer[nBytes++] = (uint8_t) ( dWord >> 16 ); + buffer[nBytes++] = (uint8_t) ( dWord >> 8 ); + buffer[nBytes++] = (uint8_t) ( dWord ); + } + } + + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_ACOUSTIC_ENV *aeEnv = (IVAS_PIDATA_ACOUSTIC_ENV *) piData; + + /* Acooustic Env data is either 1, 5 or 8 bytes */ + if ( numDataBytes != 1 && numDataBytes != 5 && numDataBytes != 8 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack PI data of type Acoustic Environment" ); + } + + piData->size = sizeof( IVAS_PIDATA_ACOUSTIC_ENV ); + aeEnv->availLateReverb = ( numDataBytes >= 5 ); + aeEnv->availEarlyReflections = ( numDataBytes == 8 ); + + if ( numDataBytes == 1 ) + { + aeEnv->aeid = buffer[0]; + } + else + { + uint64_t dWord = 0ull; + uint32_t n; + for ( n = 0; n < numDataBytes; n++ ) + { + dWord <<= 8; + dWord |= buffer[n]; + } + dWord <<= ( 8 - numDataBytes ) * 8; + + aeEnv->aeid = (uint8_t) ( ( dWord >> 57 ) & MASK_AEID ); + aeEnv->rt60[IVAS_PI_AE_LOW] = mapRT60[( dWord >> 52 ) & MASK_RT60]; + aeEnv->dsr[IVAS_PI_AE_LOW] = mapDSR[( dWord >> 46 ) & MASK_DSR]; + aeEnv->rt60[IVAS_PI_AE_MID] = mapRT60[( dWord >> 41 ) & MASK_RT60]; + aeEnv->dsr[IVAS_PI_AE_MID] = mapDSR[( dWord >> 35 ) & MASK_DSR]; + aeEnv->rt60[IVAS_PI_AE_HIGH] = mapRT60[( dWord >> 30 ) & MASK_RT60]; + aeEnv->dsr[IVAS_PI_AE_HIGH] = mapDSR[( dWord >> 24 ) & MASK_DSR]; + + aeEnv->roomDimensions.x = mapRoomDims[( dWord >> 20 ) & MASK_DIM]; + aeEnv->roomDimensions.y = mapRoomDims[( dWord >> 16 ) & MASK_DIM]; + aeEnv->roomDimensions.z = mapRoomDims[( dWord >> 12 ) & MASK_DIM]; + + aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] = mapAbsorbtion[( dWord >> 10 ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] = mapAbsorbtion[( dWord >> 8 ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_LEFT] = mapAbsorbtion[( dWord >> 6 ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> 4 ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> 2 ) & MASK_ABS]; + aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> 0 ) & MASK_ABS]; + } + + return IVAS_ERR_OK; +} + +#ifdef RTP_S4_251135_CR26253_0016_REV1 +static ivas_error packAudioDescription( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t n; + uint32_t nBytes = 0; + const IVAS_PIDATA_AUDIO_DESC *audioDesc = (const IVAS_PIDATA_AUDIO_DESC *) piData; + uint32_t packedSize = audioDesc->nValidEntries; /* Each Entry is 1 byte */ + + *nBytesWritten = 0; + + if ( audioDesc->nValidEntries > ( IVAS_MAX_NUM_OBJECTS + 1 ) ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNSUPPORTED_FRAME, "Audio Description cannot have more than 5 entries" ); + } + + /* Audio Description data is max 5 bytes, 2 bytes header */ + if ( maxDataBytes < packedSize + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space in Audio Description PI data buffer" ); + } + + buffer[nBytes++] = ( IVAS_PI_AUDIO_DESCRIPTION ); /* PF/PM populated during final packing */ + buffer[nBytes++] = (uint8_t) packedSize; + + for ( n = 0; n < audioDesc->nValidEntries; n++ ) + { + buffer[nBytes++] = ( audioDesc->audioId[n].speech ? PI_AD_SPEECH_INDICATED : 0 ) | + ( audioDesc->audioId[n].music ? PI_AD_MUSIC_INDICATED : 0 ) | + ( audioDesc->audioId[n].ambiance ? PI_AD_AMBIANCE_INDICATED : 0 ) | + ( audioDesc->audioId[n].editable ? PI_AD_EDITABLE_INDICATED : 0 ) | + ( audioDesc->audioId[n].binaural ? PI_AD_BINAURAL_INDICATED : 0 ); + } + + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackAudioDescription( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t n; + IVAS_PIDATA_AUDIO_DESC *audioDesc = (IVAS_PIDATA_AUDIO_DESC *) piData; + + /* Audio Description data is max 5 bytes */ + if ( numDataBytes > ( IVAS_MAX_NUM_OBJECTS + 1 ) ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack Orientation PI data" ); + } + + audioDesc->size = sizeof( IVAS_PIDATA_AUDIO_DESC ); + audioDesc->nValidEntries = numDataBytes; + audioDesc->piDataType = IVAS_PI_AUDIO_DESCRIPTION; + + for ( n = 0; n < audioDesc->nValidEntries; n++ ) + { + audioDesc->audioId[n].speech = ( buffer[n] & PI_AD_SPEECH_INDICATED ) != 0; + audioDesc->audioId[n].music = ( buffer[n] & PI_AD_MUSIC_INDICATED ) != 0; + audioDesc->audioId[n].ambiance = ( buffer[n] & PI_AD_AMBIANCE_INDICATED ) != 0; + audioDesc->audioId[n].editable = ( buffer[n] & PI_AD_EDITABLE_INDICATED ) != 0; + audioDesc->audioId[n].binaural = ( buffer[n] & PI_AD_BINAURAL_INDICATED ) != 0; + } + + return IVAS_ERR_OK; +} + +static ivas_error packDynamicSuppression( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = (const IVAS_PIDATA_DYNAMIC_SUPPRESSION *) piData; + + *nBytesWritten = 0; + + /* Dynamic Audio Suppression data is 2 bytes, 2 bytes header */ + if ( maxDataBytes < 2 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space in DAS PI data buffer" ); + } + + buffer[nBytes++] = ( IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION ); /* PF/PM populated during final packing */ + buffer[nBytes++] = 2u; + + buffer[nBytes++] = ( das->speech ? PI_AD_SPEECH_INDICATED : 0 ) | + ( das->music ? PI_AD_MUSIC_INDICATED : 0 ) | + ( das->ambiance ? PI_AD_AMBIANCE_INDICATED : 0 ); + buffer[nBytes++] = ( (uint8_t) das->sli & MASK_4BIT ) << 4; + + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackDynamicSuppression( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = (IVAS_PIDATA_DYNAMIC_SUPPRESSION *) piData; + + /* Dynamic Suppression data is 2 bytes */ + if ( numDataBytes != 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack DAS PI data" ); + } + + das->size = sizeof( IVAS_PIDATA_AUDIO_DESC ); + das->piDataType = IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION; + das->speech = ( buffer[0] & PI_AD_SPEECH_INDICATED ) != 0; + das->music = ( buffer[0] & PI_AD_MUSIC_INDICATED ) != 0; + das->ambiance = ( buffer[0] & PI_AD_AMBIANCE_INDICATED ) != 0; + das->sli = ( buffer[1] >> 4 ); + + return IVAS_ERR_OK; +} + +static ivas_error packListenerPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + const IVAS_PIDATA_LISTENER_POSITION *listener = (const IVAS_PIDATA_LISTENER_POSITION *) piData; + + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_LISTENER_POSITION ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in LISTENER POSITION PI data" ); + } + + if ( piData->piDataType != IVAS_PI_LISTENER_POSITION ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in LISTENER POSITION PI data" ); + } + + /* Position data is 6 bytes, header is 2 bytes */ + if ( maxDataBytes < 6 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack LISTENER POSITION PI data" ); + } + + buffer[nBytes++] = ( listener->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = 6; + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( listener->position.x / MAX_PI_POSITION_METERS ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( listener->position.y / MAX_PI_POSITION_METERS ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( listener->position.z / MAX_PI_POSITION_METERS ) ); + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackListenerPosition( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_LISTENER_POSITION *listener = (IVAS_PIDATA_LISTENER_POSITION *) piData; + + /* Position data is 6 bytes */ + if ( numDataBytes != 6 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack LISTENER POSITION PI data" ); + } + + listener->size = sizeof( IVAS_PIDATA_LISTENER_POSITION ); + listener->piDataType = IVAS_PI_LISTENER_POSITION; + listener->position.x = FLOAT_FROM_Q15( readInt16( &buffer[0] ) ) * MAX_PI_POSITION_METERS; + listener->position.y = FLOAT_FROM_Q15( readInt16( &buffer[2] ) ) * MAX_PI_POSITION_METERS; + listener->position.z = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ) * MAX_PI_POSITION_METERS; + return IVAS_ERR_OK; +} + +static ivas_error packDiegetic( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0, n; + uint8_t byte = 0; + const IVAS_PIDATA_DIEGETIC *diegetic = (const IVAS_PIDATA_DIEGETIC *) piData; + + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_DIEGETIC ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in Diegetic Type PI data" ); + } + + if ( piData->piDataType != IVAS_PI_DIEGETIC_TYPE ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in Diegetic Type PI data" ); + } + + /* Diegetic data is 1 bytes, header is 2 bytes */ + if ( maxDataBytes < 1 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack Diegetic Type PI data" ); + } + + /* Valid bits must be based on active bits defined for the input format */ + for ( n = 0; n < ( IVAS_MAX_NUM_OBJECTS + 1 ); n++ ) + { + byte <<= 1; + byte |= ( diegetic->isDiegetic[n] ); + } + byte <<= 3; + + buffer[nBytes++] = ( diegetic->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = 1; + buffer[nBytes++] = byte; + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackDiegetic( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t n; + IVAS_PIDATA_DIEGETIC *diegetic = (IVAS_PIDATA_DIEGETIC *) piData; + uint8_t byte; + + /* Diegetic data is 1 bytes */ + if ( numDataBytes != 1 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack Diegetic PI data" ); + } + + diegetic->size = sizeof( IVAS_PIDATA_DIEGETIC ); + diegetic->piDataType = IVAS_PI_DIEGETIC_TYPE; + + byte = buffer[0]; + /* Valid bits must be based on active bits defined for the input format */ + for ( n = 0; n < ( IVAS_MAX_NUM_OBJECTS + 1 ); n++ ) + { + diegetic->isDiegetic[n] = ( ( byte >> ( 7 - n ) ) & 1 ) != 0; + } + + return IVAS_ERR_OK; +} + +static ivas_error packAudioFocusCommon( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + uint8_t packedSize = 1; + const IVAS_PIDATA_AUDIO_FOCUS *audioFocus = (const IVAS_PIDATA_AUDIO_FOCUS *) piData; + + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_AUDIO_FOCUS ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in PI data of type Audio Focus" ); + } + + if ( audioFocus->availDirection && audioFocus->availLevel ) + { + packedSize = 9; + } + else if ( audioFocus->availDirection ) + { + packedSize = 8; + } + else if ( audioFocus->availLevel ) + { + packedSize = 1; + } + else + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Neither direction or level is available for packing Audio Focus" ); + } + + /* Audio Focus data is packedSize bytes, header is 2 bytes */ + if ( maxDataBytes < (uint32_t) packedSize + 2 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Insufficient space to pack Audio Focus PI data" ); + } + + buffer[nBytes++] = ( audioFocus->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = packedSize; + + if ( packedSize == 9 || packedSize == 8 ) + { + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( audioFocus->direction.w ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( audioFocus->direction.x ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( audioFocus->direction.y ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( audioFocus->direction.z ) ); + } + if ( packedSize == 9 || packedSize == 1 ) + { + buffer[nBytes++] = ( (uint8_t) audioFocus->flvl & MASK_4BIT ) << 4; + } + + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_AUDIO_FOCUS *audioFocus = (IVAS_PIDATA_AUDIO_FOCUS *) piData; + + /* Audio Focus data is either 1, 8 or 9 bytes */ + if ( numDataBytes != 1 && numDataBytes != 8 && numDataBytes != 9 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack PI data of type Audio Focus" ); + } + + piData->size = sizeof( IVAS_PIDATA_AUDIO_FOCUS ); + audioFocus->availDirection = ( numDataBytes >= 8 ); + audioFocus->availLevel = ( numDataBytes == 1 || numDataBytes == 9 ); + + if ( numDataBytes == 1 ) + { + audioFocus->flvl = ( buffer[0] >> 4 ); + } + else + { + audioFocus->direction.w = FLOAT_FROM_Q15( readInt16( &buffer[0] ) ); + audioFocus->direction.x = FLOAT_FROM_Q15( readInt16( &buffer[2] ) ); + audioFocus->direction.y = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ); + audioFocus->direction.z = FLOAT_FROM_Q15( readInt16( &buffer[6] ) ); + + if ( numDataBytes == 9 ) + { + audioFocus->flvl = ( buffer[8] >> 4 ); + } + } + + return IVAS_ERR_OK; +} + + +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + +static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { + packOrientation, /* SCENE_ORIENTATION */ + packOrientation, /* DEVICE_ORIENTATION_COMPENSATED */ + packOrientation, /* DEVICE_ORIENTATION_UNCOMPENSATED */ + packAcousticEnvironment, /* ACOUSTIC_ENVIRONMENT */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + packAudioDescription, /* AUDIO_DESCRIPTION */ +#else + packUnsupportedData, /* AUDIO_DESCRIPTION */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + packUnsupportedData, /* ISM_NUM */ + packUnsupportedData, /* ISM_ID */ + packUnsupportedData, /* ISM_GAIN */ + packUnsupportedData, /* ISM_ORIENTATION */ + packUnsupportedData, /* ISM_POSITION */ + packUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ + packUnsupportedData, /* ISM_DIRECTIVITY */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + packDiegetic, /* DIEGETIC_TYPE */ +#else + packUnsupportedData, /* DIEGETIC_TYPE */ +#endif + packUnsupportedData, /* RESERVED13 */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + packAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ +#else + packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ +#endif + packUnsupportedData, /* RESERVED15 */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + packOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ + packOrientation, /* HEAD_ORIENTATION */ + packListenerPosition, /* LISTENER_POSITION */ + packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ + packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ +#else + packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ + packUnsupportedData, /* HEAD_ORIENTATION */ + packUnsupportedData, /* LISTENER_POSITION */ + packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ + packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ +#endif + packUnsupportedData, /* PI_LATENCY */ + packUnsupportedData, /* R_ISM_ID */ + packUnsupportedData, /* R_ISM_GAIN */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + packOrientation, /* R_ISM_ORIENTATION */ +#else + packUnsupportedData, /* R_ISM_ORIENTATION */ +#endif + packUnsupportedData, /* R_ISM_POSITION */ + packUnsupportedData, /* R_ISM_DIRECTION */ + packUnsupportedData, /* RESERVED27 */ + packUnsupportedData, /* RESERVED28 */ + packUnsupportedData, /* RESERVED29 */ + packUnsupportedData, /* RESERVED30 */ + packNoPiData /* NO_DATA */ +}; + +static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { + unpackOrientation, /* SCENE_ORIENTATION */ + unpackOrientation, /* DEVICE_ORIENTATION_COMPENSATED */ + unpackOrientation, /* DEVICE_ORIENTATION_UNCOMPENSATED */ + unpackAcousticEnvironment, /* ACOUSTIC_ENVIRONMENT */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + unpackAudioDescription, /* AUDIO_DESCRIPTION */ +#else + unpackUnsupportedData, /* AUDIO_DESCRIPTION */ +#endif + unpackUnsupportedData, /* ISM_NUM */ + unpackUnsupportedData, /* ISM_ID */ + unpackUnsupportedData, /* ISM_GAIN */ + unpackUnsupportedData, /* ISM_ORIENTATION */ + unpackUnsupportedData, /* ISM_POSITION */ + unpackUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ + unpackUnsupportedData, /* ISM_DIRECTIVITY */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + unpackDiegetic, /* DIEGETIC_TYPE */ +#else + unpackUnsupportedData, /* DIEGETIC_TYPE */ +#endif + unpackUnsupportedData, /* RESERVED13 */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + unpackAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ +#else + unpackUnsupportedData, /* AUDIO_FOCUS_INDICATION */ +#endif + unpackUnsupportedData, /* RESERVED15 */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + unpackOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ + unpackOrientation, /* HEAD_ORIENTATION */ + unpackListenerPosition, /* LISTENER_POSITION */ + unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ + unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ +#else + unpackUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ + unpackUnsupportedData, /* HEAD_ORIENTATION */ + unpackUnsupportedData, /* LISTENER_POSITION */ + unpackUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ + unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ +#endif + unpackUnsupportedData, /* PI_LATENCY */ + unpackUnsupportedData, /* R_ISM_ID */ + unpackUnsupportedData, /* R_ISM_GAIN */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + unpackOrientation, /* R_ISM_ORIENTATION */ +#else + unpackUnsupportedData, /* R_ISM_ORIENTATION */ +#endif + unpackUnsupportedData, /* R_ISM_POSITION */ + unpackUnsupportedData, /* R_ISM_DIRECTION */ + unpackUnsupportedData, /* RESERVED27 */ + unpackUnsupportedData, /* RESERVED28 */ + unpackUnsupportedData, /* RESERVED29 */ + unpackUnsupportedData, /* RESERVED30 */ + unpackNoPiData /* NO_DATA */ +}; + +static const uint32_t maxPiDataSize[IVAS_PI_MAX_ID] = { + 8, /* IVAS_PI_SCENE_ORIENTATION */ + 8, /* IVAS_PI_DEVICE_ORIENTATION_COMPENSATED */ + 8, /* IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED */ + 8, /* IVAS_PI_ACOUSTIC_ENVIRONMENT */ + 5, /* IVAS_PI_AUDIO_DESCRIPTION */ + 1, /* IVAS_PI_ISM_NUM */ + 4, /* IVAS_PI_ISM_ID */ + 4, /* IVAS_PI_ISM_GAIN */ + 32, /* IVAS_PI_ISM_ORIENTATION */ + 24, /* IVAS_PI_ISM_POSITION */ + 12, /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ + 8, /* IVAS_PI_ISM_DIRECTIVITY */ + 1, /* IVAS_PI_DIEGETIC_TYPE */ + 0, /* IVAS_PI_RESERVED13 */ + 9, /* IVAS_PI_AUDIO_FOCUS_INDICATION */ + 0, /* IVAS_PI_RESERVED15 */ + 8, /* IVAS_PI_PLAYBACK_DEVICE_ORIENTATION */ + 8, /* IVAS_PI_HEAD_ORIENTATION */ + 6, /* IVAS_PI_LISTENER_POSITION */ + 2, /* IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION */ + 9, /* IVAS_PI_AUDIO_FOCUS_REQUEST */ + 4, /* IVAS_PI_PI_LATENCY */ + 1, /* IVAS_PI_R_ISM_ID */ + 1, /* IVAS_PI_R_ISM_GAIN */ + 8, /* IVAS_PI_R_ISM_ORIENTATION */ + 6, /* IVAS_PI_R_ISM_POSITION */ + 2, /* IVAS_PI_R_ISM_DIRECTION */ + 0, /* IVAS_PI_RESERVED27 */ + 0, /* IVAS_PI_RESERVED28 */ + 0, /* IVAS_PI_RESERVED29 */ + 0, /* IVAS_PI_RESERVED30 */ + 0, /* IVAS_PI_NO_DATA = 31 */ +}; + +ivas_error PI_PackData( const IVAS_PIDATA_GENERIC *piData, PIDATA_PACKED *packed, uint8_t pmBits ) +{ + uint32_t type = (IVAS_PI_TYPE) ( piData->piDataType & MASK_5BIT ); + ivas_error error = packPiDataFuntions[type]( piData, packed->data, sizeof( packed->data ), &packed->size ); + if ( error == IVAS_ERR_OK ) + { + packed->data[0] |= pmBits; /* Update the PM bits */ + } + assert( packed->size != 0 ); + return error; +} + +ivas_error PI_UnPackData( uint8_t piDataType, uint32_t piSize, const uint8_t *piDataBuffer, IVAS_PIDATA_GENERIC *piData ) +{ + ivas_error error; + + /* Sanitize maximum sizes for each PI Type */ + if ( piSize > maxPiDataSize[piDataType] ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Max size for PI Data type exceeded" ); + } + + error = unpackPiDataFuntions[piDataType]( piDataBuffer, piSize, piData ); + ERR_CHECK_RETURN( error ); + + /* since some pi data share piData structure, pi id are re-filled after unpacking */ + piData->piDataType = piDataType; + + return IVAS_ERR_OK; +} + +/* PIDATA Tables */ +const float mapRT60[1u << NBITS_RT60] = { + 0.01f, 0.0126f, 0.0159f, 0.02f, 0.0252f, 0.0317f, 0.04f, 0.0504f, + 0.0635f, 0.08f, 0.1008f, 0.1270f, 0.16f, 0.2016f, 0.2540f, 0.32f, + 0.4032f, 0.5080f, 0.64f, 0.8063f, 1.0159f, 1.28f, 1.6127f, 2.0319f, + 2.56f, 3.2254f, 4.0637f, 5.12f, 6.4508f, 8.1275f, 10.24f, 12.9016f +}; + +const float mapDSR[1u << NBITS_DSR] = { + -20.f, -21.f, -22.f, -23.f, -24.f, -25.f, -26.f, -27.f, + -28.f, -29.f, -30.f, -31.f, -32.f, -33.f, -34.f, -35.f, + -36.f, -37.f, -38.f, -39.f, -40.f, -41.f, -42.f, -43.f, + -44.f, -45.f, -46.f, -47.f, -48.f, -49.f, -50.f, -51.f, + -52.f, -53.f, -54.f, -55.f, -56.f, -57.f, -58.f, -59.f, + -60.f, -61.f, -62.f, -63.f, -64.f, -65.f, -66.f, -67.f, + -68.f, -69.f, -70.f, -71.f, -72.f, -73.f, -74.f, -75.f, + -76.f, -77.f, -78.f, -79.f, -80.f, -81.f, -82.f, -83.f +}; + +const float mapRoomDims[1u << NBITS_DIM] = { + 0.5f, 0.707f, 1.f, 1.4141f, 2, 2.8282f, 4.f, 5.6568f, + 8.f, 11.314f, 16.f, 22.627f, 32.f, 45.255f, 64.f, 90.51f +}; + +const float mapAbsorbtion[1u << NBITS_ABS] = { + 0.0800f, 0.1656f, 0.3430f, 0.7101f +}; + + +#endif /* IVAS_RTPDUMP */ diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h new file mode 100644 index 000000000..3fc95f8d8 --- /dev/null +++ b/lib_util/ivas_rtp_pi_data.h @@ -0,0 +1,471 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef IVAS_RTP_PI_DATA_H +#define IVAS_RTP_PI_DATA_H + +#include "common_api_types.h" + +#ifdef IVAS_RTPDUMP + +#define IVAS_PI_MAX_DATA_SIZE ( 32 + 2 ) /* max packed PI data bytes + pi header bytes */ + +/* IVAS PI Data Types */ +typedef enum +{ + /* Forward direction PI types */ + IVAS_PI_SCENE_ORIENTATION, /* orientation of audio scene in unit quaternions */ + IVAS_PI_DEVICE_ORIENTATION_COMPENSATED, /* orientation of device in unit quaternions (compensated) */ + IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED, /* orientation of device in unit quaternions (un-compensated) */ + IVAS_PI_ACOUSTIC_ENVIRONMENT, /* describe the acoustic environment */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_PI_AUDIO_DESCRIPTION, /* audio content description (voice/music/ambiance) */ + IVAS_PI_ISM_NUM, /* Number of objects */ + IVAS_PI_ISM_ID, /* id of each object */ + IVAS_PI_ISM_GAIN, /* gain of each object */ + IVAS_PI_ISM_ORIENTATION, /* orientation of each object */ + IVAS_PI_ISM_POSITION, /* position of each object */ + IVAS_PI_ISM_DISTANCE_ATTENUATION, /* distance attenuation for each object */ + IVAS_PI_ISM_DIRECTIVITY, /* directivity of each object */ + IVAS_PI_DIEGETIC_TYPE, /* digetic audio indication */ + IVAS_PI_RESERVED13, /* reserved */ + IVAS_PI_AUDIO_FOCUS_INDICATION, /* audio focus indication (direction in Quaternions and/or level) */ + IVAS_PI_RESERVED15, /* reserved */ + + /* Reverse direction PI types */ + IVAS_PI_PLAYBACK_DEVICE_ORIENTATION, /* orientation of the playback device in quaternions */ + IVAS_PI_HEAD_ORIENTATION, /* head orientation of the listener in Quaternions */ + IVAS_PI_LISTENER_POSITION, /* position of the listener in 3D space */ + IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION, /* receiver’s preference with respect to audio suppression */ + IVAS_PI_AUDIO_FOCUS_REQUEST, /* direction of interest for the listener in Quaternions and/or audio focus level */ + IVAS_PI_PI_LATENCY, /* round-trip latency for PI frames */ + IVAS_PI_R_ISM_ID, /* id of an object for editing */ + IVAS_PI_R_ISM_GAIN, /* editing request for gain factor for received object */ + IVAS_PI_R_ISM_ORIENTATION, /* editing request for orientation for received object */ + IVAS_PI_R_ISM_POSITION, /* editing request for position for received object */ + IVAS_PI_R_ISM_DIRECTION, /* editing request for direction for received object */ + IVAS_PI_RESERVED27, /* reserved */ + IVAS_PI_RESERVED28, /* reserved */ + IVAS_PI_RESERVED29, /* reserved */ + IVAS_PI_RESERVED30, /* reserved */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_PI_NO_DATA = 31, /* Indicates an empty PI data frame */ + IVAS_PI_MAX_ID /* Max number of PI data IDs supprted */ +} IVAS_PI_TYPE; + +/* cartesian coordinates (X,Y,Z) in 3D space */ +typedef struct +{ + float x, y, z; +} IVAS_COORDINATE; + +/* orientation data corresponding to any of the following pi data types :- + * - IVAS_PI_SCENE_ORIENTATION + * - IVAS_PI_DEVICE_ORIENTATION_COMPENSATED + * - IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED + * - IVAS_PI_PLAYBACK_DEVICE_ORIENTATION + * - IVAS_PI_HEAD_ORIENTATION + * - IVAS_PI_R_ISM_ORIENTATION + * + * piDataType is used to identify the correct pi data type contained here + */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_SCENE_ORIENTATION) */ + uint32_t piDataType; /* one of supported orientation data types */ + IVAS_QUATERNION orientation; /* orientation data expressed as quartenions */ +} IVAS_PIDATA_ORIENTATION; + +/* Acoustic environment corresponding to IVAS_PI_ACOUSTIC_ENVIRONMENT + * + * acoustic environment ID + * late reverb parameters + * - RT60 – indicating the time that it takes for the reflections to reduce 60 dB in energy level, per frequency band + * - DSR – diffuse to source signal energy ratio, per frequency band + * - Pre-delay – delay at which the computation of DSR values was performed + * early reflections + * - 3D rectangular virtual room dimensions + * - Broadband energy absorption coefficient per wall surface + */ +typedef enum +{ + IVAS_PI_AE_LOW, /* center frequency 25 Hz */ + IVAS_PI_AE_MID, /* center frequency 250 Hz */ + IVAS_PI_AE_HIGH, /* center frequency 2.5 kHz */ + IVAS_PI_AE_NUM_BANDS /* number of ae bands */ +} IVAS_PI_AE_BANDS; + +typedef enum +{ + IVAS_PI_AE_FRONT, + IVAS_PI_AE_BACK, + IVAS_PI_AE_LEFT, + IVAS_PI_AE_RIGHT, + IVAS_PI_AE_CEILING, + IVAS_PI_AE_FLOOR, + IVAS_PI_AE_NUM_SURFACE +} IVAS_PI_AE_SURFACE; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ACOUSTIC_ENV) */ + uint32_t piDataType; /* IVAS_PI_ACOUSTIC_ENVIRONMENT */ + bool availLateReverb; /* AE contains only late reverb parameters */ + bool availEarlyReflections; /* AE containing late reverb and simplified early reflections */ + uint8_t aeid; /* seven-bit acoustic environment identifier */ + + /* only valid if availLateReverb==true or availEarlyReflections==true */ + float rt60[IVAS_PI_AE_NUM_BANDS]; /* time for the reflections to reduce 60 dB per band in seconds */ + float dsr[IVAS_PI_AE_NUM_BANDS]; /* diffuse to source signal energy ratio per band in dB */ + + /* only valid if availEarlyReflections==true */ + IVAS_COORDINATE roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ + float absorbCoeffs[IVAS_PI_AE_NUM_SURFACE]; /* absorption coefficients for all surfaces */ +} IVAS_PIDATA_ACOUSTIC_ENV; + +#ifdef RTP_S4_251135_CR26253_0016_REV1 +/* Audio Description corresponding to IVAS_PI_AUDIO_DESCRIPTION + * Describe the following audio decriptors per object/type :- + * - audio content type is speech/music/ambiance + * - if audio rendering is editable + * - if stereo audio is binaural + * + * number of valid entries decide on basis of audio format:- + * - Stereo/SBA/MASA = 1 entry + * - MultiChannel = 2 entries (1 for center channel + 1 for all other channels) + * - ISM = Number of Object entries ( 1 per object ) + * - OMASA/OSBA = 1 + Num Discrete Coded Objects + * + */ +typedef struct +{ + bool speech; /* audio has voice/speech */ + bool music; /* audio has music */ + bool ambiance; /* audio has background ambiance */ + bool editable; /* rendering audio metadata is editable */ + bool binaural; /* stereo stream is binaural */ +} IVAS_AUDIO_ID; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_AUDIO_DESC) */ + uint32_t piDataType; /* IVAS_PI_AUDIO_DESCRIPTION */ + uint32_t nValidEntries; /* Number of valid audio IDs */ + IVAS_AUDIO_ID audioId[1 + IVAS_MAX_NUM_OBJECTS]; /* audio id as per format */ +} IVAS_PIDATA_AUDIO_DESC; + +/* ISM specific PI data related to PI types : - + * + * - IVAS_PI_ISM_NUM + * - IVAS_PI_ISM_ID + * - IVAS_PI_ISM_GAIN + * - IVAS_PI_ISM_ORIENTATION + * - IVAS_PI_ISM_POSITION + * - IVAS_PI_ISM_DISTANCE_ATTENUATION + * - IVAS_PI_ISM_DIRECTIVITY + */ + +/* Number of ISMs */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_NUM) */ + uint32_t piDataType; /* IVAS_PI_ISM_NUM */ + uint32_t numObjects; /* Number of ISM */ +} IVAS_PIDATA_ISM_NUM; + +/* ISM ID */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ + uint32_t piDataType; /* IVAS_PI_ISM_ID */ + uint8_t id[IVAS_MAX_NUM_OBJECTS]; /* 8-bit ISM id of object */ +} IVAS_PIDATA_ISM_ID; + +/* ISM gain */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ + uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ + int8_t dB[IVAS_MAX_NUM_OBJECTS]; /* ISM gain in dB per object [-96, +3] */ +} IVAS_PIDATA_ISM_GAIN; + +/* ISM orientation */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ + uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ + IVAS_QUATERNION orientation[IVAS_MAX_NUM_OBJECTS]; /* Orientation of audio objects in ISM(s) */ +} IVAS_PIDATA_ISM_ORIENTATION; + +/* ISM position */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ + uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ + IVAS_COORDINATE position[IVAS_MAX_NUM_OBJECTS]; /* Position of audio objects in ISM(s) */ +} IVAS_PIDATA_ISM_POSITION; + +/* ISM distance attenuation comprising of following gains per ISM + * - reference distance + * - maximum distance + * - roll-off factor + */ +typedef struct +{ + float ref_dist; /* reference distance in meters */ + float max_dist; /* maximum distance in meters */ + float roll; /* roll-off factor values */ +} IVAS_DIST_ATTEN; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ + uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ + IVAS_DIST_ATTEN distAtten[IVAS_MAX_NUM_OBJECTS]; /* Distance attenuation of audio objects */ +} IVAS_PIDATA_ISM_ATTENUATION; + +/* ISM Directivity comprising of following per ISM :- + * - inner cone angle determines the size of the main cone directed to the front of the object + * - outer cone angle determines the size of the outer (back) cone + * - outer attenuation gain determines the attenuation outside the outer cone + */ +typedef struct +{ + uint16_t innerConeAngle; /* inner cone angle in degrees (0 - 360) */ + uint16_t outerConeAngle; /* outer cone angle in degrees (0 - 360) */ + float outerAttenuationdB; /* attenuation outside the outer cone in dB */ +} IVAS_ISM_DIRECTIVITY; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ + uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ + IVAS_ISM_DIRECTIVITY directivity[IVAS_MAX_NUM_OBJECTS]; /* Directivity of audio objects */ +} IVAS_PIDATA_ISM_DIRECTIVITY; + +/* Diegetic and non-diegetic indication flag as per audio format + * + * number of valid entries decided on basis of audio format:- + * - Stereo/SBA/MASA/MultiChannel = 1 entry + * - ISM = Number of Object entries ( 1 per object ) + * - OMASA/OSBA = 1 (last) + Num Discrete Coded Objects + */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_DIEGETIC) */ + uint32_t piDataType; /* IVAS_PI_DIEGETIC_TYPE */ + bool isDiegetic[1 + IVAS_MAX_NUM_OBJECTS]; /* diegetic indication as per audio format */ +} IVAS_PIDATA_DIEGETIC; + +/* Audio focus direction indicates a direction of interest. + * The audio focus level indicates the amount of suppression applied to the + * directions other than the audio focus direction. + */ +typedef enum +{ + IVAS_FLVL_NO_AUDIO_FOCUS = 0, /* Apply no audio focus */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_1, /* Audio focus level 1 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_2, /* Audio focus level 2 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_3, /* Audio focus level 3 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_4, /* Audio focus level 4 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_5, /* Audio focus level 5 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_6, /* Audio focus level 6 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_7, /* Audio focus level 7 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_8, /* Audio focus level 8 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_9, /* Audio focus level 9 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_10, /* Audio focus level 10 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_11, /* Audio focus level 11 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_12, /* Audio focus level 12 */ + IVAS_FLVL_FOCUS_LEVEL_LEVEL_13, /* Audio focus level 13 */ + IVAS_FLVL_DEFAULT_AUDIO_FOCUS, /* Default audio focus */ + IVAS_FLVL_MAX_AUDIO_FOCUS, /* Apply max audio focus */ +} IVAS_FLVL; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_AUDIO_FOCUS) */ + uint32_t piDataType; /* IVAS_PI_AUDIO_FOCUS_INDCATION or IVAS_PI_AUDIO_FOCUS_REQUEST */ + bool availDirection; /* audio focus contains direction */ + bool availLevel; /* audio focus contains level */ + IVAS_QUATERNION direction; /* direction data expressed as quarternions */ + IVAS_FLVL flvl; /* audio focus level */ +} IVAS_PIDATA_AUDIO_FOCUS; + +/* Listener position */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_LISTENER_POSITION) */ + uint32_t piDataType; /* IVAS_PI_LISTENER_POSITION */ + IVAS_COORDINATE position; /* Position of audio objects in ISM(s) */ +} IVAS_PIDATA_LISTENER_POSITION; + + +/* Dynamic Audio Suppression describes receiver’s preference with respect to the + * type of audio content that should be enhanced and the amount of suppression to + * be applied to the background noise + */ +typedef enum +{ + IVAS_SLI_NO_SUPPRESSION = 0, /* Apply no suppression */ + IVAS_SLI_SUPPRESSION_LEVEL_1, /* Suppression level 1 */ + IVAS_SLI_SUPPRESSION_LEVEL_2, /* Suppression level 2 */ + IVAS_SLI_SUPPRESSION_LEVEL_3, /* Suppression level 3 */ + IVAS_SLI_SUPPRESSION_LEVEL_4, /* Suppression level 4 */ + IVAS_SLI_SUPPRESSION_LEVEL_5, /* Suppression level 5 */ + IVAS_SLI_SUPPRESSION_LEVEL_6, /* Suppression level 6 */ + IVAS_SLI_SUPPRESSION_LEVEL_7, /* Suppression level 7 */ + IVAS_SLI_SUPPRESSION_LEVEL_8, /* Suppression level 8 */ + IVAS_SLI_SUPPRESSION_LEVEL_9, /* Suppression level 9 */ + IVAS_SLI_SUPPRESSION_LEVEL_10, /* Suppression level 10 */ + IVAS_SLI_SUPPRESSION_LEVEL_11, /* Suppression level 11 */ + IVAS_SLI_SUPPRESSION_LEVEL_12, /* Suppression level 12 */ + IVAS_SLI_SUPPRESSION_LEVEL_13, /* Suppression level 13 */ + IVAS_SLI_SUPPRESSION_LEVEL_14, /* Suppression level 14 */ + IVAS_SLI_MAX_SUPPRESSION, /* Apply max suppression */ +} IVAS_SLI; + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_DYNAMIC_SUPPRESSION) */ + uint32_t piDataType; /* IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION */ + bool speech; /* receiver's preference is voice/speech */ + bool music; /* receiver's preference is music */ + bool ambiance; /* receiver's preference is background ambiance */ + IVAS_SLI sli; /* suppression level indicator [0, 15] */ +} IVAS_PIDATA_DYNAMIC_SUPPRESSION; + +/* Reverse PI latency calculated as the elapsed time between the sent reverse PI data + * and received forward PI data. It is based on the receiving device experiencing the + * result of its sent data by receiving the corresponding data in forward direction as + * forward PI data + */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_REVERSE_PI_LATENCY) */ + uint32_t piDataType; /* IVAS_PI_PI_LATENCY */ + IVAS_PI_TYPE type; /* Reverse PI used for computation of Latency */ + int32_t latency; /* Latency as 27-bit int on RTP Clock @ 16KHz */ +} IVAS_PIDATA_REVERSE_PI_LATENCY; + +/* ISM specific PI data editing requests */ + +/* ISM ID in editing requests */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_ID) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_ID */ + uint8_t id; /* 8-bit ISM id of object to edit */ +} IVAS_PIDATA_ISM_EDIT_ID; + +/* Editing request for ISM gain */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_GAIN) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_GAIN */ + int8_t dB; /* Preferred ISM gain in dB [-96, +3] */ +} IVAS_PIDATA_ISM_EDIT_GAIN; + +/* Editing request for ISM orientation */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_ORIENTATION) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_ORIENTATION */ + IVAS_QUATERNION orientation; /* orientation editing request for received ISM */ +} IVAS_PIDATA_ISM_EDIT_ORIENTATION; + +/* Editing request for ISM position */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_POSITION) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_POSITION */ + IVAS_COORDINATE position; /* Positional editing request for received ISM */ +} IVAS_PIDATA_ISM_EDIT_POSITION; + +/* Editing request for ISM direction */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_ISM_EDIT_DIRECTION) */ + uint32_t piDataType; /* IVAS_PI_R_ISM_DIRECTION */ + float azimuth; /* azimuth angle in degrees [-180, 180] */ + float elevation; /* elevation angle in degrees [-90°, 90°] */ +} IVAS_PIDATA_ISM_EDIT_DIRECTION; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_NO_DATA) */ + uint32_t piDataType; /* IVAS_PI_NO_DATA */ +} IVAS_PIDATA_NO_DATA; + + +typedef union +{ + IVAS_PIDATA_ORIENTATION scene; + IVAS_PIDATA_ORIENTATION deviceCompensated; + IVAS_PIDATA_ORIENTATION deviceUnCompensated; + IVAS_PIDATA_ACOUSTIC_ENV acousticEnv; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_PIDATA_AUDIO_DESC audioDesc; + IVAS_PIDATA_ISM_NUM ismNum; + IVAS_PIDATA_ISM_ID ismId; + IVAS_PIDATA_ISM_GAIN ismGain; + IVAS_PIDATA_ISM_ORIENTATION ismOrientation; + IVAS_PIDATA_ISM_POSITION ismPosition; + IVAS_PIDATA_ISM_ATTENUATION ismAttenuation; + IVAS_PIDATA_ISM_DIRECTIVITY ismDirectivity; + IVAS_PIDATA_DIEGETIC digeticIndicator; + IVAS_PIDATA_AUDIO_FOCUS focusIndication; + + IVAS_PIDATA_ORIENTATION playbackOrientation; + IVAS_PIDATA_ORIENTATION headOrientation; + IVAS_PIDATA_LISTENER_POSITION listnerPosition; + IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppression; + IVAS_PIDATA_AUDIO_FOCUS focusRequest; + IVAS_PIDATA_REVERSE_PI_LATENCY piLatency; + IVAS_PIDATA_ISM_EDIT_ID ismEditId; + IVAS_PIDATA_ISM_EDIT_GAIN ismEditGain; + IVAS_PIDATA_ISM_EDIT_ORIENTATION ismEditOrientation; + IVAS_PIDATA_ISM_EDIT_POSITION ismEditPosition; + IVAS_PIDATA_ISM_EDIT_DIRECTION ismEditDirection; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_PIDATA_NO_DATA noPiData; +} PIDATA; + +typedef struct +{ + PIDATA data; + uint32_t timestamp; +} PIDATA_TS; + +#endif /* IVAS_RTPDUMP */ + +#endif /* IVAS_RTP_PI_DATA_H */ diff --git a/lib_util/mutex.h b/lib_util/mutex.h new file mode 100644 index 000000000..82094b61c --- /dev/null +++ b/lib_util/mutex.h @@ -0,0 +1,104 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 + ====================================================================================*/ + +#ifndef _MUTEX_H +#define _MUTEX_H + +#if defined( __unix__ ) || defined( __linux__ ) || ( defined( __MACH__ ) && defined( __APPLE__ ) ) +#include +typedef pthread_mutex_t mtx_t; +#define _USE_POSIX ( 1 ) +#elif defined( _WIN32 ) || defined( _WIN64 ) +#include +typedef CRITICAL_SECTION mtx_t; +#define _USE_WIN ( 1 ) +#else +typedef int mtx_t; +#warning Mutex implementation to be defined for this platform here. +#endif + +static __inline int mtx_init( mtx_t *mutex, int type ) +{ + int err = 0; + (void) type; +#ifdef _USE_POSIX + err = pthread_mutex_init( mutex, NULL ); +#elif defined( _USE_WIN ) + InitializeCriticalSection( mutex ); +#else + (void) mutex; +#endif + return err; +} + +static __inline void mtx_destroy( mtx_t *mutex ) +{ +#if _USE_POSIX + pthread_mutex_destroy( mutex ); +#elif defined( _USE_WIN ) + DeleteCriticalSection( mutex ); +#else + (void) mutex; +#endif +} + +static __inline int mtx_lock( mtx_t *mutex ) +{ + int err = 0; +#if _USE_POSIX + err = pthread_mutex_lock( mutex ); +#elif defined( _USE_WIN ) + EnterCriticalSection( mutex ); +#else + (void) mutex; +#endif + return err; +} + +static __inline int mtx_unlock( mtx_t *mutex ) +{ + int err = 0; +#if _USE_POSIX + err = pthread_mutex_unlock( mutex ); +#elif defined( _USE_WIN ) + LeaveCriticalSection( mutex ); +#else + (void) mutex; +#endif + return err; +} + +#endif /* _MUTEX_H */ diff --git a/lib_util/rtpdump.c b/lib_util/rtpdump.c index d2f13f6bc..5c9faf59a 100644 --- a/lib_util/rtpdump.c +++ b/lib_util/rtpdump.c @@ -38,6 +38,7 @@ #include #include #include "rtpdump.h" +#include "options.h" struct RTPDUMP { @@ -118,10 +119,17 @@ static int readShort( FILE *file, unsigned short *value ) static int writeLong( FILE *file, unsigned int value ) { char buffer[4] = { 0 }; +#ifdef IVAS_RTPDUMP + buffer[3] = (char) ( value & 0xff ); + buffer[2] = (char) ( ( value >> 8 ) & 0xff ); + buffer[1] = (char) ( ( value >> 16 ) & 0xff ); + buffer[0] = (char) ( ( value >> 24 ) & 0xff ); +#else buffer[3] = value & 0xff; buffer[2] = ( value >> 8 ) & 0xff; buffer[1] = ( value >> 16 ) & 0xff; buffer[0] = ( value >> 24 ) & 0xff; +#endif if ( fwrite( buffer, 4, 1, file ) != 1U ) { return -1; @@ -133,8 +141,13 @@ static int writeLong( FILE *file, unsigned int value ) static int writeShort( FILE *file, unsigned short value ) { char buffer[2] = { 0 }; +#ifdef IVAS_RTPDUMP + buffer[1] = (char) ( value & 0xff ); + buffer[0] = (char) ( ( value >> 8 ) & 0xff ); +#else buffer[1] = value & 0xff; buffer[0] = ( value >> 8 ) & 0xff; +#endif if ( fwrite( buffer, 2, 1, file ) != 1U ) { return -1; diff --git a/readme.txt b/readme.txt index 391e0a35f..65be85c12 100644 --- a/readme.txt +++ b/readme.txt @@ -250,7 +250,12 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. Currently, all values default to level 3 (full functionality). -q : Quiet mode, limit printouts to terminal, default is deactivated - +-rtpdump : RTPDump output, hf_only=1 by default. The encoder will packetize the + bitstream frames into TS26.253 Annex A IVAS RTP Payload Format packets and + writes those to the output file. In EVS mono operating mode, TS26.445 Annex A.2.2 + EVS RTP Payload Format is used. Optional N represents number of frames per RTP packet +-scene_orientation : Scene orientation trajectory file. Only used with rtpdump output. +-device_orientation : Device orientation trajectory file. Only used with rtpdump output. The usage of the "IVAS_dec" program is as follows: -------------------------------------------------- @@ -275,9 +280,10 @@ Options: -------- -VOIP : VoIP mode: RTP in G192 -VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump --VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump +-VOIP_hf_only=1 : VoIP mode: EVS or IVAS RTP Payload Format hf_only=1 in rtpdump The decoder may read rtpdump files containing TS26.445 Annex A.2.2 - EVS RTP Payload Format. The SDP parameter hf_only is required. + EVS RTP Payload Format or rtpdump files containing TS26.253 Annex A + IVAS RTP Payload Format. The SDP parameter hf_only is required. Reading RFC4867 AMR/AMR-WB RTP payload format is not supported. -Tracefile TF : VoIP mode: Generate trace file named TF. Requires -no_delay_cmp to be enabled so that trace contents remain in sync with audio output. -- GitLab From 61bf6252ec5740cd2e9af3e7dbade718c84a2174 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 12:02:54 +0200 Subject: [PATCH 124/351] Adapt PI orientations to use fx orientations --- lib_util/ivas_rtp_file.c | 12 ++++++------ lib_util/ivas_rtp_pi_data.c | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 8555480ef..f5da78017 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -191,8 +191,8 @@ void IVAS_RTP_LogPiData( case IVAS_PI_R_ISM_ORIENTATION: #endif { - fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", - cur->data.scene.orientation.w, cur->data.scene.orientation.x, cur->data.scene.orientation.y, cur->data.scene.orientation.z ); + fprintf( f_piDataOut, "{\n\t\t\t\"w\": %d,\n\t\t\t\"x\": %d,\n\t\t\t\"y\": %d,\n\t\t\t\"z\": %d \n\t\t}", + cur->data.scene.orientation.w_fx, cur->data.scene.orientation.x_fx, cur->data.scene.orientation.y_fx, cur->data.scene.orientation.z_fx ); } break; @@ -259,8 +259,8 @@ void IVAS_RTP_LogPiData( if ( cur->data.focusIndication.availDirection ) { fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); - fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", - cur->data.focusIndication.direction.w, cur->data.focusIndication.direction.x, cur->data.focusIndication.direction.y, cur->data.focusIndication.direction.z ); + fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %d,\n\t\t\t\t\t\t\"x\": %d,\n\t\t\t\t\t\t\"y\": %d,\n\t\t\t\t\t\t\"z\": %d \n\t\t\t}", + cur->data.focusIndication.direction.w_fx, cur->data.focusIndication.direction.x_fx, cur->data.focusIndication.direction.y_fx, cur->data.focusIndication.direction.z_fx ); if ( cur->data.focusIndication.availLevel ) { fprintf( f_piDataOut, "," ); @@ -291,8 +291,8 @@ void IVAS_RTP_LogPiData( if ( cur->data.focusRequest.availDirection ) { fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); - fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", - cur->data.focusRequest.direction.w, cur->data.focusRequest.direction.x, cur->data.focusRequest.direction.y, cur->data.focusRequest.direction.z ); + fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %d,\n\t\t\t\t\t\t\"x\": %d,\n\t\t\t\t\t\t\"y\": %d,\n\t\t\t\t\t\t\"z\": %d \n\t\t\t}", + cur->data.focusRequest.direction.w_fx, cur->data.focusRequest.direction.x_fx, cur->data.focusRequest.direction.y_fx, cur->data.focusRequest.direction.z_fx ); if ( cur->data.focusRequest.availLevel ) { fprintf( f_piDataOut, "," ); diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 7150cfe4a..419d2ea9f 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -145,10 +145,10 @@ static ivas_error packOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t *b buffer[nBytes++] = ( orientation->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ buffer[nBytes++] = 8; - nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( orientation->orientation.w ) ); - nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( orientation->orientation.x ) ); - nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( orientation->orientation.y ) ); - nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( orientation->orientation.z ) ); + nBytes = writeInt16( buffer, nBytes, orientation->orientation.w_fx ); + nBytes = writeInt16( buffer, nBytes, orientation->orientation.x_fx ); + nBytes = writeInt16( buffer, nBytes, orientation->orientation.y_fx ); + nBytes = writeInt16( buffer, nBytes, orientation->orientation.z_fx ); *nBytesWritten = nBytes; return IVAS_ERR_OK; @@ -165,10 +165,10 @@ static ivas_error unpackOrientation( const uint8_t *buffer, uint32_t numDataByte } piData->size = sizeof( IVAS_PIDATA_ORIENTATION ); - orientation->orientation.w = FLOAT_FROM_Q15( readInt16( &buffer[0] ) ); - orientation->orientation.x = FLOAT_FROM_Q15( readInt16( &buffer[2] ) ); - orientation->orientation.y = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ); - orientation->orientation.z = FLOAT_FROM_Q15( readInt16( &buffer[6] ) ); + orientation->orientation.w_fx = readInt16( &buffer[0] ); + orientation->orientation.x_fx = readInt16( &buffer[2] ); + orientation->orientation.y_fx = readInt16( &buffer[4] ); + orientation->orientation.z_fx = readInt16( &buffer[6] ); return IVAS_ERR_OK; } @@ -583,10 +583,10 @@ static ivas_error packAudioFocusCommon( const IVAS_PIDATA_GENERIC *piData, uint8 if ( packedSize == 9 || packedSize == 8 ) { - nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( audioFocus->direction.w ) ); - nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( audioFocus->direction.x ) ); - nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( audioFocus->direction.y ) ); - nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( audioFocus->direction.z ) ); + nBytes = writeInt16( buffer, nBytes, audioFocus->direction.w_fx ); + nBytes = writeInt16( buffer, nBytes, audioFocus->direction.x_fx ); + nBytes = writeInt16( buffer, nBytes, audioFocus->direction.y_fx ); + nBytes = writeInt16( buffer, nBytes, audioFocus->direction.z_fx ); } if ( packedSize == 9 || packedSize == 1 ) { @@ -617,10 +617,10 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat } else { - audioFocus->direction.w = FLOAT_FROM_Q15( readInt16( &buffer[0] ) ); - audioFocus->direction.x = FLOAT_FROM_Q15( readInt16( &buffer[2] ) ); - audioFocus->direction.y = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ); - audioFocus->direction.z = FLOAT_FROM_Q15( readInt16( &buffer[6] ) ); + audioFocus->direction.w_fx = readInt16( &buffer[0] ); + audioFocus->direction.x_fx = readInt16( &buffer[2] ); + audioFocus->direction.y_fx = readInt16( &buffer[4] ); + audioFocus->direction.z_fx = readInt16( &buffer[6] ); if ( numDataBytes == 9 ) { -- GitLab From f986548d5f2fa95f7749fedb0a631b1fa9deb41a Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 12:04:49 +0200 Subject: [PATCH 125/351] Port float MR2296 sanitizer fix --- lib_util/ivas_rtp_payload.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 4e4b11f2a..e759f674b 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -199,7 +199,10 @@ ivas_error IVAS_RTP_PACK_UpdateHeader( header->ssrc = ssrc; header->CC = numCC; - memcpy( header->CSRC, csrc, numCC & 0xF ); + if ( csrc != NULL ) + { + memcpy( header->CSRC, csrc, numCC & 0xF ); + } if ( ( numExtensionBytes > 0 ) && ( extData != NULL ) ) { -- GitLab From abad172317e16975e3f24c0915a59e1905891aa3 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 12:15:24 +0200 Subject: [PATCH 126/351] Add compact frame encoding --- lib_com/bitstream_fx.c | 32 ++++++++++++++++++++++++++++++++ lib_com/prot_fx.h | 8 ++++++++ 2 files changed, 40 insertions(+) diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index b1c7a2efd..334fa3dbc 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -3839,6 +3839,38 @@ ivas_error write_indices_ivas_fx( return error; } +#ifdef IVAS_RTPDUMP + + +/*---------------------------------------------------------------------* + * convertSerialToBytestream( ) + * + * convert 16-bit short serial streams with 0x0000 and 0x0001 to a bytstream + *---------------------------------------------------------------------*/ + +void convertSerialToBytestream_fx( + const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ + const UWord16 num_bits, /* i : number of bits in the input bitstream */ + UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ +) +{ + UWord32 i; + UWord8 bit, bitinbyte; + + for ( i = 0; i < num_bits; ++i ) + { + bit = ( serial[i] == 0x0001 ) ? 1 : 0; + bitinbyte = bit << ( 7 - ( i & 0x7 ) ); + if ( !( i & 0x7 ) ) + { + bytestream[i >> 3] = 0; + } + bytestream[i >> 3] |= bitinbyte; + } + + return; +} +#endif /*-------------------------------------------------------------------* diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 85984d53d..ddfb27c3a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -11189,6 +11189,14 @@ void ivas_set_bitstream_pointers( Decoder_State **reset_elements( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifdef IVAS_RTPDUMP + +void convertSerialToBytestream_fx( + const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ + const UWord16 num_bits, /* i : number of bits in the input bitstream */ + UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ +); +#endif void mdct_switching_dec_fx( Decoder_State *st /* i/o: decoder state structure */ -- GitLab From 3dcabfbf5c843677edd5ede3d673b087e091af0c Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 12:16:15 +0200 Subject: [PATCH 127/351] Add compact frame encoding (missing add) --- lib_enc/lib_enc_fx.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index a242ad679..522f89d0e 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1525,6 +1525,36 @@ move16(); return error; } +#ifdef IVAS_RTPDUMP + + +/*---------------------------------------------------------------------* + * IVAS_ENC_EncodeFrameToCompact() + * + * Main function to encode one frame to a compact bitstream (bytestream) + *---------------------------------------------------------------------*/ + +ivas_error IVAS_ENC_EncodeFrameToCompact( + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + Word16 *inputBuffer, /* i : PCM input */ + const Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ + UWord8 *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ + UWord16 *numOutBits /* o : number of bits written to output bitstream */ +) +{ + ivas_error error; + UWord16 bitstream[IVAS_MAX_BITS_PER_FRAME]; + + if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, inputBuffer, inputBufferSize, bitstream, numOutBits ) ) != IVAS_ERR_OK ) + { + return error; + } + + convertSerialToBytestream_fx( bitstream, *numOutBits, outputBitStream ); + + return IVAS_ERR_OK; +} +#endif /*---------------------------------------------------------------------* -- GitLab From 6c090f8b69d891344bb0e7d5106750ecd71036e8 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 11:19:04 +0100 Subject: [PATCH 128/351] Use BASOPs for computing allocation size --- lib_dec/lib_dec_fx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e942efd7f..f42e83633 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1239,8 +1239,12 @@ static ivas_error isar_render_poses( /* init flush buffer for rate switch if not already initizalized */ IF( hIvasDec->flushbuffer == NULL ) { - hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); - set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); + /* hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ + /* set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ + Word32 size; + size = L_mult0( mult0( sizeof( Word16 ), mult0( numPoses, BINAURAL_CHANNELS ) ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); + hIvasDec->flushbuffer = (void *) malloc( size ); + set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, size ); } /* render */ -- GitLab From 0ce0cbe1ba3b4c3890a3521cfc9eaaa6670aea8b Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 11:23:17 +0100 Subject: [PATCH 129/351] Initialise flags using if statements --- lib_dec/lib_dec_fx.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f42e83633..81f765506 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1297,8 +1297,16 @@ static ivas_error isar_generate_metadata_and_bitstream( hSplitBinRend = st_ivas->hSplitBinRend; max_band = extract_l( ar_div( imult3216( st_ivas->hDecoderConfig->output_Fs, BINAURAL_MAXBANDS ), 48000 ) ); - pcm_out_flag = extract_l( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ); + move16(); cldfb_in_flag = ivas_dec_split_rend_cldfb_in( st_ivas->renderer_type ); + move16(); + pcm_out_flag = 0; + move16(); + if( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + pcm_out_flag = 1; + move16(); + } n_samples_in_cldfb_slot = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); assert( nSamples % n_samples_in_cldfb_slot == 0 ); @@ -1602,10 +1610,15 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( return IVAS_ERR_WRONG_PARAMS; } - pcm_out_flag = extract_l( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ); - move16(); numSamplesPerChannelToOutput = isar_get_frame_size( st_ivas ); move16(); + pcm_out_flag = 0; + move16(); + if( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + pcm_out_flag = 1; + move16(); + } IF( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { -- GitLab From 953487ed26ac1f599519a8d38e954944429c7241 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 11:25:13 +0100 Subject: [PATCH 130/351] Instrument copy of a struct --- lib_dec/lib_dec_fx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 81f765506..d0e43b16e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1353,6 +1353,12 @@ static ivas_error isar_generate_metadata_and_bitstream( IF( st_ivas->hHeadTrackData != NULL ) { Quaternion = st_ivas->hHeadTrackData->Quaternions[0]; + /* Copy of a struct: 4x Word32 and 1x Word32 */ + move32(); + move32(); + move32(); + move32(); + move16(); } ELSE { -- GitLab From 038bbadbb39d855d22cbd6fc1602475512a0e948 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 11:53:02 +0100 Subject: [PATCH 131/351] Replace leftover == and != with EQ and NE macros --- lib_dec/lib_dec_fx.c | 44 +++++++++++++++++++++++++----------------- lib_rend/lib_rend_fx.c | 8 +++----- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index d0e43b16e..2b92f2b09 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1248,7 +1248,7 @@ static ivas_error isar_render_poses( } /* render */ - IF( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF( NE_32 ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ), IVAS_ERR_OK ) ) { return error; } @@ -1422,7 +1422,7 @@ static ivas_error isar_generate_metadata_and_bitstream( move16(); } - IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, + IF( NE_32( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, Quaternion, st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, st_ivas->hRenderConfig->split_rend_config.codec, @@ -1431,7 +1431,7 @@ static ivas_error isar_generate_metadata_and_bitstream( splitRendBits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -1611,7 +1611,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( st_ivas = hIvasDec->st_ivas; - IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) + IF( EQ_16( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ), 0 ) ) { return IVAS_ERR_WRONG_PARAMS; } @@ -1626,7 +1626,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( move16(); } - IF( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = isar_render_poses( hIvasDec, numSamplesPerChannelToOutput, nOutSamples, needNewFrame ) ), IVAS_ERR_OK ) ) { return error; } @@ -1641,7 +1641,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( p_head_pose_buf[i] = head_pose_buf[i]; } - IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nOutSamples, splitRendBits, Q_out ) ), IVAS_ERR_OK ) ) { return error; } @@ -1653,7 +1653,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } - IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); @@ -2002,7 +2002,7 @@ static ivas_error ivas_dec_setup_all( test(); #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( st_ivas->ini_frame == 0 && splitRendBits != NULL ) + IF( EQ_16( st_ivas->ini_frame, 0 ) && splitRendBits != NULL ) #else IF( st_ivas->ini_frame == 0 && isSplitRend ) #endif @@ -3851,7 +3851,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( *-----------------------------------------------------------------*/ #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, splitRendBits ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, splitRendBits ) ), IVAS_ERR_OK ) ) #else IF( ( error = ivas_dec_setup_all( hIvasDec, &nTransportChannels, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) #endif @@ -4816,7 +4816,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples IF( hIvasDec->nSamplesAvailableNext == 0 || EQ_16( hIvasDec->nSamplesAvailableNext, hIvasDec->nSamplesFrame ) ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ), IVAS_ERR_OK ) ) #else IF( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, 0, 0 ) ) != IVAS_ERR_OK ) #endif @@ -4847,7 +4847,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples IF( splitRendBits != NULL ) { /* Render head poses from time-scaled transport channels */ - IF( ( error = isar_render_poses( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = isar_render_poses( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) { return error; } @@ -4876,20 +4876,20 @@ ivas_error IVAS_DEC_VoIP_GetSamples Word16 i; /* Analyse head poses over entire frame, generate ISAR metadata and maybe encode if split coded */ - IF( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesRendered, splitRendBits, Q_out ) ), IVAS_ERR_OK ) ) { return error; } /* Synthesise PCM output if split PCM */ - IF( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 } - IF( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) + IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); @@ -4977,7 +4977,7 @@ ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( ivas_error error = IVAS_ERR_UNKNOWN; Word16 nSamplesPerChannel = 0; - IF( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nSamplesPerChannel ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nSamplesPerChannel ) ), IVAS_ERR_OK ) ) { return error; } @@ -6185,6 +6185,7 @@ static ivas_error ivas_dec_init_split_rend( Word16 mixed_td_cldfb_flag; #ifdef FIX_1119_SPLIT_RENDERING_VOIP Word16 i, num_poses; + ISAR_SPLIT_REND_ROT_AXIS head_rot_axis; #endif pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; @@ -6214,7 +6215,14 @@ static ivas_error ivas_dec_init_split_rend( #endif #ifdef FIX_1119_SPLIT_RENDERING_VOIP - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + head_rot_axis = DEFAULT_AXIS; + move32(); + if ( st_ivas->hHeadTrackData != NULL ) + { + head_rot_axis = st_ivas->hHeadTrackData->sr_pose_pred_axis; + move32(); + } + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, head_rot_axis ); num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; move16(); @@ -6225,7 +6233,7 @@ static ivas_error ivas_dec_init_split_rend( FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { /* note: this is intra-frame heap memory */ - IF( ( error = ivas_CLDFB_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinCldfbData[i], CLDFB_NO_COL_MAX ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_CLDFB_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinCldfbData[i], CLDFB_NO_COL_MAX ) ), IVAS_ERR_OK ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); } @@ -6233,7 +6241,7 @@ static ivas_error ivas_dec_init_split_rend( } ELSE { - IF( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), i_mult( num_poses, BINAURAL_CHANNELS ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_TD_RINGBUF_Open( &st_ivas->hSplitBinRend->hMultiBinTdData, get_render_frame_size_samples( st_ivas->hDecoderConfig ), i_mult( num_poses, BINAURAL_CHANNELS ) ) ), IVAS_ERR_OK ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); } diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 431e4d693..ac350a2eb 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9043,19 +9043,17 @@ static ivas_error getSamplesInternal( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, + IF( NE_32( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ), IVAS_ERR_OK ) ) #else IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) #endif { return error; -- GitLab From 0ccced8119c65b8f83e8d770fd6899a2bfe2a8f5 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 12:01:59 +0100 Subject: [PATCH 132/351] Fix formatting --- lib_dec/lib_dec_fx.c | 25 +++++++++++++------------ lib_rend/lib_rend_fx.c | 11 ++++++----- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2b92f2b09..c3ac98c47 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1248,7 +1248,7 @@ static ivas_error isar_render_poses( } /* render */ - IF( NE_32 ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesAsked, pcmBuf, nOutSamples, needNewFrame ) ), IVAS_ERR_OK ) ) { return error; } @@ -1302,7 +1302,7 @@ static ivas_error isar_generate_metadata_and_bitstream( move16(); pcm_out_flag = 0; move16(); - if( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { pcm_out_flag = 1; move16(); @@ -1423,15 +1423,16 @@ static ivas_error isar_generate_metadata_and_bitstream( } IF( NE_32( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, - Quaternion, - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, - st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, - st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - splitRendBits, - p_Cldfb_RealBuffer_Binaural, - p_Cldfb_ImagBuffer_Binaural, - max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ), IVAS_ERR_OK ) ) + Quaternion, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + splitRendBits, + p_Cldfb_RealBuffer_Binaural, + p_Cldfb_ImagBuffer_Binaural, + max_band, p_head_pose_buf, 1, cldfb_in_flag, pcm_out_flag, ro_md_flag, Q_buff, &Q_out[0] ) ), + IVAS_ERR_OK ) ) { return error; } @@ -1620,7 +1621,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( move16(); pcm_out_flag = 0; move16(); - if( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { pcm_out_flag = 1; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index ac350a2eb..3a7718724 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9044,11 +9044,12 @@ static ivas_error getSamplesInternal( #ifdef FIX_1119_SPLIT_RENDERING_VOIP IF( NE_32( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, - hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, - hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, - p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, - extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ), IVAS_ERR_OK ) ) + hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, + hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, + &bits, + p_Cldfb_RealBuffer_Binaural, p_Cldfb_ImagBuffer_Binaural, + extract_l( Mpy_32_32( hIvasRend->sampleRateOut, 2684355 /*(BINAURAL_MAXBANDS / 48000) in Q31*/ ) ), tmpBinaural, 1, cldfb_in_flag, extract_l( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ), ro_md_flag, Q_buff, &Q_out[0] ) ), + IVAS_ERR_OK ) ) #else IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, -- GitLab From 1ec0d89cd7a9c629890a2c14bc4e8ccf356cf798 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 13:09:12 +0200 Subject: [PATCH 133/351] Clang format --- lib_enc/lib_enc_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 522f89d0e..5eac61b60 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1535,11 +1535,11 @@ return error; *---------------------------------------------------------------------*/ ivas_error IVAS_ENC_EncodeFrameToCompact( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - Word16 *inputBuffer, /* i : PCM input */ - const Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ - UWord8 *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ - UWord16 *numOutBits /* o : number of bits written to output bitstream */ + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + Word16 *inputBuffer, /* i : PCM input */ + const Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ + UWord8 *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ + UWord16 *numOutBits /* o : number of bits written to output bitstream */ ) { ivas_error error; -- GitLab From 165ee5a97d235ee1246305e8eac7df7364d5b13f Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 12:09:58 +0100 Subject: [PATCH 134/351] Fix incorrect allocation size --- lib_dec/lib_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index bbe309720..7d3ee4ffd 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1241,10 +1241,10 @@ static ivas_error isar_render_poses( { /* hIvasDec->flushbuffer = (void *) malloc( sizeof( Word16 ) * numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ /* set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); */ - Word32 size; - size = L_mult0( mult0( sizeof( Word16 ), mult0( numPoses, BINAURAL_CHANNELS ) ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); - hIvasDec->flushbuffer = (void *) malloc( size ); - set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, size ); + Word16 num_samples_flushbuffer; + num_samples_flushbuffer = mult0( mult0( numPoses, BINAURAL_CHANNELS ), shl( div_l( hIvasDec->nSamplesFrame, IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ), 1 ) ); + hIvasDec->flushbuffer = (void *) malloc( L_mult0( sizeof( Word16 ), num_samples_flushbuffer ) ); + set16_fx( (Word16 *) hIvasDec->flushbuffer, 0, num_samples_flushbuffer ); } /* render */ -- GitLab From aa91e67eebfe27d38afbcae939ea7809825909e4 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 3 Nov 2025 13:41:57 +0100 Subject: [PATCH 135/351] fix inverted logic in if condition that controls limiter being applied --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e537eb71c..ff12ac1bd 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9291,7 +9291,7 @@ ivas_error IVAS_REND_GetSamples( } - IF( NE_16( outAudio.config.is_cldfb, 0 ) ) + IF( EQ_16( outAudio.config.is_cldfb, 0 ) ) { Word32 limiter_threshold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); #ifndef DISABLE_LIMITER -- GitLab From a87d3e602bf4a7e1452af2fe7c69903490998848 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 15:12:06 +0200 Subject: [PATCH 136/351] Port float MR1809 --- apps/decoder.c | 188 +++++++++++++- apps/encoder.c | 4 + apps/isar_post_rend.c | 228 +++++++++++++++++ lib_dec/ivas_binRenderer_internal_fx.c | 4 + lib_dec/ivas_dirac_dec_fx.c | 4 + lib_dec/ivas_init_dec_fx.c | 4 + lib_dec/ivas_mc_param_dec_fx.c | 4 + lib_dec/ivas_mc_paramupmix_dec_fx.c | 4 + lib_dec/ivas_mct_dec_fx.c | 4 + lib_dec/ivas_output_config_fx.c | 16 ++ lib_dec/lib_dec.h | 5 + lib_dec/lib_dec_fx.c | 130 ++++++++++ lib_rend/ivas_rotation_fx.c | 76 ++++++ lib_rend/ivas_stat_rend.h | 4 + lib_util/ivas_rtp_api.h | 7 +- lib_util/ivas_rtp_file.c | 330 ++++++++++++++++++++++++- lib_util/ivas_rtp_file.h | 16 +- lib_util/ivas_rtp_internal.h | 9 + lib_util/ivas_rtp_payload.c | 31 ++- lib_util/ivas_rtp_pi_data.c | 3 +- lib_util/ivas_rtp_pi_data.h | 77 +++--- 21 files changed, 1087 insertions(+), 61 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0e7931fe8..c7707df5d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -133,7 +133,9 @@ typedef struct bool objEditEnabled; char *objEditFileName; #ifdef IVAS_RTPDUMP + bool applyPiData; char *piOutputFilename; + bool rtpOutSR; #endif } DecArguments; @@ -412,6 +414,10 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; +#ifdef IVAS_RTPDUMP + arg.enableHeadRotation = arg.enableHeadRotation || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; +#endif + 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_fx, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) @@ -450,7 +456,9 @@ int main( goto cleanup; } +#ifndef IVAS_RTPDUMP arg.enableHeadRotation = true; +#endif } /*------------------------------------------------------------------------------------------* @@ -847,7 +855,9 @@ static bool parseCmdlIVAS_dec( arg->enableExternalOrientation = false; arg->externalOrientationTrajFileName = NULL; #ifdef IVAS_RTPDUMP + arg->applyPiData = false; arg->piOutputFilename = NULL; + arg->rtpOutSR = false; #endif #ifdef SUPPORT_JBM_TRACEFILE @@ -940,6 +950,16 @@ static bool parseCmdlIVAS_dec( arg->piOutputFilename = argv[i++]; } + else if ( strcmp( argv_to_upper, "-APPLYPIDATA" ) == 0 ) + { + arg->applyPiData = true; + i++; + } + else if ( strcmp( argv_to_upper, "-RTPOUTSR" ) == 0 ) + { + arg->rtpOutSR = true; + i++; + } #endif #ifdef SUPPORT_JBM_TRACEFILE else if ( strcmp( argv_to_upper, "-TRACEFILE" ) == 0 ) @@ -1541,6 +1561,8 @@ static void usage_dec( void ) fprintf( stdout, " IVAS RTP Payload Format. The SDP parameter hf_only is required.\n" ); fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" ); fprintf( stdout, "-PiDataFile PF Log the timestampped PI data.\n" ); + fprintf( stdout, "-ApplyPiData Apply the PI data found in the rtp packet.\n" ); + fprintf( stdout, "-rtpOutSR : Split Rendering bitstream RTPDump output \n" ); #else fprintf( stdout, "-VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" ); fprintf( stdout, " The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" ); @@ -1618,6 +1640,9 @@ static ivas_error initOnFirstGoodFrame( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : */ int16_t *pNumOutChannels, /* o : */ uint16_t *pNumObj, /* o : */ +#ifdef IVAS_RTPDUMP + IVAS_RTP *srRtp, /* o : */ +#endif SplitFileReadWrite **splitRendWriter ) { int16_t isSplitRend, isSplitCoded; @@ -1682,7 +1707,41 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifdef IVAS_RTPDUMP + /* Split Rendering RTPDump Output file */ + if ( arg.rtpOutSR && srRtp != NULL ) + { + FILE *fParamsSR = NULL; + char srParamsFile[FILENAME_MAX], *ext = ".sr.txt"; + strncpy( srParamsFile, arg.outputWavFilename, FILENAME_MAX - sizeof( ext ) ); + strncat( srParamsFile, ext, sizeof( ext ) + 1 ); + + /* Write the Split Rendering Params passed from SDP to srParamsFile */ + fParamsSR = fopen( srParamsFile, "w" ); + if ( NULL != fParamsSR ) + { + fprintf( fParamsSR, "CODEC = %s;\nDOF = %d;\nFRAMESIZE = %d;\nRENDERSIZE = %d;\nLC3PLUS_HIGHRES = %d;\n", + splitRendCodec == ISAR_SPLIT_REND_CODEC_LC3PLUS ? "LC3PLUS" : "LCLD", + poseCorrection, + splitRendCodecFrameSizeMs, + splitRendIsarFrameSizeMs, + lc3plusHighRes ); + fclose( fParamsSR ); + fParamsSR = NULL; + } + + + /* Split Rendering RTPDump Output file */ + if ( ( error = IVAS_RTP_WRITER_Init( srRtp, arg.outputWavFilename, 1000 / ( IVAS_NUM_FRAMES_PER_SEC * splitRendCodecFrameSizeMs ) ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open SR output bitstream file for RTP output %s \n\n", arg.outputWavFilename ); + return error; + } + } + else if ( isSplitCoded ) +#else if ( isSplitCoded ) +#endif { if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) { @@ -1716,6 +1775,65 @@ static ivas_error initOnFirstGoodFrame( } } +#ifdef IVAS_RTPDUMP + if ( !arg.rtpOutSR ) + { + 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; + } + + /* Write zeros to the output audio buffer */ + int16_t *zeroBuf = calloc( pcmFrameSize, sizeof( int16_t ) ); + if ( zeroBuf == NULL ) + { + fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); + return IVAS_ERR_FAILED_ALLOC; + } + + for ( int16_t i = 0; i < numInitialBadFrames; ++i ) + { + if ( *splitRendWriter != NULL ) + { + ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero; + splitRendBitsZero.bits_buf = NULL; + splitRendBitsZero.bits_read = 0; + splitRendBitsZero.bits_written = 0; + splitRendBitsZero.buf_len = 0; + splitRendBitsZero.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; + splitRendBitsZero.pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + splitRendBitsZero.codec_frame_size_ms = 0; + splitRendBitsZero.isar_frame_size_ms = 20; + + if ( split_rend_write_bitstream_to_file( *splitRendWriter, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to write to bitstream file!\n" ); + return error; + } + } + else + { + if ( *pRemainingDelayNumSamples < *numOutSamples ) + { + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + return error; + } + *pRemainingDelayNumSamples = 0; + } + else + { + *pRemainingDelayNumSamples -= *numOutSamples; + } + } + } + + free( zeroBuf ); + } +#else int16_t pcmFrameSize; if ( ( error = IVAS_DEC_GetOutputBufferSize( hIvasDec, &pcmFrameSize ) ) != IVAS_ERR_OK ) { @@ -1770,6 +1888,7 @@ static ivas_error initOnFirstGoodFrame( } free( zeroBuf ); +#endif /* Open other output files if EXT output config - now details about ISM or MASA are known */ if ( arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) @@ -1863,7 +1982,11 @@ static ivas_error initOnFirstGoodFrame( } } +#ifdef IVAS_RTPDUMP + if ( arg.rtpOutSR || *splitRendWriter != NULL ) +#else if ( *splitRendWriter != NULL ) +#endif { if ( numOutSamples == NULL || vec_pos_len == NULL ) { @@ -2306,7 +2429,11 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifdef IVAS_RTPDUMP + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, NULL, &splitRendWriter ) ) != IVAS_ERR_OK ) +#else if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error in initOnFirstGoodFrame(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2688,6 +2815,9 @@ static ivas_error decodeVoIP( int16_t i; #ifdef IVAS_RTPDUMP IVAS_RTP ivasRtp = { 0 }; + IVAS_RTP srRtp = { 0 }; + IVAS_RTP_SR_INFO srInfo = { true, false, 0, IVAS_SR_TRANSPORT_LCLD }; + int32_t initialTsOffsetSystemAndRTP = 0; #else FILE *f_rtpstream = NULL; EVS_RTPDUMP_DEPACKER rtpdumpDepacker; @@ -2741,7 +2871,11 @@ static ivas_error decodeVoIP( case IVAS_DEC_INPUT_FORMAT_RTPDUMP: case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF: #ifdef IVAS_RTPDUMP - if ( ( error = IVAS_RTP_READER_Init( &ivasRtp, arg.inputBitstreamFilename, arg.piOutputFilename ) ) != IVAS_ERR_OK ) +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( ( error = IVAS_RTP_READER_Init( &ivasRtp, 0, arg.inputBitstreamFilename, arg.piOutputFilename, arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL, arg.outputWavFilename ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_RTP_READER_Init( &ivasRtp, arg.inputBitstreamFilename, arg.piOutputFilename, arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL, arg.outputWavFilename ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "error in IVAS_RTP_READER_Init(): %d\n", error ); goto cleanup; @@ -2804,7 +2938,12 @@ static ivas_error decodeVoIP( { auPtr = au; /* might have been set to RTP packet in prev call */ #ifdef IVAS_RTPDUMP +#ifdef RTP_S4_251135_CR26253_0016_REV1 + error = IVAS_RTP_ReadNextFrame( &ivasRtp, auPtr, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, NULL, &qBit ); +#else error = IVAS_RTP_ReadNextFrame( &ivasRtp, auPtr, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &qBit ); +#endif + initialTsOffsetSystemAndRTP = rtpTimeStamp - systemTime_ms * 16; /* For time mapping */ #else rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); #endif @@ -2988,7 +3127,11 @@ static ivas_error decodeVoIP( { auPtr = au; /* might have been set to RTP packet in prev call */ #ifdef IVAS_RTPDUMP +#ifdef RTP_S4_251135_CR26253_0016_REV1 + error = IVAS_RTP_ReadNextFrame( &ivasRtp, au, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, NULL, &qBit ); +#else error = IVAS_RTP_ReadNextFrame( &ivasRtp, au, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &qBit ); +#endif /* IVAS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; @@ -3033,6 +3176,28 @@ static ivas_error decodeVoIP( /* decode and get samples */ while ( nSamplesRendered < nOutSamples ) { +#ifdef IVAS_RTPDUMP + if ( arg.applyPiData ) + { + /* Rudimentry Time Mapping to map system time to rtp timestamp */ + uint32_t piTs = systemTime_ms * 16 + initialTsOffsetSystemAndRTP; + uint32_t numPiData = 0; + + while ( ivasRtp.nProcPiData + numPiData < ivasRtp.nReadPiData && + ivasRtp.piData[ivasRtp.nProcPiData + numPiData].timestamp <= piTs ) + { + numPiData++; + } + + if ( ( error = IVAS_RTP_FeedPiDataToDecoder( hIvasDec, &ivasRtp.piData[ivasRtp.nProcPiData], numPiData ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + ivasRtp.nProcPiData += numPiData; + } +#endif #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else @@ -3124,7 +3289,11 @@ static ivas_error decodeVoIP( SplitFileReadWrite *splitRendWriter = NULL; if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, +#ifdef IVAS_RTPDUMP + &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &srRtp, &splitRendWriter ) ) != IVAS_ERR_OK ) +#else &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) +#endif { goto cleanup; } @@ -3136,7 +3305,11 @@ static ivas_error decodeVoIP( } /* Write current frame */ +#ifdef IVAS_RTPDUMP + if ( !srRtp.hPack && decodedGoodFrame ) +#else if ( decodedGoodFrame ) +#endif { if ( delayNumSamples < nOutSamples ) { @@ -3205,6 +3378,10 @@ static ivas_error decodeVoIP( goto cleanup; } } +#ifdef IVAS_RTPDUMP + + IVAS_RTP_WriteExtPiData( ivasRtp.f_piExtOut, ivasRtp.piData, ivasRtp.nReadPiData, numObj ); +#endif } } @@ -3300,6 +3477,10 @@ static ivas_error decodeVoIP( goto cleanup; } } +#ifdef IVAS_RTPDUMP + + IVAS_RTP_WriteExtPiData( ivasRtp.f_piExtOut, ivasRtp.piData, ivasRtp.nReadPiData, numObj ); +#endif } } @@ -3346,6 +3527,10 @@ static ivas_error decodeVoIP( { fprintf( stdout, "\nOutput MASA metadata file: %s\n", MasaFileWriter_getFilePath( masaWriter ) ); } +#ifdef IVAS_RTPDUMP + + fprintf( stdout, "\nOutput PI data file: %s\n", IVAS_RTP_GetExtPiFilePath( &ivasRtp ) ); +#endif } /*------------------------------------------------------------------------------------------* @@ -3357,6 +3542,7 @@ static ivas_error decodeVoIP( cleanup: #ifdef IVAS_RTPDUMP + IVAS_RTP_Term( &srRtp ); IVAS_RTP_Term( &ivasRtp ); #else EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker ); diff --git a/apps/encoder.c b/apps/encoder.c index 122875635..5e2de5f45 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -867,7 +867,11 @@ int main( goto cleanup; } +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( ( error = IVAS_RTP_WriteNextFrame( &ivasRtp, au, NULL, numBits, isMono, forcePacket ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_RTP_WriteNextFrame( &ivasRtp, au, numBits, isMono, forcePacket ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError %s while pushing audio frame to RTP pack\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index aa799c3f2..2ebea17a6 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -47,6 +47,9 @@ #endif #include "stl.h" #include "wmc_auto.h" +#ifdef RTP_S4_251135_CR26253_0016_REV1 +#include "ivas_rtp_file.h" +#endif #define WMC_TOOL_SKIP @@ -79,6 +82,9 @@ static typedef struct { +#ifdef RTP_S4_251135_CR26253_0016_REV1 + bool srRtp; +#endif IVAS_AUDIO_CONFIG audioConfig; int32_t inputChannelIndex; float gain_dB; @@ -100,6 +106,9 @@ typedef struct char executableName[POST_REND_MAX_CLI_ARG_LENGTH]; char inputFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; char outputFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + char srParamsFilePath[POST_REND_MAX_CLI_ARG_LENGTH]; +#endif int32_t sampleRate; InputConfig inConfig; OutputConfig outConfig; @@ -129,6 +138,9 @@ typedef enum CmdLnOptionId_listFormats, CmdLnOptionId_SplitRendBFIFile, CmdLnOptionId_framing, +#ifdef RTP_S4_251135_CR26253_0016_REV1 + CmdLnOptionId_srParamsFile, +#endif } CmdLnOptionId; static const CmdLnParser_Option cliOptions[] = { @@ -204,6 +216,14 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "fr", .description = "Set Render audio framing.", }, +#ifdef RTP_S4_251135_CR26253_0016_REV1 + { + .id = CmdLnOptionId_srParamsFile, + .match = "sr_params", + .matchShort = "s", + .description = "Path to the split rendering init params file", + }, +#endif }; @@ -215,7 +235,11 @@ static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_ static void printSupportedAudioConfigs( void ); +#ifdef RTP_S4_251135_CR26253_0016_REV1 +static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString, bool *srRtp ); +#else static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); +#endif static void convertOutputBuffer( const Word32 *fixedBuffer, Word16 q, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); @@ -303,12 +327,20 @@ static bool parseInConfig( } /* Check for single-format inputs. The given string should map to a member of AUDIO_CONFIG enum. */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + bool srRtp = false; + IVAS_AUDIO_CONFIG audioConfig = parseAudioConfig( inFormatStr, &srRtp ); +#else IVAS_AUDIO_CONFIG audioConfig = parseAudioConfig( inFormatStr ); +#endif switch ( audioConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: inConfig->numBinBuses = 1; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + inConfig->binBuses[0].srRtp = srRtp; +#endif inConfig->binBuses[0].audioConfig = audioConfig; inConfig->binBuses[0].inputChannelIndex = 0; inConfig->binBuses[0].gain_dB = 0.0f; @@ -359,11 +391,19 @@ static bool parseRenderFramesize( static IVAS_AUDIO_CONFIG parseAudioConfig( +#ifdef RTP_S4_251135_CR26253_0016_REV1 + const char *configString, + bool *srRtp ) +#else const char *configString ) +#endif { char charBuf[25]; charBuf[24] = '\0'; + #ifdef RTP_S4_251135_CR26253_0016_REV1 + *srRtp = false; + #endif strncpy( charBuf, configString, sizeof( charBuf ) - 1 ); charBuf[sizeof( charBuf ) - 1] = '\0'; to_upper( charBuf ); @@ -380,6 +420,13 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( { return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; } +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( strcmp( charBuf, "RTPDUMP" ) == 0 ) + { + *srRtp = true; + return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; + } +#endif return IVAS_AUDIO_CONFIG_INVALID; } @@ -436,6 +483,9 @@ static CmdlnArgs defaultArgs( strncpy( args.executableName, executableName, POST_REND_MAX_CLI_ARG_LENGTH ); clearString( args.inputFilePath ); clearString( args.outputFilePath ); +#ifdef RTP_S4_251135_CR26253_0016_REV1 + clearString( args.srParamsFilePath ); +#endif args.sampleRate = 0; args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID; @@ -543,6 +593,12 @@ static void parseOption( } break; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case CmdLnOptionId_srParamsFile: + assert( numOptionValues == 1 ); + strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 ); + break; +#endif default: assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); break; @@ -579,6 +635,9 @@ static void printSupportedAudioConfigs( void ) "BINAURAL (output only)", "BINAURAL_SPLIT_PCM", "BINAURAL_SPLIT_CODED", +#ifdef RTP_S4_251135_CR26253_0016_REV1 + "RTPDUMP", +#endif }; fprintf( stdout, "Supported audio formats:\n" ); @@ -670,6 +729,97 @@ static void convertOutputBuffer( return; } +#ifdef RTP_S4_251135_CR26253_0016_REV1 +static void trim( char *str ) +{ + char c; + int r = 0, w = 0; + while ( ( c = str[r] ) != 0 && ( c == ' ' || c == '\t' || c == ';' ) ) + { + r++; + } + + while ( ( c = str[r] ) != 0 && ( c != ' ' && c != '\t' && c != ';' ) ) + { + str[w++] = c; + r++; + } + str[w] = 0; +} + +static ivas_error parseSRParamsFile( + const char *srParamsFilePath, + ISAR_SPLIT_REND_CODEC *codec, + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, + int16_t *codec_frame_size_ms, + int16_t *isar_frame_size_ms, + int16_t *lc3plusHighRes ) +{ + FILE *fParamSR = fopen( srParamsFilePath, "r" ); + if ( NULL == fParamSR ) + { + fprintf( stderr, "error in opening srParams File %s)\n", srParamsFilePath ); + return IVAS_ERR_FAILED_FILE_OPEN; + } + + *codec = ISAR_SPLIT_REND_CODEC_NONE; + *poseCorrection = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + *codec_frame_size_ms = 5; + *lc3plusHighRes = 0; + + while ( !feof( fParamSR ) ) + { + char key[16], value[16]; + if ( 2 == fscanf( fParamSR, "%15s = %15s", key, value ) ) + { + trim( key ); + trim( value ); + + if ( 0 == strncmp( key, "CODEC", 5 ) ) + { + *codec = ( 0 == strncmp( value, "LCLD", 4 ) ) ? ISAR_SPLIT_REND_CODEC_LCLD : *codec; + *codec = ( 0 == strncmp( value, "LC3PLUS", 7 ) ) ? ISAR_SPLIT_REND_CODEC_LC3PLUS : *codec; + } + else if ( 0 == strncmp( key, "DOF", 3 ) ) + { + int val = atoi( value ); + if ( val == 0 || val == 1 ) + { + *poseCorrection = ( val == 0 ) ? ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE : ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + } + } + else if ( 0 == strncmp( key, "FRAMESIZE", 9 ) ) + { + int val = atoi( value ); + if ( val == 5 || val == 10 || val == 20 ) + { + *codec_frame_size_ms = (int16_t) val; + } + } + else if ( 0 == strncmp( key, "RENDERSIZE", 9 ) ) + { + int val = atoi( value ); + if ( val == 5 || val == 10 || val == 20 ) + { + *isar_frame_size_ms = (int16_t) val; + } + } + else if ( 0 == strncmp( key, "LC3PLUS_HIGHRES", 15 ) ) + { + int val = atoi( value ); + if ( val == 0 || val == 1 ) + { + *lc3plusHighRes = (int16_t) val; + } + } + } + } + + fclose( fParamSR ); + return IVAS_ERR_OK; +} +#endif + /*------------------------------------------------------------------------------------------* * main() @@ -710,6 +860,9 @@ int main( int16_t i, numChannels; ivas_error error = IVAS_ERR_OK; bool splitBinNeedsNewFrame = true; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP srRTP = { 0 }; +#endif #ifdef WMOPS reset_wmops(); @@ -739,6 +892,9 @@ int main( convert_backslash( args.inputFilePath ); convert_backslash( args.outputFilePath ); convert_backslash( args.headRotationFilePath ); +#ifdef RTP_S4_251135_CR26253_0016_REV1 + convert_backslash( args.srParamsFilePath ); +#endif /*------------------------------------------------------------------------------------------* * Open head-rotation file @@ -789,8 +945,34 @@ int main( } } +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].srRtp ) ) + { + error = parseSRParamsFile( args.srParamsFilePath, + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms, + &bitsBuffer.config.isar_frame_size_ms, + &bitsBuffer.config.lc3plusHighRes ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCould not open split rend params file %s\n", args.srParamsFilePath ); + goto cleanup; + } + + if ( ( error = IVAS_RTP_READER_Init( &srRTP, (uint32_t) bitsBuffer.config.codec_frame_size_ms, args.inputFilePath, NULL, false, NULL ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "error in IVAS_RTP_READER_Init(): %d\n", error ); + goto cleanup; + } + audioReader = NULL; + } + /*if split renderer is running in post renderer mode*/ + else if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) +#else /*if split renderer is running in post renderer mode*/ if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) +#endif { error = split_rend_reader_open( &hSplitRendFileReadWrite, args.inputFilePath, @@ -997,7 +1179,53 @@ int main( num_in_channels = inBuffer.config.numChannels; numSamplesRead = 0; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( srRTP.hRtpFile && splitBinNeedsNewFrame ) + { + IVAS_RTP_SR_INFO srInfo = { 0 }; + uint32_t rtpTimeStamp = 0, nextPacketRcvTime_ms = 0; + uint16_t rtpSequenceNumber = 0; + int16_t auSizeBits = 0; + bool qBit = false; + uint8_t *bitBuffer = bitsBuffer.bits; + int16_t frameMS = 0; + + numSamplesRead = (int16_t) inBufferSize; + bitsBuffer.config.bitsRead = 0; + bitsBuffer.config.bitsWritten = 0; + + while ( frameMS < bitsBuffer.config.isar_frame_size_ms ) + { + error = IVAS_RTP_ReadNextFrame( &srRTP, bitBuffer, &auSizeBits, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &srInfo, &qBit ); + if ( error != IVAS_ERR_OK ) + { + if ( error == IVAS_ERR_END_OF_FILE ) + { + numSamplesRead = 0; + } + else + { + fprintf( stderr, "\nUnable to read from bitstream file!\n" ); + goto cleanup; + } + } + /* Ensure a SR RTP stream was received */ + if ( !srInfo.valid ) + { + fprintf( stderr, "\nNon-SR RTP stream detected !\n" ); + goto cleanup; + } + + bitBuffer += ( auSizeBits + 7 ) / 8; + bitsBuffer.config.bitsWritten += auSizeBits; + bitsBuffer.config.codec = srInfo.codec == IVAS_SR_TRANSPORT_LC3PLUS ? ISAR_SPLIT_REND_CODEC_LC3PLUS : ISAR_SPLIT_REND_CODEC_LCLD; + frameMS += bitsBuffer.config.codec_frame_size_ms; + } + } + else if ( ( hSplitRendFileReadWrite != NULL ) && splitBinNeedsNewFrame ) +#else if ( ( hSplitRendFileReadWrite != NULL ) && splitBinNeedsNewFrame ) +#endif { ivas_error error_tmp; numSamplesRead = (int16_t) inBufferSize; diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 70e288ba3..0ed0696d2 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1245,7 +1245,11 @@ ivas_error ivas_binRenderer_open_fx( // Q29: hBinRenderer->hReverb->foa_enc_fx[k] } } +#ifdef IVAS_RTPDUMP + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) +#else ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) +#endif { IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 6e30bc084..0f4e513d6 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3082,7 +3082,11 @@ void ivas_dirac_dec_render_sf_fx( test(); test(); +#ifdef IVAS_RTPDUMP + IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) +#else IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) +#endif { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; move16(); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 5cf6a86e1..4aadcf6fb 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2579,7 +2579,11 @@ ivas_error ivas_init_decoder_fx( test(); test(); test(); +#ifdef IVAS_RTPDUMP + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( hDecoderConfig->Opt_Headrotation || hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) +#else IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( hDecoderConfig->Opt_Headrotation || hDecoderConfig->Opt_ExternalOrientation ) ) +#endif { IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 1aa07241e..4faac7183 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -461,7 +461,11 @@ ivas_error ivas_param_mc_dec_open_fx( test(); test(); test(); +#ifdef IVAS_RTPDUMP + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) +#else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) +#endif { IF( ( hParamMC->hoa_encoder_fx = (Word32 *) malloc( st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS * sizeof( Word32 ) ) ) == NULL ) { diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 75b9de19e..09be09281 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -381,7 +381,11 @@ ivas_error ivas_mc_paramupmix_dec_open( } /* Head or external rotation */ +#ifdef IVAS_RTPDUMP + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) +#else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) +#endif { IF( ( hMCParamUpmix->hoa_encoder_fx = (Word32 *) malloc( st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS * sizeof( Word32 ) ) ) == NULL ) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 7881c2976..15d3ba346 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1369,7 +1369,11 @@ static ivas_error ivas_mc_dec_reconfig_fx( ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); test(); +#ifdef IVAS_RTPDUMP + IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) +#else IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) +#endif { efap_free_data_fx( &st_ivas->hEFAPdata ); } diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 284bd0859..5ce0eea84 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -70,7 +70,11 @@ void ivas_renderer_select( *-----------------------------------------------------------------*/ test(); +#ifdef IVAS_RTPDUMP + IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) +#else IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) +#endif { st_ivas->hCombinedOrientationData->shd_rot_max_order = -1; move16(); @@ -163,7 +167,11 @@ void ivas_renderer_select( } test(); +#ifdef IVAS_RTPDUMP + IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) +#else IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) +#endif { nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); test(); @@ -220,7 +228,11 @@ void ivas_renderer_select( test(); test(); test(); +#ifdef IVAS_RTPDUMP + IF( ( EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1 ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) +#else IF( ( EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1 ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) +#endif { *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; move16(); @@ -239,7 +251,11 @@ void ivas_renderer_select( } test(); +#ifdef IVAS_RTPDUMP + IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) +#else IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) +#endif { /* force HOA3 domain for rotation*/ *internal_config = IVAS_AUDIO_CONFIG_HOA3; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index cf23f0e64..0177b8709 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -492,6 +492,11 @@ void IVAS_DEC_PrintDisclaimer( void ); +#ifdef IVAS_RTPDUMP +#include "ivas_rtp_pi_data.h" +ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, uint32_t numPiData ); +#endif + /* clang-format on */ #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 73c8c9a40..3ac27bd2c 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5618,3 +5618,133 @@ Word16 IVAS_DEC_is_split_rendering_coded_out( return IVAS_ERR_OK; } + +#ifdef IVAS_RTPDUMP +/*---------------------------------------------------------------------* + * IVAS_DEC_feedSinglePIorientation( ) + * + * Feed a single orientation PI data to external orientation handle. + *---------------------------------------------------------------------*/ + +static ivas_error IVAS_DEC_feedSinglePIorientation( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + bool isOrientationSaved, /* i : flag to indicate if an orientation for this PI type was previously saved */ + IVAS_QUATERNION *savedOrientation /* i : previously saved orientation for this PI type */ +) +{ + int16_t i; + ivas_error error = IVAS_ERR_OK; + IVAS_QUATERNION savedInvOrientation; + + if ( isOrientationSaved ) + { + if ( !hIvasDec->st_ivas->hExtOrientationData ) + { + if ( ( error = ivas_external_orientation_open_fx( &( hIvasDec->st_ivas->hExtOrientationData ), hIvasDec->st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( !hIvasDec->st_ivas->hCombinedOrientationData ) + { + if ( ( error = ivas_combined_orientation_open_fx( &( hIvasDec->st_ivas->hCombinedOrientationData ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, hIvasDec->st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + QuaternionInverse_fx( *savedOrientation, &savedInvOrientation ); + + /* use the new PI orientation or the previously saved orientation in processing */ + for ( i = 0; i < hIvasDec->st_ivas->hExtOrientationData->num_subframes; i++ ) + { + QuaternionProduct_fx( hIvasDec->st_ivas->hExtOrientationData->Quaternions[i], savedInvOrientation, + &hIvasDec->st_ivas->hExtOrientationData->Quaternions[i] ); + hIvasDec->st_ivas->hExtOrientationData->enableExternalOrientation[i] = true; + } + hIvasDec->updateOrientation = true; + } + return error; +} +#endif + +#ifdef RTP_S4_251135_CR26253_0016_REV1 +/*---------------------------------------------------------------------* + * IVAS_DEC_setDiegeticInput( ) + * + * Set isDiegeticInput flag for combined orientation handle based on PI data. + *---------------------------------------------------------------------*/ + +static void IVAS_DEC_setDiegeticInputPI( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const bool *diegeticPIValues /* i : diegetic values for the input stream */ +) +{ + if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) + { + int8_t i; + for ( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) + { + hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPI[i] = diegeticPIValues[i]; + } + hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPISet = true; + } +} +#endif + +#ifdef IVAS_RTPDUMP +ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, uint32_t numPiData ) +{ + ivas_error error = IVAS_ERR_OK; + while ( numPiData-- ) + { + uint32_t piDataType = piData->data.noPiData.piDataType; + switch ( piDataType ) + { + case IVAS_PI_SCENE_ORIENTATION: + { + IVAS_QUATERNION *quat = &piData->data.scene.orientation; +#ifdef DEBUGGING + fprintf( stdout, "PI_SCENE_ORIENTATION : %f, %f, %f, %f\n", quat->w, quat->x, quat->y, quat->z ); +#endif + error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); + } + break; + + case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: + { + IVAS_QUATERNION *quat = &piData->data.deviceCompensated.orientation; +#ifdef DEBUGGING + fprintf( stdout, "PI_DEVICE_ORIENTATION : %f, %f, %f, %f\n", quat->w, quat->x, quat->y, quat->z ); +#endif + error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); + } + break; + +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case IVAS_PI_DIEGETIC_TYPE: + { +#ifdef DEBUGGING + fprintf( stdout, "PI_DIEGETIC_TYPE : %d, %d, %d, %d, %d\n", piData->data.digeticIndicator.isDiegetic[0], piData->data.digeticIndicator.isDiegetic[1], piData->data.digeticIndicator.isDiegetic[2], piData->data.digeticIndicator.isDiegetic[3], piData->data.digeticIndicator.isDiegetic[4] ); +#endif + IVAS_DEC_setDiegeticInputPI( hIvasDec, piData->data.digeticIndicator.isDiegetic ); + } + break; +#endif + + default: + { + /* NOT HANDLED PI DATA - DO NOTHING */ + } + break; + } + if ( error != IVAS_ERR_OK ) + { + return error; + } + piData++; + } + return error; +} +#endif diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index b58294d06..cf0386c63 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1439,6 +1439,16 @@ ivas_error ivas_combined_orientation_open_fx( move16(); ( *hCombinedOrientationData )->cur_subframe_samples_rendered = 0; move16(); +#ifdef RTP_S4_251135_CR26253_0016_REV1 + + FOR ( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) + { + ( *hCombinedOrientationData )->isDiegeticInputPI[i] = TRUE; + move16(); + } + ( *hCombinedOrientationData )->isDiegeticInputPISet = FALSE; + move16(); +#endif return IVAS_ERR_OK; } @@ -1629,11 +1639,30 @@ ivas_error combine_external_and_head_orientations( } ELSE IF( hExtOrientationData == NULL && headRotQuaternions != NULL ) { +#ifdef RTP_S4_251135_CR26253_0016_REV1 + /* Disable head rotation if diegetic PI data indicating non-diegetic audio is received */ + IF( hCombinedOrientationData->isDiegeticInputPISet && !hCombinedOrientationData->isDiegeticInputPI[0] && !hCombinedOrientationData->isDiegeticInputPI[1] && !hCombinedOrientationData->isDiegeticInputPI[2] && !hCombinedOrientationData->isDiegeticInputPI[3] && !hCombinedOrientationData->isDiegeticInputPI[4] ) + { + FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + hCombinedOrientationData->Quaternions[i] = identity; + } + } + ELSE + { + /* Head rotation only */ + FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + hCombinedOrientationData->Quaternions[i] = headRotQuaternions[i]; + } + } +#else /* Head rotation only */ FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { hCombinedOrientationData->Quaternions[i] = headRotQuaternions[i]; } +#endif } IF( hExtOrientationData != NULL ) @@ -1755,6 +1784,41 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->isHeadRotationFrozen = 0; move16(); } + +#ifdef RTP_S4_251135_CR26253_0016_REV1 + /* Disable head rotation if diegetic PI data indicating non-diegetic audio is received */ + IF( hCombinedOrientationData->isDiegeticInputPISet && !hCombinedOrientationData->isDiegeticInputPI[0] && !hCombinedOrientationData->isDiegeticInputPI[1] && !hCombinedOrientationData->isDiegeticInputPI[2] && !hCombinedOrientationData->isDiegeticInputPI[3] && !hCombinedOrientationData->isDiegeticInputPI[4] ) + { + continue; + } + ELSE + { + /* Use the most recent head rotation */ + IF( EQ_16( hExtOrientationData->enableHeadRotation[i], 1 ) ) + { + IF( hExtOrientationData->enableExternalOrientation[i] > 0 ) + { + QuaternionProduct_fx( hCombinedOrientationData->Quaternions[i], headRotQuaternions[i], &hCombinedOrientationData->Quaternions[i] ); + } + ELSE + { + hCombinedOrientationData->Quaternions[i] = headRotQuaternions[i]; + } + } + /* Use the freezed head rotation */ + ELSE IF( EQ_16( hExtOrientationData->enableHeadRotation[i], 2 ) ) + { + IF( hExtOrientationData->enableExternalOrientation[i] > 0 ) + { + QuaternionProduct_fx( hCombinedOrientationData->Quaternions[i], hCombinedOrientationData->Quaternion_frozen_head, &hCombinedOrientationData->Quaternions[i] ); + } + ELSE + { + hCombinedOrientationData->Quaternions[i] = hCombinedOrientationData->Quaternion_frozen_head; + } + } + } +#else /* Use the most recent head rotation */ IF( EQ_16( hExtOrientationData->enableHeadRotation[i], 1 ) ) { @@ -1779,6 +1843,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->Quaternions[i] = hCombinedOrientationData->Quaternion_frozen_head; } } +#endif /* Reset the combined orientations to identity */ test(); if ( hExtOrientationData->enableHeadRotation[i] == 0 && hExtOrientationData->enableExternalOrientation[i] == 0 ) @@ -1908,6 +1973,17 @@ ivas_error combine_external_and_head_orientations( } hCombinedOrientationData->sr_pose_pred_axis = sr_pose_pred_axis; +#ifdef IVAS_RTPDUMP + + /* Reset external orientations */ + IF( hExtOrientationData != NULL ) + { + FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + hExtOrientationData->Quaternions[i] = identity; + } + } +#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index aec8eb3b9..be7ec113c 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -851,6 +851,10 @@ typedef struct ivas_combined_orientation_struct Word16 cur_subframe_samples_rendered; Word16 subframe_idx_start; Word16 cur_subframe_samples_rendered_start; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + bool isDiegeticInputPI[1 + IVAS_MAX_NUM_OBJECTS]; + bool isDiegeticInputPISet; +#endif } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h index 06c56cd70..405893581 100644 --- a/lib_util/ivas_rtp_api.h +++ b/lib_util/ivas_rtp_api.h @@ -33,7 +33,6 @@ #ifndef IVAS_RTP_API_H #define IVAS_RTP_API_H -#include #include #include "common_api_types.h" @@ -275,6 +274,7 @@ typedef struct { bool valid; /* Valid Split Rendering Info for/in the ToC */ bool diegetic; /* SR content digetic */ + uint32_t bitrateKbps; /* SR bitrate in kbps */ IVAS_RTP_SR_TRANSPORT codec; /* SR Transport Codec used*/ } IVAS_RTP_SR_INFO; #endif /* RTP_S4_251135_CR26253_0016_REV1 */ @@ -345,7 +345,7 @@ ivas_error IVAS_RTP_PACK_PushFrame( IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o : IVAS rtp packer handle */ IVAS_RTP_CODEC codecId, /* i : Codec type (IVAS/EVS) */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info (NULL if absent) */ + const IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info (NULL if absent) */ #endif /* RTP_S4_251135_CR26253_0016_REV1 */ const IVAS_DATA_BUFFER *frameBuffer /* i : packed frame bitstream for IVAS/EVS */ ); @@ -407,6 +407,9 @@ typedef struct IVAS_RTP_UNPACK *IVAS_RTP_UNPACK_HANDLE; /* rtp unpacker handle t typedef struct { uint32_t maxFramesPerPacket; /* maximum no of frame per packet expected during the session */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + uint32_t srCodecFrameSizeMs; /* split rendering transport codec frame size in ms (5/10/20) set by sdp negotiation */ +#endif } IVAS_RTP_UNPACK_CONFIG; /* Open an instance of the RTP unpacker and return a handle to rtp unpacker on success diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index f5da78017..5846b0423 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -139,9 +139,9 @@ static ivas_error IvasRtpFile_Read( static const char *const PiDataNames[IVAS_PI_MAX_ID] = { "SCENE_ORIENTATION", "DEVICE_ORIENTATION_COMPENSATED", "DEVICE_ORIENTATION_UNCOMPENSATED", "ACOUSTIC_ENVIRONMENT", "AUDIO_DESCRIPTION", "ISM_NUM", "ISM_ID", "ISM_GAIN", "ISM_ORIENTATION", - "ISM_POSITION", "ISM_DISTANCE_ATTENUATION", "ISM_DIRECTIVITY", "DIEGETIC_TYPE", "RESERVED13", + "ISM_POSITION", "ISM_DISTANCE_ATTENUATION", "ISM_DIRECTIVITY", "DIEGETIC_TYPE", "DYNAMIC_AUDIO_SUPPRESSION_INDICATION", "AUDIO_FOCUS_INDICATION", "RESERVED15", "PLAYBACK_DEVICE_ORIENTATION", "HEAD_ORIENTATION", "LISTENER_POSITION", - "DYNAMIC_AUDIO_SUPPRESSION", "AUDIO_FOCUS_REQUEST", "PI_LATENCY", "R_ISM_ID", "R_ISM_GAIN", + "DYNAMIC_AUDIO_SUPPRESSION_REQUEST", "AUDIO_FOCUS_REQUEST", "PI_LATENCY", "R_ISM_ID", "R_ISM_GAIN", "R_ISM_ORIENTATION", "R_ISM_POSITION", "R_ISM_DIRECTION", "RESERVED27", "RESERVED28", "RESERVED29", "RESERVED30", "NO_DATA" }; @@ -273,9 +273,20 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, "\n\t\t}" ); } break; - case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION: + case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST: { - const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppression; + const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppressionRequest; + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"preferSpeech\": %s,\n", das->speech ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"preferMusic\": %s,\n", das->music ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"preferAmbiance\": %s,\n", das->ambiance ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"level\": %d", das->sli ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION: + { + const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppressionIndication; fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"preferSpeech\": %s,\n", das->speech ? "true" : "false" ); fprintf( f_piDataOut, "\t\t\t\"preferMusic\": %s,\n", das->music ? "true" : "false" ); @@ -284,7 +295,6 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, "\n\t\t}" ); } break; - case IVAS_PI_RESERVED13: case IVAS_PI_AUDIO_FOCUS_REQUEST: { fprintf( f_piDataOut, "{" ); @@ -337,6 +347,262 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, "\n\t}" ); } +void IVAS_RTP_WriteExtPiData( + FILE *f_piDataOut, /* i/o : Output csv file handle to dump PI data for external output */ + const PIDATA_TS *piData, /* i : PI Data + Timestamp array containing all PI data in current packet */ + uint32_t nPiDataPresent, /* i : Number of valid elements in the piData array */ + uint16_t numObj /* i : Number of objects */ +) +{ + if ( f_piDataOut == NULL || piData == NULL || nPiDataPresent == 0 ) + { + return; + } + + int i = 0; + + while ( nPiDataPresent-- > 0 ) + { + const PIDATA_TS *cur = piData++; + + /* The writing follows the pattern of: timestamp, PI DATA TYPE, PI DATA */ + + fprintf( f_piDataOut, "%d,%s,", cur->timestamp, PiDataNames[cur->data.noPiData.piDataType] ); + switch ( cur->data.noPiData.piDataType ) + { + case IVAS_PI_SCENE_ORIENTATION: + { + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.scene.orientation.w_fx, cur->data.scene.orientation.x_fx, cur->data.scene.orientation.y_fx, cur->data.scene.orientation.z_fx ); + } + break; + case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: + { + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.deviceCompensated.orientation.w_fx, cur->data.deviceCompensated.orientation.x_fx, cur->data.deviceCompensated.orientation.y_fx, cur->data.deviceCompensated.orientation.z_fx ); + } + break; + case IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED: + { + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.deviceUnCompensated.orientation.w_fx, cur->data.deviceUnCompensated.orientation.x_fx, cur->data.deviceUnCompensated.orientation.y_fx, cur->data.deviceUnCompensated.orientation.z_fx ); + } + break; + case IVAS_PI_ACOUSTIC_ENVIRONMENT: + { + fprintf( f_piDataOut, "%d", cur->data.acousticEnv.aeid ); + if ( cur->data.acousticEnv.availLateReverb ) + { + fprintf( f_piDataOut, ",%f,%f,%f", cur->data.acousticEnv.rt60[0], cur->data.acousticEnv.rt60[1], cur->data.acousticEnv.rt60[2] ); + fprintf( f_piDataOut, ",%f,%f,%f", cur->data.acousticEnv.dsr[0], cur->data.acousticEnv.dsr[1], cur->data.acousticEnv.dsr[2] ); + } + if ( cur->data.acousticEnv.availEarlyReflections ) + { + fprintf( f_piDataOut, ",%f,%f,%f", cur->data.acousticEnv.roomDimensions.x, cur->data.acousticEnv.roomDimensions.y, cur->data.acousticEnv.roomDimensions.z ); + fprintf( f_piDataOut, ",%f,%f,%f,%f,%f,%f", cur->data.acousticEnv.absorbCoeffs[0], cur->data.acousticEnv.absorbCoeffs[1], cur->data.acousticEnv.absorbCoeffs[2], cur->data.acousticEnv.absorbCoeffs[3], cur->data.acousticEnv.absorbCoeffs[4], cur->data.acousticEnv.absorbCoeffs[5] ); + } + } + break; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case IVAS_PI_AUDIO_DESCRIPTION: + { + uint32_t nEntries = cur->data.audioDesc.nValidEntries; + const IVAS_AUDIO_ID *audioId = cur->data.audioDesc.audioId; + + while ( nEntries-- > 0 ) + { + fprintf( f_piDataOut, "%d,%d,%d,%d,%d", audioId->speech, audioId->music, audioId->ambiance, audioId->editable, audioId->binaural ); + audioId++; + } + } + break; + case IVAS_PI_ISM_NUM: + { + fprintf( f_piDataOut, "%d", cur->data.ismNum.numObjects ); + } + break; + case IVAS_PI_ISM_ID: + { + for ( i = 0; i < numObj; ++i ) + { + if ( i != 0 ) + { + fprintf( f_piDataOut, "," ); + } + fprintf( f_piDataOut, "%d", cur->data.ismId.id[i] ); + } + } + break; + case IVAS_PI_ISM_GAIN: + { + for ( i = 0; i < numObj; ++i ) + { + if ( i != 0 ) + { + fprintf( f_piDataOut, "," ); + } + fprintf( f_piDataOut, "%d", cur->data.ismGain.dB[i] ); + } + } + break; + case IVAS_PI_ISM_ORIENTATION: + { + for ( i = 0; i < numObj; ++i ) + { + if ( i != 0 ) + { + fprintf( f_piDataOut, "," ); + } + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.ismOrientation.orientation[i].w_fx, cur->data.ismOrientation.orientation[i].x_fx, cur->data.ismOrientation.orientation[i].y_fx, cur->data.ismOrientation.orientation[i].z_fx ); + } + } + break; + case IVAS_PI_ISM_POSITION: + { + for ( i = 0; i < numObj; ++i ) + { + if ( i != 0 ) + { + fprintf( f_piDataOut, "," ); + } + fprintf( f_piDataOut, "%f,%f,%f", cur->data.ismPosition.position[i].x, cur->data.ismPosition.position[i].y, cur->data.ismPosition.position[i].z ); + } + } + break; + case IVAS_PI_ISM_DISTANCE_ATTENUATION: + { + for ( i = 0; i < numObj; ++i ) + { + if ( i != 0 ) + { + fprintf( f_piDataOut, "," ); + } + fprintf( f_piDataOut, "%f,%f,%f", cur->data.ismAttenuation.distAtten[i].ref_dist, cur->data.ismAttenuation.distAtten[i].max_dist, cur->data.ismAttenuation.distAtten[i].roll ); + } + } + break; + case IVAS_PI_ISM_DIRECTIVITY: + { + for ( i = 0; i < numObj; ++i ) + { + if ( i != 0 ) + { + fprintf( f_piDataOut, "," ); + } + fprintf( f_piDataOut, "%d,%d,%f", cur->data.ismDirectivity.directivity[i].innerConeAngle, cur->data.ismDirectivity.directivity[i].outerConeAngle, cur->data.ismDirectivity.directivity[i].outerAttenuationdB ); + } + } + break; + case IVAS_PI_DIEGETIC_TYPE: + { + const bool *isDiegetic = cur->data.digeticIndicator.isDiegetic; + fprintf( f_piDataOut, "%d,%d,%d,%d,%d", isDiegetic[0], isDiegetic[1], isDiegetic[2], isDiegetic[3], isDiegetic[4] ); + } + break; + case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION: + { + const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppressionIndication; + fprintf( f_piDataOut, "%d,%d,%d,%d", das->speech, das->music, das->ambiance, das->sli ); + } + break; + case IVAS_PI_AUDIO_FOCUS_INDICATION: + { + if ( cur->data.focusIndication.availDirection ) + { + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.focusIndication.direction.w_fx, cur->data.focusIndication.direction.x_fx, cur->data.focusIndication.direction.y_fx, cur->data.focusIndication.direction.z_fx ); + if ( cur->data.focusIndication.availLevel ) + { + fprintf( f_piDataOut, "," ); + } + } + if ( cur->data.focusIndication.availLevel ) + { + fprintf( f_piDataOut, "%d", cur->data.focusIndication.flvl ); + } + } + break; + case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: + { + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.playbackOrientation.orientation.w_fx, cur->data.playbackOrientation.orientation.x_fx, cur->data.playbackOrientation.orientation.y_fx, cur->data.playbackOrientation.orientation.z_fx ); + } + break; + case IVAS_PI_HEAD_ORIENTATION: + { + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.headOrientation.orientation.w_fx, cur->data.headOrientation.orientation.x_fx, cur->data.headOrientation.orientation.y_fx, cur->data.headOrientation.orientation.z_fx ); + } + break; + case IVAS_PI_LISTENER_POSITION: + { + fprintf( f_piDataOut, "%f,%f,%f", cur->data.listnerPosition.position.x, cur->data.listnerPosition.position.y, cur->data.listnerPosition.position.z ); + } + break; + case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST: + { + const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppressionRequest; + fprintf( f_piDataOut, "%d,%d,%d,%d", das->speech, das->music, das->ambiance, das->sli ); + } + break; + case IVAS_PI_AUDIO_FOCUS_REQUEST: + { + + if ( cur->data.focusRequest.availDirection ) + { + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.focusRequest.direction.w_fx, cur->data.focusRequest.direction.x_fx, cur->data.focusRequest.direction.y_fx, cur->data.focusRequest.direction.z_fx ); + if ( cur->data.focusRequest.availLevel ) + { + fprintf( f_piDataOut, "," ); + } + } + if ( cur->data.focusRequest.availLevel ) + { + fprintf( f_piDataOut, "%d", cur->data.focusRequest.flvl ); + } + } + break; + case IVAS_PI_PI_LATENCY: + { + fprintf( f_piDataOut, "%d", cur->data.piLatency.latency ); + } + break; + case IVAS_PI_R_ISM_ID: + { + fprintf( f_piDataOut, "%d", cur->data.ismEditId.id ); + } + break; + case IVAS_PI_R_ISM_GAIN: + { + fprintf( f_piDataOut, "%d", cur->data.ismEditGain.piDataType ); + } + break; + case IVAS_PI_R_ISM_ORIENTATION: + { + fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.ismEditOrientation.orientation.w_fx, cur->data.ismEditOrientation.orientation.x_fx, cur->data.ismEditOrientation.orientation.y_fx, cur->data.ismEditOrientation.orientation.z_fx ); + } + break; + case IVAS_PI_R_ISM_POSITION: + { + fprintf( f_piDataOut, "%f,%f,%f", cur->data.ismEditPosition.position.x, cur->data.ismEditPosition.position.y, cur->data.ismEditPosition.position.z ); + } + break; + case IVAS_PI_R_ISM_DIRECTION: + { + fprintf( f_piDataOut, "%f,%f", cur->data.ismEditDirection.azimuth, cur->data.ismEditDirection.elevation ); + } + break; + case IVAS_PI_RESERVED15: + case IVAS_PI_RESERVED27: + case IVAS_PI_RESERVED28: + case IVAS_PI_RESERVED29: + case IVAS_PI_RESERVED30: + break; +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + } + fprintf( f_piDataOut, "\n" ); + } +} + +const char *IVAS_RTP_GetExtPiFilePath( IVAS_RTP *rtp ) +{ + return rtp->piExtFilename; +} + void IVAS_RTP_Term( IVAS_RTP *rtp /* i/o : IVAS RTP File reader/writer handle */ ) @@ -378,6 +644,12 @@ void IVAS_RTP_Term( rtp->f_piDataOut = NULL; } + if ( rtp->f_piExtOut != NULL ) + { + fclose( rtp->f_piExtOut ); + rtp->f_piExtOut = NULL; + } + if ( rtp->hRtpFile != NULL ) { IvasRtpFile_Close( &rtp->hRtpFile ); @@ -422,8 +694,13 @@ ivas_error IVAS_RTP_WRITER_Init( ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, /* i/o : IVAS RTP File reader handle */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + uint32_t srCodecFrameSizeMs, /* i : SR Codec Framesize in ms */ +#endif const char *inputBitstreamFilename, /* i : Input rtpdump filename */ - const char *piOutputFilename /* i : Output PI data json filename */ + const char *piOutputFilename, /* i : Output PI data json filename */ + bool isExtOutput, /* i : External output mode */ + const char *outputWavFilename /* i : name of the output audio file */ ) { ivas_error error = IVAS_ERR_OK; @@ -431,6 +708,9 @@ ivas_error IVAS_RTP_READER_Init( memset( rtp, 0, sizeof( IVAS_RTP ) ); rtp->unpackCfg.maxFramesPerPacket = IVAS_MAX_FRAMES_PER_RTP_PACKET; +#ifdef RTP_S4_251135_CR26253_0016_REV1 + rtp->unpackCfg.srCodecFrameSizeMs = srCodecFrameSizeMs; +#endif rtp->rtpPacket.buffer = rtp->packet; rtp->rtpPacket.capacity = sizeof( rtp->packet ); @@ -455,12 +735,36 @@ ivas_error IVAS_RTP_READER_Init( } } + if ( isExtOutput ) + { + char ext_pi[12]; + + /* sizeof( ext_pi ) accounts for terminating NULL, don't subtract extra 1 */ + const int32_t maxNameLenWithoutExt = FILENAME_MAX - (int32_t) sizeof( ext_pi ); + strncpy( rtp->piExtFilename, outputWavFilename, maxNameLenWithoutExt ); + snprintf( ext_pi, sizeof( ext_pi ), ".pidata.csv" ); + + /* strlen( metadata_filename[0] ) doesn't account for terminating NULL, subtract extra 1 */ + const int32_t maxNumCharactersToAppend = FILENAME_MAX - (int32_t) strlen( rtp->piExtFilename ) - 1; + strncat( rtp->piExtFilename, ext_pi, maxNumCharactersToAppend ); + + rtp->f_piExtOut = fopen( rtp->piExtFilename, "w" ); + if ( rtp->f_piExtOut == NULL ) + { + fprintf( stderr, "could not open: %s\n", rtp->piExtFilename ); + return IVAS_ERR_FAILED_FILE_OPEN; + } + } + return error; } ivas_error IVAS_RTP_WriteNextFrame( IVAS_RTP *rtp, /* i/o : IVAS RTP File writer handle */ uint8_t *au, /* i : IVAS Compressed AU (Packed frame) */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + const IVAS_RTP_SR_INFO *srInfo, /* i : Split rendering info in present, else NULL */ +#endif int16_t auSizeBits, /* i : Frame size in bits */ bool isMono, /* i : input was evs(true) or ivas(false) */ bool forcePacket /* i : force packets with whatever frames pushed so far */ @@ -479,7 +783,7 @@ ivas_error IVAS_RTP_WriteNextFrame( error = IVAS_RTP_PACK_PushFrame( rtp->hPack, isMono ? IVAS_RTP_EVS : IVAS_RTP_IVAS, #ifdef RTP_S4_251135_CR26253_0016_REV1 - NULL, + srInfo, #endif /* RTP_S4_251135_CR26253_0016_REV1 */ &packedFrame ); if ( error != IVAS_ERR_OK ) @@ -487,7 +791,7 @@ ivas_error IVAS_RTP_WriteNextFrame( return error; } - while ( rtp->nWrittenPiData-- > 0 ) + while ( rtp->nWrittenPiData > 0 ) { PIDATA_TS *piDataTs = &rtp->piData[nProcPiData++]; if ( ( error = IVAS_RTP_PACK_PushPiData( rtp->hPack, (const IVAS_PIDATA_GENERIC *) &piDataTs->data ) ) != IVAS_ERR_OK ) @@ -495,6 +799,7 @@ ivas_error IVAS_RTP_WriteNextFrame( fprintf( stderr, "\nError %s while pushing scene orientation\n", ivas_error_to_string( error ) ); return error; } + rtp->nWrittenPiData--; } if ( forcePacket || IVAS_RTP_PACK_GetNumFrames( rtp->hPack ) == rtp->packCfg.maxFramesPerPacket ) @@ -525,6 +830,9 @@ ivas_error IVAS_RTP_ReadNextFrame( uint32_t *rtpTimeStamp, /* o : RTP Timestamp for this frame */ uint16_t *rtpSequenceNumber, /* o : RTP sequence number for this packet */ uint32_t *nextPacketRcvTime_ms, /* i/o : Clock indicating packet receive times need in JBM */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + IVAS_RTP_SR_INFO *srInfo, /* o : Split Rendering info if SR RTP frame unpacked */ +#endif bool *qBit /* o : AMRWB Q bite as indicated in the RTP packet */ ) { @@ -603,6 +911,12 @@ ivas_error IVAS_RTP_ReadNextFrame( rtp->isAMRWB_IOmode = isAMRWB_IOmode; } +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( srInfo != NULL ) + { + *srInfo = rtp->srInfo; + } +#endif *qBit = !rtp->speechLostIndicated; rtp->numFramesInPacket--; rtp->numFramesProduced++; diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index 2a58dc1c9..d5fbc0504 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -46,6 +46,8 @@ typedef struct IVAS_RTP_FILE_HANDLE hRtpFile; FILE *f_piDataOut; + FILE *f_piExtOut; + char piExtFilename[FILENAME_MAX]; IVAS_RTP_CODEC codecId; uint32_t nWrittenPiData; uint32_t nReadPiData; @@ -69,11 +71,23 @@ typedef struct } IVAS_RTP; ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, const char *outputBitstreamFilename, uint32_t numFramesPerPacket ); -ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, const char *inputBitstreamFilename, const char *piOutputFilename ); +#ifdef RTP_S4_251135_CR26253_0016_REV1 +ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, uint32_t srCodecFrameSizeMs, const char *inputBitstreamFilename, const char *piOutputFilename, bool isExtOutput, const char *outputWavFilename ); +#else +ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, const char *inputBitstreamFilename, const char *piOutputFilename, bool isExtOutput, const char *outputWavFilename ); +#endif void IVAS_RTP_Term( IVAS_RTP *rtp ); +#ifdef RTP_S4_251135_CR26253_0016_REV1 +ivas_error IVAS_RTP_WriteNextFrame( IVAS_RTP *rtp, uint8_t *au, const IVAS_RTP_SR_INFO *srInfo, int16_t auSizeBits, bool isMono, bool forcePacket ); +ivas_error IVAS_RTP_ReadNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t *auSizeBits, uint32_t *rtpTimeStamp, uint16_t *rtpSequenceNumber, uint32_t *nextPacketRcvTime_ms, IVAS_RTP_SR_INFO *srInfo, bool *qBit ); +#else + ivas_error IVAS_RTP_WriteNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t auSizeBits, bool isMono, bool forcePacket ); ivas_error IVAS_RTP_ReadNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t *auSizeBits, uint32_t *rtpTimeStamp, uint16_t *rtpSequenceNumber, uint32_t *nextPacketRcvTime_ms, bool *qBit ); +#endif void IVAS_RTP_LogPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent ); +void IVAS_RTP_WriteExtPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent, uint16_t numObj ); +const char *IVAS_RTP_GetExtPiFilePath( IVAS_RTP *rtp ); #endif /* IVAS_RTP_FILE_H */ diff --git a/lib_util/ivas_rtp_internal.h b/lib_util/ivas_rtp_internal.h index f3569ca03..032717d8f 100644 --- a/lib_util/ivas_rtp_internal.h +++ b/lib_util/ivas_rtp_internal.h @@ -96,11 +96,20 @@ enum IVAS_RTP_HEADER_BITS EBYTE_CMR_T_IVAS = 0xF0, /* Initial E-byte indicating IVAS modes */ EBYTE_CMR_T_NO_REQ = 0xFF, /* If no bitrate and no CA mode requested for IVAS/EVS */ + +#ifdef RTP_S4_251135_CR26253_0016_REV1 EBYTE_BANDWIDTH_REQUEST = 0x80, /* Subsequent E-byte for Bandwidth Request */ EBYTE_FORMAT_REQUEST = 0x90, /* Subsequent E-byte for Format Request */ EBYTE_SUBFORMAT_REQUEST = 0x9F, /* Subsequent E-byte for SubFormat Request */ EBYTE_PI_INDICATOR = 0xA0, /* Subsequent E-byte for PI Indicator */ EBYTE_SR_REQUEST = 0xB0, /* Subsequent E-byte for Split Rendering Request */ +#else + EBYTE_BANDWIDTH_REQUEST = 0x40, /* Subsequent E-byte for Bandwidth Request */ + EBYTE_FORMAT_REQUEST = 0x50, /* Subsequent E-byte for Format Request */ + EBYTE_SUBFORMAT_REQUEST = 0x9F, /* Subsequent E-byte for SubFormat Request */ + EBYTE_PI_INDICATOR = 0x60, /* Subsequent E-byte for PI Indicator */ + EBYTE_SR_REQUEST = 0x70, /* Subsequent E-byte for Split Rendering Request */ +#endif PI_HEADER_PF_LAST = 0x00, /* Last PI header of the Payload in PI Header */ PI_HEADER_PF_NOT_LAST = 0x80, /* Another PI header follows after this in PI Header */ diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index e759f674b..46198011a 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -835,18 +835,17 @@ static void packEBytes( #ifdef RTP_S4_251135_CR26253_0016_REV1 static ivas_error getSRToCByte( - IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info */ - uint32_t bitrateKbps, /* i : Bitrate in kbps */ - uint8_t *tocByte /* o : toc byte 2 */ + const IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info */ + uint8_t *tocByte /* o : toc byte 2 */ ) { uint8_t bitIdx, codecId, digetic; - if ( bitrateKbps < 256000 || bitrateKbps > 512000 ) + if ( srInfo->bitrateKbps < 256000 || srInfo->bitrateKbps > 512000 ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported bitrate for SR" ); } - bitIdx = ( ( bitrateKbps / 128000u ) - 1 ) & MASK_2BIT; + bitIdx = ( ( srInfo->bitrateKbps / 128000u ) - 1 ) & MASK_2BIT; codecId = (uint8_t) srInfo->codec; digetic = srInfo->diegetic ? 1 : 0; @@ -882,7 +881,7 @@ ivas_error IVAS_RTP_PACK_PushFrame( IVAS_RTP_PACK_HANDLE hPack, /* i/o : IVAS rtp packer handle */ IVAS_RTP_CODEC codecId, /* i : Codec type (IVAS/EVS) */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info */ + const IVAS_RTP_SR_INFO *srInfo, /* i : Split Rendering Info */ #endif /* RTP_S4_251135_CR26253_0016_REV1 */ const IVAS_DATA_BUFFER *frameBuffer /* i : packed frame bitstream for IVAS/EVS */ ) @@ -907,7 +906,8 @@ ivas_error IVAS_RTP_PACK_PushFrame( else if ( srInfo != NULL && srInfo->valid ) { tocByte = TOC_INDICATE_SR; - error = getSRToCByte( srInfo, bitrate, &tocByte1 ); + frameLengthInBits = frameBuffer->length * 8; + error = getSRToCByte( srInfo, &tocByte1 ); ERR_CHECK_RETURN( error ); } #endif @@ -1339,7 +1339,11 @@ static uint32_t parseSubsequentEByte( const IVAS_DATA_BUFFER *payload, uint32_t while ( nBytes < payload->length ) { uint8_t byte = payload->buffer[nBytes]; +#ifdef RTP_S4_251135_CR26253_0016_REV1 uint8_t ET = ( byte & ( ~MASK_4BIT ) ); +#else + uint8_t ET = ( byte & ( ~MASK_3BIT ) ); +#endif if ( ( byte & EBYTE_TOC_HEADER_BIT ) == 0 ) { @@ -1388,14 +1392,18 @@ static uint32_t parseSubsequentEByte( const IVAS_DATA_BUFFER *payload, uint32_t break; #endif default: /* Reserved for future use - unhandled atm */ - assert( 0 ); + break; } } return nBytes; } +#ifdef RTP_S4_251135_CR26253_0016_REV1 +static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBytes, uint32_t *numFrames, TOC_INFO *toc, uint32_t maxNumberOfToCBytes, uint32_t srCodecFrameSizeMs ) +#else static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBytes, uint32_t *numFrames, TOC_INFO *toc, uint32_t maxNumberOfToCBytes ) +#endif { bool headerFollows = true; uint32_t nBytes = *numBytes; @@ -1462,7 +1470,8 @@ static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBy toc->srInfo.valid = true; toc->srInfo.diegetic = ( byte >> 6 ) & MASK_1BIT; toc->srInfo.codec = IVAS_SR_TRANSPORT_LCLD + ( ( byte >> 5 ) & MASK_1BIT ); - toc->auNumBits = ( SR_BR + 1 ) * 128000u / IVAS_NUM_FRAMES_PER_SEC; + toc->srInfo.bitrateKbps = ( SR_BR + 1 ) * 128000u; + toc->auNumBits = toc->srInfo.bitrateKbps * srCodecFrameSizeMs / 1000; } else { @@ -1644,7 +1653,11 @@ ivas_error IVAS_RTP_UNPACK_PushPayload( nBytes = parseSubsequentEByte( payload, nBytes, hUnpack->requests, &piDataIndicated ); /* Unpack the ToC Bytes => Extract number of frames in packet */ +#ifdef RTP_S4_251135_CR26253_0016_REV1 + error = parseToCByte( payload, &nBytes, &numFrames, toc, sizeof( toc ) / sizeof( toc[0] ), hUnpack->initConfig.srCodecFrameSizeMs ); +#else error = parseToCByte( payload, &nBytes, &numFrames, toc, sizeof( toc ) / sizeof( toc[0] ) ); +#endif ERR_CHECK_RETURN( error ); /* Read frame bits */ diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 419d2ea9f..8d50b9681 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -396,7 +396,7 @@ static ivas_error packDynamicSuppression( const IVAS_PIDATA_GENERIC *piData, uin return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space in DAS PI data buffer" ); } - buffer[nBytes++] = ( IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION ); /* PF/PM populated during final packing */ + buffer[nBytes++] = ( das->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ buffer[nBytes++] = 2u; buffer[nBytes++] = ( das->speech ? PI_AD_SPEECH_INDICATED : 0 ) | @@ -419,7 +419,6 @@ static ivas_error unpackDynamicSuppression( const uint8_t *buffer, uint32_t numD } das->size = sizeof( IVAS_PIDATA_AUDIO_DESC ); - das->piDataType = IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION; das->speech = ( buffer[0] & PI_AD_SPEECH_INDICATED ) != 0; das->music = ( buffer[0] & PI_AD_MUSIC_INDICATED ) != 0; das->ambiance = ( buffer[0] & PI_AD_AMBIANCE_INDICATED ) != 0; diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index 3fc95f8d8..dc4c7f8ba 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -48,38 +48,38 @@ typedef enum IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED, /* orientation of device in unit quaternions (un-compensated) */ IVAS_PI_ACOUSTIC_ENVIRONMENT, /* describe the acoustic environment */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - IVAS_PI_AUDIO_DESCRIPTION, /* audio content description (voice/music/ambiance) */ - IVAS_PI_ISM_NUM, /* Number of objects */ - IVAS_PI_ISM_ID, /* id of each object */ - IVAS_PI_ISM_GAIN, /* gain of each object */ - IVAS_PI_ISM_ORIENTATION, /* orientation of each object */ - IVAS_PI_ISM_POSITION, /* position of each object */ - IVAS_PI_ISM_DISTANCE_ATTENUATION, /* distance attenuation for each object */ - IVAS_PI_ISM_DIRECTIVITY, /* directivity of each object */ - IVAS_PI_DIEGETIC_TYPE, /* digetic audio indication */ - IVAS_PI_RESERVED13, /* reserved */ - IVAS_PI_AUDIO_FOCUS_INDICATION, /* audio focus indication (direction in Quaternions and/or level) */ - IVAS_PI_RESERVED15, /* reserved */ + IVAS_PI_AUDIO_DESCRIPTION, /* audio content description (voice/music/ambiance) */ + IVAS_PI_ISM_NUM, /* Number of objects */ + IVAS_PI_ISM_ID, /* id of each object */ + IVAS_PI_ISM_GAIN, /* gain of each object */ + IVAS_PI_ISM_ORIENTATION, /* orientation of each object */ + IVAS_PI_ISM_POSITION, /* position of each object */ + IVAS_PI_ISM_DISTANCE_ATTENUATION, /* distance attenuation for each object */ + IVAS_PI_ISM_DIRECTIVITY, /* directivity of each object */ + IVAS_PI_DIEGETIC_TYPE, /* digetic audio indication */ + IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION, /* audio suppression indication */ + IVAS_PI_AUDIO_FOCUS_INDICATION, /* audio focus indication (direction in Quaternions and/or level) */ + IVAS_PI_RESERVED15, /* reserved */ /* Reverse direction PI types */ - IVAS_PI_PLAYBACK_DEVICE_ORIENTATION, /* orientation of the playback device in quaternions */ - IVAS_PI_HEAD_ORIENTATION, /* head orientation of the listener in Quaternions */ - IVAS_PI_LISTENER_POSITION, /* position of the listener in 3D space */ - IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION, /* receiver’s preference with respect to audio suppression */ - IVAS_PI_AUDIO_FOCUS_REQUEST, /* direction of interest for the listener in Quaternions and/or audio focus level */ - IVAS_PI_PI_LATENCY, /* round-trip latency for PI frames */ - IVAS_PI_R_ISM_ID, /* id of an object for editing */ - IVAS_PI_R_ISM_GAIN, /* editing request for gain factor for received object */ - IVAS_PI_R_ISM_ORIENTATION, /* editing request for orientation for received object */ - IVAS_PI_R_ISM_POSITION, /* editing request for position for received object */ - IVAS_PI_R_ISM_DIRECTION, /* editing request for direction for received object */ - IVAS_PI_RESERVED27, /* reserved */ - IVAS_PI_RESERVED28, /* reserved */ - IVAS_PI_RESERVED29, /* reserved */ - IVAS_PI_RESERVED30, /* reserved */ -#endif /* RTP_S4_251135_CR26253_0016_REV1 */ - IVAS_PI_NO_DATA = 31, /* Indicates an empty PI data frame */ - IVAS_PI_MAX_ID /* Max number of PI data IDs supprted */ + IVAS_PI_PLAYBACK_DEVICE_ORIENTATION, /* orientation of the playback device in quaternions */ + IVAS_PI_HEAD_ORIENTATION, /* head orientation of the listener in Quaternions */ + IVAS_PI_LISTENER_POSITION, /* position of the listener in 3D space */ + IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST, /* receiver’s preference with respect to audio suppression */ + IVAS_PI_AUDIO_FOCUS_REQUEST, /* direction of interest for the listener in Quaternions and/or audio focus level */ + IVAS_PI_PI_LATENCY, /* round-trip latency for PI frames */ + IVAS_PI_R_ISM_ID, /* id of an object for editing */ + IVAS_PI_R_ISM_GAIN, /* editing request for gain factor for received object */ + IVAS_PI_R_ISM_ORIENTATION, /* editing request for orientation for received object */ + IVAS_PI_R_ISM_POSITION, /* editing request for position for received object */ + IVAS_PI_R_ISM_DIRECTION, /* editing request for direction for received object */ + IVAS_PI_RESERVED27, /* reserved */ + IVAS_PI_RESERVED28, /* reserved */ + IVAS_PI_RESERVED29, /* reserved */ + IVAS_PI_RESERVED30, /* reserved */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ + IVAS_PI_NO_DATA = 31, /* Indicates an empty PI data frame */ + IVAS_PI_MAX_ID /* Max number of PI data IDs supprted */ } IVAS_PI_TYPE; /* cartesian coordinates (X,Y,Z) in 3D space */ @@ -305,9 +305,9 @@ typedef enum IVAS_FLVL_FOCUS_LEVEL_LEVEL_10, /* Audio focus level 10 */ IVAS_FLVL_FOCUS_LEVEL_LEVEL_11, /* Audio focus level 11 */ IVAS_FLVL_FOCUS_LEVEL_LEVEL_12, /* Audio focus level 12 */ - IVAS_FLVL_FOCUS_LEVEL_LEVEL_13, /* Audio focus level 13 */ - IVAS_FLVL_DEFAULT_AUDIO_FOCUS, /* Default audio focus */ IVAS_FLVL_MAX_AUDIO_FOCUS, /* Apply max audio focus */ + IVAS_FLVL_DEFAULT_AUDIO_FOCUS, /* Default audio focus */ + IVAS_FLVL_NO_PREFERENCE, /* No preference / No indication */ } IVAS_FLVL; typedef struct @@ -335,7 +335,7 @@ typedef struct */ typedef enum { - IVAS_SLI_NO_SUPPRESSION = 0, /* Apply no suppression */ + IVAS_SLI_MIN_SUPPRESSION = 0, /* Apply min suppression */ IVAS_SLI_SUPPRESSION_LEVEL_1, /* Suppression level 1 */ IVAS_SLI_SUPPRESSION_LEVEL_2, /* Suppression level 2 */ IVAS_SLI_SUPPRESSION_LEVEL_3, /* Suppression level 3 */ @@ -347,16 +347,16 @@ typedef enum IVAS_SLI_SUPPRESSION_LEVEL_9, /* Suppression level 9 */ IVAS_SLI_SUPPRESSION_LEVEL_10, /* Suppression level 10 */ IVAS_SLI_SUPPRESSION_LEVEL_11, /* Suppression level 11 */ - IVAS_SLI_SUPPRESSION_LEVEL_12, /* Suppression level 12 */ - IVAS_SLI_SUPPRESSION_LEVEL_13, /* Suppression level 13 */ - IVAS_SLI_SUPPRESSION_LEVEL_14, /* Suppression level 14 */ IVAS_SLI_MAX_SUPPRESSION, /* Apply max suppression */ + IVAS_SLI_NO_SUPPRESSION, /* Apply no suppression */ + IVAS_SLI_DEFAULT_SUPPRESSION, /* Apply default suppression */ + IVAS_SLI_NO_PREFERENCE, /* No preference / No indication */ } IVAS_SLI; typedef struct { size_t size; /* sizeof(IVAS_PIDATA_DYNAMIC_SUPPRESSION) */ - uint32_t piDataType; /* IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION */ + uint32_t piDataType; /* IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST or IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION */ bool speech; /* receiver's preference is voice/speech */ bool music; /* receiver's preference is music */ bool ambiance; /* receiver's preference is background ambiance */ @@ -443,12 +443,13 @@ typedef union IVAS_PIDATA_ISM_ATTENUATION ismAttenuation; IVAS_PIDATA_ISM_DIRECTIVITY ismDirectivity; IVAS_PIDATA_DIEGETIC digeticIndicator; + IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionIndication; IVAS_PIDATA_AUDIO_FOCUS focusIndication; IVAS_PIDATA_ORIENTATION playbackOrientation; IVAS_PIDATA_ORIENTATION headOrientation; IVAS_PIDATA_LISTENER_POSITION listnerPosition; - IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppression; + IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionRequest; IVAS_PIDATA_AUDIO_FOCUS focusRequest; IVAS_PIDATA_REVERSE_PI_LATENCY piLatency; IVAS_PIDATA_ISM_EDIT_ID ismEditId; -- GitLab From 7b668297291b268e93a15b015d7b686aeb19d2a6 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 15:17:08 +0200 Subject: [PATCH 137/351] Clang format --- apps/isar_post_rend.c | 6 +++--- lib_dec/lib_dec_fx.c | 2 +- lib_rend/ivas_rotation_fx.c | 2 +- lib_util/ivas_rtp_file.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 2ebea17a6..bb8b3eaf2 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -401,9 +401,9 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( char charBuf[25]; charBuf[24] = '\0'; - #ifdef RTP_S4_251135_CR26253_0016_REV1 - *srRtp = false; - #endif +#ifdef RTP_S4_251135_CR26253_0016_REV1 + *srRtp = false; +#endif strncpy( charBuf, configString, sizeof( charBuf ) - 1 ); charBuf[sizeof( charBuf ) - 1] = '\0'; to_upper( charBuf ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 3ac27bd2c..66193ac60 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5660,7 +5660,7 @@ static ivas_error IVAS_DEC_feedSinglePIorientation( for ( i = 0; i < hIvasDec->st_ivas->hExtOrientationData->num_subframes; i++ ) { QuaternionProduct_fx( hIvasDec->st_ivas->hExtOrientationData->Quaternions[i], savedInvOrientation, - &hIvasDec->st_ivas->hExtOrientationData->Quaternions[i] ); + &hIvasDec->st_ivas->hExtOrientationData->Quaternions[i] ); hIvasDec->st_ivas->hExtOrientationData->enableExternalOrientation[i] = true; } hIvasDec->updateOrientation = true; diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index cf0386c63..676ca7147 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1441,7 +1441,7 @@ ivas_error ivas_combined_orientation_open_fx( move16(); #ifdef RTP_S4_251135_CR26253_0016_REV1 - FOR ( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) + FOR( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) { ( *hCombinedOrientationData )->isDiegeticInputPI[i] = TRUE; move16(); diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 5846b0423..ab08b5e02 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -693,7 +693,7 @@ ivas_error IVAS_RTP_WRITER_Init( } ivas_error IVAS_RTP_READER_Init( - IVAS_RTP *rtp, /* i/o : IVAS RTP File reader handle */ + IVAS_RTP *rtp, /* i/o : IVAS RTP File reader handle */ #ifdef RTP_S4_251135_CR26253_0016_REV1 uint32_t srCodecFrameSizeMs, /* i : SR Codec Framesize in ms */ #endif @@ -760,8 +760,8 @@ ivas_error IVAS_RTP_READER_Init( } ivas_error IVAS_RTP_WriteNextFrame( - IVAS_RTP *rtp, /* i/o : IVAS RTP File writer handle */ - uint8_t *au, /* i : IVAS Compressed AU (Packed frame) */ + IVAS_RTP *rtp, /* i/o : IVAS RTP File writer handle */ + uint8_t *au, /* i : IVAS Compressed AU (Packed frame) */ #ifdef RTP_S4_251135_CR26253_0016_REV1 const IVAS_RTP_SR_INFO *srInfo, /* i : Split rendering info in present, else NULL */ #endif @@ -833,7 +833,7 @@ ivas_error IVAS_RTP_ReadNextFrame( #ifdef RTP_S4_251135_CR26253_0016_REV1 IVAS_RTP_SR_INFO *srInfo, /* o : Split Rendering info if SR RTP frame unpacked */ #endif - bool *qBit /* o : AMRWB Q bite as indicated in the RTP packet */ + bool *qBit /* o : AMRWB Q bite as indicated in the RTP packet */ ) { ivas_error error = IVAS_ERR_OK; -- GitLab From c17ed8c8d8921f06670adfd084c62fa15e2f7c05 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 15:24:40 +0200 Subject: [PATCH 138/351] Remove unused parameter --- apps/decoder.c | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index c7707df5d..256926c56 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2816,7 +2816,6 @@ static ivas_error decodeVoIP( #ifdef IVAS_RTPDUMP IVAS_RTP ivasRtp = { 0 }; IVAS_RTP srRtp = { 0 }; - IVAS_RTP_SR_INFO srInfo = { true, false, 0, IVAS_SR_TRANSPORT_LCLD }; int32_t initialTsOffsetSystemAndRTP = 0; #else FILE *f_rtpstream = NULL; -- GitLab From e0f58ca142236b273577a2ef30cc66529cad40eb Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 3 Nov 2025 14:48:28 +0100 Subject: [PATCH 139/351] improve precision of latencyNsToSamples NS2SA macro was off by one for low values --- lib_rend/lib_rend_fx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index ff12ac1bd..cd8490928 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -289,10 +289,12 @@ static Word16 latencyNsToSamples( Word32 sampleRate, Word32 latency_ns ) { - Word16 n_samples; + Word16 var1, exp; + Word32 var2; + var1 = BASOP_Util_Divide3232_Scale( sampleRate, 1000000000, &exp ); + var2 = L_shr_r( Mpy_32_32( latency_ns, L_deposit_h( var1 ) ), negate( exp ) ); /* Q0 */ - n_samples = NS2SA_FX2( sampleRate, latency_ns ); - return n_samples; + return extract_l(var2); } static ivas_error allocateMcLfeDelayBuffer_fx( -- GitLab From 1ae952addfdb9915124aa62555b226db72405c33 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 3 Nov 2025 14:52:27 +0100 Subject: [PATCH 140/351] clang-format --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index cd8490928..770cc89aa 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -294,7 +294,7 @@ static Word16 latencyNsToSamples( var1 = BASOP_Util_Divide3232_Scale( sampleRate, 1000000000, &exp ); var2 = L_shr_r( Mpy_32_32( latency_ns, L_deposit_h( var1 ) ), negate( exp ) ); /* Q0 */ - return extract_l(var2); + return extract_l( var2 ); } static ivas_error allocateMcLfeDelayBuffer_fx( -- GitLab From 0342dccc05e40e4d1a96d3e02414eb3c3c38d3a3 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 3 Nov 2025 15:01:38 +0100 Subject: [PATCH 141/351] Handle negative shr in hp20_fx_32_opt() --- lib_com/hp50_fx.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index 1586bc252..3debe546b 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -331,8 +331,10 @@ void hp20_fx_32_opt( move32(); move32(); move32(); +#ifndef FIX_2086_ENABLE_HP20_OPT_FOR_ENC mem_fx[4] = L_deposit_l( prescale_current_frame ); move32(); +#endif IF( EQ_32( Fs, 8000 ) ) { @@ -405,7 +407,36 @@ void hp20_fx_32_opt( signal_fx[1] = W_round64_L( W_shl( W_y1, prescale ) ); move32(); +#ifdef FIX_2086_ENABLE_HP20_OPT_FOR_ENC + Word16 scf_min = 63; + move16(); + IF( GT_32( prescale, prescale_current_frame ) ) + { + if ( NE_64( W_y1, 0 ) ) + scf_min = s_min( scf_min, W_norm( W_y1 ) ); + if ( NE_64( W_y2, 0 ) ) + scf_min = s_min( scf_min, W_norm( W_y1 ) ); + if ( NE_32( x1, 0 ) ) + scf_min = s_min( scf_min, norm_l( x1 ) ); + if ( NE_32( x2, 0 ) ) + scf_min = s_min( scf_min, norm_l( x2 ) ); + diff = sub( prescale_current_frame, prescale ); + diff = s_max( negate( scf_min ), diff ); + prescale_current_frame = add( prescale, diff ); + //prescale_current_frame = prescale; + //diff = 0; + //move16(); + } + ELSE + { + diff = sub( prescale_current_frame, prescale ); + } + mem_fx[4] = L_deposit_l( prescale_current_frame ); + move32(); +#else diff = sub( prescale_current_frame, prescale ); +#endif + W_y1 = W_shr( W_y1, diff ); W_y2 = W_shr( W_y2, diff ); x2 = L_shr( x2, diff ); -- GitLab From 1037c58204bf07dfdab78e3d9468adb7df7baf61 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 3 Nov 2025 15:05:04 +0100 Subject: [PATCH 142/351] Apply clang formatting patch --- lib_com/hp50_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index 3debe546b..e5f762ed9 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -423,9 +423,9 @@ void hp20_fx_32_opt( diff = sub( prescale_current_frame, prescale ); diff = s_max( negate( scf_min ), diff ); prescale_current_frame = add( prescale, diff ); - //prescale_current_frame = prescale; - //diff = 0; - //move16(); + // prescale_current_frame = prescale; + // diff = 0; + // move16(); } ELSE { -- GitLab From 729f2a1640b3700c3b472f2076d78d3633c67a78 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 15:09:30 +0100 Subject: [PATCH 143/351] Align with port 369 branch --- lib_rend/ivas_td_ring_buffer_fx.c | 46 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index a67143dbb..cb066b544 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -52,12 +52,12 @@ static Word32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { - IF( h->is_full ) + IF ( h->is_full ) { return h->capacity; } - IF( LE_32( h->read_pos, h->write_pos ) ) + IF ( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - IF( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -95,7 +95,7 @@ static void ivas_td_ringbuf_push_interleaved( read_s = 0; move32(); - FOR( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) + FOR ( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) { h->data[h->write_pos] = data[read_s]; move32(); @@ -146,7 +146,7 @@ ivas_error ivas_TD_RINGBUF_Open( move32(); h = malloc( sizeof( TD_RINGBUF_DATA ) ); - IF( h == NULL ) + IF ( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -164,7 +164,7 @@ ivas_error ivas_TD_RINGBUF_Open( *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - IF( h->data == NULL ) + IF ( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -188,18 +188,18 @@ void ivas_TD_RINGBUF_Close( { TD_RINGBUF_HANDLE h; - IF( ph == NULL ) + IF ( ph == NULL ) { return; } h = *ph; - IF( h == NULL ) + IF ( h == NULL ) { return; } - IF( h->data != NULL ) + IF ( h->data != NULL ) { free( h->data ); } @@ -262,16 +262,16 @@ void ivas_TD_RINGBUF_Push( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - FOR( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } #endif assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - FOR( s = 0; s < num_samples_per_channel; ++s ) + FOR ( s = 0; s < num_samples_per_channel; ++s ) { - FOR( c = 0; c < h->num_channels; ++c ) + FOR ( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP h->data[h->write_pos] = p_channels[c][s]; @@ -333,20 +333,20 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - IF( !num_samples_per_channel ) + IF ( !num_samples_per_channel ) { return; } - FOR( s = 0; s < num_samples_per_channel; ++s ) + FOR ( s = 0; s < num_samples_per_channel; ++s ) { - FOR( c = 0; c < h->num_channels; ++c ) + FOR ( c = 0; c < h->num_channels; ++c ) { - h->data[h->write_pos] = 0.f; + h->data[h->write_pos] = 0; move32(); h->write_pos = L_add( h->write_pos, 1 ); - IF( EQ_32( h->write_pos, h->capacity ) ) + IF ( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -397,16 +397,16 @@ void ivas_TD_RINGBUF_Pop( #ifdef FIX_1119_SPLIT_RENDERING_VOIP assert( h != NULL ); assert( p_channels != NULL ); - FOR( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ + for ( c = 0; c < h->num_channels; ++c ) /* Not using BASOP FOR because this loops only does assertions */ { assert( p_channels[c] != NULL ); } #endif assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); - FOR( s = 0; s < num_samples_per_channel; ++s ) + FOR ( s = 0; s < num_samples_per_channel; ++s ) { - FOR( c = 0; c < h->num_channels; ++c ) + FOR ( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP p_channels[c][s] = h->data[h->read_pos]; @@ -417,7 +417,7 @@ void ivas_TD_RINGBUF_Pop( #endif ++h->read_pos; - IF( EQ_32( h->read_pos, h->capacity ) ) + IF ( EQ_32( h->read_pos, h->capacity ) ) { h->read_pos = 0; move32(); @@ -426,13 +426,13 @@ void ivas_TD_RINGBUF_Pop( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF( NE_16( num_samples_per_channel, 0 ) ) + IF ( NE_16( num_samples_per_channel, 0 ) ) { h->is_full = 0; move16(); } #else - IF( h->is_full ) + IF ( h->is_full ) { h->is_full = 0; move16(); -- GitLab From 1f22a948a660e17c651db8ee99ed3e590e255fbd Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 3 Nov 2025 16:39:54 +0200 Subject: [PATCH 144/351] Fix PI orientations --- lib_util/ivas_rtp_file.c | 70 +++++++++++++++++++++++++++++-------- lib_util/ivas_rtp_pi_data.c | 32 ++++++++--------- 2 files changed, 72 insertions(+), 30 deletions(-) diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index ab08b5e02..10eaa73c1 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -33,6 +33,7 @@ #include #include "ivas_rtp_file.h" #include "ivas_error_utils.h" +#include "prot_fx.h" struct IVAS_RTP_FILE { @@ -191,8 +192,11 @@ void IVAS_RTP_LogPiData( case IVAS_PI_R_ISM_ORIENTATION: #endif { - fprintf( f_piDataOut, "{\n\t\t\t\"w\": %d,\n\t\t\t\"x\": %d,\n\t\t\t\"y\": %d,\n\t\t\t\"z\": %d \n\t\t}", - cur->data.scene.orientation.w_fx, cur->data.scene.orientation.x_fx, cur->data.scene.orientation.y_fx, cur->data.scene.orientation.z_fx ); + fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", + fixedToFloat( cur->data.scene.orientation.w_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.x_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.y_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.z_fx, Q15 ) ); } break; @@ -259,8 +263,11 @@ void IVAS_RTP_LogPiData( if ( cur->data.focusIndication.availDirection ) { fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); - fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %d,\n\t\t\t\t\t\t\"x\": %d,\n\t\t\t\t\t\t\"y\": %d,\n\t\t\t\t\t\t\"z\": %d \n\t\t\t}", - cur->data.focusIndication.direction.w_fx, cur->data.focusIndication.direction.x_fx, cur->data.focusIndication.direction.y_fx, cur->data.focusIndication.direction.z_fx ); + fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", + fixedToFloat( cur->data.focusIndication.direction.w_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.x_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.y_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.z_fx, Q15 ) ); if ( cur->data.focusIndication.availLevel ) { fprintf( f_piDataOut, "," ); @@ -301,8 +308,11 @@ void IVAS_RTP_LogPiData( if ( cur->data.focusRequest.availDirection ) { fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); - fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %d,\n\t\t\t\t\t\t\"x\": %d,\n\t\t\t\t\t\t\"y\": %d,\n\t\t\t\t\t\t\"z\": %d \n\t\t\t}", - cur->data.focusRequest.direction.w_fx, cur->data.focusRequest.direction.x_fx, cur->data.focusRequest.direction.y_fx, cur->data.focusRequest.direction.z_fx ); + fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", + fixedToFloat( cur->data.focusRequest.direction.w_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.x_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.y_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.z_fx, Q15 ) ); if ( cur->data.focusRequest.availLevel ) { fprintf( f_piDataOut, "," ); @@ -372,17 +382,29 @@ void IVAS_RTP_WriteExtPiData( { case IVAS_PI_SCENE_ORIENTATION: { - fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.scene.orientation.w_fx, cur->data.scene.orientation.x_fx, cur->data.scene.orientation.y_fx, cur->data.scene.orientation.z_fx ); + fprintf( f_piDataOut, "%f,%f,%f,%f", + fixedToFloat( cur->data.scene.orientation.w_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.x_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.y_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.z_fx, Q15 ) ); } break; case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: { - fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.deviceCompensated.orientation.w_fx, cur->data.deviceCompensated.orientation.x_fx, cur->data.deviceCompensated.orientation.y_fx, cur->data.deviceCompensated.orientation.z_fx ); + fprintf( f_piDataOut, "%f,%f,%f,%f", + fixedToFloat( cur->data.deviceCompensated.orientation.w_fx, Q15 ), + fixedToFloat( cur->data.deviceCompensated.orientation.x_fx, Q15 ), + fixedToFloat( cur->data.deviceCompensated.orientation.y_fx, Q15 ), + fixedToFloat( cur->data.deviceCompensated.orientation.z_fx, Q15 ) ); } break; case IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED: { - fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.deviceUnCompensated.orientation.w_fx, cur->data.deviceUnCompensated.orientation.x_fx, cur->data.deviceUnCompensated.orientation.y_fx, cur->data.deviceUnCompensated.orientation.z_fx ); + fprintf( f_piDataOut, "%f,%f,%f,%f", + fixedToFloat( cur->data.deviceUnCompensated.orientation.w_fx, Q15 ), + fixedToFloat( cur->data.deviceUnCompensated.orientation.x_fx, Q15 ), + fixedToFloat( cur->data.deviceUnCompensated.orientation.y_fx, Q15 ), + fixedToFloat( cur->data.deviceUnCompensated.orientation.z_fx, Q15 ) ); } break; case IVAS_PI_ACOUSTIC_ENVIRONMENT: @@ -450,7 +472,11 @@ void IVAS_RTP_WriteExtPiData( { fprintf( f_piDataOut, "," ); } - fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.ismOrientation.orientation[i].w_fx, cur->data.ismOrientation.orientation[i].x_fx, cur->data.ismOrientation.orientation[i].y_fx, cur->data.ismOrientation.orientation[i].z_fx ); + fprintf( f_piDataOut, "%f,%f,%f,%f", + fixedToFloat( cur->data.ismOrientation.orientation[i].w_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[i].x_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[i].y_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[i].z_fx, Q15 ) ); } } break; @@ -506,7 +532,11 @@ void IVAS_RTP_WriteExtPiData( { if ( cur->data.focusIndication.availDirection ) { - fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.focusIndication.direction.w_fx, cur->data.focusIndication.direction.x_fx, cur->data.focusIndication.direction.y_fx, cur->data.focusIndication.direction.z_fx ); + fprintf( f_piDataOut, "%f,%f,%f,%f", + fixedToFloat( cur->data.focusIndication.direction.w_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.x_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.y_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.z_fx, Q15 ) ); if ( cur->data.focusIndication.availLevel ) { fprintf( f_piDataOut, "," ); @@ -520,12 +550,20 @@ void IVAS_RTP_WriteExtPiData( break; case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: { - fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.playbackOrientation.orientation.w_fx, cur->data.playbackOrientation.orientation.x_fx, cur->data.playbackOrientation.orientation.y_fx, cur->data.playbackOrientation.orientation.z_fx ); + fprintf( f_piDataOut, "%f,%f,%f,%f", + fixedToFloat( cur->data.playbackOrientation.orientation.w_fx, Q15 ), + fixedToFloat( cur->data.playbackOrientation.orientation.x_fx, Q15 ), + fixedToFloat( cur->data.playbackOrientation.orientation.y_fx, Q15 ), + fixedToFloat( cur->data.playbackOrientation.orientation.z_fx, Q15 ) ); } break; case IVAS_PI_HEAD_ORIENTATION: { - fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.headOrientation.orientation.w_fx, cur->data.headOrientation.orientation.x_fx, cur->data.headOrientation.orientation.y_fx, cur->data.headOrientation.orientation.z_fx ); + fprintf( f_piDataOut, "%f,%f,%f,%f", + fixedToFloat( cur->data.headOrientation.orientation.w_fx, Q15 ), + fixedToFloat( cur->data.headOrientation.orientation.x_fx, Q15 ), + fixedToFloat( cur->data.headOrientation.orientation.y_fx, Q15 ), + fixedToFloat( cur->data.headOrientation.orientation.z_fx, Q15 ) ); } break; case IVAS_PI_LISTENER_POSITION: @@ -544,7 +582,11 @@ void IVAS_RTP_WriteExtPiData( if ( cur->data.focusRequest.availDirection ) { - fprintf( f_piDataOut, "%d,%d,%d,%d", cur->data.focusRequest.direction.w_fx, cur->data.focusRequest.direction.x_fx, cur->data.focusRequest.direction.y_fx, cur->data.focusRequest.direction.z_fx ); + fprintf( f_piDataOut, "%f,%f,%f,%f", + fixedToFloat( cur->data.focusRequest.direction.w_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.x_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.y_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.z_fx, Q15 ) ); if ( cur->data.focusRequest.availLevel ) { fprintf( f_piDataOut, "," ); diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 8d50b9681..be2e9dd4d 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -145,10 +145,10 @@ static ivas_error packOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t *b buffer[nBytes++] = ( orientation->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ buffer[nBytes++] = 8; - nBytes = writeInt16( buffer, nBytes, orientation->orientation.w_fx ); - nBytes = writeInt16( buffer, nBytes, orientation->orientation.x_fx ); - nBytes = writeInt16( buffer, nBytes, orientation->orientation.y_fx ); - nBytes = writeInt16( buffer, nBytes, orientation->orientation.z_fx ); + nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation.w_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation.x_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation.y_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation.z_fx ) ); *nBytesWritten = nBytes; return IVAS_ERR_OK; @@ -165,10 +165,10 @@ static ivas_error unpackOrientation( const uint8_t *buffer, uint32_t numDataByte } piData->size = sizeof( IVAS_PIDATA_ORIENTATION ); - orientation->orientation.w_fx = readInt16( &buffer[0] ); - orientation->orientation.x_fx = readInt16( &buffer[2] ); - orientation->orientation.y_fx = readInt16( &buffer[4] ); - orientation->orientation.z_fx = readInt16( &buffer[6] ); + orientation->orientation.w_fx = L_deposit_l( readInt16( &buffer[0] ) ); + orientation->orientation.x_fx = L_deposit_l( readInt16( &buffer[2] ) ); + orientation->orientation.y_fx = L_deposit_l( readInt16( &buffer[4] ) ); + orientation->orientation.z_fx = L_deposit_l( readInt16( &buffer[6] ) ); return IVAS_ERR_OK; } @@ -582,10 +582,10 @@ static ivas_error packAudioFocusCommon( const IVAS_PIDATA_GENERIC *piData, uint8 if ( packedSize == 9 || packedSize == 8 ) { - nBytes = writeInt16( buffer, nBytes, audioFocus->direction.w_fx ); - nBytes = writeInt16( buffer, nBytes, audioFocus->direction.x_fx ); - nBytes = writeInt16( buffer, nBytes, audioFocus->direction.y_fx ); - nBytes = writeInt16( buffer, nBytes, audioFocus->direction.z_fx ); + nBytes = writeInt16( buffer, nBytes, round_fx( audioFocus->direction.w_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( audioFocus->direction.x_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( audioFocus->direction.y_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( audioFocus->direction.z_fx ) ); } if ( packedSize == 9 || packedSize == 1 ) { @@ -616,10 +616,10 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat } else { - audioFocus->direction.w_fx = readInt16( &buffer[0] ); - audioFocus->direction.x_fx = readInt16( &buffer[2] ); - audioFocus->direction.y_fx = readInt16( &buffer[4] ); - audioFocus->direction.z_fx = readInt16( &buffer[6] ); + audioFocus->direction.w_fx = L_deposit_l( readInt16( &buffer[0] ) ); + audioFocus->direction.x_fx = L_deposit_l( readInt16( &buffer[2] ) ); + audioFocus->direction.y_fx = L_deposit_l( readInt16( &buffer[4] ) ); + audioFocus->direction.z_fx = L_deposit_l( readInt16( &buffer[6] ) ); if ( numDataBytes == 9 ) { -- GitLab From 8a93dcbefb1eb32b3005a93d454d0c80fab91e63 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 15:46:18 +0100 Subject: [PATCH 145/351] Fix formatting --- lib_rend/ivas_td_ring_buffer_fx.c | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index cb066b544..2bd4f35a7 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -52,12 +52,12 @@ static Word32 ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { - IF ( h->is_full ) + IF( h->is_full ) { return h->capacity; } - IF ( LE_32( h->read_pos, h->write_pos ) ) + IF( LE_32( h->read_pos, h->write_pos ) ) { return L_sub( h->write_pos, h->read_pos ); } @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - IF ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -95,7 +95,7 @@ static void ivas_td_ringbuf_push_interleaved( read_s = 0; move32(); - FOR ( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) + FOR( s = 0; s < L_mult0( num_samples_per_channel, h->num_channels ); ++s ) { h->data[h->write_pos] = data[read_s]; move32(); @@ -146,7 +146,7 @@ ivas_error ivas_TD_RINGBUF_Open( move32(); h = malloc( sizeof( TD_RINGBUF_DATA ) ); - IF ( h == NULL ) + IF( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -164,7 +164,7 @@ ivas_error ivas_TD_RINGBUF_Open( *ph = h; h->data = malloc( capacity * sizeof( Word32 ) ); - IF ( h->data == NULL ) + IF( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -188,18 +188,18 @@ void ivas_TD_RINGBUF_Close( { TD_RINGBUF_HANDLE h; - IF ( ph == NULL ) + IF( ph == NULL ) { return; } h = *ph; - IF ( h == NULL ) + IF( h == NULL ) { return; } - IF ( h->data != NULL ) + IF( h->data != NULL ) { free( h->data ); } @@ -269,9 +269,9 @@ void ivas_TD_RINGBUF_Push( #endif assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP h->data[h->write_pos] = p_channels[c][s]; @@ -333,20 +333,20 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - IF ( !num_samples_per_channel ) + IF( !num_samples_per_channel ) { return; } - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { h->data[h->write_pos] = 0; move32(); h->write_pos = L_add( h->write_pos, 1 ); - IF ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -404,9 +404,9 @@ void ivas_TD_RINGBUF_Pop( #endif assert( ivas_td_ringbuf_total_size( h ) >= num_samples_per_channel * h->num_channels ); - FOR ( s = 0; s < num_samples_per_channel; ++s ) + FOR( s = 0; s < num_samples_per_channel; ++s ) { - FOR ( c = 0; c < h->num_channels; ++c ) + FOR( c = 0; c < h->num_channels; ++c ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP p_channels[c][s] = h->data[h->read_pos]; @@ -417,7 +417,7 @@ void ivas_TD_RINGBUF_Pop( #endif ++h->read_pos; - IF ( EQ_32( h->read_pos, h->capacity ) ) + IF( EQ_32( h->read_pos, h->capacity ) ) { h->read_pos = 0; move32(); @@ -426,13 +426,13 @@ void ivas_TD_RINGBUF_Pop( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - IF ( NE_16( num_samples_per_channel, 0 ) ) + IF( NE_16( num_samples_per_channel, 0 ) ) { h->is_full = 0; move16(); } #else - IF ( h->is_full ) + IF( h->is_full ) { h->is_full = 0; move16(); -- GitLab From fd6402296bdbf390f768ca46b66dae0da6c4fcaa Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 3 Nov 2025 15:55:47 +0100 Subject: [PATCH 146/351] align ring buffer code with later MR --- lib_rend/ivas_prot_rend_fx.h | 3 ++- lib_rend/ivas_stat_rend.h | 10 +++++----- lib_rend/ivas_td_ring_buffer_fx.c | 18 +++++++----------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 84dcc6072..ef62dbe9d 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1624,10 +1624,11 @@ void ivas_TD_RINGBUF_Pop( Word32 *data, /* i : Output data */ const Word16 num_samples_per_channel /* i : Number of samples per channel to retrieve*/ ); -#endif Word16 ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ); /* clang-format on */ + +#endif /* IVAS_PROT_REND_H */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 75a37e30f..3f6ac811b 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1440,11 +1440,11 @@ typedef struct typedef struct { - Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ - UWord32 capacity; /* max number of Word32 values that can be stored */ - UWord16 num_channels; - UWord32 write_pos; - UWord32 read_pos; + Word32 *data; /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */ + Word32 capacity; /* max number of Word32 values that can be stored */ + Word16 num_channels; + Word32 write_pos; + Word32 read_pos; Word16 is_full; } TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE; diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index e640f9501..a7301a3a6 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const Word32 num_samples ) { - if ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) + IF( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) ) { return 1; } @@ -108,7 +108,6 @@ ivas_error ivas_TD_RINGBUF_Open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } h->data = NULL; - move32(); h->capacity = 0; move32(); h->num_channels = num_channels; @@ -120,10 +119,9 @@ ivas_error ivas_TD_RINGBUF_Open( h->is_full = 0; move16(); *ph = h; - move32(); h->data = malloc( capacity * sizeof( Word32 ) ); - if ( h->data == NULL ) + IF( h->data == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); } @@ -152,7 +150,6 @@ void ivas_TD_RINGBUF_Close( return; } h = *ph; - move32(); IF( h == NULL ) { @@ -166,7 +163,6 @@ void ivas_TD_RINGBUF_Close( free( h ); *ph = NULL; - move32(); return; } @@ -196,7 +192,7 @@ void ivas_TD_RINGBUF_Push( { h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; move32(); - ++h->write_pos; + h->write_pos = L_add( h->write_pos, 1 ); if ( EQ_32( h->write_pos, h->capacity ) ) { @@ -231,7 +227,7 @@ void ivas_TD_RINGBUF_PushZeros( Word16 c; assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) ); - if ( !num_samples_per_channel ) + IF( !num_samples_per_channel ) { return; } @@ -242,9 +238,9 @@ void ivas_TD_RINGBUF_PushZeros( { h->data[h->write_pos] = 0; move32(); - ++h->write_pos; + h->write_pos = L_add( h->write_pos, 1 ); - if ( EQ_32( h->write_pos, h->capacity ) ) + IF( EQ_32( h->write_pos, h->capacity ) ) { h->write_pos = 0; move32(); @@ -295,7 +291,7 @@ void ivas_TD_RINGBUF_Pop( } } - if ( h->is_full ) + IF( h->is_full ) { h->is_full = 0; move16(); -- GitLab From aa36b6b40b14360f3308e0cdf6f24f1c069db727 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 3 Nov 2025 16:07:49 +0100 Subject: [PATCH 147/351] use MAC operators instead of separate add and mult --- lib_rend/ivas_td_ring_buffer_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index a7301a3a6..24ab8a8a6 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -190,7 +190,7 @@ void ivas_TD_RINGBUF_Push( { FOR( c = 0; c < h->num_channels; ++c ) { - h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; + h->data[h->write_pos] = data[L_mac0( s, c, num_samples_per_channel )]; move32(); h->write_pos = L_add( h->write_pos, 1 ); @@ -279,7 +279,7 @@ void ivas_TD_RINGBUF_Pop( { FOR( c = 0; c < h->num_channels; ++c ) { - data[L_add( L_mult0( c, num_samples_per_channel ), s )] = h->data[h->read_pos]; + data[L_mac0( s, c, num_samples_per_channel )] = h->data[h->read_pos]; move32(); ++h->read_pos; -- GitLab From 6cbfcd50ce8a7593092f8c7aed677708b966f41f Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 3 Nov 2025 16:08:43 +0100 Subject: [PATCH 148/351] Align one more thing with port 369 --- lib_rend/ivas_td_ring_buffer_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c index 2bd4f35a7..5866c31ad 100644 --- a/lib_rend/ivas_td_ring_buffer_fx.c +++ b/lib_rend/ivas_td_ring_buffer_fx.c @@ -277,7 +277,7 @@ void ivas_TD_RINGBUF_Push( h->data[h->write_pos] = p_channels[c][s]; move32(); #else - h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )]; + h->data[h->write_pos] = data[L_mac0( s, c, num_samples_per_channel )]; move32(); #endif h->write_pos = L_add( h->write_pos, 1 ); @@ -412,7 +412,7 @@ void ivas_TD_RINGBUF_Pop( p_channels[c][s] = h->data[h->read_pos]; move32(); #else - data[L_add( L_mult0( c, num_samples_per_channel ), s )] = h->data[h->read_pos]; + data[L_mac0( s, c, num_samples_per_channel )] = h->data[h->read_pos]; move32(); #endif ++h->read_pos; -- GitLab From bdebaafc79b8682b3b6d508119944737f9e28059 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 3 Nov 2025 17:03:21 +0100 Subject: [PATCH 149/351] Handle overflow in shr() scaling more simply --- lib_com/hp50_fx.c | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index e5f762ed9..26cc77794 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -316,8 +316,12 @@ void hp20_fx_32_opt( prescale = s_min( prescale, diff ); prescale = sub( 1 + HP20_FX_COEFF_SCALE, prescale ); - +#ifdef FIX_2086_ENABLE_HP20_OPT_FOR_ENC + if ( EQ_16( prescale_current_frame, 1 + HP20_FX_COEFF_SCALE - 31 ) || // signal_fx buffer contains only zeros, so use the mem_fx scale_factor instead + LT_16( prescale_current_frame, prescale ) ) // To avoid overflow in the subsequent shr() scaling for W_y1, W_y2, x2, and x1 calculations before the for loop. +#else if ( EQ_16( prescale_current_frame, 1 + HP20_FX_COEFF_SCALE - 31 ) ) // signal_fx buffer contains only zeros, so use the mem_fx scale_factor instead +#endif { prescale_current_frame = prescale; } @@ -331,10 +335,8 @@ void hp20_fx_32_opt( move32(); move32(); move32(); -#ifndef FIX_2086_ENABLE_HP20_OPT_FOR_ENC mem_fx[4] = L_deposit_l( prescale_current_frame ); move32(); -#endif IF( EQ_32( Fs, 8000 ) ) { @@ -407,36 +409,7 @@ void hp20_fx_32_opt( signal_fx[1] = W_round64_L( W_shl( W_y1, prescale ) ); move32(); -#ifdef FIX_2086_ENABLE_HP20_OPT_FOR_ENC - Word16 scf_min = 63; - move16(); - IF( GT_32( prescale, prescale_current_frame ) ) - { - if ( NE_64( W_y1, 0 ) ) - scf_min = s_min( scf_min, W_norm( W_y1 ) ); - if ( NE_64( W_y2, 0 ) ) - scf_min = s_min( scf_min, W_norm( W_y1 ) ); - if ( NE_32( x1, 0 ) ) - scf_min = s_min( scf_min, norm_l( x1 ) ); - if ( NE_32( x2, 0 ) ) - scf_min = s_min( scf_min, norm_l( x2 ) ); - diff = sub( prescale_current_frame, prescale ); - diff = s_max( negate( scf_min ), diff ); - prescale_current_frame = add( prescale, diff ); - // prescale_current_frame = prescale; - // diff = 0; - // move16(); - } - ELSE - { - diff = sub( prescale_current_frame, prescale ); - } - mem_fx[4] = L_deposit_l( prescale_current_frame ); - move32(); -#else diff = sub( prescale_current_frame, prescale ); -#endif - W_y1 = W_shr( W_y1, diff ); W_y2 = W_shr( W_y2, diff ); x2 = L_shr( x2, diff ); -- GitLab From 1a9156a94344370a8ce8f16d2ac85b8b5fe60619 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 3 Nov 2025 17:42:42 +0100 Subject: [PATCH 150/351] port MR 2288 from float - BASOP version Avoid rounding when passing angular information to efap_determine_gains() --- lib_com/options.h | 1 + lib_dec/ivas_ism_param_dec_fx.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c967fd233..a31745014 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -126,6 +126,7 @@ #define FIX_1383_HEAD_TRACK_SANITIZER /* Nok: issue 1383: Fix head tracking struc values reading in renderer */ #define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ #define FIX_1411_IGF_CRASH_BW_SWITCHING /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/ +#define NONBE_1412_AVOID_ROUNDING_AZ_ELEV /* FhG: Avoid rounding when passing azimuth and elevation to efap_determine_gains() */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 1c94fbe39..a951a6bad 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -942,7 +942,9 @@ void ivas_ism_dec_digest_tc_fx( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) { Word16 i; +#ifndef NONBE_1412_AVOID_ROUNDING_AZ_ELEV Word32 azimuth_fx, elevation_fx; +#endif /* we have a full frame interpolator, adapt it */ /* for BE testing */ @@ -1011,9 +1013,11 @@ void ivas_ism_dec_digest_tc_fx( } ELSE { +#ifndef NONBE_1412_AVOID_ROUNDING_AZ_ELEV // TODO tmu review when #215 is resolved azimuth_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22 elevation_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22 +#endif test(); test(); @@ -1029,6 +1033,9 @@ void ivas_ism_dec_digest_tc_fx( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) ) && st_ivas->hCombinedOrientationData == NULL ) { +#ifdef NONBE_1412_AVOID_ROUNDING_AZ_ELEV + Word32 elevation_fx = st_ivas->hIsmMetaData[i]->edited_elevation_fx; +#endif if ( st_ivas->hIntSetup.is_planar_setup ) { /* If no elevation support in output format, then rendering should be done with zero elevation */ @@ -1038,10 +1045,16 @@ void ivas_ism_dec_digest_tc_fx( IF( st_ivas->hEFAPdata != NULL ) { - azimuth_fx = L_shl( azimuth_fx, Q22 ); // Q22 +#ifndef NONBE_1412_AVOID_ROUNDING_AZ_ELEV + azimuth_fx = L_shl( azimuth_fx, Q22 ); // Q22 +#endif elevation_fx = L_shl( elevation_fx, Q22 ); // Q22 +#ifdef NONBE_1412_AVOID_ROUNDING_AZ_ELEV + efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); +#else efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); +#endif // TODO: align Q values properly IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) { -- GitLab From 76eaae3b919695102c3c1946af57c4cb9001c368 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 3 Nov 2025 20:36:15 +0100 Subject: [PATCH 151/351] remove remaining instances of BASOP_Util_Divide3232_Scale_cadence() --- lib_isar/isar_splitRendererPre.c | 16 ++++++++++++++++ lib_isar/lib_isar_pre_rend.c | 12 ++++++++++++ lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 71e285a9c..227b159c8 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2964,7 +2964,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( // target_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; target_md_bits = W_extract_l( W_mult0_32_32( isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ), L_FRAME48k ) ); tmp_e = 0; +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence tmp_32 = BASOP_Util_Divide3232_Scale_cadence( target_md_bits, 48000, &tmp_e ); +#else + tmp_32 = BASOP_Util_Divide3232_Scale_newton( target_md_bits, 48000, &tmp_e ); +#endif target_md_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 /*scaling to max Q*/ @@ -3002,7 +3006,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( // available_bits = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); available_bits = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); tmp_e = 0; +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence tmp_32 = BASOP_Util_Divide3232_Scale_cadence( available_bits, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); +#else + tmp_32 = BASOP_Util_Divide3232_Scale_newton( available_bits, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); +#endif available_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 available_bits = L_sub( available_bits, pBits->bits_written ); pBits->codec_frame_size_ms = codec_frame_size_ms; @@ -3050,7 +3058,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( bit_len = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); tmp_e = 0; +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence tmp_32 = BASOP_Util_Divide3232_Scale_cadence( bit_len, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); +#else + tmp_32 = BASOP_Util_Divide3232_Scale_newton( bit_len, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); +#endif bit_len = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 } ELSE @@ -3061,7 +3073,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( // bit_len = hSplitBin->hLc3plusEnc->config.ivas_frame_duration_us / 1000; // bit_len = SplitRendBitRate * bit_len / 1000; tmp_e = 0; +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence tmp_32 = BASOP_Util_Divide3232_Scale_cadence( W_extract_l( W_mult0_32_32( SplitRendBitRate, bit_len ) ), 1000, &tmp_e ); +#else + tmp_32 = BASOP_Util_Divide3232_Scale_newton( W_extract_l( W_mult0_32_32( SplitRendBitRate, bit_len ) ), 1000, &tmp_e ); +#endif bit_len = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 } } diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 1ba5cafc4..42a81a217 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -376,7 +376,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( // available_bits = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); available_bits = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); tmp_e = 0; +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence tmp_32 = BASOP_Util_Divide3232_Scale_cadence( available_bits, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); +#else + tmp_32 = BASOP_Util_Divide3232_Scale_newton( available_bits, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); +#endif available_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 available_bits = L_sub( available_bits, pBits->bits_written ); pBits->codec_frame_size_ms = codec_frame_size_ms; @@ -543,7 +547,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( bit_len = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); tmp_e = 0; +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence tmp_32 = BASOP_Util_Divide3232_Scale_cadence( bit_len, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); +#else + tmp_32 = BASOP_Util_Divide3232_Scale_newton( bit_len, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); +#endif bit_len = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 } ELSE @@ -554,7 +562,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( // bit_len = hSplitBin->hLc3plusEnc->config.ivas_frame_duration_us / 1000; // bit_len = SplitRendBitRate * bit_len / 1000; tmp_e = 0; +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence tmp_32 = BASOP_Util_Divide3232_Scale_cadence( W_extract_l( W_mult0_32_32( SplitRendBitRate, bit_len ) ), 1000, &tmp_e ); +#else + tmp_32 = BASOP_Util_Divide3232_Scale_newton( W_extract_l( W_mult0_32_32( SplitRendBitRate, bit_len ) ), 1000, &tmp_e ); +#endif bit_len = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 } } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 60bbce7a9..d68d17746 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1500,7 +1500,11 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( move16(); den = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEnePrev_fx[0][bin], hDiracDecBin->ChEnePrev_e[0][bin], hDiracDecBin->ChEnePrev_fx[1][bin], hDiracDecBin->ChEnePrev_e[1][bin], &den_e ); den = L_max( 1, den ); +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence IIReneLimiter_fx[bin] = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp ); +#else + IIReneLimiter_fx[bin] = BASOP_Util_Divide3232_Scale_newton( num, den, &exp ); +#endif exp = add( sub( num_e, den_e ), add( 5, exp ) ); IF( L_shr_sat( IIReneLimiter_fx[bin], sub( 31, exp ) ) > 0 ) { @@ -2002,7 +2006,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( move32(); /* Formulate average diffuseness over frame */ +#ifndef REMOVE_BASOP_Util_Divide3232_Scale_cadence frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_cadence( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1 +#else + frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_newton( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1 +#endif exp = sub( exp, sub( sub( 31, q_meanEnePerCh ), exp1 ) ); hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29 move32(); -- GitLab From 56448500a6cc7d5050c54a08ed9d574af60717c5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 3 Nov 2025 20:51:24 +0100 Subject: [PATCH 152/351] empty commit to push -- GitLab From cb0418136aaaa387dba9bf0fd951048bca026ddd Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 4 Nov 2025 15:12:13 +1100 Subject: [PATCH 153/351] fix bugs in lib rend --- lib_isar/isar_lcld_encoder.c | 6 ++--- lib_rend/lib_rend_fx.c | 46 +++++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 87e4f39cc..4d3b4f042 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -1411,7 +1411,7 @@ static void QuantizeSpectrumDPCM_Opt( FOR( k = 0; k < piGroupLengths[n]; k++ ) { /* prediction */ - fReal_fx = L_sub_sat( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevReal_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevImag_fx ) ); + fReal_fx = L_sub( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevReal_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevImag_fx ) ); fImag_fx = L_add( Mpy_32_32( pfA1Real_fx[iFBOffset], fPrevImag_fx ), Mpy_32_32( pfA1Imag_fx[iFBOffset], fPrevReal_fx ) ); ppiQReal_fx = Quantize_fx( L_add_sat( L_shr_r_sat( ppfReal_fx[iBlockOffset][iFBOffset], sub( q_final, Q28 ) ), fReal_fx ), /* quantize residual */ fSCFGain_fx, @@ -1426,7 +1426,7 @@ static void QuantizeSpectrumDPCM_Opt( ppiQImag[iBlockOffset][iFBOffset] = L_shr( ppiQImag_fx, 21 ); ppiQReal_fx = L_shl( ppiQReal[iBlockOffset][iFBOffset], 21 ); - fPrevReal_fx = L_sub_sat( L_shl( UnQuantize_fx( ppiQReal_fx, + fPrevReal_fx = L_sub( L_shl( UnQuantize_fx( ppiQReal_fx, fInvSCFGain_fx, ppiSignReal[iBlockOffset][iFBOffset] ), 9 ), @@ -1434,7 +1434,7 @@ static void QuantizeSpectrumDPCM_Opt( /* add prediction to quantized residual = reconstructed sample */ ppiQImag_fx = L_shl( ppiQImag[iBlockOffset][iFBOffset], 21 ); - fPrevImag_fx = L_sub_sat( L_shl( UnQuantize_fx( ppiQImag_fx, + fPrevImag_fx = L_sub( L_shl( UnQuantize_fx( ppiQImag_fx, fInvSCFGain_fx, ppiSignImag[iBlockOffset][iFBOffset] ), 9 ), diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 770cc89aa..c2e812b76 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1641,7 +1641,7 @@ static ivas_error alignInputDelay( const IVAS_REND_ReadOnlyAudioBuffer inputAudio, const Word32 maxGlobalDelayNs, const Word32 sampleRateOut, - const Word16 cldfb2tdSampleFact, + const Word16 cldfb2tdSampleShift, const bool flushInputs ) { ivas_error error; @@ -1650,7 +1650,7 @@ static ivas_error alignInputDelay( UWord16 ringBufferSize, preDelay; maxGlobalDelaySamples = latencyNsToSamples( sampleRateOut, maxGlobalDelayNs ); - maxGlobalDelaySamples = i_mult( maxGlobalDelaySamples, cldfb2tdSampleFact ); + maxGlobalDelaySamples = shl( maxGlobalDelaySamples, cldfb2tdSampleShift ); /* check if we need to open the delay buffer */ IF( inputBase->delayBuffer == NULL ) @@ -1661,7 +1661,7 @@ static ivas_error alignInputDelay( /* pre delay for this input is maximum delay - input delay */ preDelay = sub( maxGlobalDelaySamples, - i_mult( inputBase->delayNumSamples, cldfb2tdSampleFact ) ); + shl( inputBase->delayNumSamples, cldfb2tdSampleShift ) ); IF( GT_32( preDelay, 0 ) ) { @@ -9422,6 +9422,46 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( } } + Word16 q1 = 31, q2 = 31, Q_buff, j; + Word16 num_poses = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + q1 = s_min( q1, L_norm_arr( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + q2 = s_min( q2, L_norm_arr( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX ) ); + } + } + Q_buff = s_min( q1, q2 ); + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) + { + scale_sig32( Cldfb_RealBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); + scale_sig32( Cldfb_ImagBuffer_Binaural[i][j], CLDFB_NO_CHANNELS_MAX, Q_buff ); + } + } + Q_buff = Q_buff + *outAudio.pq_fact; + + IF( EQ_16( cldfb_in_flag, 0 ) ) + { + /*TD input*/ + num_poses = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + Q_out[0] = s_min( Q_out[0], L_norm_arr( tmpBinaural_buff[i], L_FRAME48k ) ); + } + + FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) + { + scale_sig32( tmpBinaural_buff[i], L_FRAME48k, Q_out[0] ); + } + + Q_out[0] = Q_out[0] + *outAudio.pq_fact; + } + max_bands = extract_l( Mpy_32_32( imult3216( hIvasRend->sampleRateOut, BINAURAL_MAXBANDS ), 44740 /* 1/48000 in Q31 */ ) ); IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], -- GitLab From 9be0431adafead8a3f4c27b0cfaab954306590cc Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 4 Nov 2025 15:15:13 +1100 Subject: [PATCH 154/351] clang format fix --- lib_isar/isar_lcld_encoder.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 4d3b4f042..915e2a5e4 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -1427,18 +1427,18 @@ static void QuantizeSpectrumDPCM_Opt( ppiQReal_fx = L_shl( ppiQReal[iBlockOffset][iFBOffset], 21 ); fPrevReal_fx = L_sub( L_shl( UnQuantize_fx( ppiQReal_fx, - fInvSCFGain_fx, - ppiSignReal[iBlockOffset][iFBOffset] ), - 9 ), - fReal_fx ); + fInvSCFGain_fx, + ppiSignReal[iBlockOffset][iFBOffset] ), + 9 ), + fReal_fx ); /* add prediction to quantized residual = reconstructed sample */ ppiQImag_fx = L_shl( ppiQImag[iBlockOffset][iFBOffset], 21 ); fPrevImag_fx = L_sub( L_shl( UnQuantize_fx( ppiQImag_fx, - fInvSCFGain_fx, - ppiSignImag[iBlockOffset][iFBOffset] ), - 9 ), - fImag_fx ); + fInvSCFGain_fx, + ppiSignImag[iBlockOffset][iFBOffset] ), + 9 ), + fImag_fx ); iBlockOffset++; } /* group length */ } /* groups */ -- GitLab From 55c3c39b143fd763d5ad9a8daaf510fc2c351ab4 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 4 Nov 2025 17:00:57 +1100 Subject: [PATCH 155/351] more bug fixes in lib rend --- apps/renderer.c | 3 +++ lib_rend/lib_rend_fx.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/renderer.c b/apps/renderer.c index f6fd7d171..153661395 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1661,6 +1661,7 @@ int main( outBuffer.pq_fact = &outBuffer.q_factor; Word16 subframe_len = (Word16) ( args.sampleRate / ( 200 ) ); // sample rate /FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES Word16 gd_bits = find_guard_bits( subframe_len ); + Word16 prev_q_fact = Q11; while ( 1 ) { int16_t num_in_channels; @@ -1723,10 +1724,12 @@ int main( *outBuffer.pq_fact = 16 - ( gd_bits ); convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, *outBuffer.pq_fact, inBuffer.config.is_cldfb, cldfbAna, &Q_out ); *outBuffer.pq_fact = Q_out; + prev_q_fact = Q_out; } else { memset( inBuffer.data_fx, 0, inBuffer.config.numChannels * inBuffer.config.numSamplesPerChannel * sizeof( Word32 ) ); + *outBuffer.pq_fact = prev_q_fact; } int16_t num_subframes, sf_idx; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c2e812b76..7f8ca19b9 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9406,6 +9406,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( move16(); copyBufferTo2dArray_fx( hIvasRend->splitRendEncBuffer, tmpBinaural_buff ); } + *outAudio.pq_fact = *hIvasRend->splitRendEncBuffer.pq_fact; /* Encode split rendering bitstream */ convertBitsBufferToInternalBitsBuff( *hBits, &bits ); @@ -9478,7 +9479,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, - hIvasRend->splitRendEncBuffer.q_factor, + Q_buff, Q_out ) ) != IVAS_ERR_OK ) { return error; -- GitLab From 8a36c53313cb5343a33916d8a6a3abeba61ffedc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 4 Nov 2025 09:34:47 +0100 Subject: [PATCH 156/351] bring back missing code this fixes post rend output from garbage to actual signal, but scaling still needs to be corrected --- lib_rend/lib_rend_fx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 7f8ca19b9..995bd3ae0 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9485,6 +9485,14 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( return error; } + IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + scale_sig32( tmpBinaural_buff[j], L_FRAME48k, sub( *outAudio.pq_fact, Q_out[j] ) ); // *outAudio.pq_fact + } + } + convertInternalBitsBuffToBitsBuffer( hBits, bits ); /* copy over first pose data to outAudio */ -- GitLab From d3d8bb5b26d90867824dce256830a0fa4d6cee9d Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 4 Nov 2025 09:38:36 +0100 Subject: [PATCH 157/351] FIX_1330_JBM_MEMORY_FIX --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec_fx.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c967fd233..b21867b03 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -125,6 +125,7 @@ #define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */ #define FIX_1383_HEAD_TRACK_SANITIZER /* Nok: issue 1383: Fix head tracking struc values reading in renderer */ #define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ +#define FIX_1330_JBM_MEMORY_FIX /* VA: basop issue: 2179 fix non-BE difference in FIX_1330_JBM_MEMORY */ #define FIX_1411_IGF_CRASH_BW_SWITCHING /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/ // object-editing feature porting diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index eb287aefa..23c803201 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1572,6 +1572,9 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch++ ) { hTcBuffer->tc_fx[ch] = &hTcBuffer->tc_buffer_fx[offset]; +#ifdef FIX_1330_JBM_MEMORY_FIX + st_ivas->p_output_fx[ch] = hTcBuffer->tc_fx[ch]; +#endif offset = add( offset, len_offset ); } } -- GitLab From b3e69999cf7534e95d1b6008c02b4d41a0fa6975 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 4 Nov 2025 10:35:37 +0100 Subject: [PATCH 158/351] correctly handle limiter threshold in GetSplitBinauralBitstream --- lib_rend/lib_rend_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 9845416c6..a9402b60f 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9567,11 +9567,12 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( IF( EQ_16( outAudio.config.is_cldfb, 0 ) ) { + Word32 limiter_threshold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); #ifndef DISABLE_LIMITER #ifdef DEBUGGING hIvasRend->numClipping += #endif - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); + limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_threshold, *outAudio.pq_fact ); #endif } -- GitLab From c1597d2c9fa1079bed2231f5162e7f0a3950bac9 Mon Sep 17 00:00:00 2001 From: lintervo Date: Tue, 4 Nov 2025 12:38:01 +0200 Subject: [PATCH 159/351] Add missing changes --- lib_dec/ivas_omasa_dec_fx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 0c5f0eeef..8b455266d 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1120,10 +1120,14 @@ void ivas_omasa_dirac_rend_jbm_fx( { Copy32( &output_fx[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) +#else #ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #else IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) +#endif #endif { /* Gain separated object, if edited */ @@ -1145,10 +1149,14 @@ void ivas_omasa_dirac_rend_jbm_fx( Copy32( &output_fx[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); /* Gain discrete objects, if edited */ +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#else #ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #else IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#endif #endif { v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 @@ -1156,7 +1164,7 @@ void ivas_omasa_dirac_rend_jbm_fx( } } - /* Gain MASA part, if edited */ + /* Gain MASA part, if edited in G192. MASA gaining with VOIP is done in ivas_dec_prepare_renderer() */ #ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->masa_gain_is_edited ) #else -- GitLab From 42bc9c81a6ebe6b0d4d280a36b557f104995b488 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 4 Nov 2025 11:44:34 +0100 Subject: [PATCH 160/351] some BASOP compliance fixes --- lib_rend/lib_rend_fx.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index a9402b60f..9a7a38809 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1716,16 +1716,21 @@ static ivas_error alignInputDelay( } #ifdef FIX_1119_SPLIT_RENDERING_VOIP - // NOTE(sgi2knj): The arithmetic below needs to use BASOPs - for ( i = 0; i < inputAudio.config.numChannels; ++i ) + FOR( i = 0; i < inputAudio.config.numChannels; ++i ) { - p_read_channels[i] = inputAudio.data_fx + i * numSamplesToPush; + Word32 tmp; + + tmp = imult3216( L_deposit_l( numSamplesToPush ), i ); + p_read_channels[i] = inputAudio.data_fx + tmp; } ivas_TD_RINGBUF_PushChannels( inputBase->delayBuffer, p_read_channels, numSamplesToPush ); - for ( i = 0; i < inputAudio.config.numChannels; ++i ) + FOR( i = 0; i < inputAudio.config.numChannels; ++i ) { - p_write_channels[i] = inputBase->inputBuffer.data_fx + i * numSamplesToPop; + Word32 tmp; + + tmp = imult3216( L_deposit_l( numSamplesToPop ), i ); + p_write_channels[i] = inputBase->inputBuffer.data_fx + tmp; } ivas_TD_RINGBUF_PopChannels( inputBase->delayBuffer, p_write_channels, numSamplesToPop ); #else @@ -9357,14 +9362,15 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( ISAR_SPLIT_REND_BITS_DATA bits; Word16 max_bands; Word16 Q_out[2]; + Word16 pcm_out_flag; #ifdef FIX_1119_SPLIT_RENDERING_VOIP Word32 *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; Word32 *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX]; Word16 j; - for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) + FOR( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i ) { - for ( j = 0; j < CLDFB_NO_COL_MAX; ++j ) + FOR( j = 0; j < CLDFB_NO_COL_MAX; ++j ) { p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j]; p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j]; @@ -9380,6 +9386,15 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( Q_out[1] = Q31; move16(); + pcm_out_flag = 0; + move16(); + + if ( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + pcm_out_flag = 1; + move16(); + } + FOR( ch = 0; ch < i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS ); ch++ ) { tmpBinaural[ch] = tmpBinaural_buff[ch]; @@ -9520,7 +9535,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( tmpBinaural, 1, cldfb_in_flag, - ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, + pcm_out_flag, ro_md_flag, Q_buff, Q_out ) ) != IVAS_ERR_OK ) @@ -9538,7 +9553,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( tmpBinaural, 1, cldfb_in_flag, - ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, + pcm_out_flag, ro_md_flag, Q_buff, Q_out ) ) != IVAS_ERR_OK ) @@ -9547,7 +9562,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( return error; } - IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( pcm_out_flag ) { FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { @@ -9558,7 +9573,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( convertInternalBitsBuffToBitsBuffer( hBits, bits ); /* copy over first pose data to outAudio */ - IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( pcm_out_flag ) { /* set outAudio to zero - getSamplesInternal only cleared splitRendEncBuffer */ set_zero_fx( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); -- GitLab From 37df39ef5555b3682ce713bc9cec8954d517f82e Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Tue, 4 Nov 2025 14:42:44 +0200 Subject: [PATCH 161/351] Convert more to BASOP. --- lib_com/bitstream_fx.c | 15 +++++++-- lib_dec/ivas_binRenderer_internal_fx.c | 3 ++ lib_dec/ivas_dirac_dec_fx.c | 1 + lib_dec/ivas_init_dec_fx.c | 1 + lib_dec/ivas_mc_param_dec_fx.c | 1 + lib_dec/ivas_mc_paramupmix_dec_fx.c | 4 +++ lib_dec/ivas_mct_dec_fx.c | 1 + lib_dec/ivas_output_config_fx.c | 4 +++ lib_dec/lib_dec.h | 2 +- lib_dec/lib_dec_fx.c | 45 +++++++++++++++----------- lib_enc/lib_enc_fx.c | 2 +- lib_rend/ivas_rotation_fx.c | 34 +++++++++++++++++-- 12 files changed, 87 insertions(+), 26 deletions(-) diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 334fa3dbc..b5162777e 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -3857,11 +3857,20 @@ void convertSerialToBytestream_fx( UWord32 i; UWord8 bit, bitinbyte; - for ( i = 0; i < num_bits; ++i ) + FOR( i = 0; i < num_bits; ++i ) { - bit = ( serial[i] == 0x0001 ) ? 1 : 0; + IF( EQ_32( serial[i], 0x0001 ) ) + { + bit = 1; + move16(); + } + ELSE + { + bit = 0; + move16(); + } bitinbyte = bit << ( 7 - ( i & 0x7 ) ); - if ( !( i & 0x7 ) ) + IF( !( i & 0x7 ) ) { bytestream[i >> 3] = 0; } diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 0ed0696d2..36471b156 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1237,6 +1237,9 @@ ivas_error ivas_binRenderer_open_fx( { test(); test(); +#ifdef IVAS_RTPDUMP + test(); +#endif IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { FOR( k = 0; k < 11; k++ ) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 0f4e513d6..0a19a4968 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3083,6 +3083,7 @@ void ivas_dirac_dec_render_sf_fx( test(); test(); #ifdef IVAS_RTPDUMP + test(); IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) #else IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 28022bbfa..658f32938 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2583,6 +2583,7 @@ ivas_error ivas_init_decoder_fx( test(); test(); #ifdef IVAS_RTPDUMP + test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( hDecoderConfig->Opt_Headrotation || hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) #else IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( hDecoderConfig->Opt_Headrotation || hDecoderConfig->Opt_ExternalOrientation ) ) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 4faac7183..e6de1f286 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -462,6 +462,7 @@ ivas_error ivas_param_mc_dec_open_fx( test(); test(); #ifdef IVAS_RTPDUMP + test(); IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) #else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 09be09281..74411d502 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -382,6 +382,10 @@ ivas_error ivas_mc_paramupmix_dec_open( /* Head or external rotation */ #ifdef IVAS_RTPDUMP + test(); + test(); + test(); + test(); IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) #else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 81b8bfe64..8970a0820 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1376,6 +1376,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); #ifdef IVAS_RTPDUMP + test(); IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) ) #else IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 5ce0eea84..a1b8ae846 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -71,6 +71,7 @@ void ivas_renderer_select( test(); #ifdef IVAS_RTPDUMP + test(); IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) #else IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) @@ -168,6 +169,7 @@ void ivas_renderer_select( test(); #ifdef IVAS_RTPDUMP + test(); IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) #else IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) @@ -229,6 +231,7 @@ void ivas_renderer_select( test(); test(); #ifdef IVAS_RTPDUMP + test(); IF( ( EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1 ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) #else IF( ( EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1 ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) @@ -252,6 +255,7 @@ void ivas_renderer_select( test(); #ifdef IVAS_RTPDUMP + test(); IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) #else IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 0177b8709..67a0297a9 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -494,7 +494,7 @@ void IVAS_DEC_PrintDisclaimer( #ifdef IVAS_RTPDUMP #include "ivas_rtp_pi_data.h" -ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, uint32_t numPiData ); +ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, UWord32 numPiData ); #endif /* clang-format on */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 66193ac60..cba2367c8 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5632,23 +5632,23 @@ static ivas_error IVAS_DEC_feedSinglePIorientation( IVAS_QUATERNION *savedOrientation /* i : previously saved orientation for this PI type */ ) { - int16_t i; + Word16 i; ivas_error error = IVAS_ERR_OK; IVAS_QUATERNION savedInvOrientation; - if ( isOrientationSaved ) + IF( isOrientationSaved ) { - if ( !hIvasDec->st_ivas->hExtOrientationData ) + IF( !hIvasDec->st_ivas->hExtOrientationData ) { - if ( ( error = ivas_external_orientation_open_fx( &( hIvasDec->st_ivas->hExtOrientationData ), hIvasDec->st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) + IF( NE_32( error = ivas_external_orientation_open_fx( &( hIvasDec->st_ivas->hExtOrientationData ), hIvasDec->st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) { return error; } } - if ( !hIvasDec->st_ivas->hCombinedOrientationData ) + IF( !hIvasDec->st_ivas->hCombinedOrientationData ) { - if ( ( error = ivas_combined_orientation_open_fx( &( hIvasDec->st_ivas->hCombinedOrientationData ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, hIvasDec->st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) + IF( NE_32( error = ivas_combined_orientation_open_fx( &( hIvasDec->st_ivas->hCombinedOrientationData ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, hIvasDec->st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) { return error; } @@ -5657,13 +5657,15 @@ static ivas_error IVAS_DEC_feedSinglePIorientation( QuaternionInverse_fx( *savedOrientation, &savedInvOrientation ); /* use the new PI orientation or the previously saved orientation in processing */ - for ( i = 0; i < hIvasDec->st_ivas->hExtOrientationData->num_subframes; i++ ) + FOR( i = 0; i < hIvasDec->st_ivas->hExtOrientationData->num_subframes; i++ ) { QuaternionProduct_fx( hIvasDec->st_ivas->hExtOrientationData->Quaternions[i], savedInvOrientation, &hIvasDec->st_ivas->hExtOrientationData->Quaternions[i] ); hIvasDec->st_ivas->hExtOrientationData->enableExternalOrientation[i] = true; + move16(); } hIvasDec->updateOrientation = true; + move16(); } return error; } @@ -5681,26 +5683,31 @@ static void IVAS_DEC_setDiegeticInputPI( const bool *diegeticPIValues /* i : diegetic values for the input stream */ ) { - if ( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) + IF( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) { - int8_t i; - for ( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) + Word8 i; + FOR( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) { hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPI[i] = diegeticPIValues[i]; + move16(); } hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPISet = true; + move16(); } } #endif #ifdef IVAS_RTPDUMP -ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, uint32_t numPiData ) +ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, UWord32 numPiData ) { ivas_error error = IVAS_ERR_OK; - while ( numPiData-- ) + move32(); + WHILE( numPiData ) { - uint32_t piDataType = piData->data.noPiData.piDataType; - switch ( piDataType ) + UWord32 piDataType = piData->data.noPiData.piDataType; + move32(); + numPiData = UL_subNsD( numPiData, 1 ); /* Subtraction of WHILE variable */ + SWITCH( piDataType ) { case IVAS_PI_SCENE_ORIENTATION: { @@ -5710,7 +5717,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #endif error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); } - break; + BREAK; case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: { @@ -5720,7 +5727,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #endif error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); } - break; + BREAK; #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_DIEGETIC_TYPE: @@ -5730,16 +5737,16 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #endif IVAS_DEC_setDiegeticInputPI( hIvasDec, piData->data.digeticIndicator.isDiegetic ); } - break; + BREAK; #endif default: { /* NOT HANDLED PI DATA - DO NOTHING */ } - break; + BREAK; } - if ( error != IVAS_ERR_OK ) + IF( NE_32(error, IVAS_ERR_OK) ) { return error; } diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 5eac61b60..98a522e69 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1545,7 +1545,7 @@ ivas_error IVAS_ENC_EncodeFrameToCompact( ivas_error error; UWord16 bitstream[IVAS_MAX_BITS_PER_FRAME]; - if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, inputBuffer, inputBufferSize, bitstream, numOutBits ) ) != IVAS_ERR_OK ) + IF( NE_32( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, inputBuffer, inputBufferSize, bitstream, numOutBits ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 676ca7147..b0f9e547e 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1641,11 +1641,21 @@ ivas_error combine_external_and_head_orientations( { #ifdef RTP_S4_251135_CR26253_0016_REV1 /* Disable head rotation if diegetic PI data indicating non-diegetic audio is received */ + test(); + test(); + test(); + test(); + test(); IF( hCombinedOrientationData->isDiegeticInputPISet && !hCombinedOrientationData->isDiegeticInputPI[0] && !hCombinedOrientationData->isDiegeticInputPI[1] && !hCombinedOrientationData->isDiegeticInputPI[2] && !hCombinedOrientationData->isDiegeticInputPI[3] && !hCombinedOrientationData->isDiegeticInputPI[4] ) { FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { hCombinedOrientationData->Quaternions[i] = identity; + move32(); /* Copying full struct */ + move32(); + move32(); + move32(); + move16(); } } ELSE @@ -1654,6 +1664,11 @@ ivas_error combine_external_and_head_orientations( FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { hCombinedOrientationData->Quaternions[i] = headRotQuaternions[i]; + move32(); /* Copying full struct */ + move32(); + move32(); + move32(); + move16(); } } #else @@ -1789,20 +1804,25 @@ ivas_error combine_external_and_head_orientations( /* Disable head rotation if diegetic PI data indicating non-diegetic audio is received */ IF( hCombinedOrientationData->isDiegeticInputPISet && !hCombinedOrientationData->isDiegeticInputPI[0] && !hCombinedOrientationData->isDiegeticInputPI[1] && !hCombinedOrientationData->isDiegeticInputPI[2] && !hCombinedOrientationData->isDiegeticInputPI[3] && !hCombinedOrientationData->isDiegeticInputPI[4] ) { - continue; + CONTINUE; } ELSE { /* Use the most recent head rotation */ IF( EQ_16( hExtOrientationData->enableHeadRotation[i], 1 ) ) { - IF( hExtOrientationData->enableExternalOrientation[i] > 0 ) + IF( GT_16(hExtOrientationData->enableExternalOrientation[i], 0) ) { QuaternionProduct_fx( hCombinedOrientationData->Quaternions[i], headRotQuaternions[i], &hCombinedOrientationData->Quaternions[i] ); } ELSE { hCombinedOrientationData->Quaternions[i] = headRotQuaternions[i]; + move32(); /* Copying full struct */ + move32(); + move32(); + move32(); + move16(); } } /* Use the freezed head rotation */ @@ -1815,6 +1835,11 @@ ivas_error combine_external_and_head_orientations( ELSE { hCombinedOrientationData->Quaternions[i] = hCombinedOrientationData->Quaternion_frozen_head; + move32(); /* Copying full struct */ + move32(); + move32(); + move32(); + move16(); } } } @@ -1981,6 +2006,11 @@ ivas_error combine_external_and_head_orientations( FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { hExtOrientationData->Quaternions[i] = identity; + move32(); + move32(); + move32(); + move32(); + move16(); } } #endif -- GitLab From ef86491f0d9ca9ccc1c17bb71699a2b2769addff Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 4 Nov 2025 14:38:24 +0100 Subject: [PATCH 162/351] Make Q-factor of synth_16_fx and output_16_fx dynamic to prevent overflow in HQ_CORE mode --- lib_com/options.h | 1 + lib_dec/ivas_core_dec_fx.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7cf668641..299ff7e9b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,6 +91,7 @@ #define FIX_2174_JBM_BASOP_ALIGNMENT /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */ #define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */ +#define FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO /* FhG: Make Q-factor of synth_16_fx and output_16_fx dynamic to prevent overflow in HQ_CORE mode */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 1fd7cb0f3..ae955c5ed 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -643,8 +643,14 @@ ivas_error ivas_core_dec_fx( ivas_hq_core_dec_fx( st, synth_16_fx[n], &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_16_fx[n], &Q_output ); Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_output ) ); // Q11 - Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) ); // Q0 - Scale_sig( output_16_fx[n], L_FRAME48k, negate( Q_output ) ); // Q0 +#ifdef FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO + st->Q_syn_factor = s_min( 0, s_min( Q_synth, Q_output ) ); + Scale_sig( synth_16_fx[n], output_frame, sub( st->Q_syn_factor, Q_synth ) ); // st->Q_syn_factor + Scale_sig( output_16_fx[n], L_FRAME48k, sub( st->Q_syn_factor, Q_output ) ); // st->Q_syn_factor +#else + Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) ); // Q0 + Scale_sig( output_16_fx[n], L_FRAME48k, negate( Q_output ) ); // Q0 +#endif } /*---------------------------------------------------------------------* -- GitLab From 0a9a564cb0ed08796d573f70e78751673a5bfe96 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 4 Nov 2025 15:57:44 +0100 Subject: [PATCH 163/351] Modify st->Q_syn_factor to allow positive values in HQ_CORE mode. --- lib_dec/ivas_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index ae955c5ed..f9287ab5f 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -644,7 +644,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_output ) ); // Q11 #ifdef FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO - st->Q_syn_factor = s_min( 0, s_min( Q_synth, Q_output ) ); + st->Q_syn_factor = s_min( Q_synth, Q_output ); Scale_sig( synth_16_fx[n], output_frame, sub( st->Q_syn_factor, Q_synth ) ); // st->Q_syn_factor Scale_sig( output_16_fx[n], L_FRAME48k, sub( st->Q_syn_factor, Q_output ) ); // st->Q_syn_factor #else -- GitLab From c021fbe355c2a25f162b2ff965fca19c08488c14 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 4 Nov 2025 16:51:09 +0100 Subject: [PATCH 164/351] Limit st->Q_syn_factor to nonpositive values in HQ_CORE mode. --- lib_dec/ivas_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index f9287ab5f..ae955c5ed 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -644,7 +644,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_output ) ); // Q11 #ifdef FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO - st->Q_syn_factor = s_min( Q_synth, Q_output ); + st->Q_syn_factor = s_min( 0, s_min( Q_synth, Q_output ) ); Scale_sig( synth_16_fx[n], output_frame, sub( st->Q_syn_factor, Q_synth ) ); // st->Q_syn_factor Scale_sig( output_16_fx[n], L_FRAME48k, sub( st->Q_syn_factor, Q_output ) ); // st->Q_syn_factor #else -- GitLab From 0560efb63b3f2098e58fe38978834a5f65606dee Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Tue, 4 Nov 2025 22:49:44 +0100 Subject: [PATCH 165/351] remove scaling also fro elevation_fx --- lib_dec/ivas_ism_param_dec_fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index a951a6bad..5e46a9af5 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1046,9 +1046,10 @@ void ivas_ism_dec_digest_tc_fx( IF( st_ivas->hEFAPdata != NULL ) { #ifndef NONBE_1412_AVOID_ROUNDING_AZ_ELEV - azimuth_fx = L_shl( azimuth_fx, Q22 ); // Q22 -#endif + azimuth_fx = L_shl( azimuth_fx, Q22 ); // Q22 elevation_fx = L_shl( elevation_fx, Q22 ); // Q22 +#endif + #ifdef NONBE_1412_AVOID_ROUNDING_AZ_ELEV efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); -- GitLab From 6f6192536ac2b0cc1bdf4f965268d1800623597b Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 5 Nov 2025 08:02:48 +0100 Subject: [PATCH 166/351] Add FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE to change nchan_in -> nchan_transport for scaling on p_tc_fx --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec_fx.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8171bdec9..8d1737e41 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -94,6 +94,7 @@ #define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */ #define FIX_2015_PREMPH_SAT_ALT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */ #define FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE /* Nokia: Fixes float to fx conversion in decoder app with object edit file interface */ +#define FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE /* Eri/Orange: scale_sig32 problem on p_tc_fx[] */ /* ################### End FIXES switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 57101b4de..f977f30aa 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2152,7 +2152,11 @@ ivas_error ivas_jbm_dec_render_fx( IF( crendInPlaceRotation ) { +#ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE + FOR( i = 0; i < st_ivas->nchan_transport; i++ ) +#else FOR( i = 0; i < nchan_in; i++ ) +#endif { scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor IF( st_ivas->hDecoderConfig->Opt_tsm ) @@ -2163,7 +2167,11 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE { +#ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE + FOR( i = 0; i < st_ivas->nchan_transport; i++ ) +#else FOR( i = 0; i < nchan_in; i++ ) +#endif { scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor } @@ -2222,7 +2230,11 @@ ivas_error ivas_jbm_dec_render_fx( move16(); } +#ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE + FOR( i = n; i < st_ivas->nchan_transport; i++ ) +#else FOR( i = n; i < nchan_in; i++ ) +#endif { scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 } -- GitLab From efac9126e772c543951dc7633df61edacd7025b3 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 5 Nov 2025 08:35:37 +0100 Subject: [PATCH 167/351] Add manual job ivas-conformance --- .gitlab-ci.yml | 2 +- .gitlab-ci/variables.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93d77386f..b8835761a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF ci/add-conformance-basop include: - project: ivas-codec-pc/ivas-codec-ci diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 817be6f79..7298f79ea 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -105,3 +105,4 @@ variables: - 'long-term-logs' - 'backup-long-term-logs' - 'test-long-self-test' + - 'ivas-conformance' -- GitLab From 7960b33dfd8443c49c86d57559b1327bf0dd9083 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 5 Nov 2025 08:42:02 +0100 Subject: [PATCH 168/351] Add ivas-conformance to .rules-basis --- .gitlab-ci/rules-basis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci/rules-basis.yml b/.gitlab-ci/rules-basis.yml index c650f574a..0b374e302 100644 --- a/.gitlab-ci/rules-basis.yml +++ b/.gitlab-ci/rules-basis.yml @@ -48,6 +48,9 @@ - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'peaq-enc-passthrough' variables: IVAS_PIPELINE_NAME: 'PEAQ encoder pass-through test: $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'ivas-conformance' + variables: + IVAS_PIPELINE_NAME: 'IVAS conformance: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch variables: IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH' -- GitLab From 8d6f1d53aee5350306d6ac60902d61ee8afd7ed8 Mon Sep 17 00:00:00 2001 From: Arnaud Lefort Date: Wed, 5 Nov 2025 09:41:09 +0100 Subject: [PATCH 169/351] Fix for issue 2184. --- lib_com/options.h | 2 + lib_enc/ivas_stat_enc.h | 12 +- lib_enc/ivas_stereo_dmx_evs_fx.c | 310 +++++++++++++++++++++++++++++-- 3 files changed, 301 insertions(+), 23 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c1a258bcf..0799870f6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -93,6 +93,8 @@ #define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */ #define FIX_2015_PREMPH_SAT_ALT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */ + +#define FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING /* Orange: Fix for issue 2184 - to prevent one channel from becoming inaudible in the mono downmix output */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index e3f40478e..6cad0ac68 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1184,8 +1184,14 @@ typedef struct stereo_dmx_evs_phase_only_correlation_structure typedef struct stereo_dmx_evs_correlation_filter_structure { - Word32 isd_rate_s_fx; // Q31 - Word32 iccr_s_fx; // Q31 + Word32 isd_rate_s_fx; // Q31 + Word32 iccr_s_fx; // Q31 +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + Word32 phitd_fx; // Q15 + Word32 iccres_s_fx; // Q31 + Word32 lvlin_fx[CPE_CHANNELS]; + Word16 lvlin_fx_e[CPE_CHANNELS]; +#endif Word32 ipd_ff_fx[STEREO_DMX_EVS_NB_SUBBAND_MAX]; // Q31 Word32 Pr_fx[STEREO_DMX_EVS_NB_SUBBAND_MAX]; // Q31 Word32 Pi_fx[STEREO_DMX_EVS_NB_SUBBAND_MAX]; // Q31 @@ -1194,7 +1200,6 @@ typedef struct stereo_dmx_evs_correlation_filter_structure Word16 pha_len; Word16 fad_len; - Word16 win_fx[STEREO_DMX_EVS_PHA_LEN_MAX]; // Q14 Word32 fad_g_fx[STEREO_DMX_EVS_FAD_LEN_MAX]; // Q31 Word32 *p_prev_taps_fx[CPE_CHANNELS], prev_taps_fx[CPE_CHANNELS][STEREO_DMX_EVS_PHA_LEN_MAX]; // Q31 @@ -1223,7 +1228,6 @@ typedef struct stereo_dmx_evs_correlation_filter_structure Word32 fad_g_prc_fx[L_FRAME48k]; // Q31 Word16 fad_len_prc; - Word32 trns_aux_energy_fx[CPE_CHANNELS]; Word16 trns_aux_energy_fx_e[CPE_CHANNELS]; Word32 crst_fctr_fx; // Q0 diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 852be98fe..73f7e246c 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -77,6 +77,16 @@ #define STEREO_DMX_EVS_ICCR_HYST_L_Q31 1610612736 #define STEREO_DMX_EVS_ICCR_HYST_H_Q31 1825361101 +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING +#define STEREO_DMX_EVS_ICCRES_FORGETTING_Q31 1975684956 +#define STEREO_DMX_EVS_LVLU_FORGETTING_Q31 1073741824 +#define STEREO_DMX_EVS_LVLD_FORGETTING_Q31 1975684956 +#define STEREO_DMX_EVS_ICLD_THRESH_FX 1610612736 +#define STEREO_DMX_EVS_ICLD_THRESH_FX_E 2 +#define STEREO_DMX_EVS_ICCRES_THRESH_Q31 858993459 +#define STEREO_DMX_EVS_DICLD_THRESH_Q30 1606570807 +#endif + #define STEREO_DMX_EVS_SWTCH_HYS_THRES 1 #define STEREO_DMX_EVS_LR_EGY_Q27 2013265920 #define STEREO_DMX_EVS_ILDS_EGY_Q17 1310720000 @@ -194,6 +204,31 @@ static void weighted_ave_fx( const Word16 input_frame, /* i : input frame length per channel */ const Word32 wnd_fx[] /* i : window coef Q31 */ ); +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING +static void calc_energy_fx( + const Word32 src1_fx[], /* i : Lch input signal */ + const Word32 src2_fx[], /* i : Rch input signal */ + Word32 energy_fx[], /* o : calculated energy */ + Word16 *energy_fx_e, /* o : calculated energy */ + Word32 *lvl_fx, /* i/o: signal level lvl_fx_e */ + Word16 *lvl_fx_e, /* i/o: signal level */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word32 ratio_float_fx ); +static void create_M_signal_fx( + const Word32 srcL_fx[], /* i : Lch input signal Q16 */ + const Word32 srcR_fx[], /* i : Rch input signal Q16 */ + Word32 dmx_fx[], /* o : output signal Q31 */ + const Word32 w_curr_fx, /* i : adapting weight Q31 */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word32 wnd_fx[], /* i : window coef Q31 */ + Word32 *w_prev_fx, /* i/o: adapting prev weight Q31 */ + Word32 *dmx_energy_fx, /* i/o: downmix signal energy dmx_energy_fx_e */ + Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ + Word32 *src_energy_fx, /* i/o: input signal energy src_energy_fx_e */ + Word16 *src_energy_fx_e, /* i/o: input signal energy */ + STEREO_DMX_EVS_PHA_HANDLE hPHA /* i/o: correlation filter structure */ +); +#else static void calc_energy_fx( const Word32 src1_fx[], /* i : Lch input signal */ const Word32 src2_fx[], /* i : Rch input signal */ @@ -201,20 +236,20 @@ static void calc_energy_fx( Word16 *energy_fx_e, /* o : calculated energy */ const Word16 input_frame, /* i : input frame length per channel */ const Word32 ratio_float_fx ); - static void create_M_signal_fx( const Word32 srcL_fx[], /* i : Lch input signal Q16 */ const Word32 srcR_fx[], /* i : Rch input signal Q16 */ Word32 dmx_fx[], /* o : output signal Q31 */ const Word32 w_curr_fx, /* i : adapting weight Q31 */ - const Word16 input_frame, /* i : input frame length per channel */ + const Word16 input_frame, /* i : input frame length per channel */ const Word32 wnd_fx[], /* i : window coef Q31 */ - Word32 *w_prev_fx, /* i/o: adapting prev weight Q31*/ + Word32 *w_prev_fx, /* i/o: adapting prev weight Q31 */ Word32 *dmx_energy_fx, /* i/o: downmix signal energy dmx_energy_fx_e */ - Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ + Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ Word32 *src_energy_fx, /* i/o: input signal energy src_energy_fx_e */ Word16 *src_energy_fx_e /* i/o: input signal energy */ ); +#endif static Word32 find_poc_peak_fx( STEREO_DMX_EVS_POC_HANDLE hPOC, /* i/o: phase only correlation structure */ Word16 itd_fx[], /* o : estimated itd */ @@ -728,6 +763,13 @@ static void calc_poc_fx( move32(); eneR_e = 0; move16(); +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + step = sub( n0 >> 3, 1 ); + tmp1 = 0; + tmp2 = 0; + n1 = 0; + n2 = 0; +#endif FOR( ( n = 1, i = 1 ); n < nsbd; n++ ) { @@ -824,6 +866,16 @@ static void calc_poc_fx( W_tmp = W_shl( W_tmp, L_tmp_e ); } eneR = BASOP_Util_Add_Mant32Exp( eneR, eneR_e, W_round64_L( W_tmp ), sub( 1, L_tmp_e ), &eneR_e ); + +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + IF( EQ_16( i, step ) ) + { + tmp1 = eneL; + n1 = eneL_e; + tmp2 = eneR; + n2 = eneR_e; + } +#endif } // Pn = (float) inv_sqrt( ( tPr * tPr + tPi * tPi ) + EPSILON ); @@ -854,8 +906,12 @@ static void calc_poc_fx( } /* Computes Spectral flatness on one channel */ +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + IF( LT_32( spectral_flatness_fx( &tEl[1], &tEl_e[1], sub( nsbd, 1 ) ), STEREO_DMX_EVS_IPD_SF_THRES_Q31 ) ) +#else tmp1 = spectral_flatness_fx( &tEl[1], &tEl_e[1], nsbd - 1 ); IF( LT_32( tmp1, STEREO_DMX_EVS_IPD_SF_THRES_Q31 ) ) +#endif { hPHA->pha_ipd_chanswitch_allowed = 0; move16(); @@ -879,6 +935,82 @@ static void calc_poc_fx( hPHA->iccr_s_fx = L_add( Mpy_32_32_r( STEREO_DMX_EVS_ICCR_FORGETTING_Q31, hPHA->iccr_s_fx ), Mpy_32_32_r( MAX_32 - STEREO_DMX_EVS_ICCR_FORGETTING_Q31, ICCr ) ); // Q31 move32(); +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + step = add( step, 1 ); + + eneL = BASOP_Util_Add_Mant32Exp( eneL, eneL_e, -tmp1, n1, &eneL_e ); + eneR = BASOP_Util_Add_Mant32Exp( eneR, eneR_e, -tmp2, n2, &eneR_e ); + + mult_angle = extract_l( imult3216( hPHA->phitd_fx, step ) ); // Remainder in Q15 + tmp1 = L_shr( imult3216( EVS_2PI_FX, mult_angle ), Q15 ); // Q13 + IF( GT_32( tmp1, EVS_PI_FX ) ) + { + tmp1 = L_sub( tmp1, EVS_2PI_FX ); + } + ELSE IF( LT_32( tmp1, -EVS_PI_FX ) ) + { + tmp1 = L_add( tmp1, EVS_2PI_FX ); + } + mult_angle = extract_l( tmp1 ); + IPDr = L_deposit_h( getCosWord16( mult_angle ) ); + IPDr = L_shl_sat( IPDr, 1 ); + IPDi = L_deposit_h( getSinWord16( mult_angle ) ); + + mult_angle = extract_l( hPHA->phitd_fx ); // Remainder in Q15 + tmp1 = L_shr( imult3216( EVS_2PI_FX, mult_angle ), Q15 ); // Q13 + IF( GT_32( tmp1, EVS_PI_FX ) ) + { + tmp1 = L_sub( tmp1, EVS_2PI_FX ); + } + ELSE IF( LT_32( tmp1, -EVS_PI_FX ) ) + { + tmp1 = L_add( tmp1, EVS_2PI_FX ); + } + mult_angle = extract_l( tmp1 ); + L_tmp1 = L_deposit_h( getCosWord16( mult_angle ) ); + L_tmp1 = L_shl_sat( L_tmp1, 1 ); + L_tmp2 = L_deposit_h( getSinWord16( mult_angle ) ); + + Nr = 0; + move32(); + Nr_e = 0; + move16(); + Ni = 0; + move32(); + Ni_e = 0; + + n1 = sub( n0, 1 ); + FOR( i = step; i < n1; i++ ) + { + tIPDr = L_add( Mpy_32_32_r( specRr[i], IPDr ), Mpy_32_32_r( specRi[i], IPDi ) ); + tIPDi = L_sub( Mpy_32_32_r( specRr[i], IPDi ), Mpy_32_32_r( specRi[i], IPDr ) ); + + Nr = BASOP_Util_Add_Mant32Exp( Nr, Nr_e, L_sub( Mpy_32_32_r( specLr[i], tIPDr ), Mpy_32_32_r( specLi[i], tIPDi ) ), 0, &Nr_e ); + Ni = BASOP_Util_Add_Mant32Exp( Ni, Ni_e, L_add( Mpy_32_32_r( specLi[i], tIPDr ), Mpy_32_32_r( specLr[i], tIPDi ) ), 0, &Ni_e ); + + tIPDr = IPDr; + move32(); + IPDr = L_sub_sat( Mpy_32_32_r( tIPDr, L_tmp1 ), Mpy_32_32_r( IPDi, L_tmp2 ) ); + IPDi = L_add_sat( Mpy_32_32_r( tIPDr, L_tmp2 ), Mpy_32_32_r( IPDi, L_tmp1 ) ); + } + + if ( EQ_32( ICCr, 0 ) ) + { + ICCr = ONE_IN_Q31; + move32(); + } + + L_tmp1 = BASOP_Util_Add_Mant32Exp( Mpy_32_32_r( Nr, Nr ), shl( Nr_e, 1 ), Mpy_32_32_r( Ni, Ni ), shl( Ni_e, 1 ), &L_tmp1_e ); + L_tmp2 = BASOP_Util_Add_Mant32Exp( Mpy_32_32_r( eneL, eneR ), add( eneL_e, eneR_e ), EPSILON_FX_M, EPSILON_FX_E, &L_tmp2_e ); + + L_tmp2 = BASOP_Util_Add_Mant32Exp( Mpy_32_32_r( eneL, eneR ), add( eneL_e, eneR_e ), EPSILON_FX_M, EPSILON_FX_E, &L_tmp2_e ); + L_tmp = BASOP_Util_Divide3232_Scale_newton( L_tmp1, L_tmp2, &L_tmp_e ); + L_tmp_e = add( L_tmp_e, sub( L_tmp1_e, L_tmp2_e ) ); + L_tmp = Sqrt32( L_tmp, &L_tmp_e ); + L_tmp = L_shl_sat( L_tmp, L_tmp_e ); // Q31 + + hPHA->iccres_s_fx = L_add( Mpy_32_32_r( STEREO_DMX_EVS_ICCRES_FORGETTING_Q31, hPHA->iccres_s_fx ), Mpy_32_32_r( L_sub( MAX_32, STEREO_DMX_EVS_ICCRES_FORGETTING_Q31 ), L_add_sat( ICCr >> 1, L_tmp >> 1 ) ) ); // Q31 +#endif IF( EQ_32( hPHA->curr_pha, STEREO_DMX_EVS_PHA_IPD ) ) { @@ -1437,7 +1569,11 @@ static Word32 find_poc_peak_fx( move16(); move16(); move16(); +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + IF( Q_fx[n] == 0 ) +#else if ( Q_fx[n] == 0 ) +#endif { Q_e[n] = 0; move16(); @@ -1823,17 +1959,33 @@ static void renorm_poc_fx( * * calculate energy *-------------------------------------------------------------------*/ -static void calc_energy_fx( - const Word32 src1_fx[], /* i : Lch input signal Q16*/ - const Word32 src2_fx[], /* i : Rch input signal Q16 */ - Word32 energy_fx[], /* o : calculated energy energy_fx_e*/ - Word16 *energy_fx_e, /* o : calculated energy */ - const Word16 input_frame, /* i : input frame length per channel */ - const Word32 ratio_float_fx // Q31 -) +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING +void calc_energy_fx( + const Word32 src1_fx[], /* i : Lch input signal */ + const Word32 src2_fx[], /* i : Rch input signal */ + Word32 energy_fx[], /* o : calculated energy */ + Word16 *energy_fx_e, /* o : calculated energy */ + Word32 *lvl_fx, /* i/o: signal level lvl_fx_e */ + Word16 *lvl_fx_e, /* i/o: signal level */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word32 ratio_float_fx ) +#else +void calc_energy_fx( + const Word32 src1_fx[], /* i : Lch input signal */ + const Word32 src2_fx[], /* i : Rch input signal */ + Word32 energy_fx[], /* o : calculated energy */ + Word16 *energy_fx_e, /* o : calculated energy */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word32 ratio_float_fx ) +#endif { +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + Word32 E_32_fx, wnd_fx, wnd_diff_fx, lvli_fx, lvlff_fx; + Word16 i, adaptlen, lvli_fx_e; +#else Word32 E_32_fx, wnd_fx, wnd_diff_fx; Word16 i, adaptlen; +#endif Word64 E_fx; /* Initialization */ @@ -1898,6 +2050,24 @@ static void calc_energy_fx( *energy_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *energy_fx, ratio_float_fx ), *energy_fx_e, Mpy_32_32( temp32, L_sub( MAX_32, ratio_float_fx ) ), sub( 31, q_temp32 ), energy_fx_e ); move32(); +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + IF( ( lvl_fx != NULL ) && ( lvl_fx_e != NULL ) ) + { + E_32_fx = BASOP_Util_Add_Mant32Exp( E_32_fx, sub( 31, q_E ), EPSILON_FX_M, EPSILON_FX_E, &temp_e ); + lvli_fx = BASOP_Util_Log10( E_32_fx, temp_e ); + lvli_fx_e = 6; // +6 : compensate result of log in Q25 + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( lvli_fx, lvli_fx_e, *lvl_fx, *lvl_fx_e ), 1 ) ) + { + lvlff_fx = STEREO_DMX_EVS_LVLU_FORGETTING_Q31; + } + ELSE + { + lvlff_fx = STEREO_DMX_EVS_LVLD_FORGETTING_Q31; + } + *lvl_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *lvl_fx, lvlff_fx ), *lvl_fx_e, Mpy_32_32( lvli_fx, L_sub( MAX_32, lvlff_fx ) ), lvli_fx_e, lvl_fx_e ); // Q(31 - *lvli_fx_e) + } +#endif + return; } @@ -1987,19 +2157,36 @@ static void adapt_gain_fx( * * create downmix signal *-------------------------------------------------------------------*/ -static void create_M_signal_fx( +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING +void create_M_signal_fx( + const Word32 srcL_fx[], /* i : Lch input signal Q16 */ + const Word32 srcR_fx[], /* i : Rch input signal Q16 */ + Word32 dmx_fx[], /* o : output signal Q31 */ + const Word32 w_curr_fx, /* i : adapting weight Q31 */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word32 wnd_fx[], /* i : window coef Q31 */ + Word32 *w_prev_fx, /* i/o: adapting prev weight Q31 */ + Word32 *dmx_energy_fx, /* i/o: downmix signal energy dmx_energy_fx_e */ + Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ + Word32 *src_energy_fx, /* i/o: input signal energy src_energy_fx_e */ + Word16 *src_energy_fx_e, /* i/o: input signal energy */ + STEREO_DMX_EVS_PHA_HANDLE hPHA /* i/o: correlation filter structure */ +) +#else +void create_M_signal_fx( const Word32 srcL_fx[], /* i : Lch input signal Q16 */ const Word32 srcR_fx[], /* i : Rch input signal Q16 */ Word32 dmx_fx[], /* o : output signal Q31 */ const Word32 w_curr_fx, /* i : adapting weight Q31 */ - const Word16 input_frame, /* i : input frame length per channel */ + const Word16 input_frame, /* i : input frame length per channel */ const Word32 wnd_fx[], /* i : window coef Q31 */ - Word32 *w_prev_fx, /* i/o: adapting prev weight Q31*/ + Word32 *w_prev_fx, /* i/o: adapting prev weight Q31 */ Word32 *dmx_energy_fx, /* i/o: downmix signal energy dmx_energy_fx_e */ - Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ + Word16 *dmx_energy_fx_e, /* i/o: downmix signal energy */ Word32 *src_energy_fx, /* i/o: input signal energy src_energy_fx_e */ Word16 *src_energy_fx_e /* i/o: input signal energy */ ) +#endif { Word32 amp_mod_fx[CPE_CHANNELS]; Word32 weighted_fx[L_FRAME48k], Lbias_fx; @@ -2022,9 +2209,15 @@ static void create_M_signal_fx( move32(); } weighted_ave_fx( srcL_fx, srcR_fx, dmx_fx, w_curr_fx, w_prev_fx[0], input_frame, wnd_fx ); +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + calc_energy_fx( srcL_fx, srcL_fx, src_energy_fx, src_energy_fx_e, hPHA->lvlin_fx, hPHA->lvlin_fx_e, input_frame, STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX ); + calc_energy_fx( srcR_fx, srcR_fx, src_energy_fx + 1, src_energy_fx_e + 1, hPHA->lvlin_fx + 1, hPHA->lvlin_fx_e + 1, input_frame, STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX ); + calc_energy_fx( dmx_fx, dmx_fx, dmx_energy_fx, dmx_energy_fx_e, NULL, NULL, input_frame, STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX ); +#else calc_energy_fx( srcL_fx, srcL_fx, src_energy_fx, src_energy_fx_e, input_frame, STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX ); calc_energy_fx( srcR_fx, srcR_fx, src_energy_fx + 1, src_energy_fx_e + 1, input_frame, STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX ); calc_energy_fx( dmx_fx, dmx_fx, dmx_energy_fx, dmx_energy_fx_e, input_frame, STEREO_DMX_EVS_DMX_EGY_FORGETTING_FX ); +#endif temp32_1 = Mpy_32_32( src_energy_fx[0], Lbias_fx ); // 31 - src_energy_fx_e + Q28-31 temp_e_1 = add( src_energy_fx_e[0], 3 ); @@ -2147,7 +2340,16 @@ void stereo_dmx_evs_enc_fx( Word32 dmx_poc_data[L_FRAME48k] /*Q11*/, dmx_pha_data[L_FRAME48k] /*Q11*/, *p_dmx_data, fx_tmp, *p_dmx_data_fo; Word16 n_fad_r, n_fad_g, m_fad_g, n_fad_cnt; +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + STEREO_DMX_EVS_PRC prev_prc, req_prc; + Word32 L_tmp1, L_tmp2, L_dmx_weight, icld_fx; + Word16 L_tmp1_e, L_tmp2_e, icld_fx_e; +#else STEREO_DMX_EVS_PRC prev_prc; + Word32 L_tmp1, L_tmp2; + Word16 L_tmp1_e, L_tmp2_e; +#endif + STEREO_DMX_EVS_PHA_HANDLE hPHA; Word16 input_subframe, is_transient, dmx_gain_sgc; @@ -2156,9 +2358,6 @@ void stereo_dmx_evs_enc_fx( Word16 input_frame; - Word32 L_tmp1, L_tmp2; - Word16 L_tmp1_e, L_tmp2_e; - Word64 W_tmp; Word16 W_tmp_q; @@ -2231,7 +2430,9 @@ void stereo_dmx_evs_enc_fx( move16(); FOR( k = 0; k < CPE_CHANNELS; k++ ) { +#ifndef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING fx_tmp = 0; +#endif move32(); FOR( m = 0; m < STEREO_DMX_EVS_NB_SBFRM; m++ ) { @@ -2273,7 +2474,11 @@ void stereo_dmx_evs_enc_fx( L_tmp2 = BASOP_Util_Divide3232_Scale_newton( subframe_energy[m], L_tmp1, &L_tmp2_e ); L_tmp2_e = add( L_tmp2_e, sub( subframe_energy_e[m], L_tmp1_e ) ); // if ( subframe_energy[m] / ( subframe_energy[m - 1] + EPSILON ) > STEREO_DMX_EVS_TRNS_DTC_INST ) +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + IF( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, STEREO_DMX_EVS_TRNS_DTC_INST_Q0, 31 ) > 0 ) +#else if ( BASOP_Util_Cmp_Mant32Exp( L_tmp2, L_tmp2_e, STEREO_DMX_EVS_TRNS_DTC_INST_Q0, 31 ) > 0 ) +#endif { is_transient = 1; move16(); @@ -2303,8 +2508,16 @@ void stereo_dmx_evs_enc_fx( move16(); } +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + L_dmx_weight = L_deposit_h( dmx_weight ); + L_tmp1 = L_deposit_l( BASOP_Util_Divide1616_Scale( hStereoDmxEVS->itd_fx, input_frame, &L_tmp1_e ) ); + hPHA->phitd_fx = L_shl( L_tmp1, L_tmp1_e ); // Q15 + create_M_signal_fx( data_fx[0], data_fx[1], dmx_poc_data, L_dmx_weight, input_frame, hStereoDmxEVS->s_wnd_fx, + hStereoDmxEVS->dmx_weight_fx, hStereoDmxEVS->pre_dmx_energy_fx, hStereoDmxEVS->pre_dmx_energy_fx_e, hStereoDmxEVS->aux_dmx_energy_fx, hStereoDmxEVS->aux_dmx_energy_fx_e, hPHA ); +#else create_M_signal_fx( data_fx[0], data_fx[1], dmx_poc_data, L_deposit_h( dmx_weight ), input_frame, hStereoDmxEVS->s_wnd_fx, hStereoDmxEVS->dmx_weight_fx, hStereoDmxEVS->pre_dmx_energy_fx, hStereoDmxEVS->pre_dmx_energy_fx_e, hStereoDmxEVS->aux_dmx_energy_fx, hStereoDmxEVS->aux_dmx_energy_fx_e ); +#endif // Downscaling signals to avoid accumulation overflows scale_sig32( data_fx[0], input_frame, -5 ); // Q31->Q26 @@ -2396,6 +2609,50 @@ void stereo_dmx_evs_enc_fx( move32(); // if ( abs( (int16_t) hStereoDmxEVS->itd ) > hPHA->prc_thres ) IF( GT_16( abs_s( hStereoDmxEVS->itd_fx ), hPHA->prc_thres ) ) +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + { + req_prc = STEREO_DMX_EVS_PRC_POC; + move32(); + + icld_fx = L_abs( BASOP_Util_Add_Mant32Exp( hPHA->lvlin_fx[0], hPHA->lvlin_fx_e[0], L_negate( hPHA->lvlin_fx[1] ), hPHA->lvlin_fx_e[1], &( icld_fx_e ) ) ); + L_tmp1 = L_add( L_shr_r( L_dmx_weight, 1 ), L_shr_r( hStereoDmxEVS->dmx_weight_fx[1], 1 ) ); // Q30 + L_tmp2 = L_add( L_sub( ONE_IN_Q30, L_shr_r( L_dmx_weight, 1 ) ), L_shr_r( hStereoDmxEVS->dmx_weight_fx[2], 1 ) ); // Q30 + + IF( ( BASOP_Util_Cmp_Mant32Exp( L_abs( icld_fx ), icld_fx_e, STEREO_DMX_EVS_ICLD_THRESH_FX, STEREO_DMX_EVS_ICLD_THRESH_FX_E ) < 0 ) && LT_32( hPHA->iccres_s_fx, STEREO_DMX_EVS_ICCRES_THRESH_Q31 ) && ( GT_32( L_shr_r( L_tmp1, 1 ), Mpy_32_32( STEREO_DMX_EVS_DICLD_THRESH_Q30, L_tmp2 ) ) || GT_32( L_shr_r( L_tmp2, 1 ), Mpy_32_32( STEREO_DMX_EVS_DICLD_THRESH_Q30, L_tmp1 ) ) ) ) + { + req_prc = STEREO_DMX_EVS_PRC_PHA; + move32(); + } + } + ELSE + { + req_prc = STEREO_DMX_EVS_PRC_PHA; + move32(); + } + + // Set mode with hysteresis + IF( NE_32( hPHA->curr_prc, req_prc ) ) + { + IF( EQ_32( hPHA->prev_prc, req_prc ) ) + { + hPHA->prc_hys_cnt = add( hPHA->prc_hys_cnt, 1 ); + move16(); + } + ELSE + { + hPHA->prc_hys_cnt = 0; + move16(); + } + + IF( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) + { + hPHA->curr_prc = req_prc; + move32(); + } + } + hPHA->prev_prc = req_prc; + move32(); +#else { IF( NE_32( hPHA->curr_prc, STEREO_DMX_EVS_PRC_POC ) ) { @@ -2409,6 +2666,7 @@ void stereo_dmx_evs_enc_fx( hPHA->prc_hys_cnt = 0; move16(); } + IF( GE_16( hPHA->prc_hys_cnt, STEREO_DMX_EVS_SWTCH_PRC_HYS_THRES ) ) { hPHA->curr_prc = STEREO_DMX_EVS_PRC_POC; @@ -2442,6 +2700,7 @@ void stereo_dmx_evs_enc_fx( hPHA->prev_prc = STEREO_DMX_EVS_PRC_PHA; move32(); } +#endif // if ( ( is_transient == 1 ) || ( hStereoDmxEVS->aux_dmx_energy[0] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[1] ) || ( hStereoDmxEVS->aux_dmx_energy[1] > STEREO_DMX_EVS_ILDS_EGY * hStereoDmxEVS->aux_dmx_energy[0] ) || ( ( hPHA->p_curr_taps[0] == NULL ) && ( hPHA->p_curr_taps[1] == NULL ) ) ) test(); @@ -2892,6 +3151,19 @@ ivas_error stereo_dmx_evs_init_encoder_fx( hStereoDmxEVS->hPHA->iccr_s_fx = 0; move32(); +#ifdef FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING + hStereoDmxEVS->hPHA->phitd_fx = 0; + hStereoDmxEVS->hPHA->iccres_s_fx = 0; + move32(); + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + hStereoDmxEVS->hPHA->lvlin_fx[n] = 0; + move32(); + hStereoDmxEVS->hPHA->lvlin_fx_e[n] = 0; + move16(); + } +#endif + pha_len = hStereoDmxEVS->hPHA->pha_len; move16(); fad_len = hStereoDmxEVS->hPHA->fad_len; -- GitLab From af956756a2d3ab889164a96f9c6ff5bd1a37bff9 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Wed, 5 Nov 2025 10:03:32 +0100 Subject: [PATCH 170/351] fix crash, best solution ? --- lib_dec/ivas_jbm_dec_fx.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f977f30aa..c9a89eec3 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2159,7 +2159,7 @@ ivas_error ivas_jbm_dec_render_fx( #endif { scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor - IF( st_ivas->hDecoderConfig->Opt_tsm ) + IF( ( p_output_fx[0] != p_tc_fx[0] ) ) { scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor } @@ -2195,7 +2195,11 @@ ivas_error ivas_jbm_dec_render_fx( } // Todo main-pc update: This might be needed also in the split rendering path +#ifdef FIX_1330_JBM_MEMORY + IF( ( p_output_fx[0] != p_tc_fx[0] ) ) +#else IF( st_ivas->hDecoderConfig->Opt_tsm ) +#endif { IF( NE_16( exp, *st_ivas->hCrendWrapper->p_io_qfactor ) ) { @@ -2211,7 +2215,11 @@ ivas_error ivas_jbm_dec_render_fx( IF( crendInPlaceRotation ) { +#ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE + n = st_ivas->nchan_transport; +#else n = nchan_in; +#endif } ELSE { @@ -2223,8 +2231,11 @@ ivas_error ivas_jbm_dec_render_fx( { scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 } - +#ifdef FIX_1330_JBM_MEMORY + IF( ( p_output_fx[0] != p_tc_fx[0] ) && crendInPlaceRotation ) +#else IF( st_ivas->hDecoderConfig->Opt_tsm && crendInPlaceRotation ) +#endif { n = 0; move16(); -- GitLab From 4410fe4ed934577adfe9be7612925a0575dab4a6 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 5 Nov 2025 10:48:03 +0100 Subject: [PATCH 171/351] Fix problems reported by UBSAN in jbm_pcmdsp_apa_fx.c --- lib_com/options.h | 1 + lib_dec/jbm_pcmdsp_apa_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8171bdec9..8229838ca 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,6 +95,7 @@ #define FIX_2015_PREMPH_SAT_ALT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */ #define FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE /* Nokia: Fixes float to fx conversion in decoder app with object edit file interface */ +#define FIX_2173_UBSAN_IN_JBM_PCMDSP_APA /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 37e3f51a7..b2418a9fc 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -127,7 +127,11 @@ struct apa_state_t UWord16 qualityred; /* quality reduction threshold */ UWord16 qualityrise; /* quality rising for adaptive quality thresholds */ +#ifdef FIX_2173_UBSAN_IN_JBM_PCMDSP_APA + Word16 last_pitch; /* last pitch/sync position */ +#else UWord16 last_pitch; /* last pitch/sync position */ +#endif UWord16 bad_frame_count; /* # frames before quality threshold is lowered */ UWord16 good_frame_count; /* # scaled frames */ @@ -1392,7 +1396,11 @@ static Word8 logarithmic_search_fx( const apa_state_t *ps, DO { +#ifdef FIX_2173_UBSAN_IN_JBM_PCMDSP_APA + coeff_max = INT32_MIN; /* will always be overwritten with result of first correlation */ +#else coeff_max = 0x80000000; /* will always be overwritten with result of first correlation */ +#endif move32(); FOR( i = s_start; i < s_start + inlen; i += css * ps->num_channels ) -- GitLab From 82ac59aa4794e5172bac6a311f11a0fbbd716fc2 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 5 Nov 2025 11:04:53 +0100 Subject: [PATCH 172/351] Change to ivas-conformance-linux --- .gitlab-ci/variables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 7298f79ea..e6419a3dc 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -105,4 +105,4 @@ variables: - 'long-term-logs' - 'backup-long-term-logs' - 'test-long-self-test' - - 'ivas-conformance' + - 'ivas-conformance-linux' -- GitLab From fbe9f9c4750745c43df11ac60f13ec841ce5452d Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 5 Nov 2025 11:20:05 +0100 Subject: [PATCH 173/351] Fix formatting --- lib_dec/jbm_pcmdsp_apa_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index b2418a9fc..bc9ef573f 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -128,9 +128,9 @@ struct apa_state_t UWord16 qualityrise; /* quality rising for adaptive quality thresholds */ #ifdef FIX_2173_UBSAN_IN_JBM_PCMDSP_APA - Word16 last_pitch; /* last pitch/sync position */ + Word16 last_pitch; /* last pitch/sync position */ #else - UWord16 last_pitch; /* last pitch/sync position */ + UWord16 last_pitch; /* last pitch/sync position */ #endif UWord16 bad_frame_count; /* # frames before quality threshold is lowered */ UWord16 good_frame_count; /* # scaled frames */ -- GitLab From 9cc18d843f29f3ab14353aeed408f8d4bed4bcc5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Nov 2025 11:20:39 +0100 Subject: [PATCH 174/351] fix + activate NONBE_1324_TC_BUFFER_MEMOERY_KEEP --- lib_com/options.h | 2 +- lib_dec/ivas_jbm_dec_fx.c | 4 ++++ lib_dec/ivas_omasa_dec_fx.c | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2b5fe5729..547f12425 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -123,7 +123,7 @@ #define FIX_NCHAN_BUFFERS /* VA: issue 1322: Correct the number of float buffers (channels) at the decoder */ #define FIX_RENDERER_STACK /* VA: issue 1322: reduction of renderers' buffers size */ #define JBM_MEMORY_OPT /* VA: issue 916: optimization of RAM in the JBM decoder */ -/*#define NONBE_1324_TC_BUFFER_MEMOERY_KEEP*/ /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */ +#define NONBE_1324_TC_BUFFER_MEMOERY_KEEP /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ #define CODE_IMPROVEMENTS diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 57101b4de..a3d1fdcbf 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -804,6 +804,10 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11 } +#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP + st_ivas->hCPE[0]->q_output_mem_fx[0] = output_q; + st_ivas->hCPE[0]->q_output_mem_fx[1] = output_q; +#endif } } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index c8da321a9..3e48df330 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -757,6 +757,19 @@ ivas_error ivas_omasa_dec_config_fx( /* ISM renderer handle + ISM data handle */ ivas_omasa_separate_object_renderer_close( st_ivas ); } +#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP + + IF( EQ_32( old_renderer_type, RENDERER_MONO_DOWNMIX ) ) + { + DECODER_TC_BUFFER_HANDLE hTcBuffer = st_ivas->hTcBuffer; + Word16 n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); + + FOR( k = 0; k < hTcBuffer->nchan_transport_internal; k++ ) + { + Scale_sig32( hTcBuffer->tc_buffer_old_fx[k], n_samples_still_available, st_ivas->hCPE[0]->q_output_mem_fx[0] - Q11 ); + } + } +#endif } IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ) -- GitLab From 9fc1139f35a9390b4cf2dfa776cd4ad577a4d54d Mon Sep 17 00:00:00 2001 From: lintervo Date: Wed, 5 Nov 2025 12:23:29 +0200 Subject: [PATCH 175/351] Clang format --- lib_dec/ivas_omasa_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 8b455266d..b1435fe77 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1124,7 +1124,7 @@ void ivas_omasa_dirac_rend_jbm_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #else #ifdef FIX_1330_JBM_MEMORY - IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #else IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #endif @@ -1153,7 +1153,7 @@ void ivas_omasa_dirac_rend_jbm_fx( IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #else #ifdef FIX_1330_JBM_MEMORY - IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #else IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #endif -- GitLab From b7e93ac4fe34c5d5650c8981fe3fb90011c4bba7 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Wed, 5 Nov 2025 11:50:21 +0100 Subject: [PATCH 176/351] simplify fix --- lib_dec/ivas_jbm_dec_fx.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index c9a89eec3..6c9b4706f 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2159,10 +2159,12 @@ ivas_error ivas_jbm_dec_render_fx( #endif { scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor - IF( ( p_output_fx[0] != p_tc_fx[0] ) ) +#ifndef FIX_1330_JBM_MEMORY + IF( st_ivas->hDecoderConfig->Opt_tsm ) { scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor } +#endif } } ELSE @@ -2179,28 +2181,37 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { +#ifdef FIX_1330_JBM_MEMORY + IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } } ELSE { +#ifdef FIX_1330_JBM_MEMORY + IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) ) +#endif { return error; } // Todo main-pc update: This might be needed also in the split rendering path -#ifdef FIX_1330_JBM_MEMORY - IF( ( p_output_fx[0] != p_tc_fx[0] ) ) -#else +#ifndef FIX_1330_JBM_MEMORY IF( st_ivas->hDecoderConfig->Opt_tsm ) -#endif { +#endif IF( NE_16( exp, *st_ivas->hCrendWrapper->p_io_qfactor ) ) { FOR( i = 0; i < nchan_in; i++ ) @@ -2208,8 +2219,9 @@ ivas_error ivas_jbm_dec_render_fx( scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, exp ) ); } } +#ifndef FIX_1330_JBM_MEMORY } - +#endif ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); } @@ -2231,15 +2243,13 @@ ivas_error ivas_jbm_dec_render_fx( { scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 } -#ifdef FIX_1330_JBM_MEMORY - IF( ( p_output_fx[0] != p_tc_fx[0] ) && crendInPlaceRotation ) -#else +#ifndef FIX_1330_JBM_MEMORY IF( st_ivas->hDecoderConfig->Opt_tsm && crendInPlaceRotation ) -#endif { n = 0; move16(); } +#endif #ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE FOR( i = n; i < st_ivas->nchan_transport; i++ ) -- GitLab From 6f847f36139e0dc212d6334d3a511e8ccd7fd4ba Mon Sep 17 00:00:00 2001 From: marc emerit Date: Wed, 5 Nov 2025 12:08:29 +0100 Subject: [PATCH 177/351] simplify fix --- lib_dec/ivas_jbm_dec_fx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 6c9b4706f..31d80e304 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2138,10 +2138,12 @@ ivas_error ivas_jbm_dec_render_fx( gd_bits = find_guarded_bits_fx( subframe_len ); exp = 13; move16(); +#ifndef FIX_1330_JBM_MEMORY IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->intern_config, &nchan_in ) ), IVAS_ERR_OK ) ) { return error; } +#endif IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) { return error; @@ -2214,7 +2216,11 @@ ivas_error ivas_jbm_dec_render_fx( #endif IF( NE_16( exp, *st_ivas->hCrendWrapper->p_io_qfactor ) ) { - FOR( i = 0; i < nchan_in; i++ ) +#ifdef FIX_1330_JBM_MEMORY + FOR( i = 0; i < st_ivas->nchan_transport; i++ ) +#else + FOR( i = 0; i < nchan_in; i++ ) +#endif { scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, exp ) ); } -- GitLab From 001f89affc8c079a980df6c74eeeddce4143d40d Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 5 Nov 2025 11:03:09 +0100 Subject: [PATCH 178/351] [revert-this] temporarily add USAN job to MR pipeline --- .gitlab-ci.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93d77386f..a6536e775 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,3 +9,58 @@ include: file: main-basop.yml - local: .gitlab-ci/variables.yml - local: .gitlab-ci/rules-basis.yml + +.tmp-ivas-pytest-sanitizers-anchor: &tmp-ivas-pytest-sanitizers-anchor + extends: + - .job-linux + stage: test + needs: ["build-codec-linux-make"] + script: + - !reference [ .job-linux, before_script ] + + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh + - python3 ci/remove_unsupported_testcases.py $PRM_FILES + + - set -euxo pipefail + - make_args="CLANG=$CLANG_NUM" + - if [[ $CLANG_NUM == 3 ]]; then + - export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1,print_stacktrace=1" + - python3 scripts/basop_create_ignorelist_for_ubsan.py + - make_args="$make_args IGNORELIST=1" + - fi + - make clean + - make -j $make_args >> /dev/null + - testcase_timeout_arg="--testcase_timeout $TESTCASE_TIMEOUT_LTV_SANITIZERS" + # disable per-testcase timeout for msan to evaluate what is going on that it takes so long + - if [[ $CLANG_NUM = 1 ]]; then + - testcase_timeout_arg="" + - fi + + # NOTE: here we do not use the "DUT_..CODER_PATH" variables because we do not build via a script, but directly from the make file (which is done because of the "make_args" - no way to inject that into build-binaries.sh) + - python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml $testcase_timeout_arg --ref_encoder_path IVAS_cod --ref_decoder_path IVAS_dec + artifacts: + name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" + when: always + expire_in: "2 weeks" + paths: + - report-junit.xml + - report.html + reports: + junit: + - report-junit.xml + +tmp-ivas-pytest-usan: + extends: + - .test-job-linux + tags: + - ivas-basop-linux-fast + resource_group: basop-long-sanitizers + rules: + timeout: "6 hours" + before_script: + - CLANG_NUM=3 + - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER + <<: *tmp-ivas-pytest-sanitizers-anchor + -- GitLab From 0b8c606b400ec77882b7e3d6354507724471a654 Mon Sep 17 00:00:00 2001 From: lintervo Date: Wed, 5 Nov 2025 13:53:57 +0200 Subject: [PATCH 179/351] Clang format --- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 94e0325ae..144953e26 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -513,7 +513,7 @@ ivas_error masaPrerendOpen_fx( maxBin = extract_l( Mpy_32_32( input_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ); /* Q0 */ FOR( i = 1; i < hMasaPrerend->nbands + 1; i++ ) { - IF( GE_16(hMasaPrerend->band_grouping[i], maxBin) ) + IF( GE_16( hMasaPrerend->band_grouping[i], maxBin ) ) { hMasaPrerend->band_grouping[i] = maxBin; move16(); diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 6071f2031..2f607a7b3 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -1713,8 +1713,6 @@ void ivas_create_masa_out_meta_fx( } - - #ifdef NONBE_1344_REND_MASA_LOW_FS /*------------------------------------------------------------------------- * ivas_masa_zero_high_bands() @@ -1723,7 +1721,7 @@ void ivas_create_masa_out_meta_fx( *------------------------------------------------------------------------*/ void ivas_masa_zero_high_bands_fx( - const Word16 nbands, /* i : Number of frequency bands with estimated values */ + const Word16 nbands, /* i : Number of frequency bands with estimated values */ Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated elevation */ Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated azimuth */ Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o : Estimated direct-to-total ratio */ -- GitLab From 95ab3f4bb3396a04eb7d00afb2d12c96b0cdef8f Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 5 Nov 2025 14:08:57 +0100 Subject: [PATCH 180/351] Revert "[revert-this] temporarily add USAN job to MR pipeline" This reverts commit 001f89affc8c079a980df6c74eeeddce4143d40d. --- .gitlab-ci.yml | 55 -------------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a6536e775..93d77386f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,58 +9,3 @@ include: file: main-basop.yml - local: .gitlab-ci/variables.yml - local: .gitlab-ci/rules-basis.yml - -.tmp-ivas-pytest-sanitizers-anchor: &tmp-ivas-pytest-sanitizers-anchor - extends: - - .job-linux - stage: test - needs: ["build-codec-linux-make"] - script: - - !reference [ .job-linux, before_script ] - - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh - - python3 ci/remove_unsupported_testcases.py $PRM_FILES - - - set -euxo pipefail - - make_args="CLANG=$CLANG_NUM" - - if [[ $CLANG_NUM == 3 ]]; then - - export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1,print_stacktrace=1" - - python3 scripts/basop_create_ignorelist_for_ubsan.py - - make_args="$make_args IGNORELIST=1" - - fi - - make clean - - make -j $make_args >> /dev/null - - testcase_timeout_arg="--testcase_timeout $TESTCASE_TIMEOUT_LTV_SANITIZERS" - # disable per-testcase timeout for msan to evaluate what is going on that it takes so long - - if [[ $CLANG_NUM = 1 ]]; then - - testcase_timeout_arg="" - - fi - - # NOTE: here we do not use the "DUT_..CODER_PATH" variables because we do not build via a script, but directly from the make file (which is done because of the "make_args" - no way to inject that into build-binaries.sh) - - python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml $testcase_timeout_arg --ref_encoder_path IVAS_cod --ref_decoder_path IVAS_dec - artifacts: - name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" - when: always - expire_in: "2 weeks" - paths: - - report-junit.xml - - report.html - reports: - junit: - - report-junit.xml - -tmp-ivas-pytest-usan: - extends: - - .test-job-linux - tags: - - ivas-basop-linux-fast - resource_group: basop-long-sanitizers - rules: - timeout: "6 hours" - before_script: - - CLANG_NUM=3 - - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER - <<: *tmp-ivas-pytest-sanitizers-anchor - -- GitLab From de32410c5896bb3145d8998db4d5b000d7e85bad Mon Sep 17 00:00:00 2001 From: Tommy Date: Wed, 5 Nov 2025 09:36:15 -0500 Subject: [PATCH 181/351] convert to fixed point convertSerialToBytestream_fx, debug code included --- lib_com/bitstream_fx.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index b5162777e..e507a7c9d 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -3854,9 +3854,12 @@ void convertSerialToBytestream_fx( UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ ) { - UWord32 i; + Word16 i, ia7, isr3; UWord8 bit, bitinbyte; - +#ifdef DEBUGGING + UWord8 bitinbyte2, bytestream_tmp; + assert( num_bits <= MAX_16 ); /* 512 kbps = 10240 bits, num_bits should always fits Word16 */ +#endif FOR( i = 0; i < num_bits; ++i ) { IF( EQ_32( serial[i], 0x0001 ) ) @@ -3869,12 +3872,29 @@ void convertSerialToBytestream_fx( bit = 0; move16(); } - bitinbyte = bit << ( 7 - ( i & 0x7 ) ); - IF( !( i & 0x7 ) ) + /*bitinbyte = bit << ( 7 - ( i & 0x7 ) );*/ + ia7 = s_and( i, 0x7 ); + isr3 = shr( i, 3 ); + bitinbyte = (UWord8) shl( (Word16) bit, sub( 7, ia7 ) ); +#ifdef DEBUGGING + bitinbyte2 = bit << ( 7 - ( i & 0x7 ) ); + assert( bitinbyte2 == bitinbyte ); +#endif + IF( !( ia7 ) ) { - bytestream[i >> 3] = 0; + bytestream[isr3] = 0; + move16(); } - bytestream[i >> 3] |= bitinbyte; + /*bytestream[i >> 3] |= bitinbyte;*/ +#ifdef DEBUGGING + bytestream_tmp = bytestream[isr3]; + bytestream_tmp |= bitinbyte2; +#endif + bytestream[isr3] = (Word8) s_or( bytestream[isr3], bitinbyte ); +#ifdef DEBUGGING + assert( bytestream_tmp == bytestream[isr3] ); +#endif + move16(); } return; -- GitLab From 9c6b784a2080ef3471075c87ccd8d19ddd201e15 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Wed, 5 Nov 2025 17:24:37 +0200 Subject: [PATCH 182/351] Port float MR2320 --- apps/decoder.c | 15 +++++++++++++++ apps/encoder.c | 17 +++++++++++++++++ lib_com/options.h | 1 + lib_util/ivas_rtp_api.h | 13 +++++++++++++ lib_util/ivas_rtp_file.c | 13 +++++++++++++ lib_util/ivas_rtp_file.h | 4 ++++ lib_util/ivas_rtp_payload.c | 13 +++++++++++++ 7 files changed, 76 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 9c303e9ad..3e8dc09de 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -56,6 +56,9 @@ #include "ivas_rtp_file.h" #endif +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_DEC ( 0xFEEDFADE ) +#endif #define WMC_TOOL_SKIP @@ -1702,6 +1705,14 @@ static ivas_error initOnFirstGoodFrame( ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; int16_t splitRendIsarFrameSizeMs; int16_t lc3plusHighRes; +#ifdef FIXED_RTP_SEQUENCE_NUM + /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we + use fixed seed for random num generator for regression based tests. Any realtime + application should implement this initialization seperately */ + srand( RANDOM_INITSEED_DEC ); + uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); + uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) { @@ -1740,7 +1751,11 @@ static ivas_error initOnFirstGoodFrame( /* Split Rendering RTPDump Output file */ +#ifdef FIXED_RTP_SEQUENCE_NUM + if ( ( error = IVAS_RTP_WRITER_Init( srRtp, arg.outputWavFilename, 1000 / ( IVAS_NUM_FRAMES_PER_SEC * splitRendCodecFrameSizeMs ), ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_RTP_WRITER_Init( srRtp, arg.outputWavFilename, 1000 / ( IVAS_NUM_FRAMES_PER_SEC * splitRendCodecFrameSizeMs ) ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError: Can't open SR output bitstream file for RTP output %s \n\n", arg.outputWavFilename ); return error; diff --git a/apps/encoder.c b/apps/encoder.c index 5e2de5f45..fe64442e1 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -63,6 +63,10 @@ #endif #endif +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) +#endif + #define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* @@ -226,6 +230,15 @@ int main( IVAS_RTP ivasRtp = { 0 }; #endif +#ifdef FIXED_RTP_SEQUENCE_NUM + /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we + use fixed seed for random num generator for regression based tests. Any realtime + application should implement this initialization seperately */ + srand( RANDOM_INITSEED_ENC ); + uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); + uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif + /*------------------------------------------------------------------------------------------* * Parse command-line arguments *------------------------------------------------------------------------------------------*/ @@ -621,7 +634,11 @@ int main( if ( arg.rtpdumpOutput ) { +#ifdef FIXED_RTP_SEQUENCE_NUM + if ( ( error = IVAS_RTP_WRITER_Init( &ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_RTP_WRITER_Init( &ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError: Can't open output bitstream file for RTP output %s \n\n", arg.outputBitstreamFilename ); goto cleanup; diff --git a/lib_com/options.h b/lib_com/options.h index b8e650b8e..6dc0310f5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,6 +141,7 @@ // RTPDUMP porting #define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ +#define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h index 405893581..8e551c5ff 100644 --- a/lib_util/ivas_rtp_api.h +++ b/lib_util/ivas_rtp_api.h @@ -309,8 +309,10 @@ void IVAS_RTP_PACK_Close( ); /* Update the RTP Header structure */ +#ifdef FIXED_RTP_SEQUENCE_NUM ivas_error IVAS_RTP_PACK_UpdateHeader( IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + uint16_t seqNumInitVal, /* i : Initial sequence number to be used for 1st packet */ uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ uint8_t numCC, /* i : numCC indicates no. of contributing sources */ uint32_t *csrc, /* i : SSRCs of contributing Sources for a mixed stream */ @@ -318,6 +320,17 @@ ivas_error IVAS_RTP_PACK_UpdateHeader( uint16_t numExtensionBytes, /* i : length of the extension data */ uint8_t *extData /* i : extension data pointer */ ); +#else +ivas_error IVAS_RTP_PACK_UpdateHeader( + IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ + uint8_t numCC, /* i : numCC indicates no. of contributing sources */ + uint32_t *csrc, /* i : SSRCs of contributing Sources for a mixed stream */ + uint16_t extHeaderId, /* i : extension header ID */ + uint16_t numExtensionBytes, /* i : length of the extension data */ + uint8_t *extData /* i : extension data pointer */ +); +#endif /* Add requests for remote sender using a key value pair api * each key must be provided with a corresponding value type diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 10eaa73c1..91a63f598 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -702,10 +702,19 @@ void IVAS_RTP_Term( ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, /* i/o : IVAS RTP File writer handle */ const char *outputBitstreamFilename, /* i : RTP Dump filename */ +#ifdef FIXED_RTP_SEQUENCE_NUM + uint32_t numFramesPerPacket, /* i : No. of frames per packet desired */ + uint32_t SSRC, /* i : SSRC for RTP Header */ + uint16_t seqNumInitVal /* i : Initial seq number in rtp header */ +#else uint32_t numFramesPerPacket /* i : No. of frames per packet desired */ +#endif ) { + +#ifndef FIXED_RTP_SEQUENCE_NUM uint32_t SSRC = ( rand() & 0xFFFF ) | ( (uint32_t) rand() << 16 ); +#endif ivas_error error = IVAS_ERR_OK; memset( rtp, 0, sizeof( IVAS_RTP ) ); @@ -724,7 +733,11 @@ ivas_error IVAS_RTP_WRITER_Init( return error; } +#ifdef FIXED_RTP_SEQUENCE_NUM + error = IVAS_RTP_PACK_UpdateHeader( rtp->hPack, seqNumInitVal, SSRC, 0, NULL, 0, 0, NULL ); +#else error = IVAS_RTP_PACK_UpdateHeader( rtp->hPack, SSRC, 0, NULL, 0, 0, NULL ); +#endif if ( error != IVAS_ERR_OK ) { fprintf( stderr, "error in IVAS_RTP_PACK_UpdateHeader(): %d\n", error ); diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index d5fbc0504..78126b393 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -70,7 +70,11 @@ typedef struct #endif } IVAS_RTP; +#ifdef FIXED_RTP_SEQUENCE_NUM +ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, const char *outputBitstreamFilename, uint32_t numFramesPerPacket, uint32_t SSRC, uint16_t seqNumInitVal ); +#else ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, const char *outputBitstreamFilename, uint32_t numFramesPerPacket ); +#endif #ifdef RTP_S4_251135_CR26253_0016_REV1 ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, uint32_t srCodecFrameSizeMs, const char *inputBitstreamFilename, const char *piOutputFilename, bool isExtOutput, const char *outputWavFilename ); #else diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 46198011a..30ba918d7 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -32,7 +32,9 @@ #include #include #include +#ifndef FIXED_RTP_SEQUENCE_NUM #include +#endif #include "common_api_types.h" #ifdef IVAS_RTPDUMP @@ -182,6 +184,9 @@ static const uint32_t amrWBIOFrameSizeInBits[] = { /* Update the RTP Header structure */ ivas_error IVAS_RTP_PACK_UpdateHeader( IVAS_RTP_PACK_HANDLE hPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ +#ifdef FIXED_RTP_SEQUENCE_NUM + uint16_t seqNumInitVal, /* i : Initial sequence number to be used for 1st packet */ +#endif uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ uint8_t numCC, /* i : numCC indicates no. of contributing sources */ uint32_t *csrc, /* i : SSRCs of contributing Sources for a mixed stream */ @@ -197,6 +202,9 @@ ivas_error IVAS_RTP_PACK_UpdateHeader( return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "CC must be less than 16" ); } +#ifdef FIXED_RTP_SEQUENCE_NUM + header->seqNumber = seqNumInitVal; +#endif header->ssrc = ssrc; header->CC = numCC; if ( csrc != NULL ) @@ -229,11 +237,16 @@ static void InitRtpHeader( RTP_HEADER *header /* RTP header structure */ ) { +#ifdef FIXED_RTP_SEQUENCE_NUM + memset( header, 0, sizeof( *header ) ); + header->version = 2; +#else time_t t; memset( header, 0, sizeof( *header ) ); srand( (uint32_t) time( &t ) ); header->version = 2; header->seqNumber = rand() & 0xFFFF; +#endif } static ivas_error PackRtpHeader( -- GitLab From 2e2f1c406bb783e12dac65270238c4a42a980556 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Wed, 5 Nov 2025 17:27:48 +0200 Subject: [PATCH 183/351] Add define switches --- lib_com/ivas_error.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 3b49667d4..64209e04e 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -147,6 +147,7 @@ typedef enum IVAS_ERR_LC3PLUS_INVALID_BITRATE, IVAS_ERR_INVALID_SPLIT_REND_CONFIG, +#ifdef IVAS_RTPDUMP /*----------------------------------------* * rtp errors * *----------------------------------------*/ @@ -154,6 +155,7 @@ typedef enum IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, IVAS_ERR_RTP_UNPACK_PI_DATA, IVAS_ERR_RTP_UNSUPPORTED_FRAME, +#endif /*----------------------------------------* * unknown error * @@ -294,6 +296,7 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) { return "data error"; } +#ifdef IVAS_RTPDUMP if ( ( error_code & 0x7000 ) == 0x7000 ) { switch ( error_code ) @@ -310,6 +313,7 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "rtp error"; } } +#endif return "Unknown error"; } -- GitLab From ec36366c76c57e80d1ca01e66847ab3ac5c221a2 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Wed, 5 Nov 2025 17:35:15 +0200 Subject: [PATCH 184/351] Bring back removed srinfo parameter and related code --- apps/decoder.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 3e8dc09de..0b799b377 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2872,6 +2872,7 @@ static ivas_error decodeVoIP( #ifdef IVAS_RTPDUMP IVAS_RTP ivasRtp = { 0 }; IVAS_RTP srRtp = { 0 }; + IVAS_RTP_SR_INFO srInfo = { true, false, 0, IVAS_SR_TRANSPORT_LCLD }; int32_t initialTsOffsetSystemAndRTP = 0; #else FILE *f_rtpstream = NULL; @@ -3515,6 +3516,20 @@ static ivas_error decodeVoIP( #endif } } +#ifdef IVAS_RTPDUMP + else if ( decodedGoodFrame ) + { + srInfo.bitrateKbps = splitRendBits->bits_written * 1000 / splitRendBits->codec_frame_size_ms; + srInfo.codec = ( splitRendBits->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) ? IVAS_SR_TRANSPORT_LC3PLUS : IVAS_SR_TRANSPORT_LCLD; + if ( ( error = IVAS_RTP_WriteNextFrame( &srRtp, splitRendBits->bits_buf, &srInfo, (int16_t) splitRendBits->bits_written, false, false ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while pushing SR audio bitstream to RTP pack\n", ivas_error_to_string( error ) ); + goto cleanup; + } + splitRendBits->bits_written = 0; + splitRendBits->bits_read = 0; + } +#endif vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; if ( vec_pos_update == 0 ) -- GitLab From 15af1606b88832cd1aaeb8cb254f94a9367e68a6 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 5 Nov 2025 17:00:16 +0100 Subject: [PATCH 185/351] Fix duplicated declarations under FIX_1119_SPLIT_RENDERING_VOIP --- lib_isar/isar_splitRendererPre.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 37985e492..8632b0aec 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -3046,7 +3046,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( move32(); FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#else FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { scale_factor = s_min( scale_factor, s_min( getScaleFactor32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ) ); } @@ -3054,7 +3058,11 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( scale_factor = sub( scale_factor, 2 ); FOR( i = 0; i < num_poses * BINAURAL_CHANNELS; i++ ) { +#ifdef FIX_1119_SPLIT_RENDERING_VOIP + FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#else FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { Scale_sig32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX, scale_factor ); Scale_sig32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX, scale_factor ); -- GitLab From cd528aa07374ebb918eae173de4fb55c376f891f Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Wed, 5 Nov 2025 17:03:10 +0100 Subject: [PATCH 186/351] Trigger CI -- GitLab From b4db0eda8eff35ce07b089ae5299faca4ff0d891 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 5 Nov 2025 18:54:02 +0100 Subject: [PATCH 187/351] formatting --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 2f9844cae..575b4c344 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1073,8 +1073,8 @@ void ivas_ism_dec_digest_tc_fx( Word16 azi = extract_l( azimuth_fx ); // Q0 Word16 ele = extract_l( elevation_fx ); // Q0 #else - Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 - Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 + Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 + Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 #endif ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); -- GitLab From 5426db3deac3f95751384cabcf2f25db9edc3fc3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 5 Nov 2025 19:26:13 +0100 Subject: [PATCH 188/351] fix merge conflicts --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 575b4c344..3036c2a4a 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1070,8 +1070,8 @@ void ivas_ism_dec_digest_tc_fx( { /*get HOA gets for direction (ACN/SN3D)*/ #ifdef FIX_2193_ISM_GAINS_WITH_OE - Word16 azi = extract_l( azimuth_fx ); // Q0 - Word16 ele = extract_l( elevation_fx ); // Q0 + Word16 azi = extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 22 ) ); // Q0 + Word16 ele = extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 22 ) ); // Q0 #else Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 -- GitLab From 094d7149bb70c3a57eb824b10432c25d6467c332 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 5 Nov 2025 20:06:44 +0100 Subject: [PATCH 189/351] use rounding to match float --- lib_dec/ivas_ism_param_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 3036c2a4a..6af94ea97 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1070,8 +1070,8 @@ void ivas_ism_dec_digest_tc_fx( { /*get HOA gets for direction (ACN/SN3D)*/ #ifdef FIX_2193_ISM_GAINS_WITH_OE - Word16 azi = extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 22 ) ); // Q0 - Word16 ele = extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 22 ) ); // Q0 + Word16 azi = round_fx( L_shr( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, Q22 - Q16 ) ); // Q0 + Word16 ele = round_fx( L_shr( st_ivas->hIsmMetaData[i]->edited_elevation_fx, Q22 - Q16 ) ); // Q0 #else Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 -- GitLab From 8006da630d5ec6082a5226dcf63bb07c0fd5fb9f Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 6 Nov 2025 09:27:54 +0200 Subject: [PATCH 190/351] Port float MR2282 --- lib_dec/lib_dec_fx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index aa27b6113..9e64630f2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -412,11 +412,17 @@ void IVAS_DEC_Close( ( *phIvasDec )->hVoIP = NULL; } +#ifndef IVAS_RTPDUMP /* destroy Split binaural renderer (ISAR) handle */ ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend ); +#endif IF( ( *phIvasDec )->st_ivas ) { +#ifdef IVAS_RTPDUMP + /* destroy Split binaural renderer (ISAR) handle */ + ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend ); +#endif ivas_destroy_dec_fx( ( *phIvasDec )->st_ivas ); ( *phIvasDec )->st_ivas = NULL; } -- GitLab From 0a908ba48cdf1b750e8942f07627dc9697b650e7 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Thu, 6 Nov 2025 08:29:44 +0100 Subject: [PATCH 191/351] Trigger Build -- GitLab From e375867f690a8200a807b8f98a09fbe97cec41be Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 6 Nov 2025 10:12:03 +0100 Subject: [PATCH 192/351] Fix for crash in debug mode in macos when reading windows stlye line ending --- lib_util/cmdl_tools.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index bec772ce4..900e003aa 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -185,20 +185,21 @@ void convert_backslash( void remove_cr( char *str ) { - char *pos; + int32_t n, p = 0; /* remove all \r characters from the string */ - pos = strchr( str, '\r' ); - while ( pos != NULL ) + for ( n = 0; str[n] != 0; n++ ) { - strcpy( pos, pos + 1 ); - pos = strchr( pos, '\r' ); + char c = str[n]; + str[p] = c; + p += ( c == '\r' ) ? 0 : 1; } - + + str[p] = 0; + return; } - /*---------------------------------------------------------------------* * clearString() * -- GitLab From f561b72f6815382a9eced09f6aea2f2f77fbf285 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 6 Nov 2025 10:17:08 +0100 Subject: [PATCH 193/351] clang format --- lib_util/cmdl_tools.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index 900e003aa..945bda07d 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -194,9 +194,9 @@ void remove_cr( str[p] = c; p += ( c == '\r' ) ? 0 : 1; } - + str[p] = 0; - + return; } -- GitLab From 71fadc9f00bc00cf6bed3dd508a3f349aa47db72 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 6 Nov 2025 10:29:42 +0100 Subject: [PATCH 194/351] Dummy commit -- GitLab From fc0987bc258f92ac3346a3f0e0908b6b3ff59609 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Thu, 6 Nov 2025 10:30:15 +0100 Subject: [PATCH 195/351] rollback nchan_in --- lib_dec/ivas_jbm_dec_fx.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 9e67be09c..909d2ae51 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2142,12 +2142,10 @@ ivas_error ivas_jbm_dec_render_fx( gd_bits = find_guarded_bits_fx( subframe_len ); exp = 13; move16(); -#ifndef FIX_1330_JBM_MEMORY IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->intern_config, &nchan_in ) ), IVAS_ERR_OK ) ) { return error; } -#endif IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) { return error; @@ -2158,11 +2156,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( crendInPlaceRotation ) { -#ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE - FOR( i = 0; i < st_ivas->nchan_transport; i++ ) -#else FOR( i = 0; i < nchan_in; i++ ) -#endif { scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor #ifndef FIX_1330_JBM_MEMORY @@ -2175,11 +2169,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE { -#ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE - FOR( i = 0; i < st_ivas->nchan_transport; i++ ) -#else FOR( i = 0; i < nchan_in; i++ ) -#endif { scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor } @@ -2217,19 +2207,13 @@ ivas_error ivas_jbm_dec_render_fx( #ifndef FIX_1330_JBM_MEMORY IF( st_ivas->hDecoderConfig->Opt_tsm ) { -#endif IF( NE_16( exp, *st_ivas->hCrendWrapper->p_io_qfactor ) ) { -#ifdef FIX_1330_JBM_MEMORY - FOR( i = 0; i < st_ivas->nchan_transport; i++ ) -#else - FOR( i = 0; i < nchan_in; i++ ) -#endif + FOR( i = 0; i < nchan_in; i++ ) { scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, exp ) ); } } -#ifndef FIX_1330_JBM_MEMORY } #endif ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); @@ -2237,11 +2221,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( crendInPlaceRotation ) { -#ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE - n = st_ivas->nchan_transport; -#else n = nchan_in; -#endif } ELSE { @@ -2261,11 +2241,7 @@ ivas_error ivas_jbm_dec_render_fx( } #endif -#ifdef FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE - FOR( i = n; i < st_ivas->nchan_transport; i++ ) -#else FOR( i = n; i < nchan_in; i++ ) -#endif { scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 } -- GitLab From b47912f932b2e6f7a789776b228e308dc6e1164a Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 6 Nov 2025 11:52:46 +0200 Subject: [PATCH 196/351] Add object editing gain limitations as agreed. --- lib_com/ivas_cnst.h | 17 ++++- lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 127 ++++++++++++++++++++++++++++---- lib_util/obj_edit_file_reader.h | 7 ++ 4 files changed, 135 insertions(+), 17 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index c445d0299..bfe3e4dee 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -202,6 +202,15 @@ typedef enum #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH #define MAX_CLDFB_DIGEST_CHANNELS 3 /* == maximum of ParamISM TCs and ParamMC TCs */ +#ifdef FIX_GAIN_EDIT_LIMITS +#define OBJ_EDIT_GAIN_MIN_Q29 33874260 /* Minimum allowed object gain edit in Q29: 0.0630957f, -24 dB */ +#define OBJ_EDIT_GAIN_MAX_Q29 2137321728 /* Maximum allowed object gain edit in Q29: 3.9810719f, +12 dB */ +#define OBJ_EDIT_GAIN_MIN_Q12 258 /* Minimum allowed object gain edit in Q12: 0.0630957f, -24 dB */ +#define OBJ_EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ +#endif + + + typedef enum { TC_BUFFER_MODE_RENDERER, @@ -1266,10 +1275,10 @@ enum #define MASA_MAXIMUM_TWO_DIR_BANDS 24 #define NBITS_HR_COH 4 #define OMASA_TDREND_MATCHING_GAIN_FX 26026 -//TODO: insert proper Q representations -#define OMASA_GAIN_EDIT_THR_FX 246 /* OMASA gain change threshold, 0.06f in Q12 */ -#define OMASA_AZI_EDIT_THR_FX ONE_IN_Q22 /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */ -#define OMASA_ELE_EDIT_THR_FX ONE_IN_Q23 /* OMASA-DISC elevation change threshold, 2.0f in Q22 */ + +#define OMASA_GAIN_EDIT_THR_Q12 246 /* OMASA gain change threshold, 0.06f in Q12 */ +#define OMASA_AZI_EDIT_THR_Q22 ONE_IN_Q22 /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */ +#define OMASA_ELE_EDIT_THR_Q22 ONE_IN_Q23 /* OMASA-DISC elevation change threshold, 2.0f in Q22 */ #define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 1453366656l /* 1.353553128183453f in Q30 */ diff --git a/lib_com/options.h b/lib_com/options.h index f6e4deb5b..9f30b849e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,6 +90,7 @@ #define FIX_2170_ASSERT_IN_FFT3 /* Eri: Assert in fft3_fx from EVS, adding _sat */ #define FIX_2082_FP_LEFTOVERS_OMASA_DEC /* Nokia: fix for issue 2082, cleaning remaining floating point code */ #define FIX_2174_JBM_BASOP_ALIGNMENT /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */ +#define FIX_GAIN_EDIT_LIMITS /* Harmonize gain edit limits for all opertation points. For all modes, limit to max +12dB. For parametric modes, limit to min -24dB. */ #define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */ #define FIX_2015_PREMPH_SAT_ALT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7d3ee4ffd..1e1c6de94 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4156,7 +4156,7 @@ ivas_error IVAS_DEC_GetEditableParameters( move32(); hIvasEditableParameters->ism_metadata[obj].radius_fx = 0; move16(); - hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q29; // TODO check Q-value + hIvasEditableParameters->ism_metadata[obj].gain_fx = ONE_IN_Q29; move32(); hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; move16(); @@ -4318,16 +4318,42 @@ ivas_error IVAS_DEC_SetEditableParameters( move32(); st_ivas->hIsmMetaData[obj]->edited_pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; move32(); +#ifdef FIX_GAIN_EDIT_LIMITS + IF ( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + { + st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MAX_Q29; + move32(); + } + ELSE + { + st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; + move32(); + } +#else st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; move32(); +#endif st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; move16(); } IF( EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) { +#ifdef FIX_GAIN_EDIT_LIMITS + IF ( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + { + st_ivas->hSbaIsmData->gain_bed_fx = OBJ_EDIT_GAIN_MAX_Q29; + move32(); + } + ELSE + { + st_ivas->hSbaIsmData->gain_bed_fx = hIvasEditableParameters.gain_bed_fx; + move32(); + } +#else st_ivas->hSbaIsmData->gain_bed_fx = hIvasEditableParameters.gain_bed_fx; move32(); +#endif } } ELSE IF( EQ_32( ism_mode, ISM_MODE_PARAM ) ) @@ -4343,12 +4369,31 @@ ivas_error IVAS_DEC_SetEditableParameters( move32(); IF( st_ivas->hMasaIsmData != NULL ) { +#ifdef FIX_GAIN_EDIT_LIMITS + /* Limit gain edit to a range of +12dB to -24dB with parametric ISM mode */ + IF ( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + { + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MAX_Q12; // Q12 + move16(); + } + ELSE IF ( LT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) + { + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MIN_Q12; // Q12 + move16(); + } + ELSE + { + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 -> Q12 + move16(); + } +#else st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 -> Q12 move32(); +#endif - /* Detect direction editing in Param-ISM mode */ - IF( GT_32( L_abs( L_sub( st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_FX ) || - GT_32( L_abs( L_sub( st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_FX ) ) + /* Detect direction editing in Param-ISM mode */ + IF( GT_32( L_abs( L_sub( st_ivas->hParamIsmDec->azimuth_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ), OMASA_AZI_EDIT_THR_Q22 ) || // | azi_orig[obj] - azi_edit[obj] | > azi_threshold + GT_32( L_abs( L_sub( st_ivas->hParamIsmDec->elevation_values_fx[obj], hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ), OMASA_ELE_EDIT_THR_Q22 ) ) // | ele_orig[obj] - ele_edit[obj] | > ele_threshold { st_ivas->hMasaIsmData->ism_dir_is_edited[obj] = 1; } @@ -4359,7 +4404,7 @@ ivas_error IVAS_DEC_SetEditableParameters( move16(); /* Detect gain editing in Param-ISM mode */ - IF( GT_16( abs_s( sub( ONE_IN_Q12, shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q values + IF( GT_16( abs_s( sub( ONE_IN_Q12, shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | 1.0f - gain_edit[obj] | > gain_threshold { st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; } @@ -4443,8 +4488,8 @@ ivas_error IVAS_DEC_SetEditableParameters( threshold_ele = delta_theta_masa_fx[st_ivas->hMasaIsmData->bits_ism[obj] - 3]; test(); - IF( ( GT_32( L_shl( abs_s( sub( new_azi, st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) || - ( GT_32( L_shl( abs_s( sub( new_ele, st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) ) + IF( ( GT_32( L_shl( abs_s( sub( new_azi, st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) || // | azi_edit[obj] - azi_orig[obj] | > azi_threshold + ( GT_32( L_shl( abs_s( sub( new_ele, st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) ) // | ele_edit[obj] - ele_orig[obj] | > ele_threshold { /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi; @@ -4464,8 +4509,8 @@ ivas_error IVAS_DEC_SetEditableParameters( { /* detect editing in ISM_MASA_MODE_DISC mode */ test(); - IF( L_abs( L_sub( st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ) > OMASA_AZI_EDIT_THR_FX || - L_abs( L_sub( st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ) > OMASA_ELE_EDIT_THR_FX ) + IF( L_abs( L_sub( st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ) > OMASA_AZI_EDIT_THR_Q22 || // | azi_orig[obj] - azi_edit[obj] | > azi_threshold + L_abs( L_sub( st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ) > OMASA_ELE_EDIT_THR_Q22 ) // | ele_orig[obj] - ele_edit[obj] | > ele_threshold { st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi; move32(); @@ -4482,11 +4527,31 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* compare pre-edit gain and the edited one to detect editing */ - IF( GT_16( abs_s( sub( shr( extract_h( st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check incoming Q value + IF( GT_16( abs_s( sub( shr( extract_h( st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_edit[obj] - gain_orig[obj] | > gain_threshold { st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; +#ifdef FIX_GAIN_EDIT_LIMITS + /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */ + test(); + IF ( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + { + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MAX_Q12; + move16(); + } + ELSE IF ( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MIN_Q29 )) + { + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MIN_Q12; + move16(); + } + ELSE + { + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 --> Q12 + move16(); + } +#else st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ); // Q29 --> Q12 move16(); +#endif } ELSE { @@ -4520,17 +4585,53 @@ ivas_error IVAS_DEC_SetEditableParameters( st_ivas->hIsmMetaData[obj]->radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; move32(); #endif - st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; // TODO: check incoming Q value +#ifdef FIX_GAIN_EDIT_LIMITS + test(); + IF ( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + { + st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MAX_Q29; + } + ELSE IF ( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) + { + st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MIN_Q29; + } + ELSE + { + st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; + } +#else + st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; move32(); +#endif st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; move16(); } } - IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_FX ) ) // TODO: check Q value + IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_bed - 1.0f | > gain_threshold { - st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ); // TODO: check type +#ifdef FIX_GAIN_EDIT_LIMITS + /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */ + test(); + IF ( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + { + st_ivas->hMasaIsmData->gain_masa_edited_fx = OBJ_EDIT_GAIN_MAX_Q12; + move16(); + } + ELSE IF (EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MIN_Q29 )) + { + st_ivas->hMasaIsmData->gain_masa_edited_fx = OBJ_EDIT_GAIN_MIN_Q12; + move16(); + } + ELSE + { + st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ); + move16(); + } +#else + st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ); move32(); +#endif st_ivas->hMasaIsmData->masa_gain_is_edited = 1; } ELSE diff --git a/lib_util/obj_edit_file_reader.h b/lib_util/obj_edit_file_reader.h index 4c3e4435f..dcd0eabff 100644 --- a/lib_util/obj_edit_file_reader.h +++ b/lib_util/obj_edit_file_reader.h @@ -41,10 +41,17 @@ the United Nations Convention on Contracts on the International Sales of Goods. * Constants ans structures *---------------------------------------------------------------------*/ +#ifdef FIX_GAIN_EDIT_LIMITS +#define OBJ_EDIT_GAIN_MIN_FX 0 /* Q29, 0.0f, -inf dB */ +#define OBJ_EDIT_GAIN_MAX_FX 2137321728 /* Q29, 3.9810719f, +12 dB */ +#define OBJ_EDIT_GAIN_MIN 0.0f /* -inf dB */ +#define OBJ_EDIT_GAIN_MAX 3.9810719f /* +12 dB */ +#else #define OBJ_EDIT_GAIN_MIN_FX 33874262 /* Q29, 0.06309573f, -24 dB */ #define OBJ_EDIT_GAIN_MAX_FX 2127207375 /* Q29, 3.9622325f, +12 dB, TODO: align with float */ #define OBJ_EDIT_GAIN_MIN 0.06309573f /* -24 dB */ #define OBJ_EDIT_GAIN_MAX 3.9622325f /* +12 dB */ +#endif typedef struct ObjectEditFileReader ObjectEditFileReader; typedef struct ReadObjectEditInfo ReadObjectEditInfo; -- GitLab From ebc4c54ff3e8e5ccd67da0f3ca8e5d8afb46f817 Mon Sep 17 00:00:00 2001 From: Sumeyra Kanik Date: Thu, 6 Nov 2025 11:33:42 +0100 Subject: [PATCH 197/351] Port MR 2337 from float --- apps/decoder.c | 40 ++++++++++++++++++++ lib_com/options.h | 1 + lib_util/obj_edit_file_reader.c | 67 ++++++++++++++++++++++++++++++++- lib_util/obj_edit_file_reader.h | 19 ++++++++++ 4 files changed, 126 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 94bfab14d..ac76ce1a4 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3500,6 +3500,46 @@ static void do_object_editing_fx( #endif } } +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA + /* object direction editing only for diegetic objects */ + if ( readInfo->obj_yaw_edited[obj_idx] ) + { + if ( readInfo->obj_yaw_relative[obj_idx] ) + { + /* yaw: apply relative edit + wrap */ + editableParameters->ism_metadata[obj_idx].yaw_fx = ( ( editableParameters->ism_metadata[obj_idx].yaw_fx + (Word32) ( readInfo->obj_yaw[obj_idx] * 4194304 ) + 2264924160 ) % 1509949440 ) - 754974720; /* Q22 */ + } + else + { + editableParameters->ism_metadata[obj_idx].yaw_fx = (Word32) ( readInfo->obj_yaw[obj_idx] * 4194304 ); /* Q22 */ + } + } + if ( readInfo->obj_pitch_edited[obj_idx] ) + { + if ( readInfo->obj_pitch_relative[obj_idx] ) + { + /* pitch: apply relative edit + saturation */ + editableParameters->ism_metadata[obj_idx].pitch_fx = L_max( L_min( editableParameters->ism_metadata[obj_idx].pitch_fx + (Word32) ( readInfo->obj_pitch[obj_idx] * 4194304 ), 377487360 ), -377487360 ); /* Q22 */ + } + else + { + editableParameters->ism_metadata[obj_idx].pitch_fx = (Word32) ( readInfo->obj_pitch[obj_idx] * 4194304 ); /* Q22 */ + } + } + /* radius editing only for diegetic objects */ + if ( readInfo->obj_radius_edited[obj_idx] ) + { + if ( readInfo->obj_radius_relative[obj_idx] ) + { + /* radius: apply relative edit + saturation */ + editableParameters->ism_metadata[obj_idx].radius_fx = L_max( L_min( L_shl_sat( Mpy_32_32( editableParameters->ism_metadata[obj_idx].radius_fx, (Word32) ( readInfo->obj_radius[obj_idx] * 536870912 ) ), 2 ), OBJ_EDIT_RADIUS_MAX_FX ), 0.0 ); /* Q29*Q29 -> Q27 shift back to Q29 */ + } + else + { + editableParameters->ism_metadata[obj_idx].radius_fx = (Word32) ( readInfo->obj_radius[obj_idx] * 536870912 ); /* Q29 */ + } + } +#endif } /* gain editing for all objects */ diff --git a/lib_com/options.h b/lib_com/options.h index f6e4deb5b..3827f88a4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,6 +145,7 @@ #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ #define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ #define FIX_2193_ISM_GAINS_WITH_OE /* FhG: fix issue 2193: use edited angles in ISM gain calculation */ +#define FIX_2192_OBJ_EDITING_EXT_METADATA /* Eri: Add support for extended metadata in object editing */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_util/obj_edit_file_reader.c b/lib_util/obj_edit_file_reader.c index 63a542094..44c100973 100644 --- a/lib_util/obj_edit_file_reader.c +++ b/lib_util/obj_edit_file_reader.c @@ -70,8 +70,11 @@ ivas_error ObjectEditFileReader_open( } self = (ObjectEditFileReader *) calloc( 1, sizeof( ObjectEditFileReader ) ); - +#ifndef FIX_2192_OBJ_EDITING_EXT_METADATA self->maxLineLen = 256; +#else + self->maxLineLen = 1024; +#endif self->editFileHandle = fileHandle; self->inLine = (char *) calloc( self->maxLineLen, sizeof( char ) ); @@ -90,6 +93,17 @@ ivas_error ObjectEditFileReader_open( self->readInfo->obj_ele[obj_idx] = 0.0f; self->readInfo->obj_ele_edited[obj_idx] = false; self->readInfo->obj_ele_relative[obj_idx] = false; +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA + self->readInfo->obj_radius[obj_idx] = 0.0f; + self->readInfo->obj_radius_edited[obj_idx] = false; + self->readInfo->obj_radius_relative[obj_idx] = false; + self->readInfo->obj_yaw[obj_idx] = 0.0f; + self->readInfo->obj_yaw_edited[obj_idx] = false; + self->readInfo->obj_yaw_relative[obj_idx] = false; + self->readInfo->obj_pitch[obj_idx] = 0.0f; + self->readInfo->obj_pitch_edited[obj_idx] = false; + self->readInfo->obj_pitch_relative[obj_idx] = false; +#endif } self->rewound = false; @@ -136,6 +150,14 @@ ivas_error ObjectEditFileReader_readNextFrame( readEdits->obj_azi_relative[obj_idx] = false; readEdits->obj_ele_edited[obj_idx] = false; readEdits->obj_ele_relative[obj_idx] = false; +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA + readEdits->obj_radius_edited[obj_idx] = false; + readEdits->obj_radius_relative[obj_idx] = false; + readEdits->obj_yaw_edited[obj_idx] = false; + readEdits->obj_yaw_relative[obj_idx] = false; + readEdits->obj_pitch_edited[obj_idx] = false; + readEdits->obj_pitch_relative[obj_idx] = false; +#endif } /* tokenize the line by comma */ @@ -207,6 +229,35 @@ ivas_error ObjectEditFileReader_readNextFrame( { readEdits->obj_ele_relative[obj_idx] = ( strcmp( paramValue, "1" ) == 0 ); } +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA + else if ( strcmp( param, "radius" ) == 0 ) + { + readEdits->obj_radius[obj_idx] = strtof( paramValue, NULL ); + readEdits->obj_radius_edited[obj_idx] = true; + } + else if ( strcmp( param, "yaw" ) == 0 ) + { + readEdits->obj_yaw[obj_idx] = strtof( paramValue, NULL ); + readEdits->obj_yaw_edited[obj_idx] = true; + } + else if ( strcmp( param, "pitch" ) == 0 ) + { + readEdits->obj_pitch[obj_idx] = strtof( paramValue, NULL ); + readEdits->obj_pitch_edited[obj_idx] = true; + } + else if ( strcmp( param, "relradius" ) == 0 ) + { + readEdits->obj_radius_relative[obj_idx] = ( strcmp( paramValue, "1" ) == 0 ); + } + else if ( strcmp( param, "relyaw" ) == 0 ) + { + readEdits->obj_yaw_relative[obj_idx] = ( strcmp( paramValue, "1" ) == 0 ); + } + else if ( strcmp( param, "relpitch" ) == 0 ) + { + readEdits->obj_pitch_relative[obj_idx] = ( strcmp( paramValue, "1" ) == 0 ); + } +#endif } } } @@ -230,6 +281,20 @@ ivas_error ObjectEditFileReader_readNextFrame( { readEdits->obj_ele[obj_idx] = max( min( readEdits->obj_ele[obj_idx], 90.f ), -90.f ); } +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA + if ( readEdits->obj_radius_edited[obj_idx] && !readEdits->obj_radius_relative[obj_idx] ) + { + readEdits->obj_radius[obj_idx] = max( min( readEdits->obj_radius[obj_idx], OBJ_EDIT_RADIUS_MAX ), 0.0f ); + } + if ( readEdits->obj_yaw_edited[obj_idx] && !readEdits->obj_yaw_relative[obj_idx] ) + { + readEdits->obj_yaw[obj_idx] = max( min( readEdits->obj_yaw[obj_idx], 180.f ), -180.f ); + } + if ( readEdits->obj_pitch_edited[obj_idx] && !readEdits->obj_pitch_relative[obj_idx] ) + { + readEdits->obj_pitch[obj_idx] = max( min( readEdits->obj_pitch[obj_idx], 90.f ), -90.f ); + } +#endif } } else diff --git a/lib_util/obj_edit_file_reader.h b/lib_util/obj_edit_file_reader.h index 4c3e4435f..ef83eb4c6 100644 --- a/lib_util/obj_edit_file_reader.h +++ b/lib_util/obj_edit_file_reader.h @@ -46,6 +46,11 @@ the United Nations Convention on Contracts on the International Sales of Goods. #define OBJ_EDIT_GAIN_MIN 0.06309573f /* -24 dB */ #define OBJ_EDIT_GAIN_MAX 3.9622325f /* +12 dB */ +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA +#define OBJ_EDIT_RADIUS_MAX 15.75f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ +#define OBJ_EDIT_RADIUS_MAX_FX 8452702364 /* Q29, 15.75f */ +#endif + typedef struct ObjectEditFileReader ObjectEditFileReader; typedef struct ReadObjectEditInfo ReadObjectEditInfo; @@ -65,6 +70,20 @@ struct ReadObjectEditInfo float obj_ele[IVAS_MAX_NUM_OBJECTS]; bool obj_ele_edited[IVAS_MAX_NUM_OBJECTS]; bool obj_ele_relative[IVAS_MAX_NUM_OBJECTS]; + +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA + float obj_radius[IVAS_MAX_NUM_OBJECTS]; + bool obj_radius_edited[IVAS_MAX_NUM_OBJECTS]; + bool obj_radius_relative[IVAS_MAX_NUM_OBJECTS]; + + float obj_yaw[IVAS_MAX_NUM_OBJECTS]; + bool obj_yaw_edited[IVAS_MAX_NUM_OBJECTS]; + bool obj_yaw_relative[IVAS_MAX_NUM_OBJECTS]; + + float obj_pitch[IVAS_MAX_NUM_OBJECTS]; + bool obj_pitch_edited[IVAS_MAX_NUM_OBJECTS]; + bool obj_pitch_relative[IVAS_MAX_NUM_OBJECTS]; +#endif }; struct ObjectEditFileReader -- GitLab From caffd92b97eecb6643dc4af5812a2857d33242a1 Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 6 Nov 2025 13:34:16 +0200 Subject: [PATCH 198/351] Clang format --- lib_dec/lib_dec_fx.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 1e1c6de94..33bf04141 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4319,7 +4319,7 @@ ivas_error IVAS_DEC_SetEditableParameters( st_ivas->hIsmMetaData[obj]->edited_pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; move32(); #ifdef FIX_GAIN_EDIT_LIMITS - IF ( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) { st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MAX_Q29; move32(); @@ -4340,7 +4340,7 @@ ivas_error IVAS_DEC_SetEditableParameters( IF( EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) { #ifdef FIX_GAIN_EDIT_LIMITS - IF ( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) { st_ivas->hSbaIsmData->gain_bed_fx = OBJ_EDIT_GAIN_MAX_Q29; move32(); @@ -4371,12 +4371,12 @@ ivas_error IVAS_DEC_SetEditableParameters( { #ifdef FIX_GAIN_EDIT_LIMITS /* Limit gain edit to a range of +12dB to -24dB with parametric ISM mode */ - IF ( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) { st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MAX_Q12; // Q12 move16(); } - ELSE IF ( LT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) + ELSE IF( LT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) { st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MIN_Q12; // Q12 move16(); @@ -4488,8 +4488,8 @@ ivas_error IVAS_DEC_SetEditableParameters( threshold_ele = delta_theta_masa_fx[st_ivas->hMasaIsmData->bits_ism[obj] - 3]; test(); - IF( ( GT_32( L_shl( abs_s( sub( new_azi, st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) || // | azi_edit[obj] - azi_orig[obj] | > azi_threshold - ( GT_32( L_shl( abs_s( sub( new_ele, st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) ) // | ele_edit[obj] - ele_orig[obj] | > ele_threshold + IF( ( GT_32( L_shl( abs_s( sub( new_azi, st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_azi ) ) || // | azi_edit[obj] - azi_orig[obj] | > azi_threshold + ( GT_32( L_shl( abs_s( sub( new_ele, st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ) ), 22 ), threshold_ele ) ) ) // | ele_edit[obj] - ele_orig[obj] | > ele_threshold { /* at least one of the threshold is exceeded, so use new direction value and set editing detection flag */ st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi; @@ -4509,8 +4509,8 @@ ivas_error IVAS_DEC_SetEditableParameters( { /* detect editing in ISM_MASA_MODE_DISC mode */ test(); - IF( L_abs( L_sub( st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ) > OMASA_AZI_EDIT_THR_Q22 || // | azi_orig[obj] - azi_edit[obj] | > azi_threshold - L_abs( L_sub( st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ) > OMASA_ELE_EDIT_THR_Q22 ) // | ele_orig[obj] - ele_edit[obj] | > ele_threshold + IF( L_abs( L_sub( st_ivas->hIsmMetaData[obj]->azimuth_fx, hIvasEditableParameters.ism_metadata[obj].azimuth_fx ) ) > OMASA_AZI_EDIT_THR_Q22 || // | azi_orig[obj] - azi_edit[obj] | > azi_threshold + L_abs( L_sub( st_ivas->hIsmMetaData[obj]->elevation_fx, hIvasEditableParameters.ism_metadata[obj].elevation_fx ) ) > OMASA_ELE_EDIT_THR_Q22 ) // | ele_orig[obj] - ele_edit[obj] | > ele_threshold { st_ivas->hMasaIsmData->azimuth_ism_edited_fx[obj] = new_azi; move32(); @@ -4527,18 +4527,18 @@ ivas_error IVAS_DEC_SetEditableParameters( } /* compare pre-edit gain and the edited one to detect editing */ - IF( GT_16( abs_s( sub( shr( extract_h( st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_edit[obj] - gain_orig[obj] | > gain_threshold + IF( GT_16( abs_s( sub( shr( extract_h( st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_edit[obj] - gain_orig[obj] | > gain_threshold { st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; #ifdef FIX_GAIN_EDIT_LIMITS /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */ test(); - IF ( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) { st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MAX_Q12; move16(); } - ELSE IF ( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MIN_Q29 )) + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) { st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MIN_Q12; move16(); @@ -4587,11 +4587,11 @@ ivas_error IVAS_DEC_SetEditableParameters( #endif #ifdef FIX_GAIN_EDIT_LIMITS test(); - IF ( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) { st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MAX_Q29; } - ELSE IF ( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) { st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MIN_Q29; } @@ -4608,17 +4608,17 @@ ivas_error IVAS_DEC_SetEditableParameters( } } - IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_bed - 1.0f | > gain_threshold + IF( GT_16( abs_s( sub( shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ), ONE_IN_Q12 ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_bed - 1.0f | > gain_threshold { #ifdef FIX_GAIN_EDIT_LIMITS /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */ test(); - IF ( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) { st_ivas->hMasaIsmData->gain_masa_edited_fx = OBJ_EDIT_GAIN_MAX_Q12; move16(); } - ELSE IF (EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MIN_Q29 )) + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) { st_ivas->hMasaIsmData->gain_masa_edited_fx = OBJ_EDIT_GAIN_MIN_Q12; move16(); -- GitLab From cff0f995072767722c445549d00f2e283f46c450 Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 6 Nov 2025 15:42:57 +0200 Subject: [PATCH 199/351] Align comments with float --- lib_com/ivas_cnst.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index bfe3e4dee..ac4866090 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -203,9 +203,9 @@ typedef enum #define MAX_CLDFB_DIGEST_CHANNELS 3 /* == maximum of ParamISM TCs and ParamMC TCs */ #ifdef FIX_GAIN_EDIT_LIMITS -#define OBJ_EDIT_GAIN_MIN_Q29 33874260 /* Minimum allowed object gain edit in Q29: 0.0630957f, -24 dB */ +#define OBJ_EDIT_GAIN_MIN_Q29 33874260 /* Minimum allowed object gain edit with parametric modes in Q29: 0.0630957f, -24 dB */ #define OBJ_EDIT_GAIN_MAX_Q29 2137321728 /* Maximum allowed object gain edit in Q29: 3.9810719f, +12 dB */ -#define OBJ_EDIT_GAIN_MIN_Q12 258 /* Minimum allowed object gain edit in Q12: 0.0630957f, -24 dB */ +#define OBJ_EDIT_GAIN_MIN_Q12 258 /* Minimum allowed object gain edit with parametric modes in Q12: 0.0630957f, -24 dB */ #define OBJ_EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ #endif -- GitLab From a26cfbe6d3680c2d97cddc8ac34dcb16fc8f30b2 Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 6 Nov 2025 15:57:20 +0200 Subject: [PATCH 200/351] Add missing code --- lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index f922513d5..1328b1465 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,6 +97,7 @@ #define FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE /* Eri/Orange: scale_sig32 problem on p_tc_fx[] */ #define FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO /* FhG: Make Q-factor of synth_16_fx and output_16_fx dynamic to prevent overflow in HQ_CORE mode */ +#define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7d3ee4ffd..e3131c740 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4033,6 +4033,9 @@ ivas_error IVAS_DEC_GetSamplesDecoder( move32(); hIsmMetaData[obj]->edited_radius_fx = hIsmMetaData[obj]->radius_fx; move32(); +#ifdef FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA + hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q29; +#endif } if ( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) -- GitLab From c5811e76dcd3c0e5aca13208d441a4229c874571 Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 6 Nov 2025 16:11:46 +0200 Subject: [PATCH 201/351] Add missing move() --- lib_dec/lib_dec_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e3131c740..ae2027e10 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4035,6 +4035,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( move32(); #ifdef FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA hIsmMetaData[obj]->edited_gain_fx = ONE_IN_Q29; + move32(); #endif } -- GitLab From bf144bd2ecad05032314e937341e6b3c1396637b Mon Sep 17 00:00:00 2001 From: lintervo Date: Thu, 6 Nov 2025 16:25:52 +0200 Subject: [PATCH 202/351] Add missing end of comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1328b1465..50c6dd6ea 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #define FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE /* Eri/Orange: scale_sig32 problem on p_tc_fx[] */ #define FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO /* FhG: Make Q-factor of synth_16_fx and output_16_fx dynamic to prevent overflow in HQ_CORE mode */ -#define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue +#define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ -- GitLab From ea7914163b6f578a8ffd81cea5b8534830436a15 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 6 Nov 2025 17:22:58 +0200 Subject: [PATCH 203/351] Add missing files to windows build --- Workspace_msvc/lib_dec.vcxproj | 2 +- Workspace_msvc/lib_util.vcxproj | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 9d98513e8..e93fc6c7c 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_basop;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + ..\lib_basop;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;..\lib_util;.%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 7b793cc4c..72dac3925 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -110,6 +110,11 @@ + + + + + @@ -137,6 +142,13 @@ + + + + + + + -- GitLab From 576c006b44637b4b78d2691a08e529ae74d2d1e7 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 6 Nov 2025 17:29:58 +0200 Subject: [PATCH 204/351] Clang format --- apps/decoder.c | 36 ++++++++++++++++++------------------ lib_dec/lib_dec_fx.c | 10 +++++----- lib_rend/ivas_rotation_fx.c | 2 +- lib_util/ivas_rtp_file.c | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 709e45961..c176e5be7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3388,28 +3388,28 @@ static ivas_error decodeVoIP( SplitFileReadWrite *splitRendWriter = NULL; #endif - if ( ( error = initOnFirstGoodFrame( hIvasDec, - arg, - numInitialBadFrames, - &nOutSamples, + if ( ( error = initOnFirstGoodFrame( hIvasDec, + arg, + numInitialBadFrames, + &nOutSamples, #ifdef FIX_1119_SPLIT_RENDERING_VOIP - &vec_pos_len, + &vec_pos_len, #else - NULL, -#endif - delayNumSamples_orig, - &delayNumSamples, - &delayTimeScale, - &bsFormat, - &afWriter, - &masaWriter, - ismWriters, - &nOutChannels, - &numObj, + NULL, +#endif + delayNumSamples_orig, + &delayNumSamples, + &delayTimeScale, + &bsFormat, + &afWriter, + &masaWriter, + ismWriters, + &nOutChannels, + &numObj, #ifdef IVAS_RTPDUMP - &srRtp, + &srRtp, #endif - &splitRendWriter ) ) != IVAS_ERR_OK ) + &splitRendWriter ) ) != IVAS_ERR_OK ) { goto cleanup; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9e64630f2..6c6700558 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6422,7 +6422,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #endif error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); } - BREAK; + BREAK; case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: { @@ -6432,7 +6432,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #endif error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); } - BREAK; + BREAK; #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_DIEGETIC_TYPE: @@ -6442,16 +6442,16 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #endif IVAS_DEC_setDiegeticInputPI( hIvasDec, piData->data.digeticIndicator.isDiegetic ); } - BREAK; + BREAK; #endif default: { /* NOT HANDLED PI DATA - DO NOTHING */ } - BREAK; + BREAK; } - IF( NE_32(error, IVAS_ERR_OK) ) + IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index b0f9e547e..b9762f72c 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1811,7 +1811,7 @@ ivas_error combine_external_and_head_orientations( /* Use the most recent head rotation */ IF( EQ_16( hExtOrientationData->enableHeadRotation[i], 1 ) ) { - IF( GT_16(hExtOrientationData->enableExternalOrientation[i], 0) ) + IF( GT_16( hExtOrientationData->enableExternalOrientation[i], 0 ) ) { QuaternionProduct_fx( hCombinedOrientationData->Quaternions[i], headRotQuaternions[i], &hCombinedOrientationData->Quaternions[i] ); } diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 91a63f598..82f198135 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -707,7 +707,7 @@ ivas_error IVAS_RTP_WRITER_Init( uint32_t SSRC, /* i : SSRC for RTP Header */ uint16_t seqNumInitVal /* i : Initial seq number in rtp header */ #else - uint32_t numFramesPerPacket /* i : No. of frames per packet desired */ + uint32_t numFramesPerPacket /* i : No. of frames per packet desired */ #endif ) { -- GitLab From e8f008ad07ca027a87fbe017203d5f6ff940e9c9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 6 Nov 2025 17:53:06 +0100 Subject: [PATCH 205/351] formatting --- lib_enc/ivas_init_enc_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index ec0fd03db..741a78dbc 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -144,6 +144,7 @@ void ivas_write_format_fx( return; } + /*-------------------------------------------------------------------* * ivas_write_format_sid() * @@ -230,6 +231,7 @@ void ivas_write_format_sid_fx( return; } + /*-------------------------------------------------------------------* * getNumChanAnalysis() * @@ -333,13 +335,13 @@ void copy_encoder_config_fx( st_fx->force_dir = st_ivas->hEncoderConfig->force_dir; #endif #endif - st_fx->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */ move16(); return; } + /*------------------------------------------------------------------------- * ivas_initialize_handles_enc_fx() * @@ -674,6 +676,7 @@ ivas_error ivas_init_encoder_fx( { return error; } + test(); IF( EQ_16( ivas_format, SBA_FORMAT ) && st_ivas->hEncoderConfig->Opt_DTX_ON ) { @@ -747,6 +750,7 @@ ivas_error ivas_init_encoder_fx( { return error; } + IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -853,6 +857,7 @@ ivas_error ivas_init_encoder_fx( return error; } } + IF( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { return error; -- GitLab From 0463d891a8a480d47feb6922b541fbaecabc2a70 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 6 Nov 2025 20:25:48 +0200 Subject: [PATCH 206/351] Port float MR 2105 to BASOP. --- apps/decoder.c | 56 +++++++++++++++++ lib_com/common_api_types.h | 10 ++++ lib_com/ivas_cnst.h | 15 +++++ lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 67 +++++++++++++++++++++ lib_dec/ivas_stat_dec.h | 3 + lib_dec/lib_dec.h | 3 + lib_dec/lib_dec_fx.c | 9 +++ lib_rend/ivas_prot_rend_fx.h | 7 +++ lib_rend/ivas_render_config_fx.c | 100 +++++++++++++++++++++++++++++++ lib_rend/ivas_rom_rend.h | 14 +++++ lib_rend/ivas_rom_rend_fx.c | 100 +++++++++++++++++++++++++++---- 12 files changed, 375 insertions(+), 10 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 94bfab14d..a3fa7595f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -129,6 +129,9 @@ typedef struct uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; bool objEditEnabled; char *objEditFileName; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + IVAS_ROOM_SIZE_T roomSize; +#endif } DecArguments; @@ -410,9 +413,15 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + 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.roomSize, 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.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain_fx, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -886,6 +895,10 @@ static bool parseCmdlIVAS_dec( arg->objEditEnabled = false; arg->objEditFileName = NULL; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + arg->roomSize = IVAS_ROOM_SIZE_AUTO; +#endif + /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -1360,6 +1373,45 @@ static bool parseCmdlIVAS_dec( } i++; } +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + else if ( strcmp( argv_to_upper, "-ROOM_SIZE" ) == 0 ) + { + i++; + if ( argc - i <= 3 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: Room size selector not specified!\n\n" ); + usage_dec(); + return false; + } + + if ( strlen( argv[i] ) != 1 ) + { + fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", argv[i] ); + usage_dec(); + return false; + } + switch ( argv[i][0] ) + { + case 'S': + case 's': + arg->roomSize = IVAS_ROOM_SIZE_SMALL; + break; + case 'M': + case 'm': + arg->roomSize = IVAS_ROOM_SIZE_MEDIUM; + break; + case 'L': + case 'l': + arg->roomSize = IVAS_ROOM_SIZE_LARGE; + break; + default: + fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", argv[i] ); + usage_dec(); + return false; + } + i++; + } +#endif /*-----------------------------------------------------------------* * Option not recognized @@ -1565,6 +1617,10 @@ static void usage_dec( void ) fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); + fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); +#endif fprintf( stdout, "-q : Quiet mode, no frame counter\n" ); fprintf( stdout, " default is deactivated\n" ); fprintf( stdout, "\n" ); diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 6259b5f8d..be4f532ab 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -189,6 +189,16 @@ typedef enum } IVAS_RENDER_FRAMESIZE; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +typedef enum +{ + IVAS_ROOM_SIZE_AUTO = -1, + IVAS_ROOM_SIZE_SMALL, + IVAS_ROOM_SIZE_MEDIUM, + IVAS_ROOM_SIZE_LARGE +} IVAS_ROOM_SIZE_T; +#endif + typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; typedef struct ivas_masa_decoder_ext_out_meta_struct *IVAS_MASA_DECODER_EXT_OUT_META_HANDLE; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index c445d0299..790139882 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1648,11 +1648,26 @@ typedef enum #define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1 #define RV_LENGTH_NR_FC_16KHZ ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1 +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +#define IVAS_REVERB_DEFAULT_L_N_BANDS 31 +#define IVAS_REVERB_DEFAULT_M_N_BANDS 31 +#define IVAS_REVERB_DEFAULT_S_N_BANDS 60 +#else #define IVAS_REVERB_DEFAULT_N_BANDS 31 +#endif #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +typedef enum +{ + DEFAULT_REVERB_SMALL, + DEFAULT_REVERB_MEDIUM, + DEFAULT_REVERB_LARGE +} IVAS_DefaultReverbSize; +#endif + /*----------------------------------------------------------------------------------* * FB mixer constants diff --git a/lib_com/options.h b/lib_com/options.h index f792698a9..a3548f68c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -139,6 +139,7 @@ #define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */ #define NONBE_1344_REND_MASA_LOW_FS /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */ #define NONBE_1412_AVOID_ROUNDING_AZ_ELEV /* FhG: Avoid rounding when passing azimuth and elevation to efap_determine_gains() */ +#define FIX_1318_ROOM_SIZE_CMD_LINE /* Philips/Nokia: Default room sizes support */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index dff92f4e4..7a31eb5d5 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1665,16 +1665,83 @@ ivas_error ivas_init_decoder_fx( } } +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + /*--------------------------------------------------------------------------* + * Allocate and initialize HRTF Statistics handle, get default reverb values + *--------------------------------------------------------------------------*/ +#else /*--------------------------------------------------------------------* * Allocate and initialize HRTF Statistics handle *--------------------------------------------------------------------*/ +#endif IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { + /* Init HRTF statistics */ IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } + + #ifdef FIX_1318_ROOM_SIZE_CMD_LINE + /* Get default reverb values based on format, if custom values were not given */ + IF( EQ_16(st_ivas->hDecoderConfig->Opt_RendConfigCustom, 0) ) + { + IVAS_DefaultReverbSize defaultReverbSize; + SWITCH( st_ivas->hDecoderConfig->Opt_RoomSize ) + { + case IVAS_ROOM_SIZE_AUTO: + SWITCH( st_ivas->ivas_format ) + { + case ISM_FORMAT: + defaultReverbSize = DEFAULT_REVERB_LARGE; + move32(); + BREAK; + case SBA_FORMAT: + defaultReverbSize = DEFAULT_REVERB_SMALL; + move32(); + BREAK; + case MASA_FORMAT: + defaultReverbSize = DEFAULT_REVERB_SMALL; + move32(); + BREAK; + case MC_FORMAT: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + move32(); + BREAK; + case MASA_ISM_FORMAT: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + move32(); + BREAK; + case SBA_ISM_FORMAT: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + move32(); + BREAK; + default: + defaultReverbSize = DEFAULT_REVERB_LARGE; + move32(); + } + BREAK; + case IVAS_ROOM_SIZE_SMALL: + defaultReverbSize = DEFAULT_REVERB_SMALL; + move32(); + BREAK; + case IVAS_ROOM_SIZE_MEDIUM: + defaultReverbSize = DEFAULT_REVERB_MEDIUM; + move32(); + BREAK; + case IVAS_ROOM_SIZE_LARGE: + default: + defaultReverbSize = DEFAULT_REVERB_LARGE; + move32(); + BREAK; + } + if ( NE_32( error = ivas_render_config_change_defaults( st_ivas->hRenderConfig, defaultReverbSize ), IVAS_ERR_OK ) ) + { + return error; + } + } +#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4a464705d..c4e52f8bf 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1086,6 +1086,9 @@ typedef struct decoder_config_structure Word16 Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ Word16 Opt_Headrotation; /* indicates whether head-rotation is used */ Word16 Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + IVAS_ROOM_SIZE_T Opt_RoomSize; /* Selected room size */ +#endif IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ Word16 Opt_non_diegetic_pan; /* indicates diegetic or not */ Word16 non_diegetic_pan_gain_fx; /* non diegetic panning gain, Q15 */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index e911a5fca..2bf376d65 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -118,6 +118,9 @@ ivas_error IVAS_DEC_Configure( const bool enableExternalOrientation, /* i : enable external orientations */ const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */ +#endif const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7d3ee4ffd..572464eef 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -359,6 +359,9 @@ static void init_decoder_config( hDecoderConfig->Opt_HRTF_binary = 0; hDecoderConfig->Opt_Headrotation = 0; hDecoderConfig->Opt_RendConfigCustom = 0; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + hDecoderConfig->Opt_RoomSize = IVAS_ROOM_SIZE_AUTO; +#endif hDecoderConfig->orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; hDecoderConfig->Opt_non_diegetic_pan = 0; hDecoderConfig->non_diegetic_pan_gain_fx = 0; // Q15 @@ -517,6 +520,9 @@ ivas_error IVAS_DEC_Configure( const bool enableExternalOrientation, /* i : enable external orientations */ const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */ +#endif const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ @@ -585,6 +591,9 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->orientation_tracking = orientation_tracking; hDecoderConfig->Opt_HRTF_binary = (Word16) hrtfReaderEnabled; hDecoderConfig->Opt_RendConfigCustom = (Word16) renderConfigEnabled; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + hDecoderConfig->Opt_RoomSize = roomSize; +#endif hDecoderConfig->Opt_non_diegetic_pan = (Word16) non_diegetic_pan_enabled; hDecoderConfig->non_diegetic_pan_gain_fx = non_diegetic_pan_gain_fx; // Q15 hDecoderConfig->Opt_delay_comp = (Word16) delayCompensationEnabled; diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 86586520e..9dce43a97 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1347,6 +1347,13 @@ ivas_error ivas_render_config_init_from_rom_fx( RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ ); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +ivas_error ivas_render_config_change_defaults( + RENDER_CONFIG_HANDLE hRenderConfig, /* i/o: Renderer config handle */ + IVAS_DefaultReverbSize reverbDefault /* i: Reverb default size */ +); + +#endif /*----------------------------------------------------------------------------------* * Quaternion operations diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 3c43b59e1..780908c71 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -42,8 +42,19 @@ * Local constants *-----------------------------------------------------------------------*/ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +#define IVAS_REVERB_DEFAULT_L_PRE_DELAY_FX 2147484 // 0.016 +#define IVAS_REVERB_DEFAULT_L_INPUT_DELAY_FX 13421773 // 0.1 + +#define IVAS_REVERB_DEFAULT_S_PRE_DELAY_FX 1677722 // 0.0125f +#define IVAS_REVERB_DEFAULT_S_INPUT_DELAY_FX 0 // 0.0f + +#define IVAS_REVERB_DEFAULT_M_PRE_DELAY_FX 1677722 // 0.0125f +#define IVAS_REVERB_DEFAULT_M_INPUT_DELAY_FX 0 // 0.0f +#else #define IVAS_REVERB_DEFAULT_PRE_DELAY_FX 2147484 // 0.016 #define IVAS_REVERB_DEFAULT_INPUT_DELAY_FX 13421773 // 0.1 +#endif #define IVAS_REVERB_DEFAULT_USE_ER 0 @@ -107,21 +118,36 @@ ivas_error ivas_render_config_init_from_rom_fx( { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); } +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_L_N_BANDS; + move16(); + ( *hRenderConfig )->roomAcoustics.acousticPreDelay_fx = IVAS_REVERB_DEFAULT_L_PRE_DELAY_FX; + move32(); + ( *hRenderConfig )->roomAcoustics.inputPreDelay_fx = IVAS_REVERB_DEFAULT_L_INPUT_DELAY_FX; + move32(); +#else ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; move16(); ( *hRenderConfig )->roomAcoustics.acousticPreDelay_fx = IVAS_REVERB_DEFAULT_PRE_DELAY_FX; move32(); ( *hRenderConfig )->roomAcoustics.inputPreDelay_fx = IVAS_REVERB_DEFAULT_INPUT_DELAY_FX; move32(); +#endif ( *hRenderConfig )->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; move16(); set32_fx( &( *hRenderConfig )->roomAcoustics.pFc_input_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( &( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( &( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx[0], 0, CLDFB_NO_CHANNELS_MAX ); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + Copy32( ivas_reverb_default_large_fc_fx, ( *hRenderConfig )->roomAcoustics.pFc_input_fx, IVAS_REVERB_DEFAULT_L_N_BANDS ); + Copy32( ivas_reverb_default_large_RT60_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_L_N_BANDS ); + Copy32( ivas_reverb_default_large_DSR_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_L_N_BANDS ); +#else Copy32( ivas_reverb_default_fc_fx, ( *hRenderConfig )->roomAcoustics.pFc_input_fx, IVAS_REVERB_DEFAULT_N_BANDS ); Copy32( ivas_reverb_default_RT60_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_N_BANDS ); Copy32( ivas_reverb_default_DSR_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_N_BANDS ); +#endif FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) { @@ -161,3 +187,77 @@ ivas_error ivas_render_config_init_from_rom_fx( return IVAS_ERR_OK; } + +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + +/*-------------------------------------------------------------------* + * ivas_render_config_change_defaults() + * + * Changes default values from ROM + *-------------------------------------------------------------------*/ + +ivas_error ivas_render_config_change_defaults( + RENDER_CONFIG_HANDLE hRenderConfig, /* i/o: Renderer config handle */ + IVAS_DefaultReverbSize defaultReverbSize /* i: Reverb default size */ +) +{ + SWITCH( defaultReverbSize ) + { + case DEFAULT_REVERB_SMALL: + hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_S_N_BANDS; + move16(); + hRenderConfig->roomAcoustics.acousticPreDelay_fx = IVAS_REVERB_DEFAULT_S_PRE_DELAY_FX; + move32(); + hRenderConfig->roomAcoustics.inputPreDelay_fx = IVAS_REVERB_DEFAULT_S_INPUT_DELAY_FX; + move32(); + hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; + move16(); + set_zero_fx( &hRenderConfig->roomAcoustics.pFc_input_fx[0], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( &hRenderConfig->roomAcoustics.pAcoustic_rt60_fx[0], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( &hRenderConfig->roomAcoustics.pAcoustic_dsr_fx[0], CLDFB_NO_CHANNELS_MAX ); + + Copy32( ivas_reverb_default_small_fc_fx, hRenderConfig->roomAcoustics.pFc_input_fx, IVAS_REVERB_DEFAULT_S_N_BANDS ); + Copy32( ivas_reverb_default_small_RT60_fx, hRenderConfig->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_S_N_BANDS ); + Copy32( ivas_reverb_default_small_DSR_fx, hRenderConfig->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_S_N_BANDS ); + BREAK; + case DEFAULT_REVERB_MEDIUM: + hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_M_N_BANDS; + move16(); + hRenderConfig->roomAcoustics.acousticPreDelay_fx = IVAS_REVERB_DEFAULT_M_PRE_DELAY_FX; + move32(); + hRenderConfig->roomAcoustics.inputPreDelay_fx = IVAS_REVERB_DEFAULT_M_INPUT_DELAY_FX; + move32(); + hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; + move16(); + set_zero_fx( &hRenderConfig->roomAcoustics.pFc_input_fx[0], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( &hRenderConfig->roomAcoustics.pAcoustic_rt60_fx[0], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( &hRenderConfig->roomAcoustics.pAcoustic_dsr_fx[0], CLDFB_NO_CHANNELS_MAX ); + + Copy32( ivas_reverb_default_medium_fc_fx, hRenderConfig->roomAcoustics.pFc_input_fx, IVAS_REVERB_DEFAULT_M_N_BANDS ); + Copy32( ivas_reverb_default_medium_RT60_fx, hRenderConfig->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_M_N_BANDS ); + Copy32( ivas_reverb_default_medium_DSR_fx, hRenderConfig->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_M_N_BANDS ); + BREAK; + case DEFAULT_REVERB_LARGE: + hRenderConfig->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_L_N_BANDS; + move16(); + hRenderConfig->roomAcoustics.acousticPreDelay_fx = IVAS_REVERB_DEFAULT_L_PRE_DELAY_FX; + move32(); + hRenderConfig->roomAcoustics.inputPreDelay_fx = IVAS_REVERB_DEFAULT_L_INPUT_DELAY_FX; + move32(); + hRenderConfig->roomAcoustics.use_er = IVAS_REVERB_DEFAULT_USE_ER; + move16(); + set_zero_fx( &hRenderConfig->roomAcoustics.pFc_input_fx[0], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( &hRenderConfig->roomAcoustics.pAcoustic_rt60_fx[0], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( &hRenderConfig->roomAcoustics.pAcoustic_dsr_fx[0], CLDFB_NO_CHANNELS_MAX ); + + Copy32( ivas_reverb_default_large_fc_fx, hRenderConfig->roomAcoustics.pFc_input_fx, IVAS_REVERB_DEFAULT_L_N_BANDS ); + Copy32( ivas_reverb_default_large_RT60_fx, hRenderConfig->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_L_N_BANDS ); + Copy32( ivas_reverb_default_large_DSR_fx, hRenderConfig->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_L_N_BANDS ); + BREAK; + default: + return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; + } + + return IVAS_ERR_OK; +} +#endif diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 5b0f33864..916cd5145 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -107,9 +107,23 @@ extern const Word32 t_design_11_elevation_int[70]; /*Q-22*/ * Reverberator ROM tables *-----------------------------------------------------------------------*/ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +extern const Word32 ivas_reverb_default_small_fc_fx[]; /*Q-16*/ +extern const Word32 ivas_reverb_default_small_RT60_fx[]; /*Q-26*/ +extern const Word32 ivas_reverb_default_small_DSR_fx[]; /*Q-30*/ + +extern const Word32 ivas_reverb_default_medium_fc_fx[]; /*Q-16*/ +extern const Word32 ivas_reverb_default_medium_RT60_fx[]; /*Q-26*/ +extern const Word32 ivas_reverb_default_medium_DSR_fx[]; /*Q-30*/ + +extern const Word32 ivas_reverb_default_large_fc_fx[]; /*Q-16*/ +extern const Word32 ivas_reverb_default_large_RT60_fx[]; /*Q-26*/ +extern const Word32 ivas_reverb_default_large_DSR_fx[]; /*Q-30*/ +#else extern const Word32 ivas_reverb_default_fc_fx[]; /*Q-16*/ extern const Word32 ivas_reverb_default_RT60_fx[]; /*Q-26*/ extern const Word32 ivas_reverb_default_DSR_fx[]; /*Q-30*/ +#endif /*----------------------------------------------------------------------------------* * EFAP ROM tables diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index f3f034c4d..4c7f0c3d6 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -252,20 +252,96 @@ const Word32 t_design_11_elevation_int[70] = //Q22 * Reverberator ROM tables *-----------------------------------------------------------------------*/ -const Word32 ivas_reverb_default_fc_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q16*/ = +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +const Word32 ivas_reverb_default_small_fc_fx[IVAS_REVERB_DEFAULT_S_N_BANDS] = { - 1310720 , 1638400 , 2064384 , 2621440 , 3276800 , - 4128768 , 5242880 , 6553600 , 8192000 , - 10485760 , 13107200 , 16384000 , 20643840 , - 26214400 , 32768000 , 41287680 , 52428800 , - 65536000 , 81920000 , 104857600 , 131072000 , - 163840000 , 206438400 , 262144000 , 327680000 , - 412876800 , 524288000 , 655360000 , 819200000 , - 1048576000 , 1310720000 + 13107200, 39321600, 65536000, 91750400, 117964800, 144179200, 170393600, 196608000, 222822400, 249036800, + 275251200, 301465600, 327680000, 353894400, 380108800, 406323200, 432537600, 458752000, 484966400, 511180800, + 537395200, 563609600, 589824000, 616038400, 642252800, 668467200, 694681600, 720896000, 747110400, 773324800, + 799539200, 825753600, 851968000, 878182400, 904396800, 930611200, 956825600, 983040000, 1009254400, 1035468800, + 1061683200, 1087897600, 1114112000, 1140326400, 1166540800, 1192755200, 1218969600, 1245184000, 1271398400, 1297612800, + 1323827200, 1350041600, 1376256000, 1402470400, 1428684800, 1454899200, 1481113600, 1507328000, 1533542400, 1559756800 }; -const Word32 ivas_reverb_default_RT60_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q26*/ = +const Word32 ivas_reverb_default_small_RT60_fx[IVAS_REVERB_DEFAULT_S_N_BANDS] = +{ + 20132660, 18371052, 17846998, 17702244, 17822236, 17568430, 16977738, 16495426, 15933590, 15312162, + 14732812, 14167755, 13640682, 13163001, 12694380, 12243073, 11827065, 11416157, 11022631, 10656284, + 10291077, 9953050, 9614419, 9287733, 8987823, 8690128, 8409345, 8176074, 7940388, 7726244, + 7560149, 7379157, 7211854, 7067302, 6912616, 6763433, 6618880, 6473925, 6330715, 6188578, + 6047516, 5909405, 5773644, 5641238, 5524872, 5405753, 5293279, 5208588, 5113897, 5027662, + 4972901, 4903511, 4842106, 4808954, 4762649, 4743657, 4712653, 4689433, 4693326, 4685541 +}; + +const Word32 ivas_reverb_default_small_DSR_fx[IVAS_REVERB_DEFAULT_S_N_BANDS] = +{ + 16773, 7628, 5046, 4620, 5666, 6853, 7771, 9876, 11530, 12337, + 11421, 10287, 8791, 7565, 6305, 5215, 4504, 3860, 3627, 4363, + 5246, 6739, 8151, 9611, 10088, 10416, 10154, 9187, 8628, 8012, + 7491, 6931, 6320, 6074, 5589, 5145, 4977, 4646, 4558, 4411, + 4331, 4253, 4147, 4018, 3821, 3629, 3428, 3361, 3361, 3361, + 3361, 3361, 3361, 3361, 3361, 3361, 3361, 3361, 3361, 3361 +}; + +const Word32 ivas_reverb_default_medium_fc_fx[IVAS_REVERB_DEFAULT_M_N_BANDS] = +{ + 1310720, 1638400, 2064384, 2621440, 3276800, + 4128768, 5242880, 6553600, 8192000, + 10485760, 13107200, 16384000, 20643840, + 26214400, 32768000, 41287680, 52428800, + 65536000, 81920000, 104857600, 131072000, + 163840000, 206438400, 262144000, 327680000, + 412876800, 524288000, 655360000, 819200000, + 1048576000, 1310720000 +}; + +const Word32 ivas_reverb_default_medium_RT60_fx[IVAS_REVERB_DEFAULT_M_N_BANDS] = +{ + 14763950, 15099494, 15535702, 16106127, + 16777216, 17649632, 18790482, 20132660, + 21810380, 24159192, 26843546, 26591888, + 26264732, 25836912, 25333596, 24785364, + 24530840, 24231400, 24127968, 24134494, + 24058024, 23406682, 22445968, 21003330, + 19424124, 17708016, 15804674, 13936498, + 12319828, 10826874, 9549390 +}; + +const Word32 ivas_reverb_default_medium_DSR_fx[IVAS_REVERB_DEFAULT_M_N_BANDS] = { + 15978, 16341, 16813, 17430, + 18156, 19101, 20335, 21788, + 23603, 26145, 29050, 27037, + 24421, 20999, 16973, 12614, + 10726, 8506, 8047, 8659, + 10526, 12575, 17260, 19074, + 13653, 7464, 6609, 12688, + 7607, 3835, 2373 +}; +#endif + +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +const Word32 ivas_reverb_default_large_fc_fx[IVAS_REVERB_DEFAULT_L_N_BANDS] /*Q16*/ = +#else +const Word32 ivas_reverb_default_fc_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q16*/ = +#endif +{ + 1310720, 1638400, 2064384, 2621440, 3276800, + 4128768, 5242880, 6553600, 8192000, + 10485760, 13107200, 16384000, 20643840, + 26214400, 32768000, 41287680, 52428800, + 65536000, 81920000, 104857600, 131072000, + 163840000, 206438400, 262144000, 327680000, + 412876800, 524288000, 655360000, 819200000, + 1048576000, 1310720000 +}; + +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +const Word32 ivas_reverb_default_large_RT60_fx[IVAS_REVERB_DEFAULT_L_N_BANDS] /*Q26*/ = +#else +const Word32 ivas_reverb_default_RT60_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q26*/ = +#endif + { 91415696, 97213904, 88368952, 105944760, 99092952, 93643712, 86496616, 90341952, 72202424, 69799928, 73618424, 72813120, @@ -276,7 +352,11 @@ const Word32 ivas_reverb_default_RT60_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q26*/ = 48281472, 41394088, 40286124 }; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +const Word32 ivas_reverb_default_large_DSR_fx[IVAS_REVERB_DEFAULT_L_N_BANDS] /*Q30*/ = +#else const Word32 ivas_reverb_default_DSR_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q30*/ = +#endif { 20, 23, 15, 16, 13, 20, 25, 42, -- GitLab From 30190e4633128dcd69a3e43c881cb0258340e12e Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 6 Nov 2025 20:33:20 +0200 Subject: [PATCH 207/351] Fix BASOP --- lib_dec/ivas_init_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 7a31eb5d5..634b31891 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1683,7 +1683,7 @@ ivas_error ivas_init_decoder_fx( return error; } - #ifdef FIX_1318_ROOM_SIZE_CMD_LINE +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE /* Get default reverb values based on format, if custom values were not given */ IF( EQ_16(st_ivas->hDecoderConfig->Opt_RendConfigCustom, 0) ) { @@ -1736,7 +1736,7 @@ ivas_error ivas_init_decoder_fx( move32(); BREAK; } - if ( NE_32( error = ivas_render_config_change_defaults( st_ivas->hRenderConfig, defaultReverbSize ), IVAS_ERR_OK ) ) + IF( NE_32( error = ivas_render_config_change_defaults( st_ivas->hRenderConfig, defaultReverbSize ), IVAS_ERR_OK ) ) { return error; } -- GitLab From 36b3f818b7a1456f9c792d502676aeeaae1437af Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 6 Nov 2025 20:06:48 +0100 Subject: [PATCH 208/351] port changes from MR 2358 to basop --- Makefile | 2 +- apps/ambi_converter.c | 4 ++-- readme.txt | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4febdc988..6153e1cb4 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,7 @@ DEPS = $(addprefix $(OBJDIR)/,$(SRCS_LIBBASOP:.c=.P) $(SRCS_LIBCOM:.c=.P) $(SRCS .PHONY: all clean -all: $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) +all: $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(CLI_AMBICONVERT) $(OBJDIR): $(QUIET)mkdir -p $(OBJDIR) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index 76619c904..895b7c0e6 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -78,8 +78,8 @@ int main( int argc, char *argv[] ) if ( argc != 5 ) { printf( "----------------------------------------------------------------------------------\n" ); - printf( "Usage:\n" ); - printf( "./ambi_converter input_file output_file input_convention output_convention\n" ); + printf( "\n" ); + printf( "Usage: ambi_converter input_file output_file input_convention output_convention\n" ); printf( "\n" ); printf( "input_convention and output convention must be an integer number in [0,5]\n" ); printf( "the following conventions are supported:\n" ); diff --git a/readme.txt b/readme.txt index 391e0a35f..d272f7a8c 100644 --- a/readme.txt +++ b/readme.txt @@ -33,12 +33,13 @@ These files represent the 3GPP EVS Codec Extension for Immersive Voice and Audio Services (IVAS) BASOP C simulation. All code is writtten -in ISO/IEC C99. The system is implemented as four separate programs: +in ISO/IEC C99. The system is implemented as five separate programs: IVAS_cod IVAS Encoder IVAS_dec IVAS Decoder IVAS_rend IVAS External Renderer ISAR_post_rend ISAR Post Renderer + ambi_converter Ambisonics format converter For encoding using the coder program, the input is a binary audio file (*.8k, *.16k, *.32k, *.48k) and the output is a binary @@ -376,6 +377,23 @@ Options: -prbfi File : BFI File +The usage of the "ambi_converter" program: +------------------------------------------ + +Usage: ambi_converter input_file output_file input_convention output_convention + +input_convention and output convention must be an integer number in [0,5] +the following conventions are supported: +0 : ACN-SN3D +1 : ACN-N3D +2 : FuMa-MaxN +3 : FuMa-FuMa +4 : SID-SN3D +5 : SID-N3D + +Either the input or the output convention must always be ACN-SN3D! + + MULTICHANNEL LOUDSPEAKER INPUT / OUTPUT CONFIGURATIONS ====================================================== The loudspeaker positions for each MC layouts are assumed to have the following azimuth and elevation -- GitLab From 8a8af21b06ca5bf70d6ca774d1e1091b0f553ca8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 6 Nov 2025 21:16:31 +0100 Subject: [PATCH 209/351] add missing dependencies --- Makefile | 2 +- apps/ambi_converter.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6153e1cb4..3edbe9ca7 100644 --- a/Makefile +++ b/Makefile @@ -227,7 +227,7 @@ $(CLI_APIPOSTREND): $(OBJS_CLI_APPPOSTREND) $(LIB_LIBBASOP) $(LIB_LIBISAR) $(LIB $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPPOSTREND) -L. -livasbasop -lisar -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIPOSTREND) $(CLI_AMBICONVERT): $(OBJS_CLI_AMBICONVERT) $(OBJS_AMBICONVERT) $(LIB_LIBBASOP) $(LIB_LIBCOM) - $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_AMBICONVERT) $(OBJS_AMBICONVERT) -L. -livascom -livasbasop $(LDLIBS) -o $(CLI_AMBICONVERT) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_AMBICONVERT) $(OBJS_AMBICONVERT) -L. -livascom -livasbasop -livasdebug $(LDLIBS) -o $(CLI_AMBICONVERT) libs: $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(LIB_LIBUTIL) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index 895b7c0e6..816f96619 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -35,6 +35,7 @@ #include "../lib_util/tinywavein_c.h" #include "../lib_util/tinywaveout_c.h" #include "ambi_convert.h" +#include "wmc_auto.h" /*-------------------------------------------------------------------------------------* * Ambisonics converter program -- GitLab From bf2d1cee11adada2368edb1f48cf6241da4ffdb4 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 7 Nov 2025 11:26:51 +0200 Subject: [PATCH 210/351] Apply clang format partially. --- lib_dec/ivas_init_dec_fx.c | 4 ++-- lib_dec/ivas_stat_dec.h | 18 +++++++++--------- lib_dec/lib_dec_fx.c | 12 ++++++------ lib_rend/ivas_rom_rend.h | 12 ++++++------ 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 634b31891..daf16a208 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1667,8 +1667,8 @@ ivas_error ivas_init_decoder_fx( #ifdef FIX_1318_ROOM_SIZE_CMD_LINE /*--------------------------------------------------------------------------* - * Allocate and initialize HRTF Statistics handle, get default reverb values - *--------------------------------------------------------------------------*/ + * Allocate and initialize HRTF Statistics handle, get default reverb values + *--------------------------------------------------------------------------*/ #else /*--------------------------------------------------------------------* * Allocate and initialize HRTF Statistics handle diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index c4e52f8bf..a10d55094 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1077,15 +1077,15 @@ typedef struct jbm_metadata_structure typedef struct decoder_config_structure { - Word32 ivas_total_brate; /* IVAS total bitrate in bps */ - Word32 last_ivas_total_brate; /* last IVAS total bitrate in bps */ - Word32 output_Fs; /* output signal sampling frequency in Hz */ - Word16 nchan_out; /* number of output audio channels */ - AUDIO_CONFIG output_config; /* output audio configuration */ - Word16 Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ - Word16 Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ - Word16 Opt_Headrotation; /* indicates whether head-rotation is used */ - Word16 Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ + Word32 ivas_total_brate; /* IVAS total bitrate in bps */ + Word32 last_ivas_total_brate; /* last IVAS total bitrate in bps */ + Word32 output_Fs; /* output signal sampling frequency in Hz */ + Word16 nchan_out; /* number of output audio channels */ + AUDIO_CONFIG output_config; /* output audio configuration */ + Word16 Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ + Word16 Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ + Word16 Opt_Headrotation; /* indicates whether head-rotation is used */ + Word16 Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ #ifdef FIX_1318_ROOM_SIZE_CMD_LINE IVAS_ROOM_SIZE_T Opt_RoomSize; /* Selected room size */ #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 572464eef..db08a7d26 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -523,12 +523,12 @@ ivas_error IVAS_DEC_Configure( #ifdef FIX_1318_ROOM_SIZE_CMD_LINE const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */ #endif - const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ - const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ - const bool dpidEnabled, /* i : enable directivity pattern option */ - const UWord16 acousticEnvironmentId, /* i : Acoustic environment ID */ - const bool objEditEnabled, /* i : enable object editing */ - const bool delayCompensationEnabled /* i : enable delay compensation */ + const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ + const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ + const bool dpidEnabled, /* i : enable directivity pattern option */ + const UWord16 acousticEnvironmentId, /* i : Acoustic environment ID */ + const bool objEditEnabled, /* i : enable object editing */ + const bool delayCompensationEnabled /* i : enable delay compensation */ ) { Decoder_Struct *st_ivas; diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 916cd5145..121f019df 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -108,17 +108,17 @@ extern const Word32 t_design_11_elevation_int[70]; /*Q-22*/ *-----------------------------------------------------------------------*/ #ifdef FIX_1318_ROOM_SIZE_CMD_LINE -extern const Word32 ivas_reverb_default_small_fc_fx[]; /*Q-16*/ -extern const Word32 ivas_reverb_default_small_RT60_fx[]; /*Q-26*/ -extern const Word32 ivas_reverb_default_small_DSR_fx[]; /*Q-30*/ +extern const Word32 ivas_reverb_default_small_fc_fx[]; /*Q-16*/ +extern const Word32 ivas_reverb_default_small_RT60_fx[]; /*Q-26*/ +extern const Word32 ivas_reverb_default_small_DSR_fx[]; /*Q-30*/ extern const Word32 ivas_reverb_default_medium_fc_fx[]; /*Q-16*/ extern const Word32 ivas_reverb_default_medium_RT60_fx[]; /*Q-26*/ extern const Word32 ivas_reverb_default_medium_DSR_fx[]; /*Q-30*/ -extern const Word32 ivas_reverb_default_large_fc_fx[]; /*Q-16*/ -extern const Word32 ivas_reverb_default_large_RT60_fx[]; /*Q-26*/ -extern const Word32 ivas_reverb_default_large_DSR_fx[]; /*Q-30*/ +extern const Word32 ivas_reverb_default_large_fc_fx[]; /*Q-16*/ +extern const Word32 ivas_reverb_default_large_RT60_fx[]; /*Q-26*/ +extern const Word32 ivas_reverb_default_large_DSR_fx[]; /*Q-30*/ #else extern const Word32 ivas_reverb_default_fc_fx[]; /*Q-16*/ extern const Word32 ivas_reverb_default_RT60_fx[]; /*Q-26*/ -- GitLab From 9a82740cd2d27a2d94bce61103bc352c603f7e04 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 7 Nov 2025 11:39:34 +0200 Subject: [PATCH 211/351] Add clang format off to a critical section. --- lib_dec/ivas_init_dec_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index daf16a208..a376b78e3 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1666,6 +1666,9 @@ ivas_error ivas_init_decoder_fx( } #ifdef FIX_1318_ROOM_SIZE_CMD_LINE +// clang-format off + /* This section is correctly formatted but clang-format in CI messes this up. Can probably be removed with accepted switches */ + /*--------------------------------------------------------------------------* * Allocate and initialize HRTF Statistics handle, get default reverb values *--------------------------------------------------------------------------*/ @@ -1741,6 +1744,7 @@ ivas_error ivas_init_decoder_fx( return error; } } +// clang-format on #endif } -- GitLab From 7cb13e43e20fcde3fb7705b33b7b2c0bbed20726 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 7 Nov 2025 10:49:11 +0100 Subject: [PATCH 212/351] Porting floating-point MR 2298, prototype --- apps/decoder.c | 70 +++++- lib_com/common_api_types.h | 3 + lib_com/ivas_cnst.h | 3 + lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 9 + lib_dec/ivas_stat_dec.h | 5 + lib_dec/lib_dec.h | 13 ++ lib_dec/lib_dec_fx.c | 364 +++++++++++++++++++++++++++++++ lib_rend/ivas_render_config_fx.c | 4 + lib_rend/lib_rend_fx.c | 8 + lib_util/ivas_rtp_file.c | 8 + lib_util/ivas_rtp_pi_data.c | 26 +++ lib_util/ivas_rtp_pi_data.h | 20 ++ lib_util/render_config_reader.c | 102 ++++++++- lib_util/render_config_reader.h | 13 ++ 15 files changed, 647 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index c176e5be7..9d8f1ad35 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -55,6 +55,9 @@ #ifdef IVAS_RTPDUMP #include "ivas_rtp_file.h" #endif +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#include "ivas_cnst.h" +#endif #ifdef FIXED_RTP_SEQUENCE_NUM #define RANDOM_INITSEED_DEC ( 0xFEEDFADE ) @@ -208,7 +211,10 @@ int main( IVAS_RENDER_FRAMESIZE asked_frame_size; IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary; ObjectEditFileReader *objectEditFileReader = NULL; - +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + IVAS_ROOM_ACOUSTICS_CONFIG_DATA **pAE = NULL; + uint32_t aeCount = 0; +#endif #ifdef WMOPS reset_wmops(); reset_mem( USE_BYTES ); @@ -419,7 +425,11 @@ int main( *------------------------------------------------------------------------------------------*/ asked_frame_size = arg.renderFramesize; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : IVAS_DEFAULT_AEID; +#else uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; +#endif #ifdef IVAS_RTPDUMP arg.enableHeadRotation = arg.enableHeadRotation || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; @@ -525,7 +535,47 @@ int main( fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); goto cleanup; } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); + if ( aeCount > 0 ) + { + uint32_t n; + + pAE = malloc( aeCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA * ) ); + + if ( pAE == NULL ) + { + fprintf( stderr, "\nError: cannot allocate memory for acoustic environment array\n\n" ); + goto cleanup; + } + + for ( n = 0; n < aeCount; n++ ) + { + pAE[n] = NULL; + + if ( NULL == ( pAE[n] = malloc( sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ) ) ) + { + fprintf( stderr, "\nError: cannot allocate memory for acoustic environment\n\n" ); + goto cleanup; + } + } + if ( ( error = RenderConfigReader_getAcousticEnvironments( renderConfigReader, pAE ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error while getting acoustic environments\n\n" ); + goto cleanup; + } + + for ( n = 0; n < aeCount; n++ ) + { + if ( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, *pAE[n] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to add acoustic environments\n\n" ); + goto cleanup; + } + } + } +#endif if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity_fx ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); @@ -564,7 +614,11 @@ int main( if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) +#else if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) +#endif { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { @@ -692,6 +746,20 @@ cleanup: free( pcmBuf ); +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + if ( pAE != NULL ) + { + uint16_t n; + + for ( n = 0; n < aeCount; n++ ) + { + free( pAE[n] ); + } + + free( pAE ); + } +#endif + if ( arg.aeSequence.count > 0 ) { free( arg.aeSequence.pID ); diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 6259b5f8d..d78ea5cef 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -330,6 +330,9 @@ typedef enum typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + Word16 aeID; /* Acoustic environment ID */ +#endif Word16 nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ Word32 pFc_input_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /*Q16 Center frequencies for which following values are provided: */ Word32 pAcoustic_rt60_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /*Q26 - The room's T60 per center frequency */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index c445d0299..cfcad5a34 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1649,6 +1649,9 @@ typedef enum #define RV_LENGTH_NR_FC_16KHZ ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1 #define IVAS_REVERB_DEFAULT_N_BANDS 31 +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#define IVAS_DEFAULT_AEID ( 65535 ) +#endif #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) diff --git a/lib_com/options.h b/lib_com/options.h index 1189abd99..49863d38b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -153,6 +153,7 @@ #define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ +#define IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT /* RTPDUMP acoustic environment */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index c005b1aa5..ffb4061a7 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3192,6 +3192,10 @@ void ivas_initialize_handles_dec( st_ivas->hRenderConfig = NULL; st_ivas->hExtOrientationData = NULL; st_ivas->hCombinedOrientationData = NULL; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + st_ivas->acousticEnvironmentsCount = 0; + st_ivas->pAcousticEnvironments = NULL; +#endif st_ivas->hSplitBinRend = NULL; for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) @@ -3208,6 +3212,11 @@ void ivas_initialize_handles_dec( st_ivas->p_output_fx[i] = NULL; } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + /* Acoustic environments */ + st_ivas->pAcousticEnvironments = NULL; +#endif + return; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4a464705d..ac1f9aaad 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1199,6 +1199,11 @@ typedef struct Decoder_Struct MASA_ISM_DATA_HANDLE hMasaIsmData; /* OMASA rendering handle */ SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcousticEnvironments; /* Acoustic environment array */ + Word16 acousticEnvironmentsCount; /* Number of acoustic environments in the array*/ +#endif + Word16 flag_omasa_brate; ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 1167d60b9..4a15804fd 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -446,6 +446,19 @@ ivas_error IVAS_DEC_HRTF_binary_close( const IVAS_BIN_RENDERER_TYPE binaural_renderer_old /* i : previous binaural renderer type */ ); +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +ivas_error IVAS_DEC_AddAcousticEnvironment( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcousticsConfig /* i : Room acoustic configuration */ +); + +ivas_error IVAS_DEC_GetAcousticEnvironment( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + Word16 aeID, /* i : Acoustic environment ID */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Room acoustic environment data pointer */ +); +#endif + /*! r: error code*/ ivas_error IVAS_DEC_GetRenderConfig( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 6c6700558..da4860bd5 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2928,6 +2928,193 @@ ivas_error IVAS_DEC_HRTF_binary_close( return IVAS_ERR_OK; } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +/*---------------------------------------------------------------------* + * IVAS_DEC_AddAcousticEnvironment( ) + * + * Adds acoustic environment configuration + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_AddAcousticEnvironment( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcousticsConfig /* i : Room acoustic configuration */ +) +{ + Word16 n; + Decoder_Struct *st_ivas; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAE = NULL; + + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || ( hIvasDec->st_ivas->acousticEnvironmentsCount > 0 && hIvasDec->st_ivas->pAcousticEnvironments == NULL ) ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; + + /* Check if already there */ + FOR( n = 0; n < st_ivas->acousticEnvironmentsCount; n++ ) + { + test(); + IF( st_ivas->pAcousticEnvironments[n].aeID == roomAcousticsConfig.aeID ) + { + move32(); + pAE = &st_ivas->pAcousticEnvironments[n]; + break; + } + } + + /* If not found */ + test(); + IF( pAE == NULL ) + { + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *ppAE = realloc( st_ivas->pAcousticEnvironments, ( st_ivas->acousticEnvironmentsCount + 1 ) * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); + + IF( ppAE == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + st_ivas->pAcousticEnvironments = ppAE; + n = st_ivas->acousticEnvironmentsCount++; + pAE = &st_ivas->pAcousticEnvironments[n]; + move32(); + move16(); + move32(); + } + + pAE->aeID = roomAcousticsConfig.aeID; + pAE->nBands = roomAcousticsConfig.nBands; + pAE->acousticPreDelay_fx = roomAcousticsConfig.acousticPreDelay_fx; + pAE->inputPreDelay_fx = roomAcousticsConfig.inputPreDelay_fx; + + Copy32( roomAcousticsConfig.pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 + Copy32( roomAcousticsConfig.pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 + Copy32( roomAcousticsConfig.pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 + + pAE->use_er = roomAcousticsConfig.use_er; + + move16(); + move16(); + move32(); + move32(); + move16(); + + test(); + IF( pAE->use_er == 1 ) + { + pAE->lowComplexity = roomAcousticsConfig.lowComplexity; + move32(); + + pAE->dimensions.x_fx = roomAcousticsConfig.dimensions.x_fx; + pAE->dimensions.y_fx = roomAcousticsConfig.dimensions.y_fx; + pAE->dimensions.z_fx = roomAcousticsConfig.dimensions.z_fx; + move32(); + move32(); + move32(); + + pAE->ListenerOrigin.x_fx = roomAcousticsConfig.ListenerOrigin.x_fx; + pAE->ListenerOrigin.y_fx = roomAcousticsConfig.ListenerOrigin.y_fx; + pAE->ListenerOrigin.z_fx = roomAcousticsConfig.ListenerOrigin.z_fx; + move32(); + move32(); + move32(); + + Copy32( roomAcousticsConfig.AbsCoeff_fx, pAE->AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); + } + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetAcousticEnvironment( ) + * + * Gets acoustic environment configuration with a given ID + *---------------------------------------------------------------------*/ +ivas_error IVAS_DEC_GetAcousticEnvironment( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + Word16 aeID, /* i : Acoustic environment ID */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Room acoustic environment data pointer */ +) +{ + Word16 n, m; + Word16 found = 0; + + Decoder_Struct *st_ivas; + + test(); + IF( hIvasDec == NULL || pAcEnv == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + st_ivas = hIvasDec->st_ivas; + move32(); + + /* In case of default AE ID, select the first one available */ + test(); + IF( aeID == IVAS_DEFAULT_AEID && st_ivas->acousticEnvironmentsCount > 0 ) + { + aeID = (uint16_t) st_ivas->pAcousticEnvironments[0].aeID; + move32(); + } + + FOR( n = 0; n < st_ivas->acousticEnvironmentsCount; n++ ) + { + IVAS_ROOM_ACOUSTICS_CONFIG_DATA ae = st_ivas->pAcousticEnvironments[n]; + move32(); + test(); + IF( aeID == ae.aeID ) + { + found = 1; + pAcEnv->aeID = aeID; + pAcEnv->nBands = ae.nBands; + pAcEnv->inputPreDelay_fx = ae.inputPreDelay_fx; + move16(); + move16(); + move16(); + move32(); + + FOR( m = 0; m < pAcEnv->nBands; m++ ) + { + pAcEnv->pFc_input_fx[m] = ae.pFc_input_fx[m]; + pAcEnv->pAcoustic_rt60_fx[m] = ae.pAcoustic_rt60_fx[m]; + pAcEnv->pAcoustic_dsr_fx[m] = ae.pAcoustic_dsr_fx[m]; + move32(); + move32(); + move32(); + } + + /* If ER are allocated then propagate parameters */ + pAcEnv->use_er = ae.use_er; + move16(); + test(); + IF( ae.use_er != 0 ) + { + pAcEnv->lowComplexity = ae.lowComplexity; + move32(); + + pAcEnv->dimensions.x_fx = ae.dimensions.x_fx; + pAcEnv->dimensions.y_fx = ae.dimensions.y_fx; + pAcEnv->dimensions.z_fx = ae.dimensions.z_fx; + move32(); + move32(); + move32(); + + pAcEnv->ListenerOrigin.x_fx = ae.ListenerOrigin.x_fx; + pAcEnv->ListenerOrigin.y_fx = ae.ListenerOrigin.y_fx; + pAcEnv->ListenerOrigin.z_fx = ae.ListenerOrigin.z_fx; + move32(); + move32(); + move32(); + + Copy32( ae.AbsCoeff_fx, pAcEnv->AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); + } + } + } + + test(); + return found ? IVAS_ERR_OK : IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; +} +#endif /*---------------------------------------------------------------------* * copyRendererConfigStruct( ) @@ -2945,6 +3132,10 @@ static ivas_error copyRendererConfigStruct( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + hRCout->roomAcoustics.aeID = hRCin->roomAcoustics.aeID; + move16(); +#endif hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->roomAcoustics.acousticPreDelay_fx = hRCin->roomAcoustics.acousticPreDelay_fx; hRCout->roomAcoustics.inputPreDelay_fx = hRCin->roomAcoustics.inputPreDelay_fx; @@ -3042,6 +3233,10 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig = hIvasDec->st_ivas->hRenderConfig; st_ivas = hIvasDec->st_ivas; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + hRenderConfig->roomAcoustics.aeID = renderConfig.roomAcoustics.aeID; + move16(); +#endif hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay_fx = renderConfig.roomAcoustics.acousticPreDelay_fx; hRenderConfig->roomAcoustics.inputPreDelay_fx = renderConfig.roomAcoustics.inputPreDelay_fx; @@ -3136,6 +3331,159 @@ ivas_error IVAS_DEC_FeedRenderConfig( return IVAS_ERR_OK; } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +/*---------------------------------------------------------------------* + * IVAS_DEC_FeedAcousticEnvPI( ) + * + * Set acoustic environment from the PI data + *---------------------------------------------------------------------*/ + +static ivas_error IVAS_DEC_FeedAcousticEnvPI( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_PIDATA_ACOUSTIC_ENV hAcoustEnvPI /* i : Render configuration struct */ +) +{ + RENDER_CONFIG_HANDLE hRenderConfig; + Decoder_Struct *st_ivas; + ivas_error error; + + test(); + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hRenderConfig = hIvasDec->st_ivas->hRenderConfig; + st_ivas = hIvasDec->st_ivas; + move32(); + move32(); + + /* Ignore if AE ID already in use */ + test(); + IF( hRenderConfig->roomAcoustics.aeID == hAcoustEnvPI.aeid ) + { + return IVAS_ERR_OK; + } + + /* Attempt to load the one already available */ + test(); + IF( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, hAcoustEnvPI.aeid, &hRenderConfig->roomAcoustics ) ) == IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING ) + { + /* Add the new compact room environment */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA acEnv; + + acEnv.aeID = hAcoustEnvPI.aeid; + acEnv.nBands = IVAS_PI_AE_NUM_BANDS; + move16(); + move16(); + + acEnv.pFc_input_fx[IVAS_PI_AE_LOW] = IVAS_PI_AE_LOW_FREQ * 0x10000; /* Q16 */ + acEnv.pFc_input_fx[IVAS_PI_AE_MID] = IVAS_PI_AE_MID_FREQ * 0x10000; + acEnv.pFc_input_fx[IVAS_PI_AE_HIGH] = IVAS_PI_AE_HIGH_FREQ * 0x10000; + move32(); + move32(); + move32(); + + acEnv.pAcoustic_rt60_fx[IVAS_PI_AE_LOW] = hAcoustEnvPI.rt60_fx[IVAS_PI_AE_LOW]; + acEnv.pAcoustic_rt60_fx[IVAS_PI_AE_MID] = hAcoustEnvPI.rt60_fx[IVAS_PI_AE_MID]; + acEnv.pAcoustic_rt60_fx[IVAS_PI_AE_HIGH] = hAcoustEnvPI.rt60_fx[IVAS_PI_AE_HIGH]; + acEnv.inputPreDelay_fx = ( ( hAcoustEnvPI.rt60_fx[IVAS_PI_AE_MID] * 0x00CCCCC ) >> 26 ); /* Q26 RT60[MID] / 10 -> Q27 */ + move32(); + move32(); + move32(); + move32(); + + acEnv.pAcoustic_dsr_fx[IVAS_PI_AE_LOW] = hAcoustEnvPI.dsr_fx[IVAS_PI_AE_LOW]; + acEnv.pAcoustic_dsr_fx[IVAS_PI_AE_MID] = hAcoustEnvPI.dsr_fx[IVAS_PI_AE_MID]; + acEnv.pAcoustic_dsr_fx[IVAS_PI_AE_HIGH] = hAcoustEnvPI.dsr_fx[IVAS_PI_AE_HIGH]; + move32(); + move32(); + move32(); + + acEnv.use_er = hAcoustEnvPI.availEarlyReflections; + move16(); + + test(); + IF( hAcoustEnvPI.availEarlyReflections ) + { + hRenderConfig->roomAcoustics.dimensions.x_fx = hAcoustEnvPI.roomDimensions.x_fx; + hRenderConfig->roomAcoustics.dimensions.y_fx = hAcoustEnvPI.roomDimensions.y_fx; + hRenderConfig->roomAcoustics.dimensions.z_fx = hAcoustEnvPI.roomDimensions.z_fx; + move32(); + move32(); + move32(); + + mvr2r( hAcoustEnvPI.absorbCoeffs, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); + } + + test(); + IF( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, acEnv ) ) != IVAS_ERR_OK ) + { + return error; + } + + test(); + IF( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, hAcoustEnvPI.aeid, &hRenderConfig->roomAcoustics ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* Re-initialize reverb instance if already available */ + + /* TD renderer Jot reverberator */ + test(); + IF( st_ivas->hReverb != NULL ) + { + test(); + IF( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* CREND Jot reverberator */ + test(); + IF( st_ivas->hCrendWrapper != NULL && st_ivas->hCrendWrapper->hCrend[0] != NULL && st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) + { + test(); + IF( ( error = ivas_reverb_open_fx( &st_ivas->hCrendWrapper->hCrend[0]->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* Parametric renderer reverberator */ + IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->hReverb != NULL ) + { + ivas_binaural_reverb_close_fx( &( st_ivas->hDiracDecBin[0]->hReverb ) ); + + test(); + IF( ( error = ivas_binaural_reverb_init_fx( &( 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 renderer reverberator */ + test(); + IF( st_ivas->hBinRenderer != NULL && st_ivas->hBinRenderer->hReverb != NULL ) + { + ivas_binaural_reverb_close_fx( &( st_ivas->hBinRenderer->hReverb ) ); + + test(); + IF( ( error = ivas_binaural_reverb_init_fx( &( 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; + } + } + + return IVAS_ERR_OK; +} +#endif /*---------------------------------------------------------------------* * IVAS_DEC_GetDelay( ) @@ -6434,6 +6782,22 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi } BREAK; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + case IVAS_PI_ACOUSTIC_ENVIRONMENT: + { + Word16 aeid = piData->data.acousticEnv.aeid; +#ifdef DEBUGGING + fprintf( stdout, "PI_ACOUSTIC_ENVIRONMENT : AEID : %d\n", aeid ); +#endif + test(); + IF( piData->data.acousticEnv.availLateReverb && hIvasDec->st_ivas->hRenderConfig != NULL && aeid != hIvasDec->st_ivas->hRenderConfig->roomAcoustics.aeID ) + { + error = IVAS_DEC_FeedAcousticEnvPI( hIvasDec, piData->data.acousticEnv ); + } + } + BREAK; +#endif + #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_DIEGETIC_TYPE: { diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 3c43b59e1..23a54d355 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -107,6 +107,10 @@ ivas_error ivas_render_config_init_from_rom_fx( { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + ( *hRenderConfig )->roomAcoustics.aeID = IVAS_DEFAULT_AEID; + move16(); +#endif ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; move16(); ( *hRenderConfig )->roomAcoustics.acousticPreDelay_fx = IVAS_REVERB_DEFAULT_PRE_DELAY_FX; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b8e282d91..6552d924a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5226,6 +5226,10 @@ ivas_error IVAS_REND_GetRenderConfig( } hRCin = hIvasRend->hRendererConfig; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + hRCout->roomAcoustics.aeID = hRCin->roomAcoustics.aeID; + move16(); +#endif hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->roomAcoustics.acousticPreDelay_fx = hRCin->roomAcoustics.acousticPreDelay_fx; hRCout->roomAcoustics.inputPreDelay_fx = hRCin->roomAcoustics.inputPreDelay_fx; @@ -5289,6 +5293,10 @@ ivas_error IVAS_REND_FeedRenderConfig( hRenderConfig = hIvasRend->hRendererConfig; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + hRenderConfig->roomAcoustics.aeID = renderConfig.roomAcoustics.aeID; + move16(); +#endif hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; move16(); hRenderConfig->roomAcoustics.acousticPreDelay_fx = renderConfig.roomAcoustics.acousticPreDelay_fx; diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 82f198135..56b4509cf 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -159,7 +159,15 @@ void IVAS_RTP_LogPiData( return; } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#ifdef _WIN32 + if ( ftell( f_piDataOut ) > 3 ) +#else if ( ftell( f_piDataOut ) > 2 ) +#endif +#else + if ( ftell( f_piDataOut ) > 2 ) +#endif { fprintf( f_piDataOut, ",\n" ); } diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index be2e9dd4d..506264ade 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -33,6 +33,11 @@ #include "ivas_error_utils.h" #include "ivas_rtp_internal.h" +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#include "cnst.h" +#include +#endif + #ifdef IVAS_RTPDUMP /* Generic PI data packing/unpacking functions */ @@ -314,6 +319,27 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] = mapAbsorbtion[( dWord >> 4 ) & MASK_ABS]; aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] = mapAbsorbtion[( dWord >> 2 ) & MASK_ABS]; aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] = mapAbsorbtion[( dWord >> 0 ) & MASK_ABS]; + +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + aeEnv->rt60_fx[IVAS_PI_AE_LOW] = (Word32) ( aeEnv->rt60[IVAS_PI_AE_LOW] * ONE_IN_Q26 ); /* Q26 */ + aeEnv->rt60_fx[IVAS_PI_AE_MID] = (Word32) ( aeEnv->rt60[IVAS_PI_AE_MID] * ONE_IN_Q26 ); + aeEnv->rt60_fx[IVAS_PI_AE_HIGH] = (Word32) ( aeEnv->rt60[IVAS_PI_AE_HIGH] * ONE_IN_Q26 ); + aeEnv->dsr_fx[IVAS_PI_AE_LOW] = (Word32) ( powf( 10.0f, aeEnv->dsr[IVAS_PI_AE_LOW] / 10.0f ) * ONE_IN_Q30 ); /* Q30 */ + aeEnv->dsr_fx[IVAS_PI_AE_MID] = (Word32) ( powf( 10.0f, aeEnv->dsr[IVAS_PI_AE_MID] / 10.0f ) * ONE_IN_Q30 ); + aeEnv->dsr_fx[IVAS_PI_AE_HIGH] = (Word32) ( powf( 10.0f, aeEnv->dsr[IVAS_PI_AE_HIGH] / 10.0f ) * ONE_IN_Q30 ); + + aeEnv->roomDimensions.x_fx = (Word32) ( aeEnv->roomDimensions.x * ONE_IN_Q22 ); /* Q22 */ + aeEnv->roomDimensions.y_fx = (Word32) ( aeEnv->roomDimensions.y * ONE_IN_Q22 ); + aeEnv->roomDimensions.z_fx = (Word32) ( aeEnv->roomDimensions.z * ONE_IN_Q22 ); + aeEnv->roomDimensions.q_fact = Q22; + + aeEnv->absorbCoeffs_fx[IVAS_PI_AE_FRONT] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] * ONE_IN_Q30 ); /* Q30 */ + aeEnv->absorbCoeffs_fx[IVAS_PI_AE_BACK] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] * ONE_IN_Q30 ); + aeEnv->absorbCoeffs_fx[IVAS_PI_AE_LEFT] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_LEFT] * ONE_IN_Q30 ); + aeEnv->absorbCoeffs_fx[IVAS_PI_AE_RIGHT] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_RIGHT] * ONE_IN_Q30 ); + aeEnv->absorbCoeffs_fx[IVAS_PI_AE_CEILING] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_CEILING] * ONE_IN_Q30 ); + aeEnv->absorbCoeffs_fx[IVAS_PI_AE_FLOOR] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_FLOOR] * ONE_IN_Q30 ); +#endif } return IVAS_ERR_OK; diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index dc4c7f8ba..ae40afbff 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -124,6 +124,15 @@ typedef enum IVAS_PI_AE_NUM_BANDS /* number of ae bands */ } IVAS_PI_AE_BANDS; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +typedef enum +{ + IVAS_PI_AE_LOW_FREQ = 25, + IVAS_PI_AE_MID_FREQ = 250, + IVAS_PI_AE_HIGH_FREQ = 2500 +} IVAS_PI_AE_BANDS_FREQ; +#endif + typedef enum { IVAS_PI_AE_FRONT, @@ -146,10 +155,21 @@ typedef struct /* only valid if availLateReverb==true or availEarlyReflections==true */ float rt60[IVAS_PI_AE_NUM_BANDS]; /* time for the reflections to reduce 60 dB per band in seconds */ float dsr[IVAS_PI_AE_NUM_BANDS]; /* diffuse to source signal energy ratio per band in dB */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + Word32 rt60_fx[IVAS_PI_AE_NUM_BANDS]; /* Q26: time for the reflections to reduce 60 dB per band in seconds */ + Word32 dsr_fx[IVAS_PI_AE_NUM_BANDS]; /* Q30: diffuse to source signal energy ratio per band in dB */ +#endif /* only valid if availEarlyReflections==true */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + IVAS_VECTOR3 roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ +#else IVAS_COORDINATE roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ +#endif float absorbCoeffs[IVAS_PI_AE_NUM_SURFACE]; /* absorption coefficients for all surfaces */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + Word32 absorbCoeffs_fx[IVAS_PI_AE_NUM_SURFACE]; /* Q30: absorption coefficients for all surfaces */ +#endif } IVAS_PIDATA_ACOUSTIC_ENV; #ifdef RTP_S4_251135_CR26253_0016_REV1 diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 14538b5ee..49c5fe49a 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -38,7 +38,9 @@ #include #include "cmdl_tools.h" #include "prot_fx.h" - +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#include "ivas_cnst.h" +#endif /*------------------------------------------------------------------------------------------* * PreProc Local Macros @@ -2832,6 +2834,100 @@ ivas_error RenderConfigReader_read( } return IVAS_ERR_OK; } + +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_getAcousticEnvironmentCount() + * + * Gets number of acoustic environments available + *------------------------------------------------------------------------------------------*/ +uint32_t RenderConfigReader_getAcousticEnvironmentCount( + RenderConfigReader *pRenderConfigReader /* i : RenderConfigReader handle */ +) +{ + return pRenderConfigReader->nAE; +} + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_getAcousticEnvironments() + * + * Gets all acoustic environments + *------------------------------------------------------------------------------------------*/ +ivas_error RenderConfigReader_getAcousticEnvironments( + RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA **ppAcEnv /* o : Acoustic environment array pointer */ +) +{ + uint16_t n, m, j; + + if ( pRenderConfigReader == NULL || ppAcEnv == NULL || pRenderConfigReader->nAE == 0 || pRenderConfigReader->pAE == NULL ) + { + return 0; + } + + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) + { + AcousticEnv pIn = pRenderConfigReader->pAE[n]; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pOut = ppAcEnv[n]; + + pOut->aeID = (Word16) pIn.id; + pOut->nBands = (Word16) pIn.pFG->nrBands; + pOut->inputPreDelay_fx = (Word32) ( pIn.preDelay * ONE_IN_Q27 ); + + for ( m = 0; m < pOut->nBands; m++ ) + { + pOut->pFc_input_fx[m] = (Word32) ( pIn.pFG->pFc[m] * ONE_IN_Q16 ); + pOut->pAcoustic_rt60_fx[m] = (Word32) ( pIn.pRT60[m] * ONE_IN_Q26 ); + pOut->pAcoustic_dsr_fx[m] = (Word32) ( pIn.pDSR[m] * ONE_IN_Q30 ); + } + + /* If ER are allocated then propagate parameters */ + if ( pIn.pEarlyReflections != 0 ) + { + pOut->use_er = pIn.pEarlyReflections->use_er; /* ER activation flag */ + pOut->lowComplexity = pIn.pEarlyReflections->lowComplexity; /* Low complexity flag */ + pOut->dimensions = pIn.pEarlyReflections->dimensions; + pOut->dimensions.x_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x * ONE_IN_Q22 ); + pOut->dimensions.y_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y * ONE_IN_Q22 ); + pOut->dimensions.z_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z * ONE_IN_Q22 ); + + /* Use default listener origin position if non provided */ + if ( pIn.pEarlyReflections->pListenerOrigin == NULL ) + { + + pOut->ListenerOrigin.x_fx = IVAS_ER_LIST_ORIGIN_X_FX; + pOut->ListenerOrigin.y_fx = IVAS_ER_LIST_ORIGIN_Y_FX; + pOut->ListenerOrigin.z_fx = IVAS_ER_LIST_HEIGHT_FX; + pOut->ListenerOrigin.q_fact = Q22; + } + else + { + pOut->ListenerOrigin.x_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx; + pOut->ListenerOrigin.y_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx; + pOut->ListenerOrigin.z_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx; + } + + for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) + { + pOut->AbsCoeff_fx[j] = (Word32) ( pIn.pEarlyReflections->pAbsCoeff[j] * ONE_IN_Q30 ); + } + } + else + { + pOut->use_er = false; + } + } + + return IVAS_ERR_OK; +} +#endif + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_getAcousticEnvironment() + * + * Gets Acoustic environment with a given ID + *------------------------------------------------------------------------------------------*/ + ivas_error RenderConfigReader_getAcousticEnvironment( RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ uint16_t id, /* i : Acoustic environment ID */ @@ -2847,7 +2943,11 @@ ivas_error RenderConfigReader_getAcousticEnvironment( } /* case when -aeid is not specified, select first ID from config file */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + if ( id == IVAS_DEFAULT_AEID && pRenderConfigReader->nAE > 0 ) +#else if ( id == 65535 && pRenderConfigReader->nAE > 0 ) +#endif { id = (uint16_t) pRenderConfigReader->pAE[0].id; } diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 58946eca6..b3cdd3f11 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -51,6 +51,19 @@ ivas_error RenderConfigReader_open( RenderConfigReader **ppRenderConfigReader /* o : RenderConfigReader handle */ ); +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +/* Get number of acoustic environments */ +uint32_t RenderConfigReader_getAcousticEnvironmentCount( + RenderConfigReader *pRenderConfigReader /* i : RenderConfigReader handle */ +); + +/* Get all acoustic environments */ +ivas_error RenderConfigReader_getAcousticEnvironments( + RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA **ppAcEnv /* o : Acoustic environment array pointer */ +); +#endif + /* Get an acoustic environment */ ivas_error RenderConfigReader_getAcousticEnvironment( RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ -- GitLab From 9190533ac56931c4181d0157edbbbdbb9dba4fb3 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 7 Nov 2025 10:57:35 +0100 Subject: [PATCH 213/351] Clang cleanup --- lib_util/ivas_rtp_pi_data.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index ae40afbff..f66f7e19a 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -162,9 +162,9 @@ typedef struct /* only valid if availEarlyReflections==true */ #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - IVAS_VECTOR3 roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ + IVAS_VECTOR3 roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ #else - IVAS_COORDINATE roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ + IVAS_COORDINATE roomDimensions; /* room dimensions in meters length (x), width (y), height (z) */ #endif float absorbCoeffs[IVAS_PI_AE_NUM_SURFACE]; /* absorption coefficients for all surfaces */ #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -- GitLab From 889e51469c74adaa39b64664310a6db3b5b37779 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 7 Nov 2025 11:58:23 +0200 Subject: [PATCH 214/351] Try another section. --- lib_dec/ivas_init_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index a376b78e3..77c1c4e6d 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1665,8 +1665,8 @@ ivas_error ivas_init_decoder_fx( } } -#ifdef FIX_1318_ROOM_SIZE_CMD_LINE // clang-format off +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE /* This section is correctly formatted but clang-format in CI messes this up. Can probably be removed with accepted switches */ /*--------------------------------------------------------------------------* @@ -1744,9 +1744,9 @@ ivas_error ivas_init_decoder_fx( return error; } } -// clang-format on #endif } +// clang-format on /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles -- GitLab From c096dbaa1e16b58fd37ac12ce604186221a905e5 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 7 Nov 2025 11:05:12 +0100 Subject: [PATCH 215/351] Typecast to resolve Linux compilation issues --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index da4860bd5..8dd90473f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3051,7 +3051,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( /* In case of default AE ID, select the first one available */ test(); - IF( aeID == IVAS_DEFAULT_AEID && st_ivas->acousticEnvironmentsCount > 0 ) + IF( aeID == (Word16) IVAS_DEFAULT_AEID && st_ivas->acousticEnvironmentsCount > 0 ) { aeID = (uint16_t) st_ivas->pAcousticEnvironments[0].aeID; move32(); -- GitLab From 9bca5e35b4e6ee2d5ba5cc267f4b03bf43c69fba Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 7 Nov 2025 12:11:54 +0200 Subject: [PATCH 216/351] Try different approach to satisfy clang format. --- lib_dec/ivas_init_dec_fx.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 77c1c4e6d..19f057def 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1665,18 +1665,10 @@ ivas_error ivas_init_decoder_fx( } } -// clang-format off #ifdef FIX_1318_ROOM_SIZE_CMD_LINE - /* This section is correctly formatted but clang-format in CI messes this up. Can probably be removed with accepted switches */ - /*--------------------------------------------------------------------------* * Allocate and initialize HRTF Statistics handle, get default reverb values *--------------------------------------------------------------------------*/ -#else - /*--------------------------------------------------------------------* - * Allocate and initialize HRTF Statistics handle - *--------------------------------------------------------------------*/ -#endif IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { @@ -1686,7 +1678,6 @@ ivas_error ivas_init_decoder_fx( return error; } -#ifdef FIX_1318_ROOM_SIZE_CMD_LINE /* Get default reverb values based on format, if custom values were not given */ IF( EQ_16(st_ivas->hDecoderConfig->Opt_RendConfigCustom, 0) ) { @@ -1744,9 +1735,21 @@ ivas_error ivas_init_decoder_fx( return error; } } -#endif } -// clang-format on +#else + /*--------------------------------------------------------------------* + * Allocate and initialize HRTF Statistics handle + *--------------------------------------------------------------------*/ + + IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + /* Init HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) + { + return error; + } + } +#endif /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles -- GitLab From c67dfae921c0239e1e2d84a4d6fad0ae20ec2f2d Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 7 Nov 2025 11:14:49 +0100 Subject: [PATCH 217/351] Typecast to resolve Linux compilation issues --- lib_rend/ivas_render_config_fx.c | 2 +- lib_util/render_config_reader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 23a54d355..25c1aa4d4 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -108,7 +108,7 @@ ivas_error ivas_render_config_init_from_rom_fx( return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - ( *hRenderConfig )->roomAcoustics.aeID = IVAS_DEFAULT_AEID; + ( *hRenderConfig )->roomAcoustics.aeID = (Word16) IVAS_DEFAULT_AEID; move16(); #endif ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 49c5fe49a..1fb664954 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2944,7 +2944,7 @@ ivas_error RenderConfigReader_getAcousticEnvironment( /* case when -aeid is not specified, select first ID from config file */ #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - if ( id == IVAS_DEFAULT_AEID && pRenderConfigReader->nAE > 0 ) + if ( id == (Word16) IVAS_DEFAULT_AEID && pRenderConfigReader->nAE > 0 ) #else if ( id == 65535 && pRenderConfigReader->nAE > 0 ) #endif -- GitLab From f23cda5bfab914e5dab8a2bb408588b62e5ad8e0 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 7 Nov 2025 12:19:21 +0200 Subject: [PATCH 218/351] Final clang format --- lib_dec/ivas_init_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 19f057def..f9eb53b82 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1679,7 +1679,7 @@ ivas_error ivas_init_decoder_fx( } /* Get default reverb values based on format, if custom values were not given */ - IF( EQ_16(st_ivas->hDecoderConfig->Opt_RendConfigCustom, 0) ) + IF( EQ_16( st_ivas->hDecoderConfig->Opt_RendConfigCustom, 0 ) ) { IVAS_DefaultReverbSize defaultReverbSize; SWITCH( st_ivas->hDecoderConfig->Opt_RoomSize ) -- GitLab From 129fd690b23f14c975a83b0f9600c23f4726fefa Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 7 Nov 2025 12:26:56 +0200 Subject: [PATCH 219/351] Fix wrong argument --- apps/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index a3fa7595f..7a000f9c5 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -416,7 +416,7 @@ int main( #ifdef FIX_1318_ROOM_SIZE_CMD_LINE 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.roomSize, arg.non_diegetic_pan_enabled, - arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) + arg.non_diegetic_pan_gain_fx, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) #else 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, -- GitLab From 270cae4d2681e4d80660febd65f219d1c2ea3346 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 5 Nov 2025 12:26:21 +0100 Subject: [PATCH 220/351] port MR 2346 from float - add FIX_1419_MONO_STEREO_UMX --- apps/decoder.c | 20 ++++++++ lib_com/ivas_cnst.h | 4 ++ lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 50 +++++++++++++++++++- lib_dec/ivas_jbm_dec_fx.c | 39 ++++++++++++++++ lib_dec/ivas_output_config_fx.c | 81 +++++++++++++++++++++++++++++++++ lib_dec/lib_dec_fx.c | 36 +++++++++++++++ lib_rend/ivas_rom_rend_fx.c | 20 ++++++++ 8 files changed, 250 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 94bfab14d..46cfd7da4 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -129,6 +129,9 @@ typedef struct uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; bool objEditEnabled; char *objEditFileName; +#ifdef FIX_1419_MONO_STEREO_UMX + bool evsMode; +#endif } DecArguments; @@ -834,6 +837,9 @@ static bool parseCmdlIVAS_dec( arg->output_Fs = IVAS_MAX_SAMPLING_RATE; arg->outputConfig = IVAS_AUDIO_CONFIG_MONO; arg->decMode = IVAS_DEC_MODE_IVAS; +#ifdef FIX_1419_MONO_STEREO_UMX + arg->evsMode = false; +#endif arg->quietModeEnabled = false; arg->delayCompensationEnabled = true; arg->voipMode = false; @@ -1360,6 +1366,14 @@ static bool parseCmdlIVAS_dec( } i++; } +#ifdef FIX_1419_MONO_STEREO_UMX + else if ( strcmp( argv_to_upper, "-EVS" ) == 0 ) + { + arg->evsMode = true; + arg->decMode = IVAS_DEC_MODE_EVS; + i++; + } +#endif /*-----------------------------------------------------------------* * Option not recognized @@ -1501,6 +1515,9 @@ static bool parseCmdlIVAS_dec( static void usage_dec( void ) { fprintf( stdout, "Usage for EVS: IVAS_dec.exe [Options] Fs bitstream_file output_file\n" ); +#ifdef FIX_1419_MONO_STEREO_UMX + fprintf( stdout, " OR usage for IVAS (below) with -evs option and OutputConf\n" ); +#endif fprintf( stdout, "Usage for IVAS: IVAS_dec.exe [Options] OutputConf Fs bitstream_file output_file\n\n" ); fprintf( stdout, "Mandatory parameters:\n" ); @@ -1517,6 +1534,9 @@ static void usage_dec( void ) fprintf( stdout, "Options:\n" ); fprintf( stdout, "--------\n" ); +#ifdef FIX_1419_MONO_STEREO_UMX + fprintf( stdout, "-evs : Specify EVS mode for supplied bitstream\n" ); +#endif fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); fprintf( stdout, "-VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" ); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index c445d0299..5274a2339 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1295,7 +1295,11 @@ typedef enum *----------------------------------------------------------------------------------*/ #define MC_LS_SETUP_BITS 3 /* number of bits for writing the MC LS configuration */ +#ifdef FIX_1419_MONO_STEREO_UMX +#define LS_SETUP_CONVERSION_NUM_MAPPINGS 41 /* number of mappings for LS setup conversion */ +#else #define LS_SETUP_CONVERSION_NUM_MAPPINGS 35 /* number of mappings for LS setup conversion */ +#endif typedef enum { diff --git a/lib_com/options.h b/lib_com/options.h index f658a0ace..036d26258 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -139,6 +139,7 @@ #define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ #define FIX_1330_JBM_MEMORY_FIX /* VA: basop issue: 2179 fix non-BE difference in FIX_1330_JBM_MEMORY */ #define FIX_1411_IGF_CRASH_BW_SWITCHING /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/ +#define FIX_1419_MONO_STEREO_UMX /* FhG: fix for issue 1419 : support upmix to all output formats for mono and stereo */ #define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */ #define NONBE_1344_REND_MASA_LOW_FS /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */ #define NONBE_1412_AVOID_ROUNDING_AZ_ELEV /* FhG: Avoid rounding when passing azimuth and elevation to efap_determine_gains() */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index dff92f4e4..d242298d7 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1531,7 +1531,16 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { test(); +#ifdef FIX_1419_MONO_STEREO_UMX + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) + { + hDecoderConfig->nchan_out = 1; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) +#else IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) +#endif { hDecoderConfig->nchan_out = CPE_CHANNELS; } @@ -1598,6 +1607,14 @@ ivas_error ivas_init_decoder_fx( st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config ); move16(); } +#ifdef FIX_1419_MONO_STEREO_UMX + + test(); + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + { + st_ivas->transport_config = EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO; + } +#endif /* Only initialize transport setup if it is used */ IF( NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_INVALID ) ) @@ -1705,8 +1722,10 @@ ivas_error ivas_init_decoder_fx( { st_ivas->nchan_transport = CPE_CHANNELS; move16(); +#ifndef FIX_1419_MONO_STEREO_UMX /* already set now by renderer_select() */ st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO; move32(); +#endif st_ivas->nSCE = 0; move16(); @@ -2832,7 +2851,8 @@ ivas_error ivas_init_decoder_fx( } /*-----------------------------------------------------------------* - * LFE handles for rendering after rendering to adjust LFE delay to filter delay + * LFE handles for rendering after rendering to adjust LFE delay to + * filter delay *-----------------------------------------------------------------*/ test(); @@ -3773,6 +3793,7 @@ static ivas_error doSanityChecks_IVAS( return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Non-diegetic panning not supported in this IVAS format" ); } +#ifndef FIX_1419_MONO_STEREO_UMX /* we now support basically everything for stereo */ /* Verify stereo output configuration */ IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { @@ -3793,10 +3814,37 @@ static ivas_error doSanityChecks_IVAS( ELSE { IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) ) +#else /* exclude invalid configs instead of matching valid ones */ + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_ISM1 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_ISM2 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_ISM3 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_ISM4 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_MASA1 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_MASA2 ) ) +#endif { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" ); } +#ifdef FIX_1419_MONO_STEREO_UMX + test(); + test(); + IF( ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) && + ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" ); + } +#endif +#ifndef FIX_1419_MONO_STEREO_UMX } +#endif + test(); test(); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 7eab2caf8..42270d50d 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1815,16 +1815,47 @@ ivas_error ivas_jbm_dec_render_fx( ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); } +#ifdef FIX_1419_MONO_STEREO_UMX + ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) +#else ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) +#endif { +#ifdef FIX_1419_MONO_STEREO_UMX + *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); +#endif + /* Rendering */ IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { +#ifndef FIX_1419_MONO_STEREO_UMX *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); move16(); +#endif ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); } +#ifdef FIX_1419_MONO_STEREO_UMX + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + { + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) + { + /* routed to W */ + ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); + } + ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + { + FOR( n = 0; n < *nSamplesRendered; n++ ) + { + Word32 tmp; + tmp = p_output_fx[0][n]; + p_output_fx[0][n] = L_shr( L_add( tmp, p_output_fx[1][n] ), 1 ); /* W = 0.5 * ( L + R ) */ + p_output_fx[1][n] = L_shr( L_sub( tmp, p_output_fx[1][n] ), 1 ); /* Y = 0.5 * ( L - R ) */ + } + } + } +#endif /* FIX_1419_MONO_STEREO_UMX */ } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { @@ -3227,12 +3258,16 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); test(); +#ifndef FIX_1419_MONO_STEREO_UMX /* since we support more output formats for mono, this is no longer sensible; leave it at the default from above */ IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) ) { num_tc = st_ivas->hDecoderConfig->nchan_out; move16(); } ELSE IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) +#else + IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) +#endif { num_tc = 1; move16(); @@ -4437,7 +4472,11 @@ void ivas_dec_prepare_renderer_fx( ivas_omasa_gain_masa_tc_fx( st_ivas->hTcBuffer->tc_fx, st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->nchan_ism, st_ivas->hTcBuffer->n_samples_available ); } } +#ifdef FIX_1419_MONO_STEREO_UMX + ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) || EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) ) +#else ELSE IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) ) +#endif { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); } diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 1958cea41..cace50215 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -37,6 +37,30 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef FIX_1419_MONO_STEREO_UMX +static void ms_bin_upmix_renderer_select( + const IVAS_FORMAT ivas_format, /* i : Decoder format */ + IVAS_AUDIO_CONFIG *internal_config, /* o : Internal configuration for rendering */ + RENDERER_TYPE *renderer_type /* o : Selected renderer type */ +) +{ + + *internal_config = EQ_32( ivas_format, MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO; + + IF( EQ_32( ivas_format, MONO_FORMAT ) ) + { + *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + move16(); + } + ELSE + { + *renderer_type = RENDERER_DISABLE; + move16(); + } + return; +} + +#endif /*-------------------------------------------------------------------------* * ivas_renderer_select() @@ -87,7 +111,17 @@ void ivas_renderer_select( test(); test(); test(); +#ifdef FIX_1419_MONO_STEREO_UMX + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + { + ms_bin_upmix_renderer_select( st_ivas->ivas_format, + internal_config, + renderer_type ); + } + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) +#else IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) +#endif { IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { @@ -268,6 +302,52 @@ void ivas_renderer_select( * Non-binaural rendering configurations *-----------------------------------------------------------------*/ +#ifdef FIX_1419_MONO_STEREO_UMX + test(); + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + { + *internal_config = EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO; + move16(); + + SWITCH( output_config ) + { + case IVAS_AUDIO_CONFIG_FOA: + case IVAS_AUDIO_CONFIG_HOA2: + case IVAS_AUDIO_CONFIG_HOA3: + *renderer_type = RENDERER_SBA_LINEAR_ENC; + move16(); + BREAK; + case IVAS_AUDIO_CONFIG_5_1: + case IVAS_AUDIO_CONFIG_7_1: + case IVAS_AUDIO_CONFIG_5_1_2: + case IVAS_AUDIO_CONFIG_5_1_4: + case IVAS_AUDIO_CONFIG_7_1_4: + case IVAS_AUDIO_CONFIG_LS_CUSTOM: + *renderer_type = RENDERER_MC; + move16(); + BREAK; + case IVAS_AUDIO_CONFIG_MONO: + IF( EQ_32( *internal_config, IVAS_AUDIO_CONFIG_STEREO ) ) + { + /* stereo to mono downmix */ + *renderer_type = RENDERER_MC; + move16(); + } + BREAK; + case IVAS_AUDIO_CONFIG_STEREO: + IF( EQ_32( *internal_config, IVAS_AUDIO_CONFIG_MONO ) ) + { + /* mono to stereo upmix */ + *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + move16(); + } + BREAK; + default: + /* RENDERER_DISABLE already set by default */ + BREAK; + } + } +#else ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) @@ -286,6 +366,7 @@ void ivas_renderer_select( move16(); } } +#endif ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { test(); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ae2027e10..945894723 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -543,12 +543,34 @@ ivas_error IVAS_DEC_Configure( return IVAS_ERR_WRONG_PARAMS; } +#ifdef FIX_1419_MONO_STEREO_UMX + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( hIvasDec->mode, IVAS_DEC_MODE_EVS ) && + ( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_INVALID ) || + EQ_16( outputConfig, IVAS_AUDIO_CONFIG_ISM1 ) || + EQ_16( outputConfig, IVAS_AUDIO_CONFIG_ISM2 ) || + EQ_16( outputConfig, IVAS_AUDIO_CONFIG_ISM3 ) || + EQ_16( outputConfig, IVAS_AUDIO_CONFIG_ISM4 ) || + EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || + EQ_16( outputConfig, IVAS_AUDIO_CONFIG_MASA1 ) || + EQ_16( outputConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) ) +#else /* we now support all output formats, so this validation is redundant */ test(); test(); test(); test(); IF( EQ_16( hIvasDec->mode, IVAS_DEC_MODE_EVS ) && !( ( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_MONO ) && non_diegetic_pan_enabled == false ) || ( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_STEREO ) && non_diegetic_pan_enabled ) ) ) +#endif { return IVAS_ERR_WRONG_MODE; } @@ -5526,7 +5548,11 @@ static ivas_error evs_dec_main_fx( { DEC_CORE_HANDLE *hCoreCoder; Word16 mixer_left_fx, mixer_right_fx; +#ifdef FIX_1419_MONO_STEREO_UMX + Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; +#else Word32 *p_output_fx[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; +#endif Word16 ch, i, nOutSamples; Word16 output_16[L_FRAME48k]; ivas_error error; @@ -5541,9 +5567,19 @@ static ivas_error evs_dec_main_fx( mdct_switching_dec_fx( hCoreCoder[0] ); +#ifdef FIX_1419_MONO_STEREO_UMX + FOR( ch = 0; ch < MAX_TRANSPORT_CHANNELS; ch++ ) +#else FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) +#endif { p_output_fx[ch] = st_ivas->p_output_fx[ch]; // Q0 +#ifdef FIX_1419_MONO_STEREO_UMX + IF( p_output_fx[ch] != NULL ) + { + set_zero_fx( p_output_fx[ch], L_FRAME48k ); + } +#endif } /* run the main EVS decoding routine */ diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index f3f034c4d..ec49c3937 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -517,6 +517,16 @@ const LS_CONVERSION_MATRIX_FX ls_conversion_cicp19_cicp16_fx[] = // Q30 }; /* Upmix matrices */ +#ifdef FIX_1419_MONO_STEREO_UMX +const LS_CONVERSION_MATRIX_FX ls_conversion_mono_cicpX_fx[] = // Q30 +{ + /* First row indicates the number of non-zero elements and the number of matrix columns */ + {1, 12}, + /* Index of non-zero element, value of non-zero element*/ + {2, 1073741824}, +}; + +#endif const LS_CONVERSION_MATRIX_FX ls_conversion_cicp12_cicp14_fx[] = // Q30 { /* First row indicates the number of non-zero elements and the number of matrix columns */ @@ -602,6 +612,9 @@ const LS_CONVERSION_MATRIX_FX ls_conversion_cicp16_cicp19_fx[] = // Q30 const LS_CONVERSION_MAPPING_FX ls_conversion_mapping_fx[LS_SETUP_CONVERSION_NUM_MAPPINGS] = { /* Dowmix mappings - NULL is a special case for MONO / STEREO downmix */ +#ifdef FIX_1419_MONO_STEREO_UMX + {IVAS_AUDIO_CONFIG_STEREO, IVAS_AUDIO_CONFIG_MONO, NULL}, +#endif {IVAS_AUDIO_CONFIG_5_1, IVAS_AUDIO_CONFIG_MONO, NULL}, {IVAS_AUDIO_CONFIG_7_1, IVAS_AUDIO_CONFIG_MONO, NULL}, {IVAS_AUDIO_CONFIG_5_1_2, IVAS_AUDIO_CONFIG_MONO, NULL}, @@ -629,6 +642,13 @@ const LS_CONVERSION_MAPPING_FX ls_conversion_mapping_fx[LS_SETUP_CONVERSION_NUM_ {IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_5_1_4, ls_conversion_cicp19_cicp16_fx}, /* Upmix mappings - NULL implies a 1:1 upmix */ +#ifdef FIX_1419_MONO_STEREO_UMX + {IVAS_AUDIO_CONFIG_MONO, IVAS_AUDIO_CONFIG_5_1, ls_conversion_mono_cicpX_fx}, + {IVAS_AUDIO_CONFIG_MONO, IVAS_AUDIO_CONFIG_7_1, ls_conversion_mono_cicpX_fx}, + {IVAS_AUDIO_CONFIG_MONO, IVAS_AUDIO_CONFIG_5_1_2, ls_conversion_mono_cicpX_fx}, + {IVAS_AUDIO_CONFIG_MONO, IVAS_AUDIO_CONFIG_5_1_4, ls_conversion_mono_cicpX_fx}, + {IVAS_AUDIO_CONFIG_MONO, IVAS_AUDIO_CONFIG_7_1_4, ls_conversion_mono_cicpX_fx}, +#endif {IVAS_AUDIO_CONFIG_STEREO, IVAS_AUDIO_CONFIG_5_1, NULL}, {IVAS_AUDIO_CONFIG_STEREO, IVAS_AUDIO_CONFIG_7_1, NULL}, {IVAS_AUDIO_CONFIG_STEREO, IVAS_AUDIO_CONFIG_5_1_2, NULL}, -- GitLab From e2a16f744f0e647999a364cf5120629ebb69b682 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 5 Nov 2025 16:37:58 +0100 Subject: [PATCH 221/351] [fix] skip conversion to short if upmixing EVS JBM --- apps/decoder.c | 2 +- lib_dec/lib_dec_fx.c | 20 +++++++++++++++++++- readme.txt | 6 ++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 46cfd7da4..79e22b1c0 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1535,7 +1535,7 @@ static void usage_dec( void ) fprintf( stdout, "Options:\n" ); fprintf( stdout, "--------\n" ); #ifdef FIX_1419_MONO_STEREO_UMX - fprintf( stdout, "-evs : Specify EVS mode for supplied bitstream\n" ); + fprintf( stdout, "-evs : Specify that the supplied bitstream is an EVS bitstream\n" ); #endif fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 945894723..4ccc753cd 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5364,7 +5364,21 @@ static ivas_error printConfigInfo_dec( } ELSE { - fprintf( stdout, "Output configuration: mono EVS bit-exact decoding\n" ); +#ifdef FIX_1419_MONO_STEREO_UMX + output_config = st_ivas->hDecoderConfig->output_config; + IF( NE_16( (Word16) output_config, IVAS_AUDIO_CONFIG_MONO ) ) + { + get_channel_config( output_config, &config_str[0] ); + fprintf( stdout, "Output configuration: mono EVS bit-exact decoding rendering to %s\n", config_str ); + } + ELSE + { +#endif + fprintf( stdout, "Output configuration: mono EVS bit-exact decoding\n" ); +#ifdef FIX_1419_MONO_STEREO_UMX + } +#endif + ; } } ELSE @@ -5641,7 +5655,11 @@ static ivas_error evs_dec_main_fx( v_multc_fx_16( p_output_fx[0], mixer_left_fx, p_output_fx[0], nOutSamples ); /* Q11 */ } +#ifdef FIX_1419_MONO_STEREO_UMX + IF( st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->nchan_out == 1 ) +#else IF( st_ivas->hDecoderConfig->Opt_tsm ) +#endif { /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ // TODO: verify if it is still needed and if it works well for EVS stereo panning output #ifdef JBM_MEMORY_OPT diff --git a/readme.txt b/readme.txt index d272f7a8c..684c8162e 100644 --- a/readme.txt +++ b/readme.txt @@ -257,13 +257,14 @@ The usage of the "IVAS_dec" program is as follows: -------------------------------------------------- Usage for EVS: IVAS_dec.exe [Options] Fs bitstream_file output_file + OR usage for IVAS (below) with -evs option and OutputConf Usage for IVAS: IVAS_dec.exe [Options] OutputConf Fs bitstream_file output_file Mandatory parameters: --------------------- OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA, - HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, - BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT + HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, + BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT By default, channel order and loudspeaker positions are equal to the encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker layout file. See below for details. @@ -274,6 +275,7 @@ output_file : Output audio filename Options: -------- +-evs : Specify that the supplied bitstream is an EVS bitstream -VOIP : VoIP mode: RTP in G192 -VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump -VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump -- GitLab From 2492c9f7d558d3b0d376fcaa4cfbe61e2d52142d Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 7 Nov 2025 12:58:07 +0100 Subject: [PATCH 222/351] AE ID type changed from Word16 to UWord16 --- lib_com/common_api_types.h | 2 +- lib_dec/lib_dec.h | 2 +- lib_dec/lib_dec_fx.c | 12 ++++++++---- lib_rend/ivas_render_config_fx.c | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index d78ea5cef..43166628d 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -331,7 +331,7 @@ typedef enum typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - Word16 aeID; /* Acoustic environment ID */ + UWord16 aeID; /* Acoustic environment ID */ #endif Word16 nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ Word32 pFc_input_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; /*Q16 Center frequencies for which following values are provided: */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 4a15804fd..6f38b2688 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -454,7 +454,7 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( ivas_error IVAS_DEC_GetAcousticEnvironment( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - Word16 aeID, /* i : Acoustic environment ID */ + UWord16 aeID, /* i : Acoustic environment ID */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Room acoustic environment data pointer */ ); #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 8dd90473f..9edc65c52 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -596,7 +596,11 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_delay_comp = (Word16) delayCompensationEnabled; hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; hDecoderConfig->Opt_dpid_on = (Word16) dpidEnabled; +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + IF( NE_32( (UWord16) acousticEnvironmentId, IVAS_DEFAULT_AEID ) ) +#else IF( NE_32( (Word32) acousticEnvironmentId, 65535 ) ) +#endif { hDecoderConfig->Opt_aeid_on = TRUE; } @@ -3032,7 +3036,7 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetAcousticEnvironment( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - Word16 aeID, /* i : Acoustic environment ID */ + UWord16 aeID, /* i : Acoustic environment ID */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Room acoustic environment data pointer */ ) { @@ -3051,9 +3055,9 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( /* In case of default AE ID, select the first one available */ test(); - IF( aeID == (Word16) IVAS_DEFAULT_AEID && st_ivas->acousticEnvironmentsCount > 0 ) + IF( aeID == (UWord16) IVAS_DEFAULT_AEID && st_ivas->acousticEnvironmentsCount > 0 ) { - aeID = (uint16_t) st_ivas->pAcousticEnvironments[0].aeID; + aeID = (UWord16) st_ivas->pAcousticEnvironments[0].aeID; move32(); } @@ -6785,7 +6789,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT case IVAS_PI_ACOUSTIC_ENVIRONMENT: { - Word16 aeid = piData->data.acousticEnv.aeid; + UWord16 aeid = piData->data.acousticEnv.aeid; #ifdef DEBUGGING fprintf( stdout, "PI_ACOUSTIC_ENVIRONMENT : AEID : %d\n", aeid ); #endif diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 25c1aa4d4..5bca8f1b3 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -108,7 +108,7 @@ ivas_error ivas_render_config_init_from_rom_fx( return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - ( *hRenderConfig )->roomAcoustics.aeID = (Word16) IVAS_DEFAULT_AEID; + ( *hRenderConfig )->roomAcoustics.aeID = (UWord16) IVAS_DEFAULT_AEID; move16(); #endif ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; -- GitLab From b6d4ff5dae90009139baae9bd22f2761ab702674 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 7 Nov 2025 13:01:42 +0100 Subject: [PATCH 223/351] fix bug in SPAR active W channel cross-fade process --- lib_com/options.h | 2 ++ lib_enc/ivas_spar_encoder_fx.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index f658a0ace..25d9aa3d1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,8 @@ #define FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING /* Orange: Fix for issue 2184 - to prevent one channel from becoming inaudible in the mono downmix output */ #define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue */ +#define BE_FIX_1391_COVERAGE_SPAR_DYN__CHANNEL /* Dolby: Fix coverage of SBA SPAR Dynamic active W not getting hit by the tests */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 0b1f77245..623e32069 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -929,7 +929,11 @@ static ivas_error ivas_spar_enc_process_fx( IF( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { /*cross fade between new active W channels and old passive W channel*/ +#ifdef BE_FIX_1391_COVERAGE_SPAR_DYN__CHANNEL + IF( EQ_16( dyn_active_w_flag, 1 ) || EQ_16( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag, 1 ) ) +#else IF( EQ_16( dyn_active_w_flag, 1 ) ) +#endif { IF( NE_16( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag, dyn_active_w_flag ) ) { -- GitLab From 97987082ae70f1d565b7cfd19b881ae628361ed4 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 7 Nov 2025 13:10:33 +0100 Subject: [PATCH 224/351] AE ID type changed from Word16 to UWord16 --- lib_util/render_config_reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 1fb664954..5311b54c5 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2944,7 +2944,7 @@ ivas_error RenderConfigReader_getAcousticEnvironment( /* case when -aeid is not specified, select first ID from config file */ #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - if ( id == (Word16) IVAS_DEFAULT_AEID && pRenderConfigReader->nAE > 0 ) + if ( id == (UWord16) IVAS_DEFAULT_AEID && pRenderConfigReader->nAE > 0 ) #else if ( id == 65535 && pRenderConfigReader->nAE > 0 ) #endif -- GitLab From 637f5534b25e9d6c90351e8da3ebb734657b194b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 7 Nov 2025 13:41:13 +0100 Subject: [PATCH 225/351] [fix] missing instrumentation in port --- lib_dec/lib_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4ccc753cd..d024de80f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5378,7 +5378,6 @@ static ivas_error printConfigInfo_dec( #ifdef FIX_1419_MONO_STEREO_UMX } #endif - ; } } ELSE @@ -5656,7 +5655,8 @@ static ivas_error evs_dec_main_fx( } #ifdef FIX_1419_MONO_STEREO_UMX - IF( st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->nchan_out == 1 ) + test(); + IF( st_ivas->hDecoderConfig->Opt_tsm && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) #else IF( st_ivas->hDecoderConfig->Opt_tsm ) #endif -- GitLab From c5be9be8994949209a55da00442ca8e0521cc850 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 7 Nov 2025 13:42:04 +0100 Subject: [PATCH 226/351] Dummy commit -- GitLab From 1d57306ebe0b98c48f42d881f98088e47d8b33df Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 7 Nov 2025 13:55:15 +0100 Subject: [PATCH 227/351] [fix] missing ELSE --- lib_dec/ivas_output_config_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index cace50215..f20d9f312 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -303,8 +303,7 @@ void ivas_renderer_select( *-----------------------------------------------------------------*/ #ifdef FIX_1419_MONO_STEREO_UMX - test(); - IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { *internal_config = EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO; move16(); -- GitLab From 817f497ac3577d77067cf4074ab1a146c5e1d3d9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 7 Nov 2025 13:58:49 +0100 Subject: [PATCH 228/351] report an error if both non-diegetic panning and stereo output format specified on commandline --- apps/decoder.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 79e22b1c0..f40e1ae5e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1424,6 +1424,15 @@ static bool parseCmdlIVAS_dec( usage_dec(); return false; } +#ifdef FIX_1419_MONO_STEREO_UMX + else if ( arg->non_diegetic_pan_enabled && arg->outputConfig == IVAS_AUDIO_CONFIG_STEREO && arg->evsMode ) + { + fprintf( stderr, "Error: Both non-diegetic panning and stereo output specified!\n\n" ); + usage_dec(); + return false; + } + +#endif if ( arg->outputMdFilename != NULL && arg->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { fprintf( stderr, "Error: Output split rendering metadata file is supported for BINAURAL_SPLIT_PCM output config. only\n\n" ); -- GitLab From 9ae4502d115191d7080a64683297fb60e4fdffee Mon Sep 17 00:00:00 2001 From: lintervo Date: Fri, 7 Nov 2025 15:54:04 +0200 Subject: [PATCH 229/351] Align macros with float --- lib_com/ivas_cnst.h | 8 ++++---- lib_dec/lib_dec_fx.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index ac4866090..e1e5f558d 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -203,10 +203,10 @@ typedef enum #define MAX_CLDFB_DIGEST_CHANNELS 3 /* == maximum of ParamISM TCs and ParamMC TCs */ #ifdef FIX_GAIN_EDIT_LIMITS -#define OBJ_EDIT_GAIN_MIN_Q29 33874260 /* Minimum allowed object gain edit with parametric modes in Q29: 0.0630957f, -24 dB */ -#define OBJ_EDIT_GAIN_MAX_Q29 2137321728 /* Maximum allowed object gain edit in Q29: 3.9810719f, +12 dB */ -#define OBJ_EDIT_GAIN_MIN_Q12 258 /* Minimum allowed object gain edit with parametric modes in Q12: 0.0630957f, -24 dB */ -#define OBJ_EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ +#define EDIT_GAIN_MIN_Q29 33874260 /* Minimum allowed object gain edit with parametric modes in Q29: 0.0630957f, -24 dB */ +#define EDIT_GAIN_MAX_Q29 2137321728 /* Maximum allowed object gain edit in Q29: 3.9810719f, +12 dB */ +#define EDIT_GAIN_MIN_Q12 258 /* Minimum allowed object gain edit with parametric modes in Q12: 0.0630957f, -24 dB */ +#define EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index cd6423d97..c6a2043dc 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4323,9 +4323,9 @@ ivas_error IVAS_DEC_SetEditableParameters( st_ivas->hIsmMetaData[obj]->edited_pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; move32(); #ifdef FIX_GAIN_EDIT_LIMITS - IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) ) { - st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MAX_Q29; + st_ivas->hIsmMetaData[obj]->edited_gain_fx = EDIT_GAIN_MAX_Q29; move32(); } ELSE @@ -4344,9 +4344,9 @@ ivas_error IVAS_DEC_SetEditableParameters( IF( EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) { #ifdef FIX_GAIN_EDIT_LIMITS - IF( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MAX_Q29 ) ) { - st_ivas->hSbaIsmData->gain_bed_fx = OBJ_EDIT_GAIN_MAX_Q29; + st_ivas->hSbaIsmData->gain_bed_fx = EDIT_GAIN_MAX_Q29; move32(); } ELSE @@ -4375,14 +4375,14 @@ ivas_error IVAS_DEC_SetEditableParameters( { #ifdef FIX_GAIN_EDIT_LIMITS /* Limit gain edit to a range of +12dB to -24dB with parametric ISM mode */ - IF( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MAX_Q29 ) ) { - st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MAX_Q12; // Q12 + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = EDIT_GAIN_MAX_Q12; // Q12 move16(); } - ELSE IF( LT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) + ELSE IF( LT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MIN_Q29 ) ) { - st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MIN_Q12; // Q12 + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = EDIT_GAIN_MIN_Q12; // Q12 move16(); } ELSE @@ -4537,14 +4537,14 @@ ivas_error IVAS_DEC_SetEditableParameters( #ifdef FIX_GAIN_EDIT_LIMITS /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */ test(); - IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) ) { - st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MAX_Q12; + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = EDIT_GAIN_MAX_Q12; move16(); } - ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MIN_Q29 ) ) { - st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = OBJ_EDIT_GAIN_MIN_Q12; + st_ivas->hMasaIsmData->gain_ism_edited_fx[obj] = EDIT_GAIN_MIN_Q12; move16(); } ELSE @@ -4591,13 +4591,13 @@ ivas_error IVAS_DEC_SetEditableParameters( #endif #ifdef FIX_GAIN_EDIT_LIMITS test(); - IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) ) { - st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MAX_Q29; + st_ivas->hIsmMetaData[obj]->edited_gain_fx = EDIT_GAIN_MAX_Q29; } - ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MIN_Q29 ) ) { - st_ivas->hIsmMetaData[obj]->edited_gain_fx = OBJ_EDIT_GAIN_MIN_Q29; + st_ivas->hIsmMetaData[obj]->edited_gain_fx = EDIT_GAIN_MIN_Q29; } ELSE { @@ -4617,14 +4617,14 @@ ivas_error IVAS_DEC_SetEditableParameters( #ifdef FIX_GAIN_EDIT_LIMITS /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */ test(); - IF( GT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MAX_Q29 ) ) + IF( GT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MAX_Q29 ) ) { - st_ivas->hMasaIsmData->gain_masa_edited_fx = OBJ_EDIT_GAIN_MAX_Q12; + st_ivas->hMasaIsmData->gain_masa_edited_fx = EDIT_GAIN_MAX_Q12; move16(); } - ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.gain_bed_fx, OBJ_EDIT_GAIN_MIN_Q29 ) ) + ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && LT_32( hIvasEditableParameters.gain_bed_fx, EDIT_GAIN_MIN_Q29 ) ) { - st_ivas->hMasaIsmData->gain_masa_edited_fx = OBJ_EDIT_GAIN_MIN_Q12; + st_ivas->hMasaIsmData->gain_masa_edited_fx = EDIT_GAIN_MIN_Q12; move16(); } ELSE -- GitLab From 0276cdb99df9e2fce1c125bf46a8e0269394d3b3 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 7 Nov 2025 17:48:42 +0100 Subject: [PATCH 230/351] ISAR PLC crash fix --- lib_com/options.h | 2 ++ lib_isar/isar_splitRend_lcld_dec.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index f658a0ace..9158b9ec8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,8 @@ #define FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING /* Orange: Fix for issue 2184 - to prevent one channel from becoming inaudible in the mono downmix output */ #define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue */ +#define FIX_2200_ISAR_PLC_CRASH /* Dolby: Fix for ISAR PLC crash observed with newly added BASOP tests */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index e1ddadf35..56446b755 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -225,6 +225,7 @@ void isar_splitBinLCLDDecProcess( #endif IF( AnyDecodingFailed( hSplitBinLCLDDec->psLCLDDecoder ) ) { +#ifndef FIX_2200_ISAR_PLC_CRASH IF( NE_16( *Q_cldfb_final, 11 ) ) { FOR( n = 0; n < hSplitBinLCLDDec->iChannels; n++ ) @@ -240,12 +241,20 @@ void isar_splitBinLCLDDecProcess( } *Q_cldfb_final = 11; } +#else + *Q_cldfb_final = hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx; +#endif + /* continue concealing */ isar_splitBinRendPLC( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (Word16) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), *Q_cldfb_final ); } IF( AnyDecodingFailedPrev( hSplitBinLCLDDec->psLCLDDecoder ) ) { +#ifndef FIX_2200_ISAR_PLC_CRASH IF( NE_16( *Q_cldfb_final, 11 ) ) +#else + IF( GT_16( *Q_cldfb_final, hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx ) ) +#endif { FOR( n = 0; n < hSplitBinLCLDDec->iChannels; n++ ) { @@ -253,12 +262,21 @@ void isar_splitBinLCLDDecProcess( { FOR( Word16 j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { +#ifndef FIX_2200_ISAR_PLC_CRASH hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k][j] = L_shl_r( hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k][j], sub( 11, *Q_cldfb_final ) ); // Q11 hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k][j] = L_shl_r( hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k][j], sub( 11, *Q_cldfb_final ) ); // Q11 +#else + hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k][j] = L_shl_r( hSplitBinLCLDDec->pppfDecLCLDReal_fx[n][k][j], sub( hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx, *Q_cldfb_final ) ); // hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx + hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k][j] = L_shl_r( hSplitBinLCLDDec->pppfDecLCLDImag_fx[n][k][j], sub( hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx, *Q_cldfb_final ) ); // hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx +#endif } } } +#ifndef FIX_2200_ISAR_PLC_CRASH *Q_cldfb_final = 11; +#else + *Q_cldfb_final = hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx; +#endif } /* cross-fade recovered frame into good frame */ isar_splitBinRendPLC_xf_fx( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (Word16) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), GetDecodingFailedPrevStatus( hSplitBinLCLDDec->psLCLDDecoder ), *Q_cldfb_final ); @@ -270,6 +288,10 @@ void isar_splitBinLCLDDecProcess( /* set states in decoder */ SetDecodingUnresolved( hSplitBinLCLDDec->psLCLDDecoder ); +#ifdef FIX_2200_ISAR_PLC_CRASH + *Q_cldfb_final = hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx; +#endif + /* do PLC for lost split renderer frame */ isar_splitBinRendPLC( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (Word16) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), *Q_cldfb_final ); } -- GitLab From c96090f272ca50a5e0fea57bc5749c937bf01d92 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 7 Nov 2025 18:00:08 +0100 Subject: [PATCH 231/351] Dummy commit -- GitLab From 398f1cd94f7a8b0de2cf699571187ffcd23b411c Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Sat, 8 Nov 2025 16:15:39 +0100 Subject: [PATCH 232/351] temporary modification to test the fix --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93d77386f..52a9ddfa1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,8 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main + # IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF vlad/ci-test-fix-2200-ISAR_crash include: - project: ivas-codec-pc/ivas-codec-ci -- GitLab From 5f13d91cab2f6e7abd0c63bb7f058048fac064a2 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sat, 8 Nov 2025 20:21:03 +0100 Subject: [PATCH 233/351] Restore pointer to ivas-codec-ci main --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b8835761a..93d77386f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF ci/add-conformance-basop + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main include: - project: ivas-codec-pc/ivas-codec-ci -- GitLab From 00ccfe9ce400b966454fc241d1e2102f52a17ef6 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Sun, 9 Nov 2025 17:34:52 +0100 Subject: [PATCH 234/351] restore the pointer to the main ref branch in CI --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 52a9ddfa1..93d77386f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - # IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF vlad/ci-test-fix-2200-ISAR_crash + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main include: - project: ivas-codec-pc/ivas-codec-ci -- GitLab From 5eb81405ad074b4accebecaf06ecd21767f16eb5 Mon Sep 17 00:00:00 2001 From: Sumeyra Kanik Date: Mon, 10 Nov 2025 11:10:27 +0100 Subject: [PATCH 235/351] Port changes from float --- apps/decoder.c | 5 +++-- lib_com/common_api_types.h | 10 +++++++--- lib_dec/lib_dec_fx.c | 12 ++++++++++++ lib_util/obj_edit_file_reader.h | 5 +++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index d6e369b1f..c24028565 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3560,8 +3560,9 @@ static void do_object_editing_fx( { if ( readInfo->obj_radius_relative[obj_idx] ) { - /* radius: apply relative edit + saturation */ - editableParameters->ism_metadata[obj_idx].radius_fx = L_max( L_min( L_shl_sat( Mpy_32_32( editableParameters->ism_metadata[obj_idx].radius_fx, (Word32) ( readInfo->obj_radius[obj_idx] * 536870912 ) ), 2 ), OBJ_EDIT_RADIUS_MAX_FX ), 0.0 ); /* Q29*Q29 -> Q27 shift back to Q29 */ + /* radius: apply relative edit + saturation */ + Word32 temp_result = L_shl_sat( Mpy_32_32( editableParameters->ism_metadata[obj_idx].radius_fx, (Word32) ( readInfo->obj_radius[obj_idx] * (Word32) 536870912L ) ), 2 ); + editableParameters->ism_metadata[obj_idx].radius_fx = L_max( L_min( temp_result, OBJ_EDIT_RADIUS_MAX_FX ), 0 ); /* Q29*Q29 -> Q27 shift back to Q29 */ } else { diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 6259b5f8d..c8238e56f 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -125,9 +125,13 @@ typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG typedef struct _IVAS_ISM_METADATA { - Word32 azimuth_fx; /* Q22 */ - Word32 elevation_fx; /* Q22 */ - Word16 radius_fx; /* Q9 */ + Word32 azimuth_fx; /* Q22 */ + Word32 elevation_fx; /* Q22 */ +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA + Word32 radius_fx; /* Q29 */ +#else + Word16 radius_fx; /* Q9 */ +#endif Word32 spread_fx; /* Q22 */ Word32 gainFactor_fx; /* Q29 */ Word32 yaw_fx; /* Q22 */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 382d72dd2..bf4c0d7a1 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4593,12 +4593,24 @@ ivas_error IVAS_DEC_SetEditableParameters( move32(); st_ivas->hIsmMetaData[obj]->edited_elevation_fx = hIvasEditableParameters.ism_metadata[obj].elevation_fx; move32(); +#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA + IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) + { + st_ivas->hIsmMetaData[obj]->edited_yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; + move32(); + st_ivas->hIsmMetaData[obj]->edited_pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; + move32(); + st_ivas->hIsmMetaData[obj]->edited_radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; + move32(); + } +#else st_ivas->hIsmMetaData[obj]->edited_yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; move32(); st_ivas->hIsmMetaData[obj]->edited_pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; move32(); st_ivas->hIsmMetaData[obj]->edited_radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; move32(); +#endif #ifndef NONBE_FIX_1172_OBJ_EDIT_JBM st_ivas->hIsmMetaData[obj]->azimuth_fx = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; move32(); diff --git a/lib_util/obj_edit_file_reader.h b/lib_util/obj_edit_file_reader.h index e3e6156d4..4f6e7ee20 100644 --- a/lib_util/obj_edit_file_reader.h +++ b/lib_util/obj_edit_file_reader.h @@ -54,8 +54,9 @@ the United Nations Convention on Contracts on the International Sales of Goods. #endif #ifdef FIX_2192_OBJ_EDITING_EXT_METADATA -#define OBJ_EDIT_RADIUS_MAX 15.75f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ -#define OBJ_EDIT_RADIUS_MAX_FX 8452702364 /* Q29, 15.75f */ +#define OBJ_EDIT_RADIUS_MAX 15.75f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ +#define OBJ_EDIT_RADIUS_MAX_FX 8455716864LL /* Q29, 15.75f */ +#define OBJ_EDIT_RADIUS_MIN_FX 0 #endif typedef struct ObjectEditFileReader ObjectEditFileReader; -- GitLab From 09109881bd36dd04438dc2a41e04be1437161401 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Nov 2025 12:53:42 +0100 Subject: [PATCH 236/351] synchronize with float-main --- Workspace_msvc/lib_rend.vcxproj.filters | 3 + lib_com/common_api_types.h | 6 +- lib_dec/lib_dec.h | 6 +- lib_dec/lib_dec_fx.c | 132 +++++++++--------------- 4 files changed, 61 insertions(+), 86 deletions(-) diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 0892a4dcb..dfa1253eb 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -119,6 +119,9 @@ rend_c + + rend_c + diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 6259b5f8d..4f144044b 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -156,7 +156,6 @@ typedef struct _IVAS_EDITABLE_PARAMETERS typedef struct { - // float w, x, y, z; Word32 w_fx, x_fx, y_fx, z_fx; Word16 q_fact; @@ -168,6 +167,7 @@ typedef struct float x, y, z; Word32 x_fx, y_fx, z_fx; Word16 q_fact; + } IVAS_VECTOR3; typedef enum @@ -326,8 +326,8 @@ typedef enum IVAS_RENDER_TYPE_OVERRIDE_FASTCONV } IVAS_RENDER_TYPE_OVERRIDE; -#endif +#endif typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { Word16 nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ @@ -342,8 +342,8 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG Word32 lowComplexity; /* Low complexity ER flag */ IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ float AbsCoeff[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ - IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ Word32 AbsCoeff_fx[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ + IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ } IVAS_ROOM_ACOUSTICS_CONFIG_DATA; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index e911a5fca..f58d8a819 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -206,12 +206,14 @@ ivas_error IVAS_DEC_GetCldfbSamples( Word16 *nOutSamples /* o : number of samples per channel written to output buffer */ ); -Word16 IVAS_DEC_is_split_rendering_enabled( +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_enabled( IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ Word16 *isSplitRend /* o : flag to indicate if split rendering is enabled */ ); -Word16 IVAS_DEC_is_split_rendering_coded_out( +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_coded_out( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ Word16 *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 382d72dd2..b65fda0da 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -31,9 +31,6 @@ *******************************************************************************************************/ #include "lib_dec.h" -#include -#include -#include #include "ivas_cnst.h" #include "ivas_prot_rend_fx.h" #include "prot_fx.h" @@ -122,17 +119,17 @@ static ivas_error ivas_dec_setup_all( IVAS_DEC_HANDLE hIvasDec, UWord8 *nTranspo static ivas_error ivas_dec_setup_all( IVAS_DEC_HANDLE hIvasDec, UWord8 *nTransportChannels, const Word16 isSplitRend, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); #endif static ivas_error apa_setup( IVAS_DEC_HANDLE hIvasDec, const bool isInitialized_voip, const UWord16 nTransportChannels ); +static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); +static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas ); +static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); +static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); #ifdef FIX_1119_SPLIT_RENDERING_VOIP static Word16 get_render_frame_size_samples( const DECODER_CONFIG_HANDLE hDecoderConfig ); static Word16 ivas_dec_split_rend_cldfb_in( const RENDERER_TYPE renderer_type ); #endif static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered ); -static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); -static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); -static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas ); -static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); -static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); /*---------------------------------------------------------------------* @@ -412,11 +409,11 @@ void IVAS_DEC_Close( ( *phIvasDec )->hVoIP = NULL; } - /* destroy Split binaural renderer (ISAR) handle */ - ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend ); - IF( ( *phIvasDec )->st_ivas ) { + /* destroy Split binaural renderer (ISAR) handle */ + ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend ); + ivas_destroy_dec_fx( ( *phIvasDec )->st_ivas ); ( *phIvasDec )->st_ivas = NULL; } @@ -1091,15 +1088,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { return error; } - Word32 ivas_total_brate = hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate; - move32(); - test(); - IF( ( EQ_16( hIvasDec->st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_16( hIvasDec->st_ivas->mc_mode, MC_MODE_PARAMMC ) ) ) - { - MC_LS_SETUP mc_ls_setup; - mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup_fx( hIvasDec->st_ivas->transport_config ); - hIvasDec->st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels_fx( ivas_total_brate, mc_ls_setup ); - } test(); IF( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) @@ -1119,6 +1107,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( move32(); } #endif + hIvasDec->isInitialized = true; move16(); } @@ -1130,33 +1119,6 @@ ivas_error IVAS_DEC_FeedFrame_Serial( move16(); } - /* Update redundant frame information in EVS (pre- read indices) */ - test(); - test(); - IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) && hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) - { - DEC_CORE_HANDLE st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; - st->bit_stream = serial; - - test(); - IF( hIvasDec->hVoIP->hCurrentDataUnit->partial_frame || st->prev_use_partial_copy ) - { - st->next_coder_type = hIvasDec->hVoIP->hCurrentDataUnit->nextCoderType; - } - ELSE - { - st->next_coder_type = INACTIVE; - } - move16(); - - test(); - if ( EQ_16( (Word16) hIvasDec->hVoIP->hCurrentDataUnit->partial_frame, 1 ) && NE_16( bfi, 1 ) ) - { - bfi = 2; - move16(); - } - } - IF( NE_32( ( error = read_indices_fx( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ), IVAS_ERR_OK ) ) { return error; @@ -1188,6 +1150,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( return IVAS_ERR_OK; } + #ifdef FIX_1119_SPLIT_RENDERING_VOIP /*---------------------------------------------------------------------* * isar_get_frame_size( ) @@ -1613,11 +1576,11 @@ ivas_error IVAS_DEC_GetSamplesRenderer( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSplitBinauralBitstream( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - Word16 *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : indication that the decoder needs a new frame */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + Word16 *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP @@ -2161,7 +2124,7 @@ static Word16 getOutputBufferSize( IF( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - return extract_l( Mult_32_16( imult3216( st_ivas->hDecoderConfig->output_Fs, ( RENDERER_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) ), INV_FRAME_PER_SEC_Q15 ) ); + return extract_l( Mult_32_16( imult3216( st_ivas->hDecoderConfig->output_Fs, ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ) ), INV_FRAME_PER_SEC_Q15 ) ); } ELSE IF( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -2249,10 +2212,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 UWord16 zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ - const UWord16 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 UWord16 zero_flag, /* i : if this flag is enabled, this function outputs a zero-initialized metadata struct */ + const UWord16 objectIdx /* i : index of the queried object */ ) { Decoder_Struct *st_ivas; @@ -2685,7 +2648,7 @@ ivas_error IVAS_DEC_FeedCustomLsData( /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfTDrendHandle( ) * - * + * Get TD binaural renderer handle *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetHrtfTDrendHandle( @@ -2709,7 +2672,7 @@ ivas_error IVAS_DEC_GetHrtfTDrendHandle( /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfCRendHandle( ) * - * + * Get Crend binaural renderer handle *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetHrtfCRendHandle( @@ -2733,7 +2696,7 @@ ivas_error IVAS_DEC_GetHrtfCRendHandle( /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfFastConvHandle( ) * - * + * Get FastConv binaural renderer handle *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetHrtfFastConvHandle( @@ -2757,7 +2720,7 @@ ivas_error IVAS_DEC_GetHrtfFastConvHandle( /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfParamBinHandle( ) * - * + * Get Parametric binaural renderer handle *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetHrtfParamBinHandle( @@ -2781,7 +2744,7 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfStatisticsHandle( ) * - * + * Get HRTF statistics (room effect) binaural renderer handle *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetHrtfStatisticsHandle( @@ -3106,7 +3069,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( } } - /* FB reverberator */ + /* Parametric renderer reverberator */ test(); IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->hReverb != NULL ) { @@ -3118,8 +3081,8 @@ ivas_error IVAS_DEC_FeedRenderConfig( } } + /* FastConv renderer reverberator */ test(); - /* Fastconv CLDFB reverberator */ IF( st_ivas->hBinRenderer != NULL && st_ivas->hBinRenderer->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &( st_ivas->hBinRenderer->hReverb ) ); @@ -3139,6 +3102,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( IF( hRenderConfig->split_rend_config.dof == 0 ) { hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + move16(); } IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, hRenderConfig ) ) @@ -3156,7 +3120,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( /*---------------------------------------------------------------------* * IVAS_DEC_GetDelay( ) * - * + * Return IVAS decoder delay in nanoseconds *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetDelay( @@ -3454,7 +3418,7 @@ ivas_error IVAS_DEC_VoIP_SetScale( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - IF( !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == 0 ) { return IVAS_ERR_TSM_NOT_ENABLED; } @@ -3829,10 +3793,11 @@ static ivas_error apa_exec_evs_wrapper( } #endif + /*---------------------------------------------------------------------* * 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( @@ -4093,12 +4058,13 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /*---------------------------------------------------------------------* * IVAS_DEC_GetEditableParameters( ) * - * + * Get editable metadata parameters *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters /* o : object editing parameters handle */ +) { Word16 obj, dirac_read_idx; Decoder_Struct *st_ivas; @@ -4284,12 +4250,13 @@ ivas_error IVAS_DEC_GetEditableParameters( /*---------------------------------------------------------------------* * IVAS_DEC_SetEditableParameters( ) * - * Main function to decode to PCM data + * Set editable metadata parameters *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_SetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters /* i : object editing parameters handle */ +) { Word16 dirac_read_idx, obj; Decoder_Struct *st_ivas; @@ -4830,7 +4797,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif - /* avoid time scaling multiple times in one sound card slot */ + /* avoid time scaling multiple times within one 20ms frame*/ IF( NE_64( scale, 100U ) ) { IF( hIvasDec->timeScalingDone ) @@ -5190,7 +5157,6 @@ ivas_error IVAS_DEC_Flush( ivas_error error; UWord16 nSamplesToRender; UWord16 nSamplesFlushedLocal; - nSamplesFlushedLocal = 0; // temp. hack test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -5223,12 +5189,12 @@ ivas_error IVAS_DEC_Flush( *nSamplesFlushed = 0; move16(); } + #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR hIvasDec->st_ivas->flushing = 0; move16(); #endif - return error; } @@ -5240,8 +5206,9 @@ ivas_error IVAS_DEC_Flush( *---------------------------------------------------------------------*/ bool IVAS_DEC_VoIP_IsEmpty( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const Word16 nSamplesAsked /* i : number of output samples asked */ +) { test(); IF( hIvasDec == NULL || hIvasDec->hVoIP == NULL ) @@ -5962,7 +5929,8 @@ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ Word16 *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ Word16 *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ - Word16 *pLc3plusHighRes ) + Word16 *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ +) { test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -6137,7 +6105,8 @@ static void ivas_destroy_handle_isar( * *---------------------------------------------------------------------*/ -Word16 IVAS_DEC_is_split_rendering_enabled( +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_enabled( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ Word16 *isSplitRend /* o : flag to indicate if split rendering is enabled */ ) @@ -6447,7 +6416,8 @@ static ivas_error ivas_dec_init_split_rend( * Return flag to indicate if split rendering is enabled *---------------------------------------------------------------------*/ -Word16 IVAS_DEC_is_split_rendering_coded_out( +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_coded_out( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ Word16 *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ) -- GitLab From a5c226d73dcd818280126138e0d54c7b901eeeba Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 14:23:24 +0200 Subject: [PATCH 237/351] Port float MR2369 reverse direction ISM PI --- lib_com/options.h | 1 + lib_util/ivas_rtp_file.c | 42 ++++++ lib_util/ivas_rtp_internal.h | 3 + lib_util/ivas_rtp_pi_data.c | 266 +++++++++++++++++++++++++++++++++++ lib_util/ivas_rtp_pi_data.h | 32 +++++ 5 files changed, 344 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c6a4efa4b..9f6426547 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ +#define REVERSE_ISM_PI_DATA /* Add reading and packing/unpacking of reverse ISM PI data */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 82f198135..cf721edf4 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -189,7 +189,9 @@ void IVAS_RTP_LogPiData( #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: case IVAS_PI_HEAD_ORIENTATION: +#ifndef REVERSE_ISM_PI_DATA case IVAS_PI_R_ISM_ORIENTATION: +#endif #endif { fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", @@ -218,7 +220,9 @@ void IVAS_RTP_LogPiData( break; #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_LISTENER_POSITION: +#ifndef REVERSE_ISM_PI_DATA case IVAS_PI_R_ISM_POSITION: +#endif { fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", cur->data.listnerPosition.position.x, cur->data.listnerPosition.position.y, cur->data.listnerPosition.position.z ); @@ -343,8 +347,46 @@ void IVAS_RTP_LogPiData( case IVAS_PI_ISM_DIRECTIVITY: case IVAS_PI_PI_LATENCY: case IVAS_PI_R_ISM_ID: +#ifdef REVERSE_ISM_PI_DATA + { + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"id\": %d", cur->data.ismEditId.id ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; +#endif case IVAS_PI_R_ISM_GAIN: +#ifdef REVERSE_ISM_PI_DATA + { + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"gain\": %d", cur->data.ismEditGain.dB ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_R_ISM_ORIENTATION: + { + fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", + fixedToFloat( cur->data.ismEditOrientation.orientation.w_fx, Q15 ), + fixedToFloat( cur->data.ismEditOrientation.orientation.x_fx, Q15 ), + fixedToFloat( cur->data.ismEditOrientation.orientation.y_fx, Q15 ), + fixedToFloat( cur->data.ismEditOrientation.orientation.z_fx, Q15 ) ); + } + break; + case IVAS_PI_R_ISM_POSITION: + { + fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", + cur->data.ismEditPosition.position.x, cur->data.ismEditPosition.position.y, cur->data.ismEditPosition.position.z ); + } + break; +#endif case IVAS_PI_R_ISM_DIRECTION: +#ifdef REVERSE_ISM_PI_DATA + { + fprintf( f_piDataOut, "{\n\t\t\t\"azi\": %f,\n\t\t\t\"elev\": %f \n\t\t}", + cur->data.ismEditDirection.azimuth, cur->data.ismEditDirection.elevation ); + } + break; +#endif #endif /* RTP_S4_251135_CR26253_0016_REV1 */ case IVAS_PI_NO_DATA: { diff --git a/lib_util/ivas_rtp_internal.h b/lib_util/ivas_rtp_internal.h index 032717d8f..8ee65bbe9 100644 --- a/lib_util/ivas_rtp_internal.h +++ b/lib_util/ivas_rtp_internal.h @@ -48,6 +48,9 @@ enum MASK_BITS MASK_6BIT = 0x3F, MASK_7BIT = 0x7F, MASK_8BIT = 0xFF, +#ifdef REVERSE_ISM_PI_DATA + MASK_9BIT = 0x1FF, +#endif }; diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index be2e9dd4d..6a55a64fb 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -32,6 +32,9 @@ #include "ivas_error_utils.h" #include "ivas_rtp_internal.h" +#ifdef REVERSE_ISM_PI_DATA +#include +#endif #ifdef IVAS_RTPDUMP @@ -427,6 +430,56 @@ static ivas_error unpackDynamicSuppression( const uint8_t *buffer, uint32_t numD return IVAS_ERR_OK; } +#ifdef REVERSE_ISM_PI_DATA +static ivas_error packPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + const IVAS_PIDATA_POSITION *position = (const IVAS_PIDATA_POSITION *) piData; + + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_POSITION ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in position PI data" ); + } + + if ( piData->piDataType != IVAS_PI_LISTENER_POSITION && piData->piDataType != IVAS_PI_R_ISM_POSITION ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in position PI data" ); + } + + /* Position data is 6 bytes, header is 2 bytes */ + if ( maxDataBytes < 6 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack position PI data" ); + } + + buffer[nBytes++] = ( position->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = 6; + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.x / MAX_PI_POSITION_METERS ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.y / MAX_PI_POSITION_METERS ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( position->position.z / MAX_PI_POSITION_METERS ) ); + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackPosition( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_POSITION *position = (IVAS_PIDATA_POSITION *) piData; + + /* Position data is 6 bytes */ + if ( numDataBytes != 6 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack position PI data" ); + } + + position->size = sizeof( IVAS_PIDATA_POSITION ); + position->position.x = FLOAT_FROM_Q15( readInt16( &buffer[0] ) ) * MAX_PI_POSITION_METERS; + position->position.y = FLOAT_FROM_Q15( readInt16( &buffer[2] ) ) * MAX_PI_POSITION_METERS; + position->position.z = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ) * MAX_PI_POSITION_METERS; + return IVAS_ERR_OK; +} +#else static ivas_error packListenerPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; @@ -476,6 +529,7 @@ static ivas_error unpackListenerPosition( const uint8_t *buffer, uint32_t numDat listener->position.z = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ) * MAX_PI_POSITION_METERS; return IVAS_ERR_OK; } +#endif static ivas_error packDiegetic( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { @@ -630,6 +684,189 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat return IVAS_ERR_OK; } +#ifdef REVERSE_ISM_PI_DATA +static ivas_error packReverseISMID( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + const IVAS_PIDATA_ISM_EDIT_ID *r_ism_id = (const IVAS_PIDATA_ISM_EDIT_ID *) piData; + + *nBytesWritten = 0; + + if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_ID ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_ID PI data" ); + } + + if ( piData->piDataType != IVAS_PI_R_ISM_ID ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in R_ISM_ID PI data" ); + } + + /* R_ISM_ID data is 1 byte, header is 2 bytes */ + if ( maxDataBytes < 1 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_NUM PI data" ); + } + + buffer[nBytes++] = ( r_ism_id->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = ( r_ism_id->id & MASK_8BIT ); + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackReverseISMID( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_ISM_EDIT_ID *r_ism_id = (IVAS_PIDATA_ISM_EDIT_ID *) piData; + + /* ISM_ID data is 1 byte*/ + if ( numDataBytes > 1 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_ID PI data" ); + } + + r_ism_id->size = sizeof( IVAS_PIDATA_ISM_EDIT_ID ); + r_ism_id->piDataType = IVAS_PI_R_ISM_ID; + r_ism_id->id = *buffer; + + return IVAS_ERR_OK; +} + +static ivas_error packReverseISMGain( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0, idx; + int16_t gain; + const IVAS_PIDATA_ISM_EDIT_GAIN *r_ism_gain = (const IVAS_PIDATA_ISM_EDIT_GAIN *) piData; + + *nBytesWritten = 0; + + if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_GAIN ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_GAIN PI data" ); + } + + if ( piData->piDataType != IVAS_PI_R_ISM_GAIN ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in R_ISM_GAIN PI data" ); + } + + /* R_ISM_GAIN data is 1 byte, header is 2 bytes */ + if ( maxDataBytes < 1 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_GAIN PI data" ); + } + + buffer[nBytes++] = ( r_ism_gain->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + gain = (int16_t) r_ism_gain->dB; + idx = min( -gain, 97 ); + if ( gain > 0 ) + { + idx += 97; + } + + buffer[nBytes++] = ( idx & MASK_7BIT ) << 1; + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackReverseISMGain( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t idx; + IVAS_PIDATA_ISM_EDIT_GAIN *r_ism_gain = (IVAS_PIDATA_ISM_EDIT_GAIN *) piData; + + /* R_ISM_GAIN data is 1 byte */ + if ( numDataBytes > 1 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_GAIN PI data" ); + } + + r_ism_gain->size = sizeof( IVAS_PIDATA_ISM_EDIT_GAIN ); + r_ism_gain->piDataType = IVAS_PI_R_ISM_GAIN; + + /* Unpack gain */ + idx = ( *buffer ) >> 1; + /* negative gains*/ + if ( idx < 97 ) + { + r_ism_gain->dB = -(int8_t) ( idx ); + } + /* Set to min for muting, to be interpreted as -Inf */ + else if ( idx == 97 ) + { + r_ism_gain->dB = -128; + } + /* postive gains */ + else if ( idx < 101 ) + { + r_ism_gain->dB = (int8_t) idx - 97; + } + else + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect index for R_ISM_GAIN PI data" ); + } + + return IVAS_ERR_OK; +} + +static ivas_error packReverseISMDirection( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + const IVAS_PIDATA_ISM_EDIT_DIRECTION *r_ism_direction = (const IVAS_PIDATA_ISM_EDIT_DIRECTION *) piData; + uint16_t word; + + *nBytesWritten = 0; + + if ( piData->size > sizeof( IVAS_PIDATA_ISM_EDIT_DIRECTION ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in R_ISM_DIRECTION PI data" ); + } + + if ( piData->piDataType != IVAS_PI_R_ISM_DIRECTION ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM_DIRECTION PI data" ); + } + + /* R_ISM_DIRECTION data is 2 bytes, header is 2 bytes */ + if ( maxDataBytes > 2 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack R_ISM_DIRECTION PI data" ); + } + + buffer[nBytes++] = ( r_ism_direction->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + + word = (uint16_t) ( min( (uint16_t) ceilf( r_ism_direction->azimuth * REVERSE_ISM_DIRECTION_AZIMUTH_STEP_INV ) + 256, 511 ) << 7 ); + word |= (uint16_t) ( min( (uint16_t) ceilf( r_ism_direction->elevation * REVERSE_ISM_DIRECTION_ELEVATION_STEP_INV ) + 64, 127 ) << 6 ); + + buffer[nBytes++] = ( word >> 8 ) & MASK_8BIT; + buffer[nBytes++] = word & MASK_8BIT; + + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackReverseISMDirection( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint16_t word; + IVAS_PIDATA_ISM_EDIT_DIRECTION *r_ism_direction = (IVAS_PIDATA_ISM_EDIT_DIRECTION *) piData; + + /* R_ISM_DIRECTION data is 2 bytes */ + if ( numDataBytes > 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack R_ISM_DIRECTION PI data" ); + } + + r_ism_direction->size = sizeof( IVAS_PIDATA_ISM_EDIT_DIRECTION ); + r_ism_direction->piDataType = IVAS_PI_R_ISM_DIRECTION; + + word = ( buffer[0] ) << 8; + word |= ( buffer[1] ); + + r_ism_direction->azimuth = (float) ( ( ( word >> 7 ) & MASK_9BIT ) + 1 ) * REVERSE_ISM_DIRECTION_AZIMUTH_STEP - 180.0f; + r_ism_direction->elevation = (float) ( word & MASK_7BIT ) * REVERSE_ISM_DIRECTION_ELEVATION_STEP - 90.0f; + + return IVAS_ERR_OK; +} +#endif + #endif /* RTP_S4_251135_CR26253_0016_REV1 */ @@ -665,7 +902,11 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ packOrientation, /* HEAD_ORIENTATION */ +#ifdef REVERSE_ISM_PI_DATA + packPosition, /* LISTENER_POSITION */ +#else packListenerPosition, /* LISTENER_POSITION */ +#endif packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #else @@ -676,15 +917,26 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif packUnsupportedData, /* PI_LATENCY */ +#ifdef REVERSE_ISM_PI_DATA + packReverseISMID, /* R_ISM_ID */ + packReverseISMGain, /* R_ISM_GAIN */ +#else packUnsupportedData, /* R_ISM_ID */ packUnsupportedData, /* R_ISM_GAIN */ +#endif #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* R_ISM_ORIENTATION */ #else packUnsupportedData, /* R_ISM_ORIENTATION */ #endif + +#ifdef REVERSE_ISM_PI_DATA + packPosition, /* R_ISM_POSITION */ + packReverseISMDirection, /* R_ISM_DIRECTION */ +#else packUnsupportedData, /* R_ISM_POSITION */ packUnsupportedData, /* R_ISM_DIRECTION */ +#endif packUnsupportedData, /* RESERVED27 */ packUnsupportedData, /* RESERVED28 */ packUnsupportedData, /* RESERVED29 */ @@ -724,7 +976,11 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ unpackOrientation, /* HEAD_ORIENTATION */ +#ifdef REVERSE_ISM_PI_DATA + unpackPosition, /* LISTENER_POSITION */ +#else unpackListenerPosition, /* LISTENER_POSITION */ +#endif unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #else @@ -735,15 +991,25 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif unpackUnsupportedData, /* PI_LATENCY */ +#ifdef REVERSE_ISM_PI_DATA + unpackReverseISMID, /* R_ISM_ID */ + unpackReverseISMGain, /* R_ISM_GAIN */ +#else unpackUnsupportedData, /* R_ISM_ID */ unpackUnsupportedData, /* R_ISM_GAIN */ +#endif #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackOrientation, /* R_ISM_ORIENTATION */ #else unpackUnsupportedData, /* R_ISM_ORIENTATION */ #endif +#ifdef REVERSE_ISM_PI_DATA + unpackPosition, /* R_ISM_POSITION */ + unpackReverseISMDirection, /* R_ISM_DIRECTION */ +#else unpackUnsupportedData, /* R_ISM_POSITION */ unpackUnsupportedData, /* R_ISM_DIRECTION */ +#endif unpackUnsupportedData, /* RESERVED27 */ unpackUnsupportedData, /* RESERVED28 */ unpackUnsupportedData, /* RESERVED29 */ diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index dc4c7f8ba..e9effd359 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -39,6 +39,13 @@ #define IVAS_PI_MAX_DATA_SIZE ( 32 + 2 ) /* max packed PI data bytes + pi header bytes */ +#ifdef REVERSE_ISM_PI_DATA +#define REVERSE_ISM_DIRECTION_AZIMUTH_STEP 0.703125f +#define REVERSE_ISM_DIRECTION_ELEVATION_STEP 1.417322835f +#define REVERSE_ISM_DIRECTION_AZIMUTH_STEP_INV 1.4222222222f +#define REVERSE_ISM_DIRECTION_ELEVATION_STEP_INV 0.7055555556f +#endif + /* IVAS PI Data Types */ typedef enum { @@ -320,6 +327,20 @@ typedef struct IVAS_FLVL flvl; /* audio focus level */ } IVAS_PIDATA_AUDIO_FOCUS; +#ifdef REVERSE_ISM_PI_DATA +/* Position data corresponding to any of the following pi data types :- + * - IVAS_PI_LISTENER_POSITION + * - IVAS_PI_R_ISM_POSITION + * + * piDataType is used to identify the correct pi data type contained here + */ +typedef struct +{ + size_t size; /* sizeof(IVAS_PIDATA_POSITION) */ + uint32_t piDataType; /* one of supported position data types */ + IVAS_COORDINATE position; /* Position data */ +} IVAS_PIDATA_POSITION; +#else /* Listener position */ typedef struct { @@ -327,6 +348,7 @@ typedef struct uint32_t piDataType; /* IVAS_PI_LISTENER_POSITION */ IVAS_COORDINATE position; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_LISTENER_POSITION; +#endif /* Dynamic Audio Suppression describes receiver’s preference with respect to the @@ -402,6 +424,7 @@ typedef struct IVAS_QUATERNION orientation; /* orientation editing request for received ISM */ } IVAS_PIDATA_ISM_EDIT_ORIENTATION; +#ifndef REVERSE_ISM_PI_DATA /* Editing request for ISM position */ typedef struct { @@ -409,6 +432,7 @@ typedef struct uint32_t piDataType; /* IVAS_PI_R_ISM_POSITION */ IVAS_COORDINATE position; /* Positional editing request for received ISM */ } IVAS_PIDATA_ISM_EDIT_POSITION; +#endif /* Editing request for ISM direction */ typedef struct @@ -448,14 +472,22 @@ typedef union IVAS_PIDATA_ORIENTATION playbackOrientation; IVAS_PIDATA_ORIENTATION headOrientation; +#ifdef REVERSE_ISM_PI_DATA + IVAS_PIDATA_POSITION listnerPosition; +#else IVAS_PIDATA_LISTENER_POSITION listnerPosition; +#endif IVAS_PIDATA_DYNAMIC_SUPPRESSION dynSuppressionRequest; IVAS_PIDATA_AUDIO_FOCUS focusRequest; IVAS_PIDATA_REVERSE_PI_LATENCY piLatency; IVAS_PIDATA_ISM_EDIT_ID ismEditId; IVAS_PIDATA_ISM_EDIT_GAIN ismEditGain; IVAS_PIDATA_ISM_EDIT_ORIENTATION ismEditOrientation; +#ifdef REVERSE_ISM_PI_DATA + IVAS_PIDATA_POSITION ismEditPosition; +#else IVAS_PIDATA_ISM_EDIT_POSITION ismEditPosition; +#endif IVAS_PIDATA_ISM_EDIT_DIRECTION ismEditDirection; #endif /* RTP_S4_251135_CR26253_0016_REV1 */ IVAS_PIDATA_NO_DATA noPiData; -- GitLab From e3a98f0858a54e5d8d645a19e3cf1ba5513a97fc Mon Sep 17 00:00:00 2001 From: "@ragot" Date: Mon, 10 Nov 2025 13:36:48 +0100 Subject: [PATCH 238/351] adding support for format switching to encoder (porting from float main) --- CMakeLists.txt | 7 + Makefile | 9 +- Workspace_msvc/Workspace_msvc.sln | 11 + Workspace_msvc/encoder_fmtsw.vcxproj | 183 ++ apps/encoder_fmtsw.c | 2474 ++++++++++++++++++++++++++ 5 files changed, 2682 insertions(+), 2 deletions(-) create mode 100644 Workspace_msvc/encoder_fmtsw.vcxproj create mode 100644 apps/encoder_fmtsw.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e975df2b9..0347d98a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,6 +201,12 @@ if(WIN32) target_link_libraries(IVAS_cod Ws2_32) endif() +add_executable(IVAS_cod_fmtsw apps/encoder_fmtsw.c) +target_link_libraries(IVAS_cod_fmtsw lib_enc lib_util) +if(WIN32) + target_link_libraries(IVAS_cod_fmtsw Ws2_32) +endif() + add_executable(IVAS_dec apps/decoder.c) target_link_libraries(IVAS_dec lib_dec lib_util) if(WIN32) @@ -225,6 +231,7 @@ target_include_directories(ambi_converter PRIVATE lib_basop lib_util lib_com lib if(COPY_EXECUTABLES_FROM_BUILD_DIR) # Optionally copy executables to the same place where Make puts them (useful for tests that expect executables in specific places) add_custom_command(TARGET IVAS_cod POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") + add_custom_command(TARGET IVAS_cod_fmtsw POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET IVAS_dec POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET IVAS_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET ISAR_post_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") diff --git a/Makefile b/Makefile index 4febdc988..8e0502434 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ SRC_DIRS = $(sort -u $(SRC_LIBBASOP) $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC # Name of CLI binaries CLI_APIDEC ?= IVAS_dec CLI_APIENC ?= IVAS_cod +CLI_APIENC_FMTSW ?= IVAS_cod_fmtsw CLI_APIREND ?= IVAS_rend CLI_APIPOSTREND ?= ISAR_post_rend CLI_AMBICONVERT ?= ambi_converter @@ -169,6 +170,7 @@ OBJS_LIBUTIL = $(addprefix $(OBJDIR)/,$(SRCS_LIBUTIL:.c=.o)) OBJS_AMBICONVERT = $(OBJDIR)/ambi_convert.o OBJS_CLI_APIDEC = $(OBJDIR)/decoder.o OBJS_CLI_APIENC = $(OBJDIR)/encoder.o +OBJS_CLI_APIENC_FMTSW = $(OBJDIR)/encoder_fmtsw.o OBJS_CLI_APPREND = $(OBJDIR)/renderer.o OBJS_CLI_APPPOSTREND = $(OBJDIR)/isar_post_rend.o OBJS_CLI_AMBICONVERT = $(OBJDIR)/ambi_converter.o @@ -181,7 +183,7 @@ DEPS = $(addprefix $(OBJDIR)/,$(SRCS_LIBBASOP:.c=.P) $(SRCS_LIBCOM:.c=.P) $(SRCS .PHONY: all clean -all: $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) +all: $(CLI_APIENC) $(CLI_APIENC_FMTSW) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(OBJDIR): $(QUIET)mkdir -p $(OBJDIR) @@ -217,6 +219,9 @@ $(LIB_LIBUTIL): $(OBJS_LIBUTIL) $(OBJS_LIBBASOP) $(OBJS_LIBCOM) $(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC) +$(CLI_APIENC_FMTSW): $(OBJS_CLI_APIENC_FMTSW) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) + $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC_FMTSW) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC_FMTSW) + $(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBBASOP) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasbasop -livasdec -livascom -livasutil -livasdebug -llc3plus $(LDLIBS) -o $(CLI_APIDEC) @@ -235,7 +240,7 @@ clean: $(QUIET)$(RM) $(OBJS_LIBENC) $(OBJS_LIBDEC) $(DEPS) $(QUIET)$(RM) $(DEPS:.P=.d) $(QUIET)test ! -d $(OBJDIR) || rm -rf $(OBJDIR) - $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(CLI_AMBICONVERT) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(OBJS_LIBBASOP) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) + $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIENC_FMTSW) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(CLI_AMBICONVERT) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(OBJS_LIBBASOP) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(OBJDIR)/%.o : %.c | $(OBJDIR) $(QUIET_CC)$(CC) $(CFLAGS) -c -MD -o $@ $< diff --git a/Workspace_msvc/Workspace_msvc.sln b/Workspace_msvc/Workspace_msvc.sln index abb9650fc..c9c1f0fde 100644 --- a/Workspace_msvc/Workspace_msvc.sln +++ b/Workspace_msvc/Workspace_msvc.sln @@ -24,6 +24,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encoder", "encoder.vcxproj" {63747FE7-94BA-410C-8D7F-EB47555DD994} = {63747FE7-94BA-410C-8D7F-EB47555DD994} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encoder_fmtsw", "encoder_fmtsw.vcxproj", "{CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}" + ProjectSection(ProjectDependencies) = postProject + {63747FE7-94BA-410C-8D7F-EB47555DD994} = {63747FE7-94BA-410C-8D7F-EB47555DD994} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderer", "renderer.vcxproj", "{12B4C8A5-1E06-4E30-B443-D1F916F52B47}" ProjectSection(ProjectDependencies) = postProject {63747FE7-94BA-410C-8D7F-EB47555DD994} = {63747FE7-94BA-410C-8D7F-EB47555DD994} @@ -106,6 +111,12 @@ Global {B3FC9DFC-7268-8660-7C0D-B60BAF02C554}.Release|Win32.ActiveCfg = Release|Win32 {B3FC9DFC-7268-8660-7C0D-B60BAF02C554}.Release|Win32.Build.0 = Release|Win32 {B3FC9DFC-7268-8660-7C0D-B60BAF02C554}.Release|x64.ActiveCfg = Release|Win32 + {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Debug|Win32.ActiveCfg = Debug|Win32 + {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Debug|Win32.Build.0 = Debug|Win32 + {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Debug|x64.ActiveCfg = Debug|Win32 + {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Release|Win32.ActiveCfg = Release|Win32 + {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Release|Win32.Build.0 = Release|Win32 + {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Release|x64.ActiveCfg = Release|Win32 {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Debug|Win32.ActiveCfg = Debug|Win32 {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Debug|Win32.Build.0 = Debug|Win32 {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Debug|x64.ActiveCfg = Debug|Win32 diff --git a/Workspace_msvc/encoder_fmtsw.vcxproj b/Workspace_msvc/encoder_fmtsw.vcxproj new file mode 100644 index 000000000..7af057ae8 --- /dev/null +++ b/Workspace_msvc/encoder_fmtsw.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + encoder_fmtsw + {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B} + encoder_fmtsw + 10.0.17763.0 + + + + Application + v141 + false + MultiByte + + + Application + v141 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + ..\ + .\Debug_$(ProjectName)\ + false + false + IVAS_cod_fmtsw + + + ..\ + .\Release_$(ProjectName)\ + false + false + IVAS_cod_fmtsw + + + + + + + $(IntDir)$(ProjectName).tlb + + + + Disabled + ..\lib_basop;..\lib_enc;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + + $(OutDir)$(TargetName).exe + true + + false + true + $(IntDir)$(ProjectName).pdb + Console + + false + + MachineX86 + + + + + + + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_basop;..\lib_enc;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + Precise + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + false + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + $(OutDir)$(TargetName).exe + true + + false + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + + + + + + + + {63747fe7-94ba-410c-8d7f-eb47555dd994} + + + {824da4cf-06f0-45c9-929a-8792f0e19c3e} + false + + + {2fa8f384-0775-f3b7-f8c3-85209222fc70} + false + + + + + + + + + + + \ No newline at end of file diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c new file mode 100644 index 000000000..143d8a1a6 --- /dev/null +++ b/apps/encoder_fmtsw.c @@ -0,0 +1,2474 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "stl.h" +#include "lib_enc.h" +#include "cmdl_tools.h" +#include "audio_file_reader.h" +#include "bitstream_writer.h" +#include "ism_file_reader.h" +#include "jbm_file_reader.h" +#include "masa_file_reader.h" +#include "wmc_auto.h" +#ifdef IVAS_RTPDUMP +#include "rotation_file_reader.h" +#include "ivas_rtp_file.h" +#endif + +#ifdef DEBUG_FORCE_DIR +/* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. + We have to define _CRT_INTERNAL_NONSTDC_NAMES 1 before #including sys/stat.h + in order for Microsoft's stat.h to define names like S_IFMT, S_IFREG, and S_IFDIR, + rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */ +#include +#if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG ) +#define S_ISREG( m ) ( ( (m) &S_IFMT ) == S_IFREG ) +#endif +#if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR ) +#define S_ISDIR( m ) ( ( (m) &S_IFMT ) == S_IFDIR ) +#endif +#endif + +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) +#endif + +#define WMC_TOOL_SKIP + +/*------------------------------------------------------------------------------------------* + * Local constants, enums + *------------------------------------------------------------------------------------------*/ + +#define MAX_ARGV 20 /* maximum number of command line arguments that can be \ + in one line of the format switching file */ + +#if !defined( DEBUGGING ) && !defined( WMOPS ) +static +#endif + int32_t frame = 0; /* Counter of frames */ + +#define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ + +/* Additional config info for each input format */ +typedef union _EncInputFormatConfig +{ + /* MONO details */ + bool stereoToMonoDownmix; + +#ifdef DEBUGGING + /* STEREO details */ + IVAS_ENC_STEREO_MODE stereoMode; +#endif + + /* ISM details */ + struct EncIsmConfig + { + int16_t numObjects; + const char *metadataFiles[IVAS_MAX_NUM_OBJECTS]; + } ism; + + /* SBA details */ + struct EncSbaConfig + { + IVAS_ENC_SBA_ORDER order; + bool isPlanar; + } sba; + + /* MASA details */ + IVAS_ENC_MASA_VARIANT masaVariant; + + /* MC details */ + IVAS_ENC_MC_LAYOUT mcLayout; + + struct EncMasaIsmConfig + { + int16_t numObjects; + const char *metadataFiles[IVAS_MAX_NUM_OBJECTS]; + IVAS_ENC_MASA_VARIANT masaVariant; + } masa_ism; + + struct EncSbaIsmConfig + { + int16_t numObjects; + const char *metadataFiles[IVAS_MAX_NUM_OBJECTS]; + IVAS_ENC_SBA_ORDER order; + bool isPlanar; + } sba_ism; + +} EncInputFormatConfig; + + +/*------------------------------------------------------------------------------------------* + * Local structure for storing cmdln arguments + *------------------------------------------------------------------------------------------*/ + +typedef struct +{ + char *inputWavFilename; + char *outputBitstreamFilename; + int32_t inputFs; + IVAS_ENC_INPUT_FORMAT inputFormat; + bool is_binaural; + EncInputFormatConfig inputFormatConfig; + bool max_bwidth_user; + IVAS_ENC_BANDWIDTH maxBandwidth; + const char *bandwithProfileFile; + IVAS_ENC_DTX_CONFIG dtxConfig; + int32_t initBitrate; + const char *bitrateProfileFile; + bool quietModeEnabled; + bool delayCompensationEnabled; + const char *masaMetadataFile; + IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig; + const char *ca_config_file; + bool mimeOutput; + IVAS_ENC_COMPLEXITY_LEVEL complexityLevel; +#ifdef DEBUGGING + IVAS_ENC_FORCED_MODE forcedMode; + const char *forcedModeFile; +#ifdef DEBUG_FORCE_DIR + const char *forcedModeDir; +#endif +#endif + bool pca; + bool ism_extended_metadata; +#ifdef IVAS_RTPDUMP + bool rtpdumpOutput; + uint32_t numFramesPerPacket; + char *sceneOrientationTrajFileName; + char *deviceOrientationTrajFileName; +#endif + +} EncArguments; + + +/*------------------------------------------------------------------------------------------* + * Local functions prototypes + *------------------------------------------------------------------------------------------*/ + +static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg ); +static void usage_enc( void ); +static bool readBandwidth( FILE *file, IVAS_ENC_BANDWIDTH *bandwidth, int32_t *bandwidthFrameCounter ); +static bool readBitrate( FILE *file, int32_t *bitrate ); +#ifdef DEBUGGING +static ivas_error readForcedMode( FILE *file, IVAS_ENC_FORCED_MODE *forcedMode, int32_t *forceFrameCounter ); +static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar ); +#endif +static void str2arg( char *str, int *argc_local, char *argv_local[] ); +#ifdef IVAS_RTPDUMP +static int encoder_main( int argc, char *argv[], IVAS_RTP *ivasRtp, int init_RtpWriter ); +#else +static int encoder_main( int argc, char *argv[] ); +#endif + +/*------------------------------------------------------------------------------------------* + * main() + * + * Main IVAS encoder function for command-line interface + * supporting format switching +*------------------------------------------------------------------------------------------*/ + +int main( + int argc, + char *argv[] ) +{ + FILE *FmtSWFile = NULL; + char line[2048]; + int argc_local = 0; + char *argv_local[MAX_ARGV] = { 0 }; +#ifdef IVAS_RTPDUMP + IVAS_RTP ivasRtp = { 0 }; + char prev_outputBitstreamFilename[2048] = { 0 }; + int rtp_term = 0; +#endif + + IVAS_ENC_PrintDisclaimer(); + + if ( argc != 2 ) + { + fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" ); + fprintf( stdout, "where format_switching_file is a text file containg a valid encoder command line in each line\n\n" ); + exit( 0 ); + } + fprintf( stdout, "Input format switching file: %s\n", argv[1] ); + + if ( ( FmtSWFile = fopen( argv[1], "r" ) ) == NULL ) + { + fprintf( stdout, "error: cannot open format switching file %s\n", argv[1] ); + exit( 0 ); + } + + while ( fgets( line, sizeof( line ), FmtSWFile ) ) + { + /* remove trimming newline */ + line[strcspn( line, "\r\n" )] = 0; + printf( "Processing format switching commandline: %s\n", line ); + str2arg( line, &argc_local, argv_local ); +#ifdef IVAS_RTPDUMP + if ( strcmp( argv_local[argc_local - 1], (char *) prev_outputBitstreamFilename ) == 0 ) + { + /* append to last Rtp file */ + encoder_main( argc_local, argv_local, &ivasRtp, 0 ); + } + else + { + if ( rtp_term == 1 ) + { + IVAS_RTP_Term( &ivasRtp ); + } + /* write in separate Rtp file */ + encoder_main( argc_local, argv_local, &ivasRtp, 1 ); + rtp_term = 1; + } + strcpy( (char *) prev_outputBitstreamFilename, argv_local[argc_local - 1] ); +#else + encoder_main( argc_local, argv_local ); +#endif + } +#ifdef IVAS_RTPDUMP + IVAS_RTP_Term( &ivasRtp ); +#endif + fclose( FmtSWFile ); + exit( 0 ); +} + + +/*-------------------------------------------------------------------* + * Local functions + *-------------------------------------------------------------------*/ + +void str2arg( + char *str, /* input string */ + int *argc_local, /* number of argument */ + char *argv_local[] /* array of arguments */ +) +{ + int i = 0; + char *token = strtok( str, " " ); + while ( token && ( i < MAX_ARGV - 1 ) ) + { + argv_local[i++] = token; + token = strtok( 0, " " ); + } + argv_local[i] = 0; + *argc_local = i; + return; +} + +int encoder_main( + int argc, +#ifdef IVAS_RTPDUMP + char *argv[], + IVAS_RTP *ivasRtp, + int init_RtpWriter ) +#else + char *argv[] ) +#endif +{ + bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ + EncArguments arg; + int16_t i; + ivas_error error = IVAS_ERR_UNKNOWN; + + /* Any handles that require cleanup must be declared here and initialized to NULL */ + IVAS_ENC_HANDLE hIvasEnc = NULL; + BS_WRITER_HANDLE hBsWriter = NULL; + AudioFileReader *audioReader = NULL; + FILE *f_bitrateProfile = NULL; + FILE *f_bwProfile = NULL; + JbmFileReader *jbmReader = NULL; + MasaFileReader *masaReader = NULL; + IsmFileReader *ismReaders[IVAS_MAX_NUM_OBJECTS] = { NULL, NULL, NULL, NULL }; + int16_t *pcmBuf = NULL; +#ifdef IVAS_RTPDUMP + RotFileReader *sceneOrientationFileReader = NULL; + RotFileReader *deviceOrientationFileReader = NULL; +#endif +#ifdef DEBUGGING + FILE *f_forcedModeProfile = NULL; +#endif + +#ifdef WMOPS + reset_wmops(); + reset_mem( USE_BYTES ); +#endif + +#ifdef IVAS_RTPDUMP + uint8_t au[IVAS_MAX_BITS_PER_FRAME / 8]; + /* IVAS_RTP ivasRtp = { 0 }; */ +#endif + +#ifdef FIXED_RTP_SEQUENCE_NUM + /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we + use fixed seed for random num generator for regression based tests. Any realtime + application should implement this initialization seperately */ + srand( RANDOM_INITSEED_ENC ); + uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); + uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif + + /*------------------------------------------------------------------------------------------* + * Parse command-line arguments + *------------------------------------------------------------------------------------------*/ + + if ( !parseCmdlIVAS_enc( (int16_t) argc, argv, &arg ) ) + { + /* Error printout done internally in parseCmdlIVAS_enc() */ + goto cleanup; + } + + /*------------------------------------------------------------------------------------------* + * Open and initialize IVAS encoder + *------------------------------------------------------------------------------------------*/ + if ( ( error = IVAS_ENC_Open_fx( &hIvasEnc ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Opening IVAS encoder failed: %s\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + /*------------------------------------------------------------------------------------------* + * Open output bitstream file + *------------------------------------------------------------------------------------------*/ + + const BS_WRITER_FORMAT bsWriterFormat = arg.mimeOutput ? BS_WRITER_FORMAT_MIME : BS_WRITER_FORMAT_G192; + +#ifdef IVAS_RTPDUMP + if ( !arg.rtpdumpOutput && BS_Writer_Open_filename( &hBsWriter, arg.outputBitstreamFilename, bsWriterFormat ) != IVAS_ERR_OK ) +#else + if ( BS_Writer_Open_filename( &hBsWriter, arg.outputBitstreamFilename, bsWriterFormat ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nCan't open %s\n\n", arg.outputBitstreamFilename ); + goto cleanup; + } + + /*------------------------------------------------------------------------------------------* + * Print out file names + *------------------------------------------------------------------------------------------*/ + + if ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) + { + for ( i = 0; i < arg.inputFormatConfig.ism.numObjects; i++ ) + { + fprintf( stdout, "Object %d input metadata: %s\n", i + 1, arg.inputFormatConfig.ism.metadataFiles[i] ); + } + } + + if ( arg.masaMetadataFile != NULL ) + { + fprintf( stdout, "MASA inp. metadata file: %s\n", arg.masaMetadataFile ); + } + + fprintf( stdout, "Input audio file: %s\n", arg.inputWavFilename ); + fprintf( stdout, "Output bitstream file: %s\n\n", arg.outputBitstreamFilename ); + + /*------------------------------------------------------------------------------------------* + * Open auxiliary input files + *------------------------------------------------------------------------------------------*/ + + int32_t totalBitrate = arg.initBitrate; + + if ( arg.bitrateProfileFile ) + { + if ( ( f_bitrateProfile = fopen( arg.bitrateProfileFile, "rb" ) ) == NULL ) + { + fprintf( stderr, "Error: bitrate profile file %s could not be opened\n\n", arg.bitrateProfileFile ); + usage_enc(); + goto cleanup; + } + + if ( !readBitrate( f_bitrateProfile, &totalBitrate ) ) + { + fprintf( stderr, "Error: bitrate profile file %s could not be read\n\n", arg.bitrateProfileFile ); + goto cleanup; + } + rewind( f_bitrateProfile ); + + fprintf( stdout, "Bitrate switching file: %s\n", arg.bitrateProfileFile ); + } + + int32_t bandwidthFrameCounter = 0; + IVAS_ENC_BANDWIDTH bandwidth = arg.maxBandwidth; + + if ( arg.bandwithProfileFile ) + { + if ( ( f_bwProfile = fopen( arg.bandwithProfileFile, "rb" ) ) == NULL ) + { + fprintf( stderr, "Error: incorrect bandwidth specification or the bandwidth profile file could not be opened: %s\n\n", arg.bandwithProfileFile ); + usage_enc(); + goto cleanup; + } + fprintf( stdout, "Bandwidth switching file: %s\n", arg.bandwithProfileFile ); + + if ( !readBandwidth( f_bwProfile, &bandwidth, &bandwidthFrameCounter ) ) + { + fprintf( stderr, "Error: bandwidth switching file %s could not be read\n\n", arg.bandwithProfileFile ); + goto cleanup; + } + rewind( f_bwProfile ); + bandwidthFrameCounter = 0; + } + else + { + if ( bandwidth == IVAS_ENC_BANDWIDTH_NB && arg.inputFormat != IVAS_ENC_INPUT_MONO ) + { + fprintf( stdout, "\nNB coding not supported in IVAS. Switching to WB.\n\n" ); + } + else + { + switch ( bandwidth ) + { + case IVAS_ENC_BANDWIDTH_UNDEFINED: + break; + case IVAS_ENC_BANDWIDTH_NB: + fprintf( stdout, "Max. encoded bandwidth: NB\n" ); + break; + case IVAS_ENC_BANDWIDTH_WB: + fprintf( stdout, "Max. encoded bandwidth: WB\n" ); + break; + case IVAS_ENC_BANDWIDTH_SWB: + fprintf( stdout, "Max. encoded bandwidth: SWB\n" ); + break; + case IVAS_ENC_BANDWIDTH_FB: + fprintf( stdout, "Max. encoded bandwidth: FB\n" ); + break; + default: + fprintf( stderr, "Error: Invalid bandwidth value\n" ); + usage_enc(); + goto cleanup; + } + } + } + + /*------------------------------------------------------------------------------------------* + * Handle Channel-aware mode + *------------------------------------------------------------------------------------------*/ + + IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig = arg.caConfig; + + if ( arg.ca_config_file ) + { + if ( ( jbmReader = JbmFileReader_open( arg.ca_config_file ) ) == NULL ) + { + fprintf( stderr, "\nError: Channel aware configuration file could not be opened: %s\n\n", arg.ca_config_file ); + usage_enc(); + goto cleanup; + } + + fprintf( stdout, "Channel-aware mode: ON, config file: %s \n", arg.ca_config_file ); + } + else if ( caConfig.channelAwareModeEnabled ) + { + fprintf( stdout, "Channel-aware mode: ON, FEC indicator : %s FEC offset: %d \n\n", ( caConfig.fec_indicator == IVAS_ENC_FEC_LO ) ? "LO" : "HI", caConfig.fec_offset ); + } + + if ( arg.inputFormat != IVAS_ENC_INPUT_MONO && ( caConfig.channelAwareModeEnabled || arg.ca_config_file ) ) + { + fprintf( stderr, "Channel-aware mode is not supported in IVAS.\n\n" ); + usage_enc(); + goto cleanup; + } + +#ifdef SUPPORT_FORCE_TCX10_TCX20 +#ifdef DEBUGGING + if ( arg.forcedMode == IVAS_ENC_FORCE_TCX10 && totalBitrate < 48000 ) + { + fprintf( stderr, "Warning: Enforcing the TCX10 mode is only supported for bitrates higher or equal than 48 kbps!\n\n" ); + } +#endif +#endif + + /*------------------------------------------------------------------------------------------* + * Configure and initialize (allocate memory for static variables) the encoder + *------------------------------------------------------------------------------------------*/ + + switch ( arg.inputFormat ) + { + case IVAS_ENC_INPUT_MONO: + if ( ( error = IVAS_ENC_ConfigureForMono( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, caConfig, arg.inputFormatConfig.stereoToMonoDownmix, arg.is_binaural ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForMono failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + break; + case IVAS_ENC_INPUT_STEREO: +#ifdef DEBUGGING + if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.is_binaural, arg.inputFormatConfig.stereoMode ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.is_binaural ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForStereo failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + break; + case IVAS_ENC_INPUT_ISM: + if ( ( error = IVAS_ENC_ConfigureForObjects( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.ism.numObjects, arg.ism_extended_metadata ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + break; + case IVAS_ENC_INPUT_SBA: + if ( ( error = IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar, + arg.pca ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + break; + case IVAS_ENC_INPUT_MASA: + if ( ( error = IVAS_ENC_ConfigureForMasa( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masaVariant ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForMasa failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + break; + case IVAS_ENC_INPUT_MC: + if ( ( error = IVAS_ENC_ConfigureForMultichannel( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.mcLayout ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForMultichannel failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + break; + case IVAS_ENC_INPUT_SBA_ISM: + if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + exit( -1 ); + } + break; + case IVAS_ENC_INPUT_MASA_ISM: + if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForMASAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + exit( -1 ); + } + break; + default: + fprintf( stderr, "\nInvalid input type\n\n" ); + goto cleanup; + } + + if ( ( error = IVAS_ENC_PrintConfig( hIvasEnc, caConfig.channelAwareModeEnabled ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\n IVAS_ENC_PrintConfig failed %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + + /*------------------------------------------------------------------------------------------* + * Open input audio file + *------------------------------------------------------------------------------------------*/ + + if ( AudioFileReader_open( &audioReader, arg.inputWavFilename ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCan't open %s\n\n", arg.inputWavFilename ); + goto cleanup; + } + + /* Validate input sampling rate */ + int32_t inFileSampleRate = 0; + error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate ); + switch ( error ) + { + case IVAS_ERR_OK: + if ( inFileSampleRate != arg.inputFs ) + { + fprintf( stderr, "\nSampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n\n", arg.inputFs, inFileSampleRate, arg.inputWavFilename ); + goto cleanup; + } + break; + case IVAS_ERR_SAMPLING_RATE_UNKNOWN: + /* IVAS_ERR_SAMPLING_RATE_UNKNOWN will be returned for raw PCM files. + * Nothing to check here */ + break; + default: + fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } + + /* Validate number of channels */ + int16_t encInNumChannels = 0; + if ( ( error = IVAS_ENC_GetNumInChannels( hIvasEnc, &encInNumChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } + + int16_t inFileNumChannels = 0; + error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); + switch ( error ) + { + case IVAS_ERR_OK: + if ( inFileNumChannels != encInNumChannels ) + { + fprintf( stderr, "\nNumber of input audio channels mismatch: %d accepted by encoder, but %d found in file %s\n\n", encInNumChannels, inFileNumChannels, arg.inputWavFilename ); + goto cleanup; + } + break; + case IVAS_ERR_NUM_CHANNELS_UNKNOWN: + /* IVAS_ERR_NUM_CHANNELS_UNKNOWN will be returned for raw PCM files. + * Nothing to check here */ + break; + default: + fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + } + + /*------------------------------------------------------------------------------------------* + * Open input metadata files + *------------------------------------------------------------------------------------------*/ + + if ( arg.masaMetadataFile ) + { + if ( ( masaReader = MasaFileReader_open( arg.masaMetadataFile ) ) == NULL ) + { + fprintf( stderr, "\nError: MASA input metadata file %s could not be opened\n\n", arg.masaMetadataFile ); + usage_enc(); + goto cleanup; + } + } + + const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) ? arg.inputFormatConfig.ism.numObjects : 0; + + for ( i = 0; i < numIsmInputs; ++i ) + { + if ( arg.inputFormatConfig.ism.metadataFiles[i] != NULL ) + { + if ( ( ismReaders[i] = IsmFileReader_open( arg.inputFormatConfig.ism.metadataFiles[i] ) ) == NULL ) + { + fprintf( stderr, "\nError: ISM input metadata file %s could not be opened\n\n", arg.inputFormatConfig.ism.metadataFiles[i] ); + usage_enc(); + goto cleanup; + } + } + } + +#ifdef DEBUGGING + IVAS_ENC_FORCED_MODE forcedMode = arg.forcedMode; + int32_t force_profile_cnt = 0; + + if ( arg.forcedModeFile ) + { + if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) + { + fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile ); + usage_enc(); + goto cleanup; + } + } +#endif + + /*------------------------------------------------------------------------------------------* + * Allocate input data buffer + *------------------------------------------------------------------------------------------*/ + + int16_t pcmBufSize; + if ( ( error = IVAS_ENC_GetInputBufferSize( hIvasEnc, &pcmBufSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nGetInputBufferSize failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + + pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); + + /*------------------------------------------------------------------------------------------* + * Compensate for encoder delay (bitstream aligned with input signal) + *------------------------------------------------------------------------------------------*/ + + int16_t encDelayInSamples; + if ( ( error = IVAS_ENC_GetDelay( hIvasEnc, &encDelayInSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nGetDelay failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( arg.delayCompensationEnabled && encDelayInSamples ) + { + /* read samples and throw them away */ + int16_t numSamplesRead = 0; + if ( ( error = AudioFileReader_read( audioReader, pcmBuf, encDelayInSamples, &numSamplesRead ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError reading from file %s\n%s\n", arg.inputWavFilename, IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + +#ifdef IVAS_RTPDUMP + /*------------------------------------------------------------------------------------------* + * RTPDump + *------------------------------------------------------------------------------------------*/ + + if ( arg.rtpdumpOutput && init_RtpWriter ) + { +#ifdef FIXED_RTP_SEQUENCE_NUM + if ( ( error = IVAS_RTP_WRITER_Init( ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_RTP_WRITER_Init( ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nError: Can't open output bitstream file for RTP output %s \n\n", arg.outputBitstreamFilename ); + goto cleanup; + } + } + + /*------------------------------------------------------------------------------------------* + * Open scene orientation file + *------------------------------------------------------------------------------------------*/ + + if ( arg.sceneOrientationTrajFileName != NULL ) + { + if ( ( error = RotationFileReader_open( arg.sceneOrientationTrajFileName, &sceneOrientationFileReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open scene orientation file %s \n\n", arg.sceneOrientationTrajFileName ); + goto cleanup; + } + } + + /*------------------------------------------------------------------------------------------* + * Open device orientation file + *------------------------------------------------------------------------------------------*/ + + if ( arg.deviceOrientationTrajFileName != NULL ) + { + if ( ( error = RotationFileReader_open( arg.deviceOrientationTrajFileName, &deviceOrientationFileReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open device orientation file %s \n\n", arg.deviceOrientationTrajFileName ); + goto cleanup; + } + } +#endif + + int16_t numSamplesRead = 0; + uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME]; + uint16_t numBits = 0; + + if ( !arg.quietModeEnabled ) + { + fprintf( stdout, "\n------ Running the encoder ------\n\n" ); + fprintf( stdout, "Frames processed: " ); + } + else + { + fprintf( stdout, "\n\n-- Start the encoder (quiet mode) --\n\n" ); + } + +#ifdef WMOPS + reset_stack(); + reset_wmops(); +#endif + + /*------------------------------------------------------------------------------------------* + * Loop for every frame of input data + * - Read the input data + * - Process switching files + * - Read input metadata + * - Run the encoder + * - Write the parameters into output bitstream file + *------------------------------------------------------------------------------------------*/ + + while ( 1 ) + { + /* Read the input data */ + if ( ( error = AudioFileReader_read( audioReader, pcmBuf, pcmBufSize, &numSamplesRead ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError reading from file %s\n%s\n", arg.inputWavFilename, IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( numSamplesRead == 0 ) + { + /* end of input data */ + break; + } + + /* Zero-pad if not enough samples were read (expected in last frame) */ + if ( numSamplesRead < pcmBufSize ) + { + for ( i = numSamplesRead; i < pcmBufSize; ++i ) + { + pcmBuf[i] = 0; + } + } + + /* Process switching files */ + if ( f_bitrateProfile ) + { + if ( !readBitrate( f_bitrateProfile, &totalBitrate ) ) + { + fprintf( stderr, "Error: bitrate profile file %s could not be read\n\n", arg.bitrateProfileFile ); + goto cleanup; + } + + if ( ( error = IVAS_ENC_SetBitrate( hIvasEnc, totalBitrate ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_SetBitrate failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + if ( f_bwProfile ) + { + if ( !readBandwidth( f_bwProfile, &bandwidth, &bandwidthFrameCounter ) ) + { + fprintf( stderr, "Error: bandwidth switching file %s could not be read\n\n", arg.bandwithProfileFile ); + goto cleanup; + } + + if ( ( error = IVAS_ENC_SetBandwidth( hIvasEnc, bandwidth ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_SetBandwidth failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + if ( jbmReader ) + { + if ( ( error = JbmFileReader_readCAconfig( jbmReader, &caConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError (%s) while reading Channel-Aware Config. from: %s\n\n", IVAS_ENC_GetErrorMessage( error ), JbmFileReader_getFilePath( jbmReader ) ); + goto cleanup; + } + + if ( ( error = IVAS_ENC_SetChannelAwareConfig( hIvasEnc, caConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "IVAS_ENC_SetChannelAwareConfig failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + +#ifdef DEBUGGING + if ( f_forcedModeProfile ) + { + if ( ( error = readForcedMode( f_forcedModeProfile, &forcedMode, &force_profile_cnt ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError reading from file: %s\n%s\n", arg.forcedModeFile, IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + /* Force mode not set when configuring, set in first frame even if not reading from file */ + if ( f_forcedModeProfile || frame == 0 ) + { + if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode +#ifdef DEBUG_FORCE_DIR + , + arg.forcedModeDir +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#endif + + /* Read ISM input metadata */ + for ( i = 0; i < numIsmInputs; ++i ) + { + if ( ismReaders[i] == NULL ) + { + continue; + } + + IVAS_ISM_METADATA ismMetadata; + if ( ( error = IsmFileReader_readNextFrame( ismReaders[i], &ismMetadata ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError (%s) while reading ism metadata from: %s\n\n", IVAS_ENC_GetErrorMessage( error ), IsmFileReader_getFilePath( ismReaders[i] ) ); + goto cleanup; + } + + if ( ( error = IVAS_ENC_FeedObjectMetadata( hIvasEnc, i, ismMetadata ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nfeed_ISM_metadata failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + /* Read MASA input metadata */ + if ( masaReader ) + { + if ( ( error = MasaFileReader_readNextFrame( masaReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError (%s) while reading masa metadata from: %s\n\n", IVAS_ENC_GetErrorMessage( error ), arg.masaMetadataFile ); + goto cleanup; + } + IVAS_MASA_METADATA_HANDLE hMetadata = MasaFileReader_getMetadataHandle( masaReader ); + + if ( ( error = IVAS_ENC_FeedMasaMetadata( hIvasEnc, hMetadata ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nfeed_MASA_frame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + /* *** Encode one frame *** */ +#ifdef IVAS_RTPDUMP + if ( ivasRtp->hPack ) + { + bool isMono = ( arg.inputFormat == IVAS_ENC_INPUT_MONO ); + bool forcePacket = ( numSamplesRead < pcmBufSize ); /* If EoF force Packet generation */ + + ivasRtp->nWrittenPiData = 0; + + /* scene orientation */ + if ( sceneOrientationFileReader ) + { + PIDATA_TS *piDataTs = &ivasRtp->piData[ivasRtp->nWrittenPiData++]; + IVAS_PIDATA_ORIENTATION *scene = &piDataTs->data.scene; + + memset( piDataTs, 0, sizeof( PIDATA_TS ) ); + scene->size = sizeof( IVAS_PIDATA_ORIENTATION ); + scene->piDataType = IVAS_PI_SCENE_ORIENTATION; + + if ( ( error = HeadRotationFileReading( sceneOrientationFileReader, &scene->orientation, NULL ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading scene orientation from %s\n", IVAS_ENC_GetErrorMessage( error ), RotationFileReader_getFilePath( sceneOrientationFileReader ) ); + goto cleanup; + } + } + + /* device orientation */ + if ( deviceOrientationFileReader ) + { + PIDATA_TS *piDataTs = &ivasRtp->piData[ivasRtp->nWrittenPiData++]; + IVAS_PIDATA_ORIENTATION *device = &piDataTs->data.deviceUnCompensated; + + memset( piDataTs, 0, sizeof( PIDATA_TS ) ); + device->size = sizeof( IVAS_PIDATA_ORIENTATION ); + device->piDataType = IVAS_PI_DEVICE_ORIENTATION_COMPENSATED; + + if ( ( error = HeadRotationFileReading( deviceOrientationFileReader, &device->orientation, NULL ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading device orientation from %s\n", IVAS_ENC_GetErrorMessage( error ), RotationFileReader_getFilePath( deviceOrientationFileReader ) ); + goto cleanup; + } + } + + if ( ( error = IVAS_ENC_EncodeFrameToCompact( hIvasEnc, pcmBuf, pcmBufSize, au, &numBits ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + +#ifdef RTP_S4_251135_CR26253_0016_REV1 + if ( ( error = IVAS_RTP_WriteNextFrame( ivasRtp, au, NULL, numBits, isMono, forcePacket ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_RTP_WriteNextFrame( ivasRtp, au, numBits, isMono, forcePacket ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nError %s while pushing audio frame to RTP pack\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + } + else + { +#endif + if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + + /* write bitstream */ + if ( ( error = BS_Writer_WriteFrame_short( hBsWriter, bitStream, numBits, totalBitrate ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nBS_Writer_WriteFrame_short failed, error code %d\n\n", error ); + goto cleanup; + } +#ifdef IVAS_RTPDUMP + } +#endif + + frame++; + if ( !arg.quietModeEnabled ) + { + fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); + } + +#ifdef WMOPS + update_mem(); + update_wmops(); +#endif + } + + if ( arg.quietModeEnabled ) + { + fprintf( stdout, "Encoding finished\n" ); + } + else + { + fprintf( stdout, "\n\nEncoding of %d frames finished\n", frame ); + } + + /*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ + + mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ + +cleanup: + + free( pcmBuf ); + + if ( ( error = BS_Writer_Close( &hBsWriter ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Can't close bitstream writer, error code %d\n", error ); + mainFailed = true; + } + + AudioFileReader_close( &audioReader ); + + if ( jbmReader ) + { + JbmFileReader_close( &jbmReader ); + } + + for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) + { + if ( ismReaders[i] != NULL ) + { + IsmFileReader_close( &ismReaders[i] ); + } + } + + if ( masaReader ) + { + MasaFileReader_close( &masaReader ); + } + + if ( f_bwProfile ) + { + fclose( f_bwProfile ); + } + + if ( f_bitrateProfile ) + { + fclose( f_bitrateProfile ); + } + +#ifdef IVAS_RTPDUMP + if ( sceneOrientationFileReader ) + { + RotationFileReader_close( &sceneOrientationFileReader ); + } + + if ( deviceOrientationFileReader ) + { + RotationFileReader_close( &deviceOrientationFileReader ); + } + + /* IVAS_RTP_Term( &ivasRtp ); */ +#endif + + IVAS_ENC_Close( &hIvasEnc ); + +#ifdef WMOPS + print_wmops(); + print_mem( NULL ); +#endif + + return mainFailed ? -1 : 0; +} + + +/*---------------------------------------------------------------------* + * parseCmdlIVAS_enc() + * + * Encoder command-line parsing + *---------------------------------------------------------------------*/ + +static bool parseCmdlIVAS_enc( + int16_t argc, + char *argv[], + EncArguments *arg ) +{ + int16_t i, j; + char argv_to_upper[FILENAME_MAX]; + char stmp[FILENAME_MAX]; + int32_t tmp; + + /*-----------------------------------------------------------------* + * Set default values + *-----------------------------------------------------------------*/ + + arg->inputWavFilename = NULL; + arg->outputBitstreamFilename = NULL; + arg->inputFs = 0; + arg->inputFormat = IVAS_ENC_INPUT_MONO; + arg->is_binaural = false; + arg->inputFormatConfig.stereoToMonoDownmix = false; + arg->max_bwidth_user = false; + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_UNDEFINED; + arg->bandwithProfileFile = NULL; + arg->dtxConfig = IVAS_ENC_GetDefaultDtxConfig(); + arg->initBitrate = 0; + arg->bitrateProfileFile = NULL; + arg->quietModeEnabled = false; + arg->delayCompensationEnabled = true; + arg->masaMetadataFile = NULL; + arg->caConfig = IVAS_ENC_GetDefaultChannelAwareConfig(); + arg->ca_config_file = NULL; + arg->mimeOutput = false; + arg->ism_extended_metadata = false; + arg->complexityLevel = IVAS_ENC_COMPLEXITY_LEVEL_THREE; +#ifdef IVAS_RTPDUMP + arg->rtpdumpOutput = false; + arg->sceneOrientationTrajFileName = NULL; + arg->deviceOrientationTrajFileName = NULL; +#endif +#ifdef DEBUGGING + arg->forcedMode = IVAS_ENC_FORCE_UNFORCED; + arg->forcedModeFile = NULL; +#ifdef DEBUG_FORCE_DIR + arg->forcedModeDir = NULL; +#endif +#endif + arg->pca = false; + + /*-----------------------------------------------------------------* + * Initialization + *-----------------------------------------------------------------*/ + + if ( argc < 5 ) + { + fprintf( stderr, "Error: Not enough input parameters. Exiting!\n\n" ); + usage_enc(); + return false; + } + + /*-----------------------------------------------------------------* + * Optional input arguments + *-----------------------------------------------------------------*/ + + i = 1; + while ( i < argc - 4 ) + { + strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 ); + argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0'; + to_upper( argv_to_upper ); + + /*-----------------------------------------------------------------* + * Bandwidth limitation + *-----------------------------------------------------------------*/ + + if ( strcmp( argv_to_upper, "-MAX_BAND" ) == 0 ) + { + arg->max_bwidth_user = true; + + strncpy( stmp, argv[i + 1], sizeof( stmp ) - 1 ); + stmp[sizeof( stmp ) - 1] = '\0'; + to_upper( stmp ); + + if ( strcmp( stmp, "-NB" ) == 0 || strcmp( stmp, "NB" ) == 0 ) + { + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_NB; + } + else if ( strcmp( stmp, "-WB" ) == 0 || strcmp( stmp, "WB" ) == 0 ) + { + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_WB; + } + else if ( strcmp( stmp, "-SWB" ) == 0 || strcmp( stmp, "SWB" ) == 0 ) + { + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_SWB; + } + else if ( strcmp( stmp, "-FB" ) == 0 || strcmp( stmp, "FB" ) == 0 ) + { + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_FB; + } + else + { + arg->bandwithProfileFile = argv[i + 1]; + } + + i += 2; + } + + /*-----------------------------------------------------------------* + * Quiet mode + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-Q" ) == 0 ) + { + i++; + arg->quietModeEnabled = true; + } + + /*-----------------------------------------------------------------* + * DTX/CNG + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-DTX" ) == 0 ) + { + i++; + if ( i < argc - 4 ) + { + if ( sscanf( argv[i], "%d", &tmp ) <= 0 ) + { + tmp = DEFAULT_FIXED_SID_RATE; + } + else + { + i++; + } + } + else + { + tmp = DEFAULT_FIXED_SID_RATE; + } + + arg->dtxConfig.enabled = true; + + if ( tmp == 0 ) + { + arg->dtxConfig.variable_SID_rate = true; + arg->dtxConfig.SID_interval = 0; + } + else if ( tmp >= 3 && tmp <= 100 ) + { + arg->dtxConfig.variable_SID_rate = false; + arg->dtxConfig.SID_interval = (int16_t) tmp; + } + else + { + fprintf( stderr, "Error: Incorrect SID update interval specified: %d (supported 3-100)\n\n", tmp ); + usage_enc(); + return false; + } + } +#ifdef DEBUGGING + /*-----------------------------------------------------------------* + * Force specific mode + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-FORCE" ) == 0 ) + { + strncpy( stmp, argv[i + 1], sizeof( stmp ) ); + + arg->forcedMode = parseForcedMode( stmp ); + +#ifdef DEBUG_FORCE_DIR + if ( arg->forcedMode < IVAS_ENC_FORCE_FILE ) + { + fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_FILE ) + { + arg->forcedModeFile = argv[i + 1]; + fprintf( stdout, "Force switching file: %s\n", argv[i + 1] ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_DIR ) + { + arg->forcedModeDir = argv[i + 1]; + fprintf( stdout, "Forcing switching directory: %s\n", argv[i + 1] ); + } + else + { + fprintf( stderr, "\nError: The force switching profile file/dir %s does not exist or could not be opened!\n\n", argv[i + 1] ); + usage_enc(); + return false; + } +#else + if ( arg->forcedMode == IVAS_ENC_FORCE_UNDEFINED ) + { + arg->forcedModeFile = argv[i + 1]; + fprintf( stdout, "Force switching file: %s\n", argv[i + 1] ); + } + else + { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( arg->forcedMode == IVAS_ENC_FORCE_TCX10 ) + { + strcpy( stmp, "TCX10" ); + } + else if ( arg->forcedMode == IVAS_ENC_FORCE_TCX20 ) + { + strcpy( stmp, "TCX20" ); + } + else + { + strncpy( stmp, argv[i + 1], sizeof( stmp ) ); + } + + fprintf( stdout, "Forcing codec to: %s\n", stmp ); +#else + fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); +#endif + } +#endif + + i += 2; + } +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK + /*-----------------------------------------------------------------* + * Define additional subfolder for debug info output in ./res + *-----------------------------------------------------------------*/ + else if ( strcmp( argv_to_upper, "-INFO" ) == 0 ) + { + extern char infoFolder[FILENAME_MAX]; + strncpy( infoFolder, argv[i + 1], sizeof( infoFolder ) ); + i += 2; + } +#endif /* #ifdef DEBUG_MODE_INFO_TWEAK */ +#endif /* #ifdef DEBUG_MODE_INFO */ +#endif /* #ifdef DEBUGGING */ + + /*-----------------------------------------------------------------* + * deactivate delay compensation + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-NO_DELAY_CMP" ) == 0 ) + { + arg->delayCompensationEnabled = false; + i++; + } + + /*-----------------------------------------------------------------* + * Activate channel-aware mode + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-RF" ) == 0 ) + { + arg->caConfig.channelAwareModeEnabled = 1; + i++; + + if ( i < argc - 4 ) + { + strncpy( stmp, argv[i], sizeof( stmp ) ); + stmp[sizeof( stmp ) - 1] = '\0'; + to_upper( stmp ); + if ( strcmp( stmp, "LO" ) == 0 ) + { + arg->caConfig.fec_indicator = IVAS_ENC_FEC_LO; + } + else if ( strcmp( stmp, "HI" ) == 0 ) + { + arg->caConfig.fec_indicator = IVAS_ENC_FEC_HI; + } + else + { + arg->ca_config_file = argv[i]; + } + i++; + + if ( ( sscanf( argv[i], "%d", &tmp ) == 1 ) && ( i < argc - 4 ) ) + { + if ( tmp == 0 ) + { + arg->caConfig.channelAwareModeEnabled = 0; + arg->caConfig.fec_offset = 0; + i++; + } + else + { + arg->caConfig.fec_offset = (int16_t) tmp; + i++; + } + } + } + else + { + arg->caConfig.fec_indicator = IVAS_ENC_FEC_HI; + } + } + + /*-----------------------------------------------------------------* + * MIME output file format + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) + { + arg->mimeOutput = true; + fprintf( stdout, "Output bitstream file format: MIME\n" ); + ++i; + } + + + /*-----------------------------------------------------------------* + * Complexity Level + *-----------------------------------------------------------------*/ + + /* actual parsing of level will be implemented after characterization */ + else if ( strcmp( argv_to_upper, "-LEVEL" ) == 0 ) + { + int16_t level; + + ++i; + level = (int16_t) atoi( argv[i++] ); + if ( level < IVAS_ENC_COMPLEXITY_LEVEL_ONE || level > IVAS_ENC_COMPLEXITY_LEVEL_THREE ) + { + fprintf( stdout, "Invalid complexity level specified.\n" ); + usage_enc(); + return false; + } + else if ( level == IVAS_ENC_COMPLEXITY_LEVEL_ONE || level == IVAS_ENC_COMPLEXITY_LEVEL_TWO ) + { + fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); + } + } + + /*-----------------------------------------------------------------* + * IVAS Formats + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-STEREO" ) == 0 ) + { + i++; + arg->inputFormat = IVAS_ENC_INPUT_STEREO; + +#ifdef DEBUGGING + if ( ( i < argc - 4 ) && argv[i][0] != 45 ) /* note: 45 corresponds to "-" */ + { + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + if ( tmp == 1 ) + { + arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_DFT; + i++; + } + else if ( tmp == 2 ) + { + arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_TD; + i++; + } + else if ( tmp == 3 ) + { + arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_DECISION; +#ifdef DEBUG_FORCE_MDCT_STEREO_MODE + i++; + + /* force mdct stereo mode for debugging purposes */ + if ( i < argc - 4 ) + { + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + if ( tmp == 0 ) + { + /* keep "DECISION" */ + arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_DECISION; + i++; + } + else if ( tmp == 1 ) + { + arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_FORCE_LR; + i++; + } + else if ( tmp == 2 ) + { + arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_FORCE_MS; + i++; + } + else + { + fprintf( stderr, "Error: Incorrect mdct stereo coding method (%d) specified\n\n", tmp ); + usage_enc(); + return false; + } + } + } +#endif + } + else + { + fprintf( stderr, "Error: Incorrect stereo mode (%d) specified\n\n", tmp ); + usage_enc(); + return false; + } + } + else + { + fprintf( stderr, "Error: Stereo mode not specified.\n\n" ); /* in the debugging stage */ + usage_enc(); + return false; + } + } + else + { + arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_UNIFIED; + } +#endif /* DEBUGGING */ + } + else if ( strcmp( argv_to_upper, "-BINAURAL" ) == 0 ) + { + arg->is_binaural = true; + i++; + } + else if ( strcmp( argv_to_upper, "-ISM" ) == 0 ) + { + arg->inputFormat = IVAS_ENC_INPUT_ISM; + i++; + + if ( i < argc - 4 ) + { + if ( argv[i][0] == '+' ) + { + argv[i]++; + arg->ism_extended_metadata = true; + } + if ( !is_digits_only( argv[i] ) ) + { + fprintf( stderr, "Error: Number of ISM channels must be an integer number!\n\n" ); + usage_enc(); + return false; + } + + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + + if ( tmp <= 0 ) + { + fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" ); + usage_enc(); + return false; + } + else if ( tmp > IVAS_MAX_NUM_OBJECTS ) + { + fprintf( stderr, "Error: Too high number of ISM channels specified!\n\n" ); + usage_enc(); + return false; + } + else + { + arg->inputFormatConfig.ism.numObjects = (int16_t) tmp; + } + } + else + { + fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" ); + usage_enc(); + return false; + } + + /* read input metadata files */ + for ( j = 0; j < arg->inputFormatConfig.ism.numObjects; j++ ) + { + if ( i < argc - 4 ) + { + if ( strcmp( argv[i], "NULL" ) == 0 || strcmp( argv[i], "null" ) == 0 ) + { + /* no metadata input file -> encode only audio streams */ + arg->inputFormatConfig.ism.metadataFiles[j] = NULL; + } + else + { + arg->inputFormatConfig.ism.metadataFiles[j] = argv[i]; + } + + i++; + } + else + { + fprintf( stderr, "Error: not enough metadata arguments specified!\n\n" ); + usage_enc(); + return false; + } + } + } + else if ( strcmp( argv_to_upper, "-SBA" ) == 0 ) + { + i++; + arg->inputFormat = IVAS_ENC_INPUT_SBA; + + /* SBA configuration */ + if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + else + { + tmp = -1; /* this is to avoid a compilation warning */ + fprintf( stderr, "Error: SBA order must be specified, expecting a number!\n\n" ); + usage_enc(); + return false; + } + + arg->inputFormatConfig.sba.isPlanar = ( tmp < 0 ); + + tmp = abs( tmp ); + switch ( tmp ) + { + case 1: + arg->inputFormatConfig.sba.order = IVAS_ENC_SBA_FOA; + break; + case 2: + arg->inputFormatConfig.sba.order = IVAS_ENC_SBA_HOA2; + break; + case 3: + arg->inputFormatConfig.sba.order = IVAS_ENC_SBA_HOA3; + break; + default: + fprintf( stderr, "Error: Wrong SBA order specified!\n\n" ); + usage_enc(); + return false; + } + } + else if ( strcmp( argv_to_upper, "-MASA" ) == 0 ) + { + arg->inputFormat = IVAS_ENC_INPUT_MASA; + i++; + + if ( i < argc - 4 ) + { + if ( !is_digits_only( argv[i] ) ) + { + fprintf( stderr, "Error: Number of MASA channels must be an integer number!\n\n" ); + usage_enc(); + return false; + } + + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + + switch ( tmp ) + { + case 1: + arg->inputFormatConfig.masaVariant = IVAS_ENC_MASA_1CH; + break; + case 2: + arg->inputFormatConfig.masaVariant = IVAS_ENC_MASA_2CH; + break; + default: + fprintf( stderr, "Error: MASA channels must be 1 or 2.\n\n" ); + usage_enc(); + return false; + } + } + + if ( i < argc - 4 ) + { + arg->masaMetadataFile = argv[i]; + i++; + } + else + { + fprintf( stderr, "Error: not enough MASA arguments\n\n" ); + usage_enc(); + return false; + } + } + else if ( strcmp( argv_to_upper, "-MC" ) == 0 ) + { + i++; + arg->inputFormat = IVAS_ENC_INPUT_MC; + + if ( i < argc - 4 ) + { + if ( strcmp( argv[i], "5_1" ) == 0 ) + { + arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_5_1; + } + else if ( strcmp( argv[i], "7_1" ) == 0 ) + { + arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_7_1; + } + else if ( strcmp( argv[i], "5_1_2" ) == 0 ) + { + arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_5_1_2; + } + else if ( strcmp( argv[i], "5_1_4" ) == 0 ) + { + arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_5_1_4; + } + else if ( strcmp( argv[i], "7_1_4" ) == 0 ) + { + arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_7_1_4; + } + else + { + fprintf( stderr, "Error: Incorrect input configuration specified for Multi-channel\n\n" ); + usage_enc(); + return false; + } + i++; + } + else + { + fprintf( stderr, "Error: Multi-channel configuration not specified!\n\n" ); + usage_enc(); + return false; + } + } + else if ( strcmp( to_upper( argv[i] ), "-ISM_MASA" ) == 0 ) + { + arg->inputFormat = IVAS_ENC_INPUT_MASA_ISM; + i++; + + if ( i < argc - 5 ) + { + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + + if ( tmp <= 0 ) + { + fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" ); + usage_enc(); + return false; + } + else + { + if ( tmp <= IVAS_MAX_NUM_OBJECTS ) /* number of ISM channels */ + { + arg->inputFormatConfig.masa_ism.numObjects = (int16_t) tmp; + } + else + { + fprintf( stderr, "Error: Too high number of ISM channels!\n\n" ); + usage_enc(); + return false; + } + } + } + else + { + fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" ); + usage_enc(); + return false; + } + if ( i < argc - 4 ) + { + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + + switch ( tmp ) + { + case 1: + arg->inputFormatConfig.masa_ism.masaVariant = IVAS_ENC_MASA_1CH; + break; + case 2: + arg->inputFormatConfig.masa_ism.masaVariant = IVAS_ENC_MASA_2CH; + break; + default: + fprintf( stderr, "Error: MASA channels must be 1 or 2.\n\n" ); + usage_enc(); + return false; + } + } + + /* read input metadata files */ + for ( j = 0; j < arg->inputFormatConfig.masa_ism.numObjects; j++ ) + { + if ( i < argc - 4 ) + { + if ( strcmp( argv[i], "NULL" ) == 0 || strcmp( argv[i], "null" ) == 0 ) + { + /* no metadata input file -> encode only audio streams */ + arg->inputFormatConfig.masa_ism.metadataFiles[j] = NULL; + } + else + { + arg->inputFormatConfig.masa_ism.metadataFiles[j] = argv[i]; + } + + i++; + } + else + { + fprintf( stderr, "Error: not enough arguments\n\n" ); + usage_enc(); + return false; + } + } + + if ( i < argc - 4 ) + { + arg->masaMetadataFile = argv[i]; + i++; + } + else + { + fprintf( stderr, "Error: not enough MASA arguments\n\n" ); + usage_enc(); + return false; + } + } + else if ( strcmp( to_upper( argv[i] ), "-ISM_SBA" ) == 0 ) + { + arg->inputFormat = IVAS_ENC_INPUT_SBA_ISM; + i++; + + if ( i < argc - 5 ) + { + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + + if ( tmp <= 0 ) + { + fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" ); + usage_enc(); + return false; + } + else + { + if ( tmp <= IVAS_MAX_NUM_OBJECTS ) /* number of ISM channels */ + { + arg->inputFormatConfig.sba_ism.numObjects = (int16_t) tmp; + } + else + { + fprintf( stderr, "Error: Too high number of ISM channels!\n\n" ); + usage_enc(); + return false; + } + } + } + else + { + fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" ); + usage_enc(); + return false; + } + + if ( i < argc - 4 ) + { + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + + arg->inputFormatConfig.sba_ism.isPlanar = ( tmp < 0 ); + + tmp = abs( tmp ); + switch ( tmp ) + { + case 1: + arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_FOA; + break; + case 2: + arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_HOA2; + break; + case 3: + arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_HOA3; + break; + default: + fprintf( stderr, "Error: Wrong SBA order specified!\n\n" ); + usage_enc(); + return false; + } + } + + /* read input metadata files */ + for ( j = 0; j < arg->inputFormatConfig.sba_ism.numObjects; j++ ) + { + if ( i < argc - 4 ) + { + if ( strcmp( argv[i], "NULL" ) == 0 || strcmp( argv[i], "null" ) == 0 ) + { + /* no metadata input file -> encode only audio streams */ + arg->inputFormatConfig.sba_ism.metadataFiles[j] = NULL; + } + else + { + arg->inputFormatConfig.sba_ism.metadataFiles[j] = argv[i]; + } + + i++; + } + else + { + fprintf( stderr, "Error: not enough arguments\n\n" ); + usage_enc(); + return false; + } + } + } + else if ( strcmp( argv_to_upper, "-STEREO_DMX_EVS" ) == 0 ) + { + arg->inputFormat = IVAS_ENC_INPUT_MONO; + arg->inputFormatConfig.stereoToMonoDownmix = true; + + i++; + } + else if ( strcmp( argv_to_upper, "-PCA" ) == 0 ) + { + arg->pca = 1; + i++; + } + +#ifdef IVAS_RTPDUMP + /*-----------------------------------------------------------------* + * RTPDump output + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-RTPDUMP" ) == 0 ) + { + i++; + arg->rtpdumpOutput = true; + if ( i < argc - 4 ) + { + if ( !is_digits_only( argv[i] ) ) + { + arg->numFramesPerPacket = 1; /* Default to 1 frame per packet */ + } + else + { + arg->numFramesPerPacket = atoi( argv[i++] ); + if ( arg->numFramesPerPacket > IVAS_MAX_FRAMES_PER_RTP_PACKET ) + { + fprintf( stderr, "numFramesPerPacket(%d) exceeds max frames per packet (%d) \n", arg->numFramesPerPacket, IVAS_MAX_FRAMES_PER_RTP_PACKET ); + arg->numFramesPerPacket = 1; + } + } + } + fprintf( stdout, "Output format: RTPDump using %d frames/packet \n", arg->numFramesPerPacket ); + } + + /*-----------------------------------------------------------------* + * Scene orientation + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-SCENE_ORIENTATION" ) == 0 ) + { + i++; + if ( argc - i <= 4 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: Scene orientation file name not specified!\n\n" ); + usage_enc(); + return false; + } + + arg->sceneOrientationTrajFileName = argv[i]; + i++; + } + + /*-----------------------------------------------------------------* + * Device orientation + *-----------------------------------------------------------------*/ + + else if ( strcmp( argv_to_upper, "-DEVICE_ORIENTATION" ) == 0 ) + { + i++; + if ( argc - i <= 4 || argv[i][0] == '-' ) + { + fprintf( stderr, "Error: Device orientation file name not specified!\n\n" ); + usage_enc(); + return false; + } + + arg->deviceOrientationTrajFileName = argv[i]; + i++; + } + +#endif + + /*-----------------------------------------------------------------* + * Option not recognized + *-----------------------------------------------------------------*/ + else + { + fprintf( stderr, "Error: option not recognized, %s\n\n", argv[i] ); + usage_enc(); + return false; + } + } /* end of while */ + + /*-----------------------------------------------------------------* + * Mandatory input arguments + *-----------------------------------------------------------------*/ + + /*-----------------------------------------------------------------* + * Bitrate + *-----------------------------------------------------------------*/ + + if ( i < argc - 2 ) + { + /* check if profile file has been entered instead of a fixed bitrate */ + if ( !is_digits_only( argv[i] ) ) + { + arg->bitrateProfileFile = argv[i]; + } + else + { + arg->initBitrate = atoi( argv[i] ); + } + + i++; + } + else + { + fprintf( stderr, "Error: no bitrate specified\n\n" ); + usage_enc(); + return false; + } + + /*-----------------------------------------------------------------* + * Input sampling frequency + *-----------------------------------------------------------------*/ + + if ( i < argc - 2 ) + { + arg->inputFs = atoi( argv[i] ) * 1000; + i++; + } + else + { + fprintf( stderr, "Error: no input sampling frequency specified\n\n" ); + usage_enc(); + return false; + } + + /* for EVS mono, restore default behavior, i.e. SWB as default maxBandwidth if not set by the user otherwise */ + if ( arg->max_bwidth_user == false ) + { + arg->maxBandwidth = IVAS_ENC_GetDefaultBandwidth( ( arg->inputFormat == IVAS_ENC_INPUT_MONO ) ? true : false ); + } + + /* Prevent maxBandwidth from being higher than inputFs/2 */ + if ( arg->inputFs == 8000 && arg->maxBandwidth > IVAS_ENC_BANDWIDTH_NB ) + { + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_NB; + } + else if ( arg->inputFs == 16000 && arg->maxBandwidth > IVAS_ENC_BANDWIDTH_WB ) + { + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_WB; + } + else if ( arg->inputFs == 32000 && arg->maxBandwidth > IVAS_ENC_BANDWIDTH_SWB ) + { + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_SWB; + } + + /*-----------------------------------------------------------------* + * Input file + *-----------------------------------------------------------------*/ + + if ( i < argc - 1 ) + { + arg->inputWavFilename = argv[i]; + i++; + } + else + { + fprintf( stderr, "Error: no input file specified\n\n" ); + usage_enc(); + return false; + } + + /*-----------------------------------------------------------------* + * Output bitstream file + *-----------------------------------------------------------------*/ + + if ( i < argc ) + { + arg->outputBitstreamFilename = argv[i]; + i++; + } + else + { + fprintf( stderr, "Error: no output bitstream file specified\n\n" ); + usage_enc(); + return false; + } + + return true; +} + + +/*---------------------------------------------------------------------* + * usage_enc() + * + * Print the usage of the "ivas_cod" program + *---------------------------------------------------------------------*/ + +static void usage_enc( void ) +{ + fprintf( stdout, "Usage: IVAS_cod.exe [Options] R Fs input_file bitstream_file\n\n" ); + + fprintf( stdout, "Mandatory parameters:\n" ); + fprintf( stdout, "---------------------\n" ); + + fprintf( stdout, "R : Bitrate in bps, \n" ); + fprintf( stdout, " for EVS native modes R = (5900*, 7200, 8000, 9600, 13200, 16400,\n" ); + fprintf( stdout, " 24400, 32000, 48000, 64000, 96000, 128000) \n" ); + fprintf( stdout, " *VBR mode (average bitrate),\n" ); + fprintf( stdout, " for AMR-WB IO modes R = (6600, 8850, 12650, 14250, 15850, 18250,\n" ); + fprintf( stdout, " 19850, 23050, 23850) \n" ); + fprintf( stdout, " for IVAS stereo R = (13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" ); + fprintf( stdout, " 96000, 128000, 160000, 192000, 256000) \n" ); + fprintf( stdout, " for IVAS ISM R = 13200 for 1 ISM, 16400 for 1 ISM and 2 ISM, \n" ); + fprintf( stdout, " (24400, 32000, 48000, 64000, 80000, 96000, 128000) \n" ); + fprintf( stdout, " for 2 ISM, 3 ISM and 4 ISM also 160000, 192000, 256000) \n" ); + fprintf( stdout, " for 3 ISM and 4 ISM also 384000 \n" ); + fprintf( stdout, " for 4 ISM also 512000 \n" ); + fprintf( stdout, " for IVAS SBA, MASA, MC, ISM-SBA, and ISM-MASA R=(13200, 16400, 24400, 32000, 48000, 64000,\n" ); + fprintf( stdout, " 80000, 96000, 128000, 160000, 192000, 256000, 384000, 512000) \n" ); + fprintf( stdout, " Alternatively, R can be a bitrate switching file which consists of R values\n" ); + fprintf( stdout, " indicating the bitrate for each frame in bps. These values are stored in\n" ); + fprintf( stdout, " binary format using 4 bytes per value\n" ); + fprintf( stdout, "Fs : Input sampling rate in kHz, Fs = (8, 16, 32 or 48) \n" ); + + fprintf( stdout, "input_file : Input audio filename \n" ); + fprintf( stdout, "bitstream_file : Output bitstream filename \n\n" ); + + fprintf( stdout, "Options:\n" ); + fprintf( stdout, "--------\n" ); + fprintf( stdout, "EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -masa, -mc, -ism_sba, -ism_masa\n" ); + fprintf( stdout, "-stereo : Stereo format \n" ); + fprintf( stdout, "-ism (+)Ch Files : ISM format \n" ); + fprintf( stdout, " where Ch specifies the number of ISMs (1-4)\n" ); + fprintf( stdout, " where positive (+) indicates extended metadata (only 64 kbps and up) \n" ); + fprintf( stdout, " and Files specify input files containing metadata, one file per object\n" ); + fprintf( stdout, " (use NULL for no input metadata)\n" ); + fprintf( stdout, "-sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D),\n" ); + fprintf( stdout, " where Order specifies the Ambisionics order (1-3),\n" ); + fprintf( stdout, " where positive (+) means full 3D and negative (-) only 2D/planar components to be coded\n" ); + fprintf( stdout, "-masa Ch File : MASA format \n" ); + fprintf( stdout, " where Ch specifies the number of MASA input/transport channels (1 or 2): \n" ); + fprintf( stdout, " and File specifies input file containing parametric MASA metadata \n" ); + fprintf( stdout, "-ism_sba IsmCh +/-Order IsmFiles : SBA and ISM combined format\n" ); + fprintf( stdout, " where IsmCh specifies the number of ISMs (1-4)\n" ); + fprintf( stdout, " and Order specifies the SBA order (1 to 3) \n" ); + fprintf( stdout, " and IsmFiles specify input files containing ISM metadata, one file per object \n" ); + fprintf( stdout, "-ism_masa IsmCh MasaCh IsmFiles MasaFile : MASA and ISM combined format \n" ); + fprintf( stdout, " where IsmCh specifies the number of ISMs (1-4),\n" ); + fprintf( stdout, " MasaCh specifies the number of MASA input/transport channels (1-2), \n" ); + fprintf( stdout, " IsmFiles specify input files containing ISM metadata, one file per object, \n" ); + fprintf( stdout, " and MasaFile specifies input file containing parametric MASA metadata \n" ); + fprintf( stdout, "-mc InputConf : Multi-channel format\n" ); + fprintf( stdout, " where InputConf specifies the channel configuration: 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4\n" ); + fprintf( stdout, " Loudspeaker positions are assumed to have azimuth and elevation as per \n" ); + fprintf( stdout, " ISO/IEC 23091-3:2018 Table 3. Channel order is as per ISO/IEC 23008-3:2015 Table 95.\n" ); + fprintf( stdout, " See readme.txt for details.\n" ); + fprintf( stdout, "-dtx D : Activate DTX mode, D = (0, 3-100) is the SID update rate\n" ); + fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" ); + fprintf( stdout, " default is deactivated\n" ); + fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" ); + fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, SBA up to 80kbps and MASA up to 128kbps \n" ); + fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" ); + fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" ); + fprintf( stdout, " Alternatively p and o can be replaced by a rf configuration file with each line \n" ); + fprintf( stdout, " contains the values of p and o separated by a space, \n" ); + fprintf( stdout, " default is deactivated \n" ); + fprintf( stdout, "-max_band B : Activate bandwidth limitation, B = (NB, WB, SWB or FB)\n" ); + fprintf( stdout, " alternatively, B can be a text file where each line contains \"nb_frames B\"\n" ); + fprintf( stdout, "-no_delay_cmp : Turn off delay compensation\n" ); + fprintf( stdout, "-stereo_dmx_evs : Activate stereo downmix function for EVS.\n" ); + fprintf( stdout, "-binaural : Optional indication that input is binaural audio (to be used with -stereo or -stereo_dmx_evs)\n" ); + fprintf( stdout, "-mime : Mime output bitstream file format\n" ); + fprintf( stdout, " The encoder produces TS26.445 Annex.2.6 Mime Storage Format, (not RFC4867 Mime Format).\n" ); + fprintf( stdout, " default output bitstream file format is G.192\n" ); + fprintf( stdout, "-pca : activate PCA in SBA format FOA at 256 kbps \n" ); + fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); + fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); +#ifdef DEBUGGING + fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" ); + fprintf( stdout, " alternatively, T can be a text file where each line contains \"nb_frames T\"\n" ); +#ifdef DEBUG_FORCE_DIR + fprintf( stdout, " or T can be a directory containing external binary files for modes/parameters enforcement\n" ); +#endif +#endif +#ifdef DEBUG_MODE_INFO +#ifdef DEBUG_MODE_INFO_TWEAK + fprintf( stdout, "-info : specify subfolder name for debug output\n" ); +#endif +#endif + fprintf( stdout, "-q : Quiet mode, no frame counters\n" ); + fprintf( stdout, " default is deactivated\n" ); +#ifdef IVAS_RTPDUMP + fprintf( stdout, "-rtpdump : RTPDump output, hf_only=1 by default. The encoder will packetize the \n" ); + fprintf( stdout, " bitstream frames into TS26.253 Annex A IVAS RTP Payload Format packets and \n" ); + fprintf( stdout, " writes those to the output file. In EVS mono operating mode, TS26.445 Annex A.2.2 \n" ); + fprintf( stdout, " EVS RTP Payload Format is used. Optional N represents number of frames per RTP packet\n" ); + fprintf( stdout, "-scene_orientation : Scene orientation trajectory file. Only used with rtpdump output.\n" ); + fprintf( stdout, "-device_orientation : Device orientation trajectory file. Only used with rtpdump output.\n" ); +#endif + fprintf( stdout, "\n" ); + + return; +} + + +/*---------------------------------------------------------------------* + * readBandwidth() + * + * + *---------------------------------------------------------------------*/ + +static bool readBandwidth( + FILE *file, + IVAS_ENC_BANDWIDTH *bandwidth, + int32_t *bandwidthFrameCounter ) +{ + int16_t res; + char stmp[4]; + + if ( *bandwidthFrameCounter == 0 ) + { + /* read next bandwidth value and number of frames from the profile file */ + while ( ( res = (int16_t) fscanf( file, "%d %3s", bandwidthFrameCounter, stmp ) ) != 2 && feof( file ) ) + { + rewind( file ); + } + + ( *bandwidthFrameCounter )--; + + to_upper( stmp ); + + if ( strcmp( stmp, "NB" ) == 0 ) + { + *bandwidth = IVAS_ENC_BANDWIDTH_NB; + } + else if ( strcmp( stmp, "WB" ) == 0 ) + { + *bandwidth = IVAS_ENC_BANDWIDTH_WB; + } + else if ( strcmp( stmp, "SWB" ) == 0 ) + { + *bandwidth = IVAS_ENC_BANDWIDTH_SWB; + } + else if ( strcmp( stmp, "FB" ) == 0 ) + { + *bandwidth = IVAS_ENC_BANDWIDTH_FB; + } + else + { + fprintf( stderr, "Error: incorrect bandwidth specified (only NB, WB, SWB and FB are supported)\n\n" ); + usage_enc(); + return false; + } + } + else + { + /* current profile still active, only decrease the counter */ + ( *bandwidthFrameCounter )--; + } + + return true; +} + + +/*---------------------------------------------------------------------* + * readBitrate() + * + * + *---------------------------------------------------------------------*/ + +static bool readBitrate( + FILE *file, + int32_t *bitrate ) +{ + for ( int32_t i = 0; i < 2; ++i ) + { + if ( fread( bitrate, sizeof( int32_t ), 1, file ) == 1 ) + { + return true; + } + + rewind( file ); + } + + fprintf( stderr, "Error: cannot read the bitrate profile file\n\n" ); + usage_enc(); + return false; +} + + +#ifdef DEBUGGING +/*---------------------------------------------------------------------* + * parseForcedMode() + * + * + *---------------------------------------------------------------------*/ + +static IVAS_ENC_FORCED_MODE parseForcedMode( + char *forcedModeChar ) +{ +#ifdef DEBUG_FORCE_DIR + struct stat path_stat; +#endif + + to_upper( forcedModeChar ); + +#ifdef DEBUG_FORCE_DIR + if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) || + ( strcmp( forcedModeChar, "0" ) == 0 ) ) + { + return IVAS_ENC_FORCE_SPEECH; + } + else if ( ( strcmp( forcedModeChar, "MUSIC" ) == 0 ) || ( strcmp( forcedModeChar, "'MUSIC'" ) == 0 ) || ( strcmp( forcedModeChar, "AUDIO" ) == 0 ) || ( strcmp( forcedModeChar, "'AUDIO'" ) == 0 ) || ( strcmp( forcedModeChar, "1" ) == 0 ) ) + { + return IVAS_ENC_FORCE_MUSIC; + } + else if ( ( strcmp( forcedModeChar, "ACELP" ) == 0 ) || ( strcmp( forcedModeChar, "'ACELP'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_ACELP; + } + else if ( ( strcmp( forcedModeChar, "GSC" ) == 0 ) || ( strcmp( forcedModeChar, "'GSC'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_GSC; + } + if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) +#ifdef SUPPORT_FORCE_TCX10_TCX20 + || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) +#endif + ) + { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + return IVAS_ENC_FORCE_TCX20; +#else + return IVAS_ENC_FORCE_TCX; +#endif + } +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_TCX10; + } +#endif + else if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_HQ; + } + else + { + if ( stat( forcedModeChar, &path_stat ) != 0 ) + { + return IVAS_ENC_FORCE_UNDEFINED; + } + + /* check if the argument represents an existing file or directory */ + if ( S_ISDIR( path_stat.st_mode ) ) + { + /* it's a directory */ + return IVAS_ENC_FORCE_DIR; + } + else + { + /* it's a file */ + return IVAS_ENC_FORCE_FILE; + } + } +#else + if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) || + ( strcmp( forcedModeChar, "0" ) == 0 ) ) + { + return IVAS_ENC_FORCE_SPEECH; + } + if ( ( strcmp( forcedModeChar, "MUSIC" ) == 0 ) || ( strcmp( forcedModeChar, "'MUSIC'" ) == 0 ) || ( strcmp( forcedModeChar, "AUDIO" ) == 0 ) || ( strcmp( forcedModeChar, "'AUDIO'" ) == 0 ) || ( strcmp( forcedModeChar, "1" ) == 0 ) ) + { + return IVAS_ENC_FORCE_MUSIC; + } + if ( ( strcmp( forcedModeChar, "ACELP" ) == 0 ) || ( strcmp( forcedModeChar, "'ACELP'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_ACELP; + } + if ( ( strcmp( forcedModeChar, "GSC" ) == 0 ) || ( strcmp( forcedModeChar, "'GSC'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_GSC; + } + if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) +#ifdef SUPPORT_FORCE_TCX10_TCX20 + || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) +#endif + ) + { +#ifdef SUPPORT_FORCE_TCX10_TCX20 + return IVAS_ENC_FORCE_TCX20; +#else + return IVAS_ENC_FORCE_TCX; +#endif + } +#ifdef SUPPORT_FORCE_TCX10_TCX20 + if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_TCX10; + } +#endif + if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) + { + return IVAS_ENC_FORCE_HQ; + } + + return IVAS_ENC_FORCE_UNDEFINED; +#endif +} + + +/*---------------------------------------------------------------------* + * readForcedMode() + * + * + *---------------------------------------------------------------------*/ + +static ivas_error readForcedMode( + FILE *file, + IVAS_ENC_FORCED_MODE *forcedMode, + int32_t *forceFrameCounter ) +{ + int16_t res; + char stmp[8]; + + if ( *forceFrameCounter == 0 ) + { + /* read next force and number of frames from the profile file */ + while ( ( res = (int16_t) fscanf( file, "%d %7s", forceFrameCounter, stmp ) ) != 2 && feof( file ) ) + { + rewind( file ); + } + + *forcedMode = parseForcedMode( stmp ); + + if ( *forcedMode == IVAS_ENC_FORCE_UNDEFINED ) + { + fprintf( stderr, "Error: incorect mode specification or the force profile file could not be opened: %s\n\n", stmp ); + return IVAS_ERR_WRONG_PARAMS; + } + + if ( res != 2 && !feof( file ) ) + { + fprintf( stderr, "Error: incorrect format of the force profile file (please ensure that it does not contain any empty lines)\n\n" ); + return IVAS_ERR_WRONG_PARAMS; + } + } + + /* current profile still active, only decrease the counter */ + ( *forceFrameCounter )--; + + return IVAS_ERR_OK; +} +#endif + + +#undef WMC_TOOL_SKIP -- GitLab From 3912e62593dd39e63854ee82cdbc75b87dd79e19 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Nov 2025 13:45:11 +0100 Subject: [PATCH 239/351] fix --- lib_dec/lib_dec_fx.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index b65fda0da..249f59f66 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1119,6 +1119,33 @@ ivas_error IVAS_DEC_FeedFrame_Serial( move16(); } + /* Update redundant frame information in EVS (pre- read indices) */ + test(); + test(); + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) && hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) + { + DEC_CORE_HANDLE st = hIvasDec->st_ivas->hSCE[0]->hCoreCoder[0]; + st->bit_stream = serial; + + test(); + IF( hIvasDec->hVoIP->hCurrentDataUnit->partial_frame || st->prev_use_partial_copy ) + { + st->next_coder_type = hIvasDec->hVoIP->hCurrentDataUnit->nextCoderType; + } + ELSE + { + st->next_coder_type = INACTIVE; + } + move16(); + + test(); + if ( EQ_16( (Word16) hIvasDec->hVoIP->hCurrentDataUnit->partial_frame, 1 ) && NE_16( bfi, 1 ) ) + { + bfi = 2; + move16(); + } + } + IF( NE_32( ( error = read_indices_fx( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ), IVAS_ERR_OK ) ) { return error; -- GitLab From 1cfdb16eeb90cb44d4bb43ce7d16b40fc0219020 Mon Sep 17 00:00:00 2001 From: "@ragot" Date: Mon, 10 Nov 2025 14:05:20 +0100 Subject: [PATCH 240/351] fix clang --- apps/encoder_fmtsw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 143d8a1a6..ff04c87fd 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -56,10 +56,10 @@ rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */ #include #if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG ) -#define S_ISREG( m ) ( ( (m) &S_IFMT ) == S_IFREG ) +#define S_ISREG( m ) ( ( ( m ) & S_IFMT ) == S_IFREG ) #endif #if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR ) -#define S_ISDIR( m ) ( ( (m) &S_IFMT ) == S_IFDIR ) +#define S_ISDIR( m ) ( ( ( m ) & S_IFMT ) == S_IFDIR ) #endif #endif @@ -200,7 +200,7 @@ static int encoder_main( int argc, char *argv[] ); * * Main IVAS encoder function for command-line interface * supporting format switching -*------------------------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------------------*/ int main( int argc, -- GitLab From 2d426c3f0a7eddbc5df22962bec1376353aefaf7 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 10 Nov 2025 14:09:47 +0100 Subject: [PATCH 241/351] port FIX_1437_LC3PLUS_EXTREND_HIRES --- apps/renderer.c | 9 +++++++++ lib_com/options.h | 1 + lib_isar/isar_splitRendererPre.c | 3 +++ lib_rend/lib_rend.h | 7 ++++++- lib_rend/lib_rend_fx.c | 10 +++++++++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 153661395..9394fb655 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1548,7 +1548,16 @@ int main( audioWriter = NULL; } +#ifdef FIX_1437_LC3PLUS_EXTREND_HIRES + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, + &bitsBuffer.config.codec, + &bitsBuffer.config.poseCorrection, + &bitsBuffer.config.codec_frame_size_ms, + &bitsBuffer.config.isar_frame_size_ms, + &bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader(): %s!\n", ivas_error_to_string( error ) ); goto cleanup; diff --git a/lib_com/options.h b/lib_com/options.h index 10ea208a2..84169d48f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,6 +145,7 @@ #define FIX_1419_MONO_STEREO_UMX /* FhG: fix for issue 1419 : support upmix to all output formats for mono and stereo */ #define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */ #define NONBE_1344_REND_MASA_LOW_FS /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */ +#define FIX_1437_LC3PLUS_EXTREND_HIRES /* FhG: fix external renderer split bitstream header writing causing a crash for LC3plus High-res mode */ #define NONBE_1412_AVOID_ROUNDING_AZ_ELEV /* FhG: Avoid rounding when passing azimuth and elevation to efap_determine_gains() */ // object-editing feature porting diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index c5902b3b5..445540715 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2876,6 +2876,9 @@ ivas_error splitRendLc3plusEncodeAndWrite( pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; pBits->codec_frame_size_ms = (Word16) ( hSplitBin->hLc3plusEnc->config.lc3plus_frame_duration_us / 1000 ); pBits->isar_frame_size_ms = (Word16) ( hSplitBin->hLc3plusEnc->config.isar_frame_duration_us / 1000 ); +#ifdef FIX_1437_LC3PLUS_EXTREND_HIRES + pBits->lc3plus_highres = hSplitBin->hLc3plusEnc->config.high_res_mode_enabled; +#endif return IVAS_ERR_OK; } diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index f5f1d86cb..ea2bc3981 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -294,7 +294,12 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ Word16 *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ - Word16 *pIsar_frame_size_ms /* o : pointer to ISAR frame size setting */ +#ifdef FIX_1437_LC3PLUS_EXTREND_HIRES + Word16 *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ + Word16 *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ +#else + Word16 *pIsar_frame_size_ms /* o : pointer to ISAR frame size setting */ +#endif ); ivas_error IVAS_REND_SetHeadRotation( diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 299fe9b2e..afd1027d2 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9620,7 +9620,12 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ Word16 *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ - Word16 *pIsar_frame_size_ms /* o : pointer to ISAR frame size setting */ +#ifdef FIX_1437_LC3PLUS_EXTREND_HIRES + Word16 *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ + Word16 *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ +#else + Word16 *pIsar_frame_size_ms /* o : pointer to ISAR frame size setting */ +#endif ) { test(); @@ -9633,6 +9638,9 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( *pCodec_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms; *pIsar_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms; *poseCorrection = hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode; +#ifdef FIX_1437_LC3PLUS_EXTREND_HIRES + *pLc3plusHighRes = hIvasRend->hRendererConfig->split_rend_config.lc3plus_highres; +#endif return IVAS_ERR_OK; } -- GitLab From a181f9a1ae7e1bc9c242858168fe9a65e3f0f296 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 15:11:37 +0200 Subject: [PATCH 242/351] Port decoder restart from float MR2279 --- apps/decoder.c | 180 +++++++++++++++++++++++++++++++++++++ lib_com/ivas_prot_fx.h | 5 ++ lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 164 +++++++++++++++++++++++++++++++++ lib_dec/ivas_stat_dec.h | 3 + lib_dec/lib_dec.h | 6 ++ lib_dec/lib_dec_fx.c | 49 ++++++++++ 7 files changed, 408 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 63c837a38..dbcf01a97 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -173,13 +173,24 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #ifdef FIX_1119_SPLIT_RENDERING_VOIP +#ifdef DECODER_FORMAT_SWITCHING +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); +#else static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#endif +#else +#ifdef DDECODER_FORMAT_SWITCHING +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); #else static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #endif +#endif static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader ); +#ifdef DECODER_FORMAT_SWITCHING +static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, IVAS_DEC_MODE codec, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData ); +#endif /*------------------------------------------------------------------------------------------* * main() @@ -657,9 +668,17 @@ int main( if ( arg.voipMode ) { #ifdef FIX_1119_SPLIT_RENDERING_VOIP +#ifdef DECODER_FORMAT_SWITCHING + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &hIvasDec, pcmBuf ); +#else error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); +#endif +#else +#ifdef DDECODER_FORMAT_SWITCHING + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &hIvasDec, pcmBuf ); #else error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hIvasDec, pcmBuf ); +#endif #endif } else @@ -2866,7 +2885,11 @@ static ivas_error decodeVoIP( #ifdef FIX_1119_SPLIT_RENDERING_VOIP ISAR_SPLIT_REND_BITS_DATA *splitRendBits, #endif +#ifdef DECODER_FORMAT_SWITCHING + IVAS_DEC_HANDLE *phIvasDec, +#else IVAS_DEC_HANDLE hIvasDec, +#endif int16_t *pcmBuf ) { bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */ @@ -2898,6 +2921,9 @@ static ivas_error decodeVoIP( int16_t delayNumSamples = -1; int32_t delayTimeScale = -1; int16_t i; +#ifdef DECODER_FORMAT_SWITCHING + IVAS_DEC_HANDLE hIvasDec = *phIvasDec; +#endif #ifdef IVAS_RTPDUMP IVAS_RTP ivasRtp = { 0 }; IVAS_RTP srRtp = { 0 }; @@ -3079,6 +3105,27 @@ static ivas_error decodeVoIP( fprintf( stdout, "\n-- Start the decoder (quiet mode) --\n\n" ); } +#ifdef DECODER_FORMAT_SWITCHING + if ( ivasRtp.restartNeeded ) + { + IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + error = restartDecoder( + &hIvasDec, + newCodecInPacket, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket ); + goto cleanup; + } + *phIvasDec = hIvasDec; /* Update for main()' s free */ + ivasRtp.restartNeeded = false; + } +#endif + #ifdef WMOPS reset_stack(); reset_wmops(); @@ -3347,6 +3394,31 @@ static ivas_error decodeVoIP( /* Placeholder for memory reallocation */ /* ... */ +#ifdef DECODER_FORMAT_SWITCHING + if ( IVAS_DEC_isRestartNeeded( hIvasDec ) ) + { + IVAS_DEC_BS_FORMAT tempFormat; + if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error ); + goto cleanup; + } + IVAS_DEC_MODE codecMode = ( tempFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + error = restartDecoder( + &hIvasDec, + codecMode, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "\nFailed to restart decoder\n" ); + goto cleanup; + } + *phIvasDec = hIvasDec; /* Update for main()' s free */ + } +#endif /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) @@ -4073,4 +4145,112 @@ static ivas_error load_hrtf_from_file( return IVAS_ERR_OK; } +#ifdef DECODER_FORMAT_SWITCHING + +ivas_error restartDecoder( + IVAS_DEC_HANDLE *phIvasDec, + IVAS_DEC_MODE codec, + DecArguments *arg, + IVAS_RENDER_CONFIG_DATA *renderConfig, + IVAS_CUSTOM_LS_DATA *hLsCustomData ) +{ + ivas_error error = IVAS_ERR_OK; + IVAS_DEC_HANDLE hIvasDec; + + if ( phIvasDec == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( NULL != *phIvasDec ) + { + IVAS_DEC_Close( phIvasDec ); + } + + if ( ( error = IVAS_DEC_Open( phIvasDec, codec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + arg->decMode = codec; + + hIvasDec = *phIvasDec; + + uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : 65535; + + IVAS_AUDIO_CONFIG outputConfig = ( codec == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO; + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, 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 ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg->renderFramesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg->renderFramesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + arg->enableHeadRotation = true; + } + + if ( arg->voipMode ) + { + if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg->inputFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg->voipMode ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( arg->renderConfigEnabled && renderConfig != NULL ) + { + if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, *renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + if ( arg->customLsOutputEnabled && hLsCustomData != NULL ) + { + if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, *hLsCustomData ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + return IVAS_ERR_OK; + +cleanup: + IVAS_DEC_Close( phIvasDec ); + return error; +} + +#endif + #undef WMC_TOOL_SKIP diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0e607039f..0cb0174d6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4030,7 +4030,12 @@ ivas_error ivas_output_buff_dec_fx( ); ivas_error ivas_dec_get_format_fx( +#ifdef DECODER_FORMAT_SWITCHING + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const bool isVoipMode /* i : voip mode indicator */ +#else Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#endif ); ivas_error ivas_dec_setup( diff --git a/lib_com/options.h b/lib_com/options.h index c6a4efa4b..3d461aa0f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ +#define DECODER_FORMAT_SWITCHING /* Re-initialize the decoder when the format/subformat of the incoming stream is changed */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index b63ca6e90..abc8f57b1 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -104,7 +104,12 @@ static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( *---------------------------------------------------------------------*/ ivas_error ivas_dec_get_format_fx( +#ifdef DECODER_FORMAT_SWITCHING + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const bool isVoipMode /* i : voip mode indicator */ +#else Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#endif ) { Word16 k, idx, num_bits_read; @@ -142,10 +147,23 @@ ivas_error ivas_dec_get_format_fx( !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) && !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } /*-------------------------------------------------------------------* @@ -183,10 +201,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -210,10 +241,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } /* read Ambisonic (SBA) order */ @@ -224,10 +268,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); @@ -235,10 +292,23 @@ ivas_error ivas_dec_get_format_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { +#ifdef DECODER_FORMAT_SWITCHING + UWord8 masaRestartCandidate; + masaRestartCandidate = 0; + move16(); +#endif /* read number of MASA transport channels */ k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); IF( st_ivas->bit_stream[k - 1] ) { +#ifdef DECODER_FORMAT_SWITCHING + test(); + IF( st_ivas->nchan_transport == 1 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } +#endif st_ivas->nchan_transport = 2; move16(); element_mode_flag = 1; @@ -246,6 +316,14 @@ ivas_error ivas_dec_get_format_fx( } ELSE { +#ifdef DECODER_FORMAT_SWITCHING + test(); + IF( st_ivas->nchan_transport == 2 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } +#endif st_ivas->nchan_transport = 1; move16(); } @@ -279,14 +357,35 @@ ivas_error ivas_dec_get_format_fx( element_mode_flag = 1; move16(); } +#ifdef DECODER_FORMAT_SWITCHING + ELSE IF( masaRestartCandidate > 0 ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } +#endif test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -305,10 +404,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -323,10 +435,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; @@ -354,10 +479,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); @@ -384,10 +522,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); @@ -486,10 +637,23 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + else + { +#endif #ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); +#ifdef DECODER_FORMAT_SWITCHING + } +#endif } st_ivas->nchan_ism = nchan_ism; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4a464705d..06ed4c4c3 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1215,6 +1215,9 @@ typedef struct Decoder_Struct #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR Word16 flushing; #endif +#ifdef DECODER_FORMAT_SWITCHING + UWord8 restartNeeded; /* Flag to check if the decoder requires a restart */ +#endif } Decoder_Struct; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 1167d60b9..38bd39dd4 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -332,6 +332,12 @@ ivas_error IVAS_DEC_Flush( Word16 *nSamplesFlushed /* o : number of samples flushed */ ); +#ifdef DECODER_FORMAT_SWITCHING +bool IVAS_DEC_isRestartNeeded( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +); + +#endif /* Setter functions - apply changes to decoder configuration */ /*! r: error code */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 44a8aa54f..021dc5b6a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -244,6 +244,11 @@ ivas_error IVAS_DEC_Open( /* initialize pointers to handles to NULL */ ivas_initialize_handles_dec( st_ivas ); +#ifdef DECODER_FORMAT_SWITCHING + st_ivas->restartNeeded = 0; + move16(); +#endif + /* set high-level parameters */ IF( EQ_16( mode, IVAS_DEC_MODE_EVS ) ) { @@ -2139,12 +2144,24 @@ ivas_error IVAS_DEC_GetFormat( } move32(); +#ifdef DECODER_FORMAT_SWITCHING + test(); + IF( EQ_32( *format, IVAS_DEC_BS_MASA ) && hIvasDec->st_ivas->hMasa != NULL ) + { + IF( EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + { + *format = IVAS_DEC_BS_MASA_ISM; + move32(); + } + } +#else test(); if ( EQ_32( *format, IVAS_DEC_BS_MASA ) && EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) { *format = IVAS_DEC_BS_MASA_ISM; move32(); } +#endif return IVAS_ERR_OK; } @@ -3620,7 +3637,9 @@ ivas_error IVAS_DEC_ReadFormat( { ivas_error error; Decoder_Struct *st_ivas; +#ifndef DECODER_FORMAT_SWITCHING IVAS_FORMAT ivas_format_old; +#endif ISM_MODE ism_mode_old; MC_MODE mc_mode_old; Word16 nchan_transport_old; @@ -3634,7 +3653,9 @@ ivas_error IVAS_DEC_ReadFormat( } st_ivas = hIvasDec->st_ivas; +#ifndef DECODER_FORMAT_SWITCHING ivas_format_old = st_ivas->ivas_format; +#endif ism_mode_old = st_ivas->ism_mode; mc_mode_old = st_ivas->mc_mode; nchan_transport_old = st_ivas->nchan_transport; @@ -3661,11 +3682,22 @@ ivas_error IVAS_DEC_ReadFormat( IF( st_ivas->bfi == 0 ) { +#ifdef DECODER_FORMAT_SWITCHING + IF( NE_32( error = ivas_dec_get_format_fx( st_ivas, hIvasDec->hVoIP != NULL ), IVAS_ERR_OK ) ) +#else IF( NE_32( error = ivas_dec_get_format_fx( st_ivas ), IVAS_ERR_OK ) ) +#endif { return error; } +#ifdef DECODER_FORMAT_SWITCHING + IF( st_ivas->restartNeeded > 0 ) + { + return IVAS_ERR_OK; + } +#else + test(); test(); test(); @@ -3673,6 +3705,7 @@ ivas_error IVAS_DEC_ReadFormat( { return ( IVAS_ERROR( IVAS_ERR_INVALID_INPUT_FORMAT, "IVAS format switching is not allowed." ) ); } +#endif /* Select binaural renderer */ ivas_renderer_select( st_ivas ); @@ -5239,6 +5272,22 @@ ivas_error IVAS_DEC_Flush( } +#ifdef DECODER_FORMAT_SWITCHING +/*---------------------------------------------------------------------* + * IVAS_DEC_isRestartNeeded( ) + * + * + *---------------------------------------------------------------------*/ + +bool IVAS_DEC_isRestartNeeded( + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) +{ + return hIvasDec->st_ivas->restartNeeded > 0; +} + + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_IsEmpty( ) * -- GitLab From 8fe09912376aad4f81d8bc601470505b727bbc54 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 10 Nov 2025 14:18:33 +0100 Subject: [PATCH 243/351] [fix] align lib_rend with ivas-codec-pc --- lib_rend/lib_rend_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 299fe9b2e..4c245e43f 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -1829,6 +1829,7 @@ static ivas_error setRendInputActiveIsm( FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { + inputIsm->splitTdRendWrappers[i] = defaultTdRendWrapper(); inputIsm->splitTdRendWrappers[i].hHrtfTD = &hrtfs->hHrtfTD; } @@ -3141,6 +3142,7 @@ static ivas_error setRendInputActiveMc( test(); FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { + inputMc->splitTdRendWrappers[i] = defaultTdRendWrapper(); if ( hrtfs->hHrtfTD ) { inputMc->splitTdRendWrappers[i].binaural_latency_ns = L_shr_r( Mpy_32_32_r( hrtfs->hHrtfTD->latency_s_fx, 1000000000 ), hrtfs->hHrtfTD->latency_s_Q_fx ); -- GitLab From 6e97e6410acde5118ff1a3b1184af05a09c10192 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 15:20:19 +0200 Subject: [PATCH 244/351] Clang format --- lib_util/ivas_rtp_pi_data.c | 30 +++++++++++++++--------------- lib_util/ivas_rtp_pi_data.h | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 6a55a64fb..c9583e048 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -900,10 +900,10 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #endif packUnsupportedData, /* RESERVED15 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - packOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ - packOrientation, /* HEAD_ORIENTATION */ + packOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ + packOrientation, /* HEAD_ORIENTATION */ #ifdef REVERSE_ISM_PI_DATA - packPosition, /* LISTENER_POSITION */ + packPosition, /* LISTENER_POSITION */ #else packListenerPosition, /* LISTENER_POSITION */ #endif @@ -918,11 +918,11 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #endif packUnsupportedData, /* PI_LATENCY */ #ifdef REVERSE_ISM_PI_DATA - packReverseISMID, /* R_ISM_ID */ + packReverseISMID, /* R_ISM_ID */ packReverseISMGain, /* R_ISM_GAIN */ #else - packUnsupportedData, /* R_ISM_ID */ - packUnsupportedData, /* R_ISM_GAIN */ + packUnsupportedData, /* R_ISM_ID */ + packUnsupportedData, /* R_ISM_GAIN */ #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* R_ISM_ORIENTATION */ @@ -931,11 +931,11 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #endif #ifdef REVERSE_ISM_PI_DATA - packPosition, /* R_ISM_POSITION */ + packPosition, /* R_ISM_POSITION */ packReverseISMDirection, /* R_ISM_DIRECTION */ #else - packUnsupportedData, /* R_ISM_POSITION */ - packUnsupportedData, /* R_ISM_DIRECTION */ + packUnsupportedData, /* R_ISM_POSITION */ + packUnsupportedData, /* R_ISM_DIRECTION */ #endif packUnsupportedData, /* RESERVED27 */ packUnsupportedData, /* RESERVED28 */ @@ -974,12 +974,12 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #endif unpackUnsupportedData, /* RESERVED15 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - unpackOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ - unpackOrientation, /* HEAD_ORIENTATION */ + unpackOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ + unpackOrientation, /* HEAD_ORIENTATION */ #ifdef REVERSE_ISM_PI_DATA - unpackPosition, /* LISTENER_POSITION */ + unpackPosition, /* LISTENER_POSITION */ #else - unpackListenerPosition, /* LISTENER_POSITION */ + unpackListenerPosition, /* LISTENER_POSITION */ #endif unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ @@ -992,7 +992,7 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #endif unpackUnsupportedData, /* PI_LATENCY */ #ifdef REVERSE_ISM_PI_DATA - unpackReverseISMID, /* R_ISM_ID */ + unpackReverseISMID, /* R_ISM_ID */ unpackReverseISMGain, /* R_ISM_GAIN */ #else unpackUnsupportedData, /* R_ISM_ID */ @@ -1004,7 +1004,7 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* R_ISM_ORIENTATION */ #endif #ifdef REVERSE_ISM_PI_DATA - unpackPosition, /* R_ISM_POSITION */ + unpackPosition, /* R_ISM_POSITION */ unpackReverseISMDirection, /* R_ISM_DIRECTION */ #else unpackUnsupportedData, /* R_ISM_POSITION */ diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index e9effd359..d29c0eea4 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -40,9 +40,9 @@ #define IVAS_PI_MAX_DATA_SIZE ( 32 + 2 ) /* max packed PI data bytes + pi header bytes */ #ifdef REVERSE_ISM_PI_DATA -#define REVERSE_ISM_DIRECTION_AZIMUTH_STEP 0.703125f -#define REVERSE_ISM_DIRECTION_ELEVATION_STEP 1.417322835f -#define REVERSE_ISM_DIRECTION_AZIMUTH_STEP_INV 1.4222222222f +#define REVERSE_ISM_DIRECTION_AZIMUTH_STEP 0.703125f +#define REVERSE_ISM_DIRECTION_ELEVATION_STEP 1.417322835f +#define REVERSE_ISM_DIRECTION_AZIMUTH_STEP_INV 1.4222222222f #define REVERSE_ISM_DIRECTION_ELEVATION_STEP_INV 0.7055555556f #endif -- GitLab From 3c3d6dc7cd84108b855401e097124c5a36c8b2a7 Mon Sep 17 00:00:00 2001 From: "@ragot" Date: Mon, 10 Nov 2025 14:20:34 +0100 Subject: [PATCH 245/351] fix clang --- apps/encoder_fmtsw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index ff04c87fd..74efb401f 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -56,10 +56,10 @@ rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */ #include #if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG ) -#define S_ISREG( m ) ( ( ( m ) & S_IFMT ) == S_IFREG ) +#define S_ISREG( m ) ( ( (m) &S_IFMT ) == S_IFREG ) #endif #if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR ) -#define S_ISDIR( m ) ( ( ( m ) & S_IFMT ) == S_IFDIR ) +#define S_ISDIR( m ) ( ( (m) &S_IFMT ) == S_IFDIR ) #endif #endif -- GitLab From a310905006ab85003e2f340fd12dc649310dcd66 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 10 Nov 2025 14:23:32 +0100 Subject: [PATCH 246/351] Moving #include to the top of the header file --- lib_dec/lib_dec.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 6f38b2688..70a6bb624 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -36,6 +36,10 @@ #include "common_api_types.h" #include #include "typedef.h" +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#include "ivas_rtp_pi_data.h" +#endif + /*---------------------------------------------------------------------* * Decoder enums @@ -526,7 +530,9 @@ void IVAS_DEC_PrintDisclaimer( ); #ifdef IVAS_RTPDUMP +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT #include "ivas_rtp_pi_data.h" +#endif ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, UWord32 numPiData ); #endif -- GitLab From 4e8797267442a8927f3976cca8c809b28ab30211 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 15:27:00 +0200 Subject: [PATCH 247/351] Fix debug build issue --- lib_dec/lib_dec_fx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 44a8aa54f..13dd59cdc 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6577,7 +6577,11 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi { IVAS_QUATERNION *quat = &piData->data.scene.orientation; #ifdef DEBUGGING - fprintf( stdout, "PI_SCENE_ORIENTATION : %f, %f, %f, %f\n", quat->w, quat->x, quat->y, quat->z ); + fprintf( stdout, "PI_SCENE_ORIENTATION : %f, %f, %f, %f\n", + fixedToFloat( quat->w_fx, Q15 ), + fixedToFloat( quat->x_fx, Q15 ), + fixedToFloat( quat->y_fx, Q15 ), + fixedToFloat( quat->z_fx, Q15 ) ); #endif error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); } @@ -6587,7 +6591,11 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi { IVAS_QUATERNION *quat = &piData->data.deviceCompensated.orientation; #ifdef DEBUGGING - fprintf( stdout, "PI_DEVICE_ORIENTATION : %f, %f, %f, %f\n", quat->w, quat->x, quat->y, quat->z ); + fprintf( stdout, "PI_DEVICE_ORIENTATION : %f, %f, %f, %f\n", + fixedToFloat( quat->w_fx, Q15 ), + fixedToFloat( quat->x_fx, Q15 ), + fixedToFloat( quat->y_fx, Q15 ), + fixedToFloat( quat->z_fx, Q15 ) ); #endif error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); } -- GitLab From cc88887744c1e5875d53b1c0f1ddde86770b5799 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 15:30:42 +0200 Subject: [PATCH 248/351] Clang format --- lib_dec/ivas_init_dec_fx.c | 814 ++++++++++++++++++------------------- 1 file changed, 397 insertions(+), 417 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index abc8f57b1..8ea034cfe 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -145,545 +145,525 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->ivas_format, st_ivas->last_ivas_format ) && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) && - !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ) - { + !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { + IF( isVoipMode ){ st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} +/*-------------------------------------------------------------------* + * Read other signaling (ISM/MC mode, number of channels, etc.) + *-------------------------------------------------------------------*/ + +IF( is_DTXrate( ivas_total_brate ) == 0 ) +{ /*-------------------------------------------------------------------* - * Read other signaling (ISM/MC mode, number of channels, etc.) + * Read IVAS format related signaling: + * - in ISM : read number of objects + * - in SBA : read SBA planar flag and SBA order + * - in MASA : read number of TC + * - in MC : read LS setup *-------------------------------------------------------------------*/ - IF( is_DTXrate( ivas_total_brate ) == 0 ) + IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - /*-------------------------------------------------------------------* - * Read IVAS format related signaling: - * - in ISM : read number of objects - * - in SBA : read SBA planar flag and SBA order - * - in MASA : read number of TC - * - in MC : read LS setup - *-------------------------------------------------------------------*/ - - IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - { - element_mode_flag = 1; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + element_mode_flag = 1; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* read the number of objects */ + nchan_ism = 1; + move16(); + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + k = sub( k, 1 ); + WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) { - /* read the number of objects */ - nchan_ism = 1; - move16(); - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( nchan_ism, 1 ); k = sub( k, 1 ); - WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) - { - nchan_ism = add( nchan_ism, 1 ); - k = sub( k, 1 ); - } + } - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } + } #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); - st_ivas->ism_mode = ivas_ism_mode_select( nchan_ism, ivas_total_brate ); +st_ivas->nchan_ism = nchan_ism; +move16(); +st_ivas->ism_mode = ivas_ism_mode_select( nchan_ism, ivas_total_brate ); - st_ivas->nchan_transport = nchan_ism; - move16(); - if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) - { - st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; - move16(); - } - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) - { - /* read Ambisonic (SBA) planar flag */ - sba_planar = st_ivas->bit_stream[num_bits_read]; - num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); +st_ivas->nchan_transport = nchan_ism; +move16(); +if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) +{ + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); +} +} +ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) +{ + /* read Ambisonic (SBA) planar flag */ + sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); + fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - /* read Ambisonic (SBA) order */ - sba_order = st_ivas->bit_stream[num_bits_read + 1]; - move16(); - sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); +/* read Ambisonic (SBA) order */ +sba_order = st_ivas->bit_stream[num_bits_read + 1]; +move16(); +sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) - { +test(); +IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; +move16(); +return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); - st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) - { +sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); +st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); +} +ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) +{ #ifdef DECODER_FORMAT_SWITCHING - UWord8 masaRestartCandidate; - masaRestartCandidate = 0; - move16(); + UWord8 masaRestartCandidate; + masaRestartCandidate = 0; + move16(); #endif - /* read number of MASA transport channels */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - IF( st_ivas->bit_stream[k - 1] ) - { + /* read number of MASA transport channels */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( st_ivas->bit_stream[k - 1] ) + { #ifdef DECODER_FORMAT_SWITCHING - test(); - IF( st_ivas->nchan_transport == 1 && isVoipMode ) - { - masaRestartCandidate = 1; - move16(); - } + test(); + IF( st_ivas->nchan_transport == 1 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } #endif - st_ivas->nchan_transport = 2; - move16(); - element_mode_flag = 1; - move16(); - } - ELSE - { + st_ivas->nchan_transport = 2; + move16(); + element_mode_flag = 1; + move16(); + } + ELSE + { #ifdef DECODER_FORMAT_SWITCHING - test(); - IF( st_ivas->nchan_transport == 2 && isVoipMode ) - { - masaRestartCandidate = 1; - move16(); - } + test(); + IF( st_ivas->nchan_transport == 2 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } #endif - st_ivas->nchan_transport = 1; - move16(); - } + st_ivas->nchan_transport = 1; + move16(); + } - /* this should be non-zero if original input format was MASA_ISM_FORMAT */ - st_ivas->ism_mode = ISM_MODE_NONE; + /* this should be non-zero if original input format was MASA_ISM_FORMAT */ + st_ivas->ism_mode = ISM_MODE_NONE; + move16(); + nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); + + IF( nchan_ism > 0 ) + { + /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ + /* info about the number of objects: + '00' - MASA format at the encoder + '01' - MASA_ISM_FORMAT at the encoder, with 4 objects + '10' - MASA_ISM_FORMAT at the encoder, with 3 objects + '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects + reading if 1 or 2 objects is performed later + */ + nchan_ism = sub( 5, nchan_ism ); + test(); + IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) + { + nchan_ism = 1; move16(); - nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); - - IF( nchan_ism > 0 ) - { - /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ - /* info about the number of objects: - '00' - MASA format at the encoder - '01' - MASA_ISM_FORMAT at the encoder, with 4 objects - '10' - MASA_ISM_FORMAT at the encoder, with 3 objects - '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects - reading if 1 or 2 objects is performed later - */ - nchan_ism = sub( 5, nchan_ism ); - test(); - IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) - { - nchan_ism = 1; - move16(); - } + } - /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ - st_ivas->nchan_transport = 2; - move16(); - element_mode_flag = 1; - move16(); - } + /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ + st_ivas->nchan_transport = 2; + move16(); + element_mode_flag = 1; + move16(); + } #ifdef DECODER_FORMAT_SWITCHING - ELSE IF( masaRestartCandidate > 0 ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } + ELSE IF( masaRestartCandidate > 0 ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } #endif - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) - { - st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ - move16(); +st_ivas->nchan_ism = nchan_ism; +move16(); +} +ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) +{ + st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ + move16(); - /* the number of objects are written at the end of the bitstream */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); - st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism ); + /* the number of objects are written at the end of the bitstream */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) - { - /* the number of objects is written at the end of the bitstream, in the SBA metadata */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); +st_ivas->nchan_ism = nchan_ism; +move16(); +} +ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) +{ + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); +st_ivas->nchan_ism = nchan_ism; +move16(); - /* read Ambisonic (SBA) planar flag */ - /*sba_planar = st_ivas->bit_stream[num_bits_read];*/ - num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); +/* read Ambisonic (SBA) planar flag */ +/*sba_planar = st_ivas->bit_stream[num_bits_read];*/ +num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); - /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ - sba_order = st_ivas->bit_stream[num_bits_read + 1]; - move16(); - sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); - num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); +/* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ +sba_order = st_ivas->bit_stream[num_bits_read + 1]; +move16(); +sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); +num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); - /* read the real Ambisonic order when the above bits are used to signal OSBA format */ - IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) - { - sba_order = st_ivas->bit_stream[num_bits_read + 1]; - move16(); - sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); - num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); - } +/* read the real Ambisonic order when the above bits are used to signal OSBA format */ +IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) +{ + sba_order = st_ivas->bit_stream[num_bits_read + 1]; + move16(); + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); + num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); +} - test(); - IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) - { +test(); +IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; +move16(); +return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); +st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); - sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); - st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); - } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) +sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); +st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); +} +ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) +{ + /* read MC configuration */ + idx = 0; + move16(); + FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) + { + IF( st_ivas->bit_stream[num_bits_read + k] ) { - /* read MC configuration */ - idx = 0; - move16(); - FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) - { - IF( st_ivas->bit_stream[num_bits_read + k] ) - { - idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); - } - } - num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); + idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); + } + } + num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); - signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); + signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); - test(); - IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; +} +ELSE +{ #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); + fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } +} #endif - } +} - st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); - st_ivas->transport_config = signaled_config; - move16(); - } +st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); +st_ivas->transport_config = signaled_config; +move16(); +} - /*-------------------------------------------------------------------* - * Read element mode - *-------------------------------------------------------------------*/ +/*-------------------------------------------------------------------* + * Read element mode + *-------------------------------------------------------------------*/ - test(); - IF( st_ivas->ini_frame == 0 && element_mode_flag ) +test(); +IF( st_ivas->ini_frame == 0 && element_mode_flag ) +{ + /* read stereo technology info */ + if ( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) + { + /* 1 bit */ + IF( st_ivas->bit_stream[num_bits_read] ) { - /* read stereo technology info */ - if ( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) + st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT ); + } + ELSE + { + st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT ); + } + } + ELSE + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + } +} +} +ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) +{ + SWITCH( st_ivas->sid_format ) + { + case SID_DFT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_DFT; + move16(); + BREAK; + case SID_MDCT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + BREAK; + case SID_ISM: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + BREAK; + case SID_MASA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + st_ivas->nchan_transport = 1; + move16(); + BREAK; + case SID_MASA_2TC: + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( st_ivas->bit_stream[k - 1 - SID_FORMAT_NBITS] == 1 ) { - /* 1 bit */ - IF( st_ivas->bit_stream[num_bits_read] ) - { - st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT ); - } - ELSE - { - st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT ); - } + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); } ELSE { - st_ivas->element_mode_init = IVAS_CPE_MDCT; + st_ivas->element_mode_init = IVAS_CPE_DFT; move16(); } - } + st_ivas->nchan_transport = 2; + move16(); + BREAK; + case SID_SBA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + BREAK; + case SID_SBA_2TC: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + BREAK; } - ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) - { - SWITCH( st_ivas->sid_format ) - { - case SID_DFT_STEREO: - st_ivas->element_mode_init = IVAS_CPE_DFT; - move16(); - BREAK; - case SID_MDCT_STEREO: - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - BREAK; - case SID_ISM: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - BREAK; - case SID_MASA_1TC: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - st_ivas->nchan_transport = 1; - move16(); - BREAK; - case SID_MASA_2TC: - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - IF( st_ivas->bit_stream[k - 1 - SID_FORMAT_NBITS] == 1 ) - { - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - ELSE - { - st_ivas->element_mode_init = IVAS_CPE_DFT; - move16(); - } - st_ivas->nchan_transport = 2; - move16(); - BREAK; - case SID_SBA_1TC: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - BREAK; - case SID_SBA_2TC: - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - BREAK; - } - IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* read the number of objects */ + nchan_ism = 1; + move16(); + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + k = sub( sub( k, 1 ), SID_FORMAT_NBITS ); + WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) { - /* read the number of objects */ - nchan_ism = 1; - move16(); - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - k = sub( sub( k, 1 ), SID_FORMAT_NBITS ); - WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) - { - nchan_ism = add( nchan_ism, 1 ); - k = sub( k, 1 ); - } + nchan_ism = add( nchan_ism, 1 ); k = sub( k, 1 ); + } + k = sub( k, 1 ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) - { + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - else - { + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + else + { #endif #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #ifdef DECODER_FORMAT_SWITCHING - } + } #endif - } +} - st_ivas->nchan_ism = nchan_ism; - move16(); +st_ivas->nchan_ism = nchan_ism; +move16(); - /* read ism_mode */ - st_ivas->ism_mode = ISM_MODE_DISC; - move32(); - IF( GT_16( nchan_ism, 2 ) ) - { - k = sub( k, nchan_ism ); /* SID metadata flags */ - idx = st_ivas->bit_stream[k]; - move16(); - st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); - move32(); - } +/* read ism_mode */ +st_ivas->ism_mode = ISM_MODE_DISC; +move32(); +IF( GT_16( nchan_ism, 2 ) ) +{ + k = sub( k, nchan_ism ); /* SID metadata flags */ + idx = st_ivas->bit_stream[k]; + move16(); + st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); + move32(); +} - st_ivas->nchan_transport = nchan_ism; - move16(); - if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) - { - st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; - move16(); - } - } - } +st_ivas->nchan_transport = nchan_ism; +move16(); +if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) +{ + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); +} +} +} - st_ivas->bit_stream = bit_stream_orig; +st_ivas->bit_stream = bit_stream_orig; - return IVAS_ERR_OK; +return IVAS_ERR_OK; } -- GitLab From f85ff450705480f2aefe4ee2b896ded7399d54ac Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Nov 2025 14:34:44 +0100 Subject: [PATCH 249/351] fix --- lib_dec/lib_dec_fx.c | 115 ++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 249f59f66..513fd8cd7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -294,12 +294,14 @@ ivas_error IVAS_DEC_Open( move16(); move16(); move16(); + return IVAS_ERR_OK; } return IVAS_ERR_WRONG_PARAMS; } + /*-------------------------------------------------------------------------* * isar_set_split_rend_setup() * @@ -321,6 +323,14 @@ static ivas_error isar_set_split_rend_setup( splitRendBits->codec_frame_size_ms = 0; splitRendBits->isar_frame_size_ms = 0; splitRendBits->lc3plus_highres = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); #ifndef TMP_FIX_SPLIT_REND IF( ( hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) @@ -339,6 +349,7 @@ static ivas_error isar_set_split_rend_setup( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * init_decoder_config() * @@ -747,18 +758,21 @@ ivas_error IVAS_DEC_SetRenderFramesize( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize; + move16(); + IF( hIvasDec->st_ivas->hExtOrientationData != NULL ) { hIvasDec->st_ivas->hExtOrientationData->num_subframes = (Word16) render_framesize; + move16(); } + IF( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) { hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (Word16) render_framesize; + move16(); } - hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize; - move16(); - return IVAS_ERR_OK; } @@ -818,10 +832,12 @@ static Word16 get_render_frame_size_samples( { tmp = 0; } + return tmp; } #endif + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesizeSamples( ) * @@ -871,6 +887,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetRenderFramesizeMs( ) * @@ -895,6 +912,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeMs( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetGetReferencesUpdateFrequency( ) * @@ -1119,7 +1137,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( move16(); } - /* Update redundant frame information in EVS (pre- read indices) */ + /* Update redundant frame information in EVS (pre- read indices) */ test(); test(); IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) && hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) @@ -1320,15 +1338,15 @@ static ivas_error isar_generate_metadata_and_bitstream( move16(); } - n_samples_in_cldfb_slot = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - assert( nSamples % n_samples_in_cldfb_slot == 0 ); - num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); - - num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; - move16(); - IF( cldfb_in_flag ) { + n_samples_in_cldfb_slot = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + assert( nSamples % n_samples_in_cldfb_slot == 0 ); + num_cldfb_slots = int_div_s_x( nSamples, n_samples_in_cldfb_slot ); + + num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + FOR( i = 0; i < imult1616( BINAURAL_CHANNELS, num_poses ); ++i ) { FOR( j = 0; j < num_cldfb_slots; ++j ) @@ -1348,8 +1366,12 @@ static ivas_error isar_generate_metadata_and_bitstream( ELSE { ivas_TD_RINGBUF_PopChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_head_pose_buf, nSamples ); - } + num_cldfb_slots = 0; // just to avoid compilation warning + num_poses = 0; // just to avoid compilation warning + move16(); + move16(); + } IF( st_ivas->hBinRendererTd != NULL ) { @@ -1470,7 +1492,7 @@ ivas_error IVAS_DEC_GetSamplesRenderer( { ivas_error error; UWord16 nSamplesRendered, nSamplesRendered_loop; - UWord16 nOutChannels; + UWord8 nOutChannels; Decoder_Struct *st_ivas; nSamplesRendered = 0; @@ -1531,11 +1553,12 @@ ivas_error IVAS_DEC_GetSamplesRenderer( move16(); move16(); move16(); + return IVAS_ERR_OK; } - test(); /* check if we are still at the beginning with bad frames, put out zeroes, keep track of subframes */ + test(); IF( !hIvasDec->isInitialized && st_ivas->bfi ) { hIvasDec->hasBeenFedFrame = false; @@ -1681,7 +1704,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); } - ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, pcmBuf_out ); } #else Decoder_Struct *st_ivas; @@ -4387,6 +4410,7 @@ ivas_error IVAS_DEC_SetEditableParameters( move32(); st_ivas->hParamIsmDec->edited_elevation_values_fx[obj] = hIvasEditableParameters.ism_metadata[obj].elevation_fx; move32(); + IF( st_ivas->hMasaIsmData != NULL ) { #ifdef FIX_GAIN_EDIT_LIMITS @@ -4786,7 +4810,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples IF( hIvasDec->hasBeenFedFirstGoodFrame ) { /* check if the TC buffer already exists, otherweise nothing is buffered anyway */ - IF( st_ivas->hTcBuffer != NULL ) { nSamplesBuffered = sub( st_ivas->hTcBuffer->n_samples_buffered, st_ivas->hTcBuffer->n_samples_rendered ); @@ -4956,6 +4979,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples move16(); *parametersAvailableForEditing = true; move16(); + return IVAS_ERR_OK; } } @@ -5028,7 +5052,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); } - ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf ); + ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } } #endif @@ -5104,6 +5128,7 @@ ivas_error IVAS_DEC_VoIP_GetSplitBinauralBitstream( Word32 *pp_head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES]; ivas_error error = IVAS_ERR_UNKNOWN; Word16 nSamplesPerChannel = 0; + move16(); IF( NE_32( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nSamplesPerChannel ) ), IVAS_ERR_OK ) ) { @@ -5300,8 +5325,8 @@ static void ivas_destroy_handle_VoIP_fx( return; } - #ifdef SUPPORT_JBM_TRACEFILE + /*---------------------------------------------------------------------* * store_JbmData() * @@ -5378,7 +5403,6 @@ ivas_error IVAS_DEC_GetJbmData( #endif - /*---------------------------------------------------------------------* * IVAS_DEC_GetErrorMessage( ) * @@ -5756,23 +5780,8 @@ static ivas_error evs_dec_main_fx( IF( st_ivas->hDecoderConfig->Opt_tsm ) #endif { - /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ // TODO: verify if it is still needed and if it works well for EVS stereo panning output -#ifdef JBM_MEMORY_OPT - Word32 pcm_buf_local[CPE_CHANNELS * L_FRAME48k]; -#else - Word32 pcm_buf_local[L_FRAME48k]; -#endif - - FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) - { -#ifdef JBM_MEMORY_OPT - ivas_buffer_deinterleaved_to_interleaved_fx( &p_output_fx[ch], st_ivas->hDecoderConfig->nchan_out, nOutSamples, pcm_buf_local ); -#else - ivas_syn_output_f_fx( &p_output_fx[ch], nOutSamples, 1, pcm_buf_local ); -#endif - - Copy32( pcm_buf_local, p_output_fx[ch], nOutSamples ); - } + /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ + /* not applicable in BASOP */ } return IVAS_ERR_OK; @@ -5824,6 +5833,7 @@ static ivas_error input_format_API_to_internal( move16(); move16(); + return IVAS_ERR_OK; } @@ -5890,6 +5900,7 @@ static ivas_error apa_setup( move16(); move16(); + test(); test(); test(); @@ -6068,6 +6079,7 @@ static ivas_error ivas_create_handle_isar( #endif hSplitBinRend->hCldfbDataOut = NULL; hSplitBinRend->numTdSamplesPerChannelCached = 0; + move16(); *hSplitBinRend_out = hSplitBinRend; @@ -6096,6 +6108,7 @@ static void ivas_destroy_handle_isar( { ivas_TD_RINGBUF_Close( &( *hSplitBinRend )->hMultiBinTdData ); } + FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; ++i ) { IF( ( *hSplitBinRend )->hMultiBinCldfbData[i] != NULL ) @@ -6175,6 +6188,9 @@ static ivas_error ivas_dec_reconfig_split_rend( cldfb_in_flag = 0; move16(); + test(); + test(); + test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || @@ -6189,6 +6205,10 @@ static ivas_error ivas_dec_reconfig_split_rend( isCldfbNeeded = 0; move16(); + test(); + test(); + test(); + test(); IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) { @@ -6220,6 +6240,7 @@ static ivas_error ivas_dec_reconfig_split_rend( move16(); } + test(); test(); IF( EQ_16( isCldfbNeeded, 1 ) && hSplitRendWrapper->hCldfbHandles == NULL ) { @@ -6228,7 +6249,7 @@ static ivas_error ivas_dec_reconfig_split_rend( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); } - num_ch = i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS ); + num_ch = MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS; move16(); FOR( ch = 0; ch < num_ch; ch++ ) { @@ -6257,7 +6278,7 @@ static ivas_error ivas_dec_reconfig_split_rend( } ELSE IF( EQ_16( isCldfbNeeded, 0 ) && hSplitRendWrapper->hCldfbHandles != NULL ) { - num_ch = i_mult( MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS ); + num_ch = MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS; move16(); FOR( ch = 0; ch < num_ch; ch++ ) { @@ -6284,6 +6305,11 @@ static ivas_error ivas_dec_reconfig_split_rend( move32(); } + test(); + test(); + test(); + test(); + test(); IF( ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) /* td-rend not needed? */ @@ -6350,7 +6376,13 @@ static ivas_error ivas_dec_init_split_rend( ISAR_SPLIT_REND_ROT_AXIS head_rot_axis; #endif - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + pcm_out_flag = 0; + move16(); + if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + pcm_out_flag = 1; + move16(); + } cldfb_in_flag = 0; move16(); @@ -6384,6 +6416,7 @@ static ivas_error ivas_dec_init_split_rend( head_rot_axis = st_ivas->hHeadTrackData->sr_pose_pred_axis; move32(); } + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, head_rot_axis ); num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -6423,6 +6456,10 @@ static ivas_error ivas_dec_init_split_rend( mixed_td_cldfb_flag = 0; move16(); + test(); + test(); + test(); + test(); IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) { -- GitLab From 96be43778b8d95ea55e6097d7040b8d4e4e2f071 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 10 Nov 2025 15:59:26 +0200 Subject: [PATCH 250/351] Adds external renderer parts into the BASOP conversion. --- apps/renderer.c | 76 +++++++++++++++ lib_com/ivas_cnst.h | 1 + lib_com/options.h | 2 +- lib_rend/lib_rend.h | 12 +++ lib_rend/lib_rend_fx.c | 203 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 293 insertions(+), 1 deletion(-) diff --git a/apps/renderer.c b/apps/renderer.c index 153661395..03ac4410d 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -200,6 +200,9 @@ typedef struct IVAS_RENDER_FRAMESIZE render_framesize; uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; AcousticEnvironmentSequence aeSequence; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + IVAS_ROOM_SIZE_T reverbRoomSize; +#endif } CmdlnArgs; typedef enum @@ -230,7 +233,12 @@ typedef enum CmdLnOptionId_framing, CmdLnOptionId_syncMdDelay, CmdLnOptionId_directivityPatternId, +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + CmdLnOptionId_acousticEnvironmentId, + CmdLnOptionId_roomSize, +#else CmdLnOptionId_acousticEnvironmentId +#endif } CmdLnOptionId; static const CmdLnParser_Option cliOptions[] = { @@ -400,6 +408,14 @@ static const CmdLnParser_Option cliOptions[] = { .description = "Acoustic environment ID( number > 0 ) or a sequence thereof in the format [ID1:duration1,ID2:duration2...] without braces and spaces, with ':' character separating ID from duration and ',' separating ID and duration pairs, where duration is specified in frames for BINAURAL_ROOM_REVERB output configuration.", #endif }, +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + { + .id = CmdLnOptionId_roomSize, + .match = "room_size", + .matchShort = "rsz", + .description = "Selects default reverb based on a room size (S - small | M - medium | L - large)", + } +#endif }; @@ -1252,6 +1268,19 @@ int main( goto cleanup; } +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + + /* Set reverb room size if specified */ + if ( args.reverbRoomSize != IVAS_ROOM_SIZE_AUTO ) + { + if ( ( IVAS_REND_SetReverbRoomSize( hIvasRend, args.reverbRoomSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError setting reverb room size\n" ); + goto cleanup; + } + } +#endif + /* Set up output custom layout configuration */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { @@ -2751,6 +2780,39 @@ static bool parseAcousticEnvironmentIds( return true; } +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + + +static bool parseReverbRoomSize( + char *value, + IVAS_ROOM_SIZE_T *reverbRoomSize ) +{ + if ( strlen( value ) != 1 ) + { + fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", value ); + return false; + } + + to_upper( value ); + switch ( value[0] ) + { + case 'S': + *reverbRoomSize = IVAS_ROOM_SIZE_SMALL; + break; + case 'M': + *reverbRoomSize = IVAS_ROOM_SIZE_MEDIUM; + break; + case 'L': + *reverbRoomSize = IVAS_ROOM_SIZE_LARGE; + break; + default: + fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", value ); + return false; + } + + return true; +} +#endif static bool checkRequiredArgs( @@ -2872,6 +2934,10 @@ static CmdlnArgs defaultArgs( args.aeSequence.pValidity = NULL; args.aeSequence.selected = 0; args.aeSequence.frameCounter = 0; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + + args.reverbRoomSize = IVAS_ROOM_SIZE_AUTO; +#endif return args; } @@ -3053,6 +3119,16 @@ static void parseOption( /* Metadata Delay to sync with audio delay in ms */ args->syncMdDelay = (int16_t) strtol( optionValues[0], NULL, 10 ); break; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + case CmdLnOptionId_roomSize: + assert( numOptionValues == 1 ); + if ( !parseReverbRoomSize( optionValues[0], &args->reverbRoomSize ) ) + { + fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", optionValues[0] ); + exit( -1 ); + } + break; +#endif default: assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); break; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index fc3e143d4..f3d33b153 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1675,6 +1675,7 @@ typedef enum #ifdef FIX_1318_ROOM_SIZE_CMD_LINE typedef enum { + DEFAULT_REVERB_UNSET = -1, DEFAULT_REVERB_SMALL, DEFAULT_REVERB_MEDIUM, DEFAULT_REVERB_LARGE diff --git a/lib_com/options.h b/lib_com/options.h index b8d5cc456..4ed5b5478 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -146,7 +146,7 @@ #define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */ #define NONBE_1344_REND_MASA_LOW_FS /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */ #define NONBE_1412_AVOID_ROUNDING_AZ_ELEV /* FhG: Avoid rounding when passing azimuth and elevation to efap_determine_gains() */ -#define FIX_1318_ROOM_SIZE_CMD_LINE /* Philips/Nokia: Default room sizes support */ +#define FIX_1318_ROOM_SIZE_CMD_LINE /* Philips/Nokia/FhG: Default room sizes support */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index f5f1d86cb..afc16e5e0 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -270,6 +270,18 @@ ivas_error IVAS_REND_FeedRenderConfig( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ ); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + +ivas_error IVAS_REND_GetReverbRoomSize( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_ROOM_SIZE_T *reverbRoomSize /* o : Reverb room size */ +); + +ivas_error IVAS_REND_SetReverbRoomSize( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + const IVAS_ROOM_SIZE_T reverbRoomSize /* i : Reverb room size */ +); +#endif ivas_error IVAS_REND_FeedSplitBinauralBitstream( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 299fe9b2e..5a7c82ea7 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -102,6 +102,9 @@ typedef struct const Word16 *pSplitRendBFI; const SPLIT_REND_WRAPPER *pSplitRendWrapper; const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + const IVAS_DefaultReverbSize *pSelectedRoomReverbSize; +#endif } rendering_context; /* Common base for input structs */ @@ -232,6 +235,9 @@ struct IVAS_REND Word8 rendererConfigEnabled; RENDER_CONFIG_DATA *hRendererConfig; /* Renderer config pointer */ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + IVAS_DefaultReverbSize selectedRoomReverbSize; +#endif #ifdef DEBUGGING Word32 numClipping; /* Counter of clipped output samples */ @@ -1374,6 +1380,9 @@ static rendering_context getRendCtx( ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; ctx.pSplitRendWrapper = hIvasRend->splitRendWrapper; ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + ctx.pSelectedRoomReverbSize = &hIvasRend->selectedRoomReverbSize; +#endif return ctx; } @@ -3647,6 +3656,10 @@ ivas_error IVAS_REND_Open( move32(); hIvasRend->efapOutWrapper.pCustomLsSetup = NULL; move32(); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_UNSET; + move32(); +#endif hIvasRend->num_subframes = num_subframes; move16(); @@ -4425,7 +4438,99 @@ static ivas_error isar_pre_rend_init( return IVAS_ERR_OK; } +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE +static IVAS_ROOM_SIZE_T getDefaultReverbSize( + input_ism *ismInputs, + input_masa *masaInputs, + input_mc *mcInputs, + input_sba *sbaInputs ) +{ + bool combinedFormat; + Word16 i; + Word16 nActiveInputsIsm, nActiveInputsMasa, nActiveInputsSba, nActiveInputsMc; + IVAS_ROOM_SIZE_T selectedReverb; + selectedReverb = IVAS_ROOM_SIZE_MEDIUM; + move32(); + combinedFormat = false; + nActiveInputsIsm = 0; + nActiveInputsMasa = 0; + nActiveInputsMc = 0; + nActiveInputsSba = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + + FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ ) + { + IF( NE_32( ismInputs[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + { + nActiveInputsIsm = add( nActiveInputsIsm, 1 ); + } + } + FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) + { + IF( NE_32( masaInputs[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + { + nActiveInputsMasa = add( nActiveInputsMasa, 1 ); + } + } + FOR( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ ) + { + IF( NE_32( mcInputs[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + { + nActiveInputsMc = add( nActiveInputsMc, 1 ); + } + } + FOR( i = 0; i < RENDERER_MAX_SBA_INPUTS; i++ ) + { + IF( NE_32( sbaInputs[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) + { + nActiveInputsSba = add( nActiveInputsSba, 1 ); + } + } + + /* ISM present with MASA/SBA inputs; treat as combined format */ + test(); + test(); + IF( nActiveInputsIsm && ( nActiveInputsMasa || nActiveInputsSba ) ) + { + combinedFormat = true; + move16(); + } + + IF( combinedFormat ) + { + selectedReverb = IVAS_ROOM_SIZE_MEDIUM; + move32(); + } + ELSE + { + /* Only set large if ISM is present alone */ + test(); + IF( nActiveInputsIsm && !nActiveInputsMc ) + { + selectedReverb = IVAS_ROOM_SIZE_LARGE; + move32(); + } + /* if only MC is present, set medium; Will not be overridden by the subsequent block */ + ELSE IF( nActiveInputsMc ) + { + selectedReverb = IVAS_ROOM_SIZE_MEDIUM; + move32(); + } + ELSE IF( nActiveInputsMasa || nActiveInputsSba ) + { + selectedReverb = IVAS_ROOM_SIZE_SMALL; + move32(); + } + } + + return selectedReverb; +} +#endif /*-------------------------------------------------------------------* * IVAS_REND_AddInput() @@ -4565,6 +4670,18 @@ ivas_error IVAS_REND_AddInput_fx( /* set global maximum delay after adding an input */ setMaxGlobalDelayNs( hIvasRend ); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + + /* select default reverb size after adding an input */ + IF( EQ_32( hIvasRend->selectedRoomReverbSize, DEFAULT_REVERB_UNSET ) ) + { + IVAS_REND_SetReverbRoomSize( hIvasRend, + getDefaultReverbSize( hIvasRend->inputsIsm, + hIvasRend->inputsMasa, + hIvasRend->inputsMc, + hIvasRend->inputsSba ) ); + } +#endif return IVAS_ERR_OK; } @@ -5788,6 +5905,92 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( * *---------------------------------------------------------------------*/ +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + +/*---------------------------------------------------------------------* + * IVAS_REND_GetReverbRoomSize() + * + * + *---------------------------------------------------------------------*/ +ivas_error IVAS_REND_GetReverbRoomSize( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_ROOM_SIZE_T *reverbRoomSize /* o : Reverb room size */ +) +{ + SWITCH( hIvasRend->selectedRoomReverbSize ) + { + case DEFAULT_REVERB_SMALL: + *reverbRoomSize = IVAS_ROOM_SIZE_SMALL; + move32(); + BREAK; + case DEFAULT_REVERB_MEDIUM: + *reverbRoomSize = IVAS_ROOM_SIZE_MEDIUM; + move32(); + BREAK; + case DEFAULT_REVERB_LARGE: + *reverbRoomSize = IVAS_ROOM_SIZE_LARGE; + move32(); + BREAK; + case DEFAULT_REVERB_UNSET: + default: + *reverbRoomSize = IVAS_ROOM_SIZE_AUTO; + move32(); + BREAK; + } + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_REND_SetReverbRoomSize() + * + * + *---------------------------------------------------------------------*/ +ivas_error IVAS_REND_SetReverbRoomSize( + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_ROOM_SIZE_T reverbRoomSize /* i : Reverb room size */ +) +{ + ivas_error error; + + SWITCH( reverbRoomSize ) + { + case IVAS_ROOM_SIZE_SMALL: + hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_SMALL; + move32(); + BREAK; + case IVAS_ROOM_SIZE_MEDIUM: + hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_MEDIUM; + move32(); + BREAK; + case IVAS_ROOM_SIZE_LARGE: + hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_LARGE; + move32(); + BREAK; + case IVAS_ROOM_SIZE_AUTO: + default: + hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_UNSET; + move32(); + BREAK; /* will be setup in IVAS_REND_AddInput() */ + } + + IF( hIvasRend->hRendererConfig != NULL ) + { + IF( EQ_32( error = ivas_render_config_change_defaults( hIvasRend->hRendererConfig, hIvasRend->selectedRoomReverbSize ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + return IVAS_ERR_OK; +} +#endif + + /*-------------------------------------------------------------------* * Local functions -- GitLab From b284947c986e0f1efe624f1537a7d874ec2b7670 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 10 Nov 2025 15:00:13 +0100 Subject: [PATCH 251/351] Resolve overflow by swapping the order of addition and multiplication --- lib_com/cnst.h | 13 +++++++----- lib_com/options.h | 2 +- lib_enc/bw_detect_fx.c | 48 ++++++++++++++++++++++++++++++------------ 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index cf1a7820f..97dd19f18 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -2787,12 +2787,15 @@ enum #define Fs_2_16k 20480 /* lsf max value (Use in reorder_fx.c) */ #define LG10 24660 /* 10*log10(2) in Q13 */ -#define TEN_MULT_LOG10_2_IN_Q29 1616142464 /* (10 * log10(2)) = 3.0103 (in Q29) */ +#define TEN_MULT_LOG10_2_IN_Q29 1616142464 /* (10 * log10(2)) = 3.0103 (in Q29) */ #define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */ -#define LOG2_10 27213 /* log base 2 of 10 in Q12 */ -#define LOG2_10_Q29 1783446566 /* log base 2 of 10 in Q12 */ -#define LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ -#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ +#define LOG2_10 27213 /* log base 2 of 10 in Q12 */ +#define LOG2_10_Q29 1783446566 /* log base 2 of 10 in Q12 */ +#define LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA +#define INV_LOG2_10 9864 /* 1/log2(10), Q15*/ +#endif +#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ #define E_MIN_FXQ15 115 /* Q15*/ #define E_MIN_FXQ31 7516193 /* 0.0035d in Q31*/ diff --git a/lib_com/options.h b/lib_com/options.h index 10ea208a2..6597217be 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,7 +103,7 @@ #define FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING /* Orange: Fix for issue 2184 - to prevent one channel from becoming inaudible in the mono downmix output */ #define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue */ #define FIX_2200_ISAR_PLC_CRASH /* Dolby: Fix for ISAR PLC crash observed with newly added BASOP tests */ - +#define FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA /* FhG: Resolve overflow by swapping the order of addition and multiplication */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 49391f60f..2cbfb0bd8 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -55,7 +55,7 @@ void bw_detect_fx( Word16 spect[L_FRAME48k], spect_bin[BWD_N_BINS_MAX]; Word32 spect32[L_FRAME48k], in_win32[BWD_TOTAL_WIDTH]; Word16 e_tmp, f_tmp; - Word32 L_tmp, sum32; + Word32 L_tmp, sum32, L_tmp_q_shift; Word32 L_tmp1, L_tmp2, L_tmp3; Word16 scale; @@ -131,12 +131,17 @@ void bw_detect_fx( } #endif L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING - L_tmp = L_add_sat( L_tmp, L_shl_sat( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + L_tmp_q_shift = L_shl_sat( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ); // This term should be added to L_temp to align it to Q25 + L_tmp_q_shift = Mpy_32_16_1( L_tmp_q_shift, INV_LOG2_10 ); // instead of adding it to L_tmp and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + cldfb_bin[0] = L_add( L_tmp, L_tmp_q_shift ); /* Q25 */ #else - L_tmp = L_add_sat( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif + L_tmp = L_add_sat( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ cldfb_bin[0] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); +#endif move32(); /* 1/log2(10) */ /* Q25 */ /* WB: 4.4 - 7.2 kHz, 8 cldfb-bands, mid band(14) counted twice */ @@ -165,12 +170,17 @@ void bw_detect_fx( move32(); } L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING - L_tmp = L_add( L_tmp, L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + L_tmp_q_shift = L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ); // This term should be added to L_temp to align it to Q25 + L_tmp_q_shift = Mpy_32_16_1( L_tmp_q_shift, INV_LOG2_10 ); // instead of adding it to L_tmp and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + cldfb_bin[i] = L_add( L_tmp, L_tmp_q_shift ); /* Q25 */ #else L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif cldfb_bin[i] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); +#endif move32(); /* 1/log2(10) */ /* Q25 */ } } @@ -208,12 +218,17 @@ void bw_detect_fx( move32(); } L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING - L_tmp = L_add( L_tmp, L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + L_tmp_q_shift = L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ); // This term should be added to L_temp to align it to Q25 + L_tmp_q_shift = Mpy_32_16_1( L_tmp_q_shift, INV_LOG2_10 ); // instead of adding it to L_tmp and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + cldfb_bin[i] = L_add( L_tmp, L_tmp_q_shift ); /* Q25 */ #else L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif cldfb_bin[i] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); +#endif move32(); /* 1/log2(10) */ /* Q25 */ } } @@ -245,12 +260,17 @@ void bw_detect_fx( move32(); } L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING - L_tmp = L_add( L_tmp, L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + L_tmp_q_shift = L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ); // This term should be added to L_temp to align it to Q25 + L_tmp_q_shift = Mpy_32_16_1( L_tmp_q_shift, INV_LOG2_10 ); // instead of adding it to L_tmp and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + cldfb_bin[i] = L_add( L_tmp, L_tmp_q_shift ); /* Q25 */ #else L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif cldfb_bin[i] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); +#endif move32(); /* 1/log2(10) */ /* Q25 */ } } -- GitLab From 01122a00d46c8a1f8ff1bf0c50fc1f9d521f12ad Mon Sep 17 00:00:00 2001 From: Sumeyra Kanik Date: Mon, 10 Nov 2025 15:16:11 +0100 Subject: [PATCH 252/351] Keep radius_fx as Word16 instead of Word32 --- apps/decoder.c | 13 +++++++++---- lib_com/common_api_types.h | 10 +++------- lib_util/obj_edit_file_reader.h | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index c24028565..62f7566d3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3560,13 +3560,18 @@ static void do_object_editing_fx( { if ( readInfo->obj_radius_relative[obj_idx] ) { - /* radius: apply relative edit + saturation */ - Word32 temp_result = L_shl_sat( Mpy_32_32( editableParameters->ism_metadata[obj_idx].radius_fx, (Word32) ( readInfo->obj_radius[obj_idx] * (Word32) 536870912L ) ), 2 ); - editableParameters->ism_metadata[obj_idx].radius_fx = L_max( L_min( temp_result, OBJ_EDIT_RADIUS_MAX_FX ), 0 ); /* Q29*Q29 -> Q27 shift back to Q29 */ + /* radius: apply relative edit + saturation */ + Word32 temp_radius = L_max( L_min( ( L_shl_sat( Mpy_32_32( (Word32) editableParameters->ism_metadata[obj_idx].radius_fx, (Word32) ( readInfo->obj_radius[obj_idx] * 512 ) ), 2 ) ), OBJ_EDIT_RADIUS_MAX_FX ), 0 ); /* Q9*Q9 -> Q7 shift back to Q9 */ + // Saturate to 16-bit range + if ( temp_radius > 32767 ) + temp_radius = 32767; + if ( temp_radius < -32768 ) + temp_radius = -32768; + editableParameters->ism_metadata[obj_idx].radius_fx = (Word16) temp_radius; } else { - editableParameters->ism_metadata[obj_idx].radius_fx = (Word32) ( readInfo->obj_radius[obj_idx] * 536870912 ); /* Q29 */ + editableParameters->ism_metadata[obj_idx].radius_fx = (Word16) ( readInfo->obj_radius[obj_idx] * 512 ); /* Q9 */ } } #endif diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index c8238e56f..6259b5f8d 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -125,13 +125,9 @@ typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG typedef struct _IVAS_ISM_METADATA { - Word32 azimuth_fx; /* Q22 */ - Word32 elevation_fx; /* Q22 */ -#ifdef FIX_2192_OBJ_EDITING_EXT_METADATA - Word32 radius_fx; /* Q29 */ -#else - Word16 radius_fx; /* Q9 */ -#endif + Word32 azimuth_fx; /* Q22 */ + Word32 elevation_fx; /* Q22 */ + Word16 radius_fx; /* Q9 */ Word32 spread_fx; /* Q22 */ Word32 gainFactor_fx; /* Q29 */ Word32 yaw_fx; /* Q22 */ diff --git a/lib_util/obj_edit_file_reader.h b/lib_util/obj_edit_file_reader.h index 4f6e7ee20..04ca7f1e5 100644 --- a/lib_util/obj_edit_file_reader.h +++ b/lib_util/obj_edit_file_reader.h @@ -55,7 +55,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. #ifdef FIX_2192_OBJ_EDITING_EXT_METADATA #define OBJ_EDIT_RADIUS_MAX 15.75f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ -#define OBJ_EDIT_RADIUS_MAX_FX 8455716864LL /* Q29, 15.75f */ +#define OBJ_EDIT_RADIUS_MAX_FX 8064 /* Q9, 15.75f (15.75 × 512 = 8064) */ #define OBJ_EDIT_RADIUS_MIN_FX 0 #endif -- GitLab From 61fab6e9c7fda6a8b263def7fdc43856a791215e Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 10 Nov 2025 15:17:57 +0100 Subject: [PATCH 253/351] Add MR switch. --- lib_enc/bw_detect_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 2cbfb0bd8..08ad07149 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -55,7 +55,11 @@ void bw_detect_fx( Word16 spect[L_FRAME48k], spect_bin[BWD_N_BINS_MAX]; Word32 spect32[L_FRAME48k], in_win32[BWD_TOTAL_WIDTH]; Word16 e_tmp, f_tmp; +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA Word32 L_tmp, sum32, L_tmp_q_shift; +#else + Word32 L_tmp, sum32; +#endif Word32 L_tmp1, L_tmp2, L_tmp3; Word16 scale; -- GitLab From 17586d3bca690eedad02354cc2040ff8cf264575 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 16:21:28 +0200 Subject: [PATCH 254/351] Clang format --- lib_dec/lib_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 13dd59cdc..3ce7d68fc 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6578,10 +6578,10 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi IVAS_QUATERNION *quat = &piData->data.scene.orientation; #ifdef DEBUGGING fprintf( stdout, "PI_SCENE_ORIENTATION : %f, %f, %f, %f\n", - fixedToFloat( quat->w_fx, Q15 ), - fixedToFloat( quat->x_fx, Q15 ), - fixedToFloat( quat->y_fx, Q15 ), - fixedToFloat( quat->z_fx, Q15 ) ); + fixedToFloat( quat->w_fx, Q15 ), + fixedToFloat( quat->x_fx, Q15 ), + fixedToFloat( quat->y_fx, Q15 ), + fixedToFloat( quat->z_fx, Q15 ) ); #endif error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); } -- GitLab From 81758bc3a5b277c6325e0423530e969e7f2aef20 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 10 Nov 2025 15:22:07 +0100 Subject: [PATCH 255/351] Clang check --- lib_dec/lib_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 13dd59cdc..3ce7d68fc 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6578,10 +6578,10 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi IVAS_QUATERNION *quat = &piData->data.scene.orientation; #ifdef DEBUGGING fprintf( stdout, "PI_SCENE_ORIENTATION : %f, %f, %f, %f\n", - fixedToFloat( quat->w_fx, Q15 ), - fixedToFloat( quat->x_fx, Q15 ), - fixedToFloat( quat->y_fx, Q15 ), - fixedToFloat( quat->z_fx, Q15 ) ); + fixedToFloat( quat->w_fx, Q15 ), + fixedToFloat( quat->x_fx, Q15 ), + fixedToFloat( quat->y_fx, Q15 ), + fixedToFloat( quat->z_fx, Q15 ) ); #endif error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); } -- GitLab From ea1129e20153ed9b1ae41df831fb34533ee45b0e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Nov 2025 15:39:57 +0100 Subject: [PATCH 256/351] fix --- lib_dec/lib_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 513fd8cd7..38c9c2fd1 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6249,7 +6249,7 @@ static ivas_error ivas_dec_reconfig_split_rend( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); } - num_ch = MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS; + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; move16(); FOR( ch = 0; ch < num_ch; ch++ ) { @@ -6278,7 +6278,7 @@ static ivas_error ivas_dec_reconfig_split_rend( } ELSE IF( EQ_16( isCldfbNeeded, 0 ) && hSplitRendWrapper->hCldfbHandles != NULL ) { - num_ch = MAX_HEAD_ROT_POSES, BINAURAL_CHANNELS; + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; move16(); FOR( ch = 0; ch < num_ch; ch++ ) { -- GitLab From 76e73aa5a6c364f6a5273e48ce42e7064b6faa21 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 10 Nov 2025 17:10:22 +0200 Subject: [PATCH 257/351] Clang format --- lib_rend/lib_rend_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 5a7c82ea7..5f2364c97 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5991,7 +5991,6 @@ ivas_error IVAS_REND_SetReverbRoomSize( #endif - /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ -- GitLab From 11fcdded769ba44832637942264747f93e0b6e30 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 10 Nov 2025 10:11:42 -0500 Subject: [PATCH 258/351] removing many PMT and PMTE introduced at the at the begining of fx point dev. --- lib_com/bits_alloc_fx.c | 4 ---- lib_com/fd_cng_com_fx.c | 4 ---- lib_com/hq_tools_fx.c | 12 ------------ lib_com/tcx_mdct_window_fx.c | 2 -- lib_com/tools_fx.c | 2 +- lib_com/wi_fx.c | 4 ---- lib_dec/FEC_HQ_phase_ecu_fx.c | 5 ----- lib_dec/TonalComponentDetection_fx.c | 1 - lib_dec/amr_wb_dec_fx.c | 5 +---- lib_dec/dec_higher_acelp_fx.c | 1 - lib_dec/fd_cng_dec_fx.c | 7 ------- lib_dec/gain_dec_fx.c | 6 ------ lib_dec/gs_dec_fx.c | 1 - lib_dec/lsf_dec_fx.c | 1 - lib_dec/peak_vq_dec_fx.c | 1 - lib_enc/acelp_core_switch_enc_fx.c | 1 - lib_enc/bw_detect_fx.c | 1 - lib_enc/cng_enc_fx.c | 2 -- lib_enc/core_enc_init_fx.c | 1 - lib_enc/dtx_fx.c | 2 -- lib_enc/enc_uv_fx.c | 1 - lib_enc/evs_enc_fx.c | 1 - lib_enc/ext_sig_ana_fx.c | 1 - lib_enc/fd_cng_enc_fx.c | 2 -- lib_enc/find_tar_fx.c | 1 - lib_enc/nois_est_fx.c | 1 - lib_enc/rst_enc_fx.c | 1 - lib_enc/sig_clas_fx.c | 4 +--- lib_enc/vad_fx.c | 12 ++---------- 29 files changed, 5 insertions(+), 82 deletions(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 9909f413d..5aea2c790 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -420,7 +420,6 @@ static Word16 fcb_table( const Word16 L_subfr ) { Word16 out; - // PMT("Not floating point computation, but fixed point operator are still missing ") out = PulseConfTable[n].bits; move16(); @@ -454,7 +453,6 @@ static ivas_error acelp_FCB_allocator_fx( Word16 *p_fixed_cdk_index; Word16 max_n; ivas_error error; - // PMT("Not floating point computation, but fixed point operator are still missing ") error = IVAS_ERR_OK; move32(); @@ -1693,7 +1691,6 @@ static Word16 allocate_unused( Word16 max_bit_per_pos = 0, bit_added = 0; move16(); move16(); - // PMT("Not floating point computation, but fixed point operator are still missing ") IF( prm_type == GAINSPRM ) { @@ -1797,7 +1794,6 @@ Word16 set_ACELP_flag( const Word16 cng_type /* i : CNG type */ ) { - // PMT("Not floating point computation, but fixed point operator are still missing ") test(); test(); test(); diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index c8f0c31ac..363113f21 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -1811,7 +1811,6 @@ void apply_scale( ) { Word16 i; - // PMT("Verifiy if the basop ued are ok for stereo too") FOR( i = 0; i < scaleTableSize; i++ ) { cast16(); @@ -1844,7 +1843,6 @@ Word16 apply_scale_ind( ) { Word16 i; - // PMT("Verifiy if the basop ued are ok for stereo too") FOR( i = 0; i < scaleTableSize; i++ ) { cast16(); @@ -1872,7 +1870,6 @@ void apply_scale_ivas_fx( Word16 *index ) { Word16 i; - // PMT("Verifiy if the basop ued are ok for stereo too") FOR( i = 0; i < scaleTableSize; i++ ) { cast16(); @@ -3137,7 +3134,6 @@ void msvq_decoder( { Word16 s, i, offset; - // PMT("msvq_decoder Not verified") offset = i_mult( Idx[0], maxN ); FOR( i = 0; i < N; i++ ) diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index 0e00b9428..df36099a4 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -926,12 +926,6 @@ void ivas_harm_bwe_fx( { exp1 = add( 1, exp1 ); } -#ifdef DEBUGGING - else - { - // PMT("VERIFY if this really matches IVAS float") - } -#endif tmp1 = s_max( tmp1, 16384 ); tmp1 = div_s( 16384, tmp1 ); L_tmp2 = L_deposit_h( tmp1 ); @@ -1095,12 +1089,6 @@ void harm_bwe_fx( { exp1 = add( 1, exp1 ); } -#ifdef DEBUGGING - else - { - // PMT("VERIFY if this really matches IVAS float") - } -#endif tmp1 = s_max( tmp1, 16384 ); tmp1 = div_s( 16384, tmp1 ); /*Q15*/ L_tmp2 = L_deposit_h( tmp1 ); /*Q31*/ diff --git a/lib_com/tcx_mdct_window_fx.c b/lib_com/tcx_mdct_window_fx.c index 285bbbf0a..576f5bef6 100644 --- a/lib_com/tcx_mdct_window_fx.c +++ b/lib_com/tcx_mdct_window_fx.c @@ -66,7 +66,6 @@ void mdct_window_sine_IVAS_updated( window[i].v.im = table[i].v.im; /* Qx */ move16(); } - // PMT("getSineWindowTable needs to be updated for IVAS") } ELSE { @@ -133,7 +132,6 @@ void mdct_window_sine( window[i].v.im = table[i].v.im; /* Qx */ move16(); } - // PMT("getSineWindowTable needs to be updated for IVAS") } } diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 1be575c24..4b902a32b 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -1890,7 +1890,7 @@ Word16 mean_fx( ) { Word16 tmp; - // PMT("TBV : this function could be written differently to minimize the risk of saturation"); + /* this function could be written differently to minimize the risk of saturation */ tmp = sum16_fx( vec_fx, lvec_fx ); tmp = mult_r( tmp, div_s( 1, lvec_fx ) ); diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c index 58f1a813d..171e04269 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -45,7 +45,6 @@ ivas_error DTFS_new_fx( DTFS_STRUCTURE *dtfs_fx = NULL; dtfs_fx = (DTFS_STRUCTURE *) calloc( 1, sizeof( DTFS_STRUCTURE ) ); - // PMT("verif mem alloc") IF( dtfs_fx == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTFS (SC-VBR) structure\n" ) ); @@ -3088,9 +3087,6 @@ ivas_error WIsyn_fx( /* Adjust the phase offset and wrap it between 0 and 2pi */ - // PMT("NEED a complete verification of mem flow and assignment") - - IF( EQ_16( flag, 2 ) ) { L_temp = L_shr( L_mult( tmp_fx, I ), 1 ); /* Q15 */ diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 4ad39acf0..f79e9e4b1 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -750,7 +750,6 @@ static void ivas_peakfinder_fx( } ELSE { - // PMTE () ii = -1; /* First point is a peak */ move16(); IF( GE_16( len, 2 ) ) @@ -1359,7 +1358,6 @@ static void ivas_spec_ana_fx( } ELSE { - // PMTE() window_corr = w_hamm[0]; move16(); window_corr_step = idiv1616( w_hamm[0], hamm_len2 ); @@ -1384,7 +1382,6 @@ static void ivas_spec_ana_fx( } ELSE { - // PMTE() window_corr = w_hamm[0]; move16(); window_corr_step = idiv1616( w_hamm[0], hamm_len2 ); @@ -2770,7 +2767,6 @@ static void rec_wtda_fx( Word16 g; Word16 tbl_delta; - // PMTE() xsubst_ = rec_buf + output_frame; Lprot2 = shr( Lprot, 1 ); @@ -4069,7 +4065,6 @@ static void ivas_fec_noise_filling_fx( const Word16 *p_mdct_ola; Word16 alignment_point; - // PMTE() L20 = extract_h( L_mult( 1639, L ) ); /*L/20 */ IF( element_mode == EVS_MONO ) { diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index bfb0b0428..093752bb7 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -85,7 +85,6 @@ void ivas_DetectTonalComponents_fx( { nBands = FDNS_NPTS; move16(); - // PMT("add nBands argument to mdct_shaping_16") mdct_shaping_16( lastMDCTSpectrum, nSamplesCore, nSamples, scaleFactors, scaleFactors_exp, scaleFactors_max_e, pScaledMdctSpectrum ); lastMDCTSpect_exp = add( lastMDCTSpectrum_exp, scaleFactors_max_e ); diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 82619a87d..92dc85b66 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -339,9 +339,7 @@ ivas_error amr_wb_dec_fx( st_fx->bfi_pitch_frame = L_FRAME; move16(); } -#ifdef _DIFF_FLOAT_FIX_ - PMT( "the code below has been removed in IVAS float (or moved somewhere else), is it ok?" ) -#endif + IF( NE_16( st_fx->last_core, AMR_WB_CORE ) ) { /* reset the unvoiced/audio signal improvement memories */ @@ -350,7 +348,6 @@ ivas_error amr_wb_dec_fx( Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + i_mult( 2, M + 1 ), M + 1 ); /*Q12*/ Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + i_mult( 3, M + 1 ), M + 1 ); /*Q12*/ } - /*End of _DIFF_FLOAT_FIX_*/ test(); if ( EQ_16( st_fx->last_bwidth, NB ) && st_fx->ini_frame != 0 ) { diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 5687f3b79..c6cb34ddc 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -184,7 +184,6 @@ void transf_cdbk_dec_fx( test(); IF( st_fx->element_mode > EVS_MONO && ( st_fx->coder_type != INACTIVE ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && !harm_flag_acelp && code_preQ[0] != 0 ) { - // PMT("Fixed point taking accound of the scaling needs to be done here ") IF( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 4 ) ) ) { st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 4 ); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index b1e051b61..dfbc8996f 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2510,7 +2510,6 @@ void generate_comfort_noise_dec_fx( /* Warning fix */ s = 0; move16(); - // PMTE(); /*IVAS CODE need to be added */ /* pointer initialization */ @@ -3839,8 +3838,6 @@ void generate_masking_noise_fx( Word32 *fftBuffer; Word16 *seed; - // PMTE(); /*IVAS CODE need to be added */ - /* pointer initializations */ cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*Q31 - hFdCngCom->cngNoiseLevelExp*/ fftBuffer = hFdCngCom->fftBuffer; /*Q31 - hFdCngCom->fftBuffer_exp*/ @@ -3977,8 +3974,6 @@ void generate_masking_noise_fx( assert( hFdCngCom->olapBufferSynth2 != NULL ); SynthesisSTFT( hFdCngCom->fftBuffer, fftBufferExp, maskingNoise, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn, 0, hFdCngCom, 0, NULL, -1 /*st->element_mode*/, -1 /*nchan_out*/ ); - // PMT("parameters need update") - /* add some comfort noise on top of decoded signal */ IF( hFdCngCom->frameSize > length ) @@ -4054,7 +4049,6 @@ void generate_masking_noise_mdct_fx( Word32 *cngNoiseLevel; Word16 *seed; - // PMTE(); /*IVAS CODE need to be added */ /* pointer initializations */ cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*Q31 - hFdCngCom->cngNoiseLevelExp*/ seed = &( hFdCngCom->seed ); @@ -4215,7 +4209,6 @@ void generate_masking_noise_mdct_ivas_fx( Word32 *cngNoiseLevel; Word16 *seed; - // PMTE(); /*IVAS CODE need to be added */ /* pointer initializations */ cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*Q31 - hFdCngCom->cngNoiseLevelExp*/ seed = &( hFdCngCom->seed ); diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index e001521bf..f7dfbbdd7 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -35,9 +35,6 @@ void Es_pred_dec_fx( const Word16 no_ltp /* i : no LTP flag */ ) { -#ifdef IVAS_GAIN_MOD - PMT( "Verify if Es_pred_dec_fx should use noltp parameters" ) -#endif IF( no_ltp == 0 ) { SWITCH( nb_bits ) @@ -471,7 +468,6 @@ void gain_dec_mless_fx( qua_table_fx = gain_qua_mless_6b_fx; /*Q14*/ if ( st_fx->element_mode > EVS_MONO ) { - // PMT("gain_qua_mless_6b_stereo to fixed point") qua_table_fx = gain_qua_mless_6b_stereo_fx; /*Q14*/ } BREAK; @@ -819,7 +815,6 @@ void gain_dec_lbr_fx( if ( EQ_16( nBits, 7 ) ) { cdbk_fx = gp_gamma_3sfr_7b_fx; /*Q14*/ - // PMT("verify if gp_gamma_3sfr_7b_fx is correct") } /* calculate predicted gain */ @@ -892,7 +887,6 @@ void gain_dec_lbr_fx( IF( EQ_16( nBits, 7 ) ) { cdbk_fx = gp_gamma_4sfr_7b_fx; /*Q14*/ - // PMT( "verify if gp_gamma_4sfr_7b_fx is correct" ) } /* calculate predicted gain */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index d174cd87b..61fb000e4 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -395,7 +395,6 @@ void decod_audio_fx( move16(); } } - // PMT("in the rare case of 4 subfr, bfi_pitch_fx might be wrong") st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); /* Q6 */ move16(); st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */ diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index ec45dbae9..c032a7454 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -290,7 +290,6 @@ void lsf_dec_fx( test(); IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) ) { - // PMT("To be verified") IF( EQ_16( st_fx->active_cnt, 1 ) ) { Copy( lsp_mid, st_fx->lsp_old_fx, M ); /* Q15 */ diff --git a/lib_dec/peak_vq_dec_fx.c b/lib_dec/peak_vq_dec_fx.c index 87d7e9cf3..4eee76ec9 100644 --- a/lib_dec/peak_vq_dec_fx.c +++ b/lib_dec/peak_vq_dec_fx.c @@ -112,7 +112,6 @@ static void peak_vq_dec_fx( set16_fx( pvq_inp_vector, 0, HVQ_PVQ_BUF_LEN ); assert( ( core_brate > HQ_16k40 && core_brate <= HQ_48k ) && "HVQ rate not supported" ); - // PMT("max_peaks equation needs to be converted") max_peaks = extract_l( Mpy_32_32( ( L_add( imult3216( core_brate, HVQ_PEAKS_PER_DELTA ), HVQ_PEAKS_PER_DELTA_OFFS ) ), 282564 ) ); /* 1 / HVQ_PEAKS_BPS_DELTA in Q31 = 282564*/ bin_th = HVQ_THRES_BIN_24k; move16(); diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index d790b1866..8ef05782b 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -97,7 +97,6 @@ void acelp_core_switch_enc_fx( } } #ifdef FIX_I4_OL_PITCH - PMTE() IF( EQ_16( st_fx->last_codec_mode, MODE1 ) ) { /* in MODE1 T_op is at 12.8 kHz */ diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 49391f60f..efa181ad0 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -983,7 +983,6 @@ void set_bw_fx( test(); IF( GT_16( element_mode, IVAS_SCE ) ) { - // PMT("this IVAS_SCE section has not been verified ") IF( LT_32( element_brate, MIN_BRATE_SWB_STEREO ) ) { st->bwidth = WB; diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 34be60d8a..fb8490127 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2540,7 +2540,6 @@ static Word16 shb_DTX_fx( { att = 0; move16(); - // PMT("apply_scale is not implemented") } ELSE { @@ -2835,7 +2834,6 @@ static void shb_CNG_encod_ivas_fx( ELSE { /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ - // PMT("shb_CNG_encod_fx quantization in missing") /* 6.0 in Q8 -> 1510 */ /* 0.7 in Q15 22938 */ /* ( 1 / log10(2.0) ) * 0.1 in Q15 -> 10886 */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 2f669f09b..044821fee 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -288,7 +288,6 @@ static void init_tcx_fx( (void) MCT_flag; (void) total_brate; (void) last_total_brate; - // PMT("init_tcx_fx needs an entire review to adapt to IVAS") fscaleFB = div_l( L_shl( st->input_Fs, LD_FSCALE_DENOM + 1 ), 12800 ); init_TCX_config( st->hTcxCfg, st->L_frame, st->fscale, hTcxEnc->L_frameTCX, fscaleFB ); diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index fa9da7f42..265288f02 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -272,7 +272,6 @@ void dtx_ivas_fx( st_fx->core_brate = SID_2k40; move32(); } - // PMT("dtx_sce_sba code is missing") test(); test(); IF( ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) ) @@ -377,7 +376,6 @@ void dtx_ivas_fx( IF( EQ_16( st_fx->element_mode, IVAS_SCE ) ) { Word32 lp_thresh, fd_thresh; - // PMT( "lp_thresh scaling is to be found" ) test(); IF( st_fx->Opt_DTX_ON && EQ_16( st_fx->dtx_sce_sba, 1 ) ) { diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 1a531b8be..0bb329f63 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -356,7 +356,6 @@ void encod_unvoiced_ivas_fx( * Unvoiced subframe processing in two stages *----------------------------------------------------------------*/ - // PMT("The code below needs validation, never been tested") /* No adaptive codebook (UC) */ set16_fx( y1, 0, L_SUBFR ); set16_fx( exc_fx + i_subfr, 0, L_SUBFR ); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 3380583c0..08c0a88a4 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -619,7 +619,6 @@ static void initFrameHeader_loc( Encoder_State *st ) } ELSE { - // PMT("Frame header needs review") FOR( n = 0; n < FRAME_SIZE_NB; n++ ) { IF( EQ_16( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) ) diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 20d18c779..30961c591 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -110,7 +110,6 @@ void core_signal_analysis_high_bitrate_fx( } IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { - // PMT("tcx_ltp_encode_fx should be verified for IVAS") tcx_ltp_encode_fx( hTcxEnc->tcxltp, (Word8) st->tcxonly, hTcxEnc->tcxMode, L_frame, L_SUBFR, st->speech_enc + st->encoderLookahead_enc, hTcxEnc->speech_ltp + st->encoderLookahead_enc, st->speech_enc + st->encoderLookahead_enc, diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 5bfb9f9ac..4f2beb880 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -1205,7 +1205,6 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru maxVal = L_add( maxVal, gain ); maxVal = L_shl( Mpy_32_16_1( maxVal, 21771 /*0.66438561897 Q15*/ ), 1 ); - // PMT("st must be replaced by hFdCngCom") sidNoiseEst_Exp = 0; move16(); WHILE( maxVal >= 0 ) @@ -2213,7 +2212,6 @@ Word16 cng_energy_ivas_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) || EQ_16( element_mode, IVAS_CPE_TD ) ) { - // PMT(" IVAS CNG ener computing is missing") enr = add( enr, mult( CNG_att, FAC_LOG2_BY10_Q16 ) ); /* Q8 (7+16-15) */ } ELSE IF( NE_16( bwidth, NB ) ) diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index ca3f50f11..2d0929e04 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -114,7 +114,6 @@ void find_targets_fx( } h1[M] = round_fx_o( L_shl_o( Ltmp, s, &Overflow ), &Overflow ); /* Q11 + s */ - // PMT("should we used extended basop here for when the L_subfr > L_SUBFR, to prevent saturation/overflow and the subsequent loop\n") FOR( i = M + 1; i < L_subfr; i++ ) { Ltmp = L_msu( 0, Aqs[1], h1[i - 1] ); /* Q27 */ diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 181b1f10e..d44495278 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1011,7 +1011,6 @@ void noise_est_fx( { hSpMusClas->ener_RAT_fx = 0; move16(); - // PMT("hSpMusClas->ener_RAT_fx = 0, that should be validated") } ELSE { diff --git a/lib_enc/rst_enc_fx.c b/lib_enc/rst_enc_fx.c index bbe32afb3..0bf82e6d3 100644 --- a/lib_enc/rst_enc_fx.c +++ b/lib_enc/rst_enc_fx.c @@ -42,7 +42,6 @@ void CNG_reset_enc_fx( set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); hLPDmem->dm_fx.prev_state = 0; - // PMTE() move16(); /* last good received frame for FEC in ACELP */ diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 78caad798..61fa63fe9 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -640,8 +640,7 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } - } //_DIFF_FLOAT_FIX_ see below - // PMT("Verify if EVS or IVAS is right about last_7k2_coder_type update") + } hSC_VBR->last_7k2_coder_type = st->coder_type; move16(); test(); @@ -650,7 +649,6 @@ void coder_type_modif_fx( hSC_VBR->last_7k2_coder_type = GENERIC; move16(); } - //} closing bracket here in IVAS float, but not in EVS float. currently affects BE for switching bitrate on Linux 20220929 _DIFF_FLOAT_FIX_ !! IF( st->element_mode == 0 ) { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index c4c6df6c3..a49dc4ba8 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -745,16 +745,8 @@ Word16 wb_vad_fx( st_fx->max_band = 19; move16(); } - /*_DIFF_FLOAT_FIX_ -> see around Ln1570, inversion in if conditions compared to float*/ - // PMT("Error in EVS fixed point ?") - /*FIXED EVS */ - /* ELSE IF(((LE_16(st_fx->last_coder_type, UNVOICED)) && (LT_32(L_snr_outlier, MAX_SNR_OUTLIER_2_FX)) && (st_fx->Opt_SC_VBR != 0)) || - ((LE_16(last_7k2_coder_type, UNVOICED)) && (LT_32(L_snr_outlier, MAX_SNR_OUTLIER_2_FX)) && (st_fx->Opt_SC_VBR == 0)))*/ - - /*FLOAT both IVAS and EVS */ - /*if ((snr_outlier_index <= 4 && (st->last_coder_type > UNVOICED) && !st->Opt_SC_VBR) || - (snr_outlier_index <= 4 && (last_7k2_coder_type > UNVOICED) && st->Opt_SC_VBR))*/ - IF( 1 ) // st_fx->Opt_SC_VBR) + + IF( st_fx->Opt_SC_VBR ) { last_7k2_coder_type = st_fx->hSC_VBR->last_7k2_coder_type; move16(); -- GitLab From 04623385907c6ac8443e8d1b8033f7a4a3cd8ca5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 10 Nov 2025 09:50:17 -0500 Subject: [PATCH 259/351] remove remaining PMT and many _DIFF_FLOAT_FIX_ --- lib_dec/amr_wb_dec_fx.c | 1 + lib_enc/ACcontextMapping_enc_fx.c | 1 - lib_enc/core_enc_2div_fx.c | 2 +- lib_enc/core_enc_updt_fx.c | 4 ---- lib_enc/gs_enc_fx.c | 4 ++-- lib_enc/peak_vq_enc_fx.c | 2 +- lib_enc/qlpc_stoch_fx.c | 9 +++------ lib_enc/swb_tbe_enc_fx.c | 9 +++------ lib_enc/updt_enc_fx.c | 2 +- lib_enc/vad_fx.c | 9 ++++----- 10 files changed, 16 insertions(+), 27 deletions(-) diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 92dc85b66..375565f62 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -348,6 +348,7 @@ ivas_error amr_wb_dec_fx( Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + i_mult( 2, M + 1 ), M + 1 ); /*Q12*/ Copy( st_fx->hAmrwb_IO->old_Aq_fx, st_fx->hAmrwb_IO->old_Aq_fx + i_mult( 3, M + 1 ), M + 1 ); /*Q12*/ } + test(); if ( EQ_16( st_fx->last_bwidth, NB ) && st_fx->ini_frame != 0 ) { diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 051b55981..34c9e9074 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -164,7 +164,6 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx( /* Get context */ ctx = &c[s_or( p1, p2 )]; /* Q0 */ - /* _DIFF_FLOAT_FIX_ float is using t as UWord16 */ t = add( *ctx, rateFlag ); /* Q0 */ if ( GT_16( idx, nt_half ) ) { diff --git a/lib_enc/core_enc_2div_fx.c b/lib_enc/core_enc_2div_fx.c index fa74ec6b5..42e5b6a93 100644 --- a/lib_enc/core_enc_2div_fx.c +++ b/lib_enc/core_enc_2div_fx.c @@ -275,7 +275,7 @@ void core_encode_twodiv_fx( hTcxEnc->fUseTns[0], st ); - /*_DIFF_FLOAT_FIX_ -> The line below is present in float */ + /*_DIFF_FLOAT_FIX_EVS_IVAS -> The line below is present in float */ // hTcxEnc->measuredBwRatio = 0x4000; /* Calculate target bits */ diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c index dcf57738a..e5694fc01 100644 --- a/lib_enc/core_enc_updt_fx.c +++ b/lib_enc/core_enc_updt_fx.c @@ -51,10 +51,6 @@ void core_encode_update_fx( Encoder_State *st ) } /* Update previous mode */ - // move16(); - // st->last_core = st->core; /* _DIFF_FLOAT_FIX_ not in float -> remove? */ - - test(); test(); test(); diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 76e92121b..b6d0e776b 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -384,7 +384,7 @@ void encod_audio_fx( * Updates *--------------------------------------------------------------------------------------*/ - hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; /*_DIFF_FLOAT_FIX_ The way it is written in the original fix point is that at this point mem_w0 falls back to its original value (before enc_pit_exc, seems not the case in float */ + hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; move16(); Copy( exc_wo_nf, exc, st_fx->L_frame ); @@ -761,7 +761,7 @@ void encod_audio_ivas_fx( * Updates *--------------------------------------------------------------------------------------*/ Copy_Scale_sig( &hGSCEnc->mem_w0_tmp_fx, &hLPDmem->mem_w0, 1, sub( hLPDmem->q_mem_syn, sub( Q_new, 1 ) ) ); - /*_DIFF_FLOAT_FIX_ The way it is written in the original fix point is that at this point mem_w0 falls back to its original value (before enc_pit_exc, seems not the case in float */ + move16(); Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_new */ diff --git a/lib_enc/peak_vq_enc_fx.c b/lib_enc/peak_vq_enc_fx.c index bd87efb23..20fc9c7b8 100644 --- a/lib_enc/peak_vq_enc_fx.c +++ b/lib_enc/peak_vq_enc_fx.c @@ -517,7 +517,7 @@ Word16 peak_vq_enc_fx( assert( ( core_brate > HQ_16k40 && core_brate <= HQ_48k ) && "HVQ rate not supported" ); - // PMT("max_peaks equation needs to be converted") + /* max_peaks equation needs to be converted */ max_peaks = (Word16) ( ( core_brate * HVQ_PEAKS_PER_DELTA + HVQ_PEAKS_PER_DELTA_OFFS ) / HVQ_PEAKS_BPS_DELTA ); diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 70a41378f..a934e0d7d 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -55,12 +55,9 @@ void lpc_quantization_fx( /****** High-rate LPC quantizer *******/ IF( st->lpcQuantization == 0 ) - { - if ( st->sr_core != 12800 ) - { - // PMT("from the comment in E_LPC_isp_isf_conversion, it seems built for 12.8kHz, current sampling rate is NOT 12800, is it ok?") - /*_DIFF_FLOAT_FIX_ E_LPC_lsp_lsf_conversion, does it work for 16kHz as well ?*/ - } + { + /* from the comment in E_LPC_isp_isf_conversion, it seems built for 12.8kHz only, if current sampling rate is NOT 12800, is it ok? , float takes into account Fs */ + /* _DIFF_FLOAT_FIX_EVS_IVAS */ E_LPC_lsp_lsf_conversion( lsp, lsf, M ); /* check resonance for pitch clipping algorithm */ diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index e89c881d2..c6c7135fc 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -589,13 +589,10 @@ void ResetSHBbuffer_Enc_fx( /* states for the filters used in generating SHB signal from SHB excitation*/ set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + hBWE_TD->fb_tbe_demph_fx = 0; + move16(); - // IF( EQ_16(st_fx->extl, FB_TBE)) _DIFF_FLOAT_FIX_ - { - set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->fb_tbe_demph_fx = 0; - move16(); - } /* states for the filters used in generating WB signal from WB excitation*/ set16_fx( hBWE_TD->decim_state1_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); set16_fx( hBWE_TD->decim_state2_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 9b6f80c3f..42cde6f82 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -266,7 +266,7 @@ void updt_IO_switch_enc_fx( hSC_VBR->nelp_mode = 0; move16(); } - st->hGSCEnc->seed_tcx = 15687; /* the re-init here was present only in float _DIFF_FLOAT_FIX_*/ + st->hGSCEnc->seed_tcx = 15687; move16(); } diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index a49dc4ba8..38def0372 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1319,7 +1319,7 @@ Word16 wb_vad_fx( test(); test(); test(); - test(); /*_DIFF_FLOAT_FIX_ -> the conditions around Opt_SC_VBR_fx are invertered compared to float + test(); /*_DIFF_FLOAT_FIX_EVS -> the conditions around Opt_SC_VBR_fx are invertered compared to float ### st_fx->Opt_SC_VBR!=0 vs !st_fx->Opt_SC_VBR #####*/ // test(); IF( LE_16( snr_outlier_index, 4 ) && ( ( GT_16( st_fx->last_coder_type, UNVOICED ) && ( st_fx->Opt_SC_VBR != 0 ) ) || @@ -1722,7 +1722,7 @@ Word16 wb_vad_fx( /* *flag_noisy_speech_snr is a Word8 parameter */ - *flag_noisy_speech_snr = 0; /*_DIFF_FLOAT_FIX_ -> this initialisation is not done here in float */ + *flag_noisy_speech_snr = 0; /*_DIFF_FLOAT_FIX_IVAS -> this initialisation is not done here in float */ move16(); IF( vad_bwidth_fx != NB ) { @@ -2585,8 +2585,7 @@ Word16 wb_vad_ivas_fx( test(); test(); test(); - test(); /*_DIFF_FLOAT_FIX_ -> the conditions around Opt_SC_VBR_fx are invertered compared to float - ### st_fx->Opt_SC_VBR!=0 vs !st_fx->Opt_SC_VBR #####*/ + test(); test(); IF( ( LE_16( snr_outlier_index, 4 ) && ( st_fx->last_coder_type > UNVOICED ) && !st_fx->Opt_SC_VBR ) || ( LE_16( snr_outlier_index, 4 ) && ( last_7k2_coder_type > UNVOICED ) && st_fx->Opt_SC_VBR ) ) @@ -2998,7 +2997,7 @@ Word16 wb_vad_ivas_fx( /* *flag_noisy_speech_snr is a Word8 parameter */ - *flag_noisy_speech_snr = 0; /*_DIFF_FLOAT_FIX_ -> this initialisation is not done here in float */ + *flag_noisy_speech_snr = 0; /*_DIFF_FLOAT_FIX_IVAS -> this initialisation is not done here in float */ move16(); IF( vad_bwidth_fx != NB ) { -- GitLab From 6bae3349986427520ce1f550152d0d3b4d6ebbbd Mon Sep 17 00:00:00 2001 From: Sumeyra Kanik Date: Mon, 10 Nov 2025 16:40:06 +0100 Subject: [PATCH 260/351] Edit format --- lib_util/obj_edit_file_reader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_util/obj_edit_file_reader.h b/lib_util/obj_edit_file_reader.h index 04ca7f1e5..084b9a67a 100644 --- a/lib_util/obj_edit_file_reader.h +++ b/lib_util/obj_edit_file_reader.h @@ -54,8 +54,8 @@ the United Nations Convention on Contracts on the International Sales of Goods. #endif #ifdef FIX_2192_OBJ_EDITING_EXT_METADATA -#define OBJ_EDIT_RADIUS_MAX 15.75f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ -#define OBJ_EDIT_RADIUS_MAX_FX 8064 /* Q9, 15.75f (15.75 × 512 = 8064) */ +#define OBJ_EDIT_RADIUS_MAX 15.75f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ +#define OBJ_EDIT_RADIUS_MAX_FX 8064 /* Q9, 15.75f (15.75 × 512 = 8064) */ #define OBJ_EDIT_RADIUS_MIN_FX 0 #endif -- GitLab From 7afa25475677b29ac2a8ee0d2a126df7b39524ef Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 10 Nov 2025 17:42:40 +0200 Subject: [PATCH 261/351] Remove BOM from lib_dec_fx --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 5c23bace1..e5754c1c5 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1,4 +1,4 @@ -/****************************************************************************************************** +/****************************************************************************************************** (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., -- GitLab From b552db40b3caf18dd15bc1b5de020e1017aa0b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Toftg=C3=A5rd?= Date: Mon, 10 Nov 2025 17:09:31 +0100 Subject: [PATCH 262/351] Add porting of ISM_PI_DATA from float main, float MR !2329. Includes already updated range for ISM_GAIN PI data, float MR !2386. --- lib_com/options.h | 1 + lib_util/ivas_rtp_file.c | 116 ++++++- lib_util/ivas_rtp_pi_data.c | 614 +++++++++++++++++++++++++++++++++--- lib_util/ivas_rtp_pi_data.h | 18 ++ 4 files changed, 706 insertions(+), 43 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c6a4efa4b..249dbfe85 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ +#define ISM_PI_DATA /* Add reading and packing/unpacking of ISM PI data */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 82f198135..e3dfbde4d 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -153,16 +153,24 @@ void IVAS_RTP_LogPiData( uint32_t nPiDataPresent /* i : Number of valid elements in the piData array */ ) { +#ifdef ISM_PI_DATA + uint16_t n; +#endif uint32_t timestamp = ~0u; if ( f_piDataOut == NULL || piData == NULL || nPiDataPresent == 0 ) { return; } +#ifdef ISM_PI_DATA +#ifdef _WIN32 + if ( ftell( f_piDataOut ) > 3 ) +#else if ( ftell( f_piDataOut ) > 2 ) - { - fprintf( f_piDataOut, ",\n" ); - } +#endif +#else + if ( ftell( f_piDataOut ) > 2 ) +#endif while ( nPiDataPresent-- > 0 ) { @@ -334,6 +342,107 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, "{}" ); } break; +#ifdef ISM_PI_DATA + case IVAS_PI_ISM_ORIENTATION: + { + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismOrientation.numObjects; n++ ) + { + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"w\": %f,\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", + fixedToFloat( cur->data.ismOrientation.orientation[n].w_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[n].x_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[n].y_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[n].z_fx, Q15 ) ); + } + fprintf( f_piDataOut, "\n\t\t]" ); + } + break; + case IVAS_PI_ISM_NUM: + { + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"num\": %d", cur->data.ismNum.numObjects ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_ISM_ID: + { + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"ids\": [\n" ); + for ( n = 0; n < cur->data.ismId.numObjects; n++ ) + { + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismId.id[n] ); + } + fprintf( f_piDataOut, "\n\t\t\t]" ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_ISM_GAIN: + { + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"gains\": [\n" ); + for ( n = 0; n < cur->data.ismGain.numObjects; n++ ) + { + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismGain.dB[n] ); + } + fprintf( f_piDataOut, "\n\t\t\t]" ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_ISM_POSITION: + { + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismPosition.numObjects; n++ ) + { + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", cur->data.ismPosition.position[n].x, cur->data.ismPosition.position[n].y, cur->data.ismPosition.position[n].z ); + } + fprintf( f_piDataOut, "\n\t\t]" ); + } + break; + case IVAS_PI_ISM_DISTANCE_ATTENUATION: + { + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismAttenuation.numObjects; n++ ) + { + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"ref_dist\": %f,\n\t\t\t\t\"max_dist\": %f,\n\t\t\t\t\"roll_off\": %f \n\t\t\t}", cur->data.ismAttenuation.distAtten[n].ref_dist, cur->data.ismAttenuation.distAtten[n].max_dist, cur->data.ismAttenuation.distAtten[n].roll ); + } + fprintf( f_piDataOut, "\n\t\t]" ); + } + break; + case IVAS_PI_ISM_DIRECTIVITY: + { + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismDirectivity.numObjects; n++ ) + { + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"inner_ang\": %d,\n\t\t\t\t\"outer_ang\": %d,\n\t\t\t\t\"outer_att\": %f \n\t\t\t}", cur->data.ismDirectivity.directivity[n].innerConeAngle, cur->data.ismDirectivity.directivity[n].outerConeAngle, cur->data.ismDirectivity.directivity[n].outerAttenuationdB ); + } + fprintf( f_piDataOut, "\n\t\t]" ); + } + break; +#else case IVAS_PI_ISM_NUM: case IVAS_PI_ISM_ID: case IVAS_PI_ISM_GAIN: @@ -341,6 +450,7 @@ void IVAS_RTP_LogPiData( case IVAS_PI_ISM_POSITION: case IVAS_PI_ISM_DISTANCE_ATTENUATION: case IVAS_PI_ISM_DIRECTIVITY: +#endif case IVAS_PI_PI_LATENCY: case IVAS_PI_R_ISM_ID: case IVAS_PI_R_ISM_GAIN: diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index be2e9dd4d..fc4330db3 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -32,6 +32,18 @@ #include "ivas_error_utils.h" #include "ivas_rtp_internal.h" +#ifdef ISM_PI_DATA +#include + +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif + +#endif #ifdef IVAS_RTPDUMP @@ -154,6 +166,43 @@ static ivas_error packOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t *b return IVAS_ERR_OK; } +#ifdef ISM_PI_DATA +static ivas_error packISMOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + const IVAS_PIDATA_ISM_ORIENTATION *orientation = (const IVAS_PIDATA_ISM_ORIENTATION *) piData; + uint16_t n; + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_ISM_ORIENTATION ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in Orientation PI data" ); + } + + if ( piData->piDataType != IVAS_PI_ISM_ORIENTATION ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in Orientation PI data" ); + } + /* Orientation data is 8 bytes, header is 2 bytes */ + if ( maxDataBytes < 8 * IVAS_MAX_NUM_OBJECTS + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack Orientation PI data" ); + } + + buffer[nBytes++] = ( orientation->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = (uint8_t) orientation->numObjects * 8; + for ( n = 0; n < orientation->numObjects; n++ ) + { + nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation[n].w_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation[n].x_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation[n].y_fx ) ); + nBytes = writeInt16( buffer, nBytes, round_fx( orientation->orientation[n].z_fx ) ); + } + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} +#endif + static ivas_error unpackOrientation( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) { IVAS_PIDATA_ORIENTATION *orientation = (IVAS_PIDATA_ORIENTATION *) piData; @@ -173,6 +222,40 @@ static ivas_error unpackOrientation( const uint8_t *buffer, uint32_t numDataByte return IVAS_ERR_OK; } +#ifdef ISM_PI_DATA +static ivas_error unpackISMOrientation( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_ISM_ORIENTATION *ism_orientation = (IVAS_PIDATA_ISM_ORIENTATION *) piData; + + /* Orientation data is 8 bytes */ + uint16_t n; + if ( numDataBytes % 8 != 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack Orientation PI data" ); + } + + ism_orientation->size = sizeof( IVAS_PIDATA_ISM_ORIENTATION ); + ism_orientation->numObjects = (uint16_t) numDataBytes / 8; + + for ( n = 0; n < ism_orientation->numObjects; n++ ) + { + ism_orientation->orientation[n].w_fx = L_deposit_l( readInt16( &buffer[8 * n] ) ); + ism_orientation->orientation[n].x_fx = L_deposit_l( readInt16( &buffer[8 * n + 2] ) ); + ism_orientation->orientation[n].y_fx = L_deposit_l( readInt16( &buffer[8 * n + 4] ) ); + ism_orientation->orientation[n].z_fx = L_deposit_l( readInt16( &buffer[8 * n + 6] ) ); + } + for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) + { + ism_orientation->orientation[n].w_fx = 0; + ism_orientation->orientation[n].x_fx = 0; + ism_orientation->orientation[n].y_fx = 0; + ism_orientation->orientation[n].z_fx = 0; + } + + return IVAS_ERR_OK; +} +#endif + static uint32_t getIndexTable( const float *table, uint32_t tableLength, float value ) { uint32_t idx = 0; @@ -477,6 +560,67 @@ static ivas_error unpackListenerPosition( const uint8_t *buffer, uint32_t numDat return IVAS_ERR_OK; } +#ifdef ISM_PI_DATA +static ivas_error packISMPosition( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0, n; + const IVAS_PIDATA_ISM_POSITION *ism_position = (const IVAS_PIDATA_ISM_POSITION *) piData; + + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_ISM_POSITION ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in ISM POSITION PI data" ); + } + + if ( piData->piDataType != IVAS_PI_ISM_POSITION ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM POSITION PI data" ); + } + + /* Position data is 6 bytes, header is 2 bytes */ + if ( maxDataBytes < 6 * IVAS_MAX_NUM_OBJECTS + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack ISM POSITION PI data" ); + } + + buffer[nBytes++] = ( ism_position->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = (uint8_t) ism_position->numObjects * 6; + for ( n = 0; n < ism_position->numObjects; n++ ) + { + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( ism_position->position[n].x / MAX_PI_POSITION_METERS ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( ism_position->position[n].y / MAX_PI_POSITION_METERS ) ); + nBytes = writeInt16( buffer, nBytes, ivasPayload_convertToQ15( ism_position->position[n].z / MAX_PI_POSITION_METERS ) ); + } + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackISMPosition( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint16_t n; + IVAS_PIDATA_ISM_POSITION *ism_position = (IVAS_PIDATA_ISM_POSITION *) piData; + + /* Position data is 6 bytes */ + if ( numDataBytes % 6 != 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack LISTENER POSITION PI data" ); + } + + ism_position->size = sizeof( IVAS_PIDATA_ISM_POSITION ); + ism_position->piDataType = IVAS_PI_ISM_POSITION; + ism_position->numObjects = (uint16_t) numDataBytes / 6; + + for ( n = 0; n < ism_position->numObjects; n++ ) + { + ism_position->position[n].x = FLOAT_FROM_Q15( readInt16( &buffer[6 * n] ) ) * MAX_PI_POSITION_METERS; + ism_position->position[n].y = FLOAT_FROM_Q15( readInt16( &buffer[6 * n + 2] ) ) * MAX_PI_POSITION_METERS; + ism_position->position[n].z = FLOAT_FROM_Q15( readInt16( &buffer[6 * n + 4] ) ) * MAX_PI_POSITION_METERS; + } + return IVAS_ERR_OK; +} +#endif + static ivas_error packDiegetic( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0, n; @@ -630,6 +774,376 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat return IVAS_ERR_OK; } +#ifdef ISM_PI_DATA +static ivas_error packISMNum( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0; + const IVAS_PIDATA_ISM_NUM *ism_num = (const IVAS_PIDATA_ISM_NUM *) piData; + + *nBytesWritten = 0; + + if ( piData->size != sizeof( IVAS_PIDATA_ISM_NUM ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in ISM_NUM PI data" ); + } + + if ( piData->piDataType != IVAS_PI_ISM_NUM ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM_NUM PI data" ); + } + + /* ISM_NUM data is 1 bytes, header is 2 bytes */ + if ( maxDataBytes < 1 + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack ISM_NUM PI data" ); + } + + buffer[nBytes++] = ( ism_num->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = 1; + buffer[nBytes++] = ( ( ism_num->numObjects - 1 ) & MASK_2BIT ) << 6; + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackISMNum( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + IVAS_PIDATA_ISM_NUM *ism_num = (IVAS_PIDATA_ISM_NUM *) piData; + uint8_t byte; + + /* ISM_NUM data is 1 bytes */ + if ( numDataBytes != 1 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack ISM_NUM PI data" ); + } + + ism_num->size = sizeof( IVAS_PIDATA_ISM_NUM ); + ism_num->piDataType = IVAS_PI_ISM_NUM; + + byte = buffer[0]; + ism_num->numObjects = ( ( byte >> 6 ) & MASK_2BIT ) + 1; + + return IVAS_ERR_OK; +} +static ivas_error packISMID( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0, n; + const IVAS_PIDATA_ISM_ID *ism_id = (const IVAS_PIDATA_ISM_ID *) piData; + + *nBytesWritten = 0; + + if ( piData->size > sizeof( IVAS_PIDATA_ISM_ID ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in ISM_ID PI data" ); + } + + if ( piData->piDataType != IVAS_PI_ISM_ID ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM_ID PI data" ); + } + + /* ISM_ID data is 1 byte per object, header is 2 bytes */ + if ( maxDataBytes < 1 * IVAS_MAX_NUM_OBJECTS + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack ISM_NUM PI data" ); + } + + buffer[nBytes++] = ( ism_id->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = (uint8_t) ism_id->numObjects; + /* Pack ID for each object */ + for ( n = 0; n < ism_id->numObjects; n++ ) + { + buffer[nBytes++] = ( ism_id->id[n] & MASK_8BIT ); + } + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackISMID( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t n; + IVAS_PIDATA_ISM_ID *ism_id = (IVAS_PIDATA_ISM_ID *) piData; + + /* ISM_ID data is 1 byte per object */ + if ( numDataBytes > IVAS_MAX_NUM_OBJECTS ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack ISM_ID PI data" ); + } + + ism_id->size = sizeof( IVAS_PIDATA_ISM_ID ); + ism_id->piDataType = IVAS_PI_ISM_ID; + ism_id->numObjects = (uint16_t) numDataBytes; + + /* Unpack ID for each object (1 byte each) */ + for ( n = 0; n < ism_id->numObjects; n++ ) + { + ism_id->id[n] = buffer[n]; + } + for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) + { + ism_id->id[n] = 0; /* Initializing to 0, although there might be another object with this ID */ + } + + return IVAS_ERR_OK; +} + +static ivas_error packISMGain( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0, n, idx; + int16_t gain; + const IVAS_PIDATA_ISM_GAIN *ism_gain = (const IVAS_PIDATA_ISM_GAIN *) piData; + + *nBytesWritten = 0; + + if ( piData->size > sizeof( IVAS_PIDATA_ISM_GAIN ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in ISM_GAIN PI data" ); + } + + if ( piData->piDataType != IVAS_PI_ISM_GAIN ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM_GAIN PI data" ); + } + + /* ISM_GAIN data is 1 byte per object, header is 2 bytes */ + if ( maxDataBytes < 1 * IVAS_MAX_NUM_OBJECTS + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack ISM_GAIN PI data" ); + } + + buffer[nBytes++] = ( ism_gain->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = (uint8_t) ism_gain->numObjects; + /* Pack ID for each object */ + for ( n = 0; n < ism_gain->numObjects; n++ ) + { + gain = (int16_t) ism_gain->dB[n]; + idx = min( -gain, 25 ); + if ( gain > 0 ) + { + idx += 25; + } + + buffer[nBytes++] = ( idx & MASK_6BIT ) << 2; + } + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackISMGain( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t n, idx; + IVAS_PIDATA_ISM_GAIN *ism_gain = (IVAS_PIDATA_ISM_GAIN *) piData; + + /* ISM_GAIN data is 1 byte per object */ + if ( numDataBytes > IVAS_MAX_NUM_OBJECTS ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack ISM_GAIN PI data" ); + } + + ism_gain->size = sizeof( IVAS_PIDATA_ISM_GAIN ); + ism_gain->piDataType = IVAS_PI_ISM_GAIN; + ism_gain->numObjects = (uint16_t) numDataBytes; + + /* Unpack ID for each object (1 byte each) */ + for ( n = 0; n < ism_gain->numObjects; n++ ) + { + idx = ( buffer[n] ) >> 2; + /* negative gains*/ + if ( idx < 25 ) + { + ism_gain->dB[n] = -(int8_t) ( idx ); + } + /* Set to min for muting, to be interpreted as -Inf */ + else if ( idx == 25 ) + { + ism_gain->dB[n] = -128; + } + /* postive gains */ + else if ( idx < 38 ) + { + ism_gain->dB[n] = (int8_t) idx - 25; + } + else + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect index for ISM_GAIN PI data" ); + } + } + for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) + { + ism_gain->dB[n] = 0; /* Set to default */ + } + return IVAS_ERR_OK; +} + +static ivas_error packISMDistanceAttenuation( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0, n; + const IVAS_PIDATA_ISM_ATTENUATION *ism_att = (const IVAS_PIDATA_ISM_ATTENUATION *) piData; + uint32_t lWord; + + *nBytesWritten = 0; + + if ( piData->size > sizeof( IVAS_PIDATA_ISM_ATTENUATION ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in ISM_DISTANCE_ATTENUATION PI data" ); + } + + if ( piData->piDataType != IVAS_PI_ISM_DISTANCE_ATTENUATION ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM_DISTANCE_ATTENUATION PI data" ); + } + + /* ISM_DISTANCE_ATTENUATION data is 3 bytes per object, header is 2 bytes */ + if ( maxDataBytes > 3 * IVAS_MAX_NUM_OBJECTS + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack ISM_DISTANCE_ATTENUATION PI data" ); + } + + buffer[nBytes++] = ( ism_att->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = (uint8_t) ism_att->numObjects * 3; + /* Pack ID for each object */ + for ( n = 0; n < ism_att->numObjects; n++ ) + { + if ( ism_att->distAtten[n].ref_dist < 0 || ism_att->distAtten[n].max_dist < 0 || ism_att->distAtten[n].roll < 0 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect DISTANCE ATTENUATION data" ); + } + lWord = (uint32_t) ( min( (uint16_t) ( ism_att->distAtten[n].ref_dist * 10.0f + 0.5f ) - 1, 63 ) << 18 ); + lWord |= (uint32_t) ( min( (uint16_t) ( ism_att->distAtten[n].max_dist + 0.5f ) - 1, 63 ) << 12 ); + lWord |= (uint32_t) ( min( (uint16_t) ( ism_att->distAtten[n].roll * 10.0f + 0.5f ), 40 ) << 6 ); + + buffer[nBytes++] = ( lWord >> 16 ) & MASK_8BIT; + buffer[nBytes++] = ( lWord >> 8 ) & MASK_8BIT; + buffer[nBytes++] = lWord & MASK_8BIT; + } + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackISMDistanceAttenuation( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t n, lWord; + IVAS_PIDATA_ISM_ATTENUATION *ism_att = (IVAS_PIDATA_ISM_ATTENUATION *) piData; + + /* ISM_DISTANCE_ATTENUATION data is 3 bytes per object */ + if ( numDataBytes % 3 != 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack ISM_DISTANCE_ATTENUATION PI data" ); + } + + ism_att->size = sizeof( IVAS_PIDATA_ISM_ATTENUATION ); + ism_att->piDataType = IVAS_PI_ISM_DISTANCE_ATTENUATION; + ism_att->numObjects = (uint16_t) numDataBytes / 3; + + /* Unpack attenuation for each object (3 bytes each) */ + for ( n = 0; n < ism_att->numObjects; n++ ) + { + lWord = ( buffer[3 * n] ) << 16; + lWord |= ( buffer[3 * n + 1] ) << 8; + lWord |= buffer[3 * n + 2]; + + ism_att->distAtten[n].ref_dist = ( ( ( lWord >> 18 ) & MASK_6BIT ) + 1 ) / 10.0f; + ism_att->distAtten[n].max_dist = (float) ( ( lWord >> 12 ) & MASK_6BIT ) + 1; + ism_att->distAtten[n].roll = ( ( lWord >> 6 ) & MASK_6BIT ) / 10.0f; + } + for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) + { + ism_att->distAtten[n].ref_dist = 1.0f; /* Set to default */ + ism_att->distAtten[n].max_dist = 16.0f; /* Set to default */ + ism_att->distAtten[n].roll = 1.0f; /* Set to default */ + } + return IVAS_ERR_OK; +} +static ivas_error packISMDirectivity( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t nBytes = 0, n; + const IVAS_PIDATA_ISM_DIRECTIVITY *ism_directivity = (const IVAS_PIDATA_ISM_DIRECTIVITY *) piData; + uint16_t word, idx; + + *nBytesWritten = 0; + + if ( piData->size > sizeof( IVAS_PIDATA_ISM_DIRECTIVITY ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in ISM_DIRECTIVITY PI data" ); + } + + if ( piData->piDataType != IVAS_PI_ISM_DIRECTIVITY ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in ISM_DIRECTIVITY PI data" ); + } + + /* ISM_DIRECTIVITY data is 2 bytes per object, header is 2 bytes */ + if ( maxDataBytes > 2 * IVAS_MAX_NUM_OBJECTS + 2 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack ISM_DIRECTIVITY PI data" ); + } + + buffer[nBytes++] = ( ism_directivity->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ + buffer[nBytes++] = (uint8_t) ism_directivity->numObjects * 2; + /* Pack directivity for each object */ + for ( n = 0; n < ism_directivity->numObjects; n++ ) + { + word = (uint16_t) ( min( ism_directivity->directivity[n].innerConeAngle / 15, 24 ) << 11 ); + word |= (uint16_t) ( min( ism_directivity->directivity[n].outerConeAngle / 15, 24 ) << 6 ); + + idx = 0; + /* For outer attenuation < -90 dB, idx = 0, which corresponds to -Inf (muting) */ + if ( ism_directivity->directivity[n].outerAttenuationdB >= -90.0f ) + { + idx = 32 - (uint16_t) ( -ism_directivity->directivity[n].outerAttenuationdB / 3.0f + 0.5f ); + } + word |= (uint16_t) ( min( idx, 31 ) << 1 ); + + buffer[nBytes++] = ( word >> 8 ) & MASK_8BIT; + buffer[nBytes++] = word & MASK_8BIT; + } + *nBytesWritten = nBytes; + return IVAS_ERR_OK; +} + +static ivas_error unpackISMDirectivity( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t n; + uint16_t word, idx; + IVAS_PIDATA_ISM_DIRECTIVITY *ism_directivity = (IVAS_PIDATA_ISM_DIRECTIVITY *) piData; + + /* ISM_DIRECTIVITY data is 2 bytes per object */ + if ( numDataBytes % 2 != 0 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack ISM_DIRECTIVITY PI data" ); + } + + ism_directivity->size = sizeof( IVAS_PIDATA_ISM_DIRECTIVITY ); + ism_directivity->piDataType = IVAS_PI_ISM_DIRECTIVITY; + ism_directivity->numObjects = (uint16_t) numDataBytes / 2; + + /* Unpack directivity for each object (2 bytes each) */ + for ( n = 0; n < ism_directivity->numObjects; n++ ) + { + word = ( buffer[2 * n] ) << 8; + word |= ( buffer[2 * n + 1] ); + + ism_directivity->directivity[n].innerConeAngle = ( ( word >> 11 ) & MASK_5BIT ) * 15; + ism_directivity->directivity[n].outerConeAngle = ( ( word >> 6 ) & MASK_5BIT ) * 15; + idx = ( word >> 1 ) & MASK_5BIT; + + if ( idx == 0 ) + { + ism_directivity->directivity[n].outerAttenuationdB = -128.0f; /* corresponds to muting */ + } + else + { + ism_directivity->directivity[n].outerAttenuationdB = -3.0f * ( 31 - ( ( word >> 1 ) & MASK_5BIT ) ); + } + } + for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) + { + ism_directivity->directivity[n].innerConeAngle = 360; /* Set to default */ + ism_directivity->directivity[n].outerConeAngle = 360; /* Set to default */ + ism_directivity->directivity[n].outerAttenuationdB = 0; /* Set to default */ + } + return IVAS_ERR_OK; +} +#endif #endif /* RTP_S4_251135_CR26253_0016_REV1 */ @@ -641,25 +1155,35 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioDescription, /* AUDIO_DESCRIPTION */ #else - packUnsupportedData, /* AUDIO_DESCRIPTION */ -#endif /* RTP_S4_251135_CR26253_0016_REV1 */ - packUnsupportedData, /* ISM_NUM */ - packUnsupportedData, /* ISM_ID */ - packUnsupportedData, /* ISM_GAIN */ - packUnsupportedData, /* ISM_ORIENTATION */ - packUnsupportedData, /* ISM_POSITION */ - packUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ - packUnsupportedData, /* ISM_DIRECTIVITY */ + packUnsupportedData, /* AUDIO_DESCRIPTION */ +#endif /* RTP_S4_251135_CR26253_0016_REV1 */ +#ifdef ISM_PI_DATA + packISMNum, /* ISM_NUM */ + packISMID, /* ISM_ID */ + packISMGain, /* ISM_GAIN */ + packISMOrientation, /* ISM_ORIENTATION */ + packISMPosition, /* ISM_POSITION */ + packISMDistanceAttenuation, /* ISM_DISTANCE_ATTENUATION */ + packISMDirectivity, /* ISM_DIRECTIVITY */ +#else + packUnsupportedData, /* ISM_NUM */ + packUnsupportedData, /* ISM_ID */ + packUnsupportedData, /* ISM_GAIN */ + packUnsupportedData, /* ISM_ORIENTATION */ + packUnsupportedData, /* ISM_POSITION */ + packUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ + packUnsupportedData, /* ISM_DIRECTIVITY */ +#endif #ifdef RTP_S4_251135_CR26253_0016_REV1 packDiegetic, /* DIEGETIC_TYPE */ #else - packUnsupportedData, /* DIEGETIC_TYPE */ + packUnsupportedData, /* DIEGETIC_TYPE */ #endif packUnsupportedData, /* RESERVED13 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ #else - packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ + packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ #endif packUnsupportedData, /* RESERVED15 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 @@ -669,11 +1193,11 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #else - packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ - packUnsupportedData, /* HEAD_ORIENTATION */ - packUnsupportedData, /* LISTENER_POSITION */ - packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ - packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ + packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ + packUnsupportedData, /* HEAD_ORIENTATION */ + packUnsupportedData, /* LISTENER_POSITION */ + packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ + packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif packUnsupportedData, /* PI_LATENCY */ packUnsupportedData, /* R_ISM_ID */ @@ -681,7 +1205,7 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* R_ISM_ORIENTATION */ #else - packUnsupportedData, /* R_ISM_ORIENTATION */ + packUnsupportedData, /* R_ISM_ORIENTATION */ #endif packUnsupportedData, /* R_ISM_POSITION */ packUnsupportedData, /* R_ISM_DIRECTION */ @@ -700,27 +1224,37 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackAudioDescription, /* AUDIO_DESCRIPTION */ #else - unpackUnsupportedData, /* AUDIO_DESCRIPTION */ + unpackUnsupportedData, /* AUDIO_DESCRIPTION */ +#endif +#ifdef ISM_PI_DATA + unpackISMNum, /* ISM_NUM */ + unpackISMID, /* ISM_ID */ + unpackISMGain, /* ISM_GAIN */ + unpackISMOrientation, /* ISM_ORIENTATION */ + unpackISMPosition, /* ISM_POSITION */ + unpackISMDistanceAttenuation, /* ISM_DISTANCE_ATTENUATION */ + unpackISMDirectivity, /* ISM_DIRECTIVITY */ +#else + unpackUnsupportedData, /* ISM_NUM */ + unpackUnsupportedData, /* ISM_ID */ + unpackUnsupportedData, /* ISM_GAIN */ + unpackUnsupportedData, /* ISM_ORIENTATION */ + unpackUnsupportedData, /* ISM_POSITION */ + unpackUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ + unpackUnsupportedData, /* ISM_DIRECTIVITY */ #endif - unpackUnsupportedData, /* ISM_NUM */ - unpackUnsupportedData, /* ISM_ID */ - unpackUnsupportedData, /* ISM_GAIN */ - unpackUnsupportedData, /* ISM_ORIENTATION */ - unpackUnsupportedData, /* ISM_POSITION */ - unpackUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ - unpackUnsupportedData, /* ISM_DIRECTIVITY */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - unpackDiegetic, /* DIEGETIC_TYPE */ + unpackDiegetic, /* DIEGETIC_TYPE */ #else unpackUnsupportedData, /* DIEGETIC_TYPE */ #endif - unpackUnsupportedData, /* RESERVED13 */ + unpackUnsupportedData, /* RESERVED13 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - unpackAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ + unpackAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ #else unpackUnsupportedData, /* AUDIO_FOCUS_INDICATION */ #endif - unpackUnsupportedData, /* RESERVED15 */ + unpackUnsupportedData, /* RESERVED15 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ unpackOrientation, /* HEAD_ORIENTATION */ @@ -734,21 +1268,21 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif - unpackUnsupportedData, /* PI_LATENCY */ - unpackUnsupportedData, /* R_ISM_ID */ - unpackUnsupportedData, /* R_ISM_GAIN */ + unpackUnsupportedData, /* PI_LATENCY */ + unpackUnsupportedData, /* R_ISM_ID */ + unpackUnsupportedData, /* R_ISM_GAIN */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - unpackOrientation, /* R_ISM_ORIENTATION */ + unpackOrientation, /* R_ISM_ORIENTATION */ #else unpackUnsupportedData, /* R_ISM_ORIENTATION */ #endif - unpackUnsupportedData, /* R_ISM_POSITION */ - unpackUnsupportedData, /* R_ISM_DIRECTION */ - unpackUnsupportedData, /* RESERVED27 */ - unpackUnsupportedData, /* RESERVED28 */ - unpackUnsupportedData, /* RESERVED29 */ - unpackUnsupportedData, /* RESERVED30 */ - unpackNoPiData /* NO_DATA */ + unpackUnsupportedData, /* R_ISM_POSITION */ + unpackUnsupportedData, /* R_ISM_DIRECTION */ + unpackUnsupportedData, /* RESERVED27 */ + unpackUnsupportedData, /* RESERVED28 */ + unpackUnsupportedData, /* RESERVED29 */ + unpackUnsupportedData, /* RESERVED30 */ + unpackNoPiData /* NO_DATA */ }; static const uint32_t maxPiDataSize[IVAS_PI_MAX_ID] = { diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index dc4c7f8ba..85e41ed37 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -207,6 +207,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ uint32_t piDataType; /* IVAS_PI_ISM_ID */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif uint8_t id[IVAS_MAX_NUM_OBJECTS]; /* 8-bit ISM id of object */ } IVAS_PIDATA_ISM_ID; @@ -215,6 +218,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif int8_t dB[IVAS_MAX_NUM_OBJECTS]; /* ISM gain in dB per object [-96, +3] */ } IVAS_PIDATA_ISM_GAIN; @@ -223,6 +229,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif IVAS_QUATERNION orientation[IVAS_MAX_NUM_OBJECTS]; /* Orientation of audio objects in ISM(s) */ } IVAS_PIDATA_ISM_ORIENTATION; @@ -231,6 +240,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif IVAS_COORDINATE position[IVAS_MAX_NUM_OBJECTS]; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_ISM_POSITION; @@ -250,6 +262,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif IVAS_DIST_ATTEN distAtten[IVAS_MAX_NUM_OBJECTS]; /* Distance attenuation of audio objects */ } IVAS_PIDATA_ISM_ATTENUATION; @@ -269,6 +284,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ +#ifdef ISM_PI_DATA + uint16_t numObjects; /* number of objects */ +#endif IVAS_ISM_DIRECTIVITY directivity[IVAS_MAX_NUM_OBJECTS]; /* Directivity of audio objects */ } IVAS_PIDATA_ISM_DIRECTIVITY; -- GitLab From dc3803ad41f5232a1e9bb24c3e8e6fee550bd5b9 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 18:24:30 +0200 Subject: [PATCH 263/351] Fix cmake build --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0347d98a1..21bb3e738 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,7 +174,7 @@ file(GLOB libDecSrcs "lib_dec/*.c") file(GLOB libDecHeaders "lib_dec/*.h") add_library(lib_dec ${libDecSrcs} ${libDecHeaders}) target_link_libraries(lib_dec lib_com lib_basop lib_rend lib_debug lib_isar) -target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_basop lib_enc lib_isar) +target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_basop lib_enc lib_isar lib_util) file(GLOB libUtilSrcs "lib_util/*.c") file(GLOB libUtilHeaders "lib_util/*.h") -- GitLab From dcf7dd4d1a4710948e7a40f1dddeba3fb2d39595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Toftg=C3=A5rd?= Date: Mon, 10 Nov 2025 17:31:06 +0100 Subject: [PATCH 264/351] Clang formatting --- lib_util/ivas_rtp_file.c | 472 ++++++++++++++++++------------------ lib_util/ivas_rtp_pi_data.c | 78 +++--- lib_util/ivas_rtp_pi_data.h | 24 +- 3 files changed, 287 insertions(+), 287 deletions(-) diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index e3dfbde4d..0bf820df4 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -172,298 +172,298 @@ void IVAS_RTP_LogPiData( if ( ftell( f_piDataOut ) > 2 ) #endif - while ( nPiDataPresent-- > 0 ) - { - const PIDATA_TS *cur = piData++; - - if ( timestamp != ( ~0u ) && timestamp != cur->timestamp ) - { - fprintf( f_piDataOut, "\n\t},\n\t\"%d\": {\n", cur->timestamp ); - } - else if ( timestamp != cur->timestamp ) - { - fprintf( f_piDataOut, "\t\"%d\": {\n", cur->timestamp ); - } - else - { - fprintf( f_piDataOut, ",\n" ); - } - fprintf( f_piDataOut, "\t\t\"%s\" : ", PiDataNames[cur->data.noPiData.piDataType] ); - switch ( cur->data.noPiData.piDataType ) + while ( nPiDataPresent-- > 0 ) { - case IVAS_PI_SCENE_ORIENTATION: - case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: - case IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED: -#ifdef RTP_S4_251135_CR26253_0016_REV1 - case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: - case IVAS_PI_HEAD_ORIENTATION: - case IVAS_PI_R_ISM_ORIENTATION: -#endif + const PIDATA_TS *cur = piData++; + + if ( timestamp != ( ~0u ) && timestamp != cur->timestamp ) { - fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", - fixedToFloat( cur->data.scene.orientation.w_fx, Q15 ), - fixedToFloat( cur->data.scene.orientation.x_fx, Q15 ), - fixedToFloat( cur->data.scene.orientation.y_fx, Q15 ), - fixedToFloat( cur->data.scene.orientation.z_fx, Q15 ) ); + fprintf( f_piDataOut, "\n\t},\n\t\"%d\": {\n", cur->timestamp ); } - break; - - case IVAS_PI_ACOUSTIC_ENVIRONMENT: + else if ( timestamp != cur->timestamp ) { - fprintf( f_piDataOut, "{\n\t\t\t\"aeid\": %d", cur->data.acousticEnv.aeid ); - if ( cur->data.acousticEnv.availLateReverb ) + fprintf( f_piDataOut, "\t\"%d\": {\n", cur->timestamp ); + } + else + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\"%s\" : ", PiDataNames[cur->data.noPiData.piDataType] ); + switch ( cur->data.noPiData.piDataType ) + { + case IVAS_PI_SCENE_ORIENTATION: + case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: + case IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED: +#ifdef RTP_S4_251135_CR26253_0016_REV1 + case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: + case IVAS_PI_HEAD_ORIENTATION: + case IVAS_PI_R_ISM_ORIENTATION: +#endif { - fprintf( f_piDataOut, ",\n\t\t\t\"rt60\": [ %f, %f, %f ],\n", cur->data.acousticEnv.rt60[0], cur->data.acousticEnv.rt60[1], cur->data.acousticEnv.rt60[2] ); - fprintf( f_piDataOut, "\t\t\t\"dsr\": [ %f, %f, %f ]", cur->data.acousticEnv.dsr[0], cur->data.acousticEnv.dsr[1], cur->data.acousticEnv.dsr[2] ); + fprintf( f_piDataOut, "{\n\t\t\t\"w\": %f,\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", + fixedToFloat( cur->data.scene.orientation.w_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.x_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.y_fx, Q15 ), + fixedToFloat( cur->data.scene.orientation.z_fx, Q15 ) ); } - if ( cur->data.acousticEnv.availEarlyReflections ) + break; + + case IVAS_PI_ACOUSTIC_ENVIRONMENT: { - fprintf( f_piDataOut, ",\n\t\t\t\"dim\": [ %f, %f, %f ],\n", cur->data.acousticEnv.roomDimensions.x, cur->data.acousticEnv.roomDimensions.y, cur->data.acousticEnv.roomDimensions.z ); - fprintf( f_piDataOut, "\t\t\t\"abscoeff\": [ %f, %f, %f, %f, %f, %f ]", cur->data.acousticEnv.absorbCoeffs[0], cur->data.acousticEnv.absorbCoeffs[1], cur->data.acousticEnv.absorbCoeffs[2], cur->data.acousticEnv.absorbCoeffs[3], cur->data.acousticEnv.absorbCoeffs[4], cur->data.acousticEnv.absorbCoeffs[5] ); + fprintf( f_piDataOut, "{\n\t\t\t\"aeid\": %d", cur->data.acousticEnv.aeid ); + if ( cur->data.acousticEnv.availLateReverb ) + { + fprintf( f_piDataOut, ",\n\t\t\t\"rt60\": [ %f, %f, %f ],\n", cur->data.acousticEnv.rt60[0], cur->data.acousticEnv.rt60[1], cur->data.acousticEnv.rt60[2] ); + fprintf( f_piDataOut, "\t\t\t\"dsr\": [ %f, %f, %f ]", cur->data.acousticEnv.dsr[0], cur->data.acousticEnv.dsr[1], cur->data.acousticEnv.dsr[2] ); + } + if ( cur->data.acousticEnv.availEarlyReflections ) + { + fprintf( f_piDataOut, ",\n\t\t\t\"dim\": [ %f, %f, %f ],\n", cur->data.acousticEnv.roomDimensions.x, cur->data.acousticEnv.roomDimensions.y, cur->data.acousticEnv.roomDimensions.z ); + fprintf( f_piDataOut, "\t\t\t\"abscoeff\": [ %f, %f, %f, %f, %f, %f ]", cur->data.acousticEnv.absorbCoeffs[0], cur->data.acousticEnv.absorbCoeffs[1], cur->data.acousticEnv.absorbCoeffs[2], cur->data.acousticEnv.absorbCoeffs[3], cur->data.acousticEnv.absorbCoeffs[4], cur->data.acousticEnv.absorbCoeffs[5] ); + } + fprintf( f_piDataOut, "\n\t\t}" ); } - fprintf( f_piDataOut, "\n\t\t}" ); - } - break; + break; #ifdef RTP_S4_251135_CR26253_0016_REV1 - case IVAS_PI_LISTENER_POSITION: - case IVAS_PI_R_ISM_POSITION: - { - fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", - cur->data.listnerPosition.position.x, cur->data.listnerPosition.position.y, cur->data.listnerPosition.position.z ); - } - break; - case IVAS_PI_AUDIO_DESCRIPTION: - { - uint32_t nEntries = cur->data.audioDesc.nValidEntries; - const IVAS_AUDIO_ID *audioId = cur->data.audioDesc.audioId; + case IVAS_PI_LISTENER_POSITION: + case IVAS_PI_R_ISM_POSITION: + { + fprintf( f_piDataOut, "{\n\t\t\t\"x\": %f,\n\t\t\t\"y\": %f,\n\t\t\t\"z\": %f \n\t\t}", + cur->data.listnerPosition.position.x, cur->data.listnerPosition.position.y, cur->data.listnerPosition.position.z ); + } + break; + case IVAS_PI_AUDIO_DESCRIPTION: + { + uint32_t nEntries = cur->data.audioDesc.nValidEntries; + const IVAS_AUDIO_ID *audioId = cur->data.audioDesc.audioId; - fprintf( f_piDataOut, "[\n" ); - while ( nEntries-- > 0 ) + fprintf( f_piDataOut, "[\n" ); + while ( nEntries-- > 0 ) + { + fprintf( f_piDataOut, "\t\t\t{\n" ); + fprintf( f_piDataOut, "\t\t\t\t\"isSpeech\": %s,\n", audioId->speech ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t\"isMusic\": %s,\n", audioId->music ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t\"isAmbiance\": %s,\n", audioId->ambiance ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t\"isEditable\": %s,\n", audioId->editable ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t\"isBinaural\": %s\n", audioId->binaural ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t}%c\n", ( nEntries == 0 ) ? ' ' : ',' ); + audioId++; + } + fprintf( f_piDataOut, "\t\t]" ); + } + break; + case IVAS_PI_DIEGETIC_TYPE: { - fprintf( f_piDataOut, "\t\t\t{\n" ); - fprintf( f_piDataOut, "\t\t\t\t\"isSpeech\": %s,\n", audioId->speech ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\t\"isMusic\": %s,\n", audioId->music ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\t\"isAmbiance\": %s,\n", audioId->ambiance ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\t\"isEditable\": %s,\n", audioId->editable ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\t\"isBinaural\": %s\n", audioId->binaural ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t}%c\n", ( nEntries == 0 ) ? ' ' : ',' ); - audioId++; + const bool *isDiegetic = cur->data.digeticIndicator.isDiegetic; + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"isDigetic\": [\n" ); + fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[0] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[1] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[2] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[3] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\t%s\n", isDiegetic[4] ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t]\n\t\t}" ); } - fprintf( f_piDataOut, "\t\t]" ); - } - break; - case IVAS_PI_DIEGETIC_TYPE: - { - const bool *isDiegetic = cur->data.digeticIndicator.isDiegetic; - fprintf( f_piDataOut, "{\n" ); - fprintf( f_piDataOut, "\t\t\t\"isDigetic\": [\n" ); - fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[0] ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[1] ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[2] ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\t%s,\n", isDiegetic[3] ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\t%s\n", isDiegetic[4] ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t]\n\t\t}" ); - } - break; - case IVAS_PI_AUDIO_FOCUS_INDICATION: - { - fprintf( f_piDataOut, "{" ); - if ( cur->data.focusIndication.availDirection ) + break; + case IVAS_PI_AUDIO_FOCUS_INDICATION: { - fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); - fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", - fixedToFloat( cur->data.focusIndication.direction.w_fx, Q15 ), - fixedToFloat( cur->data.focusIndication.direction.x_fx, Q15 ), - fixedToFloat( cur->data.focusIndication.direction.y_fx, Q15 ), - fixedToFloat( cur->data.focusIndication.direction.z_fx, Q15 ) ); + fprintf( f_piDataOut, "{" ); + if ( cur->data.focusIndication.availDirection ) + { + fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); + fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", + fixedToFloat( cur->data.focusIndication.direction.w_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.x_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.y_fx, Q15 ), + fixedToFloat( cur->data.focusIndication.direction.z_fx, Q15 ) ); + if ( cur->data.focusIndication.availLevel ) + { + fprintf( f_piDataOut, "," ); + } + } if ( cur->data.focusIndication.availLevel ) { - fprintf( f_piDataOut, "," ); + fprintf( f_piDataOut, "\n\t\t\t\"level\": %d", cur->data.focusIndication.flvl ); } + fprintf( f_piDataOut, "\n\t\t}" ); } - if ( cur->data.focusIndication.availLevel ) + break; + case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST: { - fprintf( f_piDataOut, "\n\t\t\t\"level\": %d", cur->data.focusIndication.flvl ); + const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppressionRequest; + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"preferSpeech\": %s,\n", das->speech ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"preferMusic\": %s,\n", das->music ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"preferAmbiance\": %s,\n", das->ambiance ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"level\": %d", das->sli ); + fprintf( f_piDataOut, "\n\t\t}" ); } - fprintf( f_piDataOut, "\n\t\t}" ); - } - break; - case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_REQUEST: - { - const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppressionRequest; - fprintf( f_piDataOut, "{\n" ); - fprintf( f_piDataOut, "\t\t\t\"preferSpeech\": %s,\n", das->speech ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\"preferMusic\": %s,\n", das->music ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\"preferAmbiance\": %s,\n", das->ambiance ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\"level\": %d", das->sli ); - fprintf( f_piDataOut, "\n\t\t}" ); - } - break; - case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION: - { - const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppressionIndication; - fprintf( f_piDataOut, "{\n" ); - fprintf( f_piDataOut, "\t\t\t\"preferSpeech\": %s,\n", das->speech ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\"preferMusic\": %s,\n", das->music ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\"preferAmbiance\": %s,\n", das->ambiance ? "true" : "false" ); - fprintf( f_piDataOut, "\t\t\t\"level\": %d", das->sli ); - fprintf( f_piDataOut, "\n\t\t}" ); - } - break; - case IVAS_PI_AUDIO_FOCUS_REQUEST: - { - fprintf( f_piDataOut, "{" ); - if ( cur->data.focusRequest.availDirection ) + break; + case IVAS_PI_DYNAMIC_AUDIO_SUPPRESSION_INDICATION: { - fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); - fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", - fixedToFloat( cur->data.focusRequest.direction.w_fx, Q15 ), - fixedToFloat( cur->data.focusRequest.direction.x_fx, Q15 ), - fixedToFloat( cur->data.focusRequest.direction.y_fx, Q15 ), - fixedToFloat( cur->data.focusRequest.direction.z_fx, Q15 ) ); + const IVAS_PIDATA_DYNAMIC_SUPPRESSION *das = &cur->data.dynSuppressionIndication; + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"preferSpeech\": %s,\n", das->speech ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"preferMusic\": %s,\n", das->music ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"preferAmbiance\": %s,\n", das->ambiance ? "true" : "false" ); + fprintf( f_piDataOut, "\t\t\t\"level\": %d", das->sli ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_AUDIO_FOCUS_REQUEST: + { + fprintf( f_piDataOut, "{" ); + if ( cur->data.focusRequest.availDirection ) + { + fprintf( f_piDataOut, "\n\t\t\t\"direction\": {\n" ); + fprintf( f_piDataOut, "\t\t\t\t\t\t\"w\": %f,\n\t\t\t\t\t\t\"x\": %f,\n\t\t\t\t\t\t\"y\": %f,\n\t\t\t\t\t\t\"z\": %f \n\t\t\t}", + fixedToFloat( cur->data.focusRequest.direction.w_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.x_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.y_fx, Q15 ), + fixedToFloat( cur->data.focusRequest.direction.z_fx, Q15 ) ); + if ( cur->data.focusRequest.availLevel ) + { + fprintf( f_piDataOut, "," ); + } + } if ( cur->data.focusRequest.availLevel ) { - fprintf( f_piDataOut, "," ); + fprintf( f_piDataOut, "\n\t\t\t\"level\": %d", cur->data.focusRequest.flvl ); } + fprintf( f_piDataOut, "\n\t\t}" ); } - if ( cur->data.focusRequest.availLevel ) + break; + case IVAS_PI_RESERVED15: + case IVAS_PI_RESERVED27: + case IVAS_PI_RESERVED28: + case IVAS_PI_RESERVED29: + case IVAS_PI_RESERVED30: { - fprintf( f_piDataOut, "\n\t\t\t\"level\": %d", cur->data.focusRequest.flvl ); + fprintf( f_piDataOut, "{}" ); } - fprintf( f_piDataOut, "\n\t\t}" ); - } - break; - case IVAS_PI_RESERVED15: - case IVAS_PI_RESERVED27: - case IVAS_PI_RESERVED28: - case IVAS_PI_RESERVED29: - case IVAS_PI_RESERVED30: - { - fprintf( f_piDataOut, "{}" ); - } - break; + break; #ifdef ISM_PI_DATA - case IVAS_PI_ISM_ORIENTATION: - { - fprintf( f_piDataOut, "[\n" ); - for ( n = 0; n < cur->data.ismOrientation.numObjects; n++ ) + case IVAS_PI_ISM_ORIENTATION: { - if ( n != 0 ) + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismOrientation.numObjects; n++ ) { - fprintf( f_piDataOut, ",\n" ); + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"w\": %f,\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", + fixedToFloat( cur->data.ismOrientation.orientation[n].w_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[n].x_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[n].y_fx, Q15 ), + fixedToFloat( cur->data.ismOrientation.orientation[n].z_fx, Q15 ) ); } - fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"w\": %f,\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", - fixedToFloat( cur->data.ismOrientation.orientation[n].w_fx, Q15 ), - fixedToFloat( cur->data.ismOrientation.orientation[n].x_fx, Q15 ), - fixedToFloat( cur->data.ismOrientation.orientation[n].y_fx, Q15 ), - fixedToFloat( cur->data.ismOrientation.orientation[n].z_fx, Q15 ) ); + fprintf( f_piDataOut, "\n\t\t]" ); } - fprintf( f_piDataOut, "\n\t\t]" ); - } - break; - case IVAS_PI_ISM_NUM: - { - fprintf( f_piDataOut, "{\n" ); - fprintf( f_piDataOut, "\t\t\t\"num\": %d", cur->data.ismNum.numObjects ); - fprintf( f_piDataOut, "\n\t\t}" ); - } - break; - case IVAS_PI_ISM_ID: - { - fprintf( f_piDataOut, "{\n" ); - fprintf( f_piDataOut, "\t\t\t\"ids\": [\n" ); - for ( n = 0; n < cur->data.ismId.numObjects; n++ ) + break; + case IVAS_PI_ISM_NUM: + { + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"num\": %d", cur->data.ismNum.numObjects ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; + case IVAS_PI_ISM_ID: { - if ( n != 0 ) + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"ids\": [\n" ); + for ( n = 0; n < cur->data.ismId.numObjects; n++ ) { - fprintf( f_piDataOut, ",\n" ); + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismId.id[n] ); } - fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismId.id[n] ); + fprintf( f_piDataOut, "\n\t\t\t]" ); + fprintf( f_piDataOut, "\n\t\t}" ); } - fprintf( f_piDataOut, "\n\t\t\t]" ); - fprintf( f_piDataOut, "\n\t\t}" ); - } - break; - case IVAS_PI_ISM_GAIN: - { - fprintf( f_piDataOut, "{\n" ); - fprintf( f_piDataOut, "\t\t\t\"gains\": [\n" ); - for ( n = 0; n < cur->data.ismGain.numObjects; n++ ) + break; + case IVAS_PI_ISM_GAIN: { - if ( n != 0 ) + fprintf( f_piDataOut, "{\n" ); + fprintf( f_piDataOut, "\t\t\t\"gains\": [\n" ); + for ( n = 0; n < cur->data.ismGain.numObjects; n++ ) { - fprintf( f_piDataOut, ",\n" ); + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismGain.dB[n] ); } - fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismGain.dB[n] ); + fprintf( f_piDataOut, "\n\t\t\t]" ); + fprintf( f_piDataOut, "\n\t\t}" ); } - fprintf( f_piDataOut, "\n\t\t\t]" ); - fprintf( f_piDataOut, "\n\t\t}" ); - } - break; - case IVAS_PI_ISM_POSITION: - { - fprintf( f_piDataOut, "[\n" ); - for ( n = 0; n < cur->data.ismPosition.numObjects; n++ ) + break; + case IVAS_PI_ISM_POSITION: { - if ( n != 0 ) + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismPosition.numObjects; n++ ) { - fprintf( f_piDataOut, ",\n" ); + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", cur->data.ismPosition.position[n].x, cur->data.ismPosition.position[n].y, cur->data.ismPosition.position[n].z ); } - fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", cur->data.ismPosition.position[n].x, cur->data.ismPosition.position[n].y, cur->data.ismPosition.position[n].z ); + fprintf( f_piDataOut, "\n\t\t]" ); } - fprintf( f_piDataOut, "\n\t\t]" ); - } - break; - case IVAS_PI_ISM_DISTANCE_ATTENUATION: - { - fprintf( f_piDataOut, "[\n" ); - for ( n = 0; n < cur->data.ismAttenuation.numObjects; n++ ) + break; + case IVAS_PI_ISM_DISTANCE_ATTENUATION: { - if ( n != 0 ) + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismAttenuation.numObjects; n++ ) { - fprintf( f_piDataOut, ",\n" ); + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"ref_dist\": %f,\n\t\t\t\t\"max_dist\": %f,\n\t\t\t\t\"roll_off\": %f \n\t\t\t}", cur->data.ismAttenuation.distAtten[n].ref_dist, cur->data.ismAttenuation.distAtten[n].max_dist, cur->data.ismAttenuation.distAtten[n].roll ); } - fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"ref_dist\": %f,\n\t\t\t\t\"max_dist\": %f,\n\t\t\t\t\"roll_off\": %f \n\t\t\t}", cur->data.ismAttenuation.distAtten[n].ref_dist, cur->data.ismAttenuation.distAtten[n].max_dist, cur->data.ismAttenuation.distAtten[n].roll ); + fprintf( f_piDataOut, "\n\t\t]" ); } - fprintf( f_piDataOut, "\n\t\t]" ); - } - break; - case IVAS_PI_ISM_DIRECTIVITY: - { - fprintf( f_piDataOut, "[\n" ); - for ( n = 0; n < cur->data.ismDirectivity.numObjects; n++ ) + break; + case IVAS_PI_ISM_DIRECTIVITY: { - if ( n != 0 ) + fprintf( f_piDataOut, "[\n" ); + for ( n = 0; n < cur->data.ismDirectivity.numObjects; n++ ) { - fprintf( f_piDataOut, ",\n" ); + if ( n != 0 ) + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"inner_ang\": %d,\n\t\t\t\t\"outer_ang\": %d,\n\t\t\t\t\"outer_att\": %f \n\t\t\t}", cur->data.ismDirectivity.directivity[n].innerConeAngle, cur->data.ismDirectivity.directivity[n].outerConeAngle, cur->data.ismDirectivity.directivity[n].outerAttenuationdB ); } - fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"inner_ang\": %d,\n\t\t\t\t\"outer_ang\": %d,\n\t\t\t\t\"outer_att\": %f \n\t\t\t}", cur->data.ismDirectivity.directivity[n].innerConeAngle, cur->data.ismDirectivity.directivity[n].outerConeAngle, cur->data.ismDirectivity.directivity[n].outerAttenuationdB ); + fprintf( f_piDataOut, "\n\t\t]" ); } - fprintf( f_piDataOut, "\n\t\t]" ); - } - break; + break; #else - case IVAS_PI_ISM_NUM: - case IVAS_PI_ISM_ID: - case IVAS_PI_ISM_GAIN: - case IVAS_PI_ISM_ORIENTATION: - case IVAS_PI_ISM_POSITION: - case IVAS_PI_ISM_DISTANCE_ATTENUATION: - case IVAS_PI_ISM_DIRECTIVITY: + case IVAS_PI_ISM_NUM: + case IVAS_PI_ISM_ID: + case IVAS_PI_ISM_GAIN: + case IVAS_PI_ISM_ORIENTATION: + case IVAS_PI_ISM_POSITION: + case IVAS_PI_ISM_DISTANCE_ATTENUATION: + case IVAS_PI_ISM_DIRECTIVITY: #endif - case IVAS_PI_PI_LATENCY: - case IVAS_PI_R_ISM_ID: - case IVAS_PI_R_ISM_GAIN: - case IVAS_PI_R_ISM_DIRECTION: + case IVAS_PI_PI_LATENCY: + case IVAS_PI_R_ISM_ID: + case IVAS_PI_R_ISM_GAIN: + case IVAS_PI_R_ISM_DIRECTION: #endif /* RTP_S4_251135_CR26253_0016_REV1 */ - case IVAS_PI_NO_DATA: - { - fprintf( f_piDataOut, "{}" ); + case IVAS_PI_NO_DATA: + { + fprintf( f_piDataOut, "{}" ); + } + break; } - break; + timestamp = cur->timestamp; } - timestamp = cur->timestamp; - } fprintf( f_piDataOut, "\n\t}" ); } diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index fc4330db3..5281ba716 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -1155,7 +1155,7 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioDescription, /* AUDIO_DESCRIPTION */ #else - packUnsupportedData, /* AUDIO_DESCRIPTION */ + packUnsupportedData, /* AUDIO_DESCRIPTION */ #endif /* RTP_S4_251135_CR26253_0016_REV1 */ #ifdef ISM_PI_DATA packISMNum, /* ISM_NUM */ @@ -1166,24 +1166,24 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packISMDistanceAttenuation, /* ISM_DISTANCE_ATTENUATION */ packISMDirectivity, /* ISM_DIRECTIVITY */ #else - packUnsupportedData, /* ISM_NUM */ - packUnsupportedData, /* ISM_ID */ - packUnsupportedData, /* ISM_GAIN */ - packUnsupportedData, /* ISM_ORIENTATION */ - packUnsupportedData, /* ISM_POSITION */ - packUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ - packUnsupportedData, /* ISM_DIRECTIVITY */ + packUnsupportedData, /* ISM_NUM */ + packUnsupportedData, /* ISM_ID */ + packUnsupportedData, /* ISM_GAIN */ + packUnsupportedData, /* ISM_ORIENTATION */ + packUnsupportedData, /* ISM_POSITION */ + packUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ + packUnsupportedData, /* ISM_DIRECTIVITY */ #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 packDiegetic, /* DIEGETIC_TYPE */ #else - packUnsupportedData, /* DIEGETIC_TYPE */ + packUnsupportedData, /* DIEGETIC_TYPE */ #endif packUnsupportedData, /* RESERVED13 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 packAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ #else - packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ + packUnsupportedData, /* AUDIO_FOCUS_INDICATION */ #endif packUnsupportedData, /* RESERVED15 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 @@ -1193,11 +1193,11 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ #else - packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ - packUnsupportedData, /* HEAD_ORIENTATION */ - packUnsupportedData, /* LISTENER_POSITION */ - packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ - packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ + packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ + packUnsupportedData, /* HEAD_ORIENTATION */ + packUnsupportedData, /* LISTENER_POSITION */ + packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ + packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif packUnsupportedData, /* PI_LATENCY */ packUnsupportedData, /* R_ISM_ID */ @@ -1205,7 +1205,7 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 packOrientation, /* R_ISM_ORIENTATION */ #else - packUnsupportedData, /* R_ISM_ORIENTATION */ + packUnsupportedData, /* R_ISM_ORIENTATION */ #endif packUnsupportedData, /* R_ISM_POSITION */ packUnsupportedData, /* R_ISM_DIRECTION */ @@ -1224,7 +1224,7 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackAudioDescription, /* AUDIO_DESCRIPTION */ #else - unpackUnsupportedData, /* AUDIO_DESCRIPTION */ + unpackUnsupportedData, /* AUDIO_DESCRIPTION */ #endif #ifdef ISM_PI_DATA unpackISMNum, /* ISM_NUM */ @@ -1235,26 +1235,26 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackISMDistanceAttenuation, /* ISM_DISTANCE_ATTENUATION */ unpackISMDirectivity, /* ISM_DIRECTIVITY */ #else - unpackUnsupportedData, /* ISM_NUM */ - unpackUnsupportedData, /* ISM_ID */ - unpackUnsupportedData, /* ISM_GAIN */ - unpackUnsupportedData, /* ISM_ORIENTATION */ - unpackUnsupportedData, /* ISM_POSITION */ - unpackUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ - unpackUnsupportedData, /* ISM_DIRECTIVITY */ + unpackUnsupportedData, /* ISM_NUM */ + unpackUnsupportedData, /* ISM_ID */ + unpackUnsupportedData, /* ISM_GAIN */ + unpackUnsupportedData, /* ISM_ORIENTATION */ + unpackUnsupportedData, /* ISM_POSITION */ + unpackUnsupportedData, /* ISM_DISTANCE_ATTENUATION */ + unpackUnsupportedData, /* ISM_DIRECTIVITY */ #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 - unpackDiegetic, /* DIEGETIC_TYPE */ + unpackDiegetic, /* DIEGETIC_TYPE */ #else unpackUnsupportedData, /* DIEGETIC_TYPE */ #endif - unpackUnsupportedData, /* RESERVED13 */ + unpackUnsupportedData, /* RESERVED13 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - unpackAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ + unpackAudioFocusCommon, /* AUDIO_FOCUS_INDICATION */ #else unpackUnsupportedData, /* AUDIO_FOCUS_INDICATION */ #endif - unpackUnsupportedData, /* RESERVED15 */ + unpackUnsupportedData, /* RESERVED15 */ #ifdef RTP_S4_251135_CR26253_0016_REV1 unpackOrientation, /* PLAYBACK_DEVICE_ORIENTATION */ unpackOrientation, /* HEAD_ORIENTATION */ @@ -1268,21 +1268,21 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ #endif - unpackUnsupportedData, /* PI_LATENCY */ - unpackUnsupportedData, /* R_ISM_ID */ - unpackUnsupportedData, /* R_ISM_GAIN */ + unpackUnsupportedData, /* PI_LATENCY */ + unpackUnsupportedData, /* R_ISM_ID */ + unpackUnsupportedData, /* R_ISM_GAIN */ #ifdef RTP_S4_251135_CR26253_0016_REV1 - unpackOrientation, /* R_ISM_ORIENTATION */ + unpackOrientation, /* R_ISM_ORIENTATION */ #else unpackUnsupportedData, /* R_ISM_ORIENTATION */ #endif - unpackUnsupportedData, /* R_ISM_POSITION */ - unpackUnsupportedData, /* R_ISM_DIRECTION */ - unpackUnsupportedData, /* RESERVED27 */ - unpackUnsupportedData, /* RESERVED28 */ - unpackUnsupportedData, /* RESERVED29 */ - unpackUnsupportedData, /* RESERVED30 */ - unpackNoPiData /* NO_DATA */ + unpackUnsupportedData, /* R_ISM_POSITION */ + unpackUnsupportedData, /* R_ISM_DIRECTION */ + unpackUnsupportedData, /* RESERVED27 */ + unpackUnsupportedData, /* RESERVED28 */ + unpackUnsupportedData, /* RESERVED29 */ + unpackUnsupportedData, /* RESERVED30 */ + unpackNoPiData /* NO_DATA */ }; static const uint32_t maxPiDataSize[IVAS_PI_MAX_ID] = { diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index 85e41ed37..137434a15 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -205,8 +205,8 @@ typedef struct /* ISM ID */ typedef struct { - size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ - uint32_t piDataType; /* IVAS_PI_ISM_ID */ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ + uint32_t piDataType; /* IVAS_PI_ISM_ID */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif @@ -216,8 +216,8 @@ typedef struct /* ISM gain */ typedef struct { - size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ - uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ + size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ + uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif @@ -227,8 +227,8 @@ typedef struct /* ISM orientation */ typedef struct { - size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ - uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ + uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif @@ -238,8 +238,8 @@ typedef struct /* ISM position */ typedef struct { - size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ - uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ + size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ + uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif @@ -260,8 +260,8 @@ typedef struct typedef struct { - size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ - uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ + size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ + uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif @@ -282,8 +282,8 @@ typedef struct typedef struct { - size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ - uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ + size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ + uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif -- GitLab From 1ac94db092b8795aebdb10d04e88dc751b759bd5 Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Mon, 10 Nov 2025 17:39:54 +0100 Subject: [PATCH 265/351] added C sources as in float but without defines to avoid conflicts this time --- lib_com/options.h | 1 + lib_util/ivas_rtp_file.c | 13 ++++++- lib_util/ivas_rtp_pi_data.c | 71 +++++++++++++++++++++++++++++++++++-- 3 files changed, 82 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c6a4efa4b..f6c7dff18 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define RTP_S4_251135_CR26253_0016_REV1 /* RTP Pack/Unpack API corresponding to CR 26253 */ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ +#define PI_LATENCY /* Support for PI latency */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 82f198135..5c10981e1 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -341,7 +341,18 @@ void IVAS_RTP_LogPiData( case IVAS_PI_ISM_POSITION: case IVAS_PI_ISM_DISTANCE_ATTENUATION: case IVAS_PI_ISM_DIRECTIVITY: + { + fprintf( f_piDataOut, "{}" ); + } + break; case IVAS_PI_PI_LATENCY: + { + fprintf( f_piDataOut, "{" ); + fprintf( f_piDataOut, "\n\t\t\t\"reverseType\": \"%s\",", PiDataNames[cur->data.piLatency.type] ); + fprintf( f_piDataOut, "\n\t\t\t\"latency\": %d", cur->data.piLatency.latency ); + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; case IVAS_PI_R_ISM_ID: case IVAS_PI_R_ISM_GAIN: case IVAS_PI_R_ISM_DIRECTION: @@ -600,7 +611,7 @@ void IVAS_RTP_WriteExtPiData( break; case IVAS_PI_PI_LATENCY: { - fprintf( f_piDataOut, "%d", cur->data.piLatency.latency ); + fprintf( f_piDataOut, "%s,%d", PiDataNames[cur->data.piLatency.type], cur->data.piLatency.latency ); } break; case IVAS_PI_R_ISM_ID: diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index be2e9dd4d..ede1f908a 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -630,6 +630,71 @@ static ivas_error unpackAudioFocusCommon( const uint8_t *buffer, uint32_t numDat return IVAS_ERR_OK; } +static ivas_error packPiLatency( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) +{ + uint32_t typeBits; + uint32_t latencyBits; + uint32_t word; + uint32_t nBytes = 0; + const IVAS_PIDATA_REVERSE_PI_LATENCY *p = (const IVAS_PIDATA_REVERSE_PI_LATENCY *) piData; + + *nBytesWritten = 0; + if ( piData->size != sizeof( IVAS_PIDATA_REVERSE_PI_LATENCY ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size for PI_LATENCY data" ); + } + if ( piData->piDataType != IVAS_PI_PI_LATENCY ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID for PI_LATENCY data" ); + } + if ( maxDataBytes < 2 + 4 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE, "Insufficient space to pack PI_LATENCY data" ); + } + + buffer[nBytes++] = ( p->piDataType & MASK_5BIT ); + buffer[nBytes++] = 4; + + typeBits = (uint32_t) ( p->type & MASK_5BIT ); + latencyBits = (uint32_t) ( p->latency & 0x07FFFFFF ); + word = ( typeBits << 27 ) | latencyBits; + + buffer[nBytes++] = (uint8_t) ( word >> 24 ); + buffer[nBytes++] = (uint8_t) ( word >> 16 ); + buffer[nBytes++] = (uint8_t) ( word >> 8 ); + buffer[nBytes++] = (uint8_t) ( word ); + *nBytesWritten = nBytes; + + return IVAS_ERR_OK; +} + +static ivas_error unpackPiLatency( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ) +{ + uint32_t word; + uint32_t lat; + IVAS_PIDATA_REVERSE_PI_LATENCY *p = (IVAS_PIDATA_REVERSE_PI_LATENCY *) piData; + + if ( numDataBytes != 4 ) + { + return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack PI_LATENCY data" ); + } + + p->size = sizeof( IVAS_PIDATA_REVERSE_PI_LATENCY ); + p->piDataType = IVAS_PI_PI_LATENCY; + + word = ( (uint32_t) buffer[0] << 24 ) | ( (uint32_t) buffer[1] << 16 ) | + ( (uint32_t) buffer[2] << 8 ) | (uint32_t) buffer[3]; + p->type = (IVAS_PI_TYPE) ( ( word >> 27 ) & MASK_5BIT ); + lat = word & 0x07FFFFFF; + + /* Sign-extend 27-bit value */ + if ( lat & ( 1u << 26 ) ) + p->latency = (int32_t) ( lat | ~0x07FFFFFF ); + else + p->latency = (int32_t) lat; + + return IVAS_ERR_OK; +} #endif /* RTP_S4_251135_CR26253_0016_REV1 */ @@ -668,14 +733,15 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packListenerPosition, /* LISTENER_POSITION */ packDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ packAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ + packPiLatency, /* PI_LATENCY */ #else packUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ packUnsupportedData, /* HEAD_ORIENTATION */ packUnsupportedData, /* LISTENER_POSITION */ packUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ packUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ + packUnsupportedData, /* PI_LATENCY */ #endif - packUnsupportedData, /* PI_LATENCY */ packUnsupportedData, /* R_ISM_ID */ packUnsupportedData, /* R_ISM_GAIN */ #ifdef RTP_S4_251135_CR26253_0016_REV1 @@ -727,14 +793,15 @@ static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { unpackListenerPosition, /* LISTENER_POSITION */ unpackDynamicSuppression, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackAudioFocusCommon, /* AUDIO_FOCUS_REQUEST */ + unpackPiLatency, /* PI_LATENCY */ #else unpackUnsupportedData, /* PLAYBACK_DEVICE_ORIENTATION */ unpackUnsupportedData, /* HEAD_ORIENTATION */ unpackUnsupportedData, /* LISTENER_POSITION */ unpackUnsupportedData, /* DYNAMIC_AUDIO_SUPPRESSION */ unpackUnsupportedData, /* AUDIO_FOCUS_DIRECTION */ -#endif unpackUnsupportedData, /* PI_LATENCY */ +#endif unpackUnsupportedData, /* R_ISM_ID */ unpackUnsupportedData, /* R_ISM_GAIN */ #ifdef RTP_S4_251135_CR26253_0016_REV1 -- GitLab From cd108b361af457ff1d9bc5463c93ac7d82e35a96 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 10 Nov 2025 17:57:53 +0100 Subject: [PATCH 266/351] Fix for defaulting early reflection parameters --- lib_util/render_config_reader.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 5311b54c5..0aa342bf6 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1308,31 +1308,49 @@ ivas_error RenderConfigReader_checkValues( if ( pRoom_acoustics->dimensions.x < ER_MIN_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.x = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.x_fx < ER_MIN_ROOM_DIMENSION_FX ) + { pRoom_acoustics->dimensions.x_fx = ER_MIN_ROOM_DIMENSION_FX; } if ( pRoom_acoustics->dimensions.x > ER_MAX_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.x = ER_MAX_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.x_fx > ER_MAX_ROOM_DIMENSION_FX ) + { pRoom_acoustics->dimensions.x_fx = ER_MAX_ROOM_DIMENSION_FX; } if ( pRoom_acoustics->dimensions.y < ER_MIN_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.y = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.y_fx < ER_MIN_ROOM_DIMENSION_FX ) + { pRoom_acoustics->dimensions.y_fx = ER_MIN_ROOM_DIMENSION_FX; } if ( pRoom_acoustics->dimensions.y > ER_MAX_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.y = ER_MAX_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.y_fx > ER_MAX_ROOM_DIMENSION_FX ) + { pRoom_acoustics->dimensions.y_fx = ER_MAX_ROOM_DIMENSION_FX; } if ( pRoom_acoustics->dimensions.z < ER_MIN_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.z = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.z_fx < ER_MIN_ROOM_DIMENSION_FX ) + { pRoom_acoustics->dimensions.z_fx = ER_MIN_ROOM_DIMENSION_FX; } if ( pRoom_acoustics->dimensions.z > ER_MAX_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.z = ER_MAX_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.z_fx > ER_MAX_ROOM_DIMENSION_FX ) + { pRoom_acoustics->dimensions.z_fx = ER_MAX_ROOM_DIMENSION_FX; } @@ -1342,11 +1360,17 @@ ivas_error RenderConfigReader_checkValues( if ( pRoom_acoustics->AbsCoeff[wall_idx] < ER_MIN_ABS_COEFF ) { pRoom_acoustics->AbsCoeff[wall_idx] = ER_MIN_ABS_COEFF; + } + if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] < ER_MIN_ABS_COEFF_FX ) + { pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MIN_ABS_COEFF_FX; } if ( pRoom_acoustics->AbsCoeff[wall_idx] > ER_MAX_ABS_COEFF ) { pRoom_acoustics->AbsCoeff[wall_idx] = ER_MAX_ABS_COEFF; + } + if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] > ER_MAX_ABS_COEFF_FX ) + { pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX; } } -- GitLab From 89ba117e14cdcb19590d7a4aaeb9cc3c1acd2f14 Mon Sep 17 00:00:00 2001 From: Sumeyra Kanik Date: Mon, 10 Nov 2025 18:01:41 +0100 Subject: [PATCH 267/351] Changes in radius_fx edit --- apps/decoder.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 62f7566d3..7194a8ea5 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3561,13 +3561,18 @@ static void do_object_editing_fx( if ( readInfo->obj_radius_relative[obj_idx] ) { /* radius: apply relative edit + saturation */ - Word32 temp_radius = L_max( L_min( ( L_shl_sat( Mpy_32_32( (Word32) editableParameters->ism_metadata[obj_idx].radius_fx, (Word32) ( readInfo->obj_radius[obj_idx] * 512 ) ), 2 ) ), OBJ_EDIT_RADIUS_MAX_FX ), 0 ); /* Q9*Q9 -> Q7 shift back to Q9 */ - // Saturate to 16-bit range - if ( temp_radius > 32767 ) - temp_radius = 32767; - if ( temp_radius < -32768 ) - temp_radius = -32768; - editableParameters->ism_metadata[obj_idx].radius_fx = (Word16) temp_radius; + #define SQ 9 + + #define SHIFT_DUE_TO_SQxSQ ( SQ - ( SQ + SQ + 1 - 16 ) ) /* ^shift by 6 == mult by 2^6 = 64.0 */ + + Word32 L_tmp1 = L_mult( editableParameters->ism_metadata[obj_idx].radius_fx, (Word16) ( readInfo->obj_radius[obj_idx] * ( 1L << ( SQ ) ) ) ); /*SQ*SQ*/ + Word32 L_tmp2 = L_shl_sat( L_tmp1, SHIFT_DUE_TO_SQxSQ); /*shift back to Q(9+16)*/ + Word16 temp_radius = round_fx(L_tmp2); /* Q25 -> Q9 */ + temp_radius = s_max( s_min( temp_radius , OBJ_EDIT_RADIUS_MAX_FX ), 0 ); + + /* L_tmp2 is in S31Q25 stored in a signed Word32 + temp_radius is in S15Q9 stored in a signed Word16 + */ } else { -- GitLab From f946e6d9f22bc74f395c1b35d7bdb77d282785ae Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 10 Nov 2025 18:48:13 +0100 Subject: [PATCH 268/351] Clang format --- apps/decoder.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 7194a8ea5..f35ed1f04 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3560,18 +3560,18 @@ static void do_object_editing_fx( { if ( readInfo->obj_radius_relative[obj_idx] ) { - /* radius: apply relative edit + saturation */ - #define SQ 9 +/* radius: apply relative edit + saturation */ +#define SQ 9 - #define SHIFT_DUE_TO_SQxSQ ( SQ - ( SQ + SQ + 1 - 16 ) ) /* ^shift by 6 == mult by 2^6 = 64.0 */ +#define SHIFT_DUE_TO_SQxSQ ( SQ - ( SQ + SQ + 1 - 16 ) ) /* ^shift by 6 == mult by 2^6 = 64.0 */ Word32 L_tmp1 = L_mult( editableParameters->ism_metadata[obj_idx].radius_fx, (Word16) ( readInfo->obj_radius[obj_idx] * ( 1L << ( SQ ) ) ) ); /*SQ*SQ*/ - Word32 L_tmp2 = L_shl_sat( L_tmp1, SHIFT_DUE_TO_SQxSQ); /*shift back to Q(9+16)*/ - Word16 temp_radius = round_fx(L_tmp2); /* Q25 -> Q9 */ - temp_radius = s_max( s_min( temp_radius , OBJ_EDIT_RADIUS_MAX_FX ), 0 ); + Word32 L_tmp2 = L_shl_sat( L_tmp1, SHIFT_DUE_TO_SQxSQ ); /*shift back to Q(9+16)*/ + Word16 temp_radius = round_fx( L_tmp2 ); /* Q25 -> Q9 */ + temp_radius = s_max( s_min( temp_radius, OBJ_EDIT_RADIUS_MAX_FX ), 0 ); - /* L_tmp2 is in S31Q25 stored in a signed Word32 - temp_radius is in S15Q9 stored in a signed Word16 + /* L_tmp2 is in S31Q25 stored in a signed Word32 + temp_radius is in S15Q9 stored in a signed Word16 */ } else -- GitLab From eb6fc88fd829a86bedf9145fb1f53c0c00a562c6 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 10 Nov 2025 18:52:08 +0100 Subject: [PATCH 269/351] Fixes for memory handling, listener origin --- .../render_config_reader.c | 3226 +++++++++++++++++ lib_dec/ivas_init_dec_fx.c | 15 +- lib_util/render_config_reader.c | 13 + 3 files changed, 3249 insertions(+), 5 deletions(-) create mode 100644 Workspace_msvc/enc_temp_folder/b685e51a257c31d9ba90c87bcc18d2c/render_config_reader.c diff --git a/Workspace_msvc/enc_temp_folder/b685e51a257c31d9ba90c87bcc18d2c/render_config_reader.c b/Workspace_msvc/enc_temp_folder/b685e51a257c31d9ba90c87bcc18d2c/render_config_reader.c new file mode 100644 index 000000000..0aa342bf6 --- /dev/null +++ b/Workspace_msvc/enc_temp_folder/b685e51a257c31d9ba90c87bcc18d2c/render_config_reader.c @@ -0,0 +1,3226 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "render_config_reader.h" +#include +#include +#include +#include +#include +#include "cmdl_tools.h" +#include "prot_fx.h" +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#include "ivas_cnst.h" +#endif + +/*------------------------------------------------------------------------------------------* + * PreProc Local Macros + *------------------------------------------------------------------------------------------*/ + +#define MAX_ITEM_LENGTH ( 64 ) +#define N_ABS_COEFFS ( 6 ) + +#define SHORTEST_REV_DEL_LINE ( 0.015f ) +#define N_BANDS_MIN ( 2 ) +#define N_BANDS_MAX ( 60 ) +#define FC_INPUT_MIN ( 0.0f ) +#define FC_INPUT_MAX ( 1.0e+5f ) +#define ACOUSTIC_RT60_MIN ( 1.0e-3f ) +#define ACOUSTIC_RT60_MAX ( 1.0e+2f ) +#define ACOUSTIC_DSR_MIN ( 0.0f ) +#define ACOUSTIC_DSR_MAX ( 1.0e+2f ) +#define ACOUSTIC_DSR_EPSILON ( 1.0e-15f ) +#define ACOUSTIC_DSR_EPSILON_FX ( 1 ) +#define ACOUSTICPREDELAY_JOTREV_MIN ( SHORTEST_REV_DEL_LINE ) +#define ACOUSTICPREDELAY_JOTREV_MAX ( SHORTEST_REV_DEL_LINE + 1.0f / (float) IVAS_NUM_FRAMES_PER_SEC ) +#define ACOUSTICPREDELAY_FDREV_MIN ( 1.0f / (float) ( 16 * IVAS_NUM_FRAMES_PER_SEC ) ) +#define ACOUSTICPREDELAY_FDREV_MAX ( (float) ( IVAS_REVERB_PREDELAY_MAX ) / (float) ( 16 * IVAS_NUM_FRAMES_PER_SEC ) ) +#define INPUTPREDELAY_MIN ( 0.0f ) +#define INPUTPREDELAY_MAX ( 1.0e+2f ) + +#define ER_MIN_ROOM_DIMENSION ( 1.0f ) +#define ER_MIN_ROOM_DIMENSION_FX ( 4194304 ) +#define ER_MAX_ROOM_DIMENSION ( 999.0f ) +#define ER_MAX_ROOM_DIMENSION_FX ( 2095054848 ) +#define ER_MIN_ABS_COEFF ( 0.0f ) +#define ER_MIN_ABS_COEFF_FX ( 0 ) +#define ER_MAX_ABS_COEFF ( 1.0f ) +#define ER_MAX_ABS_COEFF_FX ( 1073741824 ) + +#define IVAS_ER_LIST_ORIGIN_X 0.0f +#define IVAS_ER_LIST_ORIGIN_Y 0.0f +#define IVAS_ER_LIST_ORIGIN_X_FX 0 +#define IVAS_ER_LIST_ORIGIN_Y_FX 0 + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif + + +/*------------------------------------------------------------------------------------------* + * Local Type definitions + *------------------------------------------------------------------------------------------*/ + +typedef struct +{ + uint32_t nrBands; /* Number of frequency bands */ + float *pFc; /* Center frequencies */ +} FrequencyGrid; + +typedef enum _FREQ_GRID_MODE +{ + FREQ_GRID_MODE_UNKNOWN = -1, + FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES = 0, + FREQ_GRID_MODE_START_HOP_AMOUNT = 1, + FREQ_GRID_MODE_DEFAULT_BANDING = 2 +} FREQ_GRID_MODE; + +typedef struct +{ + uint16_t use_er; /* Activation Flag */ + IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ + float pAbsCoeff[N_ABS_COEFFS]; /* Absorption coeffs table */ + IVAS_VECTOR3 *pListenerOrigin; /* Listener origin */ + uint32_t lowComplexity; /* Low complexity mode flag */ +} EarlyReflectionsConfig; + +typedef struct +{ + uint32_t id; /* Acoustic environment ID */ + FrequencyGrid *pFG; /* Pointer into Frequency grids table for late reverb coeffs */ + float *pRT60; /* RT60 table */ + float *pDSR; /* DSR table */ + float preDelay; /* Pre-delay */ + EarlyReflectionsConfig *pEarlyReflections; /* Early reflections configuration */ +} AcousticEnv; + +typedef struct +{ + uint32_t id; /* Pattern ID */ + float *pDirectivity; /* Source directivity */ +} DirectrivityPat; + +struct RenderConfigReader +{ + FILE *pConfigFile; + uint8_t *pBitstream; /* Renderer config bitstream */ + size_t length; /* Bitstream length */ + size_t readOffset; /* Bitstream read offset */ + uint32_t nFG; /* Number of frequency grids */ + FrequencyGrid *pFG; /* Frequency grids */ + uint32_t nAE; /* Number of acoustic environments */ + AcousticEnv *pAE; /* Acoustic environments */ + uint32_t nDP; /* Number of directivity patterns */ + DirectrivityPat *pDP; /* Directivity Pattern */ + float distAtt[3]; /* [MaxDist Q30, RefDist Q30, Rolloff Q30] */ +}; + + +typedef enum _RC_LUT +{ + RC_LUT_INVALID = 0x00, + RC_LUT_COUNT_IDX_LO, + RC_LUT_COUNT_IDX_HI, + RC_LUT_DECI_SEC, + RC_LUT_SEC, + RC_LUT_MILLI_SEC, + RC_LUT_MICRO_SEC, + RC_LUT_FREQ, + RC_LUT_FREQ_HOP, + RC_LUT_DSR, + RC_LUT_METERS, + RC_LUT_HECTOMETERS, + RC_LUT_KILOMETERS, + RC_LUT_CENTIMETERS, + RC_LUT_ABSORPTION +} RC_LUT; + +/*------------------------------------------------------------------------------------------* + * Lookup tables + *------------------------------------------------------------------------------------------*/ + +const float lutCountIdxLo_Value[] = { + 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, + 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, + 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, + 48.0f, 49.0f, 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, 56.0f, 57.0f, 58.0f, 59.0f, 60.0f, 61.0f, 62.0f, 63.0f +}; +const uint16_t lutCountIdxLo_Code[] = { + 7, 4, 12, 13, 10, 11, 8, 9, 15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0, 63, 62, 61, 60, 59, 58, 57, 56, + 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, + 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80 +}; +const uint8_t lutCountIdxLo_Len[] = { + 4, 3, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 +}; + +const float lutCountIdxHi_Value[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }; +const uint16_t lutCountIdxHi_Code[] = { 1, 0, 6, 5, 4, 7, 5, 15, 14, 13, 9, 8, 25, 49, 48 }; +const uint8_t lutCountIdxHi_Len[] = { 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 7, 7 }; + +const float lutDeciSec_Value[] = { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f }; +const uint16_t lutDeciSec_Code[] = { 6, 4, 5, 6, 7, 7, 4, 5, 2, 3, 0 }; +const uint8_t lutDeciSec_Len[] = { 3, 3, 3, 4, 4, 3, 4, 4, 4, 4, 3 }; + +const float lutSec_Value[] = { + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, + 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f +}; +const uint16_t lutSec_Code[] = { 3, 1, 0, 15, 13, 12, 11, 9, 8, 14, 13, 12, 11, 9, 8, 5, 29, 28, 21, 31, 30, 21, 9, 8, 41, 41, 40, 81, 161, 160 }; +const uint8_t lutSec_Len[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 8, 8 }; + +const float lutMilliSec_Value[] = { + 0.00f, 0.001f, 0.002f, 0.003f, 0.004f, 0.005f, 0.006f, 0.007f, 0.008f, 0.009f, + 0.01f, 0.011f, 0.012f, 0.013f, 0.014f, 0.015f, 0.016f, 0.017f, 0.018f, 0.019f, + 0.02f, 0.021f, 0.022f, 0.023f, 0.024f, 0.025f, 0.026f, 0.027f, 0.028f, 0.029f, + 0.03f, 0.031f, 0.032f, 0.033f, 0.034f, 0.035f, 0.036f, 0.037f, 0.038f, 0.039f, + 0.04f, 0.041f, 0.042f, 0.043f, 0.044f, 0.045f, 0.046f, 0.047f, 0.048f, 0.049f, + 0.05f, 0.051f, 0.052f, 0.053f, 0.054f, 0.055f, 0.056f, 0.057f, 0.058f, 0.059f, + 0.06f, 0.061f, 0.062f, 0.063f, 0.064f, 0.065f, 0.066f, 0.067f, 0.068f, 0.069f, + 0.07f, 0.071f, 0.072f, 0.073f, 0.074f, 0.075f, 0.076f, 0.077f, 0.078f, 0.079f, + 0.08f, 0.081f, 0.082f, 0.083f, 0.084f, 0.085f, 0.086f, 0.087f, 0.088f, 0.089f, + 0.09f, 0.091f, 0.092f, 0.093f, 0.094f, 0.095f, 0.096f, 0.097f, 0.098f, 0.099f +}; +const uint16_t lutMilliSec_Code[] = { + 122, 123, 120, 121, 126, 127, 124, 125, 114, 115, 25, 112, 113, 118, 119, 116, 117, 42, 43, 40, + 18, 41, 46, 47, 44, 45, 34, 35, 32, 33, 19, 38, 39, 36, 37, 58, 59, 56, 57, 62, + 16, 63, 60, 61, 50, 51, 48, 49, 54, 55, 17, 52, 53, 10, 11, 8, 9, 14, 15, 12, + 22, 13, 2, 3, 0, 1, 6, 7, 4, 5, 23, 26, 27, 24, 25, 30, 31, 28, 29, 18, + 20, 19, 16, 17, 22, 23, 20, 21, 106, 107, 21, 104, 105, 110, 111, 108, 109, 98, 99, 48 +}; +const uint8_t lutMilliSec_Len[] = { + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 6 +}; + +const float lutMicroSec_Value[] = { + 0.00001f, 0.00002f, 0.00003f, 0.00004f, 0.00005f, 0.00006f, 0.00007f, 0.00008f, 0.00009f, 0.0001f, + 0.00011f, 0.00012f, 0.00013f, 0.00014f, 0.00015f, 0.00016f, 0.00017f, 0.00018f, 0.00019f, 0.0002f, + 0.00021f, 0.00022f, 0.00023f, 0.00024f, 0.00025f, 0.00026f, 0.00027f, 0.00028f, 0.00029f, 0.0003f, + 0.00031f, 0.00032f, 0.00033f, 0.00034f, 0.00035f, 0.00036f, 0.00037f, 0.00038f, 0.00039f, 0.0004f, + 0.00041f, 0.00042f, 0.00043f, 0.00044f, 0.00045f, 0.00046f, 0.00047f, 0.00048f, 0.00049f, 0.0005f, + 0.00051f, 0.00052f, 0.00053f, 0.00054f, 0.00055f, 0.00056f, 0.00057f, 0.00058f, 0.00059f, 0.0006f, + 0.00061f, 0.00062f, 0.00063f, 0.00064f, 0.00065f, 0.00066f, 0.00067f, 0.00068f, 0.00069f, 0.0007f, + 0.00071f, 0.00072f, 0.00073f, 0.00074f, 0.00075f, 0.00076f, 0.00077f, 0.00078f, 0.00079f, 0.0008f, + 0.00081f, 0.00082f, 0.00083f, 0.00084f, 0.00085f, 0.00086f, 0.00087f, 0.00088f, 0.00089f, 0.0009f, + 0.00091f, 0.00092f, 0.00093f, 0.00094f, 0.00095f, 0.00096f, 0.00097f, 0.00098f, 0.00099f +}; +const uint16_t lutMicroSec_Code[] = { + 444, 18, 445, 19, 894, 16, 895, 17, 892, 22, 893, 23, 434, 20, 435, 21, 432, 10, 433, 11, + 438, 8, 439, 9, 436, 14, 437, 15, 410, 12, 411, 13, 408, 2, 409, 3, 414, 0, 415, 1, + 412, 6, 413, 7, 402, 4, 403, 5, 400, 26, 401, 27, 406, 24, 407, 25, 404, 30, 405, 31, + 426, 28, 427, 29, 424, 18, 425, 19, 430, 16, 431, 17, 428, 22, 429, 23, 418, 20, 419, 21, + 416, 58, 417, 59, 422, 56, 423, 57, 420, 62, 421, 63, 442, 60, 443, 61, 440, 24, 441 +}; +const uint8_t lutMicroSec_Len[] = { + 9, 5, 9, 5, 10, 5, 10, 5, 10, 5, 10, 5, 9, 5, 9, 5, 9, 6, 9, 6, + 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, + 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, + 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, + 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 5, 9 +}; + +const float lutFreq_Value[] = { + 16.0f, 20.0f, 25.0f, 31.5f, 40.0f, 50.0f, 63.0f, 80.0f, 100.0f, 125.0f, + 160.0f, 200.0f, 250.0f, 315.0f, 400.0f, 500.0f, 630.0f, 800.0f, 1000.0f, 1250.0f, + 1600.0f, 2000.0f, 2500.0f, 3150.0f, 4000.0f, 5000.0f, 6300.0f, 8000.0f, 10000.0f, 12500.0f, + 16000.0f, 20000.0f, 25000.0f, 31500.0f, 40000.0f +}; +const uint16_t lutFreq_Code[] = { 35, 14, 15, 9, 12, 13, 0, 26, 27, 1, 24, 25, 14, 30, 31, 15, 28, 29, 12, 18, 19, 13, 16, 17, 10, 22, 23, 11, 20, 21, 2, 16, 138, 139, 68 }; +const uint8_t lutFreq_Len[] = { 6, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 5, 8, 8, 7 }; + +const float lutFreqHop_Value[] = { 1.059463094f, 1.122462048f, 1.189207115f, 1.259921050f, 1.414213562f, 2.0f, 4.0f }; +const uint16_t lutFreqHop_Code[] = { 2, 3, 0, 1, 1, 3, 2 }; +const uint8_t lutFreqHop_Len[] = { 4, 4, 4, 2, 4, 2, 2 }; + +const float lutDsr_Value[] = { + -150.0f, -149.0f, -148.0f, -147.0f, -146.0f, -145.0f, -144.0f, -143.0f, -142.0f, -141.0f, + -140.0f, -139.0f, -138.0f, -137.0f, -136.0f, -135.0f, -134.0f, -133.0f, -132.0f, -131.0f, + -130.0f, -129.0f, -128.0f, -127.0f, -126.0f, -125.0f, -124.0f, -123.0f, -122.0f, -121.0f, + -120.0f, -119.0f, -118.0f, -117.0f, -116.0f, -115.0f, -114.0f, -113.0f, -112.0f, -111.0f, + -110.0f, -109.0f, -108.0f, -107.0f, -106.0f, -105.0f, -104.0f, -103.0f, -102.0f, -101.0f, + -100.0f, -99.0f, -98.0f, -97.0f, -96.0f, -95.0f, -94.0f, -93.0f, -92.0f, -91.0f, + -90.0f, -89.0f, -88.0f, -87.0f, -86.0f, -85.0f, -84.0f, -83.0f, -82.0f, -81.0f, + -80.0f, -79.0f, -78.0f, -77.0f, -76.0f, -75.0f, -74.0f, -73.0f, -72.0f, -71.0f, + -70.0f, -69.0f, -68.0f, -67.0f, -66.0f, -65.0f, -64.0f, -63.0f, -62.0f, -61.0f, + -60.0f, -59.0f, -58.0f, -57.0f, -56.0f, -55.0f, -54.0f, -53.0f, -52.0f, -51.0f, + -50.0f, -49.0f, -48.0f, -47.0f, -46.0f, -45.0f, -44.0f, -43.0f, -42.0f, -41.0f, + -40.0f, -39.0f, -38.0f, -37.0f, -36.0f, -35.0f, -34.0f, -33.0f, -32.0f, -31.0f, + -30.0f, -29.0f, -28.0f, -27.0f, -26.0f, -25.0f, -24.0f, -23.0f, -22.0f, -21.0f, + -20.0f, -19.0f, -18.0f, -17.0f, -16.0f, -15.0f, -14.0f, -13.0f, -12.0f, -11.0f, + -10.0f +}; +const uint16_t lutDsr_Code[] = { + 140, 141, 286, 287, 284, 285, 130, 131, 128, 129, 134, 135, 132, 133, 234, 235, 232, 233, 238, 239, + 236, 237, 226, 227, 224, 225, 230, 231, 228, 229, 250, 251, 248, 249, 254, 255, 252, 253, 242, 243, + 240, 241, 246, 247, 244, 245, 202, 203, 200, 201, 206, 207, 204, 205, 194, 195, 192, 193, 198, 199, + 196, 197, 218, 219, 216, 217, 222, 223, 220, 221, 20, 21, 38, 39, 36, 37, 58, 59, 56, 57, + 62, 63, 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, 10, 11, 8, 9, 14, 15, 12, 13, + 2, 3, 0, 1, 6, 7, 4, 5, 42, 43, 40, 41, 46, 47, 44, 45, 18, 19, 16, 17, + 22, 210, 211, 208, 209, 214, 215, 212, 213, 186, 187, 184, 185, 190, 191, 188, 189, 138, 139, 136, + 137 +}; +const uint8_t lutDsr_Len[] = { + 8, 8, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, + 8 +}; + +const float lutMeters_Value[] = { + 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, + 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, + 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, + 30.0f, 31.0f, 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, + 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, 48.0f, 49.0f, + 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, 56.0f, 57.0f, 58.0f, 59.0f, + 60.0f, 61.0f, 62.0f, 63.0f, 64.0f, 65.0f, 66.0f, 67.0f, 68.0f, 69.0f, + 70.0f, 71.0f, 72.0f, 73.0f, 74.0f, 75.0f, 76.0f, 77.0f, 78.0f, 79.0f, + 80.0f, 81.0f, 82.0f, 83.0f, 84.0f, 85.0f, 86.0f, 87.0f, 88.0f, 89.0f, + 90.0f, 91.0f, 92.0f, 93.0f, 94.0f, 95.0f, 96.0f, 97.0f, 98.0f, 99.0f +}; + +const uint16_t lutMeters_Code[] = { + 61, 50, 51, 48, 49, 54, 55, 52, 53, 10, + 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, + 1, 6, 7, 4, 5, 26, 27, 24, 25, 30, + 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, + 21, 42, 43, 40, 41, 46, 47, 44, 45, 16, + 68, 69, 142, 143, 140, 141, 154, 155, 152, 153, + 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, + 148, 149, 234, 235, 232, 233, 238, 239, 236, 237, + 226, 227, 224, 225, 230, 231, 228, 229, 250, 251, + 248, 249, 254, 255, 252, 253, 242, 243, 240, 241 +}; + +const uint8_t lutMeters_Len[] = { + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, + 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 +}; + +const float lutHectometers_Value[] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f }; +const uint16_t lutHectometers_Code[] = { 0, 1, 6, 7, 4, 5, 6, 7, 4, 5 }; +const uint8_t lutHectometers_Len[] = { 3, 3, 3, 3, 3, 3, 4, 4, 4, 4 }; + +const float lutKilometers_Value[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f }; +const uint16_t lutKilometers_Code[] = { 2, 3, 1, 0, 7, 5, 4, 13, 25, 24 }; +const uint8_t lutKilometers_Len[] = { 2, 3, 3, 3, 3, 4, 4, 4, 5, 5 }; + +const float lutCentimeters_Value[] = { + 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, + 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, + 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, + 30.0f, 31.0f, 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, + 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, 48.0f, 49.0f, + 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, 56.0f, 57.0f, 58.0f, 59.0f, + 60.0f, 61.0f, 62.0f, 63.0f, 64.0f, 65.0f, 66.0f, 67.0f, 68.0f, 69.0f, + 70.0f, 71.0f, 72.0f, 73.0f, 74.0f, 75.0f, 76.0f, 77.0f, 78.0f, 79.0f, + 80.0f, 81.0f, 82.0f, 83.0f, 84.0f, 85.0f, 86.0f, 87.0f, 88.0f, 89.0f, + 90.0f, 91.0f, 92.0f, 93.0f, 94.0f, 95.0f, 96.0f, 97.0f, 98.0f, 99.0f +}; + +const uint16_t lutCentimeters_Code[] = { + 50, 51, 48, 49, 54, 55, 52, 53, 42, 43, + 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, + 38, 39, 36, 37, 58, 59, 56, 57, 62, 63, + 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, + 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, + 0, 1, 6, 7, 4, 5, 26, 27, 24, 25, + 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, + 20, 21, 42, 43, 40, 41, 46, 47, 44, 45, + 34, 35, 32, 33, 38, 39, 36, 37, 122, 123, + 120, 121, 126, 127, 124, 125, 58, 59, 56, 57 +}; + +const uint8_t lutCentimeters_Len[] = { + 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, + 7, 7, 7, 7, 7, 7, 6, 6, 6, 6 +}; + +const float lutAbsorption_Value[] = { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f }; +const uint16_t lutAbsorption_Code[] = { 6, 4, 5, 6, 7, 7, 4, 5, 2, 3, 0 }; +const uint8_t lutAbsorption_Len[] = { 3, 3, 3, 4, 4, 3, 4, 4, 4, 4, 3 }; + +/*------------------------------------------------------------------------------------------* + * Default frequency grids + *------------------------------------------------------------------------------------------*/ + +const float defaultFrequencyGrid_0[] = { 31.5f, 63.0f, 125.0f, 250.0f, 500.0f, 1000.0f, 2000.0f, 4000.0f, 8000.0f, 16000.0f }; +const float defaultFrequencyGrid_1[] = { 25.0f, 50.0f, 100.0f, 200.0f, 400.0f, 800.0f, 1600.0f, 3150.0f, 6300.0f, 12500.0f }; +const float defaultFrequencyGrid_2[] = { + 20.0f, 25.0f, 31.5f, 40.0f, 50.0f, 63.0f, 80.0f, 100.0f, 125.0f, 160.0f, + 200.0f, 250.0f, 315.0f, 400.0f, 500.0f, 630.0f, 800.0f, 1000.0f, 1250.0f, 1600.0f, + 2000.0f, 2500.0f, 3150.0f, 4000.0f, 5000.0f, 6300.0f, 8000.0f, 10000.0f, 12500.0f, 16000.0f, 20000.0f +}; +const float defaultFrequencyGrid_3[] = { 25.0f, 100.0f, 400.0f, 1600.0f, 6300.0f }; +const float defaultFrequencyGrid_4[] = { 125.0f, 250.0f, 500.0f, 1000.0f, 2000.0f, 4000.0f }; +const float defaultFrequencyGrid_5[] = { 25.0f, 250.0f, 2500.0f }; +const float defaultFrequencyGrid_6[] = { + 27.0f, 56.0f, 89.0f, 126.0f, 168.0f, 214.0f, 265.0f, 323.0f, 387.0f, 459.0f, + 539.0f, 628.0f, 727.0f, 839.0f, 963.0f, 1101.0f, 1256.0f, 1429.0f, 1621.0f, 1836.0f, + 2077.0f, 2345.0f, 2644.0f, 2978.0f, 3351.0f, 3767.0f, 4232.0f, 4750.0f, 5329.0f, 5975.0f, + 6697.0f, 7502.0f, 8401.0f, 9405.0f, 10525.0f, 11775.0f, 13171.0f, 14729.0f, 16468.0f, 18410.0f, 20577.0f +}; +const float defaultFrequencyGrid_7[] = { + 27.0f, 89.0f, 168.0f, 265.0f, 387.0f, 539.0f, 727.0f, 963.0f, 1256.0f, 1621.0f, + 2077.0f, 2644.0f, 3351.0f, 4232.0f, 5329.0f, 6697.0f, 8401.0f, 10525.0f, 13171.0f, 16468.0f, 20577.0f +}; +const float defaultFrequencyGrid_8[] = { + 50.0f, 150.0f, 250.0f, 350.0f, 450.0f, 570.0f, 700.0f, 840.0f, 1000.0f, 1170.0f, + 1370.0f, 1600.0f, 1850.0f, 2150.0f, 2150.0f, 2500.0f, 2900.0f, 3400.0f, 4000.0f, 4800.0f, + 5800.0f, 7000.0f, 8500.0f, 10500.0f, 13500.0f +}; + + +/*-----------------------------------------------------------------------------------------* + * Function read_bin_bits() + * Reads a given number of bits from the bitstream + *-----------------------------------------------------------------------------------------*/ + +static ivas_error read_bin_bits( + RenderConfigReader *this, /* i/o : Renderer config reader handle */ + uint32_t *pTarget, /* o : Target read data pointer */ + const size_t nBits /* i : Number of bits to read */ +) +{ + uint8_t n; + uint32_t nByte; + uint8_t bit; + + if ( this == NULL || this->pBitstream == NULL || pTarget == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( this->readOffset + nBits > this->length * 8 ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + *pTarget = 0; + for ( n = 0; n < nBits; n++ ) + { + nByte = (uint32_t) ( ( this->readOffset + n ) >> 3 ); + bit = this->pBitstream[nByte] >> ( 7 - ( ( this->readOffset + n ) % 8 ) ) & 1; + *pTarget = ( *pTarget << 1 ) + bit; + } + + this->readOffset += nBits; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function read_bin_bool() + * Reads a boolean value from a bitstream + *-----------------------------------------------------------------------------------------*/ + +static ivas_error read_bin_bool( + RenderConfigReader *this, /* i/o : Renderer config reader handle */ + uint32_t *pResult /* o : Target read data pointer */ +) +{ + return read_bin_bits( this, pResult, 1 ); +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_id() + * Reads an ID from a bitstream + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_id( + RenderConfigReader *this, /* i/o : Renderer config reader handle */ + uint32_t *pResult /* o : Target read data pointer */ +) +{ + ivas_error error; + uint32_t id; + uint32_t cont; + + *pResult = 0; + id = 0; + cont = true; + + if ( pResult == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + while ( cont ) + { + if ( ( error = read_bin_bits( this, &id, 7 ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult = ( *pResult << 7 ) | id; + + if ( ( error = read_bin_bool( this, &cont ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function read_bin_code_word() + * Reads a code word from a LUT + *-----------------------------------------------------------------------------------------*/ + +static ivas_error read_bin_code_word( + RenderConfigReader *this, /* i/o : Renderer config reader handle */ + const RC_LUT table, /* i : Table enum */ + float *pResult /* o : Code value */ +) +{ + ivas_error error; + const float *pValues; + const uint16_t *pCodes; + const uint8_t *pLengths; + uint8_t minLen; + uint8_t maxLen; + uint8_t size; + uint8_t n; + uint32_t code; + uint32_t bits; + uint32_t nr_bits; + uint8_t len; + + minLen = 255; + maxLen = 0; + bits = 0; + nr_bits = 0; + code = 0; + + if ( pResult == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* Select the right tables */ + switch ( table ) + { + case RC_LUT_COUNT_IDX_LO: + pValues = lutCountIdxLo_Value; + pCodes = lutCountIdxLo_Code; + pLengths = lutCountIdxLo_Len; + size = sizeof lutCountIdxLo_Len / sizeof( uint8_t ); + break; + case RC_LUT_COUNT_IDX_HI: + pValues = lutCountIdxHi_Value; + pCodes = lutCountIdxHi_Code; + pLengths = lutCountIdxHi_Len; + size = sizeof lutCountIdxHi_Len / sizeof( uint8_t ); + break; + case RC_LUT_DECI_SEC: + pValues = lutDeciSec_Value; + pCodes = lutDeciSec_Code; + pLengths = lutDeciSec_Len; + size = sizeof lutDeciSec_Len / sizeof( uint8_t ); + break; + case RC_LUT_SEC: + pValues = lutSec_Value; + pCodes = lutSec_Code; + pLengths = lutSec_Len; + size = sizeof lutSec_Len / sizeof( uint8_t ); + break; + case RC_LUT_MILLI_SEC: + pValues = lutMilliSec_Value; + pCodes = lutMilliSec_Code; + pLengths = lutMilliSec_Len; + size = sizeof lutMilliSec_Len / sizeof( uint8_t ); + break; + case RC_LUT_MICRO_SEC: + pValues = lutMicroSec_Value; + pCodes = lutMicroSec_Code; + pLengths = lutMicroSec_Len; + size = sizeof lutMicroSec_Len / sizeof( uint8_t ); + break; + case RC_LUT_FREQ: + pValues = lutFreq_Value; + pCodes = lutFreq_Code; + pLengths = lutFreq_Len; + size = sizeof lutFreq_Len / sizeof( uint8_t ); + break; + case RC_LUT_FREQ_HOP: + pValues = lutFreqHop_Value; + pCodes = lutFreqHop_Code; + pLengths = lutFreqHop_Len; + size = sizeof lutFreqHop_Len / sizeof( uint8_t ); + break; + case RC_LUT_DSR: + pValues = lutDsr_Value; + pCodes = lutDsr_Code; + pLengths = lutDsr_Len; + size = sizeof lutDsr_Len / sizeof( uint8_t ); + break; + case RC_LUT_METERS: + pValues = lutMeters_Value; + pCodes = lutMeters_Code; + pLengths = lutMeters_Len; + size = sizeof lutMeters_Len / sizeof( uint8_t ); + break; + case RC_LUT_HECTOMETERS: + pValues = lutHectometers_Value; + pCodes = lutHectometers_Code; + pLengths = lutHectometers_Len; + size = sizeof lutHectometers_Len / sizeof( uint8_t ); + break; + case RC_LUT_KILOMETERS: + pValues = lutKilometers_Value; + pCodes = lutKilometers_Code; + pLengths = lutKilometers_Len; + size = sizeof lutKilometers_Len / sizeof( uint8_t ); + break; + case RC_LUT_CENTIMETERS: + pValues = lutCentimeters_Value; + pCodes = lutCentimeters_Code; + pLengths = lutCentimeters_Len; + size = sizeof lutCentimeters_Len / sizeof( uint8_t ); + break; + case RC_LUT_ABSORPTION: + pValues = lutAbsorption_Value; + pCodes = lutAbsorption_Code; + pLengths = lutAbsorption_Len; + size = sizeof lutAbsorption_Len / sizeof( uint8_t ); + break; + case RC_LUT_INVALID: + default: + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + /* First read minLen bits, then add one bit per iteration to find the correct value */ + for ( n = 0; n < size; n++ ) + { + minLen = min( minLen, pLengths[n] ); + maxLen = max( maxLen, pLengths[n] ); + } + for ( len = minLen; len <= maxLen; len++ ) + { + nr_bits = ( len == minLen ) ? minLen : 1; + if ( ( error = read_bin_bits( this, &bits, nr_bits ) ) != IVAS_ERR_OK ) + { + return error; + } + code = ( code << nr_bits ) | bits; + for ( n = 0; n < size; n++ ) + { + if ( code == pCodes[n] && len == pLengths[n] ) + { + *pResult = pValues[n]; + return IVAS_ERR_OK; + } + } + } + return IVAS_ERR_INVALID_RENDER_CONFIG; +} + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_count_or_index() + * Gets a count or index + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_count_or_index( + RenderConfigReader *this, /* i/o : Renderer config reader handle */ + uint32_t *pResult /* o : Count or index value */ +) +{ + ivas_error error; + float value; + uint32_t isLarge; + + if ( pResult == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( ( error = read_bin_code_word( this, RC_LUT_COUNT_IDX_LO, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult = (uint32_t) value; + + if ( ( error = read_bin_bool( this, &isLarge ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( isLarge ) + { + if ( ( error = read_bin_code_word( this, RC_LUT_COUNT_IDX_HI, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult += (uint32_t) value << 6; + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_duration() + * Gets a duration value + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_duration( + RenderConfigReader *this, /* i/o : Renderer config reader handle */ + float *pResult /* o : Duration value */ +) +{ + ivas_error error; + float value; + uint32_t addFlag; + + /* Deciseconds */ + if ( ( error = read_bin_code_word( this, RC_LUT_DECI_SEC, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult = value; + + /* Milliseconds */ + if ( ( error = read_bin_bool( this, &addFlag ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( addFlag ) + { + if ( ( error = read_bin_code_word( this, RC_LUT_MILLI_SEC, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult += value; + + /* Microseconds */ + if ( ( error = read_bin_bool( this, &addFlag ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( addFlag ) + { + if ( ( error = read_bin_code_word( this, RC_LUT_MICRO_SEC, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult += value; + } + } + + /* Seconds */ + if ( ( error = read_bin_bool( this, &addFlag ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( addFlag ) + { + if ( ( error = read_bin_code_word( this, RC_LUT_SEC, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult += value; + } + + /* Correct rounding errors due to multiple additions: */ + *pResult = roundf( *pResult * 100000.0f ) / 100000.0f; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_frequency() + * Gets a frequency value + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_frequency( + RenderConfigReader *this, /* i/o : Renderer config reader handle */ + float *pResult /* o : Frequency value */ +) +{ + ivas_error error; + uint32_t hiRes; + uint32_t refine; + + hiRes = 0; + refine = 0; + + if ( ( error = read_bin_code_word( this, RC_LUT_FREQ, pResult ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = read_bin_bool( this, &hiRes ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( hiRes ) + { + if ( ( error = read_bin_bits( this, &refine, 4 ) ) != IVAS_ERR_OK ) + { + return error; + } + + *pResult *= powf( 2.0f, ( (float) refine + 1.0f ) / 51.0f ); + } + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_dsr() + * Gets a DSR value + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_dsr( + RenderConfigReader *this, /* i/o : Renderer config reader handle */ + float *pResult /* o : DSR value */ +) +{ + ivas_error error; + float value; + + if ( ( error = read_bin_code_word( this, RC_LUT_DSR, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult = powf( 10.0f, value / 10.0f ); + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_distance() + * Gets a distance value (in meters) + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_distance( + RenderConfigReader *this, /* i/o : Render config reader handle */ + uint16_t isSmall, /* i : Flag indicating a small distance */ + float *pResult /* o : Distance value */ +) +{ + ivas_error error; + float value; + uint32_t flag; + + if ( ( error = read_bin_code_word( this, RC_LUT_METERS, pResult ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( isSmall == false ) + { + /* addHectometers flag */ + if ( ( error = read_bin_bool( this, &flag ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( flag == true ) + { + /* Hectometers */ + if ( ( error = read_bin_code_word( this, RC_LUT_HECTOMETERS, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult += value * 100.0f; + + /* addKilometers flag */ + if ( ( error = read_bin_bool( this, &flag ) ) != IVAS_ERR_OK ) + { + return error; + } + + while ( flag == true ) + { + /* Kilometers */ + if ( ( error = read_bin_code_word( this, RC_LUT_KILOMETERS, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult += value * 1000.0f; + + /* addKilometers flag */ + if ( ( error = read_bin_bool( this, &flag ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + } + + /* addCentimeters flag */ + if ( ( error = read_bin_bool( this, &flag ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( flag == true ) + { + /* Centimeters */ + if ( ( error = read_bin_code_word( this, RC_LUT_CENTIMETERS, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + *pResult += value * 0.01f; + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_absorption() + * Gets an absorption value + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_absorption( + RenderConfigReader *this, /* i/o : Render config reader handle */ + float *pResult /* o : Absorption value */ +) +{ + ivas_error error; + + if ( ( error = read_bin_code_word( this, RC_LUT_ABSORPTION, pResult ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function read_txt_bool() + * Reads a boolean value from a line + *-----------------------------------------------------------------------------------------*/ + +static ivas_error read_txt_bool( + const char *pLine, /* i : String to read from */ + uint32_t *pTarget /* o : Output pointer */ +) +{ + char value[8 + 1]; + + if ( sscanf( pLine, "%8s", (char *) &value ) != 1 ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + if ( strcmp( value, "TRUE" ) == 0 ) + { + *pTarget = TRUE; + return IVAS_ERR_OK; + } + if ( strcmp( value, "FALSE" ) == 0 ) + { + *pTarget = FALSE; + return IVAS_ERR_OK; + } + + return IVAS_ERR_INVALID_RENDER_CONFIG; +} + + +/*-------------------------------------------------------------------* + * usdequant_rend_cfg() + * + * Uniform scalar de-quantizer routine + *-------------------------------------------------------------------*/ + +static float usdequant_rend_cfg( + const uint32_t idx, /* i : quantizer index */ + const float qlow, /* i : lowest codebook entry (index 0) */ + const float delta /* i : quantization step */ +) +{ + float g; + + g = idx * delta + qlow; + + return ( g ); +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_angle() + * Gets an angle value in degrees [0,360] + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_angle( + RenderConfigReader *this, /* i/o : Render config reader handle */ + float *pResult /* o : Angle value */ +) +{ + ivas_error error; + uint32_t value; + + if ( ( error = read_bin_bits( this, &value, 5 ) ) != IVAS_ERR_OK ) + { + return error; + } + + *pResult = usdequant_rend_cfg( value, 0.0f, 20.0f ); + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_outer_attenuation () + * Gets an outer attenuation value [3.1623e-05,1.0], or in dB: [-90,0] + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_outer_attenuation( + RenderConfigReader *this, /* i/o : Render config reader handle */ + float *pResult /* o : Attenuation value */ +) +{ + ivas_error error; + uint32_t value; + float logval, att; + + if ( ( error = read_bin_bits( this, &value, 5 ) ) != IVAS_ERR_OK ) + { + return error; + } + + logval = usdequant_rend_cfg( value, -90.0f, 3.0f ); + att = powf( 10, logval / 20.0f ); + + *pResult = att; + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_max_dist () + * Gets a Maximum Distance value [1.0, 64.0] + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_max_dist( + RenderConfigReader *this, /* i/o : Render config reader handle */ + float *pResult /* o : Attenuation value */ +) +{ + ivas_error error; + uint32_t value; + + if ( ( error = read_bin_bits( this, &value, 6 ) ) != IVAS_ERR_OK ) + { + return error; + } + + *pResult = usdequant_rend_cfg( value, 1.0f, 1.0f ); + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_ref_dist () + * Gets a Reference Distance value [0.1, 6.4] + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_ref_dist( + RenderConfigReader *this, /* i/o : Render config reader handle */ + float *pResult /* o : Attenuation value */ +) +{ + ivas_error error; + uint32_t value; + + if ( ( error = read_bin_bits( this, &value, 6 ) ) != IVAS_ERR_OK ) + { + return error; + } + + *pResult = usdequant_rend_cfg( value, 0.1f, 0.1f ); + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function get_bin_rolloff () + * Gets a Rollof Factor [0.0, 4.0] + *-----------------------------------------------------------------------------------------*/ + +static ivas_error get_bin_rolloff( + RenderConfigReader *this, /* i/o : Render config reader handle */ + float *pResult /* o : Attenuation value */ +) +{ + ivas_error error; + uint32_t value; + + if ( ( error = read_bin_bits( this, &value, 6 ) ) != IVAS_ERR_OK ) + { + return error; + } + + *pResult = usdequant_rend_cfg( value, 0.0f, 0.1f ); + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------------------------* + * Function read_txt_vector() + * + * Reads a vector value from a line + *-----------------------------------------------------------------------------------------*/ + +static int16_t read_txt_vector( + char *pLine, /* i : String to read from */ + const uint32_t length, /* i : Number of expected vector elements */ + float *pTarget /* o : Output vector pointer */ +) +{ + char *tmp; + uint16_t n; + uint16_t count; + + n = (int16_t) sscanf( pLine, "[%s", pLine ); + if ( n == 0 ) + { + return true; + } + + /* Additional comma to make parsing easier */ + pLine[strlen( pLine ) - 1] = ','; + + tmp = pLine; + /* Count # of commas to determine vector length */ + for ( n = 0; tmp[n]; tmp[n] == ',' ? n++ : *tmp++ ) + ; + + count = n; + + tmp = pLine; + + /* Check for maximum vector length */ + if ( n != length ) + { + return true; + } + + for ( n = 0; n < count; n++ ) + { + if ( (int16_t) sscanf( tmp, "%f,", &pTarget[n] ) != 1 ) + { + return true; + } + + tmp = strchr( tmp, ',' ) + 1; + } + + return false; +} + + +/*-----------------------------------------------------------------------------------------* + * Function strip_spaces() + * + * Strips the spaces from a buffer + *-----------------------------------------------------------------------------------------*/ + +static void strip_spaces( + char *pStr /* i : String to read from */ +) +{ + int32_t read_idx = 0, write_idx = 0; + + while ( pStr[read_idx] ) + { + if ( !isspace( (int32_t) pStr[read_idx] ) && !iscntrl( (int32_t) pStr[read_idx] ) ) + { + pStr[write_idx++] = pStr[read_idx]; + } + read_idx++; + } + pStr[write_idx] = '\0'; + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function errorHandler() + * + * Prints error message and exits + *-----------------------------------------------------------------------------------------*/ + +/*! r: error accumulation */ +static int32_t errorHandler( + const char *badStr, /* i : String to complain about */ + const ERROR_CODES_t error ) +{ + static int32_t numErrors = 0; + + switch ( error ) + { + case ERROR_NONE: + break; + case ERROR_ITEM_UNKNOWN: + numErrors++; + fprintf( stderr, "Unknown variable %s in renderer configuration file.\n\n", badStr ); + break; + case ERROR_VALUE_INVALID: + numErrors++; + fprintf( stderr, "Invalid value %s in renderer configuration file.\n\n", badStr ); + break; + default: + numErrors++; + fprintf( stderr, "Unknown error while reading configuration file.\n\n" ); + } + + return numErrors; +} + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_checkValues() + * + * Verifies if the configuration parameters lie within acceptable limits + *------------------------------------------------------------------------------------------*/ +ivas_error RenderConfigReader_checkValues( + IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ +) +{ + int16_t band_idx, tab_value_err_count; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; + pRoom_acoustics = &hRenderConfig->roomAcoustics; + tab_value_err_count = 0; + int16_t wall_idx; +#ifndef FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK + int16_t i; +#endif + + /* Verify the number of frequency bands in the config input data */ + if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + /* Verify data per band in the acoustic properties table */ + for ( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ ) + { + /* Verify if the frequencies are in the ascending order (required for interpolation) */ + if ( band_idx != 0 ) + { + if ( pRoom_acoustics->pFc_input_fx[band_idx] <= pRoom_acoustics->pFc_input_fx[band_idx - 1] ) + { + tab_value_err_count++; + } + } + + /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */ + if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] == 0 ) + { + pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; + } + } + + if ( tab_value_err_count != 0 ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + + if ( pRoom_acoustics->use_er == 1 ) + { + /* Room dimensions */ + if ( pRoom_acoustics->dimensions.x < ER_MIN_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.x = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.x_fx < ER_MIN_ROOM_DIMENSION_FX ) + { + pRoom_acoustics->dimensions.x_fx = ER_MIN_ROOM_DIMENSION_FX; + } + if ( pRoom_acoustics->dimensions.x > ER_MAX_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.x = ER_MAX_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.x_fx > ER_MAX_ROOM_DIMENSION_FX ) + { + pRoom_acoustics->dimensions.x_fx = ER_MAX_ROOM_DIMENSION_FX; + } + if ( pRoom_acoustics->dimensions.y < ER_MIN_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.y = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.y_fx < ER_MIN_ROOM_DIMENSION_FX ) + { + pRoom_acoustics->dimensions.y_fx = ER_MIN_ROOM_DIMENSION_FX; + } + if ( pRoom_acoustics->dimensions.y > ER_MAX_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.y = ER_MAX_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.y_fx > ER_MAX_ROOM_DIMENSION_FX ) + { + pRoom_acoustics->dimensions.y_fx = ER_MAX_ROOM_DIMENSION_FX; + } + if ( pRoom_acoustics->dimensions.z < ER_MIN_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.z = ER_MIN_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.z_fx < ER_MIN_ROOM_DIMENSION_FX ) + { + pRoom_acoustics->dimensions.z_fx = ER_MIN_ROOM_DIMENSION_FX; + } + if ( pRoom_acoustics->dimensions.z > ER_MAX_ROOM_DIMENSION ) + { + pRoom_acoustics->dimensions.z = ER_MAX_ROOM_DIMENSION; + } + if ( pRoom_acoustics->dimensions.z_fx > ER_MAX_ROOM_DIMENSION_FX ) + { + pRoom_acoustics->dimensions.z_fx = ER_MAX_ROOM_DIMENSION_FX; + } + + /* Abs Coeff */ + for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) + { + if ( pRoom_acoustics->AbsCoeff[wall_idx] < ER_MIN_ABS_COEFF ) + { + pRoom_acoustics->AbsCoeff[wall_idx] = ER_MIN_ABS_COEFF; + } + if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] < ER_MIN_ABS_COEFF_FX ) + { + pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MIN_ABS_COEFF_FX; + } + if ( pRoom_acoustics->AbsCoeff[wall_idx] > ER_MAX_ABS_COEFF ) + { + pRoom_acoustics->AbsCoeff[wall_idx] = ER_MAX_ABS_COEFF; + } + if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] > ER_MAX_ABS_COEFF_FX ) + { + pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX; + } + } +#ifndef FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK + /* Verify range of distance attenuation parameters: 0.1 <= distAtt[0] <= distAtt[1] */ + /* 0.0 <= distAtt[2] <= 10.0 */ + hRenderConfig->distAtt[0] = max( 0.1f, hRenderConfig->distAtt[0] ); + hRenderConfig->distAtt[1] = max( hRenderConfig->distAtt[0], hRenderConfig->distAtt[1] ); + hRenderConfig->distAtt[2] = max( 0.0f, min( 10.0f, hRenderConfig->distAtt[2] ) ); + + /* Verify range of directivity patterns */ + for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) + { + hRenderConfig->directivity[i * 3] = max( 0.0f, min( 360.0f, hRenderConfig->directivity[i * 3] ) ); + hRenderConfig->directivity[i * 3 + 1] = max( 0.0f, min( 360.0f, hRenderConfig->directivity[i * 3 + 1] ) ); + hRenderConfig->directivity[i * 3 + 2] = max( 0.0f, min( 1.0f, hRenderConfig->directivity[i * 3 + 2] ) ); + } +#endif + } + + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_open() + * + * Allocates and initializes a renderer configuration reader instance + *------------------------------------------------------------------------------------------*/ + +ivas_error RenderConfigReader_open( + char *pConfigPath, /* i : renderer configuration file path */ + RenderConfigReader **ppRenderConfigReader /* o : RenderConfigReader handle */ +) +{ + RenderConfigReader *pSelf; + FILE *pConfigFile; + + /* Open the configuration file */ + if ( strlen( pConfigPath ) < 1 ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + pConfigFile = fopen( pConfigPath, "r" ); + + if ( !pConfigFile ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + pSelf = calloc( 1, sizeof( RenderConfigReader ) ); + pSelf->pConfigFile = pConfigFile; + pSelf->nFG = 0; + pSelf->pFG = NULL; + pSelf->nAE = 0; + pSelf->pAE = NULL; + pSelf->nDP = 0; + pSelf->pDP = NULL; + pSelf->distAtt[0] = -1; + + *ppRenderConfigReader = pSelf; + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_readBinary() + * + * Reads the binary configuration from a file + *------------------------------------------------------------------------------------------*/ + +static ivas_error RenderConfigReader_readBinary( + const char *pReverbConfigPath, /* i : Configuration file path */ + RenderConfigReader *pRenderConfigReader /* i/o: RenderConfigReader handle */ +) +{ + uint32_t file_size; + uint32_t value; + uint32_t signx, signy, k; + uint32_t i, m, n; + uint32_t nFG, nAE; + uint32_t nDP; + ivas_error error; + float freqHop; + uint32_t gridLen; + uint32_t subGridLen; + const float *pGrid; + FILE *pReverbConfigFile; + + /* Open the configuration file */ + pReverbConfigFile = fopen( pReverbConfigPath, "rb" ); + + if ( !pReverbConfigFile ) + { + return IVAS_ERR_FAILED_FILE_OPEN; + } + + /* Read the bitstream */ + fseek( pReverbConfigFile, 0, SEEK_END ); + file_size = ftell( pReverbConfigFile ); + rewind( pReverbConfigFile ); + + pRenderConfigReader->pBitstream = (uint8_t *) malloc( file_size * sizeof( uint8_t ) ); + if ( pRenderConfigReader->pBitstream == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + fread( pRenderConfigReader->pBitstream, sizeof( uint8_t ), file_size, pReverbConfigFile ); + pRenderConfigReader->length = file_size; + /* we read the config twice in the decoder, so reset the read offset here */ + pRenderConfigReader->readOffset = 0; + + /****************************/ + /* Read the presence flag */ + /****************************/ + if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + /* acoustic environment data available */ + if ( value == true ) + { + /****************************/ + /* Read the frequency grids */ + /****************************/ + + /* Number of frequency grids */ + if ( ( error = get_bin_count_or_index( pRenderConfigReader, &nFG ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Allocate memory for the frequency grids */ + if ( nFG > 0 ) + { + if ( pRenderConfigReader->nFG > 0 ) + { + for ( n = 0; n < pRenderConfigReader->nFG; n++ ) + { + free( pRenderConfigReader->pFG[n].pFc ); + } + free( pRenderConfigReader->pFG ); + } + pRenderConfigReader->nFG = nFG; + if ( ( pRenderConfigReader->pFG = (FrequencyGrid *) malloc( pRenderConfigReader->nFG * sizeof( FrequencyGrid ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + for ( n = 0; n < nFG; n++ ) + { + /* Initialize memory pointers to allow safe freeing ico errors */ + pRenderConfigReader->pFG[n].pFc = NULL; + } + } + + /* Loop through the frequency grids read from the binary stream */ + for ( n = 0; n < nFG; n++ ) + { + /* Read the representation method */ + value = 0; + if ( ( error = read_bin_bits( pRenderConfigReader, &value, 2 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Process depending on the representation method */ + switch ( value ) + { + case FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES: + if ( ( error = get_bin_count_or_index( pRenderConfigReader, &pRenderConfigReader->pFG[n].nrBands ) ) != IVAS_ERR_OK ) + { + return error; + } + /* Allocate memory for the center frequency array */ + if ( ( pRenderConfigReader->pFG[n].pFc = (float *) malloc( pRenderConfigReader->pFG[n].nrBands * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + /* Read the individual frequencies */ + for ( m = 0; m < pRenderConfigReader->pFG[n].nrBands; m++ ) + { + if ( ( error = get_bin_frequency( pRenderConfigReader, &pRenderConfigReader->pFG[n].pFc[m] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + break; + case FREQ_GRID_MODE_START_HOP_AMOUNT: + if ( ( error = get_bin_count_or_index( pRenderConfigReader, &pRenderConfigReader->pFG[n].nrBands ) ) != IVAS_ERR_OK ) + { + return error; + } + /* Allocate memory for the center frequency array */ + if ( ( pRenderConfigReader->pFG[n].pFc = (float *) malloc( pRenderConfigReader->pFG[n].nrBands * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + /* Read the first frequency */ + if ( ( error = get_bin_frequency( pRenderConfigReader, &pRenderConfigReader->pFG[n].pFc[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + /* Read frequency hop from LUT */ + if ( ( error = read_bin_code_word( pRenderConfigReader, RC_LUT_FREQ_HOP, &freqHop ) ) != IVAS_ERR_OK ) + { + return error; + } + /* Fill up the center frequency array */ + for ( m = 1; m < pRenderConfigReader->pFG[n].nrBands; m++ ) + { + pRenderConfigReader->pFG[n].pFc[m] = pRenderConfigReader->pFG[n].pFc[m - 1] * freqHop; + } + break; + case FREQ_GRID_MODE_DEFAULT_BANDING: + /* Read the default grid ID */ + value = 0; + if ( ( error = read_bin_bits( pRenderConfigReader, &value, 4 ) ) != IVAS_ERR_OK ) + { + return error; + } + switch ( value ) + { + case 0: + gridLen = sizeof( defaultFrequencyGrid_0 ) / sizeof( defaultFrequencyGrid_0[0] ); + pGrid = defaultFrequencyGrid_0; + break; + case 1: + gridLen = sizeof( defaultFrequencyGrid_1 ) / sizeof( defaultFrequencyGrid_1[0] ); + pGrid = defaultFrequencyGrid_1; + break; + case 2: + gridLen = sizeof( defaultFrequencyGrid_2 ) / sizeof( defaultFrequencyGrid_2[0] ); + pGrid = defaultFrequencyGrid_2; + break; + case 3: + gridLen = sizeof( defaultFrequencyGrid_3 ) / sizeof( defaultFrequencyGrid_3[0] ); + pGrid = defaultFrequencyGrid_3; + break; + case 4: + gridLen = sizeof( defaultFrequencyGrid_4 ) / sizeof( defaultFrequencyGrid_4[0] ); + pGrid = defaultFrequencyGrid_4; + break; + case 5: + gridLen = sizeof( defaultFrequencyGrid_5 ) / sizeof( defaultFrequencyGrid_5[0] ); + pGrid = defaultFrequencyGrid_5; + break; + case 6: + gridLen = sizeof( defaultFrequencyGrid_6 ) / sizeof( defaultFrequencyGrid_6[0] ); + pGrid = defaultFrequencyGrid_6; + break; + case 7: + gridLen = sizeof( defaultFrequencyGrid_7 ) / sizeof( defaultFrequencyGrid_7[0] ); + pGrid = defaultFrequencyGrid_7; + break; + case 8: + gridLen = sizeof( defaultFrequencyGrid_8 ) / sizeof( defaultFrequencyGrid_8[0] ); + pGrid = defaultFrequencyGrid_8; + break; + default: + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + m = 0; + /* Read sub-grid flag */ + if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( value != false ) + { + /* Read the sub-grid offset */ + if ( ( error = read_bin_bits( pRenderConfigReader, &m, 3 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Read the sub-grid length */ + subGridLen = 0; + if ( ( error = read_bin_bits( pRenderConfigReader, &subGridLen, 6 ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( m + subGridLen > gridLen ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + gridLen = subGridLen; + } + pRenderConfigReader->pFG[n].nrBands = gridLen; + /* Allocate memory for the center frequency array */ + if ( ( pRenderConfigReader->pFG[n].pFc = (float *) malloc( gridLen * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + /* Copy the ROM content to the frequency grid*/ + for ( i = 0; i < gridLen; i++ ) + { + pRenderConfigReader->pFG[n].pFc[i] = pGrid[m + i]; + } + + break; + default: + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + /* Initialize memory pointers to allow safe freeing ico errors */ + pRenderConfigReader->pFG[n].pFc = NULL; + } + + /**********************************/ + /* Read the acoustic environments */ + /**********************************/ + + /* Number of acoustic environments */ + if ( ( error = get_bin_count_or_index( pRenderConfigReader, &nAE ) ) != IVAS_ERR_OK ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + /* Allocate memory for the acoustic environments array */ + if ( nAE > 0 ) + { + if ( pRenderConfigReader->nAE > 0 ) + { + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) + { + free( pRenderConfigReader->pAE[n].pRT60 ); + free( pRenderConfigReader->pAE[n].pDSR ); + if ( pRenderConfigReader->pAE[n].pEarlyReflections != NULL ) + { + free( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin ); + free( pRenderConfigReader->pAE[n].pEarlyReflections ); + } + } + free( pRenderConfigReader->pAE ); + } + pRenderConfigReader->nAE = nAE; + + if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + /* Initialize memory pointers to allow safe freeing ico errors */ + for ( n = 0; n < nAE; n++ ) + { + pRenderConfigReader->pAE[n].pRT60 = NULL; + pRenderConfigReader->pAE[n].pDSR = NULL; + pRenderConfigReader->pAE[n].pEarlyReflections = NULL; + } + } + + /* Loop through the acoustic environments from the binary stream */ + for ( n = 0; n < nAE; n++ ) + { + /* Read the AE ID */ + if ( ( error = get_bin_id( pRenderConfigReader, &pRenderConfigReader->pAE[n].id ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Read the frequency grid ID */ + if ( ( error = get_bin_count_or_index( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Associate the frequency grid */ + if ( value >= pRenderConfigReader->nFG ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + pRenderConfigReader->pAE[n].pFG = &( pRenderConfigReader->pFG[value] ); + + /* Allocate memory for RT60 and DSR arrays */ + if ( ( pRenderConfigReader->pAE[n].pRT60 = (float *) malloc( pRenderConfigReader->pAE[n].pFG->nrBands * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + if ( ( pRenderConfigReader->pAE[n].pDSR = (float *) malloc( pRenderConfigReader->pAE[n].pFG->nrBands * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + /* Read the values */ + if ( ( error = get_bin_duration( pRenderConfigReader, &pRenderConfigReader->pAE[n].preDelay ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( m = 0; m < pRenderConfigReader->pAE[n].pFG->nrBands; m++ ) + { + if ( ( error = get_bin_duration( pRenderConfigReader, &pRenderConfigReader->pAE[n].pRT60[m] ) ) != IVAS_ERR_OK ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + for ( m = 0; m < pRenderConfigReader->pAE[n].pFG->nrBands; m++ ) + { + if ( ( error = get_bin_dsr( pRenderConfigReader, &pRenderConfigReader->pAE[n].pDSR[m] ) ) != IVAS_ERR_OK ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + + /*****************************************/ + /* Read the early reflections parameters */ + /*****************************************/ + + /* Has early reflections */ + if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( value == true ) + { + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections = (EarlyReflectionsConfig *) malloc( sizeof( EarlyReflectionsConfig ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + /* Initialize memory pointers to allow safe freeing ico eg errors */ + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = NULL; + + pRenderConfigReader->pAE[n].pEarlyReflections->use_er = 1; + + /* Room sizes */ + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( k = 0; k < N_ABS_COEFFS; k++ ) + { + if ( ( error = get_bin_absorption( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[k] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* Has listener origin */ + if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( value == true ) + { + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + if ( ( error = read_bin_bits( pRenderConfigReader, &signx, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = read_bin_bits( pRenderConfigReader, &signy, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( signx == 0 ) + { + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x *= -1.0f; + } + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( signy == 0 ) + { + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y *= -1.0f; + } + if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else /* load defaults if origin is not specified in config */ + { + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = IVAS_ER_LIST_ORIGIN_X; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = IVAS_ER_LIST_ORIGIN_Y; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = IVAS_ER_LIST_HEIGHT; + } + + /* Low complexity mode */ + if ( ( error = read_bin_bool( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + } + /**********************************/ + /* Read the directivity patterns */ + /**********************************/ + + /* Has source directivity */ + if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( value == true ) + { + + /* Number of directivity patterns */ + if ( ( error = get_bin_id( pRenderConfigReader, &nDP ) ) != IVAS_ERR_OK ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + if ( nDP > 0 ) + { + if ( pRenderConfigReader->nDP > 0 ) + { + for ( n = 0; n < pRenderConfigReader->nDP; n++ ) + { + free( pRenderConfigReader->pDP[n].pDirectivity ); + } + free( pRenderConfigReader->pDP ); + } + + pRenderConfigReader->nDP = nDP; + + if ( ( pRenderConfigReader->pDP = (DirectrivityPat *) malloc( pRenderConfigReader->nDP * sizeof( DirectrivityPat ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + for ( n = 0; n < nDP; n++ ) + { + /* Allocate memory for directivity arrays*/ + if ( ( pRenderConfigReader->pDP[n].pDirectivity = (float *) malloc( 3 * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + } + } + /* Loop through the directivity patterns from the binary stream */ + for ( n = 0; n < nDP; n++ ) + { + + /* Read the Directivity ID */ + if ( ( error = get_bin_id( pRenderConfigReader, &pRenderConfigReader->pDP[n].id ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = get_bin_angle( pRenderConfigReader, &pRenderConfigReader->pDP[n].pDirectivity[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = get_bin_angle( pRenderConfigReader, &pRenderConfigReader->pDP[n].pDirectivity[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = get_bin_outer_attenuation( pRenderConfigReader, &pRenderConfigReader->pDP[n].pDirectivity[2] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + /**********************************/ + /* Read the distance attenuation */ + /**********************************/ + + /* Has distance attenuation */ + if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( value == true ) + { + /* Read the Max Distance */ + if ( ( error = get_bin_max_dist( pRenderConfigReader, &pRenderConfigReader->distAtt[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + /* Read the Ref Distance */ + if ( ( error = get_bin_ref_dist( pRenderConfigReader, &pRenderConfigReader->distAtt[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + /* Read the Rolloff Facto r*/ + if ( ( error = get_bin_rolloff( pRenderConfigReader, &pRenderConfigReader->distAtt[2] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + + /* Cleanup */ + free( pRenderConfigReader->pBitstream ); + + return IVAS_ERR_OK; +} + + +ivas_error RenderConfigReader_read( + RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ + const char *pRenderConfigPath, /* i : Renderer configuration file path */ + IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ +) +{ + int32_t file_size; + char *pConfig_str; + char *pParams; + char *pTemp; + int32_t read_idx; + int32_t params_idx; + char item[MAX_ITEM_LENGTH + 1]; + char chapter[MAX_ITEM_LENGTH + 1]; + char *pValue; + ivas_error error; + int32_t params_length; + int32_t length; + uint32_t i, idx; + uint32_t nFG, nAE; + char *pToken; + FREQ_GRID_MODE fgMode; + float freqHop; + uint32_t acIdx; + uint32_t defGridId, defGridLen, defGridOffset, defGridNrBands; + const float *pDefGrid; + float erTemp[N_ABS_COEFFS]; + uint32_t roomAcHasFgCount, roomAcHasAcEnvCount; + uint32_t fgHasMethod, fgHasNBands, fgHasFreqs, fgHasDefaultGrid, fgHasStartFreq, fgHasFreqHop; + uint32_t aeHasFgIdx, aeHasPredelay, aeHasRt60, aeHasDsr; + uint32_t aeHasERsize, aeHasERabs; + bool dofProvided = false; + bool poseCorrProvided = false; + + uint32_t nDP; + uint32_t accDPIdx; + accDPIdx = 0; + + fseek( pRenderConfigReader->pConfigFile, 0, SEEK_END ); + file_size = ftell( pRenderConfigReader->pConfigFile ); + rewind( pRenderConfigReader->pConfigFile ); + pConfig_str = (char *) calloc( file_size + 1, sizeof( char ) ); + pParams = (char *) calloc( file_size + 1, sizeof( char ) ); + pTemp = (char *) calloc( file_size + 1, sizeof( char ) ); + acIdx = 0; + roomAcHasFgCount = roomAcHasAcEnvCount = FALSE; + setvbuf( pRenderConfigReader->pConfigFile, pConfig_str, _IONBF, sizeof( char ) ); /* Work-around for VS bug that gives incorrect ftell for UNIX-style line endings */ + + /* read file line by line */ + while ( fgets( pConfig_str, file_size, pRenderConfigReader->pConfigFile ) != NULL ) + { + + if ( sscanf( pConfig_str, "[%64[^]]]", chapter ) == 1 ) + { + /* read line by line (except comments) until next chapter or EOF */ + pParams[0] = '\0'; + do + { + read_idx = ftell( pRenderConfigReader->pConfigFile ); + if ( fgets( pTemp, file_size, pRenderConfigReader->pConfigFile ) == NULL ) + { + break; + } + + if ( ( pTemp[0] != '#' ) && ( sscanf( pTemp, "[%64[^]]]", item ) != 1 ) ) + { + /* ignore inline comments */ + sscanf( pTemp, "%[^#]", pTemp ); + strcat( pParams, pTemp ); + } + } while ( sscanf( pTemp, "[%64[^]]]", item ) != 1 ); + + /* go back one line */ + fseek( pRenderConfigReader->pConfigFile, read_idx, SEEK_SET ); + + strip_spaces( pParams ); + strcpy( pTemp, pParams ); + to_upper( pParams ); + to_upper( chapter ); + + /* interpret params */ + pToken = strtok( chapter, ":" ); + if ( strcmp( chapter, "ROOMACOUSTICS" ) == 0 && strlen( pParams ) != 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + if ( strcmp( item, "FREQUENCYGRIDCOUNT" ) == 0 ) + { + /* Read the number of frequency grids */ + if ( !sscanf( pValue, "%u", &nFG ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( nFG > 0 ) + { + for ( idx = 0; idx < pRenderConfigReader->nFG; idx++ ) + { + free( pRenderConfigReader->pFG[idx].pFc ); + } + free( pRenderConfigReader->pFG ); + + pRenderConfigReader->nFG = nFG; + + /* Allocate memory for the frequency grids */ + if ( ( pRenderConfigReader->pFG = (FrequencyGrid *) malloc( pRenderConfigReader->nFG * sizeof( FrequencyGrid ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + for ( idx = 0; idx < nFG; idx++ ) + { + pRenderConfigReader->pFG[idx].nrBands = 0; + pRenderConfigReader->pFG[idx].pFc = NULL; + } + } + roomAcHasFgCount = TRUE; + } + else if ( strcmp( item, "ACOUSTICENVIRONMENTCOUNT" ) == 0 ) + { + /* Read the number of acoustic environments */ + if ( !sscanf( pValue, "%u", &nAE ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( nAE > 0 ) + { + for ( idx = 0; idx < pRenderConfigReader->nAE; idx++ ) + { + free( pRenderConfigReader->pAE[idx].pRT60 ); + free( pRenderConfigReader->pAE[idx].pDSR ); + if ( pRenderConfigReader->pAE[idx].pEarlyReflections != NULL ) + { + free( pRenderConfigReader->pAE[idx].pEarlyReflections->pListenerOrigin ); + free( pRenderConfigReader->pAE[idx].pEarlyReflections ); + } + } + free( pRenderConfigReader->pAE ); + + pRenderConfigReader->nAE = nAE; + + /* Allocate memory for the acoustic environments array */ + if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + /* Initialize memory pointers to allow for safe freeing */ + for ( acIdx = 0; acIdx < pRenderConfigReader->nAE; acIdx++ ) + { + pRenderConfigReader->pAE[acIdx].pRT60 = NULL; + pRenderConfigReader->pAE[acIdx].pDSR = NULL; + pRenderConfigReader->pAE[acIdx].pEarlyReflections = NULL; + } + } + acIdx = 0; + roomAcHasAcEnvCount = TRUE; + } + } + if ( roomAcHasFgCount == FALSE || roomAcHasAcEnvCount == FALSE ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + free( pValue ); + } + else if ( strcmp( pToken, "FREQUENCYGRID" ) == 0 ) + { + if ( pRenderConfigReader->pFG == NULL ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + idx = strtol( strtok( NULL, ":" ), NULL, 0 ); + if ( idx >= pRenderConfigReader->nFG ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + fgHasMethod = fgHasNBands = fgHasFreqs = fgHasDefaultGrid = fgHasStartFreq = fgHasFreqHop = FALSE; + fgMode = FREQ_GRID_MODE_UNKNOWN; + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + if ( strcmp( item, "METHOD" ) == 0 ) + { + if ( strcmp( pValue, "INDIVIDUALFREQUENCIES" ) == 0 ) + { + fgMode = FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES; + } + else if ( strcmp( pValue, "STARTHOPAMOUNT" ) == 0 ) + { + fgMode = FREQ_GRID_MODE_START_HOP_AMOUNT; + } + else if ( strcmp( pValue, "DEFAULTBANDING" ) == 0 ) + { + fgMode = FREQ_GRID_MODE_DEFAULT_BANDING; + } + fgHasMethod = TRUE; + } + /* Read number of bands for individual frequency, start-hop-amount mode */ + else if ( strcmp( item, "NRBANDS" ) == 0 ) + { + if ( fgMode != FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES && fgMode != FREQ_GRID_MODE_START_HOP_AMOUNT ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( !sscanf( pValue, "%u", &pRenderConfigReader->pFG[idx].nrBands ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + /* Allocate memory for the center frequency array */ + if ( ( pRenderConfigReader->pFG[idx].pFc = (float *) malloc( pRenderConfigReader->pFG[idx].nrBands * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + fgHasNBands = TRUE; + } + else if ( strcmp( item, "FREQUENCIES" ) == 0 ) + { + if ( fgMode != FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES || pRenderConfigReader->pFG[idx].nrBands == 0 || pRenderConfigReader->pFG[idx].pFc == NULL ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + /* Read the individual frequencies */ + if ( read_txt_vector( pValue, pRenderConfigReader->pFG[idx].nrBands, pRenderConfigReader->pFG[idx].pFc ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + fgHasFreqs = TRUE; + } + else if ( strcmp( item, "STARTFREQUENCY" ) == 0 ) + { + if ( fgMode != FREQ_GRID_MODE_START_HOP_AMOUNT || pRenderConfigReader->pFG[idx].nrBands == 0 || pRenderConfigReader->pFG[idx].pFc == NULL ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( !sscanf( pValue, "%f", &pRenderConfigReader->pFG[idx].pFc[0] ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + fgHasStartFreq = TRUE; + } + else if ( strcmp( item, "FREQUENCYHOP" ) == 0 ) + { + if ( fgMode != FREQ_GRID_MODE_START_HOP_AMOUNT || pRenderConfigReader->pFG[idx].nrBands == 0 || pRenderConfigReader->pFG[idx].pFc == NULL || pRenderConfigReader->pFG[idx].pFc[0] == 0.0f ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( !sscanf( pValue, "%f", &freqHop ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + /* Fill up the center frequency array */ + for ( i = 1; i < pRenderConfigReader->pFG[idx].nrBands; i++ ) + { + pRenderConfigReader->pFG[idx].pFc[i] = pRenderConfigReader->pFG[idx].pFc[i - 1] * freqHop; + } + fgHasFreqHop = TRUE; + } + /* Handle default grids, with optional sub-grids */ + else if ( strcmp( item, "DEFAULTGRID" ) == 0 ) + { + if ( !sscanf( pValue, "%u", &defGridId ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + switch ( defGridId ) + { + case 0: + defGridLen = sizeof( defaultFrequencyGrid_0 ) / sizeof( defaultFrequencyGrid_0[0] ); + pDefGrid = defaultFrequencyGrid_0; + break; + case 1: + defGridLen = sizeof( defaultFrequencyGrid_1 ) / sizeof( defaultFrequencyGrid_1[0] ); + pDefGrid = defaultFrequencyGrid_1; + break; + case 2: + defGridLen = sizeof( defaultFrequencyGrid_2 ) / sizeof( defaultFrequencyGrid_2[0] ); + pDefGrid = defaultFrequencyGrid_2; + break; + case 3: + defGridLen = sizeof( defaultFrequencyGrid_3 ) / sizeof( defaultFrequencyGrid_3[0] ); + pDefGrid = defaultFrequencyGrid_3; + break; + case 4: + defGridLen = sizeof( defaultFrequencyGrid_4 ) / sizeof( defaultFrequencyGrid_4[0] ); + pDefGrid = defaultFrequencyGrid_4; + break; + case 5: + defGridLen = sizeof( defaultFrequencyGrid_5 ) / sizeof( defaultFrequencyGrid_5[0] ); + pDefGrid = defaultFrequencyGrid_5; + break; + case 6: + defGridLen = sizeof( defaultFrequencyGrid_6 ) / sizeof( defaultFrequencyGrid_6[0] ); + pDefGrid = defaultFrequencyGrid_6; + break; + case 7: + defGridLen = sizeof( defaultFrequencyGrid_7 ) / sizeof( defaultFrequencyGrid_7[0] ); + pDefGrid = defaultFrequencyGrid_7; + break; + case 8: + defGridLen = sizeof( defaultFrequencyGrid_8 ) / sizeof( defaultFrequencyGrid_8[0] ); + pDefGrid = defaultFrequencyGrid_8; + break; + default: + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + fgHasDefaultGrid = TRUE; + + /* Handle sub-grids */ + defGridOffset = 0; + defGridNrBands = defGridLen; + + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + if ( strcmp( item, "DEFAULTGRIDOFFSET" ) == 0 ) + { + if ( !sscanf( pValue, "%u", &defGridOffset ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + else if ( strcmp( item, "DEFAULTGRIDNRBANDS" ) == 0 ) + { + if ( !sscanf( pValue, "%u", &defGridNrBands ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + else + { + break; + } + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + } + + if ( defGridOffset + defGridNrBands > defGridLen ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + pRenderConfigReader->pFG[idx].nrBands = defGridNrBands; + + /* Allocate memory for the center frequency array */ + if ( ( pRenderConfigReader->pFG[idx].pFc = (float *) malloc( defGridNrBands * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + /* Copy the ROM content to the frequency grid*/ + for ( i = 0; i < defGridNrBands; i++ ) + { + pRenderConfigReader->pFG[idx].pFc[i] = pDefGrid[defGridOffset + i]; + } + } + } + if ( fgHasMethod == FALSE || + ( fgMode == FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES && ( fgHasFreqs == FALSE || fgHasNBands == FALSE ) ) || + ( fgMode == FREQ_GRID_MODE_DEFAULT_BANDING && fgHasDefaultGrid == FALSE ) || + ( fgMode == FREQ_GRID_MODE_START_HOP_AMOUNT && ( fgHasStartFreq == FALSE || fgHasFreqHop == FALSE || fgHasNBands == FALSE ) ) ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + free( pValue ); + } + /* Handle multiple acoustic environments */ + else if ( strcmp( pToken, "ACOUSTICENVIRONMENT" ) == 0 ) + { + if ( pRenderConfigReader->pAE == NULL || acIdx >= pRenderConfigReader->nAE ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + idx = strtol( strtok( NULL, ":" ), NULL, 0 ); + pRenderConfigReader->pAE[acIdx].id = idx; + + aeHasFgIdx = aeHasPredelay = aeHasRt60 = aeHasDsr = FALSE; + aeHasERsize = aeHasERabs = FALSE; + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + /* Frequency grid index */ + if ( strcmp( item, "FREQUENCYGRIDINDEX" ) == 0 ) + { + if ( !sscanf( pValue, "%u", &i ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( i >= pRenderConfigReader->nFG || pRenderConfigReader->pFG[i].pFc == NULL ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + pRenderConfigReader->pAE[acIdx].pFG = &pRenderConfigReader->pFG[i]; + + /* Allocate memory for RT60 and DSR arrays */ + if ( ( pRenderConfigReader->pAE[acIdx].pRT60 = (float *) malloc( pRenderConfigReader->pAE[acIdx].pFG->nrBands * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + if ( ( pRenderConfigReader->pAE[acIdx].pDSR = (float *) malloc( pRenderConfigReader->pAE[acIdx].pFG->nrBands * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + aeHasFgIdx = TRUE; + } + + /* Acoustic pre-delay */ + else if ( strcmp( item, "ACOUSTICPREDELAY" ) == 0 ) + { + float f; + if ( !sscanf( pValue, "%f", &f ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + hRenderConfig->roomAcoustics.acousticPreDelay_fx = (Word32) ( f * ONE_IN_Q27 ); + } + /* Pre-delay */ + else if ( strcmp( item, "PREDELAY" ) == 0 ) + { + if ( !sscanf( pValue, "%f", &pRenderConfigReader->pAE[acIdx].preDelay ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + aeHasPredelay = TRUE; + } + /* RT60 */ + else if ( strcmp( item, "RT60" ) == 0 ) + { + if ( read_txt_vector( pValue, pRenderConfigReader->pAE[acIdx].pFG->nrBands, pRenderConfigReader->pAE[acIdx].pRT60 ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + aeHasRt60 = TRUE; + } + /* DSR */ + else if ( strcmp( item, "DSR" ) == 0 ) + { + if ( read_txt_vector( pValue, pRenderConfigReader->pAE[acIdx].pFG->nrBands, pRenderConfigReader->pAE[acIdx].pDSR ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + aeHasDsr = TRUE; + } + else if ( strcmp( item, "EARLYREFLECTIONSSIZE" ) == 0 ) + { + if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) + { + if ( ( pRenderConfigReader->pAE[acIdx].pEarlyReflections = (EarlyReflectionsConfig *) malloc( sizeof( EarlyReflectionsConfig ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin = NULL; + pRenderConfigReader->pAE[acIdx].pEarlyReflections->lowComplexity = FALSE; + } + if ( strcmp( item, "EARLYREFLECTIONSSIZE" ) == 0 ) + { + if ( read_txt_vector( pValue, 3, erTemp ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + pRenderConfigReader->pAE[acIdx].pEarlyReflections->dimensions.x = erTemp[0]; + pRenderConfigReader->pAE[acIdx].pEarlyReflections->dimensions.y = erTemp[1]; + pRenderConfigReader->pAE[acIdx].pEarlyReflections->dimensions.z = erTemp[2]; + aeHasERsize = TRUE; + } + } + else if ( strcmp( item, "ABSORPTIONCOEFFS" ) == 0 ) + { + if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( read_txt_vector( pValue, N_ABS_COEFFS, erTemp ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + for ( i = 0; i < N_ABS_COEFFS; i++ ) + { + pRenderConfigReader->pAE[acIdx].pEarlyReflections->pAbsCoeff[i] = erTemp[i]; + } + aeHasERabs = TRUE; + } + else if ( strcmp( item, "LISTENERORIGIN" ) == 0 ) + { + if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( read_txt_vector( pValue, 3, erTemp ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( ( pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin->x = erTemp[0]; + pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin->y = erTemp[1]; + pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin->z = erTemp[2]; + } + else if ( strcmp( item, "LOWCOMPLEXITY" ) == 0 ) + { + if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( read_txt_bool( pValue, &pRenderConfigReader->pAE[acIdx].pEarlyReflections->lowComplexity ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + } + if ( aeHasFgIdx == FALSE || aeHasPredelay == FALSE || aeHasRt60 == FALSE || aeHasDsr == FALSE ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( aeHasERsize == TRUE && aeHasERabs == FALSE ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + else if ( aeHasERsize == TRUE && aeHasERabs == TRUE ) + { + pRenderConfigReader->pAE[acIdx].pEarlyReflections->use_er = 1; + } + + free( pValue ); + acIdx++; + } + else if ( strcmp( chapter, "SPLITREND" ) == 0 && strlen( pParams ) != 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + fprintf( stderr, " PARAM: %s -> %s\n", item, pValue ); +#endif + if ( strcmp( item, "CODECDELAY" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.codec_delay_ms ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "HQMODE" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.hq_mode ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "BITRATE" ) == 0 ) + { + if ( !sscanf( pValue, "%d", &hRenderConfig->split_rend_config.splitRendBitRate ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "DOF" ) == 0 ) + { + dofProvided = true; + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.dof ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + /* 0 DOF implies no pose correction */ + if ( hRenderConfig->split_rend_config.dof == 0 && !poseCorrProvided ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + } + } + else if ( strcmp( item, "CODEC" ) == 0 ) + { + if ( strcmp( pValue, "LCLD" ) == 0 ) + { + hRenderConfig->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_LCLD; + } + else if ( strcmp( pValue, "LC3PLUS" ) == 0 ) + { + hRenderConfig->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_LC3PLUS; + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "FRAMESIZE" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.codec_frame_size_ms ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + if ( hRenderConfig->split_rend_config.codec_frame_size_ms != 5 && + hRenderConfig->split_rend_config.codec_frame_size_ms != 10 && + hRenderConfig->split_rend_config.codec_frame_size_ms != 20 ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "POSECORRECTION" ) == 0 ) + { + poseCorrProvided = true; + if ( strcmp( pValue, "CLDFB" ) == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + } + else if ( strcmp( pValue, "NONE" ) == 0 ) + { + hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; + /* no pose correction implies 0 DOF */ + if ( !dofProvided ) + { + hRenderConfig->split_rend_config.dof = 0; + } + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "RENDERER" ) == 0 ) + { + if ( strcmp( pValue, "CREND" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_CREND; + } + else if ( strcmp( pValue, "FASTCONV" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_FASTCONV; + } + else if ( strcmp( pValue, "PARAMBIN" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_PARAMBIN; + } + else if ( strcmp( pValue, "TDREND" ) == 0 ) + { + hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_TDREND; + } + else + { + errorHandler( pValue, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "LC3PLUS_HIGHRES" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.lc3plus_highres ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } +#ifdef DEBUGGING + else + { + fprintf( stderr, "Unsupported configuration property %s\n", item ); + } +#endif + } + free( pValue ); + } + else if ( strcmp( chapter, "DIRECTIVITYSETTING" ) == 0 && strlen( pParams ) != 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + if ( strcmp( item, "DIRECTIVITYCOUNT" ) == 0 ) + { + /* Read the number of directivity chapters */ + if ( !sscanf( pValue, "%u", &nDP ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + if ( nDP > 0 ) + { + for ( idx = 0; idx < pRenderConfigReader->nDP; idx++ ) + { + free( pRenderConfigReader->pDP[idx].pDirectivity ); + } + + free( pRenderConfigReader->pDP ); + pRenderConfigReader->nDP = nDP; + + /* Allocate memory for the directivity pattern*/ + if ( ( pRenderConfigReader->pDP = (DirectrivityPat *) malloc( pRenderConfigReader->nDP * sizeof( DirectrivityPat ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + for ( idx = 0; idx < nDP; idx++ ) + { + pRenderConfigReader->pDP[idx].pDirectivity = NULL; + } + } + accDPIdx = 0; + } + } + free( pValue ); + } + else if ( strcmp( pToken, "DIRECTIVITYPATTERN" ) == 0 ) + { + if ( pRenderConfigReader->pDP == NULL || accDPIdx >= pRenderConfigReader->nDP ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + idx = strtol( strtok( NULL, ":" ), NULL, 0 ); + + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + /* Allocate memory for directivity arrays*/ + if ( ( pRenderConfigReader->pDP[accDPIdx].pDirectivity = (float *) malloc( 3 * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + + pRenderConfigReader->pDP[accDPIdx].id = idx; + + if ( strcmp( item, "DIRECTIVITY" ) == 0 ) + { + if ( read_txt_vector( pValue, 3, pRenderConfigReader->pDP[accDPIdx].pDirectivity ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + } + free( pValue ); + accDPIdx++; + } + else if ( strcmp( chapter, "DISTANCEATTENUATION" ) == 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + + /* Set default values if parameters are only partially specified */ + pRenderConfigReader->distAtt[0] = 15.75f; + pRenderConfigReader->distAtt[1] = 1.0f; + pRenderConfigReader->distAtt[2] = 1.0f; + + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + + if ( strcmp( item, "MAXDIST" ) == 0 ) + { + /* Read the Maximum distance */ + if ( !sscanf( pValue, "%f", &pRenderConfigReader->distAtt[0] ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + if ( strcmp( item, "REFDIST" ) == 0 ) + { + /* Read the Reference distance */ + if ( !sscanf( pValue, "%f", &pRenderConfigReader->distAtt[1] ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + if ( strcmp( item, "ROLLOFFFACTOR" ) == 0 ) + { + /* Read the Rolloff Factor */ + if ( !sscanf( pValue, "%f", &pRenderConfigReader->distAtt[2] ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + } + + free( pValue ); + } + else if ( strcmp( chapter, "GENERAL" ) == 0 && strlen( pParams ) != 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_length = (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); + if ( strcmp( item, "BINARYCONFIG" ) == 0 ) + { + /* get correct case reverb configuration file path */ + sscanf( pTemp + params_idx, "%*[^=] = %[^;];", pValue ); + + /* make reverb configuration file path relative to render configuration file path */ + for ( length = (int32_t) strlen( pRenderConfigPath ) - 1; length >= 0; length-- ) + { + if ( pRenderConfigPath[length] == '\\' || pRenderConfigPath[length] == '/' ) + { + length++; + break; + } + } + if ( length < 0 ) + { + /* no slash found */ + length = 0; + } + char *pCombinedName = calloc( length + (int32_t) strlen( pValue ) + 1, sizeof( char ) ); + strncpy( pCombinedName, pRenderConfigPath, length ); + strcpy( pCombinedName + length, pValue ); + + if ( ( error = RenderConfigReader_readBinary( pCombinedName, pRenderConfigReader ) ) != IVAS_ERR_OK ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + free( pCombinedName ); + } + else if ( strcmp( item, "DIRECTIVITY" ) == 0 ) + { + if ( read_txt_vector( pValue, 3, hRenderConfig->directivity ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + params_idx += params_length; + } + free( pValue ); + } + else + { + fprintf( stderr, "Unknown chapter: %s\n", chapter ); + } + } + else if ( pConfig_str[0] == '#' ) + { + /* comment lines are to be ignored */ + } + } + + free( pConfig_str ); + free( pParams ); + free( pTemp ); + + if ( errorHandler( "", ERROR_NONE ) > 0 ) + { + fprintf( stderr, "Errors occurred\n" ); + return IVAS_ERR_FAILED_FILE_PARSE; + } + return IVAS_ERR_OK; +} + +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_getAcousticEnvironmentCount() + * + * Gets number of acoustic environments available + *------------------------------------------------------------------------------------------*/ +uint32_t RenderConfigReader_getAcousticEnvironmentCount( + RenderConfigReader *pRenderConfigReader /* i : RenderConfigReader handle */ +) +{ + return pRenderConfigReader->nAE; +} + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_getAcousticEnvironments() + * + * Gets all acoustic environments + *------------------------------------------------------------------------------------------*/ +ivas_error RenderConfigReader_getAcousticEnvironments( + RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA **ppAcEnv /* o : Acoustic environment array pointer */ +) +{ + uint16_t n, m, j; + + if ( pRenderConfigReader == NULL || ppAcEnv == NULL || pRenderConfigReader->nAE == 0 || pRenderConfigReader->pAE == NULL ) + { + return 0; + } + + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) + { + AcousticEnv pIn = pRenderConfigReader->pAE[n]; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pOut = ppAcEnv[n]; + + pOut->aeID = (Word16) pIn.id; + pOut->nBands = (Word16) pIn.pFG->nrBands; + pOut->inputPreDelay_fx = (Word32) ( pIn.preDelay * ONE_IN_Q27 ); + + for ( m = 0; m < pOut->nBands; m++ ) + { + pOut->pFc_input_fx[m] = (Word32) ( pIn.pFG->pFc[m] * ONE_IN_Q16 ); + pOut->pAcoustic_rt60_fx[m] = (Word32) ( pIn.pRT60[m] * ONE_IN_Q26 ); + pOut->pAcoustic_dsr_fx[m] = (Word32) ( pIn.pDSR[m] * ONE_IN_Q30 ); + } + + /* If ER are allocated then propagate parameters */ + if ( pIn.pEarlyReflections != 0 ) + { + pOut->use_er = pIn.pEarlyReflections->use_er; /* ER activation flag */ + pOut->lowComplexity = pIn.pEarlyReflections->lowComplexity; /* Low complexity flag */ + pOut->dimensions = pIn.pEarlyReflections->dimensions; + pOut->dimensions.x_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x * ONE_IN_Q22 ); + pOut->dimensions.y_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y * ONE_IN_Q22 ); + pOut->dimensions.z_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z * ONE_IN_Q22 ); + + /* Use default listener origin position if non provided */ + if ( pIn.pEarlyReflections->pListenerOrigin == NULL ) + { + + pOut->ListenerOrigin.x_fx = IVAS_ER_LIST_ORIGIN_X_FX; + pOut->ListenerOrigin.y_fx = IVAS_ER_LIST_ORIGIN_Y_FX; + pOut->ListenerOrigin.z_fx = IVAS_ER_LIST_HEIGHT_FX; + pOut->ListenerOrigin.q_fact = Q22; + } + else + { + pOut->ListenerOrigin.x_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx; + pOut->ListenerOrigin.y_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx; + pOut->ListenerOrigin.z_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx; + } + + for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) + { + pOut->AbsCoeff_fx[j] = (Word32) ( pIn.pEarlyReflections->pAbsCoeff[j] * ONE_IN_Q30 ); + } + } + else + { + pOut->use_er = false; + } + } + + return IVAS_ERR_OK; +} +#endif + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_getAcousticEnvironment() + * + * Gets Acoustic environment with a given ID + *------------------------------------------------------------------------------------------*/ + +ivas_error RenderConfigReader_getAcousticEnvironment( + RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ + uint16_t id, /* i : Acoustic environment ID */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Target acoustic environment pointer */ +) +{ + uint16_t n, m; + uint16_t j; + + if ( pRenderConfigReader == NULL || pAcEnv == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* case when -aeid is not specified, select first ID from config file */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + if ( id == (UWord16) IVAS_DEFAULT_AEID && pRenderConfigReader->nAE > 0 ) +#else + if ( id == 65535 && pRenderConfigReader->nAE > 0 ) +#endif + { + id = (uint16_t) pRenderConfigReader->pAE[0].id; + } + + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) + { + if ( id == pRenderConfigReader->pAE[n].id ) + { + pAcEnv->nBands = (int16_t) pRenderConfigReader->pAE[n].pFG->nrBands; + pAcEnv->inputPreDelay_fx = (Word32) ( pRenderConfigReader->pAE[n].preDelay * ONE_IN_Q27 ); + if ( pRenderConfigReader->pAE[n].preDelay > INPUTPREDELAY_MAX || + pRenderConfigReader->pAE[n].preDelay < INPUTPREDELAY_MIN ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + for ( m = 0; m < pAcEnv->nBands; m++ ) + { + if ( pRenderConfigReader->pAE[n].pFG->pFc[m] > FC_INPUT_MAX || + pRenderConfigReader->pAE[n].pFG->pFc[m] < FC_INPUT_MIN || + pRenderConfigReader->pAE[n].pRT60[m] > ACOUSTIC_RT60_MAX || + pRenderConfigReader->pAE[n].pRT60[m] < ACOUSTIC_RT60_MIN || + pRenderConfigReader->pAE[n].pDSR[m] > ACOUSTIC_DSR_MAX || + pRenderConfigReader->pAE[n].pDSR[m] < ACOUSTIC_DSR_MIN ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + pAcEnv->pFc_input_fx[m] = (Word32) ( pRenderConfigReader->pAE[n].pFG->pFc[m] * ONE_IN_Q16 ); + pAcEnv->pAcoustic_rt60_fx[m] = (Word32) ( pRenderConfigReader->pAE[n].pRT60[m] * ONE_IN_Q26 ); + pAcEnv->pAcoustic_dsr_fx[m] = (Word32) ( pRenderConfigReader->pAE[n].pDSR[m] * ONE_IN_Q30 ); + } + + /* If ER are allocated then propagate parameters */ + if ( pRenderConfigReader->pAE[n].pEarlyReflections != 0 ) + { + pAcEnv->use_er = pRenderConfigReader->pAE[n].pEarlyReflections->use_er; /* ER activation flag */ + pAcEnv->lowComplexity = pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity; /* Low complexity flag */ + pAcEnv->dimensions = pRenderConfigReader->pAE[n].pEarlyReflections->dimensions; + pAcEnv->dimensions.x_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x * ONE_IN_Q22 ); + pAcEnv->dimensions.y_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y * ONE_IN_Q22 ); + pAcEnv->dimensions.z_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z * ONE_IN_Q22 ); + /* Use default listener origin position if non provided */ + if ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin == NULL ) + { + if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = IVAS_ER_LIST_ORIGIN_X; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = IVAS_ER_LIST_ORIGIN_Y; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = IVAS_ER_LIST_HEIGHT; + + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx = IVAS_ER_LIST_ORIGIN_X_FX; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx = IVAS_ER_LIST_ORIGIN_Y_FX; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx = IVAS_ER_LIST_HEIGHT_FX; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->q_fact = Q22; + } + else + { + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x * ONE_IN_Q22 ); + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y * ONE_IN_Q22 ); + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z * ONE_IN_Q22 ); + } + pAcEnv->ListenerOrigin = *pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin; + for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) + { + pAcEnv->AbsCoeff[j] = pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[j]; + pAcEnv->AbsCoeff_fx[j] = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[j] * ONE_IN_Q30 ); + } + } + else + { + pAcEnv->use_er = false; + } + return IVAS_ERR_OK; + } + } + return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; +} + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_getDirectivity() + * + * Gets Directivity DirectrivityPatern with a given ID + *------------------------------------------------------------------------------------------*/ + +ivas_error RenderConfigReader_getDirectivity( + RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ + uint16_t *id, /* i : Directivity pattern ID */ + Word16 *directivity_fx /* o : Target directivity */ +) +{ + uint16_t n, m, i; + uint16_t last_specified_id; + bool idExists; + float directivity[12]; + + if ( pRenderConfigReader == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + if ( pRenderConfigReader->pDP == NULL ) + { + for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) + { + directivity[n * 3] = 360.0f; + directivity[n * 3 + 1] = 360.0f; + directivity[n * 3 + 2] = 1.0f; + } + } + else + { + last_specified_id = id[0]; + + /* set unpspecified Directivity Patterns ID to last specified ID */ + for ( n = MAX_NUM_OBJECTS - 1; n > 0; n-- ) + { + if ( id[n] != 65535 ) + { + last_specified_id = id[n]; + break; + } + } + /* case when -dpid is not specified, select first directivity pattern from config file */ + move16(); + if ( last_specified_id == 65535 ) + { + last_specified_id = (uint16_t) pRenderConfigReader->pDP[0].id; + } + + for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) + { + id[n] = last_specified_id; + } + + for ( n = 0; n < IVAS_MAX_NUM_OBJECTS; n++ ) + { + idExists = false; + for ( m = 0; m < pRenderConfigReader->nDP; m++ ) + { + if ( id[n] == pRenderConfigReader->pDP[m].id ) + { + idExists = true; + for ( i = 0; i < 3; i++ ) + { + directivity[n * 3 + i] = pRenderConfigReader->pDP[m].pDirectivity[i]; + } + + break; + } + } + if ( !idExists ) + { + return IVAS_ERR_DIRECTIVITY_PATTERN_ID_MISSING; + } + } + } + + /* Convert to Word16 */ + FOR( n = 0; n < 4; n++ ) + { + directivity_fx[n * 3] = (Word16) ( directivity[n * 3] * ( 1u << 6 ) ); + directivity_fx[n * 3 + 1] = (Word16) ( directivity[n * 3 + 1] * ( 1u << 6 ) ); + directivity_fx[n * 3 + 2] = (Word16) ( directivity[n * 3 + 2] * ( ( 1u << 15 ) - 1 ) ); + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_getDistanceAttenuation() + * + * Gets Distance Attenuation + *------------------------------------------------------------------------------------------*/ + +ivas_error RenderConfigReader_getDistanceAttenuation( + RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ + + Word32 *distAtt_fx /* o : Distance attenuation */ +) +{ + float distAtt[3]; + + if ( pRenderConfigReader->distAtt[0] == -1 ) + { + distAtt[0] = 15.75f; + distAtt[1] = 1.0f; + distAtt[2] = 1.0f; + } + else + { + distAtt[0] = pRenderConfigReader->distAtt[0]; + distAtt[1] = pRenderConfigReader->distAtt[1]; + distAtt[2] = pRenderConfigReader->distAtt[2]; + } + + /* Convert to Word32 */ + distAtt_fx[0] = (Word32) ( distAtt[0] * ( 1u << 27 ) ); + distAtt_fx[1] = (Word32) ( distAtt[1] * ( 1u << 30 ) ); + distAtt_fx[2] = (Word32) ( distAtt[2] * ( 1u << 30 ) ); + + return IVAS_ERR_OK; +} + +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_close() + * + * Closes the renderer configuration reader and deallocates memory + *------------------------------------------------------------------------------------------*/ + +void RenderConfigReader_close( + RenderConfigReader **ppRenderConfigReader /* i : RenderConfigReader handle */ +) +{ + uint32_t n; + + if ( ppRenderConfigReader == NULL || *ppRenderConfigReader == NULL ) + { + return; + } + + /* Free the acoustic environments */ + for ( n = 0; n < ( *ppRenderConfigReader )->nAE; n++ ) + { + if ( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections != NULL ) + { + free( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections->pListenerOrigin ); + free( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections ); + } + free( ( *ppRenderConfigReader )->pAE[n].pRT60 ); + free( ( *ppRenderConfigReader )->pAE[n].pDSR ); + } + free( ( *ppRenderConfigReader )->pAE ); + + /* Free the frequency grids */ + for ( n = 0; n < ( *ppRenderConfigReader )->nFG; n++ ) + { + free( ( *ppRenderConfigReader )->pFG[n].pFc ); + } + free( ( *ppRenderConfigReader )->pFG ); + /* Free the directivity patterns */ + for ( n = 0; n < ( *ppRenderConfigReader )->nDP; n++ ) + { + free( ( *ppRenderConfigReader )->pDP[n].pDirectivity ); + } + free( ( *ppRenderConfigReader )->pDP ); + fclose( ( *ppRenderConfigReader )->pConfigFile ); + free( *ppRenderConfigReader ); + + return; +} diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 9f9e222c5..784ef1e20 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3225,11 +3225,6 @@ void ivas_initialize_handles_dec( st_ivas->p_output_fx[i] = NULL; } -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - /* Acoustic environments */ - st_ivas->pAcousticEnvironments = NULL; -#endif - return; } @@ -3468,6 +3463,16 @@ void ivas_destroy_dec_fx( #endif } +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + /* Acoustic environments */ + IF( st_ivas->pAcousticEnvironments != NULL ) + { + free( st_ivas->pAcousticEnvironments ); + st_ivas->pAcousticEnvironments = NULL; + } +#endif + + /* main IVAS handle */ free( st_ivas ); diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 0aa342bf6..a212c79b7 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2896,6 +2896,11 @@ ivas_error RenderConfigReader_getAcousticEnvironments( pOut->aeID = (Word16) pIn.id; pOut->nBands = (Word16) pIn.pFG->nrBands; + if ( pRenderConfigReader->pAE[n].preDelay > INPUTPREDELAY_MAX || + pRenderConfigReader->pAE[n].preDelay < INPUTPREDELAY_MIN ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } pOut->inputPreDelay_fx = (Word32) ( pIn.preDelay * ONE_IN_Q27 ); for ( m = 0; m < pOut->nBands; m++ ) @@ -2918,6 +2923,9 @@ ivas_error RenderConfigReader_getAcousticEnvironments( /* Use default listener origin position if non provided */ if ( pIn.pEarlyReflections->pListenerOrigin == NULL ) { + pOut->ListenerOrigin.x = IVAS_ER_LIST_ORIGIN_X; + pOut->ListenerOrigin.y = IVAS_ER_LIST_ORIGIN_Y; + pOut->ListenerOrigin.z = IVAS_ER_LIST_HEIGHT; pOut->ListenerOrigin.x_fx = IVAS_ER_LIST_ORIGIN_X_FX; pOut->ListenerOrigin.y_fx = IVAS_ER_LIST_ORIGIN_Y_FX; @@ -2926,6 +2934,10 @@ ivas_error RenderConfigReader_getAcousticEnvironments( } else { + pOut->ListenerOrigin.x = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x; + pOut->ListenerOrigin.y = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y; + pOut->ListenerOrigin.z = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z; + pOut->ListenerOrigin.x_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx; pOut->ListenerOrigin.y_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx; pOut->ListenerOrigin.z_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx; @@ -2933,6 +2945,7 @@ ivas_error RenderConfigReader_getAcousticEnvironments( for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) { + pOut->AbsCoeff[j] = (Word32) ( pIn.pEarlyReflections->pAbsCoeff[j] ); pOut->AbsCoeff_fx[j] = (Word32) ( pIn.pEarlyReflections->pAbsCoeff[j] * ONE_IN_Q30 ); } } -- GitLab From 3c9de80ac8df6b149a7a5a3f56e57aaf8fd4a63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Toftg=C3=A5rd?= Date: Mon, 10 Nov 2025 18:56:24 +0100 Subject: [PATCH 270/351] Bug fix for IVAS_RTP_LogPiData, add missing fprintf(). --- lib_util/ivas_rtp_file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 0bf820df4..b3be95782 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -171,6 +171,9 @@ void IVAS_RTP_LogPiData( #else if ( ftell( f_piDataOut ) > 2 ) #endif + { + fprintf( f_piDataOut, ",\n" ); + } while ( nPiDataPresent-- > 0 ) { -- GitLab From 6cd46fe0d0724ba7fe0f2b887d45c8903c6c83d7 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 10 Nov 2025 19:28:08 +0100 Subject: [PATCH 271/351] Fix move32->move16 --- lib_dec/lib_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index bc4419a95..827d937db 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4624,11 +4624,11 @@ ivas_error IVAS_DEC_SetEditableParameters( IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) { st_ivas->hIsmMetaData[obj]->edited_yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; - move32(); + move16(); st_ivas->hIsmMetaData[obj]->edited_pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; - move32(); + move16(); st_ivas->hIsmMetaData[obj]->edited_radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; - move32(); + move16(); } #else st_ivas->hIsmMetaData[obj]->edited_yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; -- GitLab From 8064809300c6beb572be02a7092861a4010cde11 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 10 Nov 2025 20:09:48 +0100 Subject: [PATCH 272/351] Fixed absorption coeff assignment --- .../render_config_reader.c | 3226 ----------------- lib_util/render_config_reader.c | 2 +- 2 files changed, 1 insertion(+), 3227 deletions(-) delete mode 100644 Workspace_msvc/enc_temp_folder/b685e51a257c31d9ba90c87bcc18d2c/render_config_reader.c diff --git a/Workspace_msvc/enc_temp_folder/b685e51a257c31d9ba90c87bcc18d2c/render_config_reader.c b/Workspace_msvc/enc_temp_folder/b685e51a257c31d9ba90c87bcc18d2c/render_config_reader.c deleted file mode 100644 index 0aa342bf6..000000000 --- a/Workspace_msvc/enc_temp_folder/b685e51a257c31d9ba90c87bcc18d2c/render_config_reader.c +++ /dev/null @@ -1,3226 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include "render_config_reader.h" -#include -#include -#include -#include -#include -#include "cmdl_tools.h" -#include "prot_fx.h" -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#include "ivas_cnst.h" -#endif - -/*------------------------------------------------------------------------------------------* - * PreProc Local Macros - *------------------------------------------------------------------------------------------*/ - -#define MAX_ITEM_LENGTH ( 64 ) -#define N_ABS_COEFFS ( 6 ) - -#define SHORTEST_REV_DEL_LINE ( 0.015f ) -#define N_BANDS_MIN ( 2 ) -#define N_BANDS_MAX ( 60 ) -#define FC_INPUT_MIN ( 0.0f ) -#define FC_INPUT_MAX ( 1.0e+5f ) -#define ACOUSTIC_RT60_MIN ( 1.0e-3f ) -#define ACOUSTIC_RT60_MAX ( 1.0e+2f ) -#define ACOUSTIC_DSR_MIN ( 0.0f ) -#define ACOUSTIC_DSR_MAX ( 1.0e+2f ) -#define ACOUSTIC_DSR_EPSILON ( 1.0e-15f ) -#define ACOUSTIC_DSR_EPSILON_FX ( 1 ) -#define ACOUSTICPREDELAY_JOTREV_MIN ( SHORTEST_REV_DEL_LINE ) -#define ACOUSTICPREDELAY_JOTREV_MAX ( SHORTEST_REV_DEL_LINE + 1.0f / (float) IVAS_NUM_FRAMES_PER_SEC ) -#define ACOUSTICPREDELAY_FDREV_MIN ( 1.0f / (float) ( 16 * IVAS_NUM_FRAMES_PER_SEC ) ) -#define ACOUSTICPREDELAY_FDREV_MAX ( (float) ( IVAS_REVERB_PREDELAY_MAX ) / (float) ( 16 * IVAS_NUM_FRAMES_PER_SEC ) ) -#define INPUTPREDELAY_MIN ( 0.0f ) -#define INPUTPREDELAY_MAX ( 1.0e+2f ) - -#define ER_MIN_ROOM_DIMENSION ( 1.0f ) -#define ER_MIN_ROOM_DIMENSION_FX ( 4194304 ) -#define ER_MAX_ROOM_DIMENSION ( 999.0f ) -#define ER_MAX_ROOM_DIMENSION_FX ( 2095054848 ) -#define ER_MIN_ABS_COEFF ( 0.0f ) -#define ER_MIN_ABS_COEFF_FX ( 0 ) -#define ER_MAX_ABS_COEFF ( 1.0f ) -#define ER_MAX_ABS_COEFF_FX ( 1073741824 ) - -#define IVAS_ER_LIST_ORIGIN_X 0.0f -#define IVAS_ER_LIST_ORIGIN_Y 0.0f -#define IVAS_ER_LIST_ORIGIN_X_FX 0 -#define IVAS_ER_LIST_ORIGIN_Y_FX 0 - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - - -/*------------------------------------------------------------------------------------------* - * Local Type definitions - *------------------------------------------------------------------------------------------*/ - -typedef struct -{ - uint32_t nrBands; /* Number of frequency bands */ - float *pFc; /* Center frequencies */ -} FrequencyGrid; - -typedef enum _FREQ_GRID_MODE -{ - FREQ_GRID_MODE_UNKNOWN = -1, - FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES = 0, - FREQ_GRID_MODE_START_HOP_AMOUNT = 1, - FREQ_GRID_MODE_DEFAULT_BANDING = 2 -} FREQ_GRID_MODE; - -typedef struct -{ - uint16_t use_er; /* Activation Flag */ - IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ - float pAbsCoeff[N_ABS_COEFFS]; /* Absorption coeffs table */ - IVAS_VECTOR3 *pListenerOrigin; /* Listener origin */ - uint32_t lowComplexity; /* Low complexity mode flag */ -} EarlyReflectionsConfig; - -typedef struct -{ - uint32_t id; /* Acoustic environment ID */ - FrequencyGrid *pFG; /* Pointer into Frequency grids table for late reverb coeffs */ - float *pRT60; /* RT60 table */ - float *pDSR; /* DSR table */ - float preDelay; /* Pre-delay */ - EarlyReflectionsConfig *pEarlyReflections; /* Early reflections configuration */ -} AcousticEnv; - -typedef struct -{ - uint32_t id; /* Pattern ID */ - float *pDirectivity; /* Source directivity */ -} DirectrivityPat; - -struct RenderConfigReader -{ - FILE *pConfigFile; - uint8_t *pBitstream; /* Renderer config bitstream */ - size_t length; /* Bitstream length */ - size_t readOffset; /* Bitstream read offset */ - uint32_t nFG; /* Number of frequency grids */ - FrequencyGrid *pFG; /* Frequency grids */ - uint32_t nAE; /* Number of acoustic environments */ - AcousticEnv *pAE; /* Acoustic environments */ - uint32_t nDP; /* Number of directivity patterns */ - DirectrivityPat *pDP; /* Directivity Pattern */ - float distAtt[3]; /* [MaxDist Q30, RefDist Q30, Rolloff Q30] */ -}; - - -typedef enum _RC_LUT -{ - RC_LUT_INVALID = 0x00, - RC_LUT_COUNT_IDX_LO, - RC_LUT_COUNT_IDX_HI, - RC_LUT_DECI_SEC, - RC_LUT_SEC, - RC_LUT_MILLI_SEC, - RC_LUT_MICRO_SEC, - RC_LUT_FREQ, - RC_LUT_FREQ_HOP, - RC_LUT_DSR, - RC_LUT_METERS, - RC_LUT_HECTOMETERS, - RC_LUT_KILOMETERS, - RC_LUT_CENTIMETERS, - RC_LUT_ABSORPTION -} RC_LUT; - -/*------------------------------------------------------------------------------------------* - * Lookup tables - *------------------------------------------------------------------------------------------*/ - -const float lutCountIdxLo_Value[] = { - 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, - 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, - 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, - 48.0f, 49.0f, 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, 56.0f, 57.0f, 58.0f, 59.0f, 60.0f, 61.0f, 62.0f, 63.0f -}; -const uint16_t lutCountIdxLo_Code[] = { - 7, 4, 12, 13, 10, 11, 8, 9, 15, 14, 13, 12, 11, 10, 9, 8, - 7, 6, 5, 4, 3, 2, 1, 0, 63, 62, 61, 60, 59, 58, 57, 56, - 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, - 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80 -}; -const uint8_t lutCountIdxLo_Len[] = { - 4, 3, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 -}; - -const float lutCountIdxHi_Value[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f }; -const uint16_t lutCountIdxHi_Code[] = { 1, 0, 6, 5, 4, 7, 5, 15, 14, 13, 9, 8, 25, 49, 48 }; -const uint8_t lutCountIdxHi_Len[] = { 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 7, 7 }; - -const float lutDeciSec_Value[] = { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f }; -const uint16_t lutDeciSec_Code[] = { 6, 4, 5, 6, 7, 7, 4, 5, 2, 3, 0 }; -const uint8_t lutDeciSec_Len[] = { 3, 3, 3, 4, 4, 3, 4, 4, 4, 4, 3 }; - -const float lutSec_Value[] = { - 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, - 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, - 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f -}; -const uint16_t lutSec_Code[] = { 3, 1, 0, 15, 13, 12, 11, 9, 8, 14, 13, 12, 11, 9, 8, 5, 29, 28, 21, 31, 30, 21, 9, 8, 41, 41, 40, 81, 161, 160 }; -const uint8_t lutSec_Len[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 8, 8 }; - -const float lutMilliSec_Value[] = { - 0.00f, 0.001f, 0.002f, 0.003f, 0.004f, 0.005f, 0.006f, 0.007f, 0.008f, 0.009f, - 0.01f, 0.011f, 0.012f, 0.013f, 0.014f, 0.015f, 0.016f, 0.017f, 0.018f, 0.019f, - 0.02f, 0.021f, 0.022f, 0.023f, 0.024f, 0.025f, 0.026f, 0.027f, 0.028f, 0.029f, - 0.03f, 0.031f, 0.032f, 0.033f, 0.034f, 0.035f, 0.036f, 0.037f, 0.038f, 0.039f, - 0.04f, 0.041f, 0.042f, 0.043f, 0.044f, 0.045f, 0.046f, 0.047f, 0.048f, 0.049f, - 0.05f, 0.051f, 0.052f, 0.053f, 0.054f, 0.055f, 0.056f, 0.057f, 0.058f, 0.059f, - 0.06f, 0.061f, 0.062f, 0.063f, 0.064f, 0.065f, 0.066f, 0.067f, 0.068f, 0.069f, - 0.07f, 0.071f, 0.072f, 0.073f, 0.074f, 0.075f, 0.076f, 0.077f, 0.078f, 0.079f, - 0.08f, 0.081f, 0.082f, 0.083f, 0.084f, 0.085f, 0.086f, 0.087f, 0.088f, 0.089f, - 0.09f, 0.091f, 0.092f, 0.093f, 0.094f, 0.095f, 0.096f, 0.097f, 0.098f, 0.099f -}; -const uint16_t lutMilliSec_Code[] = { - 122, 123, 120, 121, 126, 127, 124, 125, 114, 115, 25, 112, 113, 118, 119, 116, 117, 42, 43, 40, - 18, 41, 46, 47, 44, 45, 34, 35, 32, 33, 19, 38, 39, 36, 37, 58, 59, 56, 57, 62, - 16, 63, 60, 61, 50, 51, 48, 49, 54, 55, 17, 52, 53, 10, 11, 8, 9, 14, 15, 12, - 22, 13, 2, 3, 0, 1, 6, 7, 4, 5, 23, 26, 27, 24, 25, 30, 31, 28, 29, 18, - 20, 19, 16, 17, 22, 23, 20, 21, 106, 107, 21, 104, 105, 110, 111, 108, 109, 98, 99, 48 -}; -const uint8_t lutMilliSec_Len[] = { - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 6 -}; - -const float lutMicroSec_Value[] = { - 0.00001f, 0.00002f, 0.00003f, 0.00004f, 0.00005f, 0.00006f, 0.00007f, 0.00008f, 0.00009f, 0.0001f, - 0.00011f, 0.00012f, 0.00013f, 0.00014f, 0.00015f, 0.00016f, 0.00017f, 0.00018f, 0.00019f, 0.0002f, - 0.00021f, 0.00022f, 0.00023f, 0.00024f, 0.00025f, 0.00026f, 0.00027f, 0.00028f, 0.00029f, 0.0003f, - 0.00031f, 0.00032f, 0.00033f, 0.00034f, 0.00035f, 0.00036f, 0.00037f, 0.00038f, 0.00039f, 0.0004f, - 0.00041f, 0.00042f, 0.00043f, 0.00044f, 0.00045f, 0.00046f, 0.00047f, 0.00048f, 0.00049f, 0.0005f, - 0.00051f, 0.00052f, 0.00053f, 0.00054f, 0.00055f, 0.00056f, 0.00057f, 0.00058f, 0.00059f, 0.0006f, - 0.00061f, 0.00062f, 0.00063f, 0.00064f, 0.00065f, 0.00066f, 0.00067f, 0.00068f, 0.00069f, 0.0007f, - 0.00071f, 0.00072f, 0.00073f, 0.00074f, 0.00075f, 0.00076f, 0.00077f, 0.00078f, 0.00079f, 0.0008f, - 0.00081f, 0.00082f, 0.00083f, 0.00084f, 0.00085f, 0.00086f, 0.00087f, 0.00088f, 0.00089f, 0.0009f, - 0.00091f, 0.00092f, 0.00093f, 0.00094f, 0.00095f, 0.00096f, 0.00097f, 0.00098f, 0.00099f -}; -const uint16_t lutMicroSec_Code[] = { - 444, 18, 445, 19, 894, 16, 895, 17, 892, 22, 893, 23, 434, 20, 435, 21, 432, 10, 433, 11, - 438, 8, 439, 9, 436, 14, 437, 15, 410, 12, 411, 13, 408, 2, 409, 3, 414, 0, 415, 1, - 412, 6, 413, 7, 402, 4, 403, 5, 400, 26, 401, 27, 406, 24, 407, 25, 404, 30, 405, 31, - 426, 28, 427, 29, 424, 18, 425, 19, 430, 16, 431, 17, 428, 22, 429, 23, 418, 20, 419, 21, - 416, 58, 417, 59, 422, 56, 423, 57, 420, 62, 421, 63, 442, 60, 443, 61, 440, 24, 441 -}; -const uint8_t lutMicroSec_Len[] = { - 9, 5, 9, 5, 10, 5, 10, 5, 10, 5, 10, 5, 9, 5, 9, 5, 9, 6, 9, 6, - 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, - 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, - 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, - 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 5, 9 -}; - -const float lutFreq_Value[] = { - 16.0f, 20.0f, 25.0f, 31.5f, 40.0f, 50.0f, 63.0f, 80.0f, 100.0f, 125.0f, - 160.0f, 200.0f, 250.0f, 315.0f, 400.0f, 500.0f, 630.0f, 800.0f, 1000.0f, 1250.0f, - 1600.0f, 2000.0f, 2500.0f, 3150.0f, 4000.0f, 5000.0f, 6300.0f, 8000.0f, 10000.0f, 12500.0f, - 16000.0f, 20000.0f, 25000.0f, 31500.0f, 40000.0f -}; -const uint16_t lutFreq_Code[] = { 35, 14, 15, 9, 12, 13, 0, 26, 27, 1, 24, 25, 14, 30, 31, 15, 28, 29, 12, 18, 19, 13, 16, 17, 10, 22, 23, 11, 20, 21, 2, 16, 138, 139, 68 }; -const uint8_t lutFreq_Len[] = { 6, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 5, 8, 8, 7 }; - -const float lutFreqHop_Value[] = { 1.059463094f, 1.122462048f, 1.189207115f, 1.259921050f, 1.414213562f, 2.0f, 4.0f }; -const uint16_t lutFreqHop_Code[] = { 2, 3, 0, 1, 1, 3, 2 }; -const uint8_t lutFreqHop_Len[] = { 4, 4, 4, 2, 4, 2, 2 }; - -const float lutDsr_Value[] = { - -150.0f, -149.0f, -148.0f, -147.0f, -146.0f, -145.0f, -144.0f, -143.0f, -142.0f, -141.0f, - -140.0f, -139.0f, -138.0f, -137.0f, -136.0f, -135.0f, -134.0f, -133.0f, -132.0f, -131.0f, - -130.0f, -129.0f, -128.0f, -127.0f, -126.0f, -125.0f, -124.0f, -123.0f, -122.0f, -121.0f, - -120.0f, -119.0f, -118.0f, -117.0f, -116.0f, -115.0f, -114.0f, -113.0f, -112.0f, -111.0f, - -110.0f, -109.0f, -108.0f, -107.0f, -106.0f, -105.0f, -104.0f, -103.0f, -102.0f, -101.0f, - -100.0f, -99.0f, -98.0f, -97.0f, -96.0f, -95.0f, -94.0f, -93.0f, -92.0f, -91.0f, - -90.0f, -89.0f, -88.0f, -87.0f, -86.0f, -85.0f, -84.0f, -83.0f, -82.0f, -81.0f, - -80.0f, -79.0f, -78.0f, -77.0f, -76.0f, -75.0f, -74.0f, -73.0f, -72.0f, -71.0f, - -70.0f, -69.0f, -68.0f, -67.0f, -66.0f, -65.0f, -64.0f, -63.0f, -62.0f, -61.0f, - -60.0f, -59.0f, -58.0f, -57.0f, -56.0f, -55.0f, -54.0f, -53.0f, -52.0f, -51.0f, - -50.0f, -49.0f, -48.0f, -47.0f, -46.0f, -45.0f, -44.0f, -43.0f, -42.0f, -41.0f, - -40.0f, -39.0f, -38.0f, -37.0f, -36.0f, -35.0f, -34.0f, -33.0f, -32.0f, -31.0f, - -30.0f, -29.0f, -28.0f, -27.0f, -26.0f, -25.0f, -24.0f, -23.0f, -22.0f, -21.0f, - -20.0f, -19.0f, -18.0f, -17.0f, -16.0f, -15.0f, -14.0f, -13.0f, -12.0f, -11.0f, - -10.0f -}; -const uint16_t lutDsr_Code[] = { - 140, 141, 286, 287, 284, 285, 130, 131, 128, 129, 134, 135, 132, 133, 234, 235, 232, 233, 238, 239, - 236, 237, 226, 227, 224, 225, 230, 231, 228, 229, 250, 251, 248, 249, 254, 255, 252, 253, 242, 243, - 240, 241, 246, 247, 244, 245, 202, 203, 200, 201, 206, 207, 204, 205, 194, 195, 192, 193, 198, 199, - 196, 197, 218, 219, 216, 217, 222, 223, 220, 221, 20, 21, 38, 39, 36, 37, 58, 59, 56, 57, - 62, 63, 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, 10, 11, 8, 9, 14, 15, 12, 13, - 2, 3, 0, 1, 6, 7, 4, 5, 42, 43, 40, 41, 46, 47, 44, 45, 18, 19, 16, 17, - 22, 210, 211, 208, 209, 214, 215, 212, 213, 186, 187, 184, 185, 190, 191, 188, 189, 138, 139, 136, - 137 -}; -const uint8_t lutDsr_Len[] = { - 8, 8, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, - 8 -}; - -const float lutMeters_Value[] = { - 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, - 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, - 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, - 30.0f, 31.0f, 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, - 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, 48.0f, 49.0f, - 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, 56.0f, 57.0f, 58.0f, 59.0f, - 60.0f, 61.0f, 62.0f, 63.0f, 64.0f, 65.0f, 66.0f, 67.0f, 68.0f, 69.0f, - 70.0f, 71.0f, 72.0f, 73.0f, 74.0f, 75.0f, 76.0f, 77.0f, 78.0f, 79.0f, - 80.0f, 81.0f, 82.0f, 83.0f, 84.0f, 85.0f, 86.0f, 87.0f, 88.0f, 89.0f, - 90.0f, 91.0f, 92.0f, 93.0f, 94.0f, 95.0f, 96.0f, 97.0f, 98.0f, 99.0f -}; - -const uint16_t lutMeters_Code[] = { - 61, 50, 51, 48, 49, 54, 55, 52, 53, 10, - 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, - 1, 6, 7, 4, 5, 26, 27, 24, 25, 30, - 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, - 21, 42, 43, 40, 41, 46, 47, 44, 45, 16, - 68, 69, 142, 143, 140, 141, 154, 155, 152, 153, - 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, - 148, 149, 234, 235, 232, 233, 238, 239, 236, 237, - 226, 227, 224, 225, 230, 231, 228, 229, 250, 251, - 248, 249, 254, 255, 252, 253, 242, 243, 240, 241 -}; - -const uint8_t lutMeters_Len[] = { - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, - 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 -}; - -const float lutHectometers_Value[] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f }; -const uint16_t lutHectometers_Code[] = { 0, 1, 6, 7, 4, 5, 6, 7, 4, 5 }; -const uint8_t lutHectometers_Len[] = { 3, 3, 3, 3, 3, 3, 4, 4, 4, 4 }; - -const float lutKilometers_Value[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f }; -const uint16_t lutKilometers_Code[] = { 2, 3, 1, 0, 7, 5, 4, 13, 25, 24 }; -const uint8_t lutKilometers_Len[] = { 2, 3, 3, 3, 3, 4, 4, 4, 5, 5 }; - -const float lutCentimeters_Value[] = { - 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, - 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, - 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, - 30.0f, 31.0f, 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, - 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, 48.0f, 49.0f, - 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, 56.0f, 57.0f, 58.0f, 59.0f, - 60.0f, 61.0f, 62.0f, 63.0f, 64.0f, 65.0f, 66.0f, 67.0f, 68.0f, 69.0f, - 70.0f, 71.0f, 72.0f, 73.0f, 74.0f, 75.0f, 76.0f, 77.0f, 78.0f, 79.0f, - 80.0f, 81.0f, 82.0f, 83.0f, 84.0f, 85.0f, 86.0f, 87.0f, 88.0f, 89.0f, - 90.0f, 91.0f, 92.0f, 93.0f, 94.0f, 95.0f, 96.0f, 97.0f, 98.0f, 99.0f -}; - -const uint16_t lutCentimeters_Code[] = { - 50, 51, 48, 49, 54, 55, 52, 53, 42, 43, - 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, - 38, 39, 36, 37, 58, 59, 56, 57, 62, 63, - 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, - 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, - 0, 1, 6, 7, 4, 5, 26, 27, 24, 25, - 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, - 20, 21, 42, 43, 40, 41, 46, 47, 44, 45, - 34, 35, 32, 33, 38, 39, 36, 37, 122, 123, - 120, 121, 126, 127, 124, 125, 58, 59, 56, 57 -}; - -const uint8_t lutCentimeters_Len[] = { - 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, - 7, 7, 7, 7, 7, 7, 6, 6, 6, 6 -}; - -const float lutAbsorption_Value[] = { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f }; -const uint16_t lutAbsorption_Code[] = { 6, 4, 5, 6, 7, 7, 4, 5, 2, 3, 0 }; -const uint8_t lutAbsorption_Len[] = { 3, 3, 3, 4, 4, 3, 4, 4, 4, 4, 3 }; - -/*------------------------------------------------------------------------------------------* - * Default frequency grids - *------------------------------------------------------------------------------------------*/ - -const float defaultFrequencyGrid_0[] = { 31.5f, 63.0f, 125.0f, 250.0f, 500.0f, 1000.0f, 2000.0f, 4000.0f, 8000.0f, 16000.0f }; -const float defaultFrequencyGrid_1[] = { 25.0f, 50.0f, 100.0f, 200.0f, 400.0f, 800.0f, 1600.0f, 3150.0f, 6300.0f, 12500.0f }; -const float defaultFrequencyGrid_2[] = { - 20.0f, 25.0f, 31.5f, 40.0f, 50.0f, 63.0f, 80.0f, 100.0f, 125.0f, 160.0f, - 200.0f, 250.0f, 315.0f, 400.0f, 500.0f, 630.0f, 800.0f, 1000.0f, 1250.0f, 1600.0f, - 2000.0f, 2500.0f, 3150.0f, 4000.0f, 5000.0f, 6300.0f, 8000.0f, 10000.0f, 12500.0f, 16000.0f, 20000.0f -}; -const float defaultFrequencyGrid_3[] = { 25.0f, 100.0f, 400.0f, 1600.0f, 6300.0f }; -const float defaultFrequencyGrid_4[] = { 125.0f, 250.0f, 500.0f, 1000.0f, 2000.0f, 4000.0f }; -const float defaultFrequencyGrid_5[] = { 25.0f, 250.0f, 2500.0f }; -const float defaultFrequencyGrid_6[] = { - 27.0f, 56.0f, 89.0f, 126.0f, 168.0f, 214.0f, 265.0f, 323.0f, 387.0f, 459.0f, - 539.0f, 628.0f, 727.0f, 839.0f, 963.0f, 1101.0f, 1256.0f, 1429.0f, 1621.0f, 1836.0f, - 2077.0f, 2345.0f, 2644.0f, 2978.0f, 3351.0f, 3767.0f, 4232.0f, 4750.0f, 5329.0f, 5975.0f, - 6697.0f, 7502.0f, 8401.0f, 9405.0f, 10525.0f, 11775.0f, 13171.0f, 14729.0f, 16468.0f, 18410.0f, 20577.0f -}; -const float defaultFrequencyGrid_7[] = { - 27.0f, 89.0f, 168.0f, 265.0f, 387.0f, 539.0f, 727.0f, 963.0f, 1256.0f, 1621.0f, - 2077.0f, 2644.0f, 3351.0f, 4232.0f, 5329.0f, 6697.0f, 8401.0f, 10525.0f, 13171.0f, 16468.0f, 20577.0f -}; -const float defaultFrequencyGrid_8[] = { - 50.0f, 150.0f, 250.0f, 350.0f, 450.0f, 570.0f, 700.0f, 840.0f, 1000.0f, 1170.0f, - 1370.0f, 1600.0f, 1850.0f, 2150.0f, 2150.0f, 2500.0f, 2900.0f, 3400.0f, 4000.0f, 4800.0f, - 5800.0f, 7000.0f, 8500.0f, 10500.0f, 13500.0f -}; - - -/*-----------------------------------------------------------------------------------------* - * Function read_bin_bits() - * Reads a given number of bits from the bitstream - *-----------------------------------------------------------------------------------------*/ - -static ivas_error read_bin_bits( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - uint32_t *pTarget, /* o : Target read data pointer */ - const size_t nBits /* i : Number of bits to read */ -) -{ - uint8_t n; - uint32_t nByte; - uint8_t bit; - - if ( this == NULL || this->pBitstream == NULL || pTarget == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - if ( this->readOffset + nBits > this->length * 8 ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - *pTarget = 0; - for ( n = 0; n < nBits; n++ ) - { - nByte = (uint32_t) ( ( this->readOffset + n ) >> 3 ); - bit = this->pBitstream[nByte] >> ( 7 - ( ( this->readOffset + n ) % 8 ) ) & 1; - *pTarget = ( *pTarget << 1 ) + bit; - } - - this->readOffset += nBits; - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function read_bin_bool() - * Reads a boolean value from a bitstream - *-----------------------------------------------------------------------------------------*/ - -static ivas_error read_bin_bool( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - uint32_t *pResult /* o : Target read data pointer */ -) -{ - return read_bin_bits( this, pResult, 1 ); -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_id() - * Reads an ID from a bitstream - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_id( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - uint32_t *pResult /* o : Target read data pointer */ -) -{ - ivas_error error; - uint32_t id; - uint32_t cont; - - *pResult = 0; - id = 0; - cont = true; - - if ( pResult == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - while ( cont ) - { - if ( ( error = read_bin_bits( this, &id, 7 ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult = ( *pResult << 7 ) | id; - - if ( ( error = read_bin_bool( this, &cont ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function read_bin_code_word() - * Reads a code word from a LUT - *-----------------------------------------------------------------------------------------*/ - -static ivas_error read_bin_code_word( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - const RC_LUT table, /* i : Table enum */ - float *pResult /* o : Code value */ -) -{ - ivas_error error; - const float *pValues; - const uint16_t *pCodes; - const uint8_t *pLengths; - uint8_t minLen; - uint8_t maxLen; - uint8_t size; - uint8_t n; - uint32_t code; - uint32_t bits; - uint32_t nr_bits; - uint8_t len; - - minLen = 255; - maxLen = 0; - bits = 0; - nr_bits = 0; - code = 0; - - if ( pResult == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - /* Select the right tables */ - switch ( table ) - { - case RC_LUT_COUNT_IDX_LO: - pValues = lutCountIdxLo_Value; - pCodes = lutCountIdxLo_Code; - pLengths = lutCountIdxLo_Len; - size = sizeof lutCountIdxLo_Len / sizeof( uint8_t ); - break; - case RC_LUT_COUNT_IDX_HI: - pValues = lutCountIdxHi_Value; - pCodes = lutCountIdxHi_Code; - pLengths = lutCountIdxHi_Len; - size = sizeof lutCountIdxHi_Len / sizeof( uint8_t ); - break; - case RC_LUT_DECI_SEC: - pValues = lutDeciSec_Value; - pCodes = lutDeciSec_Code; - pLengths = lutDeciSec_Len; - size = sizeof lutDeciSec_Len / sizeof( uint8_t ); - break; - case RC_LUT_SEC: - pValues = lutSec_Value; - pCodes = lutSec_Code; - pLengths = lutSec_Len; - size = sizeof lutSec_Len / sizeof( uint8_t ); - break; - case RC_LUT_MILLI_SEC: - pValues = lutMilliSec_Value; - pCodes = lutMilliSec_Code; - pLengths = lutMilliSec_Len; - size = sizeof lutMilliSec_Len / sizeof( uint8_t ); - break; - case RC_LUT_MICRO_SEC: - pValues = lutMicroSec_Value; - pCodes = lutMicroSec_Code; - pLengths = lutMicroSec_Len; - size = sizeof lutMicroSec_Len / sizeof( uint8_t ); - break; - case RC_LUT_FREQ: - pValues = lutFreq_Value; - pCodes = lutFreq_Code; - pLengths = lutFreq_Len; - size = sizeof lutFreq_Len / sizeof( uint8_t ); - break; - case RC_LUT_FREQ_HOP: - pValues = lutFreqHop_Value; - pCodes = lutFreqHop_Code; - pLengths = lutFreqHop_Len; - size = sizeof lutFreqHop_Len / sizeof( uint8_t ); - break; - case RC_LUT_DSR: - pValues = lutDsr_Value; - pCodes = lutDsr_Code; - pLengths = lutDsr_Len; - size = sizeof lutDsr_Len / sizeof( uint8_t ); - break; - case RC_LUT_METERS: - pValues = lutMeters_Value; - pCodes = lutMeters_Code; - pLengths = lutMeters_Len; - size = sizeof lutMeters_Len / sizeof( uint8_t ); - break; - case RC_LUT_HECTOMETERS: - pValues = lutHectometers_Value; - pCodes = lutHectometers_Code; - pLengths = lutHectometers_Len; - size = sizeof lutHectometers_Len / sizeof( uint8_t ); - break; - case RC_LUT_KILOMETERS: - pValues = lutKilometers_Value; - pCodes = lutKilometers_Code; - pLengths = lutKilometers_Len; - size = sizeof lutKilometers_Len / sizeof( uint8_t ); - break; - case RC_LUT_CENTIMETERS: - pValues = lutCentimeters_Value; - pCodes = lutCentimeters_Code; - pLengths = lutCentimeters_Len; - size = sizeof lutCentimeters_Len / sizeof( uint8_t ); - break; - case RC_LUT_ABSORPTION: - pValues = lutAbsorption_Value; - pCodes = lutAbsorption_Code; - pLengths = lutAbsorption_Len; - size = sizeof lutAbsorption_Len / sizeof( uint8_t ); - break; - case RC_LUT_INVALID: - default: - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - /* First read minLen bits, then add one bit per iteration to find the correct value */ - for ( n = 0; n < size; n++ ) - { - minLen = min( minLen, pLengths[n] ); - maxLen = max( maxLen, pLengths[n] ); - } - for ( len = minLen; len <= maxLen; len++ ) - { - nr_bits = ( len == minLen ) ? minLen : 1; - if ( ( error = read_bin_bits( this, &bits, nr_bits ) ) != IVAS_ERR_OK ) - { - return error; - } - code = ( code << nr_bits ) | bits; - for ( n = 0; n < size; n++ ) - { - if ( code == pCodes[n] && len == pLengths[n] ) - { - *pResult = pValues[n]; - return IVAS_ERR_OK; - } - } - } - return IVAS_ERR_INVALID_RENDER_CONFIG; -} - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_count_or_index() - * Gets a count or index - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_count_or_index( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - uint32_t *pResult /* o : Count or index value */ -) -{ - ivas_error error; - float value; - uint32_t isLarge; - - if ( pResult == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - if ( ( error = read_bin_code_word( this, RC_LUT_COUNT_IDX_LO, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult = (uint32_t) value; - - if ( ( error = read_bin_bool( this, &isLarge ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( isLarge ) - { - if ( ( error = read_bin_code_word( this, RC_LUT_COUNT_IDX_HI, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult += (uint32_t) value << 6; - } - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_duration() - * Gets a duration value - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_duration( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - float *pResult /* o : Duration value */ -) -{ - ivas_error error; - float value; - uint32_t addFlag; - - /* Deciseconds */ - if ( ( error = read_bin_code_word( this, RC_LUT_DECI_SEC, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult = value; - - /* Milliseconds */ - if ( ( error = read_bin_bool( this, &addFlag ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( addFlag ) - { - if ( ( error = read_bin_code_word( this, RC_LUT_MILLI_SEC, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult += value; - - /* Microseconds */ - if ( ( error = read_bin_bool( this, &addFlag ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( addFlag ) - { - if ( ( error = read_bin_code_word( this, RC_LUT_MICRO_SEC, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult += value; - } - } - - /* Seconds */ - if ( ( error = read_bin_bool( this, &addFlag ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( addFlag ) - { - if ( ( error = read_bin_code_word( this, RC_LUT_SEC, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult += value; - } - - /* Correct rounding errors due to multiple additions: */ - *pResult = roundf( *pResult * 100000.0f ) / 100000.0f; - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_frequency() - * Gets a frequency value - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_frequency( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - float *pResult /* o : Frequency value */ -) -{ - ivas_error error; - uint32_t hiRes; - uint32_t refine; - - hiRes = 0; - refine = 0; - - if ( ( error = read_bin_code_word( this, RC_LUT_FREQ, pResult ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( ( error = read_bin_bool( this, &hiRes ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( hiRes ) - { - if ( ( error = read_bin_bits( this, &refine, 4 ) ) != IVAS_ERR_OK ) - { - return error; - } - - *pResult *= powf( 2.0f, ( (float) refine + 1.0f ) / 51.0f ); - } - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_dsr() - * Gets a DSR value - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_dsr( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - float *pResult /* o : DSR value */ -) -{ - ivas_error error; - float value; - - if ( ( error = read_bin_code_word( this, RC_LUT_DSR, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult = powf( 10.0f, value / 10.0f ); - - return IVAS_ERR_OK; -} - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_distance() - * Gets a distance value (in meters) - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_distance( - RenderConfigReader *this, /* i/o : Render config reader handle */ - uint16_t isSmall, /* i : Flag indicating a small distance */ - float *pResult /* o : Distance value */ -) -{ - ivas_error error; - float value; - uint32_t flag; - - if ( ( error = read_bin_code_word( this, RC_LUT_METERS, pResult ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( isSmall == false ) - { - /* addHectometers flag */ - if ( ( error = read_bin_bool( this, &flag ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( flag == true ) - { - /* Hectometers */ - if ( ( error = read_bin_code_word( this, RC_LUT_HECTOMETERS, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult += value * 100.0f; - - /* addKilometers flag */ - if ( ( error = read_bin_bool( this, &flag ) ) != IVAS_ERR_OK ) - { - return error; - } - - while ( flag == true ) - { - /* Kilometers */ - if ( ( error = read_bin_code_word( this, RC_LUT_KILOMETERS, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult += value * 1000.0f; - - /* addKilometers flag */ - if ( ( error = read_bin_bool( this, &flag ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - } - - /* addCentimeters flag */ - if ( ( error = read_bin_bool( this, &flag ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( flag == true ) - { - /* Centimeters */ - if ( ( error = read_bin_code_word( this, RC_LUT_CENTIMETERS, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - *pResult += value * 0.01f; - } - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_absorption() - * Gets an absorption value - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_absorption( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Absorption value */ -) -{ - ivas_error error; - - if ( ( error = read_bin_code_word( this, RC_LUT_ABSORPTION, pResult ) ) != IVAS_ERR_OK ) - { - return error; - } - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function read_txt_bool() - * Reads a boolean value from a line - *-----------------------------------------------------------------------------------------*/ - -static ivas_error read_txt_bool( - const char *pLine, /* i : String to read from */ - uint32_t *pTarget /* o : Output pointer */ -) -{ - char value[8 + 1]; - - if ( sscanf( pLine, "%8s", (char *) &value ) != 1 ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - if ( strcmp( value, "TRUE" ) == 0 ) - { - *pTarget = TRUE; - return IVAS_ERR_OK; - } - if ( strcmp( value, "FALSE" ) == 0 ) - { - *pTarget = FALSE; - return IVAS_ERR_OK; - } - - return IVAS_ERR_INVALID_RENDER_CONFIG; -} - - -/*-------------------------------------------------------------------* - * usdequant_rend_cfg() - * - * Uniform scalar de-quantizer routine - *-------------------------------------------------------------------*/ - -static float usdequant_rend_cfg( - const uint32_t idx, /* i : quantizer index */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta /* i : quantization step */ -) -{ - float g; - - g = idx * delta + qlow; - - return ( g ); -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_angle() - * Gets an angle value in degrees [0,360] - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_angle( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Angle value */ -) -{ - ivas_error error; - uint32_t value; - - if ( ( error = read_bin_bits( this, &value, 5 ) ) != IVAS_ERR_OK ) - { - return error; - } - - *pResult = usdequant_rend_cfg( value, 0.0f, 20.0f ); - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_outer_attenuation () - * Gets an outer attenuation value [3.1623e-05,1.0], or in dB: [-90,0] - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_outer_attenuation( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Attenuation value */ -) -{ - ivas_error error; - uint32_t value; - float logval, att; - - if ( ( error = read_bin_bits( this, &value, 5 ) ) != IVAS_ERR_OK ) - { - return error; - } - - logval = usdequant_rend_cfg( value, -90.0f, 3.0f ); - att = powf( 10, logval / 20.0f ); - - *pResult = att; - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_max_dist () - * Gets a Maximum Distance value [1.0, 64.0] - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_max_dist( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Attenuation value */ -) -{ - ivas_error error; - uint32_t value; - - if ( ( error = read_bin_bits( this, &value, 6 ) ) != IVAS_ERR_OK ) - { - return error; - } - - *pResult = usdequant_rend_cfg( value, 1.0f, 1.0f ); - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_ref_dist () - * Gets a Reference Distance value [0.1, 6.4] - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_ref_dist( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Attenuation value */ -) -{ - ivas_error error; - uint32_t value; - - if ( ( error = read_bin_bits( this, &value, 6 ) ) != IVAS_ERR_OK ) - { - return error; - } - - *pResult = usdequant_rend_cfg( value, 0.1f, 0.1f ); - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function get_bin_rolloff () - * Gets a Rollof Factor [0.0, 4.0] - *-----------------------------------------------------------------------------------------*/ - -static ivas_error get_bin_rolloff( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Attenuation value */ -) -{ - ivas_error error; - uint32_t value; - - if ( ( error = read_bin_bits( this, &value, 6 ) ) != IVAS_ERR_OK ) - { - return error; - } - - *pResult = usdequant_rend_cfg( value, 0.0f, 0.1f ); - - return IVAS_ERR_OK; -} - - -/*-----------------------------------------------------------------------------------------* - * Function read_txt_vector() - * - * Reads a vector value from a line - *-----------------------------------------------------------------------------------------*/ - -static int16_t read_txt_vector( - char *pLine, /* i : String to read from */ - const uint32_t length, /* i : Number of expected vector elements */ - float *pTarget /* o : Output vector pointer */ -) -{ - char *tmp; - uint16_t n; - uint16_t count; - - n = (int16_t) sscanf( pLine, "[%s", pLine ); - if ( n == 0 ) - { - return true; - } - - /* Additional comma to make parsing easier */ - pLine[strlen( pLine ) - 1] = ','; - - tmp = pLine; - /* Count # of commas to determine vector length */ - for ( n = 0; tmp[n]; tmp[n] == ',' ? n++ : *tmp++ ) - ; - - count = n; - - tmp = pLine; - - /* Check for maximum vector length */ - if ( n != length ) - { - return true; - } - - for ( n = 0; n < count; n++ ) - { - if ( (int16_t) sscanf( tmp, "%f,", &pTarget[n] ) != 1 ) - { - return true; - } - - tmp = strchr( tmp, ',' ) + 1; - } - - return false; -} - - -/*-----------------------------------------------------------------------------------------* - * Function strip_spaces() - * - * Strips the spaces from a buffer - *-----------------------------------------------------------------------------------------*/ - -static void strip_spaces( - char *pStr /* i : String to read from */ -) -{ - int32_t read_idx = 0, write_idx = 0; - - while ( pStr[read_idx] ) - { - if ( !isspace( (int32_t) pStr[read_idx] ) && !iscntrl( (int32_t) pStr[read_idx] ) ) - { - pStr[write_idx++] = pStr[read_idx]; - } - read_idx++; - } - pStr[write_idx] = '\0'; - - return; -} - - -/*-----------------------------------------------------------------------------------------* - * Function errorHandler() - * - * Prints error message and exits - *-----------------------------------------------------------------------------------------*/ - -/*! r: error accumulation */ -static int32_t errorHandler( - const char *badStr, /* i : String to complain about */ - const ERROR_CODES_t error ) -{ - static int32_t numErrors = 0; - - switch ( error ) - { - case ERROR_NONE: - break; - case ERROR_ITEM_UNKNOWN: - numErrors++; - fprintf( stderr, "Unknown variable %s in renderer configuration file.\n\n", badStr ); - break; - case ERROR_VALUE_INVALID: - numErrors++; - fprintf( stderr, "Invalid value %s in renderer configuration file.\n\n", badStr ); - break; - default: - numErrors++; - fprintf( stderr, "Unknown error while reading configuration file.\n\n" ); - } - - return numErrors; -} - -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_checkValues() - * - * Verifies if the configuration parameters lie within acceptable limits - *------------------------------------------------------------------------------------------*/ -ivas_error RenderConfigReader_checkValues( - IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ -) -{ - int16_t band_idx, tab_value_err_count; - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; - pRoom_acoustics = &hRenderConfig->roomAcoustics; - tab_value_err_count = 0; - int16_t wall_idx; -#ifndef FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK - int16_t i; -#endif - - /* Verify the number of frequency bands in the config input data */ - if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) - { - return IVAS_ERR_WRONG_PARAMS; - } - - /* Verify data per band in the acoustic properties table */ - for ( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ ) - { - /* Verify if the frequencies are in the ascending order (required for interpolation) */ - if ( band_idx != 0 ) - { - if ( pRoom_acoustics->pFc_input_fx[band_idx] <= pRoom_acoustics->pFc_input_fx[band_idx - 1] ) - { - tab_value_err_count++; - } - } - - /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */ - if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] == 0 ) - { - pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; - } - } - - if ( tab_value_err_count != 0 ) - { - return IVAS_ERR_WRONG_PARAMS; - } - - - if ( pRoom_acoustics->use_er == 1 ) - { - /* Room dimensions */ - if ( pRoom_acoustics->dimensions.x < ER_MIN_ROOM_DIMENSION ) - { - pRoom_acoustics->dimensions.x = ER_MIN_ROOM_DIMENSION; - } - if ( pRoom_acoustics->dimensions.x_fx < ER_MIN_ROOM_DIMENSION_FX ) - { - pRoom_acoustics->dimensions.x_fx = ER_MIN_ROOM_DIMENSION_FX; - } - if ( pRoom_acoustics->dimensions.x > ER_MAX_ROOM_DIMENSION ) - { - pRoom_acoustics->dimensions.x = ER_MAX_ROOM_DIMENSION; - } - if ( pRoom_acoustics->dimensions.x_fx > ER_MAX_ROOM_DIMENSION_FX ) - { - pRoom_acoustics->dimensions.x_fx = ER_MAX_ROOM_DIMENSION_FX; - } - if ( pRoom_acoustics->dimensions.y < ER_MIN_ROOM_DIMENSION ) - { - pRoom_acoustics->dimensions.y = ER_MIN_ROOM_DIMENSION; - } - if ( pRoom_acoustics->dimensions.y_fx < ER_MIN_ROOM_DIMENSION_FX ) - { - pRoom_acoustics->dimensions.y_fx = ER_MIN_ROOM_DIMENSION_FX; - } - if ( pRoom_acoustics->dimensions.y > ER_MAX_ROOM_DIMENSION ) - { - pRoom_acoustics->dimensions.y = ER_MAX_ROOM_DIMENSION; - } - if ( pRoom_acoustics->dimensions.y_fx > ER_MAX_ROOM_DIMENSION_FX ) - { - pRoom_acoustics->dimensions.y_fx = ER_MAX_ROOM_DIMENSION_FX; - } - if ( pRoom_acoustics->dimensions.z < ER_MIN_ROOM_DIMENSION ) - { - pRoom_acoustics->dimensions.z = ER_MIN_ROOM_DIMENSION; - } - if ( pRoom_acoustics->dimensions.z_fx < ER_MIN_ROOM_DIMENSION_FX ) - { - pRoom_acoustics->dimensions.z_fx = ER_MIN_ROOM_DIMENSION_FX; - } - if ( pRoom_acoustics->dimensions.z > ER_MAX_ROOM_DIMENSION ) - { - pRoom_acoustics->dimensions.z = ER_MAX_ROOM_DIMENSION; - } - if ( pRoom_acoustics->dimensions.z_fx > ER_MAX_ROOM_DIMENSION_FX ) - { - pRoom_acoustics->dimensions.z_fx = ER_MAX_ROOM_DIMENSION_FX; - } - - /* Abs Coeff */ - for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) - { - if ( pRoom_acoustics->AbsCoeff[wall_idx] < ER_MIN_ABS_COEFF ) - { - pRoom_acoustics->AbsCoeff[wall_idx] = ER_MIN_ABS_COEFF; - } - if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] < ER_MIN_ABS_COEFF_FX ) - { - pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MIN_ABS_COEFF_FX; - } - if ( pRoom_acoustics->AbsCoeff[wall_idx] > ER_MAX_ABS_COEFF ) - { - pRoom_acoustics->AbsCoeff[wall_idx] = ER_MAX_ABS_COEFF; - } - if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] > ER_MAX_ABS_COEFF_FX ) - { - pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX; - } - } -#ifndef FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK - /* Verify range of distance attenuation parameters: 0.1 <= distAtt[0] <= distAtt[1] */ - /* 0.0 <= distAtt[2] <= 10.0 */ - hRenderConfig->distAtt[0] = max( 0.1f, hRenderConfig->distAtt[0] ); - hRenderConfig->distAtt[1] = max( hRenderConfig->distAtt[0], hRenderConfig->distAtt[1] ); - hRenderConfig->distAtt[2] = max( 0.0f, min( 10.0f, hRenderConfig->distAtt[2] ) ); - - /* Verify range of directivity patterns */ - for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) - { - hRenderConfig->directivity[i * 3] = max( 0.0f, min( 360.0f, hRenderConfig->directivity[i * 3] ) ); - hRenderConfig->directivity[i * 3 + 1] = max( 0.0f, min( 360.0f, hRenderConfig->directivity[i * 3 + 1] ) ); - hRenderConfig->directivity[i * 3 + 2] = max( 0.0f, min( 1.0f, hRenderConfig->directivity[i * 3 + 2] ) ); - } -#endif - } - - - return IVAS_ERR_OK; -} - -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_open() - * - * Allocates and initializes a renderer configuration reader instance - *------------------------------------------------------------------------------------------*/ - -ivas_error RenderConfigReader_open( - char *pConfigPath, /* i : renderer configuration file path */ - RenderConfigReader **ppRenderConfigReader /* o : RenderConfigReader handle */ -) -{ - RenderConfigReader *pSelf; - FILE *pConfigFile; - - /* Open the configuration file */ - if ( strlen( pConfigPath ) < 1 ) - { - return IVAS_ERR_FAILED_FILE_OPEN; - } - - pConfigFile = fopen( pConfigPath, "r" ); - - if ( !pConfigFile ) - { - return IVAS_ERR_FAILED_FILE_OPEN; - } - - pSelf = calloc( 1, sizeof( RenderConfigReader ) ); - pSelf->pConfigFile = pConfigFile; - pSelf->nFG = 0; - pSelf->pFG = NULL; - pSelf->nAE = 0; - pSelf->pAE = NULL; - pSelf->nDP = 0; - pSelf->pDP = NULL; - pSelf->distAtt[0] = -1; - - *ppRenderConfigReader = pSelf; - return IVAS_ERR_OK; -} - - -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_readBinary() - * - * Reads the binary configuration from a file - *------------------------------------------------------------------------------------------*/ - -static ivas_error RenderConfigReader_readBinary( - const char *pReverbConfigPath, /* i : Configuration file path */ - RenderConfigReader *pRenderConfigReader /* i/o: RenderConfigReader handle */ -) -{ - uint32_t file_size; - uint32_t value; - uint32_t signx, signy, k; - uint32_t i, m, n; - uint32_t nFG, nAE; - uint32_t nDP; - ivas_error error; - float freqHop; - uint32_t gridLen; - uint32_t subGridLen; - const float *pGrid; - FILE *pReverbConfigFile; - - /* Open the configuration file */ - pReverbConfigFile = fopen( pReverbConfigPath, "rb" ); - - if ( !pReverbConfigFile ) - { - return IVAS_ERR_FAILED_FILE_OPEN; - } - - /* Read the bitstream */ - fseek( pReverbConfigFile, 0, SEEK_END ); - file_size = ftell( pReverbConfigFile ); - rewind( pReverbConfigFile ); - - pRenderConfigReader->pBitstream = (uint8_t *) malloc( file_size * sizeof( uint8_t ) ); - if ( pRenderConfigReader->pBitstream == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - fread( pRenderConfigReader->pBitstream, sizeof( uint8_t ), file_size, pReverbConfigFile ); - pRenderConfigReader->length = file_size; - /* we read the config twice in the decoder, so reset the read offset here */ - pRenderConfigReader->readOffset = 0; - - /****************************/ - /* Read the presence flag */ - /****************************/ - if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - /* acoustic environment data available */ - if ( value == true ) - { - /****************************/ - /* Read the frequency grids */ - /****************************/ - - /* Number of frequency grids */ - if ( ( error = get_bin_count_or_index( pRenderConfigReader, &nFG ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* Allocate memory for the frequency grids */ - if ( nFG > 0 ) - { - if ( pRenderConfigReader->nFG > 0 ) - { - for ( n = 0; n < pRenderConfigReader->nFG; n++ ) - { - free( pRenderConfigReader->pFG[n].pFc ); - } - free( pRenderConfigReader->pFG ); - } - pRenderConfigReader->nFG = nFG; - if ( ( pRenderConfigReader->pFG = (FrequencyGrid *) malloc( pRenderConfigReader->nFG * sizeof( FrequencyGrid ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - for ( n = 0; n < nFG; n++ ) - { - /* Initialize memory pointers to allow safe freeing ico errors */ - pRenderConfigReader->pFG[n].pFc = NULL; - } - } - - /* Loop through the frequency grids read from the binary stream */ - for ( n = 0; n < nFG; n++ ) - { - /* Read the representation method */ - value = 0; - if ( ( error = read_bin_bits( pRenderConfigReader, &value, 2 ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* Process depending on the representation method */ - switch ( value ) - { - case FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES: - if ( ( error = get_bin_count_or_index( pRenderConfigReader, &pRenderConfigReader->pFG[n].nrBands ) ) != IVAS_ERR_OK ) - { - return error; - } - /* Allocate memory for the center frequency array */ - if ( ( pRenderConfigReader->pFG[n].pFc = (float *) malloc( pRenderConfigReader->pFG[n].nrBands * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - /* Read the individual frequencies */ - for ( m = 0; m < pRenderConfigReader->pFG[n].nrBands; m++ ) - { - if ( ( error = get_bin_frequency( pRenderConfigReader, &pRenderConfigReader->pFG[n].pFc[m] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - break; - case FREQ_GRID_MODE_START_HOP_AMOUNT: - if ( ( error = get_bin_count_or_index( pRenderConfigReader, &pRenderConfigReader->pFG[n].nrBands ) ) != IVAS_ERR_OK ) - { - return error; - } - /* Allocate memory for the center frequency array */ - if ( ( pRenderConfigReader->pFG[n].pFc = (float *) malloc( pRenderConfigReader->pFG[n].nrBands * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - /* Read the first frequency */ - if ( ( error = get_bin_frequency( pRenderConfigReader, &pRenderConfigReader->pFG[n].pFc[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - /* Read frequency hop from LUT */ - if ( ( error = read_bin_code_word( pRenderConfigReader, RC_LUT_FREQ_HOP, &freqHop ) ) != IVAS_ERR_OK ) - { - return error; - } - /* Fill up the center frequency array */ - for ( m = 1; m < pRenderConfigReader->pFG[n].nrBands; m++ ) - { - pRenderConfigReader->pFG[n].pFc[m] = pRenderConfigReader->pFG[n].pFc[m - 1] * freqHop; - } - break; - case FREQ_GRID_MODE_DEFAULT_BANDING: - /* Read the default grid ID */ - value = 0; - if ( ( error = read_bin_bits( pRenderConfigReader, &value, 4 ) ) != IVAS_ERR_OK ) - { - return error; - } - switch ( value ) - { - case 0: - gridLen = sizeof( defaultFrequencyGrid_0 ) / sizeof( defaultFrequencyGrid_0[0] ); - pGrid = defaultFrequencyGrid_0; - break; - case 1: - gridLen = sizeof( defaultFrequencyGrid_1 ) / sizeof( defaultFrequencyGrid_1[0] ); - pGrid = defaultFrequencyGrid_1; - break; - case 2: - gridLen = sizeof( defaultFrequencyGrid_2 ) / sizeof( defaultFrequencyGrid_2[0] ); - pGrid = defaultFrequencyGrid_2; - break; - case 3: - gridLen = sizeof( defaultFrequencyGrid_3 ) / sizeof( defaultFrequencyGrid_3[0] ); - pGrid = defaultFrequencyGrid_3; - break; - case 4: - gridLen = sizeof( defaultFrequencyGrid_4 ) / sizeof( defaultFrequencyGrid_4[0] ); - pGrid = defaultFrequencyGrid_4; - break; - case 5: - gridLen = sizeof( defaultFrequencyGrid_5 ) / sizeof( defaultFrequencyGrid_5[0] ); - pGrid = defaultFrequencyGrid_5; - break; - case 6: - gridLen = sizeof( defaultFrequencyGrid_6 ) / sizeof( defaultFrequencyGrid_6[0] ); - pGrid = defaultFrequencyGrid_6; - break; - case 7: - gridLen = sizeof( defaultFrequencyGrid_7 ) / sizeof( defaultFrequencyGrid_7[0] ); - pGrid = defaultFrequencyGrid_7; - break; - case 8: - gridLen = sizeof( defaultFrequencyGrid_8 ) / sizeof( defaultFrequencyGrid_8[0] ); - pGrid = defaultFrequencyGrid_8; - break; - default: - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - m = 0; - /* Read sub-grid flag */ - if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( value != false ) - { - /* Read the sub-grid offset */ - if ( ( error = read_bin_bits( pRenderConfigReader, &m, 3 ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* Read the sub-grid length */ - subGridLen = 0; - if ( ( error = read_bin_bits( pRenderConfigReader, &subGridLen, 6 ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( m + subGridLen > gridLen ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - gridLen = subGridLen; - } - pRenderConfigReader->pFG[n].nrBands = gridLen; - /* Allocate memory for the center frequency array */ - if ( ( pRenderConfigReader->pFG[n].pFc = (float *) malloc( gridLen * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - /* Copy the ROM content to the frequency grid*/ - for ( i = 0; i < gridLen; i++ ) - { - pRenderConfigReader->pFG[n].pFc[i] = pGrid[m + i]; - } - - break; - default: - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - /* Initialize memory pointers to allow safe freeing ico errors */ - pRenderConfigReader->pFG[n].pFc = NULL; - } - - /**********************************/ - /* Read the acoustic environments */ - /**********************************/ - - /* Number of acoustic environments */ - if ( ( error = get_bin_count_or_index( pRenderConfigReader, &nAE ) ) != IVAS_ERR_OK ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - /* Allocate memory for the acoustic environments array */ - if ( nAE > 0 ) - { - if ( pRenderConfigReader->nAE > 0 ) - { - for ( n = 0; n < pRenderConfigReader->nAE; n++ ) - { - free( pRenderConfigReader->pAE[n].pRT60 ); - free( pRenderConfigReader->pAE[n].pDSR ); - if ( pRenderConfigReader->pAE[n].pEarlyReflections != NULL ) - { - free( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin ); - free( pRenderConfigReader->pAE[n].pEarlyReflections ); - } - } - free( pRenderConfigReader->pAE ); - } - pRenderConfigReader->nAE = nAE; - - if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - /* Initialize memory pointers to allow safe freeing ico errors */ - for ( n = 0; n < nAE; n++ ) - { - pRenderConfigReader->pAE[n].pRT60 = NULL; - pRenderConfigReader->pAE[n].pDSR = NULL; - pRenderConfigReader->pAE[n].pEarlyReflections = NULL; - } - } - - /* Loop through the acoustic environments from the binary stream */ - for ( n = 0; n < nAE; n++ ) - { - /* Read the AE ID */ - if ( ( error = get_bin_id( pRenderConfigReader, &pRenderConfigReader->pAE[n].id ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* Read the frequency grid ID */ - if ( ( error = get_bin_count_or_index( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* Associate the frequency grid */ - if ( value >= pRenderConfigReader->nFG ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - pRenderConfigReader->pAE[n].pFG = &( pRenderConfigReader->pFG[value] ); - - /* Allocate memory for RT60 and DSR arrays */ - if ( ( pRenderConfigReader->pAE[n].pRT60 = (float *) malloc( pRenderConfigReader->pAE[n].pFG->nrBands * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - if ( ( pRenderConfigReader->pAE[n].pDSR = (float *) malloc( pRenderConfigReader->pAE[n].pFG->nrBands * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - /* Read the values */ - if ( ( error = get_bin_duration( pRenderConfigReader, &pRenderConfigReader->pAE[n].preDelay ) ) != IVAS_ERR_OK ) - { - return error; - } - - for ( m = 0; m < pRenderConfigReader->pAE[n].pFG->nrBands; m++ ) - { - if ( ( error = get_bin_duration( pRenderConfigReader, &pRenderConfigReader->pAE[n].pRT60[m] ) ) != IVAS_ERR_OK ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - for ( m = 0; m < pRenderConfigReader->pAE[n].pFG->nrBands; m++ ) - { - if ( ( error = get_bin_dsr( pRenderConfigReader, &pRenderConfigReader->pAE[n].pDSR[m] ) ) != IVAS_ERR_OK ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - - /*****************************************/ - /* Read the early reflections parameters */ - /*****************************************/ - - /* Has early reflections */ - if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( value == true ) - { - if ( ( pRenderConfigReader->pAE[n].pEarlyReflections = (EarlyReflectionsConfig *) malloc( sizeof( EarlyReflectionsConfig ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - /* Initialize memory pointers to allow safe freeing ico eg errors */ - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = NULL; - - pRenderConfigReader->pAE[n].pEarlyReflections->use_er = 1; - - /* Room sizes */ - if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z ) ) != IVAS_ERR_OK ) - { - return error; - } - - for ( k = 0; k < N_ABS_COEFFS; k++ ) - { - if ( ( error = get_bin_absorption( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[k] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - /* Has listener origin */ - if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( value == true ) - { - if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - if ( ( error = read_bin_bits( pRenderConfigReader, &signx, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = read_bin_bits( pRenderConfigReader, &signy, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( signx == 0 ) - { - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x *= -1.0f; - } - if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( signy == 0 ) - { - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y *= -1.0f; - } - if ( ( error = get_bin_distance( pRenderConfigReader, true, &pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else /* load defaults if origin is not specified in config */ - { - if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = IVAS_ER_LIST_ORIGIN_X; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = IVAS_ER_LIST_ORIGIN_Y; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = IVAS_ER_LIST_HEIGHT; - } - - /* Low complexity mode */ - if ( ( error = read_bin_bool( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - } - /**********************************/ - /* Read the directivity patterns */ - /**********************************/ - - /* Has source directivity */ - if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( value == true ) - { - - /* Number of directivity patterns */ - if ( ( error = get_bin_id( pRenderConfigReader, &nDP ) ) != IVAS_ERR_OK ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - if ( nDP > 0 ) - { - if ( pRenderConfigReader->nDP > 0 ) - { - for ( n = 0; n < pRenderConfigReader->nDP; n++ ) - { - free( pRenderConfigReader->pDP[n].pDirectivity ); - } - free( pRenderConfigReader->pDP ); - } - - pRenderConfigReader->nDP = nDP; - - if ( ( pRenderConfigReader->pDP = (DirectrivityPat *) malloc( pRenderConfigReader->nDP * sizeof( DirectrivityPat ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - for ( n = 0; n < nDP; n++ ) - { - /* Allocate memory for directivity arrays*/ - if ( ( pRenderConfigReader->pDP[n].pDirectivity = (float *) malloc( 3 * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - } - } - /* Loop through the directivity patterns from the binary stream */ - for ( n = 0; n < nDP; n++ ) - { - - /* Read the Directivity ID */ - if ( ( error = get_bin_id( pRenderConfigReader, &pRenderConfigReader->pDP[n].id ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = get_bin_angle( pRenderConfigReader, &pRenderConfigReader->pDP[n].pDirectivity[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = get_bin_angle( pRenderConfigReader, &pRenderConfigReader->pDP[n].pDirectivity[1] ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( ( error = get_bin_outer_attenuation( pRenderConfigReader, &pRenderConfigReader->pDP[n].pDirectivity[2] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - /**********************************/ - /* Read the distance attenuation */ - /**********************************/ - - /* Has distance attenuation */ - if ( ( error = read_bin_bool( pRenderConfigReader, &value ) ) != IVAS_ERR_OK ) - { - return error; - } - if ( value == true ) - { - /* Read the Max Distance */ - if ( ( error = get_bin_max_dist( pRenderConfigReader, &pRenderConfigReader->distAtt[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - /* Read the Ref Distance */ - if ( ( error = get_bin_ref_dist( pRenderConfigReader, &pRenderConfigReader->distAtt[1] ) ) != IVAS_ERR_OK ) - { - return error; - } - /* Read the Rolloff Facto r*/ - if ( ( error = get_bin_rolloff( pRenderConfigReader, &pRenderConfigReader->distAtt[2] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - - /* Cleanup */ - free( pRenderConfigReader->pBitstream ); - - return IVAS_ERR_OK; -} - - -ivas_error RenderConfigReader_read( - RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ - const char *pRenderConfigPath, /* i : Renderer configuration file path */ - IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ -) -{ - int32_t file_size; - char *pConfig_str; - char *pParams; - char *pTemp; - int32_t read_idx; - int32_t params_idx; - char item[MAX_ITEM_LENGTH + 1]; - char chapter[MAX_ITEM_LENGTH + 1]; - char *pValue; - ivas_error error; - int32_t params_length; - int32_t length; - uint32_t i, idx; - uint32_t nFG, nAE; - char *pToken; - FREQ_GRID_MODE fgMode; - float freqHop; - uint32_t acIdx; - uint32_t defGridId, defGridLen, defGridOffset, defGridNrBands; - const float *pDefGrid; - float erTemp[N_ABS_COEFFS]; - uint32_t roomAcHasFgCount, roomAcHasAcEnvCount; - uint32_t fgHasMethod, fgHasNBands, fgHasFreqs, fgHasDefaultGrid, fgHasStartFreq, fgHasFreqHop; - uint32_t aeHasFgIdx, aeHasPredelay, aeHasRt60, aeHasDsr; - uint32_t aeHasERsize, aeHasERabs; - bool dofProvided = false; - bool poseCorrProvided = false; - - uint32_t nDP; - uint32_t accDPIdx; - accDPIdx = 0; - - fseek( pRenderConfigReader->pConfigFile, 0, SEEK_END ); - file_size = ftell( pRenderConfigReader->pConfigFile ); - rewind( pRenderConfigReader->pConfigFile ); - pConfig_str = (char *) calloc( file_size + 1, sizeof( char ) ); - pParams = (char *) calloc( file_size + 1, sizeof( char ) ); - pTemp = (char *) calloc( file_size + 1, sizeof( char ) ); - acIdx = 0; - roomAcHasFgCount = roomAcHasAcEnvCount = FALSE; - setvbuf( pRenderConfigReader->pConfigFile, pConfig_str, _IONBF, sizeof( char ) ); /* Work-around for VS bug that gives incorrect ftell for UNIX-style line endings */ - - /* read file line by line */ - while ( fgets( pConfig_str, file_size, pRenderConfigReader->pConfigFile ) != NULL ) - { - - if ( sscanf( pConfig_str, "[%64[^]]]", chapter ) == 1 ) - { - /* read line by line (except comments) until next chapter or EOF */ - pParams[0] = '\0'; - do - { - read_idx = ftell( pRenderConfigReader->pConfigFile ); - if ( fgets( pTemp, file_size, pRenderConfigReader->pConfigFile ) == NULL ) - { - break; - } - - if ( ( pTemp[0] != '#' ) && ( sscanf( pTemp, "[%64[^]]]", item ) != 1 ) ) - { - /* ignore inline comments */ - sscanf( pTemp, "%[^#]", pTemp ); - strcat( pParams, pTemp ); - } - } while ( sscanf( pTemp, "[%64[^]]]", item ) != 1 ); - - /* go back one line */ - fseek( pRenderConfigReader->pConfigFile, read_idx, SEEK_SET ); - - strip_spaces( pParams ); - strcpy( pTemp, pParams ); - to_upper( pParams ); - to_upper( chapter ); - - /* interpret params */ - pToken = strtok( chapter, ":" ); - if ( strcmp( chapter, "ROOMACOUSTICS" ) == 0 && strlen( pParams ) != 0 ) - { - params_idx = 0; - pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); - - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); - if ( strcmp( item, "FREQUENCYGRIDCOUNT" ) == 0 ) - { - /* Read the number of frequency grids */ - if ( !sscanf( pValue, "%u", &nFG ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( nFG > 0 ) - { - for ( idx = 0; idx < pRenderConfigReader->nFG; idx++ ) - { - free( pRenderConfigReader->pFG[idx].pFc ); - } - free( pRenderConfigReader->pFG ); - - pRenderConfigReader->nFG = nFG; - - /* Allocate memory for the frequency grids */ - if ( ( pRenderConfigReader->pFG = (FrequencyGrid *) malloc( pRenderConfigReader->nFG * sizeof( FrequencyGrid ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - for ( idx = 0; idx < nFG; idx++ ) - { - pRenderConfigReader->pFG[idx].nrBands = 0; - pRenderConfigReader->pFG[idx].pFc = NULL; - } - } - roomAcHasFgCount = TRUE; - } - else if ( strcmp( item, "ACOUSTICENVIRONMENTCOUNT" ) == 0 ) - { - /* Read the number of acoustic environments */ - if ( !sscanf( pValue, "%u", &nAE ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( nAE > 0 ) - { - for ( idx = 0; idx < pRenderConfigReader->nAE; idx++ ) - { - free( pRenderConfigReader->pAE[idx].pRT60 ); - free( pRenderConfigReader->pAE[idx].pDSR ); - if ( pRenderConfigReader->pAE[idx].pEarlyReflections != NULL ) - { - free( pRenderConfigReader->pAE[idx].pEarlyReflections->pListenerOrigin ); - free( pRenderConfigReader->pAE[idx].pEarlyReflections ); - } - } - free( pRenderConfigReader->pAE ); - - pRenderConfigReader->nAE = nAE; - - /* Allocate memory for the acoustic environments array */ - if ( ( pRenderConfigReader->pAE = (AcousticEnv *) malloc( pRenderConfigReader->nAE * sizeof( AcousticEnv ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - /* Initialize memory pointers to allow for safe freeing */ - for ( acIdx = 0; acIdx < pRenderConfigReader->nAE; acIdx++ ) - { - pRenderConfigReader->pAE[acIdx].pRT60 = NULL; - pRenderConfigReader->pAE[acIdx].pDSR = NULL; - pRenderConfigReader->pAE[acIdx].pEarlyReflections = NULL; - } - } - acIdx = 0; - roomAcHasAcEnvCount = TRUE; - } - } - if ( roomAcHasFgCount == FALSE || roomAcHasAcEnvCount == FALSE ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - free( pValue ); - } - else if ( strcmp( pToken, "FREQUENCYGRID" ) == 0 ) - { - if ( pRenderConfigReader->pFG == NULL ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - idx = strtol( strtok( NULL, ":" ), NULL, 0 ); - if ( idx >= pRenderConfigReader->nFG ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - fgHasMethod = fgHasNBands = fgHasFreqs = fgHasDefaultGrid = fgHasStartFreq = fgHasFreqHop = FALSE; - fgMode = FREQ_GRID_MODE_UNKNOWN; - params_idx = 0; - pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); - if ( strcmp( item, "METHOD" ) == 0 ) - { - if ( strcmp( pValue, "INDIVIDUALFREQUENCIES" ) == 0 ) - { - fgMode = FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES; - } - else if ( strcmp( pValue, "STARTHOPAMOUNT" ) == 0 ) - { - fgMode = FREQ_GRID_MODE_START_HOP_AMOUNT; - } - else if ( strcmp( pValue, "DEFAULTBANDING" ) == 0 ) - { - fgMode = FREQ_GRID_MODE_DEFAULT_BANDING; - } - fgHasMethod = TRUE; - } - /* Read number of bands for individual frequency, start-hop-amount mode */ - else if ( strcmp( item, "NRBANDS" ) == 0 ) - { - if ( fgMode != FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES && fgMode != FREQ_GRID_MODE_START_HOP_AMOUNT ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( !sscanf( pValue, "%u", &pRenderConfigReader->pFG[idx].nrBands ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - /* Allocate memory for the center frequency array */ - if ( ( pRenderConfigReader->pFG[idx].pFc = (float *) malloc( pRenderConfigReader->pFG[idx].nrBands * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - fgHasNBands = TRUE; - } - else if ( strcmp( item, "FREQUENCIES" ) == 0 ) - { - if ( fgMode != FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES || pRenderConfigReader->pFG[idx].nrBands == 0 || pRenderConfigReader->pFG[idx].pFc == NULL ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - /* Read the individual frequencies */ - if ( read_txt_vector( pValue, pRenderConfigReader->pFG[idx].nrBands, pRenderConfigReader->pFG[idx].pFc ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - fgHasFreqs = TRUE; - } - else if ( strcmp( item, "STARTFREQUENCY" ) == 0 ) - { - if ( fgMode != FREQ_GRID_MODE_START_HOP_AMOUNT || pRenderConfigReader->pFG[idx].nrBands == 0 || pRenderConfigReader->pFG[idx].pFc == NULL ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( !sscanf( pValue, "%f", &pRenderConfigReader->pFG[idx].pFc[0] ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - fgHasStartFreq = TRUE; - } - else if ( strcmp( item, "FREQUENCYHOP" ) == 0 ) - { - if ( fgMode != FREQ_GRID_MODE_START_HOP_AMOUNT || pRenderConfigReader->pFG[idx].nrBands == 0 || pRenderConfigReader->pFG[idx].pFc == NULL || pRenderConfigReader->pFG[idx].pFc[0] == 0.0f ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( !sscanf( pValue, "%f", &freqHop ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - /* Fill up the center frequency array */ - for ( i = 1; i < pRenderConfigReader->pFG[idx].nrBands; i++ ) - { - pRenderConfigReader->pFG[idx].pFc[i] = pRenderConfigReader->pFG[idx].pFc[i - 1] * freqHop; - } - fgHasFreqHop = TRUE; - } - /* Handle default grids, with optional sub-grids */ - else if ( strcmp( item, "DEFAULTGRID" ) == 0 ) - { - if ( !sscanf( pValue, "%u", &defGridId ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - switch ( defGridId ) - { - case 0: - defGridLen = sizeof( defaultFrequencyGrid_0 ) / sizeof( defaultFrequencyGrid_0[0] ); - pDefGrid = defaultFrequencyGrid_0; - break; - case 1: - defGridLen = sizeof( defaultFrequencyGrid_1 ) / sizeof( defaultFrequencyGrid_1[0] ); - pDefGrid = defaultFrequencyGrid_1; - break; - case 2: - defGridLen = sizeof( defaultFrequencyGrid_2 ) / sizeof( defaultFrequencyGrid_2[0] ); - pDefGrid = defaultFrequencyGrid_2; - break; - case 3: - defGridLen = sizeof( defaultFrequencyGrid_3 ) / sizeof( defaultFrequencyGrid_3[0] ); - pDefGrid = defaultFrequencyGrid_3; - break; - case 4: - defGridLen = sizeof( defaultFrequencyGrid_4 ) / sizeof( defaultFrequencyGrid_4[0] ); - pDefGrid = defaultFrequencyGrid_4; - break; - case 5: - defGridLen = sizeof( defaultFrequencyGrid_5 ) / sizeof( defaultFrequencyGrid_5[0] ); - pDefGrid = defaultFrequencyGrid_5; - break; - case 6: - defGridLen = sizeof( defaultFrequencyGrid_6 ) / sizeof( defaultFrequencyGrid_6[0] ); - pDefGrid = defaultFrequencyGrid_6; - break; - case 7: - defGridLen = sizeof( defaultFrequencyGrid_7 ) / sizeof( defaultFrequencyGrid_7[0] ); - pDefGrid = defaultFrequencyGrid_7; - break; - case 8: - defGridLen = sizeof( defaultFrequencyGrid_8 ) / sizeof( defaultFrequencyGrid_8[0] ); - pDefGrid = defaultFrequencyGrid_8; - break; - default: - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - fgHasDefaultGrid = TRUE; - - /* Handle sub-grids */ - defGridOffset = 0; - defGridNrBands = defGridLen; - - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - if ( strcmp( item, "DEFAULTGRIDOFFSET" ) == 0 ) - { - if ( !sscanf( pValue, "%u", &defGridOffset ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - else if ( strcmp( item, "DEFAULTGRIDNRBANDS" ) == 0 ) - { - if ( !sscanf( pValue, "%u", &defGridNrBands ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - else - { - break; - } - params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); - } - - if ( defGridOffset + defGridNrBands > defGridLen ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - pRenderConfigReader->pFG[idx].nrBands = defGridNrBands; - - /* Allocate memory for the center frequency array */ - if ( ( pRenderConfigReader->pFG[idx].pFc = (float *) malloc( defGridNrBands * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - /* Copy the ROM content to the frequency grid*/ - for ( i = 0; i < defGridNrBands; i++ ) - { - pRenderConfigReader->pFG[idx].pFc[i] = pDefGrid[defGridOffset + i]; - } - } - } - if ( fgHasMethod == FALSE || - ( fgMode == FREQ_GRID_MODE_INDIVIDUAL_FREQUENCIES && ( fgHasFreqs == FALSE || fgHasNBands == FALSE ) ) || - ( fgMode == FREQ_GRID_MODE_DEFAULT_BANDING && fgHasDefaultGrid == FALSE ) || - ( fgMode == FREQ_GRID_MODE_START_HOP_AMOUNT && ( fgHasStartFreq == FALSE || fgHasFreqHop == FALSE || fgHasNBands == FALSE ) ) ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - free( pValue ); - } - /* Handle multiple acoustic environments */ - else if ( strcmp( pToken, "ACOUSTICENVIRONMENT" ) == 0 ) - { - if ( pRenderConfigReader->pAE == NULL || acIdx >= pRenderConfigReader->nAE ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - idx = strtol( strtok( NULL, ":" ), NULL, 0 ); - pRenderConfigReader->pAE[acIdx].id = idx; - - aeHasFgIdx = aeHasPredelay = aeHasRt60 = aeHasDsr = FALSE; - aeHasERsize = aeHasERabs = FALSE; - params_idx = 0; - pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); - /* Frequency grid index */ - if ( strcmp( item, "FREQUENCYGRIDINDEX" ) == 0 ) - { - if ( !sscanf( pValue, "%u", &i ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( i >= pRenderConfigReader->nFG || pRenderConfigReader->pFG[i].pFc == NULL ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - pRenderConfigReader->pAE[acIdx].pFG = &pRenderConfigReader->pFG[i]; - - /* Allocate memory for RT60 and DSR arrays */ - if ( ( pRenderConfigReader->pAE[acIdx].pRT60 = (float *) malloc( pRenderConfigReader->pAE[acIdx].pFG->nrBands * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - if ( ( pRenderConfigReader->pAE[acIdx].pDSR = (float *) malloc( pRenderConfigReader->pAE[acIdx].pFG->nrBands * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - aeHasFgIdx = TRUE; - } - - /* Acoustic pre-delay */ - else if ( strcmp( item, "ACOUSTICPREDELAY" ) == 0 ) - { - float f; - if ( !sscanf( pValue, "%f", &f ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - hRenderConfig->roomAcoustics.acousticPreDelay_fx = (Word32) ( f * ONE_IN_Q27 ); - } - /* Pre-delay */ - else if ( strcmp( item, "PREDELAY" ) == 0 ) - { - if ( !sscanf( pValue, "%f", &pRenderConfigReader->pAE[acIdx].preDelay ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - aeHasPredelay = TRUE; - } - /* RT60 */ - else if ( strcmp( item, "RT60" ) == 0 ) - { - if ( read_txt_vector( pValue, pRenderConfigReader->pAE[acIdx].pFG->nrBands, pRenderConfigReader->pAE[acIdx].pRT60 ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - aeHasRt60 = TRUE; - } - /* DSR */ - else if ( strcmp( item, "DSR" ) == 0 ) - { - if ( read_txt_vector( pValue, pRenderConfigReader->pAE[acIdx].pFG->nrBands, pRenderConfigReader->pAE[acIdx].pDSR ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - aeHasDsr = TRUE; - } - else if ( strcmp( item, "EARLYREFLECTIONSSIZE" ) == 0 ) - { - if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) - { - if ( ( pRenderConfigReader->pAE[acIdx].pEarlyReflections = (EarlyReflectionsConfig *) malloc( sizeof( EarlyReflectionsConfig ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin = NULL; - pRenderConfigReader->pAE[acIdx].pEarlyReflections->lowComplexity = FALSE; - } - if ( strcmp( item, "EARLYREFLECTIONSSIZE" ) == 0 ) - { - if ( read_txt_vector( pValue, 3, erTemp ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - pRenderConfigReader->pAE[acIdx].pEarlyReflections->dimensions.x = erTemp[0]; - pRenderConfigReader->pAE[acIdx].pEarlyReflections->dimensions.y = erTemp[1]; - pRenderConfigReader->pAE[acIdx].pEarlyReflections->dimensions.z = erTemp[2]; - aeHasERsize = TRUE; - } - } - else if ( strcmp( item, "ABSORPTIONCOEFFS" ) == 0 ) - { - if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( read_txt_vector( pValue, N_ABS_COEFFS, erTemp ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - for ( i = 0; i < N_ABS_COEFFS; i++ ) - { - pRenderConfigReader->pAE[acIdx].pEarlyReflections->pAbsCoeff[i] = erTemp[i]; - } - aeHasERabs = TRUE; - } - else if ( strcmp( item, "LISTENERORIGIN" ) == 0 ) - { - if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( read_txt_vector( pValue, 3, erTemp ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( ( pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin->x = erTemp[0]; - pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin->y = erTemp[1]; - pRenderConfigReader->pAE[acIdx].pEarlyReflections->pListenerOrigin->z = erTemp[2]; - } - else if ( strcmp( item, "LOWCOMPLEXITY" ) == 0 ) - { - if ( pRenderConfigReader->pAE[acIdx].pEarlyReflections == NULL ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( read_txt_bool( pValue, &pRenderConfigReader->pAE[acIdx].pEarlyReflections->lowComplexity ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - } - if ( aeHasFgIdx == FALSE || aeHasPredelay == FALSE || aeHasRt60 == FALSE || aeHasDsr == FALSE ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( aeHasERsize == TRUE && aeHasERabs == FALSE ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - else if ( aeHasERsize == TRUE && aeHasERabs == TRUE ) - { - pRenderConfigReader->pAE[acIdx].pEarlyReflections->use_er = 1; - } - - free( pValue ); - acIdx++; - } - else if ( strcmp( chapter, "SPLITREND" ) == 0 && strlen( pParams ) != 0 ) - { - params_idx = 0; - pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - fprintf( stderr, " PARAM: %s -> %s\n", item, pValue ); -#endif - if ( strcmp( item, "CODECDELAY" ) == 0 ) - { - if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.codec_delay_ms ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - } - else if ( strcmp( item, "HQMODE" ) == 0 ) - { - if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.hq_mode ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - } - else if ( strcmp( item, "BITRATE" ) == 0 ) - { - if ( !sscanf( pValue, "%d", &hRenderConfig->split_rend_config.splitRendBitRate ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - } - else if ( strcmp( item, "DOF" ) == 0 ) - { - dofProvided = true; - if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.dof ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - /* 0 DOF implies no pose correction */ - if ( hRenderConfig->split_rend_config.dof == 0 && !poseCorrProvided ) - { - hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; - } - } - else if ( strcmp( item, "CODEC" ) == 0 ) - { - if ( strcmp( pValue, "LCLD" ) == 0 ) - { - hRenderConfig->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_LCLD; - } - else if ( strcmp( pValue, "LC3PLUS" ) == 0 ) - { - hRenderConfig->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_LC3PLUS; - } - else - { - errorHandler( pValue, ERROR_VALUE_INVALID ); - } - } - else if ( strcmp( item, "FRAMESIZE" ) == 0 ) - { - if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.codec_frame_size_ms ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - if ( hRenderConfig->split_rend_config.codec_frame_size_ms != 5 && - hRenderConfig->split_rend_config.codec_frame_size_ms != 10 && - hRenderConfig->split_rend_config.codec_frame_size_ms != 20 ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - } - else if ( strcmp( item, "POSECORRECTION" ) == 0 ) - { - poseCorrProvided = true; - if ( strcmp( pValue, "CLDFB" ) == 0 ) - { - hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; - } - else if ( strcmp( pValue, "NONE" ) == 0 ) - { - hRenderConfig->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; - /* no pose correction implies 0 DOF */ - if ( !dofProvided ) - { - hRenderConfig->split_rend_config.dof = 0; - } - } - else - { - errorHandler( pValue, ERROR_VALUE_INVALID ); - } - } - else if ( strcmp( item, "RENDERER" ) == 0 ) - { - if ( strcmp( pValue, "CREND" ) == 0 ) - { - hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_CREND; - } - else if ( strcmp( pValue, "FASTCONV" ) == 0 ) - { - hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_FASTCONV; - } - else if ( strcmp( pValue, "PARAMBIN" ) == 0 ) - { - hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_PARAMBIN; - } - else if ( strcmp( pValue, "TDREND" ) == 0 ) - { - hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_TDREND; - } - else - { - errorHandler( pValue, ERROR_VALUE_INVALID ); - } - } - else if ( strcmp( item, "LC3PLUS_HIGHRES" ) == 0 ) - { - if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.lc3plus_highres ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - } -#ifdef DEBUGGING - else - { - fprintf( stderr, "Unsupported configuration property %s\n", item ); - } -#endif - } - free( pValue ); - } - else if ( strcmp( chapter, "DIRECTIVITYSETTING" ) == 0 && strlen( pParams ) != 0 ) - { - params_idx = 0; - pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); - - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); - if ( strcmp( item, "DIRECTIVITYCOUNT" ) == 0 ) - { - /* Read the number of directivity chapters */ - if ( !sscanf( pValue, "%u", &nDP ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - if ( nDP > 0 ) - { - for ( idx = 0; idx < pRenderConfigReader->nDP; idx++ ) - { - free( pRenderConfigReader->pDP[idx].pDirectivity ); - } - - free( pRenderConfigReader->pDP ); - pRenderConfigReader->nDP = nDP; - - /* Allocate memory for the directivity pattern*/ - if ( ( pRenderConfigReader->pDP = (DirectrivityPat *) malloc( pRenderConfigReader->nDP * sizeof( DirectrivityPat ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - for ( idx = 0; idx < nDP; idx++ ) - { - pRenderConfigReader->pDP[idx].pDirectivity = NULL; - } - } - accDPIdx = 0; - } - } - free( pValue ); - } - else if ( strcmp( pToken, "DIRECTIVITYPATTERN" ) == 0 ) - { - if ( pRenderConfigReader->pDP == NULL || accDPIdx >= pRenderConfigReader->nDP ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - idx = strtol( strtok( NULL, ":" ), NULL, 0 ); - - params_idx = 0; - pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); - /* Allocate memory for directivity arrays*/ - if ( ( pRenderConfigReader->pDP[accDPIdx].pDirectivity = (float *) malloc( 3 * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - - pRenderConfigReader->pDP[accDPIdx].id = idx; - - if ( strcmp( item, "DIRECTIVITY" ) == 0 ) - { - if ( read_txt_vector( pValue, 3, pRenderConfigReader->pDP[accDPIdx].pDirectivity ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - } - free( pValue ); - accDPIdx++; - } - else if ( strcmp( chapter, "DISTANCEATTENUATION" ) == 0 ) - { - params_idx = 0; - pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); - - /* Set default values if parameters are only partially specified */ - pRenderConfigReader->distAtt[0] = 15.75f; - pRenderConfigReader->distAtt[1] = 1.0f; - pRenderConfigReader->distAtt[2] = 1.0f; - - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - params_idx += (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); - - if ( strcmp( item, "MAXDIST" ) == 0 ) - { - /* Read the Maximum distance */ - if ( !sscanf( pValue, "%f", &pRenderConfigReader->distAtt[0] ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - if ( strcmp( item, "REFDIST" ) == 0 ) - { - /* Read the Reference distance */ - if ( !sscanf( pValue, "%f", &pRenderConfigReader->distAtt[1] ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - if ( strcmp( item, "ROLLOFFFACTOR" ) == 0 ) - { - /* Read the Rolloff Factor */ - if ( !sscanf( pValue, "%f", &pRenderConfigReader->distAtt[2] ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - } - } - - free( pValue ); - } - else if ( strcmp( chapter, "GENERAL" ) == 0 && strlen( pParams ) != 0 ) - { - params_idx = 0; - pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); - while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) - { - params_length = (int32_t) ( strlen( item ) + strlen( pValue ) + 2 ); - if ( strcmp( item, "BINARYCONFIG" ) == 0 ) - { - /* get correct case reverb configuration file path */ - sscanf( pTemp + params_idx, "%*[^=] = %[^;];", pValue ); - - /* make reverb configuration file path relative to render configuration file path */ - for ( length = (int32_t) strlen( pRenderConfigPath ) - 1; length >= 0; length-- ) - { - if ( pRenderConfigPath[length] == '\\' || pRenderConfigPath[length] == '/' ) - { - length++; - break; - } - } - if ( length < 0 ) - { - /* no slash found */ - length = 0; - } - char *pCombinedName = calloc( length + (int32_t) strlen( pValue ) + 1, sizeof( char ) ); - strncpy( pCombinedName, pRenderConfigPath, length ); - strcpy( pCombinedName + length, pValue ); - - if ( ( error = RenderConfigReader_readBinary( pCombinedName, pRenderConfigReader ) ) != IVAS_ERR_OK ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - free( pCombinedName ); - } - else if ( strcmp( item, "DIRECTIVITY" ) == 0 ) - { - if ( read_txt_vector( pValue, 3, hRenderConfig->directivity ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - } - params_idx += params_length; - } - free( pValue ); - } - else - { - fprintf( stderr, "Unknown chapter: %s\n", chapter ); - } - } - else if ( pConfig_str[0] == '#' ) - { - /* comment lines are to be ignored */ - } - } - - free( pConfig_str ); - free( pParams ); - free( pTemp ); - - if ( errorHandler( "", ERROR_NONE ) > 0 ) - { - fprintf( stderr, "Errors occurred\n" ); - return IVAS_ERR_FAILED_FILE_PARSE; - } - return IVAS_ERR_OK; -} - -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_getAcousticEnvironmentCount() - * - * Gets number of acoustic environments available - *------------------------------------------------------------------------------------------*/ -uint32_t RenderConfigReader_getAcousticEnvironmentCount( - RenderConfigReader *pRenderConfigReader /* i : RenderConfigReader handle */ -) -{ - return pRenderConfigReader->nAE; -} - -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_getAcousticEnvironments() - * - * Gets all acoustic environments - *------------------------------------------------------------------------------------------*/ -ivas_error RenderConfigReader_getAcousticEnvironments( - RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ - IVAS_ROOM_ACOUSTICS_CONFIG_DATA **ppAcEnv /* o : Acoustic environment array pointer */ -) -{ - uint16_t n, m, j; - - if ( pRenderConfigReader == NULL || ppAcEnv == NULL || pRenderConfigReader->nAE == 0 || pRenderConfigReader->pAE == NULL ) - { - return 0; - } - - for ( n = 0; n < pRenderConfigReader->nAE; n++ ) - { - AcousticEnv pIn = pRenderConfigReader->pAE[n]; - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pOut = ppAcEnv[n]; - - pOut->aeID = (Word16) pIn.id; - pOut->nBands = (Word16) pIn.pFG->nrBands; - pOut->inputPreDelay_fx = (Word32) ( pIn.preDelay * ONE_IN_Q27 ); - - for ( m = 0; m < pOut->nBands; m++ ) - { - pOut->pFc_input_fx[m] = (Word32) ( pIn.pFG->pFc[m] * ONE_IN_Q16 ); - pOut->pAcoustic_rt60_fx[m] = (Word32) ( pIn.pRT60[m] * ONE_IN_Q26 ); - pOut->pAcoustic_dsr_fx[m] = (Word32) ( pIn.pDSR[m] * ONE_IN_Q30 ); - } - - /* If ER are allocated then propagate parameters */ - if ( pIn.pEarlyReflections != 0 ) - { - pOut->use_er = pIn.pEarlyReflections->use_er; /* ER activation flag */ - pOut->lowComplexity = pIn.pEarlyReflections->lowComplexity; /* Low complexity flag */ - pOut->dimensions = pIn.pEarlyReflections->dimensions; - pOut->dimensions.x_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x * ONE_IN_Q22 ); - pOut->dimensions.y_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y * ONE_IN_Q22 ); - pOut->dimensions.z_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z * ONE_IN_Q22 ); - - /* Use default listener origin position if non provided */ - if ( pIn.pEarlyReflections->pListenerOrigin == NULL ) - { - - pOut->ListenerOrigin.x_fx = IVAS_ER_LIST_ORIGIN_X_FX; - pOut->ListenerOrigin.y_fx = IVAS_ER_LIST_ORIGIN_Y_FX; - pOut->ListenerOrigin.z_fx = IVAS_ER_LIST_HEIGHT_FX; - pOut->ListenerOrigin.q_fact = Q22; - } - else - { - pOut->ListenerOrigin.x_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx; - pOut->ListenerOrigin.y_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx; - pOut->ListenerOrigin.z_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx; - } - - for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) - { - pOut->AbsCoeff_fx[j] = (Word32) ( pIn.pEarlyReflections->pAbsCoeff[j] * ONE_IN_Q30 ); - } - } - else - { - pOut->use_er = false; - } - } - - return IVAS_ERR_OK; -} -#endif - -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_getAcousticEnvironment() - * - * Gets Acoustic environment with a given ID - *------------------------------------------------------------------------------------------*/ - -ivas_error RenderConfigReader_getAcousticEnvironment( - RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ - uint16_t id, /* i : Acoustic environment ID */ - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Target acoustic environment pointer */ -) -{ - uint16_t n, m; - uint16_t j; - - if ( pRenderConfigReader == NULL || pAcEnv == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - /* case when -aeid is not specified, select first ID from config file */ -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - if ( id == (UWord16) IVAS_DEFAULT_AEID && pRenderConfigReader->nAE > 0 ) -#else - if ( id == 65535 && pRenderConfigReader->nAE > 0 ) -#endif - { - id = (uint16_t) pRenderConfigReader->pAE[0].id; - } - - for ( n = 0; n < pRenderConfigReader->nAE; n++ ) - { - if ( id == pRenderConfigReader->pAE[n].id ) - { - pAcEnv->nBands = (int16_t) pRenderConfigReader->pAE[n].pFG->nrBands; - pAcEnv->inputPreDelay_fx = (Word32) ( pRenderConfigReader->pAE[n].preDelay * ONE_IN_Q27 ); - if ( pRenderConfigReader->pAE[n].preDelay > INPUTPREDELAY_MAX || - pRenderConfigReader->pAE[n].preDelay < INPUTPREDELAY_MIN ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - for ( m = 0; m < pAcEnv->nBands; m++ ) - { - if ( pRenderConfigReader->pAE[n].pFG->pFc[m] > FC_INPUT_MAX || - pRenderConfigReader->pAE[n].pFG->pFc[m] < FC_INPUT_MIN || - pRenderConfigReader->pAE[n].pRT60[m] > ACOUSTIC_RT60_MAX || - pRenderConfigReader->pAE[n].pRT60[m] < ACOUSTIC_RT60_MIN || - pRenderConfigReader->pAE[n].pDSR[m] > ACOUSTIC_DSR_MAX || - pRenderConfigReader->pAE[n].pDSR[m] < ACOUSTIC_DSR_MIN ) - { - return IVAS_ERR_INVALID_RENDER_CONFIG; - } - - pAcEnv->pFc_input_fx[m] = (Word32) ( pRenderConfigReader->pAE[n].pFG->pFc[m] * ONE_IN_Q16 ); - pAcEnv->pAcoustic_rt60_fx[m] = (Word32) ( pRenderConfigReader->pAE[n].pRT60[m] * ONE_IN_Q26 ); - pAcEnv->pAcoustic_dsr_fx[m] = (Word32) ( pRenderConfigReader->pAE[n].pDSR[m] * ONE_IN_Q30 ); - } - - /* If ER are allocated then propagate parameters */ - if ( pRenderConfigReader->pAE[n].pEarlyReflections != 0 ) - { - pAcEnv->use_er = pRenderConfigReader->pAE[n].pEarlyReflections->use_er; /* ER activation flag */ - pAcEnv->lowComplexity = pRenderConfigReader->pAE[n].pEarlyReflections->lowComplexity; /* Low complexity flag */ - pAcEnv->dimensions = pRenderConfigReader->pAE[n].pEarlyReflections->dimensions; - pAcEnv->dimensions.x_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.x * ONE_IN_Q22 ); - pAcEnv->dimensions.y_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.y * ONE_IN_Q22 ); - pAcEnv->dimensions.z_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->dimensions.z * ONE_IN_Q22 ); - /* Use default listener origin position if non provided */ - if ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin == NULL ) - { - if ( ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = IVAS_ER_LIST_ORIGIN_X; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = IVAS_ER_LIST_ORIGIN_Y; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = IVAS_ER_LIST_HEIGHT; - - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx = IVAS_ER_LIST_ORIGIN_X_FX; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx = IVAS_ER_LIST_ORIGIN_Y_FX; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx = IVAS_ER_LIST_HEIGHT_FX; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->q_fact = Q22; - } - else - { - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x * ONE_IN_Q22 ); - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y * ONE_IN_Q22 ); - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z * ONE_IN_Q22 ); - } - pAcEnv->ListenerOrigin = *pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin; - for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) - { - pAcEnv->AbsCoeff[j] = pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[j]; - pAcEnv->AbsCoeff_fx[j] = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[j] * ONE_IN_Q30 ); - } - } - else - { - pAcEnv->use_er = false; - } - return IVAS_ERR_OK; - } - } - return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; -} - -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_getDirectivity() - * - * Gets Directivity DirectrivityPatern with a given ID - *------------------------------------------------------------------------------------------*/ - -ivas_error RenderConfigReader_getDirectivity( - RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ - uint16_t *id, /* i : Directivity pattern ID */ - Word16 *directivity_fx /* o : Target directivity */ -) -{ - uint16_t n, m, i; - uint16_t last_specified_id; - bool idExists; - float directivity[12]; - - if ( pRenderConfigReader == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - if ( pRenderConfigReader->pDP == NULL ) - { - for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) - { - directivity[n * 3] = 360.0f; - directivity[n * 3 + 1] = 360.0f; - directivity[n * 3 + 2] = 1.0f; - } - } - else - { - last_specified_id = id[0]; - - /* set unpspecified Directivity Patterns ID to last specified ID */ - for ( n = MAX_NUM_OBJECTS - 1; n > 0; n-- ) - { - if ( id[n] != 65535 ) - { - last_specified_id = id[n]; - break; - } - } - /* case when -dpid is not specified, select first directivity pattern from config file */ - move16(); - if ( last_specified_id == 65535 ) - { - last_specified_id = (uint16_t) pRenderConfigReader->pDP[0].id; - } - - for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) - { - id[n] = last_specified_id; - } - - for ( n = 0; n < IVAS_MAX_NUM_OBJECTS; n++ ) - { - idExists = false; - for ( m = 0; m < pRenderConfigReader->nDP; m++ ) - { - if ( id[n] == pRenderConfigReader->pDP[m].id ) - { - idExists = true; - for ( i = 0; i < 3; i++ ) - { - directivity[n * 3 + i] = pRenderConfigReader->pDP[m].pDirectivity[i]; - } - - break; - } - } - if ( !idExists ) - { - return IVAS_ERR_DIRECTIVITY_PATTERN_ID_MISSING; - } - } - } - - /* Convert to Word16 */ - FOR( n = 0; n < 4; n++ ) - { - directivity_fx[n * 3] = (Word16) ( directivity[n * 3] * ( 1u << 6 ) ); - directivity_fx[n * 3 + 1] = (Word16) ( directivity[n * 3 + 1] * ( 1u << 6 ) ); - directivity_fx[n * 3 + 2] = (Word16) ( directivity[n * 3 + 2] * ( ( 1u << 15 ) - 1 ) ); - } - - return IVAS_ERR_OK; -} - - -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_getDistanceAttenuation() - * - * Gets Distance Attenuation - *------------------------------------------------------------------------------------------*/ - -ivas_error RenderConfigReader_getDistanceAttenuation( - RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ - - Word32 *distAtt_fx /* o : Distance attenuation */ -) -{ - float distAtt[3]; - - if ( pRenderConfigReader->distAtt[0] == -1 ) - { - distAtt[0] = 15.75f; - distAtt[1] = 1.0f; - distAtt[2] = 1.0f; - } - else - { - distAtt[0] = pRenderConfigReader->distAtt[0]; - distAtt[1] = pRenderConfigReader->distAtt[1]; - distAtt[2] = pRenderConfigReader->distAtt[2]; - } - - /* Convert to Word32 */ - distAtt_fx[0] = (Word32) ( distAtt[0] * ( 1u << 27 ) ); - distAtt_fx[1] = (Word32) ( distAtt[1] * ( 1u << 30 ) ); - distAtt_fx[2] = (Word32) ( distAtt[2] * ( 1u << 30 ) ); - - return IVAS_ERR_OK; -} - -/*------------------------------------------------------------------------------------------* - * RenderConfigReader_close() - * - * Closes the renderer configuration reader and deallocates memory - *------------------------------------------------------------------------------------------*/ - -void RenderConfigReader_close( - RenderConfigReader **ppRenderConfigReader /* i : RenderConfigReader handle */ -) -{ - uint32_t n; - - if ( ppRenderConfigReader == NULL || *ppRenderConfigReader == NULL ) - { - return; - } - - /* Free the acoustic environments */ - for ( n = 0; n < ( *ppRenderConfigReader )->nAE; n++ ) - { - if ( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections != NULL ) - { - free( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections->pListenerOrigin ); - free( ( *ppRenderConfigReader )->pAE[n].pEarlyReflections ); - } - free( ( *ppRenderConfigReader )->pAE[n].pRT60 ); - free( ( *ppRenderConfigReader )->pAE[n].pDSR ); - } - free( ( *ppRenderConfigReader )->pAE ); - - /* Free the frequency grids */ - for ( n = 0; n < ( *ppRenderConfigReader )->nFG; n++ ) - { - free( ( *ppRenderConfigReader )->pFG[n].pFc ); - } - free( ( *ppRenderConfigReader )->pFG ); - /* Free the directivity patterns */ - for ( n = 0; n < ( *ppRenderConfigReader )->nDP; n++ ) - { - free( ( *ppRenderConfigReader )->pDP[n].pDirectivity ); - } - free( ( *ppRenderConfigReader )->pDP ); - fclose( ( *ppRenderConfigReader )->pConfigFile ); - free( *ppRenderConfigReader ); - - return; -} diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index a212c79b7..1efe5d2b4 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2945,7 +2945,7 @@ ivas_error RenderConfigReader_getAcousticEnvironments( for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) { - pOut->AbsCoeff[j] = (Word32) ( pIn.pEarlyReflections->pAbsCoeff[j] ); + pOut->AbsCoeff[j] = pIn.pEarlyReflections->pAbsCoeff[j]; pOut->AbsCoeff_fx[j] = (Word32) ( pIn.pEarlyReflections->pAbsCoeff[j] * ONE_IN_Q30 ); } } -- GitLab From 145155312d1ca24c46a15574e82a3a2169e06cc8 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 21:40:44 +0200 Subject: [PATCH 273/351] Fix gain ranges for reverse ISM gain --- lib_util/ivas_rtp_pi_data.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index c9583e048..e02e2023e 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -757,13 +757,13 @@ static ivas_error packReverseISMGain( const IVAS_PIDATA_GENERIC *piData, uint8_t buffer[nBytes++] = ( r_ism_gain->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */ gain = (int16_t) r_ism_gain->dB; - idx = min( -gain, 97 ); + idx = min( -gain, 25 ); if ( gain > 0 ) { - idx += 97; + idx += 25; } - buffer[nBytes++] = ( idx & MASK_7BIT ) << 1; + buffer[nBytes++] = ( idx & MASK_6BIT ) << 2; *nBytesWritten = nBytes; return IVAS_ERR_OK; } @@ -785,19 +785,19 @@ static ivas_error unpackReverseISMGain( const uint8_t *buffer, uint32_t numDataB /* Unpack gain */ idx = ( *buffer ) >> 1; /* negative gains*/ - if ( idx < 97 ) + if ( idx < 25 ) { r_ism_gain->dB = -(int8_t) ( idx ); } /* Set to min for muting, to be interpreted as -Inf */ - else if ( idx == 97 ) + else if ( idx == 25 ) { r_ism_gain->dB = -128; } /* postive gains */ - else if ( idx < 101 ) + else if ( idx < 38 ) { - r_ism_gain->dB = (int8_t) idx - 97; + r_ism_gain->dB = (int8_t) idx - 25; } else { -- GitLab From 33fcfb9d760c49c9f791df90676e10f4225b5f4c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 10 Nov 2025 20:59:36 +0100 Subject: [PATCH 274/351] add disabled FIX_I4_OL_PITCH --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index 9865b30c6..da5b38dfb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -73,6 +73,7 @@ #endif /* ################### Start FIXES switches ########################### */ +/*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define REMOVE_BASOP_Util_Divide3232_Scale_cadence /* remove this division variant */ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ -- GitLab From 09777c860a7f4c330fa6ce5aa66db4f7bd698005 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 22:09:43 +0200 Subject: [PATCH 275/351] Change while loop to for loop --- lib_dec/lib_dec_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 6fe7006c7..f367927ee 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6594,7 +6594,8 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi { ivas_error error = IVAS_ERR_OK; move32(); - WHILE( numPiData ) + UWord32 i; + FOR( i = 0; i < numPiData; i++ ) { UWord32 piDataType = piData->data.noPiData.piDataType; move32(); -- GitLab From a158757e9dfbfd42f1cd7cd995afaacc5b87d535 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 22:11:42 +0200 Subject: [PATCH 276/351] Clang format --- lib_util/ivas_rtp_file.c | 82 ++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index aca878b35..4ef3578f6 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -175,28 +175,28 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, ",\n" ); } - while ( nPiDataPresent-- > 0 ) - { - const PIDATA_TS *cur = piData++; + while ( nPiDataPresent-- > 0 ) + { + const PIDATA_TS *cur = piData++; - if ( timestamp != ( ~0u ) && timestamp != cur->timestamp ) - { - fprintf( f_piDataOut, "\n\t},\n\t\"%d\": {\n", cur->timestamp ); - } - else if ( timestamp != cur->timestamp ) - { - fprintf( f_piDataOut, "\t\"%d\": {\n", cur->timestamp ); - } - else - { - fprintf( f_piDataOut, ",\n" ); - } - fprintf( f_piDataOut, "\t\t\"%s\" : ", PiDataNames[cur->data.noPiData.piDataType] ); - switch ( cur->data.noPiData.piDataType ) - { - case IVAS_PI_SCENE_ORIENTATION: - case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: - case IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED: + if ( timestamp != ( ~0u ) && timestamp != cur->timestamp ) + { + fprintf( f_piDataOut, "\n\t},\n\t\"%d\": {\n", cur->timestamp ); + } + else if ( timestamp != cur->timestamp ) + { + fprintf( f_piDataOut, "\t\"%d\": {\n", cur->timestamp ); + } + else + { + fprintf( f_piDataOut, ",\n" ); + } + fprintf( f_piDataOut, "\t\t\"%s\" : ", PiDataNames[cur->data.noPiData.piDataType] ); + switch ( cur->data.noPiData.piDataType ) + { + case IVAS_PI_SCENE_ORIENTATION: + case IVAS_PI_DEVICE_ORIENTATION_COMPENSATED: + case IVAS_PI_DEVICE_ORIENTATION_UNCOMPENSATED: #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_PLAYBACK_DEVICE_ORIENTATION: case IVAS_PI_HEAD_ORIENTATION: @@ -213,22 +213,22 @@ void IVAS_RTP_LogPiData( } break; - case IVAS_PI_ACOUSTIC_ENVIRONMENT: + case IVAS_PI_ACOUSTIC_ENVIRONMENT: + { + fprintf( f_piDataOut, "{\n\t\t\t\"aeid\": %d", cur->data.acousticEnv.aeid ); + if ( cur->data.acousticEnv.availLateReverb ) { - fprintf( f_piDataOut, "{\n\t\t\t\"aeid\": %d", cur->data.acousticEnv.aeid ); - if ( cur->data.acousticEnv.availLateReverb ) - { - fprintf( f_piDataOut, ",\n\t\t\t\"rt60\": [ %f, %f, %f ],\n", cur->data.acousticEnv.rt60[0], cur->data.acousticEnv.rt60[1], cur->data.acousticEnv.rt60[2] ); - fprintf( f_piDataOut, "\t\t\t\"dsr\": [ %f, %f, %f ]", cur->data.acousticEnv.dsr[0], cur->data.acousticEnv.dsr[1], cur->data.acousticEnv.dsr[2] ); - } - if ( cur->data.acousticEnv.availEarlyReflections ) - { - fprintf( f_piDataOut, ",\n\t\t\t\"dim\": [ %f, %f, %f ],\n", cur->data.acousticEnv.roomDimensions.x, cur->data.acousticEnv.roomDimensions.y, cur->data.acousticEnv.roomDimensions.z ); - fprintf( f_piDataOut, "\t\t\t\"abscoeff\": [ %f, %f, %f, %f, %f, %f ]", cur->data.acousticEnv.absorbCoeffs[0], cur->data.acousticEnv.absorbCoeffs[1], cur->data.acousticEnv.absorbCoeffs[2], cur->data.acousticEnv.absorbCoeffs[3], cur->data.acousticEnv.absorbCoeffs[4], cur->data.acousticEnv.absorbCoeffs[5] ); - } - fprintf( f_piDataOut, "\n\t\t}" ); + fprintf( f_piDataOut, ",\n\t\t\t\"rt60\": [ %f, %f, %f ],\n", cur->data.acousticEnv.rt60[0], cur->data.acousticEnv.rt60[1], cur->data.acousticEnv.rt60[2] ); + fprintf( f_piDataOut, "\t\t\t\"dsr\": [ %f, %f, %f ]", cur->data.acousticEnv.dsr[0], cur->data.acousticEnv.dsr[1], cur->data.acousticEnv.dsr[2] ); } - break; + if ( cur->data.acousticEnv.availEarlyReflections ) + { + fprintf( f_piDataOut, ",\n\t\t\t\"dim\": [ %f, %f, %f ],\n", cur->data.acousticEnv.roomDimensions.x, cur->data.acousticEnv.roomDimensions.y, cur->data.acousticEnv.roomDimensions.z ); + fprintf( f_piDataOut, "\t\t\t\"abscoeff\": [ %f, %f, %f, %f, %f, %f ]", cur->data.acousticEnv.absorbCoeffs[0], cur->data.acousticEnv.absorbCoeffs[1], cur->data.acousticEnv.absorbCoeffs[2], cur->data.acousticEnv.absorbCoeffs[3], cur->data.acousticEnv.absorbCoeffs[4], cur->data.acousticEnv.absorbCoeffs[5] ); + } + fprintf( f_piDataOut, "\n\t\t}" ); + } + break; #ifdef RTP_S4_251135_CR26253_0016_REV1 case IVAS_PI_LISTENER_POSITION: #ifndef REVERSE_ISM_PI_DATA @@ -512,14 +512,14 @@ void IVAS_RTP_LogPiData( break; #endif #endif /* RTP_S4_251135_CR26253_0016_REV1 */ - case IVAS_PI_NO_DATA: - { - fprintf( f_piDataOut, "{}" ); - } - break; + case IVAS_PI_NO_DATA: + { + fprintf( f_piDataOut, "{}" ); } - timestamp = cur->timestamp; + break; } + timestamp = cur->timestamp; + } fprintf( f_piDataOut, "\n\t}" ); } -- GitLab From de277821623e419795f1a9b7e176bfe7ac235aa6 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 10 Nov 2025 21:17:28 +0100 Subject: [PATCH 277/351] Fix for early reflections listener origin --- lib_util/render_config_reader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 1efe5d2b4..28dd6abf6 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2886,7 +2886,7 @@ ivas_error RenderConfigReader_getAcousticEnvironments( if ( pRenderConfigReader == NULL || ppAcEnv == NULL || pRenderConfigReader->nAE == 0 || pRenderConfigReader->pAE == NULL ) { - return 0; + return IVAS_ERR_UNEXPECTED_NULL_POINTER; } for ( n = 0; n < pRenderConfigReader->nAE; n++ ) @@ -2938,9 +2938,9 @@ ivas_error RenderConfigReader_getAcousticEnvironments( pOut->ListenerOrigin.y = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y; pOut->ListenerOrigin.z = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z; - pOut->ListenerOrigin.x_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx; - pOut->ListenerOrigin.y_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx; - pOut->ListenerOrigin.z_fx = pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx; + pOut->ListenerOrigin.x_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x * ONE_IN_Q22 ); + pOut->ListenerOrigin.y_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y * ONE_IN_Q22 ); + pOut->ListenerOrigin.z_fx = (Word32) ( pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z * ONE_IN_Q22 ); } for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) -- GitLab From 9418eba8c3e3b190a4df169a3f81408ba0d9a915 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 22:49:21 +0200 Subject: [PATCH 278/351] Fix unpacking for reverse direction ISM PI --- lib_util/ivas_rtp_pi_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index c0e9baa51..3817a8447 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -1298,7 +1298,7 @@ static ivas_error unpackReverseISMGain( const uint8_t *buffer, uint32_t numDataB r_ism_gain->piDataType = IVAS_PI_R_ISM_GAIN; /* Unpack gain */ - idx = ( *buffer ) >> 1; + idx = ( *buffer ) >> 2; /* negative gains*/ if ( idx < 25 ) { -- GitLab From c491820267035f7df4597c26ee2e5d62cb36ec6d Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 22:57:09 +0200 Subject: [PATCH 279/351] Fix function call --- apps/decoder.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0f25996bc..6c5f9a9b9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -4287,9 +4287,15 @@ ivas_error restartDecoder( uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : 65535; IVAS_AUDIO_CONFIG outputConfig = ( codec == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO; +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->renderFramesize, arg->customLsOutputEnabled, arg->hrtfReaderEnabled, + arg->enableHeadRotation, arg->enableExternalOrientation, arg->orientation_tracking, arg->renderConfigEnabled, arg->roomSize, arg->non_diegetic_pan_enabled, + arg->non_diegetic_pan_gain_fx, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, 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 ) + arg->non_diegetic_pan_gain_fx, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; -- GitLab From a6d3fa31dd90902eb9e5115c5b4f9cffcf46b690 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 23:13:18 +0200 Subject: [PATCH 280/351] General basop fixes --- lib_dec/ivas_init_dec_fx.c | 1 + lib_dec/lib_dec_fx.c | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 453861bb4..5300b598b 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3281,6 +3281,7 @@ void ivas_initialize_handles_dec( st_ivas->hCombinedOrientationData = NULL; #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT st_ivas->acousticEnvironmentsCount = 0; + move16(); st_ivas->pAcousticEnvironments = NULL; #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index be99da3ae..5ae845a46 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2986,6 +2986,8 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( Decoder_Struct *st_ivas; IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAE = NULL; + test(); + test(); test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || ( hIvasDec->st_ivas->acousticEnvironmentsCount > 0 && hIvasDec->st_ivas->pAcousticEnvironments == NULL ) ) { @@ -2997,7 +2999,6 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( /* Check if already there */ FOR( n = 0; n < st_ivas->acousticEnvironmentsCount; n++ ) { - test(); IF( st_ivas->pAcousticEnvironments[n].aeID == roomAcousticsConfig.aeID ) { move32(); @@ -3007,7 +3008,6 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( } /* If not found */ - test(); IF( pAE == NULL ) { IVAS_ROOM_ACOUSTICS_CONFIG_DATA *ppAE = realloc( st_ivas->pAcousticEnvironments, ( st_ivas->acousticEnvironmentsCount + 1 ) * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); @@ -3041,7 +3041,6 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( move32(); move16(); - test(); IF( pAE->use_er == 1 ) { pAE->lowComplexity = roomAcousticsConfig.lowComplexity; @@ -3103,7 +3102,6 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( { IVAS_ROOM_ACOUSTICS_CONFIG_DATA ae = st_ivas->pAcousticEnvironments[n]; move32(); - test(); IF( aeID == ae.aeID ) { found = 1; @@ -3128,7 +3126,6 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( /* If ER are allocated then propagate parameters */ pAcEnv->use_er = ae.use_er; move16(); - test(); IF( ae.use_er != 0 ) { pAcEnv->lowComplexity = ae.lowComplexity; @@ -3153,7 +3150,6 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( } } - test(); return found ? IVAS_ERR_OK : IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; } #endif @@ -3403,14 +3399,12 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( move32(); /* Ignore if AE ID already in use */ - test(); IF( hRenderConfig->roomAcoustics.aeID == hAcoustEnvPI.aeid ) { return IVAS_ERR_OK; } /* Attempt to load the one already available */ - test(); IF( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, hAcoustEnvPI.aeid, &hRenderConfig->roomAcoustics ) ) == IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING ) { /* Add the new compact room environment */ @@ -3447,7 +3441,6 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( acEnv.use_er = hAcoustEnvPI.availEarlyReflections; move16(); - test(); IF( hAcoustEnvPI.availEarlyReflections ) { hRenderConfig->roomAcoustics.dimensions.x_fx = hAcoustEnvPI.roomDimensions.x_fx; @@ -3460,13 +3453,11 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( mvr2r( hAcoustEnvPI.absorbCoeffs, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); } - test(); IF( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, acEnv ) ) != IVAS_ERR_OK ) { return error; } - test(); IF( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, hAcoustEnvPI.aeid, &hRenderConfig->roomAcoustics ) ) != IVAS_ERR_OK ) { return error; @@ -3476,10 +3467,8 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( /* Re-initialize reverb instance if already available */ /* TD renderer Jot reverberator */ - test(); IF( st_ivas->hReverb != NULL ) { - test(); IF( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; @@ -3488,9 +3477,9 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( /* CREND Jot reverberator */ test(); + test(); IF( st_ivas->hCrendWrapper != NULL && st_ivas->hCrendWrapper->hCrend[0] != NULL && st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) { - test(); IF( ( error = ivas_reverb_open_fx( &st_ivas->hCrendWrapper->hCrend[0]->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; @@ -3498,11 +3487,11 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( } /* Parametric renderer reverberator */ + test(); IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &( st_ivas->hDiracDecBin[0]->hReverb ) ); - test(); IF( ( error = ivas_binaural_reverb_init_fx( &( 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 ) { @@ -3516,7 +3505,6 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( { ivas_binaural_reverb_close_fx( &( st_ivas->hBinRenderer->hReverb ) ); - test(); IF( ( error = ivas_binaural_reverb_init_fx( &( 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 ) { @@ -7006,10 +6994,13 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT case IVAS_PI_ACOUSTIC_ENVIRONMENT: { - UWord16 aeid = piData->data.acousticEnv.aeid; + UWord16 aeid; + aeid = piData->data.acousticEnv.aeid; + move16(); #ifdef DEBUGGING fprintf( stdout, "PI_ACOUSTIC_ENVIRONMENT : AEID : %d\n", aeid ); #endif + test(); test(); IF( piData->data.acousticEnv.availLateReverb && hIvasDec->st_ivas->hRenderConfig != NULL && aeid != hIvasDec->st_ivas->hRenderConfig->roomAcoustics.aeID ) { -- GitLab From 606baabdde46be462e04fc5167c93fb484e0acc1 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Mon, 10 Nov 2025 23:57:22 +0200 Subject: [PATCH 281/351] Format code --- lib_dec/ivas_init_dec_fx.c | 959 +++++++++++++++++++------------------ lib_dec/lib_dec_fx.c | 2 + 2 files changed, 504 insertions(+), 457 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 5c6649b54..faafc0e3c 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -145,525 +145,570 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->ivas_format, st_ivas->last_ivas_format ) && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) && - !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ){ + !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ) + { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ + move16(); + return IVAS_ERR_OK; + } + ELSE + { +#ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } +#else #ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); #endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); #endif -} - -/*-------------------------------------------------------------------* - * Read other signaling (ISM/MC mode, number of channels, etc.) - *-------------------------------------------------------------------*/ + } -IF( is_DTXrate( ivas_total_brate ) == 0 ) -{ /*-------------------------------------------------------------------* - * Read IVAS format related signaling: - * - in ISM : read number of objects - * - in SBA : read SBA planar flag and SBA order - * - in MASA : read number of TC - * - in MC : read LS setup + * Read other signaling (ISM/MC mode, number of channels, etc.) *-------------------------------------------------------------------*/ - IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - { - element_mode_flag = 1; - move16(); - } - ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( is_DTXrate( ivas_total_brate ) == 0 ) { - /* read the number of objects */ - nchan_ism = 1; - move16(); - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - k = sub( k, 1 ); - WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) + /*-------------------------------------------------------------------* + * Read IVAS format related signaling: + * - in ISM : read number of objects + * - in SBA : read SBA planar flag and SBA order + * - in MASA : read number of TC + * - in MC : read LS setup + *-------------------------------------------------------------------*/ + + IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - nchan_ism = add( nchan_ism, 1 ); - k = sub( k, 1 ); + element_mode_flag = 1; + move16(); } + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* read the number of objects */ + nchan_ism = 1; + move16(); + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + k = sub( k, 1 ); + WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) + { + nchan_ism = add( nchan_ism, 1 ); + k = sub( k, 1 ); + } - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - ELSE - { -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING - } -#endif -} + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } -st_ivas->nchan_ism = nchan_ism; -move16(); -st_ivas->ism_mode = ivas_ism_mode_select( nchan_ism, ivas_total_brate ); + st_ivas->nchan_ism = nchan_ism; + move16(); + st_ivas->ism_mode = ivas_ism_mode_select( nchan_ism, ivas_total_brate ); -st_ivas->nchan_transport = nchan_ism; -move16(); -if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) -{ - st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; - move16(); -} -} -ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) -{ - /* read Ambisonic (SBA) planar flag */ - sba_planar = st_ivas->bit_stream[num_bits_read]; - num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); + st_ivas->nchan_transport = nchan_ism; + move16(); + if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + { + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + /* read Ambisonic (SBA) planar flag */ + sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + test(); + IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); + #endif + } -/* read Ambisonic (SBA) order */ -sba_order = st_ivas->bit_stream[num_bits_read + 1]; -move16(); -sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); + /* read Ambisonic (SBA) order */ + sba_order = st_ivas->bit_stream[num_bits_read + 1]; + move16(); + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); -test(); -IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; -move16(); -return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + test(); + IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + } + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + #else + #endif + } -sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); -st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); -} -ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) -{ -#ifdef DECODER_FORMAT_SWITCHING - UWord8 masaRestartCandidate; - masaRestartCandidate = 0; - move16(); -#endif - /* read number of MASA transport channels */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - IF( st_ivas->bit_stream[k - 1] ) - { -#ifdef DECODER_FORMAT_SWITCHING - test(); - IF( st_ivas->nchan_transport == 1 && isVoipMode ) - { - masaRestartCandidate = 1; - move16(); + sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); + st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); } -#endif - st_ivas->nchan_transport = 2; - move16(); - element_mode_flag = 1; - move16(); - } - ELSE - { -#ifdef DECODER_FORMAT_SWITCHING - test(); - IF( st_ivas->nchan_transport == 2 && isVoipMode ) + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { - masaRestartCandidate = 1; + #ifdef DECODER_FORMAT_SWITCHING + UWord8 masaRestartCandidate; + masaRestartCandidate = 0; move16(); - } -#endif - st_ivas->nchan_transport = 1; - move16(); - } - - /* this should be non-zero if original input format was MASA_ISM_FORMAT */ - st_ivas->ism_mode = ISM_MODE_NONE; - move16(); - nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); + #endif + /* read number of MASA transport channels */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( st_ivas->bit_stream[k - 1] ) + { + #ifdef DECODER_FORMAT_SWITCHING + test(); + IF( st_ivas->nchan_transport == 1 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } + #endif + st_ivas->nchan_transport = 2; + move16(); + element_mode_flag = 1; + move16(); + } + ELSE + { + #ifdef DECODER_FORMAT_SWITCHING + test(); + IF( st_ivas->nchan_transport == 2 && isVoipMode ) + { + masaRestartCandidate = 1; + move16(); + } + #endif + st_ivas->nchan_transport = 1; + move16(); + } - IF( nchan_ism > 0 ) - { - /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ - /* info about the number of objects: - '00' - MASA format at the encoder - '01' - MASA_ISM_FORMAT at the encoder, with 4 objects - '10' - MASA_ISM_FORMAT at the encoder, with 3 objects - '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects - reading if 1 or 2 objects is performed later - */ - nchan_ism = sub( 5, nchan_ism ); - test(); - IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) - { - nchan_ism = 1; + /* this should be non-zero if original input format was MASA_ISM_FORMAT */ + st_ivas->ism_mode = ISM_MODE_NONE; move16(); - } + nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); - /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ - st_ivas->nchan_transport = 2; - move16(); - element_mode_flag = 1; - move16(); - } -#ifdef DECODER_FORMAT_SWITCHING - ELSE IF( masaRestartCandidate > 0 ) - { - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } -#endif + IF( nchan_ism > 0 ) + { + /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ + /* info about the number of objects: + '00' - MASA format at the encoder + '01' - MASA_ISM_FORMAT at the encoder, with 4 objects + '10' - MASA_ISM_FORMAT at the encoder, with 3 objects + '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects + reading if 1 or 2 objects is performed later + */ + nchan_ism = sub( 5, nchan_ism ); + test(); + IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) + { + nchan_ism = 1; + move16(); + } - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ + st_ivas->nchan_transport = 2; + move16(); + element_mode_flag = 1; + move16(); + } + #ifdef DECODER_FORMAT_SWITCHING + ELSE IF( masaRestartCandidate > 0 ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + #endif -st_ivas->nchan_ism = nchan_ism; -move16(); -} -ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) -{ - st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ - move16(); + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } - /* the number of objects are written at the end of the bitstream */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); - st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism ); + st_ivas->nchan_ism = nchan_ism; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + { + st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ + move16(); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + /* the number of objects are written at the end of the bitstream */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); + st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism ); -st_ivas->nchan_ism = nchan_ism; -move16(); -} -ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) -{ - /* the number of objects is written at the end of the bitstream, in the SBA metadata */ - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + st_ivas->nchan_ism = nchan_ism; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + { + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 ); -st_ivas->nchan_ism = nchan_ism; -move16(); + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } -/* read Ambisonic (SBA) planar flag */ -/*sba_planar = st_ivas->bit_stream[num_bits_read];*/ -num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); + st_ivas->nchan_ism = nchan_ism; + move16(); -/* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ -sba_order = st_ivas->bit_stream[num_bits_read + 1]; -move16(); -sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); -num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); + /* read Ambisonic (SBA) planar flag */ + /*sba_planar = st_ivas->bit_stream[num_bits_read];*/ + num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); -/* read the real Ambisonic order when the above bits are used to signal OSBA format */ -IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) -{ - sba_order = st_ivas->bit_stream[num_bits_read + 1]; - move16(); - sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); - num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); -} + /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ + sba_order = st_ivas->bit_stream[num_bits_read + 1]; + move16(); + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); + num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); -test(); -IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; -move16(); -return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + /* read the real Ambisonic order when the above bits are used to signal OSBA format */ + IF( LT_32( ivas_total_brate, IVAS_24k4 ) ) + { + sba_order = st_ivas->bit_stream[num_bits_read + 1]; + move16(); + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); + num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); + } -st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); + test(); + IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); + #endif + } -sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); -st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); -} -ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) -{ - /* read MC configuration */ - idx = 0; - move16(); - FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) - { - IF( st_ivas->bit_stream[num_bits_read + k] ) - { - idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); + st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); + + sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); + st_ivas->nchan_transport = ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_analysis_order ); } - } - num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) + { + /* read MC configuration */ + idx = 0; + move16(); + FOR( k = 0; k < MC_LS_SETUP_BITS; k++ ) + { + IF( st_ivas->bit_stream[num_bits_read + k] ) + { + idx = add( idx, shl( 1, sub( ( MC_LS_SETUP_BITS - 1 ), k ) ) ); + } + } + num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); - signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); + signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); - test(); - IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; -} -ELSE -{ -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING -} -#endif -} + test(); + IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) + { + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); + #endif + } -st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); -st_ivas->transport_config = signaled_config; -move16(); -} + st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); + st_ivas->transport_config = signaled_config; + move16(); + } -/*-------------------------------------------------------------------* - * Read element mode - *-------------------------------------------------------------------*/ + /*-------------------------------------------------------------------* + * Read element mode + *-------------------------------------------------------------------*/ -test(); -IF( st_ivas->ini_frame == 0 && element_mode_flag ) -{ - /* read stereo technology info */ - if ( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) - { - /* 1 bit */ - IF( st_ivas->bit_stream[num_bits_read] ) - { - st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT ); - } - ELSE + test(); + IF( st_ivas->ini_frame == 0 && element_mode_flag ) { - st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT ); - } - } - ELSE - { - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - } -} -} -ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) -{ - SWITCH( st_ivas->sid_format ) - { - case SID_DFT_STEREO: - st_ivas->element_mode_init = IVAS_CPE_DFT; - move16(); - BREAK; - case SID_MDCT_STEREO: - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - BREAK; - case SID_ISM: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - BREAK; - case SID_MASA_1TC: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - st_ivas->nchan_transport = 1; - move16(); - BREAK; - case SID_MASA_2TC: - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - IF( st_ivas->bit_stream[k - 1 - SID_FORMAT_NBITS] == 1 ) + /* read stereo technology info */ + if ( LT_32( ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) { - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); + /* 1 bit */ + IF( st_ivas->bit_stream[num_bits_read] ) + { + st_ivas->element_mode_init = add( 1, IVAS_CPE_DFT ); + } + ELSE + { + st_ivas->element_mode_init = add( 0, IVAS_CPE_DFT ); + } } ELSE { - st_ivas->element_mode_init = IVAS_CPE_DFT; + st_ivas->element_mode_init = IVAS_CPE_MDCT; move16(); } - st_ivas->nchan_transport = 2; - move16(); - BREAK; - case SID_SBA_1TC: - st_ivas->element_mode_init = IVAS_SCE; - move16(); - BREAK; - case SID_SBA_2TC: - st_ivas->element_mode_init = IVAS_CPE_MDCT; - move16(); - BREAK; + } } - - IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + ELSE IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) { - /* read the number of objects */ - nchan_ism = 1; - move16(); - k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - k = sub( sub( k, 1 ), SID_FORMAT_NBITS ); - WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) + SWITCH( st_ivas->sid_format ) { - nchan_ism = add( nchan_ism, 1 ); - k = sub( k, 1 ); + case SID_DFT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_DFT; + move16(); + BREAK; + case SID_MDCT_STEREO: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + BREAK; + case SID_ISM: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + BREAK; + case SID_MASA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + st_ivas->nchan_transport = 1; + move16(); + BREAK; + case SID_MASA_2TC: + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( st_ivas->bit_stream[k - 1 - SID_FORMAT_NBITS] == 1 ) + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + } + ELSE + { + st_ivas->element_mode_init = IVAS_CPE_DFT; + move16(); + } + st_ivas->nchan_transport = 2; + move16(); + BREAK; + case SID_SBA_1TC: + st_ivas->element_mode_init = IVAS_SCE; + move16(); + BREAK; + case SID_SBA_2TC: + st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); + BREAK; } - k = sub( k, 1 ); - test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ -#ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ - st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; - } - else - { -#endif -#ifdef DEBUGGING - fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); -#endif - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); -#ifdef DECODER_FORMAT_SWITCHING - } -#endif -} + IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) + { + /* read the number of objects */ + nchan_ism = 1; + move16(); + k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + k = sub( sub( k, 1 ), SID_FORMAT_NBITS ); + WHILE( st_ivas->bit_stream[k] && ( nchan_ism < MAX_NUM_OBJECTS ) ) + { + nchan_ism = add( nchan_ism, 1 ); + k = sub( k, 1 ); + } + k = sub( k, 1 ); + + test(); + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ + #ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ){ + st_ivas->restartNeeded = 1; + move16(); + return IVAS_ERR_OK; + } + ELSE + { + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + } + #else + #ifdef DEBUGGING + fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); + #endif + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); + #endif + } -st_ivas->nchan_ism = nchan_ism; -move16(); + st_ivas->nchan_ism = nchan_ism; + move16(); -/* read ism_mode */ -st_ivas->ism_mode = ISM_MODE_DISC; -move32(); -IF( GT_16( nchan_ism, 2 ) ) -{ - k = sub( k, nchan_ism ); /* SID metadata flags */ - idx = st_ivas->bit_stream[k]; - move16(); - st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); - move32(); -} + /* read ism_mode */ + st_ivas->ism_mode = ISM_MODE_DISC; + move32(); + IF( GT_16( nchan_ism, 2 ) ) + { + k = sub( k, nchan_ism ); /* SID metadata flags */ + idx = st_ivas->bit_stream[k]; + move16(); + st_ivas->ism_mode = (ISM_MODE) add( idx, 1 ); + move32(); + } -st_ivas->nchan_transport = nchan_ism; -move16(); -if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) -{ - st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; - move16(); -} -} -} + st_ivas->nchan_transport = nchan_ism; + move16(); + if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + { + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + move16(); + } + } + } -st_ivas->bit_stream = bit_stream_orig; + st_ivas->bit_stream = bit_stream_orig; -return IVAS_ERR_OK; + return IVAS_ERR_OK; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 027baa528..0e99c4c6e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3681,7 +3681,9 @@ ivas_error IVAS_DEC_ReadFormat( renderer_type_old = st_ivas->renderer_type; renderer_type_sec_old = ivas_renderer_secondary_select_fx( st_ivas ); move32(); +#ifndef DECODER_FORMAT_SWITCHING move32(); +#endif move32(); move16(); move32(); -- GitLab From 3aec5f5b9cd539c73b4167e4f6f9834c8b2d5b30 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 10 Nov 2025 20:52:04 -0500 Subject: [PATCH 282/351] fix clang format --- lib_com/tools_fx.c | 2 +- lib_enc/ACcontextMapping_enc_fx.c | 2 +- lib_enc/gs_enc_fx.c | 2 +- lib_enc/qlpc_stoch_fx.c | 2 +- lib_enc/sig_clas_fx.c | 2 +- lib_enc/updt_enc_fx.c | 2 +- lib_enc/vad_fx.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 4b902a32b..5b4f0b127 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -1890,7 +1890,7 @@ Word16 mean_fx( ) { Word16 tmp; - /* this function could be written differently to minimize the risk of saturation */ + /* this function could be written differently to minimize the risk of saturation */ tmp = sum16_fx( vec_fx, lvec_fx ); tmp = mult_r( tmp, div_s( 1, lvec_fx ) ); diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 34c9e9074..cfc8ebb05 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -163,7 +163,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx( idx = s_min( idx1, idx2 ); /* Q0 */ /* Get context */ - ctx = &c[s_or( p1, p2 )]; /* Q0 */ + ctx = &c[s_or( p1, p2 )]; /* Q0 */ t = add( *ctx, rateFlag ); /* Q0 */ if ( GT_16( idx, nt_half ) ) { diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index b6d0e776b..43036184e 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -384,7 +384,7 @@ void encod_audio_fx( * Updates *--------------------------------------------------------------------------------------*/ - hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; + hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; move16(); Copy( exc_wo_nf, exc, st_fx->L_frame ); diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index a934e0d7d..2d7c49107 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -55,7 +55,7 @@ void lpc_quantization_fx( /****** High-rate LPC quantizer *******/ IF( st->lpcQuantization == 0 ) - { + { /* from the comment in E_LPC_isp_isf_conversion, it seems built for 12.8kHz only, if current sampling rate is NOT 12800, is it ok? , float takes into account Fs */ /* _DIFF_FLOAT_FIX_EVS_IVAS */ E_LPC_lsp_lsf_conversion( lsp, lsf, M ); diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 61fa63fe9..4822a5669 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -640,7 +640,7 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } - } + } hSC_VBR->last_7k2_coder_type = st->coder_type; move16(); test(); diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 42cde6f82..9c68847a4 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -266,7 +266,7 @@ void updt_IO_switch_enc_fx( hSC_VBR->nelp_mode = 0; move16(); } - st->hGSCEnc->seed_tcx = 15687; + st->hGSCEnc->seed_tcx = 15687; move16(); } diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 38def0372..0471ef04e 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -2585,7 +2585,7 @@ Word16 wb_vad_ivas_fx( test(); test(); test(); - test(); + test(); test(); IF( ( LE_16( snr_outlier_index, 4 ) && ( st_fx->last_coder_type > UNVOICED ) && !st_fx->Opt_SC_VBR ) || ( LE_16( snr_outlier_index, 4 ) && ( last_7k2_coder_type > UNVOICED ) && st_fx->Opt_SC_VBR ) ) -- GitLab From ac1f4fba1e6257487a8211de5bff35838c9bf814 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 10 Nov 2025 21:33:36 -0500 Subject: [PATCH 283/351] roll back a change to fix BE on 26.444 (hopefully) --- lib_enc/vad_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 0471ef04e..8d6d1719c 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -746,7 +746,7 @@ Word16 wb_vad_fx( move16(); } - IF( st_fx->Opt_SC_VBR ) + IF( 1 ) //st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ { last_7k2_coder_type = st_fx->hSC_VBR->last_7k2_coder_type; move16(); -- GitLab From a872cf0b1dc03f98145144657d1cd5c4602e7a64 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 10 Nov 2025 21:35:49 -0500 Subject: [PATCH 284/351] fix clang --- lib_enc/vad_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 8d6d1719c..77f38bf52 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -746,7 +746,7 @@ Word16 wb_vad_fx( move16(); } - IF( 1 ) //st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ + IF( 1 ) // st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ { last_7k2_coder_type = st_fx->hSC_VBR->last_7k2_coder_type; move16(); -- GitLab From 676f09d6e20523c664575bc73f99dc43f1ea6990 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 11 Nov 2025 09:28:37 +0100 Subject: [PATCH 285/351] Render config: disabling float value checks --- lib_util/render_config_reader.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 28dd6abf6..c56ab9df9 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1305,50 +1305,62 @@ ivas_error RenderConfigReader_checkValues( if ( pRoom_acoustics->use_er == 1 ) { /* Room dimensions */ +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT if ( pRoom_acoustics->dimensions.x < ER_MIN_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.x = ER_MIN_ROOM_DIMENSION; } +#endif if ( pRoom_acoustics->dimensions.x_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.x_fx = ER_MIN_ROOM_DIMENSION_FX; } +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT if ( pRoom_acoustics->dimensions.x > ER_MAX_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.x = ER_MAX_ROOM_DIMENSION; } +#endif if ( pRoom_acoustics->dimensions.x_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.x_fx = ER_MAX_ROOM_DIMENSION_FX; } +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT if ( pRoom_acoustics->dimensions.y < ER_MIN_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.y = ER_MIN_ROOM_DIMENSION; } +#endif if ( pRoom_acoustics->dimensions.y_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.y_fx = ER_MIN_ROOM_DIMENSION_FX; } +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT if ( pRoom_acoustics->dimensions.y > ER_MAX_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.y = ER_MAX_ROOM_DIMENSION; } +#endif if ( pRoom_acoustics->dimensions.y_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.y_fx = ER_MAX_ROOM_DIMENSION_FX; } +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT if ( pRoom_acoustics->dimensions.z < ER_MIN_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.z = ER_MIN_ROOM_DIMENSION; } +#endif if ( pRoom_acoustics->dimensions.z_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.z_fx = ER_MIN_ROOM_DIMENSION_FX; } +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT if ( pRoom_acoustics->dimensions.z > ER_MAX_ROOM_DIMENSION ) { pRoom_acoustics->dimensions.z = ER_MAX_ROOM_DIMENSION; } +#endif if ( pRoom_acoustics->dimensions.z_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.z_fx = ER_MAX_ROOM_DIMENSION_FX; @@ -1357,18 +1369,22 @@ ivas_error RenderConfigReader_checkValues( /* Abs Coeff */ for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) { +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT if ( pRoom_acoustics->AbsCoeff[wall_idx] < ER_MIN_ABS_COEFF ) { pRoom_acoustics->AbsCoeff[wall_idx] = ER_MIN_ABS_COEFF; } +#endif if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] < ER_MIN_ABS_COEFF_FX ) { pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MIN_ABS_COEFF_FX; } +#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT if ( pRoom_acoustics->AbsCoeff[wall_idx] > ER_MAX_ABS_COEFF ) { pRoom_acoustics->AbsCoeff[wall_idx] = ER_MAX_ABS_COEFF; } +#endif if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] > ER_MAX_ABS_COEFF_FX ) { pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX; -- GitLab From ff0d8fd52f101ff20666a23737a317cf9f0e08da Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Tue, 11 Nov 2025 10:41:08 +0200 Subject: [PATCH 286/351] Correct place for rtp restart, clean up --- apps/decoder.c | 42 ++++++++++++++++---------------- lib_dec/ivas_init_dec_fx.c | 50 ++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 6c5f9a9b9..baba111e8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3161,27 +3161,6 @@ static ivas_error decodeVoIP( fprintf( stdout, "\n-- Start the decoder (quiet mode) --\n\n" ); } -#ifdef DECODER_FORMAT_SWITCHING - if ( ivasRtp.restartNeeded ) - { - IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - error = restartDecoder( - &hIvasDec, - newCodecInPacket, - &arg, - NULL, /* ToDo : Provide rendererConfig */ - NULL /* ToDo : Provide LS Custom Data */ - ); - if ( error != IVAS_ERR_OK ) - { - fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket ); - goto cleanup; - } - *phIvasDec = hIvasDec; /* Update for main()' s free */ - ivasRtp.restartNeeded = false; - } -#endif - #ifdef WMOPS reset_stack(); reset_wmops(); @@ -3195,6 +3174,27 @@ static ivas_error decodeVoIP( { nSamplesRendered = 0; +#ifdef DECODER_FORMAT_SWITCHING + if ( ivasRtp.restartNeeded ) + { + IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + error = restartDecoder( + &hIvasDec, + newCodecInPacket, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket ); + goto cleanup; + } + *phIvasDec = hIvasDec; /* Update for main()' s free */ + ivasRtp.restartNeeded = false; + } +#endif + /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index faafc0e3c..f9e3ce80b 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -204,7 +204,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -213,17 +213,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; @@ -247,7 +247,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -256,17 +256,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA planar/3D layout is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA planar flag signalled!" ); - #endif +#endif } /* read Ambisonic (SBA) order */ @@ -281,22 +281,22 @@ ivas_error ivas_dec_get_format_fx( IF( isVoipMode ) { st_ivas->restartNeeded = 1; - move16(); - return IVAS_ERR_OK; + move16(); + return IVAS_ERR_OK; } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); } - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); - #else - #endif +#endif } sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, sba_order ); @@ -659,9 +659,11 @@ ivas_error ivas_dec_get_format_fx( k = sub( k, 1 ); test(); - IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){ + IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) + { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; -- GitLab From 5b9ee25dd4a5576c60e4e4f7e256cfc7c233644e Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Tue, 11 Nov 2025 10:44:16 +0200 Subject: [PATCH 287/351] Clang format --- lib_dec/ivas_init_dec_fx.c | 111 +++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index f9e3ce80b..2b45965c5 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -277,7 +277,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -304,23 +304,23 @@ ivas_error ivas_dec_get_format_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING UWord8 masaRestartCandidate; masaRestartCandidate = 0; move16(); - #endif +#endif /* read number of MASA transport channels */ k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); IF( st_ivas->bit_stream[k - 1] ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING test(); IF( st_ivas->nchan_transport == 1 && isVoipMode ) { masaRestartCandidate = 1; move16(); } - #endif +#endif st_ivas->nchan_transport = 2; move16(); element_mode_flag = 1; @@ -328,14 +328,14 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING test(); IF( st_ivas->nchan_transport == 2 && isVoipMode ) { masaRestartCandidate = 1; move16(); } - #endif +#endif st_ivas->nchan_transport = 1; move16(); } @@ -369,19 +369,19 @@ ivas_error ivas_dec_get_format_fx( element_mode_flag = 1; move16(); } - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING ELSE IF( masaRestartCandidate > 0 ) { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; } - #endif +#endif test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -390,17 +390,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; @@ -419,25 +419,26 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; @@ -452,7 +453,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -461,17 +462,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; @@ -499,25 +500,26 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { - #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the SBA order is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong SBA order signalled!" ); - #endif +#endif } st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); @@ -544,25 +546,26 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) { - #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ){ +#ifdef DECODER_FORMAT_SWITCHING + IF( isVoipMode ) + { st_ivas->restartNeeded = 1; move16(); return IVAS_ERR_OK; } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Switching of MC configurations is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); - #endif +#endif } st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); @@ -661,7 +664,7 @@ ivas_error ivas_dec_get_format_fx( test(); IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { - #ifdef DECODER_FORMAT_SWITCHING +#ifdef DECODER_FORMAT_SWITCHING IF( isVoipMode ) { st_ivas->restartNeeded = 1; @@ -670,17 +673,17 @@ ivas_error ivas_dec_get_format_fx( } ELSE { - #ifdef DEBUGGING +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); } - #else - #ifdef DEBUGGING +#else +#ifdef DEBUGGING fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" ); - #endif +#endif return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" ); - #endif +#endif } st_ivas->nchan_ism = nchan_ism; -- GitLab From edb15cfc415b09eb8abcc5d8de6fa422a303ce16 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 11 Nov 2025 09:52:15 +0100 Subject: [PATCH 288/351] Adjust Q_real to prevent overflow in st->cldfbSyn->cldfb_state_fx scaling. --- lib_com/options.h | 1 + lib_dec/acelp_core_dec_fx.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index b139d74a3..68b09b3c8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -105,6 +105,7 @@ #define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue */ #define FIX_2200_ISAR_PLC_CRASH /* Dolby: Fix for ISAR PLC crash observed with newly added BASOP tests */ #define FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA /* FhG: Resolve overflow by swapping the order of addition and multiplication */ +#define FIX_2217_ASSERT_IN_IVAS_CORE_DECODER_WITH_MC /* FhG: Adjust Q_real to prevent overflow in st->cldfbSyn->cldfb_state_fx scaling */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 513a9c692..6cab4b201 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -124,7 +124,11 @@ ivas_error acelp_core_dec_fx( ivas_error error; Word32 bpf_error_signal_fx[L_FRAME16k]; Word16 bpf_error_signal_16fx[L_FRAME16k]; +#ifdef FIX_2217_ASSERT_IN_IVAS_CORE_DECODER_WITH_MC + Word16 Q_real, scf; +#else Word16 Q_real; +#endif Word32 max_real, max_imag, max_val; set32_fx( bpf_error_signal_fx, 0, L_FRAME16k ); @@ -2083,11 +2087,16 @@ ivas_error acelp_core_dec_fx( } max_val = L_max( max_real, max_imag ); Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; +#ifdef FIX_2217_ASSERT_IN_IVAS_CORE_DECODER_WITH_MC + scf = L_norm_arr( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length ); + Q_real = s_min( Q_real, scf ); +#endif FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); move16(); -- GitLab From c7525e86acbc5b5adf8113093201a0fc0d752bb3 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 11 Nov 2025 10:39:00 +0100 Subject: [PATCH 289/351] Adjust scf in st->cldfbSyn->cldfb_state_fx scaling --- lib_dec/acelp_core_dec_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 6cab4b201..0bc1b8403 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2089,7 +2089,8 @@ ivas_error acelp_core_dec_fx( Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; #ifdef FIX_2217_ASSERT_IN_IVAS_CORE_DECODER_WITH_MC scf = L_norm_arr( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length ); - Q_real = s_min( Q_real, scf ); + scf = s_min( scf, sub( Q_real, Q11 ) ); + Q_real = add( scf, Q11 ); #endif FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { @@ -2097,7 +2098,11 @@ ivas_error acelp_core_dec_fx( scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } +#ifdef FIX_2217_ASSERT_IN_IVAS_CORE_DECODER_WITH_MC + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, scf ); // Q10 - > (Q_real-1) +#else scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#endif st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); move16(); -- GitLab From 2347c27af93089b3e847214e24a9f6e2bb472988 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 13:49:18 +0100 Subject: [PATCH 290/351] remove float <-> fixed conversion leftovers --- Workspace_msvc/lib_com.vcxproj | 1 - Workspace_msvc/lib_com.vcxproj.filters | 3 - Workspace_msvc/lib_util.vcxproj | 4 +- lib_com/float_to_fix_ops.c | 297 ------------------------- lib_com/prot_fx.h | 100 +-------- lib_com/tools_fx.c | 293 ------------------------ lib_dec/lib_dec_fx.c | 4 +- lib_enc/ivas_ism_metadata_enc_fx.c | 2 - lib_isar/isar_splitRendererPre.c | 3 + lib_rend/ivas_reverb_fft_filter_fx.c | 6 +- lib_rend/ivas_rotation_fx.c | 20 ++ lib_util/float_to_fix_ops.c | 129 +++++++++++ lib_util/float_to_fix_ops.h | 20 ++ lib_util/ism_file_reader.c | 23 +- lib_util/ism_file_writer.c | 5 +- lib_util/ivas_rtp_file.c | 7 +- lib_util/rotation_file_reader.c | 13 +- lib_util/vector3_pair_file_reader.c | 7 +- 18 files changed, 220 insertions(+), 717 deletions(-) delete mode 100644 lib_com/float_to_fix_ops.c create mode 100644 lib_util/float_to_fix_ops.c create mode 100644 lib_util/float_to_fix_ops.h diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index ee67280d0..702c6c1ad 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -161,7 +161,6 @@ - diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index e8bbb17e9..37a179045 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -256,9 +256,6 @@ common_all_c - - common_all_c - common_all_c diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 72dac3925..bfbfa8d4c 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -109,6 +109,7 @@ + @@ -141,6 +142,7 @@ + @@ -176,4 +178,4 @@ - + \ No newline at end of file diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c deleted file mode 100644 index 8b69e05e8..000000000 --- a/lib_com/float_to_fix_ops.c +++ /dev/null @@ -1,297 +0,0 @@ -#include -#include -#include -#include -#include "options.h" -#include "prot_fx.h" -#define WMC_TOOL_SKIP - -Word32 floatToFixed( float f, Word16 Q ) -{ - Word64 result_32; - if ( f == 1.0f && Q == Q15 ) - return MAX16B; - if ( f == 1.0f && Q == Q31 ) - return MAXVAL_WORD32; - if ( Q < 0 ) - result_32 = (Word64) ( (float) ( f ) / (double) ( (unsigned Word64) 1 << ( -Q ) ) + ( f >= 0 ? 0.5 : -0.5 ) ); - else - result_32 = (Word64) ( f * (double) ( (unsigned Word64) 1 << Q ) + ( f >= 0 ? 0.5 : -0.5 ) ); - if ( result_32 > MAX_32 ) - return MAX_32; - if ( result_32 < MIN_32 ) - return MIN_32; - return (Word32) result_32; -} - - -float fixedToFloat( Word32 i, Word16 Q ) -{ - if ( Q < 0 ) - return ( i * (float) ( ( 1LL ) << ( -Q ) ) ); - else - return (float) ( i ) / (float) ( 1LL << Q ); -} -void floatToFixed_arrL( float *f, Word32 *i, Word16 Q, Word16 l ) -{ - for ( int j = 0; j < l; j++ ) - { - Word64 i64_val = floatToFixed( f[j], Q ); - IF( i64_val > MAX_32 ) - { - i64_val = MAX_32; - } - ELSE IF( i64_val < MIN_32 ) - { - i64_val = MIN_32; - } - i[j] = (Word32) i64_val; - } -} -void floatToFixed_arr16( float *f, Word16 *i, Word16 Q, Word16 l ) -{ - if ( Q <= 0 ) - { - floatToFixed_arr( f, i, Q, l ); - return; - } - for ( int j = 0; j < l; j++ ) - { - i[j] = float_to_fix16( f[j], Q ); - } -} -void floatToFixed_arr32( float *f, Word32 *i, Word16 Q, Word16 l ) -{ - if ( Q <= 0 ) - { - floatToFixed_arrL( f, i, Q, l ); - return; - } - for ( int j = 0; j < l; j++ ) - { - i[j] = float_to_fix( f[j], Q ); - } -} - -float fixedToFloat_16( Word16 i, Word16 Q ) -{ - if ( Q < 0 ) - return ( i * (float) ( ( (unsigned) 1 ) << ( -Q ) ) ); - else - return (float) ( i ) / (float) ( (unsigned int) 1 << Q ); -} -float fixedToFloat_32( Word32 number, Word16 Q ) -{ - float val = 0.0f; - assert( abs_s( Q ) <= 63 ); - if ( abs_s( Q ) > 31 ) - { - if ( Q > 0 ) - { - val = ( ( (float) number / ( 1 << ( Q - 31 ) ) ) / ( (unsigned int) MAX_32 + 1 ) ); - } - else - { - val = ( (float) number * ( 1 << ( -Q - 31 ) ) * (unsigned int) MIN_32 ); - } - } - else - { - val = fixedToFloat( number, Q ); - } - return val; -} - -Word32 floatToFixed_32( float number, Word16 Q ) -{ - float val = 0.0f; - assert( abs_s( Q ) <= 63 ); - if ( abs_s( Q ) > 31 ) - { - if ( Q > 0 ) - { - val = ( number * ( (unsigned int) MAX_32 + 1 ) ) * ( 1 << ( Q - 31 ) ); - } - else - { - val = ( number / ( 1 << ( -Q - 31 ) ) ) / (unsigned int) MIN_32; - } - if ( val >= 0.0f ) - { - assert( (Word32) val <= MAX_32 ); - } - else - { - assert( (Word32) val >= MIN_32 ); - } - } - else - { - return floatToFixed( number, Q ); - } - - return (Word32) val; -} - -void floatToFixed_arrL32( float *f, Word32 *i, Word16 Q, Word16 l ) -{ - for ( int j = 0; j < l; j++ ) - { - i[j] = floatToFixed_32( f[j], Q ); - } -} - -void fixedToFloat_arrL32( Word32 *i, float *f, Word16 Q, Word16 l ) -{ - for ( int j = 0; j < l; j++ ) - { - f[j] = fixedToFloat_32( i[j], Q ); - } -} - -void floatToFixed_arr( float *f, Word16 *i, Word16 Q, Word16 l ) -{ - for ( int j = 0; j < l; j++ ) - { - Word32 i32_val = floatToFixed( f[j], Q ); - IF( i32_val > MAX_16 ) - { - i32_val = MAX_16; - } - ELSE IF( i32_val < MIN_16 ) - { - i32_val = MIN_16; - } - i[j] = (Word16) i32_val; - } -} -void fixedToFloat_arrL( Word32 *i, float *f, Word16 Q, Word16 l ) -{ - for ( int j = 0; j < l; j++ ) - { - f[j] = fixedToFloat( i[j], Q ); - } -} -void fixedToFloat_arr( Word16 *i, float *f, Word16 Q, Word16 l ) -{ - for ( int j = 0; j < l; j++ ) - { - f[j] = fixedToFloat( i[j], Q ); - } -} -Word16 Q_factor( float x ) -{ - Word16 Q = 15; - if ( x >= 1 || x <= -1 ) - Q = norm_s( (Word16) L_abs( (Word32) x ) ); - return Q; -} -Word16 Q_factor_L( float x ) -{ - Word16 Q = 31; - if ( x >= 1 || x <= -1 ) - Q = norm_l( L_abs( (Word32) x ) ); - return Q; -} -Word16 Q_factor_L_32( Word32 x ) -{ - Word16 Q = 31; - if ( x >= 1 || x <= -1 ) - Q = norm_l( L_abs( (Word32) x ) ); - return Q; -} -Word16 Q_factor_arr( float *x, Word16 l ) -{ - Word16 Q = 15; - for ( int i = 0; i < l; i++ ) - { - if ( x[i] >= 1 || x[i] <= -1 ) - Q = s_min( Q, norm_s( (Word16) L_abs( (Word32) x[i] ) ) ); - } - return Q; -} -Word16 Q_factor_arrL( float *x, Word16 l ) -{ - Word16 Q = 31; - for ( int i = 0; i < l; i++ ) - { - if ( x[i] >= 1 || x[i] <= -1 ) - Q = s_min( Q, norm_l( (Word32) L_abs( (Word32) x[i] ) ) ); - } - return Q; -} - -Word16 L_get_q( float f ) -{ - if ( fabsf( f ) > (float) INT_MAX ) - { - return sub( sub( W_norm( (Word64) f ), 32 ), 0 ); - } - else - { - return sub( norm_l( (Word32) f ), 0 ); - } -} - -Word16 L_get_q_buf( float *ptr_flt, Word16 length ) -{ - Word16 k; - float ftemp = 0.0; - - for ( k = 0; k < length; k++ ) - { - if ( fabsf( ptr_flt[k] ) > ftemp ) - ftemp = fabsf( ptr_flt[k] ); - } - - if ( ftemp > (float) INT_MAX ) - { - return sub( sub( W_norm( (Word64) ftemp ), 32 ), 0 ); - } - else - { - return sub( norm_l( (Word32) ftemp ), 0 ); - } -} - -Word16 L_get_q1( float f ) -{ - if ( fabsf( f ) >= 0.f && fabsf( f ) < 1.f ) - { - return Q31; - } - else if ( fabsf( f ) > (float) INT_MAX ) - { - return sub( sub( W_norm( (Word64) f ), 32 ), 0 ); - } - else - { - return sub( norm_l( (Word32) f ), 0 ); - } -} - -Word16 L_get_q_buf1( float *ptr_flt, Word16 length ) -{ - Word16 k; - float ftemp = 0.0; - - for ( k = 0; k < length; k++ ) - { - if ( fabsf( ptr_flt[k] ) > ftemp ) - ftemp = fabsf( ptr_flt[k] ); - } - - if ( ftemp >= 0.f && ftemp < 1.f ) - { - return Q31; - } - else if ( ftemp > (float) INT_MAX ) - { - return sub( sub( W_norm( (Word64) ftemp ), 32 ), 0 ); - } - else - { - return sub( norm_l( (Word32) ftemp ), 0 ); - } -} -#undef WMC_TOOL_SKIP diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8f4b53c5e..e5bdb4c29 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -102,80 +102,16 @@ } #endif -/*================================================================================*/ -/* conversion functions: */ -/*================================================================================*/ - -// Float to Word32 -Word32 float_to_fix( float number, Word32 Q ); -// Word32 to Float -float fix_to_float( Word32 number, Word32 Q ); -// Float to Word16 -Word16 float_to_fix16( float number, Word16 Q ); -// Word16 to Float -float fix16_to_float( Word16 number, Word16 Q ); - -Word16 float_to_fix16_thrld( float number, Word16 Q ); - -void floatToFixed_arrL( float *f, Word32 *i, Word16 Q, Word16 l ); -void floatToFixed_arr( float *f, Word16 *i, Word16 Q, Word16 l ); -void fixedToFloat_arrL( Word32 *i, float *f, Word16 Q, Word16 l ); -void fixedToFloat_arr( Word16 *i, float *f, Word16 Q, Word16 l ); -void floatToFixed_arrL32( float *f, Word32 *i, Word16 Q, Word16 l ); -void fixedToFloat_arrL32( Word32 *i, float *f, Word16 Q, Word16 l ); -Word16 Q_factor( float x ); -Word16 Q_factor_L( float x ); -Word16 Q_factor_arr( float *x, Word16 l ); -Word16 Q_factor_arrL( float *x, Word16 l ); -Word16 Q_factor_L_32( Word32 x ); -// Handles the cases where Q is negative -Word32 floatToFixed( float f, Word16 Q ); -float fixedToFloat( Word32 i, Word16 Q ); -Word32 floatToFixed_32( float f, Word16 Q ); -float fixedToFloat_32( Word32 i, Word16 Q ); -float fixedToFloat_16( Word16 i, Word16 Q ); - -void floatToFixed_arr16( float *f, Word16 *i, Word16 Q, Word16 l ); -void floatToFixed_arr32( float *f, Word32 *i, Word16 Q, Word16 l ); -// Float to 32-bit Mantissa and Exponent using frexp -void f2me( float n, Word32 *mantissa, Word16 *expo ); -// 32-bit Mantissa and Exponent to Float using ldexp -float me2f( Word32 m, Word16 expo ); -// Float to 32-bit Mantissa Array and Exponent -void f2me_buf( const float *x, Word32 *m, Word16 *e, const Word32 n ); -// 32-bit Mantissa Array and Exponent to Float -void me2f_buf( const Word32 *m, const Word16 e, float *out, const Word32 n ); -// Float to 16-bit Mantissa and Exponent using frexp -void f2me_16( float n, Word16 *mantissa, Word16 *expo ); -// 16-bit Mantissa and Exponent to Float using ldexp -float me2f_16( Word16 m, Word16 expo ); -// Float to 16-bit Mantissa Array and Exponent -void f2me_buf_16( const float *x, Word16 *m, Word16 *e, const Word32 n ); -// 16-bit Mantissa Array and Exponent to Float -void me2f_buf_16( const Word16 *m, const Word16 e, float *out, const Word32 n ); - -void f2fix_16( float *var_flt, Word16 *var_fix, Word32 expo ); -void fix2f_16( Word16 *var_fix, float *var_flt, Word32 expo ); -void f2fix( float *var_flt, Word32 *var_fix, Word32 expo ); -void fix2f( Word32 *var_fix, float *var_flt, Word32 expo ); - -// Get max Q factor for a float value before sat in 32-bit -Word16 L_get_q( float f ); -Word16 L_get_q1( float f ); -// Get max Q factor for a float buffer before sat in 32-bit -Word16 L_get_q_buf( float *ptr_flt, Word16 length ); -Word16 L_get_q_buf1( float *ptr_flt, Word16 length ); - -/*================================================================================*/ -/* conversion functions: */ -/*================================================================================*/ + +/*----------------------------------------------------------------------------------* + * Prototypes of tools + *----------------------------------------------------------------------------------*/ Word32 sum_l_fx( const Word32 *vec, /* i : input vector */ const Word16 lvec /* i : length of input vector */ ); - Word32 Mult_32_16( Word32 a, Word16 b ); @@ -215,13 +151,11 @@ void set32_fx( const Word16 N /* i : Lenght of the vector */ ); -// tools.c /* o : output random value */ Word16 Random( Word16 *seed /* i/o: random seed */ ); -// tools.c void Copy( const Word16 x[], /* i : i vector */ Word16 y[], /* o : output vector */ @@ -10980,9 +10914,6 @@ Word16 own_random( Word16 *seed /* i/o: random seed */ ); -Word16 norm_ul_float( - UWord32 UL_var1 ); - /*! r: sum of all vector elements */ Word16 sum_s( const Word16 *vec, /* i : input vector */ @@ -11022,17 +10953,6 @@ void set16_zero_fx( const Word16 lvec /* i : length of the vector */ ); -void set_zero( - float *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); - -void mvr2r( - const float x[], /* i : input vector */ - float y[], /* o : output vector */ - const Word16 n /* i : vector size */ -); - void mvs2s( const Word16 x[], /* i : input vector */ Word16 y[], /* o : output vector */ @@ -11058,18 +10978,6 @@ Word16 minimum_s( Word16 *min_val /* o : minimum value in the input vector */ ); -/*! r: dequanzited gain */ -float usdequant( - const Word16 idx, /* i : quantizer index */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta /* i : quantization step */ -); - -void sort( - UWord16 *x, /* i/o: Vector to be sorted */ - UWord16 len /* i/o: vector length */ -); - void sort_l( Word32 *x, /* i/o: Vector to be sorted */ Word16 len /* i/o: vector length */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 1be575c24..d6eb0e2dc 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -72,31 +72,6 @@ Word16 own_random( return ( *seed ); } -/*--------------------------------------------------------------------- - * norm_ul_float() - * - *---------------------------------------------------------------------*/ - -Word16 norm_ul_float( UWord32 UL_var1 ) -{ - Word16 var_out; - - if ( UL_var1 == 0 ) - { - var_out = 0; - } - else - { - for ( var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++ ) - { - UL_var1 <<= 1; - } - } - BASOP_CHECK(); - - return ( var_out ); -} - /*--------------------------------------------------------------------- * sum_s() @@ -359,68 +334,6 @@ void set_l( return; } -/*---------------------------------------------------------------------* - * set_zero() - * - * Set a vector vec[] of dimension lvec to zero - *---------------------------------------------------------------------*/ - -void set_zero( - float *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -) -{ - Word16 i; - - for ( i = 0; i < lvec; i++ ) - { - *vec++ = 0.0f; - } - - return; -} - - -/*---------------------------------------------------------------------* - * mvr2r() - * mvs2s() - * mvr2d() - * mvd2r() - * - * Transfer the contents of vector x[] to vector y[] - *---------------------------------------------------------------------*/ - -void mvr2r( - const float x[], /* i : input vector */ - float y[], /* o : output vector */ - const Word16 n /* i : vector size */ -) -{ - Word16 i; - - if ( n <= 0 ) - { - /* cannot transfer vectors with size 0 */ - return; - } - - if ( y < x ) - { - for ( i = 0; i < n; i++ ) - { - y[i] = x[i]; - } - } - else - { - for ( i = n - 1; i >= 0; i-- ) - { - y[i] = x[i]; - } - } - - return; -} void mvs2s( const Word16 x[], /* i : input vector */ @@ -879,26 +792,6 @@ void v_multc_fx_16_16( return; } -/*-------------------------------------------------------------------* - * usdequant() - * - * Uniform scalar de-quantizer routine - * - * Applies de-quantization based on scale and round operations. - *-------------------------------------------------------------------*/ - -float usdequant( - const Word16 idx, /* i : quantizer index */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta /* i : quantization step */ -) -{ - float g; - - g = idx * delta + qlow; - - return ( g ); -} void sort( UWord16 *x, /* i/o: Vector to be sorted */ @@ -925,192 +818,6 @@ void sort( return; } -#define WMC_TOOL_SKIP - -// conversion functions: -Word32 float_to_fix( float number, Word32 Q ) -{ - assert( Q >= 0 ); - if ( number == 1.0f && Q == Q31 ) - { - return ONE_IN_Q31; - } - if ( isnan( number ) ) - { - number = 0; - } - assert( fabs( number ) < pow( 2, 31 - Q ) ); - Word32 ret = (Word32) ( number * ( (UWord32) 1 << Q ) ); - return ret; -} - -float fix_to_float( - Word32 number, - Word32 Q ) -{ - assert( Q >= 0 ); - float ret = (float) number / ( (UWord32) 1 << Q ); - return ret; -} - -Word16 float_to_fix16( - float number, - Word16 Q ) -{ - assert( Q >= 0 ); - IF( isnan( number ) ) - return 0; - if ( number == 1.0f && Q == Q15 ) - return MAX16B; - if ( number == -1.0f && Q == Q15 ) - return MIN16B; - assert( fabs( number ) < pow( 2, 15 - Q ) ); - Word16 ret = (Word16) ( number * ( (UWord16) 1 << Q ) ); - return ret; -} - -Word16 float_to_fix16_thrld( float number, Word16 Q ) -{ - assert( Q >= 0 ); - if ( number == 1.0f && Q == Q15 ) - return MAX16B; - float limit = (float) pow( 2, 15 - Q ); - /*Add threshold*/ - if ( number > MAX16B_FLT ) - { - number = MAX16B_FLT; - } - else if ( number < MIN16B_FLT ) - { - number = MIN16B_FLT; - } - assert( number <= limit && number >= -limit ); - Word16 ret = (Word16) ( number * ( (UWord16) 1 << Q ) ); - return ret; -} - -float fix16_to_float( Word16 number, Word16 Q ) -{ - assert( Q >= 0 ); - float ret = (float) number / ( (UWord16) 1 << Q ); - return ret; -} - -// Float to 32-bit Mantissa and Exponent -void f2me( float n, Word32 *mantissa, Word16 *expo ) -{ - Word32 e; - float mf = (float) frexp( n, &e ); - *expo = (Word16) e; - *mantissa = float_to_fix( mf, Q31 ); -} - -// 32-bit Mantissa and Exponent to Float -float me2f( Word32 m, Word16 expo ) -{ - float mf = fix_to_float( m, Q31 ); - return (float) ldexp( mf, expo ); -} - -// Float buffer to 32-bit mantissa buffer and common exponent. -void f2me_buf( const float *x, Word32 *m, Word16 *e, const Word32 n ) -{ - Word16 max_e = -32, tmp_e; - Word32 i; - - for ( i = 0; i < n; i++ ) - { - f2me( x[i], &m[i], &tmp_e ); - max_e = ( max_e > tmp_e ) ? max_e : tmp_e; - } - - for ( i = 0; i < n; i++ ) - { - f2me( x[i], &m[i], &tmp_e ); - m[i] = L_shr( m[i], max_e - tmp_e ); - } - - *e = max_e; -} - -// 32-bit Mantissa buffer and exponent into float buffer. -void me2f_buf( const Word32 *m, const Word16 e, float *out, const Word32 n ) -{ - for ( int i = 0; i < n; i++ ) - { - out[i] = me2f( m[i], e ); - } -} - -// Float to 16-bit Mantissa and Exponent -void f2me_16( float n, Word16 *mantissa, Word16 *expo ) -{ - Word32 e; - float mf = (float) frexp( n, &e ); - *expo = (Word16) e; - *mantissa = float_to_fix16( mf, 15 ); -} - -// 16-bit Mantissa and Exponent to Float -float me2f_16( Word16 m, Word16 expo ) -{ - float mf = fix16_to_float( m, 15 ); - return (float) ldexp( mf, expo ); -} - -// Float buffer to 16-bit mantissa buffer and common exponent. -void f2me_buf_16( const float *x, Word16 *m, Word16 *e, const Word32 n ) -{ - Word16 max_e = -16, tmp_e; - Word32 i; - - for ( i = 0; i < n; i++ ) - { - f2me_16( x[i], &m[i], &tmp_e ); - max_e = ( max_e > tmp_e ) ? max_e : tmp_e; - } - - for ( i = 0; i < n; i++ ) - { - f2me_16( x[i], &m[i], &tmp_e ); - m[i] = shr( m[i], max_e - tmp_e ); - } - - *e = max_e; -} - -// 16-bit Mantissa buffer and exponent into float buffer. -void me2f_buf_16( const Word16 *m, const Word16 e, float *out, const Word32 n ) -{ - for ( int i = 0; i < n; i++ ) - { - out[i] = me2f_16( m[i], e ); - } -} -void f2fix( float *var_flt, Word32 *var_fix, Word32 expo ) -{ - *var_fix = (Word32) ( *var_flt * pow( 2, 31 - expo ) ); -} - -void fix2f( Word32 *var_fix, float *var_flt, Word32 expo ) -{ - float mf = fix_to_float( *var_fix, 31 ); - *var_flt = (float) ldexp( mf, expo ); -} - -void f2fix_16( float *var_flt, Word16 *var_fix, Word32 expo ) -{ - *var_fix = (Word16) ( *var_flt * pow( 2, 15 - expo ) ); -} - -void fix2f_16( Word16 *var_fix, float *var_flt, Word32 expo ) -{ - float mf = fix16_to_float( *var_fix, 15 ); - *var_flt = (float) ldexp( mf, expo ); -} - -#undef WMC_TOOL_SKIP - /*-------------------------------------------------------------------* * usdequant_fx() diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index dd5bb4264..d0d31f93a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5499,7 +5499,7 @@ static ivas_error printConfigInfo_dec( IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) { fprintf( stdout, "Output configuration: mono EVS bit-exact decoding to stereo\n" ); - float non_diegetic_pan_gain = fixedToFloat( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, 15 ); + float non_diegetic_pan_gain = (float) ( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx ) / (float) ( 1LL << Q15 ); fprintf( stdout, "Non-diegetic panning: %.2f\n", non_diegetic_pan_gain * 90.f ); } ELSE @@ -5620,7 +5620,7 @@ static ivas_error printConfigInfo_dec( IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) { - float non_diegetic_pan_gain = fixedToFloat( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, 15 ); + float non_diegetic_pan_gain = (float) ( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx ) / (float) ( 1LL << Q15 ); fprintf( stdout, "Non-diegetic panning: %.2f\n", non_diegetic_pan_gain * 90.f ); } diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 32582f2db..e68556664 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -505,7 +505,6 @@ ivas_error ivas_ism_metadata_enc_fx( { idx_angle1_abs = ism_quant_meta_fx( hIsmMetaData->azimuth_fx, &valQ_fx, ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_AZIMUTH_NBITS ); idx_angle2_abs = ism_quant_meta_fx( hIsmMetaData->elevation_fx, &valQ_fx, ism_elevation_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_ELEVATION_NBITS ); - // valQ = fixedToFloat( valQ_fx, Q22 ); } ELSE /* ISM_MODE_PARAM */ { @@ -527,7 +526,6 @@ ivas_error ivas_ism_metadata_enc_fx( Word16 valQ_fx_tmp = extract_h( valQ_fx ); // 22 - 16 = 6 idx_radius_abs = usquant_fx( hIsmMetaData->radius_fx, &valQ_fx_tmp, ISM_RADIUS_MIN_Q9, ISM_RADIUS_DELTA_Q8, 1 << ISM_RADIUS_NBITS ); valQ_fx = L_shr( L_deposit_h( valQ_fx_tmp ), 3 ); // Q22 - // valQ = fixedToFloat( valQ_fx, Q22 ); encode_angle_indices_fx( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] ); encode_radius_fx( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] ); } diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 445540715..37ebdf278 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -48,6 +48,9 @@ #ifdef DBG_WAV_WRITER #include "string.h" #endif +#ifdef DEBUG_QUANT_CODE_OUT +#include "float_to_fix_ops.h" +#endif #include "basop_util.h" /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index 09720d202..b7f890ec3 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -37,15 +37,17 @@ #include #include "wmc_auto.h" #include "debug.h" -#define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) -#define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) + /*------------------------------------------------------------------------------------------* * Static functions declarations *------------------------------------------------------------------------------------------*/ + static void fft_wrapper_2ch_fx( Word32 *buffer_L, Word32 *buffer_R, const Word16 fft_size ); static void ifft_wrapper_2ch_fx( Word32 *buffer_L, Word32 *buffer_R, const Word16 fft_size ); + + /*-----------------------------------------------------------------------------------------* * Function int_log2() * diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index b9762f72c..d45002320 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -98,6 +98,26 @@ static void external_target_interpolation_fx( EXTERNAL_ORIENTATION_HANDLE hExtOr static bool are_orientations_same_fx( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 ); +/*-----------------------------------------------------------------------* + * function Q_factor_L_32() + * + * + *-----------------------------------------------------------------------*/ + +static Word16 Q_factor_L_32( + const Word32 x ) +{ + Word16 Q = 31; + + if ( x >= 1 || x <= -1 ) + { + Q = norm_l( L_abs( (Word32) x ) ); + } + + return Q; +} + + /*-----------------------------------------------------------------------* * ivas_headTrack_open() * diff --git a/lib_util/float_to_fix_ops.c b/lib_util/float_to_fix_ops.c new file mode 100644 index 000000000..0b0dda78c --- /dev/null +++ b/lib_util/float_to_fix_ops.c @@ -0,0 +1,129 @@ + +#include "common_api_types.h" +#include "float_to_fix_ops.h" +#include +#include + + +#define Q15 15 +#define Q31 31 +#define ONE_IN_Q31 0x7fffffff +#define MAX16B 32767 +#define MIN16B ( -32768 ) +#define MAXVAL_WORD32 ( (int32_t) 0x7FFFFFFF ) + + +Word32 float_to_fix( + float number, + const Word32 Q ) +{ + assert( Q >= 0 ); + if ( number == 1.0f && Q == Q31 ) + { + return ONE_IN_Q31; + } + if ( isnan( number ) ) + { + number = 0; + } + assert( fabs( number ) < pow( 2, 31 - Q ) ); + Word32 ret = (Word32) ( number * ( (UWord32) 1 << Q ) ); + + return ret; +} + + +Word16 float_to_fix16( + const float number, + const Word16 Q ) +{ + assert( Q >= 0 ); + if( isnan( number ) ) + return 0; + if ( number == 1.0f && Q == Q15 ) + return MAX16B; + if ( number == -1.0f && Q == Q15 ) + return MIN16B; + assert( fabs( number ) < pow( 2, 15 - Q ) ); + Word16 ret = (Word16) ( number * ( (UWord16) 1 << Q ) ); + + return ret; +} + + +Word32 floatToFixed( + const float f, + const Word16 Q ) +{ + Word64 result_32; + + if ( f == 1.0f && Q == Q15 ) + return MAX16B; + if ( f == 1.0f && Q == Q31 ) + return MAXVAL_WORD32; + if ( Q < 0 ) + result_32 = (Word64) ( (float) ( f ) / (double) ( (unsigned Word64) 1 << ( -Q ) ) + ( f >= 0 ? 0.5 : -0.5 ) ); + else + result_32 = (Word64) ( f * (double) ( (unsigned Word64) 1 << Q ) + ( f >= 0 ? 0.5 : -0.5 ) ); + if ( result_32 > MAX_32 ) + return MAX_32; + if ( result_32 < MIN_32 ) + return MIN_32; + + return (Word32) result_32; +} + +float fixedToFloat( + const Word32 i, + const Word16 Q ) +{ + if ( Q < 0 ) + return ( i * (float) ( ( 1LL ) << ( -Q ) ) ); + else + return (float) ( i ) / (float) ( 1LL << Q ); +} + + +float fix16_to_float( + const Word16 number, + const Word16 Q ) +{ + assert( Q >= 0 ); + float ret = (float) number / ( (UWord16) 1 << Q ); + + return ret; +} + + +Word32 floatToFixed_32( + const float number, + const Word16 Q ) +{ + float val = 0.0f; + assert( abs_s( Q ) <= 63 ); + if ( abs_s( Q ) > 31 ) + { + if ( Q > 0 ) + { + val = ( number * ( (unsigned int) MAX_32 + 1 ) ) * ( 1 << ( Q - 31 ) ); + } + else + { + val = ( number / ( 1 << ( -Q - 31 ) ) ) / (unsigned int) MIN_32; + } + if ( val >= 0.0f ) + { + assert( (Word32) val <= MAX_32 ); + } + else + { + assert( (Word32) val >= MIN_32 ); + } + } + else + { + return floatToFixed( number, Q ); + } + + return (Word32) val; +} diff --git a/lib_util/float_to_fix_ops.h b/lib_util/float_to_fix_ops.h new file mode 100644 index 000000000..35ae446bf --- /dev/null +++ b/lib_util/float_to_fix_ops.h @@ -0,0 +1,20 @@ + +#include "common_api_types.h" + +#ifndef FLOAT_TO_FIX_OPS_H +#define FLOAT_TO_FIX_OPS_H + +Word32 float_to_fix( float number, const Word32 Q ); + +Word16 float_to_fix16( const float number, const Word16 Q ); + +Word32 floatToFixed( const float f, const Word16 Q ); + +Word32 floatToFixed_32( const float number, const Word16 Q ); + +float fixedToFloat( const Word32 i, const Word16 Q ); + +float fix16_to_float( const Word16 number, const Word16 Q ); + +#endif /* FLOAT_TO_FIX_OPS_H */ + diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index aa9c62661..2cced2665 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -34,12 +34,19 @@ #include "cmdl_tools.h" #include #include -#include "prot_fx.h" +#include "float_to_fix_ops.h" + #define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ #define NUM_ISM_METADATA_PER_LINE 8 /* Number of ISM metadata per line in a metadata file */ #define NUM_MIN_ISM_METADATA 1 /* Minimum number of metadata parameters (azimuth) */ +#define Q9 9 +#define Q22 22 +#define Q31 31 +#define DEG_360_IN_Q22 ( 360 << Q22 ) /* Q22 */ +#define DEG_180_IN_Q22 ( 180 << Q22 ) /* Q22 */ +#define DEG_90_IN_Q22 ( 90 << Q22 ) /* Q22 */ struct IsmFileReader { @@ -175,7 +182,7 @@ ivas_error IsmFileReader_readNextFrame( } #ifdef FIX_2084_FLOATING_POINT_LEFTOVERS - if ( GT_32( ismMetadata->azimuth_fx, DEG_180_IN_Q22 ) || LT_32( ismMetadata->azimuth_fx, -DEG_180_IN_Q22 ) ) + if ( ( ismMetadata->azimuth_fx > DEG_180_IN_Q22 ) || ( ismMetadata->azimuth_fx < -DEG_180_IN_Q22 ) ) #else if ( ismMetadata->azimuth > 180 || ismMetadata->azimuth < -180 ) #endif @@ -183,7 +190,7 @@ ivas_error IsmFileReader_readNextFrame( return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } #ifdef FIX_2084_FLOATING_POINT_LEFTOVERS - if ( GT_32( ismMetadata->elevation_fx, DEG_90_IN_Q22 ) || LT_32( ismMetadata->elevation_fx, -DEG_90_IN_Q22 ) ) + if ( ( ismMetadata->elevation_fx > DEG_90_IN_Q22 ) || ( ismMetadata->elevation_fx < -DEG_90_IN_Q22 ) ) #else if ( ismMetadata->elevation > 90 || ismMetadata->elevation < -90 ) #endif @@ -191,7 +198,7 @@ ivas_error IsmFileReader_readNextFrame( return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } #ifdef FIX_2084_FLOATING_POINT_LEFTOVERS - if ( LT_32( ismMetadata->radius_fx, 0 ) ) /* Negative radius not supported. Max quantized radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ + if ( ismMetadata->radius_fx < 0 ) /* Negative radius not supported. Max quantized radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ #else if ( ismMetadata->radius < 0 ) /* Negative radius not supported. Max quantized radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ #endif @@ -199,7 +206,7 @@ ivas_error IsmFileReader_readNextFrame( return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } #ifdef FIX_2084_FLOATING_POINT_LEFTOVERS - if ( GT_32( ismMetadata->spread_fx, DEG_360_IN_Q22 ) || LT_32( ismMetadata->spread_fx, 0 ) ) + if ( ( ismMetadata->spread_fx > DEG_360_IN_Q22 ) || ( ismMetadata->spread_fx < 0 ) ) #else if ( ismMetadata->spread > 360 || ismMetadata->spread < 0 ) #endif @@ -207,7 +214,7 @@ ivas_error IsmFileReader_readNextFrame( return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } #ifdef FIX_2084_FLOATING_POINT_LEFTOVERS - if ( /*GT_32( ismMetadata->gainFactor_fx, ONE_IN_Q31 ) ||*/ LT_32( ismMetadata->gainFactor_fx, 0 ) ) + if ( /*( ismMetadata->gainFactor_fx > ONE_IN_Q31 ) ||*/ ( ismMetadata->gainFactor_fx < 0 ) ) #else if ( ismMetadata->gainFactor > 1 || ismMetadata->gainFactor < 0 ) #endif @@ -215,7 +222,7 @@ ivas_error IsmFileReader_readNextFrame( return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } #ifdef FIX_2084_FLOATING_POINT_LEFTOVERS - if ( GT_32( ismMetadata->yaw_fx, DEG_180_IN_Q22 ) || LT_32( ismMetadata->yaw_fx, -DEG_180_IN_Q22 ) ) + if ( ( ismMetadata->yaw_fx > DEG_180_IN_Q22 ) || ( ismMetadata->yaw_fx < -DEG_180_IN_Q22 ) ) #else if ( ismMetadata->yaw > 180 || ismMetadata->yaw < -180 ) #endif @@ -223,7 +230,7 @@ ivas_error IsmFileReader_readNextFrame( return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } #ifdef FIX_2084_FLOATING_POINT_LEFTOVERS - if ( GT_32( ismMetadata->pitch_fx, DEG_90_IN_Q22 ) || LT_32( ismMetadata->pitch_fx, -DEG_90_IN_Q22 ) ) + if ( ( ismMetadata->pitch_fx > DEG_90_IN_Q22 ) || ( ismMetadata->pitch_fx < -DEG_90_IN_Q22 ) ) #else if ( ismMetadata->pitch > 90 || ismMetadata->pitch < -90 ) #endif diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index 8e55187c8..ba53566af 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -33,11 +33,14 @@ #include "ism_file_writer.h" #include #include +#include "float_to_fix_ops.h" -#include "prot_fx.h" #define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ +#define Q9 9 +#define Q22 22 +#define Q31 31 struct IsmFileWriter { diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 4ef3578f6..dd4d235ef 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -29,11 +29,16 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ + +#include #include #include #include "ivas_rtp_file.h" #include "ivas_error_utils.h" -#include "prot_fx.h" +#include "float_to_fix_ops.h" + + +#define Q15 15 struct IVAS_RTP_FILE { diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 2f32ea858..9746c69ac 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -33,10 +33,14 @@ #include "rotation_file_reader.h" #include #include -#include -#include "prot_fx.h" +#include "float_to_fix_ops.h" +#define Q22 22 +#define Q25 25 +#define Q29 29 +#define Q31 31 + struct RotFileReader { FILE *trajFile; @@ -206,10 +210,7 @@ ivas_error ExternalOrientationFileReading( pQuaternion->x_fx = float_to_fix( x, Q29 ); pQuaternion->y_fx = float_to_fix( y, Q29 ); pQuaternion->z_fx = float_to_fix( z, Q29 ); - move32(); - move32(); - move32(); - move32(); + *enableHeadRotation = (int8_t) headRotFlag; *enableExternalOrientation = (int8_t) extOrientationFlag; *enableRotationInterpolation = (int8_t) rotInterpolationFlag; diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index a4b8cc450..737ef91af 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -33,8 +33,7 @@ #include "vector3_pair_file_reader.h" #include #include -#include "prot_fx.h" // needed for floatToFixed_32 -//#include "ivas_prot_fx.h" // needed for floatToFixed_32 +#include "float_to_fix_ops.h" // needed for floatToFixed_32 struct Vector3PairFileReader @@ -115,8 +114,8 @@ ivas_error Vector3PairFileReader_read( pSecond->y = y2; pSecond->z = z2; - pFirst->q_fact = Q29; - pSecond->q_fact = Q29; + pFirst->q_fact = 29; // Q29 + pSecond->q_fact = 29; // Q29 pFirst->x_fx = floatToFixed_32( pFirst->x, pFirst->q_fact ); pFirst->y_fx = floatToFixed_32( pFirst->y, pFirst->q_fact ); pFirst->z_fx = floatToFixed_32( pFirst->z, pFirst->q_fact ); -- GitLab From eb0ef329ec186bc70e11d0541beda95ce1b81fa3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 14:26:57 +0100 Subject: [PATCH 291/351] clang-format + more cleaning --- apps/decoder.c | 1 - apps/encoder.c | 1 - lib_com/ivas_tools_fx.c | 90 ------------------------------- lib_util/float_to_fix_ops.c | 14 ++--- lib_util/float_to_fix_ops.h | 3 +- lib_util/ls_custom_file_reader.c | 92 +++++++++++++++++++++++++++++++- 6 files changed, 99 insertions(+), 102 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 7bbc63e61..b4068a0c8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -50,7 +50,6 @@ #include "obj_edit_file_reader.h" #include "vector3_pair_file_reader.h" #include "wmc_auto.h" -#include "options.h" #include "stl.h" #ifdef IVAS_RTPDUMP #include "ivas_rtp_file.h" diff --git a/apps/encoder.c b/apps/encoder.c index fe64442e1..95802ba80 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include "options.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 515a10cdb..29d470a55 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -1992,26 +1992,6 @@ void lls_interp_n_fx( } -/* helper function for panning_wrap_angles */ -static float wrap_azi( - const float azi_deg ) -{ - float azi = azi_deg; - - /* Wrap azimuth value */ - while ( azi > 180 ) - { - azi -= 360.0f; - } - - while ( azi <= -180 ) - { - azi += 360; - } - - return azi; -} - /* helper function for panning_wrap_angles */ static Word32 wrap_azi_fx( const Word32 azi_deg /* Q22 */ ) @@ -2034,76 +2014,6 @@ static Word32 wrap_azi_fx( } -/*-------------------------------------------------------------------* - * panning_wrap_angles() - * - * Wrap angles for amplitude panning to the range: - * azimuth = (-180, 180] - * elevation = [-90, 90] - * Considers direction changes from large elevation values - *-------------------------------------------------------------------*/ - -void panning_wrap_angles( - const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ - const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ - float *azi_wrapped, /* o : wrapped azimuth component */ - float *ele_wrapped /* o : wrapped elevation component */ -) -{ - float azi, ele; - - azi = azi_deg; - ele = ele_deg; - - if ( fabsf( ele ) < 90 ) - { - *ele_wrapped = ele; - *azi_wrapped = wrap_azi( azi ); - return; - } - else - { - /* Special case when elevation is a multiple of 90; azimuth is irrelevant */ - if ( ( fmodf( ele, 90 ) == 0 ) && ( fmodf( ele, 180 ) != 0 ) ) - { - *azi_wrapped = 0; - while ( ele > 90 ) - { - ele -= 360; - } - while ( ele < -90 ) - { - ele += 360; - } - *ele_wrapped = ele; - } - else - { - /* Wrap elevation and adjust azimuth accordingly */ - while ( fabsf( ele ) > 90 ) - { - /* Flip to other hemisphere */ - azi += 180; - - /* Compensate elevation accordingly */ - if ( ele > 90 ) - { - ele = 180 - ele; - } - else if ( ele < -90 ) - { - ele = -180 - ele; - } - } - *azi_wrapped = wrap_azi( azi ); - *ele_wrapped = ele; - } - - return; - } -} - - /*-------------------------------------------------------------------* * panning_wrap_angles_fx() * diff --git a/lib_util/float_to_fix_ops.c b/lib_util/float_to_fix_ops.c index 0b0dda78c..4bab0a6b1 100644 --- a/lib_util/float_to_fix_ops.c +++ b/lib_util/float_to_fix_ops.c @@ -5,11 +5,11 @@ #include -#define Q15 15 -#define Q31 31 -#define ONE_IN_Q31 0x7fffffff -#define MAX16B 32767 -#define MIN16B ( -32768 ) +#define Q15 15 +#define Q31 31 +#define ONE_IN_Q31 0x7fffffff +#define MAX16B 32767 +#define MIN16B ( -32768 ) #define MAXVAL_WORD32 ( (int32_t) 0x7FFFFFFF ) @@ -38,8 +38,8 @@ Word16 float_to_fix16( const Word16 Q ) { assert( Q >= 0 ); - if( isnan( number ) ) - return 0; + if ( isnan( number ) ) + return 0; if ( number == 1.0f && Q == Q15 ) return MAX16B; if ( number == -1.0f && Q == Q15 ) diff --git a/lib_util/float_to_fix_ops.h b/lib_util/float_to_fix_ops.h index 35ae446bf..0cd23cbc6 100644 --- a/lib_util/float_to_fix_ops.h +++ b/lib_util/float_to_fix_ops.h @@ -13,8 +13,7 @@ Word32 floatToFixed( const float f, const Word16 Q ); Word32 floatToFixed_32( const float number, const Word16 Q ); float fixedToFloat( const Word32 i, const Word16 Q ); - + float fix16_to_float( const Word16 number, const Word16 Q ); #endif /* FLOAT_TO_FIX_OPS_H */ - diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 37784a630..5c1ac6ae0 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -33,7 +33,7 @@ #include "ls_custom_file_reader.h" #include #include -#include "ivas_prot_fx.h" +#include struct LsCustomFileReader @@ -105,6 +105,96 @@ void CustomLsReader_close( } +/*-------------------------------------------------------------------* + * panning_wrap_angles() + * + * Wrap angles for amplitude panning to the range: + * azimuth = (-180, 180] + * elevation = [-90, 90] + * Considers direction changes from large elevation values + *-------------------------------------------------------------------*/ + +/* helper function for panning_wrap_angles */ +static float wrap_azi( + const float azi_deg ) +{ + float azi = azi_deg; + + /* Wrap azimuth value */ + while ( azi > 180 ) + { + azi -= 360.0f; + } + + while ( azi <= -180 ) + { + azi += 360; + } + + return azi; +} + +static void panning_wrap_angles( + const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ + const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ + float *azi_wrapped, /* o : wrapped azimuth component */ + float *ele_wrapped /* o : wrapped elevation component */ +) +{ + float azi, ele; + + azi = azi_deg; + ele = ele_deg; + + if ( fabsf( ele ) < 90 ) + { + *ele_wrapped = ele; + *azi_wrapped = wrap_azi( azi ); + return; + } + else + { + /* Special case when elevation is a multiple of 90; azimuth is irrelevant */ + if ( ( fmodf( ele, 90 ) == 0 ) && ( fmodf( ele, 180 ) != 0 ) ) + { + *azi_wrapped = 0; + while ( ele > 90 ) + { + ele -= 360; + } + while ( ele < -90 ) + { + ele += 360; + } + *ele_wrapped = ele; + } + else + { + /* Wrap elevation and adjust azimuth accordingly */ + while ( fabsf( ele ) > 90 ) + { + /* Flip to other hemisphere */ + azi += 180; + + /* Compensate elevation accordingly */ + if ( ele > 90 ) + { + ele = 180 - ele; + } + else if ( ele < -90 ) + { + ele = -180 - ele; + } + } + *azi_wrapped = wrap_azi( azi ); + *ele_wrapped = ele; + } + + return; + } +} + + /*-------------------------------------------------------------------------* * CustomLoudspeakerLayout_validate() * -- GitLab From ce6307ad646a82a063f3f334b7a1e0c3d733079c Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 14:41:51 +0100 Subject: [PATCH 292/351] clang-format + more cleaning --- lib_com/ivas_prot_fx.h | 12 ------------ lib_dec/lib_dec_fx.c | 3 +++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0e607039f..75227dd6a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -6771,18 +6771,6 @@ void ivas_ism_renderer_close( ); -/*----------------------------------------------------------------------------------* - * Amplitude Panning VBAP prototypes - *----------------------------------------------------------------------------------*/ - -void panning_wrap_angles( - const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ - const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ - float *azi_wrapped, /* o : wrapped azimuth component */ - float *ele_wrapped /* o : wrapped elevation component */ -); - - /*----------------------------------------------------------------------------------* * McMASA prototypes *----------------------------------------------------------------------------------*/ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index d0d31f93a..34abd9c41 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -43,6 +43,9 @@ #include "jbm_pcmdsp_fifo.h" #include #include +#ifdef DEBUGGING +#include "float_to_fix_ops.h" +#endif #include "wmc_auto.h" -- GitLab From 4051f3c87ab93631c2349cd81ac35652e5c966c7 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 11 Nov 2025 16:35:30 +0100 Subject: [PATCH 293/351] Add headroom to p_output_fx to prevent overflow in ivas_rend_crendProcessSubframe_fx(). --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec_fx.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index b6d1ca2b6..f814ac861 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -105,6 +105,7 @@ #define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue */ #define FIX_2200_ISAR_PLC_CRASH /* Dolby: Fix for ISAR PLC crash observed with newly added BASOP tests */ #define FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA /* FhG: Resolve overflow by swapping the order of addition and multiplication */ +#define FIX_2211_ASSERT_IN_REND_CREND_CONVOLER /* FhG: Add headroom to p_output_fx to prevent overflow in ivas_rend_crendProcessSubframe_fx() */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 42270d50d..3dbc4f15f 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2766,9 +2766,19 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { return error; } +#ifdef FIX_2211_ASSERT_IN_REND_CREND_CONVOLER + Word16 subframe_len, gd_bits; + subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity ); + gd_bits = find_guarded_bits_fx( subframe_len ); + *st_ivas->hCrendWrapper->p_io_qfactor = sub( 13, gd_bits ); + FOR( Word16 i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor + } +#else *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); - +#end IF( NE_32( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : st_ivas->hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ), IVAS_ERR_OK ) ) @@ -2777,6 +2787,12 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); +#ifdef FIX_2211_ASSERT_IN_REND_CREND_CONVOLER + FOR( Word16 i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 + } +#endif } ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) { -- GitLab From a75f0f0e90eb32b35bd23fd191ae8f3646b83843 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 11 Nov 2025 16:40:44 +0100 Subject: [PATCH 294/351] Fix macro terminator --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3dbc4f15f..988013697 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2778,7 +2778,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( #else *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); -#end +#endif IF( NE_32( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : st_ivas->hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ), IVAS_ERR_OK ) ) -- GitLab From 5224af90575367d8abb566b883ea9878b4398986 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 17:23:50 +0100 Subject: [PATCH 295/351] RTP revision --- apps/decoder.c | 93 ++++++++++------- apps/encoder.c | 18 ++-- apps/encoder_fmtsw.c | 55 +++++++--- lib_com/bitstream_fx.c | 1 + lib_com/common_api_types.h | 3 + lib_com/ivas_cnst.h | 3 - lib_com/ivas_prot_fx.h | 7 +- lib_dec/ivas_init_dec_fx.c | 67 +++++++----- lib_dec/ivas_output_config_fx.c | 4 +- lib_dec/ivas_stat_dec.h | 6 +- lib_dec/lib_dec.h | 39 ++++--- lib_dec/lib_dec_fx.c | 174 +++++++++++++++++++++++-------- lib_rend/ivas_render_config_fx.c | 2 +- lib_rend/ivas_rotation_fx.c | 5 + lib_util/ivas_rtp_pi_data.h | 2 +- readme.txt | 48 ++++++--- 16 files changed, 349 insertions(+), 178 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 458c164ac..88b330e8e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -55,13 +55,7 @@ #ifdef IVAS_RTPDUMP #include "ivas_rtp_file.h" #endif -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#include "ivas_cnst.h" -#endif -#ifdef FIXED_RTP_SEQUENCE_NUM -#define RANDOM_INITSEED_DEC ( 0xFEEDFADE ) -#endif #define WMC_TOOL_SKIP @@ -74,6 +68,10 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_DEC ( 0xFEEDFADE ) +#endif + #ifdef DEBUGGING #define MIN_NUM_BITS_ACTIVE_FRAME 56 #define NUM_BITS_SID_IVAS_5K2 104 @@ -193,11 +191,11 @@ static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS #endif static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader ); - #ifdef DECODER_FORMAT_SWITCHING -static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, IVAS_DEC_MODE codec, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData ); +static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, const IVAS_DEC_MODE decMode, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData ); #endif + /*------------------------------------------------------------------------------------------* * main() * @@ -495,7 +493,6 @@ int main( fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - #ifndef IVAS_RTPDUMP arg.enableHeadRotation = true; #endif @@ -558,6 +555,7 @@ int main( fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); goto cleanup; } + #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); if ( aeCount > 0 ) @@ -1877,6 +1875,7 @@ static ivas_error initOnFirstGoodFrame( ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; int16_t splitRendIsarFrameSizeMs; int16_t lc3plusHighRes; + #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we use fixed seed for random num generator for regression based tests. Any realtime @@ -2411,7 +2410,7 @@ static ivas_error decodeG192( fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); goto cleanup; } - /* Head-tracking input simulation */ + /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -3047,6 +3046,7 @@ static ivas_error decodeVoIP( int16_t i; #ifdef DECODER_FORMAT_SWITCHING IVAS_DEC_HANDLE hIvasDec = *phIvasDec; + bool restartNeeded; #endif #ifdef IVAS_RTPDUMP IVAS_RTP ivasRtp = { 0 }; @@ -3243,21 +3243,22 @@ static ivas_error decodeVoIP( nSamplesRendered = 0; #ifdef DECODER_FORMAT_SWITCHING + /* restart decoder in case of format switching */ if ( ivasRtp.restartNeeded ) { - IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - error = restartDecoder( + IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + if(( error = restartDecoder( &hIvasDec, - newCodecInPacket, + newDecModeInPacket, &arg, NULL, /* ToDo : Provide rendererConfig */ NULL /* ToDo : Provide LS Custom Data */ - ); - if ( error != IVAS_ERR_OK ) + ) )!= IVAS_ERR_OK ) { - fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket ); + fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newDecModeInPacket ); goto cleanup; } + *phIvasDec = hIvasDec; /* Update for main()' s free */ ivasRtp.restartNeeded = false; } @@ -3296,6 +3297,7 @@ static ivas_error decodeVoIP( goto cleanup; } } + int16_t num_subframes; if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) { @@ -3303,7 +3305,6 @@ static ivas_error decodeVoIP( goto cleanup; } - /* Head-tracking input simulation */ /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -3446,12 +3447,17 @@ static ivas_error decodeVoIP( /* we are finished when all packets have been received and jitter buffer is empty */ /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */ /* last clause should make sure that for BE tests we end up with the same number of samples...*/ - if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) + bool isEmpty; + if ( ( error = IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples, &isEmpty ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( isEmpty || nFramesFed < 2 ) ) { break; } - /* decode and get samples */ while ( nSamplesRendered < nOutSamples ) { @@ -3468,7 +3474,7 @@ static ivas_error decodeVoIP( numPiData++; } - if ( ( error = IVAS_RTP_FeedPiDataToDecoder( hIvasDec, &ivasRtp.piData[ivasRtp.nProcPiData], numPiData ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedPiDataToDecoder( hIvasDec, &ivasRtp.piData[ivasRtp.nProcPiData], numPiData ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3477,6 +3483,7 @@ static ivas_error decodeVoIP( ivasRtp.nProcPiData += numPiData; } #endif + #ifdef FIX_1119_SPLIT_RENDERING_VOIP if ( isSplitRend ) { @@ -3516,34 +3523,42 @@ static ivas_error decodeVoIP( return error; } - /* Placeholder for memory reallocation */ - /* ... */ #ifdef DECODER_FORMAT_SWITCHING - if ( IVAS_DEC_isRestartNeeded( hIvasDec ) ) + /* restart decoder in case of format switching */ + if ( ( error = IVAS_DEC_isRestartNeeded( hIvasDec, &restartNeeded ) ) != IVAS_ERR_OK ) { - IVAS_DEC_BS_FORMAT tempFormat; - if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK ) + return error; + } + + if ( restartNeeded ) + { + IVAS_DEC_BS_FORMAT tempBsFormat; + if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempBsFormat ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error ); goto cleanup; } - IVAS_DEC_MODE codecMode = ( tempFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - error = restartDecoder( + + IVAS_DEC_MODE newDecModeInPacket = ( tempBsFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; + if((error = restartDecoder( &hIvasDec, - codecMode, + newDecModeInPacket , &arg, NULL, /* ToDo : Provide rendererConfig */ NULL /* ToDo : Provide LS Custom Data */ - ); - if ( error != IVAS_ERR_OK ) + ) )!= IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to restart decoder\n" ); goto cleanup; } + *phIvasDec = hIvasDec; /* Update for main()' s free */ } #endif + /* Placeholder for memory reallocation */ + /* ... */ + /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { @@ -3859,7 +3874,6 @@ static ivas_error decodeVoIP( } } - /*------------------------------------------------------------------------------------------* * Add zeros at the end to have equal length of synthesized signals *------------------------------------------------------------------------------------------*/ @@ -4322,9 +4336,15 @@ static ivas_error load_hrtf_from_file( #ifdef DECODER_FORMAT_SWITCHING -ivas_error restartDecoder( +/*---------------------------------------------------------------------* + * restartDecoder() + * + * Restart decoder in case of IVAS format switching + *---------------------------------------------------------------------*/ + +static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, - IVAS_DEC_MODE codec, + const IVAS_DEC_MODE decMode, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData ) @@ -4342,19 +4362,19 @@ ivas_error restartDecoder( IVAS_DEC_Close( phIvasDec ); } - if ( ( error = IVAS_DEC_Open( phIvasDec, codec ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_Open( phIvasDec, decMode ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - arg->decMode = codec; + arg->decMode = decMode; hIvasDec = *phIvasDec; uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : 65535; - IVAS_AUDIO_CONFIG outputConfig = ( codec == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO; + IVAS_AUDIO_CONFIG outputConfig = ( decMode == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO; #ifdef FIX_1318_ROOM_SIZE_CMD_LINE if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->renderFramesize, arg->customLsOutputEnabled, arg->hrtfReaderEnabled, arg->enableHeadRotation, arg->enableExternalOrientation, arg->orientation_tracking, arg->renderConfigEnabled, arg->roomSize, arg->non_diegetic_pan_enabled, @@ -4429,6 +4449,7 @@ ivas_error restartDecoder( cleanup: IVAS_DEC_Close( phIvasDec ); + return error; } diff --git a/apps/encoder.c b/apps/encoder.c index fe64442e1..3e2bd7778 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -63,10 +63,6 @@ #endif #endif -#ifdef FIXED_RTP_SEQUENCE_NUM -#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) -#endif - #define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* @@ -78,6 +74,10 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) +#endif + #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ @@ -468,14 +468,14 @@ int main( if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - exit( -1 ); + goto cleanup; } break; case IVAS_ENC_INPUT_MASA_ISM: if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForMASAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - exit( -1 ); + goto cleanup; } break; default: @@ -672,6 +672,10 @@ int main( } #endif + /*------------------------------------------------------------------------------------------* + * Run the encoder + *------------------------------------------------------------------------------------------*/ + int16_t numSamplesRead = 0; uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME]; uint16_t numBits = 0; @@ -1841,6 +1845,7 @@ static bool parseCmdlIVAS_enc( { i++; arg->rtpdumpOutput = true; + if ( i < argc - 4 ) { if ( !is_digits_only( argv[i] ) ) @@ -1857,6 +1862,7 @@ static bool parseCmdlIVAS_enc( } } } + fprintf( stdout, "Output format: RTPDump using %d frames/packet \n", arg->numFramesPerPacket ); } diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 74efb401f..5d48ec04f 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -63,10 +63,6 @@ #endif #endif -#ifdef FIXED_RTP_SEQUENCE_NUM -#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) -#endif - #define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* @@ -81,6 +77,10 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef FIXED_RTP_SEQUENCE_NUM +#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) +#endif + #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ @@ -199,13 +199,14 @@ static int encoder_main( int argc, char *argv[] ); * main() * * Main IVAS encoder function for command-line interface - * supporting format switching + * supporting IVAS format switching *------------------------------------------------------------------------------------------*/ int main( int argc, char *argv[] ) { + bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ FILE *FmtSWFile = NULL; char line[2048]; int argc_local = 0; @@ -218,18 +219,18 @@ int main( IVAS_ENC_PrintDisclaimer(); - if ( argc != 2 ) + if ( argc != 3 ) { fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" ); fprintf( stdout, "where format_switching_file is a text file containg a valid encoder command line in each line\n\n" ); - exit( 0 ); + goto cleanup; } fprintf( stdout, "Input format switching file: %s\n", argv[1] ); if ( ( FmtSWFile = fopen( argv[1], "r" ) ) == NULL ) { fprintf( stdout, "error: cannot open format switching file %s\n", argv[1] ); - exit( 0 ); + goto cleanup; } while ( fgets( line, sizeof( line ), FmtSWFile ) ) @@ -238,11 +239,15 @@ int main( line[strcspn( line, "\r\n" )] = 0; printf( "Processing format switching commandline: %s\n", line ); str2arg( line, &argc_local, argv_local ); + #ifdef IVAS_RTPDUMP if ( strcmp( argv_local[argc_local - 1], (char *) prev_outputBitstreamFilename ) == 0 ) { /* append to last Rtp file */ - encoder_main( argc_local, argv_local, &ivasRtp, 0 ); + if ( encoder_main( argc_local, argv_local, &ivasRtp, 0 ) != 0 ) + { + goto cleanup; + } } else { @@ -250,8 +255,13 @@ int main( { IVAS_RTP_Term( &ivasRtp ); } + /* write in separate Rtp file */ - encoder_main( argc_local, argv_local, &ivasRtp, 1 ); + if ( encoder_main( argc_local, argv_local, &ivasRtp, 1 ) != 0 ) + { + goto cleanup; + } + rtp_term = 1; } strcpy( (char *) prev_outputBitstreamFilename, argv_local[argc_local - 1] ); @@ -259,11 +269,24 @@ int main( encoder_main( argc_local, argv_local ); #endif } + + /*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ + + mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ + +cleanup: + #ifdef IVAS_RTPDUMP IVAS_RTP_Term( &ivasRtp ); #endif - fclose( FmtSWFile ); - exit( 0 ); + if( FmtSWFile) + { + fclose( FmtSWFile ); + } + + return mainFailed ? -1 : 0; } @@ -568,14 +591,14 @@ int encoder_main( if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - exit( -1 ); + goto cleanup; } break; case IVAS_ENC_INPUT_MASA_ISM: if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForMASAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - exit( -1 ); + goto cleanup; } break; default: @@ -772,6 +795,10 @@ int encoder_main( } #endif + /*------------------------------------------------------------------------------------------* + * Run the encoder + *------------------------------------------------------------------------------------------*/ + int16_t numSamplesRead = 0; uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME]; uint16_t numBits = 0; diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index a80929e68..ea576255a 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -3860,6 +3860,7 @@ void convertSerialToBytestream_fx( UWord8 bitinbyte2, bytestream_tmp; assert( num_bits <= MAX_16 ); /* 512 kbps = 10240 bits, num_bits should always fits Word16 */ #endif + FOR( i = 0; i < num_bits; ++i ) { IF( EQ_32( serial[i], 0x0001 ) ) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 3c3c6b2b7..d41635f8d 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -62,6 +62,9 @@ #define IVAS_REVERB_PREDELAY_MAX 20 /* Max input delay for reverb module */ #define IVAS_ER_LIST_HEIGHT 1.6f #define IVAS_ER_LIST_HEIGHT_FX 6710886 /* 1.6f in Q.22 */ +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT +#define IVAS_DEFAULT_AEID 65535 +#endif /* JBM constants for adaptive-playout */ #define IVAS_TIME_SCALE_MIN 50 /* min. time-scaling [%] */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 335721a0a..f3d33b153 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1668,9 +1668,6 @@ typedef enum #else #define IVAS_REVERB_DEFAULT_N_BANDS 31 #endif -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#define IVAS_DEFAULT_AEID ( 65535 ) -#endif #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0cb0174d6..55a4efde9 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4030,16 +4030,11 @@ ivas_error ivas_output_buff_dec_fx( ); ivas_error ivas_dec_get_format_fx( -#ifdef DECODER_FORMAT_SWITCHING - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const bool isVoipMode /* i : voip mode indicator */ -#else Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#endif ); ivas_error ivas_dec_setup( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); ivas_error create_mct_dec_fx( diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 984f02ece..ffbb0c6ab 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -104,18 +104,17 @@ static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( *---------------------------------------------------------------------*/ ivas_error ivas_dec_get_format_fx( -#ifdef DECODER_FORMAT_SWITCHING - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const bool isVoipMode /* i : voip mode indicator */ -#else Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#endif ) { Word16 k, idx, num_bits_read; Word16 nchan_ism, element_mode_flag; Word16 sba_order, sba_planar, sba_analysis_order; Word32 ivas_total_brate; +#ifdef DECODER_FORMAT_SWITCHING + int16_t Opt_tsm; +#endif + UWord16 *bit_stream_orig; AUDIO_CONFIG signaled_config; ivas_error error; @@ -127,6 +126,10 @@ ivas_error ivas_dec_get_format_fx( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); +#ifdef DECODER_FORMAT_SWITCHING + Opt_tsm = st_ivas->hDecoderConfig->Opt_tsm; + move16(); +#endif bit_stream_orig = st_ivas->bit_stream; /*-------------------------------------------------------------------* @@ -148,10 +151,11 @@ ivas_error ivas_dec_get_format_fx( !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -205,10 +209,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -248,10 +253,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -278,10 +284,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -315,7 +322,7 @@ ivas_error ivas_dec_get_format_fx( { #ifdef DECODER_FORMAT_SWITCHING test(); - IF( st_ivas->nchan_transport == 1 && isVoipMode ) + if( st_ivas->nchan_transport == 1 && Opt_tsm ) { masaRestartCandidate = 1; move16(); @@ -330,7 +337,7 @@ ivas_error ivas_dec_get_format_fx( { #ifdef DECODER_FORMAT_SWITCHING test(); - IF( st_ivas->nchan_transport == 2 && isVoipMode ) + if( st_ivas->nchan_transport == 2 && Opt_tsm ) { masaRestartCandidate = 1; move16(); @@ -374,6 +381,7 @@ ivas_error ivas_dec_get_format_fx( { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } #endif @@ -382,10 +390,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -420,10 +429,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -454,10 +464,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -501,10 +512,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -547,10 +559,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -665,10 +678,11 @@ ivas_error ivas_dec_get_format_fx( IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ) { #ifdef DECODER_FORMAT_SWITCHING - IF( isVoipMode ) + IF( Opt_tsm ) { st_ivas->restartNeeded = 1; move16(); + return IVAS_ERR_OK; } ELSE @@ -3699,6 +3713,15 @@ void ivas_destroy_dec_fx( /* Config. Renderer */ ivas_render_config_close_fx( &( st_ivas->hRenderConfig ) ); +#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + /* Acoustic environments */ + IF( st_ivas->pAcousticEnvironments != NULL ) + { + free( st_ivas->pAcousticEnvironments ); + st_ivas->pAcousticEnvironments = NULL; + } +#endif + /* Limiter struct */ ivas_limiter_close_fx( &( st_ivas->hLimiter ) ); @@ -3732,16 +3755,6 @@ void ivas_destroy_dec_fx( #endif } -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - /* Acoustic environments */ - IF( st_ivas->pAcousticEnvironments != NULL ) - { - free( st_ivas->pAcousticEnvironments ); - st_ivas->pAcousticEnvironments = NULL; - } -#endif - - /* main IVAS handle */ free( st_ivas ); diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 0cec1b914..0637ea4c9 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -119,9 +119,7 @@ void ivas_renderer_select( #ifdef FIX_1419_MONO_STEREO_UMX IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - ms_bin_upmix_renderer_select( st_ivas->ivas_format, - internal_config, - renderer_type ); + ms_bin_upmix_renderer_select( st_ivas->ivas_format, internal_config, renderer_type ); } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) #else diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index df8607cb5..95030d576 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1217,14 +1217,14 @@ typedef struct Decoder_Struct JBM_METADATA_HANDLE hJbmMetadata; /* Structure for metadata buffering in JBM */ Word32 last_active_ivas_total_brate; - Word16 ism_extmeta_active; /* Extended metadata active in decoder */ - Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ + Word16 ism_extmeta_active; /* Extended metadata active in decoder */ + Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR Word16 flushing; #endif #ifdef DECODER_FORMAT_SWITCHING - UWord8 restartNeeded; /* Flag to check if the decoder requires a restart */ + Word16 restartNeeded; /* Flag to signal decoder restart */ #endif } Decoder_Struct; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 23a353ff0..633d2016c 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -90,6 +90,7 @@ typedef enum _IVAS_DEC_BS_FORMAT } IVAS_DEC_BS_FORMAT; typedef struct IVAS_DEC *IVAS_DEC_HANDLE; +typedef struct pidata_ts_struct *hPiDataTs; #ifdef SUPPORT_JBM_TRACEFILE /* Callback function for JBM tracefile writing */ @@ -292,7 +293,7 @@ ivas_error IVAS_DEC_VoIP_SetScale( #ifdef VARIABLE_SPEED_DECODING ivas_error IVAS_DEC_EnableTsm( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); ivas_error IVAS_DEC_TSM_SetQuality( @@ -342,11 +343,13 @@ ivas_error IVAS_DEC_Flush( ); #ifdef DECODER_FORMAT_SWITCHING -bool IVAS_DEC_isRestartNeeded( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +ivas_error IVAS_DEC_isRestartNeeded( + IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ + bool *restartNeeded /* o : flag to signal decoder restart */ ); #endif + /* Setter functions - apply changes to decoder configuration */ /*! r: error code */ @@ -463,14 +466,14 @@ ivas_error IVAS_DEC_HRTF_binary_close( #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT ivas_error IVAS_DEC_AddAcousticEnvironment( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcousticsConfig /* i : Room acoustic configuration */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcousticsConfig /* i: Room acoustic configuration */ ); ivas_error IVAS_DEC_GetAcousticEnvironment( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 aeID, /* i : Acoustic environment ID */ - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Room acoustic environment data pointer */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 aeID, /* i : Acoustic environment ID */ + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcEnv /* o : Room acoustic environment data pointer */ ); #endif @@ -505,9 +508,10 @@ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( ); /*! r: true if decoder has no data in VoIP jitter buffer */ -bool IVAS_DEC_VoIP_IsEmpty( +ivas_error IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked + const Word16 nSamplesAsked, /* i : number of output samples asked */ + bool *isEmpty /* o : isEmpty flag */ ); ivas_error IVAS_DEC_VoIP_Get_CA_offset( @@ -523,6 +527,14 @@ ivas_error IVAS_DEC_GetJbmData( ); #endif +#ifdef IVAS_RTPDUMP +ivas_error IVAS_DEC_FeedPiDataToDecoder( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + hPiDataTs piData, /* i : PI data received in rtp packet */ + UWord32 numPiData /* i : number of PI data received in rtp packet */ +); +#endif + /* Utility functions */ /*! r: pointer to an error message string */ @@ -540,13 +552,6 @@ void IVAS_DEC_PrintDisclaimer( void ); -#ifdef IVAS_RTPDUMP -#ifndef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#include "ivas_rtp_pi_data.h" -#endif -ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, UWord32 numPiData ); -#endif - /* clang-format on */ #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 246fd4e29..178465c10 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -41,6 +41,9 @@ #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" #include "jbm_pcmdsp_fifo.h" +#ifdef IVAS_RTPDUMP +#include "ivas_rtp_pi_data.h" +#endif #include #include #include "wmc_auto.h" @@ -2987,6 +2990,7 @@ ivas_error IVAS_DEC_HRTF_binary_close( return IVAS_ERR_OK; } + #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT /*---------------------------------------------------------------------* * IVAS_DEC_AddAcousticEnvironment( ) @@ -3033,6 +3037,7 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( { return IVAS_ERR_FAILED_ALLOC; } + st_ivas->pAcousticEnvironments = ppAE; n = st_ivas->acousticEnvironmentsCount++; pAE = &st_ivas->pAcousticEnvironments[n]; @@ -3058,7 +3063,7 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( move32(); move16(); - IF( pAE->use_er == 1 ) + IF( EQ_16( pAE->use_er, 1 ) ) { pAE->lowComplexity = roomAcousticsConfig.lowComplexity; move32(); @@ -3083,11 +3088,13 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetAcousticEnvironment( ) * * Gets acoustic environment configuration with a given ID *---------------------------------------------------------------------*/ + ivas_error IVAS_DEC_GetAcousticEnvironment( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ UWord16 aeID, /* i : Acoustic environment ID */ @@ -3096,7 +3103,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( { Word16 n, m; Word16 found = 0; - + move16(); Decoder_Struct *st_ivas; test(); @@ -3104,6 +3111,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + st_ivas = hIvasDec->st_ivas; move32(); @@ -3111,7 +3119,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( test(); IF( aeID == (UWord16) IVAS_DEFAULT_AEID && st_ivas->acousticEnvironmentsCount > 0 ) { - aeID = (UWord16) st_ivas->pAcousticEnvironments[0].aeID; + aeID = st_ivas->pAcousticEnvironments[0].aeID; move32(); } @@ -3143,6 +3151,7 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( /* If ER are allocated then propagate parameters */ pAcEnv->use_er = ae.use_er; move16(); + IF( ae.use_er != 0 ) { pAcEnv->lowComplexity = ae.lowComplexity; @@ -3167,8 +3176,16 @@ ivas_error IVAS_DEC_GetAcousticEnvironment( } } - return found ? IVAS_ERR_OK : IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; + IF( found == 0 ) + { + return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; + } + ELSE + { + return IVAS_ERR_OK; + } } + #endif /*---------------------------------------------------------------------* @@ -3388,13 +3405,14 @@ ivas_error IVAS_DEC_FeedRenderConfig( } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT + /*---------------------------------------------------------------------* - * IVAS_DEC_FeedAcousticEnvPI( ) + * feedAcousticEnvPI( ) * * Set acoustic environment from the PI data *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_FeedAcousticEnvPI( +static ivas_error feedAcousticEnvPI( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const IVAS_PIDATA_ACOUSTIC_ENV hAcoustEnvPI /* i : Render configuration struct */ ) @@ -3416,7 +3434,7 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( move32(); /* Ignore if AE ID already in use */ - IF( hRenderConfig->roomAcoustics.aeID == hAcoustEnvPI.aeid ) + IF( EQ_16(hRenderConfig->roomAcoustics.aeID , hAcoustEnvPI.aeid )) { return IVAS_ERR_OK; } @@ -3531,6 +3549,7 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( return IVAS_ERR_OK; } + #endif /*---------------------------------------------------------------------* @@ -4041,17 +4060,13 @@ ivas_error IVAS_DEC_ReadFormat( IF( st_ivas->bfi == 0 ) { -#ifdef DECODER_FORMAT_SWITCHING - IF( NE_32( error = ivas_dec_get_format_fx( st_ivas, hIvasDec->hVoIP != NULL ), IVAS_ERR_OK ) ) -#else IF( NE_32( error = ivas_dec_get_format_fx( st_ivas ), IVAS_ERR_OK ) ) -#endif { return error; } #ifdef DECODER_FORMAT_SWITCHING - IF( st_ivas->restartNeeded > 0 ) + IF( EQ_16( st_ivas->restartNeeded, 1 ) ) { return IVAS_ERR_OK; } @@ -5654,11 +5669,26 @@ ivas_error IVAS_DEC_Flush( * *---------------------------------------------------------------------*/ -bool IVAS_DEC_isRestartNeeded( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +ivas_error IVAS_DEC_isRestartNeeded( + IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ + bool *restartNeeded /* o : flag to signal decoder restart */ ) { - return hIvasDec->st_ivas->restartNeeded > 0; + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *restartNeeded = false; + move16(); + if ( EQ_16( hIvasDec->st_ivas->restartNeeded, 1 ) ) + { + *restartNeeded = true; + move16(); + } + + return IVAS_ERR_OK; } @@ -5666,12 +5696,13 @@ bool IVAS_DEC_isRestartNeeded( /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_IsEmpty( ) * - * + * Returns 'true' if decoder has no data in VoIP jitter buffer *---------------------------------------------------------------------*/ -bool IVAS_DEC_VoIP_IsEmpty( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked /* i : number of output samples asked */ +ivas_error IVAS_DEC_VoIP_IsEmpty( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const Word16 nSamplesAsked, /* i : number of output samples asked */ + bool *isEmpty /* o : isEmpty flag */ ) { test(); @@ -5680,8 +5711,16 @@ bool IVAS_DEC_VoIP_IsEmpty( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + *isEmpty = false; + move16(); test(); - return ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 && LT_16( hIvasDec->nSamplesAvailableNext, nSamplesAsked ) ); + if ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && LT_16( hIvasDec->nSamplesAvailableNext, nSamplesAsked ) ) + { + *isEmpty = true; + move16(); + } + + return IVAS_ERR_OK; } @@ -6924,35 +6963,45 @@ ivas_error IVAS_DEC_is_split_rendering_coded_out( } #ifdef IVAS_RTPDUMP + /*---------------------------------------------------------------------* - * IVAS_DEC_feedSinglePIorientation( ) + * feedSinglePIorientation( ) * * Feed a single orientation PI data to external orientation handle. *---------------------------------------------------------------------*/ -static ivas_error IVAS_DEC_feedSinglePIorientation( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - bool isOrientationSaved, /* i : flag to indicate if an orientation for this PI type was previously saved */ - IVAS_QUATERNION *savedOrientation /* i : previously saved orientation for this PI type */ +static ivas_error feedSinglePIorientation( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const bool isOrientationSaved, /* i : flag to indicate if an orientation for this PI type was previously saved */ + IVAS_QUATERNION *savedOrientation /* i : previously saved orientation for this PI type */ ) { Word16 i; - ivas_error error = IVAS_ERR_OK; + ivas_error error; + Decoder_Struct *st_ivas; IVAS_QUATERNION savedInvOrientation; + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; + IF( isOrientationSaved ) { - IF( !hIvasDec->st_ivas->hExtOrientationData ) + IF( !st_ivas->hExtOrientationData ) { - IF( NE_32( error = ivas_external_orientation_open_fx( &( hIvasDec->st_ivas->hExtOrientationData ), hIvasDec->st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) + IF( NE_32( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) { return error; } } - IF( !hIvasDec->st_ivas->hCombinedOrientationData ) + IF( !st_ivas->hCombinedOrientationData ) { - IF( NE_32( error = ivas_combined_orientation_open_fx( &( hIvasDec->st_ivas->hCombinedOrientationData ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, hIvasDec->st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) + IF( NE_32( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) ) { return error; } @@ -6961,57 +7010,87 @@ static ivas_error IVAS_DEC_feedSinglePIorientation( QuaternionInverse_fx( *savedOrientation, &savedInvOrientation ); /* use the new PI orientation or the previously saved orientation in processing */ - FOR( i = 0; i < hIvasDec->st_ivas->hExtOrientationData->num_subframes; i++ ) + FOR( i = 0; i < st_ivas->hExtOrientationData->num_subframes; i++ ) { - QuaternionProduct_fx( hIvasDec->st_ivas->hExtOrientationData->Quaternions[i], savedInvOrientation, - &hIvasDec->st_ivas->hExtOrientationData->Quaternions[i] ); - hIvasDec->st_ivas->hExtOrientationData->enableExternalOrientation[i] = true; + QuaternionProduct_fx( st_ivas->hExtOrientationData->Quaternions[i], savedInvOrientation, + &st_ivas->hExtOrientationData->Quaternions[i] ); + st_ivas->hExtOrientationData->enableExternalOrientation[i] = true; move16(); } + hIvasDec->updateOrientation = true; move16(); } - return error; + + return IVAS_ERR_OK; } + #endif #ifdef RTP_S4_251135_CR26253_0016_REV1 + /*---------------------------------------------------------------------* - * IVAS_DEC_setDiegeticInput( ) + * setDiegeticInput( ) * * Set isDiegeticInput flag for combined orientation handle based on PI data. *---------------------------------------------------------------------*/ -static void IVAS_DEC_setDiegeticInputPI( +static void setDiegeticInputPI( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const bool *diegeticPIValues /* i : diegetic values for the input stream */ ) { + Word16 i; + IF( hIvasDec->st_ivas->hCombinedOrientationData != NULL ) { - Word8 i; FOR( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) { hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPI[i] = diegeticPIValues[i]; move16(); } + hIvasDec->st_ivas->hCombinedOrientationData->isDiegeticInputPISet = true; move16(); } + + return; } + #endif #ifdef IVAS_RTPDUMP -ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, UWord32 numPiData ) +/*---------------------------------------------------------------------* + * IVAS_DEC_FeedPiDataToDecoder( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_FeedPiDataToDecoder( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + hPiDataTs piData, /* i : PI data received in rtp packet */ + UWord32 numPiData /* i : number of PI data received in rtp packet */ +) { + UWord32 i; + Decoder_Struct *st_ivas; ivas_error error = IVAS_ERR_OK; move32(); - UWord32 i; + + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + st_ivas = hIvasDec->st_ivas; + FOR( i = 0; i < numPiData; i++ ) { UWord32 piDataType = piData->data.noPiData.piDataType; move32(); numPiData = UL_subNsD( numPiData, 1 ); /* Subtraction of WHILE variable */ + SWITCH( piDataType ) { case IVAS_PI_SCENE_ORIENTATION: @@ -7024,7 +7103,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi fixedToFloat( quat->y_fx, Q15 ), fixedToFloat( quat->z_fx, Q15 ) ); #endif - error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); + error = feedSinglePIorientation( hIvasDec, true, quat ); } BREAK; @@ -7038,7 +7117,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi fixedToFloat( quat->y_fx, Q15 ), fixedToFloat( quat->z_fx, Q15 ) ); #endif - error = IVAS_DEC_feedSinglePIorientation( hIvasDec, true, quat ); + error = feedSinglePIorientation( hIvasDec, true, quat ); } BREAK; @@ -7053,9 +7132,9 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #endif test(); test(); - IF( piData->data.acousticEnv.availLateReverb && hIvasDec->st_ivas->hRenderConfig != NULL && aeid != hIvasDec->st_ivas->hRenderConfig->roomAcoustics.aeID ) + IF( piData->data.acousticEnv.availLateReverb && st_ivas->hRenderConfig != NULL && aeid != st_ivas->hRenderConfig->roomAcoustics.aeID ) { - error = IVAS_DEC_FeedAcousticEnvPI( hIvasDec, piData->data.acousticEnv ); + error = feedAcousticEnvPI( hIvasDec, piData->data.acousticEnv ); } } BREAK; @@ -7067,7 +7146,7 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi #ifdef DEBUGGING fprintf( stdout, "PI_DIEGETIC_TYPE : %d, %d, %d, %d, %d\n", piData->data.digeticIndicator.isDiegetic[0], piData->data.digeticIndicator.isDiegetic[1], piData->data.digeticIndicator.isDiegetic[2], piData->data.digeticIndicator.isDiegetic[3], piData->data.digeticIndicator.isDiegetic[4] ); #endif - IVAS_DEC_setDiegeticInputPI( hIvasDec, piData->data.digeticIndicator.isDiegetic ); + setDiegeticInputPI( hIvasDec, piData->data.digeticIndicator.isDiegetic ); } BREAK; #endif @@ -7078,12 +7157,15 @@ ivas_error IVAS_RTP_FeedPiDataToDecoder( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *pi } BREAK; } + IF( NE_32( error, IVAS_ERR_OK ) ) { return error; } + piData++; } - return error; + + return IVAS_ERR_OK; } #endif diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index e8258930a..e4c6f62f7 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -119,7 +119,7 @@ ivas_error ivas_render_config_init_from_rom_fx( return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT - ( *hRenderConfig )->roomAcoustics.aeID = (UWord16) IVAS_DEFAULT_AEID; + ( *hRenderConfig )->roomAcoustics.aeID = IVAS_DEFAULT_AEID; move16(); #endif #ifdef FIX_1318_ROOM_SIZE_CMD_LINE diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index b9762f72c..b96ce5e54 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1777,6 +1777,7 @@ ivas_error combine_external_and_head_orientations( } } } + test(); IF( hExtOrientationData != NULL && headRotQuaternions != NULL ) { @@ -1877,6 +1878,7 @@ ivas_error combine_external_and_head_orientations( } } } + test(); IF( headRotQuaternions != NULL || hExtOrientationData != NULL ) { @@ -1899,6 +1901,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->Quaternion_prev_extOrientation = identity; } } + IF( headRotQuaternions != NULL ) { FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) @@ -1906,6 +1909,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->listenerPos[i] = listenerPos[i]; } } + /* Check if combined orientation is enabled */ test(); test(); @@ -2014,6 +2018,7 @@ ivas_error combine_external_and_head_orientations( } } #endif + return IVAS_ERR_OK; } diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index cc238d97e..2bce92fa7 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -531,7 +531,7 @@ typedef union IVAS_PIDATA_NO_DATA noPiData; } PIDATA; -typedef struct +typedef struct pidata_ts_struct { PIDATA data; uint32_t timestamp; diff --git a/readme.txt b/readme.txt index c7bbcc4f2..169db9ad7 100644 --- a/readme.txt +++ b/readme.txt @@ -33,13 +33,14 @@ These files represent the 3GPP EVS Codec Extension for Immersive Voice and Audio Services (IVAS) BASOP C simulation. All code is writtten -in ISO/IEC C99. The system is implemented as five separate programs: +in ISO/IEC C99. The system is implemented as six separate programs: IVAS_cod IVAS Encoder IVAS_dec IVAS Decoder IVAS_rend IVAS External Renderer ISAR_post_rend ISAR Post Renderer - ambi_converter Ambisonics format converter + IVAS_cod_fmtsw IVAS Encoder with support for format switching + ambi_converter example program for Ambisonics format conversion For encoding using the coder program, the input is a binary audio file (*.8k, *.16k, *.32k, *.48k) and the output is a binary @@ -123,32 +124,39 @@ should have the following structure: . `-- c-code + |-- readme.txt |-- Makefile |-- Workspace_msvc |-- apps + |-- lib_basop |-- lib_com |-- lib_debug |-- lib_dec |-- lib_enc |-- lib_isar |-- lib_lc3plus - |-- lib_rend + |-- lib_rend |-- lib_util - |-- readme.txt - |-- .clang-format + |-- scripts The package includes a Makefile for gcc, which has been verified on 32-bit Linux systems. The code can be compiled by entering the directory "c-code" and typing the command: make. The resulting encoder/decoder/renderer/ ISAR_post_renderer executables are named "IVAS_cod", "IVAS_dec", "IVAS_rend", -and "ISAR_post_rend". All reside in the c-code directory. +and "ISAR_post_rend". All reside in the c-code directory. In addition, this +directory will contain a version of the encoder with support for format switching +(named "IVAS_cod_fmtsw") and an example program for Ambisonics format conversion +(named "ambi_converter"). The package also includes a solution-file for Microsoft Visual Studio 2017 (x86). To compile the code, please open "Workspace_msvc\Workspace_msvc.sln" and build "encoder" for the encoder, "decoder" for the decoder, and "renderer" for the renderer executable. The resulting encoder/decoder/renderer/ISAR_post_renderer executables are "IVAS_cod.exe", "IVAS_dec.exe", "IVAS_rend.exe", and -"ISAR_post_rend.exe". All reside in the c-code main directory. +"ISAR_post_rend.exe". All reside in the c-code main directory. In addition, this +directory will contain a version of the encoder with support for format switching +(named "IVAS_cod_fmtsw.exe") and an example program for Ambisonics format conversion +(named "ambi_converter.exe"). @@ -176,7 +184,7 @@ some potential race conditions. The usage of the "IVAS_cod" program is as follows: -------------------------------------------------- -Usage: IVAS_cod.exe [Options] R Fs input_file bitstream_file +Usage: IVAS_cod [Options] R Fs input_file bitstream_file Mandatory parameters: --------------------- @@ -261,9 +269,9 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, The usage of the "IVAS_dec" program is as follows: -------------------------------------------------- -Usage for EVS: IVAS_dec.exe [Options] Fs bitstream_file output_file +Usage for EVS: IVAS_dec [Options] Fs bitstream_file output_file OR usage for IVAS (below) with -evs option and OutputConf -Usage for IVAS: IVAS_dec.exe [Options] OutputConf Fs bitstream_file output_file +Usage for IVAS: IVAS_dec [Options] OutputConf Fs bitstream_file output_file Mandatory parameters: --------------------- @@ -370,8 +378,8 @@ Options: -q : Quiet mode, limit printouts to terminal, default is deactivated -The usage of the "ISAR_post_rend" program: ------------------------------------------- +The usage of the "ISAR_post_rend" program is as follows: +-------------------------------------------------------- Usage: ISAR_post_rend [options] @@ -385,8 +393,8 @@ Options: -prbfi File : BFI File -The usage of the "ambi_converter" program: ------------------------------------------- +The usage of the "ambi_converter" program is as follows: +-------------------------------------------------------- Usage: ambi_converter input_file output_file input_convention output_convention @@ -399,7 +407,17 @@ the following conventions are supported: 4 : SID-SN3D 5 : SID-N3D -Either the input or the output convention must always be ACN-SN3D! +Either the input or the output convention must always be ACN-SN3D. + +The usage of the "IVAS_cod_fmtsw" program is as follows: +-------------------------------------------------------- + +Usage: IVAS_cod_fmtsw format_switching_file + +Mandatory parameters: +--------------------- +format_switching_file: Text file containg a valid encoder command line in each line + MULTICHANNEL LOUDSPEAKER INPUT / OUTPUT CONFIGURATIONS -- GitLab From 01a8a6636c287207b347164f757af349bae52ff0 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 11 Nov 2025 17:25:52 +0100 Subject: [PATCH 296/351] Remove redundant negate() usage. --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 988013697..1f2f77791 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2773,7 +2773,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( *st_ivas->hCrendWrapper->p_io_qfactor = sub( 13, gd_bits ); FOR( Word16 i = 0; i < nchan_in; i++ ) { - scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor + scale_sig32( p_output_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor } #else *st_ivas->hCrendWrapper->p_io_qfactor = 11; -- GitLab From 885eee3573fc4745c5999cb2a5dfa0798c1486f0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 17:26:10 +0100 Subject: [PATCH 297/351] fix --- apps/encoder_fmtsw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 5d48ec04f..501979b7b 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -219,7 +219,7 @@ int main( IVAS_ENC_PrintDisclaimer(); - if ( argc != 3 ) + if ( argc != 2 ) { fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" ); fprintf( stdout, "where format_switching_file is a text file containg a valid encoder command line in each line\n\n" ); -- GitLab From 9412db9f2d7e74c83c7091cf22d49c7ebc15cf1d Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 17:35:47 +0100 Subject: [PATCH 298/351] clang-format --- apps/decoder.c | 28 ++++++++++++++-------------- apps/encoder_fmtsw.c | 4 ++-- lib_com/common_api_types.h | 2 +- lib_dec/ivas_init_dec_fx.c | 4 ++-- lib_dec/ivas_output_config_fx.c | 2 +- lib_dec/lib_dec_fx.c | 2 +- readme.txt | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 88b330e8e..b8ec6184e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3247,13 +3247,13 @@ static ivas_error decodeVoIP( if ( ivasRtp.restartNeeded ) { IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - if(( error = restartDecoder( - &hIvasDec, - newDecModeInPacket, - &arg, - NULL, /* ToDo : Provide rendererConfig */ - NULL /* ToDo : Provide LS Custom Data */ - ) )!= IVAS_ERR_OK ) + if ( ( error = restartDecoder( + &hIvasDec, + newDecModeInPacket, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newDecModeInPacket ); goto cleanup; @@ -3540,13 +3540,13 @@ static ivas_error decodeVoIP( } IVAS_DEC_MODE newDecModeInPacket = ( tempBsFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; - if((error = restartDecoder( - &hIvasDec, - newDecModeInPacket , - &arg, - NULL, /* ToDo : Provide rendererConfig */ - NULL /* ToDo : Provide LS Custom Data */ - ) )!= IVAS_ERR_OK ) + if ( ( error = restartDecoder( + &hIvasDec, + newDecModeInPacket, + &arg, + NULL, /* ToDo : Provide rendererConfig */ + NULL /* ToDo : Provide LS Custom Data */ + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to restart decoder\n" ); goto cleanup; diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 501979b7b..df8236361 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -222,7 +222,7 @@ int main( if ( argc != 2 ) { fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" ); - fprintf( stdout, "where format_switching_file is a text file containg a valid encoder command line in each line\n\n" ); + fprintf( stdout, "where format_switching_file is a text file containing a valid encoder command line in each line\n\n" ); goto cleanup; } fprintf( stdout, "Input format switching file: %s\n", argv[1] ); @@ -281,7 +281,7 @@ cleanup: #ifdef IVAS_RTPDUMP IVAS_RTP_Term( &ivasRtp ); #endif - if( FmtSWFile) + if ( FmtSWFile ) { fclose( FmtSWFile ); } diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index d41635f8d..27290eb18 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -63,7 +63,7 @@ #define IVAS_ER_LIST_HEIGHT 1.6f #define IVAS_ER_LIST_HEIGHT_FX 6710886 /* 1.6f in Q.22 */ #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#define IVAS_DEFAULT_AEID 65535 +#define IVAS_DEFAULT_AEID 65535 #endif /* JBM constants for adaptive-playout */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index ffbb0c6ab..3a1576404 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -322,7 +322,7 @@ ivas_error ivas_dec_get_format_fx( { #ifdef DECODER_FORMAT_SWITCHING test(); - if( st_ivas->nchan_transport == 1 && Opt_tsm ) + if ( st_ivas->nchan_transport == 1 && Opt_tsm ) { masaRestartCandidate = 1; move16(); @@ -337,7 +337,7 @@ ivas_error ivas_dec_get_format_fx( { #ifdef DECODER_FORMAT_SWITCHING test(); - if( st_ivas->nchan_transport == 2 && Opt_tsm ) + if ( st_ivas->nchan_transport == 2 && Opt_tsm ) { masaRestartCandidate = 1; move16(); diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 0637ea4c9..9c988937b 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -119,7 +119,7 @@ void ivas_renderer_select( #ifdef FIX_1419_MONO_STEREO_UMX IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - ms_bin_upmix_renderer_select( st_ivas->ivas_format, internal_config, renderer_type ); + ms_bin_upmix_renderer_select( st_ivas->ivas_format, internal_config, renderer_type ); } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) #else diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 178465c10..298d18697 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3434,7 +3434,7 @@ static ivas_error feedAcousticEnvPI( move32(); /* Ignore if AE ID already in use */ - IF( EQ_16(hRenderConfig->roomAcoustics.aeID , hAcoustEnvPI.aeid )) + IF( EQ_16( hRenderConfig->roomAcoustics.aeID, hAcoustEnvPI.aeid ) ) { return IVAS_ERR_OK; } diff --git a/readme.txt b/readme.txt index 169db9ad7..c1783175a 100644 --- a/readme.txt +++ b/readme.txt @@ -416,7 +416,7 @@ Usage: IVAS_cod_fmtsw format_switching_file Mandatory parameters: --------------------- -format_switching_file: Text file containg a valid encoder command line in each line +format_switching_file: Text file containing a valid encoder command line in each line -- GitLab From c20b9516ed0e92127548cd7f5e491cffcbedb528 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 17:55:39 +0100 Subject: [PATCH 299/351] fix --- lib_dec/lib_dec_fx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index afedc30c1..0c96500a2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3470,7 +3470,11 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI( move32(); move32(); - mvr2r( hAcoustEnvPI.absorbCoeffs, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); + FOR( Word16 i = 0; i < IVAS_ROOM_ABS_COEFF; i++ ) + { + hRenderConfig->roomAcoustics.AbsCoeff[i] = hAcoustEnvPI.absorbCoeffs[i]; + move16(); + } } IF( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, acEnv ) ) != IVAS_ERR_OK ) -- GitLab From ae192da685f6613a7045ad4f6a5055fac194a8b4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 22:30:37 +0100 Subject: [PATCH 300/351] remove forgotten float/intX_t datatypes --- apps/decoder.c | 3 +-- lib_com/basop_proto_func.h | 4 ---- lib_com/fd_cng_com_fx.c | 5 +++-- lib_com/ivas_prot_fx.h | 4 ++-- lib_com/ivas_tools_fx.c | 8 ++++---- lib_com/prot_fx.h | 11 +++-------- lib_com/pvq_com_fx.c | 12 ++++++------ lib_dec/ivas_binRenderer_internal_fx.c | 2 +- lib_dec/ivas_jbm_dec_fx.c | 2 -- lib_dec/ivas_omasa_dec_fx.c | 2 +- lib_dec/lib_dec_fx.c | 1 - lib_dec/updt_dec_fx.c | 6 +++--- lib_enc/core_switching_enc_fx.c | 4 ++-- lib_enc/ivas_tcx_core_enc_fx.c | 1 - lib_enc/prot_fx_enc.h | 2 +- lib_enc/swb_tbe_enc_fx.c | 2 +- lib_rend/ivas_hrtf_fx.c | 4 ++-- lib_rend/ivas_prot_rend_fx.h | 6 +++--- 18 files changed, 33 insertions(+), 46 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 19a72df38..640fb83af 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1786,12 +1786,11 @@ static void usage_dec( void ) fprintf( stdout, " ID and duration pairs, where duration is specified in frames\n" ); fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration.\n" ); fprintf( stdout, "-obj_edit File : Object editing instructions file or NULL for built-in example\n" ); - fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); #ifdef FIX_1318_ROOM_SIZE_CMD_LINE fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); - fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); + fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration\n" ); #endif fprintf( stdout, "-q : Quiet mode, no frame counter\n" ); fprintf( stdout, " default is deactivated\n" ); diff --git a/lib_com/basop_proto_func.h b/lib_com/basop_proto_func.h index 0e2fc5ad7..55c15f291 100644 --- a/lib_com/basop_proto_func.h +++ b/lib_com/basop_proto_func.h @@ -43,10 +43,6 @@ #include "basop_util.h" -/* tcx_lpc_cdk.h */ -#define LSF_GAP_VAL( x ) ( Word16 )( (x) *2.0f * 1.28f ) -#define LSFM( x ) FL2WORD16_SCALE( x * 1.28, 15 - 1 ) /* 14Q1*1.28 */ - /* cnst.h */ #define GAMMA1_INV 17809 /* weighting factor (numerator) default:0.92 (1Q14format) */ #define GAMMA16k_INV 17430 /* weighting factor (numerator) default:0.94 (1Q14format) */ diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 363113f21..390afbd00 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -27,7 +27,7 @@ * Local function prototypes *-------------------------------------------------------------------*/ static void getmidbands( const Word16 *part, const Word16 npart, Word16 *midband, Word16 *psize, Word16 *psize_norm, Word16 *psize_norm_exp, Word16 *psize_inv ); - +static void mhvals( const Word16 d, Word16 *m ); /*------------------------------------------------------------------- * createFdCngCom() @@ -2823,7 +2823,8 @@ void SynthesisSTFT_ivas_fx( /************************************************************************************** * Compute some values used in the bias correction of the minimum statistics algorithm * **************************************************************************************/ -void mhvals( + +static void mhvals( const Word16 d, Word16 *m /*, Word16 * h*/ ) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6989cc524..db13b368b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3720,8 +3720,8 @@ void ivas_init_binaural_hrtf_fx( ivas_error ivas_allocate_binaural_hrtf_fx( HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ - const int16_t n_channels, /* i : number of input channels */ - const int16_t allocate_init_flag /* i : Memory allocation flag */ + const Word16 n_channels, /* i : number of input channels */ + const Word16 allocate_init_flag /* i : Memory allocation flag */ ); void ivas_binRenderer_fx( diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 29d470a55..973837ac0 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -117,8 +117,8 @@ void mvc2c( /*! r: number of clipped samples */ UWord32 ivas_syn_output_fx( - Word32 *synth[], /* i/o: float synthesis signal q_synth*/ - const Word16 q_synth, + Word32 *synth[], /* i/o: synthesis signal q_synth*/ + const Word16 q_synth, /* i : Q factor */ const Word16 output_frame, /* i : output frame length (one channel) Q0*/ const Word16 n_channels, /* i : number of output channels Q0*/ Word16 *synth_out /* o : integer 16 bits synthesis signal Q0*/ @@ -131,7 +131,7 @@ UWord32 ivas_syn_output_fx( move32(); /*-----------------------------------------------------------------* - * float to integer conversion with saturation control + * Word32 to Word16 conversion with saturation control *-----------------------------------------------------------------*/ FOR( n = 0; n < n_channels; n++ ) @@ -2094,7 +2094,7 @@ void panning_wrap_angles_fx( /*-------------------------------------------------------------------------* * v_sort_ind_fixed() * - * Sort a float array + * Sort a Word32 array * (modified version of v_sort() to return an index array) *-------------------------------------------------------------------------*/ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index e5bdb4c29..28601b9ca 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3401,7 +3401,7 @@ void apply_gain_fx( const Word16 *band_end, /* i : Sub band end indices Q0 */ const Word16 num_sfm, /* i : Number of bands Q0 */ const Word16 *gains, /* i : Band gain vector Q12 */ - Word16 *xq /* i/o: Float synthesis / Gain adjusted synth Q15/Q12 */ + Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ ); void fine_gain_quant_fx( @@ -5344,11 +5344,6 @@ void SynthesisSTFT_ivas_fx( const Word16 nchan_out /* i : number of output channels */ ); -void mhvals( - const Word16 d, - Word16 *m /*, float * h*/ -); - Word32 sign_l( const Word32 x /* i : input value of x */ ); @@ -7820,8 +7815,8 @@ void updt_IO_switch_dec_fx( ); void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : float synthesis signal */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ const Word16 Qpost ); void updt_dec_common_fx( diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index 98ca8c4ab..73276fda3 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -474,12 +474,12 @@ void NearOppSplitAdjustment_fx( *--------------------------------------------------------------------------*/ void apply_gain_fx( - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 *band_start, /* i : Sub band start indices Q0 */ - const Word16 *band_end, /* i : Sub band end indices Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gains, /* i : Band gain vector Qx */ - Word16 *xq /* i/o: Float synthesis / Gain adjusted synth Q15/Qx */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 *band_start, /* i : Sub band start indices Q0 */ + const Word16 *band_end, /* i : Sub band end indices Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gains, /* i : Band gain vector Qx */ + Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Qx */ ) { Word16 band, i; diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 36471b156..5d4a6d964 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -543,7 +543,7 @@ return IVAS_ERR_OK; ivas_error ivas_allocate_binaural_hrtf_fx( HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ - const int16_t n_channels, /* i : number of input channels */ + const Word16 n_channels, /* i : number of input channels */ const Word16 allocate_init_flag /* i : Memory allocation flag */ ) { diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 42270d50d..94d709461 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2710,7 +2710,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - /*TODO :To be tested : no stream entering---------------------------------------*/ /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15 @@ -2755,7 +2754,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( test(); IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - /*TODO :To be tested : no stream entering*/ st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; IF( NE_32( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 30f307731..7df8ddfef 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -681,7 +681,7 @@ ivas_error ivas_omasa_dec_config_fx( { set_s( hMasaIsmData->azimuth_ism_fx[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); set_s( hMasaIsmData->elevation_ism_fx[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - FOR( int16_t sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) + FOR( Word16 sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) { set_l( hMasaIsmData->energy_ratio_ism_fx[obj_idx][sf], 0, CLDFB_NO_CHANNELS_MAX ); } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0c96500a2..82d52ca00 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1457,7 +1457,6 @@ static ivas_error isar_generate_metadata_and_bitstream( { /*TD input*/ /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ - /* local float2fix, to be removed */ num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; move16(); diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 8704c2e07..7d389a0e2 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -394,8 +394,8 @@ void updt_IO_switch_dec_fx( *-------------------------------------------------------------------*/ void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : fixed point synthesis signal Qpost */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ const Word16 Qpost ) { test(); @@ -786,7 +786,7 @@ static void ivas_updt_bw_switching_fx( move16(); } } - st_fx->prev_bws_cnt = st_fx->bws_cnt; // TODO: Duplicate variables + st_fx->prev_bws_cnt = st_fx->bws_cnt; move16(); return; } diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index b7cdbc994..c390ab78b 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -298,7 +298,7 @@ void core_switching_pre_enc_fx( /* reset BWE memories */ IF( hBWE_FD != NULL ) { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO : this might not be needed */ + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } } test(); @@ -915,7 +915,7 @@ void core_switching_pre_enc_ivas_fx( /* reset BWE memories */ IF( hBWE_FD != NULL ) { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO : this might not be needed */ + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); } } test(); diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index c10705e5d..7c5972545 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -370,7 +370,6 @@ void stereo_tcx_core_enc( * Core Signal Analysis: MDCT, TNS, LPC analysis *---------------------------------------------------------------*/ - /* TODO: integrate this. */ st->prev_Q_new = 0; st->Q_old = 0; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 5e9950615..6e15790ad 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3625,7 +3625,7 @@ void re8_cod_fx( void TBEreset_enc_fx( TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t last_core, /* i : last core */ + const Word16 last_core, /* i : last core */ Word16 bandwidth /* i : bandwidth mode */ ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index c6c7135fc..9aeaf5f2c 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7637,7 +7637,7 @@ void tbe_write_bitstream_fx( void TBEreset_enc_fx( TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t last_core, /* i : last core */ + const Word16 last_core, /* i : last core */ Word16 bandwidth /* i : bandwidth mode */ ) { diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 8bc3c0379..dee0fe052 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -55,7 +55,7 @@ ivas_error ivas_HRTF_binary_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary!" ); } - set_c( (int8_t *) ( *hHrtfTD ), 0, (int32_t) sizeof( TDREND_HRFILT_FiltSet_t ) ); + set_c( (Word8 *) ( *hHrtfTD ), 0, (Word32) sizeof( TDREND_HRFILT_FiltSet_t ) ); return IVAS_ERR_OK; } @@ -246,7 +246,7 @@ ivas_error ivas_HRTF_parambin_binary_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for parametric binauralizer HRTF tables!" ); } - set_c( (int8_t *) ( *hHrtfParambin ), 0, (int32_t) sizeof( HRTFS_PARAMBIN ) ); + set_c( (Word8 *) ( *hHrtfParambin ), 0, (Word32) sizeof( HRTFS_PARAMBIN ) ); return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 9dce43a97..e257ccd12 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -608,7 +608,7 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( ); ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( - int16_t **buffer, /* o : buffer to allocate */ + Word16 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ); @@ -618,7 +618,7 @@ void ivas_HRTF_CRend_binary_close_fx( ivas_error ivas_HRTF_statistics_init_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ - const int32_t sampleRate /* i : Sample rate */ + const Word32 sampleRate /* i : Sample rate */ ); void ivas_HRTF_statistics_close_fx( @@ -891,7 +891,7 @@ ivas_error ivas_rend_openCrend_fx( HRTFS_CREND_HANDLE hHrtfCrend, HRTFS_STATISTICS_HANDLE hHrtfStatistics, const Word32 output_Fs, - const int16_t ext_rend_flag, + const Word16 ext_rend_flag, const Word16 num_poses ); -- GitLab From 5b61fc19dd4cb1b3c6c36d72fe9d8c9f01c25fa2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 22:36:39 +0100 Subject: [PATCH 301/351] update Readme.txt --- apps/decoder.c | 9 ++++----- readme.txt | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index b8ec6184e..60c3c2020 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1770,6 +1770,10 @@ static void usage_dec( void ) fprintf( stdout, "-rvf File : Reference vector specified by external trajectory File\n" ); fprintf( stdout, " works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" ); fprintf( stdout, "-render_config File : Renderer configuration File\n" ); +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); + fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); +#endif fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with panning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); @@ -1785,13 +1789,8 @@ static void usage_dec( void ) fprintf( stdout, " ID and duration pairs, where duration is specified in frames\n" ); fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration.\n" ); fprintf( stdout, "-obj_edit File : Object editing instructions file or NULL for built-in example\n" ); - fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); -#ifdef FIX_1318_ROOM_SIZE_CMD_LINE - fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); - fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); -#endif fprintf( stdout, "-q : Quiet mode, no frame counter\n" ); fprintf( stdout, " default is deactivated\n" ); fprintf( stdout, "\n" ); diff --git a/readme.txt b/readme.txt index c1783175a..83285ff40 100644 --- a/readme.txt +++ b/readme.txt @@ -318,6 +318,8 @@ Options: -rvf File : Reference vector specified by external trajectory File works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes -render_config File : Binaural renderer configuration parameters in File (only for binaural outputs) +-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large) + for BINAURAL_ROOM_REVERB output configuration -non_diegetic_pan P : panning mono non-diegetic sound to stereo -90<= P <=90, left or l or 90->left, right or r or -90->right, center or c or 0->middle -exof File : External orientation trajectory File for simulation of external orientations @@ -352,6 +354,7 @@ Options: -rf File : Reference rotation trajectory File for simulation of head tracking (only for binaural outputs) -rvf File : Reference vector trajectory File for simulation of head tracking (only for binaural outputs) -render_config File : Binaural renderer configuration parameters in File (only for binaural outputs) +-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large) -non_diegetic_pan P : Panning mono non-diegetic sound to stereo -90<= P <= 90 left or l or 90->left, right or r or -90->right, center or c or 0 ->middle -exof File : External orientation trajectory File for simulation of external orientations -- GitLab From f082ed6ec32c3a4f3c47da8721b98c5471940b56 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Nov 2025 22:43:19 +0100 Subject: [PATCH 302/351] clang-format --- lib_enc/prot_fx_enc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 6e15790ad..e4b29eb08 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3625,7 +3625,7 @@ void re8_cod_fx( void TBEreset_enc_fx( TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 last_core, /* i : last core */ + const Word16 last_core, /* i : last core */ Word16 bandwidth /* i : bandwidth mode */ ); -- GitLab From 957f6fa31b24d8ad09bae25fdc97e27edb5148e5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Nov 2025 08:59:20 +0100 Subject: [PATCH 303/351] clang-format --- apps/decoder.c | 2 +- readme.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 60c3c2020..e63caa5a3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1773,7 +1773,7 @@ static void usage_dec( void ) #ifdef FIX_1318_ROOM_SIZE_CMD_LINE fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" ); fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" ); -#endif +#endif fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with panning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); diff --git a/readme.txt b/readme.txt index 83285ff40..5adec9098 100644 --- a/readme.txt +++ b/readme.txt @@ -356,7 +356,7 @@ Options: -render_config File : Binaural renderer configuration parameters in File (only for binaural outputs) -room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large) -non_diegetic_pan P : Panning mono non-diegetic sound to stereo -90<= P <= 90 - left or l or 90->left, right or r or -90->right, center or c or 0 ->middle + left or l or 90->left, right or r or -90->right, center or c or 0 ->middle -exof File : External orientation trajectory File for simulation of external orientations -dpid ID : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration @@ -367,10 +367,10 @@ Options: for BINAURAL_ROOM_REVERB output configuration. -lp Position : Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees. - If specified, overrides the default behavior which attempts to map input to output LFE channel(s) + If specified, overrides the default behavior which attempts to map input to output LFE channel(s) -lm File : LFE panning matrix File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). - If specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s) + If specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s) -no_delay_cmp : Turn off delay compensation -g : Input gain (linear, not in dB) to be applied to input audio file -l : List supported audio formats -- GitLab From 237cafabcebdfce34b941c66056fb23b2668cb3e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 12 Nov 2025 10:15:02 +0100 Subject: [PATCH 304/351] accept switch BASOP_NOGLOB_DECLARE_LOCAL --- lib_basop/enh32.c | 6 ------ lib_com/enr_1_az_fx.c | 2 -- lib_com/env_stab_fx.c | 2 -- lib_com/fft_rel_fx.c | 2 -- lib_com/log2.c | 2 -- lib_com/lsf_tools_fx.c | 6 ------ lib_com/modif_fs_fx.c | 4 ---- lib_com/options.h | 3 --- lib_com/swb_bwe_com_fx.c | 2 -- lib_com/swb_bwe_com_lr_fx.c | 4 ---- lib_com/tools_fx.c | 6 ------ lib_dec/arith_coder_dec_fx.c | 2 -- lib_dec/dec_tcx_fx.c | 4 ---- lib_dec/er_dec_tcx_fx.c | 4 ---- lib_dec/fd_cng_dec_fx.c | 2 -- lib_dec/gs_dec_amr_wb_fx.c | 2 -- lib_dec/igf_dec_fx.c | 2 -- lib_dec/tcq_core_dec_fx.c | 6 ------ lib_enc/acelp_core_switch_enc_fx.c | 2 -- lib_enc/cod_tcx_fx.c | 2 -- lib_enc/detect_transient_fx.c | 2 -- lib_enc/enc_higher_acelp_fx.c | 4 ---- lib_enc/find_tar_fx.c | 2 -- lib_enc/igf_enc_fx.c | 2 -- lib_enc/lp_exc_e_fx.c | 4 ---- lib_enc/sig_clas_fx.c | 4 ---- lib_enc/speech_music_classif_fx.c | 2 -- lib_enc/swb_bwe_enc_lr_fx.c | 2 -- lib_enc/swb_pre_proc_fx.c | 4 ---- lib_enc/transition_enc_fx.c | 4 ---- lib_enc/updt_tar_fx.c | 4 ---- 31 files changed, 99 deletions(-) diff --git a/lib_basop/enh32.c b/lib_basop/enh32.c index cf40bbec9..d2931dd5d 100644 --- a/lib_basop/enh32.c +++ b/lib_basop/enh32.c @@ -71,9 +71,7 @@ Word32 Mpy_32_32( Word32 L_var1, Word32 L_var2 ) { Word32 L_var_out; Word64 L64_var1; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif L64_var1 = ( (Word64) L_var1 * L_var2 ); L64_var1 = W_shl_o( L64_var1, 1, &Overflow ); @@ -105,9 +103,7 @@ Word32 Mpy_32_32_r( Word32 L_var1, Word32 L_var2 ) Word32 Madd_32_16( Word32 L_var3, Word32 L_var1, Word16 var2 ) { Word32 L_var_out; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif L_var_out = Mpy_32_16_1( L_var1, var2 ); L_var_out = L_add_o( L_var3, L_var_out, &Overflow ); @@ -138,9 +134,7 @@ Word32 Madd_32_16_r( Word32 L_var3, Word32 L_var1, Word16 var2 ) Word32 Msub_32_16( Word32 L_var3, Word32 L_var1, Word16 var2 ) { Word32 L_var_out; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif L_var_out = Mpy_32_16_1( L_var1, var2 ); L_var_out = L_sub_o( L_var3, L_var_out, &Overflow ); diff --git a/lib_com/enr_1_az_fx.c b/lib_com/enr_1_az_fx.c index 5e840df8b..afcd5b838 100644 --- a/lib_com/enr_1_az_fx.c +++ b/lib_com/enr_1_az_fx.c @@ -51,10 +51,8 @@ Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 Word16 *y; Word16 i, j, a0, q; Word32 L_tmp, L_tmp2; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif /* Find the impulse response */ q = sub( 3, norm_s( Aq[0] ) ); diff --git a/lib_com/env_stab_fx.c b/lib_com/env_stab_fx.c index 728cfddb9..033417ce6 100644 --- a/lib_com/env_stab_fx.c +++ b/lib_com/env_stab_fx.c @@ -74,10 +74,8 @@ Word16 env_stability_fx( /* in Q15 */ Word16 exp, exp2; Word32 L_tmp, L_env_delta; Word16 inv_nb_sfm; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif IF( core_switching_flag ) { diff --git a/lib_com/fft_rel_fx.c b/lib_com/fft_rel_fx.c index 9f8f03556..b3fcc967a 100644 --- a/lib_com/fft_rel_fx.c +++ b/lib_com/fft_rel_fx.c @@ -643,10 +643,8 @@ void fft_rel_fx( Word16 *x0, *x1, *x2; const Word16 *s, *c; Word16 *xi2, *xi3, *xi4, *xi1; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif /*-----------------------------------------------------------------* diff --git a/lib_com/log2.c b/lib_com/log2.c index 3df1a960e..70e6b93c0 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -127,10 +127,8 @@ Word32 pow_10( Word32 x, Word16 *Q ) /*o : Q15, i: Q26*/ Word32 L_tmp; Word16 n1, i; Word16 count = 0; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif move16(); diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 0fbc7f758..e4dbd7e2a 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -354,9 +354,7 @@ void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ) Word32 f1[NC_MAX + 1], f2[NC_MAX + 1]; /* Q23 */ Word16 nc, q; Word32 t0, tmax, t0p, t0n; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif /*-----------------------------------------------------* @@ -777,9 +775,7 @@ void lsp2lpc_fx( Word16 tmp_pci[M + 1]; Word16 giOverflow; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif FOR( i = 0; i < order; i++ ) { @@ -956,10 +952,8 @@ Word16 E_LPC_f_lsp_pol_get( const Word16 lsp[], Word32 f[], const Word16 n, cons Word16 Q_out; Word16 m2; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif Q_out = 31 - 23; move16(); diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 6bd1e7a69..1a73578ae 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -548,11 +548,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ test(); if ( GT_32( fin, 16000 ) && ( EQ_16( lg_out, L_FRAME ) || EQ_16( lg_out, L_FRAME16k ) || EQ_16( lg_out, 512 ) ) ) { -#ifdef BASOP_NOGLOB_DECLARE_LOCAL num_den = shl_sat( num_den, 1 ); -#else - num_den = shl( num_den, 1 ); -#endif } FOR( i = 0; i < lg_out; i++ ) { diff --git a/lib_com/options.h b/lib_com/options.h index 8fb55599e..6480b96a3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -68,9 +68,6 @@ /* #################### End DEBUGGING switches ############################ */ -#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS -#define BASOP_NOGLOB_DECLARE_LOCAL -#endif /* ################### Start FIXES switches ########################### */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 0e618f7d9..cc8b22db6 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -567,10 +567,8 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 Word16 tmp1, tmp2; const Word16 *ptr; Word16 exp2; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif BASOP_SATURATE_WARNING_OFF_EVS diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index 0e6524ce8..1326b31a9 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -927,10 +927,8 @@ void SpectrumSmoothing_fx( Word16 reset_flag; Word16 pp, pk; Word16 exp_norm; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif *Qss = 10; move16(); @@ -2225,10 +2223,8 @@ void ton_ene_est_fx( Word16 temp2_fx, Qtemp2; Word16 temp_fx; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif *QbeL = 3; move16(); diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 5b4f0b127..38b39f36e 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -2465,10 +2465,8 @@ Flag conv_fx( Word16 i, n; Word32 L_sum; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif y[0] = mult_r( x[0], h[0] ); move16(); FOR( n = 1; n < L; n++ ) @@ -4253,10 +4251,8 @@ Word32 Calc_Energy_Autoscaled( Word16 temp, temp2; Word32 L_temp, L_Energy; Word16 i, j; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif Overflow = 0; move16(); @@ -4950,10 +4946,8 @@ Word16 dot_prod_satcontr( Word16 shift, q, ener, i; Word32 L_tmp; Word16 *pt1, *pt2; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif Copy( x, tmp_tab_x, len ); /* OPTIMIZE !!!!! the copy into local table is not necessary */ Copy( y, tmp_tab_y, len ); /* could be reworked to do a 1st iteration with the original x[] and y[] */ diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 2919210dc..997bc43c7 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -27,11 +27,9 @@ static Word16 tcx_arith_decode_fx( Tastat as; Word16 exp_k; Word16 tmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Word32 Q; Word64 W_tmp; move32(); -#endif bp = ari_start_decoding_14bits_prm_fx( prm, 0, &as ); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index a8db9f9cc..86bacc41f 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -82,12 +82,10 @@ void decoder_tcx_fx( Word16 L_spec_con; TCX_LTP_DEC_HANDLE hTcxLtpDec; TCX_DEC_HANDLE hTcxDec; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; Flag Carry = 0; move32(); move32(); -#endif temp_concealment_method = 0; move16(); @@ -4727,12 +4725,10 @@ void decoder_tcx_noisefilling_fx( Word32 total_brate; Word32 tmp32; Word16 *pInfoTCXNoise; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); Flag Carry = 0; move32(); -#endif total_brate = ( (Word16) EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? st->element_brate : st->total_brate ); move32(); /*-----------------------------------------------------------------* diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 2c197d23d..2aba77f62 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -18,10 +18,8 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, Word16 tmp16, tmp16_2, tmp16_3, tmp_e, tmp2_e, tmp_loop, i; Word64 W_acc; Word32 L_tmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL move32(); move32(); -#endif W_acc = 0; @@ -56,10 +54,8 @@ static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr /*Q0*/, Wor Word16 i, cnt, tmp16, tmp_e, tmp2_e; Word64 W_acc; Word32 L_tmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL move16(); move16(); -#endif W_acc = 0; diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index dfbc8996f..ddad53e05 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -587,10 +587,8 @@ Word16 ApplyFdCng_fx( Word16 lsp_cng[M]; HANDLE_FD_CNG_DEC hFdCngDec; HANDLE_FD_CNG_COM hFdCngCom; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL move16(); move16(); -#endif Word16 L_frame, last_L_frame; hFdCngDec = st->hFdCngDec; diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c index 4a0bf352f..2b8eb455a 100644 --- a/lib_dec/gs_dec_amr_wb_fx.c +++ b/lib_dec/gs_dec_amr_wb_fx.c @@ -363,10 +363,8 @@ void improv_amr_wb_gs_fx( Word16 i, exp_a, exp_b, exp_diff, j; Word16 dct_exc_in_fx[L_FRAME], dct_exc_out_fx[L_FRAME]; Word16 Aq_orig[NB_SUBFR * ( M + 1 )], enr_LP_old, enr_LP_new; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif /*------------------------------------------------------------* * Condition to enter the section on excitation modification diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 686882fd3..36bba5599 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1483,10 +1483,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in Word16 dS_e[IGF_MAX_SFB]; Word32 energyTmp[24]; Word16 Hr; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL move16(); move16(); -#endif /* initialize variables */ diff --git a/lib_dec/tcq_core_dec_fx.c b/lib_dec/tcq_core_dec_fx.c index c13a88565..b0c6d9f6a 100644 --- a/lib_dec/tcq_core_dec_fx.c +++ b/lib_dec/tcq_core_dec_fx.c @@ -69,12 +69,6 @@ void tcq_core_LR_dec_fx( Word32 divider = 0; move32(); -#ifndef BASOP_NOGLOB_DECLARE_LOCAL - if ( Overflow == 1 ) - { - Overflow = 0; /* set overflow flag to zero before entering TCQ functions without any message */ - } -#endif /* initialization */ set16_fx( dpath, 0, 280 ); diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 8ef05782b..77f634a60 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -1004,9 +1004,7 @@ static Word16 dotprod_satcont( Word16 tmp_tabx[L_FRAME48k], tmp_taby[L_FRAME48k]; Word16 shift, q, ener, i; Word32 L_tmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif Copy( x, tmp_tabx, len ); /* qx */ Copy( y, tmp_taby, len ); /* qy */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 1e01d8c3c..ea9ebc17a 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -40,10 +40,8 @@ void HBAutocorrelation_fx( Word32 L_tmp, L_sum; Word16 y[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif /*-----------------------------------------------------------* * Windowing * diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index 14a6d6c80..20bf2d7cc 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -116,10 +116,8 @@ Word16 detect_transient_fx( Word32 E_low_fx, E_high_fx; Word16 temp16, Thres_fx = 0; Word16 exp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif shift = 0; move16(); diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 014ce4603..4890991e9 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -57,10 +57,8 @@ void transf_cdbk_enc_fx( Word16 Qdct; Word16 avq_bit_sFlag; Word16 trgtSvPos; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif avq_bit_sFlag = 0; move16(); @@ -414,10 +412,8 @@ void transf_cdbk_enc_ivas_fx( Word16 Qdct; Word16 avq_bit_sFlag; Word16 trgtSvPos; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif avq_bit_sFlag = 0; move16(); diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 2d0929e04..3e9cdf41d 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -31,10 +31,8 @@ void find_targets_fx( Word16 scale, scaleq, j, d, s, s2, tmp; Word16 Aqs[M + 1]; Word32 Ltmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif /*------------------------------------------------------------------------* * Find the target vector for excitation search: * diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 25dfa2534..a41af976f 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -879,10 +879,8 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value Word16 numf; Word32 SFM32; Word16 invDenom, SFM; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL move32(); move32(); -#endif move32(); num = 0; diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 4d6084c87..f028474f2 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -200,9 +200,7 @@ static Word16 adpt_enr_fx( Word16 ener, i; Word16 exc_tmp[L_FRAME16k], xn_tmp[L_FRAME16k]; Word32 Ltmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL /* Critical Overflow */ Flag Overflow = 0; -#endif Overflow = 0; move16(); @@ -289,9 +287,7 @@ Word16 corr_xy1_fx( Word16 tmp, xx, xy, yy, exp_xy, exp_xx, exp_yy, exp_div, gain, gain_p_snr; Word32 Ltmp1, Ltmp2; Word16 xn[L_FRAME16k], y1[L_FRAME16k]; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif /*----------------------------------------------------------------* * Find the ACELP correlations and the pitch gain diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 4822a5669..81df36ccd 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -55,10 +55,8 @@ Word16 signal_clas_fx( /* o : classification for current Word16 i, clas, pc, zc, lo, lo2, hi, hi2, exp_ee, frac_ee; Word16 tmp16, tmpS; const Word16 *pt1; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif /*----------------------------------------------------------------* * Calculate average voicing @@ -286,10 +284,8 @@ Word16 signal_clas_ivas_fx( /* o : classification for cur Word16 tmp16, tmpS; const Word16 *pt1; Word64 tmp64; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif /*----------------------------------------------------------------* * Calculate average voicing diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 4f384b575..fef5f7250 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -4146,10 +4146,8 @@ static void tonal_context_improv_fx( Word32 L_tmp, tonality, tonality1, tonality2, tonality3, sort_max, sort_avg, sort_val[80]; VAD_HANDLE hVAD = st_fx->hVAD; SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif IF( EQ_16( st_fx->last_codec_mode, MODE2 ) ) { diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index a8b6f0a6d..7d31b8532 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -89,10 +89,8 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : Word32 L_tmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif exp_safe_e = 4; move16(); diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 6a108ce6f..844ed0e6b 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -521,10 +521,8 @@ void swb_pre_proc_fx( Word16 ts, nB, uB; /* Highband energy computation using CLDFB */ Word32 CldfbHB_ener; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif Word16 realQ_neg1, imagQ_neg1, exp, Cldfbtemp1; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -1108,10 +1106,8 @@ void swb_pre_proc_ivas_fx( move64(); Word32 CldfbHB_fx = 0; // fixed counterpart Word16 CldfbHB_fx_e = 0; // fixed counterpart -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif Word16 realQ_neg1, imagQ_neg1, exp = 0, Cldfbtemp1; move32(); move16(); diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 842b63551..4d72013be 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -1758,10 +1758,8 @@ static void tc_enc_fx( Word16 pitch_index, pitch_sign_fx; Word32 gain_trans32; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif imp_pos = sub( *position, i_subfr ); FOR( i = 0; i < L_SUBFR; i++ ) { @@ -1987,10 +1985,8 @@ static void tc_enc_ivas_fx( Word16 pitch_index, pitch_sign_fx; Word32 gain_trans32; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif imp_pos = sub( *position, i_subfr ); /*-----------------------------------------------------------------* * get number of bits for pitch encoding diff --git a/lib_enc/updt_tar_fx.c b/lib_enc/updt_tar_fx.c index 9d6b5d2d6..7a33971f3 100644 --- a/lib_enc/updt_tar_fx.c +++ b/lib_enc/updt_tar_fx.c @@ -23,10 +23,8 @@ void updt_tar_fx( { Word16 i; Word32 L_tmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif FOR( i = 0; i < L; i++ ) @@ -55,10 +53,8 @@ void updt_tar_HR_fx( { Word16 i; Word32 L_tmp, L_tmp1; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif FOR( i = 0; i < L; i++ ) { -- GitLab From 11527d4407a16d4ab100d55c31ebbb12f0762c51 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 12 Nov 2025 10:25:04 +0100 Subject: [PATCH 305/351] Add saturations of DFT stereo related signales to avoid crashes from issue #2205 and #2206. --- lib_com/options.h | 3 +++ lib_enc/ivas_cpe_enc_fx.c | 6 +++++- lib_enc/ivas_stereo_switching_enc_fx.c | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8fb55599e..7cf66743a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,6 +108,9 @@ #define FIX_2217_ASSERT_IN_IVAS_CORE_DECODER_WITH_MC /* FhG: Adjust Q_real to prevent overflow in st->cldfbSyn->cldfb_state_fx scaling */ #define FIX_2211_ASSERT_IN_REND_CREND_CONVOLER /* FhG: Add headroom to p_output_fx to prevent overflow in ivas_rend_crendProcessSubframe_fx() */ +#define NONBE_FIX_2205_SATURATE_ALTERNATIVE +#define NONBE_FIX_2206_SATURATE_ALTERNATIVE + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index da4bec541..9f206be4d 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -826,9 +826,13 @@ ivas_error ivas_cpe_enc_fx( move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); - +#ifdef NONBE_FIX_2205_SATURATE_ALTERNATIVE + Scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_old_inp32 ) ); // scaling initial part of the input buffer + Scale_sig32( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer +#else scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_old_inp32 ) ); // scaling initial part of the input buffer scale_sig32( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer +#endif sts[0]->q_inp32 = Q15; sts[0]->q_old_inp32 = Q15; move16(); diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index b9fc815a7..0b27de0f6 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -682,7 +682,11 @@ void stereo_switching_enc_fx( /* window DFT synthesis overlap memory @input_Fs, primary channel */ FOR( i = 0; i < dft_ovl; i++ ) { +#ifdef NONBE_FIX_2206_SATURATE_ALTERNATIVE + hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl_sat( Mpy_32_32_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), sub( 15, q_inp ) ); // Q15 +#else hCPE->hStereoDft->output_mem_dmx_fx[i] = L_shl( Mpy_32_32_r( hCPE->hStereoDft->win_fx[dft_ovl - 1 - i], old_input_signal_pri[input_frame - dft_ovl + i] ), sub( 15, q_inp ) ); // Q15 +#endif move32(); } /* reset 48kHz BWE overlap memory */ -- GitLab From a4aba2e41d44deabbbaf2205d1128454618564d3 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 12 Nov 2025 10:32:53 +0100 Subject: [PATCH 306/351] remove utf8 char in comment --- lib_util/obj_edit_file_reader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/obj_edit_file_reader.h b/lib_util/obj_edit_file_reader.h index 084b9a67a..eb8fe681c 100644 --- a/lib_util/obj_edit_file_reader.h +++ b/lib_util/obj_edit_file_reader.h @@ -55,7 +55,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. #ifdef FIX_2192_OBJ_EDITING_EXT_METADATA #define OBJ_EDIT_RADIUS_MAX 15.75f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ -#define OBJ_EDIT_RADIUS_MAX_FX 8064 /* Q9, 15.75f (15.75 × 512 = 8064) */ +#define OBJ_EDIT_RADIUS_MAX_FX 8064 /* Q9, 15.75f (15.75 * 512 = 8064) */ #define OBJ_EDIT_RADIUS_MIN_FX 0 #endif -- GitLab From cb50b5e46e9d1f12ec393905f05c74229ae9638b Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Wed, 12 Nov 2025 11:38:26 +0200 Subject: [PATCH 307/351] Port float MR 2392 to BASOP main in points where it applies. --- lib_com/options.h | 1 + lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8fb55599e..eb01152a9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -152,6 +152,7 @@ #define FIX_1437_LC3PLUS_EXTREND_HIRES /* FhG: fix external renderer split bitstream header writing causing a crash for LC3plus High-res mode */ #define NONBE_1412_AVOID_ROUNDING_AZ_ELEV /* FhG: Avoid rounding when passing azimuth and elevation to efap_determine_gains() */ #define FIX_1318_ROOM_SIZE_CMD_LINE /* Philips/Nokia/FhG: Default room sizes support */ +#define NONBE_FIX_1442_MASA_EXT_REND_ORIENT_IDX /* Nokia: Fix issue 1442 of wrong index to combinedOrientationData */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 3211b0e46..705b52fdb 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -6744,6 +6744,15 @@ static void ivas_masa_ext_rend_parambin_internal_fx( Copy( hMasaExtRend->hDiracDecBin[0]->ChCrossRe_e, hDiracDecBin->ChCrossRe_e, hSpatParamRendCom->num_freq_bands ); Copy( hMasaExtRend->hDiracDecBin[0]->ChCrossIm_e, hDiracDecBin->ChCrossIm_e, hSpatParamRendCom->num_freq_bands ); +#ifdef NONBE_FIX_1442_MASA_EXT_REND_ORIENT_IDX + ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, + subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, NULL ); + + ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, + 0, NULL ); +#else ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, NULL ); @@ -6751,7 +6760,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, 0, NULL ); - +#endif q_mat = hDiracDecBin->q_processMtx; move16(); -- GitLab From 0608ce7faa32250cf2ec19dcb8be69a29402ff3a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Nov 2025 11:00:42 +0100 Subject: [PATCH 308/351] tabs -> spaces --- lib_com/ACcontextMapping_fx.c | 24 +- lib_com/arith_coder_fx.c | 12 +- lib_com/basop_util.h | 2 +- lib_com/cnst.h | 62 +- lib_com/deemph_fx.c | 28 +- lib_com/env_stab_trans_fx.c | 16 +- lib_com/est_tilt_fx.c | 8 +- lib_com/fft_fx_evs.c | 36 +- lib_com/gs_bitallocation_fx.c | 36 +- lib_com/gs_bitallocation_ivas_fx.c | 36 +- lib_com/gs_gains_fx.c | 86 +- lib_com/gs_inact_switching_fx.c | 22 +- lib_com/gs_noisefill_fx.c | 70 +- lib_com/gs_preech_fx.c | 14 +- lib_com/guided_plc_util_fx.c | 8 +- lib_com/hq2_bit_alloc_fx.c | 6 +- lib_com/hq2_core_com_fx.c | 40 +- lib_com/int_lsp_fx.c | 4 +- lib_com/ivas_rom_com_fx.c | 52 +- lib_com/ivas_tools_fx.c | 4 +- lib_com/math_op.h | 2 +- lib_com/ppp_fx.c | 2 +- lib_com/pred_lt4_fx.c | 2 +- lib_com/preemph_fx.c | 4 +- lib_com/prot_fx.h | 624 +- lib_com/pvq_com_fx.c | 70 +- lib_com/range_com_fx.c | 12 +- lib_com/re8_ppv_fx.c | 14 +- lib_com/re8_util_fx.c | 26 +- lib_com/recovernorm_fx.c | 8 +- lib_com/residu_fx.c | 20 +- lib_com/rom_com.h | 58 +- lib_com/rom_com_fx.c | 12268 ++++++++++----------- lib_com/stat_noise_uv_mod_fx.c | 62 +- lib_com/swb_tbe_com_fx.c | 4 +- lib_com/syn_12k8_fx.c | 30 +- lib_com/tcx_ltp_fx.c | 6 +- lib_com/tcx_mdct_fx.c | 16 +- lib_com/vlpc_2st_com_fx.c | 4 +- lib_com/weight_a_fx.c | 22 +- lib_com/weight_fx.c | 12 +- lib_com/window_fx.c | 8 +- lib_dec/FEC_lsf_estim_fx.c | 8 +- lib_dec/FEC_pitch_estim_fx.c | 30 +- lib_dec/FEC_scale_syn_fx.c | 50 +- lib_dec/acelp_core_switch_dec_fx.c | 8 +- lib_dec/ari_dec_fx.c | 2 +- lib_dec/avq_dec_fx.c | 20 +- lib_dec/bass_psfilter_fx.c | 32 +- lib_dec/cng_dec_fx.c | 8 +- lib_dec/core_dec_init_fx.c | 10 +- lib_dec/core_dec_reconf_fx.c | 2 +- lib_dec/core_dec_switch_fx.c | 14 +- lib_dec/core_switching_dec_fx.c | 8 +- lib_dec/dec2t32_fx.c | 46 +- lib_dec/dec4t64_fx.c | 32 +- lib_dec/dec_gen_voic_fx.c | 2 +- lib_dec/dec_higher_acelp_fx.c | 30 +- lib_dec/dec_nelp_fx.c | 12 +- lib_dec/dec_pit_exc_fx.c | 24 +- lib_dec/dec_ppp_fx.c | 36 +- lib_dec/dec_tcx_fx.c | 16 +- lib_dec/dec_tran_fx.c | 34 +- lib_dec/dec_uv_fx.c | 18 +- lib_dec/fd_cng_dec_fx.c | 8 +- lib_dec/gain_dec_fx.c | 178 +- lib_dec/gaus_dec_fx.c | 32 +- lib_dec/gs_dec_amr_wb_fx.c | 40 +- lib_dec/gs_dec_fx.c | 70 +- lib_dec/hdecnrm_fx.c | 16 +- lib_dec/hf_synth_fx.c | 94 +- lib_dec/hq_core_dec_fx.c | 2 +- lib_dec/hq_hr_dec_fx.c | 14 +- lib_dec/hq_lr_dec_fx.c | 22 +- lib_dec/inov_dec_fx.c | 4 +- lib_dec/ivas_rom_dec_fx.c | 108 +- lib_dec/ivas_stereo_adapt_GR_dec_fx.c | 44 +- lib_dec/ivas_stereo_cng_dec_fx.c | 50 +- lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 10 +- lib_dec/ivas_stereo_dft_dec_fx.c | 118 +- lib_dec/ivas_stereo_dft_plc_fx.c | 58 +- lib_dec/ivas_stereo_eclvq_dec_fx.c | 2 +- lib_dec/ivas_stereo_ica_dec_fx.c | 8 +- lib_dec/ivas_stereo_icbwe_dec_fx.c | 20 +- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 8 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 74 +- lib_dec/ivas_stereo_switching_dec_fx.c | 36 +- lib_dec/ivas_stereo_td_dec_fx.c | 20 +- lib_dec/ivas_svd_dec_fx.c | 82 +- lib_dec/ivas_tcx_core_dec_fx.c | 52 +- lib_dec/ivas_td_low_rate_dec_fx.c | 36 +- lib_dec/lib_dec.h | 6 +- lib_dec/lp_exc_d_fx.c | 39 +- lib_dec/lsf_dec_fx.c | 24 +- lib_dec/lsf_msvq_ma_dec_fx.c | 14 +- lib_dec/pit_dec_fx.c | 2 +- lib_dec/ppp_dec_fx.c | 48 +- lib_dec/transition_dec_fx.c | 62 +- lib_enc/FEC_enc_fx.c | 70 +- lib_enc/SNR_calc_fx.c | 64 +- lib_enc/acelp_core_enc_fx.c | 50 +- lib_enc/acelp_enc_util_fx.c | 38 +- lib_enc/analy_lp_fx.c | 20 +- lib_enc/analy_sp_fx.c | 2 +- lib_enc/ari_enc_fx.c | 10 +- lib_enc/cod4t64_fx.c | 6 +- lib_enc/cod_tcx_fx.c | 4 +- lib_enc/detect_transient_fx.c | 12 +- lib_enc/dtx_fx.c | 8 +- lib_enc/enc_gen_voic_fx.c | 71 +- lib_enc/enc_gen_voic_rf_fx.c | 22 +- lib_enc/enc_higher_acelp_fx.c | 14 +- lib_enc/enc_nelp_fx.c | 57 +- lib_enc/enc_pit_exc_fx.c | 73 +- lib_enc/enc_ppp_fx.c | 86 +- lib_enc/enc_prm_fx.c | 8 +- lib_enc/enc_tran_fx.c | 56 +- lib_enc/enc_uv_fx.c | 14 +- lib_enc/energy_fx.c | 34 +- lib_enc/eval_pit_contr_fx.c | 48 +- lib_enc/evs_enc_fx.c | 8 +- lib_enc/ext_sig_ana_fx.c | 12 +- lib_enc/fd_cng_enc_fx.c | 36 +- lib_enc/find_tar_fx.c | 4 +- lib_enc/find_tilt_fx.c | 40 +- lib_enc/find_uv_fx.c | 46 +- lib_enc/find_wsp_fx.c | 28 +- lib_enc/frame_spec_dif_cor_rate_fx.c | 8 +- lib_enc/gain_enc_fx.c | 146 +- lib_enc/gaus_enc_fx.c | 46 +- lib_enc/gp_clip_fx.c | 18 +- lib_enc/gs_enc_fx.c | 90 +- lib_enc/igf_enc_fx.c | 6 +- lib_enc/inov_enc_fx.c | 71 +- lib_enc/ivas_core_enc_fx.c | 20 +- lib_enc/ivas_core_pre_proc_front_fx.c | 94 +- lib_enc/ivas_core_pre_proc_fx.c | 56 +- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 2 +- lib_enc/ivas_cpe_enc_fx.c | 24 +- lib_enc/ivas_decision_matrix_enc_fx.c | 12 +- lib_enc/ivas_dirac_enc_fx.c | 34 +- lib_enc/ivas_enc_cov_handler_fx.c | 12 +- lib_enc/ivas_enc_fx.c | 6 +- lib_enc/ivas_front_vad_fx.c | 44 +- lib_enc/ivas_init_enc_fx.c | 8 +- lib_enc/ivas_ism_dtx_enc_fx.c | 16 +- lib_enc/ivas_ism_enc_fx.c | 12 +- lib_enc/ivas_rom_enc_fx.c | 2 +- lib_enc/long_enr_fx.c | 4 +- lib_enc/lp_exc_e_fx.c | 10 +- lib_enc/lsf_msvq_ma_enc_fx.c | 14 +- lib_enc/ltd_stable_fx.c | 6 +- lib_enc/multi_harm_fx.c | 40 +- lib_enc/pit_enc_fx.c | 54 +- lib_enc/ppp_enc_fx.c | 62 +- lib_enc/prot_fx_enc.h | 4 +- lib_enc/qlpc_avq_fx.c | 2 +- lib_enc/qlpc_stoch_fx.c | 14 +- lib_enc/range_enc_fx.c | 66 +- lib_enc/rom_enc.h | 12 +- lib_enc/rom_enc_fx.c | 668 +- lib_enc/scale_enc_fx.c | 24 +- lib_enc/set_impulse_fx.c | 28 +- lib_enc/spec_center_fx.c | 14 +- lib_enc/spec_flatness_fx.c | 6 +- lib_enc/stat_noise_uv_enc_fx.c | 4 +- lib_enc/swb_pre_proc_fx.c | 64 +- lib_enc/tns_base_enc_fx.c | 14 +- lib_enc/transition_enc_fx.c | 56 +- lib_enc/vad_fx.c | 10 +- lib_enc/vbr_average_rate_fx.c | 22 +- lib_enc/vlpc_2st_cod_fx.c | 2 +- 172 files changed, 9268 insertions(+), 9283 deletions(-) diff --git a/lib_com/ACcontextMapping_fx.c b/lib_com/ACcontextMapping_fx.c index 3fecfd2af..ee51f0ca3 100644 --- a/lib_com/ACcontextMapping_fx.c +++ b/lib_com/ACcontextMapping_fx.c @@ -11,10 +11,10 @@ /* Returns: index of next coefficient */ Word16 get_next_coeff_mapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { Word16 p; @@ -41,10 +41,10 @@ Word16 get_next_coeff_mapped( /* Returns: index of next coefficient */ Word16 get_next_coeff_unmapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { (void) pp; @@ -104,10 +104,10 @@ Word32 update_mixed_context_ivas_fx( /*! r: index of next coefficient */ Word16 get_next_coeff_mapped_ivas_fx( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { UWord32 p; diff --git a/lib_com/arith_coder_fx.c b/lib_com/arith_coder_fx.c index 09e2b7f4f..58ff0047c 100644 --- a/lib_com/arith_coder_fx.c +++ b/lib_com/arith_coder_fx.c @@ -427,13 +427,13 @@ void tcx_arith_scale_envelope( * and decoder remain synchronized. *-------------------------------------------------------------------------*/ void tcx_arith_render_envelope( - const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i: number of spectral lines Q0*/ + const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i: number of spectral lines Q0*/ const Word16 L_spec, /* Q0 */ - const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o: shaped signal envelope Q16*/ + const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o: shaped signal envelope Q16*/ ) { Word16 k; diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index bfafdfacb..3ef5cf664 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -434,7 +434,7 @@ Word16 BASOP_util_norm_s_bands2shift( Word16 x ); /***********************************************************************/ /*! - \brief Calculate the headroom of the complex data in a 2 dimensional array + \brief Calculate the headroom of the complex data in a 2 dimensional array \return number of headroom bits */ diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 97dd19f18..7fdbbe954 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -67,37 +67,37 @@ *Q values *----------------------------------------------------------------------------------*/ -#define Q1 1 -#define Q2 2 -#define Q3 3 -#define Q4 4 -#define Q5 5 -#define Q6 6 -#define Q7 7 -#define Q8 8 -#define Q9 9 -#define Q10 10 -#define Q11 11 -#define Q12 12 -#define Q13 13 -#define Q14 14 -#define Q15 15 -#define Q16 16 -#define Q17 17 -#define Q18 18 -#define Q19 19 -#define Q20 20 -#define Q21 21 -#define Q22 22 -#define Q23 23 -#define Q24 24 -#define Q25 25 -#define Q26 26 -#define Q27 27 -#define Q28 28 -#define Q29 29 -#define Q30 30 -#define Q31 31 +#define Q1 1 +#define Q2 2 +#define Q3 3 +#define Q4 4 +#define Q5 5 +#define Q6 6 +#define Q7 7 +#define Q8 8 +#define Q9 9 +#define Q10 10 +#define Q11 11 +#define Q12 12 +#define Q13 13 +#define Q14 14 +#define Q15 15 +#define Q16 16 +#define Q17 17 +#define Q18 18 +#define Q19 19 +#define Q20 20 +#define Q21 21 +#define Q22 22 +#define Q23 23 +#define Q24 24 +#define Q25 25 +#define Q26 26 +#define Q27 27 +#define Q28 28 +#define Q29 29 +#define Q30 30 +#define Q31 31 /*----------------------------------------------------------------------------------* * one in Q diff --git a/lib_com/deemph_fx.c b/lib_com/deemph_fx.c index 829b4045b..d80136272 100644 --- a/lib_com/deemph_fx.c +++ b/lib_com/deemph_fx.c @@ -64,27 +64,27 @@ void deemph_fx_32( /*========================================================================*/ -/* FUNCTION : deemph_fx() */ +/* FUNCTION : deemph_fx() */ /*------------------------------------------------------------------------*/ -/* PURPOSE : Deemphasis: filtering through 1/(1-mu z^-1) */ +/* PURPOSE : Deemphasis: filtering through 1/(1-mu z^-1) */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) mu : deemphasis factor Q15 */ -/* _ (Word16) L : vector size */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) mu : deemphasis factor Q15 */ +/* _ (Word16) L : vector size */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16*) signal : signal Q_syn2-1 */ -/* _ (Word16*) mem : memory (y[-1]) Q_syn2-1 */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16*) signal : signal Q_syn2-1 */ +/* _ (Word16*) mem : memory (y[-1]) Q_syn2-1 */ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ void deemph_fx( - Word16 *signal, /* i/o: signal Qx */ + Word16 *signal, /* i/o: signal Qx */ const Word16 mu, /* i : deemphasis factor Q15 */ const Word16 L, /* i : vector size Q0 */ Word16 *mem /* i/o: memory (y[-1]) Qx */ @@ -150,8 +150,8 @@ void Deemph2( * * Parameters: * shift I: scale output - * x I/O: signal Qx/Qx-shift - * mu I: deemphasis factor Qx + * x I/O: signal Qx/Qx-shift + * mu I: deemphasis factor Qx * L I: vector size * mem I/O: memory (signal[-1]) Qx * diff --git a/lib_com/env_stab_trans_fx.c b/lib_com/env_stab_trans_fx.c index 0e4d54962..ccab6f2c1 100644 --- a/lib_com/env_stab_trans_fx.c +++ b/lib_com/env_stab_trans_fx.c @@ -48,15 +48,15 @@ *--------------------------------------------------------------------------*/ void env_stab_transient_detect_fx( - const Word16 is_transient, /* i: Transient flag */ - const Word16 length, /* i : Length of spectrum (32 or 48 kHz) */ - const Word16 norm[], /* i : quantization indices for norms */ - Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover (Q0) */ + const Word16 is_transient, /* i: Transient flag */ + const Word16 length, /* i : Length of spectrum (32 or 48 kHz) */ + const Word16 norm[], /* i : quantization indices for norms */ + Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover (Q0) */ Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection (Q13) */ - const Word16 HQ_mode, /* i : HQ coding mode */ - const Word16 bin_th, /* i : HVQ cross-over frequency bin */ - const Word32 *L_coeff, /* i : Coded spectral coefficients */ - const Word16 Qcoeff /* i : Q of coded spectral coefficients */ + const Word16 HQ_mode, /* i : HQ coding mode */ + const Word16 bin_th, /* i : HVQ cross-over frequency bin */ + const Word32 *L_coeff, /* i : Coded spectral coefficients */ + const Word16 Qcoeff /* i : Q of coded spectral coefficients */ ) { Word16 i, blk, norm_ind, sqrt_exp, bin_th_1, temp, sh; diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 4ff9c6c11..f3a30403f 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -10,13 +10,13 @@ /*======================================================================*/ -/* FUNCTION : est_tilt_fx() */ +/* FUNCTION : est_tilt_fx() */ /*-----------------------------------------------------------------------*/ /* PURPOSE : Estimate spectral tilt based on the relative E of adaptive */ /* and innovative excitations */ /* */ /*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word16 *) exc : adaptive excitation vector Q0 */ /* _ (Word16) gain_pit : adaptive gain Q14 */ /* _ (Word16 *) code : algebraic exctitation vector Q12 */ @@ -88,13 +88,13 @@ Word16 est_tilt_fx( /* o : tilt of the code } /*======================================================================*/ -/* FUNCTION : est_tilt_ivas_fx() */ +/* FUNCTION : est_tilt_ivas_fx() */ /*-----------------------------------------------------------------------*/ /* PURPOSE : Estimate spectral tilt based on the relative E of adaptive */ /* and innovative excitations */ /* */ /*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word16 *) exc : adaptive excitation vector Q0 */ /* _ (Word16) gain_pit : adaptive gain Q14 */ /* _ (Word16 *) code : algebraic exctitation vector Q12 */ diff --git a/lib_com/fft_fx_evs.c b/lib_com/fft_fx_evs.c index 41a70b20c..77d8bdd34 100644 --- a/lib_com/fft_fx_evs.c +++ b/lib_com/fft_fx_evs.c @@ -113,10 +113,10 @@ void DoRTFTn_fx( * Main fuction of Complex Discrete Fourier Transform *-----------------------------------------------------------------*/ static void cdftForw_fx( - Word16 n, /* i : data length of real and imag */ + Word16 n, /* i : data length of real and imag */ Word32 *a, /* i/o : input/output data Q(q)*/ - const Word16 *ip, /* i : work area for bit reversal */ - const Word16 *w /* i : cos/sin table Q14*/ + const Word16 *ip, /* i : work area for bit reversal */ + const Word16 *w /* i : cos/sin table Q14*/ ) { /* bit reversal */ @@ -131,8 +131,8 @@ static void cdftForw_fx( * Bit reversal *-----------------------------------------------------------------*/ static void bitrv2_SR_fx( - Word16 n, /* i : data length of real and imag */ - const Word16 *ip, /* i/o : work area for bit reversal */ + Word16 n, /* i : data length of real and imag */ + const Word16 *ip, /* i/o : work area for bit reversal */ Word32 *a /* i/o : input/output data Q(q)*/ ) { @@ -308,7 +308,7 @@ static void bitrv2_SR_fx( * Complex Discrete Fourier Transform *-----------------------------------------------------------------*/ static void cftfsub_fx( - Word16 n, /* i : data length of real and imag */ + Word16 n, /* i : data length of real and imag */ Word32 *a, /* i/o : input/output data Q(q)*/ const Word16 *w /* i : cos/sin table Q14*/ ) @@ -550,10 +550,10 @@ static void cft1st_fx( * Subfunction of Complex Discrete Fourier Transform *-----------------------------------------------------------------*/ static void cftmdl_fx( - Word16 n, /* i : data length of real and imag */ - Word16 l, /* i : initial shift for processing */ + Word16 n, /* i : data length of real and imag */ + Word16 l, /* i : initial shift for processing */ Word32 *a, /* i/o : input/output data Q(Qx+Q_edct)*/ - const Word16 *w /* i : cos/sin table Q30*/ + const Word16 *w /* i : cos/sin table Q30*/ ) { Word16 j, j1, j2, j3, k, k1, k2, m, m2; @@ -1468,10 +1468,10 @@ void DoRTFT128_16fx( * Main fuction of Complex Discrete Fourier Transform *-----------------------------------------------------------------*/ static void cdftForw_16fx( - Word16 n, /* i : data length of real and imag */ + Word16 n, /* i : data length of real and imag */ Word16 *a, /* i/o : input/output data Q(Qx+Q_edct)*/ - const Word16 *ip, /* i : work area for bit reversal */ - const Word32 *w /* i : cos/sin table Q30*/ + const Word16 *ip, /* i : work area for bit reversal */ + const Word32 *w /* i : cos/sin table Q30*/ ) { /* bit reversal */ @@ -1486,8 +1486,8 @@ static void cdftForw_16fx( * Bit reversal *-----------------------------------------------------------------*/ static void bitrv2_SR_16fx( - Word16 n, /* i : data length of real and imag */ - const Word16 *ip, /* i/o : work area for bit reversal */ + Word16 n, /* i : data length of real and imag */ + const Word16 *ip, /* i/o : work area for bit reversal */ Word16 *a /* i/o : input/output data Q(Qx+Q_edct)*/ ) { @@ -1663,7 +1663,7 @@ static void bitrv2_SR_16fx( * Complex Discrete Fourier Transform *-----------------------------------------------------------------*/ static void cftfsub_16fx( - Word16 n, /* i : data length of real and imag */ + Word16 n, /* i : data length of real and imag */ Word16 *a, /* i/o : input/output data Q(Qx+Q_edct)*/ const Word32 *w /* i : cos/sin table Q30*/ ) @@ -1964,10 +1964,10 @@ static void cft1st_16fx( * Subfunction of Complex Discrete Fourier Transform *-----------------------------------------------------------------*/ static void cftmdl_16fx( - Word16 n, /* i : data length of real and imag */ - Word16 l, /* i : initial shift for processing */ + Word16 n, /* i : data length of real and imag */ + Word16 l, /* i : initial shift for processing */ Word16 *a, /* i/o : input/output data Q(Qx+Q_edct)*/ - const Word32 *w /* i : cos/sin table Q30*/ + const Word32 *w /* i : cos/sin table Q30*/ ) { Word16 j, j1, j2, j3, k, k1, k2, m, m2; diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index a4ebbe2d5..ee2c3f98c 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -10,34 +10,34 @@ #include "stl.h" /*==================================================================================*/ -/* FUNCTION : void bands_and_bit_alloc_fx(); */ +/* FUNCTION : void bands_and_bit_alloc_fx(); */ /*----------------------------------------------------------------------------------*/ /* PURPOSE : AC mode (GSC) bands and bits allocation */ /*----------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) cor_strong_limit : HF correlation */ -/* _ (Word16) noise_lev : dwn scaling factor Q0 */ -/* _ (Word32) core_brate : core codec used Q0 */ -/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) cor_strong_limit : HF correlation */ +/* _ (Word16) noise_lev : dwn scaling factor Q0 */ +/* _ (Word32) core_brate : core codec used Q0 */ +/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ /* _ (Word16) bits_used : Number of bit used before frequency Q0 */ -/* _ (Word16) idx : Energy band 14 Q0 */ -/* _ (Word16*) exc_diff : Difference signal to quantize (Encoder only) */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) bwidth : input signal bandwidth Q0 */ +/* _ (Word16) idx : Energy band 14 Q0 */ +/* _ (Word16*) exc_diff : Difference signal to quantize (Encoder only) */ +/* _ (Word16) coder_type : coding type Q0 */ +/* _ (Word16) bwidth : input signal bandwidth Q0 */ /*----------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) max_ener_band : Sorted order */ -/* _ (Word16*) nb_subbands : Number of subband allowed Q0 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) max_ener_band : Sorted order */ +/* _ (Word16*) nb_subbands : Number of subband allowed Q0 */ /* _ (Word16*) concat_in : Concatened PVQ's input vector (Encoder Only) */ -/* _ (Word16*) pvq_len : Number of bin covered with the PVQ Q0 */ +/* _ (Word16*) pvq_len : Number of bin covered with the PVQ Q0 */ /*----------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16*) bit :Number of bit allowed for frequency quantization */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16*) bit :Number of bit allowed for frequency quantization */ /* _ (Word16*) Ener_per_bd_iQ : Quantized energy vector Q13 */ /* _ (Word32*) bits_per_bands : Number of bit allowed per allowed subband Q18 */ /*----------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*==================================================================================*/ void bands_and_bit_alloc_fx( const Word16 cor_strong_limit, /* i : HF correlation */ diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index 2223c0f8f..549edd345 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -41,34 +41,34 @@ static Word16 Find_norm_inv_fx( const Word32 ToDivide, Word16 *e_div ); static Word16 Find_bit_alloc_IVAS_fx( const Word32 core_brate, const Word16 GSC_IVAS_mode, const Word16 Diff_len, const Word16 nb_tot_bands, Word16 *bit, Word16 *max_ener_band, Word16 *ener_vec, Word32 *bits_per_bands ); static Word32 Find_bit_frac_fx( const Word16 nb_band, const Word16 remaining_bits ); /*==================================================================================*/ -/* FUNCTION : void bands_and_bit_alloc_ivas_fx(); */ +/* FUNCTION : void bands_and_bit_alloc_ivas_fx(); */ /*----------------------------------------------------------------------------------*/ /* PURPOSE : AC mode (GSC) bands and bits allocation */ /*----------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) cor_strong_limit : HF correlation */ -/* _ (Word16) noise_lev : dwn scaling factor Q0 */ -/* _ (Word32) core_brate : core codec used Q0 */ -/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) cor_strong_limit : HF correlation */ +/* _ (Word16) noise_lev : dwn scaling factor Q0 */ +/* _ (Word32) core_brate : core codec used Q0 */ +/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ /* _ (Word16) bits_used : Number of bit used before frequency Q0 */ -/* _ (Word16) idx : Energy band 14 Q0 */ -/* _ (Word16*) exc_diff : Difference signal to quantize (Encoder only) */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) bwidth : input signal bandwidth Q0 */ +/* _ (Word16) idx : Energy band 14 Q0 */ +/* _ (Word16*) exc_diff : Difference signal to quantize (Encoder only) */ +/* _ (Word16) coder_type : coding type Q0 */ +/* _ (Word16) bwidth : input signal bandwidth Q0 */ /*----------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) max_ener_band : Sorted order */ -/* _ (Word16*) nb_subbands : Number of subband allowed Q0 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) max_ener_band : Sorted order */ +/* _ (Word16*) nb_subbands : Number of subband allowed Q0 */ /* _ (Word16*) concat_in : Concatened PVQ's input vector (Encoder Only) */ -/* _ (Word16*) pvq_len : Number of bin covered with the PVQ Q0 */ +/* _ (Word16*) pvq_len : Number of bin covered with the PVQ Q0 */ /*----------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16*) bit :Number of bit allowed for frequency quantization */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16*) bit :Number of bit allowed for frequency quantization */ /* _ (Word16*) Ener_per_bd_iQ : Quantized energy vector Q12 */ /* _ (Word32*) bits_per_bands : Number of bit allowed per allowed subband Q18 */ /*----------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*==================================================================================*/ void bands_and_bit_alloc_ivas_fx( const Word16 cor_strong_limit, /* i : HF correlation */ diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 860ed90b0..eb089cc5b 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -50,24 +50,24 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const Word16 *dic_fx, const Word16 index_fx, const Word16 vec_en_fx ); /*========================================================================*/ -/* FUNCTION : void Comp_and_apply_gain_enc_fx */ +/* FUNCTION : void Comp_and_apply_gain_enc_fx */ /*------------------------------------------------------------------------*/ /* PURPOSE : Compute and apply the quantized per band gain */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word16[]) Ener_per_bd_iQ : Target ener per band Q12 */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_diffQ : Quantized excitation Qexc */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_diffQ : Quantized excitation Qexc */ /* _ (Word16[]) Ener_per_bd_yQ : Ener per band for norm vectori->Q12/o->Q2*/ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ None */ +/* OUTPUT ARGUMENTS : */ +/* _ None */ /*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ void Comp_and_apply_gain_fx( @@ -238,27 +238,27 @@ void Comp_and_apply_gain_ivas_fx( /*========================================================================*/ -/* FUNCTION : Ener_per_band_comp_fx() */ +/* FUNCTION : Ener_per_band_comp_fx() */ /*------------------------------------------------------------------------*/ /* PURPOSE : Compute the energy per band in log domain for quantization */ -/* purposes. */ -/* Loops are decomposed to accomodate the PVQ quantization */ +/* purposes. */ +/* Loops are decomposed to accomodate the PVQ quantization */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word16*) edct_table_128_fx : edct table Q15 */ /* _ (Word16*) Q_exc_diff : input format of exc_diff */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) y_gain4 : Energy per band to quantize Q12 */ -/* _ (Word32*) etmp14 : Energy band 14 Q_exc_diff*2+1 */ -/* _ (Word32*) etmp15 : Energy band 15 Q_exc_diff*2+1 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) y_gain4 : Energy per band to quantize Q12 */ +/* _ (Word32*) etmp14 : Energy band 14 Q_exc_diff*2+1 */ +/* _ (Word32*) etmp15 : Energy band 15 Q_exc_diff*2+1 */ /*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ static Word16 Comp_band_log_ener( /* o : Band gain Q12 */ @@ -281,7 +281,7 @@ static Word16 Comp_band_log_ener( /* o : Band gain Q12 */ void Ener_per_band_comp_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ - Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ + Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ const Word16 Eflag /* i : flag of highest band */ @@ -317,7 +317,7 @@ void Ener_per_band_comp_fx( void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ - Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ + Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ const Word16 Eflag, /* i : flag of highest band */ @@ -914,24 +914,24 @@ Word16 gsc_gainQ_ivas_fx( /*==========================================================================*/ -/* FUNCTION : Word16 gsc_gaindec_fx () */ +/* FUNCTION : Word16 gsc_gaindec_fx() */ /*--------------------------------------------------------------------------*/ /* PURPOSE : Generic signal frequency band decoding and application */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) pvq_bits_fx : core used Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) pvq_bits_fx : core used Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) core_fx : core used Q0 */ /* _ (Word16) bwidth_fx : input signal bandwidth Q0 */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) y_gainQ_fx : quantized gain per band */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) y_gainQ_fx : quantized gain per band */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ (Word16) : average frequency gain */ +/* RETURN ARGUMENTS : */ +/* _ (Word16) : : average frequency gain */ /*==========================================================================*/ Word16 gsc_gaindec_fx( /* o : average frequency gain */ @@ -1073,24 +1073,24 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /*==========================================================================*/ -/* FUNCTION : Word16 gsc_gaindec_ivas_fx () */ +/* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ /*--------------------------------------------------------------------------*/ /* PURPOSE : Generic signal frequency band decoding and application */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) pvq_bits_fx : core used Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) core_fx : core used Q0 */ -/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) pvq_bits_fx : core used Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ +/* _ (Word16) core_fx : core used Q0 */ +/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) y_gainQ_fx : quantized gain per band */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) y_gainQ_fx : quantized gain per band */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ (Word16) : average frequency gain */ +/* RETURN ARGUMENTS : */ +/* _ (Word16) : : average frequency gain */ /*==========================================================================*/ Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 119811275..9ad424102 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -16,26 +16,26 @@ #define BETA0_FX ( 32768 - ALPHA0_FX ) /*Q15*/ /*========================================================================*/ -/* FUNCTION : Inac_swtch_ematch_fx() */ +/* FUNCTION : Inac_swtch_ematch_fx() */ /*------------------------------------------------------------------------*/ /* PURPOSE : Apply energy matching when swithcing to INACTIVE frame coded */ -/* by the GSC technology */ +/* by the GSC technology */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) coder_type : Coding mode */ -/* _ (Word16) L_frame : Frame lenght */ -/* _ (Word32) core_brate : core bitrate */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) coder_type : Coding mode */ +/* _ (Word16) L_frame : Frame lenght */ +/* _ (Word32) core_brate : core bitrate */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc2 : CELP/GSC excitation buffer Q_exc */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc2 : CELP/GSC excitation buffer Q_exc */ /* _ (Word16[]) lt_ener_per_band : Long term energy per band Q12 */ /* _ (Word16*) Q_exc : input and output format of exc2 */ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ void Inac_switch_ematch_fx( diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 2617bd5ce..3668c3d77 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -128,27 +128,27 @@ static void EstimateNoiseLevel_inner_fx( return; } /*==========================================================================*/ -/* FUNCTION : void EstimateNoiseLevel_fx() */ +/* FUNCTION : void EstimateNoiseLevel_fx() */ /*--------------------------------------------------------------------------*/ -/* PURPOSE : */ +/* PURPOSE : */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) bitrate : Bitrate of the codec Q0 */ -/* _ (Word16) Diff_len : number of bin before cut-off frequency */ -/* _ (Word16) Mbands_gn : number of bands Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word32) bitrate : Bitrate of the codec Q0 */ +/* _ (Word16) Diff_len : number of bin before cut-off frequency */ +/* _ (Word16) Mbands_gn : number of bands Q0 */ /* _ (Word16) coder_type : coder type Q0 */ -/* _ (Word16) noise_lev : pulses dynamic Q0 */ +/* _ (Word16) noise_lev : pulses dynamic Q0 */ /* _ (Word16) pit_band_idx : bin position of the cut-off frequency */ -/* _ (Word16*) freq_nsbin_per_band : bin per bands tables Q0 */ +/* _ (Word16*) freq_nsbin_per_band : bin per bands tables Q0 */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) noisepb : Noise per band Q15 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) noisepb : Noise per band Q15 */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /* None */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*==========================================================================*/ static void EstimateNoiseLevel_fx( Word16 *noisepb, /* o : Noise per band */ @@ -241,27 +241,27 @@ static void EstimateNoiseLevel_fx( } /*============================================================================*/ -/* FUNCTION : void Appy_NoiseFill_fx() */ +/* FUNCTION : void Appy_NoiseFill_fx() */ /*----------------------------------------------------------------------------*/ -/* PURPOSE : */ +/* PURPOSE : */ /*----------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word16*) seed_tcx : Seed for noise Q0 */ -/* _ (Word16*) noisepb : Noise per band Q15 */ +/* _ (Word16*) noisepb : Noise per band Q15 */ /* _ (Word16) Diff_len : number of bin before cut-off frequency Q0 */ /* _ (Word16) Mbands_gn : number of bands Q0 */ -/* _ (Word16) coder_type : pulses dynamic Q0 */ +/* _ (Word16) coder_type : pulses dynamic Q0 */ /* _ (Word16*) freq_nsbin_per_band: bin per bands tables Q0 */ -/* _ (Word16) qexc_diffQ : Q format of exc_diffQ */ +/* _ (Word16) qexc_diffQ : Q format of exc_diffQ */ /*----------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) exc_diffQ : Noise per band qexc_diffQ */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) exc_diffQ : Noise per band qexc_diffQ */ /*----------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /* None */ /*----------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*============================================================================*/ static void Apply_NoiseFill_fx( Word16 *exc_diffQ, /* i/o: Noise per band qexc_diffQ */ @@ -294,25 +294,25 @@ static void Apply_NoiseFill_fx( return; } /*==========================================================================*/ -/* FUNCTION :void freq_dnw_scaling_fx () */ +/* FUNCTION :void freq_dnw_scaling_fx () */ /*--------------------------------------------------------------------------*/ /* PURPOSE : */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) cor_strong_limit : HF correlation Q0 */ -/* _ (Word16) coder_type : coder type Q0 */ -/* _ (Word16) noise_lev : Noise level Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) cor_strong_limit : HF correlation Q0 */ +/* _ (Word16) coder_type : coder type Q0 */ +/* _ (Word16) noise_lev : Noise level Q0 */ /* _ (Word32) core_brate : Core bitrate Q0 */ -/* _ (Word16) Qx : Q format of fy_norm */ +/* _ (Word16) Qx : Q format of fy_norm */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) fy_norm : Frequency quantized parameter Qx */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) fy_norm : Frequency quantized parameter Qx */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _None */ +/* RETURN ARGUMENTS : */ +/* _None */ /*==========================================================================*/ void freq_dnw_scaling_fx( const Word16 cor_strong_limit, /* i : HF correlation */ diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index e607d66c5..3b4c4f2a8 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -54,10 +54,10 @@ void pre_echo_att_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ - const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ + const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, - const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ + const Word16 last_coder_type, /* i : Last coding mode Q0*/ + const Word16 L_frame /* i : Frame length Q0*/ ) { Word32 etmp_fx; @@ -117,7 +117,7 @@ void pre_echo_att_fx( etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */ /* Find the correction factor and apply it before the attack */ /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/ - /* = isqrt(etmp/(*Last_frame_ener)) */ + /* = isqrt(etmp/(*Last_frame_ener)) */ etmp_fx = L_max( etmp_fx, 1 ); *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 ); move32(); @@ -166,10 +166,10 @@ void pre_echo_att_fx( void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ - const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ + const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, - const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ + const Word16 last_coder_type, /* i : Last coding mode Q0*/ + const Word16 L_frame /* i : Frame length Q0*/ ) { Word32 etmp_fx; diff --git a/lib_com/guided_plc_util_fx.c b/lib_com/guided_plc_util_fx.c index 91075df44..7f5e44881 100644 --- a/lib_com/guided_plc_util_fx.c +++ b/lib_com/guided_plc_util_fx.c @@ -251,10 +251,10 @@ void modify_lsf( static void reorder_lsfs( - Word16 *lsf, /* i/o: vector of lsfs in the frequency domain (0..0.5) 1.28 Q1*/ - const Word16 min_dist0, /* i : minimum required distance 1.28 Q1*/ - const Word16 n, /* i : LPC order Q0*/ - const Word32 sr_core /* i : input sampling frequency Q0*/ + Word16 *lsf, /* i/o: vector of lsfs in the frequency domain (0..0.5) 1.28 Q1*/ + const Word16 min_dist0, /* i : minimum required distance 1.28 Q1*/ + const Word16 n, /* i : LPC order Q0*/ + const Word32 sr_core /* i : input sampling frequency Q0*/ ) { Word16 i; diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c index 0f097b669..e4c671a74 100644 --- a/lib_com/hq2_bit_alloc_fx.c +++ b/lib_com/hq2_bit_alloc_fx.c @@ -187,7 +187,7 @@ void Bits2indvsb_fx( exp_normn = sub( exp_normn, 1 ); exp_normd = norm_s( Rcnt_fx ); Ravg_fx = div_s( shl( be_sum_fx, exp_normn ), shl( Rcnt_fx, exp_normd ) ); - Ravg_fx = shr( Ravg_fx, 2 ); /* safe shift exp_normn - exp_normd + 13*/ + Ravg_fx = shr( Ravg_fx, 2 ); /* safe shift exp_normn - exp_normd + 13*/ QRavg = add( sub( exp_normn, exp_normd ), 15 - 2 ); if ( be_sum_fx <= 0 ) @@ -207,7 +207,7 @@ void Bits2indvsb_fx( exp_normn = sub( exp_normn, 1 ); exp_normd = norm_s( be_sum_fx ); Bits_avg_fx = div_s( shl( Bits, exp_normn ), shl( be_sum_fx, exp_normd ) ); - Bits_avg_fx = shr( Bits_avg_fx, 2 ); /* safe_shift exp_normn - exp_normd + 13*/ + Bits_avg_fx = shr( Bits_avg_fx, 2 ); /* safe_shift exp_normn - exp_normd + 13*/ QBavg = add( sub( exp_normn, exp_normd ), 15 - 2 ); } FOR( k = 0; k <= i; k++ ) @@ -262,7 +262,7 @@ void hq2_bit_alloc_har_fx( Word16 B_fx, /* i : Q0 number of available bits */ const Word16 N_fx, /* i : Q0 number of sub-vectors */ Word32 *L_Rsubband, /* o : QRk sub-band bit-allocation vector */ - Word16 p2a_bands_fx, /* i : Q0 highfreq bands */ + Word16 p2a_bands_fx, /* i : Q0 highfreq bands */ const Word32 L_core_brate, /* i : Q0 core bit rate */ Word16 p2a_flags_fx[], /* i/o: Q0 p2a_flags */ const Word16 band_width_fx[] /* i : Q0 table of band_width */ diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index a77513009..78f60d465 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -629,7 +629,7 @@ void reverse_transient_frame_energies_fx( p_be2--; } - k1 = sub( bands, bands_4 ); /* 3*bands/4 Q0 */ + k1 = sub( bands, bands_4 ); /* 3*bands/4 Q0 */ k2 = sub( bands, 1 ); /* Q0 */ p_be1 = &L_band_energy[k1]; /* Q14 */ p_be2 = &L_band_energy[k2]; /* Q14 */ @@ -739,13 +739,13 @@ void spt_shorten_domain_pre_fx( *--------------------------------------------------------------------------*/ void spt_shorten_domain_band_save_fx( - const Word16 bands, /* i: total subband Q0*/ - const Word16 band_start[], /* i: starting position of subband Q0*/ - const Word16 band_end[], /* i: end position of subband Q0*/ - const Word16 band_width[], /* i: band width of subband Q0*/ - Word16 org_band_start[], /* o: starting position of subband Q0*/ - Word16 org_band_end[], /* o: end position of subband Q0*/ - Word16 org_band_width[] /* o: band width of subband Q0*/ + const Word16 bands, /* i: total subband Q0*/ + const Word16 band_start[], /* i: starting position of subband Q0*/ + const Word16 band_end[], /* i: end position of subband Q0*/ + const Word16 band_width[], /* i: band width of subband Q0*/ + Word16 org_band_start[], /* o: starting position of subband Q0*/ + Word16 org_band_end[], /* o: end position of subband Q0*/ + Word16 org_band_width[] /* o: band width of subband Q0*/ ) { Word16 k; @@ -774,13 +774,13 @@ void spt_shorten_domain_band_save_fx( *--------------------------------------------------------------------------*/ void spt_shorten_domain_band_restore_fx( - const Word16 bands, /* i: total subband Q0*/ - Word16 band_start[], /* i/o: starting position of subband Q0*/ - Word16 band_end[], /* i/o: end position of subband Q0*/ - Word16 band_width[], /* i/o: band width of subband Q0*/ - const Word16 org_band_start[], /* o: starting position of subband Q0*/ - const Word16 org_band_end[], /* o: end position of subband Q0*/ - const Word16 org_band_width[] /* o: band width of subband Q0*/ + const Word16 bands, /* i: total subband Q0*/ + Word16 band_start[], /* i/o: starting position of subband Q0*/ + Word16 band_end[], /* i/o: end position of subband Q0*/ + Word16 band_width[], /* i/o: band width of subband Q0*/ + const Word16 org_band_start[], /* o: starting position of subband Q0*/ + const Word16 org_band_end[], /* o: end position of subband Q0*/ + const Word16 org_band_width[] /* o: band width of subband Q0*/ ) { Word16 k; @@ -809,11 +809,11 @@ void spt_shorten_domain_band_restore_fx( *--------------------------------------------------------------------------*/ void spt_swb_peakpos_tmp_save_fx( - const Word32 L_y2[], /* i: coded spectral information Qx*/ - const Word16 bands, /* i: total number of bands Q0*/ - const Word16 band_start[], /* i: starting position of subband Q0*/ - const Word16 band_end[], /* i: end position of subband Q0*/ - Word16 prev_SWB_peak_pos_tmp[] /* o: spectral peaks Q0*/ + const Word32 L_y2[], /* i: coded spectral information Qx*/ + const Word16 bands, /* i: total number of bands Q0*/ + const Word16 band_start[], /* i: starting position of subband Q0*/ + const Word16 band_end[], /* i: end position of subband Q0*/ + Word16 prev_SWB_peak_pos_tmp[] /* o: spectral peaks Q0*/ ) { diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c index f40b11cfa..0404a2f61 100644 --- a/lib_com/int_lsp_fx.c +++ b/lib_com/int_lsp_fx.c @@ -106,7 +106,7 @@ void int_lsp_fx( void int_lsp4_fx( const Word16 L_frame, /* i : length of the frame */ const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ - const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ + const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ const Word16 m, /* i : order of LP filter */ @@ -181,7 +181,7 @@ void int_lsp4_fx( void int_lsp4_ivas_fx( const Word16 L_frame, /* i : length of the frame */ const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ - const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ + const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ const Word16 m, /* i : order of LP filter */ diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index dd99410ac..a5af89655 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -2100,7 +2100,7 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_64k, &ivas_param_mc_ild_mapping_CICP14_2tc, &ivas_param_mc_icc_mapping_CICP14_2tc, - &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], + &ivas_param_mc_ild_fac_CICP14_2tc_fx[0], &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0] }, /* CICP14 80000 */ @@ -2122,7 +2122,7 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_96k, &ivas_param_mc_ild_mapping_CICP14_3tc, &ivas_param_mc_icc_mapping_CICP14_3tc, - &ivas_param_mc_ild_fac_CICP14_3tc_fx[0], + &ivas_param_mc_ild_fac_CICP14_3tc_fx[0], &ivas_param_mc_dmx_fac_CICP14_3tc_fx[0] }, /* CICP16 96000 */ @@ -2135,7 +2135,7 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = &ivas_param_mc_icc_mapping_CICP16_3tc, &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] - }, + }, /* CICP16 128000 */ { MC_LS_SETUP_5_1_4, @@ -2144,9 +2144,9 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_128k, &ivas_param_mc_ild_mapping_CICP16_3tc, &ivas_param_mc_icc_mapping_CICP16_3tc, - &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], + &ivas_param_mc_ild_fac_CICP16_3tc_fx[0], &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0] - }, + }, /* CICP19 128000 */ { MC_LS_SETUP_7_1_4, @@ -3069,30 +3069,30 @@ const Word16 nf_tw_smoothing_coeffs_fx[N_LTP_GAIN_MEMS] = const Word16 dft_trigo_12k8_fx[STEREO_DFT_N_12k8_ENC / 4 + 1] = { - 0, 402, 804, 1206, 1607, 2009, 2410, 2811, 3211, 3611, 4011, 4409, 4808, 5205, 5602, 5997, 6392, 6786, 7179, 7571, 7961, 8351, 8739, 9126, 9512, 9896, 10278, 10659, - 11039, 11416, 11793, 12167, 12539, 12910, 13278, 13645, 14010, 14372, 14732, 15090, 15446, 15800, 16151, 16499, 16846, 17189, 17530, 17869, 18204, 18537, 18868, - 19195, 19519, 19841, 20159, 20475, 20787, 21097, 21403, 21706, 22005, 22301, 22594, 22884, 23170, 23453, 23732, 24007, 24279, 24547, 24812, 25073, 25330, 25583, - 25832, 26077, 26319, 26557, 26790, 27020, 27245, 27466, 27684, 27897, 28106, 28310, 28511, 28707, 28898, 29086, 29269, 29447, 29621, 29791, 29956, 30117, 30273, - 30425, 30572, 30714, 30852, 30985, 31114, 31237, 31357, 31471, 31581, 31685, 31785, 31881, 31971, 32057, 32138, 32214, 32285, 32351, 32413, 32469, 32521, 32568, - 32610, 32647, 32679, 32706, 32728, 32745, 32758, 32765, 32767 + 0, 402, 804, 1206, 1607, 2009, 2410, 2811, 3211, 3611, 4011, 4409, 4808, 5205, 5602, 5997, 6392, 6786, 7179, 7571, 7961, 8351, 8739, 9126, 9512, 9896, 10278, 10659, + 11039, 11416, 11793, 12167, 12539, 12910, 13278, 13645, 14010, 14372, 14732, 15090, 15446, 15800, 16151, 16499, 16846, 17189, 17530, 17869, 18204, 18537, 18868, + 19195, 19519, 19841, 20159, 20475, 20787, 21097, 21403, 21706, 22005, 22301, 22594, 22884, 23170, 23453, 23732, 24007, 24279, 24547, 24812, 25073, 25330, 25583, + 25832, 26077, 26319, 26557, 26790, 27020, 27245, 27466, 27684, 27897, 28106, 28310, 28511, 28707, 28898, 29086, 29269, 29447, 29621, 29791, 29956, 30117, 30273, + 30425, 30572, 30714, 30852, 30985, 31114, 31237, 31357, 31471, 31581, 31685, 31785, 31881, 31971, 32057, 32138, 32214, 32285, 32351, 32413, 32469, 32521, 32568, + 32610, 32647, 32679, 32706, 32728, 32745, 32758, 32765, 32767 }; const Word16 dft_trigo_32k_fx[STEREO_DFT_N_32k_ENC / 4 + 1] = { - 0, 160, 321, 482, 643, 804, 964, 1125, 1286, 1447, 1607, 1768, 1929, 2089, 2250, 2410, 2570, 2731, 2891, 3051, 3211, 3371, 3531, 3691, 3851, 4011, 4170, 4330, 4489, - 4648, 4808, 4967, 5126, 5284, 5443, 5602, 5760, 5918, 6076, 6234, 6392, 6550, 6707, 6865, 7022, 7179, 7336, 7493, 7649, 7805, 7961, 8117, 8273, 8429, 8584, 8739, - 8894, 9049, 9203, 9358, 9512, 9665, 9819, 9972, 10125, 10278, 10431, 10583, 10735, 10887, 11039, 11190, 11341, 11492, 11642, 11793, 11942, 12092, 12241, 12391, - 12539, 12688, 12836, 12984, 13131, 13278, 13425, 13572, 13718, 13864, 14010, 14155, 14300, 14444, 14589, 14732, 14876, 15019, 15162, 15304, 15446, 15588, 15729, - 15870, 16011, 16151, 16291, 16430, 16569, 16707, 16846, 16983, 17121, 17258, 17394, 17530, 17666, 17801, 17936, 18070, 18204, 18338, 18471, 18604, 18736, 18868, - 18999, 19130, 19260, 19390, 19519, 19648, 19777, 19905, 20032, 20159, 20286, 20412, 20538, 20663, 20787, 20911, 21035, 21158, 21281, 21403, 21524, 21645, 21766, - 21886, 22005, 22124, 22242, 22360, 22478, 22594, 22711, 22826, 22941, 23056, 23170, 23283, 23396, 23509, 23620, 23732, 23842, 23952, 24062, 24171, 24279, 24387, - 24494, 24600, 24706, 24812, 24916, 25021, 25124, 25227, 25330, 25431, 25532, 25633, 25733, 25832, 25931, 26029, 26126, 26223, 26319, 26415, 26509, 26604, 26697, - 26790, 26882, 26974, 27065, 27155, 27245, 27334, 27423, 27510, 27597, 27684, 27769, 27854, 27939, 28023, 28106, 28188, 28270, 28351, 28431, 28511, 28589, 28668, - 28745, 28822, 28898, 28974, 29049, 29123, 29196, 29269, 29341, 29412, 29482, 29552, 29621, 29690, 29758, 29825, 29891, 29956, 30021, 30085, 30149, 30211, 30273, - 30334, 30395, 30455, 30514, 30572, 30629, 30686, 30742, 30797, 30852, 30906, 30959, 31011, 31063, 31114, 31164, 31213, 31262, 31309, 31357, 31403, 31448, 31493, - 31537, 31581, 31623, 31665, 31706, 31746, 31785, 31824, 31862, 31899, 31936, 31971, 32006, 32040, 32074, 32106, 32138, 32169, 32199, 32229, 32257, 32285, 32312, - 32339, 32364, 32389, 32413, 32436, 32458, 32480, 32501, 32521, 32540, 32559, 32577, 32594, 32610, 32625, 32640, 32653, 32666, 32679, 32690, 32701, 32711, 32720, - 32728, 32736, 32742, 32748, 32753, 32758, 32761, 32764, 32766, 32767, 32767 + 0, 160, 321, 482, 643, 804, 964, 1125, 1286, 1447, 1607, 1768, 1929, 2089, 2250, 2410, 2570, 2731, 2891, 3051, 3211, 3371, 3531, 3691, 3851, 4011, 4170, 4330, 4489, + 4648, 4808, 4967, 5126, 5284, 5443, 5602, 5760, 5918, 6076, 6234, 6392, 6550, 6707, 6865, 7022, 7179, 7336, 7493, 7649, 7805, 7961, 8117, 8273, 8429, 8584, 8739, + 8894, 9049, 9203, 9358, 9512, 9665, 9819, 9972, 10125, 10278, 10431, 10583, 10735, 10887, 11039, 11190, 11341, 11492, 11642, 11793, 11942, 12092, 12241, 12391, + 12539, 12688, 12836, 12984, 13131, 13278, 13425, 13572, 13718, 13864, 14010, 14155, 14300, 14444, 14589, 14732, 14876, 15019, 15162, 15304, 15446, 15588, 15729, + 15870, 16011, 16151, 16291, 16430, 16569, 16707, 16846, 16983, 17121, 17258, 17394, 17530, 17666, 17801, 17936, 18070, 18204, 18338, 18471, 18604, 18736, 18868, + 18999, 19130, 19260, 19390, 19519, 19648, 19777, 19905, 20032, 20159, 20286, 20412, 20538, 20663, 20787, 20911, 21035, 21158, 21281, 21403, 21524, 21645, 21766, + 21886, 22005, 22124, 22242, 22360, 22478, 22594, 22711, 22826, 22941, 23056, 23170, 23283, 23396, 23509, 23620, 23732, 23842, 23952, 24062, 24171, 24279, 24387, + 24494, 24600, 24706, 24812, 24916, 25021, 25124, 25227, 25330, 25431, 25532, 25633, 25733, 25832, 25931, 26029, 26126, 26223, 26319, 26415, 26509, 26604, 26697, + 26790, 26882, 26974, 27065, 27155, 27245, 27334, 27423, 27510, 27597, 27684, 27769, 27854, 27939, 28023, 28106, 28188, 28270, 28351, 28431, 28511, 28589, 28668, + 28745, 28822, 28898, 28974, 29049, 29123, 29196, 29269, 29341, 29412, 29482, 29552, 29621, 29690, 29758, 29825, 29891, 29956, 30021, 30085, 30149, 30211, 30273, + 30334, 30395, 30455, 30514, 30572, 30629, 30686, 30742, 30797, 30852, 30906, 30959, 31011, 31063, 31114, 31164, 31213, 31262, 31309, 31357, 31403, 31448, 31493, + 31537, 31581, 31623, 31665, 31706, 31746, 31785, 31824, 31862, 31899, 31936, 31971, 32006, 32040, 32074, 32106, 32138, 32169, 32199, 32229, 32257, 32285, 32312, + 32339, 32364, 32389, 32413, 32436, 32458, 32480, 32501, 32521, 32540, 32559, 32577, 32594, 32610, 32625, 32640, 32653, 32666, 32679, 32690, 32701, 32711, 32720, + 32728, 32736, 32742, 32748, 32753, 32758, 32761, 32764, 32766, 32767, 32767 }; const Word16 dft_trigo_48k_fx[STEREO_DFT_N_MAX_ENC / 4 + 1] = @@ -4671,7 +4671,7 @@ const Word16 ivas_lpf_4_butter_32k_sos_e[IVAS_BIQUAD_FILT_LEN << 2] = { }; const Word32 ivas_lpf_4_butter_48k_sos_fx[IVAS_BIQUAD_FILT_LEN << 2] = { - // 6, 11, 6, 1073741824, /* Q30 */ + // 6, 11, 6, 1073741824, /* Q30 */ 1477520448, 1477520448, 1477520448, 1073741824, -2113939767, 1040504054, 1073741824, 2147483480, 1073741829, 1073741824, -2133281237, 1059848324 diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 515a10cdb..2050b1116 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -2635,8 +2635,8 @@ Word16 ceil_log_2( Word64 var_32_fx( const Word32 *x, /* i : input vector q*/ - const Word16 len, /* i : length of inputvector Q0*/ - Word16 q /* q : q-factor for the array */ + const Word16 len, /* i : length of inputvector Q0*/ + Word16 q /* q : q-factor for the array */ ) { Word16 i; diff --git a/lib_com/math_op.h b/lib_com/math_op.h index 0e5fa825b..d4eca9f2b 100644 --- a/lib_com/math_op.h +++ b/lib_com/math_op.h @@ -1,5 +1,5 @@ /*--------------------------------------------------------------------------* - * MATH_OP.H * + * MATH_OP.H * *--------------------------------------------------------------------------* * Mathematical operations * *--------------------------------------------------------------------------*/ diff --git a/lib_com/ppp_fx.c b/lib_com/ppp_fx.c index c08241249..2f44e1081 100644 --- a/lib_com/ppp_fx.c +++ b/lib_com/ppp_fx.c @@ -41,7 +41,7 @@ /* PURPOSE : Interpolate pitch lag for a subframe */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (Word16) last_fx: previous frame delay, Q0 */ +/* _ (Word16) last_fx: previous frame delay, Q0 */ /* _ (Word16) current_fx: current frame delay, Q0 */ /* _ (Word16) SubNum : subframe number */ /*-------------------------------------------------------------------*/ diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index 869edfd1b..0da3c2742 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -152,7 +152,7 @@ void pred_lt4( /* _ (Word16 []) exc : output excitation buffer Q0 */ /*-----------------------------------------------------------------------*/ /* INPUT OUTPUT ARGUMENTS */ -/* NONE */ +/* NONE */ /*-----------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* NONE */ diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c index e8dfb4018..52ee86532 100644 --- a/lib_com/preemph_fx.c +++ b/lib_com/preemph_fx.c @@ -131,8 +131,8 @@ void preemph_ivas_fx( * * Parameters: * shift I: scale output - * signal I/O: signal Qx/Qx+shift - * mu I: preemphasis factor Q15 + * signal I/O: signal Qx/Qx+shift + * mu I: preemphasis factor Q15 * L I: vector size * mem I/O: memory (x[-1]) * diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8f4b53c5e..c6f70a9cd 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1728,7 +1728,7 @@ void int_lsp_fx( void int_lsp4_fx( const Word16 L_frame, /* i : length of the frame */ const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ - const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ + const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ const Word16 m, /* i : order of LP filter */ @@ -1738,7 +1738,7 @@ void int_lsp4_fx( void int_lsp4_ivas_fx( const Word16 L_frame, /* i : length of the frame */ const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ - const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ + const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ const Word16 m, /* i : order of LP filter */ @@ -1828,7 +1828,7 @@ void Ener_per_band_comp_fx( void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ - Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ + Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ const Word16 Eflag, /* i : flag of highest band */ @@ -1856,19 +1856,19 @@ void Comp_and_apply_gain_ivas_fx( void pre_echo_att_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ - const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ + const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, - const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ + const Word16 last_coder_type, /* i : Last coding mode Q0*/ + const Word16 L_frame /* i : Frame length Q0*/ ); void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ - const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ + const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, - const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ + const Word16 last_coder_type, /* i : Last coding mode Q0*/ + const Word16 L_frame /* i : Frame length Q0*/ ); void tcx_get_windows_mode1( @@ -2262,7 +2262,7 @@ void hq2_bit_alloc_har_fx( Word16 B_fx, /* i : Q0 number of available bits */ const Word16 N_fx, /* i : Q0 number of sub-vectors */ Word32 *L_Rsubband, /* o : QRk sub-band bit-allocation vector */ - Word16 p2a_bands_fx, /* i : Q0 highfreq bands */ + Word16 p2a_bands_fx, /* i : Q0 highfreq bands */ const Word32 L_core_brate, /* i : Q0 core bit rate */ Word16 p2a_flags_fx[], /* i/o: Q0 p2a_flags */ const Word16 band_width_fx[] /* i : Q0 table of band_width */ @@ -2383,31 +2383,31 @@ void spt_shorten_domain_pre_fx( ); void spt_shorten_domain_band_save_fx( - const Word16 bands, /* i: total subband Q0*/ - const Word16 band_start[], /* i: starting position of subband Q0*/ - const Word16 band_end[], /* i: end position of subband Q0*/ - const Word16 band_width[], /* i: band width of subband Q0*/ - Word16 org_band_start[], /* o: starting position of subband Q0*/ - Word16 org_band_end[], /* o: end position of subband Q0*/ - Word16 org_band_width[] /* o: band width of subband Q0*/ + const Word16 bands, /* i: total subband Q0*/ + const Word16 band_start[], /* i: starting position of subband Q0*/ + const Word16 band_end[], /* i: end position of subband Q0*/ + const Word16 band_width[], /* i: band width of subband Q0*/ + Word16 org_band_start[], /* o: starting position of subband Q0*/ + Word16 org_band_end[], /* o: end position of subband Q0*/ + Word16 org_band_width[] /* o: band width of subband Q0*/ ); void spt_shorten_domain_band_restore_fx( - const Word16 bands, /* i: total subband Q0*/ - Word16 band_start[], /* i/o: starting position of subband Q0*/ - Word16 band_end[], /* i/o: end position of subband Q0*/ - Word16 band_width[], /* i/o: band width of subband Q0*/ - const Word16 org_band_start[], /* o: starting position of subband Q0*/ - const Word16 org_band_end[], /* o: end position of subband Q0*/ - const Word16 org_band_width[] /* o: band width of subband Q0*/ + const Word16 bands, /* i: total subband Q0*/ + Word16 band_start[], /* i/o: starting position of subband Q0*/ + Word16 band_end[], /* i/o: end position of subband Q0*/ + Word16 band_width[], /* i/o: band width of subband Q0*/ + const Word16 org_band_start[], /* o: starting position of subband Q0*/ + const Word16 org_band_end[], /* o: end position of subband Q0*/ + const Word16 org_band_width[] /* o: band width of subband Q0*/ ); void spt_swb_peakpos_tmp_save_fx( - const Word32 L_y2[], /* i: coded spectral information Qx*/ - const Word16 bands, /* i: total number of bands Q0*/ - const Word16 band_start[], /* i: starting position of subband Q0*/ - const Word16 band_end[], /* i: end position of subband Q0*/ - Word16 prev_SWB_peak_pos_tmp[] /* o: spectral peaks Q0*/ + const Word32 L_y2[], /* i: coded spectral information Qx*/ + const Word16 bands, /* i: total number of bands Q0*/ + const Word16 band_start[], /* i: starting position of subband Q0*/ + const Word16 band_end[], /* i: end position of subband Q0*/ + Word16 prev_SWB_peak_pos_tmp[] /* o: spectral peaks Q0*/ ); void bit_allocation_second_fx( @@ -3314,9 +3314,9 @@ void synthesise_fb_high_band_fx( Word16 Q_fb_exc, Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ const Word32 fb_exc_energy, /* i : full band excitation energy */ - const Word16 ratio, /* i : energy ratio */ + const Word16 ratio, /* i : energy ratio */ const Word16 L_frame, /* i : ACELP frame length */ - const Word16 bfi, /* i : fec flag */ + const Word16 bfi, /* i : fec flag */ Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], @@ -3374,9 +3374,9 @@ Word16 shrtCDivSignedApprox( ); void obtainEnergyQuantizerDensity_fx( - const Word16 L, /* i : left vector energy Q0*/ - const Word16 R, /* i : right vector energy Q0*/ - Word16 *Density /* o : quantizer density Q0*/ + const Word16 L, /* i : left vector energy Q0*/ + const Word16 R, /* i : right vector energy Q0*/ + Word16 *Density /* o : quantizer density Q0*/ ); void dsDirac2Dirac_fx( @@ -3385,11 +3385,11 @@ void dsDirac2Dirac_fx( ); void dsDiracPerQuanta_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ - const Word16 dsm, /* i : Conservative rounding flag Q0*/ - const unsigned char *const *frQuanta, /* i : Quanta lookup table */ - Word16 *DsIdx /* o : Lookup table index Q0*/ + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ + const Word16 dsm, /* i : Conservative rounding flag Q0*/ + const unsigned char *const *frQuanta, /* i : Quanta lookup table */ + Word16 *DsIdx /* o : Lookup table index Q0*/ ); void QuantaPerDsDirac_fx( @@ -3427,20 +3427,20 @@ void bandBitsAdjustment_fx( ); void densityAngle2RmsProjDec_fx( - const Word16 D, /* i : density Q0*/ - const Word16 indexphi, /* i : decoded index from AR dec Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ + const Word16 D, /* i : density Q0*/ + const Word16 indexphi, /* i : decoded index from AR dec Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ ); void densityAngle2RmsProjEnc_fx( - const Word16 D, /* i : density Q0*/ - const Word16 phiQ14uq, /* i : angle Q14*/ - Word16 *indexphi, /* o : index Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ + const Word16 D, /* i : density Q0*/ + const Word16 phiQ14uq, /* i : angle Q14*/ + Word16 *indexphi, /* o : index Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ ); void NearOppSplitAdjustment_fx( @@ -3458,7 +3458,7 @@ void NearOppSplitAdjustment_fx( Word16 oppRQ3, /* i : ratio Q0*/ Word16 *qnear, /* o : quantized near Q0*/ Word16 *qopp, /* o : quantized opposite Q0*/ - Word16 *qglobalupd /* o : quanta remaining Q0*/ + Word16 *qglobalupd /* o : quanta remaining Q0*/ ); void apply_gain_fx( @@ -3480,9 +3480,9 @@ void fine_gain_quant_fx( ); void srt_vec_ind16_fx( - const Word16 *linear, /* linear input Q3*/ - Word16 *srt, /* sorted output Q3*/ - Word16 *I, /* index for sorted output Q0*/ + const Word16 *linear, /* linear input Q3*/ + Word16 *srt, /* sorted output Q3*/ + Word16 *I, /* index for sorted output Q0*/ Word16 length /* Q0 */ ); @@ -3492,16 +3492,16 @@ Word16 atan2_fx( const Word32 x /* i : opposite side (Q15) */ ); -/* o: Number of bits needed Q0*/ +/* o: Number of bits needed Q0*/ Word16 rc_get_bits2_fx( - const Word16 N, /* i: Number of bits currently used Q0*/ - const UWord32 range /* i: Range of range coder Q0*/ + const Word16 N, /* i: Number of bits currently used Q0*/ + const UWord32 range /* i: Range of range coder Q0*/ ); void rangeCoderFinalizationFBits_fx( - Word16 Brc, /* i : Current number of decoded bits Q0*/ - UWord32 INTrc, /* i : Range coder state Q0*/ - Word16 *FBits /* i : Fractional finalization bits Q0*/ + Word16 Brc, /* i : Current number of decoded bits Q0*/ + UWord32 INTrc, /* i : Range coder state Q0*/ + Word16 *FBits /* i : Fractional finalization bits Q0*/ ); ivas_error DTFS_new_fx( @@ -3835,7 +3835,7 @@ gp_clips_fx.c /========================================================================================================*/ void init_gp_clip_fx( - Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ ); Word16 gp_clip_fx( @@ -3858,10 +3858,10 @@ void gp_clip_test_isf_fx( ); void gp_clip_test_gain_pit_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ - Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ + Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ ); Word16 Mode2_gp_clip_fx( @@ -3881,10 +3881,10 @@ Word16 Mode2_gp_clip_fx( ); void gp_clip_test_lsf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 m /* i : dimension of lsf Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 m /* i : dimension of lsf Q0*/ ); void gp_clip_test_lsf_ivas_fx( @@ -5067,7 +5067,7 @@ void fine_gain_pred_fx( ); void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *ord, /* i : Indices for energy order Q0 */ const Word16 num_sfm, /* i : Number of bands Q0 */ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ @@ -5503,10 +5503,10 @@ void Inverse_Transform( ); void recovernorm_fx( - const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ - Word16 *ynrm, /* o : recovered quantization indices Q0*/ - Word16 *normqlg2, /* o : recovered quantized norms Q0*/ - const Word16 nb_sfm /* i : number of SFMs Q0*/ + const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ + Word16 *ynrm, /* o : recovered quantization indices Q0*/ + Word16 *normqlg2, /* o : recovered quantized norms Q0*/ + const Word16 nb_sfm /* i : number of SFMs Q0*/ ); Word32 ar_div( Word32 num, Word32 denum ); @@ -5943,13 +5943,13 @@ void tcx_arith_scale_envelope( ); void tcx_arith_render_envelope( - const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i: number of spectral lines Q0*/ + const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i: number of spectral lines Q0*/ const Word16 L_spec, /* Q0 */ - const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o: shaped signal envelope Q16*/ + const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o: shaped signal envelope Q16*/ ); /* returns innovation gain Q16 */ @@ -6070,7 +6070,7 @@ void lsf_dec_fx( Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ); @@ -6206,21 +6206,21 @@ Word32 dotp_me_fx( void lsf_end_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 mode2_flag, /* Q0 */ - const Word16 coder_type_org, /* i : coding type Q0*/ - const Word16 bwidth, /* i : input signal bandwidth Q0*/ - const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ - Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ - Word16 *lpc_param, /* i : LPC parameters Q0*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *nb_indices, /* o : number of indices Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + const Word16 coder_type_org, /* i : coding type Q0*/ + const Word16 bwidth, /* i : input signal bandwidth Q0*/ + const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ + Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ + Word16 *lpc_param, /* i : LPC parameters Q0*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *nb_indices, /* o : number of indices Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ); void lsf_mid_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ + Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ - Word16 coder_type, /* i : Coder type Q0*/ - Word16 lsp_mid[] /* o : quantized LSPs Q15*/ + Word16 coder_type, /* i : Coder type Q0*/ + Word16 lsp_mid[] /* o : quantized LSPs Q15*/ ); void CNG_dec_fx( @@ -6235,7 +6235,7 @@ void CNG_dec_fx( void swb_CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn /* i : Q value of ACELP core synthesis */ @@ -6565,24 +6565,24 @@ void hf_synth_reset_fx( ); void hf_synth_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ const Word16 Q_exc, /* i : excitation scaling */ const Word16 Q_syn2 /* i : synthesis scaling */ ); void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ const Word16 Q_exc, /* i : excitation scaling */ const Word16 Q_syn2 /* i : synthesis scaling */ @@ -6602,17 +6602,17 @@ void hf_synth_amr_wb_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az : Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ - Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ + const Word16 *Aq, /* i : quantized Az : Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ + Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ - Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ - Word16 fmerit, /* i : classify parameter from FEC : Q14*/ + Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ + Word16 fmerit, /* i : classify parameter from FEC : Q14*/ const Word16 *hf_gain, /* i : decoded HF gain Q0*/ - const Word16 *voice_factors, /* i : voicing factors : Q15*/ - const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ - const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ - const Word16 *lsf_new, /* i : ISF vector : Q2*/ + const Word16 *voice_factors, /* i : voicing factors : Q15*/ + const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ + const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ + const Word16 *lsf_new, /* i : ISF vector : Q2*/ const Word16 Q_exc, /* i : exc scaling */ const Word16 Q_out /* i : Q_syn2-1 */ ); @@ -6722,17 +6722,17 @@ void bass_psfilter_init_fx( ); void bass_psfilter_fx( - BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ - const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ - Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ - const Word16 L_frame, /* i : length of the last frame Q0*/ - Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ - const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ - Word16 v_stab_fx, /* i : stability factor Q15*/ - Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ - const Word16 coder_type, /* i : coder_type Q0*/ + BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ + const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ + Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ + const Word16 L_frame, /* i : length of the last frame Q0*/ + Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ + const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ + Word16 v_stab_fx, /* i : stability factor Q15*/ + Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ + const Word16 coder_type, /* i : coder_type Q0*/ Word16 Q_syn, - Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ + Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ ); void addBassPostFilter_fx( @@ -6794,7 +6794,7 @@ void PulseResynchronization_fx( ); void decod_audio_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ + Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ const Word16 *Aq, /* i : LP filter coefficient Q12*/ Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ @@ -6803,7 +6803,7 @@ void decod_audio_fx( Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ @@ -6813,12 +6813,12 @@ void decod_audio_fx( void gsc_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *Q_exc ); @@ -6955,19 +6955,19 @@ Word16 gain_dequant_fx( Word16 *expg ); void AVQ_demuxdec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ - Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ - const Word16 Nsv, /* i : number of subvectors Q0*/ - Word16 nq[], /* i/o: AVQ nq index Q0*/ - Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ - Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ + Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ + const Word16 Nsv, /* i : number of subvectors Q0*/ + Word16 nq[], /* i/o: AVQ nq index Q0*/ + Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ + Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ ); void AVQ_dec_lpc( - Word16 *indx, /* input: index[] (4 bits per words) Q0*/ - Word16 *nvecq, /* output: vector quantized Q0*/ - Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ + Word16 *indx, /* input: index[] (4 bits per words) Q0*/ + Word16 *nvecq, /* output: vector quantized Q0*/ + Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ void re8_dec_fx( Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ @@ -6982,22 +6982,22 @@ void re8_decode_base_index_fx( Word16 *x ); void re8_k2y_fx( - const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ - const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ - Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ + const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ + const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ + Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ ); void re8_vor_fx( - const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ - Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ - Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ - Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ + const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ + Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ + Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ + Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ ); void re8_PPV_fx( - const Word32 x[], /* i : point in R^8 Q15 */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ + const Word32 x[], /* i : point in R^8 Q15 */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ ); void dec_pit_exc_fx( @@ -7010,7 +7010,7 @@ void dec_pit_exc_fx( Word16 *exc_fx, /* i/o: adapt. excitation exc */ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ const Word16 nb_subfr_fx, /* i : Number of subframe considered */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ ); @@ -7655,8 +7655,8 @@ void dequantize_norms_fx( void hdecnrm_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 numNorms, /* (i) number of norms Q0*/ - Word16 *index ); /* (o) indices of quantized norms Q0*/ + const Word16 numNorms, /* (i) number of norms Q0*/ + Word16 *index ); /* (o) indices of quantized norms Q0*/ Word16 decode_huff_context_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -7672,8 +7672,8 @@ void hdecnrm_context_fx( void hdecnrm_resize_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* (i) number of SFMs Q0*/ - Word16 *index /* (o) norm quantization index vector Q0*/ + const Word16 N, /* (i) number of SFMs Q0*/ + Word16 *index /* (o) norm quantization index vector Q0*/ ); void huff_dec_fx( @@ -7688,9 +7688,9 @@ void huff_dec_fx( ); void hdecnrm_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : number of norms Q0*/ - Word16 *index /* o : indices of quantized norms Q0*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : number of norms Q0*/ + Word16 *index /* o : indices of quantized norms Q0*/ ); void tcq_core_LR_dec_fx( @@ -7753,7 +7753,7 @@ void hq_pred_hb_bws_fx( const Word16 *ynrm, /* i : norm quantization index vector Q0*/ const Word16 length, /* i : frame length Q0*/ const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ - const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ + const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ ); void hq_hr_dec_fx( @@ -7765,7 +7765,7 @@ void hq_hr_dec_fx( Word16 *is_transient, /* o : transient flag Q0 */ Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ - const Word16 core_switching_flag /* i : Core switching flag Q1 */ + const Word16 core_switching_flag /* i : Core switching flag Q1 */ ); /* o : Consumed bits */ @@ -7820,7 +7820,7 @@ void bandwidth_switching_detect_ivas_fx( ); void bw_switching_pre_proc_fx( - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ Decoder_State *st_fx /* i/o: decoder state structure */ ); @@ -7841,7 +7841,7 @@ ivas_error core_switching_post_dec_fx( ivas_error core_switching_post_dec_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ @@ -8059,24 +8059,24 @@ void music_postfilt_init( ); void improv_amr_wb_gs_fx( - const Word16 clas, /* i : signal frame class Q0*/ - const Word16 coder_type, /* i : coder type Q0*/ - const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ - Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ - Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type, /* i : coder type Q0*/ + const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ + Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ - const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ + const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ const Word16 locattack, /* i : Flag for a detected attack Q0*/ Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ - const Word16 Q_exc2, /* i : Exponent of Exc2 */ - Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ + const Word16 Q_exc2, /* i : Exponent of Exc2 */ + Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ - const Word16 Q_syn, /* i : Synthesis scaling */ - const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ - const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ - const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ - const Word16 last_coder_type /* i : Last coder_type Q0*/ + const Word16 Q_syn, /* i : Synthesis scaling */ + const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ + const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ + const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ + const Word16 last_coder_type /* i : Last coder_type Q0*/ ); void decod_amr_wb_fx( @@ -8110,15 +8110,15 @@ void sc_vbr_dec_init( ); ivas_error ppp_quarter_decoder_fx( - DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ - Word16 prevCW_lag_fx, /* i : Previous lag */ - Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ - Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ - Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ - Word16 bfi, /* i : FER flag */ + DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ + Word16 prevCW_lag_fx, /* i : Previous lag */ + Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ + Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ + Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ + Word16 bfi, /* i : FER flag */ Word16 *S_fx, /* i : sine table, Q15 */ Word16 *C_fx, /* i : cosine table, Q15 */ - DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ + DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ Decoder_State *st_fx ); void open_decoder_LPD_fx( @@ -8128,10 +8128,10 @@ void open_decoder_LPD_fx( ); void open_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ @@ -8201,49 +8201,49 @@ void stat_noise_uv_dec_fx( ); void stat_noise_uv_mod_fx( - const Word16 coder_type, /* i : Coder type */ + const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q0 */ const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ - Word16 *exc2, /* i/o: excitation buffer Q_exc */ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ + Word16 *exc2, /* i/o: excitation buffer Q_exc */ Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q15 */ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : input bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q15 */ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : input bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ); void stat_noise_uv_mod_ivas_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q=0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ - Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q=0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ + Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q=15*/ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q=15*/ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : i bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : i bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ); Word16 FEC_SinOnset_fx( @@ -8274,37 +8274,37 @@ Word16 FEC_synchro_exc_fx( ); void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ Word16 *gain_buf ); void gaus_dec_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* o : unvoiced excitation Q12 */ - Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ - Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ - Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ - Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ - Word16 *voice_fac, /* o : estimated voicing factor Q15 */ - Word16 *gain_pit, /* o : pitch gain Q14 */ - Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ - Word16 *exc, /* o : excitation signal frame */ - Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ - Word16 *exc2, /* o : Scaled excitation signal frame */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* o : unvoiced excitation Q12 */ + Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ + Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ + Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ + Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ + Word16 *voice_fac, /* o : estimated voicing factor Q15 */ + Word16 *gain_pit, /* o : pitch gain Q14 */ + Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ + Word16 *exc, /* o : excitation signal frame */ + Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ + Word16 *exc2, /* o : Scaled excitation signal frame */ Word16 *bwe_exc_fx, - Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ - Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ + Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ + Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ ); void gaus_L2_dec( @@ -8440,13 +8440,13 @@ void mode_switch_decoder_LPD_fx( ); void mode_switch_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ - const Word16 frame_size_index, /* i : index determining the frame size Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ + const Word16 frame_size_index, /* i : index determining the frame size Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ Word16 *Q_syn_Overl_TDAC, Word16 *Q_fer_samples, Word16 *Q_syn_Overl, @@ -8487,12 +8487,12 @@ Word16 lsf_bctcvq_decprm( ); Word16 D_lsf_tcxlpc( - const Word16 indices[], /* i : VQ indices Q0*/ - Word16 lsf_q[], /* o : quantized LSF Q1*/ - Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk, /* i : codebook selector Q0*/ - Word16 mem_MA[] /* i : MA memory Q1*/ + const Word16 indices[], /* i : VQ indices Q0*/ + Word16 lsf_q[], /* o : quantized LSF Q1*/ + Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk, /* i : codebook selector Q0*/ + Word16 mem_MA[] /* i : MA memory Q1*/ ); Word16 dec_lsf_tcxlpc( @@ -8628,7 +8628,7 @@ void ConfigureContextHm( ); Word16 CountIndexBits( - Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ + Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ Word16 PeriodicityIndex /* Q0 */ ); @@ -8874,25 +8874,25 @@ void vlpc_2st_dec( Word32 sr_core ); void lsf_weight_2st( - const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ - Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ const Word16 mode /* input: operational mode Q0 */ ); /* Returns: index of next coefficient */ Word16 get_next_coeff_mapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ); /* Returns: index of next coefficient */ Word16 get_next_coeff_unmapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ); Word16 update_mixed_context( @@ -8939,7 +8939,7 @@ void reconfig_decoder_LPD_fx( ); void reconfig_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ + Decoder_State *st, /* i/o: decoder state structure */ const Word16 bits_frame, /* i : bit budget Q0*/ const Word16 bwidth, /* i : audio bandwidth Q0*/ const Word32 total_brate, /* i : total bitrate Q0*/ @@ -9229,15 +9229,15 @@ void fft_cldfb_fx( ); void stereo_dft_dec_analyze_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 *input_fx, /* i : input signal q*/ - Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ - const Word16 chan, /* i : channel number Q0*/ - const Word16 input_frame, /* i : input frame size Q0*/ - const Word16 output_frame, /* i : output frame size Q0*/ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ - const Word16 k_offset, /* i : offset of DFT Q0*/ - const Word16 delay, /* i : delay in samples FOR input signal Q0*/ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 *input_fx, /* i : input signal q*/ + Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ + const Word16 chan, /* i : channel number Q0*/ + const Word16 input_frame, /* i : input frame size Q0*/ + const Word16 output_frame, /* i : output frame size Q0*/ + const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ + const Word16 k_offset, /* i : offset of DFT Q0*/ + const Word16 delay, /* i : delay in samples FOR input signal Q0*/ Word16 *q, Word16 *q_DFT ); @@ -9628,10 +9628,10 @@ void tcx_scalar_quantization_ivas_fx( Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( Word16 *x, /* Spectral coefficients Q0*/ - const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ + const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ Word16 *lastnz_out, /* Q0 */ Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ - const Word16 target, /* Target bits Q0*/ + const Word16 target, /* Target bits Q0*/ Word16 *stop, /* Q0 */ Word16 mode, /* Q0 */ CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ @@ -10295,7 +10295,7 @@ Word16 ceil_log_2( UWord64 val ); Word32 imax_pos_fx( - const Word32 *y /* i : Input vector for peak interpolation Qx*/ + const Word32 *y /* i : Input vector for peak interpolation Qx*/ ); void msvq_enc_ivas_fx( @@ -10914,16 +10914,16 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( ); void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ + const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ + const Word16 coder_type, /* i : type of coder Q0*/ + Word16 clas, /* i : signal clas for current frame Q0*/ + const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ + const Word16 *res, /* i : LP residual signal frame Qx*/ + Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ + const Word16 L_frame, /* i : Frame length Q0*/ + const Word32 total_brate, /* i : total codec bitrate Q0*/ const Word16 Q_synth /* i : input scaling */ ); @@ -11246,22 +11246,22 @@ ivas_error init_encoder_fx( ivas_error acelp_core_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ Word16 Q_new ); void flip_and_downmix_generic_fx32( @@ -11400,15 +11400,15 @@ void tcx_hm_decode( ); void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ ); void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ ); void writeLPCparam( diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index 98ca8c4ab..4c8b3fa8a 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -52,8 +52,8 @@ Word16 shrtCDivSignedApprox( } static void nearProjQ15_fx( - const Word16 x, /* i : input coefficient Q15*/ - Word16 *result /* o : projection Q15*/ + const Word16 x, /* i : input coefficient Q15*/ + Word16 *result /* o : projection Q15*/ ) { const Word16 a[4] = { 14967, -25518, 3415, 32351 }; /* Q15 */ @@ -81,9 +81,9 @@ static void nearProjQ15_fx( * *-------------------------------------------------------------------*/ void obtainEnergyQuantizerDensity_fx( - const Word16 L, /* i : left vector energy Q0*/ - const Word16 R, /* i : right vector energy Q0*/ - Word16 *Density /* o : quantizer density Q0*/ + const Word16 L, /* i : left vector energy Q0*/ + const Word16 R, /* i : right vector energy Q0*/ + Word16 *Density /* o : quantizer density Q0*/ ) { Word16 Rnrg, den, n; @@ -117,8 +117,8 @@ void obtainEnergyQuantizerDensity_fx( * *-------------------------------------------------------------------*/ void dsDirac2Dirac_fx( - const Word16 dsDiracIndex, /* i : input index Q0*/ - Word16 *diracs /* o : number of diracs Q0*/ + const Word16 dsDiracIndex, /* i : input index Q0*/ + Word16 *diracs /* o : number of diracs Q0*/ ) { *diracs = dsDiracsTab[dsDiracIndex]; /* Q0 */ @@ -127,11 +127,11 @@ void dsDirac2Dirac_fx( } void dsDiracPerQuanta_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ - const Word16 dsm, /* i : Conservative rounding flag Q0*/ - const unsigned char *const *frQuanta, /* i : Quanta lookup table */ - Word16 *DsIdx /* o : Lookup table index Q0*/ + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ + const Word16 dsm, /* i : Conservative rounding flag Q0*/ + const unsigned char *const *frQuanta, /* i : Quanta lookup table */ + Word16 *DsIdx /* o : Lookup table index Q0*/ ) { const unsigned char *sv; @@ -241,7 +241,7 @@ void conservativeL1Norm_fx( if ( Mprime < 0 ) { - *Qspare = add( Qavail, QUANTAQ3OFFSET ); /* single op Q0*/ + *Qspare = add( Qavail, QUANTAQ3OFFSET ); /* single op Q0*/ move16(); } dsDirac2Dirac_fx( add( Mprime, 1 ), Dvec ); @@ -280,7 +280,7 @@ void bandBitsAdjustment_fx( IF( LT_16( D, Nbands ) ) { L_tmp = L_deposit_l( sub( Breserv, Bff ) ); /* Q0 */ - Btemp = extract_l( intLimCDivSigned_fx( L_tmp, s_min( D, 3 ) ) ); /* result always fits in Word16 Q0*/ + Btemp = extract_l( intLimCDivSigned_fx( L_tmp, s_min( D, 3 ) ) ); /* result always fits in Word16 Q0*/ *Breservplus = add( Bband, Breserv ); /* Q0 */ move16(); } @@ -329,9 +329,9 @@ static Word16 Ratio_base2Q11_fx( /* o : Q11 */ } static void Ratio_rQ3_fx( - Word16 opp, /* i : opposite Q15*/ - Word16 near, /* i : near Q15*/ - Word16 *result /* o : ratio Q3*/ + Word16 opp, /* i : opposite Q15*/ + Word16 near, /* i : near Q15*/ + Word16 *result /* o : ratio Q3*/ ) { Word16 tmp; @@ -344,11 +344,11 @@ static void Ratio_rQ3_fx( void densityAngle2RmsProjDec_fx( - const Word16 D, /* i : density Q0*/ - const Word16 indexphi, /* i : decoded index from AR dec Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ + const Word16 D, /* i : density Q0*/ + const Word16 indexphi, /* i : decoded index from AR dec Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ ) { Word16 phiQ14q; @@ -385,12 +385,12 @@ void densityAngle2RmsProjDec_fx( } void densityAngle2RmsProjEnc_fx( - const Word16 D, /* i : density Q0*/ - const Word16 phiQ14uq, /* i : angle Q14*/ - Word16 *indexphi, /* o : index Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ + const Word16 D, /* i : density Q0*/ + const Word16 phiQ14uq, /* i : angle Q14*/ + Word16 *indexphi, /* o : index Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ ) { *indexphi = mult_r( shl( D, 1 ), phiQ14uq ); /* Q0 */ @@ -435,14 +435,14 @@ void NearOppSplitAdjustment_fx( move16(); IF( GT_16( Nhead, 1 ) ) { - qavg = extract_h( L_shl( intLimCDivSigned_fx( L_deposit_l( qboth ), Np ), 16 ) ); /* qboth may be negative Q0*/ + qavg = extract_h( L_shl( intLimCDivSigned_fx( L_deposit_l( qboth ), Np ), 16 ) ); /* qboth may be negative Q0*/ dsDiracPerQuanta_fx( Ntail, qavg, FlagCons, hBitsN, &Midx ); QuantaPerDsDirac_fx( Nhead, Midx, hBitsN, &qmin ); qskew = sub( qavg, qmin ); /* Q0 */ qskew = s_max( 0, qskew ); /* Q0 */ } /* end of skew calc code*/ - QIa = add( extract_l( intLimCDivPos_fx( (UWord32) L_deposit_l( Nopp ), Nnear ) ), 1 ); /* always positive Word16 out Q0*/ + QIa = add( extract_l( intLimCDivPos_fx( (UWord32) L_deposit_l( Nopp ), Nnear ) ), 1 ); /* always positive Word16 out Q0*/ L_qnum = L_sub( L_deposit_l( sub( sub( add( qband, qzero ), qac ), qskew ) ), L_mult0( Nopp, oppRQ3 ) ); /* Q0 */ L_QIb = L_deposit_l( 0 ); @@ -452,7 +452,7 @@ void NearOppSplitAdjustment_fx( } *qnear = qboth; /* Q3 */ move16(); - QIb = extract_h( L_shl_sat( L_QIb, 16 ) ); /* may saturate Q0*/ + QIb = extract_h( L_shl_sat( L_QIb, 16 ) ); /* may saturate Q0*/ if ( LE_16( QIb, qboth ) ) { *qnear = QIb; /* Q0 */ @@ -506,7 +506,7 @@ void apply_gain_fx( * Fine gain quantization *--------------------------------------------------------------------------*/ void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *ord, /* i : Indices for energy order Q0 */ const Word16 num_sfm, /* i : Number of bands Q0 */ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ @@ -572,9 +572,9 @@ void fine_gain_quant_fx( *-------------------------------------------------------------------*/ void srt_vec_ind16_fx( - const Word16 *linear, /* linear input Q3*/ - Word16 *srt, /* sorted output Q3*/ - Word16 *I, /* index for sorted output Q0*/ + const Word16 *linear, /* linear input Q3*/ + Word16 *srt, /* sorted output Q3*/ + Word16 *I, /* index for sorted output Q0*/ Word16 length /* Q0 */ ) { diff --git a/lib_com/range_com_fx.c b/lib_com/range_com_fx.c index b84ec6c26..23eeaea17 100644 --- a/lib_com/range_com_fx.c +++ b/lib_com/range_com_fx.c @@ -13,9 +13,9 @@ * Get number of bits needed to finalize range coder *-------------------------------------------------------------------*/ -Word16 rc_get_bits2_fx( /* o: Number of bits needed Q0*/ - const Word16 N, /* i: Number of bits currently used Q0*/ - const UWord32 range /* i: Range of range coder Q0*/ +Word16 rc_get_bits2_fx( /* o: Number of bits needed Q0*/ + const Word16 N, /* i: Number of bits currently used Q0*/ + const UWord32 range /* i: Range of range coder Q0*/ ) { return add( add( N, 2 ), norm_ul( range ) ); @@ -28,9 +28,9 @@ Word16 rc_get_bits2_fx( /* o: Number of bits needed Q0*/ *-------------------------------------------------------------------*/ void rangeCoderFinalizationFBits_fx( - Word16 Brc, /* i : Current number of decoded bits Q0*/ - UWord32 INTrc, /* i : Range coder state Q0*/ - Word16 *FBits /* i : Fractional finalization bits Q0*/ + Word16 Brc, /* i : Current number of decoded bits Q0*/ + UWord32 INTrc, /* i : Range coder state Q0*/ + Word16 *FBits /* i : Fractional finalization bits Q0*/ ) { Word32 L_Bq15; diff --git a/lib_com/re8_ppv_fx.c b/lib_com/re8_ppv_fx.c index c643bf1ea..9a09e02d1 100644 --- a/lib_com/re8_ppv_fx.c +++ b/lib_com/re8_ppv_fx.c @@ -24,8 +24,8 @@ static Word32 compute_error_2D8_fx( const Word32 x[], const Word16 y[] ); * --------------------------------------------------------------*/ void re8_PPV_fx( - const Word32 x[], /* i : point in R^8 Q15 */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0*/ + const Word32 x[], /* i : point in R^8 Q15 */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0*/ ) { Word16 i, y0[8]; @@ -83,8 +83,8 @@ void re8_PPV_fx( --------------------------------------------------------------*/ static void nearest_neighbor_2D8_fx( - const Word32 x[], /* i : point in R^8 Q15*/ - Word16 y[] /* o : point in 2D8 (8-dimensional integer vector) Q0*/ + const Word32 x[], /* i : point in R^8 Q15*/ + Word16 y[] /* o : point in 2D8 (8-dimensional integer vector) Q0*/ ) { Word16 i, j; @@ -164,9 +164,9 @@ static void nearest_neighbor_2D8_fx( * (quantized) point in 2D8. --------------------------------------------------------------*/ -static Word32 compute_error_2D8_fx( /* o : mean squared error Q15*/ - const Word32 x[], /* i : input vector Q15*/ - const Word16 y[] /* i : point in 2D8 (8-dimensional integer vector) Q0*/ +static Word32 compute_error_2D8_fx( /* o : mean squared error Q15*/ + const Word32 x[], /* i : input vector Q15*/ + const Word16 y[] /* i : point in 2D8 (8-dimensional integer vector) Q0*/ ) { Word16 i, hi, lo; diff --git a/lib_com/re8_util_fx.c b/lib_com/re8_util_fx.c index de70279eb..d18a9577d 100644 --- a/lib_com/re8_util_fx.c +++ b/lib_com/re8_util_fx.c @@ -23,11 +23,11 @@ static void re8_coord_fx( const Word16 *y, Word16 *k ); * MULTI-RATE RE8 INDEXING BY VORONOI EXTENSION *----------------------------------------------------------------*/ void re8_vor_fx( - const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ - Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ - Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ - Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ + const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ + Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ + Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ + Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ ) { Word16 i, r, iter, ka_tmp, n_tmp, mask; @@ -99,7 +99,7 @@ void re8_vor_fx( /*------------------------------------------------------------* * compute m and the mask needed for modulo m (for Voronoi coding) *------------------------------------------------------------*/ - mask = sub( shl( 1, r ), 1 ); /* 0x0..011...1 Q0*/ + mask = sub( shl( 1, r ), 1 ); /* 0x0..011...1 Q0*/ /*------------------------------------------------------------* * find the minimal value of r (or equivalently of m) in 2 iterations @@ -187,9 +187,9 @@ void re8_vor_fx( * VORONOI INDEXING (INDEX DECODING) k -> y -------------------------------------------------------------------------*/ void re8_k2y_fx( - const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ - const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ - Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ + const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ + const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ + Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ ) { Word16 i, v[8], *ptr1, *ptr2, m_tmp, mm; @@ -318,8 +318,8 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer i * only the id's related to the shell of number s are checked *---------------------------------------------------------------*/ - nb = Da_nb[s - 1]; /* get the number of absolute leaders used on the shell of number s Q0*/ - pos = Da_pos[s - 1]; /* get the position of the first absolute leader of shell s in Da_id Q0*/ + nb = Da_nb[s - 1]; /* get the number of absolute leaders used on the shell of number s Q0*/ + pos = Da_pos[s - 1]; /* get the position of the first absolute leader of shell s in Da_id Q0*/ move16(); move16(); @@ -350,8 +350,8 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer i -----------------------------------------------------------------------*/ static void re8_coord_fx( - const Word16 *y, /* i : 8-dimensional point y[0..7] in RE8 Q0*/ - Word16 *k /* o : coordinates k[0..7] Q0*/ + const Word16 *y, /* i : 8-dimensional point y[0..7] in RE8 Q0*/ + Word16 *k /* o : coordinates k[0..7] Q0*/ ) { Word16 i, tmp, sum; diff --git a/lib_com/recovernorm_fx.c b/lib_com/recovernorm_fx.c index 2f9859758..695ad424f 100644 --- a/lib_com/recovernorm_fx.c +++ b/lib_com/recovernorm_fx.c @@ -14,10 +14,10 @@ *--------------------------------------------------------------------------*/ void recovernorm_fx( - const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ - Word16 *ynrm, /* o : recovered quantization indices Q0*/ - Word16 *normqlg2, /* o : recovered quantized norms Q0*/ - const Word16 nb_sfm /* i : number of SFMs Q0*/ + const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ + Word16 *ynrm, /* o : recovered quantization indices Q0*/ + Word16 *normqlg2, /* o : recovered quantized norms Q0*/ + const Word16 nb_sfm /* i : number of SFMs Q0*/ ) { Word16 i, j, k; diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index ecfb672b0..b7923a3ec 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -176,25 +176,25 @@ void Residu3_fx( } /*==========================================================================*/ -/* FUNCTION : void calc_residu() */ +/* FUNCTION : void calc_residu() */ /*--------------------------------------------------------------------------*/ -/* PURPOSE : Compute the LP residual by filtering the input through */ -/* A(z) in all subframes */ +/* PURPOSE : Compute the LP residual by filtering the input through */ +/* A(z) in all subframes */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* Word16 *speech i : weighted speech signal Qx */ -/* Word16 L_frame i : order of LP filter Q0 */ +/* Word16 L_frame i : order of LP filter Q0 */ /* Word16 *p_Aq i : quantized LP filter coefficients Q12 */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* Word16 *res o : residual signal Qx+1 */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*==========================================================================*/ void calc_residu_fx( diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 829cf266a..75950a7a3 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -50,14 +50,14 @@ typedef struct { - Word32 fin_fx; /* input frequency Q0 */ - Word32 fout_fx; /* output frequency Q0 */ - Word16 fac_num_fx; /* numerator of resampling factor Q0 */ - Word16 fac_den_fx; /* denominator of resampling factor Q0 */ - Word16 lg_out; /* denominator of resampling factor Q15 */ - const Word16 *filter_fx; /* resampling filter coefficients Q14 */ - Word16 filt_len_fx; /* number of filter coeff. Q0 */ - UWord16 flags_fx; /* flags from config. table Q0 */ + Word32 fin_fx; /* input frequency Q0 */ + Word32 fout_fx; /* output frequency Q0 */ + Word16 fac_num_fx; /* numerator of resampling factor Q0 */ + Word16 fac_den_fx; /* denominator of resampling factor Q0 */ + Word16 lg_out; /* denominator of resampling factor Q15 */ + const Word16 *filter_fx; /* resampling filter coefficients Q14 */ + Word16 filt_len_fx; /* number of filter coeff. Q0 */ + UWord16 flags_fx; /* flags from config. table Q0 */ } Resampling_cfg; typedef struct @@ -109,16 +109,16 @@ extern const Word16 mid_LSF_bits_tbl[]; /* Bit allocation table for mid-frame IS extern const Word16 Es_pred_bits_tbl[]; /* Bit allocation table for scaled innovation energy prediction Q0*/ extern const Word16 gain_bits_tbl[]; /* Bit allocation table for gain quantizer Q0*/ -extern const Word16 ACB_bits_tbl[]; /* Bit allocation table for adaptive codebook (pitch) Q0*/ +extern const Word16 ACB_bits_tbl[]; /* Bit allocation table for adaptive codebook (pitch) Q0*/ extern const Word16 FCB_bits_tbl[]; /* Bit allocation table for algebraic (fixed) codebook (innovation) Q0*/ -extern const Word16 reserved_bits_tbl[]; /* Bit allocation table for reseved bits Q0*/ +extern const Word16 reserved_bits_tbl[]; /* Bit allocation table for reseved bits Q0*/ -extern const Word16 ACB_bits_16kHz_tbl[]; /* Bit allocation table for adaptive codebook (pitch) @16kHz Q0*/ +extern const Word16 ACB_bits_16kHz_tbl[]; /* Bit allocation table for adaptive codebook (pitch) @16kHz Q0*/ extern const Word16 FCB_bits_16kHz_tbl[]; /* Bit allocation table for algebraic (fixed) codebook (innovation) @16kHz Q0*/ -extern const Word16 gain_bits_16kHz_tbl[]; /* Bit allocation table for gain quantizer @16kHz Q0*/ -extern const Word16 AVQ_bits_16kHz_tbl[]; /* Bit allocation table for AVQ bits @16kHz ACELP, active segments Q0*/ +extern const Word16 gain_bits_16kHz_tbl[]; /* Bit allocation table for gain quantizer @16kHz Q0*/ +extern const Word16 AVQ_bits_16kHz_tbl[]; /* Bit allocation table for AVQ bits @16kHz ACELP, active segments Q0*/ -extern const UWord32 pulsestostates[17][9]; /* Number of states for any combination of pulses in any combination of vector length Q0*/ +extern const UWord32 pulsestostates[17][9]; /* Number of states for any combination of pulses in any combination of vector length Q0*/ extern const UWord8 ACELP_NRG_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX + RF_MODE_MAX]; // Q0 extern const UWord8 ACELP_NRG_BITS[3]; // Q0 @@ -161,7 +161,7 @@ extern const Word16 h_high_fx[5]; // Q15 extern const Word16 sincos_t_fx[161]; // Q15 extern const Word16 sincos_t_ext_fx[]; // Q15 extern const Word32 crit_bands_fx[]; -extern const Word16 fft256_read_indexes[]; /* FFT Q0*/ +extern const Word16 fft256_read_indexes[]; /* FFT Q0*/ extern const Word16 inter4_2_fx[]; extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*Q15*/ @@ -171,7 +171,7 @@ extern const Word16 Assym_window_W16fx[]; // Q15 extern const Word16 assym_window_16k_fx[]; // Q15 extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15 extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15 -extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/ +extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/ extern const Word16 wind_sss_fx[LEN_WIN_SSS]; // Q15 /*window for modify_sf ana*/ extern const Word16 filter5_39s320_120_fx[]; // Q15 @@ -346,11 +346,11 @@ extern const Word16 dico21_isf_36b_fx[]; /* ISF codebook - 36b, 2nd stage, 1st s extern const Word16 dico22_isf_36b_fx[]; /* ISF codebook - 36b, 2nd stage, 2nd split (only in AMR-WB IO mode) Qlog2(2.56)*/ extern const Word16 dico23_isf_36b_fx[]; /* ISF codebook - 36b, 2nd stage, 3rd split (only in AMR-WB IO mode) Qlog2(2.56)*/ -extern const Word16 dico1_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 1st split Qlog2(2.56)*/ -extern const Word16 dico2_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 2nd spilt Qlog2(2.56)*/ -extern const Word16 dico3_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 3rd spilt Qlog2(2.56)*/ -extern const Word16 dico4_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 4th spilt Qlog2(2.56)*/ -extern const Word16 dico5_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 5th spilt Qlog2(2.56)*/ +extern const Word16 dico1_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 1st split Qlog2(2.56)*/ +extern const Word16 dico2_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 2nd spilt Qlog2(2.56)*/ +extern const Word16 dico3_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 3rd spilt Qlog2(2.56)*/ +extern const Word16 dico4_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 4th spilt Qlog2(2.56)*/ +extern const Word16 dico5_ns_28b_fx[]; /*Qlog2(2.56)*/ /* ISF codebook for SID frames - 28b, 5th spilt Qlog2(2.56)*/ /*----------------------------------------------------------------------------------* * LSF quantization - MSVQ tables @@ -433,7 +433,7 @@ extern const UWord32 table_no_cv[]; // Q0 extern const Word32 table_no_cv_fx[]; // Q0 extern const Word16 pl_par[]; // Q0 -// extern const Word16 pl_par_fx[]; /* 1 if even number of signs */ +// extern const Word16 pl_par_fx[]; /* 1 if even number of signs */ extern const Word16 *const Quantizers_p_fx[]; // Qlog2(2.56) extern const Word16 *const Quantizers_fx[]; // Qlog2(2.56) @@ -577,8 +577,8 @@ extern const Word16 Da_nq[]; /* Codebook number for each absolute leader */ * SWB TBE tables *------------------------------------------------------------------------------*/ -extern const Word16 skip_bands_SWB_TBE[]; /* bands for SWB TBE quantisation Q0*/ -extern const Word16 skip_bands_WB_TBE[]; /* bands for WB TBE quantisation Q0*/ +extern const Word16 skip_bands_SWB_TBE[]; /* bands for SWB TBE quantisation Q0*/ +extern const Word16 skip_bands_WB_TBE[]; /* bands for WB TBE quantisation Q0*/ extern const Word16 interpol_frac_shb[NB_SUBFR * 2]; // Q15 extern const Word16 interpol_frac_shb[NB_SUBFR * 2]; // Q15 @@ -617,11 +617,11 @@ extern const Word16 full_band_bpf_1_fx[][5]; /*Q13*/ extern const Word16 full_band_bpf_2_fx[][5]; /*Q13*/ extern const Word16 full_band_bpf_3_fx[][5]; /*Q13*/ extern const Word16 *const lsf_q_cb_fx[]; // Q15 -extern const Word16 lsf_q_cb_size[]; /* Size of each element of the above Q0*/ -extern const Word16 lsf_q_num_bits[]; /* Size of each element of the above, in bits Q0*/ +extern const Word16 lsf_q_cb_size[]; /* Size of each element of the above Q0*/ +extern const Word16 lsf_q_num_bits[]; /* Size of each element of the above, in bits Q0*/ extern const Word16 mirror_point_q_cb_fx[]; // Q15 extern const Word16 lsf_grid_fx[4][5]; // Q15 -extern const Word16 grid_smoothing_fx[]; /* LSF mirroring smoothing table Q15*/ +extern const Word16 grid_smoothing_fx[]; /* LSF mirroring smoothing table Q15*/ extern const Word16 overlap_coefs_fx[NSV_OVERLAP * WIDTH_BAND]; /* in Q15 */ extern const Word16 overlap_coefs_48kHz_fx[NSV_OVERLAP * WIDTH_BAND]; /* in Q15 */ @@ -1522,7 +1522,7 @@ extern const Word32 pow_tilt_32k[64]; /* Q23 */ extern const Word16 num_nelp_lp_fx[NELP_LP_ORDER + 1]; // Q13 extern const Word16 den_nelp_lp_fx[NELP_LP_ORDER + 1]; // Q13 -extern const Word16 fir_6k_8k_fx[]; /* HF BWE - band-pass filter coefficients Q15*/ +extern const Word16 fir_6k_8k_fx[]; /* HF BWE - band-pass filter coefficients Q15*/ extern const Word16 pwf78_fx[17]; // Q15 enum FUNC_GAIN_ENC @@ -1537,7 +1537,7 @@ enum FUNC_GAIN_ENC extern const Word16 hamcos_window_fx[]; // Q15 extern const Word16 CNG_burst_att_fx[6][8]; // Q15 extern const Word16 lpc_weights_fx[]; // Q15 -extern const Word16 SHBCB_SubGain5bit_12_fx[]; /* 5 bit Quantizer table for SHB gain shapes Q12*/ +extern const Word16 SHBCB_SubGain5bit_12_fx[]; /* 5 bit Quantizer table for SHB gain shapes Q12*/ extern const Word16 E_ROM_inter4_1_fx[PIT_UP_SAMP * L_INTERPOL1 + 1]; // Q14 extern const Word16 E_ROM_inter6_1_fx[PIT_UP_SAMP6 * L_INTERPOL1 + 1]; // Q14 extern const Word16 kLog2TableFrac_x[256]; // Q8 diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c index 51d65d917..2102ae86f 100644 --- a/lib_com/rom_com_fx.c +++ b/lib_com/rom_com_fx.c @@ -50,13 +50,13 @@ * Table of bitrates *----------------------------------------------------------------------------------*/ -const Word32 brate_tbl[SIZE_BRATE_TBL] = // Q0 +const Word32 brate_tbl[SIZE_BRATE_TBL] = // Q0 { ACELP_7k20, ACELP_8k00, ACELP_9k60, ACELP_13k20, ACELP_16k40, ACELP_24k40, ACELP_32k, ACELP_48k, ACELP_64k, HQ_96k, HQ_128k }; -const Word32 brate_intermed_tbl[SIZE_BRATE_INTERMED_TBL] = // Q0 +const Word32 brate_intermed_tbl[SIZE_BRATE_INTERMED_TBL] = // Q0 { ACELP_5k00, ACELP_6k15, ACELP_7k20, ACELP_8k00, ACELP_9k60, ACELP_11k60, ACELP_12k15, ACELP_12k85, ACELP_13k20, ACELP_14k80, ACELP_16k40, ACELP_22k60, ACELP_24k40, ACELP_29k00, ACELP_29k20, ACELP_30k20, @@ -109,7 +109,7 @@ const FrameSizeParams FrameSizeConfig[FRAME_SIZE_NB] = * - the other values represent indices created by combining different parameters into a single value through the macro SIG2IND() *----------------------------------------------------------------------------------*/ -const Word32 acelp_sig_tbl[MAX_ACELP_SIG] = // Q0 +const Word32 acelp_sig_tbl[MAX_ACELP_SIG] = // Q0 { /* GENERIC UNVOICED VOICED TRANSITION AUDIO INACTIVE */ ACELP_7k20, 4, @@ -160,7 +160,7 @@ const Word32 acelp_sig_tbl[MAX_ACELP_SIG] = // Q0 *----------------------------------------------------------------------------------*/ /* bit allocation table for end-frame LSF quantizer */ -const Word16 LSF_bits_tbl[] = // Q0 +const Word16 LSF_bits_tbl[] = // Q0 { /* IC UC VC GC TC AC */ 22, 31, 24, 29, 24, 22, /* ACELP_5k00 */ @@ -186,7 +186,7 @@ const Word16 LSF_bits_tbl[] = // Q0 }; /* bit allocation table for mid-frame LSF quantizer */ -const Word16 mid_LSF_bits_tbl[] = // Q0 +const Word16 mid_LSF_bits_tbl[] = // Q0 { /* IC UC VC GC TC AC */ 2, 5, 1, 2, 2, 2, /* ACELP_5k00 */ @@ -213,7 +213,7 @@ const Word16 mid_LSF_bits_tbl[] = // Q0 /* bit allocation table for scaled innovation energy prediction */ -const Word16 Es_pred_bits_tbl[] = // Q0 +const Word16 Es_pred_bits_tbl[] = // Q0 { /* UC VC GC TC */ 0, 0, 0, 4, /* ACELP_5k00 */ @@ -240,7 +240,7 @@ const Word16 Es_pred_bits_tbl[] = // Q0 /* bit allocation table for gain quantizer (ACELP@12.8kHz) */ /* the 4 values allocated correspond to 4 subframes */ -const Word16 gain_bits_tbl[] = // Q0 +const Word16 gain_bits_tbl[] = // Q0 { /* UC VC GC TC0_0 TC0_64 TC0_128 TC0_192 TC64 TC128 TC192 */ 6,6,6,6, 7,6,6,6, 7,6,6,6, 5,5,5,5, 5,5,6,5, 5,3,6,6, 5,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,10, /* ACELP_5k00 */ @@ -261,7 +261,7 @@ const Word16 gain_bits_tbl[] = // Q0 /* bit allocation table for gain gain quantizer (ACELP@16kHz) */ /* the 5 values allocated correspond to 5 subframes */ -const Word16 gain_bits_16kHz_tbl[] = // Q0 +const Word16 gain_bits_16kHz_tbl[] = // Q0 { /* IC GC TC0 TC64 TC128 TC192 TC256 */ 0,0,0,0,0, 6,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0, 0, /* ACELP_8k00 */ @@ -279,7 +279,7 @@ const Word16 gain_bits_16kHz_tbl[] = // Q0 /* bit allocation table for adaptive codebook (pitch) (ACELP@12.8kHz) */ /* the 4 values correspond to 4 subframes */ -const Word16 ACB_bits_tbl[] = // Q0 +const Word16 ACB_bits_tbl[] = // Q0 { /* UC VC GC TC0_0 TC0_64 TC0_128 TC0_192 TC64 TC128 TC192 */ 0,0,0,0, 9,5,5,5, 8,5, 8,5, 6,5,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,8, /* ACELP_5k00 */ @@ -299,7 +299,7 @@ const Word16 ACB_bits_tbl[] = // Q0 /* bit allocation table for adaptive codebook (pitch) (ACELP@16kHz) */ /* the 5 values correspond to 5 subframes */ -const Word16 ACB_bits_16kHz_tbl[] = // Q0 +const Word16 ACB_bits_16kHz_tbl[] = // Q0 { /* IC GC TC0 TC64 TC128 TC192 TC256 */ 0,0, 0,0,0, 9,0, 0,0,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0,0, 0,0, 0,0,0,0, 0, /* ACELP_8k00 */ @@ -317,7 +317,7 @@ const Word16 ACB_bits_16kHz_tbl[] = // Q0 /* bit allocation table for algebraic (fixed) codebook (innovation) (ACELP@12.8kHz) */ /* the 4 values correspond to 4 subframes */ -const Word16 FCB_bits_tbl[] = // Q0 +const Word16 FCB_bits_tbl[] = // Q0 { /* UC VC GC TC0_0 TC0_64 TC0_128 TC0_192 TC64 TC128 TC192 */ 8,8,8,8, 12,12,12,20, 7, 7, 0, 7, 12, 7,12,12, 12,12, 7,12, 12,12,12,12, 12,12,20,12, 12,12,12,12, 12,12,12,12, 12,12,12,20, /* ACELP_5k00 */ @@ -337,7 +337,7 @@ const Word16 FCB_bits_tbl[] = // Q0 /* bit allocation table for algebraic (fixed) codebook (innovation) (ACELP@16kHz) */ /* the 5 values correspond to 5 subframes */ -const Word16 FCB_bits_16kHz_tbl[] = // Q0 +const Word16 FCB_bits_16kHz_tbl[] = // Q0 { /* IC GC TC0 TC64 TC128 TC192 TC256 */ 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_8k00 */ @@ -354,7 +354,7 @@ const Word16 FCB_bits_16kHz_tbl[] = // Q0 }; /* bit allocation table for AVQ bits in active segments (ACELP@16kHz) */ -const Word16 AVQ_bits_16kHz_tbl[] = // Q0 +const Word16 AVQ_bits_16kHz_tbl[] = // Q0 { /* IC GC TC0 TC64 TC128 TC192 TC256 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_8k00 */ @@ -371,7 +371,7 @@ const Word16 AVQ_bits_16kHz_tbl[] = // Q0 }; /* bit allocation table for reserved bits (ACELP@12.8kHz) */ -const Word16 reserved_bits_tbl[] = // Q0 +const Word16 reserved_bits_tbl[] = // Q0 { /* UC VC GC TC0_0 TC0_64 TC0_128 TC0_192 TC64 TC128 TC192 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_5k00 */ @@ -390,24 +390,24 @@ const Word16 reserved_bits_tbl[] = // Q0 }; /* NRG mode */ -const UWord8 ACELP_NRG_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 +const UWord8 ACELP_NRG_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 { {{0,0,1,1,0,0,0,0},{2,2,1,1,0,0,0,0}}, {{1,1,1,1,0,0,0,0},{1,1,1,1,1,1,1,0}}, }; /* NRG bits : (0/2/3 bits) */ -const UWord8 ACELP_NRG_BITS[3] = { 0, 3, 4 }; // Q0 +const UWord8 ACELP_NRG_BITS[3] = { 0, 3, 4 }; // Q0 /* LTP MODE*/ -const UWord8 ACELP_LTP_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 +const UWord8 ACELP_LTP_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 { {{0,0,1,2,0,0,0,0},{0,0,1,2,0,0,0,0}}, {{4,4,3,4,0,0,0,0},{4,4,3,4,8,0,9,0}}, }; /* LTP bits */ -const UWord8 ACELP_LTP_BITS_SFR[8+RF_MODE_MAX][5] = // Q0 +const UWord8 ACELP_LTP_BITS_SFR[8+RF_MODE_MAX][5] = // Q0 { {0,0,0,0,0}, {8,4,4,4,4}, @@ -423,25 +423,25 @@ const UWord8 ACELP_LTP_BITS_SFR[8+RF_MODE_MAX][5] = // Q0 /* LTF modes (0 - LOW_PASS (LP filtering), 1 - FULL_BAND (no filtering), 2 - NORMAL_OPERATION (adaptive)) */ /* Mode 2 ACELP: INACTIVE,UNVOICED,VOICED,GENERIC */ -const UWord8 ACELP_LTF_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 +const UWord8 ACELP_LTF_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 { {{1,1,1,0,0,0,0,0},{1,1,1,0,0,0,0,0}}, {{0,0,2,0,0,0,0,0},{0,0,2,0,1,1,1,0}}, }; /* LTF bits */ -const UWord8 ACELP_LTF_BITS[4] = { 0, 0, 4, 0 }; // Q0 +const UWord8 ACELP_LTF_BITS[4] = { 0, 0, 4, 0 }; // Q0 /* GAINS ELEMENT */ /* 5 modes: (EVS: 5b/subframe), (AMRWB: 7b/subframe),(AMRWB: 6b/subframe),(UC: 5b/subframe) */ -const UWord8 ACELP_GAINS_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 +const UWord8 ACELP_GAINS_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 { {{6,6,1,1,0,0,0,0},{7,7,1,1,0,0,0,0}}, {{2,2,3,3,0,0,0,0},{2,2,3,3,3,2,1,0}}, }; /* gains bits */ -const UWord8 ACELP_GAINS_BITS[10] = // Q0 +const UWord8 ACELP_GAINS_BITS[10] = // Q0 { 0, /* skip sub-frame wise gain coding*/ 5, @@ -456,14 +456,14 @@ const UWord8 ACELP_GAINS_BITS[10] = // Q0 }; /* BPF modes (0 - no filtering, 1 - filtering, 2 - adaptive) */ -const UWord8 ACELP_BPF_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 +const UWord8 ACELP_BPF_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] = // Q0 { {{1,1,1,1,0,0,0,0},{1,1,1,1,0,0,0,0}}, {{1,1,2,2,0,0,0,0},{1,1,2,2,1,1,1,1}}, }; /* BPF bits */ -const UWord8 ACELP_BPF_BITS[3] = { 0, 0, 2 }; // Q0 +const UWord8 ACELP_BPF_BITS[3] = { 0, 0, 2 }; // Q0 const Word16 ACELP_CDK_BITS[ACELP_FIXED_CDK_NB] = { 7, 10, 12, 15, 17, 20, 24, 26, 28, 30, 32, 34, 36, 40, 43, 46, @@ -489,7 +489,7 @@ const Word16 crit_bins_corr_fx[CRIT_NOIS_BAND] = 29491, 29491, 27853, 26214, 25395, 24576, 23577 , 22938, 22118, 21299, 20480, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661 }; -const Word16 crit_bins[CRIT_NOIS_BAND] = // Q0 +const Word16 crit_bins[CRIT_NOIS_BAND] = // Q0 { 4, 4, 4, 4, 4, 5, 6, 6, 6, 8, 8, 10, 11, 13, 15, 18, 22, 16, 16, 20, 20, 20, 16 }; @@ -587,7 +587,7 @@ const Word32 thren_fx[39] = /* Q8 */ 108, 76, 54 }; -const Word16 dicnlg2[40] = // Q0 +const Word16 dicnlg2[40] = // Q0 { 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, @@ -611,30 +611,30 @@ const Word16 inv_mfreq_bindiv_LD_M1_fx[] = { 3641, 3641, 3641, 3641, 3277, 2979, const Word16 post_dct_wind_fx[OFFSET2] = /*Q15 */ { - 32767, 32766, 32759, 32748, 32733, 32713, 32689, 32660, - 32627, 32590, 32548, 32502, 32452, 32397, 32338, 32274, - 32207, 32135, 32059, 31979, 31894, 31805, 31712, 31615, - 31514, 31409, 31300, 31187, 31070, 30949, 30823, 30695, - 30562, 30425, 30285, 30141, 29993, 29841, 29686, 29527, - 29365, 29200, 29030, 28858, 28682, 28503, 28320, 28134, - 27945, 27753, 27558, 27360, 27159, 26955, 26749, 26539, - 26327, 26112, 25894, 25674, 25452, 25226, 24999, 24769, - 24537, 24303, 24067, 23828, 23588, 23345, 23101, 22855, - 22607, 22358, 22107, 21854, 21600, 21345, 21088, 20830, - 20570, 20310, 20049, 19786, 19523, 19258, 18993, 18728, - 18461, 18195, 17927, 17659, 17391, 17123, 16854, 16586, - 16317, 16048, 15779, 15511, 15243, 14975, 14707, 14440, - 14173, 13907, 13642, 13377, 13114, 12851, 12589, 12328, - 12068, 11809, 11552, 11296, 11041, 10787, 10536, 10285, - 10037, 9790, 9545, 9301, 9060, 8820, 8583, 8348, - 8115, 7884, 7655, 7429, 7205, 6983, 6765, 6548, - 6335, 6124, 5916, 5710, 5508, 5308, 5112, 4918, - 4728, 4540, 4356, 4175, 3998, 3824, 3653, 3485, - 3321, 3161, 3004, 2851, 2701, 2555, 2413, 2274, - 2139, 2009, 1882, 1758, 1639, 1524, 1413, 1306, - 1203, 1104, 1009, 918, 831, 749, 671, 597, - 527, 461, 400, 343, 291, 242, 199, 159, - 124, 93, 67, 45, 27, 14, 5, 1 + 32767, 32766, 32759, 32748, 32733, 32713, 32689, 32660, + 32627, 32590, 32548, 32502, 32452, 32397, 32338, 32274, + 32207, 32135, 32059, 31979, 31894, 31805, 31712, 31615, + 31514, 31409, 31300, 31187, 31070, 30949, 30823, 30695, + 30562, 30425, 30285, 30141, 29993, 29841, 29686, 29527, + 29365, 29200, 29030, 28858, 28682, 28503, 28320, 28134, + 27945, 27753, 27558, 27360, 27159, 26955, 26749, 26539, + 26327, 26112, 25894, 25674, 25452, 25226, 24999, 24769, + 24537, 24303, 24067, 23828, 23588, 23345, 23101, 22855, + 22607, 22358, 22107, 21854, 21600, 21345, 21088, 20830, + 20570, 20310, 20049, 19786, 19523, 19258, 18993, 18728, + 18461, 18195, 17927, 17659, 17391, 17123, 16854, 16586, + 16317, 16048, 15779, 15511, 15243, 14975, 14707, 14440, + 14173, 13907, 13642, 13377, 13114, 12851, 12589, 12328, + 12068, 11809, 11552, 11296, 11041, 10787, 10536, 10285, + 10037, 9790, 9545, 9301, 9060, 8820, 8583, 8348, + 8115, 7884, 7655, 7429, 7205, 6983, 6765, 6548, + 6335, 6124, 5916, 5710, 5508, 5308, 5112, 4918, + 4728, 4540, 4356, 4175, 3998, 3824, 3653, 3485, + 3321, 3161, 3004, 2851, 2701, 2555, 2413, 2274, + 2139, 2009, 1882, 1758, 1639, 1524, 1413, 1306, + 1203, 1104, 1009, 918, 831, 749, 671, 597, + 527, 461, 400, 343, 291, 242, 199, 159, + 124, 93, 67, 45, 27, 14, 5, 1 }; const Word16 MAX_SNR_SNR1_tab_FX[MBANDS_GN_LD] = { 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 17096, 17096, 17096, 17096 };//Q14 @@ -666,22 +666,22 @@ const Word16 wind_sss_fx[LEN_WIN_SSS] = /*window for subsampling*/ const Word16 filter5_39s320_120_fx[121] = /* Q15 */ { - 19968, 19480, 18061, 15834, 12993, 9779, 6458, 3290, - 506, -1713, -3253, -4075, -4212, -3762, -2873, -1720, - -488, 654, 1568, 2160, 2389, 2263, 1838, 1201, - 460, -275, -903, -1348, -1566, -1546, -1312, -914, - -422, 90, 547, 891, 1083, 1108, 975, 716, - 376, 9, -331, -599, -762, -805, -732, -562, - -325, -61, 192, 399, 533, 582, 546, 435, - 272, 83, -103, -259, -366, -413, -398, -328, - -218, -86, 46, 161, 243, 283, 280, 238, - 166, 77, -14, -94, -153, -185, -188, -163, - -119, -62, -3, 50, 90, 113, 117, 104, - 78, 44, 9, -23, -47, -62, -65, -58, - -45, -27, -8, 9, 21, 28, 30, 27, - 20, 13, 5, -2, -7, -9, -9, -8, - -6, -3, -1, 0, 1, 1, 1, 0, - 0 + 19968, 19480, 18061, 15834, 12993, 9779, 6458, 3290, + 506, -1713, -3253, -4075, -4212, -3762, -2873, -1720, + -488, 654, 1568, 2160, 2389, 2263, 1838, 1201, + 460, -275, -903, -1348, -1566, -1546, -1312, -914, + -422, 90, 547, 891, 1083, 1108, 975, 716, + 376, 9, -331, -599, -762, -805, -732, -562, + -325, -61, 192, 399, 533, 582, 546, 435, + 272, 83, -103, -259, -366, -413, -398, -328, + -218, -86, 46, 161, 243, 283, 280, 238, + 166, 77, -14, -94, -153, -185, -188, -163, + -119, -62, -3, 50, 90, 113, 117, 104, + 78, 44, 9, -23, -47, -62, -65, -58, + -45, -27, -8, 9, 21, 28, 30, 27, + 20, 13, 5, -2, -7, -9, -9, -8, + -6, -3, -1, 0, 1, 1, 1, 0, + 0 }; @@ -691,100 +691,100 @@ const Word16 filter5_39s320_120_fx[121] = /* Q15 */ *----------------------------------------------------------------------------------*/ const Word16 Assym_window_W16fx[L_LP] = /*Q15*/ { - 2621, 2624, 2630, 2640, 2655, 2674, 2698, 2725, - 2757, 2792, 2833, 2877, 2925, 2978, 3034, 3095, - 3160, 3229, 3302, 3379, 3460, 3545, 3634, 3727, - 3824, 3925, 4029, 4138, 4250, 4366, 4486, 4609, - 4737, 4867, 5002, 5140, 5281, 5426, 5575, 5727, - 5882, 6040, 6202, 6367, 6535, 6707, 6881, 7059, - 7239, 7422, 7609, 7798, 7990, 8184, 8382, 8581, - 8784, 8989, 9196, 9406, 9618, 9832, 10049, 10268, - 10489, 10711, 10936, 11163, 11391, 11622, 11854, 12087, - 12322, 12559, 12797, 13037, 13278, 13520, 13763, 14007, - 14253, 14499, 14746, 14994, 15243, 15493, 15743, 15994, - 16245, 16496, 16748, 17000, 17253, 17505, 17758, 18010, - 18263, 18515, 18767, 19019, 19270, 19521, 19772, 20022, - 20271, 20519, 20767, 21014, 21260, 21504, 21748, 21991, - 22232, 22473, 22711, 22949, 23185, 23419, 23652, 23883, - 24113, 24340, 24566, 24790, 25012, 25231, 25449, 25664, - 25878, 26089, 26297, 26503, 26707, 26908, 27107, 27303, - 27496, 27687, 27874, 28059, 28241, 28420, 28596, 28769, - 28939, 29105, 29269, 29429, 29586, 29739, 29889, 30036, - 30179, 30319, 30455, 30588, 30717, 30842, 30964, 31082, - 31196, 31306, 31413, 31516, 31615, 31709, 31800, 31888, - 31971, 32050, 32125, 32196, 32263, 32325, 32384, 32439, - 32489, 32535, 32577, 32615, 32649, 32679, 32704, 32725, - 32742, 32755, 32763, 32767, 32767, 32758, 32741, 32715, - 32681, 32638, 32587, 32527, 32458, 32381, 32296, 32203, - 32101, 31991, 31873, 31746, 31612, 31470, 31320, 31162, - 30996, 30823, 30642, 30454, 30259, 30056, 29847, 29630, - 29407, 29177, 28940, 28697, 28448, 28193, 27931, 27664, - 27391, 27113, 26829, 26540, 26246, 25947, 25643, 25335, - 25022, 24706, 24385, 24060, 23732, 23401, 23066, 22728, - 22387, 22043, 21697, 21349, 20999, 20646, 20292, 19937, - 19580, 19223, 18864, 18505, 18145, 17785, 17425, 17065, - 16705, 16346, 15988, 15631, 15275, 14920, 14567, 14215, - 13866, 13519, 13174, 12832, 12492, 12156, 11823, 11493, - 11166, 10844, 10525, 10210, 9900, 9594, 9292, 8996, - 8704, 8418, 8137, 7861, 7591, 7327, 7068, 6816, - 6570, 6330, 6097, 5870, 5650, 5437, 5231, 5032, - 4840, 4656, 4479, 4310, 4148, 3994, 3848, 3709, - 3579, 3457, 3343, 3237, 3139, 3050, 2969, 2896, - 2832, 2776, 2729, 2690, 2660, 2639, 2626, 2621 + 2621, 2624, 2630, 2640, 2655, 2674, 2698, 2725, + 2757, 2792, 2833, 2877, 2925, 2978, 3034, 3095, + 3160, 3229, 3302, 3379, 3460, 3545, 3634, 3727, + 3824, 3925, 4029, 4138, 4250, 4366, 4486, 4609, + 4737, 4867, 5002, 5140, 5281, 5426, 5575, 5727, + 5882, 6040, 6202, 6367, 6535, 6707, 6881, 7059, + 7239, 7422, 7609, 7798, 7990, 8184, 8382, 8581, + 8784, 8989, 9196, 9406, 9618, 9832, 10049, 10268, + 10489, 10711, 10936, 11163, 11391, 11622, 11854, 12087, + 12322, 12559, 12797, 13037, 13278, 13520, 13763, 14007, + 14253, 14499, 14746, 14994, 15243, 15493, 15743, 15994, + 16245, 16496, 16748, 17000, 17253, 17505, 17758, 18010, + 18263, 18515, 18767, 19019, 19270, 19521, 19772, 20022, + 20271, 20519, 20767, 21014, 21260, 21504, 21748, 21991, + 22232, 22473, 22711, 22949, 23185, 23419, 23652, 23883, + 24113, 24340, 24566, 24790, 25012, 25231, 25449, 25664, + 25878, 26089, 26297, 26503, 26707, 26908, 27107, 27303, + 27496, 27687, 27874, 28059, 28241, 28420, 28596, 28769, + 28939, 29105, 29269, 29429, 29586, 29739, 29889, 30036, + 30179, 30319, 30455, 30588, 30717, 30842, 30964, 31082, + 31196, 31306, 31413, 31516, 31615, 31709, 31800, 31888, + 31971, 32050, 32125, 32196, 32263, 32325, 32384, 32439, + 32489, 32535, 32577, 32615, 32649, 32679, 32704, 32725, + 32742, 32755, 32763, 32767, 32767, 32758, 32741, 32715, + 32681, 32638, 32587, 32527, 32458, 32381, 32296, 32203, + 32101, 31991, 31873, 31746, 31612, 31470, 31320, 31162, + 30996, 30823, 30642, 30454, 30259, 30056, 29847, 29630, + 29407, 29177, 28940, 28697, 28448, 28193, 27931, 27664, + 27391, 27113, 26829, 26540, 26246, 25947, 25643, 25335, + 25022, 24706, 24385, 24060, 23732, 23401, 23066, 22728, + 22387, 22043, 21697, 21349, 20999, 20646, 20292, 19937, + 19580, 19223, 18864, 18505, 18145, 17785, 17425, 17065, + 16705, 16346, 15988, 15631, 15275, 14920, 14567, 14215, + 13866, 13519, 13174, 12832, 12492, 12156, 11823, 11493, + 11166, 10844, 10525, 10210, 9900, 9594, 9292, 8996, + 8704, 8418, 8137, 7861, 7591, 7327, 7068, 6816, + 6570, 6330, 6097, 5870, 5650, 5437, 5231, 5032, + 4840, 4656, 4479, 4310, 4148, 3994, 3848, 3709, + 3579, 3457, 3343, 3237, 3139, 3050, 2969, 2896, + 2832, 2776, 2729, 2690, 2660, 2639, 2626, 2621 }; const Word16 assym_window_16k_fx[L_LP_16k] = /*Q15*/ { - 2621, 2623, 2627, 2634, 2643, 2655, 2670, 2688, - 2708, 2731, 2757, 2785, 2816, 2849, 2886, 2925, - 2966, 3011, 3058, 3107, 3159, 3214, 3271, 3331, - 3394, 3459, 3527, 3597, 3670, 3745, 3823, 3903, - 3985, 4071, 4158, 4248, 4341, 4436, 4533, 4632, - 4734, 4839, 4945, 5054, 5165, 5279, 5394, 5512, - 5632, 5754, 5879, 6005, 6134, 6264, 6397, 6531, - 6668, 6807, 6947, 7090, 7234, 7381, 7529, 7679, - 7831, 7984, 8140, 8297, 8455, 8616, 8778, 8941, - 9107, 9273, 9442, 9611, 9782, 9955, 10129, 10304, - 10481, 10659, 10838, 11019, 11200, 11383, 11567, 11752, - 11938, 12125, 12313, 12502, 12693, 12883, 13075, 13268, - 13461, 13655, 13850, 14046, 14242, 14439, 14637, 14835, - 15033, 15232, 15432, 15631, 15832, 16032, 16233, 16434, - 16635, 16837, 17039, 17240, 17442, 17644, 17846, 18048, - 18250, 18452, 18653, 18855, 19056, 19257, 19458, 19658, - 19858, 20058, 20257, 20456, 20654, 20852, 21049, 21245, - 21441, 21637, 21831, 22025, 22218, 22410, 22602, 22792, - 22982, 23170, 23358, 23545, 23730, 23915, 24098, 24280, - 24461, 24641, 24820, 24997, 25173, 25348, 25521, 25693, - 25863, 26032, 26200, 26366, 26530, 26693, 26854, 27014, - 27171, 27328, 27482, 27635, 27786, 27935, 28082, 28227, - 28371, 28513, 28652, 28790, 28926, 29059, 29191, 29320, - 29448, 29573, 29697, 29818, 29937, 30053, 30168, 30280, - 30390, 30498, 30603, 30706, 30807, 30905, 31002, 31095, - 31186, 31275, 31362, 31446, 31527, 31606, 31683, 31757, - 31828, 31897, 31963, 32027, 32088, 32147, 32203, 32257, - 32307, 32356, 32401, 32444, 32484, 32522, 32557, 32589, - 32619, 32646, 32670, 32692, 32711, 32727, 32741, 32751, - 32760, 32765, 32767, 32767, 32762, 32751, 32734, 32712, - 32685, 32652, 32614, 32570, 32521, 32466, 32406, 32341, - 32270, 32194, 32112, 32026, 31934, 31837, 31735, 31627, - 31515, 31398, 31275, 31148, 31016, 30878, 30737, 30590, - 30438, 30282, 30122, 29957, 29787, 29613, 29434, 29252, - 29065, 28874, 28679, 28480, 28277, 28070, 27859, 27644, - 27426, 27205, 26980, 26751, 26520, 26285, 26047, 25805, - 25561, 25314, 25065, 24812, 24557, 24300, 24040, 23777, - 23513, 23246, 22978, 22707, 22435, 22161, 21885, 21608, - 21329, 21049, 20768, 20485, 20202, 19918, 19632, 19347, - 19060, 18773, 18486, 18198, 17911, 17623, 17335, 17047, - 16760, 16473, 16186, 15900, 15614, 15330, 15046, 14763, - 14481, 14200, 13921, 13643, 13367, 13092, 12818, 12547, - 12277, 12010, 11744, 11481, 11220, 10961, 10705, 10451, - 10200, 9951, 9706, 9463, 9223, 8987, 8754, 8523, - 8297, 8073, 7854, 7637, 7425, 7216, 7011, 6810, - 6613, 6420, 6231, 6046, 5865, 5689, 5517, 5350, - 5187, 5028, 4875, 4726, 4581, 4442, 4307, 4177, - 4052, 3932, 3818, 3708, 3603, 3503, 3409, 3320, - 3236, 3157, 3084, 3016, 2953, 2895, 2844, 2797, - 2756, 2720, 2690, 2665, 2646, 2632, 2624, 2621 + 2621, 2623, 2627, 2634, 2643, 2655, 2670, 2688, + 2708, 2731, 2757, 2785, 2816, 2849, 2886, 2925, + 2966, 3011, 3058, 3107, 3159, 3214, 3271, 3331, + 3394, 3459, 3527, 3597, 3670, 3745, 3823, 3903, + 3985, 4071, 4158, 4248, 4341, 4436, 4533, 4632, + 4734, 4839, 4945, 5054, 5165, 5279, 5394, 5512, + 5632, 5754, 5879, 6005, 6134, 6264, 6397, 6531, + 6668, 6807, 6947, 7090, 7234, 7381, 7529, 7679, + 7831, 7984, 8140, 8297, 8455, 8616, 8778, 8941, + 9107, 9273, 9442, 9611, 9782, 9955, 10129, 10304, + 10481, 10659, 10838, 11019, 11200, 11383, 11567, 11752, + 11938, 12125, 12313, 12502, 12693, 12883, 13075, 13268, + 13461, 13655, 13850, 14046, 14242, 14439, 14637, 14835, + 15033, 15232, 15432, 15631, 15832, 16032, 16233, 16434, + 16635, 16837, 17039, 17240, 17442, 17644, 17846, 18048, + 18250, 18452, 18653, 18855, 19056, 19257, 19458, 19658, + 19858, 20058, 20257, 20456, 20654, 20852, 21049, 21245, + 21441, 21637, 21831, 22025, 22218, 22410, 22602, 22792, + 22982, 23170, 23358, 23545, 23730, 23915, 24098, 24280, + 24461, 24641, 24820, 24997, 25173, 25348, 25521, 25693, + 25863, 26032, 26200, 26366, 26530, 26693, 26854, 27014, + 27171, 27328, 27482, 27635, 27786, 27935, 28082, 28227, + 28371, 28513, 28652, 28790, 28926, 29059, 29191, 29320, + 29448, 29573, 29697, 29818, 29937, 30053, 30168, 30280, + 30390, 30498, 30603, 30706, 30807, 30905, 31002, 31095, + 31186, 31275, 31362, 31446, 31527, 31606, 31683, 31757, + 31828, 31897, 31963, 32027, 32088, 32147, 32203, 32257, + 32307, 32356, 32401, 32444, 32484, 32522, 32557, 32589, + 32619, 32646, 32670, 32692, 32711, 32727, 32741, 32751, + 32760, 32765, 32767, 32767, 32762, 32751, 32734, 32712, + 32685, 32652, 32614, 32570, 32521, 32466, 32406, 32341, + 32270, 32194, 32112, 32026, 31934, 31837, 31735, 31627, + 31515, 31398, 31275, 31148, 31016, 30878, 30737, 30590, + 30438, 30282, 30122, 29957, 29787, 29613, 29434, 29252, + 29065, 28874, 28679, 28480, 28277, 28070, 27859, 27644, + 27426, 27205, 26980, 26751, 26520, 26285, 26047, 25805, + 25561, 25314, 25065, 24812, 24557, 24300, 24040, 23777, + 23513, 23246, 22978, 22707, 22435, 22161, 21885, 21608, + 21329, 21049, 20768, 20485, 20202, 19918, 19632, 19347, + 19060, 18773, 18486, 18198, 17911, 17623, 17335, 17047, + 16760, 16473, 16186, 15900, 15614, 15330, 15046, 14763, + 14481, 14200, 13921, 13643, 13367, 13092, 12818, 12547, + 12277, 12010, 11744, 11481, 11220, 10961, 10705, 10451, + 10200, 9951, 9706, 9463, 9223, 8987, 8754, 8523, + 8297, 8073, 7854, 7637, 7425, 7216, 7011, 6810, + 6613, 6420, 6231, 6046, 5865, 5689, 5517, 5350, + 5187, 5028, 4875, 4726, 4581, 4442, 4307, 4177, + 4052, 3932, 3818, 3708, 3603, 3503, 3409, 3320, + 3236, 3157, 3084, 3016, 2953, 2895, 2844, 2797, + 2756, 2720, 2690, 2665, 2646, 2632, 2624, 2621 }; const Word16 lag_window_8k[2][16] = /* LAGW_STRONG Q15*/ @@ -969,38 +969,38 @@ const Word16 sincos_t_fx[161] = { /*Q15 */ 0, - 804, 1607, 2410, 3211, 4011, - 4808, 5602, 6392, 7179, 7961, - 8739, 9512, 10278, 11039, 11793, - 12539, 13278, 14010, 14732, 15446, - 16151, 16846, 17530, 18204, 18868, - 19519, 20159, 20787, 21403, 22005, - 22594, 23170, 23732, 24279, 24812, - 25330, 25832, 26319, 26790, 27245, - 27684, 28106, 28511, 28898, 29269, - 29621, 29956, 30273, 30572, 30852, - 31114, 31357, 31581, 31785, 31971, - 32138, 32285, 32413, 32521, 32610, - 32679, 32728, 32758, 32767, 32758, - 32728, 32679, 32610, 32521, 32413, - 32285, 32138, 31971, 31785, 31581, - 31357, 31114, 30852, 30572, 30273, - 29956, 29621, 29269, 28898, 28511, - 28106, 27684, 27245, 26790, 26319, - 25832, 25330, 24812, 24279, 23732, - 23170, 22594, 22005, 21403, 20787, - 20159, 19519, 18868, 18204, 17530, - 16846, 16151, 15446, 14732, 14010, - 13278, 12539, 11793, 11039, 10278, - 9512, 8739, 7961, 7179, 6392, - 5602, 4808, 4011, 3211, 2410, - 1607, 804, 0, -804, -1607, - -2410, -3211, -4011, -4808, -5602, - -6392, -7179, -7961, -8739, -9512, - -10278, -11039, -11793, -12539, -13278, - -14010, -14732, -15446, -16151, -16846, - -17530, -18204, -18868, -19519, -20159, - -20787, -21403, -22005, -22594, -23170, + 804, 1607, 2410, 3211, 4011, + 4808, 5602, 6392, 7179, 7961, + 8739, 9512, 10278, 11039, 11793, + 12539, 13278, 14010, 14732, 15446, + 16151, 16846, 17530, 18204, 18868, + 19519, 20159, 20787, 21403, 22005, + 22594, 23170, 23732, 24279, 24812, + 25330, 25832, 26319, 26790, 27245, + 27684, 28106, 28511, 28898, 29269, + 29621, 29956, 30273, 30572, 30852, + 31114, 31357, 31581, 31785, 31971, + 32138, 32285, 32413, 32521, 32610, + 32679, 32728, 32758, 32767, 32758, + 32728, 32679, 32610, 32521, 32413, + 32285, 32138, 31971, 31785, 31581, + 31357, 31114, 30852, 30572, 30273, + 29956, 29621, 29269, 28898, 28511, + 28106, 27684, 27245, 26790, 26319, + 25832, 25330, 24812, 24279, 23732, + 23170, 22594, 22005, 21403, 20787, + 20159, 19519, 18868, 18204, 17530, + 16846, 16151, 15446, 14732, 14010, + 13278, 12539, 11793, 11039, 10278, + 9512, 8739, 7961, 7179, 6392, + 5602, 4808, 4011, 3211, 2410, + 1607, 804, 0, -804, -1607, + -2410, -3211, -4011, -4808, -5602, + -6392, -7179, -7961, -8739, -9512, + -10278, -11039, -11793, -12539, -13278, + -14010, -14732, -15446, -16151, -16846, + -17530, -18204, -18868, -19519, -20159, + -20787, -21403, -22005, -22594, -23170, }; @@ -1398,265 +1398,265 @@ const Word16 pitch_inter6_2[PIT_FIR_SIZE6_2] = const Word16 filter_LP12_180H_fx[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )' */ {//Q14 - 16384, 16196, 15641, 14741, 13533, 12067, - 10402, 8604, 6742, 4887, 3105, 1459, - 0, -1230, -2202, -2900, -3322, -3478, - -3392, -3095, -2628, -2037, -1371, -676, - 0, 618, 1143, 1550, 1822, 1954, - 1946, 1811, 1565, 1233, 842, 421, - 0, -394, -736, -1008, -1196, -1294, - -1299, -1217, -1059, -839, -576, -290, - 0, 274, 514, 707, 842, 913, - 920, 865, 755, 600, 413, 208, - 0, -197, -371, -511, -609, -662, - -667, -627, -548, -436, -300, -151, - 0, 143, 270, 371, 443, 481, - 485, 456, 398, 316, 217, 109, - 0, -104, -195, -268, -319, -346, - -348, -326, -284, -225, -155, -78, - 0, 73, 137, 189, 224, 242, - 243, 227, 198, 156, 107, 54, - 0, -50, -94, -128, -151, -163, - -163, -152, -131, -103, -70, -35, - 0, 32, 60, 82, 96, 103, - 102, 95, 81, 64, 43, 21, - 0, -19, -36, -48, -56, -59, - -58, -53, -45, -35, -23, -11, - 0, 10, 18, 24, 28, 29, - 28, 25, 21, 16, 10, 5, - 0, -4, -7, -9, -10, -10, - -9, -8, -6, -5, -3, -1, - 0, 1, 1, 2, 2, 1, - 1, 1, 0, 0, 0, 0, - 0 + 16384, 16196, 15641, 14741, 13533, 12067, + 10402, 8604, 6742, 4887, 3105, 1459, + 0, -1230, -2202, -2900, -3322, -3478, + -3392, -3095, -2628, -2037, -1371, -676, + 0, 618, 1143, 1550, 1822, 1954, + 1946, 1811, 1565, 1233, 842, 421, + 0, -394, -736, -1008, -1196, -1294, + -1299, -1217, -1059, -839, -576, -290, + 0, 274, 514, 707, 842, 913, + 920, 865, 755, 600, 413, 208, + 0, -197, -371, -511, -609, -662, + -667, -627, -548, -436, -300, -151, + 0, 143, 270, 371, 443, 481, + 485, 456, 398, 316, 217, 109, + 0, -104, -195, -268, -319, -346, + -348, -326, -284, -225, -155, -78, + 0, 73, 137, 189, 224, 242, + 243, 227, 198, 156, 107, 54, + 0, -50, -94, -128, -151, -163, + -163, -152, -131, -103, -70, -35, + 0, 32, 60, 82, 96, 103, + 102, 95, 81, 64, 43, 21, + 0, -19, -36, -48, -56, -59, + -58, -53, -45, -35, -23, -11, + 0, 10, 18, 24, 28, 29, + 28, 25, 21, 16, 10, 5, + 0, -4, -7, -9, -10, -10, + -9, -8, -6, -5, -3, -1, + 0, 1, 1, 2, 2, 1, + 1, 1, 0, 0, 0, 0, + 0 }; const Word16 filter_LP12_180H_13b_fx[] = /*Q13 Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )*/ {//Q13 - 8192, 8098, 7820, 7370, 6766, 6033, - 5201, 4302, 3371, 2443, 1553, 729, - 0, -615, -1101, -1450, -1661, -1739, - -1696, -1547, -1314, -1019, -685, -338, - 0, 309, 571, 775, 911, 977, - 973, 905, 783, 616, 421, 210, - 0, -197, -368, -504, -598, -647, - -649, -608, -529, -420, -288, -145, - 0, 137, 257, 353, 421, 457, - 460, 432, 377, 300, 206, 104, - 0, -99, -185, -255, -305, -331, - -333, -314, -274, -218, -150, -76, - 0, 72, 135, 186, 221, 240, - 242, 228, 199, 158, 109, 55, - 0, -52, -97, -134, -159, -173, - -174, -163, -142, -113, -77, -39, - 0, 37, 69, 94, 112, 121, - 121, 114, 99, 78, 53, 27, - 0, -25, -47, -64, -76, -81, - -81, -76, -66, -52, -35, -18, - 0, 16, 30, 41, 48, 52, - 51, 47, 41, 32, 21, 11, - 0, -10, -18, -24, -28, -30, - -29, -27, -23, -17, -12, -6, - 0, 5, 9, 12, 14, 14, - 14, 13, 10, 8, 5, 2, - 0, -2, -4, -5, -5, -5, - -5, -4, -3, -2, -1, -1, - 0, 0, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, - 0 + 8192, 8098, 7820, 7370, 6766, 6033, + 5201, 4302, 3371, 2443, 1553, 729, + 0, -615, -1101, -1450, -1661, -1739, + -1696, -1547, -1314, -1019, -685, -338, + 0, 309, 571, 775, 911, 977, + 973, 905, 783, 616, 421, 210, + 0, -197, -368, -504, -598, -647, + -649, -608, -529, -420, -288, -145, + 0, 137, 257, 353, 421, 457, + 460, 432, 377, 300, 206, 104, + 0, -99, -185, -255, -305, -331, + -333, -314, -274, -218, -150, -76, + 0, 72, 135, 186, 221, 240, + 242, 228, 199, 158, 109, 55, + 0, -52, -97, -134, -159, -173, + -174, -163, -142, -113, -77, -39, + 0, 37, 69, 94, 112, 121, + 121, 114, 99, 78, 53, 27, + 0, -25, -47, -64, -76, -81, + -81, -76, -66, -52, -35, -18, + 0, 16, 30, 41, 48, 52, + 51, 47, 41, 32, 21, 11, + 0, -10, -18, -24, -28, -30, + -29, -27, -23, -17, -12, -6, + 0, 5, 9, 12, 14, 14, + 14, 13, 10, 8, 5, 2, + 0, -2, -4, -5, -5, -5, + -5, -4, -3, -2, -1, -1, + 0, 0, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, + 0 }; const Word16 filter_LP15_180H_fx[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/15, hann( N )' */ {//Q14 - 16384, 16263, 15904, 15317, 14516, 13524, - 12366, 11073, 9678, 8216, 6723, 5236, - 3790, 2416, 1144, 0, -997, -1831, - -2492, -2976, -3285, -3425, -3408, -3248, - -2966, -2583, -2123, -1610, -1070, -526, - 0, 487, 919, 1281, 1564, 1761, - 1869, 1891, 1830, 1695, 1496, 1244, - 954, 641, 318, 0, -300, -569, - -799, -982, -1113, -1188, -1209, -1176, - -1094, -969, -809, -623, -420, -209, - 0, 198, 377, 531, 653, 741, - 793, 807, 786, 732, 649, 543, - 418, 282, 140, 0, -133, -253, - -356, -438, -497, -531, -540, -526, - -489, -433, -362, -278, -187, -93, - 0, 88, 167, 234, 288, 325, - 347, 352, 342, 317, 280, 233, - 179, 120, 59, 0, -56, -105, - -147, -180, -203, -215, -217, -210, - -194, -170, -141, -107, -72, -35, - 0, 33, 61, 85, 103, 116, - 122, 122, 117, 107, 93, 76, - 58, 38, 19, 0, -17, -31, - -43, -51, -57, -59, -58, -55, - -49, -42, -34, -25, -16, -8, - 0, 7, 12, 16, 19, 20, - 21, 20, 18, 16, 13, 10, - 7, 4, 2, 0, -1, -2, - -3, -3, -3, -3, -2, -2, - -1, -1, 0, 0, 0, 0, - 0 + 16384, 16263, 15904, 15317, 14516, 13524, + 12366, 11073, 9678, 8216, 6723, 5236, + 3790, 2416, 1144, 0, -997, -1831, + -2492, -2976, -3285, -3425, -3408, -3248, + -2966, -2583, -2123, -1610, -1070, -526, + 0, 487, 919, 1281, 1564, 1761, + 1869, 1891, 1830, 1695, 1496, 1244, + 954, 641, 318, 0, -300, -569, + -799, -982, -1113, -1188, -1209, -1176, + -1094, -969, -809, -623, -420, -209, + 0, 198, 377, 531, 653, 741, + 793, 807, 786, 732, 649, 543, + 418, 282, 140, 0, -133, -253, + -356, -438, -497, -531, -540, -526, + -489, -433, -362, -278, -187, -93, + 0, 88, 167, 234, 288, 325, + 347, 352, 342, 317, 280, 233, + 179, 120, 59, 0, -56, -105, + -147, -180, -203, -215, -217, -210, + -194, -170, -141, -107, -72, -35, + 0, 33, 61, 85, 103, 116, + 122, 122, 117, 107, 93, 76, + 58, 38, 19, 0, -17, -31, + -43, -51, -57, -59, -58, -55, + -49, -42, -34, -25, -16, -8, + 0, 7, 12, 16, 19, 20, + 21, 20, 18, 16, 13, 10, + 7, 4, 2, 0, -1, -2, + -3, -3, -3, -3, -2, -2, + -1, -1, 0, 0, 0, 0, + 0 }; const Word16 filter_LP15_180H_13b_fx[6 * 31] = /*Q13 Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )'*/ {//Q13 - 8192, 8132, 7952, 7658, 7258, 6762, - 6183, 5536, 4839, 4108, 3362, 2618, - 1895, 1208, 572, 0, -498, -915, - -1246, -1488, -1643, -1713, -1704, -1624, - -1483, -1291, -1061, -805, -535, -263, - 0, 244, 459, 640, 782, 880, - 935, 945, 915, 848, 748, 622, - 477, 320, 159, 0, -150, -285, - -400, -491, -556, -594, -604, -588, - -547, -485, -405, -312, -210, -104, - 0, 99, 189, 265, 327, 371, - 396, 404, 393, 366, 325, 271, - 209, 141, 70, 0, -66, -127, - -178, -219, -248, -266, -270, -263, - -245, -217, -181, -139, -94, -46, - 0, 44, 83, 117, 144, 163, - 173, 176, 171, 158, 140, 116, - 89, 60, 30, 0, -28, -53, - -74, -90, -101, -108, -109, -105, - -97, -85, -70, -54, -36, -18, - 0, 16, 31, 43, 52, 58, - 61, 61, 58, 53, 47, 38, - 29, 19, 9, 0, -8, -16, - -21, -26, -28, -29, -29, -27, - -25, -21, -17, -13, -8, -4, - 0, 3, 6, 8, 10, 10, - 10, 10, 9, 8, 6, 5, - 3, 2, 1, 0, -1, -1, - -1, -2, -2, -1, -1, -1, - -1, 0, 0, 0, 0, 0, - 0 + 8192, 8132, 7952, 7658, 7258, 6762, + 6183, 5536, 4839, 4108, 3362, 2618, + 1895, 1208, 572, 0, -498, -915, + -1246, -1488, -1643, -1713, -1704, -1624, + -1483, -1291, -1061, -805, -535, -263, + 0, 244, 459, 640, 782, 880, + 935, 945, 915, 848, 748, 622, + 477, 320, 159, 0, -150, -285, + -400, -491, -556, -594, -604, -588, + -547, -485, -405, -312, -210, -104, + 0, 99, 189, 265, 327, 371, + 396, 404, 393, 366, 325, 271, + 209, 141, 70, 0, -66, -127, + -178, -219, -248, -266, -270, -263, + -245, -217, -181, -139, -94, -46, + 0, 44, 83, 117, 144, 163, + 173, 176, 171, 158, 140, 116, + 89, 60, 30, 0, -28, -53, + -74, -90, -101, -108, -109, -105, + -97, -85, -70, -54, -36, -18, + 0, 16, 31, 43, 52, 58, + 61, 61, 58, 53, 47, 38, + 29, 19, 9, 0, -8, -16, + -21, -26, -28, -29, -29, -27, + -25, -21, -17, -13, -8, -4, + 0, 3, 6, 8, 10, 10, + 10, 10, 9, 8, 6, 5, + 3, 2, 1, 0, -1, -1, + -1, -2, -2, -1, -1, -1, + -1, 0, 0, 0, 0, 0, + 0 }; const Word16 filter_LP24_90H_fx[] = {//Q14 - 10240, 10208, 10111, 9951, 9731, - 9452, 9119, 8734, 8304, 7834, - 7328, 6794, 6237, 5664, 5081, - 4495, 3913, 3339, 2780, 2241, - 1727, 1242, 791, 376, 0, - -335, -629, -880, -1089, -1256, - -1383, -1471, -1523, -1540, -1527, - -1487, -1422, -1337, -1235, -1119, - -994, -862, -727, -592, -460, - -333, -212, -101, 0, 90, - 167, 232, 285, 325, 354, - 371, 378, 376, 366, 349, - 326, 299, 269, 236, 203, - 171, 139, 109, 81, 56, - 34, 15, 0, -12, -21, - -27, -30, -31, -31, -29, - -26, -22, -18, -14, -10, - -7, -4, -2, -1, 0, - 0, 0, 0, 0, 0, - 0, - 0 + 10240, 10208, 10111, 9951, 9731, + 9452, 9119, 8734, 8304, 7834, + 7328, 6794, 6237, 5664, 5081, + 4495, 3913, 3339, 2780, 2241, + 1727, 1242, 791, 376, 0, + -335, -629, -880, -1089, -1256, + -1383, -1471, -1523, -1540, -1527, + -1487, -1422, -1337, -1235, -1119, + -994, -862, -727, -592, -460, + -333, -212, -101, 0, 90, + 167, 232, 285, 325, 354, + 371, 378, 376, 366, 349, + 326, 299, 269, 236, 203, + 171, 139, 109, 81, 56, + 34, 15, 0, -12, -21, + -27, -30, -31, -31, -29, + -26, -22, -18, -14, -10, + -7, -4, -2, -1, 0, + 0, 0, 0, 0, 0, + 0, + 0 }; const Word16 filter_LP24_90H_13b_fx[] = {//Q13 - 5120, 5104, 5056, 4976, 4865, - 4726, 4559, 4367, 4152, 3917, - 3664, 3397, 3119, 2832, 2541, - 2248, 1956, 1669, 1390, 1120, - 863, 621, 396, 188, 0, - -168, -315, -440, -545, -628, - -691, -735, -761, -770, -764, - -743, -711, -668, -617, -560, - -497, -431, -364, -296, -230, - -166, -106, -51, 0, 45, - 84, 116, 143, 163, 177, - 186, 189, 188, 183, 174, - 163, 149, 134, 118, 102, - 85, 69, 54, 40, 28, - 17, 8, 0, -6, -10, - -13, -15, -16, -15, -14, - -13, -11, -9, -7, -5, - -3, -2, -1, 0, 0, - 0, 0, 0, 0, 0, - 0, - 0 + 5120, 5104, 5056, 4976, 4865, + 4726, 4559, 4367, 4152, 3917, + 3664, 3397, 3119, 2832, 2541, + 2248, 1956, 1669, 1390, 1120, + 863, 621, 396, 188, 0, + -168, -315, -440, -545, -628, + -691, -735, -761, -770, -764, + -743, -711, -668, -617, -560, + -497, -431, -364, -296, -230, + -166, -106, -51, 0, 45, + 84, 116, 143, 163, 177, + 186, 189, 188, 183, 174, + 163, 149, 134, 118, 102, + 85, 69, 54, 40, 28, + 17, 8, 0, -6, -10, + -13, -15, -16, -15, -14, + -13, -11, -9, -7, -5, + -3, -2, -1, 0, 0, + 0, 0, 0, 0, 0, + 0, + 0 }; const Word16 filter_LP3_90H_fx[] = /* Sincfilt.m: N=90*2+1, Fmin=0, Fmax=1/3, hann( N )' */ {//Q14 - 16384, 13545, 6766, 0, -3371, -2689, - 0, 1907, 1661, 0, -1314, -1187, - 0, 990, 911, 0, -783, -729, - 0, 638, 598, 0, -529, -499, - 0, 445, 421, 0, -377, -357, - 0, 321, 305, 0, -274, -260, - 0, 234, 221, 0, -199, -188, - 0, 169, 159, 0, -142, -134, - 0, 119, 112, 0, -99, -93, - 0, 81, 76, 0, -66, -61, - 0, 52, 48, 0, -41, -37, - 0, 31, 28, 0, -23, -20, - 0, 16, 14, 0, -10, -9, - 0, 6, 5, 0, -3, -2, - 0, 1, 1, 0, 0, 0, - 0 + 16384, 13545, 6766, 0, -3371, -2689, + 0, 1907, 1661, 0, -1314, -1187, + 0, 990, 911, 0, -783, -729, + 0, 638, 598, 0, -529, -499, + 0, 445, 421, 0, -377, -357, + 0, 321, 305, 0, -274, -260, + 0, 234, 221, 0, -199, -188, + 0, 169, 159, 0, -142, -134, + 0, 119, 112, 0, -99, -93, + 0, 81, 76, 0, -66, -61, + 0, 52, 48, 0, -41, -37, + 0, 31, 28, 0, -23, -20, + 0, 16, 14, 0, -10, -9, + 0, 6, 5, 0, -3, -2, + 0, 1, 1, 0, 0, 0, + 0 }; const Word16 filter_LP15_360H_13b_fx[] = /* Sincfilt.m: N=360*2+1, Fmin=0, Fmax=1/15, hann( N )' */ {//Q13 - 8192, 8132, 7954, 7662, 7265, 6772, 6196, 5552, - 4857, 4127, 3381, 2636, 1911, 1220, 579, 0, - -506, -931, -1269, -1519, -1681, -1757, -1752, -1674, - -1533, -1339, -1104, -840, -560, -276, 0, 258, - 488, 682, 836, 946, 1008, 1024, 996, 927, - 821, 687, 529, 357, 178, 0, -170, -325, - -458, -567, -646, -694, -710, -696, -652, -581, - -489, -379, -257, -129, 0, 124, 238, 338, - 420, 481, 518, 533, 523, 492, 440, 372, - 289, 197, 99, 0, -96, -184, -262, -326, - -374, -405, -417, -410, -386, -346, -293, -228, - -156, -78, 0, 76, 147, 209, 260, 299, - 324, 334, 329, 310, 279, 236, 184, 125, - 63, 0, -62, -119, -169, -211, -243, -263, - -271, -268, -252, -227, -192, -150, -102, -52, - 0, 50, 97, 138, 173, 198, 215, 222, - 219, 207, 186, 157, 123, 84, 42, 0, - -41, -80, -113, -142, -163, -176, -182, -180, - -170, -152, -129, -101, -69, -35, 0, 34, - 65, 93, 116, 133, 144, 149, 147, 139, - 125, 106, 82, 56, 28, 0, -28, -53, - -76, -95, -109, -118, -121, -120, -113, -101, - -86, -67, -46, -23, 0, 22, 43, 61, - 77, 88, 95, 98, 97, 91, 82, 69, - 54, 37, 19, 0, -18, -35, -49, -61, - -70, -76, -78, -77, -73, -65, -55, -43, - -29, -15, 0, 14, 27, 39, 48, 55, - 60, 62, 61, 57, 51, 43, 33, 23, - 11, 0, -11, -21, -30, -37, -43, -46, - -48, -47, -44, -39, -33, -26, -17, -9, - 0, 8, 16, 23, 28, 32, 35, 36, - 35, 33, 29, 25, 19, 13, 6, 0, - -6, -12, -17, -21, -24, -25, -26, -25, - -24, -21, -18, -14, -9, -5, 0, 4, - 8, 12, 14, 16, 18, 18, 17, 16, - 14, 12, 9, 6, 3, 0, -3, -6, - -8, -10, -11, -11, -12, -11, -10, -9, - -8, -6, -4, -2, 0, 2, 3, 5, - 6, 6, 7, 7, 7, 6, 5, 4, - 3, 2, 1, 0, -1, -2, -3, -3, - -3, -3, -3, -3, -3, -3, -2, -2, - -1, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0 + 8192, 8132, 7954, 7662, 7265, 6772, 6196, 5552, + 4857, 4127, 3381, 2636, 1911, 1220, 579, 0, + -506, -931, -1269, -1519, -1681, -1757, -1752, -1674, + -1533, -1339, -1104, -840, -560, -276, 0, 258, + 488, 682, 836, 946, 1008, 1024, 996, 927, + 821, 687, 529, 357, 178, 0, -170, -325, + -458, -567, -646, -694, -710, -696, -652, -581, + -489, -379, -257, -129, 0, 124, 238, 338, + 420, 481, 518, 533, 523, 492, 440, 372, + 289, 197, 99, 0, -96, -184, -262, -326, + -374, -405, -417, -410, -386, -346, -293, -228, + -156, -78, 0, 76, 147, 209, 260, 299, + 324, 334, 329, 310, 279, 236, 184, 125, + 63, 0, -62, -119, -169, -211, -243, -263, + -271, -268, -252, -227, -192, -150, -102, -52, + 0, 50, 97, 138, 173, 198, 215, 222, + 219, 207, 186, 157, 123, 84, 42, 0, + -41, -80, -113, -142, -163, -176, -182, -180, + -170, -152, -129, -101, -69, -35, 0, 34, + 65, 93, 116, 133, 144, 149, 147, 139, + 125, 106, 82, 56, 28, 0, -28, -53, + -76, -95, -109, -118, -121, -120, -113, -101, + -86, -67, -46, -23, 0, 22, 43, 61, + 77, 88, 95, 98, 97, 91, 82, 69, + 54, 37, 19, 0, -18, -35, -49, -61, + -70, -76, -78, -77, -73, -65, -55, -43, + -29, -15, 0, 14, 27, 39, 48, 55, + 60, 62, 61, 57, 51, 43, 33, 23, + 11, 0, -11, -21, -30, -37, -43, -46, + -48, -47, -44, -39, -33, -26, -17, -9, + 0, 8, 16, 23, 28, 32, 35, 36, + 35, 33, 29, 25, 19, 13, 6, 0, + -6, -12, -17, -21, -24, -25, -26, -25, + -24, -21, -18, -14, -9, -5, 0, 4, + 8, 12, 14, 16, 18, 18, 17, 16, + 14, 12, 9, 6, 3, 0, -3, -6, + -8, -10, -11, -11, -12, -11, -10, -9, + -8, -6, -4, -2, 0, 2, 3, 5, + 6, 6, 7, 7, 7, 6, 5, 4, + 3, 2, 1, 0, -1, -2, -3, -3, + -3, -3, -3, -3, -3, -3, -2, -2, + -1, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0 }; @@ -1679,33 +1679,33 @@ static const Word16 filter_LP30_300K_fx[LFE_PLC_FDEL + 1] = }; const Resampling_cfg resampling_cfg_tbl[] = -{ +{ /* fin fout up.fact. den.fac. len.out filter coefs. filter length/2 filter mem./2 flags */ { 8000, 12800, 8, 5, 256, /*filter5_39s320_120,*/ filter5_39s320_120_fx, 15, RS_INV_FAC }, - { 12800, 8000, 5, 8, 160, /*filter5_39s320_120,*/ filter5_39s320_120_fx, L_FILT_UP8k, RS_INV_FAC }, - { 16000, 8000, 6, 12, 160, /*filter_LP12_180H,*/ filter_LP12_180H_fx, 180 / 6, 0 }, - { 12800, 16000, 15, 12, 320, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP16k, 0 }, - { 12800, 32000, 15, 6, 640, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP32k, 0 }, - { 12800, 48000, 15, 4, 960, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP48k, 0 }, - + { 12800, 8000, 5, 8, 160, /*filter5_39s320_120,*/ filter5_39s320_120_fx, L_FILT_UP8k, RS_INV_FAC }, + { 16000, 8000, 6, 12, 160, /*filter_LP12_180H,*/ filter_LP12_180H_fx, 180 / 6, 0 }, + { 12800, 16000, 15, 12, 320, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP16k, 0 }, + { 12800, 32000, 15, 6, 640, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP32k, 0 }, + { 12800, 48000, 15, 4, 960, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP48k, 0 }, + { 16000, 12800, 12, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT16k, 0, }, - { 16000, 32000, 12, 6, 640, /*filter_LP12_180H, */ filter_LP12_180H_fx, L_FILT16k, 0, }, - { 16000, 48000, 12, 4, 960, /*filter_LP12_180H,*/ filter_LP12_180H_fx, L_FILT16k, 0, }, - - { 32000, 12800, 6, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT32k, 0, }, - { 32000, 16000, 6, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT32k, 0, }, - { 32000, 25600, 12, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT32k, 0, }, - { 32000, 48000, 3, 2, 960, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT32k, 0, }, - - { 48000, 12800, 4, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT48k, 0, }, - { 48000, 16000, 4, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT48k, 0, }, - { 48000, 25600, 8, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT48k, 0, }, - { 48000, 32000, 2, 3, 640, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT48k, 0, }, - - /* configs with NB 4kHz low-pass */ - { 16000, 12800, 12, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_fx, L_FILT16k, 0, }, - { 32000, 12800, 6, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT32k, 0, }, - { 48000, 12800, 4, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT48k, 0, }, + { 16000, 32000, 12, 6, 640, /*filter_LP12_180H, */ filter_LP12_180H_fx, L_FILT16k, 0, }, + { 16000, 48000, 12, 4, 960, /*filter_LP12_180H,*/ filter_LP12_180H_fx, L_FILT16k, 0, }, + + { 32000, 12800, 6, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT32k, 0, }, + { 32000, 16000, 6, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT32k, 0, }, + { 32000, 25600, 12, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT32k, 0, }, + { 32000, 48000, 3, 2, 960, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT32k, 0, }, + + { 48000, 12800, 4, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT48k, 0, }, + { 48000, 16000, 4, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT48k, 0, }, + { 48000, 25600, 8, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT48k, 0, }, + { 48000, 32000, 2, 3, 640, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT48k, 0, }, + + /* configs with NB 4kHz low-pass */ + { 16000, 12800, 12, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_fx, L_FILT16k, 0, }, + { 32000, 12800, 6, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT32k, 0, }, + { 48000, 12800, 4, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT48k, 0, }, /* entry for LFE PLC */ { 1600, 48000, 30, 1, 960, /*filter_LP30_300K,*/ filter_LP30_300K_fx, LFE_PLC_FDEL / 30, 0, }, @@ -1743,17 +1743,17 @@ const Word16 interpol_isp_amr_wb_fx[] = { 14746, 26214, 31457, 32767 };/*Q15*/ const Word16 interpol_frac_16k_fx[NB_SUBFR16k] = { 6554, 13107, 19661, 26214, 32767 };//Q15 -const Word16 interpol_frac_mid_fx[NB_SUBFR * 3] = { 16384, 16384, 0,//Q15 - 0, 32767, 0, - 0, 16384, 16384, - 0, 0, 32767 +const Word16 interpol_frac_mid_fx[NB_SUBFR * 3] = { 16384, 16384, 0,//Q15 + 0, 32767, 0, + 0, 16384, 16384, + 0, 0, 32767 };/*Q15*/ -const Word16 interpol_frac_mid_16k_fx[NB_SUBFR16k * 3] = { 18022, 14746, 0,//Q15 - 4915, 27853, 0, - 0, 24576, 8192, - 0, 11469, 21299, - 0, 0, 32767 +const Word16 interpol_frac_mid_16k_fx[NB_SUBFR16k * 3] = { 18022, 14746, 0,//Q15 + 4915, 27853, 0, + 0, 24576, 8192, + 0, 11469, 21299, + 0, 0, 32767 }; const Word16 interpol_frac_mid_relaxprev_12k8_fx[NB_SUBFR * 3] = { 0, 22938, 9830,//Q15 @@ -1878,134 +1878,134 @@ const UWord32 pulsestostates[17][9] = const Word16 gain_qua_mless_7b_fx[128*2] = {//Q14 - 419, 28, - 1499, 607, - 1586, 322, - 1632, 144, - 1686, 229, - 1745, 495, - 2182, 409, - 2515, 716, - 2772, 824, - 3069, 1069, - 3211, 936, - 3218, 89, - 3477, 1244, - 3755, 272, - 3865, 549, - 3881, 348, - 4171, 181, - 4414, 627, - 4419, 472, - 4909, 1429, - 5238, 404, - 5241, 1651, - 5721, 85, - 5833, 250, - 5846, 693, - 5897, 325, - 6036, 544, - 6088, 779, - 6459, 1889, - 6650, 157, - 6678, 462, - 6798, 879, - 6922, 993, - 6929, 1130, - 7352, 620, - 7461, 386, - 7864, 232, - 7999, 314, - 8136, 536, - 8398, 712, - 8680, 459, - 8797, 1276, - 9046, 806, - 9198, 86, - 9434, 398, - 9730, 587, - 9735, 267, - 9742, 175, - 9917, 917, - 10042, 509, - 10053, 655, - 10132, 1030, - 10238, 339, - 10694, 1560, - 10817, 447, - 10964, 723, - 11405, 1149, - 11526, 549, - 11582, 386, - 11602, 791, - 11618, 286, - 11883, 862, - 11954, 607, - 12057, 214, - 12104, 496, - 12170, 1397, - 12437, 668, - 12616, 335, - 12668, 952, - 12684, 435, - 12983, 112, - 13235, 742, - 13399, 549, - 13525, 380, - 13527, 270, - 13625, 1044, - 13733, 482, - 13820, 617, - 14036, 817, - 14041, 1257, - 14295, 425, - 14346, 684, - 14367, 319, - 14416, 199, - 14644, 898, - 14944, 518, - 15090, 364, - 15154, 578, - 15309, 462, - 15360, 1933, - 15362, 756, - 15381, 262, - 15566, 1127, - 15699, 639, - 15804, 410, - 16081, 316, - 16161, 993, - 16359, 701, - 16451, 828, - 16500, 543, - 16540, 491, - 16617, 1729, - 16630, 196, - 16749, 369, - 16959, 1530, - 17028, 442, - 17139, 603, - 17369, 898, - 17393, 268, - 17972, 763, - 17985, 1361, - 18016, 333, - 18032, 667, - 18234, 406, - 18270, 105, - 18299, 554, - 18342, 488, - 18747, 1207, - 19027, 1073, - 19530, 216, - 19566, 963, - 19751, 835, - 19794, 615, - 19810, 298, - 19988, 710, - 19990, 449, - 20005, 374, - 20149, 531, + 419, 28, + 1499, 607, + 1586, 322, + 1632, 144, + 1686, 229, + 1745, 495, + 2182, 409, + 2515, 716, + 2772, 824, + 3069, 1069, + 3211, 936, + 3218, 89, + 3477, 1244, + 3755, 272, + 3865, 549, + 3881, 348, + 4171, 181, + 4414, 627, + 4419, 472, + 4909, 1429, + 5238, 404, + 5241, 1651, + 5721, 85, + 5833, 250, + 5846, 693, + 5897, 325, + 6036, 544, + 6088, 779, + 6459, 1889, + 6650, 157, + 6678, 462, + 6798, 879, + 6922, 993, + 6929, 1130, + 7352, 620, + 7461, 386, + 7864, 232, + 7999, 314, + 8136, 536, + 8398, 712, + 8680, 459, + 8797, 1276, + 9046, 806, + 9198, 86, + 9434, 398, + 9730, 587, + 9735, 267, + 9742, 175, + 9917, 917, + 10042, 509, + 10053, 655, + 10132, 1030, + 10238, 339, + 10694, 1560, + 10817, 447, + 10964, 723, + 11405, 1149, + 11526, 549, + 11582, 386, + 11602, 791, + 11618, 286, + 11883, 862, + 11954, 607, + 12057, 214, + 12104, 496, + 12170, 1397, + 12437, 668, + 12616, 335, + 12668, 952, + 12684, 435, + 12983, 112, + 13235, 742, + 13399, 549, + 13525, 380, + 13527, 270, + 13625, 1044, + 13733, 482, + 13820, 617, + 14036, 817, + 14041, 1257, + 14295, 425, + 14346, 684, + 14367, 319, + 14416, 199, + 14644, 898, + 14944, 518, + 15090, 364, + 15154, 578, + 15309, 462, + 15360, 1933, + 15362, 756, + 15381, 262, + 15566, 1127, + 15699, 639, + 15804, 410, + 16081, 316, + 16161, 993, + 16359, 701, + 16451, 828, + 16500, 543, + 16540, 491, + 16617, 1729, + 16630, 196, + 16749, 369, + 16959, 1530, + 17028, 442, + 17139, 603, + 17369, 898, + 17393, 268, + 17972, 763, + 17985, 1361, + 18016, 333, + 18032, 667, + 18234, 406, + 18270, 105, + 18299, 554, + 18342, 488, + 18747, 1207, + 19027, 1073, + 19530, 216, + 19566, 963, + 19751, 835, + 19794, 615, + 19810, 298, + 19988, 710, + 19990, 449, + 20005, 374, + 20149, 531, }; const Word16 gain_qua_mless_6b_stereo_fx[64 * 2] = @@ -2078,106 +2078,106 @@ const Word16 gain_qua_mless_6b_stereo_fx[64 * 2] = const Word16 gain_qua_mless_6b_fx[64 * 2] = {//Q14 - 1676, 71, - 2128, 198, - 2318, 491, - 2348, 339, - 2798, 625, - 2893, 785, - 3911, 1099, - 4779, 244, - 4781, 427, - 5115, 935, - 5294, 1509, - 5767, 114, - 6018, 543, - 6152, 335, - 6205, 675, - 6234, 1822, - 6740, 1251, - 7034, 802, - 7782, 434, - 8005, 230, - 9232, 622, - 9337, 336, - 9388, 520, - 9770, 1038, - 9865, 734, - 10224, 879, - 10617, 118, - 10776, 426, - 11518, 249, - 11708, 1399, - 12044, 587, - 12270, 501, - 12277, 348, - 12498, 684, - 13020, 786, - 13097, 1196, - 13530, 422, - 13818, 917, - 14123, 290, - 14500, 1039, - 14538, 636, - 14636, 556, - 14667, 484, - 14931, 362, - 15055, 210, - 15653, 1594, - 15830, 1874, - 15868, 717, - 15897, 828, - 16153, 434, - 16540, 294, - 16874, 608, - 16936, 513, - 17182, 373, - 17644, 1337, - 17696, 126, - 18342, 1122, - 18461, 944, - 18991, 242, - 19114, 795, - 19187, 674, - 19256, 449, - 19485, 557, - 19515, 344, + 1676, 71, + 2128, 198, + 2318, 491, + 2348, 339, + 2798, 625, + 2893, 785, + 3911, 1099, + 4779, 244, + 4781, 427, + 5115, 935, + 5294, 1509, + 5767, 114, + 6018, 543, + 6152, 335, + 6205, 675, + 6234, 1822, + 6740, 1251, + 7034, 802, + 7782, 434, + 8005, 230, + 9232, 622, + 9337, 336, + 9388, 520, + 9770, 1038, + 9865, 734, + 10224, 879, + 10617, 118, + 10776, 426, + 11518, 249, + 11708, 1399, + 12044, 587, + 12270, 501, + 12277, 348, + 12498, 684, + 13020, 786, + 13097, 1196, + 13530, 422, + 13818, 917, + 14123, 290, + 14500, 1039, + 14538, 636, + 14636, 556, + 14667, 484, + 14931, 362, + 15055, 210, + 15653, 1594, + 15830, 1874, + 15868, 717, + 15897, 828, + 16153, 434, + 16540, 294, + 16874, 608, + 16936, 513, + 17182, 373, + 17644, 1337, + 17696, 126, + 18342, 1122, + 18461, 944, + 18991, 242, + 19114, 795, + 19187, 674, + 19256, 449, + 19485, 557, + 19515, 344, }; const Word16 gain_qua_mless_5b_fx[32 * 2] = {//Q14 - 2695, 109, - 3444, 271, - 3529, 433, - 4284, 801, - 4365, 607, - 4935, 1089, - 6896, 1407, - 7722, 324, - 7913, 146, - 8090, 468, - 9049, 913, - 9499, 600, - 9894, 741, - 9942, 1840, - 11906, 382, - 12008, 1103, - 12349, 243, - 12429, 501, - 13687, 630, - 13974, 896, - 14510, 748, - 15160, 322, - 15424, 428, - 15679, 541, - 15832, 1574, - 15999, 1281, - 17223, 211, - 17719, 1029, - 18185, 649, - 18432, 818, - 18638, 353, - 18889, 493, + 2695, 109, + 3444, 271, + 3529, 433, + 4284, 801, + 4365, 607, + 4935, 1089, + 6896, 1407, + 7722, 324, + 7913, 146, + 8090, 468, + 9049, 913, + 9499, 600, + 9894, 741, + 9942, 1840, + 11906, 382, + 12008, 1103, + 12349, 243, + 12429, 501, + 13687, 630, + 13974, 896, + 14510, 748, + 15160, 322, + 15424, 428, + 15679, 541, + 15832, 1574, + 15999, 1281, + 17223, 211, + 17719, 1029, + 18185, 649, + 18432, 818, + 18638, 353, + 18889, 493, }; const Word16 E_ROM_qua_gain5b_const[NB_QUA_GAIN5B * 2]= @@ -2681,7 +2681,7 @@ const Word16 Es_pred_qua_4b_fx[16] = 5742, 6821, 7834, - /*8779, */ + /*8779, */ 8778, 9701, 10610, @@ -3017,798 +3017,798 @@ const Word16 gp_gamma_4sfr_7b_fx[2 * 128] = /*Q14/Q9 */ const Word16 gp_gamma_1sfr_8b_fx[2 * 256] = /*Q14/Q9 */ { - 305, 152, - 333, 37, - 352, 556, - 573, 82, - 652, 12, - 694, 207, - 808, 389, - 915, 776, - 986, 1089, - 987, 1583, - 1055, 60, - 1202, 2779, - 1205, 20, - 1346, 127, - 1432, 332, - 1689, 6554, - 1715, 261, - 1820, 49, - 2041, 698, - 2179, 4032, - 2199, 100, - 2272, 1303, - 2317, 461, - 2340, 175, - 2562, 26, - 2574, 14814, - 2657, 2101, - 2732, 66, - 2818, 9, - 2836, 296, - 2929, 938, - 3479, 130, - 3510, 220, - 3651, 3154, - 3667, 717, - 3720, 384, - 3783, 530, - 3811, 10744, - 3883, 5385, - 3941, 1609, - 3964, 46, - 4120, 80, - 4402, 15, - 4440, 1181, - 4485, 173, - 4740, 311, - 4848, 31, - 5125, 7642, - 5147, 110, - 5167, 908, - 5237, 252, - 5323, 623, - 5376, 2514, - 5590, 7, - 5595, 4475, - 5634, 64, - 5654, 461, - 5822, 22, - 5893, 140, - 5905, 1810, - 6177, 367, - 6268, 201, - 6352, 1092, - 6567, 752, - 6626, 50, - 6734, 95, - 6758, 295, - 6882, 3085, - 6962, 1363, - 7274, 540, - 7413, 166, - 7635, 2120, - 7642, 38, - 7671, 393, - 7730, 227, - 7860, 75, - 7980, 115, - 8011, 955, - 8092, 3687, - 8120, 17, - 8146, 5902, - 8453, 672, - 8524, 1602, - 8583, 58, - 8679, 275, - 8873, 332, - 8920, 454, - 8969, 9712, - 9129, 2566, - 9159, 196, - 9193, 1127, - 9219, 142, - 9300, 9, - 9302, 828, - 9409, 91, - 9736, 26, - 9872, 574, - 10066, 246, - 10131, 1352, - 10154, 1971, - 10196, 399, - 10238, 15785, - 10255, 4254, - 10401, 67, - 10439, 43, - 10511, 116, - 10531, 7399, - 10706, 998, - 10798, 722, - 10845, 171, - 10848, 304, - 10876, 2981, - 11069, 28204, - 11139, 507, - 11280, 12, - 11427, 388, - 11459, 214, - 11647, 1174, - 11710, 5061, - 11742, 1614, - 11793, 806, - 11816, 82, - 11890, 132, - 11996, 2301, - 12000, 603, - 12060, 55, - 12232, 256, - 12299, 33, - 12438, 338, - 12452, 458, - 12627, 3563, - 12646, 9489, - 12665, 934, - 12801, 1329, - 12802, 190, - 12877, 683, - 12941, 103, - 13038, 1890, - 13209, 6209, - 13222, 12674, - 13318, 21, - 13374, 283, - 13385, 149, - 13391, 383, - 13453, 545, - 13564, 1064, - 13596, 2561, - 13771, 810, - 13834, 1481, - 13874, 69, - 14027, 226, - 14093, 4429, - 14147, 7, - 14171, 609, - 14185, 47, - 14223, 3051, - 14273, 434, - 14321, 314, - 14415, 120, - 14443, 1252, - 14500, 173, - 14557, 933, - 14616, 1696, - 14639, 8229, - 14724, 89, - 14837, 703, - 14902, 2072, - 14917, 366, - 15000, 487, - 15009, 30, - 15095, 256, - 15138, 1119, - 15228, 3580, - 15371, 1386, - 15387, 5525, - 15398, 17932, - 15462, 149, - 15471, 791, - 15551, 569, - 15554, 2467, - 15559, 201, - 15616, 14, - 15664, 319, - 15798, 401, - 15811, 974, - 15874, 41, - 15929, 1649, - 15945, 79, - 16046, 111, - 16225, 647, - 16230, 1240, - 16297, 4110, - 16328, 10499, - 16331, 278, - 16355, 3003, - 16383, 455, - 16404, 169, - 16435, 2172, - 16438, 850, - 16745, 7090, - 16776, 354, - 16801, 1063, - 16803, 62, - 16812, 223, - 16927, 530, - 16951, 721, - 17039, 1447, - 17208, 1837, - 17233, 135, - 17371, 4642, - 17570, 406, - 17608, 267, - 17696, 906, - 17702, 2529, - 17705, 23239, - 17709, 1209, - 17745, 592, - 17800, 92, - 17858, 35, - 17860, 3360, - 17866, 9, - 17978, 184, - 18035, 321, - 18255, 754, - 18274, 480, - 18320, 18, - 18406, 55, - 18582, 13017, - 18677, 1516, - 18726, 1998, - 18904, 25, - 18914, 6103, - 19020, 8567, - 19022, 1116, - 19025, 349, - 19147, 239, - 19224, 604, - 19251, 160, - 19270, 4870, - 19358, 3789, - 19394, 126, - 19394, 103, - 19433, 72, - 19444, 46, - 19448, 2842, - 19489, 430, - 19575, 815, - 19628, 1306, - 19631, 972, - 19637, 202, - 19642, 289, - 19660, 527, - 19717, 1697, - 19731, 2263, - 19754, 676, - 19854, 382, + 305, 152, + 333, 37, + 352, 556, + 573, 82, + 652, 12, + 694, 207, + 808, 389, + 915, 776, + 986, 1089, + 987, 1583, + 1055, 60, + 1202, 2779, + 1205, 20, + 1346, 127, + 1432, 332, + 1689, 6554, + 1715, 261, + 1820, 49, + 2041, 698, + 2179, 4032, + 2199, 100, + 2272, 1303, + 2317, 461, + 2340, 175, + 2562, 26, + 2574, 14814, + 2657, 2101, + 2732, 66, + 2818, 9, + 2836, 296, + 2929, 938, + 3479, 130, + 3510, 220, + 3651, 3154, + 3667, 717, + 3720, 384, + 3783, 530, + 3811, 10744, + 3883, 5385, + 3941, 1609, + 3964, 46, + 4120, 80, + 4402, 15, + 4440, 1181, + 4485, 173, + 4740, 311, + 4848, 31, + 5125, 7642, + 5147, 110, + 5167, 908, + 5237, 252, + 5323, 623, + 5376, 2514, + 5590, 7, + 5595, 4475, + 5634, 64, + 5654, 461, + 5822, 22, + 5893, 140, + 5905, 1810, + 6177, 367, + 6268, 201, + 6352, 1092, + 6567, 752, + 6626, 50, + 6734, 95, + 6758, 295, + 6882, 3085, + 6962, 1363, + 7274, 540, + 7413, 166, + 7635, 2120, + 7642, 38, + 7671, 393, + 7730, 227, + 7860, 75, + 7980, 115, + 8011, 955, + 8092, 3687, + 8120, 17, + 8146, 5902, + 8453, 672, + 8524, 1602, + 8583, 58, + 8679, 275, + 8873, 332, + 8920, 454, + 8969, 9712, + 9129, 2566, + 9159, 196, + 9193, 1127, + 9219, 142, + 9300, 9, + 9302, 828, + 9409, 91, + 9736, 26, + 9872, 574, + 10066, 246, + 10131, 1352, + 10154, 1971, + 10196, 399, + 10238, 15785, + 10255, 4254, + 10401, 67, + 10439, 43, + 10511, 116, + 10531, 7399, + 10706, 998, + 10798, 722, + 10845, 171, + 10848, 304, + 10876, 2981, + 11069, 28204, + 11139, 507, + 11280, 12, + 11427, 388, + 11459, 214, + 11647, 1174, + 11710, 5061, + 11742, 1614, + 11793, 806, + 11816, 82, + 11890, 132, + 11996, 2301, + 12000, 603, + 12060, 55, + 12232, 256, + 12299, 33, + 12438, 338, + 12452, 458, + 12627, 3563, + 12646, 9489, + 12665, 934, + 12801, 1329, + 12802, 190, + 12877, 683, + 12941, 103, + 13038, 1890, + 13209, 6209, + 13222, 12674, + 13318, 21, + 13374, 283, + 13385, 149, + 13391, 383, + 13453, 545, + 13564, 1064, + 13596, 2561, + 13771, 810, + 13834, 1481, + 13874, 69, + 14027, 226, + 14093, 4429, + 14147, 7, + 14171, 609, + 14185, 47, + 14223, 3051, + 14273, 434, + 14321, 314, + 14415, 120, + 14443, 1252, + 14500, 173, + 14557, 933, + 14616, 1696, + 14639, 8229, + 14724, 89, + 14837, 703, + 14902, 2072, + 14917, 366, + 15000, 487, + 15009, 30, + 15095, 256, + 15138, 1119, + 15228, 3580, + 15371, 1386, + 15387, 5525, + 15398, 17932, + 15462, 149, + 15471, 791, + 15551, 569, + 15554, 2467, + 15559, 201, + 15616, 14, + 15664, 319, + 15798, 401, + 15811, 974, + 15874, 41, + 15929, 1649, + 15945, 79, + 16046, 111, + 16225, 647, + 16230, 1240, + 16297, 4110, + 16328, 10499, + 16331, 278, + 16355, 3003, + 16383, 455, + 16404, 169, + 16435, 2172, + 16438, 850, + 16745, 7090, + 16776, 354, + 16801, 1063, + 16803, 62, + 16812, 223, + 16927, 530, + 16951, 721, + 17039, 1447, + 17208, 1837, + 17233, 135, + 17371, 4642, + 17570, 406, + 17608, 267, + 17696, 906, + 17702, 2529, + 17705, 23239, + 17709, 1209, + 17745, 592, + 17800, 92, + 17858, 35, + 17860, 3360, + 17866, 9, + 17978, 184, + 18035, 321, + 18255, 754, + 18274, 480, + 18320, 18, + 18406, 55, + 18582, 13017, + 18677, 1516, + 18726, 1998, + 18904, 25, + 18914, 6103, + 19020, 8567, + 19022, 1116, + 19025, 349, + 19147, 239, + 19224, 604, + 19251, 160, + 19270, 4870, + 19358, 3789, + 19394, 126, + 19394, 103, + 19433, 72, + 19444, 46, + 19448, 2842, + 19489, 430, + 19575, 815, + 19628, 1306, + 19631, 972, + 19637, 202, + 19642, 289, + 19660, 527, + 19717, 1697, + 19731, 2263, + 19754, 676, + 19854, 382, }; const Word16 gp_gamma_1sfr_7b_fx[2 * 128] = /*Q14/Q9 */ { - 350, 85, - 428, 24, - 438, 681, - 642, 195, - 1071, 2012, - 1080, 402, - 1148, 1236, - 1159, 62, - 1424, 12, - 1662, 134, - 1985, 299, - 2100, 34, - 2163, 3168, - 2219, 538, - 2393, 6580, - 2499, 967, - 2882, 221, - 2974, 12743, - 3251, 98, - 3294, 51, - 3586, 1560, - 3711, 411, - 3721, 700, - 3862, 21, - 3947, 169, - 4001, 2249, - 4198, 4632, - 4372, 8, - 4993, 70, - 5022, 265, - 5568, 1194, - 5664, 495, - 5698, 115, - 5885, 854, - 6115, 2990, - 6266, 153, - 6376, 39, - 6432, 16, - 6601, 345, - 7108, 1957, - 7231, 660, - 7491, 202, - 7687, 93, - 8054, 3882, - 8108, 9624, - 8186, 1424, - 8243, 59, - 8354, 935, - 8358, 6401, - 8383, 439, - 8794, 285, - 8940, 124, - 9643, 25, - 9643, 581, - 9670, 2709, - 10065, 160, - 10218, 9, - 10240, 1728, - 10249, 80, - 10418, 1113, - 10497, 373, - 10650, 236, - 11095, 44, - 11095, 756, - 11284, 4978, - 11290, 16722, - 11815, 2299, - 11882, 482, - 12059, 114, - 12332, 8550, - 12363, 1394, - 12392, 186, - 12517, 336, - 12549, 3413, - 12694, 953, - 13096, 614, - 13185, 71, - 13247, 262, - 13479, 1914, - 13791, 14, - 13805, 30, - 14064, 138, - 14182, 420, - 14212, 1175, - 14477, 765, - 14605, 2745, - 14612, 6324, - 14730, 4199, - 14833, 301, - 14842, 203, - 14910, 12790, - 15171, 100, - 15191, 1625, - 15289, 532, - 15405, 52, - 15550, 985, - 16096, 357, - 16175, 2113, - 16284, 232, - 16333, 669, - 16363, 22999, - 16396, 156, - 16443, 1270, - 16455, 3482, - 16543, 8, - 16650, 5425, - 16878, 452, - 16989, 84, - 17024, 9676, - 17194, 876, - 17730, 20, - 17780, 1442, - 17864, 38, - 17874, 254, - 17929, 526, - 18011, 2403, - 18751, 7153, - 18786, 117, - 18820, 4420, - 19002, 63, - 19099, 401, - 19111, 183, - 19197, 776, - 19202, 2953, - 19236, 1052, - 19255, 301, - 19354, 1760, - 19432, 593, + 350, 85, + 428, 24, + 438, 681, + 642, 195, + 1071, 2012, + 1080, 402, + 1148, 1236, + 1159, 62, + 1424, 12, + 1662, 134, + 1985, 299, + 2100, 34, + 2163, 3168, + 2219, 538, + 2393, 6580, + 2499, 967, + 2882, 221, + 2974, 12743, + 3251, 98, + 3294, 51, + 3586, 1560, + 3711, 411, + 3721, 700, + 3862, 21, + 3947, 169, + 4001, 2249, + 4198, 4632, + 4372, 8, + 4993, 70, + 5022, 265, + 5568, 1194, + 5664, 495, + 5698, 115, + 5885, 854, + 6115, 2990, + 6266, 153, + 6376, 39, + 6432, 16, + 6601, 345, + 7108, 1957, + 7231, 660, + 7491, 202, + 7687, 93, + 8054, 3882, + 8108, 9624, + 8186, 1424, + 8243, 59, + 8354, 935, + 8358, 6401, + 8383, 439, + 8794, 285, + 8940, 124, + 9643, 25, + 9643, 581, + 9670, 2709, + 10065, 160, + 10218, 9, + 10240, 1728, + 10249, 80, + 10418, 1113, + 10497, 373, + 10650, 236, + 11095, 44, + 11095, 756, + 11284, 4978, + 11290, 16722, + 11815, 2299, + 11882, 482, + 12059, 114, + 12332, 8550, + 12363, 1394, + 12392, 186, + 12517, 336, + 12549, 3413, + 12694, 953, + 13096, 614, + 13185, 71, + 13247, 262, + 13479, 1914, + 13791, 14, + 13805, 30, + 14064, 138, + 14182, 420, + 14212, 1175, + 14477, 765, + 14605, 2745, + 14612, 6324, + 14730, 4199, + 14833, 301, + 14842, 203, + 14910, 12790, + 15171, 100, + 15191, 1625, + 15289, 532, + 15405, 52, + 15550, 985, + 16096, 357, + 16175, 2113, + 16284, 232, + 16333, 669, + 16363, 22999, + 16396, 156, + 16443, 1270, + 16455, 3482, + 16543, 8, + 16650, 5425, + 16878, 452, + 16989, 84, + 17024, 9676, + 17194, 876, + 17730, 20, + 17780, 1442, + 17864, 38, + 17874, 254, + 17929, 526, + 18011, 2403, + 18751, 7153, + 18786, 117, + 18820, 4420, + 19002, 63, + 19099, 401, + 19111, 183, + 19197, 776, + 19202, 2953, + 19236, 1052, + 19255, 301, + 19354, 1760, + 19432, 593, }; const Word16 gp_gamma_1sfr_6b_fx[2 * 64] = /*Q14/Q9 */ { - 436, 182, - 473, 63, - 962, 16, - 992, 647, - 1258, 1582, - 1447, 351, - 1711, 125, - 1809, 46, - 2569, 4173, - 2607, 957, - 2826, 251, - 2904, 12481, - 3248, 26, - 3594, 2254, - 3664, 78, - 3715, 483, - 4232, 8, - 4681, 188, - 5066, 6623, - 5232, 1273, - 6232, 695, - 6234, 49, - 6238, 113, - 6312, 318, - 7012, 17, - 7327, 3183, - 8008, 1739, - 8692, 446, - 8769, 163, - 8923, 1019, - 9094, 81, - 10358, 286, - 10491, 28, - 10612, 9788, - 10715, 760, - 11045, 4822, - 11319, 2403, - 11684, 56, - 12314, 108, - 12460, 556, - 12580, 9, - 12716, 213, - 12821, 1336, - 14202, 374, - 14325, 16971, - 14612, 838, - 14625, 3285, - 14668, 6231, - 14919, 39, - 15131, 137, - 15476, 1847, - 16056, 255, - 16277, 494, - 16290, 66, - 16582, 1048, - 16859, 17, - 17220, 8723, - 17443, 4295, - 18069, 2499, - 18212, 176, - 18499, 91, - 18517, 1445, - 18522, 332, - 18596, 663, + 436, 182, + 473, 63, + 962, 16, + 992, 647, + 1258, 1582, + 1447, 351, + 1711, 125, + 1809, 46, + 2569, 4173, + 2607, 957, + 2826, 251, + 2904, 12481, + 3248, 26, + 3594, 2254, + 3664, 78, + 3715, 483, + 4232, 8, + 4681, 188, + 5066, 6623, + 5232, 1273, + 6232, 695, + 6234, 49, + 6238, 113, + 6312, 318, + 7012, 17, + 7327, 3183, + 8008, 1739, + 8692, 446, + 8769, 163, + 8923, 1019, + 9094, 81, + 10358, 286, + 10491, 28, + 10612, 9788, + 10715, 760, + 11045, 4822, + 11319, 2403, + 11684, 56, + 12314, 108, + 12460, 556, + 12580, 9, + 12716, 213, + 12821, 1336, + 14202, 374, + 14325, 16971, + 14612, 838, + 14625, 3285, + 14668, 6231, + 14919, 39, + 15131, 137, + 15476, 1847, + 16056, 255, + 16277, 494, + 16290, 66, + 16582, 1048, + 16859, 17, + 17220, 8723, + 17443, 4295, + 18069, 2499, + 18212, 176, + 18499, 91, + 18517, 1445, + 18522, 332, + 18596, 663, }; const Word16 gp_gamma_2sfr_7b_fx[2 * 128] = /*Q14/Q9 */ { - 99, 1224, - 156, 243, - 168, 579, - 290, 355, - 437, 441, - 475, 187, - 734, 738, - 930, 93, - 1133, 153, - 1136, 298, - 1490, 508, - 1946, 401, - 1978, 16790, - 2098, 224, - 2117, 962, - 2407, 119, - 2686, 339, - 2929, 555, - 3404, 271, - 3465, 171, - 3469, 422, - 3714, 663, - 4436, 494, - 4494, 332, - 4571, 220, - 4583, 2182, - 4997, 848, - 5346, 380, - 5419, 108, - 5570, 579, - 5758, 266, - 5875, 442, - 5927, 170, - 6204, 3338, - 6394, 6435, - 6515, 328, - 6638, 730, - 6687, 1472, - 7045, 1056, - 7101, 498, - 7123, 210, - 7163, 9668, - 7345, 386, - 7598, 280, - 7853, 627, - 8462, 442, - 8648, 331, - 8822, 236, - 8887, 551, - 8953, 906, - 9317, 136, - 9587, 386, - 9651, 691, - 9796, 286, - 9852, 489, - 10005, 1215, - 10041, 192, - 10623, 576, - 10758, 329, - 10840, 425, - 10944, 792, - 11038, 257, - 11190, 1870, - 11541, 501, - 11729, 642, - 11873, 367, - 12064, 163, - 12332, 216, - 12339, 1100, - 12339, 295, - 12478, 444, - 12561, 568, - 12665, 845, - 13257, 396, - 13317, 677, - 13411, 511, - 13709, 324, - 13710, 1547, - 13711, 246, - 14054, 991, - 14112, 447, - 14246, 580, - 14355, 748, - 14394, 175, - 14453, 99, - 14604, 363, - 14887, 491, - 15074, 282, - 15110, 637, - 15242, 1292, - 15351, 413, - 15430, 843, - 15700, 541, - 15776, 204, - 15964, 335, - 15992, 688, - 16077, 453, - 16315, 4617, - 16406, 1032, - 16549, 595, - 16666, 384, - 16850, 776, - 16851, 482, - 16916, 253, - 17234, 309, - 17307, 2128, - 17469, 546, - 17666, 643, - 17699, 421, - 17852, 882, - 17870, 146, - 18146, 1244, - 18457, 489, - 18478, 346, - 18588, 723, - 18826, 208, - 19011, 1731, - 19042, 586, - 19286, 281, - 19428, 944, - 19446, 382, - 19555, 444, - 19689, 792, - 19755, 1111, - 19762, 527, - 19769, 1405, - 19774, 657, - 19780, 2675, + 99, 1224, + 156, 243, + 168, 579, + 290, 355, + 437, 441, + 475, 187, + 734, 738, + 930, 93, + 1133, 153, + 1136, 298, + 1490, 508, + 1946, 401, + 1978, 16790, + 2098, 224, + 2117, 962, + 2407, 119, + 2686, 339, + 2929, 555, + 3404, 271, + 3465, 171, + 3469, 422, + 3714, 663, + 4436, 494, + 4494, 332, + 4571, 220, + 4583, 2182, + 4997, 848, + 5346, 380, + 5419, 108, + 5570, 579, + 5758, 266, + 5875, 442, + 5927, 170, + 6204, 3338, + 6394, 6435, + 6515, 328, + 6638, 730, + 6687, 1472, + 7045, 1056, + 7101, 498, + 7123, 210, + 7163, 9668, + 7345, 386, + 7598, 280, + 7853, 627, + 8462, 442, + 8648, 331, + 8822, 236, + 8887, 551, + 8953, 906, + 9317, 136, + 9587, 386, + 9651, 691, + 9796, 286, + 9852, 489, + 10005, 1215, + 10041, 192, + 10623, 576, + 10758, 329, + 10840, 425, + 10944, 792, + 11038, 257, + 11190, 1870, + 11541, 501, + 11729, 642, + 11873, 367, + 12064, 163, + 12332, 216, + 12339, 1100, + 12339, 295, + 12478, 444, + 12561, 568, + 12665, 845, + 13257, 396, + 13317, 677, + 13411, 511, + 13709, 324, + 13710, 1547, + 13711, 246, + 14054, 991, + 14112, 447, + 14246, 580, + 14355, 748, + 14394, 175, + 14453, 99, + 14604, 363, + 14887, 491, + 15074, 282, + 15110, 637, + 15242, 1292, + 15351, 413, + 15430, 843, + 15700, 541, + 15776, 204, + 15964, 335, + 15992, 688, + 16077, 453, + 16315, 4617, + 16406, 1032, + 16549, 595, + 16666, 384, + 16850, 776, + 16851, 482, + 16916, 253, + 17234, 309, + 17307, 2128, + 17469, 546, + 17666, 643, + 17699, 421, + 17852, 882, + 17870, 146, + 18146, 1244, + 18457, 489, + 18478, 346, + 18588, 723, + 18826, 208, + 19011, 1731, + 19042, 586, + 19286, 281, + 19428, 944, + 19446, 382, + 19555, 444, + 19689, 792, + 19755, 1111, + 19762, 527, + 19769, 1405, + 19774, 657, + 19780, 2675, }; const Word16 gp_gamma_2sfr_6b_fx[2 * 64] = /*Q14/Q9 */ { - 185, 306, - 435, 519, - 458, 145, - 1000, 211, - 1217, 394, - 1241, 751, - 1788, 93, - 2026, 1234, - 2162, 265, - 2397, 158, - 2617, 472, - 3324, 340, - 3391, 623, - 3835, 207, - 4503, 17210, - 4628, 407, - 4939, 897, - 5102, 275, - 5300, 120, - 5560, 511, - 6309, 1909, - 6571, 335, - 6770, 205, - 6990, 642, - 7085, 5087, - 7500, 428, - 8357, 827, - 8452, 261, - 9079, 537, - 9289, 354, - 9854, 1176, - 9864, 165, - 10436, 8580, - 10549, 437, - 10615, 677, - 11010, 282, - 11940, 530, - 12183, 367, - 12475, 920, - 12865, 225, - 13359, 618, - 13431, 441, - 13521, 1623, - 14177, 341, - 14299, 130, - 14452, 775, - 14799, 508, - 15250, 276, - 15715, 1130, - 15757, 660, - 15879, 422, - 16355, 3256, - 16439, 187, - 16751, 562, - 16906, 331, - 17178, 827, - 17889, 471, - 18219, 2175, - 18786, 248, - 18985, 1354, - 19067, 703, - 19220, 384, - 19349, 954, - 19422, 553, + 185, 306, + 435, 519, + 458, 145, + 1000, 211, + 1217, 394, + 1241, 751, + 1788, 93, + 2026, 1234, + 2162, 265, + 2397, 158, + 2617, 472, + 3324, 340, + 3391, 623, + 3835, 207, + 4503, 17210, + 4628, 407, + 4939, 897, + 5102, 275, + 5300, 120, + 5560, 511, + 6309, 1909, + 6571, 335, + 6770, 205, + 6990, 642, + 7085, 5087, + 7500, 428, + 8357, 827, + 8452, 261, + 9079, 537, + 9289, 354, + 9854, 1176, + 9864, 165, + 10436, 8580, + 10549, 437, + 10615, 677, + 11010, 282, + 11940, 530, + 12183, 367, + 12475, 920, + 12865, 225, + 13359, 618, + 13431, 441, + 13521, 1623, + 14177, 341, + 14299, 130, + 14452, 775, + 14799, 508, + 15250, 276, + 15715, 1130, + 15757, 660, + 15879, 422, + 16355, 3256, + 16439, 187, + 16751, 562, + 16906, 331, + 17178, 827, + 17889, 471, + 18219, 2175, + 18786, 248, + 18985, 1354, + 19067, 703, + 19220, 384, + 19349, 954, + 19422, 553, }; const Word16 gp_gamma_3sfr_6b_fx[2 * 64] = /*Q14/Q9 */ { - 195, 150, - 817, 288, - 1152, 616, - 1366, 188, - 1377, 410, - 1526, 902, - 1570, 98, - 2258, 238, - 2489, 518, - 2935, 338, - 3142, 161, - 3456, 1705, - 3990, 432, - 4159, 709, - 4187, 270, - 4374, 1236, - 5283, 526, - 5431, 131, - 5507, 356, - 5762, 211, - 6792, 620, - 6842, 446, - 6969, 304, - 7671, 807, - 8362, 245, - 8448, 530, - 8610, 380, - 9314, 1088, - 9828, 170, - 9921, 7010, - 10026, 459, - 10193, 312, - 10261, 658, - 11554, 394, - 11739, 882, - 11791, 542, - 11985, 4329, - 11996, 246, - 12762, 13441, - 12844, 1512, - 13131, 465, - 13135, 339, - 13215, 740, - 14138, 608, - 14524, 417, - 14780, 1030, - 14823, 283, - 15016, 171, - 15264, 527, - 15823, 2706, - 15943, 699, - 15959, 360, - 16350, 473, - 17211, 573, - 17366, 901, - 17517, 238, - 17799, 414, - 18069, 1415, - 18630, 1920, - 18887, 634, - 19018, 318, - 19304, 495, - 19400, 1114, - 19413, 767, + 195, 150, + 817, 288, + 1152, 616, + 1366, 188, + 1377, 410, + 1526, 902, + 1570, 98, + 2258, 238, + 2489, 518, + 2935, 338, + 3142, 161, + 3456, 1705, + 3990, 432, + 4159, 709, + 4187, 270, + 4374, 1236, + 5283, 526, + 5431, 131, + 5507, 356, + 5762, 211, + 6792, 620, + 6842, 446, + 6969, 304, + 7671, 807, + 8362, 245, + 8448, 530, + 8610, 380, + 9314, 1088, + 9828, 170, + 9921, 7010, + 10026, 459, + 10193, 312, + 10261, 658, + 11554, 394, + 11739, 882, + 11791, 542, + 11985, 4329, + 11996, 246, + 12762, 13441, + 12844, 1512, + 13131, 465, + 13135, 339, + 13215, 740, + 14138, 608, + 14524, 417, + 14780, 1030, + 14823, 283, + 15016, 171, + 15264, 527, + 15823, 2706, + 15943, 699, + 15959, 360, + 16350, 473, + 17211, 573, + 17366, 901, + 17517, 238, + 17799, 414, + 18069, 1415, + 18630, 1920, + 18887, 634, + 19018, 318, + 19304, 495, + 19400, 1114, + 19413, 767, }; const Word16 gp_gamma_4sfr_6b_fx[2 * 64] = /*Q14/Q9 */ { - 153, 141, - 282, 501, - 399, 239, - 783, 369, - 1110, 744, - 1430, 183, - 1440, 1748, - 1524, 1091, - 1602, 296, - 1828, 99, - 2000, 439, - 2678, 228, - 2815, 600, - 3084, 347, - 3861, 477, - 4154, 163, - 4214, 285, - 4428, 733, - 4976, 384, - 5482, 566, - 5552, 234, - 6158, 929, - 6536, 470, - 6560, 326, - 7288, 173, - 7429, 663, - 7447, 10616, - 7871, 407, - 8457, 266, - 8559, 550, - 8679, 1421, - 9457, 356, - 9533, 785, - 9854, 471, - 10584, 5781, - 10792, 3815, - 10813, 206, - 10829, 302, - 10986, 606, - 11380, 433, - 11468, 1073, - 12485, 356, - 12726, 520, - 12783, 721, - 13554, 259, - 13763, 139, - 13884, 430, - 14060, 2592, - 14266, 599, - 14332, 925, - 14997, 337, - 15355, 485, - 15526, 712, - 16440, 587, - 16504, 395, - 16626, 204, - 17228, 1287, - 17563, 805, - 17629, 517, - 18159, 1814, - 18320, 303, - 19228, 437, - 19263, 636, - 19417, 989, + 153, 141, + 282, 501, + 399, 239, + 783, 369, + 1110, 744, + 1430, 183, + 1440, 1748, + 1524, 1091, + 1602, 296, + 1828, 99, + 2000, 439, + 2678, 228, + 2815, 600, + 3084, 347, + 3861, 477, + 4154, 163, + 4214, 285, + 4428, 733, + 4976, 384, + 5482, 566, + 5552, 234, + 6158, 929, + 6536, 470, + 6560, 326, + 7288, 173, + 7429, 663, + 7447, 10616, + 7871, 407, + 8457, 266, + 8559, 550, + 8679, 1421, + 9457, 356, + 9533, 785, + 9854, 471, + 10584, 5781, + 10792, 3815, + 10813, 206, + 10829, 302, + 10986, 606, + 11380, 433, + 11468, 1073, + 12485, 356, + 12726, 520, + 12783, 721, + 13554, 259, + 13763, 139, + 13884, 430, + 14060, 2592, + 14266, 599, + 14332, 925, + 14997, 337, + 15355, 485, + 15526, 712, + 16440, 587, + 16504, 395, + 16626, 204, + 17228, 1287, + 17563, 805, + 17629, 517, + 18159, 1814, + 18320, 303, + 19228, 437, + 19263, 636, + 19417, 989, }; @@ -3961,305 +3961,305 @@ const Word16 fir_6k_7k_fx[31] = }; const Word16 no_lead_fx[][MAX_NO_SCALES * 2] = {//Q0 - { 1, 0, 0, 1, 0, 0, }, /* 14 */ - { 2, 0, 0, 1, 0, 0, }, /* 15 */ - { 4, 2, 0, 1, 0, 0, }, /* 18 */ - { 4, 2, 0, 2, 0, 0, }, /* 19 */ - { 7, 5, 2, 5, 4, 2, }, /* 25 */ - { 8, 8, 3, 8, 6, 2, }, /* 28 */ /* mode UV WB*/ - { 4, 2, 0, 1, 0, 0, }, /* 18 */ - { 4, 0, 0, 2, 1, 0, }, /* 19 */ - { 9, 8, 8, 2, 2, 1, }, /* 24 */ - { 8, 5, 2, 5, 2, 1, }, /* 25 */ - { 18, 16, 8, 5, 5, 1, }, /* 29 */ - { 24, 21, 10, 8, 8, 2, }, /* 32 */ /* mode UV NB*/ - - { 2, 0, 0, 2, 0, 0, }, /* 17 */ - { 4, 2, 0, 1, 0, 0, }, /* 18 */ - { 7, 5, 2, 2, 0, 0, }, /* 21 */ - { 5, 2, 1, 4, 1, 0, }, /* 22 */ - { 8, 5, 2, 5, 2, 0, }, /* 25 */ - { 8, 7, 4, 5, 3, 2, }, - { 8, 8, 4, 6, 5, 2, }, - { 13, 8, 5, 6, 5, 2, }, - { 13, 8, 5, 8, 6, 2, }, - { 13, 8, 5, 11, 8, 2, }, /* 30 */ - { 24, 21, 8, 9, 8, 2, }, /* 32 */ - { 23, 18, 8, 13, 11, 3, }, - { 23, 21, 8, 17, 13, 4, }, /* 34 */ - { 31, 31, 17, 26, 25, 9, }, /* 37 */ /* mode V WB*/ - { 2, 0, 0, 2, 2, 0, }, /* 17 */ - { 4, 2, 0, 1, 0, 0, }, /* 18 */ - { 7, 5, 2, 2, 2, 0, }, /* 22 */ - { 8, 7, 2, 2, 2, 0, }, /* 23 */ - { 11, 8, 2, 2, 2, 0, }, /* 24 */ - { 13, 13, 9, 2, 2, 0, }, /* 25 */ - { 13, 11, 7, 5, 2, 0, }, /* 27 */ - { 18, 14, 9, 5, 5, 2, }, /* 29 */ - { 31, 31, 14, 11, 11, 5, }, /* 34 */ - { 31, 31, 27, 24, 21, 14, }, /* 37 */ /* mode V NB */ - { 5, 4, 0, 0, 0, 0, }, /* 12 (11.883) */ - { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */ - { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */ - { 5, 4, 0, 2, 0, 0, }, /* 20 (19.796) */ - { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ - { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */ - { 5, 5, 2, 4, 2, 0, }, /* 23 (22.959) */ - { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ - { 8, 8, 7, 5, 2, 0, }, /* 26 (25.904) */ - { 13, 9, 8, 5, 2, 0, }, /* 27 (26.829) */ - { 13, 11, 8, 5, 5, 1, }, /* 28 (27.989) */ - { 13, 9, 8, 8, 5, 2, }, /* 29 (28.984) */ - { 22, 16, 10, 6, 5, 2, }, /* 30 (29.980) */ - { 21, 14, 10, 8, 7, 2, }, /* 31 (30.966) */ - { 24, 21, 10, 8, 8, 2, }, /* 32 (31.995) */ /* G WB*/ - - { 5, 4, 1, 0, 0, 0, }, /* 12 (11.925) */ - { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */ - { 5, 4, 1, 1, 0, 0, }, /* 19 (18.745) */ - { 5, 4, 1, 2, 0, 0, }, /* 20 (19.838) */ - { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ - { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */ - { 9, 8, 5, 2, 1, 0, }, /* 23 (22.815) */ - { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */ - { 13, 8, 7, 4, 2, 0, }, /* 26 (25.993) */ - { 13, 9, 8, 5, 2, 2, }, /* 27 (26.954) */ - { 18, 13, 8, 5, 2, 2, }, /* 28 (27.992) */ - { 21, 13, 11, 5, 3, 2, }, /* 29 (28.996) */ - { 22, 21, 13, 5, 5, 2, }, /* 30 (29.988) */ - { 23, 21, 17, 7, 5, 2, }, /* 31 (30.962) */ - { 27, 23, 21, 8, 5, 2, }, /* 32 (31.987) */ /* G NB*/ - { 2, 0, 0, 2, 0, 0, }, /* 17 */ - { 4, 2, 0, 1, 0, 0, }, /* 18 */ - { 4, 1, 0, 4, 0, 0, }, /* 21 */ - { 5, 2, 0, 4, 1, 0, }, /* 22 */ - { 8, 5, 2, 4, 0, 0, }, /* 24 */ - { 8, 5, 2, 5, 2, 0, }, /* 25 */ - { 14, 10, 5, 5, 5, 1, }, /* 28 */ - { 14, 10, 5, 8, 8, 4, }, /* 30 */ - { 13, 10, 5, 13, 8, 8, }, - { 23, 21, 8, 8, 8, 4, }, - { 23, 18, 5, 13, 8, 8, }, /* 33 */ - /* mode T WB */ - { 2, 0, 0, 2, 2, 0, }, /* 17 */ - { 4, 2, 0, 1, 0, 0, }, /* 18 */ - { 7, 5, 2, 2, 2, 0, }, /* 22 */ - { 8, 7, 4, 2, 2, 0, }, /* 23 */ - { 11, 8, 5, 2, 2, 0, }, /* 24 */ - { 18, 8, 5, 2, 2, 0, }, /* 25 */ - { 16, 8, 5, 5, 5, 2, }, /* 28 */ - { 28, 23, 8, 5, 5, 5, }, /* 31 */ - { 31, 31, 8, 5, 5, 7, }, /* 32 */ /* mode T NB */ - - { 18, 18, 11, 9, 6, 5, }, /* 31 */ - { 24, 23, 13, 9, 6, 5, }, /* 32 */ /* mode G 16k */ - - { 24, 23, 13, 9, 6, 5, }, /* 32 (31.998) */ - { 36, 31, 18, 9, 6, 5, }, /* 33 (32.983) */ /* T 16k */ - - { 2, 0, 0, 2, 2, 0, }, /* 17 */ - { 7, 5, 2, 2, 0, 0, }, /* 21 */ - { 7, 5, 2, 2, 2, 0, }, /* 22 */ - { 9, 8, 3, 4, 2, 0, }, /* 25 */ - { 11, 9, 8, 4, 2, 0, }, /* 26 */ - { 48, 48, 34, 13, 11, 9 }, /* 36 */ /* mode AUDIO_WB 36 + 4 + 1 */ - - { 22, 10, 3, 0, 0, 0 }, /* 17 */ - { 6, 6, 2, 2, 0, 0 }, /* 21 */ - { 6, 6, 2, 2, 2, 0 }, /* 22 */ - { 23, 10, 3, 2, 2, 0 }, /* 26 */ - { 32, 16, 3, 2, 2, 0 }, /* 27 */ /* AUDIO_NB */ - { 39, 30, 12, 2, 2, 0 }, /* 28 */ /* AUDIO_NB */ - { 11, 9, 8, 4, 2, 0, }, /* 26 */ - { 48, 48, 48, 13, 9, 8 }, /* 36 */ /* mode AUDIO_WB 16k 15-36 + 4 + 1*/ - { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */ - { 13, 13, 5, 5, 5, 0, }, /* 28 (27.994) */ - { 18, 17, 5, 5, 5, 1, }, /* 29 (28.996) */ - { 17, 13, 5, 8, 6, 2, }, /* 30 (29.991) */ - { 23, 21, 8, 9, 8, 3, }, /* 32 (31.992) */ - { 31, 29, 16, 8, 8, 3, }, /* 33 (32.993) */ - { 31, 25, 16, 12, 8, 8, }, /* 34 (33.968) */ - { 46, 48, 18, 18, 18, 12, }, /* 37 (36.995) */ /* VOICED 16k */ - { 14, 12, 9, 2, 2, 0, }, /* 25 (24.980) */ - { 15, 13, 3, 2, 2, 0, }, /* 25 (24.974) */ - { 17, 3, 0, 2, 2, 1, }, /* 25 (24.852) */ - { 13, 10, 3, 2, 2, 2, }, /* 25 (24.994) */ - { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */ - { 7, 3, 0, 5, 3, 1, }, /* 25 (24.671) */ - { 4, 3, 2, 6, 6, 5, }, /* 25 (24.936) */ - { 4, 2, 0, 9, 9, 3, }, /* 25 (24.955) */ - { 4, 2, 0, 9, 8, 2, }, /* 25 (24.853) */ - { 4, 2, 0, 9, 7, 6, }, /* 25 (24.881) */ - { 6, 3, 0, 6, 3, 2, }, /* 25 (24.939) */ - { 3, 2, 0, 9, 8, 5, }, /* 25 (24.996) */ - { 2, 2, 0, 15, 3, 3, }, /* 25 (24.310) */ - { 4, 2, 0, 9, 9, 3, }, /* 25 (24.955) */ - { 4, 4, 2, 7, 6, 3, }, /* 25 (24.984) */ - { 3, 2, 0, 9, 7, 6, }, /* 25 (24.866) */ - -}; - -const Word16 no_lead_p_fx[][MAX_NO_SCALES * 2] = // Q0 -{ - - { 2, 1, 0, 0, 0, 0, }, /* 9 (8.464) */ - { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */ - { 5, 5, 2, 4, 2, 0, }, /* 23 (22.959) */ - { 8, 5, 2, 4, 0, 0, }, /* 24 (23.949) */ - { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ - { 13, 11, 5, 5, 2, 0, }, /* 27 (26.902) */ - { 11, 10, 5, 6, 5, 2, }, /* 28 (27.996) */ - { 14, 13, 5, 7, 5, 2, }, /* 29 (28.937) */ - { 16, 13, 5, 8, 7, 2, }, /* 30 (29.954) */ - { 21, 21, 5, 8, 5, 2, }, /* 31 (30.978) */ - { 24, 21, 5, 8, 8, 4, }, /* 32 (31.978) */ - { 32, 23, 5, 13, 11, 5, }, /* 34 (33.975) */ - { 36, 31, 8, 16, 13, 5, }, /* 35 (34.975) */ - { 45, 35, 16, 18, 13, 5, }, /* 36 (35.889) */ - { 45, 35, 16, 38, 31, 8, }, /* 39 (38.488) */ /* V WB*/ /* 14 */ - - { 2, 0, 0, 0, 0, 0, }, /* 8 (7.913) */ - { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */ - { 8, 7, 2, 2, 2, 0, }, /* 23 (22.773) */ - { 13, 11, 5, 2, 1, 0, }, /* 24 (23.999) */ - { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ - { 13, 11, 5, 5, 2, 1, }, /* 27 (26.962) */ - { 13, 11, 5, 5, 5, 2, }, /* 28 (27.835) */ - { 14, 13, 5, 7, 5, 2, }, /* 29 (28.937) */ - { 23, 21, 5, 5, 5, 2, }, /* 30 (29.969) */ - { 23, 18, 5, 8, 5, 2, }, /* 31 (30.952) */ - { 24, 21, 5, 8, 8, 4, }, /* 32 (31.978) */ - { 43, 41, 13, 9, 8, 5, }, /* 34 (33.992) */ - { 43, 36, 13, 13, 10, 5, }, /* 35 (35.000) */ - { 43, 40, 13, 17, 13, 9, }, /* 36 (35.980) */ - { 43, 42, 13, 31, 30, 18, }, /* 39 (38.512) */ /* V NB*/ /* 29 */ - - { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */ - { 5, 4, 1, 1, 0, 0, }, /* 19 (18.745) */ - { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */ - { 10, 9, 5, 2, 0, 0, }, /* 23 (22.791) */ - { 14, 13, 8, 2, 0, 0, }, /* 24 (23.999) */ - { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */ - { 18, 17, 13, 2, 2, 0, }, /* 26 (25.934) */ - { 14, 13, 8, 5, 4, 0, }, /* 28 (27.969) */ - { 18, 17, 13, 5, 4, 2, }, /* 29 (28.996) */ - { 22, 21, 13, 5, 5, 2, }, /* 30 (29.988) */ - { 31, 23, 21, 5, 5, 2, }, /* 31 (30.931) */ - { 27, 23, 21, 8, 5, 2, }, /* 32 (31.987) */ - { 31, 23, 21, 9, 8, 5, }, /* 33 (32.982) */ - { 32, 31, 24, 11, 8, 5, }, /* 34 (33.967) */ - { 32, 32, 28, 13, 11, 8, }, /* 35 (34.994) */ /* G WB*/ /* 44 */ - - { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */ - { 5, 4, 2, 1, 0, 0, }, /* 19 (18.792) */ - { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */ - { 8, 7, 2, 2, 2, 0, }, /* 23 (22.773) */ - { 13, 11, 2, 2, 1, 0, }, /* 24 (23.932) */ - { 16, 13, 2, 2, 2, 0, }, /* 25 (24.955) */ - { 21, 17, 2, 2, 2, 0, }, /* 26 (25.991) */ - { 13, 12, 2, 5, 5, 2, }, /* 28 (27.979) */ - { 18, 16, 2, 5, 5, 2, }, /* 29 (28.878) */ - { 23, 21, 2, 5, 5, 2, }, /* 30 (29.954) */ - { 32, 28, 2, 5, 5, 2, }, /* 31 (30.893) */ - { 38, 31, 2, 7, 5, 2, }, /* 32 (31.963) */ - { 33, 31, 2, 8, 8, 4, }, /* 33 (32.997) */ - { 42, 31, 2, 9, 9, 8, }, /* 34 (33.986) */ - { 42, 31, 2, 13, 11, 9, }, /* 35 (34.952) */ /* G NB*/ /* 59 */ - - { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ - { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ - { 13, 8, 5, 4, 2, 0, }, /* 26 */ - { 13, 8, 5, 8, 6, 2, }, /* 29 */ - { 13, 8, 5, 9, 8, 5, }, /* 30 */ - { 48, 48, 48, 36, 36, 28 }, /* 40 */ /* mode 7 AUDIO_WB */ /* 65*/ - - { 7, 5, 2, 2, 0, 0 }, /* 21 */ - { 13, 13, 9, 2, 2, 0 }, /* 25 */ - { 18, 18, 9, 2, 2, 0 }, /* 26 */ - { 24, 23, 10, 5, 4, 2 }, /* 30 */ - { 31, 31, 12, 5, 5, 2 }, /* 31 */ /*AUDIO_NB */ /* 70 */ - { 43, 34, 12, 5, 5, 4 }, /* 32 */ /*AUDIO_NB */ /* 71 */ - { 13, 8, 5, 9, 8, 5, }, /* 30 */ - { 48, 48, 45, 45, 31, 25 }, /* 40 */ /* mode AUDIO_WB 16k */ /* 73*/ - - { 2, 0, 0, 2, 2, 0, }, /* 17 (16.823) */ - { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ - { 7, 5, 2, 2, 2, 0, }, /* 22 (21.907) */ - { 13, 11, 10, 2, 2, 0, }, /* 25 (24.863) */ - { 18, 18, 10, 2, 2, 0, }, /* 26 (25.921) */ - { 13, 9, 9, 5, 2, 0, }, /* 27 (26.837) */ - { 40, 28, 25, 18, 17, 2, }, /* 36 (35.998) */ /* INACTIVE NB*/ /* 80*/ - - { 18, 17, 11, 0, 0, 0, }, /* 17 (16.932) */ - { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ - { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */ - { 13, 13, 9, 2, 2, 0, }, /* 25 (24.845) */ - { 18, 18, 12, 2, 2, 0, }, /* 26 (25.999) */ - { 23, 23, 16, 2, 2, 0, }, /* 27 (26.981) */ - { 36, 32, 24, 17, 13, 13, }, /* 36 (35.929) */ /* INACTIVE WB */ /* 87 */ - - { 2, 2, 0, 2, 0, 0, }, /* 17 (16.823) */ - { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ - { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */ - { 13, 13, 9, 2, 2, 0, }, /* 25 (24.845) */ - { 18, 17, 13, 2, 2, 0, }, /* 26 (25.934) */ - { 23, 22, 17, 2, 2, 0, }, /* 27 (26.914) */ - { 34, 32, 24, 16, 16, 13, }, /* 36 (35.915) */ /* INACTIVE WB 16k*/ /* 94 */ - - { 4, 2, 0, 1, 0, 0, }, /* 18 (17.479) */ - { 5, 4, 0, 1, 0, 0, }, /* 19 (18.703) */ - { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */ - { 10, 9, 5, 2, 0, 0, }, /* 23 (22.791) */ - { 15, 13, 5, 2, 0, 0, }, /* 24 (23.999) */ - { 18, 16, 8, 5, 5, 1, }, /* 29 (28.966) */ - { 42, 32, 31, 5, 5, 2, }, /* 32 (31.990) */ /* UNVOICED NB*/ /* 100 */ - - { 1, 0, 0, 1, 0, 0, }, /* 14 (13.640) */ - { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */ - { 4, 2, 0, 1, 0, 0, }, /* 18 (17.479) */ - { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */ - { 5, 4, 0, 2, 0, 0, }, /* 20 (19.796) */ - { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ - { 11, 10, 5, 6, 5, 2, }, /* 28 (27.996) */ /* UNVOICED WB */ /* 106 */ - { 9, 3, 0, 4, 0, 0, }, /* 24 (23.818) */ - { 18, 13, 10, 8, 3, 0, }, /* 30 (29.992) */ - { 24, 18, 10, 9, 3, 0, }, /* 31 (30.998) */ - { 32, 25, 10, 9, 3, 0, }, /* 32 (31.987) */ - { 42, 31, 10, 12, 3, 2, }, /* 34 (33.994) */ - { 44, 32, 27, 15, 3, 2, }, /* 35 (35.000) */ - { 44, 32, 25, 19, 3, 2, }, /* 36 (35.994) */ - { 48, 39, 32, 35, 15, 3, }, /* 39 (38.301) */ /* VOICED 16k */ - { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */ /* 107 */ - { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */ - { 32, 31, 18, 9, 7, 5, }, /* 33 (32.990) */ - { 31, 31, 18, 11, 9, 8, }, /* 34 (33.974) */ - { 32, 32, 20, 13, 12, 8, }, /* 35 (34.989) */ - { 32, 32, 23, 18, 17, 8, }, /* 36 (35.988) */ - { 32, 32, 23, 23, 22, 10, }, /* 37 (36.989) */ /* GENERIC 16k*/ /* 113 */ - - { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */ /* 114 */ - { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ - { 14, 13, 8, 2, 0, 0, }, /* 24 (23.999) */ - { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ - { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */ - { 16, 13, 8, 4, 2, 0, }, /* 27 (26.883) */ - { 13, 13, 8, 5, 4, 2, }, /* 28 (27.901) */ - { 23, 18, 13, 5, 5, 2, }, /* 30 (29.916) */ - { 23, 23, 13, 7, 5, 2, }, /* 31 (30.993) */ - { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */ - { 32, 31, 24, 8, 7, 2, }, /* 33 (32.958) */ - { 42, 32, 31, 9, 9, 4, }, /* 34 (33.987) */ - { 40, 32, 29, 12, 9, 9, }, /* 35 (34.994) */ - { 40, 32, 31, 17, 11, 11, }, /* 36 (35.968) */ - { 41, 32, 31, 20, 18, 13, }, /* 37 (36.971) */ /* GENERIC 12.8k MA*/ /* 128 */ - - { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */ /* 129 */ - { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */ - { 31, 31, 18, 9, 8, 2, }, /* 33 (32.995) */ - { 48, 32, 24, 9, 8, 3, }, /* 34 (33.993) */ - { 48, 32, 28, 11, 10, 3, }, /* 35 (34.992) */ - { 48, 37, 32, 16, 12, 4, }, /* 36 (35.997) */ - { 48, 37, 32, 18, 17, 12, }, /* 37 (36.961) */ /* AUDIO 16k */ + { 1, 0, 0, 1, 0, 0, }, /* 14 */ + { 2, 0, 0, 1, 0, 0, }, /* 15 */ + { 4, 2, 0, 1, 0, 0, }, /* 18 */ + { 4, 2, 0, 2, 0, 0, }, /* 19 */ + { 7, 5, 2, 5, 4, 2, }, /* 25 */ + { 8, 8, 3, 8, 6, 2, }, /* 28 */ /* mode UV WB*/ + { 4, 2, 0, 1, 0, 0, }, /* 18 */ + { 4, 0, 0, 2, 1, 0, }, /* 19 */ + { 9, 8, 8, 2, 2, 1, }, /* 24 */ + { 8, 5, 2, 5, 2, 1, }, /* 25 */ + { 18, 16, 8, 5, 5, 1, }, /* 29 */ + { 24, 21, 10, 8, 8, 2, }, /* 32 */ /* mode UV NB*/ + + { 2, 0, 0, 2, 0, 0, }, /* 17 */ + { 4, 2, 0, 1, 0, 0, }, /* 18 */ + { 7, 5, 2, 2, 0, 0, }, /* 21 */ + { 5, 2, 1, 4, 1, 0, }, /* 22 */ + { 8, 5, 2, 5, 2, 0, }, /* 25 */ + { 8, 7, 4, 5, 3, 2, }, + { 8, 8, 4, 6, 5, 2, }, + { 13, 8, 5, 6, 5, 2, }, + { 13, 8, 5, 8, 6, 2, }, + { 13, 8, 5, 11, 8, 2, }, /* 30 */ + { 24, 21, 8, 9, 8, 2, }, /* 32 */ + { 23, 18, 8, 13, 11, 3, }, + { 23, 21, 8, 17, 13, 4, }, /* 34 */ + { 31, 31, 17, 26, 25, 9, }, /* 37 */ /* mode V WB*/ + { 2, 0, 0, 2, 2, 0, }, /* 17 */ + { 4, 2, 0, 1, 0, 0, }, /* 18 */ + { 7, 5, 2, 2, 2, 0, }, /* 22 */ + { 8, 7, 2, 2, 2, 0, }, /* 23 */ + { 11, 8, 2, 2, 2, 0, }, /* 24 */ + { 13, 13, 9, 2, 2, 0, }, /* 25 */ + { 13, 11, 7, 5, 2, 0, }, /* 27 */ + { 18, 14, 9, 5, 5, 2, }, /* 29 */ + { 31, 31, 14, 11, 11, 5, }, /* 34 */ + { 31, 31, 27, 24, 21, 14, }, /* 37 */ /* mode V NB */ + { 5, 4, 0, 0, 0, 0, }, /* 12 (11.883) */ + { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */ + { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */ + { 5, 4, 0, 2, 0, 0, }, /* 20 (19.796) */ + { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ + { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */ + { 5, 5, 2, 4, 2, 0, }, /* 23 (22.959) */ + { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ + { 8, 8, 7, 5, 2, 0, }, /* 26 (25.904) */ + { 13, 9, 8, 5, 2, 0, }, /* 27 (26.829) */ + { 13, 11, 8, 5, 5, 1, }, /* 28 (27.989) */ + { 13, 9, 8, 8, 5, 2, }, /* 29 (28.984) */ + { 22, 16, 10, 6, 5, 2, }, /* 30 (29.980) */ + { 21, 14, 10, 8, 7, 2, }, /* 31 (30.966) */ + { 24, 21, 10, 8, 8, 2, }, /* 32 (31.995) */ /* G WB*/ + + { 5, 4, 1, 0, 0, 0, }, /* 12 (11.925) */ + { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */ + { 5, 4, 1, 1, 0, 0, }, /* 19 (18.745) */ + { 5, 4, 1, 2, 0, 0, }, /* 20 (19.838) */ + { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ + { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */ + { 9, 8, 5, 2, 1, 0, }, /* 23 (22.815) */ + { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */ + { 13, 8, 7, 4, 2, 0, }, /* 26 (25.993) */ + { 13, 9, 8, 5, 2, 2, }, /* 27 (26.954) */ + { 18, 13, 8, 5, 2, 2, }, /* 28 (27.992) */ + { 21, 13, 11, 5, 3, 2, }, /* 29 (28.996) */ + { 22, 21, 13, 5, 5, 2, }, /* 30 (29.988) */ + { 23, 21, 17, 7, 5, 2, }, /* 31 (30.962) */ + { 27, 23, 21, 8, 5, 2, }, /* 32 (31.987) */ /* G NB*/ + { 2, 0, 0, 2, 0, 0, }, /* 17 */ + { 4, 2, 0, 1, 0, 0, }, /* 18 */ + { 4, 1, 0, 4, 0, 0, }, /* 21 */ + { 5, 2, 0, 4, 1, 0, }, /* 22 */ + { 8, 5, 2, 4, 0, 0, }, /* 24 */ + { 8, 5, 2, 5, 2, 0, }, /* 25 */ + { 14, 10, 5, 5, 5, 1, }, /* 28 */ + { 14, 10, 5, 8, 8, 4, }, /* 30 */ + { 13, 10, 5, 13, 8, 8, }, + { 23, 21, 8, 8, 8, 4, }, + { 23, 18, 5, 13, 8, 8, }, /* 33 */ + /* mode T WB */ + { 2, 0, 0, 2, 2, 0, }, /* 17 */ + { 4, 2, 0, 1, 0, 0, }, /* 18 */ + { 7, 5, 2, 2, 2, 0, }, /* 22 */ + { 8, 7, 4, 2, 2, 0, }, /* 23 */ + { 11, 8, 5, 2, 2, 0, }, /* 24 */ + { 18, 8, 5, 2, 2, 0, }, /* 25 */ + { 16, 8, 5, 5, 5, 2, }, /* 28 */ + { 28, 23, 8, 5, 5, 5, }, /* 31 */ + { 31, 31, 8, 5, 5, 7, }, /* 32 */ /* mode T NB */ + + { 18, 18, 11, 9, 6, 5, }, /* 31 */ + { 24, 23, 13, 9, 6, 5, }, /* 32 */ /* mode G 16k */ + + { 24, 23, 13, 9, 6, 5, }, /* 32 (31.998) */ + { 36, 31, 18, 9, 6, 5, }, /* 33 (32.983) */ /* T 16k */ + + { 2, 0, 0, 2, 2, 0, }, /* 17 */ + { 7, 5, 2, 2, 0, 0, }, /* 21 */ + { 7, 5, 2, 2, 2, 0, }, /* 22 */ + { 9, 8, 3, 4, 2, 0, }, /* 25 */ + { 11, 9, 8, 4, 2, 0, }, /* 26 */ + { 48, 48, 34, 13, 11, 9 }, /* 36 */ /* mode AUDIO_WB 36 + 4 + 1 */ + + { 22, 10, 3, 0, 0, 0 }, /* 17 */ + { 6, 6, 2, 2, 0, 0 }, /* 21 */ + { 6, 6, 2, 2, 2, 0 }, /* 22 */ + { 23, 10, 3, 2, 2, 0 }, /* 26 */ + { 32, 16, 3, 2, 2, 0 }, /* 27 */ /* AUDIO_NB */ + { 39, 30, 12, 2, 2, 0 }, /* 28 */ /* AUDIO_NB */ + { 11, 9, 8, 4, 2, 0, }, /* 26 */ + { 48, 48, 48, 13, 9, 8 }, /* 36 */ /* mode AUDIO_WB 16k 15-36 + 4 + 1*/ + { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */ + { 13, 13, 5, 5, 5, 0, }, /* 28 (27.994) */ + { 18, 17, 5, 5, 5, 1, }, /* 29 (28.996) */ + { 17, 13, 5, 8, 6, 2, }, /* 30 (29.991) */ + { 23, 21, 8, 9, 8, 3, }, /* 32 (31.992) */ + { 31, 29, 16, 8, 8, 3, }, /* 33 (32.993) */ + { 31, 25, 16, 12, 8, 8, }, /* 34 (33.968) */ + { 46, 48, 18, 18, 18, 12, }, /* 37 (36.995) */ /* VOICED 16k */ + { 14, 12, 9, 2, 2, 0, }, /* 25 (24.980) */ + { 15, 13, 3, 2, 2, 0, }, /* 25 (24.974) */ + { 17, 3, 0, 2, 2, 1, }, /* 25 (24.852) */ + { 13, 10, 3, 2, 2, 2, }, /* 25 (24.994) */ + { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */ + { 7, 3, 0, 5, 3, 1, }, /* 25 (24.671) */ + { 4, 3, 2, 6, 6, 5, }, /* 25 (24.936) */ + { 4, 2, 0, 9, 9, 3, }, /* 25 (24.955) */ + { 4, 2, 0, 9, 8, 2, }, /* 25 (24.853) */ + { 4, 2, 0, 9, 7, 6, }, /* 25 (24.881) */ + { 6, 3, 0, 6, 3, 2, }, /* 25 (24.939) */ + { 3, 2, 0, 9, 8, 5, }, /* 25 (24.996) */ + { 2, 2, 0, 15, 3, 3, }, /* 25 (24.310) */ + { 4, 2, 0, 9, 9, 3, }, /* 25 (24.955) */ + { 4, 4, 2, 7, 6, 3, }, /* 25 (24.984) */ + { 3, 2, 0, 9, 7, 6, }, /* 25 (24.866) */ + +}; + +const Word16 no_lead_p_fx[][MAX_NO_SCALES * 2] = // Q0 +{ + + { 2, 1, 0, 0, 0, 0, }, /* 9 (8.464) */ + { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */ + { 5, 5, 2, 4, 2, 0, }, /* 23 (22.959) */ + { 8, 5, 2, 4, 0, 0, }, /* 24 (23.949) */ + { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ + { 13, 11, 5, 5, 2, 0, }, /* 27 (26.902) */ + { 11, 10, 5, 6, 5, 2, }, /* 28 (27.996) */ + { 14, 13, 5, 7, 5, 2, }, /* 29 (28.937) */ + { 16, 13, 5, 8, 7, 2, }, /* 30 (29.954) */ + { 21, 21, 5, 8, 5, 2, }, /* 31 (30.978) */ + { 24, 21, 5, 8, 8, 4, }, /* 32 (31.978) */ + { 32, 23, 5, 13, 11, 5, }, /* 34 (33.975) */ + { 36, 31, 8, 16, 13, 5, }, /* 35 (34.975) */ + { 45, 35, 16, 18, 13, 5, }, /* 36 (35.889) */ + { 45, 35, 16, 38, 31, 8, }, /* 39 (38.488) */ /* V WB*/ /* 14 */ + + { 2, 0, 0, 0, 0, 0, }, /* 8 (7.913) */ + { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */ + { 8, 7, 2, 2, 2, 0, }, /* 23 (22.773) */ + { 13, 11, 5, 2, 1, 0, }, /* 24 (23.999) */ + { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ + { 13, 11, 5, 5, 2, 1, }, /* 27 (26.962) */ + { 13, 11, 5, 5, 5, 2, }, /* 28 (27.835) */ + { 14, 13, 5, 7, 5, 2, }, /* 29 (28.937) */ + { 23, 21, 5, 5, 5, 2, }, /* 30 (29.969) */ + { 23, 18, 5, 8, 5, 2, }, /* 31 (30.952) */ + { 24, 21, 5, 8, 8, 4, }, /* 32 (31.978) */ + { 43, 41, 13, 9, 8, 5, }, /* 34 (33.992) */ + { 43, 36, 13, 13, 10, 5, }, /* 35 (35.000) */ + { 43, 40, 13, 17, 13, 9, }, /* 36 (35.980) */ + { 43, 42, 13, 31, 30, 18, }, /* 39 (38.512) */ /* V NB*/ /* 29 */ + + { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */ + { 5, 4, 1, 1, 0, 0, }, /* 19 (18.745) */ + { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */ + { 10, 9, 5, 2, 0, 0, }, /* 23 (22.791) */ + { 14, 13, 8, 2, 0, 0, }, /* 24 (23.999) */ + { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */ + { 18, 17, 13, 2, 2, 0, }, /* 26 (25.934) */ + { 14, 13, 8, 5, 4, 0, }, /* 28 (27.969) */ + { 18, 17, 13, 5, 4, 2, }, /* 29 (28.996) */ + { 22, 21, 13, 5, 5, 2, }, /* 30 (29.988) */ + { 31, 23, 21, 5, 5, 2, }, /* 31 (30.931) */ + { 27, 23, 21, 8, 5, 2, }, /* 32 (31.987) */ + { 31, 23, 21, 9, 8, 5, }, /* 33 (32.982) */ + { 32, 31, 24, 11, 8, 5, }, /* 34 (33.967) */ + { 32, 32, 28, 13, 11, 8, }, /* 35 (34.994) */ /* G WB*/ /* 44 */ + + { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */ + { 5, 4, 2, 1, 0, 0, }, /* 19 (18.792) */ + { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */ + { 8, 7, 2, 2, 2, 0, }, /* 23 (22.773) */ + { 13, 11, 2, 2, 1, 0, }, /* 24 (23.932) */ + { 16, 13, 2, 2, 2, 0, }, /* 25 (24.955) */ + { 21, 17, 2, 2, 2, 0, }, /* 26 (25.991) */ + { 13, 12, 2, 5, 5, 2, }, /* 28 (27.979) */ + { 18, 16, 2, 5, 5, 2, }, /* 29 (28.878) */ + { 23, 21, 2, 5, 5, 2, }, /* 30 (29.954) */ + { 32, 28, 2, 5, 5, 2, }, /* 31 (30.893) */ + { 38, 31, 2, 7, 5, 2, }, /* 32 (31.963) */ + { 33, 31, 2, 8, 8, 4, }, /* 33 (32.997) */ + { 42, 31, 2, 9, 9, 8, }, /* 34 (33.986) */ + { 42, 31, 2, 13, 11, 9, }, /* 35 (34.952) */ /* G NB*/ /* 59 */ + + { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ + { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ + { 13, 8, 5, 4, 2, 0, }, /* 26 */ + { 13, 8, 5, 8, 6, 2, }, /* 29 */ + { 13, 8, 5, 9, 8, 5, }, /* 30 */ + { 48, 48, 48, 36, 36, 28 }, /* 40 */ /* mode 7 AUDIO_WB */ /* 65*/ + + { 7, 5, 2, 2, 0, 0 }, /* 21 */ + { 13, 13, 9, 2, 2, 0 }, /* 25 */ + { 18, 18, 9, 2, 2, 0 }, /* 26 */ + { 24, 23, 10, 5, 4, 2 }, /* 30 */ + { 31, 31, 12, 5, 5, 2 }, /* 31 */ /*AUDIO_NB */ /* 70 */ + { 43, 34, 12, 5, 5, 4 }, /* 32 */ /*AUDIO_NB */ /* 71 */ + { 13, 8, 5, 9, 8, 5, }, /* 30 */ + { 48, 48, 45, 45, 31, 25 }, /* 40 */ /* mode AUDIO_WB 16k */ /* 73*/ + + { 2, 0, 0, 2, 2, 0, }, /* 17 (16.823) */ + { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ + { 7, 5, 2, 2, 2, 0, }, /* 22 (21.907) */ + { 13, 11, 10, 2, 2, 0, }, /* 25 (24.863) */ + { 18, 18, 10, 2, 2, 0, }, /* 26 (25.921) */ + { 13, 9, 9, 5, 2, 0, }, /* 27 (26.837) */ + { 40, 28, 25, 18, 17, 2, }, /* 36 (35.998) */ /* INACTIVE NB*/ /* 80*/ + + { 18, 17, 11, 0, 0, 0, }, /* 17 (16.932) */ + { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ + { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */ + { 13, 13, 9, 2, 2, 0, }, /* 25 (24.845) */ + { 18, 18, 12, 2, 2, 0, }, /* 26 (25.999) */ + { 23, 23, 16, 2, 2, 0, }, /* 27 (26.981) */ + { 36, 32, 24, 17, 13, 13, }, /* 36 (35.929) */ /* INACTIVE WB */ /* 87 */ + + { 2, 2, 0, 2, 0, 0, }, /* 17 (16.823) */ + { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ + { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */ + { 13, 13, 9, 2, 2, 0, }, /* 25 (24.845) */ + { 18, 17, 13, 2, 2, 0, }, /* 26 (25.934) */ + { 23, 22, 17, 2, 2, 0, }, /* 27 (26.914) */ + { 34, 32, 24, 16, 16, 13, }, /* 36 (35.915) */ /* INACTIVE WB 16k*/ /* 94 */ + + { 4, 2, 0, 1, 0, 0, }, /* 18 (17.479) */ + { 5, 4, 0, 1, 0, 0, }, /* 19 (18.703) */ + { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */ + { 10, 9, 5, 2, 0, 0, }, /* 23 (22.791) */ + { 15, 13, 5, 2, 0, 0, }, /* 24 (23.999) */ + { 18, 16, 8, 5, 5, 1, }, /* 29 (28.966) */ + { 42, 32, 31, 5, 5, 2, }, /* 32 (31.990) */ /* UNVOICED NB*/ /* 100 */ + + { 1, 0, 0, 1, 0, 0, }, /* 14 (13.640) */ + { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */ + { 4, 2, 0, 1, 0, 0, }, /* 18 (17.479) */ + { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */ + { 5, 4, 0, 2, 0, 0, }, /* 20 (19.796) */ + { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ + { 11, 10, 5, 6, 5, 2, }, /* 28 (27.996) */ /* UNVOICED WB */ /* 106 */ + { 9, 3, 0, 4, 0, 0, }, /* 24 (23.818) */ + { 18, 13, 10, 8, 3, 0, }, /* 30 (29.992) */ + { 24, 18, 10, 9, 3, 0, }, /* 31 (30.998) */ + { 32, 25, 10, 9, 3, 0, }, /* 32 (31.987) */ + { 42, 31, 10, 12, 3, 2, }, /* 34 (33.994) */ + { 44, 32, 27, 15, 3, 2, }, /* 35 (35.000) */ + { 44, 32, 25, 19, 3, 2, }, /* 36 (35.994) */ + { 48, 39, 32, 35, 15, 3, }, /* 39 (38.301) */ /* VOICED 16k */ + { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */ /* 107 */ + { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */ + { 32, 31, 18, 9, 7, 5, }, /* 33 (32.990) */ + { 31, 31, 18, 11, 9, 8, }, /* 34 (33.974) */ + { 32, 32, 20, 13, 12, 8, }, /* 35 (34.989) */ + { 32, 32, 23, 18, 17, 8, }, /* 36 (35.988) */ + { 32, 32, 23, 23, 22, 10, }, /* 37 (36.989) */ /* GENERIC 16k*/ /* 113 */ + + { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */ /* 114 */ + { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */ + { 14, 13, 8, 2, 0, 0, }, /* 24 (23.999) */ + { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */ + { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */ + { 16, 13, 8, 4, 2, 0, }, /* 27 (26.883) */ + { 13, 13, 8, 5, 4, 2, }, /* 28 (27.901) */ + { 23, 18, 13, 5, 5, 2, }, /* 30 (29.916) */ + { 23, 23, 13, 7, 5, 2, }, /* 31 (30.993) */ + { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */ + { 32, 31, 24, 8, 7, 2, }, /* 33 (32.958) */ + { 42, 32, 31, 9, 9, 4, }, /* 34 (33.987) */ + { 40, 32, 29, 12, 9, 9, }, /* 35 (34.994) */ + { 40, 32, 31, 17, 11, 11, }, /* 36 (35.968) */ + { 41, 32, 31, 20, 18, 13, }, /* 37 (36.971) */ /* GENERIC 12.8k MA*/ /* 128 */ + + { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */ /* 129 */ + { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */ + { 31, 31, 18, 9, 8, 2, }, /* 33 (32.995) */ + { 48, 32, 24, 9, 8, 3, }, /* 34 (33.993) */ + { 48, 32, 28, 11, 10, 3, }, /* 35 (34.992) */ + { 48, 37, 32, 16, 12, 4, }, /* 36 (35.997) */ + { 48, 37, 32, 18, 17, 12, }, /* 37 (36.961) */ /* AUDIO 16k */ }; /*----------------------------------------------------------------------------------* @@ -4345,7 +4345,7 @@ const Word16 filt_lp_16kHz_fx[1 + L_FILT16k] = * Pulse indexing tables for ACELP innovation coding *-------------------------------------------------------------------*/ -const Word32 PI_select_table[23][8] = // Q0 +const Word32 PI_select_table[23][8] = // Q0 { {1, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0, 0}, @@ -4372,7 +4372,7 @@ const Word32 PI_select_table[23][8] = // Q0 {1, 22, 231, 1540, 7315, 26334, 74613, 1705444} }; -const Word32 PI_offset[8][8] = // Q0 +const Word32 PI_offset[8][8] = // Q0 { /* for 0p(0). */ {0x00000,0x00000,0x00000,0x00000,0x00000,0x00000,0x00000,0x00000}, @@ -4392,15 +4392,15 @@ const Word32 PI_offset[8][8] = // Q0 {0x00000,0x00000,0x165800,0x454400,0x654200,0x6E2500,0x6F2B80,0x6F36C0} }; -const Word16 PI_factor[7] = {0,0,120,560,1820,4368,8008}; // Q0 +const Word16 PI_factor[7] = {0,0,120,560,1820,4368,8008}; // Q0 /* ACELP pulse coding */ -const Word16 hi_to_low_tmpl[10] = { 0, 0, 0, 3, 9, 5, 3, 1, 8, 8 }; // Q0 -const UWord16 low_len[10] = { 0, 0, 8, 5, 7,11,13,15,16,16 }; // Q0 -const UWord16 low_mask[10] = { 0, 0, 255,31,127,2047,8191,32767,65535,65535 }; // Q0 -const UWord16 indx_fact[10] = { 0, 0,2,172,345,140,190,223,463,1732 }; // Q0 -const Word16 index_len[3] = { 0, 5, 9 }; // Q0 -const Word16 index_mask_ACELP[3] = { 0, 31, 511 }; // Q0 +const Word16 hi_to_low_tmpl[10] = { 0, 0, 0, 3, 9, 5, 3, 1, 8, 8 }; // Q0 +const UWord16 low_len[10] = { 0, 0, 8, 5, 7,11,13,15,16,16 }; // Q0 +const UWord16 low_mask[10] = { 0, 0, 255,31,127,2047,8191,32767,65535,65535 }; // Q0 +const UWord16 indx_fact[10] = { 0, 0,2,172,345,140,190,223,463,1732 }; // Q0 +const Word16 index_len[3] = { 0, 5, 9 }; // Q0 +const Word16 index_mask_ACELP[3] = { 0, 31, 511 }; // Q0 /*------------------------------------------------------------------------------* @@ -4874,88 +4874,88 @@ const Word16 edct_table_400_fx[] =/*Q16 */ const Word16 edct_table_320_16fx[320] =/*Q16 */ { - 7747, 7747, 7747, 7746, 7746, 7745, 7744, 7742, - 7741, 7739, 7737, 7735, 7733, 7730, 7728, 7725, - 7722, 7719, 7716, 7712, 7708, 7704, 7700, 7696, - 7692, 7687, 7682, 7677, 7672, 7666, 7661, 7655, - 7649, 7643, 7637, 7630, 7623, 7617, 7610, 7602, - 7595, 7587, 7580, 7572, 7563, 7555, 7547, 7538, - 7529, 7520, 7511, 7501, 7492, 7482, 7472, 7462, - 7451, 7441, 7430, 7419, 7408, 7397, 7386, 7374, - 7362, 7350, 7338, 7326, 7314, 7301, 7288, 7275, - 7262, 7249, 7235, 7221, 7208, 7194, 7179, 7165, - 7150, 7136, 7121, 7106, 7091, 7075, 7060, 7044, - 7028, 7012, 6995, 6979, 6962, 6946, 6929, 6912, - 6894, 6877, 6859, 6842, 6824, 6806, 6787, 6769, - 6750, 6732, 6713, 6694, 6674, 6655, 6635, 6616, - 6596, 6576, 6556, 6535, 6515, 6494, 6473, 6452, - 6431, 6410, 6388, 6367, 6345, 6323, 6301, 6279, - 6257, 6234, 6211, 6189, 6166, 6143, 6119, 6096, - 6072, 6049, 6025, 6001, 5977, 5953, 5928, 5904, - 5879, 5854, 5829, 5804, 5779, 5753, 5728, 5702, - 5676, 5650, 5624, 5598, 5572, 5545, 5518, 5492, - 5465, 5438, 5411, 5383, 5356, 5328, 5301, 5273, - 5245, 5217, 5189, 5160, 5132, 5104, 5075, 5046, - 5017, 4988, 4959, 4930, 4900, 4871, 4841, 4811, - 4781, 4751, 4721, 4691, 4661, 4630, 4600, 4569, - 4538, 4508, 4477, 4446, 4414, 4383, 4352, 4320, - 4288, 4257, 4225, 4193, 4161, 4129, 4097, 4064, - 4032, 3999, 3967, 3934, 3901, 3868, 3835, 3802, - 3769, 3736, 3702, 3669, 3635, 3602, 3568, 3534, - 3500, 3466, 3432, 3398, 3364, 3330, 3295, 3261, - 3226, 3192, 3157, 3122, 3087, 3052, 3017, 2982, - 2947, 2912, 2877, 2841, 2806, 2771, 2735, 2699, - 2664, 2628, 2592, 2556, 2520, 2484, 2448, 2412, - 2376, 2340, 2304, 2267, 2231, 2194, 2158, 2121, - 2085, 2048, 2011, 1975, 1938, 1901, 1864, 1827, - 1790, 1753, 1716, 1679, 1642, 1605, 1567, 1530, - 1493, 1455, 1418, 1381, 1343, 1306, 1268, 1231, - 1193, 1156, 1118, 1080, 1043, 1005, 967, 930, - 892, 854, 816, 778, 740, 703, 665, 627, - 589, 551, 513, 475, 437, 399, 361, 323, - 285, 247, 209, 171, 133, 95, 57, 19 + 7747, 7747, 7747, 7746, 7746, 7745, 7744, 7742, + 7741, 7739, 7737, 7735, 7733, 7730, 7728, 7725, + 7722, 7719, 7716, 7712, 7708, 7704, 7700, 7696, + 7692, 7687, 7682, 7677, 7672, 7666, 7661, 7655, + 7649, 7643, 7637, 7630, 7623, 7617, 7610, 7602, + 7595, 7587, 7580, 7572, 7563, 7555, 7547, 7538, + 7529, 7520, 7511, 7501, 7492, 7482, 7472, 7462, + 7451, 7441, 7430, 7419, 7408, 7397, 7386, 7374, + 7362, 7350, 7338, 7326, 7314, 7301, 7288, 7275, + 7262, 7249, 7235, 7221, 7208, 7194, 7179, 7165, + 7150, 7136, 7121, 7106, 7091, 7075, 7060, 7044, + 7028, 7012, 6995, 6979, 6962, 6946, 6929, 6912, + 6894, 6877, 6859, 6842, 6824, 6806, 6787, 6769, + 6750, 6732, 6713, 6694, 6674, 6655, 6635, 6616, + 6596, 6576, 6556, 6535, 6515, 6494, 6473, 6452, + 6431, 6410, 6388, 6367, 6345, 6323, 6301, 6279, + 6257, 6234, 6211, 6189, 6166, 6143, 6119, 6096, + 6072, 6049, 6025, 6001, 5977, 5953, 5928, 5904, + 5879, 5854, 5829, 5804, 5779, 5753, 5728, 5702, + 5676, 5650, 5624, 5598, 5572, 5545, 5518, 5492, + 5465, 5438, 5411, 5383, 5356, 5328, 5301, 5273, + 5245, 5217, 5189, 5160, 5132, 5104, 5075, 5046, + 5017, 4988, 4959, 4930, 4900, 4871, 4841, 4811, + 4781, 4751, 4721, 4691, 4661, 4630, 4600, 4569, + 4538, 4508, 4477, 4446, 4414, 4383, 4352, 4320, + 4288, 4257, 4225, 4193, 4161, 4129, 4097, 4064, + 4032, 3999, 3967, 3934, 3901, 3868, 3835, 3802, + 3769, 3736, 3702, 3669, 3635, 3602, 3568, 3534, + 3500, 3466, 3432, 3398, 3364, 3330, 3295, 3261, + 3226, 3192, 3157, 3122, 3087, 3052, 3017, 2982, + 2947, 2912, 2877, 2841, 2806, 2771, 2735, 2699, + 2664, 2628, 2592, 2556, 2520, 2484, 2448, 2412, + 2376, 2340, 2304, 2267, 2231, 2194, 2158, 2121, + 2085, 2048, 2011, 1975, 1938, 1901, 1864, 1827, + 1790, 1753, 1716, 1679, 1642, 1605, 1567, 1530, + 1493, 1455, 1418, 1381, 1343, 1306, 1268, 1231, + 1193, 1156, 1118, 1080, 1043, 1005, 967, 930, + 892, 854, 816, 778, 740, 703, 665, 627, + 589, 551, 513, 475, 437, 399, 361, 323, + 285, 247, 209, 171, 133, 95, 57, 19 }; const Word16 edct_table_128_16fx[128] = /*Q15 */ { - 9742, 9740, 9737, 9733, 9727, 9720, 9711, 9701, - 9689, 9676, 9661, 9645, 9627, 9608, 9588, 9566, - 9543, 9518, 9492, 9464, 9435, 9405, 9373, 9339, - 9305, 9269, 9231, 9192, 9152, 9110, 9067, 9023, - 8977, 8930, 8882, 8832, 8781, 8728, 8675, 8619, - 8563, 8505, 8447, 8386, 8325, 8262, 8198, 8133, - 8067, 7999, 7930, 7860, 7789, 7717, 7643, 7568, - 7492, 7415, 7337, 7258, 7178, 7097, 7014, 6931, - 6846, 6761, 6674, 6586, 6498, 6408, 6318, 6226, - 6134, 6040, 5946, 5851, 5755, 5658, 5560, 5462, - 5362, 5262, 5161, 5059, 4957, 4854, 4750, 4645, - 4539, 4433, 4327, 4219, 4111, 4002, 3893, 3783, - 3673, 3562, 3450, 3338, 3226, 3113, 2999, 2885, - 2771, 2656, 2541, 2425, 2309, 2193, 2076, 1959, - 1842, 1724, 1607, 1489, 1370, 1252, 1133, 1014, - 895, 776, 657, 538, 418, 299, 179, 60 + 9742, 9740, 9737, 9733, 9727, 9720, 9711, 9701, + 9689, 9676, 9661, 9645, 9627, 9608, 9588, 9566, + 9543, 9518, 9492, 9464, 9435, 9405, 9373, 9339, + 9305, 9269, 9231, 9192, 9152, 9110, 9067, 9023, + 8977, 8930, 8882, 8832, 8781, 8728, 8675, 8619, + 8563, 8505, 8447, 8386, 8325, 8262, 8198, 8133, + 8067, 7999, 7930, 7860, 7789, 7717, 7643, 7568, + 7492, 7415, 7337, 7258, 7178, 7097, 7014, 6931, + 6846, 6761, 6674, 6586, 6498, 6408, 6318, 6226, + 6134, 6040, 5946, 5851, 5755, 5658, 5560, 5462, + 5362, 5262, 5161, 5059, 4957, 4854, 4750, 4645, + 4539, 4433, 4327, 4219, 4111, 4002, 3893, 3783, + 3673, 3562, 3450, 3338, 3226, 3113, 2999, 2885, + 2771, 2656, 2541, 2425, 2309, 2193, 2076, 1959, + 1842, 1724, 1607, 1489, 1370, 1252, 1133, 1014, + 895, 776, 657, 538, 418, 299, 179, 60 }; const Word16 edct_table_160_16fx[160] =//Q15 { - 9213, 9212, 9211, 9208, 9204, 9200, 9195, 9188, - 9181, 9173, 9164, 9155, 9144, 9132, 9120, 9107, - 9093, 9078, 9062, 9045, 9027, 9009, 8989, 8969, - 8948, 8926, 8903, 8880, 8855, 8830, 8803, 8776, - 8748, 8719, 8690, 8659, 8628, 8596, 8563, 8529, - 8495, 8459, 8423, 8386, 8348, 8309, 8270, 8230, - 8188, 8147, 8104, 8061, 8016, 7971, 7926, 7879, - 7832, 7784, 7735, 7686, 7635, 7584, 7533, 7480, - 7427, 7373, 7319, 7263, 7207, 7151, 7093, 7035, - 6976, 6917, 6857, 6796, 6735, 6673, 6610, 6547, - 6483, 6418, 6353, 6287, 6221, 6154, 6086, 6018, - 5949, 5880, 5810, 5739, 5668, 5597, 5525, 5452, - 5379, 5305, 5231, 5156, 5081, 5005, 4929, 4852, - 4775, 4698, 4620, 4541, 4462, 4383, 4303, 4223, - 4142, 4061, 3980, 3898, 3816, 3734, 3651, 3568, - 3484, 3400, 3316, 3231, 3146, 3061, 2976, 2890, - 2804, 2718, 2631, 2544, 2457, 2370, 2282, 2195, - 2107, 2019, 1930, 1842, 1753, 1664, 1575, 1486, - 1397, 1307, 1218, 1128, 1038, 948, 858, 768, - 678, 588, 497, 407, 317, 226, 136, 45 + 9213, 9212, 9211, 9208, 9204, 9200, 9195, 9188, + 9181, 9173, 9164, 9155, 9144, 9132, 9120, 9107, + 9093, 9078, 9062, 9045, 9027, 9009, 8989, 8969, + 8948, 8926, 8903, 8880, 8855, 8830, 8803, 8776, + 8748, 8719, 8690, 8659, 8628, 8596, 8563, 8529, + 8495, 8459, 8423, 8386, 8348, 8309, 8270, 8230, + 8188, 8147, 8104, 8061, 8016, 7971, 7926, 7879, + 7832, 7784, 7735, 7686, 7635, 7584, 7533, 7480, + 7427, 7373, 7319, 7263, 7207, 7151, 7093, 7035, + 6976, 6917, 6857, 6796, 6735, 6673, 6610, 6547, + 6483, 6418, 6353, 6287, 6221, 6154, 6086, 6018, + 5949, 5880, 5810, 5739, 5668, 5597, 5525, 5452, + 5379, 5305, 5231, 5156, 5081, 5005, 4929, 4852, + 4775, 4698, 4620, 4541, 4462, 4383, 4303, 4223, + 4142, 4061, 3980, 3898, 3816, 3734, 3651, 3568, + 3484, 3400, 3316, 3231, 3146, 3061, 2976, 2890, + 2804, 2718, 2631, 2544, 2457, 2370, 2282, 2195, + 2107, 2019, 1930, 1842, 1753, 1664, 1575, 1486, + 1397, 1307, 1218, 1128, 1038, 948, 858, 768, + 678, 588, 497, 407, 317, 226, 136, 45 }; @@ -4965,8 +4965,8 @@ const Word16 edct_table_160_16fx[160] =//Q15 const Word16 mean_isf_amr_wb_fx[M] =/*Qlog2(2.56)*/ { - 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730, - 8750, 9753,10705, 11728, 12833, 13971,15043, 4037 + 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730, + 8750, 9753,10705, 11728, 12833, 13971,15043, 4037 };/*1.28f Q1*/ /*----------------------------------------------------------------------------------* @@ -4975,8 +4975,8 @@ const Word16 mean_isf_amr_wb_fx[M] =/*Qlog2(2.56)*/ const Word16 mean_isf_noise_amr_wb_fx[M] =/*Qlog2(2.56)*/ { - 478, 1100, 2213, 3267, 4219, 5222, 6198, 7240, - 8229, 9153,10098, 11108, 12144, 13184,14165, 3803 + 478, 1100, 2213, 3267, 4219, 5222, 6198, 7240, + 8229, 9153,10098, 11108, 12144, 13184,14165, 3803 };/*14Q1*1.28*/ /* ISF codebook - common 1st stage, 1st split (only in AMR-WB IO mode) */ @@ -4984,47 +4984,47 @@ const Word16 mean_isf_noise_amr_wb_fx[M] =/*Qlog2(2.56)*/ * Indirection for 1st stage 1st split of 46 bit cb. : The transmitted_index = indirect_dico1[found_index]; *------------------------------------------------------*/ -const Word16 Indirect_dico1[SIZE_BK1] = // Q0 -{ - 2, 6, 18, 22, 34, 35, 38, 50, - 66, 67, 70, 82, 98, 99, 102, 130, - 131, 134, 146, 150, 162, 178, 194, 198, - 210, 226, 230, 242, 0, 1, 3, 4, - 5, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 19, 20, 21, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 36, 37, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 51, - 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 68, 69, - 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 100, 101, 103, 104, 105, 106, - 107, 108, 109, 110, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, - 123, 124, 125, 126, 127, 128, 129, 132, - 133, 135, 136, 137, 138, 139, 140, 141, - 142, 143, 144, 145, 147, 148, 149, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 163, 164, 165, 166, 167, 168, - 169, 170, 171, 172, 173, 174, 175, 176, - 177, 179, 180, 181, 182, 183, 184, 185, - 186, 187, 188, 189, 190, 191, 192, 193, - 195, 196, 197, 199, 200, 201, 202, 203, - 204, 205, 206, 207, 208, 209, 211, 212, - 213, 214, 215, 216, 217, 218, 219, 220, - 221, 222, 223, 224, 225, 227, 228, 229, - 231, 232, 233, 234, 235, 236, 237, 238, - 239, 240, 241, 243, 244, 245, 246, 247, - 248, 249, 250, 251, 252, 253, 254, 255 +const Word16 Indirect_dico1[SIZE_BK1] = // Q0 +{ + 2, 6, 18, 22, 34, 35, 38, 50, + 66, 67, 70, 82, 98, 99, 102, 130, + 131, 134, 146, 150, 162, 178, 194, 198, + 210, 226, 230, 242, 0, 1, 3, 4, + 5, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 19, 20, 21, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 36, 37, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 51, + 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 68, 69, + 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 100, 101, 103, 104, 105, 106, + 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 132, + 133, 135, 136, 137, 138, 139, 140, 141, + 142, 143, 144, 145, 147, 148, 149, 151, + 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 163, 164, 165, 166, 167, 168, + 169, 170, 171, 172, 173, 174, 175, 176, + 177, 179, 180, 181, 182, 183, 184, 185, + 186, 187, 188, 189, 190, 191, 192, 193, + 195, 196, 197, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 211, 212, + 213, 214, 215, 216, 217, 218, 219, 220, + 221, 222, 223, 224, 225, 227, 228, 229, + 231, 232, 233, 234, 235, 236, 237, 238, + 239, 240, 241, 243, 244, 245, 246, 247, + 248, 249, 250, 251, 252, 253, 254, 255 }; /*----------------------------------------------------------------------------------* * Initial LSF memory *----------------------------------------------------------------------------------*/ -const Word16 lsf_init_fx[16] = /*14Q1*1.28*/ +const Word16 lsf_init_fx[16] = /*14Q1*1.28*/ { 960, 1920, 2880, 3840, 4800, 5760, 6720, 7680, 8640, 9600, 10560, 11520, 12480, 13440, 14400, 15360 }; @@ -5065,38 +5065,38 @@ const Word16 gaus_dico_fx[190] = const Word16 gaus_dico_swb_fx[256] = { /*Q15 */ - 709, 11759, -5333, -2701, 2397, -18, -4286, 2368, - -4576, -1584, -900, -940, 3676, 5441, -44, 2234, - -5698, 3082, -2671, 1666, -640, -3343, -1005, -1689, - 2048, 281, -3935, -3723, 5628, 385, -746, -3243, - -3332, -7228, -1748, -206, -5474, 2554, 2861, 3168, - 5039, 588, -508, -8167, 6549, -3433, 2187, -3666, - -5874, 2767, 8370, 1038, 6434, 6279, 625, 4030, - -1031, 1823, 9896, -1395, 2712, -1110, -742, 6142, - -4456, -10487, -144, -5104, 1968, -312, 6176, 2173, - 2334, -240, 2712, 7460, 2219, -3116, -56, 2770, - 5577, -1225, 770, 3557, 2246, 2322, 3077, 41, - 992, -4971, 441, -5039, 4913, 3811, 1142, -1283, - -6578, 4171, -1473, -3793, -5008, 1984, -1138, -1185, - 5646, 1014, -5118, 7141, 2656, -7241, -3538, 2337, - 7239, -504, -943, -10129, 702, -3811, -302, 2435, - 5090, 3744, 2335, -3904, -1401, -1662, -7256, 6484, - -6864, -5428, 1954, -7316, -1420, -1542, 5442, 311, - 3698, -1343, -2974, 8756, 324, -1903, 2580, 2635, - 4236, -1851, 3147, -772, -708, -3830, 2601, -1889, - -3444, -762, 3939, 3206, -7406, -837, -1167, -438, - 3707, -1015, -7472, 1849, 4277, 1459, -3047, -3760, - 740, -7134, -3753, -3092, 209, -12121, 1398, 2266, - 2505, -7974, -1121, -3481, -5644, 1329, 4532, 958, - 5311, -4258, -3195, -1769, -3055, 4399, -15, 10182, - 4503, 1912, -1574, 5054, -3163, 4881, -5364, 1925, - -1205, -6432, 2305, -8917, -1422, 514, -3001, 3928, - 2321, 360, -355, 1477, -3492, -4570, 1913, 2772, - -1380, -5161, 3812, 2614, 2204, -3135, 1244, -3066, - -4446, -6389, 4899, -5250, 1372, 1999, 1122, 5312, - 1310, -1189, -3310, 6403, 3818, 7734, 1620, -8533, - 706, 7498, -4472, 1272, -949, 3203, -4427, -2855, - 4419, 2283, 6410, 2584, -3397, -3382, -2976, -48, + 709, 11759, -5333, -2701, 2397, -18, -4286, 2368, + -4576, -1584, -900, -940, 3676, 5441, -44, 2234, + -5698, 3082, -2671, 1666, -640, -3343, -1005, -1689, + 2048, 281, -3935, -3723, 5628, 385, -746, -3243, + -3332, -7228, -1748, -206, -5474, 2554, 2861, 3168, + 5039, 588, -508, -8167, 6549, -3433, 2187, -3666, + -5874, 2767, 8370, 1038, 6434, 6279, 625, 4030, + -1031, 1823, 9896, -1395, 2712, -1110, -742, 6142, + -4456, -10487, -144, -5104, 1968, -312, 6176, 2173, + 2334, -240, 2712, 7460, 2219, -3116, -56, 2770, + 5577, -1225, 770, 3557, 2246, 2322, 3077, 41, + 992, -4971, 441, -5039, 4913, 3811, 1142, -1283, + -6578, 4171, -1473, -3793, -5008, 1984, -1138, -1185, + 5646, 1014, -5118, 7141, 2656, -7241, -3538, 2337, + 7239, -504, -943, -10129, 702, -3811, -302, 2435, + 5090, 3744, 2335, -3904, -1401, -1662, -7256, 6484, + -6864, -5428, 1954, -7316, -1420, -1542, 5442, 311, + 3698, -1343, -2974, 8756, 324, -1903, 2580, 2635, + 4236, -1851, 3147, -772, -708, -3830, 2601, -1889, + -3444, -762, 3939, 3206, -7406, -837, -1167, -438, + 3707, -1015, -7472, 1849, 4277, 1459, -3047, -3760, + 740, -7134, -3753, -3092, 209, -12121, 1398, 2266, + 2505, -7974, -1121, -3481, -5644, 1329, 4532, 958, + 5311, -4258, -3195, -1769, -3055, 4399, -15, 10182, + 4503, 1912, -1574, 5054, -3163, 4881, -5364, 1925, + -1205, -6432, 2305, -8917, -1422, 514, -3001, 3928, + 2321, 360, -355, 1477, -3492, -4570, 1913, 2772, + -1380, -5161, 3812, 2614, 2204, -3135, 1244, -3066, + -4446, -6389, 4899, -5250, 1372, 1999, 1122, 5312, + 1310, -1189, -3310, 6403, 3818, 7734, 1620, -8533, + 706, 7498, -4472, 1272, -949, 3203, -4427, -2855, + 4419, 2283, 6410, 2584, -3397, -3382, -2976, -48, }; @@ -5104,7 +5104,7 @@ const Word16 gaus_dico_swb_fx[256] = * CLDFB tables *----------------------------------------------------------------------------------*/ -const Word16 freqTable[2] = {20, 40}; // Q0 +const Word16 freqTable[2] = {20, 40}; // Q0 /* SNR: 109.44, PHASE: 3.500000000000000 */ @@ -6657,11 +6657,11 @@ const Word16 iRotVectr_60[] =//Q(sqrt(1.0/2.00)) W16(0x9ae0), W16(0x99a2), W16(0x98ac), W16(0x97fe), W16(0x9799) }; -const Word16 cldfb_anaScale[] = // Q0 +const Word16 cldfb_anaScale[] = // Q0 { SCALE_CLDFB_ANA_10, SCALE_CLDFB_ANA_16, SCALE_CLDFB_ANA_20, SCALE_CLDFB_ANA_32, SCALE_CLDFB_ANA_40, SCALE_CLDFB_ANA_60, SCALE_CLDFB_ANA_30 }; -const Word16 cldfb_synScale[] = // Q0 +const Word16 cldfb_synScale[] = // Q0 { SCALE_CLDFB_SYN_10, SCALE_CLDFB_SYN_16, SCALE_CLDFB_SYN_20, SCALE_CLDFB_SYN_32, SCALE_CLDFB_SYN_40, SCALE_CLDFB_SYN_60, SCALE_CLDFB_SYN_30 }; @@ -6749,7 +6749,7 @@ const Word32 rot_vec_syn_im_L20_fx[10] = const Word32 rot_vec_syn_re_L30_fx[15] = { 240075408 ,238431728 ,234175760 ,227354112 ,218041520 ,206340016 ,192377808 ,176307872 , - 158306272 ,138570240 ,117315992 ,94776408 ,71198440 ,46840400 ,21969170 , + 158306272 ,138570240 ,117315992 ,94776408 ,71198440 ,46840400 ,21969170 , }; @@ -6757,7 +6757,7 @@ const Word32 rot_vec_syn_re_L30_fx[15] = const Word32 rot_vec_syn_im_L30_fx[15] = { -3142759 ,-28220256 ,-52988564 ,-77176320 ,-100518520 ,-122759408 ,-143655328 ,-162977328 , - -180513712 ,-196072352 ,-209482768 ,-220598064 ,-229296448 ,-235482592 ,-239088752 , + -180513712 ,-196072352 ,-209482768 ,-220598064 ,-229296448 ,-235482592 ,-239088752 , }; @@ -6765,7 +6765,7 @@ const Word32 rot_vec_syn_im_L30_fx[15] = const Word32 rot_vec_syn_re_L32_fx[16] = { 240077888 ,238633056 ,234890064 ,228884944 ,220675536 ,210340896 ,197980576 ,183713584 , - 167677328 ,150026240 ,130930336 ,110573488 ,89151760 ,66871456 ,43947140 ,20599588 , + 167677328 ,150026240 ,130930336 ,110573488 ,89151760 ,66871456 ,43947140 ,20599588 , }; @@ -6773,7 +6773,7 @@ const Word32 rot_vec_syn_re_L32_fx[16] = const Word32 rot_vec_syn_im_L32_fx[16] = { -2946347 ,-26463908 ,-49726608 ,-72510408 ,-94595904 ,-115770384 ,-135829936 ,-154581360 , - -171844080 ,-187451856 ,-201254368 ,-213118704 ,-222930576 ,-230595504 ,-236039664 ,-239210640 , + -171844080 ,-187451856 ,-201254368 ,-213118704 ,-222930576 ,-230595504 ,-236039664 ,-239210640 , }; @@ -6781,8 +6781,8 @@ const Word32 rot_vec_syn_im_L32_fx[16] = const Word32 rot_vec_syn_re_L40_fx[20] = { 240084400 ,239159360 ,236759824 ,232900592 ,227605456 ,220907040 ,212846672 ,203474016 , - 192846896 ,181030800 ,168098592 ,154130000 ,139211136 ,123434000 ,106895848 ,89698648 , - 71948424 ,53754620 ,35229396 ,16486972 , + 192846896 ,181030800 ,168098592 ,154130000 ,139211136 ,123434000 ,106895848 ,89698648 , + 71948424 ,53754620 ,35229396 ,16486972 , }; @@ -6790,8 +6790,8 @@ const Word32 rot_vec_syn_re_L40_fx[20] = const Word32 rot_vec_syn_im_L40_fx[20] = { -2357099 ,-21186638 ,-39885552 ,-58338564 ,-76431896 ,-94054000 ,-111096224 ,-127453512 , - -143025008 ,-157714704 ,-171432032 ,-184092416 ,-195617824 ,-205937184 ,-214986864 ,-222711088 , - -229062224 ,-234001104 ,-237497296 ,-239529232 , + -143025008 ,-157714704 ,-171432032 ,-184092416 ,-195617824 ,-205937184 ,-214986864 ,-222711088 , + -229062224 ,-234001104 ,-237497296 ,-239529232 , }; @@ -6799,9 +6799,9 @@ const Word32 rot_vec_syn_im_L40_fx[20] = const Word32 rot_vec_syn_re_L60_fx[30] = { 240090832 ,239679552 ,238611328 ,236889088 ,234517552 ,231503216 ,227854352 ,223580960 ,218694736 , - 213209088 ,207139056 ,200501264 ,193313904 ,185596688 ,177370784 ,168658704 ,159484336 ,149872832 , - 139850544 ,129444936 ,118684528 ,107598816 ,96218184 ,84573816 ,72697640 ,60622212 ,48380616 , - 36006412 ,23533520 ,10996123 , + 213209088 ,207139056 ,200501264 ,193313904 ,185596688 ,177370784 ,168658704 ,159484336 ,149872832 , + 139850544 ,129444936 ,118684528 ,107598816 ,96218184 ,84573816 ,72697640 ,60622212 ,48380616 , + 36006412 ,23533520 ,10996123 , }; @@ -6809,9 +6809,9 @@ const Word32 rot_vec_syn_re_L60_fx[30] = const Word32 rot_vec_syn_im_L60_fx[30] = { -1571413 ,-14134643 ,-26659130 ,-39110548 ,-51454764 ,-63657948 ,-75686648 ,-87507896 ,-99089296 , - -110399096 ,-121406296 ,-132080736 ,-142393152 ,-152315264 ,-161819904 ,-170881008 ,-179473744 , - -187574544 ,-195161216 ,-202212960 ,-208710464 ,-214635904 ,-219973040 ,-224707248 ,-228825536 , - -232316640 ,-235170976 ,-237380736 ,-238939840 ,-239844032 , + -110399096 ,-121406296 ,-132080736 ,-142393152 ,-152315264 ,-161819904 ,-170881008 ,-179473744 , + -187574544 ,-195161216 ,-202212960 ,-208710464 ,-214635904 ,-219973040 ,-224707248 ,-228825536 , + -232316640 ,-235170976 ,-237380736 ,-238939840 ,-239844032 , }; @@ -7022,21 +7022,21 @@ const Word32 scaleTable_cn_only_amrwbio_fx_by_10f[SIZE_SCALE_TABLE_CN_AMRWB][2] { ACELP_12k65, 429496729 } }; -const Word16 sidparts_encoder_noise_est[SIZE_SIDPARTS_ENC_NOISE_EST] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259, 264, 269, 279 }; // Q0 +const Word16 sidparts_encoder_noise_est[SIZE_SIDPARTS_ENC_NOISE_EST] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259, 264, 269, 279 }; // Q0 -const Word16 sidPartitions_nb[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 159 }; // Q0 -const Word16 sidPartitions_wb1[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255 }; // Q0 -const Word16 sidPartitions_wb2[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259 }; // Q0 -const Word16 sidPartitions_wb3[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 319 }; // Q0 -const Word16 sidPartitions_swb1[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259, 264, 269, 274 }; // Q0 -const Word16 sidPartitions_swb2[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 319, 324, 329, 339 }; // Q0 +const Word16 sidPartitions_nb[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 159 }; // Q0 +const Word16 sidPartitions_wb1[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255 }; // Q0 +const Word16 sidPartitions_wb2[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259 }; // Q0 +const Word16 sidPartitions_wb3[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 319 }; // Q0 +const Word16 sidPartitions_swb1[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259, 264, 269, 274 }; // Q0 +const Word16 sidPartitions_swb2[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 319, 324, 329, 339 }; // Q0 -const Word16 shapingPartitions_nb[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 159 }; // Q0 -const Word16 shapingPartitions_wb1[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 }; // Q0 -const Word16 shapingPartitions_wb2[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 }; // Q0 -const Word16 shapingPartitions_wb3[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 148, 176, 212, 256, 308, 319 }; // Q0 -const Word16 shapingPartitions_swb1[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 }; // Q0 -const Word16 shapingPartitions_swb2[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 148, 176, 212, 256, 308, 319 }; // Q0 +const Word16 shapingPartitions_nb[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 159 }; // Q0 +const Word16 shapingPartitions_wb1[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 }; // Q0 +const Word16 shapingPartitions_wb2[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 }; // Q0 +const Word16 shapingPartitions_wb3[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 148, 176, 212, 256, 308, 319 }; // Q0 +const Word16 shapingPartitions_swb1[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 }; // Q0 +const Word16 shapingPartitions_swb2[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 148, 176, 212, 256, 308, 319 }; // Q0 const FD_CNG_SETUP FdCngSetup_nb = { 512, 160, sizeof(sidPartitions_nb)/sizeof(Word16), sidPartitions_nb, sizeof(shapingPartitions_nb)/sizeof(Word16), shapingPartitions_nb }; const FD_CNG_SETUP FdCngSetup_wb1 = { 512, 256, sizeof(sidPartitions_wb1)/sizeof(Word16), sidPartitions_wb1, sizeof(shapingPartitions_wb1)/sizeof(Word16), shapingPartitions_wb1 }; @@ -7046,8 +7046,8 @@ const FD_CNG_SETUP FdCngSetup_swb1 = { 512, 256, sizeof(sidPartitions_swb1)/size const FD_CNG_SETUP FdCngSetup_swb2 = { 640, 320, sizeof(sidPartitions_swb2)/sizeof(Word16), sidPartitions_swb2, sizeof(shapingPartitions_swb2)/sizeof(Word16), shapingPartitions_swb2 }; -const Word16 levels_37bits[FD_CNG_stages_37bits] = { 128, 64, 64, 64, 64, 64 }; // Q0 -const Word16 bits_37bits[FD_CNG_stages_37bits] = { 7, 6, 6, 6, 6, 6 }; // Q0 +const Word16 levels_37bits[FD_CNG_stages_37bits] = { 128, 64, 64, 64, 64, 64 }; // Q0 +const Word16 bits_37bits[FD_CNG_stages_37bits] = { 7, 6, 6, 6, 6, 6 }; // Q0 /* IDCT_MATRIX_ROM: 18*24 Word16 = 432 Word16 */ /* or compressed IDCT_MATRIX_ROM: 18*24 Word8 + 25 = 230 Word16 + WMOPS (INDIRECT(432) and STORE(432) ) */ @@ -7060,8 +7060,8 @@ const Word16 bits_37bits[FD_CNG_stages_37bits] = { 7, 6, 6, 6, 6, 6 }; // Q0 /* additional minor Table ROM ( dct_mid points 18 Word16, dct_col_upshifts 52, scaleFactors 2*2 = ~= 74 Word16s */ -const Word16 cdk1_ivas_entries_per_segment[FDCNG_VQ_DCT_NSEGM] = { 16, 17, 17, 78 }; // Q0 -const Word16 cdk1_ivas_cum_entries_per_segment[FDCNG_VQ_DCT_NSEGM + 1] = { 0, 16 ,33, 50, 128 }; // Q0 +const Word16 cdk1_ivas_entries_per_segment[FDCNG_VQ_DCT_NSEGM] = { 16, 17, 17, 78 }; // Q0 +const Word16 cdk1_ivas_cum_entries_per_segment[FDCNG_VQ_DCT_NSEGM + 1] = { 0, 16 ,33, 50, 128 }; // Q0 const Word16 /* DCT trunc_len */ cdk1_ivas_cols_per_segment[FDCNG_VQ_DCT_NSEGM] = { FDCNG_VQ_DCT_MINTRUNC, 10, 16, FDCNG_VQ_DCT_MAXTRUNC }; /* 8, 10, 16, 18 */ const Word16 /* segment inner DCT trunc_len */ cdk1_ivas_trunc_dct_cols_per_segment[FDCNG_VQ_DCT_NSEGM] = { FDCNG_VQ_DCT_MAXTRUNC - FDCNG_VQ_DCT_MINTRUNC, FDCNG_VQ_DCT_MAXTRUNC - 10 , FDCNG_VQ_DCT_MAXTRUNC - 16 , 0 }; @@ -7079,25 +7079,25 @@ const Word8* const cdk_37bits_ivas_stage1_W8Qx_dct_sections[] = { cdk1_ivas_dct_ /* scaling constants */ const Word32 fdcng_dct_scaleF_fx[3] = { 902561792, 56410112,1481781 };//Q31 -const Word16 stage1_col_syn_shift_segm0[8] = { // Q0 +const Word16 stage1_col_syn_shift_segm0[8] = { // Q0 4, 4, 4, 3, 2, 2, 2, 1 }; -const Word16 stage1_col_syn_shift_segm1[10] = { // Q0 +const Word16 stage1_col_syn_shift_segm1[10] = { // Q0 4, 4, 4, 3, 2, 2, 2, 1, 1, 1 }; -const Word16 stage1_col_syn_shift_segm2[16] = { // Q0 +const Word16 stage1_col_syn_shift_segm2[16] = { // Q0 4, 4, 4, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1 }; -const Word16 stage1_col_syn_shift_segm3[18] = { // Q0 +const Word16 stage1_col_syn_shift_segm3[18] = { // Q0 4, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1 }; /* segment individual shiftfactor to Q4 for each stored DCT Word8 coeff column */ -const Word16 * stage1_dct_col_syn_shift[FDCNG_VQ_DCT_NSEGM] = { stage1_col_syn_shift_segm0, stage1_col_syn_shift_segm1,stage1_col_syn_shift_segm2,stage1_col_syn_shift_segm3 }; // Q0 +const Word16 * stage1_dct_col_syn_shift[FDCNG_VQ_DCT_NSEGM] = { stage1_col_syn_shift_segm0, stage1_col_syn_shift_segm1,stage1_col_syn_shift_segm2,stage1_col_syn_shift_segm3 }; // Q0 /* 25 unique abs values of idct24_18matrix Q16 */ @@ -7124,7 +7124,7 @@ const Word8 idctT2_24_compressed_idx[(FDCNG_VQ_DCT_MAXTRUNC * FDCNG_VQ_MAX_LEN) 12, 5, -14, -15, 4, 23, 6, -13, -16, 3, 22, 7, -12, -17, 2, 21, 8, -11, 12, 3, -18, -9, 12, 15, -6, -21, 0, 21, 6, -15, -12, 9, 18, -3, -24, -3, 12, 1, -22, -3, 20, 5, -18, -7, 16, 9, -14, -11, 12, 13, -10, -15, 8, 17 -}; // Q0 +}; // Q0 const Word16 unique_idctT2_21coeffsQ16[23] = {//Q16 @@ -7156,7 +7156,7 @@ const Word8 idctT2_21_compressed_idx[(FDCNG_VQ_DCT_MAXTRUNC *( (21/2) + 1)) /* /*tables in truncated DCTII_24 domain */ -const Word8 /*seg 0, 16 x 8 */ cdk1_ivas_dct_s0_W8[128] = { // Q0 +const Word8 /*seg 0, 16 x 8 */ cdk1_ivas_dct_s0_W8[128] = { // Q0 29, -126, 8, -34, -45, -42, -13, 2, 22, -120, 0, -27, -41, -50, -25, 42, 20, -116, -2, -39, -61, -33, -22, -25, @@ -7175,7 +7175,7 @@ const Word8 /*seg 0, 16 x 8 */ cdk1_ivas_dct_s0_W8[128] = { // Q0 -17, 125, 6, 74, 21, 85, 5, 98 }; -const Word8 /*seg 1, 17 x 10 */ cdk1_ivas_dct_s1_W8[170] = { // Q0 +const Word8 /*seg 1, 17 x 10 */ cdk1_ivas_dct_s1_W8[170] = { // Q0 20, -127, -12, -9, 1, -30, -2, -1, -43, -54, 24, -113, 3, -39, -49, -25, -15, -27, 6, 2, 55, 17, 74, 22, 78, 77, 87, 97, 89, 61, @@ -7195,7 +7195,7 @@ const Word8 /*seg 1, 17 x 10 */ cdk1_ivas_dct_s1_W8[170] = { // Q0 -8, 127, 23, 24, 58, 89, 46, 20, 14, 54 }; -const Word8 /*seg 2, 17 x 16 */ cdk1_ivas_dct_s2_W8[272] = { // Q0 +const Word8 /*seg 2, 17 x 16 */ cdk1_ivas_dct_s2_W8[272] = { // Q0 32, -69, 21, 3, -9, 17, 3, 14, 15, 35, -17, -10, -20, 28, -52, -19, 24, -49, 17, 9, -6, 14, 22, 33, 51, 38, 21, 14, 5, 38, 13, -5, 27, -8, 30, 9, 93, 65, 65, 66, 67, 30, 39, 21, 9, 22, 5, -17, @@ -7215,7 +7215,7 @@ const Word8 /*seg 2, 17 x 16 */ cdk1_ivas_dct_s2_W8[272] = { // Q0 4, 117, 37, 43, 44, 32, 13, 75, 32, 33, 15, -70, 51, 39, 68, 15 }; -const Word8 /*seg 3, 78 x 18 */ cdk1_ivas_dct_s3_W8[1404] = { // Q0 +const Word8 /*seg 3, 78 x 18 */ cdk1_ivas_dct_s3_W8[1404] = { // Q0 21, -127, -23, -10, 7, -26, 1, 6, -39, -53, -19, -84, -34, 16, -10, -24, -75, 9, 76, -117, 124, -63, 75, 72, -9, 115, 42, 100, -36, 120, -37, 66, 46, 72, -34, 18, 24, -115, 3, -65, -47, -24, -7, -13, 1, -18, -10, -58, -30, 2, -37, -27, -78, 9, @@ -7299,7 +7299,7 @@ const Word8 /*seg 3, 78 x 18 */ cdk1_ivas_dct_s3_W8[1404] = { // Q0 /* stage1 low complex search tables */ /* segm_neighbour_fwd/segm_neighbour_rev nex/previous indeces in an circularly ordered list of close MSE neighbours */ -const Word8 cdk1_ivas_segm_neighbour_fwd[128] = { // Q0 +const Word8 cdk1_ivas_segm_neighbour_fwd[128] = { // Q0 3, 0, 4, 62, 5, 58, 64, 59, 33, 19, 9, 127, 26, 12, 28, 31, 1, 2, 51, 38, 18, 25, 43, 21, @@ -7317,7 +7317,7 @@ const Word8 cdk1_ivas_segm_neighbour_fwd[128] = { // Q0 82, 103, 121, 110, 109, 115, 40, 123, 116, 122, 120, 46, 93, 20, 125, 45 }; -const Word8 cdk1_ivas_segm_neighbour_rev[128] = { // Q0 +const Word8 cdk1_ivas_segm_neighbour_rev[128] = { // Q0 1, 16, 17, 0, 2, 4, 63, 51, 65, 10, 44, 27, 13, 29, 30, 49, 50, 57, 20, 9, 125, 23, 36, 26, @@ -8706,11 +8706,11 @@ const Word16 cdk_37bits_6_fx[1536] =//Q7 const Word16 * const cdk_37bits[] = { cdk_37bits_1_fx, cdk_37bits_2_fx, cdk_37bits_3_fx, cdk_37bits_4_fx, cdk_37bits_5_fx, cdk_37bits_6_fx -}; // Q7 +}; // Q7 const Word16 * const ivas_cdk_37bits_fx[] = { NULL, cdk_37bits_2_fx, cdk_37bits_3_fx, cdk_37bits_4_fx, cdk_37bits_5_fx, cdk_37bits_6_fx -}; // Q7 +}; // Q7 /* Sine tables for FFT */ /* for (j=0; jfftlen/2+1; j++) hs->fftSineTab[j] = (float)sin(2.0*EVS_PI*j/hs->fftlen); */ @@ -8942,290 +8942,290 @@ const Word16 olapWinSyn320_fx[320] = const Word16 dico1_isf_fx[] = {/*Qlog2(2.56)*/ - 740, 1263, 1292, 1006, 997, 1019, 1017, 976, 923, - 557, 946, 1049, 867, 846, 990, 1112, 1262, 1241, - 633, 898, 996, 756, 662, 683, 783, 909, 996, - 830, 736, 278, 820, 1254, 686, 712, 1039, 473, - 503, 885, 1508, 1307, 1282, 1172, 1119, 1209, 1061, - 416, 719, 989, 1227, 1001, 1052, 954, 741, 1044, - 585, 1132, 1233, 1091, 1247, 1433, 1512, 1448, 1314, - -31, 469, 803, 659, 619, 658, 843, 987, 1113, - 842, 1678, 1841, 1549, 1474, 1256, 1082, 905, 742, - 370, 1216, 1768, 1633, 1212, 636, 22, -330, 71, - 73, 738, 893, 968, 993, 1768, 2273, 1840, 1391, - 1513, 1714, 1238, 534, 276, 315, 461, 459, 508, - 421, 1293, 1640, 1623, 1742, 1617, 1499, 1284, 1006, - -95, 752, 1680, 1569, 1618, 1436, 1200, 980, 712, - -78, 831, 1194, 1110, 1378, 1481, 1492, 1365, 1217, - 670, 1208, 1168, 860, 742, 601, 528, 403, 309, - 397, 621, 966, 752, 579, 398, 400, 329, 252, - 510, 864, 1108, 807, 939, 902, 925, 717, 481, - 539, 835, 913, 719, 617, 544, 591, 565, 642, - 162, 889, 654, 108, -34, 244, 488, 561, 532, - -62, 1033, 1308, 1035, 1127, 1098, 1029, 961, 823, - -14, 945, 990, 801, 755, 815, 847, 913, 892, - 394, 1765, 1666, 1339, 1117, 806, 642, 479, 380, - 529, 1851, 2003, 1228, 622, -41, -416, 344, 819, - 635, 1058, 883, 492, 372, 312, 317, 274, 241, - 279, 966, 1642, 1478, 1463, 1123, 795, 525, 339, - 457, 955, 1177, 1214, 1427, 1457, 1345, 917, 539, - 148, 751, 1515, 1105, 867, 606, 474, 448, 399, - 579, 1081, 1035, 390, 3, -263, -198, -82, 38, - 18, -68, -12, 313, 761, 405, 249, 111, -76, - -91, 827, 948, 648, 613, 535, 522, 490, 421, - 41, -44, -281, -472, 652, 534, 193, 135, -90, - 41, -121, -356, -60, 663, 307, 61, -48, -344, - -118, -204, 328, 512, 870, 793, 610, 402, 186, - 156, 293, 74, -338, -475, -897, -594, -161, -497, - 226, 131, -138, 307, 169, -271, -164, -387, -624, - 62, -32, -61, -252, -541, -828, -1027, -523, -662, - 102, -61, 141, 112, -270, -251, -541, 25, -150, - 6, -132, -356, -686, -96, -322, -522, -31, -326, - -36, -209, -521, -229, 307, -132, -5, -99, -384, - 60, -51, -237, -668, -973, -407, -708, -75, -172, - 26, -138, -266, 111, -302, 43, -278, -356, -359, - 570, 822, 496, -154, -312, -92, 137, 279, 371, - -146, 368, 409, 68, 6, 77, 167, 202, 162, - -103, 294, 607, 415, 483, 462, 480, 431, 408, - -120, -338, -612, -524, 584, 331, 92, 433, 276, - -178, -293, -154, -41, 269, 100, -9, 213, 160, - -218, -304, 463, 454, 397, 273, 202, 286, 273, - -232, 7, 6, -388, -472, -427, -378, -167, -100, - -294, -183, 134, -47, 101, -88, -84, -117, -3, - 57, 17, -202, -634, -989, -1119, -533, 176, -36, - 120, -28, 23, 111, -319, 318, -22, -77, 266, - -271, -464, -434, -658, -640, -385, -385, -99, -69, - -198, -259, -266, -44, -39, -139, -137, 171, 66, - 9, -145, -377, -846, -1000, -111, -325, 342, 135, - -81, -286, -380, 192, -57, 307, 76, -24, -140, - 677, 702, 247, 56, 249, 141, -105, -236, -99, - 36, -39, -69, 348, 198, -93, 322, 91, -72, - -127, -376, -657, 139, 623, 223, 501, 306, 220, - -113, -384, -796, 504, 438, 85, 213, -83, -194, - -174, -422, 7, 1155, 1089, 1182, 1003, 945, 806, - 8, -126, -317, -103, -351, -695, -98, -268, -537, - 33, -103, -290, 167, -39, -407, 44, -208, -375, - 104, -23, -64, -291, -637, -851, -1084, -61, -112, - -75, -306, -434, 218, -148, -354, -680, -133, -216, - -121, -377, -718, -97, -130, -361, -156, -379, -599, - -56, -254, -586, 235, 157, -214, 11, -260, -149, - -124, -267, -397, -580, -593, -527, -805, -385, 346, - -193, -440, -708, -351, -141, -255, -499, -147, -185, - 448, 660, 494, 208, 509, 461, 338, 291, 149, - -223, 88, 335, 159, 212, 191, 286, 308, 205, - -171, -242, 514, 362, 295, 524, 552, 694, 585, - -64, -308, -448, -21, 284, 786, 446, 289, 92, - -218, -390, -7, 169, 206, 330, 352, 408, 358, - -36, 702, 959, 859, 861, 1115, 1269, 1357, 1305, - -133, -341, -65, 678, 417, 440, 486, 518, 780, - 33, -44, -191, -344, -461, -755, -201, 217, -31, - -353, -547, -44, 123, -61, -68, -79, 29, 60, - 73, -57, -406, -766, -1243, -1203, 240, 400, 165, - -73, -282, -601, -213, -171, -375, 332, 35, -103, - -29, -207, -553, -476, -638, -908, 172, -22, -135, - -192, -239, -164, -103, -111, -47, 153, 125, 110, - -1, -203, -570, -1030, -1424, -535, 155, 1, 147, - -333, -653, -865, -197, -158, -21, -44, 95, 108, - 389, 588, 490, 33, -237, -524, -628, -136, -260, - 40, -177, -462, 453, 862, 380, 131, -130, -405, - -76, -281, -741, -742, 898, 619, 277, 71, -222, - -32, -265, -556, -25, 994, 682, 305, 126, -165, - -69, -349, -585, 234, 1158, 903, 626, 510, 251, - -1, -99, -272, -210, -603, -351, -540, -811, -383, - -16, -230, -504, 410, 149, -205, -343, -651, -639, - 103, -9, -227, -205, -562, -781, -1079, -1208, -156, - 143, 63, -135, -67, -317, -602, -784, -1154, -640, - -144, -391, -674, -622, -200, -254, -660, -947, -395, - -40, -250, -625, 27, 543, 94, -131, -386, -673, - -123, -371, -757, -451, -564, -614, -415, -711, -35, - -116, -309, -593, -268, 239, -33, -338, -650, -135, - 94, 251, 554, 57, -312, -423, -154, -57, 235, - -268, -71, 381, 114, -44, -87, 125, 173, 133, - -131, -19, 1149, 670, 486, 356, 309, 369, 296, - -223, -501, -899, -722, -70, 6, 131, 310, 394, - -99, -303, -517, 249, 64, -53, 135, -11, 453, - -147, -399, -730, -401, 817, 738, 802, 749, 575, - -154, -435, -739, 800, 593, 366, 529, 318, 326, - -224, 45, -39, -387, -515, -518, -608, -384, -321, - -315, -377, 143, -101, -113, -377, -177, -144, -12, - 117, 40, -239, -651, -1051, -581, -737, -990, -328, - 26, -50, -157, -23, -453, -283, -531, -546, 192, - -252, -501, -743, -589, -627, -499, -328, -118, -72, - -324, -494, -244, -306, -144, -177, -262, -135, -78, - -36, -234, -519, -961, -1290, -314, -479, -371, -45, - -95, -292, -535, -8, -300, 112, -164, -277, 198, - -99, -128, 880, 836, 579, 351, 23, -95, -217, - -27, -258, 124, 1011, 597, 425, 144, 7, -73, - -69, -300, -683, -435, 1132, 899, 504, 332, 109, - -74, -323, -637, 563, 1074, 608, 371, 105, -49, - -259, -121, 1440, 1334, 1628, 1490, 1438, 1223, 933, - -82, -306, -613, -222, -378, -675, -545, -671, -845, - 53, -124, -347, 422, 52, -125, -270, -529, 9, - 79, -89, -320, -662, -999, -1199, -1243, -676, -297, - -68, -273, -611, 137, -146, -397, -627, -845, -220, - -112, -346, -797, -826, 234, -132, -188, -278, -522, - -159, -405, -734, -419, 293, 74, -167, -167, 184, - -153, -437, -833, -1080, -336, -472, -561, -340, -253, - -169, -423, -820, -904, -131, -19, -346, -604, 31, - 33, -31, 312, 62, -148, 49, -59, 564, 486, - -306, -333, 194, -44, 67, 72, 147, 205, 243, - -207, -49, 1360, 983, 969, 991, 1014, 1110, 973, - -211, -172, 883, 627, 711, 674, 705, 798, 746, - -88, -325, -763, -974, 687, 908, 514, 382, 172, - -292, -612, -805, 63, 131, 270, 259, 352, 348, - -235, -84, 955, 818, 1120, 1289, 1559, 1480, 1285, - -180, -461, -614, 657, 691, 745, 854, 783, 713, - -97, -309, -477, -614, -777, -734, -768, -526, -472, - -344, -476, -35, -169, 49, -77, -150, -240, -141, - -52, -268, -639, -919, -1278, -1113, -342, -333, -151, - -68, -242, -585, -73, -209, -478, -159, -429, 133, - -197, -499, -1005, -1268, -272, -224, -105, -67, 17, - -363, -618, -414, -116, -62, 20, 10, 116, 108, - -195, -475, -906, -1260, -891, -441, -277, -142, -28, - -226, -519, -950, -700, -275, -266, -116, -105, 82, - 404, 511, 520, 327, 17, -194, -333, -536, -586, - -114, -130, 276, 237, 204, 342, 135, -16, -111, - 191, 180, -137, -467, 272, 106, -95, 17, -192, - -80, -290, -626, 194, 598, 196, 21, -281, 77, - 137, 367, 534, 764, 670, 382, 296, 153, 84, - 303, 497, 144, -85, -125, -539, -482, -464, -764, - 233, 347, 68, -147, 169, -210, -242, -226, -482, - 307, 422, 154, -175, -386, -722, -724, -904, -1015, - 309, 308, 160, -60, -470, -420, -598, -791, -219, - 68, 121, -137, -560, -146, -446, -515, -494, -729, - 130, 53, -227, 46, 474, 32, -161, -192, -490, - 213, 164, -71, -465, -876, -161, -456, -587, -48, - 218, 117, 39, 177, -194, -88, -226, -418, 50, - 210, 547, 569, 279, 121, -44, -50, 10, -84, - 58, 140, 182, -5, 267, 117, 106, 211, 198, - 153, 559, 872, 460, 222, 108, 188, 180, 183, - 158, 119, 284, -153, -271, 229, 87, 110, -57, - -183, 82, 118, 21, 13, 40, 118, 191, 185, - 163, 56, 609, 341, 50, 329, 68, 266, 218, - 100, 206, 18, -304, -107, -436, -487, -65, -306, - -86, 154, 134, -30, -45, -73, -104, -80, -96, - 245, 330, 10, -440, -849, -1082, 79, 40, -265, - 196, 372, 272, -181, -493, -389, 275, 80, -59, - 2, -12, -246, -505, -100, -436, 21, -187, -431, - -221, -48, 36, -271, -186, -147, -109, 26, 71, - 213, 140, 72, -351, -620, -84, -363, 69, 46, - 91, 167, -3, -95, -99, -105, -48, 114, 147, - 259, 249, 172, 607, 406, 52, 59, -189, -320, - 115, -85, -54, 574, 128, 226, -59, -253, 130, - 39, 364, 757, 940, 728, 660, 659, 583, 770, - -115, -338, -760, -471, 394, 37, 441, 178, 6, - -57, -305, -525, 796, 453, 188, -4, -114, 248, - 71, 444, 797, 731, 1096, 1157, 1222, 1029, 811, - 135, 359, 551, 425, 749, 815, 874, 704, 502, - 132, 247, 0, -206, -449, -750, -258, -514, -633, - 248, 249, 91, 121, -195, -499, -90, -282, -435, - 78, 20, -277, -623, -983, -1224, -415, -458, -639, - 347, 509, 208, -179, -464, -728, -76, -237, -486, - -103, -343, -756, -713, -265, -609, -191, -398, -636, - -121, -383, -749, 567, 252, -36, -354, -417, -50, - 204, 100, -149, -650, -1081, -47, -7, -263, 111, - -46, -180, -267, -324, -562, -394, -692, 398, 292, - 482, 670, 683, 624, 442, 165, 116, 36, -149, - 108, 247, 291, 247, 355, 122, 109, 224, 296, - 292, 349, 725, 482, 388, 329, 429, 620, 667, - -34, 197, 213, -127, 84, 494, 620, 575, 375, - 126, 207, 172, 167, 362, 202, 296, 395, 455, - -6, 250, 539, 467, 636, 801, 1149, 1287, 1118, - 27, 240, 369, 280, 440, 411, 634, 892, 953, - 159, 170, -58, -395, -797, -690, 77, -211, -334, - -5, -28, -13, -74, -335, -603, 300, 88, -205, - 82, -33, -364, -698, -1203, -1153, 110, -146, -289, - 113, 1, -243, -588, -994, -496, 414, 160, 42, - -56, -247, -440, -693, -996, -479, 11, -178, -357, - -151, -353, -327, -211, -340, 141, 65, 425, 453, - 34, -169, -455, -932, -1215, 138, 499, 256, 324, - 68, 139, -15, -547, -478, 17, 306, 502, 481, - -32, -134, 445, 129, -143, -244, -503, -507, -599, - 61, -140, -345, 496, 458, -2, 20, -227, -514, - 215, 519, 920, 1053, 1090, 791, 528, 290, 155, - -54, -233, -647, -602, 639, 294, -2, -167, -442, - -78, -315, -791, -113, 820, 403, 158, -116, -356, - -105, -379, -236, 1224, 893, 749, 568, 356, 214, - -17, -199, -144, 50, -283, -247, -578, -846, -1087, - 69, -11, -381, -206, 209, -284, -387, -416, -716, - 39, -5, -145, -374, -682, -909, -1074, -1169, -1066, - 287, 226, 67, -221, -662, -171, -421, -642, -707, - -132, -348, -538, -448, -20, -4, -354, -748, -933, - 4, -75, -289, -598, 317, 52, -208, -297, -559, - -88, -264, -358, -589, -631, -248, -523, -822, -1071, - 70, -8, 54, -314, -515, 92, -146, -274, -493, - 199, 62, 391, 158, -141, 71, -219, -203, -207, - 152, 40, 329, 162, -29, 48, -149, 108, 127, - 267, 722, 1256, 882, 625, 248, 8, -81, -60, - -58, -138, -291, -600, -12, -2, -39, 147, 117, - -107, -345, -513, 459, 76, 92, -272, 388, 262, - 362, 516, 203, -409, -716, -831, -331, 185, 209, - -117, -391, -298, 671, 292, 538, 257, 166, -38, - -102, -319, -194, -283, -573, -262, -579, -219, -444, - -235, 78, 11, -168, -101, -229, -263, -321, -123, - 70, 50, -170, -599, -996, -588, -263, -516, -455, - 394, 363, 229, -136, -538, 21, -183, -348, -201, - -124, -368, -640, -879, -847, -209, -409, -494, -515, - -127, -341, -541, -425, -510, -10, -252, -473, -291, - 84, -69, -201, -676, -868, 103, -311, -132, -320, - 5, -173, -188, -297, -628, 197, -57, 7, -11, - 49, -160, 56, 558, 111, 33, -311, -440, -463, - -1, -246, -307, 862, 453, 139, -170, -355, -232, - -197, -38, 1702, 1331, 1252, 950, 692, 504, 426, - -108, -344, -861, -1172, 444, 354, 88, -46, -220, - -53, -321, -494, 1113, 744, 364, 198, -34, -75, - -69, 199, 897, 1140, 1343, 1183, 977, 742, 522, - 122, 44, -269, 27, -155, -562, -307, -590, -773, - 154, 42, -160, 252, -129, -305, -471, -733, -371, - 135, 185, -82, -416, -722, -913, -504, -743, -880, - 149, 214, -84, -329, -680, -835, -426, -661, -81, - -128, -380, -735, -998, -337, 17, -182, -467, -697, - -84, -290, -510, -592, 13, 440, 154, -38, -279, - 70, -61, -246, -727, -1047, -80, -381, -535, -704, - 178, -2, -146, -670, -938, 482, 138, 63, 65, - -11, 15, 772, 443, 142, -20, -209, -126, -161, - -32, -249, 95, 552, 124, 30, -343, 82, -86, - -163, -257, 899, 1097, 906, 751, 502, 390, 294, - -51, -258, -447, -806, -368, 763, 464, 364, 183, - -166, -374, -367, 87, 35, 399, 418, 856, 833, - -205, -310, 588, 778, 785, 1065, 1118, 1245, 1157, - -173, -312, 107, 345, 400, 790, 870, 1113, 1001, - -7, -120, -387, -410, -614, -943, -226, -384, -491, - -203, -288, -51, -331, -90, -178, -408, -573, -338, - 56, -29, -273, -627, -1041, -798, -247, -467, 148, - 66, -2, -205, -205, -575, -349, -57, -352, -58, - -45, -225, -471, -924, -497, 77, -32, 44, -135, - -277, -491, -497, -502, -424, -202, -137, 77, 96, - 26, -179, -469, -1008, -1260, 262, -35, -132, -259, - -66, -232, -447, -533, -789, -191, -100, -267, 364, - 111, 43, -287, -423, -608, -987, -922, -799, -827, - 77, 76, -101, -260, -549, -850, -88, -231, -329, - 75, 24, -66, -269, -427, -528, -773, 201, -5, - 67, 7, -61, -320, -487, 12, -200, -242, -94, - 27, -54, -149, -354, -661, -594, -450, -481, 560, - 31, -69, -246, -549, -1141, -178, -232, -275, -288, - 16, -84, -176, 7, -83, -210, -246, -424, -589, - 63, -60, -201, -90, -269, -400, -685, -1218, -258, - 169, 217, 142, -71, -243, -433, -504, -511, -537, - 6, -105, -234, -321, -188, -131, -307, -521, -1319, - -34, -151, -369, 11, 44, -95, -280, -500, 160, - 31, -37, -163, -334, 288, 89, -150, -86, -299, - -35, -161, -362, -74, -74, -263, 240, 9, -153, - -45, -208, -529, -896, 89, 24, -130, -313, -373, - 234, 276, 197, -10, -236, -162, -134, -85, -112, - 42, -73, 133, 392, 98, 72, -153, -162, -99, - -3, -145, -338, 408, 401, 133, -52, -296, -501, - 3, -109, -152, -85, -56, 42, -145, 703, 205, - -49, -149, -281, -134, -121, -41, -21, 16, 958, - 30, -107, -196, -463, -523, 490, 236, 70, -128, - -33, -161, -364, -148, 757, 516, 250, 43, -65, - -34, -193, -244, 750, 527, 349, 234, 172, 134, - -64, -223, -379, 55, 28, 248, 793, 442, 320, - 29, -85, -298, -622, -888, 127, 206, 387, 460, - -48, -170, -477, -876, 573, 635, 440, 375, 311, - 42, 3, -212, -441, -718, -821, 388, 373, 211, - -106, -155, 1092, 459, 570, 561, 506, 604, 514, - -144, -264, 0, 460, 619, 877, 916, 1273, 921 + 740, 1263, 1292, 1006, 997, 1019, 1017, 976, 923, + 557, 946, 1049, 867, 846, 990, 1112, 1262, 1241, + 633, 898, 996, 756, 662, 683, 783, 909, 996, + 830, 736, 278, 820, 1254, 686, 712, 1039, 473, + 503, 885, 1508, 1307, 1282, 1172, 1119, 1209, 1061, + 416, 719, 989, 1227, 1001, 1052, 954, 741, 1044, + 585, 1132, 1233, 1091, 1247, 1433, 1512, 1448, 1314, + -31, 469, 803, 659, 619, 658, 843, 987, 1113, + 842, 1678, 1841, 1549, 1474, 1256, 1082, 905, 742, + 370, 1216, 1768, 1633, 1212, 636, 22, -330, 71, + 73, 738, 893, 968, 993, 1768, 2273, 1840, 1391, + 1513, 1714, 1238, 534, 276, 315, 461, 459, 508, + 421, 1293, 1640, 1623, 1742, 1617, 1499, 1284, 1006, + -95, 752, 1680, 1569, 1618, 1436, 1200, 980, 712, + -78, 831, 1194, 1110, 1378, 1481, 1492, 1365, 1217, + 670, 1208, 1168, 860, 742, 601, 528, 403, 309, + 397, 621, 966, 752, 579, 398, 400, 329, 252, + 510, 864, 1108, 807, 939, 902, 925, 717, 481, + 539, 835, 913, 719, 617, 544, 591, 565, 642, + 162, 889, 654, 108, -34, 244, 488, 561, 532, + -62, 1033, 1308, 1035, 1127, 1098, 1029, 961, 823, + -14, 945, 990, 801, 755, 815, 847, 913, 892, + 394, 1765, 1666, 1339, 1117, 806, 642, 479, 380, + 529, 1851, 2003, 1228, 622, -41, -416, 344, 819, + 635, 1058, 883, 492, 372, 312, 317, 274, 241, + 279, 966, 1642, 1478, 1463, 1123, 795, 525, 339, + 457, 955, 1177, 1214, 1427, 1457, 1345, 917, 539, + 148, 751, 1515, 1105, 867, 606, 474, 448, 399, + 579, 1081, 1035, 390, 3, -263, -198, -82, 38, + 18, -68, -12, 313, 761, 405, 249, 111, -76, + -91, 827, 948, 648, 613, 535, 522, 490, 421, + 41, -44, -281, -472, 652, 534, 193, 135, -90, + 41, -121, -356, -60, 663, 307, 61, -48, -344, + -118, -204, 328, 512, 870, 793, 610, 402, 186, + 156, 293, 74, -338, -475, -897, -594, -161, -497, + 226, 131, -138, 307, 169, -271, -164, -387, -624, + 62, -32, -61, -252, -541, -828, -1027, -523, -662, + 102, -61, 141, 112, -270, -251, -541, 25, -150, + 6, -132, -356, -686, -96, -322, -522, -31, -326, + -36, -209, -521, -229, 307, -132, -5, -99, -384, + 60, -51, -237, -668, -973, -407, -708, -75, -172, + 26, -138, -266, 111, -302, 43, -278, -356, -359, + 570, 822, 496, -154, -312, -92, 137, 279, 371, + -146, 368, 409, 68, 6, 77, 167, 202, 162, + -103, 294, 607, 415, 483, 462, 480, 431, 408, + -120, -338, -612, -524, 584, 331, 92, 433, 276, + -178, -293, -154, -41, 269, 100, -9, 213, 160, + -218, -304, 463, 454, 397, 273, 202, 286, 273, + -232, 7, 6, -388, -472, -427, -378, -167, -100, + -294, -183, 134, -47, 101, -88, -84, -117, -3, + 57, 17, -202, -634, -989, -1119, -533, 176, -36, + 120, -28, 23, 111, -319, 318, -22, -77, 266, + -271, -464, -434, -658, -640, -385, -385, -99, -69, + -198, -259, -266, -44, -39, -139, -137, 171, 66, + 9, -145, -377, -846, -1000, -111, -325, 342, 135, + -81, -286, -380, 192, -57, 307, 76, -24, -140, + 677, 702, 247, 56, 249, 141, -105, -236, -99, + 36, -39, -69, 348, 198, -93, 322, 91, -72, + -127, -376, -657, 139, 623, 223, 501, 306, 220, + -113, -384, -796, 504, 438, 85, 213, -83, -194, + -174, -422, 7, 1155, 1089, 1182, 1003, 945, 806, + 8, -126, -317, -103, -351, -695, -98, -268, -537, + 33, -103, -290, 167, -39, -407, 44, -208, -375, + 104, -23, -64, -291, -637, -851, -1084, -61, -112, + -75, -306, -434, 218, -148, -354, -680, -133, -216, + -121, -377, -718, -97, -130, -361, -156, -379, -599, + -56, -254, -586, 235, 157, -214, 11, -260, -149, + -124, -267, -397, -580, -593, -527, -805, -385, 346, + -193, -440, -708, -351, -141, -255, -499, -147, -185, + 448, 660, 494, 208, 509, 461, 338, 291, 149, + -223, 88, 335, 159, 212, 191, 286, 308, 205, + -171, -242, 514, 362, 295, 524, 552, 694, 585, + -64, -308, -448, -21, 284, 786, 446, 289, 92, + -218, -390, -7, 169, 206, 330, 352, 408, 358, + -36, 702, 959, 859, 861, 1115, 1269, 1357, 1305, + -133, -341, -65, 678, 417, 440, 486, 518, 780, + 33, -44, -191, -344, -461, -755, -201, 217, -31, + -353, -547, -44, 123, -61, -68, -79, 29, 60, + 73, -57, -406, -766, -1243, -1203, 240, 400, 165, + -73, -282, -601, -213, -171, -375, 332, 35, -103, + -29, -207, -553, -476, -638, -908, 172, -22, -135, + -192, -239, -164, -103, -111, -47, 153, 125, 110, + -1, -203, -570, -1030, -1424, -535, 155, 1, 147, + -333, -653, -865, -197, -158, -21, -44, 95, 108, + 389, 588, 490, 33, -237, -524, -628, -136, -260, + 40, -177, -462, 453, 862, 380, 131, -130, -405, + -76, -281, -741, -742, 898, 619, 277, 71, -222, + -32, -265, -556, -25, 994, 682, 305, 126, -165, + -69, -349, -585, 234, 1158, 903, 626, 510, 251, + -1, -99, -272, -210, -603, -351, -540, -811, -383, + -16, -230, -504, 410, 149, -205, -343, -651, -639, + 103, -9, -227, -205, -562, -781, -1079, -1208, -156, + 143, 63, -135, -67, -317, -602, -784, -1154, -640, + -144, -391, -674, -622, -200, -254, -660, -947, -395, + -40, -250, -625, 27, 543, 94, -131, -386, -673, + -123, -371, -757, -451, -564, -614, -415, -711, -35, + -116, -309, -593, -268, 239, -33, -338, -650, -135, + 94, 251, 554, 57, -312, -423, -154, -57, 235, + -268, -71, 381, 114, -44, -87, 125, 173, 133, + -131, -19, 1149, 670, 486, 356, 309, 369, 296, + -223, -501, -899, -722, -70, 6, 131, 310, 394, + -99, -303, -517, 249, 64, -53, 135, -11, 453, + -147, -399, -730, -401, 817, 738, 802, 749, 575, + -154, -435, -739, 800, 593, 366, 529, 318, 326, + -224, 45, -39, -387, -515, -518, -608, -384, -321, + -315, -377, 143, -101, -113, -377, -177, -144, -12, + 117, 40, -239, -651, -1051, -581, -737, -990, -328, + 26, -50, -157, -23, -453, -283, -531, -546, 192, + -252, -501, -743, -589, -627, -499, -328, -118, -72, + -324, -494, -244, -306, -144, -177, -262, -135, -78, + -36, -234, -519, -961, -1290, -314, -479, -371, -45, + -95, -292, -535, -8, -300, 112, -164, -277, 198, + -99, -128, 880, 836, 579, 351, 23, -95, -217, + -27, -258, 124, 1011, 597, 425, 144, 7, -73, + -69, -300, -683, -435, 1132, 899, 504, 332, 109, + -74, -323, -637, 563, 1074, 608, 371, 105, -49, + -259, -121, 1440, 1334, 1628, 1490, 1438, 1223, 933, + -82, -306, -613, -222, -378, -675, -545, -671, -845, + 53, -124, -347, 422, 52, -125, -270, -529, 9, + 79, -89, -320, -662, -999, -1199, -1243, -676, -297, + -68, -273, -611, 137, -146, -397, -627, -845, -220, + -112, -346, -797, -826, 234, -132, -188, -278, -522, + -159, -405, -734, -419, 293, 74, -167, -167, 184, + -153, -437, -833, -1080, -336, -472, -561, -340, -253, + -169, -423, -820, -904, -131, -19, -346, -604, 31, + 33, -31, 312, 62, -148, 49, -59, 564, 486, + -306, -333, 194, -44, 67, 72, 147, 205, 243, + -207, -49, 1360, 983, 969, 991, 1014, 1110, 973, + -211, -172, 883, 627, 711, 674, 705, 798, 746, + -88, -325, -763, -974, 687, 908, 514, 382, 172, + -292, -612, -805, 63, 131, 270, 259, 352, 348, + -235, -84, 955, 818, 1120, 1289, 1559, 1480, 1285, + -180, -461, -614, 657, 691, 745, 854, 783, 713, + -97, -309, -477, -614, -777, -734, -768, -526, -472, + -344, -476, -35, -169, 49, -77, -150, -240, -141, + -52, -268, -639, -919, -1278, -1113, -342, -333, -151, + -68, -242, -585, -73, -209, -478, -159, -429, 133, + -197, -499, -1005, -1268, -272, -224, -105, -67, 17, + -363, -618, -414, -116, -62, 20, 10, 116, 108, + -195, -475, -906, -1260, -891, -441, -277, -142, -28, + -226, -519, -950, -700, -275, -266, -116, -105, 82, + 404, 511, 520, 327, 17, -194, -333, -536, -586, + -114, -130, 276, 237, 204, 342, 135, -16, -111, + 191, 180, -137, -467, 272, 106, -95, 17, -192, + -80, -290, -626, 194, 598, 196, 21, -281, 77, + 137, 367, 534, 764, 670, 382, 296, 153, 84, + 303, 497, 144, -85, -125, -539, -482, -464, -764, + 233, 347, 68, -147, 169, -210, -242, -226, -482, + 307, 422, 154, -175, -386, -722, -724, -904, -1015, + 309, 308, 160, -60, -470, -420, -598, -791, -219, + 68, 121, -137, -560, -146, -446, -515, -494, -729, + 130, 53, -227, 46, 474, 32, -161, -192, -490, + 213, 164, -71, -465, -876, -161, -456, -587, -48, + 218, 117, 39, 177, -194, -88, -226, -418, 50, + 210, 547, 569, 279, 121, -44, -50, 10, -84, + 58, 140, 182, -5, 267, 117, 106, 211, 198, + 153, 559, 872, 460, 222, 108, 188, 180, 183, + 158, 119, 284, -153, -271, 229, 87, 110, -57, + -183, 82, 118, 21, 13, 40, 118, 191, 185, + 163, 56, 609, 341, 50, 329, 68, 266, 218, + 100, 206, 18, -304, -107, -436, -487, -65, -306, + -86, 154, 134, -30, -45, -73, -104, -80, -96, + 245, 330, 10, -440, -849, -1082, 79, 40, -265, + 196, 372, 272, -181, -493, -389, 275, 80, -59, + 2, -12, -246, -505, -100, -436, 21, -187, -431, + -221, -48, 36, -271, -186, -147, -109, 26, 71, + 213, 140, 72, -351, -620, -84, -363, 69, 46, + 91, 167, -3, -95, -99, -105, -48, 114, 147, + 259, 249, 172, 607, 406, 52, 59, -189, -320, + 115, -85, -54, 574, 128, 226, -59, -253, 130, + 39, 364, 757, 940, 728, 660, 659, 583, 770, + -115, -338, -760, -471, 394, 37, 441, 178, 6, + -57, -305, -525, 796, 453, 188, -4, -114, 248, + 71, 444, 797, 731, 1096, 1157, 1222, 1029, 811, + 135, 359, 551, 425, 749, 815, 874, 704, 502, + 132, 247, 0, -206, -449, -750, -258, -514, -633, + 248, 249, 91, 121, -195, -499, -90, -282, -435, + 78, 20, -277, -623, -983, -1224, -415, -458, -639, + 347, 509, 208, -179, -464, -728, -76, -237, -486, + -103, -343, -756, -713, -265, -609, -191, -398, -636, + -121, -383, -749, 567, 252, -36, -354, -417, -50, + 204, 100, -149, -650, -1081, -47, -7, -263, 111, + -46, -180, -267, -324, -562, -394, -692, 398, 292, + 482, 670, 683, 624, 442, 165, 116, 36, -149, + 108, 247, 291, 247, 355, 122, 109, 224, 296, + 292, 349, 725, 482, 388, 329, 429, 620, 667, + -34, 197, 213, -127, 84, 494, 620, 575, 375, + 126, 207, 172, 167, 362, 202, 296, 395, 455, + -6, 250, 539, 467, 636, 801, 1149, 1287, 1118, + 27, 240, 369, 280, 440, 411, 634, 892, 953, + 159, 170, -58, -395, -797, -690, 77, -211, -334, + -5, -28, -13, -74, -335, -603, 300, 88, -205, + 82, -33, -364, -698, -1203, -1153, 110, -146, -289, + 113, 1, -243, -588, -994, -496, 414, 160, 42, + -56, -247, -440, -693, -996, -479, 11, -178, -357, + -151, -353, -327, -211, -340, 141, 65, 425, 453, + 34, -169, -455, -932, -1215, 138, 499, 256, 324, + 68, 139, -15, -547, -478, 17, 306, 502, 481, + -32, -134, 445, 129, -143, -244, -503, -507, -599, + 61, -140, -345, 496, 458, -2, 20, -227, -514, + 215, 519, 920, 1053, 1090, 791, 528, 290, 155, + -54, -233, -647, -602, 639, 294, -2, -167, -442, + -78, -315, -791, -113, 820, 403, 158, -116, -356, + -105, -379, -236, 1224, 893, 749, 568, 356, 214, + -17, -199, -144, 50, -283, -247, -578, -846, -1087, + 69, -11, -381, -206, 209, -284, -387, -416, -716, + 39, -5, -145, -374, -682, -909, -1074, -1169, -1066, + 287, 226, 67, -221, -662, -171, -421, -642, -707, + -132, -348, -538, -448, -20, -4, -354, -748, -933, + 4, -75, -289, -598, 317, 52, -208, -297, -559, + -88, -264, -358, -589, -631, -248, -523, -822, -1071, + 70, -8, 54, -314, -515, 92, -146, -274, -493, + 199, 62, 391, 158, -141, 71, -219, -203, -207, + 152, 40, 329, 162, -29, 48, -149, 108, 127, + 267, 722, 1256, 882, 625, 248, 8, -81, -60, + -58, -138, -291, -600, -12, -2, -39, 147, 117, + -107, -345, -513, 459, 76, 92, -272, 388, 262, + 362, 516, 203, -409, -716, -831, -331, 185, 209, + -117, -391, -298, 671, 292, 538, 257, 166, -38, + -102, -319, -194, -283, -573, -262, -579, -219, -444, + -235, 78, 11, -168, -101, -229, -263, -321, -123, + 70, 50, -170, -599, -996, -588, -263, -516, -455, + 394, 363, 229, -136, -538, 21, -183, -348, -201, + -124, -368, -640, -879, -847, -209, -409, -494, -515, + -127, -341, -541, -425, -510, -10, -252, -473, -291, + 84, -69, -201, -676, -868, 103, -311, -132, -320, + 5, -173, -188, -297, -628, 197, -57, 7, -11, + 49, -160, 56, 558, 111, 33, -311, -440, -463, + -1, -246, -307, 862, 453, 139, -170, -355, -232, + -197, -38, 1702, 1331, 1252, 950, 692, 504, 426, + -108, -344, -861, -1172, 444, 354, 88, -46, -220, + -53, -321, -494, 1113, 744, 364, 198, -34, -75, + -69, 199, 897, 1140, 1343, 1183, 977, 742, 522, + 122, 44, -269, 27, -155, -562, -307, -590, -773, + 154, 42, -160, 252, -129, -305, -471, -733, -371, + 135, 185, -82, -416, -722, -913, -504, -743, -880, + 149, 214, -84, -329, -680, -835, -426, -661, -81, + -128, -380, -735, -998, -337, 17, -182, -467, -697, + -84, -290, -510, -592, 13, 440, 154, -38, -279, + 70, -61, -246, -727, -1047, -80, -381, -535, -704, + 178, -2, -146, -670, -938, 482, 138, 63, 65, + -11, 15, 772, 443, 142, -20, -209, -126, -161, + -32, -249, 95, 552, 124, 30, -343, 82, -86, + -163, -257, 899, 1097, 906, 751, 502, 390, 294, + -51, -258, -447, -806, -368, 763, 464, 364, 183, + -166, -374, -367, 87, 35, 399, 418, 856, 833, + -205, -310, 588, 778, 785, 1065, 1118, 1245, 1157, + -173, -312, 107, 345, 400, 790, 870, 1113, 1001, + -7, -120, -387, -410, -614, -943, -226, -384, -491, + -203, -288, -51, -331, -90, -178, -408, -573, -338, + 56, -29, -273, -627, -1041, -798, -247, -467, 148, + 66, -2, -205, -205, -575, -349, -57, -352, -58, + -45, -225, -471, -924, -497, 77, -32, 44, -135, + -277, -491, -497, -502, -424, -202, -137, 77, 96, + 26, -179, -469, -1008, -1260, 262, -35, -132, -259, + -66, -232, -447, -533, -789, -191, -100, -267, 364, + 111, 43, -287, -423, -608, -987, -922, -799, -827, + 77, 76, -101, -260, -549, -850, -88, -231, -329, + 75, 24, -66, -269, -427, -528, -773, 201, -5, + 67, 7, -61, -320, -487, 12, -200, -242, -94, + 27, -54, -149, -354, -661, -594, -450, -481, 560, + 31, -69, -246, -549, -1141, -178, -232, -275, -288, + 16, -84, -176, 7, -83, -210, -246, -424, -589, + 63, -60, -201, -90, -269, -400, -685, -1218, -258, + 169, 217, 142, -71, -243, -433, -504, -511, -537, + 6, -105, -234, -321, -188, -131, -307, -521, -1319, + -34, -151, -369, 11, 44, -95, -280, -500, 160, + 31, -37, -163, -334, 288, 89, -150, -86, -299, + -35, -161, -362, -74, -74, -263, 240, 9, -153, + -45, -208, -529, -896, 89, 24, -130, -313, -373, + 234, 276, 197, -10, -236, -162, -134, -85, -112, + 42, -73, 133, 392, 98, 72, -153, -162, -99, + -3, -145, -338, 408, 401, 133, -52, -296, -501, + 3, -109, -152, -85, -56, 42, -145, 703, 205, + -49, -149, -281, -134, -121, -41, -21, 16, 958, + 30, -107, -196, -463, -523, 490, 236, 70, -128, + -33, -161, -364, -148, 757, 516, 250, 43, -65, + -34, -193, -244, 750, 527, 349, 234, 172, 134, + -64, -223, -379, 55, 28, 248, 793, 442, 320, + 29, -85, -298, -622, -888, 127, 206, 387, 460, + -48, -170, -477, -876, 573, 635, 440, 375, 311, + 42, 3, -212, -441, -718, -821, 388, 373, 211, + -106, -155, 1092, 459, 570, 561, 506, 604, 514, + -144, -264, 0, 460, 619, 877, 916, 1273, 921 }; /*-------------------------------------------------------------------* @@ -9235,262 +9235,262 @@ const Word16 dico1_isf_fx[] = /* ISF codebook - common 1st stage, 2nd split (only in AMR-WB IO mode) */ const Word16 dico2_isf_fx[] = {/*Qlog2(2.56)*/ - 1357, 1313, 1136, 784, 438, 181, 145, - 636, 648, 667, 568, 442, 217, 362, - 427, 440, 674, 524, 332, 117, -417, - 121, 295, 468, 465, 230, 44, -221, - -147, -240, 149, 80, 390, 278, 106, - -418, -556, 552, 511, 235, 144, -95, - 43, 193, 274, 150, 67, 34, -273, - -43, -126, 171, 416, 282, 63, -354, - -372, -86, -344, -108, -94, -182, -89, - -600, -840, -200, 465, 258, -11, -253, - -48, 329, 97, -290, -543, -795, -354, - -570, -117, 187, 10, -133, -416, -76, - -618, -129, -247, -371, 45, -76, 277, - -1022, -1079, 126, 474, 254, 127, 52, - -281, 76, -167, -361, -283, -551, -283, - -119, -52, -1, 134, -32, -204, -415, - 1064, 827, 637, 684, 464, 209, 12, - 482, 416, 449, 371, 335, 294, 194, - 719, 576, 365, 135, 113, 91, -199, - 298, 176, 493, 366, 194, 163, 36, - -35, -236, -259, -36, -4, 99, 152, - -98, -306, -27, 228, 90, 111, -86, - 91, 13, -211, -258, -106, 86, -64, - 73, -35, -57, -31, 162, 35, -192, - -109, -335, -629, -66, -61, -128, 322, - -495, -669, -728, 193, 31, -220, 122, - 324, 95, -89, -91, -409, -710, -154, - 0, -234, 92, 33, -343, -609, -220, - -343, -408, -476, -655, -153, 82, 222, - -490, -745, -255, 49, -48, 135, -127, - 119, -67, -328, -390, -272, -545, -56, - -57, -130, -10, -7, -164, -47, -22, - 984, 1064, 961, 568, 210, -27, 16, - 811, 691, 754, 514, 224, -35, 166, - 662, 704, 618, 386, 57, -211, -257, - 510, 359, 418, 393, 91, -144, -18, - -193, -31, -27, 223, 89, -143, 24, - -112, -98, 471, 319, 185, 3, 175, - 252, 146, -47, 272, 48, -211, -234, - 146, 69, 203, 364, 68, -52, 51, - -259, -478, -697, -349, -758, -501, 63, - -501, -769, -289, 79, -311, -497, -106, - 251, 53, -235, -469, -895, -884, 145, - -416, -551, 140, -133, -523, -775, 44, - -326, -423, -713, -497, -86, -431, 99, - -757, -772, -160, -76, -46, -32, 379, - 85, -35, -200, -401, -663, -1040, -247, - -180, -330, -92, -376, 27, -183, -110, - 1279, 1086, 781, 502, 324, 164, 157, - 682, 466, 449, 277, 146, 28, 409, - 635, 472, 390, 107, -232, -538, -139, - 196, 396, 332, 213, 209, -29, -81, - 150, -95, -312, 76, -77, -320, -50, - 46, 9, 47, 175, 139, 30, 384, - 218, 206, -24, -250, -96, -276, -183, - 26, 119, 38, 14, -4, -133, -52, - -477, -614, -987, -715, -631, -813, 200, - -744, -1009, -1065, -745, -631, -171, 18, - -137, -251, -483, -613, -980, -1203, 12, - -605, -767, -562, -686, -1088, -515, 58, - -202, -428, -782, -1072, -96, -234, -179, - -480, -709, -1070, -897, -131, -92, 321, - -145, -193, -512, -729, -572, -765, -210, - -331, -585, -525, -631, -281, -208, -303, - 1165, 1104, 939, 828, 716, 426, 155, - 6, -109, 820, 778, 415, 113, -27, - 381, 339, 314, 265, 121, -9, -474, - -373, 47, 584, 442, 99, -231, -113, - -496, -38, -285, 262, 305, 170, 4, - -587, -556, 69, 66, 471, 354, 13, - -138, 70, -18, 106, 67, 167, -302, - -445, -141, 185, 191, 151, 83, -133, - -257, -521, -720, -198, 134, -46, -182, - -819, -1168, -777, 512, 359, 95, -113, - 137, -2, -74, -138, -401, -114, -371, - -242, -466, 204, 223, -31, -212, -192, - -532, -637, -466, -686, 256, 277, -139, - -1141, -1244, -381, -75, -54, 14, 88, - -311, 115, -143, -499, -343, 124, -416, - -616, -147, -135, 43, -4, 121, -369, - 835, 783, 641, 390, 355, 350, 64, - 72, 194, 443, 467, 436, 219, 372, - 464, 369, 192, 4, -156, -72, -226, - 57, 206, 303, 205, 188, 101, 265, - -40, -205, -488, -184, 276, 64, -26, - -217, -433, -297, 137, 328, 308, -289, - 378, 81, -308, -465, 57, -37, 227, - -100, 24, -36, -151, 199, 8, 143, - -426, -697, -1059, -133, 388, 161, 321, - -644, -1023, -1271, 39, 66, -123, 70, - 372, 177, -173, -556, -553, -304, -189, - -117, -369, -425, -122, -462, -152, -73, - -649, -850, -1189, -767, 497, 360, 222, - -798, -1139, -1455, -190, 430, 234, 179, - 42, -94, -405, -692, 38, -202, -246, - -169, -366, -290, -88, -64, 32, -292, - 1010, 923, 938, 710, 465, 230, 342, - 217, 300, 1054, 675, 68, -458, -179, - 78, 453, 316, 18, -237, -496, -243, - 167, 21, 424, 215, -91, -303, -170, - -290, -81, -70, -67, 40, 54, -59, - -353, -427, -90, 53, 94, 9, 54, - -28, 318, 283, 15, -240, -58, 79, - -75, -121, 229, 35, 58, 6, -133, - -351, -514, -744, -834, -705, -137, 164, - -1124, -1388, -1055, -230, -73, 40, 36, - -163, -233, -532, -785, -1170, -697, 96, - -788, -959, -246, -430, -624, -165, -8, - -856, -540, -630, -907, -337, -70, 76, - -937, -1042, -659, -733, -208, 199, -26, - -523, 78, -98, -501, -869, -890, -81, - -624, -703, -45, -348, -25, 87, -186, - 1005, 823, 546, 249, 90, -22, 207, - 298, 397, 381, 319, 200, 62, 303, - 473, 379, 133, -247, -632, -441, 75, - 284, 208, 391, 115, -25, 44, 95, - -72, 79, -95, -63, -129, -293, 203, - -164, -349, 115, 122, 69, -1, 378, - 348, 170, 99, 58, -179, -302, 188, - -190, -2, 150, 23, -51, -11, 216, - -615, -863, -1090, -1427, -802, -48, -6, - -961, -1276, -1548, -727, -58, 56, 223, - -124, -255, -561, -988, -1277, -148, -82, - -480, -660, -891, -1191, -1339, -325, 20, - -621, -917, -1296, -1350, 264, 289, 50, - -844, -1022, -1345, -1329, -293, 46, 278, - -260, -468, -829, -1176, -533, -560, -78, - -215, -484, -822, -1233, -791, 15, -138, - 1301, 1317, 1262, 1048, 716, 357, -64, - 578, 824, 925, 802, 630, 362, 102, - 470, 925, 767, 514, 327, 190, -112, - 225, 492, 495, 437, 598, 384, -45, - 43, 82, -42, 175, 519, 342, -64, - -304, -154, 159, 576, 403, 221, 327, - 214, 244, 122, -62, 312, 92, -160, - 218, 208, 310, 268, 306, 323, -199, - -285, -269, -79, -124, -143, -153, 236, - -205, -384, -426, 344, 59, -185, -184, - -272, 247, 126, -210, -518, -468, 78, - -99, -120, 502, 160, -280, -557, 304, - -423, -17, -283, -443, 215, 212, -140, - -564, -684, -228, 510, 361, 130, 323, - -428, 335, 98, -65, 36, -215, -246, - -362, 51, 364, -16, -234, 150, -165, - 914, 883, 751, 653, 676, 464, -153, - 631, 545, 535, 720, 596, 360, -81, - 783, 712, 512, 439, 341, 251, -391, - 497, 417, 249, 372, 295, 173, -193, - 128, -110, -385, 93, 39, 173, -231, - 216, -59, -253, 462, 389, 154, 69, - 455, 270, -4, -337, -49, 233, -322, - 307, 143, 53, 218, 128, 236, -156, - -37, -186, -240, -411, -110, 9, 399, - -140, -365, -628, 258, 380, 214, 277, - 131, 454, 177, -285, -520, 108, -214, - 77, -141, 201, -123, -490, -131, 60, - -14, -194, -521, -741, 273, 362, -33, - -362, -566, -287, -228, 161, 237, 317, - -269, 195, -75, -375, -204, 11, 77, - -128, -264, -156, -223, -475, 265, 27, - 1238, 1147, 916, 689, 432, 210, -280, - 800, 664, 879, 726, 411, 160, -164, - 454, 686, 536, 275, 147, 46, 111, - 303, 486, 512, 355, 241, 181, -69, - 79, 92, 29, 147, 233, 52, 17, - -171, 289, 131, 439, 271, 3, -10, - 413, 241, 144, 174, 155, -2, 14, - 58, 217, 247, 219, 149, 175, -18, - 228, -8, -240, -206, -513, -191, 202, - -96, -272, -454, 33, -300, -575, 46, - -10, -108, -246, -347, -770, -535, 9, - -326, -430, -61, -321, -704, -299, 201, - -1, -280, -603, -419, -185, 18, -36, - -516, -522, -379, -291, -181, -97, 27, - -159, -313, -525, -224, -510, -831, -197, - -292, -459, -59, -310, -562, -143, -351, - 1066, 912, 631, 389, 207, 86, -224, - 596, 512, 596, 505, 314, 122, -48, - 787, 861, 441, -93, -303, 33, -190, - 257, 469, 337, 51, 15, 298, -93, - 295, 73, -119, 25, 36, 23, 108, - -28, -3, -32, 114, 21, 185, 107, - 482, 305, 15, -279, -319, 52, 96, - 226, 46, 115, 72, -136, 133, -125, - 18, -207, -559, -590, -503, -482, 321, - -571, -789, -951, -172, -441, -538, 113, - 181, 14, -310, -641, -1001, -202, 159, - -136, -393, -433, -513, -911, -144, -22, - 72, -265, -706, -954, -159, 53, 332, - -338, -591, -852, -383, -395, 56, 44, - 43, -158, -464, -897, -631, -157, -294, - -161, -128, -328, -573, -483, -125, 11, - 1017, 906, 1051, 1005, 679, 341, -102, - 359, 334, 1567, 1314, 723, 105, 10, - -65, 726, 529, 301, 220, 43, -273, - -510, 436, 719, 566, 358, 179, 114, - -560, 298, 133, -120, 342, 225, 14, - -899, -101, 217, 617, 400, 146, -58, - -41, 352, 82, -196, 39, 121, -167, - -212, 59, 447, 284, 423, 250, -169, - -371, -484, -596, 30, -41, 249, 22, - -372, -650, -794, 477, 445, 216, -79, - -352, 275, 17, -443, -929, 92, 19, - -699, -696, 431, 264, -49, -310, 182, - -978, -217, -430, -400, 101, 261, 72, - -929, -889, -357, -13, 463, 378, 236, - -826, 56, 30, -299, -360, -128, -51, - -878, -299, -111, 75, 65, 36, 3, - 817, 368, -25, 354, 697, 591, -173, - 309, 212, 222, 751, 484, 140, -56, - 593, 379, 70, -8, 258, 180, 110, - 165, -46, 255, 297, 219, 273, 105, - 160, -70, -358, -181, 379, 330, 319, - -238, -369, -198, 740, 580, 319, -143, - 201, 109, -202, -456, 328, 276, -141, - 203, 170, 111, 42, 207, 360, 188, - -345, -399, -513, -233, 650, 422, 81, - -635, -961, -1220, 463, 539, 204, 209, - 202, -25, -194, -498, -787, 193, -143, - -449, -538, 195, -106, -331, 68, 62, - -228, -477, -840, -576, 317, 128, 283, - -671, -937, -807, -114, 391, 335, -62, - 246, 2, -314, -679, -303, 180, -88, - -107, -272, 90, -198, -28, 290, -112, - 885, 1149, 1021, 712, 496, 281, -83, - 269, 492, 787, 643, 347, 70, 124, - 336, 636, 499, 92, -229, -179, 191, - 26, 402, 564, 340, 149, -11, 135, - -440, 561, 470, 204, -72, -186, 140, - -720, 14, 355, 229, 68, -133, 465, - 110, 310, 103, 12, 106, 29, 158, - -178, 113, 161, 142, 121, 115, 27, - -651, -414, -645, -152, -164, -13, -429, - -639, -944, -681, -104, -81, 52, -189, - -663, -164, -316, -683, -954, -205, -83, - -609, -669, -172, -517, -694, 283, -80, - -646, -152, -383, -678, -246, -40, -143, - -747, -796, -745, -390, -98, 43, 275, - -599, -199, -398, -433, -436, -538, 31, - -1107, -568, -376, -265, -126, -21, 1, - 847, 573, 308, 392, 305, 101, 55, - 273, 293, 201, 267, 346, 201, 123, - 727, 480, 226, 2, -65, -138, 164, - 273, 208, 173, 292, 12, 253, 174, - 340, 207, 180, 88, 116, 46, 475, - -460, -166, -30, 13, 110, 173, 396, - 137, 88, 43, -137, -94, 34, 284, - 96, -14, 226, 40, 63, 70, 130, - -467, -735, -1012, -1174, -307, 305, -67, - -612, -920, -1146, -567, -8, 92, -25, - -182, -271, -492, -754, -857, 287, -75, - -494, -787, -689, -683, -709, 137, -326, - -288, -550, -903, -1105, 334, 321, -62, - -354, -653, -834, -445, 1, 377, -152, - -162, -306, -608, -937, -297, 247, -192, - -234, -477, -244, -488, -266, 342, -332 + 1357, 1313, 1136, 784, 438, 181, 145, + 636, 648, 667, 568, 442, 217, 362, + 427, 440, 674, 524, 332, 117, -417, + 121, 295, 468, 465, 230, 44, -221, + -147, -240, 149, 80, 390, 278, 106, + -418, -556, 552, 511, 235, 144, -95, + 43, 193, 274, 150, 67, 34, -273, + -43, -126, 171, 416, 282, 63, -354, + -372, -86, -344, -108, -94, -182, -89, + -600, -840, -200, 465, 258, -11, -253, + -48, 329, 97, -290, -543, -795, -354, + -570, -117, 187, 10, -133, -416, -76, + -618, -129, -247, -371, 45, -76, 277, + -1022, -1079, 126, 474, 254, 127, 52, + -281, 76, -167, -361, -283, -551, -283, + -119, -52, -1, 134, -32, -204, -415, + 1064, 827, 637, 684, 464, 209, 12, + 482, 416, 449, 371, 335, 294, 194, + 719, 576, 365, 135, 113, 91, -199, + 298, 176, 493, 366, 194, 163, 36, + -35, -236, -259, -36, -4, 99, 152, + -98, -306, -27, 228, 90, 111, -86, + 91, 13, -211, -258, -106, 86, -64, + 73, -35, -57, -31, 162, 35, -192, + -109, -335, -629, -66, -61, -128, 322, + -495, -669, -728, 193, 31, -220, 122, + 324, 95, -89, -91, -409, -710, -154, + 0, -234, 92, 33, -343, -609, -220, + -343, -408, -476, -655, -153, 82, 222, + -490, -745, -255, 49, -48, 135, -127, + 119, -67, -328, -390, -272, -545, -56, + -57, -130, -10, -7, -164, -47, -22, + 984, 1064, 961, 568, 210, -27, 16, + 811, 691, 754, 514, 224, -35, 166, + 662, 704, 618, 386, 57, -211, -257, + 510, 359, 418, 393, 91, -144, -18, + -193, -31, -27, 223, 89, -143, 24, + -112, -98, 471, 319, 185, 3, 175, + 252, 146, -47, 272, 48, -211, -234, + 146, 69, 203, 364, 68, -52, 51, + -259, -478, -697, -349, -758, -501, 63, + -501, -769, -289, 79, -311, -497, -106, + 251, 53, -235, -469, -895, -884, 145, + -416, -551, 140, -133, -523, -775, 44, + -326, -423, -713, -497, -86, -431, 99, + -757, -772, -160, -76, -46, -32, 379, + 85, -35, -200, -401, -663, -1040, -247, + -180, -330, -92, -376, 27, -183, -110, + 1279, 1086, 781, 502, 324, 164, 157, + 682, 466, 449, 277, 146, 28, 409, + 635, 472, 390, 107, -232, -538, -139, + 196, 396, 332, 213, 209, -29, -81, + 150, -95, -312, 76, -77, -320, -50, + 46, 9, 47, 175, 139, 30, 384, + 218, 206, -24, -250, -96, -276, -183, + 26, 119, 38, 14, -4, -133, -52, + -477, -614, -987, -715, -631, -813, 200, + -744, -1009, -1065, -745, -631, -171, 18, + -137, -251, -483, -613, -980, -1203, 12, + -605, -767, -562, -686, -1088, -515, 58, + -202, -428, -782, -1072, -96, -234, -179, + -480, -709, -1070, -897, -131, -92, 321, + -145, -193, -512, -729, -572, -765, -210, + -331, -585, -525, -631, -281, -208, -303, + 1165, 1104, 939, 828, 716, 426, 155, + 6, -109, 820, 778, 415, 113, -27, + 381, 339, 314, 265, 121, -9, -474, + -373, 47, 584, 442, 99, -231, -113, + -496, -38, -285, 262, 305, 170, 4, + -587, -556, 69, 66, 471, 354, 13, + -138, 70, -18, 106, 67, 167, -302, + -445, -141, 185, 191, 151, 83, -133, + -257, -521, -720, -198, 134, -46, -182, + -819, -1168, -777, 512, 359, 95, -113, + 137, -2, -74, -138, -401, -114, -371, + -242, -466, 204, 223, -31, -212, -192, + -532, -637, -466, -686, 256, 277, -139, + -1141, -1244, -381, -75, -54, 14, 88, + -311, 115, -143, -499, -343, 124, -416, + -616, -147, -135, 43, -4, 121, -369, + 835, 783, 641, 390, 355, 350, 64, + 72, 194, 443, 467, 436, 219, 372, + 464, 369, 192, 4, -156, -72, -226, + 57, 206, 303, 205, 188, 101, 265, + -40, -205, -488, -184, 276, 64, -26, + -217, -433, -297, 137, 328, 308, -289, + 378, 81, -308, -465, 57, -37, 227, + -100, 24, -36, -151, 199, 8, 143, + -426, -697, -1059, -133, 388, 161, 321, + -644, -1023, -1271, 39, 66, -123, 70, + 372, 177, -173, -556, -553, -304, -189, + -117, -369, -425, -122, -462, -152, -73, + -649, -850, -1189, -767, 497, 360, 222, + -798, -1139, -1455, -190, 430, 234, 179, + 42, -94, -405, -692, 38, -202, -246, + -169, -366, -290, -88, -64, 32, -292, + 1010, 923, 938, 710, 465, 230, 342, + 217, 300, 1054, 675, 68, -458, -179, + 78, 453, 316, 18, -237, -496, -243, + 167, 21, 424, 215, -91, -303, -170, + -290, -81, -70, -67, 40, 54, -59, + -353, -427, -90, 53, 94, 9, 54, + -28, 318, 283, 15, -240, -58, 79, + -75, -121, 229, 35, 58, 6, -133, + -351, -514, -744, -834, -705, -137, 164, + -1124, -1388, -1055, -230, -73, 40, 36, + -163, -233, -532, -785, -1170, -697, 96, + -788, -959, -246, -430, -624, -165, -8, + -856, -540, -630, -907, -337, -70, 76, + -937, -1042, -659, -733, -208, 199, -26, + -523, 78, -98, -501, -869, -890, -81, + -624, -703, -45, -348, -25, 87, -186, + 1005, 823, 546, 249, 90, -22, 207, + 298, 397, 381, 319, 200, 62, 303, + 473, 379, 133, -247, -632, -441, 75, + 284, 208, 391, 115, -25, 44, 95, + -72, 79, -95, -63, -129, -293, 203, + -164, -349, 115, 122, 69, -1, 378, + 348, 170, 99, 58, -179, -302, 188, + -190, -2, 150, 23, -51, -11, 216, + -615, -863, -1090, -1427, -802, -48, -6, + -961, -1276, -1548, -727, -58, 56, 223, + -124, -255, -561, -988, -1277, -148, -82, + -480, -660, -891, -1191, -1339, -325, 20, + -621, -917, -1296, -1350, 264, 289, 50, + -844, -1022, -1345, -1329, -293, 46, 278, + -260, -468, -829, -1176, -533, -560, -78, + -215, -484, -822, -1233, -791, 15, -138, + 1301, 1317, 1262, 1048, 716, 357, -64, + 578, 824, 925, 802, 630, 362, 102, + 470, 925, 767, 514, 327, 190, -112, + 225, 492, 495, 437, 598, 384, -45, + 43, 82, -42, 175, 519, 342, -64, + -304, -154, 159, 576, 403, 221, 327, + 214, 244, 122, -62, 312, 92, -160, + 218, 208, 310, 268, 306, 323, -199, + -285, -269, -79, -124, -143, -153, 236, + -205, -384, -426, 344, 59, -185, -184, + -272, 247, 126, -210, -518, -468, 78, + -99, -120, 502, 160, -280, -557, 304, + -423, -17, -283, -443, 215, 212, -140, + -564, -684, -228, 510, 361, 130, 323, + -428, 335, 98, -65, 36, -215, -246, + -362, 51, 364, -16, -234, 150, -165, + 914, 883, 751, 653, 676, 464, -153, + 631, 545, 535, 720, 596, 360, -81, + 783, 712, 512, 439, 341, 251, -391, + 497, 417, 249, 372, 295, 173, -193, + 128, -110, -385, 93, 39, 173, -231, + 216, -59, -253, 462, 389, 154, 69, + 455, 270, -4, -337, -49, 233, -322, + 307, 143, 53, 218, 128, 236, -156, + -37, -186, -240, -411, -110, 9, 399, + -140, -365, -628, 258, 380, 214, 277, + 131, 454, 177, -285, -520, 108, -214, + 77, -141, 201, -123, -490, -131, 60, + -14, -194, -521, -741, 273, 362, -33, + -362, -566, -287, -228, 161, 237, 317, + -269, 195, -75, -375, -204, 11, 77, + -128, -264, -156, -223, -475, 265, 27, + 1238, 1147, 916, 689, 432, 210, -280, + 800, 664, 879, 726, 411, 160, -164, + 454, 686, 536, 275, 147, 46, 111, + 303, 486, 512, 355, 241, 181, -69, + 79, 92, 29, 147, 233, 52, 17, + -171, 289, 131, 439, 271, 3, -10, + 413, 241, 144, 174, 155, -2, 14, + 58, 217, 247, 219, 149, 175, -18, + 228, -8, -240, -206, -513, -191, 202, + -96, -272, -454, 33, -300, -575, 46, + -10, -108, -246, -347, -770, -535, 9, + -326, -430, -61, -321, -704, -299, 201, + -1, -280, -603, -419, -185, 18, -36, + -516, -522, -379, -291, -181, -97, 27, + -159, -313, -525, -224, -510, -831, -197, + -292, -459, -59, -310, -562, -143, -351, + 1066, 912, 631, 389, 207, 86, -224, + 596, 512, 596, 505, 314, 122, -48, + 787, 861, 441, -93, -303, 33, -190, + 257, 469, 337, 51, 15, 298, -93, + 295, 73, -119, 25, 36, 23, 108, + -28, -3, -32, 114, 21, 185, 107, + 482, 305, 15, -279, -319, 52, 96, + 226, 46, 115, 72, -136, 133, -125, + 18, -207, -559, -590, -503, -482, 321, + -571, -789, -951, -172, -441, -538, 113, + 181, 14, -310, -641, -1001, -202, 159, + -136, -393, -433, -513, -911, -144, -22, + 72, -265, -706, -954, -159, 53, 332, + -338, -591, -852, -383, -395, 56, 44, + 43, -158, -464, -897, -631, -157, -294, + -161, -128, -328, -573, -483, -125, 11, + 1017, 906, 1051, 1005, 679, 341, -102, + 359, 334, 1567, 1314, 723, 105, 10, + -65, 726, 529, 301, 220, 43, -273, + -510, 436, 719, 566, 358, 179, 114, + -560, 298, 133, -120, 342, 225, 14, + -899, -101, 217, 617, 400, 146, -58, + -41, 352, 82, -196, 39, 121, -167, + -212, 59, 447, 284, 423, 250, -169, + -371, -484, -596, 30, -41, 249, 22, + -372, -650, -794, 477, 445, 216, -79, + -352, 275, 17, -443, -929, 92, 19, + -699, -696, 431, 264, -49, -310, 182, + -978, -217, -430, -400, 101, 261, 72, + -929, -889, -357, -13, 463, 378, 236, + -826, 56, 30, -299, -360, -128, -51, + -878, -299, -111, 75, 65, 36, 3, + 817, 368, -25, 354, 697, 591, -173, + 309, 212, 222, 751, 484, 140, -56, + 593, 379, 70, -8, 258, 180, 110, + 165, -46, 255, 297, 219, 273, 105, + 160, -70, -358, -181, 379, 330, 319, + -238, -369, -198, 740, 580, 319, -143, + 201, 109, -202, -456, 328, 276, -141, + 203, 170, 111, 42, 207, 360, 188, + -345, -399, -513, -233, 650, 422, 81, + -635, -961, -1220, 463, 539, 204, 209, + 202, -25, -194, -498, -787, 193, -143, + -449, -538, 195, -106, -331, 68, 62, + -228, -477, -840, -576, 317, 128, 283, + -671, -937, -807, -114, 391, 335, -62, + 246, 2, -314, -679, -303, 180, -88, + -107, -272, 90, -198, -28, 290, -112, + 885, 1149, 1021, 712, 496, 281, -83, + 269, 492, 787, 643, 347, 70, 124, + 336, 636, 499, 92, -229, -179, 191, + 26, 402, 564, 340, 149, -11, 135, + -440, 561, 470, 204, -72, -186, 140, + -720, 14, 355, 229, 68, -133, 465, + 110, 310, 103, 12, 106, 29, 158, + -178, 113, 161, 142, 121, 115, 27, + -651, -414, -645, -152, -164, -13, -429, + -639, -944, -681, -104, -81, 52, -189, + -663, -164, -316, -683, -954, -205, -83, + -609, -669, -172, -517, -694, 283, -80, + -646, -152, -383, -678, -246, -40, -143, + -747, -796, -745, -390, -98, 43, 275, + -599, -199, -398, -433, -436, -538, 31, + -1107, -568, -376, -265, -126, -21, 1, + 847, 573, 308, 392, 305, 101, 55, + 273, 293, 201, 267, 346, 201, 123, + 727, 480, 226, 2, -65, -138, 164, + 273, 208, 173, 292, 12, 253, 174, + 340, 207, 180, 88, 116, 46, 475, + -460, -166, -30, 13, 110, 173, 396, + 137, 88, 43, -137, -94, 34, 284, + 96, -14, 226, 40, 63, 70, 130, + -467, -735, -1012, -1174, -307, 305, -67, + -612, -920, -1146, -567, -8, 92, -25, + -182, -271, -492, -754, -857, 287, -75, + -494, -787, -689, -683, -709, 137, -326, + -288, -550, -903, -1105, 334, 321, -62, + -354, -653, -834, -445, 1, 377, -152, + -162, -306, -608, -937, -297, 247, -192, + -234, -477, -244, -488, -266, 342, -332 }; /*-------------------------------------------------------------------* @@ -9513,70 +9513,70 @@ const Word16 dico2_isf_fx[] = /* ISF codebook - 46b, 2nd stage, 1st split (only in AMR-WB IO mode) */ const Word16 dico21_isf_46b_fx[] = {/*Qlog2(2.56)*/ - 329, 409, 249, - -33, 505, 160, - -29, -14, 582, - -262, 127, 354, - 145, 237, 175, - -152, 245, 122, - 27, 42, 340, - -84, -93, 311, - 285, 222, -156, - 47, -43, -504, - 234, 121, 385, - 104, -317, 45, - 176, 195, 8, - 104, -59, -94, - 177, 53, 192, - -34, -127, 152, - 570, 277, -34, - -67, -329, -639, - -157, -272, 462, - -177, -462, 198, - 322, 179, 115, - -386, 171, 19, - 19, -12, 195, - -120, -252, 201, - 304, 36, -336, - -128, -221, -380, - 171, -185, 296, - -242, -312, 23, - 198, 39, 16, - -3, -177, -111, - 111, -93, 76, - -92, -223, 4, - 177, 406, -44, - -168, 380, -149, - -4, 273, 331, - -420, 513, 277, - 21, 247, 47, - -58, 131, -2, - -3, 134, 180, - -145, 40, 175, - 189, 74, -145, - -27, -45, -325, - 370, -114, -21, - -83, -415, -173, - 77, 95, -51, - -40, -30, -67, - 71, 88, 86, - -35, -98, 14, - 69, 197, -334, - -196, 79, -231, - -348, -137, 218, - -352, -89, -85, - 47, 201, -130, - -165, 37, -15, - -43, 3, 86, - -161, -108, 79, - 83, 21, -237, - -81, -149, -238, - 150, -186, -251, - -186, -249, -162, - -19, 66, -139, - -26, -50, -181, - 24, 11, 0, - -130, -105, -98 + 329, 409, 249, + -33, 505, 160, + -29, -14, 582, + -262, 127, 354, + 145, 237, 175, + -152, 245, 122, + 27, 42, 340, + -84, -93, 311, + 285, 222, -156, + 47, -43, -504, + 234, 121, 385, + 104, -317, 45, + 176, 195, 8, + 104, -59, -94, + 177, 53, 192, + -34, -127, 152, + 570, 277, -34, + -67, -329, -639, + -157, -272, 462, + -177, -462, 198, + 322, 179, 115, + -386, 171, 19, + 19, -12, 195, + -120, -252, 201, + 304, 36, -336, + -128, -221, -380, + 171, -185, 296, + -242, -312, 23, + 198, 39, 16, + -3, -177, -111, + 111, -93, 76, + -92, -223, 4, + 177, 406, -44, + -168, 380, -149, + -4, 273, 331, + -420, 513, 277, + 21, 247, 47, + -58, 131, -2, + -3, 134, 180, + -145, 40, 175, + 189, 74, -145, + -27, -45, -325, + 370, -114, -21, + -83, -415, -173, + 77, 95, -51, + -40, -30, -67, + 71, 88, 86, + -35, -98, 14, + 69, 197, -334, + -196, 79, -231, + -348, -137, 218, + -352, -89, -85, + 47, 201, -130, + -165, 37, -15, + -43, 3, 86, + -161, -108, 79, + 83, 21, -237, + -81, -149, -238, + 150, -186, -251, + -186, -249, -162, + -19, 66, -139, + -26, -50, -181, + 24, 11, 0, + -130, -105, -98 }; /*-------------------------------------------------------------------* @@ -9586,134 +9586,134 @@ const Word16 dico21_isf_46b_fx[] = /* ISF codebook - 46b, 2nd stage, 2st split (only in AMR-WB IO mode) */ const Word16 dico22_isf_46b_fx[] = {/*Qlog2(2.56)*/ - -127, 310, 42, - -242, 197, 5, - -151, 84, -17, - -214, 127, -149, - -247, -131, 159, - -268, -267, -95, - -217, 1, -79, - -271, -80, -185, - -45, 436, 159, - 165, 199, 391, - -33, 81, 187, - -66, -42, 355, - -298, -57, 343, - -108, -537, 226, - -144, -23, 193, - 176, -402, 87, - 53, 296, 25, - -84, 253, -104, - -58, 105, -126, - -169, 174, -314, - -48, 44, -294, - -164, -417, -242, - -139, 3, -194, - -155, -207, -211, - 119, 322, 213, - 333, 50, 380, - 237, 247, -2, - 466, -16, 201, - 238, -255, -107, - 67, -440, -149, - 122, -88, -139, - 88, -247, -73, - -41, 231, 167, - -62, 155, 16, - -65, 16, 77, - -68, -2, -63, - -151, -300, 160, - -18, -333, 54, - -56, -94, 5, - 2, -190, 14, - 92, 148, 209, - 108, 9, 272, - 108, 35, 110, - 142, -85, 145, - 47, -157, 279, - 3, -320, 246, - 43, -72, 68, - 86, -217, 135, - 36, 140, 79, - 56, 175, -49, - 26, 45, 3, - 73, 55, -101, - 109, -183, -242, - -4, -283, -242, - 48, -68, -48, - -6, -153, -122, - 161, 196, 96, - 232, 80, 190, - 165, 97, 11, - 258, -31, 71, - 267, -77, -91, - 311, -209, 87, - 152, -14, -22, - 150, -149, 9, - -324, 557, 187, - -384, 307, 46, - -251, 27, 77, - -365, 77, -52, - -482, -84, 160, - -424, -515, -64, - -294, -120, -4, - -476, -116, -109, - -97, 318, 365, - 106, 627, 445, - -190, 120, 287, - -146, 65, 619, - -427, 242, 363, - -361, -371, 432, - -347, 102, 168, - -629, 195, -14, - -65, 476, -47, - -297, 320, -168, - -55, 356, -264, - -391, 82, -286, - -51, -31, -556, - -178, -399, -586, - -205, -49, -360, - -343, -238, -337, - 220, 457, 58, - 561, 467, 259, - 340, 270, -168, - 450, 77, -280, - 60, 167, -413, - 133, -252, -492, - 216, 157, -290, - 282, 0, -495, - -226, 293, 183, - -157, 135, 122, - -158, -59, 39, - -133, -118, -97, - -332, -309, 113, - -160, -425, -6, - -149, -211, 24, - -80, -277, -90, - -11, 125, 338, - 130, -71, 465, - 5, -45, 184, - 237, -95, 253, - -139, -197, 297, - -19, -300, 511, - -63, -152, 139, - 250, -289, 336, - 124, 339, -150, - 34, 176, -208, - 171, 166, -116, - 94, 38, -229, - 75, -65, -339, - -78, -205, -385, - 0, -30, -163, - -56, -110, -242, - 321, 244, 194, - 505, 238, -1, - 317, 116, 65, - 309, 88, -74, - 452, -51, -50, - 334, -217, -290, - 211, 41, -152, - 238, -55, -260 + -127, 310, 42, + -242, 197, 5, + -151, 84, -17, + -214, 127, -149, + -247, -131, 159, + -268, -267, -95, + -217, 1, -79, + -271, -80, -185, + -45, 436, 159, + 165, 199, 391, + -33, 81, 187, + -66, -42, 355, + -298, -57, 343, + -108, -537, 226, + -144, -23, 193, + 176, -402, 87, + 53, 296, 25, + -84, 253, -104, + -58, 105, -126, + -169, 174, -314, + -48, 44, -294, + -164, -417, -242, + -139, 3, -194, + -155, -207, -211, + 119, 322, 213, + 333, 50, 380, + 237, 247, -2, + 466, -16, 201, + 238, -255, -107, + 67, -440, -149, + 122, -88, -139, + 88, -247, -73, + -41, 231, 167, + -62, 155, 16, + -65, 16, 77, + -68, -2, -63, + -151, -300, 160, + -18, -333, 54, + -56, -94, 5, + 2, -190, 14, + 92, 148, 209, + 108, 9, 272, + 108, 35, 110, + 142, -85, 145, + 47, -157, 279, + 3, -320, 246, + 43, -72, 68, + 86, -217, 135, + 36, 140, 79, + 56, 175, -49, + 26, 45, 3, + 73, 55, -101, + 109, -183, -242, + -4, -283, -242, + 48, -68, -48, + -6, -153, -122, + 161, 196, 96, + 232, 80, 190, + 165, 97, 11, + 258, -31, 71, + 267, -77, -91, + 311, -209, 87, + 152, -14, -22, + 150, -149, 9, + -324, 557, 187, + -384, 307, 46, + -251, 27, 77, + -365, 77, -52, + -482, -84, 160, + -424, -515, -64, + -294, -120, -4, + -476, -116, -109, + -97, 318, 365, + 106, 627, 445, + -190, 120, 287, + -146, 65, 619, + -427, 242, 363, + -361, -371, 432, + -347, 102, 168, + -629, 195, -14, + -65, 476, -47, + -297, 320, -168, + -55, 356, -264, + -391, 82, -286, + -51, -31, -556, + -178, -399, -586, + -205, -49, -360, + -343, -238, -337, + 220, 457, 58, + 561, 467, 259, + 340, 270, -168, + 450, 77, -280, + 60, 167, -413, + 133, -252, -492, + 216, 157, -290, + 282, 0, -495, + -226, 293, 183, + -157, 135, 122, + -158, -59, 39, + -133, -118, -97, + -332, -309, 113, + -160, -425, -6, + -149, -211, 24, + -80, -277, -90, + -11, 125, 338, + 130, -71, 465, + 5, -45, 184, + 237, -95, 253, + -139, -197, 297, + -19, -300, 511, + -63, -152, 139, + 250, -289, 336, + 124, 339, -150, + 34, 176, -208, + 171, 166, -116, + 94, 38, -229, + 75, -65, -339, + -78, -205, -385, + 0, -30, -163, + -56, -110, -242, + 321, 244, 194, + 505, 238, -1, + 317, 116, 65, + 309, 88, -74, + 452, -51, -50, + 334, -217, -290, + 211, 41, -152, + 238, -55, -260 }; /*-------------------------------------------------------------------* @@ -9723,134 +9723,134 @@ const Word16 dico22_isf_46b_fx[] = /* ISF codebook - 46b, 2nd stage, 3rd split (only in AMR-WB IO mode) */ const Word16 dico23_isf_46b_fx[] = {/*Qlog2(2.56)*/ - -10, 151, 359, - 136, 298, 223, - 255, -104, 290, - 423, 6, 183, - -270, -269, -98, - -52, -82, 13, - -82, -274, -97, - 90, -246, -72, - -299, -70, 421, - -88, 365, 430, - 187, -318, 381, - 380, 37, 488, - -373, -316, 79, - -308, -101, 5, - -135, -451, 8, - 72, -421, -154, - 180, 170, -121, - 62, 177, -40, - 326, 80, -105, - 248, 263, -5, - -168, -181, -221, - -2, -23, -158, - -14, -149, -121, - 119, -91, -147, - 119, 332, -153, - 49, 303, 34, - 442, -55, -69, - 217, 454, 58, - -359, -187, -375, - -42, 50, -274, - -8, -267, -249, - 85, -86, -346, - -77, -40, 345, - 89, 134, 219, - 156, -80, 160, - 108, 40, 116, - -158, -206, 29, - 5, -32, 175, - -65, -158, 146, - 55, -78, 73, - -114, -222, 353, - -47, 81, 211, - 49, -151, 268, - 105, 4, 302, - -263, -132, 183, - -151, -28, 201, - -177, -307, 166, - 101, -221, 130, - 74, 58, -98, - 32, 44, 13, - 194, 30, -142, - 170, 96, 8, - -136, -119, -91, - -65, 8, -55, - 3, -188, 12, - 45, -63, -49, - 149, -21, -19, - 24, 144, 95, - 254, -22, 60, - 161, 196, 96, - -158, -61, 48, - -70, 33, 82, - -23, -321, 58, - 155, -147, 5, - -364, 328, 77, - -21, 453, 173, - -108, 82, 630, - 367, 263, 208, - -300, -62, -176, - -205, 143, -158, - -169, -410, -264, - 257, -269, -100, - -636, 289, -2, - -292, 627, 173, - -382, -363, 387, - 248, 524, 447, - -521, -111, -107, - -395, 118, -274, - -343, -680, -125, - -172, -447, -663, - 75, 148, -367, - -79, 263, -94, - 249, 148, -286, - 380, 271, -162, - -142, -4, -186, - -57, 111, -125, - -35, -108, -254, - 100, 29, -242, - -80, 303, -264, - -78, 464, -57, - 248, -22, -494, - 661, 662, 44, - -193, -40, -330, - -178, 145, -337, - -90, -199, -400, - -40, -23, -498, - -192, 114, 315, - -41, 244, 190, - 88, -97, 485, - 241, 80, 212, - -246, 40, 87, - -156, 147, 134, - -2, -334, 239, - 308, -203, 110, - -459, 251, 422, - -218, 310, 228, - -86, -346, 654, - 184, 175, 425, - -481, -63, 169, - -349, 117, 188, - -125, -560, 310, - 158, -416, 94, - 46, 171, -192, - -63, 157, 14, - 256, -35, -271, - 322, 123, 53, - -214, 4, -76, - -156, 86, -18, - 128, -197, -232, - 265, -90, -98, - -308, 332, -145, - -131, 308, 58, - 509, 59, -339, - 562, 196, -14, - -378, 100, -47, - -234, 202, 1, - 104, -270, -493, - 319, -210, -325 + -10, 151, 359, + 136, 298, 223, + 255, -104, 290, + 423, 6, 183, + -270, -269, -98, + -52, -82, 13, + -82, -274, -97, + 90, -246, -72, + -299, -70, 421, + -88, 365, 430, + 187, -318, 381, + 380, 37, 488, + -373, -316, 79, + -308, -101, 5, + -135, -451, 8, + 72, -421, -154, + 180, 170, -121, + 62, 177, -40, + 326, 80, -105, + 248, 263, -5, + -168, -181, -221, + -2, -23, -158, + -14, -149, -121, + 119, -91, -147, + 119, 332, -153, + 49, 303, 34, + 442, -55, -69, + 217, 454, 58, + -359, -187, -375, + -42, 50, -274, + -8, -267, -249, + 85, -86, -346, + -77, -40, 345, + 89, 134, 219, + 156, -80, 160, + 108, 40, 116, + -158, -206, 29, + 5, -32, 175, + -65, -158, 146, + 55, -78, 73, + -114, -222, 353, + -47, 81, 211, + 49, -151, 268, + 105, 4, 302, + -263, -132, 183, + -151, -28, 201, + -177, -307, 166, + 101, -221, 130, + 74, 58, -98, + 32, 44, 13, + 194, 30, -142, + 170, 96, 8, + -136, -119, -91, + -65, 8, -55, + 3, -188, 12, + 45, -63, -49, + 149, -21, -19, + 24, 144, 95, + 254, -22, 60, + 161, 196, 96, + -158, -61, 48, + -70, 33, 82, + -23, -321, 58, + 155, -147, 5, + -364, 328, 77, + -21, 453, 173, + -108, 82, 630, + 367, 263, 208, + -300, -62, -176, + -205, 143, -158, + -169, -410, -264, + 257, -269, -100, + -636, 289, -2, + -292, 627, 173, + -382, -363, 387, + 248, 524, 447, + -521, -111, -107, + -395, 118, -274, + -343, -680, -125, + -172, -447, -663, + 75, 148, -367, + -79, 263, -94, + 249, 148, -286, + 380, 271, -162, + -142, -4, -186, + -57, 111, -125, + -35, -108, -254, + 100, 29, -242, + -80, 303, -264, + -78, 464, -57, + 248, -22, -494, + 661, 662, 44, + -193, -40, -330, + -178, 145, -337, + -90, -199, -400, + -40, -23, -498, + -192, 114, 315, + -41, 244, 190, + 88, -97, 485, + 241, 80, 212, + -246, 40, 87, + -156, 147, 134, + -2, -334, 239, + 308, -203, 110, + -459, 251, 422, + -218, 310, 228, + -86, -346, 654, + 184, 175, 425, + -481, -63, 169, + -349, 117, 188, + -125, -560, 310, + 158, -416, 94, + 46, 171, -192, + -63, 157, 14, + 256, -35, -271, + 322, 123, 53, + -214, 4, -76, + -156, 86, -18, + 128, -197, -232, + 265, -90, -98, + -308, 332, -145, + -131, 308, 58, + 509, 59, -339, + 562, 196, -14, + -378, 100, -47, + -234, 202, 1, + 104, -270, -493, + 319, -210, -325 }; /*-------------------------------------------------------------------* @@ -9860,38 +9860,38 @@ const Word16 dico23_isf_46b_fx[] = /* ISF codebook - 46b, 2nd stage, 4th split (only in AMR-WB IO mode) */ const Word16 dico24_isf_46b_fx[] = {/*Qlog2(2.56)*/ - -79, -89, -4, - -171, 77, -211, - 160, -193, 98, - 120, -103, 323, - 32, -22, -129, - 72, 78, -268, - 182, -76, -66, - 309, 99, -145, - -229, -157, -84, - -383, 98, -71, - -90, -352, 12, - -284, -178, 178, - -65, -125, -166, - -87, -175, -351, - 42, -198, -48, - 154, -140, -243, - -77, 18, 108, - -39, 355, 91, - 87, 8, 155, - -4, 158, 239, - 128, 95, -54, - 7, 246, -124, - 258, 15, 89, - 206, 216, 98, - -201, 9, 18, - -312, 233, 204, - -39, -174, 155, - -144, -9, 284, - -57, 70, -69, - -157, 187, 18, - 54, -30, 23, - 24, 135, 55 + -79, -89, -4, + -171, 77, -211, + 160, -193, 98, + 120, -103, 323, + 32, -22, -129, + 72, 78, -268, + 182, -76, -66, + 309, 99, -145, + -229, -157, -84, + -383, 98, -71, + -90, -352, 12, + -284, -178, 178, + -65, -125, -166, + -87, -175, -351, + 42, -198, -48, + 154, -140, -243, + -77, 18, 108, + -39, 355, 91, + 87, 8, 155, + -4, 158, 239, + 128, 95, -54, + 7, 246, -124, + 258, 15, 89, + 206, 216, 98, + -201, 9, 18, + -312, 233, 204, + -39, -174, 155, + -144, -9, 284, + -57, 70, -69, + -157, 187, 18, + 54, -30, 23, + 24, 135, 55 }; /*-------------------------------------------------------------------* @@ -9901,38 +9901,38 @@ const Word16 dico24_isf_46b_fx[] = /* ISF codebook - 46b, 2nd stage, 5th split (only in AMR-WB IO mode) */ const Word16 dico25_isf_46b_fx[] = {/*Qlog2(2.56)*/ - 169, 142, -119, 115, - 206, -20, 94, 226, - -106, 313, -21, 16, - -62, 161, 71, 255, - -89, 101, -185, 125, - 72, -30, -201, 344, - -258, 33, -8, 81, - -104, -154, 72, 296, - 144, -68, -268, -25, - 81, -78, -87, 106, - 22, 155, -186, -119, - -46, -28, 27, 91, - -114, -37, -175, -33, - -94, -222, -189, 122, - -132, -119, -191, -270, - -172, -173, 18, -43, - 279, 135, -42, -128, - 187, -86, 229, -138, - 159, 240, 140, 46, - 69, 25, 227, 77, - 21, 115, 13, 8, - 68, -248, 126, 81, - -150, 137, 207, -9, - -154, -133, 289, 67, - 143, -37, -86, -326, - 180, -32, 19, -23, - 26, 168, 116, -233, - -32, -26, 118, -78, - 3, -8, -45, -115, - 57, -215, -54, -83, - -209, 112, -22, -167, - -91, -151, 168, -262 + 169, 142, -119, 115, + 206, -20, 94, 226, + -106, 313, -21, 16, + -62, 161, 71, 255, + -89, 101, -185, 125, + 72, -30, -201, 344, + -258, 33, -8, 81, + -104, -154, 72, 296, + 144, -68, -268, -25, + 81, -78, -87, 106, + 22, 155, -186, -119, + -46, -28, 27, 91, + -114, -37, -175, -33, + -94, -222, -189, 122, + -132, -119, -191, -270, + -172, -173, 18, -43, + 279, 135, -42, -128, + 187, -86, 229, -138, + 159, 240, 140, 46, + 69, 25, 227, 77, + 21, 115, 13, 8, + 68, -248, 126, 81, + -150, 137, 207, -9, + -154, -133, 289, 67, + 143, -37, -86, -326, + 180, -32, 19, -23, + 26, 168, 116, -233, + -32, -26, 118, -78, + 3, -8, -45, -115, + 57, -215, -54, -83, + -209, 112, -22, -167, + -91, -151, 168, -262 }; @@ -9954,134 +9954,134 @@ const Word16 dico25_isf_46b_fx[] = /* ISF codebook - 36b, 2nd stage, 1st split (only in AMR-WB IO mode) */ const Word16 dico21_isf_36b_fx[] = {/*Qlog2(2.56)*/ - -52, -96, 212, 315, -73, - 82, -204, 363, 136, -197, - -126, -331, 183, 218, 143, - -49, -41, 557, 230, 72, - 2, -73, 163, 377, 221, - 133, 111, 278, 215, -110, - -102, -20, 284, 113, 273, - 84, 319, 290, 18, 85, - -25, -5, 125, 132, -204, - -38, -5, 286, -9, -356, - -140, -256, 92, 117, -189, - -144, 191, 313, 51, -98, - 167, -10, 44, 247, 36, - 381, 197, 238, 74, 6, - 38, -408, 29, -3, -85, - 92, 266, 157, -25, -200, - 161, -121, 70, 84, -140, - -16, -86, 112, -94, -189, - -269, -270, 351, 107, -24, - -68, -67, 492, -103, -155, - -53, -131, 62, 122, 10, - 135, 84, 283, -55, -120, - -12, -219, 331, -81, 167, - 220, -136, 147, -172, -42, - 140, -95, -109, -88, -194, - 0, -2, -4, -33, -381, - -66, -217, 152, -186, -402, - 244, 108, 156, -140, -395, - 113, -136, -196, 110, -24, - 214, 118, 11, -64, -131, - -110, -286, -6, -332, 16, - 94, 97, 79, -291, -205, - -5, -39, -20, 252, -96, - 76, 174, 101, 163, 61, - -69, -239, -55, 399, 6, - -115, 319, 164, 275, 196, - -15, 36, -47, 331, 121, - 226, 209, 271, 325, 184, - 13, -80, -218, 471, 353, - 288, 378, 16, -51, 251, - 174, 116, 52, 149, -279, - 235, 276, 39, 120, -48, - 0, -108, -108, 241, -339, - -93, 534, 45, 33, -87, - 194, 149, -71, 405, -44, - 409, 370, 81, -186, -154, - 25, -102, -448, 124, -173, - 22, 408, -110, -310, -214, - -26, 23, -83, 114, 14, - -110, 164, 52, 223, -82, - 37, -25, -263, 306, -15, - -466, 415, 292, 165, -18, - 29, -19, -171, 155, 182, - 179, 144, -27, 231, 258, - -103, -247, -396, 238, 113, - 375, -154, -109, -4, 156, - 98, 85, -292, -5, -124, - 116, 139, -116, -98, -294, - -14, -83, -278, -117, -378, - 106, 33, -106, -344, -484, - 119, 17, -412, 138, 166, - 384, 101, -204, 88, -156, - -121, -284, -300, -1, -166, - 280, 33, -152, -313, -81, - -37, 22, 229, 153, 37, - -60, -83, 236, -8, -41, - -169, -228, 126, -20, 363, - -235, 17, 364, -156, 156, - -25, -30, 72, 144, 156, - 153, -26, 256, 97, 144, - -21, -37, 48, -65, 250, - 63, 77, 273, -128, 124, - -129, -26, 40, 9, -115, - -6, 82, 38, -90, -182, - -336, -13, 28, 158, 91, - -30, 241, 137, -170, -17, - 146, 14, -11, 33, 61, - 192, 197, 54, -84, 85, - 23, -200, -78, -29, 140, - 122, 237, 106, -341, 136, - -57, -142, -85, -16, -74, - -59, -90, -8, -187, -20, - -211, -267, 216, -179, -110, - -50, -7, 220, -267, -70, - -57, -42, -17, -15, 71, - 32, 21, 63, -137, 33, - -137, -175, 104, -68, 97, - -67, -43, 133, -301, 221, - -116, -200, -81, -92, -272, - -64, -41, -54, -244, -220, - -287, -242, -50, -87, -89, - -245, 236, 102, -166, -295, - 66, 24, -162, -71, 95, - 66, 136, -90, -220, -36, - -98, -161, -222, -188, 29, - -18, 18, -19, -415, 9, - 49, 61, 100, 39, -56, - -111, 82, 135, -31, 52, - -90, -153, -93, 189, 182, - -214, 295, 119, -74, 284, - 2, 137, 37, 47, 182, - 92, 117, 184, -53, 373, - -21, -14, -35, 136, 391, - 146, 129, -164, -28, 333, - 92, 80, -84, 100, -134, - -8, 217, -32, 3, -47, - -151, 251, -215, 142, 92, - -224, 310, -172, -275, 98, - 159, 155, -177, 112, 53, - 205, 27, 8, -240, 192, - 169, 120, -319, -201, 106, - 11, 36, -86, -237, 455, - -109, -154, -163, 174, -55, - -38, 32, -101, -78, -59, - -205, -321, -97, 69, 79, - -310, 44, 18, -185, 34, - -115, -20, -148, -39, 203, - -29, 154, -30, -158, 166, - -45, -131, -317, -24, 363, - -165, -205, -112, -222, 265, - -32, -44, -150, 54, -193, - -6, -38, -255, -169, -115, - -266, 87, -189, -36, -169, - -60, -87, -266, -436, -170, - -68, -81, -278, 24, 38, - -23, -19, -155, -256, 141, - -61, -226, -565, -175, 71, - 9, -29, -237, -515, 263 + -52, -96, 212, 315, -73, + 82, -204, 363, 136, -197, + -126, -331, 183, 218, 143, + -49, -41, 557, 230, 72, + 2, -73, 163, 377, 221, + 133, 111, 278, 215, -110, + -102, -20, 284, 113, 273, + 84, 319, 290, 18, 85, + -25, -5, 125, 132, -204, + -38, -5, 286, -9, -356, + -140, -256, 92, 117, -189, + -144, 191, 313, 51, -98, + 167, -10, 44, 247, 36, + 381, 197, 238, 74, 6, + 38, -408, 29, -3, -85, + 92, 266, 157, -25, -200, + 161, -121, 70, 84, -140, + -16, -86, 112, -94, -189, + -269, -270, 351, 107, -24, + -68, -67, 492, -103, -155, + -53, -131, 62, 122, 10, + 135, 84, 283, -55, -120, + -12, -219, 331, -81, 167, + 220, -136, 147, -172, -42, + 140, -95, -109, -88, -194, + 0, -2, -4, -33, -381, + -66, -217, 152, -186, -402, + 244, 108, 156, -140, -395, + 113, -136, -196, 110, -24, + 214, 118, 11, -64, -131, + -110, -286, -6, -332, 16, + 94, 97, 79, -291, -205, + -5, -39, -20, 252, -96, + 76, 174, 101, 163, 61, + -69, -239, -55, 399, 6, + -115, 319, 164, 275, 196, + -15, 36, -47, 331, 121, + 226, 209, 271, 325, 184, + 13, -80, -218, 471, 353, + 288, 378, 16, -51, 251, + 174, 116, 52, 149, -279, + 235, 276, 39, 120, -48, + 0, -108, -108, 241, -339, + -93, 534, 45, 33, -87, + 194, 149, -71, 405, -44, + 409, 370, 81, -186, -154, + 25, -102, -448, 124, -173, + 22, 408, -110, -310, -214, + -26, 23, -83, 114, 14, + -110, 164, 52, 223, -82, + 37, -25, -263, 306, -15, + -466, 415, 292, 165, -18, + 29, -19, -171, 155, 182, + 179, 144, -27, 231, 258, + -103, -247, -396, 238, 113, + 375, -154, -109, -4, 156, + 98, 85, -292, -5, -124, + 116, 139, -116, -98, -294, + -14, -83, -278, -117, -378, + 106, 33, -106, -344, -484, + 119, 17, -412, 138, 166, + 384, 101, -204, 88, -156, + -121, -284, -300, -1, -166, + 280, 33, -152, -313, -81, + -37, 22, 229, 153, 37, + -60, -83, 236, -8, -41, + -169, -228, 126, -20, 363, + -235, 17, 364, -156, 156, + -25, -30, 72, 144, 156, + 153, -26, 256, 97, 144, + -21, -37, 48, -65, 250, + 63, 77, 273, -128, 124, + -129, -26, 40, 9, -115, + -6, 82, 38, -90, -182, + -336, -13, 28, 158, 91, + -30, 241, 137, -170, -17, + 146, 14, -11, 33, 61, + 192, 197, 54, -84, 85, + 23, -200, -78, -29, 140, + 122, 237, 106, -341, 136, + -57, -142, -85, -16, -74, + -59, -90, -8, -187, -20, + -211, -267, 216, -179, -110, + -50, -7, 220, -267, -70, + -57, -42, -17, -15, 71, + 32, 21, 63, -137, 33, + -137, -175, 104, -68, 97, + -67, -43, 133, -301, 221, + -116, -200, -81, -92, -272, + -64, -41, -54, -244, -220, + -287, -242, -50, -87, -89, + -245, 236, 102, -166, -295, + 66, 24, -162, -71, 95, + 66, 136, -90, -220, -36, + -98, -161, -222, -188, 29, + -18, 18, -19, -415, 9, + 49, 61, 100, 39, -56, + -111, 82, 135, -31, 52, + -90, -153, -93, 189, 182, + -214, 295, 119, -74, 284, + 2, 137, 37, 47, 182, + 92, 117, 184, -53, 373, + -21, -14, -35, 136, 391, + 146, 129, -164, -28, 333, + 92, 80, -84, 100, -134, + -8, 217, -32, 3, -47, + -151, 251, -215, 142, 92, + -224, 310, -172, -275, 98, + 159, 155, -177, 112, 53, + 205, 27, 8, -240, 192, + 169, 120, -319, -201, 106, + 11, 36, -86, -237, 455, + -109, -154, -163, 174, -55, + -38, 32, -101, -78, -59, + -205, -321, -97, 69, 79, + -310, 44, 18, -185, 34, + -115, -20, -148, -39, 203, + -29, 154, -30, -158, 166, + -45, -131, -317, -24, 363, + -165, -205, -112, -222, 265, + -32, -44, -150, 54, -193, + -6, -38, -255, -169, -115, + -266, 87, -189, -36, -169, + -60, -87, -266, -436, -170, + -68, -81, -278, 24, 38, + -23, -19, -155, -256, 141, + -61, -226, -565, -175, 71, + 9, -29, -237, -515, 263 }; /*-------------------------------------------------------------------* @@ -10092,134 +10092,134 @@ const Word16 dico21_isf_36b_fx[] = const Word16 dico22_isf_36b_fx[] = {/*Qlog2(2.56)*/ - -298, -6, 95, 31, - -213, -87, -122, 261, - 4, -49, 208, 14, - -129, -110, 30, 118, - -214, 258, 110, -235, - -41, -18, -126, 120, - 103, 65, 127, -37, - 126, -36, -24, 25, - -138, -67, -278, -186, - -164, -194, -201, 78, - -211, -87, -51, -221, - -174, -79, -94, -39, - 23, -6, -157, -240, - 22, -110, -153, -68, - 148, -5, -2, -149, - -1, -135, -39, -179, - 68, 360, -117, -15, - 137, 47, -278, 146, - 136, 260, 135, 65, - 61, 116, -45, 97, - 231, 379, 87, -120, - 338, 177, -272, 3, - 266, 156, 28, -69, - 260, 84, -85, 86, - -266, 154, -256, -182, - -17, -65, -304, -6, - -40, 175, -151, -180, - -27, 27, -87, -63, - 121, 114, -166, -469, - 159, -66, -323, -231, - 214, 152, -141, -212, - 137, 36, -184, -51, - -282, -237, 40, 10, - -48, -235, -37, 251, - -54, -323, 136, 29, - -88, -174, 213, 198, - -390, 99, -63, -375, - 107, -169, -164, 424, - 69, -111, 141, -167, - 74, -129, 65, 144, - -353, -207, -205, -109, - -160, -386, -355, 98, - -176, -493, -20, -143, - -252, -432, -2, 216, - -90, -174, -168, -411, - 13, -284, -229, -160, - -87, -279, 34, -251, - -75, -263, -58, -42, - 420, 53, -211, -358, - 384, -35, -374, 396, - 68, -228, 323, -2, - 167, -307, 192, 194, - 459, 329, -5, -332, - 375, 79, -7, 313, - 282, -124, 200, -92, - 271, -162, -70, 180, - -157, -298, -514, -309, - 58, -163, -546, 18, - 124, -364, 167, -238, - 83, -411, -117, 96, - 140, -112, -388, -624, - 259, -133, -317, 41, - 163, -130, -64, -334, - 226, -165, -124, -110, - -466, -61, 6, 229, - -153, 205, -145, 242, - -159, 48, 195, 148, - -58, 28, 31, 279, - -303, 185, 279, -4, - -61, 197, 59, 86, - -114, 123, 168, -52, - 35, 36, 100, 126, - -407, 102, -77, -40, - -338, -1, -342, 156, - -179, 105, -34, -97, - -185, 84, -35, 108, - -133, 107, -91, -357, - -180, 54, -229, 24, - -44, 47, 47, -182, - -66, 13, 45, 4, - -339, 251, 64, 226, - -42, 101, -350, 275, - -99, 398, 142, 121, - 111, 12, -102, 260, - 0, 505, 260, -94, - 161, 285, -96, 224, - -4, 206, 314, 33, - 167, 139, 88, 204, - -235, 316, -60, -25, - -8, -150, -312, 201, - -36, 292, 61, -104, - -40, 174, -162, 42, - -21, 402, -29, -351, - 21, 152, -360, -93, - 57, 191, 212, -196, - 76, 158, -21, -69, - -328, -185, 331, 119, - -53, 285, 56, 337, - -107, -24, 405, 29, - -18, 137, 272, 277, - -255, 22, 173, -191, - 295, 322, 325, 302, - 21, -27, 332, -178, - 119, 13, 271, 129, - -455, -180, 116, -191, - -227, 62, -148, 524, - -176, -287, 282, -157, - -243, 13, 199, 430, - -59, -49, 115, -365, - 72, -172, -137, 93, - -138, -126, 141, -84, - 5, -124, 38, -20, - -258, 311, 601, 213, - 94, 130, -61, 502, - -1, -157, 485, 313, - 146, -74, 158, 345, - 276, 135, 280, -57, - 490, 252, 99, 43, - 267, -74, 429, 105, - 278, -23, 119, 94, - -542, 488, 257, -115, - -84, -244, -438, 478, - -113, -545, 387, 101, - -95, -306, 111, 498, - 95, 166, 22, -301, - 420, -15, -58, -78, - 270, 29, 122, -282, - 160, -240, 50, -38 + -298, -6, 95, 31, + -213, -87, -122, 261, + 4, -49, 208, 14, + -129, -110, 30, 118, + -214, 258, 110, -235, + -41, -18, -126, 120, + 103, 65, 127, -37, + 126, -36, -24, 25, + -138, -67, -278, -186, + -164, -194, -201, 78, + -211, -87, -51, -221, + -174, -79, -94, -39, + 23, -6, -157, -240, + 22, -110, -153, -68, + 148, -5, -2, -149, + -1, -135, -39, -179, + 68, 360, -117, -15, + 137, 47, -278, 146, + 136, 260, 135, 65, + 61, 116, -45, 97, + 231, 379, 87, -120, + 338, 177, -272, 3, + 266, 156, 28, -69, + 260, 84, -85, 86, + -266, 154, -256, -182, + -17, -65, -304, -6, + -40, 175, -151, -180, + -27, 27, -87, -63, + 121, 114, -166, -469, + 159, -66, -323, -231, + 214, 152, -141, -212, + 137, 36, -184, -51, + -282, -237, 40, 10, + -48, -235, -37, 251, + -54, -323, 136, 29, + -88, -174, 213, 198, + -390, 99, -63, -375, + 107, -169, -164, 424, + 69, -111, 141, -167, + 74, -129, 65, 144, + -353, -207, -205, -109, + -160, -386, -355, 98, + -176, -493, -20, -143, + -252, -432, -2, 216, + -90, -174, -168, -411, + 13, -284, -229, -160, + -87, -279, 34, -251, + -75, -263, -58, -42, + 420, 53, -211, -358, + 384, -35, -374, 396, + 68, -228, 323, -2, + 167, -307, 192, 194, + 459, 329, -5, -332, + 375, 79, -7, 313, + 282, -124, 200, -92, + 271, -162, -70, 180, + -157, -298, -514, -309, + 58, -163, -546, 18, + 124, -364, 167, -238, + 83, -411, -117, 96, + 140, -112, -388, -624, + 259, -133, -317, 41, + 163, -130, -64, -334, + 226, -165, -124, -110, + -466, -61, 6, 229, + -153, 205, -145, 242, + -159, 48, 195, 148, + -58, 28, 31, 279, + -303, 185, 279, -4, + -61, 197, 59, 86, + -114, 123, 168, -52, + 35, 36, 100, 126, + -407, 102, -77, -40, + -338, -1, -342, 156, + -179, 105, -34, -97, + -185, 84, -35, 108, + -133, 107, -91, -357, + -180, 54, -229, 24, + -44, 47, 47, -182, + -66, 13, 45, 4, + -339, 251, 64, 226, + -42, 101, -350, 275, + -99, 398, 142, 121, + 111, 12, -102, 260, + 0, 505, 260, -94, + 161, 285, -96, 224, + -4, 206, 314, 33, + 167, 139, 88, 204, + -235, 316, -60, -25, + -8, -150, -312, 201, + -36, 292, 61, -104, + -40, 174, -162, 42, + -21, 402, -29, -351, + 21, 152, -360, -93, + 57, 191, 212, -196, + 76, 158, -21, -69, + -328, -185, 331, 119, + -53, 285, 56, 337, + -107, -24, 405, 29, + -18, 137, 272, 277, + -255, 22, 173, -191, + 295, 322, 325, 302, + 21, -27, 332, -178, + 119, 13, 271, 129, + -455, -180, 116, -191, + -227, 62, -148, 524, + -176, -287, 282, -157, + -243, 13, 199, 430, + -59, -49, 115, -365, + 72, -172, -137, 93, + -138, -126, 141, -84, + 5, -124, 38, -20, + -258, 311, 601, 213, + 94, 130, -61, 502, + -1, -157, 485, 313, + 146, -74, 158, 345, + 276, 135, 280, -57, + 490, 252, 99, 43, + 267, -74, 429, 105, + 278, -23, 119, 94, + -542, 488, 257, -115, + -84, -244, -438, 478, + -113, -545, 387, 101, + -95, -306, 111, 498, + 95, 166, 22, -301, + 420, -15, -58, -78, + 270, 29, 122, -282, + 160, -240, 50, -38 }; /*-------------------------------------------------------------------* @@ -10229,70 +10229,70 @@ const Word16 dico22_isf_36b_fx[] = /* ISF codebook - 36b, 2nd stage, 3rd split (only in AMR-WB IO mode) */ const Word16 dico23_isf_36b_fx[] = {/*Qlog2(2.56)*/ - 81, -18, 68, -27, -122, -280, -4, - 45, -177, 209, -30, -136, -74, 131, - -44, 101, -75, -88, -48, -137, -54, - -245, -28, 63, -18, -112, -103, 58, - -79, -6, 220, -65, 114, -35, -50, - 109, -65, 143, -114, 129, 76, 125, - 166, 90, -61, -242, 186, -74, -43, - -46, -92, 49, -227, 24, -155, 39, - 67, 85, 99, -42, 53, -184, -281, - 142, -122, 0, 21, -142, -15, -17, - 223, 92, -21, -48, -82, -14, -167, - 51, -37, -243, -30, -90, 18, -56, - 54, 105, 74, 86, 69, 13, -101, - 196, 72, -89, 43, 65, 19, 39, - 121, 34, 131, -82, 25, 213, -156, - 101, -102, -136, -21, 57, 214, 22, - 36, -124, 205, 204, 58, -156, -83, - 83, -117, 137, 137, 85, 116, 44, - -92, -148, -68, 11, -102, -197, -220, - -76, -185, -58, 132, -26, -183, 85, - -7, -31, -2, 23, 205, -151, 10, - -27, -37, -5, -18, 292, 131, 1, - 117, -168, 9, -93, 80, -59, -125, - -182, -244, 98, -24, 135, -22, 94, - 221, 97, 106, 42, 43, -160, 83, - 25, -64, -21, 6, 14, -15, 154, - 126, 15, -140, 150, -10, -207, -114, - 79, -63, -211, -70, -28, -217, 165, - 46, 38, -22, 281, 132, -62, 109, - 112, 54, -112, -93, 208, 27, 296, - 115, 10, -147, 41, 216, 42, -276, - 50, -115, -254, 167, 117, -2, 61, - 17, 144, 34, -72, -186, -150, 272, - -29, -66, -89, -95, -149, 129, 251, - 122, 0, -50, -234, -91, 36, 26, - -105, -102, -88, -121, -236, -7, -11, - -204, 109, 5, -191, 105, -15, 163, - -80, 32, -24, -209, 41, 294, 70, - -106, -94, -204, -118, 120, -50, -37, - -82, -241, 46, -131, -29, 150, -55, - 33, 155, 120, -89, -8, 7, 62, - 213, 82, 61, 18, -161, 144, 152, - 30, 131, 65, -87, -255, -17, -107, - -8, 85, -64, 51, -162, 223, -53, - -134, 261, 69, -56, 218, 72, -111, - 2, 155, -113, -87, 49, 85, -28, - -163, 42, -1, -196, 7, 39, -245, - 14, -137, -79, 11, -160, 202, -293, - -94, 33, 208, 100, 56, -44, 326, - -78, -41, 232, 13, -142, 227, 80, - -16, -87, 201, 33, -133, 15, -183, - -58, -192, -47, 184, -128, 133, 99, - -205, 11, -155, 78, 52, 72, 141, - -246, 26, 99, 151, 59, 115, -64, - -79, -47, -16, -14, 6, 47, -43, - -72, -178, -27, 162, 112, 43, -174, - -175, 238, 186, 71, -54, -188, -76, - -225, 233, 39, -39, -158, 122, 44, - -26, 43, 84, 130, -93, -51, 22, - 3, 92, -150, 136, -182, -57, 97, - -131, 179, -78, 80, 91, -165, 90, - -2, 148, 15, 130, 65, 175, 117, - -138, 114, -137, 132, 3, -10, -186, - 140, -4, -37, 254, -62, 92, -109 + 81, -18, 68, -27, -122, -280, -4, + 45, -177, 209, -30, -136, -74, 131, + -44, 101, -75, -88, -48, -137, -54, + -245, -28, 63, -18, -112, -103, 58, + -79, -6, 220, -65, 114, -35, -50, + 109, -65, 143, -114, 129, 76, 125, + 166, 90, -61, -242, 186, -74, -43, + -46, -92, 49, -227, 24, -155, 39, + 67, 85, 99, -42, 53, -184, -281, + 142, -122, 0, 21, -142, -15, -17, + 223, 92, -21, -48, -82, -14, -167, + 51, -37, -243, -30, -90, 18, -56, + 54, 105, 74, 86, 69, 13, -101, + 196, 72, -89, 43, 65, 19, 39, + 121, 34, 131, -82, 25, 213, -156, + 101, -102, -136, -21, 57, 214, 22, + 36, -124, 205, 204, 58, -156, -83, + 83, -117, 137, 137, 85, 116, 44, + -92, -148, -68, 11, -102, -197, -220, + -76, -185, -58, 132, -26, -183, 85, + -7, -31, -2, 23, 205, -151, 10, + -27, -37, -5, -18, 292, 131, 1, + 117, -168, 9, -93, 80, -59, -125, + -182, -244, 98, -24, 135, -22, 94, + 221, 97, 106, 42, 43, -160, 83, + 25, -64, -21, 6, 14, -15, 154, + 126, 15, -140, 150, -10, -207, -114, + 79, -63, -211, -70, -28, -217, 165, + 46, 38, -22, 281, 132, -62, 109, + 112, 54, -112, -93, 208, 27, 296, + 115, 10, -147, 41, 216, 42, -276, + 50, -115, -254, 167, 117, -2, 61, + 17, 144, 34, -72, -186, -150, 272, + -29, -66, -89, -95, -149, 129, 251, + 122, 0, -50, -234, -91, 36, 26, + -105, -102, -88, -121, -236, -7, -11, + -204, 109, 5, -191, 105, -15, 163, + -80, 32, -24, -209, 41, 294, 70, + -106, -94, -204, -118, 120, -50, -37, + -82, -241, 46, -131, -29, 150, -55, + 33, 155, 120, -89, -8, 7, 62, + 213, 82, 61, 18, -161, 144, 152, + 30, 131, 65, -87, -255, -17, -107, + -8, 85, -64, 51, -162, 223, -53, + -134, 261, 69, -56, 218, 72, -111, + 2, 155, -113, -87, 49, 85, -28, + -163, 42, -1, -196, 7, 39, -245, + 14, -137, -79, 11, -160, 202, -293, + -94, 33, 208, 100, 56, -44, 326, + -78, -41, 232, 13, -142, 227, 80, + -16, -87, 201, 33, -133, 15, -183, + -58, -192, -47, 184, -128, 133, 99, + -205, 11, -155, 78, 52, 72, 141, + -246, 26, 99, 151, 59, 115, -64, + -79, -47, -16, -14, 6, 47, -43, + -72, -178, -27, 162, 112, 43, -174, + -175, 238, 186, 71, -54, -188, -76, + -225, 233, 39, -39, -158, 122, 44, + -26, 43, 84, 130, -93, -51, 22, + 3, 92, -150, 136, -182, -57, 97, + -131, 179, -78, 80, 91, -165, 90, + -2, 148, 15, 130, 65, 175, 117, + -138, 114, -137, 132, 3, -10, -186, + 140, -4, -37, 254, -62, 92, -109 }; /*-------------------------------------------------------------------* @@ -10314,70 +10314,70 @@ const Word16 dico23_isf_36b_fx[] = /* ISF codebook for SID frames - 28b, 1st split */ const Word16 dico1_ns_28b_fx[] = {/*Qlog2(2.56)*/ - -269, -673, - -222, -537, - -233, -430, - -138, -451, - -212, -331, - -192, -241, - -87, -231, - -191, -128, - -70, -106, - -164, -6, - 74, -179, - 27, -33, - -102, 74, - -162, 115, - -94, 172, - -6, 130, - -143, 234, - 14, 218, - -65, 270, - 88, 182, - -124, 341, - -44, 381, - 38, 335, - 117, 274, - -112, 454, - 74, 431, - -5, 488, - 175, 384, - -83, 561, - 122, 529, - 21, 601, - 229, 481, - 231, 303, - 226, 608, - 300, 372, - 210, 187, - 306, 265, - 328, 473, - 382, 331, - 371, 132, - 139, 58, - 365, 21, - 250, -82, - 443, 218, - 483, 110, - 426, 415, - 579, 222, - 518, 333, - 573, 448, - 455, 529, - 685, 329, - 332, 580, - 595, 593, - 468, 645, - 762, 517, - 326, 709, - 485, 793, - 130, 684, - 671, 737, - 354, 876, - 88, 806, - -65, 706, - -35, 1016, - 266, 1123 + -269, -673, + -222, -537, + -233, -430, + -138, -451, + -212, -331, + -192, -241, + -87, -231, + -191, -128, + -70, -106, + -164, -6, + 74, -179, + 27, -33, + -102, 74, + -162, 115, + -94, 172, + -6, 130, + -143, 234, + 14, 218, + -65, 270, + 88, 182, + -124, 341, + -44, 381, + 38, 335, + 117, 274, + -112, 454, + 74, 431, + -5, 488, + 175, 384, + -83, 561, + 122, 529, + 21, 601, + 229, 481, + 231, 303, + 226, 608, + 300, 372, + 210, 187, + 306, 265, + 328, 473, + 382, 331, + 371, 132, + 139, 58, + 365, 21, + 250, -82, + 443, 218, + 483, 110, + 426, 415, + 579, 222, + 518, 333, + 573, 448, + 455, 529, + 685, 329, + 332, 580, + 595, 593, + 468, 645, + 762, 517, + 326, 709, + 485, 793, + 130, 684, + 671, 737, + 354, 876, + 88, 806, + -65, 706, + -35, 1016, + 266, 1123 }; /*-------------------------------------------------------------------* @@ -10387,70 +10387,70 @@ const Word16 dico1_ns_28b_fx[] = /* ISF codebook for SID frames - 28b, 2nd spilt */ const Word16 dico2_ns_28b_fx[] = {/*Qlog2(2.56)*/ - -824, -884, -949, - -805, -456, -418, - -442, -438, -541, - -217, -578, -793, - -168, -444, -582, - -287, -492, -274, - -552, -297, -300, - -163, -333, -358, - -370, -232, -232, - -175, -358, -159, - -381, -21, -357, - -184, -159, -162, - -53, -191, -280, - 18, -267, -215, - -138, 61, -283, - 71, -95, -294, - 13, -156, -546, - 0, -83, -79, - 44, 97, -316, - 178, -52, -213, - 222, -261, -422, - 237, -118, -44, - 141, 145, -132, - 363, 81, -287, - 213, 65, 34, - -107, 94, -5, - 91, -29, 126, - -355, 51, -41, - -219, -76, 145, - -63, 100, 244, - -719, 44, 27, - -572, -124, 155, - -423, 133, 315, - -917, 71, 224, - -268, 318, 131, - -93, -190, 420, - -97, 122, 491, - -79, 317, 355, - 130, 100, 325, - 86, -293, 210, - 133, 258, 161, - 176, -73, 465, - 195, 300, 384, - 348, 22, 221, - 376, 183, 409, - 377, 286, 202, - 242, 213, 659, - 257, 565, 248, - 344, 408, -76, - 405, 440, 509, - 612, 385, 379, - 536, 607, 216, - -56, 582, 192, - 100, 517, 567, - -365, 448, 445, - 728, 347, 10, - 505, 357, 759, - 636, 582, 658, - 335, 517, 852, - 378, 809, 572, - -195, 878, 829, - 529, 707, 987, - 918, 726, 392, - 1250, 997, 1063 + -824, -884, -949, + -805, -456, -418, + -442, -438, -541, + -217, -578, -793, + -168, -444, -582, + -287, -492, -274, + -552, -297, -300, + -163, -333, -358, + -370, -232, -232, + -175, -358, -159, + -381, -21, -357, + -184, -159, -162, + -53, -191, -280, + 18, -267, -215, + -138, 61, -283, + 71, -95, -294, + 13, -156, -546, + 0, -83, -79, + 44, 97, -316, + 178, -52, -213, + 222, -261, -422, + 237, -118, -44, + 141, 145, -132, + 363, 81, -287, + 213, 65, 34, + -107, 94, -5, + 91, -29, 126, + -355, 51, -41, + -219, -76, 145, + -63, 100, 244, + -719, 44, 27, + -572, -124, 155, + -423, 133, 315, + -917, 71, 224, + -268, 318, 131, + -93, -190, 420, + -97, 122, 491, + -79, 317, 355, + 130, 100, 325, + 86, -293, 210, + 133, 258, 161, + 176, -73, 465, + 195, 300, 384, + 348, 22, 221, + 376, 183, 409, + 377, 286, 202, + 242, 213, 659, + 257, 565, 248, + 344, 408, -76, + 405, 440, 509, + 612, 385, 379, + 536, 607, 216, + -56, 582, 192, + 100, 517, 567, + -365, 448, 445, + 728, 347, 10, + 505, 357, 759, + 636, 582, 658, + 335, 517, 852, + 378, 809, 572, + -195, 878, 829, + 529, 707, 987, + 918, 726, 392, + 1250, 997, 1063 }; /*-------------------------------------------------------------------* @@ -10460,70 +10460,70 @@ const Word16 dico2_ns_28b_fx[] = /* ISF codebook for SID frames - 28b, 3rd spilt */ const Word16 dico3_ns_28b_fx[] = {/*Qlog2(2.56)*/ - -805, -838, -774, - -522, -627, -828, - -477, -486, -603, - -295, -481, -634, - -366, -384, -393, - -186, -414, -396, - -237, -394, -106, - -252, -202, -275, - -61, -177, -442, - -84, -198, -199, - -179, -125, -31, - -72, -47, -163, - -298, -220, 215, - -64, -168, 251, - -133, 156, -59, - -30, -2, 127, - 54, 66, -61, - -233, 21, 251, - 209, -50, 32, - 33, 194, 136, - -117, -18, 475, - 202, 46, 309, - 256, 185, 53, - 35, 200, 390, - 200, 263, 242, - -216, 302, 294, - 128, 358, 0, - 19, 431, 287, - 224, 447, 280, - 367, 165, 213, - 397, 314, 319, - 383, 379, 75, - 277, 325, 462, - 394, 505, 334, - 251, 98, -213, - 450, 153, 448, - 565, 226, 76, - 470, 383, 502, - 635, 390, 278, - 237, 135, 620, - 342, 401, 649, - 331, 551, 518, - 130, 418, 592, - 531, 306, 737, - 729, 389, 580, - 497, 557, 699, - 296, 383, 874, - 283, 624, 759, - 126, 622, 476, - 559, 595, 472, - 382, 770, 616, - 719, 613, 745, - 540, 639, 928, - 517, 826, 801, - 684, 811, 604, - 752, 786, 857, - 933, 661, 350, - 694, 450, 1061, - 562, 911, 1051, - 824, 813, 1104, - 758, 1047, 882, - 1140, 917, 889, - 1039, 1246, 1426, - 1483, 1666, 1876 + -805, -838, -774, + -522, -627, -828, + -477, -486, -603, + -295, -481, -634, + -366, -384, -393, + -186, -414, -396, + -237, -394, -106, + -252, -202, -275, + -61, -177, -442, + -84, -198, -199, + -179, -125, -31, + -72, -47, -163, + -298, -220, 215, + -64, -168, 251, + -133, 156, -59, + -30, -2, 127, + 54, 66, -61, + -233, 21, 251, + 209, -50, 32, + 33, 194, 136, + -117, -18, 475, + 202, 46, 309, + 256, 185, 53, + 35, 200, 390, + 200, 263, 242, + -216, 302, 294, + 128, 358, 0, + 19, 431, 287, + 224, 447, 280, + 367, 165, 213, + 397, 314, 319, + 383, 379, 75, + 277, 325, 462, + 394, 505, 334, + 251, 98, -213, + 450, 153, 448, + 565, 226, 76, + 470, 383, 502, + 635, 390, 278, + 237, 135, 620, + 342, 401, 649, + 331, 551, 518, + 130, 418, 592, + 531, 306, 737, + 729, 389, 580, + 497, 557, 699, + 296, 383, 874, + 283, 624, 759, + 126, 622, 476, + 559, 595, 472, + 382, 770, 616, + 719, 613, 745, + 540, 639, 928, + 517, 826, 801, + 684, 811, 604, + 752, 786, 857, + 933, 661, 350, + 694, 450, 1061, + 562, 911, 1051, + 824, 813, 1104, + 758, 1047, 882, + 1140, 917, 889, + 1039, 1246, 1426, + 1483, 1666, 1876 }; /*-------------------------------------------------------------------* @@ -10533,38 +10533,38 @@ const Word16 dico3_ns_28b_fx[] = /* ISF codebook for SID frames - 28b, 4th spilt */ const Word16 dico4_ns_28b_fx[] = {/*Qlog2(2.56)*/ - -776, -854, -891, -920, - -552, -610, -663, -741, - -321, -370, -476, -565, - 274, -160, -456, 201, - 265, 67, -160, -306, - -8, -210, 79, 272, - 163, 236, 307, 308, - 578, 317, 64, 298, - -9, 197, 342, 620, - 343, 232, 314, 622, - 173, 149, 548, 527, - 356, 370, 481, 376, - 135, 444, 488, 556, - 391, 471, 487, 653, - 228, 424, 576, 835, - 422, 372, 722, 682, - 295, 673, 693, 635, - 539, 596, 590, 449, - 475, 618, 659, 818, - 735, 517, 491, 673, - 602, 346, 257, 877, - 625, 635, 849, 720, - 727, 818, 698, 595, - 653, 481, 690, 1139, - 814, 762, 704, 908, - 507, 747, 898, 936, - 848, 855, 924, 785, - 646, 1037, 882, 795, - 772, 845, 1024, 1151, - 1133, 983, 818, 921, - 940, 1068, 1252, 1302, - 1588, 1767, 1718, 1513 + -776, -854, -891, -920, + -552, -610, -663, -741, + -321, -370, -476, -565, + 274, -160, -456, 201, + 265, 67, -160, -306, + -8, -210, 79, 272, + 163, 236, 307, 308, + 578, 317, 64, 298, + -9, 197, 342, 620, + 343, 232, 314, 622, + 173, 149, 548, 527, + 356, 370, 481, 376, + 135, 444, 488, 556, + 391, 471, 487, 653, + 228, 424, 576, 835, + 422, 372, 722, 682, + 295, 673, 693, 635, + 539, 596, 590, 449, + 475, 618, 659, 818, + 735, 517, 491, 673, + 602, 346, 257, 877, + 625, 635, 849, 720, + 727, 818, 698, 595, + 653, 481, 690, 1139, + 814, 762, 704, 908, + 507, 747, 898, 936, + 848, 855, 924, 785, + 646, 1037, 882, 795, + 772, 845, 1024, 1151, + 1133, 983, 818, 921, + 940, 1068, 1252, 1302, + 1588, 1767, 1718, 1513 }; /*-------------------------------------------------------------------* @@ -10574,38 +10574,38 @@ const Word16 dico4_ns_28b_fx[] = /* ISF codebook for SID frames - 28b, 5th spilt */ const Word16 dico5_ns_28b_fx[] = {/*Qlog2(2.56)*/ - -810, -879, -945, -254, - 248, 184, 671, 128, - 288, 703, 918, 99, - 658, 558, 662, 219, - 552, 585, 910, 208, - 559, 804, 759, 119, - 606, 774, 921, -139, - 782, 761, 748, 208, - 756, 708, 983, 56, - 544, 864, 1010, 152, - 737, 698, 987, 299, - 771, 924, 879, 103, - 536, 785, 961, 405, - 667, 916, 801, 328, - 738, 705, 773, 439, - 823, 871, 992, 355, - 640, 1004, 1052, 369, - 724, 822, 949, 597, - 415, 655, 729, 482, - 1009, 896, 793, 363, - 908, 803, 687, -25, - 1016, 838, 1011, 189, - 947, 1112, 942, 222, - 914, 1049, 981, 527, - 956, 987, 1011, -120, - 781, 1049, 1121, 92, - 1178, 1053, 884, 47, - 1123, 1059, 1182, 118, - 933, 972, 1277, 357, - 1109, 918, 1101, 503, - 1039, 1286, 1220, 317, - 1351, 1207, 1010, 326 + -810, -879, -945, -254, + 248, 184, 671, 128, + 288, 703, 918, 99, + 658, 558, 662, 219, + 552, 585, 910, 208, + 559, 804, 759, 119, + 606, 774, 921, -139, + 782, 761, 748, 208, + 756, 708, 983, 56, + 544, 864, 1010, 152, + 737, 698, 987, 299, + 771, 924, 879, 103, + 536, 785, 961, 405, + 667, 916, 801, 328, + 738, 705, 773, 439, + 823, 871, 992, 355, + 640, 1004, 1052, 369, + 724, 822, 949, 597, + 415, 655, 729, 482, + 1009, 896, 793, 363, + 908, 803, 687, -25, + 1016, 838, 1011, 189, + 947, 1112, 942, 222, + 914, 1049, 981, 527, + 956, 987, 1011, -120, + 781, 1049, 1121, 92, + 1178, 1053, 884, 47, + 1123, 1059, 1182, 118, + 933, 972, 1277, 357, + 1109, 918, 1101, 503, + 1039, 1286, 1220, 317, + 1351, 1207, 1010, 326 }; /*1.28f Q1*/ const Word16 means_nb_31bits_ma_lsf[16] = { 861 /*336.3281f*1.28f Q1*/, 1360 /*531.2500f*1.28f Q1*/, 2270 /*886.7188f*1.28f Q1*/, 3243 /*1266.7969f*1.28f Q1*/, 4171 /*1629.2969f*1.28f Q1*/, 5052 /*1973.4375f*1.28f Q1*/, 6012 /*2348.4375f*1.28f Q1*/, 6776 /*2646.8750f*1.28f Q1*/, 7676 /*2998.4375f*1.28f Q1*/, 8428 /*3292.1875f*1.28f Q1*/, 9194 /*3591.4062f*1.28f Q1*/, 9744 /*3806.2500f*1.28f Q1*/, 10580 /*4132.8125f*1.28f Q1*/, 11911 /*4652.7344f*1.28f Q1*/, 13440 /*5250.0000f*1.28f Q1*/, 15061 /*5883.2031f*1.28f Q1*/ }; @@ -10655,7 +10655,7 @@ const lsp_unw_triplet p16_gamma0_94to1[16] = /* Q14 */ }; -const Word16 dico_lsf_abs_8b[256 * M] = /*14Q1*1.28*/ +const Word16 dico_lsf_abs_8b[256 * M] = /*14Q1*1.28*/ { 966, 1761, 2937, 3740, 4574, 5488, 6457, 7398, 8355, 9289, 10254, 11211, 12247, 13202, 14221, 15172, 1540, 2731, 3544, 4232, 5065, 5917, 6846, 7707, 8602, 9538, 10479, 11445, 12439, 13339, 14332, 15243, @@ -11209,7 +11209,7 @@ const Word16 lsf_cdk_wb_vc_stg3[] = /* 14Q1*1.28 */ 13, 12, 1888, 3621, 3935, 4000, 3607, 2932, 2128 }; -const Word16 *const lsf_codebook[2][2][TCXLPC_NUMSTAGES] = /* 14Q1*1.28 */ +const Word16 *const lsf_codebook[2][2][TCXLPC_NUMSTAGES] = /* 14Q1*1.28 */ { { { lsf_cdk_wb_gc_stg1, lsf_cdk_wb_gc_stg2, lsf_cdk_wb_gc_stg3 }, @@ -11221,12 +11221,12 @@ const Word16 *const lsf_codebook[2][2][TCXLPC_NUMSTAGES] = /* 14Q1*1.28 */ } }; -const Word16 lsf_numbits[TCXLPC_NUMSTAGES] = { 5, 4, 4 }; // Q0 +const Word16 lsf_numbits[TCXLPC_NUMSTAGES] = { 5, 4, 4 }; // Q0 -const Word16 lsf_dims_ivas[TCXLPC_NUMSTAGES] = { 16, 6, 10 }; // Q0 -const Word16 lsf_offs_ivas[TCXLPC_NUMSTAGES] = { 0, 0, 6 }; // Q0 -const Word16 lsf_dims[TCXLPC_NUMSTAGES] = { 16, 8, 12 }; // Q0 -const Word16 lsf_offs[TCXLPC_NUMSTAGES] = { 0, 0, 4 }; // Q0 +const Word16 lsf_dims_ivas[TCXLPC_NUMSTAGES] = { 16, 6, 10 }; // Q0 +const Word16 lsf_offs_ivas[TCXLPC_NUMSTAGES] = { 0, 0, 6 }; // Q0 +const Word16 lsf_dims[TCXLPC_NUMSTAGES] = { 16, 8, 12 }; // Q0 +const Word16 lsf_offs[TCXLPC_NUMSTAGES] = { 0, 0, 4 }; // Q0 const Word16 lsf_ind_cdk_nb_gc_stg4[] = /* 14Q1*1.28 */ @@ -11258,17 +11258,17 @@ const Word16 lsf_ind_cdk_wb_vc_stg4[] = /* 14Q1*1.28 */ 2256, 2704, 0 }; -const Word16 *const lsf_ind_codebook[2][2][TCXLPC_IND_NUMSTAGES] = /* 14Q1*1.28 */ +const Word16 *const lsf_ind_codebook[2][2][TCXLPC_IND_NUMSTAGES] = /* 14Q1*1.28 */ { { { lsf_ind_cdk_wb_gc_stg4 }, { lsf_ind_cdk_wb_vc_stg4 } }, { { lsf_ind_cdk_nb_gc_stg4 }, { lsf_ind_cdk_nb_vc_stg4 } } }; -const Word16 lsf_ind_numbits[TCXLPC_IND_NUMSTAGES] = { 2 }; // Q0 +const Word16 lsf_ind_numbits[TCXLPC_IND_NUMSTAGES] = { 2 }; // Q0 -const Word16 lsf_ind_dims_ivas[TCXLPC_IND_NUMSTAGES] = { 2 }; // Q0 -const Word16 lsf_ind_dims[TCXLPC_IND_NUMSTAGES] = { 4 }; // Q0 -const Word16 lsf_ind_offs[TCXLPC_IND_NUMSTAGES] = { 0 }; // Q0 +const Word16 lsf_ind_dims_ivas[TCXLPC_IND_NUMSTAGES] = { 2 }; // Q0 +const Word16 lsf_ind_dims[TCXLPC_IND_NUMSTAGES] = { 4 }; // Q0 +const Word16 lsf_ind_offs[TCXLPC_IND_NUMSTAGES] = { 0 }; // Q0 const Word16 min_distance_thr[2][2] = /* 14Q1*1.28 */ { @@ -11563,22 +11563,22 @@ const Word16 means_swb_cleanspeech_lsf32k0[16] = { 757, 1855, 2862, 3798, 4705, /* An 16-by-1 matrix */ -const Word16 SVWB2_Ave_fx[16] = { 998, 1488, 2682, 3823, 5084, 6305, 7485, 8686, 9861, 11004, 12339, 13664, 15088, 16330, 17663, 18754 }; // Q2.56 +const Word16 SVWB2_Ave_fx[16] = { 998, 1488, 2682, 3823, 5084, 6305, 7485, 8686, 9861, 11004, 12339, 13664, 15088, 16330, 17663, 18754 }; // Q2.56 /* An 16-by-1 matrix */ const Word16 IANB_Ave_fx[16] = { 726, 1433, 2493, 3408, 4340, 5215, 6103, 6947, 7772, 8536, 9252, 10012, 10909, 12427, 13997, 15193 -}; // Q2.56 +}; // Q2.56 /* An 16-by-1 matrix */ const Word16 IAWB_Ave_fx[16] = { 577, 1350, 2526, 3535, 4539, 5504, 6497, 7460, 8445, 9396, 10371, 11319, 12307, 13268, 14249, 15207 -}; // Q2.56 +}; // Q2.56 /* An 16-by-1 matrix */ const Word16 IAWB2_Ave_fx[16] = { 731, 1777, 3194, 4386, 5629, 6806, 8012, 9164, 10329, 11469, 12731, 14037, 15326, 16538, 17801, 18927 -}; // Q2.56 +}; // Q2.56 /* Length 16 vector in Scale = 2.56f */ const Word16 UVNB_Ave_fx[16] = { 1018, 1764, 2856, 3751, 4611, 5410, 6233, 6961, 7685, 8304, 8859, 9325, 9977, 11741, 13699, 15074 }; /* Length 16 vector in Scale = 2.56f */ @@ -11737,7 +11737,7 @@ const Word16 CB_lsf[] = 10, /* Mode 16 : TRANSITION WB16k, Safety net */ -1, /* Mode 17 : AUDIO WB16k, Safety net */ 13 /* Mode 18 : CNG, Safety net */ -}; // Q0 +}; // Q0 const Word16 CB_p_lsf[] = { @@ -11760,20 +11760,20 @@ const Word16 CB_p_lsf[] = -1, /* Mode 16 : TRANSITION WB16k, Predictive */ 10, /* Mode 17 : AUDIO WB16k, Predictive */ 9, /* Mode 18 : GENERIC WB, MA Predictive */ -}; // Q0 +}; // Q0 const Word16 *const ModeMeans_fx[] = { IANB_Ave_fx, UVNB_Ave_fx, SVNB_Ave_fx, GENB_Ave_fx, TRNB_Ave_fx, AUNB_Ave_fx, IAWB_Ave_fx, UVWB_Ave_fx, SVWB_Ave_fx, GEWB_Ave_fx, TRWB_Ave_fx, AUWB_Ave_fx, IAWB2_Ave_fx, NULL, SVWB2_Ave_fx, GEWB2_Ave_fx, TRWB2_Ave_fx, AUWB2_Ave_fx -}; //Qlog2(2.56) +}; //Qlog2(2.56) const Word16 * const Predictors_fx[] = { Predictor6_fx, NULL, Predictor1_fx, Predictor3_fx, NULL, Predictor6_fx,Predictor5_fx, NULL, Predictor0_fx, Predictor2_fx, NULL, Predictor5_fx, Predictor7_fx, NULL, Predictor8_fx, Predictor4_fx, NULL, Predictor7_fx -}; // Q15 +}; // Q15 const Word16 CBsizes[] = { 1,2,4,8,16,32,64 -}; // Q0 +}; // Q0 const Word16 CBbits[] = @@ -11797,7 +11797,7 @@ const Word16 CBbits[] = 4, /* Mode 16 : TRANSITION WB16k, Safety net */ -1, /* Mode 17 : AUDIO WB16k, Safety net */ 4, /* Mode 18: CNG, Safety net */ -}; // Q0 +}; // Q0 const Word16 CBbits_p[] = @@ -11821,7 +11821,7 @@ const Word16 CBbits_p[] = -1, /* Mode 16 : TRANSITION WB16k, Predictive */ 5, /* Mode 17 : AUDIO WB16k, Predictive */ 5, /* Mode 9 : GENERIC WB, Predictive */ -}; // Q0 +}; // Q0 @@ -11846,7 +11846,7 @@ const Word16 BitsVQ[]= 8, /* Mode 16 : TRANSITION WB16k, Safety net */ -1, /* Mode 17 : AUDIO WB16k, Safety net */ 4, /* Mode 18: CNG, Safety net */ -}; // Q0 +}; // Q0 const Word16 BitsVQ_p[]= @@ -11870,7 +11870,7 @@ const Word16 BitsVQ_p[]= -1, /* Mode 16 : TRANSITION WB16k, Predictive */ 5, /* Mode 17 : AUDIO WB16k, Predictive */ 5, /* Mode 18 : GENERIC WB, MA Predictive */ -}; // Q0 +}; // Q0 const Word16 predmode_tab_float[][6] = @@ -11887,7 +11887,7 @@ const Word16 predmode_tab[][6] = {1,1,2,2,0,2}, {1,-1,2,1,0,1}, {1,1,2,1,0,2} /* should check how is the cb for audio mode at 13.2*/ -}; // Q0 +}; // Q0 const Word16 SVNB_SN1_fx[256] = @@ -12513,7 +12513,7 @@ const Word16 vals_fx[NO_LEADERS][MAX_NO_VALS] = /*Q1 */ {7, 3, 1, 0}, }; -const Word16 no_vals[NO_LEADERS]= {2,1,2,2,2,2,3,2,1,3,2,2,2,3,3,3,2,3,3,2,3,2,3,2,3,3,4,2,3,2,2,3,2,2,4,2,2,3,3,3,3,4,4,2,3,1,3,3,3}; // Q0 +const Word16 no_vals[NO_LEADERS]= {2,1,2,2,2,2,3,2,1,3,2,2,2,3,3,3,2,3,3,2,3,2,3,2,3,3,4,2,3,2,2,3,2,2,4,2,2,3,3,3,3,4,4,2,3,1,3,3,3}; // Q0 const Word16 no_vals_ind[NO_LEADERS][MAX_NO_VALS]= { @@ -12566,7 +12566,7 @@ const Word16 no_vals_ind[NO_LEADERS][MAX_NO_VALS]= {1,5,2,0}, {2,2,4,0}, {1,2,5,0} -}; // Q0 +}; // Q0 const Word16 C_VQ[LATTICE_DIM+1][LATTICE_DIM+1] = @@ -12584,16 +12584,16 @@ const Word16 C_VQ[LATTICE_DIM+1][LATTICE_DIM+1] = const Word16 C_VQ_fx[LATTICE_DIM + 1][LATTICE_DIM + 1] = { - {1,0,0,0,0,0,0,0,0}, - {1,1,0,0,0,0,0,0,0}, - {1,2,1,0,0,0,0,0,0}, - {1,3,3,1,0,0,0,0,0}, - {1,4,6,4,1,0,0,0,0}, - {1,5,10,10,5,1,0,0,0}, - {1,6,15,20,15,6,1,0,0}, - {1,7,21,35,35,21,7,1,0}, - {1,8,28,56,70,56,28,8,1} -}; // Q0 + {1,0,0,0,0,0,0,0,0}, + {1,1,0,0,0,0,0,0,0}, + {1,2,1,0,0,0,0,0,0}, + {1,3,3,1,0,0,0,0,0}, + {1,4,6,4,1,0,0,0,0}, + {1,5,10,10,5,1,0,0,0}, + {1,6,15,20,15,6,1,0,0}, + {1,7,21,35,35,21,7,1,0}, + {1,8,28,56,70,56,28,8,1} +}; // Q0 const UWord32 table_no_cv[] = //Q0 { @@ -12603,17 +12603,17 @@ const UWord32 table_no_cv[] = //Q0 }; //Q0 const Word32 table_no_cv_fx[] = { 0, 112, 240, 1360, 1376, 2400, 4192, 5536, 9120, 9376, 18336, 18448, 25616, 26640, 33808, 40528, 40752, - 49712, 56880, 83760, 84208, 88688, 95856, 117360, 124528, 142448, 153200, 155888, 159472, 195312, 198896, 199920, - 235760, 236880, 238928, 274768, 274784, 275808, 311648, 333152, 340320, 367200, 410208, 423648,423760, 425104, 425232, 446736, 500496, 522000 - ,0 -}; // Q0 + 49712, 56880, 83760, 84208, 88688, 95856, 117360, 124528, 142448, 153200, 155888, 159472, 195312, 198896, 199920, + 235760, 236880, 238928, 274768, 274784, 275808, 311648, 333152, 340320, 367200, 410208, 423648,423760, 425104, 425232, 446736, 500496, 522000 + ,0 +}; // Q0 const Word16 pi0[] = { 28,1,70,8,8,28,168,28,1,280,28,56,8,56,420,56, 70, 56,420, 56, 280, 56, 168, 28, 560, 168,336,28,280,28,8, 280,70, 8, 1120, 8, 8, 280, 168, 56, 420, 336, 840, 28, 168, 1, 168, 420, 168 -}; // Q0 +}; // Q0 const Word16 pl_HQ_fx[] = /* Q1 vectors in first layers */ { @@ -12671,7 +12671,7 @@ const Word16 pl_HQ_fx[] = /* Q1 vectors in first layers */ * LSF quantization for CNG *----------------------------------------------------------------------------------*/ -const Word16 cng_sort[] = {/*5f */1,1,0,1,0,0, /* 4f */0,1,0,1,0,0,1,1,1,1}; // Q0 +const Word16 cng_sort[] = {/*5f */1,1,0,1,0,0, /* 4f */0,1,0,1,0,0,1,1,1,1}; // Q0 const Word16 perm_MSLVQ[][4] = @@ -12694,7 +12694,7 @@ const Word16 perm_MSLVQ[][4] = {6,11,7,12}, {6,11,7,12}, {6,11,7,12} -}; // Q0 +}; // Q0 const Word16 pl_par[] = /* 1 if even number of signs */ { @@ -12702,7 +12702,7 @@ const Word16 pl_par[] = /* 1 if even number of signs */ 0, -1, 1, 0, 0, 0, 1, -1, 0, 0, 0, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 0, 0, 0, 0, 0, -1, 1, -1, 1, 0, 0, 0, 0, 0, 1, -1, 1, -1 -}; // Q0 +}; // Q0 const Word16 scales_fx[][6] =//Q11 { @@ -13183,7 +13183,7 @@ const Word16 inv_sigma_p_ivas_fx[][16] = {471, 409, 323, 325, 308, 295, 304, 290, 281, 280, 271, 262, 251, 255, 266, 312} }; -const Word8 leaders_short[][MAX_NO_SCALES] = // Q0 +const Word8 leaders_short[][MAX_NO_SCALES] = // Q0 {{ 0, 0, 0}, { 1, 0, 0}, { 15, 3, 3}, @@ -13461,7 +13461,7 @@ const Word8 leaders_short[][MAX_NO_SCALES] = // Q0 { 48, 48, 47}, { 48, 48, 48}}; -const UWord8 no_lead_idx[][2] = { // Q0 +const UWord8 no_lead_idx[][2] = { // Q0 { 1, 1}, { 4, 1}, { 41, 1}, @@ -13632,7 +13632,7 @@ const UWord8 no_lead_idx[][2] = { // Q0 { 55, 31}, { 81, 7}, }; -const UWord8 no_lead_p_idx[][2] = { // Q0 +const UWord8 no_lead_p_idx[][2] = { // Q0 { 5, 0}, { 3, 0}, { 41, 0}, @@ -13914,24 +13914,24 @@ const Word16 offset_in_lvq_mode_SN[][21] = const Word16 offset_in_lvq_mode_SN_fx[][21] = {//Q0 - {0}, /* I NB */ - {0,1,1,1,1,1,2,3,3,3,3,4,4,4,5}, /* UV NB*/ - {0,1,1,1,1,2,3,4,5,5,6,6,7,7,7,7,7,8,8,8,9}, /* V NB */ - {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G NB */ - {0,1,1,1,1,2,3,4,5,5,5,6,6,6,7,8}, /* T NB */ - {0,0,0,0,1,2,2,2,2,3,4,5}, /* A NB */ - {0}, /* I WB */ - {0,1,1,1,2,3,3,3,3,3,3,4,4,4,5}, /* UV WB*/ - {0,1,1,1,2,3,3,3,4,5,6,7,8,9,9,10,11,12,12,12,13}, /* V WB */ - {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB */ - {0,1,1,1,2,3,3,4,5,5,5,6,6,7,8,9,10}, /* T WB */ - {0,0,0,0,1,2,2,2,3,4,4,4,4,4,4,4,4,4,4,5}, /* A WB */ - {0}, - {0}, - {0,0,0,0,0,0,1,2,3,3,4,5,6,6,6,7}, /* V 16k */ - {0}, /* G 16k */ - {0,1}, /* T 16k */ - {0}, /*{0,0,0,0,0,0,0,0,0,0,1} */ /* A 16k */ + {0}, /* I NB */ + {0,1,1,1,1,1,2,3,3,3,3,4,4,4,5}, /* UV NB*/ + {0,1,1,1,1,2,3,4,5,5,6,6,7,7,7,7,7,8,8,8,9}, /* V NB */ + {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G NB */ + {0,1,1,1,1,2,3,4,5,5,5,6,6,6,7,8}, /* T NB */ + {0,0,0,0,1,2,2,2,2,3,4,5}, /* A NB */ + {0}, /* I WB */ + {0,1,1,1,2,3,3,3,3,3,3,4,4,4,5}, /* UV WB*/ + {0,1,1,1,2,3,3,3,4,5,6,7,8,9,9,10,11,12,12,12,13}, /* V WB */ + {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB */ + {0,1,1,1,2,3,3,4,5,5,5,6,6,7,8,9,10}, /* T WB */ + {0,0,0,0,1,2,2,2,3,4,4,4,4,4,4,4,4,4,4,5}, /* A WB */ + {0}, + {0}, + {0,0,0,0,0,0,1,2,3,3,4,5,6,6,6,7}, /* V 16k */ + {0}, /* G 16k */ + {0,1}, /* T 16k */ + {0}, /*{0,0,0,0,0,0,0,0,0,0,1} */ /* A 16k */ }; const Word16 offset_in_lvq_mode_pred[][32] = @@ -13959,25 +13959,25 @@ const Word16 offset_in_lvq_mode_pred[][32] = const Word16 offset_in_lvq_mode_pred_fx[][32] = {//Q0 - {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I NB */ - {0,1,1,1,2,3,4,4,4,4,4,5,5,5,6}, /* UV NB */ - {0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,3,4,4,5,6,7,8,9,10,10,11,12,13,13,13,14}, /* V NB */ - {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G NB */ - {0}, /* T NB */ - {0,0,0,0,1,2,2,2,2,3,4,5}, /* A NB */ - {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I WB */ - {0,1,1,1,2,3,4,4,4,4,4,5,5,5,6}, /* UV WB */ - {0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,3,4,4,5,6,7,8,9,10,10,11,12,13,13,13,14}, /* V WB */ - {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB */ - {0}, /* T WB */ - {0,0,0,0,1,2,2,2,3,4,4,4,4,4,4,4,4,4,4,5}, /* A WB */ - {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I 16k */ - {0}, /* UV 16k */ - {0,0,0,0,0,0,1,2,3,3,4,5,6,6,6,7}, /* V 16k */ - {0,0,0,0,0,0,1,2,3,4,5,6}, /* G 16k */ - {0}, /* T 16k */ - {0,0,0,0,0,0,1,2,3,4,5,6}, /* A 16k */ - {0,0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB MA*/ + {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I NB */ + {0,1,1,1,2,3,4,4,4,4,4,5,5,5,6}, /* UV NB */ + {0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,3,4,4,5,6,7,8,9,10,10,11,12,13,13,13,14}, /* V NB */ + {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G NB */ + {0}, /* T NB */ + {0,0,0,0,1,2,2,2,2,3,4,5}, /* A NB */ + {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I WB */ + {0,1,1,1,2,3,4,4,4,4,4,5,5,5,6}, /* UV WB */ + {0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,3,4,4,5,6,7,8,9,10,10,11,12,13,13,13,14}, /* V WB */ + {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB */ + {0}, /* T WB */ + {0,0,0,0,1,2,2,2,3,4,4,4,4,4,4,4,4,4,4,5}, /* A WB */ + {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I 16k */ + {0}, /* UV 16k */ + {0,0,0,0,0,0,1,2,3,3,4,5,6,6,6,7}, /* V 16k */ + {0,0,0,0,0,0,1,2,3,4,5,6}, /* G 16k */ + {0}, /* T 16k */ + {0,0,0,0,0,0,1,2,3,4,5,6}, /* A 16k */ + {0,0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB MA*/ }; /*-----------------------------------------------------------------* @@ -13987,16 +13987,16 @@ const Word16 NTRANS[4][NUM_STATE] = {{0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14}, {1,3,5,7,9,11,13,15,1,3,5,7,9,11,13,15}, /* indices of previous state of second branches */ {4,2,1,3,0,2,1,3,2,0,3,1,7,0,3,1}, /* indices of previous subset of first branch */ {2,0,3,6,2,0,3,1,0,2,1,3,0,2,1,5} /* indices of previous subset of second branch */ -}; // Q0 +}; // Q0 const Word16 NTRANS2[4][NUM_STATE] = {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7}, {8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15}, {4,2,2,0,1,3,3,6,0,2,2,0,1,3,3,1}, {2,0,0,2,3,1,1,3,7,0,0,2,3,1,1,5} -}; // Q0 +}; // Q0 /* BC-TCQ Bit Allocations */ -const Word16 BC_TCVQ_BIT_ALLOC_40B[M/2+4] = {1, 4, 5,5,4,4, 2,2,2,2, 5,4 }; /*1+39bit Q0*/ +const Word16 BC_TCVQ_BIT_ALLOC_40B[M/2+4] = {1, 4, 5,5,4,4, 2,2,2,2, 5,4 }; /*1+39bit Q0*/ const Word16 FixBranch_tbl[4][4][N_STAGE_VQ - 4] = { @@ -14004,25 +14004,25 @@ const Word16 FixBranch_tbl[4][4][N_STAGE_VQ - 4] = {{0, 0, 1, 0}, {1, 0, 1, 0}, {0, 1, 1, 0}, {1, 1, 1, 0}}, /* incase of initial state 4 */ {{0, 0, 0, 1}, {1, 0, 0, 1}, {0, 1, 0, 1}, {1, 1, 0, 1}}, /* incase of initial state 8 */ {{0, 0, 1, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}, {1, 1, 1, 1}} /* incase of initial state 12 */ -}; // Q0 +}; // Q0 /* Intra-Prediction */ const Word16 SN_IntraCoeff_fx[N_STAGE_VQ - 1][2][2] = /* Q15 */ { - {{-14822, 26501}, {-17180, 10012}}, + {{-14822, 26501}, {-17180, 10012}}, {{ 317, 19858}, { -432, 13799}}, {{ 4747, 22069}, { 2653, 19016}}, {{ 6823, 20747}, { 7077, 19154}}, {{ 1665, 25161}, { 2519, 13654}}, - {{ 166, 18043}, { -221, 9732}}, + {{ 166, 18043}, { -221, 9732}}, {{ -781, 20026}, { -5332, 18882}} }; const Word16 AR_IntraCoeff_fx[N_STAGE_VQ - 1][2][2] = /* Q15 */ { - {{-9584, 22162}, {-13849, 7127}}, - {{ 1604, 16400}, { 2861, 9414}}, + {{-9584, 22162}, {-13849, 7127}}, + {{ 1604, 16400}, { 2861, 9414}}, {{ 6537, 16475}, { 3498, 13792}}, {{ 7879, 14434}, { 7021, 12992}}, {{ 6329, 16215}, { 5200, 10052}}, @@ -14032,14 +14032,14 @@ const Word16 AR_IntraCoeff_fx[N_STAGE_VQ - 1][2][2] = /* Q15 */ const Word16 scale_ARSN_fx[M] = /* Q14 */ { - 29994, 30153, 29506, 28534, 28246, 28618, 26388, 27029, - 25726, 25474, 25797, 26540, 25613, 24968, 25880, 25584 + 29994, 30153, 29506, 28534, 28246, 28618, 26388, 27029, + 25726, 25474, 25797, 26540, 25613, 24968, 25880, 25584 }; const Word16 scale_inv_ARSN_fx[M] = /* Q15 */ { - 17898, 17806, 18196, 18815, 19005, 18760, 20342, 19864, - 20870, 21076, 20811, 20228, 20962, 21502, 20745, 20985 + 17898, 17806, 18196, 18815, 19005, 18760, 20342, 19864, + 20870, 21076, 20811, 20228, 20962, 21502, 20745, 20985 }; /* TCVQ Codebook */ @@ -14047,90 +14047,90 @@ const Word16 scale_inv_ARSN_fx[M] = /* Q15 */ const Word16 AR_TCVQ_CB_SUB1_fx[2][128][2] = /* x2.65 */ {//Qlog2(2.56) { - {-435 , -434}, {-233 , 124}, {-381 , 44}, {-274 , -88}, {-332 , -224}, {-563 , -600}, {-332 , 134}, { 53 , -739}, - {-567 , 0}, { 149 , 316}, {-191 , 541}, {-123 , 317}, {-493 , -634}, {-528 , 268}, {-321 , -386}, {-432 , -220}, - {-244 , -230}, { -33 , 454}, {-188 , -642}, {-131 , -215}, {-676 , 263}, {-472 , -403}, {-312 , -159}, {-340 , 297}, - {-121 , -217}, { -6 , 241}, {-203 , -211}, {-126 , -15}, {-734 , -374}, {-458 , -6}, {-297 , -27}, {-307 , -553}, - {-177 , 3}, {-175 , -273}, { 63 , 363}, { 133 , 527}, {-133 , -185}, {-449 , -1206}, {-287 , -281}, {-131 , 869}, - {-100 , -105}, { -75 , -179}, {-141 , 131}, { -32 , 108}, { -81 , 161}, {-446 , -230}, {-283 , -884}, {-128 , -165}, - {-153 , -451}, {-177 , -114}, {-113 , -127}, {-223 , -355}, {-246 , -447}, {-396 , -705}, {-280 , 329}, { -37 , -64}, - {-118 , 208}, { -82 , 64}, {-339 , -367}, { -58 , -132}, {-458 , 644}, {-381 , -543}, {-272 , 557}, { 62 , 75}, - {-307 , -829}, { 310 , 445}, { 73 , -26}, { 95 , 219}, { 223 , 611}, { 279 , 195}, { 430 , 575}, { 424 , 221}, - { -25 , 2}, { 323 , 236}, {-100 , -310}, { 11 , -35}, { 83 , -3}, { 281 , 738}, { 495 , 393}, { 89 , 1284}, - { 32 , 136}, { 29 , 34}, { 491 , 575}, { 105 , -188}, { 15 , -440}, { 285 , 10}, { 516 , -105}, { 313 , 704}, - { -6 , -274}, { -62 , -64}, { -12 , -127}, { 170 , 2387}, { 162 , 196}, { 336 , 413}, { 543 , 210}, { 231 , -70}, - { -2 , 691}, { 98 , 134}, { 25 , 141}, { 261 , 305}, { 312 , -322}, { 336 , 228}, { 561 , 781}, { 766 , 514}, - { -14 , -117}, { 166 , 905}, { -50 , 1}, { 471 , 369}, { 345 , 247}, { 347 , -383}, { 561 , 1128}, { 513 , 1030}, - { 100 , -15}, { 185 , 70}, { 167 , 131}, { 122 , 36}, { 561 , 743}, { 401 , 111}, { 595 , -579}, { 674 , 215}, - { 191 , 189}, { 38 , -78}, { 428 , 0}, { 261 , 136}, { -29 , -99}, { 405 , 308}, { 614 , 574}, {1682 , 1704} + {-435 , -434}, {-233 , 124}, {-381 , 44}, {-274 , -88}, {-332 , -224}, {-563 , -600}, {-332 , 134}, { 53 , -739}, + {-567 , 0}, { 149 , 316}, {-191 , 541}, {-123 , 317}, {-493 , -634}, {-528 , 268}, {-321 , -386}, {-432 , -220}, + {-244 , -230}, { -33 , 454}, {-188 , -642}, {-131 , -215}, {-676 , 263}, {-472 , -403}, {-312 , -159}, {-340 , 297}, + {-121 , -217}, { -6 , 241}, {-203 , -211}, {-126 , -15}, {-734 , -374}, {-458 , -6}, {-297 , -27}, {-307 , -553}, + {-177 , 3}, {-175 , -273}, { 63 , 363}, { 133 , 527}, {-133 , -185}, {-449 , -1206}, {-287 , -281}, {-131 , 869}, + {-100 , -105}, { -75 , -179}, {-141 , 131}, { -32 , 108}, { -81 , 161}, {-446 , -230}, {-283 , -884}, {-128 , -165}, + {-153 , -451}, {-177 , -114}, {-113 , -127}, {-223 , -355}, {-246 , -447}, {-396 , -705}, {-280 , 329}, { -37 , -64}, + {-118 , 208}, { -82 , 64}, {-339 , -367}, { -58 , -132}, {-458 , 644}, {-381 , -543}, {-272 , 557}, { 62 , 75}, + {-307 , -829}, { 310 , 445}, { 73 , -26}, { 95 , 219}, { 223 , 611}, { 279 , 195}, { 430 , 575}, { 424 , 221}, + { -25 , 2}, { 323 , 236}, {-100 , -310}, { 11 , -35}, { 83 , -3}, { 281 , 738}, { 495 , 393}, { 89 , 1284}, + { 32 , 136}, { 29 , 34}, { 491 , 575}, { 105 , -188}, { 15 , -440}, { 285 , 10}, { 516 , -105}, { 313 , 704}, + { -6 , -274}, { -62 , -64}, { -12 , -127}, { 170 , 2387}, { 162 , 196}, { 336 , 413}, { 543 , 210}, { 231 , -70}, + { -2 , 691}, { 98 , 134}, { 25 , 141}, { 261 , 305}, { 312 , -322}, { 336 , 228}, { 561 , 781}, { 766 , 514}, + { -14 , -117}, { 166 , 905}, { -50 , 1}, { 471 , 369}, { 345 , 247}, { 347 , -383}, { 561 , 1128}, { 513 , 1030}, + { 100 , -15}, { 185 , 70}, { 167 , 131}, { 122 , 36}, { 561 , 743}, { 401 , 111}, { 595 , -579}, { 674 , 215}, + { 191 , 189}, { 38 , -78}, { 428 , 0}, { 261 , 136}, { -29 , -99}, { 405 , 308}, { 614 , 574}, {1682 , 1704} }, { - {-942 , -168}, {-262 , -361}, { -53 , -171}, {-245 , 472}, {-2145 , -2315}, {-1307 , 1261}, {-870 , -1940}, { -652 , -564}, - {-500 , 447}, {-578 , -198}, {-554 , 111}, { -98 , -84}, {-1315 , 0}, {-1229 , -1618}, {-868 , 230}, { -385 , 1061}, - {-768 , -998}, {-202 , -60}, {-283 , -197}, {-142 , -325}, { -558 , 755}, {-1217 , 456}, {-803 , 766}, { -982 , 743}, - {-415 , -357}, { -28 , 1054}, { 114 , -246}, { 81 , 732}, { -804 , -506}, {-1126 , -112}, {-797 , -132}, { -289 , -204}, - {-347 , -29}, { -37 , -259}, {-142 , -438}, {-249 , 87}, { -874 , 341}, {-1074 , -2635}, {-668 , -1552}, {-1140 , -764}, - {-245 , -513}, { -48 , 526}, { 14 , 395}, {-452 , -646}, { -441 , -969}, { -953 , -1284}, {-645 , -387}, { -736 , 111}, - {-163 , 305}, {-349 , 224}, {-225 , 736}, { 94 , -85}, { -302 , -549}, { -937 , -892}, {-605 , -1089}, { -64 , -101}, - {-161 , -211}, {-392 , -1299}, {-148 , 125}, { 14 , 131}, { -432 , -127}, { -920 , -510}, {-598 , -730}, { 85 , 154}, - { 25 , -155}, { -57 , 238}, { 471 , 276}, { 421 , 680}, { -173 , 316}, { 597 , 1805}, { 906 , -673}, { 538 , 450}, - {-267 , -805}, { 2 , -19}, { 222 , 219}, { 185 , 352}, { -33 , -178}, { 606 , 118}, { 959 , -70}, { 350 , -91}, - { -87 , 42}, { 727 , 905}, { 54 , 33}, { 316 , 44}, { 251 , 15}, { 610 , -122}, { 990 , 1436}, { 82 , 1480}, - { 181 , 535}, { 177 , 130}, { 700 , 565}, { 626 , 331}, { 279 , 551}, { 680 , 707}, {1012 , 727}, { 1057 , 766}, - { -13 , -396}, { 364 , 412}, { 442 , -181}, { 202 , -386}, { 565 , 1397}, { 740 , 2621}, {1080 , 361}, { 1118 , 191}, - { 81 , 266}, { 217 , -130}, { 349 , 1009}, { 678 , -476}, { 1361 , 878}, { 795 , 472}, {1267 , 1034}, { 1040 , 1255}, - { 351 , 201}, { -69 , -633}, { -36 , -1046}, { 808 , 30}, { 1300 , -198}, { 803 , 1026}, {1390 , -326}, { 2291 , 2479}, - { 166 , 13}, { 521 , 84}, { 255 , -717}, { 987 , 448}, { 777 , 220}, { 811 , 208}, {1395 , 2021}, { 1499 , 417} + {-942 , -168}, {-262 , -361}, { -53 , -171}, {-245 , 472}, {-2145 , -2315}, {-1307 , 1261}, {-870 , -1940}, { -652 , -564}, + {-500 , 447}, {-578 , -198}, {-554 , 111}, { -98 , -84}, {-1315 , 0}, {-1229 , -1618}, {-868 , 230}, { -385 , 1061}, + {-768 , -998}, {-202 , -60}, {-283 , -197}, {-142 , -325}, { -558 , 755}, {-1217 , 456}, {-803 , 766}, { -982 , 743}, + {-415 , -357}, { -28 , 1054}, { 114 , -246}, { 81 , 732}, { -804 , -506}, {-1126 , -112}, {-797 , -132}, { -289 , -204}, + {-347 , -29}, { -37 , -259}, {-142 , -438}, {-249 , 87}, { -874 , 341}, {-1074 , -2635}, {-668 , -1552}, {-1140 , -764}, + {-245 , -513}, { -48 , 526}, { 14 , 395}, {-452 , -646}, { -441 , -969}, { -953 , -1284}, {-645 , -387}, { -736 , 111}, + {-163 , 305}, {-349 , 224}, {-225 , 736}, { 94 , -85}, { -302 , -549}, { -937 , -892}, {-605 , -1089}, { -64 , -101}, + {-161 , -211}, {-392 , -1299}, {-148 , 125}, { 14 , 131}, { -432 , -127}, { -920 , -510}, {-598 , -730}, { 85 , 154}, + { 25 , -155}, { -57 , 238}, { 471 , 276}, { 421 , 680}, { -173 , 316}, { 597 , 1805}, { 906 , -673}, { 538 , 450}, + {-267 , -805}, { 2 , -19}, { 222 , 219}, { 185 , 352}, { -33 , -178}, { 606 , 118}, { 959 , -70}, { 350 , -91}, + { -87 , 42}, { 727 , 905}, { 54 , 33}, { 316 , 44}, { 251 , 15}, { 610 , -122}, { 990 , 1436}, { 82 , 1480}, + { 181 , 535}, { 177 , 130}, { 700 , 565}, { 626 , 331}, { 279 , 551}, { 680 , 707}, {1012 , 727}, { 1057 , 766}, + { -13 , -396}, { 364 , 412}, { 442 , -181}, { 202 , -386}, { 565 , 1397}, { 740 , 2621}, {1080 , 361}, { 1118 , 191}, + { 81 , 266}, { 217 , -130}, { 349 , 1009}, { 678 , -476}, { 1361 , 878}, { 795 , 472}, {1267 , 1034}, { 1040 , 1255}, + { 351 , 201}, { -69 , -633}, { -36 , -1046}, { 808 , 30}, { 1300 , -198}, { 803 , 1026}, {1390 , -326}, { 2291 , 2479}, + { 166 , 13}, { 521 , 84}, { 255 , -717}, { 987 , 448}, { 777 , 220}, { 811 , 208}, {1395 , 2021}, { 1499 , 417} } }; const Word16 AR_TCVQ_CB_SUB2_fx[2][64][2] = {//Qlog2(2.56) { - {-357 , -53}, {-525 , 167}, {-232 , 255}, {-132 , -359}, {-940 , -221}, { -260 , -1296}, {-1197 , -455}, { -833 , 49}, - {-132 , -1}, {-401 , -280}, {-212 , -217}, {-194 , 92}, {-580 , -710}, { -862 , -750}, { -669 , 430}, { -521 , 719}, - {-620 , -454}, {-239 , 509}, { -15 , -575}, { 389 , 704}, {-890 , 518}, {-1154 , 84}, { -632 , -1023}, { -620 , -1263}, - {-268 , -470}, {-326 , -738}, { 44 , 635}, { 73 , 362}, {-226 , -22}, { -625 , -106}, { -720 , -114}, {-1114 , -1070}, - { 19 , -250}, { 83 , 99}, { 35 , -16}, { 263 , -316}, { 472 , 1096}, { -52 , -328}, { -249 , 971}, { 1387 , 876}, - { 10 , 203}, { 869 , 649}, { 225 , 170}, { 301 , 83}, {1256 , 482}, { 391 , -777}, { 1064 , -320}, { 52 , 1207}, - { 309 , 375}, { 469 , 226}, { 619 , 400}, { 60 , -93}, { 335 , 244}, { 316 , -65}, { -45 , -987}, { 648 , -294}, - { 218 , -66}, {-108 , -133}, { 500 , -19}, { 824 , 163}, { 483 , -443}, { 1297 , 240}, { 1000 , 1205}, { 623 , 1347} + {-357 , -53}, {-525 , 167}, {-232 , 255}, {-132 , -359}, {-940 , -221}, { -260 , -1296}, {-1197 , -455}, { -833 , 49}, + {-132 , -1}, {-401 , -280}, {-212 , -217}, {-194 , 92}, {-580 , -710}, { -862 , -750}, { -669 , 430}, { -521 , 719}, + {-620 , -454}, {-239 , 509}, { -15 , -575}, { 389 , 704}, {-890 , 518}, {-1154 , 84}, { -632 , -1023}, { -620 , -1263}, + {-268 , -470}, {-326 , -738}, { 44 , 635}, { 73 , 362}, {-226 , -22}, { -625 , -106}, { -720 , -114}, {-1114 , -1070}, + { 19 , -250}, { 83 , 99}, { 35 , -16}, { 263 , -316}, { 472 , 1096}, { -52 , -328}, { -249 , 971}, { 1387 , 876}, + { 10 , 203}, { 869 , 649}, { 225 , 170}, { 301 , 83}, {1256 , 482}, { 391 , -777}, { 1064 , -320}, { 52 , 1207}, + { 309 , 375}, { 469 , 226}, { 619 , 400}, { 60 , -93}, { 335 , 244}, { 316 , -65}, { -45 , -987}, { 648 , -294}, + { 218 , -66}, {-108 , -133}, { 500 , -19}, { 824 , 163}, { 483 , -443}, { 1297 , 240}, { 1000 , 1205}, { 623 , 1347} }, { - {-424 , -965}, { -46 , -194}, { 20 , 298}, {-333 , -278}, {-797 , -522}, {-868 , -60}, { -20 , -140}, {-1085 , -904}, - {-615 , -243}, {-367 , 22}, {-261 , -519}, {-111 , -27}, {-745 , 142}, {-484 , -1519}, { -329 , 13}, {-1077 , 92}, - {-529 , 218}, {-519 , -597}, {-276 , -72}, { -87 , -398}, { -51 , -1257}, {-291 , 409}, { -883 , 611}, { 176 , -401}, - {-134 , -245}, { 37 , 506}, { 23 , -10}, {-225 , 293}, {-913 , -1324}, {-174 , -290}, {-1086 , -386}, { -139 , -78}, - {-123 , 125}, { -26 , -738}, { 113 , -344}, { 175 , 182}, { 754 , -446}, {1207 , 529}, { 932 , 990}, { 136 , 122}, - { 267 , 327}, { 382 , -182}, { 718 , 471}, { 738 , 108}, { 158 , 130}, { 437 , 401}, { 358 , -667}, { 1380 , 836}, - { 184 , -17}, { 435 , 231}, { 403 , 63}, { 151 , -125}, {-109 , -237}, { 692 , -241}, { 1247 , 193}, { 885 , 324}, - {-283 , 661}, { 44 , 105}, { 156 , 911}, { 387 , 588}, { 690 , 1459}, { 664 , 1057}, { -38 , 1455}, { 645 , 909} + {-424 , -965}, { -46 , -194}, { 20 , 298}, {-333 , -278}, {-797 , -522}, {-868 , -60}, { -20 , -140}, {-1085 , -904}, + {-615 , -243}, {-367 , 22}, {-261 , -519}, {-111 , -27}, {-745 , 142}, {-484 , -1519}, { -329 , 13}, {-1077 , 92}, + {-529 , 218}, {-519 , -597}, {-276 , -72}, { -87 , -398}, { -51 , -1257}, {-291 , 409}, { -883 , 611}, { 176 , -401}, + {-134 , -245}, { 37 , 506}, { 23 , -10}, {-225 , 293}, {-913 , -1324}, {-174 , -290}, {-1086 , -386}, { -139 , -78}, + {-123 , 125}, { -26 , -738}, { 113 , -344}, { 175 , 182}, { 754 , -446}, {1207 , 529}, { 932 , 990}, { 136 , 122}, + { 267 , 327}, { 382 , -182}, { 718 , 471}, { 738 , 108}, { 158 , 130}, { 437 , 401}, { 358 , -667}, { 1380 , 836}, + { 184 , -17}, { 435 , 231}, { 403 , 63}, { 151 , -125}, {-109 , -237}, { 692 , -241}, { 1247 , 193}, { 885 , 324}, + {-283 , 661}, { 44 , 105}, { 156 , 911}, { 387 , 588}, { 690 , 1459}, { 664 , 1057}, { -38 , 1455}, { 645 , 909} } }; const Word16 AR_TCVQ_CB_SUB3_fx[4][32][2] = {//Qlog2(2.56) { - {-487 , 9}, {-456 , -400}, { 96 , 451}, {-239 , 422}, {-685 , -1309}, { 68 , -709}, {-302 , -1185}, { 481 , -287}, - {-287 , -697}, {-194 , 73}, {-159 , -132}, {-161 , -312}, {-809 , 417}, {-860 , -926}, { -26 , -71}, {-1052 , -432}, - { 53 , 134}, { 106 , -140}, { 336 , -18}, { 404 , 735}, {-109 , -516}, { 719 , -65}, { -34 , 1336}, { -171 , 905}, - { 52 , -347}, { 359 , 266}, { 715 , 351}, { 100 , 133}, { 87 , 130}, { 975 , 999}, {1257 , 547}, { 738 , 1372} + {-487 , 9}, {-456 , -400}, { 96 , 451}, {-239 , 422}, {-685 , -1309}, { 68 , -709}, {-302 , -1185}, { 481 , -287}, + {-287 , -697}, {-194 , 73}, {-159 , -132}, {-161 , -312}, {-809 , 417}, {-860 , -926}, { -26 , -71}, {-1052 , -432}, + { 53 , 134}, { 106 , -140}, { 336 , -18}, { 404 , 735}, {-109 , -516}, { 719 , -65}, { -34 , 1336}, { -171 , 905}, + { 52 , -347}, { 359 , 266}, { 715 , 351}, { 100 , 133}, { 87 , 130}, { 975 , 999}, {1257 , 547}, { 738 , 1372} }, { - {-340 , -464}, {-216 , -779}, { 104 , -403}, { -92 , -221}, {-760 , -602}, {-914 , -811}, {-661 , -895}, {-1292 , -290}, - {-317 , 131}, {-575 , -154}, {-228 , -129}, {-257 , 487}, {-286 , -1354}, { -93 , -259}, {-798 , 179}, { -815 , -1368}, - { 215 , 570}, { -2 , 73}, { 545 , 167}, { 250 , 188}, { 76 , 48}, {-943 , 587}, { 379 , 1232}, { 1070 , 112}, - { 117 , -27}, { 389 , -142}, { 18 , 214}, { 735 , 581}, {1098 , 1244}, { 451 , 408}, {1482 , 650}, { -174 , 1160} + {-340 , -464}, {-216 , -779}, { 104 , -403}, { -92 , -221}, {-760 , -602}, {-914 , -811}, {-661 , -895}, {-1292 , -290}, + {-317 , 131}, {-575 , -154}, {-228 , -129}, {-257 , 487}, {-286 , -1354}, { -93 , -259}, {-798 , 179}, { -815 , -1368}, + { 215 , 570}, { -2 , 73}, { 545 , 167}, { 250 , 188}, { 76 , 48}, {-943 , 587}, { 379 , 1232}, { 1070 , 112}, + { 117 , -27}, { 389 , -142}, { 18 , 214}, { 735 , 581}, {1098 , 1244}, { 451 , 408}, {1482 , 650}, { -174 , 1160} }, { - {-256 , -485}, { -67 , 571}, { -5 , 161}, {-171 , 153}, {-1188 , -440}, {-1081 , 110}, {-641 , -921}, {-232 , -96}, - {-511 , 146}, {-288 , -93}, { 484 , 665}, {-610 , -366}, { -357 , -899}, { -861 , -1088}, { -78 , -105}, {-265 , -845}, - { 15 , 18}, { 79 , -383}, {-205 , -258}, { 306 , 264}, { 28 , 69}, { 34 , 65}, {1170 , 669}, { 133 , 74}, - { 521 , 183}, { 132 , 84}, { 362 , -90}, { 57 , -181}, { 894 , 456}, { 1147 , 742}, { 212 , 274}, { 891 , 262} + {-256 , -485}, { -67 , 571}, { -5 , 161}, {-171 , 153}, {-1188 , -440}, {-1081 , 110}, {-641 , -921}, {-232 , -96}, + {-511 , 146}, {-288 , -93}, { 484 , 665}, {-610 , -366}, { -357 , -899}, { -861 , -1088}, { -78 , -105}, {-265 , -845}, + { 15 , 18}, { 79 , -383}, {-205 , -258}, { 306 , 264}, { 28 , 69}, { 34 , 65}, {1170 , 669}, { 133 , 74}, + { 521 , 183}, { 132 , 84}, { 362 , -90}, { 57 , -181}, { 894 , 456}, { 1147 , 742}, { 212 , 274}, { 891 , 262} }, { - { 94 , 464}, { 8 , 138}, {-365 , -640}, {-399 , 172}, {-249 , -109}, { -94 , -316}, {-163 , -250}, {-598 , -704}, - {-185 , 36}, {-470 , -199}, { 65 , 241}, {-104 , -362}, {-220 , -801}, {-866 , -66}, {-931 , -400}, {-172 , -132}, - {-148 , -494}, { 465 , 251}, {-179 , -72}, { 439 , 287}, { 824 , 559}, { 33 , 134}, { 59 , 134}, { 88 , 146}, - { 186 , 43}, { 69 , -261}, { 267 , -96}, { 40 , 79}, { 84 , 130}, { 678 , 378}, { 811 , 448}, { 920 , 541} + { 94 , 464}, { 8 , 138}, {-365 , -640}, {-399 , 172}, {-249 , -109}, { -94 , -316}, {-163 , -250}, {-598 , -704}, + {-185 , 36}, {-470 , -199}, { 65 , 241}, {-104 , -362}, {-220 , -801}, {-866 , -66}, {-931 , -400}, {-172 , -132}, + {-148 , -494}, { 465 , 251}, {-179 , -72}, { 439 , 287}, { 824 , 559}, { 33 , 134}, { 59 , 134}, { 88 , 146}, + { 186 , 43}, { 69 , -261}, { 267 , -96}, { 40 , 79}, { 84 , 130}, { 678 , 378}, { 811 , 448}, { 920 , 541} } }; @@ -14138,155 +14138,155 @@ const Word16 AR_TCVQ_CB_SUB3_fx[4][32][2] = const Word16 SN_TCVQ_CB_SUB1_fx[2][128][2] = {//Qlog2(2.56) { - {-639 , 105}, {-488 , -449}, {-530 , -811}, {-419 , -634}, {-781 , -1061}, {-585 , 386}, {-501 , -737}, {-489 , -728}, - {-702 , -685}, {-510 , -762}, {-390 , -287}, {-379 , -379}, {-573 , -848}, {-583 , -778}, {-500 , -810}, {-671 , -420}, - {-516 , 802}, {-265 , -492}, {-523 , -568}, {-195 , 2882}, {-600 , -172}, {-568 , -869}, {-497 , 663}, {-643 , -929}, - {-346 , -378}, {-253 , -313}, {-418 , 595}, {-240 , -465}, {-424 , -546}, {-556 , -305}, {-497 , 2453}, {-451 , -235}, - {-452 , -670}, {-368 , -624}, {-379 , -662}, {-305 , -85}, {-549 , 399}, {-546 , -644}, {-484 , -426}, {-387 , -546}, - {-325 , -550}, {-229 , 118}, { -83 , 1004}, {-120 , 465}, {-289 , -222}, {-516 , 155}, {-480 , 1494}, {-415 , 138}, - {-419 , -100}, {-347 , 1091}, {-434 , 76}, {-138 , -291}, {-434 , -719}, {-514 , 945}, {-473 , -26}, {-144 , -320}, - {-376 , 1505}, {-329 , 374}, {-316 , -504}, { -58 , -6}, {-270 , -466}, {-507 , -540}, {-466 , -181}, {-256 , -518}, - {-196 , 726}, { -88 , -356}, {-186 , -394}, { 31 , -201}, { -77 , -319}, { 408 , 136}, { 630 , 680}, { 875 , 1365}, - {-200 , -190}, { 166 , 1289}, { 600 , 1085}, { 276 , 464}, { 567 , 1575}, { 425 , 278}, { 666 , 377}, {1209 , 2344}, - {-182 , -409}, { -95 , -141}, { 65 , 507}, { 127 , 212}, { 340 , 235}, { 481 , 408}, { 721 , 1203}, {1112 , 756}, - { 162 , 362}, { 138 , 753}, {-169 , -128}, { 187 , -32}, { 68 , -93}, { 528 , 2866}, { 786 , 789}, {1247 , 1468}, - {-476 , 2428}, { 20 , 133}, { 2 , -236}, { 426 , 799}, { 393 , 590}, { 532 , 1562}, { 807 , 534}, {1410 , 1051}, - { -14 , -263}, { 83 , -158}, { 158 , -38}, { 616 , 550}, { 845 , 543}, { 536 , 238}, { 912 , 1521}, {1635 , 1344}, - { 115 , -55}, { 263 , 87}, {-126 , 234}, { 376 , 191}, { 459 , 2644}, { 542 , 927}, { 941 , 948}, {1896 , 1528}, - { -19 , 1853}, { 455 , 366}, { 545 , 283}, { 831 , 835}, {1217 , 846}, { 560 , 542}, {1013 , 650}, {1905 , 2343} + {-639 , 105}, {-488 , -449}, {-530 , -811}, {-419 , -634}, {-781 , -1061}, {-585 , 386}, {-501 , -737}, {-489 , -728}, + {-702 , -685}, {-510 , -762}, {-390 , -287}, {-379 , -379}, {-573 , -848}, {-583 , -778}, {-500 , -810}, {-671 , -420}, + {-516 , 802}, {-265 , -492}, {-523 , -568}, {-195 , 2882}, {-600 , -172}, {-568 , -869}, {-497 , 663}, {-643 , -929}, + {-346 , -378}, {-253 , -313}, {-418 , 595}, {-240 , -465}, {-424 , -546}, {-556 , -305}, {-497 , 2453}, {-451 , -235}, + {-452 , -670}, {-368 , -624}, {-379 , -662}, {-305 , -85}, {-549 , 399}, {-546 , -644}, {-484 , -426}, {-387 , -546}, + {-325 , -550}, {-229 , 118}, { -83 , 1004}, {-120 , 465}, {-289 , -222}, {-516 , 155}, {-480 , 1494}, {-415 , 138}, + {-419 , -100}, {-347 , 1091}, {-434 , 76}, {-138 , -291}, {-434 , -719}, {-514 , 945}, {-473 , -26}, {-144 , -320}, + {-376 , 1505}, {-329 , 374}, {-316 , -504}, { -58 , -6}, {-270 , -466}, {-507 , -540}, {-466 , -181}, {-256 , -518}, + {-196 , 726}, { -88 , -356}, {-186 , -394}, { 31 , -201}, { -77 , -319}, { 408 , 136}, { 630 , 680}, { 875 , 1365}, + {-200 , -190}, { 166 , 1289}, { 600 , 1085}, { 276 , 464}, { 567 , 1575}, { 425 , 278}, { 666 , 377}, {1209 , 2344}, + {-182 , -409}, { -95 , -141}, { 65 , 507}, { 127 , 212}, { 340 , 235}, { 481 , 408}, { 721 , 1203}, {1112 , 756}, + { 162 , 362}, { 138 , 753}, {-169 , -128}, { 187 , -32}, { 68 , -93}, { 528 , 2866}, { 786 , 789}, {1247 , 1468}, + {-476 , 2428}, { 20 , 133}, { 2 , -236}, { 426 , 799}, { 393 , 590}, { 532 , 1562}, { 807 , 534}, {1410 , 1051}, + { -14 , -263}, { 83 , -158}, { 158 , -38}, { 616 , 550}, { 845 , 543}, { 536 , 238}, { 912 , 1521}, {1635 , 1344}, + { 115 , -55}, { 263 , 87}, {-126 , 234}, { 376 , 191}, { 459 , 2644}, { 542 , 927}, { 941 , 948}, {1896 , 1528}, + { -19 , 1853}, { 455 , 366}, { 545 , 283}, { 831 , 835}, {1217 , 846}, { 560 , 542}, {1013 , 650}, {1905 , 2343} }, { - {-528 , -246}, {-631 , 56}, {-717 , -277}, { -40 , 1327}, {-1011 , -688}, {-827 , -341}, {-656 , -1599}, { -992 , -1559}, - {-450 , 933}, {-540 , 2109}, {-598 , -1267}, {-387 , -512}, {-1100 , -1979}, {-812 , -617}, {-649 , -147}, { -874 , 586}, - {-720 , -601}, {-281 , -279}, {-578 , 635}, { 169 , 80}, {-1020 , -134}, {-794 , 259}, {-638 , 821}, { -907 , 42}, - {-709 , -1525}, {-482 , 1340}, {-232 , -979}, { 104 , 2314}, { -918 , -1179}, {-790 , 1284}, {-609 , 2259}, { -854 , -978}, - {-624 , 326}, {-194 , 1705}, { -88 , 1060}, { 383 , 1190}, { -415 , 15}, {-789 , -1145}, {-604 , 407}, { -869 , 1136}, - {-503 , -1047}, {-545 , -794}, {-128 , 471}, { 84 , 638}, { -591 , -1509}, {-699 , 1746}, {-600 , -369}, { -784 , 1642}, - {-221 , -668}, {-223 , 261}, { -82 , -446}, {-378 , -1215}, { -741 , 969}, {-689 , -863}, {-569 , -595}, {-1012 , -403}, - {-331 , 518}, {-175 , 787}, {-220 , -3}, { -46 , -841}, { -960 , 297}, {-666 , 68}, {-565 , -1364}, { -265 , -21}, - { 649 , 767}, { 255 , 360}, { 338 , -342}, {1664 , 1627}, { 205 , -226}, { 967 , 31}, {1217 , 928}, { 1697 , 1233}, - { 322 , 1445}, { 320 , 1790}, { 413 , 212}, { 994 , 209}, { 766 , 264}, { 974 , 883}, {1228 , 241}, { 1679 , 801}, - { 75 , 312}, { 754 , 1425}, { 348 , 621}, { 644 , 474}, { 1008 , 763}, {1036 , 2024}, {1354 , 530}, { 1611 , 2129}, - { 162 , 931}, { 883 , 822}, { 990 , 488}, { 615 , -203}, { 1929 , 1234}, {1059 , 1375}, {1382 , 1426}, { 2048 , 1599}, - { 602 , 162}, { 380 , 820}, { 709 , 1064}, {1168 , 1374}, { 549 , 583}, {1062 , 470}, {1415 , 1092}, { 2095 , 2234}, - { 187 , -630}, { 118 , -493}, { 714 , 1787}, {1298 , 673}, { 957 , 1258}, {1082 , 1124}, {1460 , 786}, { 2124 , 1205}, - { 34 , -189}, { 54 , -35}, { 798 , 0}, { 747 , 2378}, { 1420 , 1152}, {1118 , 1673}, {1492 , 2287}, { 2416 , 1618}, - {1159 , 1795}, { 389 , -126}, {1194 , 1003}, {1578 , 1002}, { 1294 , 366}, {1148 , 694}, {1513 , 1791}, { 2746 , 2096} + {-528 , -246}, {-631 , 56}, {-717 , -277}, { -40 , 1327}, {-1011 , -688}, {-827 , -341}, {-656 , -1599}, { -992 , -1559}, + {-450 , 933}, {-540 , 2109}, {-598 , -1267}, {-387 , -512}, {-1100 , -1979}, {-812 , -617}, {-649 , -147}, { -874 , 586}, + {-720 , -601}, {-281 , -279}, {-578 , 635}, { 169 , 80}, {-1020 , -134}, {-794 , 259}, {-638 , 821}, { -907 , 42}, + {-709 , -1525}, {-482 , 1340}, {-232 , -979}, { 104 , 2314}, { -918 , -1179}, {-790 , 1284}, {-609 , 2259}, { -854 , -978}, + {-624 , 326}, {-194 , 1705}, { -88 , 1060}, { 383 , 1190}, { -415 , 15}, {-789 , -1145}, {-604 , 407}, { -869 , 1136}, + {-503 , -1047}, {-545 , -794}, {-128 , 471}, { 84 , 638}, { -591 , -1509}, {-699 , 1746}, {-600 , -369}, { -784 , 1642}, + {-221 , -668}, {-223 , 261}, { -82 , -446}, {-378 , -1215}, { -741 , 969}, {-689 , -863}, {-569 , -595}, {-1012 , -403}, + {-331 , 518}, {-175 , 787}, {-220 , -3}, { -46 , -841}, { -960 , 297}, {-666 , 68}, {-565 , -1364}, { -265 , -21}, + { 649 , 767}, { 255 , 360}, { 338 , -342}, {1664 , 1627}, { 205 , -226}, { 967 , 31}, {1217 , 928}, { 1697 , 1233}, + { 322 , 1445}, { 320 , 1790}, { 413 , 212}, { 994 , 209}, { 766 , 264}, { 974 , 883}, {1228 , 241}, { 1679 , 801}, + { 75 , 312}, { 754 , 1425}, { 348 , 621}, { 644 , 474}, { 1008 , 763}, {1036 , 2024}, {1354 , 530}, { 1611 , 2129}, + { 162 , 931}, { 883 , 822}, { 990 , 488}, { 615 , -203}, { 1929 , 1234}, {1059 , 1375}, {1382 , 1426}, { 2048 , 1599}, + { 602 , 162}, { 380 , 820}, { 709 , 1064}, {1168 , 1374}, { 549 , 583}, {1062 , 470}, {1415 , 1092}, { 2095 , 2234}, + { 187 , -630}, { 118 , -493}, { 714 , 1787}, {1298 , 673}, { 957 , 1258}, {1082 , 1124}, {1460 , 786}, { 2124 , 1205}, + { 34 , -189}, { 54 , -35}, { 798 , 0}, { 747 , 2378}, { 1420 , 1152}, {1118 , 1673}, {1492 , 2287}, { 2416 , 1618}, + {1159 , 1795}, { 389 , -126}, {1194 , 1003}, {1578 , 1002}, { 1294 , 366}, {1148 , 694}, {1513 , 1791}, { 2746 , 2096} } }; const Word16 SN_TCVQ_CB_SUB2_fx[2][64][2] = {//Qlog2(2.56) { - {-709 , -609}, {-615 , -1025}, {-430 , -321}, { -44 , 1032}, {-1050 , -32}, {-1028 , -1856}, {-970 , -109}, { -572 , -1426}, - {-568 , 154}, {-142 , -189}, { -80 , 533}, { -38 , -632}, { -391 , 1275}, { -986 , -732}, {-479 , -510}, { -966 , 96}, - {-847 , -1387}, {-895 , 607}, {-368 , -930}, {-386 , 352}, { -290 , 10}, { -833 , 94}, {-528 , 1718}, { -210 , 115}, - {-529 , 857}, {-727 , -230}, {-128 , 31}, { 133 , 76}, { -275 , -777}, { -615 , -1367}, {-339 , -13}, {-1035 , 1231}, - { 448 , 851}, { 599 , 106}, {1103 , 1112}, { 635 , 1249}, { 761 , 774}, { 531 , -71}, { 722 , 473}, { 767 , 413}, - { 258 , 276}, { 346 , -380}, { 487 , 504}, {1114 , 122}, { 882 , 1553}, { 1983 , 1239}, {2126 , 1217}, { 1742 , 1262}, - { 135 , -252}, { 216 , 545}, { 500 , -125}, {1379 , 1910}, { 304 , 76}, { 1509 , 609}, {1543 , 1385}, { 542 , 1831}, - {-240 , -467}, { 771 , 652}, { 913 , 280}, {1307 , 716}, { 1834 , 1029}, { 1049 , 491}, {1624 , 733}, { 2495 , 1944} + {-709 , -609}, {-615 , -1025}, {-430 , -321}, { -44 , 1032}, {-1050 , -32}, {-1028 , -1856}, {-970 , -109}, { -572 , -1426}, + {-568 , 154}, {-142 , -189}, { -80 , 533}, { -38 , -632}, { -391 , 1275}, { -986 , -732}, {-479 , -510}, { -966 , 96}, + {-847 , -1387}, {-895 , 607}, {-368 , -930}, {-386 , 352}, { -290 , 10}, { -833 , 94}, {-528 , 1718}, { -210 , 115}, + {-529 , 857}, {-727 , -230}, {-128 , 31}, { 133 , 76}, { -275 , -777}, { -615 , -1367}, {-339 , -13}, {-1035 , 1231}, + { 448 , 851}, { 599 , 106}, {1103 , 1112}, { 635 , 1249}, { 761 , 774}, { 531 , -71}, { 722 , 473}, { 767 , 413}, + { 258 , 276}, { 346 , -380}, { 487 , 504}, {1114 , 122}, { 882 , 1553}, { 1983 , 1239}, {2126 , 1217}, { 1742 , 1262}, + { 135 , -252}, { 216 , 545}, { 500 , -125}, {1379 , 1910}, { 304 , 76}, { 1509 , 609}, {1543 , 1385}, { 542 , 1831}, + {-240 , -467}, { 771 , 652}, { 913 , 280}, {1307 , 716}, { 1834 , 1029}, { 1049 , 491}, {1624 , 733}, { 2495 , 1944} }, { - {-729 , -852}, {-590 , 306}, {-398 , 295}, { -31 , 13}, {-659 , -75}, {-604 , -1229}, {-519 , -675}, {-823 , 47}, - {-755 , -207}, {-818 , -424}, {-705 , -1285}, {-258 , -828}, {-807 , -707}, {-182 , -712}, {-928 , 3}, {-455 , -1149}, - {-844 , 422}, {-596 , -1008}, {-504 , -470}, {-459 , 737}, {-338 , -728}, {-836 , 1028}, {-613 , 1242}, {-609 , 1292}, - {-285 , 36}, {-280 , -424}, { 100 , 126}, {-459 , -135}, {-159 , -151}, {-287 , 190}, { 56 , -262}, {-264 , -317}, - { -8 , 603}, { 63 , 301}, { 537 , -155}, { 289 , 569}, { 193 , -412}, { 864 , 79}, { 686 , 399}, { 842 , 1657}, - { 115 , -211}, { 608 , 340}, { 12 , -650}, { 711 , 1103}, { 101 , 510}, { 358 , -416}, {1266 , 453}, { 532 , 612}, - {-256 , -680}, { 41 , 1163}, { 597 , 793}, { 484 , -61}, { 476 , 256}, {1729 , 1246}, {1209 , 1483}, {1472 , 1113}, - { 389 , 330}, { 176 , -388}, {1025 , 317}, {1049 , 732}, {1480 , 1108}, {1285 , 616}, {1730 , 999}, {2001 , 1669} + {-729 , -852}, {-590 , 306}, {-398 , 295}, { -31 , 13}, {-659 , -75}, {-604 , -1229}, {-519 , -675}, {-823 , 47}, + {-755 , -207}, {-818 , -424}, {-705 , -1285}, {-258 , -828}, {-807 , -707}, {-182 , -712}, {-928 , 3}, {-455 , -1149}, + {-844 , 422}, {-596 , -1008}, {-504 , -470}, {-459 , 737}, {-338 , -728}, {-836 , 1028}, {-613 , 1242}, {-609 , 1292}, + {-285 , 36}, {-280 , -424}, { 100 , 126}, {-459 , -135}, {-159 , -151}, {-287 , 190}, { 56 , -262}, {-264 , -317}, + { -8 , 603}, { 63 , 301}, { 537 , -155}, { 289 , 569}, { 193 , -412}, { 864 , 79}, { 686 , 399}, { 842 , 1657}, + { 115 , -211}, { 608 , 340}, { 12 , -650}, { 711 , 1103}, { 101 , 510}, { 358 , -416}, {1266 , 453}, { 532 , 612}, + {-256 , -680}, { 41 , 1163}, { 597 , 793}, { 484 , -61}, { 476 , 256}, {1729 , 1246}, {1209 , 1483}, {1472 , 1113}, + { 389 , 330}, { 176 , -388}, {1025 , 317}, {1049 , 732}, {1480 , 1108}, {1285 , 616}, {1730 , 999}, {2001 , 1669} } }; const Word16 SN_TCVQ_CB_SUB3_fx[4][32][2] = {//Qlog2(2.56) { - {-377 , -872}, {-407 , 801}, {-611 , -449}, {-397 , -87}, {-476 , -1063}, {-797 , -249}, {-263 , -662}, {-473 , 1508}, - {-716 , 310}, {-616 , -982}, {-742 , -1326}, { 197 , 327}, {-894 , -1556}, {-871 , -1259}, {-708 , -1380}, {-789 , -848}, - { 64 , -313}, { -59 , -547}, { -2 , 67}, { 363 , -167}, { 633 , 1840}, { 232 , -357}, {1243 , 1492}, {1640 , 973}, - { 203 , 518}, { 511 , 946}, { 612 , 241}, {1085 , 724}, { 811 , 326}, { 863 , 241}, { 556 , 534}, {1956 , 2087} + {-377 , -872}, {-407 , 801}, {-611 , -449}, {-397 , -87}, {-476 , -1063}, {-797 , -249}, {-263 , -662}, {-473 , 1508}, + {-716 , 310}, {-616 , -982}, {-742 , -1326}, { 197 , 327}, {-894 , -1556}, {-871 , -1259}, {-708 , -1380}, {-789 , -848}, + { 64 , -313}, { -59 , -547}, { -2 , 67}, { 363 , -167}, { 633 , 1840}, { 232 , -357}, {1243 , 1492}, {1640 , 973}, + { 203 , 518}, { 511 , 946}, { 612 , 241}, {1085 , 724}, { 811 , 326}, { 863 , 241}, { 556 , 534}, {1956 , 2087} }, { - {-948 , 28}, {-827 , -1180}, {-348 , -331}, { -36 , 216}, {-1453 , -1162}, {-682 , -639}, {-747 , -1517}, {-704 , 1228}, - {-535 , -988}, {-550 , -109}, {-478 , 580}, {-310 , -699}, {-1308 , -225}, {-775 , -1581}, {-831 , -613}, {-120 , -222}, - { 32 , 200}, { 120 , -221}, { 470 , 466}, { 808 , 313}, { 950 , 711}, { 430 , -576}, {1984 , 1405}, {1645 , 887}, - { 131 , 1148}, { 286 , 508}, { 342 , -236}, {1003 , 1202}, { 317 , -726}, {1493 , 732}, {1336 , 694}, {2382 , 1772} + {-948 , 28}, {-827 , -1180}, {-348 , -331}, { -36 , 216}, {-1453 , -1162}, {-682 , -639}, {-747 , -1517}, {-704 , 1228}, + {-535 , -988}, {-550 , -109}, {-478 , 580}, {-310 , -699}, {-1308 , -225}, {-775 , -1581}, {-831 , -613}, {-120 , -222}, + { 32 , 200}, { 120 , -221}, { 470 , 466}, { 808 , 313}, { 950 , 711}, { 430 , -576}, {1984 , 1405}, {1645 , 887}, + { 131 , 1148}, { 286 , 508}, { 342 , -236}, {1003 , 1202}, { 317 , -726}, {1493 , 732}, {1336 , 694}, {2382 , 1772} }, { - {-874 , -374}, {-237 , 26}, { 15 , 870}, {-710 , 433}, { 40 , -769}, {-1059 , -1350}, { 65 , 208}, {-1012 , -1369}, - { -79 , -459}, {-671 , -942}, { -12 , 56}, {-162 , -431}, {-820 , -1073}, { -886 , -136}, {-327 , -501}, { -55 , -14}, - { 652 , 647}, { 365 , 411}, { 614 , 252}, { 154 , 215}, { 12 , 62}, { 226 , 177}, {1689 , 1213}, { 751 , 179}, - { 31 , 182}, { 281 , -291}, {-354 , -642}, { 939 , 924}, { 619 , 90}, { 1675 , 1130}, { 827 , 272}, { 1550 , 1446} + {-874 , -374}, {-237 , 26}, { 15 , 870}, {-710 , 433}, { 40 , -769}, {-1059 , -1350}, { 65 , 208}, {-1012 , -1369}, + { -79 , -459}, {-671 , -942}, { -12 , 56}, {-162 , -431}, {-820 , -1073}, { -886 , -136}, {-327 , -501}, { -55 , -14}, + { 652 , 647}, { 365 , 411}, { 614 , 252}, { 154 , 215}, { 12 , 62}, { 226 , 177}, {1689 , 1213}, { 751 , 179}, + { 31 , 182}, { 281 , -291}, {-354 , -642}, { 939 , 924}, { 619 , 90}, { 1675 , 1130}, { 827 , 272}, { 1550 , 1446} }, { - {-366 , -916}, {-346 , -234}, {-518 , -140}, { 26 , 305}, {-254 , -92}, {-634 , -976}, {-493 , -1076}, {-334 , -913}, - {-566 , 68}, { 102 , 216}, {-296 , -927}, {-501 , -1030}, {-437 , -1006}, {-146 , -145}, {-211 , -202}, { 62 , 359}, - { 163 , -122}, { 759 , 553}, { 82 , 207}, {-177 , -243}, { 163 , 343}, {1152 , 929}, { 197 , 248}, { 43 , -147}, - { 169 , 371}, {-468 , -1043}, { 686 , 418}, { 563, 245}, {1052 , 843}, { 259 , 341}, {1063 , 637}, { 865 , 654} + {-366 , -916}, {-346 , -234}, {-518 , -140}, { 26 , 305}, {-254 , -92}, {-634 , -976}, {-493 , -1076}, {-334 , -913}, + {-566 , 68}, { 102 , 216}, {-296 , -927}, {-501 , -1030}, {-437 , -1006}, {-146 , -145}, {-211 , -202}, { 62 , 359}, + { 163 , -122}, { 759 , 553}, { 82 , 207}, {-177 , -243}, { 163 , 343}, {1152 , 929}, { 197 , 248}, { 43 , -147}, + { 169 , 371}, {-468 , -1043}, { 686 , 418}, { 563, 245}, {1052 , 843}, { 259 , 341}, {1063 , 637}, { 865 , 654} } }; const Word16 AR_SVQ_CB1_fx[32][8] = /* x2.56 */ {//Qlog2(2.56) - { -1, 4, 16, 4, 45, -110, 10, 167, }, - { -3, 2, 8, -12, -7, 23, 279, -46, }, - { 0, 2, 1, 8, -73, -40, 71, -97, }, - { 0, 2, 42, 74, -39, 72, 27, 8, }, - { 0, 1, 9, -6, 40, -65, -55, -128, }, - { 0, 0, 8, -10, -43, 105, -5, -126, }, - { 0, 0, 12, -3, -98, -18, -88, -73, }, - { 0, 1, -6, -12, -49, -179, -30, -15, }, - { -1, 0, 24, 78, 25, -69, -26, -14, }, - { 0, 1, -1, -29, 23, -65, -126, 34, }, - { 2, -4, -23, -7, -13, -2, -22, -4, }, - { -1, 1, -2, 44, -54, -58, 107, 60, }, - { 0, 1, -3, -15, -54, 97, -100, 41, }, - { 0, -2, -81, 93, -13, 18, -31, -75, }, - { -1, 2, 0, -5, 166, -64, -48, 8, }, - { -2, 0, -27, -108, 36, 3, 12, -80, }, - { 0, 0, 0, 4, 82, -1, 79, 54, }, - { 1, -4, 5, -9, -38, 289, 16, 16, }, - { -1, 2, 6, -68, 61, 67, -31, 100, }, - { 3, -6, 2, -2, -1, -6, -217, 273, }, - { 0, 1, -43, -62, -7, -60, 28, 78, }, - { -1, 2, 10, 0, 76, 84, -55, -45, }, - { -1, -2, 4, 5, -32, 75, 70, 176, }, - { 2, -1, 0, 6, 27, 29, -220, -97, }, - { -1, 1, 90, -56, -10, -16, 29, 8, }, - { -1, 3, -10, 0, 2, -24, 49, -336, }, - { -1, 1, -8, -9, 55, -134, 105, -44, }, - { 0, 1, -16, 69, 51, 40, -51, 98, }, - { 0, 2, -12, -32, -140, 49, 50, 26, }, - { 0, 3, 8, 29, 77, 24, 76, -103, }, - { -1, 2, -24, -18, 7, 100, 94, 5, }, - { 0, -1, 10, 26, -87, -34, -56, 103, } + { -1, 4, 16, 4, 45, -110, 10, 167, }, + { -3, 2, 8, -12, -7, 23, 279, -46, }, + { 0, 2, 1, 8, -73, -40, 71, -97, }, + { 0, 2, 42, 74, -39, 72, 27, 8, }, + { 0, 1, 9, -6, 40, -65, -55, -128, }, + { 0, 0, 8, -10, -43, 105, -5, -126, }, + { 0, 0, 12, -3, -98, -18, -88, -73, }, + { 0, 1, -6, -12, -49, -179, -30, -15, }, + { -1, 0, 24, 78, 25, -69, -26, -14, }, + { 0, 1, -1, -29, 23, -65, -126, 34, }, + { 2, -4, -23, -7, -13, -2, -22, -4, }, + { -1, 1, -2, 44, -54, -58, 107, 60, }, + { 0, 1, -3, -15, -54, 97, -100, 41, }, + { 0, -2, -81, 93, -13, 18, -31, -75, }, + { -1, 2, 0, -5, 166, -64, -48, 8, }, + { -2, 0, -27, -108, 36, 3, 12, -80, }, + { 0, 0, 0, 4, 82, -1, 79, 54, }, + { 1, -4, 5, -9, -38, 289, 16, 16, }, + { -1, 2, 6, -68, 61, 67, -31, 100, }, + { 3, -6, 2, -2, -1, -6, -217, 273, }, + { 0, 1, -43, -62, -7, -60, 28, 78, }, + { -1, 2, 10, 0, 76, 84, -55, -45, }, + { -1, -2, 4, 5, -32, 75, 70, 176, }, + { 2, -1, 0, 6, 27, 29, -220, -97, }, + { -1, 1, 90, -56, -10, -16, 29, 8, }, + { -1, 3, -10, 0, 2, -24, 49, -336, }, + { -1, 1, -8, -9, 55, -134, 105, -44, }, + { 0, 1, -16, 69, 51, 40, -51, 98, }, + { 0, 2, -12, -32, -140, 49, 50, 26, }, + { 0, 3, 8, 29, 77, 24, 76, -103, }, + { -1, 2, -24, -18, 7, 100, 94, 5, }, + { 0, -1, 10, 26, -87, -34, -56, 103, } }; const Word16 AR_SVQ_CB2_fx[16][8] = /* x2.56 */ {//Qlog2(2.56) - { -37, -59, 208, -88, 54, 58, -16, -24, }, - { 0, -98, 9, -65, -182, -21, 19, 9, }, - { -1, 110, -8, 59, 201, 9, -38, -22, }, - { -1, 40, -22, -183, 46, -162, -38, -6, }, - { 12, 2, -193, 64, -43, -48, 11, 9, }, - { -83, 175, -8, -55, -65, 66, 26, 6, }, - { 29, 3, 2, -10, -100, 293, 75, -12, }, - { 7, -54, -76, -91, 63, 119, -84, -84, }, - { 3, 7, 6, 6, -30, 15, -176, 168, }, - { -10, 45, 26, 57, -92, -68, -117, -134, }, - { 0, -37, -34, -69, 106, 54, 121, 131, }, - { -25, -64, 7, 205, 1, 93, 27, 6, }, - { 64, 28, 51, 8, -7, 18, 27, 0, }, - { -20, 44, 57, 78, -55, -170, 88, 93, }, - { 12, -125, 12, 56, 100, -160, -87, -3, }, - { -7, -18, -7, -6, 36, -54, 175, -176, } + { -37, -59, 208, -88, 54, 58, -16, -24, }, + { 0, -98, 9, -65, -182, -21, 19, 9, }, + { -1, 110, -8, 59, 201, 9, -38, -22, }, + { -1, 40, -22, -183, 46, -162, -38, -6, }, + { 12, 2, -193, 64, -43, -48, 11, 9, }, + { -83, 175, -8, -55, -65, 66, 26, 6, }, + { 29, 3, 2, -10, -100, 293, 75, -12, }, + { 7, -54, -76, -91, 63, 119, -84, -84, }, + { 3, 7, 6, 6, -30, 15, -176, 168, }, + { -10, 45, 26, 57, -92, -68, -117, -134, }, + { 0, -37, -34, -69, 106, 54, 121, 131, }, + { -25, -64, 7, 205, 1, 93, 27, 6, }, + { 64, 28, 51, 8, -7, 18, 27, 0, }, + { -20, 44, 57, 78, -55, -170, 88, 93, }, + { 12, -125, 12, 56, 100, -160, -87, -3, }, + { -7, -18, -7, -6, 36, -54, 175, -176, } }; const Word16 W_DTX_HO_FX[HO_HIST_SIZE] = /* Q15 */ { - 6554, 5243, 4194, 3355, 2684, 2147, 1718, 344 + 6554, 5243, 4194, 3355, 2684, 2147, 1718, 344 }; @@ -14301,7 +14301,7 @@ const Word16 HO_ATT_FX[5] = /* Q15 */ 17597, 20205, 22410, 23198, 23198 }; -const Word16 uniform_model[] = { MAX_AR_FREQ, MAX_AR_FREQ / 2, 0 }; // Q0 +const Word16 uniform_model[] = { MAX_AR_FREQ, MAX_AR_FREQ / 2, 0 }; // Q0 /*-----------------------------------------------------------------* @@ -14311,10 +14311,10 @@ const Word16 uniform_model[] = { MAX_AR_FREQ, MAX_AR_FREQ / 2, 0 }; // Q0 const Word16 tbl_mid_gen_wb_2b_fx[] =//Q13 { - 3814, 5145, 5856, 5290, 5277, 4880, 4877, 4273, 3868, 3776, 3392, 3163, 3120, 3019, 3395, 5814, - 1482, 861, 1968, 3198, 3105, 3737, 3749, 4525, 4982, 4828, 5023, 5335, 5327, 5296, 5092, 3444, - 3955, 3851, 1520, 1666, 1554, 1385, 1537, 1276, 1443, 1526, 1597, 1636, 1867, 2041, 2483, 2059, - 7038, 8112, 7324, 6969, 6877, 7028, 6987, 7098, 7003, 6955, 6927, 6808, 6685, 6459, 5871, 6047, + 3814, 5145, 5856, 5290, 5277, 4880, 4877, 4273, 3868, 3776, 3392, 3163, 3120, 3019, 3395, 5814, + 1482, 861, 1968, 3198, 3105, 3737, 3749, 4525, 4982, 4828, 5023, 5335, 5327, 5296, 5092, 3444, + 3955, 3851, 1520, 1666, 1554, 1385, 1537, 1276, 1443, 1526, 1597, 1636, 1867, 2041, 2483, 2059, + 7038, 8112, 7324, 6969, 6877, 7028, 6987, 7098, 7003, 6955, 6927, 6808, 6685, 6459, 5871, 6047, }; const Word16 tbl_mid_gen_wb_4b_fx[] = @@ -14340,156 +14340,156 @@ const Word16 tbl_mid_gen_wb_4b_fx[] = const Word16 tbl_mid_gen_wb_5b_fx[] = {//Q13 - 6510, 8058, 7103, 6095, 6483, 5866, 6026, 6443, 6882, 6907, 7015, 6581, 5649, 4044, 2816, 2519, - 3778, 2123, 3580, 4221, 2598, 4631, 2844, 4905, 5446, 4529, 5186, 6228, 6210, 5693, 6213, -4670, - 9050, 9934, 8441, 7921, 7546, 7840, 7977, 8335, 8679, 8706, 8703, 8607, 8560, 8375, 7759, 6405, - 4243, 5775, 2939, 5887, 4078, 3117, 5267, 5680, 4589, 2401, 731, 1011, 1657, 4733, 7051, 3992, - 2508, 3156, 3347, 1605, 4450, 4633, 3476, 6019, 4083, 3824, 5133, 6020, 3253, 1368, 1736, 13507, - 5934, 6372, 4494, 2957, 4424, 6667, 8167, 8413, 7957, 7139, 5518, 3059, 2829, 2821, 2773, 3274, - 4984, 5566, 5831, 4556, 5732, 6738, 6689, 4683, 2265, 4214, 7242, 9989, 9776, 9068, 4748, 2292, - 2601, 4933, 2764, 4923, 3763, 3678, 5596, 2079, 6108, 6824, 5507, 5612, 6793, 5553, 1140, 9993, - 7084, 6685, 5313, 5196, 3111, 5337, 3535, 2476, 2477, 1737, 2090, 4033, 5680, 6548, 7310, 11811, - 8140, 8602, 7166, 6738, 6018, 5299, 5686, 4722, 4108, 4456, 3713, 3131, 2658, 2336, 2250, 8051, - 727, 1865, 6073, 3932, 2258, 2413, 4823, 5733, 5101, 6126, 4690, 1130, 1172, 1479, 3956, 7204, - 6042, 1024, 5371, 5997, 4964, 5575, 5078, 5843, 6909, 8465, 8601, 6137, 5699, 8049, 9922, 8318, - 2728, 1625, 4750, 5004, 5799, 4938, 6353, 3274, 1781, 3095, 1479, 3136, 5470, 1391, -626, 2422, - 4407, 3228, 1266, 1488, 1222, 963, 1148, 1182, 1330, 1770, 860, 381, 813, 1268, 2352, 3956, - 1683, -120, 83, 1239, 946, 1609, 1982, 3215, 3950, 4200, 4497, 4898, 4551, 3595, 2345, 2444, - 1055, 3207, 7460, 6808, 7103, 6980, 7902, 8196, 6821, 6190, 6405, 7414, 7967, 7506, 6921, 9871, - 3164, 7995, 8446, 8770, 8443, 8302, 7372, 7049, 6090, 5698, 5090, 4792, 4996, 4874, 4285, 6685, - 3681, 319, 536, 3174, 4495, 5486, 5807, 5751, 5461, 4423, 3556, 3449, 5148, 7560, 6277, 3783, - 1987, 4209, 6954, 5880, 7459, 7762, 4326, 4958, 5154, 2150, 2988, 2469, 1175, 1099, 3999, 3950, - 1306, 2303, 7748, 8238, 6116, 2824, 1772, 1130, 2538, 3345, 5317, 4773, 3668, 5458, 5519, 5594, - 4140, 4329, 3339, 3001, 2669, -79, -582, -1729, -680, 1294, 2752, 3700, 3627, 4428, 4950, 2744, - 5309, 3611, 993, 3526, 2043, 3938, 2069, 1434, 4173, 2609, 2704, 3690, 3686, 1894, 1401, -1682, - 6091, 4810, 970, 1063, 1707, 3056, 4597, 6742, 7397, 6913, 7359, 7884, 7571, 6830, 6039, 3823, - 6599, 6006, 1248, 4330, 6935, 3784, 3535, 3902, 3221, 5384, 5691, 5997, 5975, 6731, 9125, 5385, - 204, 242, 2009, 3375, 3412, 3407, 2691, 2547, 598, -150, 67, 250, 618, 1185, 1987, 1157, - 4986, 7977, 6971, 1528, 86, 281, 1497, 3002, 4193, 4430, 4721, 5317, 6001, 6181, 6962, 5480, - 6914, 7963, 5254, 3050, 5365, 3224, 3781, 3044, 2571, 3155, 2243, 1612, 2157, 2526, 2784, -1629, - 7350, 6702, 2435, 1937, 2549, 1978, 2819, 2817, 2059, 2493, 3408, 2344, 1239, 1177, 914, 3763, - 4362, 3105, -1457, -1760, 314, 1452, 2603, 1642, 1670, 1652, 2258, 2492, 3844, 4399, 5213, 660, - 350, 357, 109, 83, -555, -886, -714, -587, -120, 25, 189, 531, 591, 146, 156, 1435, - 498, 211, 3062, 6766, 7150, 8142, 7531, 7527, 7855, 6898, 6613, 6480, 5290, 4310, 5341, 4129, - 2753, 6959, 7088, 4622, 2646, 2395, 1756, 325, 488, 259, -125, -577, -553, 615, 557, 4617, + 6510, 8058, 7103, 6095, 6483, 5866, 6026, 6443, 6882, 6907, 7015, 6581, 5649, 4044, 2816, 2519, + 3778, 2123, 3580, 4221, 2598, 4631, 2844, 4905, 5446, 4529, 5186, 6228, 6210, 5693, 6213, -4670, + 9050, 9934, 8441, 7921, 7546, 7840, 7977, 8335, 8679, 8706, 8703, 8607, 8560, 8375, 7759, 6405, + 4243, 5775, 2939, 5887, 4078, 3117, 5267, 5680, 4589, 2401, 731, 1011, 1657, 4733, 7051, 3992, + 2508, 3156, 3347, 1605, 4450, 4633, 3476, 6019, 4083, 3824, 5133, 6020, 3253, 1368, 1736, 13507, + 5934, 6372, 4494, 2957, 4424, 6667, 8167, 8413, 7957, 7139, 5518, 3059, 2829, 2821, 2773, 3274, + 4984, 5566, 5831, 4556, 5732, 6738, 6689, 4683, 2265, 4214, 7242, 9989, 9776, 9068, 4748, 2292, + 2601, 4933, 2764, 4923, 3763, 3678, 5596, 2079, 6108, 6824, 5507, 5612, 6793, 5553, 1140, 9993, + 7084, 6685, 5313, 5196, 3111, 5337, 3535, 2476, 2477, 1737, 2090, 4033, 5680, 6548, 7310, 11811, + 8140, 8602, 7166, 6738, 6018, 5299, 5686, 4722, 4108, 4456, 3713, 3131, 2658, 2336, 2250, 8051, + 727, 1865, 6073, 3932, 2258, 2413, 4823, 5733, 5101, 6126, 4690, 1130, 1172, 1479, 3956, 7204, + 6042, 1024, 5371, 5997, 4964, 5575, 5078, 5843, 6909, 8465, 8601, 6137, 5699, 8049, 9922, 8318, + 2728, 1625, 4750, 5004, 5799, 4938, 6353, 3274, 1781, 3095, 1479, 3136, 5470, 1391, -626, 2422, + 4407, 3228, 1266, 1488, 1222, 963, 1148, 1182, 1330, 1770, 860, 381, 813, 1268, 2352, 3956, + 1683, -120, 83, 1239, 946, 1609, 1982, 3215, 3950, 4200, 4497, 4898, 4551, 3595, 2345, 2444, + 1055, 3207, 7460, 6808, 7103, 6980, 7902, 8196, 6821, 6190, 6405, 7414, 7967, 7506, 6921, 9871, + 3164, 7995, 8446, 8770, 8443, 8302, 7372, 7049, 6090, 5698, 5090, 4792, 4996, 4874, 4285, 6685, + 3681, 319, 536, 3174, 4495, 5486, 5807, 5751, 5461, 4423, 3556, 3449, 5148, 7560, 6277, 3783, + 1987, 4209, 6954, 5880, 7459, 7762, 4326, 4958, 5154, 2150, 2988, 2469, 1175, 1099, 3999, 3950, + 1306, 2303, 7748, 8238, 6116, 2824, 1772, 1130, 2538, 3345, 5317, 4773, 3668, 5458, 5519, 5594, + 4140, 4329, 3339, 3001, 2669, -79, -582, -1729, -680, 1294, 2752, 3700, 3627, 4428, 4950, 2744, + 5309, 3611, 993, 3526, 2043, 3938, 2069, 1434, 4173, 2609, 2704, 3690, 3686, 1894, 1401, -1682, + 6091, 4810, 970, 1063, 1707, 3056, 4597, 6742, 7397, 6913, 7359, 7884, 7571, 6830, 6039, 3823, + 6599, 6006, 1248, 4330, 6935, 3784, 3535, 3902, 3221, 5384, 5691, 5997, 5975, 6731, 9125, 5385, + 204, 242, 2009, 3375, 3412, 3407, 2691, 2547, 598, -150, 67, 250, 618, 1185, 1987, 1157, + 4986, 7977, 6971, 1528, 86, 281, 1497, 3002, 4193, 4430, 4721, 5317, 6001, 6181, 6962, 5480, + 6914, 7963, 5254, 3050, 5365, 3224, 3781, 3044, 2571, 3155, 2243, 1612, 2157, 2526, 2784, -1629, + 7350, 6702, 2435, 1937, 2549, 1978, 2819, 2817, 2059, 2493, 3408, 2344, 1239, 1177, 914, 3763, + 4362, 3105, -1457, -1760, 314, 1452, 2603, 1642, 1670, 1652, 2258, 2492, 3844, 4399, 5213, 660, + 350, 357, 109, 83, -555, -886, -714, -587, -120, 25, 189, 531, 591, 146, 156, 1435, + 498, 211, 3062, 6766, 7150, 8142, 7531, 7527, 7855, 6898, 6613, 6480, 5290, 4310, 5341, 4129, + 2753, 6959, 7088, 4622, 2646, 2395, 1756, 325, 488, 259, -125, -577, -553, 615, 557, 4617, }; const Word16 tbl_mid_voi_wb_1b_fx[] = /* Q13*/ { - 4551, 4599, 4754, 5035, 4982, 5228, 5318, 5603, 5699, 5652, 5642, 5766, 5825, 5874, 5819, 6056, - 3816, 3355, 2321, 2712, 2900, 2715, 2790, 2508, 2506, 2610, 2617, 2419, 2538, 2622, 3004, 2725, + 4551, 4599, 4754, 5035, 4982, 5228, 5318, 5603, 5699, 5652, 5642, 5766, 5825, 5874, 5819, 6056, + 3816, 3355, 2321, 2712, 2900, 2715, 2790, 2508, 2506, 2610, 2617, 2419, 2538, 2622, 3004, 2725, }; const Word16 tbl_mid_voi_wb_4b_fx[] =//Q13 { - 4337, 4235, 3526, 4083, 3514, 5457, 3168, 2509, 4418, 5021, 1313, 2952, 5347, 3893, 8325, 11758, - 4180, 4037, 3965, 3481, 4028, 3284, 2644, 4585, 4749, 3076, 3211, 1101, 4175, 7440, 5745, -4105, - 4239, 3957, 4450, 4974, 5400, 5734, 6246, 6586, 7774, 2699, 2783, 3474, 1345, -316, 5069, 4904, - 3964, 3810, 2673, 3031, 2249, 3168, 3155, 4204, 7316, 7176, 8680, 7147, 4918, 4136, 3142, 3011, - 4071, 3853, 3898, 3973, 3464, 2878, 5783, 5341, 1725, 801, 1194, 4239, 6866, 4950, 794, 6270, - 3933, 3750, 4931, 3667, 3585, 2550, 4308, 5757, 4503, 7081, 4893, 1076, 109, 1650, 1887, 8861, - 4803, 4827, 4969, 5511, 5768, 4327, 5277, 4934, 6909, 7672, 5355, 3940, 9990, 9622, 7457, 4202, - 4515, 4259, 2444, 4847, 3728, 4599, 4975, 6144, 4087, 4367, 7025, 5028, 2405, 7014, 13366, 6264, - 4746, 4556, 5408, 5866, 4733, 4088, 3965, 3329, 4669, 3105, 5918, 7824, 6026, 9177, 1856, 13229, - 4130, 4214, 2516, 3542, 4847, 3751, 3704, 2380, 4190, 4787, 4651, 4981, 5702, -27, -2961, 129, - 4461, 4724, 5233, 4680, 6010, 7222, 6351, 3069, 605, 5934, 5627, 3836, 3490, 6060, 3556, 2585, - 4628, 4723, 5465, 4180, 4460, 6173, 5915, 7260, 4703, 4114, 3938, 9585, 8085, 3781, 7520, 625, - 5002, 5621, 6352, 6914, 7170, 7719, 7585, 8408, 8360, 7883, 7370, 7222, 6616, 6002, 5565, 9394, - 4059, 4121, 4178, 4417, 3437, 1460, 1031, 111, 585, 1708, 4219, 5419, 2585, 3195, 6149, 3221, - 3394, 2776, 1970, 2707, 2983, 3931, 3247, 1729, 449, -109, -46, -469, 397, 1980, 2305, 1573, - 3259, 1870, 242, 392, 748, 615, 1185, 1285, 2259, 2687, 2212, 1762, 2174, 1887, 1847, 2073, + 4337, 4235, 3526, 4083, 3514, 5457, 3168, 2509, 4418, 5021, 1313, 2952, 5347, 3893, 8325, 11758, + 4180, 4037, 3965, 3481, 4028, 3284, 2644, 4585, 4749, 3076, 3211, 1101, 4175, 7440, 5745, -4105, + 4239, 3957, 4450, 4974, 5400, 5734, 6246, 6586, 7774, 2699, 2783, 3474, 1345, -316, 5069, 4904, + 3964, 3810, 2673, 3031, 2249, 3168, 3155, 4204, 7316, 7176, 8680, 7147, 4918, 4136, 3142, 3011, + 4071, 3853, 3898, 3973, 3464, 2878, 5783, 5341, 1725, 801, 1194, 4239, 6866, 4950, 794, 6270, + 3933, 3750, 4931, 3667, 3585, 2550, 4308, 5757, 4503, 7081, 4893, 1076, 109, 1650, 1887, 8861, + 4803, 4827, 4969, 5511, 5768, 4327, 5277, 4934, 6909, 7672, 5355, 3940, 9990, 9622, 7457, 4202, + 4515, 4259, 2444, 4847, 3728, 4599, 4975, 6144, 4087, 4367, 7025, 5028, 2405, 7014, 13366, 6264, + 4746, 4556, 5408, 5866, 4733, 4088, 3965, 3329, 4669, 3105, 5918, 7824, 6026, 9177, 1856, 13229, + 4130, 4214, 2516, 3542, 4847, 3751, 3704, 2380, 4190, 4787, 4651, 4981, 5702, -27, -2961, 129, + 4461, 4724, 5233, 4680, 6010, 7222, 6351, 3069, 605, 5934, 5627, 3836, 3490, 6060, 3556, 2585, + 4628, 4723, 5465, 4180, 4460, 6173, 5915, 7260, 4703, 4114, 3938, 9585, 8085, 3781, 7520, 625, + 5002, 5621, 6352, 6914, 7170, 7719, 7585, 8408, 8360, 7883, 7370, 7222, 6616, 6002, 5565, 9394, + 4059, 4121, 4178, 4417, 3437, 1460, 1031, 111, 585, 1708, 4219, 5419, 2585, 3195, 6149, 3221, + 3394, 2776, 1970, 2707, 2983, 3931, 3247, 1729, 449, -109, -46, -469, 397, 1980, 2305, 1573, + 3259, 1870, 242, 392, 748, 615, 1185, 1285, 2259, 2687, 2212, 1762, 2174, 1887, 1847, 2073, }; const Word16 tbl_mid_voi_wb_5b_fx[] =//Q13 { - 4182, 3820, 4103, 5620, 4100, 4478, 3949, 5053, 2918, 3083, 4229, 3732, 1823, 6350, 17230, 4601, - 4361, 4077, 2236, 4128, 3216, 4673, 6022, 6522, 5746, 4282, 3121, 4448, 6457, 12573, 4401, 7796, - 4228, 4086, 4375, 4320, 4474, 4735, 4427, 5616, 5975, 138, 5887, 3722, 2304, -3430, 4995, 6246, - 4320, 4344, 4008, 4327, 3323, 6835, 3627, 3330, 3123, 3971, 2382, 1801, 6422, 3162, 9038, 14129, - 4193, 4202, 4413, 2703, 4175, 4330, 2615, 7600, 1717, 3506, 5671, 7170, 3545, 2350, -2738, 7287, - 4170, 3912, 4323, 3821, 4450, 6765, 7496, 8107, 7447, 5525, 3088, 1963, 2014, 3330, 976, 1002, - 4583, 4419, 3584, 4125, 4783, 5133, 3188, 5000, 4812, 4639, 10038, 7018, 5114, 5567, 3292, -6364, - 3926, 4092, 2710, 2721, 1799, 3509, 4542, 3351, 4583, 5877, 6539, 5135, 981, 4029, 7221, 592, - 4624, 4567, 4468, 4630, 5710, 5222, 5883, 2562, 8453, 2825, 109, 6491, 1210, 2921, 7292, 7118, - 4245, 4160, 5119, 4356, 5544, 3034, 1507, 4179, 5971, 1949, 3388, 613, 4995, 9019, 6755, -628, - 4905, 4962, 4529, 7025, 4905, 4470, 5063, 3440, 6348, 6102, 4319, 4395, 7515, 6549, -3697, 6513, - 4683, 4592, 5303, 4593, 4171, 5264, 6116, 7434, 4105, 5454, 2544, 8493, 6491, 894, 8983, -2406, - 3632, 3435, 3988, 4195, 3684, 2173, 6735, 4552, -339, 763, 308, 3463, 6123, 2895, 2831, 5715, - 4316, 4111, 2236, 2682, 1058, 544, 2541, 1677, 3549, 2767, 3376, 5901, 6689, 5811, 6617, 3311, - 4487, 4285, 4992, 3656, 5970, 4547, 3975, 5998, 4985, 6614, 4807, 1971, 14937, 4388, 6153, 3352, - 4601, 4710, 4957, 4454, 4873, 7207, 5881, 3461, 2282, 1829, 5617, 9926, 10043, 7722, 3232, 4629, - 3965, 3837, 2088, 4265, 5042, 3478, 4453, 2804, 4162, 4858, 4315, 4343, 5193, -1823, -5028, -1137, - 3439, 2837, 2549, 4062, 2857, 2657, 2662, 5088, 10548, 8913, 6631, 6395, 5568, 3210, 2431, 3400, - 4073, 3839, 5806, 5296, 3766, 2342, 2585, 891, 3144, 2988, 6807, 4626, 3700, 5854, 1543, 16158, - 4189, 4045, 4293, 4527, 4008, 1413, 4871, 6081, 3297, 6546, 5006, -365, -2369, 1375, 5522, 8787, - 4778, 4782, 4941, 4538, 4497, 3129, 4934, 4371, 7175, 6923, 8620, 10236, 8664, 10088, 10923, 7314, - 4945, 5016, 6439, 6353, 6624, 6463, 6938, 7547, 7004, 7283, 7655, 7149, 7650, 2747, 3416, 14892, - 4776, 5431, 5515, 6194, 5700, 5485, 2795, 5476, 4024, 8891, 2930, 7916, 3428, 8070, 5920, 13440, - 4718, 4986, 4800, 5286, 6567, 6554, 6601, 1235, -1216, 6556, 6098, 3962, 4361, 5536, 5517, 3935, - 4741, 4679, 5593, 4891, 3849, 5675, 6487, 6239, 7062, 12044, 10918, 2438, 3977, 7296, 8445, 6625, - 4859, 5781, 6592, 7399, 8027, 8858, 8139, 8951, 8760, 5506, 6294, 6540, 6516, 7527, 7688, 4084, - 4077, 3771, 3650, 3381, 3367, 4048, 3899, 4382, 3017, -2156, -1464, -2207, 828, 4838, 2071, 2363, - 3796, 3437, 3558, 3842, 2170, 4311, 2602, 696, 1939, 2576, 1239, 328, -129, -647, 1702, 2893, - 4015, 3506, 367, 1350, 3328, 3700, 3827, 2439, 1434, 3887, 2279, 1593, 3673, 5508, 3905, -2973, - 4088, 3990, 3732, 3256, 4718, 1375, 152, -99, -254, 1140, 3578, 3316, 2195, 2408, 5027, 999, - 3749, 3175, 1475, 686, 2006, 1959, 1558, 3059, 5374, 5014, 2439, 2396, 2467, 2218, 1031, 7866, - 2037, 701, 124, 278, 328, 253, 660, 528, 826, 473, 801, 800, 1053, 1330, 804, 967, + 4182, 3820, 4103, 5620, 4100, 4478, 3949, 5053, 2918, 3083, 4229, 3732, 1823, 6350, 17230, 4601, + 4361, 4077, 2236, 4128, 3216, 4673, 6022, 6522, 5746, 4282, 3121, 4448, 6457, 12573, 4401, 7796, + 4228, 4086, 4375, 4320, 4474, 4735, 4427, 5616, 5975, 138, 5887, 3722, 2304, -3430, 4995, 6246, + 4320, 4344, 4008, 4327, 3323, 6835, 3627, 3330, 3123, 3971, 2382, 1801, 6422, 3162, 9038, 14129, + 4193, 4202, 4413, 2703, 4175, 4330, 2615, 7600, 1717, 3506, 5671, 7170, 3545, 2350, -2738, 7287, + 4170, 3912, 4323, 3821, 4450, 6765, 7496, 8107, 7447, 5525, 3088, 1963, 2014, 3330, 976, 1002, + 4583, 4419, 3584, 4125, 4783, 5133, 3188, 5000, 4812, 4639, 10038, 7018, 5114, 5567, 3292, -6364, + 3926, 4092, 2710, 2721, 1799, 3509, 4542, 3351, 4583, 5877, 6539, 5135, 981, 4029, 7221, 592, + 4624, 4567, 4468, 4630, 5710, 5222, 5883, 2562, 8453, 2825, 109, 6491, 1210, 2921, 7292, 7118, + 4245, 4160, 5119, 4356, 5544, 3034, 1507, 4179, 5971, 1949, 3388, 613, 4995, 9019, 6755, -628, + 4905, 4962, 4529, 7025, 4905, 4470, 5063, 3440, 6348, 6102, 4319, 4395, 7515, 6549, -3697, 6513, + 4683, 4592, 5303, 4593, 4171, 5264, 6116, 7434, 4105, 5454, 2544, 8493, 6491, 894, 8983, -2406, + 3632, 3435, 3988, 4195, 3684, 2173, 6735, 4552, -339, 763, 308, 3463, 6123, 2895, 2831, 5715, + 4316, 4111, 2236, 2682, 1058, 544, 2541, 1677, 3549, 2767, 3376, 5901, 6689, 5811, 6617, 3311, + 4487, 4285, 4992, 3656, 5970, 4547, 3975, 5998, 4985, 6614, 4807, 1971, 14937, 4388, 6153, 3352, + 4601, 4710, 4957, 4454, 4873, 7207, 5881, 3461, 2282, 1829, 5617, 9926, 10043, 7722, 3232, 4629, + 3965, 3837, 2088, 4265, 5042, 3478, 4453, 2804, 4162, 4858, 4315, 4343, 5193, -1823, -5028, -1137, + 3439, 2837, 2549, 4062, 2857, 2657, 2662, 5088, 10548, 8913, 6631, 6395, 5568, 3210, 2431, 3400, + 4073, 3839, 5806, 5296, 3766, 2342, 2585, 891, 3144, 2988, 6807, 4626, 3700, 5854, 1543, 16158, + 4189, 4045, 4293, 4527, 4008, 1413, 4871, 6081, 3297, 6546, 5006, -365, -2369, 1375, 5522, 8787, + 4778, 4782, 4941, 4538, 4497, 3129, 4934, 4371, 7175, 6923, 8620, 10236, 8664, 10088, 10923, 7314, + 4945, 5016, 6439, 6353, 6624, 6463, 6938, 7547, 7004, 7283, 7655, 7149, 7650, 2747, 3416, 14892, + 4776, 5431, 5515, 6194, 5700, 5485, 2795, 5476, 4024, 8891, 2930, 7916, 3428, 8070, 5920, 13440, + 4718, 4986, 4800, 5286, 6567, 6554, 6601, 1235, -1216, 6556, 6098, 3962, 4361, 5536, 5517, 3935, + 4741, 4679, 5593, 4891, 3849, 5675, 6487, 6239, 7062, 12044, 10918, 2438, 3977, 7296, 8445, 6625, + 4859, 5781, 6592, 7399, 8027, 8858, 8139, 8951, 8760, 5506, 6294, 6540, 6516, 7527, 7688, 4084, + 4077, 3771, 3650, 3381, 3367, 4048, 3899, 4382, 3017, -2156, -1464, -2207, 828, 4838, 2071, 2363, + 3796, 3437, 3558, 3842, 2170, 4311, 2602, 696, 1939, 2576, 1239, 328, -129, -647, 1702, 2893, + 4015, 3506, 367, 1350, 3328, 3700, 3827, 2439, 1434, 3887, 2279, 1593, 3673, 5508, 3905, -2973, + 4088, 3990, 3732, 3256, 4718, 1375, 152, -99, -254, 1140, 3578, 3316, 2195, 2408, 5027, 999, + 3749, 3175, 1475, 686, 2006, 1959, 1558, 3059, 5374, 5014, 2439, 2396, 2467, 2218, 1031, 7866, + 2037, 701, 124, 278, 328, 253, 660, 528, 826, 473, 801, 800, 1053, 1330, 804, 967, }; const Word16 tbl_mid_unv_wb_4b_fx[] =//Q13 { - 5190, 3143, 50, 2521, 5180, 6320, 3890, 3365, 3582, 3517, 3406, 3049, 2864, 1621, 1932, -950, - 6813, 6650, 2135, 972, 452, 1453, 3221, 1697, 3165, 4443, 5924, 6297, 3907, 2862, 3586, 4625, - 3204, 2673, 6499, 4319, 1054, 559, 4404, 5815, 5072, 6625, 4493, 2479, 1773, 1606, 2099, 8330, - 1924, 2666, 4171, 5517, 5898, 7238, 7318, 7696, 7250, 6269, 6164, 6038, 5249, 4284, 4147, 2828, - 2834, 788, 77, 2016, 1824, 3224, 3441, 4472, 6286, 6717, 6783, 6743, 6715, 7051, 6562, 2531, - 6386, 5634, 5761, 5184, 3523, 4284, 1867, 1045, 579, 1176, 1743, 2599, 5276, 5564, 5368, 7914, - 1795, 1380, 5184, 9326, 8023, 3138, 1258, 1729, 3328, 3934, 5169, 5645, 5271, 5894, 5591, 5145, - 5734, 5844, 8799, 8753, 5628, 5710, 5255, 4872, 5349, 3431, 3006, 2486, 1418, 974, 1115, 2035, - 4194, 8421, 1812, 6078, 3003, 3455, 6719, 7501, 2120, 1892, 2658, 2317, 2296, 5735, 6553, 4485, - 8072, 11456, 6455, 5069, 4918, 4936, 4819, 4932, 6029, 6246, 6289, 6704, 6749, 5337, 4526, 3974, - 3709, 5584, 4884, -1502, 4864, 2333, 606, 5976, 6438, 2413, 1937, 3663, 5593, 6989, 6450, 3555, - 3843, -6887, 3697, 3880, 4448, 4264, 5961, 4198, 3583, 3942, 3606, 3768, 4457, 4374, 4096, 4524, - 2551, 6781, 7017, 2902, 9227, 8728, 7130, 1873, 2308, 4393, 3981, 3976, 4002, 4080, 4820, 5611, - 220, -174, -43, -542, 449, 1470, 1759, 1893, 1294, 995, 723, 723, 769, 994, 1369, 4413, - 1651, 2259, 3079, 2913, 1176, -491, -1262, -827, -217, 908, 1126, 1751, 1901, 1765, 2656, 247, - 5380, 7307, 7727, 8135, 8270, 8471, 8792, 8573, 8335, 8420, 8057, 7562, 7119, 7458, 6806, 7385, + 5190, 3143, 50, 2521, 5180, 6320, 3890, 3365, 3582, 3517, 3406, 3049, 2864, 1621, 1932, -950, + 6813, 6650, 2135, 972, 452, 1453, 3221, 1697, 3165, 4443, 5924, 6297, 3907, 2862, 3586, 4625, + 3204, 2673, 6499, 4319, 1054, 559, 4404, 5815, 5072, 6625, 4493, 2479, 1773, 1606, 2099, 8330, + 1924, 2666, 4171, 5517, 5898, 7238, 7318, 7696, 7250, 6269, 6164, 6038, 5249, 4284, 4147, 2828, + 2834, 788, 77, 2016, 1824, 3224, 3441, 4472, 6286, 6717, 6783, 6743, 6715, 7051, 6562, 2531, + 6386, 5634, 5761, 5184, 3523, 4284, 1867, 1045, 579, 1176, 1743, 2599, 5276, 5564, 5368, 7914, + 1795, 1380, 5184, 9326, 8023, 3138, 1258, 1729, 3328, 3934, 5169, 5645, 5271, 5894, 5591, 5145, + 5734, 5844, 8799, 8753, 5628, 5710, 5255, 4872, 5349, 3431, 3006, 2486, 1418, 974, 1115, 2035, + 4194, 8421, 1812, 6078, 3003, 3455, 6719, 7501, 2120, 1892, 2658, 2317, 2296, 5735, 6553, 4485, + 8072, 11456, 6455, 5069, 4918, 4936, 4819, 4932, 6029, 6246, 6289, 6704, 6749, 5337, 4526, 3974, + 3709, 5584, 4884, -1502, 4864, 2333, 606, 5976, 6438, 2413, 1937, 3663, 5593, 6989, 6450, 3555, + 3843, -6887, 3697, 3880, 4448, 4264, 5961, 4198, 3583, 3942, 3606, 3768, 4457, 4374, 4096, 4524, + 2551, 6781, 7017, 2902, 9227, 8728, 7130, 1873, 2308, 4393, 3981, 3976, 4002, 4080, 4820, 5611, + 220, -174, -43, -542, 449, 1470, 1759, 1893, 1294, 995, 723, 723, 769, 994, 1369, 4413, + 1651, 2259, 3079, 2913, 1176, -491, -1262, -827, -217, 908, 1126, 1751, 1901, 1765, 2656, 247, + 5380, 7307, 7727, 8135, 8270, 8471, 8792, 8573, 8335, 8420, 8057, 7562, 7119, 7458, 6806, 7385, }; const Word16 tbl_mid_unv_wb_5b_fx[] = {//Q13 - 6237, 6323, 1151, 763, 4218, 6546, 8437, 8701, 7456, 6604, 4631, 2901, 3050, 1793, 1955, 2260, - 5542, 4318, 5343, 5521, 5999, 5477, 5265, 5234, 4616, 3329, 3444, 1816, -442, 45, -2, 8922, - 6370, 8208, 6583, 5630, 5401, 5458, 5188, 5595, 6637, 6891, 6962, 6967, 7014, 6330, 5445, 3101, - 2750, 2858, 5206, 4594, 3310, 3494, 2463, 3410, 3405, 6151, 7682, 8593, 4440, 3715, 2946, -4371, - 1157, 661, 3743, 6418, 7515, 8319, 7485, 7298, 7928, 7515, 6812, 5671, 5095, 5122, 4997, 3940, - 5133, 3446, 2693, 1620, 1860, 2663, 4603, 6289, 7451, 7255, 7511, 7486, 8869, 8704, 8431, 6632, - 2497, 6706, 7036, 3437, 10854, 8893, 6033, 3021, 2936, 4766, 4145, 4097, 5177, 4883, 5920, 7612, - -152, -54, 3955, 1170, 5562, 4695, 1370, 8293, 3106, 1942, 5508, 4878, 3495, 1094, 1079, 5401, - 482, 373, 220, -355, -236, -328, -426, -147, 244, 563, 567, 915, 1012, 676, 804, 2721, - 437, 816, 3208, 3395, 2501, 3795, 4380, 2553, 399, 31, -519, -475, -162, 1755, 2852, 1040, - 2067, 2125, 1247, 2393, 2872, 2218, 3502, 3977, 4712, 4275, 2600, 2380, 2314, 2893, 3555, 13929, - 3967, -635, -1752, 2490, 303, 969, 1045, 2839, 5670, 4651, 5202, 5248, 4182, 4381, 5492, 53, - 3041, 2494, 9264, 4970, 360, -3795, 6296, 6475, 4482, 6667, 5265, 2908, 2381, 2889, 3718, 5160, - 3364, 4119, 5929, 3164, -745, 9368, 1652, -719, 6323, 5113, 1919, 1260, 2630, 3585, 2224, 3178, - 1643, 837, 8074, 8337, 4237, 2332, 2190, -1176, 1968, 1238, 2354, 4756, 5269, 5759, 4962, 5411, - 7590, 6471, 2635, 1869, 1209, 1505, 2118, 892, 1652, 3717, 5010, 3969, 2265, 2428, 3278, 5027, - 7289, 8658, 11183, 8913, 6084, 6673, 5961, 4041, 3839, 2643, 2094, 3215, 2956, 2895, 3327, 5063, - 5814, -4982, 1120, 2112, 4384, 5288, 6052, 4305, 4724, 5062, 3380, 4200, 5838, 7181, 6383, 4771, - 3891, 7361, 4160, 1422, 4971, 939, 281, 3585, 4817, 1176, -306, 260, 3815, 8273, 7095, 1529, - 8179, 19416, 3518, 3547, 4619, 4231, 3359, 3606, 5131, 4469, 5204, 5115, 4941, 4772, 4175, 5160, - 4539, 5393, 2706, 5371, 1468, 8488, 10356, 2778, 1426, 371, 8093, 7808, 5208, 5996, 6081, 5057, - 3266, 3481, -4953, -5638, 4022, 5502, 3586, 3117, 2737, 3826, 3658, 3933, 3602, 4920, 4959, 3483, - 3846, 9592, 3360, 6480, 1215, 3170, 5218, 8641, 664, 2695, 3353, 1479, 1687, 6049, 7074, 4696, - 2231, 4497, 6761, 6799, 5941, 5445, 8083, 7944, 5879, 3744, 2518, 6482, 6581, 6096, 6379, -133, - 3360, 6078, 1064, 13807, 8185, 3605, 4327, 3777, 6211, 4977, 5015, 4871, 5825, 2506, 2130, 4946, - 5412, 4507, 952, 4098, 5027, 3949, 3501, 1778, 1955, 2126, 1626, 3669, 4446, -1101, 736, -2708, - 4824, 7481, 8884, -2619, -2754, 281, 4158, 3251, 4602, 2946, 3915, 6169, 6075, 3495, 3266, 4375, - 6135, 2668, 6784, 10326, 6892, 5479, 1511, 3070, 6410, 9193, 6954, 1084, 2873, 7030, 8139, 5670, - 7255, 5764, 5122, 5787, 3129, 5475, -2720, 3770, -827, 872, 1591, 4645, 7218, 5513, 5778, 6323, - 1185, -13100, 5560, 5867, 4153, 2591, 4923, 3450, 2062, 4251, 4289, 3397, 3835, 2082, 2343, 3172, - 4460, 4411, 3940, 4420, 9410, -2789, -2525, -2877, -1868, 2850, 4490, 4093, 3162, 3889, 3800, 3492, - 6408, 8292, 8434, 8544, 8707, 9146, 9377, 9301, 9063, 8945, 8346, 8173, 7175, 7254, 6120, 7420, + 6237, 6323, 1151, 763, 4218, 6546, 8437, 8701, 7456, 6604, 4631, 2901, 3050, 1793, 1955, 2260, + 5542, 4318, 5343, 5521, 5999, 5477, 5265, 5234, 4616, 3329, 3444, 1816, -442, 45, -2, 8922, + 6370, 8208, 6583, 5630, 5401, 5458, 5188, 5595, 6637, 6891, 6962, 6967, 7014, 6330, 5445, 3101, + 2750, 2858, 5206, 4594, 3310, 3494, 2463, 3410, 3405, 6151, 7682, 8593, 4440, 3715, 2946, -4371, + 1157, 661, 3743, 6418, 7515, 8319, 7485, 7298, 7928, 7515, 6812, 5671, 5095, 5122, 4997, 3940, + 5133, 3446, 2693, 1620, 1860, 2663, 4603, 6289, 7451, 7255, 7511, 7486, 8869, 8704, 8431, 6632, + 2497, 6706, 7036, 3437, 10854, 8893, 6033, 3021, 2936, 4766, 4145, 4097, 5177, 4883, 5920, 7612, + -152, -54, 3955, 1170, 5562, 4695, 1370, 8293, 3106, 1942, 5508, 4878, 3495, 1094, 1079, 5401, + 482, 373, 220, -355, -236, -328, -426, -147, 244, 563, 567, 915, 1012, 676, 804, 2721, + 437, 816, 3208, 3395, 2501, 3795, 4380, 2553, 399, 31, -519, -475, -162, 1755, 2852, 1040, + 2067, 2125, 1247, 2393, 2872, 2218, 3502, 3977, 4712, 4275, 2600, 2380, 2314, 2893, 3555, 13929, + 3967, -635, -1752, 2490, 303, 969, 1045, 2839, 5670, 4651, 5202, 5248, 4182, 4381, 5492, 53, + 3041, 2494, 9264, 4970, 360, -3795, 6296, 6475, 4482, 6667, 5265, 2908, 2381, 2889, 3718, 5160, + 3364, 4119, 5929, 3164, -745, 9368, 1652, -719, 6323, 5113, 1919, 1260, 2630, 3585, 2224, 3178, + 1643, 837, 8074, 8337, 4237, 2332, 2190, -1176, 1968, 1238, 2354, 4756, 5269, 5759, 4962, 5411, + 7590, 6471, 2635, 1869, 1209, 1505, 2118, 892, 1652, 3717, 5010, 3969, 2265, 2428, 3278, 5027, + 7289, 8658, 11183, 8913, 6084, 6673, 5961, 4041, 3839, 2643, 2094, 3215, 2956, 2895, 3327, 5063, + 5814, -4982, 1120, 2112, 4384, 5288, 6052, 4305, 4724, 5062, 3380, 4200, 5838, 7181, 6383, 4771, + 3891, 7361, 4160, 1422, 4971, 939, 281, 3585, 4817, 1176, -306, 260, 3815, 8273, 7095, 1529, + 8179, 19416, 3518, 3547, 4619, 4231, 3359, 3606, 5131, 4469, 5204, 5115, 4941, 4772, 4175, 5160, + 4539, 5393, 2706, 5371, 1468, 8488, 10356, 2778, 1426, 371, 8093, 7808, 5208, 5996, 6081, 5057, + 3266, 3481, -4953, -5638, 4022, 5502, 3586, 3117, 2737, 3826, 3658, 3933, 3602, 4920, 4959, 3483, + 3846, 9592, 3360, 6480, 1215, 3170, 5218, 8641, 664, 2695, 3353, 1479, 1687, 6049, 7074, 4696, + 2231, 4497, 6761, 6799, 5941, 5445, 8083, 7944, 5879, 3744, 2518, 6482, 6581, 6096, 6379, -133, + 3360, 6078, 1064, 13807, 8185, 3605, 4327, 3777, 6211, 4977, 5015, 4871, 5825, 2506, 2130, 4946, + 5412, 4507, 952, 4098, 5027, 3949, 3501, 1778, 1955, 2126, 1626, 3669, 4446, -1101, 736, -2708, + 4824, 7481, 8884, -2619, -2754, 281, 4158, 3251, 4602, 2946, 3915, 6169, 6075, 3495, 3266, 4375, + 6135, 2668, 6784, 10326, 6892, 5479, 1511, 3070, 6410, 9193, 6954, 1084, 2873, 7030, 8139, 5670, + 7255, 5764, 5122, 5787, 3129, 5475, -2720, 3770, -827, 872, 1591, 4645, 7218, 5513, 5778, 6323, + 1185, -13100, 5560, 5867, 4153, 2591, 4923, 3450, 2062, 4251, 4289, 3397, 3835, 2082, 2343, 3172, + 4460, 4411, 3940, 4420, 9410, -2789, -2525, -2877, -1868, 2850, 4490, 4093, 3162, 3889, 3800, 3492, + 6408, 8292, 8434, 8544, 8707, 9146, 9377, 9301, 9063, 8945, 8346, 8173, 7175, 7254, 6120, 7420, }; @@ -14504,7 +14504,7 @@ const Word16 select_table22[5][9] = {0, 0, 1, 3, 6, 10, 15, 21, 28}, {0, 0, 0, 1, 4, 10, 20, 35, 56}, {0, 0, 0, 0, 1, 5, 15, 35, 70} -}; // Q0 +}; // Q0 /* value of leader element */ const Word16 vals_a[36][4] = @@ -14514,7 +14514,7 @@ const Word16 vals_a[36][4] = {1,3,5}, {0,2,6}, {0,4}, {0,2,6}, {0,2,4,6}, {1,7}, {0,8}, {0,6}, {0,2,8}, {0,4,8}, {1,9}, {0,2,10}, {0,8}, {0,6,10}, {0,12}, {0,4,12}, {0,10}, {0,2,14}, {0,8,12}, {0,16} -}; // Q0 +}; // Q0 /* code parameter for every leader */ const Word16 vals_q[36][4] = @@ -14524,7 +14524,7 @@ const Word16 vals_q[36][4] = {7,3,2,1}, {2,3,2,1}, {3,2,3}, {4,3,4,1}, {3,4,3,2}, {7,2,1}, {1,2,1}, {2,2,2}, {3,3,3,1}, {2,3,2,1}, {7,2,1}, {2,3,2,1}, {2,2,2}, {2,3,2,1}, {1,2,1}, {2,3,2,1}, {2,2,2}, {2,3,2,1}, {2,3,2,1}, {1,2,1} -}; // Q0 +}; // Q0 /* codebook start address for every leader */ const UWord16 Is[36] = @@ -14532,13 +14532,13 @@ const UWord16 Is[36] = 0, 128, 256, 1376, 240, 0, 1792, 2400, 5376, 5632, 12800, 3744, 21760, 22784, 31744, 38912, 45632, 3856, 52800, 53248, 57728, 60416, 4080, 61440, 61552, 62896, 63120, 64144, 64368, 64480, 64704, 64720, 64944, 65056, 65280, 65504 -}; // Q0 +}; // Q0 /* A3 - Number of the absolute leaders in codebook Q3 */ const Word16 AA3[NB_LDQ3] = { 0, 1, 4, 2, 3, 7, 11, 17, 22 -}; // Q0 +}; // Q0 /* A4 - Number of the absolute leaders in codebook Q4 */ const Word16 AA4[NB_LDQ4] = @@ -14546,13 +14546,13 @@ const Word16 AA4[NB_LDQ4] = 5, 6, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 -}; // Q0 +}; // Q0 /* I3 - Cardinality offsets for absolute leaders in Q3 */ const UWord16 II3[NB_LDQ3] = { 0, 128, 240, 256, 1376, 2400, 3744, 3856, 4080 -}; // Q0 +}; // Q0 /* I4 - Cardinality offset for absolute leaders in Q4 */ const UWord16 II4[NB_LDQ4] = @@ -14560,21 +14560,21 @@ const UWord16 II4[NB_LDQ4] = 0, 1792, 5376, 5632, 12800, 21760, 22784, 31744, 38912, 45632, 52800, 53248, 57728, 60416, 61440, 61552, 62896, 63120, 64144, 64368, 64480, 64704, 64720, 64944, 65056, 65280, 65504 -}; // Q0 +}; // Q0 /* Position of the first absolute leader on a spherical shell (or sphere) */ const Word16 Da_pos[NB_SPHERE] = { 0, 2, 5, 8, 13, 18, 20, 22, 23, 25, 26, 27, 27, 28, 28, 28, 29, 30, 31, 31, 32, 32, 32, 32, 32, 34, 35, 35, 35, 35, 35, 35 -}; // Q0 +}; // Q0 /* Number of absolute leaders on a spherical shell */ const Word16 Da_nb[NB_SPHERE] = { 2, 3, 3, 5, 5, 2, 2, 1, 2, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1 -}; // Q0 +}; // Q0 /* Identification code of an absolute leader */ const Word16 Da_id[NB_LEADER] = @@ -14584,7 +14584,7 @@ const Word16 Da_id[NB_LEADER] = 0x0059, 0x00A4, 0x0060, 0x00A8, 0x00C4, 0x012D, 0x0200, 0x0144, 0x0204, 0x0220, 0x0335, 0x04E4, 0x0400, 0x0584, 0x0A20, 0x0A40, 0x09C4, 0x12C4, 0x0C20, 0x2000 -}; // Q0 +}; // Q0 /* Codebook number for each absolute leader */ const Word16 Da_nq[NB_LEADER+2] = @@ -14592,15 +14592,15 @@ const Word16 Da_nq[NB_LEADER+2] = 2, 2, 3, 3, 2, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 100 -}; // Q0 +}; // Q0 /*------------------------------------------------------------------------------* * SWB TBE tables *------------------------------------------------------------------------------*/ -const Word16 skip_bands_SWB_TBE[NUM_SHB_SUBFR+1] = {0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320}; /* bands for SWB TBE quantisation Q0*/ -const Word16 skip_bands_WB_TBE[NUM_SHB_SUBFR/2+1] = {0, 10, 20, 30, 40, 50, 60, 70, 80}; /* bands for WB TBE quantisation Q0*/ +const Word16 skip_bands_SWB_TBE[NUM_SHB_SUBFR+1] = {0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320}; /* bands for SWB TBE quantisation Q0*/ +const Word16 skip_bands_WB_TBE[NUM_SHB_SUBFR/2+1] = {0, 10, 20, 30, 40, 50, 60, 70, 80}; /* bands for WB TBE quantisation Q0*/ const Word16 interpol_frac_shb[NB_SUBFR * 2] = { @@ -14637,8 +14637,8 @@ const Word16 Hilbert_coeffs_fx[4 * NUM_HILBERTS][HILBERT_ORDER1 + 1] = /* Q14 */ const Word16 window_shb_fx[L_SHB_LAHEAD] = /*sin, 1, sin */ { /*Q15(round) */ - 1513, 4527, 7502, 10413, 13236, 15945, 18518, 20934, 23170, 25210, - 27034, 28627, 29976, 31069, 31898, 32454, 32733, 32767, 32767, 32767, + 1513, 4527, 7502, 10413, 13236, 15945, 18518, 20934, 23170, 25210, + 27034, 28627, 29976, 31069, 31898, 32454, 32733, 32767, 32767, 32767, }; /* Upsampled overlap add window for SHB excitation used transition generation */ @@ -14646,10 +14646,10 @@ const Word16 window_shb_fx[L_SHB_LAHEAD] = /*sin, 1, sin */ const Word16 window_shb_32k_fx[2 * L_SHB_LAHEAD] = { /*Q15(round) */ - 1513, 3020, 4527, 6015, 7502, 8958, 10413, 11825, 13236, 14590, - 15945, 17232, 18518, 19726, 20934, 22052, 23170, 24190, 25210, 26122, - 27034, 27830, 28627, 29301, 29976, 30523, 31069, 31483, 31898, 32176, - 32454, 32593, 32733, 32751, 32767, 32767, 32767, 32767, 32767, 32767, + 1513, 3020, 4527, 6015, 7502, 8958, 10413, 11825, 13236, 14590, + 15945, 17232, 18518, 19726, 20934, 22052, 23170, 24190, 25210, 26122, + 27034, 27830, 28627, 29301, 29976, 30523, 31069, 31483, 31898, 32176, + 32454, 32593, 32733, 32751, 32767, 32767, 32767, 32767, 32767, 32767, }; /* Short overlap add window for SHB excitation used in anal and synth */ @@ -14657,10 +14657,10 @@ const Word16 window_shb_32k_fx[2 * L_SHB_LAHEAD] = const Word16 subwin_shb_fx[SHB_OVERLAP_LEN + 1] = { /*Q15(round) */ - 0, 202, 802, 1786, 3129, - 4799, 6754, 8946, 11321, 13821, - 16384,18947, 21447, 23822, 26014, - 27969, 29639, 30982, 31966, 32566, + 0, 202, 802, 1786, 3129, + 4799, 6754, 8946, 11321, 13821, + 16384,18947, 21447, 23822, 26014, + 27969, 29639, 30982, 31966, 32566, 32767 }; @@ -14670,7 +14670,7 @@ const Word16 window_wb_fx[L_SHB_LAHEAD / 4] =/*sin, 1 */ /* Short overlap add window for SHB excitation used in anal and synth */ const Word16 subwin_wb_fx[SHB_OVERLAP_LEN / 2 + 1] = -{ 0, 5126, 10126, 14876, 19261, 23170, 26510, 29197, 31164, 32365, 32767 }; // Q15 +{ 0, 5126, 10126, 14876, 19261, 23170, 26510, 29197, 31164, 32365, 32767 }; // Q15 /* Window for calculating SHB LPC coeffs */ @@ -14719,21 +14719,21 @@ const Word16 win_lpc_hb_wb_fx[(L_LOOK_12k8 + L_SUBFR + L_FRAME) * 5 / 32] = const Word16 win_lpc_hb_wb_ivas_fx[(L_LOOK_12k8 + L_SUBFR + L_FRAME) * 5 / 32] = {//Q15 - 6, 51, 140, 274, - 453, 675, 940, 1247, - 1596, 1985, 2414, 2882, - 3386, 3926, 4499, 5106, - 5743, 6410, 7104, 7823, - 8566, 9331, 10114, 10915, - 11731, 12559, 13398, 14245, - 15099, 15955, 16813, 17669, - 18523, 19370, 20209, 21037, - 21853, 22654, 23437, 24202, - 24945, 25664, 26358, 27025, - 27662, 28269, 28842, 29382, - 29886, 30354, 30783, 31172, - 31521, 31828, 32093, 32315, - 32494, 32628, 32717, 32762 + 6, 51, 140, 274, + 453, 675, 940, 1247, + 1596, 1985, 2414, 2882, + 3386, 3926, 4499, 5106, + 5743, 6410, 7104, 7823, + 8566, 9331, 10114, 10915, + 11731, 12559, 13398, 14245, + 15099, 15955, 16813, 17669, + 18523, 19370, 20209, 21037, + 21853, 22654, 23437, 24202, + 24945, 25664, 26358, 27025, + 27662, 28269, 28842, 29382, + 29886, 30354, 30783, 31172, + 31521, 31828, 32093, 32315, + 32494, 32628, 32717, 32762 }; @@ -14755,291 +14755,291 @@ const Word16 ola_win_shb_switch_fold_fx[L_SUBFR16k] = const Word16 win_flatten_fx[L_FRAME16k / 2] = /*Q15 */ { - 3, 13, 28, 50, 78, 113, 154, 200, 254, 313, - 378, 450, 528, 611, 701, 797, 899, 1006, 1120, 1239, - 1365, 1496, 1632, 1775, 1923, 2076, 2235, 2400, 2569, 2745, - 2925, 3110, 3301, 3496, 3697, 3902, 4112, 4327, 4546, 4770, - 4999, 5232, 5469, 5710, 5955, 6205, 6458, 6715, 6976, 7240, - 7508, 7779, 8054, 8331, 8612, 8896, 9183, 9472, 9764, 10059, - 10356, 10655, 10956, 11260, 11566, 11873, 12182, 12493, 12805, 13119, - 13434, 13750, 14067, 14385, 14703, 15023, 15342, 15663, 15983, 16304, - 16625, 16945, 17265, 17586, 17905, 18224, 18542, 18860, 19176, 19492, - 19806, 20119, 20431, 20741, 21049, 21355, 21660, 21963, 22263, 22561, - 22857, 23150, 23441, 23729, 24014, 24297, 24576, 24852, 25125, 25395, - 25661, 25923, 26182, 26437, 26689, 26936, 27179, 27418, 27653, 27884, - 28110, 28332, 28549, 28761, 28969, 29172, 29370, 29563, 29751, 29934, - 30112, 30284, 30451, 30613, 30769, 30920, 31065, 31205, 31338, 31467, - 31589, 31705, 31816, 31921, 32020, 32113, 32199, 32280, 32355, 32423, - 32486, 32542, 32592, 32636, 32673, 32704, 32730, 32748, 32761, 32767 + 3, 13, 28, 50, 78, 113, 154, 200, 254, 313, + 378, 450, 528, 611, 701, 797, 899, 1006, 1120, 1239, + 1365, 1496, 1632, 1775, 1923, 2076, 2235, 2400, 2569, 2745, + 2925, 3110, 3301, 3496, 3697, 3902, 4112, 4327, 4546, 4770, + 4999, 5232, 5469, 5710, 5955, 6205, 6458, 6715, 6976, 7240, + 7508, 7779, 8054, 8331, 8612, 8896, 9183, 9472, 9764, 10059, + 10356, 10655, 10956, 11260, 11566, 11873, 12182, 12493, 12805, 13119, + 13434, 13750, 14067, 14385, 14703, 15023, 15342, 15663, 15983, 16304, + 16625, 16945, 17265, 17586, 17905, 18224, 18542, 18860, 19176, 19492, + 19806, 20119, 20431, 20741, 21049, 21355, 21660, 21963, 22263, 22561, + 22857, 23150, 23441, 23729, 24014, 24297, 24576, 24852, 25125, 25395, + 25661, 25923, 26182, 26437, 26689, 26936, 27179, 27418, 27653, 27884, + 28110, 28332, 28549, 28761, 28969, 29172, 29370, 29563, 29751, 29934, + 30112, 30284, 30451, 30613, 30769, 30920, 31065, 31205, 31338, 31467, + 31589, 31705, 31816, 31921, 32020, 32113, 32199, 32280, 32355, 32423, + 32486, 32542, 32592, 32636, 32673, 32704, 32730, 32748, 32761, 32767 }; const Word16 win_flatten_4k_fx[L_FRAME16k / 8] = /*Q15 */ { - 13, 114, 315, 615, 1013, 1505, 2089, 2761, - 3517, 4353, 5263, 6241, 7282, 8378, 9525, 10713, - 11937, 13188, 14458, 15741, 17027, 18310, 19580, 20831, - 22055, 23243, 24390, 25486, 26527, 27505, 28415, 29251, - 30007, 30679, 31263, 31755, 32153, 32453, 32654, 32755 + 13, 114, 315, 615, 1013, 1505, 2089, 2761, + 3517, 4353, 5263, 6241, 7282, 8378, 9525, 10713, + 11937, 13188, 14458, 15741, 17027, 18310, 19580, 20831, + 22055, 23243, 24390, 25486, 26527, 27505, 28415, 29251, + 30007, 30679, 31263, 31755, 32153, 32453, 32654, 32755 }; const Word16 wb_bwe_lsfvq_cbook_8bit_fx[256 * 6] = {//Q15 - 2107, 3430, 5123, 6677, 9403, 13197, - 4031, 5069, 7343, 8910, 10647, 12245, - 2037, 3542, 6708, 8763, 10505, 12655, - 5732, 6373, 7912, 9546, 12584, 14230, - 2028, 3337, 5473, 7880, 10269, 12450, - 5809, 6497, 8317, 9624, 11497, 14007, - 2428, 3962, 5675, 7724, 11361, 13385, - 6348, 8307, 8898, 9948, 11058, 13350, - 3552, 4421, 5896, 7143, 9975, 13233, - 5719, 6344, 7482, 8403, 10765, 13455, - 3509, 4379, 5896, 7437, 11765, 14307, - 4521, 8122, 8791, 9856, 11232, 14020, - 2175, 3970, 7788, 9803, 11334, 12910, - 4511, 8156, 8886, 10450, 12686, 14959, - 4223, 5285, 7053, 8423, 11317, 14566, - 7159, 8379, 9040, 10122, 11799, 14270, - 1866, 3064, 4848, 7227, 11225, 13963, - 5915, 6631, 8740, 10002, 11385, 12726, - 3342, 4547, 6475, 9404, 11994, 13418, - 6156, 6880, 8932, 10353, 12380, 13746, - 2648, 4972, 7575, 9476, 12117, 13875, - 5822, 6526, 8747, 10941, 12671, 13971, - 4032, 5110, 7592, 9267, 11374, 14390, - 6864, 8384, 9086, 10649, 12944, 15026, - 3661, 4636, 6668, 8329, 10374, 12185, - 5802, 6444, 8344, 9811, 12234, 14843, - 3593, 4436, 6663, 8693, 11539, 14272, - 5110, 8270, 9006, 10703, 12269, 13901, - 1992, 3229, 5616, 9085, 11419, 13254, - 4319, 5859, 9602, 11396, 12836, 14199, - 3836, 4822, 8285, 10190, 11728, 13302, - 8016, 8698, 10179, 11434, 12944, 14783, - 1891, 3329, 6168, 8307, 10818, 14213, - 5803, 6442, 7973, 9131, 11090, 12657, - 2803, 5499, 8093, 9694, 11223, 12849, - 6222, 6981, 8615, 9848, 12016, 13380, - 2543, 4747, 7638, 9373, 11129, 13652, - 5912, 6615, 9006, 10553, 11959, 13312, - 3604, 4520, 7650, 9833, 12161, 14748, - 7970, 8729, 9780, 10789, 12483, 13985, - 3793, 4716, 7041, 8547, 10610, 13601, - 5640, 6235, 7313, 8370, 12057, 14300, - 3765, 4699, 6784, 9512, 12663, 14216, - 4634, 8363, 9195, 10385, 11477, 13310, - 2462, 4816, 8556, 10394, 11920, 13468, - 3698, 7974, 9207, 10962, 13507, 15208, - 3738, 4667, 7545, 10775, 13024, 14559, - 7267, 8610, 9509, 11264, 12821, 14495, - 2624, 4295, 6173, 8897, 12343, 14174, - 6324, 7135, 8742, 10013, 12598, 14108, - 4448, 5839, 8842, 10335, 11737, 13071, - 6147, 6988, 9510, 10893, 12240, 13535, - 3025, 5140, 7152, 9223, 11404, 13255, - 5985, 6782, 9611, 11341, 12723, 14007, - 4679, 5958, 8100, 9842, 11835, 13492, - 7740, 8565, 9432, 10478, 12611, 14609, - 3830, 4784, 7681, 9528, 11134, 12675, - 5742, 6527, 8359, 10728, 13195, 14626, - 4491, 5635, 7284, 8749, 11594, 13785, - 6772, 8490, 9253, 10943, 12476, 13973, - 2024, 3588, 7524, 10453, 12198, 13858, - 5783, 8882, 9978, 11763, 13237, 14829, - 3979, 5009, 8342, 10323, 12231, 14313, - 8148, 8903, 10193, 11350, 13246, 14490, - 2297, 3810, 5638, 7265, 9162, 11514, - 5809, 6518, 7832, 8766, 10327, 11957, - 2535, 4591, 7415, 9080, 10623, 12257, - 5948, 6598, 8515, 10082, 12721, 14188, - 2443, 4278, 6581, 8172, 9883, 11807, - 5913, 6535, 8878, 10296, 12141, 14245, - 2428, 3925, 6409, 9835, 11962, 13628, - 7430, 8531, 9302, 10259, 11444, 12933, - 3701, 4694, 6372, 7671, 9445, 11571, - 5822, 6470, 7807, 8885, 11506, 14529, - 3742, 4580, 6232, 7860, 11252, 13127, - 5710, 8330, 8943, 10243, 11696, 14511, - 2607, 4197, 6714, 10408, 12714, 14320, - 4116, 8438, 9717, 11018, 12156, 13663, - 4224, 5318, 7486, 10110, 12779, 14331, - 5565, 8413, 9115, 10930, 12588, 14759, - 1898, 3150, 5779, 9497, 12432, 14439, - 6274, 7186, 9258, 10404, 11733, 12952, - 3700, 4591, 7575, 9533, 11461, 13777, - 6234, 7104, 9032, 10986, 13088, 14417, - 2354, 4579, 7744, 9960, 12629, 14802, - 6050, 6729, 9345, 10745, 12436, 14253, - 4345, 5529, 8117, 9718, 12433, 14109, - 8009, 8701, 9863, 10954, 13046, 14474, - 4184, 5186, 6876, 8428, 11236, 12973, - 6113, 6842, 8386, 9659, 12892, 14707, - 3989, 4936, 7152, 8879, 11743, 13632, - 5169, 8411, 9209, 11361, 13452, 15076, - 2397, 4387, 7033, 9035, 11821, 13736, - 3607, 8128, 10170, 11565, 12819, 14147, - 4449, 5805, 8963, 10676, 12596, 14558, - 7911, 8741, 10040, 11622, 13579, 15092, - 2372, 4290, 6990, 8705, 10637, 13685, - 6137, 6917, 8382, 9380, 10859, 12348, - 3235, 5973, 8187, 10174, 12420, 14382, - 6077, 6764, 8551, 9803, 12150, 14079, - 2952, 5097, 6853, 8952, 12066, 14080, - 6606, 7683, 9508, 10695, 12182, 13601, - 3707, 4638, 7468, 10484, 12295, 13754, - 7960, 8715, 10051, 11348, 12757, 14072, - 4139, 5241, 7576, 9037, 10912, 13485, - 5838, 6444, 7768, 8965, 12867, 14998, - 4245, 5338, 7248, 9190, 12328, 14047, - 6159, 8874, 9899, 11134, 12150, 13512, - 2250, 4288, 8698, 10944, 12624, 14316, - 3146, 6848, 9904, 11775, 13534, 14953, - 4044, 5161, 8365, 10294, 12945, 14907, - 7398, 8724, 9813, 11821, 13246, 14552, - 2121, 3890, 6855, 9274, 12059, 14663, - 6329, 7182, 8789, 10081, 13001, 14917, - 4484, 5761, 8634, 10295, 12111, 14022, - 6326, 7208, 9672, 11078, 12830, 14529, - 3230, 5564, 7646, 9955, 12011, 13683, - 4683, 6896, 10002, 11805, 13329, 14747, - 4771, 6044, 8081, 10305, 12526, 14037, - 8231, 9203, 10351, 11427, 12926, 14635, - 4385, 5774, 7989, 9305, 10751, 12299, - 5810, 6658, 9062, 11629, 13359, 14655, - 4288, 5388, 7804, 9378, 11781, 13652, - 4398, 8560, 9646, 11161, 12701, 14872, - 1947, 3440, 7202, 10953, 13222, 14806, - 4686, 8972, 10615, 12054, 13260, 14615, - 3801, 4849, 8922, 11200, 12882, 14423, - 8061, 8813, 10453, 11912, 13335, 14710, - 2365, 3888, 5664, 7346, 10407, 14331, - 4563, 5839, 7472, 8684, 10572, 12800, - 2593, 4197, 6719, 9323, 11229, 12919, - 6081, 6774, 8132, 9244, 12202, 13918, - 2405, 3981, 6144, 8740, 11347, 13796, - 5793, 6444, 8286, 10049, 12152, 13520, - 2795, 4727, 6528, 8506, 11323, 13474, - 6181, 8598, 9346, 10614, 11725, 13545, - 4002, 5001, 6596, 7792, 9987, 13065, - 5748, 6365, 7759, 9028, 11818, 13487, - 3906, 4863, 6462, 7763, 10705, 14359, - 4315, 8428, 9322, 10582, 11942, 14500, - 2812, 4622, 7346, 10036, 11745, 13429, - 4221, 8338, 9277, 11280, 12869, 14317, - 4345, 5427, 7121, 8736, 12787, 14837, - 7678, 8614, 9456, 10461, 12024, 13852, - 2193, 3662, 5609, 7867, 12276, 14739, - 6083, 6864, 8879, 10080, 11623, 13720, - 4114, 5125, 7224, 9729, 11808, 13297, - 6383, 7232, 9252, 10720, 12622, 14030, - 2788, 5189, 8074, 9953, 11795, 14361, - 6079, 6987, 8662, 10589, 12444, 14390, - 4480, 5690, 7708, 9115, 11800, 14576, - 7848, 8763, 9802, 10924, 12515, 14832, - 3582, 4575, 6729, 9084, 11139, 12800, - 5885, 6534, 8853, 10432, 12664, 14960, - 3891, 4850, 7195, 8932, 12097, 14665, - 5797, 8545, 9385, 11556, 12997, 14392, - 1962, 3544, 7039, 9349, 11272, 13857, - 4106, 5493, 9652, 12038, 13603, 14932, - 4328, 5413, 7949, 10282, 12164, 13618, - 8135, 8918, 10057, 11085, 13190, 15015, - 2702, 4627, 6447, 8009, 10197, 13676, - 5998, 6656, 8315, 9496, 11597, 13122, - 3146, 6293, 8530, 10158, 11798, 13558, - 6374, 7289, 8698, 9776, 11885, 14236, - 3171, 5794, 7737, 9377, 11312, 13878, - 6279, 7150, 9192, 10414, 12052, 14174, - 4117, 5195, 7805, 9512, 12450, 14849, - 7963, 8955, 10071, 11129, 12324, 13605, - 4365, 5505, 7013, 8171, 10488, 13658, - 6124, 6894, 8286, 9349, 11859, 14737, - 3753, 4673, 6421, 8146, 12726, 14980, - 5457, 8706, 9598, 11035, 12294, 14268, - 2783, 4916, 7947, 10568, 12395, 14123, - 3909, 8145, 9524, 11951, 14052, 15282, - 3952, 5139, 8180, 11380, 13699, 15085, - 7200, 9031, 10025, 11484, 12924, 14848, - 2533, 4412, 6472, 8299, 11405, 14627, - 6563, 7530, 9064, 10267, 12560, 14422, - 4849, 6618, 8678, 10166, 11983, 13841, - 6393, 7569, 9960, 11300, 12644, 13906, - 3170, 5117, 7158, 9665, 11687, 14114, - 6122, 7071, 10013, 11733, 13170, 14466, - 4308, 5441, 7607, 9900, 11904, 14292, - 8129, 9024, 10087, 11081, 12670, 14356, - 4253, 5392, 8175, 9780, 11353, 12988, - 5453, 6638, 8596, 11453, 13885, 15263, - 4664, 5903, 7618, 9420, 12198, 13853, - 7149, 8859, 9746, 11029, 12219, 14188, - 2318, 4251, 7702, 9889, 11778, 14182, - 6679, 9280, 10573, 11950, 13100, 14491, - 4010, 5176, 8989, 10821, 12250, 13654, - 8076, 8886, 10411, 11722, 12992, 14267, - 2308, 4017, 6024, 7618, 9736, 13081, - 6001, 6751, 7987, 8966, 10964, 13589, - 2908, 5350, 7266, 8739, 10442, 12981, - 6143, 6839, 9027, 10366, 12881, 14416, - 2667, 4224, 6172, 8378, 10717, 12602, - 6275, 7120, 9249, 10613, 12580, 14823, - 2692, 4586, 6968, 9858, 12120, 14209, - 7771, 8769, 9743, 10745, 11943, 13225, - 4201, 5355, 7129, 8337, 9975, 11767, - 6216, 7100, 8444, 9442, 11298, 13690, - 4111, 5040, 6562, 8071, 12034, 13923, - 6657, 8599, 9337, 10665, 12040, 14704, - 3060, 5215, 7260, 10118, 12577, 14386, - 5103, 8913, 10157, 11519, 12669, 14220, - 4633, 5920, 7804, 9514, 12741, 14690, - 6720, 8585, 9448, 11556, 13510, 15095, - 2361, 3970, 6213, 9335, 13270, 15075, - 6506, 7440, 9041, 10179, 12024, 13587, - 4221, 5405, 8311, 9818, 11579, 14044, - 6216, 7224, 9515, 11389, 13545, 15068, - 2872, 5507, 8153, 10650, 13065, 14825, - 6002, 6676, 9393, 11023, 12965, 14755, - 4438, 5642, 8268, 10097, 12295, 14724, - 7797, 8622, 9642, 10932, 13287, 15118, - 4471, 5638, 7551, 9217, 11440, 12928, - 6051, 6890, 8906, 10655, 13437, 15116, - 3953, 4934, 7779, 9619, 12204, 14012, - 5439, 8649, 9791, 12232, 13899, 15193, - 2728, 4495, 6728, 9363, 11344, 14053, - 4069, 8460, 9835, 11742, 13366, 14825, - 4874, 6937, 9226, 10944, 12845, 14547, - 8195, 9093, 10392, 11594, 13355, 15010, - 2956, 5192, 7080, 8765, 11014, 14174, - 6384, 7287, 8812, 9816, 11336, 12808, - 2912, 6122, 9132, 10874, 12583, 14265, - 6148, 6925, 8821, 10030, 12212, 14758, - 2572, 4778, 7325, 9216, 11620, 14651, - 6654, 7718, 9546, 10806, 12633, 14354, - 4328, 5514, 8231, 10852, 12821, 14261, - 8051, 9205, 10385, 11490, 12674, 13988, - 4624, 6013, 7907, 9239, 11160, 13787, - 5786, 6531, 8210, 9968, 13410, 15249, - 3859, 4898, 7132, 9692, 13395, 15118, - 6712, 8944, 10028, 11521, 12690, 14118, - 2417, 4875, 9132, 11671, 13382, 14841, - 4113, 8355, 10734, 12517, 13905, 15115, - 4455, 5753, 7923, 10298, 13343, 15030, - 6998, 8878, 10113, 12233, 13768, 15107, - 2720, 4801, 6883, 9267, 12694, 14837, - 6507, 7496, 9312, 10696, 13185, 14850, - 4631, 6341, 9164, 10796, 12325, 13734, - 6602, 7817, 9932, 11349, 13132, 14672, - 3089, 5561, 7579, 9433, 12256, 14633, - 6246, 7715, 10371, 12065, 13563, 14878, - 4757, 6352, 8543, 10216, 12748, 14620, - 8183, 9366, 10628, 11857, 13185, 14599, - 4734, 6314, 8348, 9716, 11274, 12942, - 5824, 6871, 9829, 12268, 13874, 15138, - 4719, 6142, 8224, 9683, 11915, 14350, - 6288, 8774, 9655, 11204, 12696, 14867, - 2661, 4586, 7326, 10934, 13501, 15026, - 5932, 9323, 10877, 12454, 13715, 15004, - 4467, 6039, 8842, 11164, 13356, 14901, - 7880, 9158, 10593, 12209, 13609, 14989, + 2107, 3430, 5123, 6677, 9403, 13197, + 4031, 5069, 7343, 8910, 10647, 12245, + 2037, 3542, 6708, 8763, 10505, 12655, + 5732, 6373, 7912, 9546, 12584, 14230, + 2028, 3337, 5473, 7880, 10269, 12450, + 5809, 6497, 8317, 9624, 11497, 14007, + 2428, 3962, 5675, 7724, 11361, 13385, + 6348, 8307, 8898, 9948, 11058, 13350, + 3552, 4421, 5896, 7143, 9975, 13233, + 5719, 6344, 7482, 8403, 10765, 13455, + 3509, 4379, 5896, 7437, 11765, 14307, + 4521, 8122, 8791, 9856, 11232, 14020, + 2175, 3970, 7788, 9803, 11334, 12910, + 4511, 8156, 8886, 10450, 12686, 14959, + 4223, 5285, 7053, 8423, 11317, 14566, + 7159, 8379, 9040, 10122, 11799, 14270, + 1866, 3064, 4848, 7227, 11225, 13963, + 5915, 6631, 8740, 10002, 11385, 12726, + 3342, 4547, 6475, 9404, 11994, 13418, + 6156, 6880, 8932, 10353, 12380, 13746, + 2648, 4972, 7575, 9476, 12117, 13875, + 5822, 6526, 8747, 10941, 12671, 13971, + 4032, 5110, 7592, 9267, 11374, 14390, + 6864, 8384, 9086, 10649, 12944, 15026, + 3661, 4636, 6668, 8329, 10374, 12185, + 5802, 6444, 8344, 9811, 12234, 14843, + 3593, 4436, 6663, 8693, 11539, 14272, + 5110, 8270, 9006, 10703, 12269, 13901, + 1992, 3229, 5616, 9085, 11419, 13254, + 4319, 5859, 9602, 11396, 12836, 14199, + 3836, 4822, 8285, 10190, 11728, 13302, + 8016, 8698, 10179, 11434, 12944, 14783, + 1891, 3329, 6168, 8307, 10818, 14213, + 5803, 6442, 7973, 9131, 11090, 12657, + 2803, 5499, 8093, 9694, 11223, 12849, + 6222, 6981, 8615, 9848, 12016, 13380, + 2543, 4747, 7638, 9373, 11129, 13652, + 5912, 6615, 9006, 10553, 11959, 13312, + 3604, 4520, 7650, 9833, 12161, 14748, + 7970, 8729, 9780, 10789, 12483, 13985, + 3793, 4716, 7041, 8547, 10610, 13601, + 5640, 6235, 7313, 8370, 12057, 14300, + 3765, 4699, 6784, 9512, 12663, 14216, + 4634, 8363, 9195, 10385, 11477, 13310, + 2462, 4816, 8556, 10394, 11920, 13468, + 3698, 7974, 9207, 10962, 13507, 15208, + 3738, 4667, 7545, 10775, 13024, 14559, + 7267, 8610, 9509, 11264, 12821, 14495, + 2624, 4295, 6173, 8897, 12343, 14174, + 6324, 7135, 8742, 10013, 12598, 14108, + 4448, 5839, 8842, 10335, 11737, 13071, + 6147, 6988, 9510, 10893, 12240, 13535, + 3025, 5140, 7152, 9223, 11404, 13255, + 5985, 6782, 9611, 11341, 12723, 14007, + 4679, 5958, 8100, 9842, 11835, 13492, + 7740, 8565, 9432, 10478, 12611, 14609, + 3830, 4784, 7681, 9528, 11134, 12675, + 5742, 6527, 8359, 10728, 13195, 14626, + 4491, 5635, 7284, 8749, 11594, 13785, + 6772, 8490, 9253, 10943, 12476, 13973, + 2024, 3588, 7524, 10453, 12198, 13858, + 5783, 8882, 9978, 11763, 13237, 14829, + 3979, 5009, 8342, 10323, 12231, 14313, + 8148, 8903, 10193, 11350, 13246, 14490, + 2297, 3810, 5638, 7265, 9162, 11514, + 5809, 6518, 7832, 8766, 10327, 11957, + 2535, 4591, 7415, 9080, 10623, 12257, + 5948, 6598, 8515, 10082, 12721, 14188, + 2443, 4278, 6581, 8172, 9883, 11807, + 5913, 6535, 8878, 10296, 12141, 14245, + 2428, 3925, 6409, 9835, 11962, 13628, + 7430, 8531, 9302, 10259, 11444, 12933, + 3701, 4694, 6372, 7671, 9445, 11571, + 5822, 6470, 7807, 8885, 11506, 14529, + 3742, 4580, 6232, 7860, 11252, 13127, + 5710, 8330, 8943, 10243, 11696, 14511, + 2607, 4197, 6714, 10408, 12714, 14320, + 4116, 8438, 9717, 11018, 12156, 13663, + 4224, 5318, 7486, 10110, 12779, 14331, + 5565, 8413, 9115, 10930, 12588, 14759, + 1898, 3150, 5779, 9497, 12432, 14439, + 6274, 7186, 9258, 10404, 11733, 12952, + 3700, 4591, 7575, 9533, 11461, 13777, + 6234, 7104, 9032, 10986, 13088, 14417, + 2354, 4579, 7744, 9960, 12629, 14802, + 6050, 6729, 9345, 10745, 12436, 14253, + 4345, 5529, 8117, 9718, 12433, 14109, + 8009, 8701, 9863, 10954, 13046, 14474, + 4184, 5186, 6876, 8428, 11236, 12973, + 6113, 6842, 8386, 9659, 12892, 14707, + 3989, 4936, 7152, 8879, 11743, 13632, + 5169, 8411, 9209, 11361, 13452, 15076, + 2397, 4387, 7033, 9035, 11821, 13736, + 3607, 8128, 10170, 11565, 12819, 14147, + 4449, 5805, 8963, 10676, 12596, 14558, + 7911, 8741, 10040, 11622, 13579, 15092, + 2372, 4290, 6990, 8705, 10637, 13685, + 6137, 6917, 8382, 9380, 10859, 12348, + 3235, 5973, 8187, 10174, 12420, 14382, + 6077, 6764, 8551, 9803, 12150, 14079, + 2952, 5097, 6853, 8952, 12066, 14080, + 6606, 7683, 9508, 10695, 12182, 13601, + 3707, 4638, 7468, 10484, 12295, 13754, + 7960, 8715, 10051, 11348, 12757, 14072, + 4139, 5241, 7576, 9037, 10912, 13485, + 5838, 6444, 7768, 8965, 12867, 14998, + 4245, 5338, 7248, 9190, 12328, 14047, + 6159, 8874, 9899, 11134, 12150, 13512, + 2250, 4288, 8698, 10944, 12624, 14316, + 3146, 6848, 9904, 11775, 13534, 14953, + 4044, 5161, 8365, 10294, 12945, 14907, + 7398, 8724, 9813, 11821, 13246, 14552, + 2121, 3890, 6855, 9274, 12059, 14663, + 6329, 7182, 8789, 10081, 13001, 14917, + 4484, 5761, 8634, 10295, 12111, 14022, + 6326, 7208, 9672, 11078, 12830, 14529, + 3230, 5564, 7646, 9955, 12011, 13683, + 4683, 6896, 10002, 11805, 13329, 14747, + 4771, 6044, 8081, 10305, 12526, 14037, + 8231, 9203, 10351, 11427, 12926, 14635, + 4385, 5774, 7989, 9305, 10751, 12299, + 5810, 6658, 9062, 11629, 13359, 14655, + 4288, 5388, 7804, 9378, 11781, 13652, + 4398, 8560, 9646, 11161, 12701, 14872, + 1947, 3440, 7202, 10953, 13222, 14806, + 4686, 8972, 10615, 12054, 13260, 14615, + 3801, 4849, 8922, 11200, 12882, 14423, + 8061, 8813, 10453, 11912, 13335, 14710, + 2365, 3888, 5664, 7346, 10407, 14331, + 4563, 5839, 7472, 8684, 10572, 12800, + 2593, 4197, 6719, 9323, 11229, 12919, + 6081, 6774, 8132, 9244, 12202, 13918, + 2405, 3981, 6144, 8740, 11347, 13796, + 5793, 6444, 8286, 10049, 12152, 13520, + 2795, 4727, 6528, 8506, 11323, 13474, + 6181, 8598, 9346, 10614, 11725, 13545, + 4002, 5001, 6596, 7792, 9987, 13065, + 5748, 6365, 7759, 9028, 11818, 13487, + 3906, 4863, 6462, 7763, 10705, 14359, + 4315, 8428, 9322, 10582, 11942, 14500, + 2812, 4622, 7346, 10036, 11745, 13429, + 4221, 8338, 9277, 11280, 12869, 14317, + 4345, 5427, 7121, 8736, 12787, 14837, + 7678, 8614, 9456, 10461, 12024, 13852, + 2193, 3662, 5609, 7867, 12276, 14739, + 6083, 6864, 8879, 10080, 11623, 13720, + 4114, 5125, 7224, 9729, 11808, 13297, + 6383, 7232, 9252, 10720, 12622, 14030, + 2788, 5189, 8074, 9953, 11795, 14361, + 6079, 6987, 8662, 10589, 12444, 14390, + 4480, 5690, 7708, 9115, 11800, 14576, + 7848, 8763, 9802, 10924, 12515, 14832, + 3582, 4575, 6729, 9084, 11139, 12800, + 5885, 6534, 8853, 10432, 12664, 14960, + 3891, 4850, 7195, 8932, 12097, 14665, + 5797, 8545, 9385, 11556, 12997, 14392, + 1962, 3544, 7039, 9349, 11272, 13857, + 4106, 5493, 9652, 12038, 13603, 14932, + 4328, 5413, 7949, 10282, 12164, 13618, + 8135, 8918, 10057, 11085, 13190, 15015, + 2702, 4627, 6447, 8009, 10197, 13676, + 5998, 6656, 8315, 9496, 11597, 13122, + 3146, 6293, 8530, 10158, 11798, 13558, + 6374, 7289, 8698, 9776, 11885, 14236, + 3171, 5794, 7737, 9377, 11312, 13878, + 6279, 7150, 9192, 10414, 12052, 14174, + 4117, 5195, 7805, 9512, 12450, 14849, + 7963, 8955, 10071, 11129, 12324, 13605, + 4365, 5505, 7013, 8171, 10488, 13658, + 6124, 6894, 8286, 9349, 11859, 14737, + 3753, 4673, 6421, 8146, 12726, 14980, + 5457, 8706, 9598, 11035, 12294, 14268, + 2783, 4916, 7947, 10568, 12395, 14123, + 3909, 8145, 9524, 11951, 14052, 15282, + 3952, 5139, 8180, 11380, 13699, 15085, + 7200, 9031, 10025, 11484, 12924, 14848, + 2533, 4412, 6472, 8299, 11405, 14627, + 6563, 7530, 9064, 10267, 12560, 14422, + 4849, 6618, 8678, 10166, 11983, 13841, + 6393, 7569, 9960, 11300, 12644, 13906, + 3170, 5117, 7158, 9665, 11687, 14114, + 6122, 7071, 10013, 11733, 13170, 14466, + 4308, 5441, 7607, 9900, 11904, 14292, + 8129, 9024, 10087, 11081, 12670, 14356, + 4253, 5392, 8175, 9780, 11353, 12988, + 5453, 6638, 8596, 11453, 13885, 15263, + 4664, 5903, 7618, 9420, 12198, 13853, + 7149, 8859, 9746, 11029, 12219, 14188, + 2318, 4251, 7702, 9889, 11778, 14182, + 6679, 9280, 10573, 11950, 13100, 14491, + 4010, 5176, 8989, 10821, 12250, 13654, + 8076, 8886, 10411, 11722, 12992, 14267, + 2308, 4017, 6024, 7618, 9736, 13081, + 6001, 6751, 7987, 8966, 10964, 13589, + 2908, 5350, 7266, 8739, 10442, 12981, + 6143, 6839, 9027, 10366, 12881, 14416, + 2667, 4224, 6172, 8378, 10717, 12602, + 6275, 7120, 9249, 10613, 12580, 14823, + 2692, 4586, 6968, 9858, 12120, 14209, + 7771, 8769, 9743, 10745, 11943, 13225, + 4201, 5355, 7129, 8337, 9975, 11767, + 6216, 7100, 8444, 9442, 11298, 13690, + 4111, 5040, 6562, 8071, 12034, 13923, + 6657, 8599, 9337, 10665, 12040, 14704, + 3060, 5215, 7260, 10118, 12577, 14386, + 5103, 8913, 10157, 11519, 12669, 14220, + 4633, 5920, 7804, 9514, 12741, 14690, + 6720, 8585, 9448, 11556, 13510, 15095, + 2361, 3970, 6213, 9335, 13270, 15075, + 6506, 7440, 9041, 10179, 12024, 13587, + 4221, 5405, 8311, 9818, 11579, 14044, + 6216, 7224, 9515, 11389, 13545, 15068, + 2872, 5507, 8153, 10650, 13065, 14825, + 6002, 6676, 9393, 11023, 12965, 14755, + 4438, 5642, 8268, 10097, 12295, 14724, + 7797, 8622, 9642, 10932, 13287, 15118, + 4471, 5638, 7551, 9217, 11440, 12928, + 6051, 6890, 8906, 10655, 13437, 15116, + 3953, 4934, 7779, 9619, 12204, 14012, + 5439, 8649, 9791, 12232, 13899, 15193, + 2728, 4495, 6728, 9363, 11344, 14053, + 4069, 8460, 9835, 11742, 13366, 14825, + 4874, 6937, 9226, 10944, 12845, 14547, + 8195, 9093, 10392, 11594, 13355, 15010, + 2956, 5192, 7080, 8765, 11014, 14174, + 6384, 7287, 8812, 9816, 11336, 12808, + 2912, 6122, 9132, 10874, 12583, 14265, + 6148, 6925, 8821, 10030, 12212, 14758, + 2572, 4778, 7325, 9216, 11620, 14651, + 6654, 7718, 9546, 10806, 12633, 14354, + 4328, 5514, 8231, 10852, 12821, 14261, + 8051, 9205, 10385, 11490, 12674, 13988, + 4624, 6013, 7907, 9239, 11160, 13787, + 5786, 6531, 8210, 9968, 13410, 15249, + 3859, 4898, 7132, 9692, 13395, 15118, + 6712, 8944, 10028, 11521, 12690, 14118, + 2417, 4875, 9132, 11671, 13382, 14841, + 4113, 8355, 10734, 12517, 13905, 15115, + 4455, 5753, 7923, 10298, 13343, 15030, + 6998, 8878, 10113, 12233, 13768, 15107, + 2720, 4801, 6883, 9267, 12694, 14837, + 6507, 7496, 9312, 10696, 13185, 14850, + 4631, 6341, 9164, 10796, 12325, 13734, + 6602, 7817, 9932, 11349, 13132, 14672, + 3089, 5561, 7579, 9433, 12256, 14633, + 6246, 7715, 10371, 12065, 13563, 14878, + 4757, 6352, 8543, 10216, 12748, 14620, + 8183, 9366, 10628, 11857, 13185, 14599, + 4734, 6314, 8348, 9716, 11274, 12942, + 5824, 6871, 9829, 12268, 13874, 15138, + 4719, 6142, 8224, 9683, 11915, 14350, + 6288, 8774, 9655, 11204, 12696, 14867, + 2661, 4586, 7326, 10934, 13501, 15026, + 5932, 9323, 10877, 12454, 13715, 15004, + 4467, 6039, 8842, 11164, 13356, 14901, + 7880, 9158, 10593, 12209, 13609, 14989, }; const Word16 swb_tbe_lsfvq_cbook_8b[256 * LPC_SHB_ORDER] = /* Q15 */ @@ -15362,68 +15362,68 @@ const Word16 wac_swb_ivas_l[LPC_SHB_ORDER] = const Word16 lbr_wb_bwe_lsfvq_cbook_2bit_fx[4 * 4] = { /*Q15 */ - 3876, 5920, 8951, 11884, - 6556, 7979, 10835, 13133, - 4401, 6781, 10676, 13493, - 8453, 9693, 12024, 13921, + 3876, 5920, 8951, 11884, + 6556, 7979, 10835, 13133, + 4401, 6781, 10676, 13493, + 8453, 9693, 12024, 13921, }; const Word16 SHBCB_SubGain5bit_fx[128] = { /*Q14 */ - -2388, -7806, -6576, -6024, - -7066, -5430, -4998, -3495, - -16722, -15343, -960, -7940, - -26291, -5921, -4917, -4378, - -1526, -6621, -8475, -9624, - -8047, -4086, -8940, -3043, - -3630, -5129, -4964, -7381, - -270, -18662, -24233, -25418, - -9246, -7551, -5584, -2053, - -2091, -4622, -9199, -14628, - -4645, -2197, -10255, -9697, - -2438, -9386, -11737, -4570, - -14366, -11436, -8252, -819, - -16192, -16332, -17043, -225, - -5407, -8588, -7577, -2296, - -26309, -21930, -7522, -2514, - -3260, -4246, -7947, -6614, - -1820, -5520, -15272, -19764, - -3706, -3737, -5850, -10520, - -10081, -4050, -4065, -5001, - -3908, -9909, -2881, -9604, - -520, -11156, -12620, -12768, - -4539, -5149, -6208, -4462, - -4866, -7672, -4235, -4407, - -9163, -13411, -2975, -3915, - -12267, -7568, -3842, -2827, - -7181, -4914, -2608, -9392, - -6275, -2868, -5962, -6511, - -12962, -1034, -8517, -10992, - -8247, -7608, -2502, -5026, - -5812, -4998, -3860, -5778, - -16907, -5974, -4434, -3276, + -2388, -7806, -6576, -6024, + -7066, -5430, -4998, -3495, + -16722, -15343, -960, -7940, + -26291, -5921, -4917, -4378, + -1526, -6621, -8475, -9624, + -8047, -4086, -8940, -3043, + -3630, -5129, -4964, -7381, + -270, -18662, -24233, -25418, + -9246, -7551, -5584, -2053, + -2091, -4622, -9199, -14628, + -4645, -2197, -10255, -9697, + -2438, -9386, -11737, -4570, + -14366, -11436, -8252, -819, + -16192, -16332, -17043, -225, + -5407, -8588, -7577, -2296, + -26309, -21930, -7522, -2514, + -3260, -4246, -7947, -6614, + -1820, -5520, -15272, -19764, + -3706, -3737, -5850, -10520, + -10081, -4050, -4065, -5001, + -3908, -9909, -2881, -9604, + -520, -11156, -12620, -12768, + -4539, -5149, -6208, -4462, + -4866, -7672, -4235, -4407, + -9163, -13411, -2975, -3915, + -12267, -7568, -3842, -2827, + -7181, -4914, -2608, -9392, + -6275, -2868, -5962, -6511, + -12962, -1034, -8517, -10992, + -8247, -7608, -2502, -5026, + -5812, -4998, -3860, -5778, + -16907, -5974, -4434, -3276, }; const Word16 HBCB_SubGain5bit_fx[128] = {//Q8 - -15224, -17789, -9897, -5048, -456, -1232, -2238, -2782, - -3391, -3864, -4026, -4045, -2017, -1311, -878, -1973, - -12837, -15376, -8273, -4141, -2791, -3037, -2403, -342, - -3388, -3646, -3471, -2829, -157, -2025, -2318, -2243, - -14652, -16433, -7699, -1188, -2567, -1755, -346, -1682, - -2068, -2321, -2344, -2348, -1759, -1038, -1865, -2041, - -11396, -13719, -7749, -2734, -809, -1935, -1886, -781, - -2136, -1940, -942, -1571, -1926, -2378, -2572, -2145, - -17531, -19267, -7721, -2672, -714, -675, -1516, -2071, - -1925, -2325, -2523, -2657, -1644, -1674, -2036, -2017, - -12781, -14601, -6714, -1380, -2093, -1704, -1124, -756, - -2776, -2687, -2066, -1202, -1102, -680, -1956, -2376, - -14436, -15846, -4918, -2071, -1613, -744, -1807, -1381, - -620, -1294, -2026, -2162, -794, -1755, -1167, -1762, - -11627, -13377, -5876, -1959, -1009, -1879, -1027, -1915, - -1734, -1265, -2001, -1018, -698, -1733, -2172, -1195, + -15224, -17789, -9897, -5048, -456, -1232, -2238, -2782, + -3391, -3864, -4026, -4045, -2017, -1311, -878, -1973, + -12837, -15376, -8273, -4141, -2791, -3037, -2403, -342, + -3388, -3646, -3471, -2829, -157, -2025, -2318, -2243, + -14652, -16433, -7699, -1188, -2567, -1755, -346, -1682, + -2068, -2321, -2344, -2348, -1759, -1038, -1865, -2041, + -11396, -13719, -7749, -2734, -809, -1935, -1886, -781, + -2136, -1940, -942, -1571, -1926, -2378, -2572, -2145, + -17531, -19267, -7721, -2672, -714, -675, -1516, -2071, + -1925, -2325, -2523, -2657, -1644, -1674, -2036, -2017, + -12781, -14601, -6714, -1380, -2093, -1704, -1124, -756, + -2776, -2687, -2066, -1202, -1102, -680, -1956, -2376, + -14436, -15846, -4918, -2071, -1613, -744, -1807, -1381, + -620, -1294, -2026, -2162, -794, -1755, -1167, -1762, + -11627, -13377, -5876, -1959, -1009, -1879, -1027, -1915, + -1734, -1265, -2001, -1018, -698, -1733, -2172, -1195, }; @@ -15488,12 +15488,12 @@ const Word16 full_band_bpf_3_fx[6][5] = /*in Q13*/ /* 4-bit/3-bit TD SWB BWE differential LSF scalar quantizer tables */ -const Word16 lsf_q_cb_size[NUM_Q_LSF] = {16, 16, 8, 8, 8}; // Q0 -const Word16 lsf_q_num_bits[NUM_Q_LSF] = { 4, 4, 3, 3, 3 }; // Q0 +const Word16 lsf_q_cb_size[NUM_Q_LSF] = {16, 16, 8, 8, 8}; // Q0 +const Word16 lsf_q_num_bits[NUM_Q_LSF] = { 4, 4, 3, 3, 3 }; // Q0 /* Tables for approximation of upper half of SWB LSFs */ -const Word16 mirror_point_q_cb_fx[MIRROR_POINT_Q_CB_SIZE] = { 471, 692, 896, 1216 }; // Q15 +const Word16 mirror_point_q_cb_fx[MIRROR_POINT_Q_CB_SIZE] = { 471, 692, 896, 1216 }; // Q15 const Word16 allpass_poles_3_ov_2[9] = /* Q15 */ { @@ -15541,8 +15541,8 @@ const Word16 F_2_5_fx[64] = /*Q10 */ * SWB BWE tables *------------------------------------------------------------------------------*/ -const Word16 swb_bwe_trans_subband[SWB_FENV_TRANS+1] = {240, 316, 392, 476, 560}; // Q0 -const Word16 swb_bwe_trans_subband_width[SWB_FENV_TRANS] = {76, 76, 84, 84}; // Q0 +const Word16 swb_bwe_trans_subband[SWB_FENV_TRANS+1] = {240, 316, 392, 476, 560}; // Q0 +const Word16 swb_bwe_trans_subband_width[SWB_FENV_TRANS] = {76, 76, 84, 84}; // Q0 const Word16 sqrt_swb_bwe_trans_subband_width_fx[SWB_FENV_TRANS] = { 17854, 17854, 18770, 18770 };/*Q11 */ @@ -15550,607 +15550,607 @@ const Word16 sqrt_swb_bwe_subband_fx_L1[SWB_FENV] = { 16384, 20066, 16384, 20066 const Word16 sqrt_swb_bwe_subband_fx_L2[SWB_FENV / 2] = { 25905, 25905, 25905, 25905, 28378, 28378, 32767 }; /*Q12 */ -const Word16 swb_bwe_subband[SWB_FENV+1] = {240, 256, 280, 296, 320, 336, 360, 376, 400, 424, 448, 472, 496, 528, 560}; // Q0 -const Word16 fb_bwe_subband[DIM_FB + 1] = { 640, 680, 720, 800 }; // Q0 -const Word16 fb_bwe_sm_subband[DIM_FB] = { 656, 696, 760 }; // Q0 +const Word16 swb_bwe_subband[SWB_FENV+1] = {240, 256, 280, 296, 320, 336, 360, 376, 400, 424, 448, 472, 496, 528, 560}; // Q0 +const Word16 fb_bwe_subband[DIM_FB + 1] = { 640, 680, 720, 800 }; // Q0 +const Word16 fb_bwe_sm_subband[DIM_FB] = { 656, 696, 760 }; // Q0 const Word16 swb_inv_bwe_subband_width_fx[SWB_FENV] = { 2048,1365,2048,1365,2048,1365,2048,1365,1365,1365,1365,1365,1024,1024 };//Q15 -const Word16 swb_bwe_sm_subband[SWB_FENV] = {248, 268, 288, 308, 328, 348, 368, 388, 412, 436, 460, 484, 512, 544}; // Q0 -const Word16 smooth_factor_fx[SWB_FENV - 1] = { 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1366, 1366, 1366, 1366, 1024, 1024 };//Q15 +const Word16 swb_bwe_sm_subband[SWB_FENV] = {248, 268, 288, 308, 328, 348, 368, 388, 412, 436, 460, 484, 512, 544}; // Q0 +const Word16 smooth_factor_fx[SWB_FENV - 1] = { 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1366, 1366, 1366, 1366, 1024, 1024 };//Q15 -const Word16 fb_bwe_subband_float[DIM_FB+1] = {640, 680, 720, 800}; // Q0 +const Word16 fb_bwe_subband_float[DIM_FB+1] = {640, 680, 720, 800}; // Q0 const Word16 fb_inv_bwe_subband_width_fx[DIM_FB] = { 819, 819, 409 };//Q15 -const Word16 fb_bwe_sm_subband_float[DIM_FB] = {656, 696, 760}; // Q0 +const Word16 fb_bwe_sm_subband_float[DIM_FB] = {656, 696, 760}; // Q0 const Word16 fb_smooth_factor_fx[DIM_FB] = { 1024, 819, 512 };//Q15 const Word16 EnvCdbk11_fx[N_CB11 * DIM11] = /*Q8 */ { - -2220, 29, 1168, 2124, 2180, 1208, 741, - 1521, -312, -843, -1523, -1970, -2205, -2541, - 746, 1835, 3461, 4398, 4292, 4184, 3462, - 1627, 2475, 2937, 2839, 2198, 1729, 1325, - -514, -731, -557, -200, 100, 475, 540, - 655, 956, 1272, 1083, 774, 687, 459, - 5987, 5460, 4689, 4192, 3845, 3615, 3393, - 3571, 4840, 5784, 6266, 5933, 5158, 4433, - 2959, 2087, 1180, 979, 1180, 1371, 1636, - 6029, 6157, 6431, 6762, 6998, 7153, 7050, - -822, 210, 450, 178, -639, -1346, -1577, - 4451, 4184, 4111, 4329, 4833, 5232, 5512, - 3420, 3994, 4321, 4205, 3684, 3154, 2651, - -3734, -2305, -1388, -324, 22, -847, -1141, - 850, 510, 896, 1780, 2130, 2688, 2826, - 3294, 2823, 2510, 2516, 3029, 3413, 3843, - -3563, -3409, -3199, -2917, -2584, -2282, -1981, - -2738, -3185, -3752, -4320, -4484, -4524, -4329, - -7534, -7481, -7283, -7175, -6757, -6281, -5865, - -4868, -4836, -4603, -4422, -4086, -3738, -3323, - -13896, -13775, -13484, -13339, -12926, -12399, -11970, - 8409, 8420, 8305, 8103, 7954, 7778, 7496, - 7180, 6845, 6369, 5971, 5557, 5309, 5027, - 4633, 4008, 3267, 2422, 2072, 1778, 1510, - 10128, 10432, 10540, 10473, 10176, 9837, 9586, - 2933, 2695, 2060, 1286, 424, -254, -825, - -10032, -9847, -9544, -9420, -9000, -8508, -8084, - 1830, 927, -158, -388, -360, -368, -287, - -21962, -21904, -21548, -21471, -21004, -20511, -20064, - -6090, -6142, -5937, -5852, -5493, -5104, -4671, - -1382, -1640, -2205, -2557, -2785, -3019, -2994, - -1300, -1567, -1744, -1642, -1409, -1080, -902, + -2220, 29, 1168, 2124, 2180, 1208, 741, + 1521, -312, -843, -1523, -1970, -2205, -2541, + 746, 1835, 3461, 4398, 4292, 4184, 3462, + 1627, 2475, 2937, 2839, 2198, 1729, 1325, + -514, -731, -557, -200, 100, 475, 540, + 655, 956, 1272, 1083, 774, 687, 459, + 5987, 5460, 4689, 4192, 3845, 3615, 3393, + 3571, 4840, 5784, 6266, 5933, 5158, 4433, + 2959, 2087, 1180, 979, 1180, 1371, 1636, + 6029, 6157, 6431, 6762, 6998, 7153, 7050, + -822, 210, 450, 178, -639, -1346, -1577, + 4451, 4184, 4111, 4329, 4833, 5232, 5512, + 3420, 3994, 4321, 4205, 3684, 3154, 2651, + -3734, -2305, -1388, -324, 22, -847, -1141, + 850, 510, 896, 1780, 2130, 2688, 2826, + 3294, 2823, 2510, 2516, 3029, 3413, 3843, + -3563, -3409, -3199, -2917, -2584, -2282, -1981, + -2738, -3185, -3752, -4320, -4484, -4524, -4329, + -7534, -7481, -7283, -7175, -6757, -6281, -5865, + -4868, -4836, -4603, -4422, -4086, -3738, -3323, + -13896, -13775, -13484, -13339, -12926, -12399, -11970, + 8409, 8420, 8305, 8103, 7954, 7778, 7496, + 7180, 6845, 6369, 5971, 5557, 5309, 5027, + 4633, 4008, 3267, 2422, 2072, 1778, 1510, + 10128, 10432, 10540, 10473, 10176, 9837, 9586, + 2933, 2695, 2060, 1286, 424, -254, -825, + -10032, -9847, -9544, -9420, -9000, -8508, -8084, + 1830, 927, -158, -388, -360, -368, -287, + -21962, -21904, -21548, -21471, -21004, -20511, -20064, + -6090, -6142, -5937, -5852, -5493, -5104, -4671, + -1382, -1640, -2205, -2557, -2785, -3019, -2994, + -1300, -1567, -1744, -1642, -1409, -1080, -902, }; const Word16 EnvCdbk1st_fx[N_CB1ST * DIM1ST] = /*Q8 */ { - -1819, -1138, 751, - -494, 162, -826, - -3199, -123, 2479, - -2071, 238, -429, - -1819, 1780, 1233, - 284, 1187, -1123, - -1689, -722, -484, - -1256, 52, -1336, - -604, 3738, -1297, - 555, 412, 743, - -626, -1685, 1527, - 145, 1557, -224, - -638, 1370, 1589, - -1188, 37, -410, - -428, -3320, 1860, - 2597, -95, -2876, - -742, -583, -684, - 1607, -1671, -1874, - -1111, -936, -1374, - 275, -2314, 518, - 2682, 2368, -302, - 1809, -555, -579, - 3193, -1270, -1208, - 750, 84, 154, - -1160, 429, 1098, - 816, -613, -2897, - 2159, -1885, 1245, - -671, 426, 3177, - 867, -144, -639, - 843, -1888, 2271, - 1542, 259, -148, - -1680, 1027, 285, - 162, -763, 1666, - -1916, 1175, -1227, - -345, -907, -151, - 1979, 1062, 402, - -1231, 2437, 3130, - -2422, 361, 1040, - -4314, -4106, -4221, - 146, -1200, -1828, - 485, 889, -3847, - 384, -2461, -2845, - 1526, -600, 1599, - -838, -571, 1097, - 1776, -3393, 4058, - -3330, 2429, 1732, - 468, -2140, -934, - 833, 2292, -1129, - -20, -1029, 652, - -346, 168, 1834, - -1730, 838, 2234, - 1622, -1695, -194, - -3198, -773, 228, - 1070, 1741, 285, - 1655, -212, -1628, - 2178, 604, 1784, - 1801, -3224, -848, - -819, 348, 187, - 16, 300, 244, - 769, 201, 1554, - 719, -394, 780, - 311, 2853, 185, - 1163, 489, -1022, - -330, 459, 877, - 109, -541, -691, - -509, -267, 478, - -340, -417, -1403, - -860, -675, -2703, - 1025, 826, 250, - -1043, 1008, -434, - -1042, -631, 60, - -173, 332, -2084, - 984, 919, -2042, - -1257, -2287, 339, - 366, -1309, -158, - 1041, 1039, 1083, - 3566, 918, 227, - 62, -139, 936, - 2424, 730, -1022, - -745, 1954, 427, - -1091, -1358, -478, - -173, 2121, -2367, - -2175, 2535, -1946, - -880, -1964, -1549, - -249, -1203, -927, - -2377, -443, -1775, - -1439, -582, 2037, - -529, -3679, -550, - 608, -284, -1566, - 201, 63, -344, - 1376, 218, 816, - 2471, -348, 479, - -1388, 988, -2674, - 1429, -3538, 1125, - 864, -1351, 845, - 301, 977, 408, - -1122, 3364, 1107, - -213, 730, -329, - 839, -683, -92, - 631, 1172, 2364, - 598, 685, -329, - -780, -1317, 448, - -424, -153, -199, - 768, -331, 2825, - 882, -1047, -975, - -375, -1835, -299, - 2861, -3375, -3158, - 2099, 2168, -2630, - 1602, 1930, 1451, - 1294, 1265, -586, - -2500, -2570, -2667, - -806, -1529, 3272, - -522, 1072, 478, - 4035, -2491, 480, - -1908, 2414, -178, - -1563, -143, 438, - 205, 861, 1287, - -691, 963, -1374, - -2359, -2032, -886, - 162, -442, 160, - 194, 2494, 1960, - -2533, -2578, 1924, - 267, 1701, 937, - 2919, 2950, 2382, - -670, 2102, -859, - -3147, 1385, -215, - 1482, -595, 415, - 228, 290, -1060, + -1819, -1138, 751, + -494, 162, -826, + -3199, -123, 2479, + -2071, 238, -429, + -1819, 1780, 1233, + 284, 1187, -1123, + -1689, -722, -484, + -1256, 52, -1336, + -604, 3738, -1297, + 555, 412, 743, + -626, -1685, 1527, + 145, 1557, -224, + -638, 1370, 1589, + -1188, 37, -410, + -428, -3320, 1860, + 2597, -95, -2876, + -742, -583, -684, + 1607, -1671, -1874, + -1111, -936, -1374, + 275, -2314, 518, + 2682, 2368, -302, + 1809, -555, -579, + 3193, -1270, -1208, + 750, 84, 154, + -1160, 429, 1098, + 816, -613, -2897, + 2159, -1885, 1245, + -671, 426, 3177, + 867, -144, -639, + 843, -1888, 2271, + 1542, 259, -148, + -1680, 1027, 285, + 162, -763, 1666, + -1916, 1175, -1227, + -345, -907, -151, + 1979, 1062, 402, + -1231, 2437, 3130, + -2422, 361, 1040, + -4314, -4106, -4221, + 146, -1200, -1828, + 485, 889, -3847, + 384, -2461, -2845, + 1526, -600, 1599, + -838, -571, 1097, + 1776, -3393, 4058, + -3330, 2429, 1732, + 468, -2140, -934, + 833, 2292, -1129, + -20, -1029, 652, + -346, 168, 1834, + -1730, 838, 2234, + 1622, -1695, -194, + -3198, -773, 228, + 1070, 1741, 285, + 1655, -212, -1628, + 2178, 604, 1784, + 1801, -3224, -848, + -819, 348, 187, + 16, 300, 244, + 769, 201, 1554, + 719, -394, 780, + 311, 2853, 185, + 1163, 489, -1022, + -330, 459, 877, + 109, -541, -691, + -509, -267, 478, + -340, -417, -1403, + -860, -675, -2703, + 1025, 826, 250, + -1043, 1008, -434, + -1042, -631, 60, + -173, 332, -2084, + 984, 919, -2042, + -1257, -2287, 339, + 366, -1309, -158, + 1041, 1039, 1083, + 3566, 918, 227, + 62, -139, 936, + 2424, 730, -1022, + -745, 1954, 427, + -1091, -1358, -478, + -173, 2121, -2367, + -2175, 2535, -1946, + -880, -1964, -1549, + -249, -1203, -927, + -2377, -443, -1775, + -1439, -582, 2037, + -529, -3679, -550, + 608, -284, -1566, + 201, 63, -344, + 1376, 218, 816, + 2471, -348, 479, + -1388, 988, -2674, + 1429, -3538, 1125, + 864, -1351, 845, + 301, 977, 408, + -1122, 3364, 1107, + -213, 730, -329, + 839, -683, -92, + 631, 1172, 2364, + 598, 685, -329, + -780, -1317, 448, + -424, -153, -199, + 768, -331, 2825, + 882, -1047, -975, + -375, -1835, -299, + 2861, -3375, -3158, + 2099, 2168, -2630, + 1602, 1930, 1451, + 1294, 1265, -586, + -2500, -2570, -2667, + -806, -1529, 3272, + -522, 1072, 478, + 4035, -2491, 480, + -1908, 2414, -178, + -1563, -143, 438, + 205, 861, 1287, + -691, 963, -1374, + -2359, -2032, -886, + 162, -442, 160, + 194, 2494, 1960, + -2533, -2578, 1924, + 267, 1701, 937, + 2919, 2950, 2382, + -670, 2102, -859, + -3147, 1385, -215, + 1482, -595, 415, + 228, 290, -1060, }; const Word16 EnvCdbk2nd_fx[N_CB2ND * DIM2ND] = /*Q8 */ { - 1104, -1833, -1110, -954, - 757, 853, -176, 286, - -873, -587, -7, 1458, - -462, -553, -350, 104, - 1938, 1957, -1340, -703, - 1202, -779, 21, 1996, - -2851, -169, 1049, 940, - -1355, -726, -1788, 1076, - -767, -641, -646, -880, - 135, -832, -197, -889, - -826, 3, 279, -502, - -714, 544, -526, 375, - 291, -1076, -816, -3929, - -1175, -475, 2219, -642, - 197, -219, -1052, -1601, - 1175, -162, -695, -336, - 1124, 126, -2326, -1573, - 1164, -1323, -1958, 1074, - -2080, -2152, 113, 649, - -637, -860, 721, 267, - -609, 1658, -1006, -1352, - 1631, 2225, 2128, 1827, - -1112, -1351, 1856, 1656, - -2132, 1006, 770, -1294, - -472, 776, 1661, 2248, - -121, -574, -1481, -316, - 2565, -1081, 188, 293, - 398, 2598, 704, -1129, - 1023, 104, 550, 499, - -416, 127, 253, -1894, - 456, -2578, 190, 1018, - -1488, 286, -1202, -915, - -1164, 1874, 1651, 302, - -1312, -1547, -1625, -1516, - 170, -233, 817, 1209, - -1090, 341, 709, 725, - 854, 819, -278, -1083, - -15, 113, 286, 283, - 1166, -906, 1880, 301, - 342, -7, -587, 776, - -785, -1259, -1166, 3194, - -1630, -1071, 300, -1080, - -12, 190, -538, -493, - 351, 907, 1929, -1534, - 480, 36, 593, -526, - 813, 1216, 986, 89, - 98, 1010, -2272, 268, - 2766, -102, -1307, -873, - -1660, -467, -365, 47, - 1496, 1277, -228, -2791, - 1565, -669, 520, -1598, - -361, 1078, 457, -364, - 543, -950, 28, 248, - 1904, 815, -1034, 1125, - -13, -1951, 1085, -1005, - -2223, 1519, -624, 857, - 1121, 831, 872, 1295, - 193, 2284, -422, 609, - -156, 827, -733, 2065, - -3390, -3384, -3197, -3220, - 31, 896, 539, 978, - -21, 408, 1502, 405, - -583, -1662, -665, -164, - 2193, 976, 613, -436, + 1104, -1833, -1110, -954, + 757, 853, -176, 286, + -873, -587, -7, 1458, + -462, -553, -350, 104, + 1938, 1957, -1340, -703, + 1202, -779, 21, 1996, + -2851, -169, 1049, 940, + -1355, -726, -1788, 1076, + -767, -641, -646, -880, + 135, -832, -197, -889, + -826, 3, 279, -502, + -714, 544, -526, 375, + 291, -1076, -816, -3929, + -1175, -475, 2219, -642, + 197, -219, -1052, -1601, + 1175, -162, -695, -336, + 1124, 126, -2326, -1573, + 1164, -1323, -1958, 1074, + -2080, -2152, 113, 649, + -637, -860, 721, 267, + -609, 1658, -1006, -1352, + 1631, 2225, 2128, 1827, + -1112, -1351, 1856, 1656, + -2132, 1006, 770, -1294, + -472, 776, 1661, 2248, + -121, -574, -1481, -316, + 2565, -1081, 188, 293, + 398, 2598, 704, -1129, + 1023, 104, 550, 499, + -416, 127, 253, -1894, + 456, -2578, 190, 1018, + -1488, 286, -1202, -915, + -1164, 1874, 1651, 302, + -1312, -1547, -1625, -1516, + 170, -233, 817, 1209, + -1090, 341, 709, 725, + 854, 819, -278, -1083, + -15, 113, 286, 283, + 1166, -906, 1880, 301, + 342, -7, -587, 776, + -785, -1259, -1166, 3194, + -1630, -1071, 300, -1080, + -12, 190, -538, -493, + 351, 907, 1929, -1534, + 480, 36, 593, -526, + 813, 1216, 986, 89, + 98, 1010, -2272, 268, + 2766, -102, -1307, -873, + -1660, -467, -365, 47, + 1496, 1277, -228, -2791, + 1565, -669, 520, -1598, + -361, 1078, 457, -364, + 543, -950, 28, 248, + 1904, 815, -1034, 1125, + -13, -1951, 1085, -1005, + -2223, 1519, -624, 857, + 1121, 831, 872, 1295, + 193, 2284, -422, 609, + -156, 827, -733, 2065, + -3390, -3384, -3197, -3220, + 31, 896, 539, 978, + -21, 408, 1502, 405, + -583, -1662, -665, -164, + 2193, 976, 613, -436, }; const Word16 EnvCdbk3rd_fx[N_CB3RD * DIM3RD] = /*Q8 */ { - 1031, -2454, 748, - 2770, 2442, 1761, - -2348, 4079, -959, - 1874, -735, -2242, - -59, 35, 201, - -1518, 162, 1809, - -1977, -1063, -103, - 2485, 1212, -863, - 882, 192, 39, - 1356, 851, 979, - -1377, -2961, -1477, - 497, -808, 593, - -394, -748, -1564, - -950, -198, -436, - -503, -1420, -234, - 318, 985, -1905, - -118, 1783, 1563, - 220, 929, 400, - 857, 37, -995, - -807, 1943, -409, - -743, -524, 552, - 940, 1643, -299, - 805, -1421, -768, - -2330, 705, 156, - 61, 203, 1213, - -138, 517, -642, - 64, -501, -435, - 2194, -625, 157, - -1600, 341, -1611, - 1137, -351, 2353, - -811, -1715, 1522, - -870, 613, 446, + 1031, -2454, 748, + 2770, 2442, 1761, + -2348, 4079, -959, + 1874, -735, -2242, + -59, 35, 201, + -1518, 162, 1809, + -1977, -1063, -103, + 2485, 1212, -863, + 882, 192, 39, + 1356, 851, 979, + -1377, -2961, -1477, + 497, -808, 593, + -394, -748, -1564, + -950, -198, -436, + -503, -1420, -234, + 318, 985, -1905, + -118, 1783, 1563, + 220, 929, 400, + 857, 37, -995, + -807, 1943, -409, + -743, -524, 552, + 940, 1643, -299, + 805, -1421, -768, + -2330, 705, 156, + 61, 203, 1213, + -138, 517, -642, + 64, -501, -435, + 2194, -625, 157, + -1600, 341, -1611, + 1137, -351, 2353, + -811, -1715, 1522, + -870, 613, 446, }; const Word16 EnvCdbk4th_fx[N_CB4TH * DIM4TH] = /*Q8 */ { - 1024, -210, -207, 591, - -280, -2486, -951, 958, - 1539, 1136, 411, 1314, - 1761, -202, 1339, 203, - -2438, -2109, -2028, -2125, - 1849, -1408, -670, 144, - -469, 2674, -1589, -3604, - 1642, -702, 139, 2476, - -483, 372, -861, 540, - -119, 827, 863, 952, - 23, 99, -24, -303, - 488, -2233, -1432, -1399, - 54, -43, 96, -1527, - 1170, 133, -119, -717, - 258, -1215, -439, 160, - -1049, 793, 970, -770, - -1914, -1245, 1281, 422, - -1194, 1005, 176, -2368, - -1631, 1316, -1125, -361, - 1124, 1132, 61, -2186, - 790, -2055, 1174, 938, - 2974, 3874, 2315, 2040, - -300, 2484, 59, -860, - 543, 1307, -1868, -725, - 389, -115, -945, -146, - -1837, -578, -620, 975, - 389, 1779, 1732, 296, - 377, 897, 1555, 2269, - -854, 26, 590, 1413, - -780, -985, 1389, 2639, - 312, -277, -935, -3289, - 1740, 1852, 641, -519, - 738, 898, -466, 115, - 1187, -286, -1514, -1309, - 74, -801, -583, -987, - 510, -667, 430, -191, - 418, -303, 806, 1258, - -1083, -1065, 362, -2114, - -1075, 82, 260, 286, - -2579, 14, 75, -854, - -661, -634, 482, -581, - -338, -306, 3255, 388, - -230, -24, 1161, 205, - 256, 546, -141, 1379, - -63, -775, -484, 1478, - -517, -546, -451, 86, - 1473, -1201, 430, -1892, - 394, 831, 620, -664, - 334, 64, 1773, -1576, - -1783, 1270, 1020, 944, - 1023, 98, -1908, 1330, - -560, -1044, 380, 707, - -427, -708, -1815, -90, - -54, 2298, -537, 1151, - -499, 703, -1018, 3322, - 92, 717, -607, -1032, - -1313, -1393, -580, -485, - 34, -2192, 788, -860, - 2641, 628, -776, -259, - -702, -159, -1483, -1638, - -33, -63, 97, 553, - 692, 523, 548, 349, - -913, 54, -456, -702, - -341, 944, 157, 100, + 1024, -210, -207, 591, + -280, -2486, -951, 958, + 1539, 1136, 411, 1314, + 1761, -202, 1339, 203, + -2438, -2109, -2028, -2125, + 1849, -1408, -670, 144, + -469, 2674, -1589, -3604, + 1642, -702, 139, 2476, + -483, 372, -861, 540, + -119, 827, 863, 952, + 23, 99, -24, -303, + 488, -2233, -1432, -1399, + 54, -43, 96, -1527, + 1170, 133, -119, -717, + 258, -1215, -439, 160, + -1049, 793, 970, -770, + -1914, -1245, 1281, 422, + -1194, 1005, 176, -2368, + -1631, 1316, -1125, -361, + 1124, 1132, 61, -2186, + 790, -2055, 1174, 938, + 2974, 3874, 2315, 2040, + -300, 2484, 59, -860, + 543, 1307, -1868, -725, + 389, -115, -945, -146, + -1837, -578, -620, 975, + 389, 1779, 1732, 296, + 377, 897, 1555, 2269, + -854, 26, 590, 1413, + -780, -985, 1389, 2639, + 312, -277, -935, -3289, + 1740, 1852, 641, -519, + 738, 898, -466, 115, + 1187, -286, -1514, -1309, + 74, -801, -583, -987, + 510, -667, 430, -191, + 418, -303, 806, 1258, + -1083, -1065, 362, -2114, + -1075, 82, 260, 286, + -2579, 14, 75, -854, + -661, -634, 482, -581, + -338, -306, 3255, 388, + -230, -24, 1161, 205, + 256, 546, -141, 1379, + -63, -775, -484, 1478, + -517, -546, -451, 86, + 1473, -1201, 430, -1892, + 394, 831, 620, -664, + 334, 64, 1773, -1576, + -1783, 1270, 1020, 944, + 1023, 98, -1908, 1330, + -560, -1044, 380, 707, + -427, -708, -1815, -90, + -54, 2298, -537, 1151, + -499, 703, -1018, 3322, + 92, 717, -607, -1032, + -1313, -1393, -580, -485, + 34, -2192, 788, -860, + 2641, 628, -776, -259, + -702, -159, -1483, -1638, + -33, -63, 97, 553, + 692, 523, 548, 349, + -913, 54, -456, -702, + -341, 944, 157, 100, }; const Word16 EnvCdbkFB_fx[N_CB_FB * DIM_FB] = /*Q7 */ { - -2126, -1242, -945, - 1628, -686, -539, - 1230, 2245, 2532, - 2822, 3094, 2669, - -12376, -11507, -11342, - 2678, 3533, 3510, - 489, 903, 689, - 1930, 2929, 3025, - 3424, 4179, 4050, - -2500, -1707, -1415, - -3511, -2563, -2224, - -865, -987, -1212, - -424, 891, 1919, - 1976, 2520, 2277, - 673, 1667, 1945, - 5169, 6024, 5983, - -1367, -501, -236, - -254, 679, 989, - -18974, -18088, -17834, - -23007, -22053, -22109, - 2262, 2301, -625, - -124, 431, 372, - 1454, 1962, 1791, - 200, 1094, 1347, - -997, -110, 213, - -697, 267, 602, - -3066, -2172, -1876, - -4358, -3493, -3164, - -360, 59, -472, - -1813, -919, -601, - 4204, 4967, 4913, - 953, 1457, 1245 + -2126, -1242, -945, + 1628, -686, -539, + 1230, 2245, 2532, + 2822, 3094, 2669, + -12376, -11507, -11342, + 2678, 3533, 3510, + 489, 903, 689, + 1930, 2929, 3025, + 3424, 4179, 4050, + -2500, -1707, -1415, + -3511, -2563, -2224, + -865, -987, -1212, + -424, 891, 1919, + 1976, 2520, 2277, + 673, 1667, 1945, + 5169, 6024, 5983, + -1367, -501, -236, + -254, 679, 989, + -18974, -18088, -17834, + -23007, -22053, -22109, + 2262, 2301, -625, + -124, 431, 372, + 1454, 1962, 1791, + 200, 1094, 1347, + -997, -110, 213, + -697, 267, 602, + -3066, -2172, -1876, + -4358, -3493, -3164, + -360, 59, -472, + -1813, -919, -601, + 4204, 4967, 4913, + 953, 1457, 1245 }; const Word16 Mean_env_fb_fx[DIM_FB] = { 1760, 805, 473 }; /*Q8 */ const Word16 w_NOR_fx[SWB_FENV] = /*Q15 */ { - 32767, 32056, 31374, 30720, 30093, 29491, 28913, - 28357, 27822, 27307, 26810, 26331, 25869, 25423, + 32767, 32056, 31374, 30720, 30093, 29491, 28913, + 28357, 27822, 27307, 26810, 26331, 25869, 25423, }; const Word16 Mean_env_fx[SWB_FENV] = /*Q8 */ { - 7327, 7414, 7181, 7160, 6889, 6866, 6746, - 6651, 6385, 6152, 5873, 5668, 5435, 5222, + 7327, 7414, 7181, 7160, 6889, 6866, 6746, + 6651, 6385, 6152, 5873, 5668, 5435, 5222, }; const Word16 Env_TR_Cdbk1_fx[N_CB_TR1 * DIM_TR1] = /*Q8 */ { - 229, -2347, - 8199, 7726, - -312, 1700, - 9881, 5949, - 8942, 8358, - 3865, 3287, - 2405, 796, - 3664, 1433, - 3059, 2215, - 618, 874, - -5479, -4636, - 2237, 2512, - 4265, 2428, - 6583, 2065, - 4548, 6579, - 11325, 7340, - 10578, 9264, - 8491, 6457, - -1380, -2484, - 3377, 5069, - 7393, 5120, - 4798, 4440, - 5506, 7614, - -3371, -3982, - 2806, 2959, - 2242, 3550, - 1334, 3065, - 2055, -1350, - 815, 5507, - 4940, 1457, - -1950, -1046, - 653, -1133, - 872, -3622, - -1756, 245, - 5792, 5542, - 4084, 7696, - 4569, 5204, - -810, -1555, - 10127, 10384, - 11341, 11713, - 6365, 4996, - 8641, 10527, - 5914, 3366, - 4522, 3266, - 5217, 2830, - 8107, 8980, - 3952, 5858, - 5848, 8990, - 6424, 5931, - 5185, 3823, - 6367, 6917, - 3548, 2683, - 1634, 2098, - 2729, -89, - 6964, 7664, - 3179, 3561, - 6388, 4193, - 4024, 4828, - -378, 434, - 9338, 9507, - 7593, 3483, - -6835, -6317, - 5207, 5029, - 11326, 10488, - 7411, 6086, - 10072, 8255, - -6099, -5652, - 7074, 8702, - -12228, -11384, - -11471, -10567, - -13025, -12253, - -12879, -11289, - -13952, -13062, - -16214, -15389, - -11659, -10789, - -12351, -11477, - -12789, -11947, - -15139, -14249, - -11326, -11219, - -11950, -11093, - -11800, -10928, - -23738, -22881, - 12795, 11890, - -3793, -2879, - -27373, -26492, - -11928, -11531, - -12110, -11258, - -20492, -19634, - -14371, -13608, - -12591, -11728, - -14055, -11739, - 9471, 7272, - -11184, -10335, - -13313, -11673, - -12209, -10610, - -13465, -12761, - 7690, 7115, - 2564, 4496, - 5587, 4551, - -813, -562, - -4483, -5521, - 1556, 98, - 2, 3468, - 1410, 1339, - 4049, 161, - -4538, -4026, - -9866, -9115, - -1616, -4727, - 2457, 1653, - 631, 2155, - -17982, -17082, - 2628, 6088, - -10791, -9933, - -12426, -11566, - 4322, 4000, - -1574, 2162, - -7968, -7599, - 1523, 4192, - 5621, 6537, - -2511, -1987, - 12471, 9218, - 8746, 4971, - 3642, 4148, - 5089, 5948, - 350, -92, - 7028, 6683, - -2430, -3216, - -3974, -886, + 229, -2347, + 8199, 7726, + -312, 1700, + 9881, 5949, + 8942, 8358, + 3865, 3287, + 2405, 796, + 3664, 1433, + 3059, 2215, + 618, 874, + -5479, -4636, + 2237, 2512, + 4265, 2428, + 6583, 2065, + 4548, 6579, + 11325, 7340, + 10578, 9264, + 8491, 6457, + -1380, -2484, + 3377, 5069, + 7393, 5120, + 4798, 4440, + 5506, 7614, + -3371, -3982, + 2806, 2959, + 2242, 3550, + 1334, 3065, + 2055, -1350, + 815, 5507, + 4940, 1457, + -1950, -1046, + 653, -1133, + 872, -3622, + -1756, 245, + 5792, 5542, + 4084, 7696, + 4569, 5204, + -810, -1555, + 10127, 10384, + 11341, 11713, + 6365, 4996, + 8641, 10527, + 5914, 3366, + 4522, 3266, + 5217, 2830, + 8107, 8980, + 3952, 5858, + 5848, 8990, + 6424, 5931, + 5185, 3823, + 6367, 6917, + 3548, 2683, + 1634, 2098, + 2729, -89, + 6964, 7664, + 3179, 3561, + 6388, 4193, + 4024, 4828, + -378, 434, + 9338, 9507, + 7593, 3483, + -6835, -6317, + 5207, 5029, + 11326, 10488, + 7411, 6086, + 10072, 8255, + -6099, -5652, + 7074, 8702, + -12228, -11384, + -11471, -10567, + -13025, -12253, + -12879, -11289, + -13952, -13062, + -16214, -15389, + -11659, -10789, + -12351, -11477, + -12789, -11947, + -15139, -14249, + -11326, -11219, + -11950, -11093, + -11800, -10928, + -23738, -22881, + 12795, 11890, + -3793, -2879, + -27373, -26492, + -11928, -11531, + -12110, -11258, + -20492, -19634, + -14371, -13608, + -12591, -11728, + -14055, -11739, + 9471, 7272, + -11184, -10335, + -13313, -11673, + -12209, -10610, + -13465, -12761, + 7690, 7115, + 2564, 4496, + 5587, 4551, + -813, -562, + -4483, -5521, + 1556, 98, + 2, 3468, + 1410, 1339, + 4049, 161, + -4538, -4026, + -9866, -9115, + -1616, -4727, + 2457, 1653, + 631, 2155, + -17982, -17082, + 2628, 6088, + -10791, -9933, + -12426, -11566, + 4322, 4000, + -1574, 2162, + -7968, -7599, + 1523, 4192, + 5621, 6537, + -2511, -1987, + 12471, 9218, + 8746, 4971, + 3642, 4148, + 5089, 5948, + 350, -92, + 7028, 6683, + -2430, -3216, + -3974, -886, }; const Word16 Env_TR_Cdbk2_fx[N_CB_TR2 * DIM_TR2] = /*Q8 */ { - 2639, 375, - -481, 1694, - -2400, -3306, - 86, -4018, - -1301, 47, - 734, 299, - 957, -1039, - 2204, 1486, - 361, -1136, - 2628, -838, - -2010, 1296, - 373, 127, - -573, 2604, - 689, -1554, - 1676, -371, - 1298, 279, - -901, 1086, - 1747, -2723, - 214, -657, - -731, -909, - 1545, -1658, - -369, -2208, - -1276, 1748, - 1141, -522, - 186, -1893, - -1260, -2016, - -478, -504, - 1287, 1882, - -97, -1400, - -1372, -1165, - 800, -152, - 413, -240, - -208, -858, - -90, -399, - 492, 2519, - 913, 1368, - -344, 282, - 305, 526, - -251, 860, - -1066, 567, - -2800, -687, - 1, 674, - 176, 878, - -716, -153, - 706, 831, - -1083, -424, - 419, 1192, - -132, 565, - 708, -2406, - 600, -661, - 1712, 2969, - -1974, 379, - -672, 208, - 26, 296, - -1821, -501, - -513, 635, - 266, 1737, - -221, 1232, - -3498, 1632, - -337, -66, - -552, -1427, - 1329, 850, - -718, -2948, - -3, 0, + 2639, 375, + -481, 1694, + -2400, -3306, + 86, -4018, + -1301, 47, + 734, 299, + 957, -1039, + 2204, 1486, + 361, -1136, + 2628, -838, + -2010, 1296, + 373, 127, + -573, 2604, + 689, -1554, + 1676, -371, + 1298, 279, + -901, 1086, + 1747, -2723, + 214, -657, + -731, -909, + 1545, -1658, + -369, -2208, + -1276, 1748, + 1141, -522, + 186, -1893, + -1260, -2016, + -478, -504, + 1287, 1882, + -97, -1400, + -1372, -1165, + 800, -152, + 413, -240, + -208, -858, + -90, -399, + 492, 2519, + 913, 1368, + -344, 282, + 305, 526, + -251, 860, + -1066, 567, + -2800, -687, + 1, 674, + 176, 878, + -716, -153, + 706, 831, + -1083, -424, + 419, 1192, + -132, 565, + 708, -2406, + 600, -661, + 1712, 2969, + -1974, 379, + -672, 208, + 26, 296, + -1821, -501, + -513, 635, + 266, 1737, + -221, 1232, + -3498, 1632, + -337, -66, + -552, -1427, + 1329, 850, + -718, -2948, + -3, 0, }; const Word16 Mean_env_tr_fx[5] = { 6971, 6095, 6111, 4995 }; /*Q8 */ @@ -16162,15 +16162,15 @@ const Word16 Mean_env_tr_fx[5] = { 6971, 6095, 6111, 4995 }; /*Q8 */ const Word16 gain_table_SWB_BWE_fx[NB_SWB_SUBBANDS] = { -6554/*-0.4f*/, 1638/*0.1f*/, 9830/*0.6f*/, 18022/*1.1f*/ }; /* Q14 */ -const Word16 bits_lagIndices_modeNormal[NB_SWB_SUBBANDS] = {2, 2, 1, 1}; // Q0 -const Word16 subband_offsets_12KBPS[NB_SWB_SUBBANDS] = {SWB_SB_OFF0_12KBPS, SWB_SB_OFF1_12KBPS, SWB_SB_OFF2_12KBPS, SWB_SB_OFF3_12KBPS}; // Q0 -const Word16 subband_offsets_16KBPS[NB_SWB_SUBBANDS] = {SWB_SB_OFF0_16KBPS, SWB_SB_OFF1_16KBPS, SWB_SB_OFF2_16KBPS, SWB_SB_OFF3_16KBPS}; // Q0 +const Word16 bits_lagIndices_modeNormal[NB_SWB_SUBBANDS] = {2, 2, 1, 1}; // Q0 +const Word16 subband_offsets_12KBPS[NB_SWB_SUBBANDS] = {SWB_SB_OFF0_12KBPS, SWB_SB_OFF1_12KBPS, SWB_SB_OFF2_12KBPS, SWB_SB_OFF3_12KBPS}; // Q0 +const Word16 subband_offsets_16KBPS[NB_SWB_SUBBANDS] = {SWB_SB_OFF0_16KBPS, SWB_SB_OFF1_16KBPS, SWB_SB_OFF2_16KBPS, SWB_SB_OFF3_16KBPS}; // Q0 /* Search offset for the subbands that use a partial search */ const Word16 subband_search_offsets[NB_SWB_SUBBANDS] = { 0, 0, 64, 64 -}; // Q0 +}; // Q0 @@ -16190,25 +16190,25 @@ const Word16 bits_lagIndices_mode0_Har[NB_SWB_SUBBANDS_HAR_SEARCH_SB] = {1,1}; / const Word16 subband_offsets_sub5_13p2kbps_Har[NB_SWB_SUBBANDS_HAR] = { SWB_SB_OFF0_SUB5_12KBPS_HAR, SWB_SB_OFF1_SUB5_12KBPS_HAR, SWB_SB_OFF2_SUB5_12KBPS_HAR, SWB_SB_OFF3_SUB5_12KBPS_HAR -}; // Q0 +}; // Q0 /* Search offset for the subbands that use a partial search */ const Word16 subband_search_offsets_13p2kbps_Har[NB_SWB_SUBBANDS_HAR_SEARCH_SB] = { 120, 210 -}; // Q0 +}; // Q0 /* 16.4 kbps */ const Word16 subband_offsets_sub5_16p4kbps_Har[NB_SWB_SUBBANDS_HAR] = { SWB_SB_OFF0_SUB5_16KBPS_HAR, SWB_SB_OFF1_SUB5_16KBPS_HAR, SWB_SB_OFF2_SUB5_16KBPS_HAR, SWB_SB_OFF3_SUB5_16KBPS_HAR -}; // Q0 +}; // Q0 /* Search offset for the subbands that use a partial search */ const Word16 subband_search_offsets_16p4kbps_Har[NB_SWB_SUBBANDS_HAR_SEARCH_SB] = { 120, 210 -}; // Q0 +}; // Q0 /*------------------------------------------------------------------------------* @@ -16323,7 +16323,7 @@ const Word16 expPkEnrg_tbl[45] = 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 34, 36, 36, 38 -}; // Q0 +}; // Q0 const Word32 manPkEnrg_tbl[45] = { @@ -16336,7 +16336,7 @@ const Word32 manPkEnrg_tbl[45] = 1073744140, 536870912, 1073744140, 536870912, 1073697800, 536870912, 1073697800, 536870912, 1073883168, 536870912, 1073512448, 536870912, 1073512448, 536870912, 1073512448 -}; // Q0 +}; // Q0 const Word32 E_max5_tbl[40] = { 2047999999, 1448154663, 1024000000, 1448154663, 1024000000, @@ -16347,38 +16347,38 @@ const Word32 E_max5_tbl[40] = 1448156250, 1024000000, 1448156250, 1024000000, 1448156250, 1024000000, 1448156250, 1024000000, 1448125000, 1024000000, 1448125000, 1024000000, 1448250000, 1024000000, 1448000000 -}; // Q0 +}; // Q0 const Word16 resize_huffsizn[32] = { 0, 0, 0, 0, 0, 11, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0 -}; // Q0 +}; // Q0 const Word16 huffsizn[32] = { 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 4, 4, 3, 3, 3, 3, 4, 4, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7 -}; // Q0 +}; // Q0 const Word16 huffnorm_tran[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,122, 10, 6, 1, 0, 3, 2, 26, 58, 186, 442, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; // Q0 +}; // Q0 const Word16 huffsizn_tran[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 5, 3, 2, 2, 2, 4, 6, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; // Q0 +}; // Q0 const Word16 pgain_huffsizn[32] = { 10, 11, 10, 10, 9, 8, 6, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 6, 7, 7, 8, 10, 10, 12, 12 -}; // Q0 +}; // Q0 const Word16 dicnlg2_float[40] = { @@ -16386,34 +16386,34 @@ const Word16 dicnlg2_float[40] = 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5 -}; // Q0 +}; // Q0 /*** Table for quantization of MLT coefficients ***/ const Word16 norm_order_48[NB_SFM] = { 0, 1, 8, 9, 16, 20, 24, 28, 32, 36, 40, 41, 37, 33, 29, 25, 21, 17, 11, 10, 3, 2, 4, 5, 12, 13, 18, 22, 26, 30, 34, 38, 42, 43, 39, 35, 31, 27, 23, 19, 15, 14, 7, 6 -}; // Q0 +}; // Q0 const Word16 norm_order_32[SFM_N_SWB] = { 0, 1, 8, 9, 16, 20, 24, 28, 32, 36, 37, 33, 29, 25, 21, 17, 11, 10, 3, 2, 4, 5, 12, 13, 18, 22, 26, 30, 34, 38, 35, 31, 27, 23, 19, 15, 14, 7, 6 -}; // Q0 +}; // Q0 const Word16 norm_order_16[SFM_N_WB] = { 0, 1, 8, 9, 16, 20, 24, 21, 17, 11, 10, 3, 2, 4, 5, 12, 13, 18, 22, 25, 23, 19, 15, 14, 7, 6 -}; // Q0 +}; // Q0 -const Word16 intl_bw_16[N_INTL_GRP_16] = {16, 16}; // Q0 -const Word16 intl_bw_32[N_INTL_GRP_32] = {16, 24}; // Q0 -const Word16 intl_bw_48[N_INTL_GRP_48] = {16, 24, 32}; // Q0 +const Word16 intl_bw_16[N_INTL_GRP_16] = {16, 16}; // Q0 +const Word16 intl_bw_32[N_INTL_GRP_32] = {16, 24}; // Q0 +const Word16 intl_bw_48[N_INTL_GRP_48] = {16, 24, 32}; // Q0 -const Word16 intl_cnt_16[N_INTL_GRP_16] = {4, 1}; // Q0 -const Word16 intl_cnt_32[N_INTL_GRP_32] = {4, 4}; // Q0 -const Word16 intl_cnt_48[N_INTL_GRP_48] = {4, 3, 2}; // Q0 +const Word16 intl_cnt_16[N_INTL_GRP_16] = {4, 1}; // Q0 +const Word16 intl_cnt_32[N_INTL_GRP_32] = {4, 4}; // Q0 +const Word16 intl_cnt_48[N_INTL_GRP_48] = {4, 3, 2}; // Q0 const Word16 band_start_HQ[44] = { @@ -16421,7 +16421,7 @@ const Word16 band_start_HQ[44] = 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256, 280, 304, 328, 352, 376, 400, 424, 448, 472, 496, 520, 544, 576, 608, 640, 672, 704, 736, 768 -}; // Q0 +}; // Q0 const Word16 band_end_HQ[44] = { @@ -16429,7 +16429,7 @@ const Word16 band_end_HQ[44] = 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256, 280, 304, 328, 352, 376, 400, 424, 448, 472, 496, 520, 544, 576, 608, 640, 672, 704, 736, 768, 800 -}; // Q0 +}; // Q0 const Word16 band_len_HQ[44] = { @@ -16437,29 +16437,29 @@ const Word16 band_len_HQ[44] = 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 32, 32, 32, 32, 32, 32, 32, 32 -}; // Q0 +}; // Q0 const Word16 band_start_wb[26] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256, 288 -}; // Q0 +}; // Q0 const Word16 band_end_wb[26] = { 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256, 288, 320 -}; // Q0 +}; // Q0 const Word16 band_len_wb[26] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32 -}; // Q0 -const Word16 band_len_harm_float[SFM_N_HARM_FB] = // Q0 +}; // Q0 +const Word16 band_len_harm_float[SFM_N_HARM_FB] = // Q0 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 32, 32, 32, 48, 48, 48, 48, 64, 64, 64, 96 @@ -16481,8 +16481,8 @@ const Word16 rat_fx[SFM_N_WB] = { 24576, 24576, 24576, 24576, 24576, 24576, 2457 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 13107, 13107 };//Q14 -const Word16 sfm_width[20] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 8}; // Q0 -const Word16 a_map[20] = {8, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 7, 11}; // Q0 +const Word16 sfm_width[20] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 8}; // Q0 +const Word16 a_map[20] = {8, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 7, 11}; // Q0 const Word32 SQRT_DIM_fx[65] = /* sqrt(x) for x = 0, 1, ..., 64. in Q15 */ @@ -16567,7 +16567,7 @@ const Word16 subf_norm_groups[4][11] = {2,3,10,11,17,21,25,29,33,37,41}, {4,5,12,13,18,22,26,30,34,38,42}, {6,7,14,15,19,23,27,31,35,39,43} -}; // Q0 +}; // Q0 const Word16 gain_att_fx[40] = /* Q=15 */ { @@ -16676,17 +16676,17 @@ const Word32 pow_getbitsfrompulses_fx[16] = /*Q21 */ }; const Word16 DDP_fx[4] = { 3, 0, 1, 2 };//Q0 -const Word16 step_tcq[8][STATES] = { {0,4}, {0,4}, {1,5}, {1,5}, {2,6}, {2,6}, {3,7}, {3,7} }; // Q0 -const Word16 denc[8][STATES] = { {0,2}, {2,0}, {1,3}, {3,1}, {2,0}, {0,2}, {3,1}, {1,3} }; /* enc trellis Q0*/ -const Word16 ddec[8][STATES] = { {0,2}, {1,3}, {2,0}, {3,1}, {2,0}, {3,1}, {0,2}, {1,3} }; /* dec trellis Q0*/ +const Word16 step_tcq[8][STATES] = { {0,4}, {0,4}, {1,5}, {1,5}, {2,6}, {2,6}, {3,7}, {3,7} }; // Q0 +const Word16 denc[8][STATES] = { {0,2}, {2,0}, {1,3}, {3,1}, {2,0}, {0,2}, {3,1}, {1,3} }; /* enc trellis Q0*/ +const Word16 ddec[8][STATES] = { {0,2}, {1,3}, {2,0}, {3,1}, {2,0}, {3,1}, {0,2}, {1,3} }; /* dec trellis Q0*/ -const Word16 step_LSB[STATES_LSB][2] = { {0,1}, {2,3}, {0,1}, {2,3} }; // Q0 -const Word16 denc_LSB[STATES_LSB][2] = { {0,3}, {2,1}, {3,0}, {1,2} }; // Q0 -const Word16 dqnt_LSB[STATES_LSB][4] = { {0,8,1,8}, {0,8,1,8}, {8,0,8,1}, {8,0,8,1} }; // Q0 +const Word16 step_LSB[STATES_LSB][2] = { {0,1}, {2,3}, {0,1}, {2,3} }; // Q0 +const Word16 denc_LSB[STATES_LSB][2] = { {0,3}, {2,1}, {3,0}, {1,2} }; // Q0 +const Word16 dqnt_LSB[STATES_LSB][4] = { {0,8,1,8}, {0,8,1,8}, {8,0,8,1}, {8,0,8,1} }; // Q0 -const Word16 dstep_LSB[4][2] = { {0,2}, {0,2}, {1,3}, {1,3} }; // Q0 -const Word16 ddec_LSB[4][2] = { {0,3}, {3,0}, {2,1}, {1,2} }; // Q0 +const Word16 dstep_LSB[4][2] = { {0,2}, {0,2}, {1,3}, {1,3} }; // Q0 +const Word16 ddec_LSB[4][2] = { {0,3}, {3,0}, {2,1}, {1,2} }; // Q0 const Word16 nextstate[STATES][2] = {{0, 1}, {2, 3}, {4, 5}, {6, 7}, {0, 1}, {2, 3}, {4, 5}, {6, 7}};/*current state points to next two states Q0*/ @@ -16695,7 +16695,7 @@ const Word16 nextstate[STATES][2] = {{0, 1}, {2, 3}, {4, 5}, {6, 7}, {0, 1}, {2, * PVQ tables *------------------------------------------------------------------------------*/ -const Word16 fine_gain_bits[8] = {0, 0, 0, 1, 2, 2, 4, 5}; // Q0 +const Word16 fine_gain_bits[8] = {0, 0, 0, 1, 2, 2, 4, 5}; // Q0 const Word16 finegain_1_fx[2] = { -12204, 12647 }; /* Q14 */ const Word16 finegain_2_fx[4] = { -17773, -5925, 6010, 18769 }; /* Q14 */ const Word16 finegain_3_fx[8] = { -16384, -11703, -7022, -2341, 2341, 7022, 11703, 16384 }; /* Q14 */ @@ -16714,7 +16714,7 @@ const Word16 finegain_5_fx[32] = /* Q14 */ const Word16* finegain_fx[5] = { finegain_1_fx, finegain_2_fx, finegain_3_fx, finegain_4_fx, finegain_5_fx };/* Q14 */ -const UWord8 hBitsMinus1_N01[2] = {1, 7}; // Q0 +const UWord8 hBitsMinus1_N01[2] = {1, 7}; // Q0 const UWord8 hBitsMinus1_N02[65]= { @@ -16723,7 +16723,7 @@ const UWord8 hBitsMinus1_N02[65]= 60, 61, 62, 63, 63, 64, 65, 65, 67, 68, 69, 69, 70, 71, 72, 72, 73, 74, 75, 76, 77, 78, 79, 80, 80, 81, 82, 83, 84, 85, 86, 87, 87 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N03[65]= { @@ -16732,7 +16732,7 @@ const UWord8 hBitsMinus1_N03[65]= 104, 106, 108, 110, 111, 113, 114, 115, 118, 120, 122, 123, 125, 127, 128, 129, 131, 133, 135, 137, 139, 141, 142, 144, 145, 146, 149, 151, 153, 155, 157, 158, 160 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N04[65]= { @@ -16741,7 +16741,7 @@ const UWord8 hBitsMinus1_N04[65]= 144, 147, 150, 152, 154, 156, 158, 160, 164, 167, 170, 173, 175, 177, 180, 182, 184, 187, 190, 193, 196, 199, 201, 203, 205, 207, 211, 214, 217, 220, 222, 225, 227 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N05[54]= { @@ -16749,101 +16749,101 @@ const UWord8 hBitsMinus1_N05[54]= 131, 134, 136, 139, 141, 144, 148, 152, 155, 158, 161, 164, 167, 170, 172, 176, 181, 184, 188, 191, 194, 197, 200, 202, 207, 211, 215, 219, 222, 225, 228, 231, 233, 238, 242, 246, 250, 253 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N06[42]= { 41, 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, 153, 156, 159, 162, 165, 168, 173, 178, 183, 187, 191, 194, 198, 201, 204, 209, 214, 219, 224, 228, 231, 235, 238, 241, 247, 253 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N07[34]= { 33, 30, 52, 70, 85, 98, 109, 118, 126, 134, 141, 147, 153, 158, 163, 168, 172, 176, 180, 184, 188, 191, 197, 203, 208, 213, 218, 222, 226, 230, 233, 240, 246, 252 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N08[29]= { 28, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, 185, 190, 195, 200, 204, 208, 212, 219, 226, 232, 238, 243, 248, 253 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N09[25]= { 24, 33, 58, 79, 97, 112, 125, 137, 148, 157, 166, 174, 182, 189, 195, 201, 207, 212, 217, 222, 227, 231, 240, 247, 254 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N10[22]= { 21, 34, 61, 83, 101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 228, 234, 239, 245, 250 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N11[19]= { 18, 35, 63, 86, 106, 123, 139, 152, 165, 176, 187, 197, 206, 214, 222, 230, 237, 243, 250 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N12[17]= { 16, 36, 65, 89, 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N13[16]= { 15, 37, 67, 92, 113, 133, 150, 165, 180, 193, 205, 216, 227, 237, 246, 254, -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N14[14]= { 13, 38, 68, 94, 117, 137, 155, 171, 186, 200, 213, 225, 236, 247 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N15[13]= { 12, 39, 70, 97, 120, 141, 160, 177, 193, 207, 221, 233, 245 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N16[13]= { 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, 228, 241, 253 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N17[12]= { 11, 40, 73, 101, 126, 148, 168, 187, 204, 220, 234, 248 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N18[12]= { 11, 41, 74, 103, 128, 151, 172, 191, 209, 225, 241, 255 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N19[11]= { 10, 41, 75, 105, 131, 154, 176, 196, 214, 231, 247 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N20[11]= { 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N21[10]= { 9, 43, 78, 108, 135, 160, 183, 204, 223, 241 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N22[10]= { 9, 43, 79, 110, 138, 163, 186, 207, 227, 246 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N23[10]= { @@ -16853,139 +16853,139 @@ const UWord8 hBitsMinus1_N23[10]= const UWord8 hBitsMinus1_N24[10]= { 9, 44, 81, 113, 142, 168, 192, 214, 235, 255 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N25[9]= { 8, 45, 82, 114, 143, 170, 195, 217, 239 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N26[9]= { 8, 45, 83, 116, 145, 172, 197, 221, 242 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N27[9]= { 8, 46, 84, 117, 147, 175, 200, 224, 246 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N28[9]= { 8, 46, 84, 118, 149, 177, 202, 227, 249 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N29[9]= { 8, 46, 85, 119, 150, 179, 205, 229, 252 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N30[8]= { 7, 47, 86, 121, 152, 181, 207, 232 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N31[8]= { 7, 47, 87, 122, 153, 182, 209, 235 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N32[8]= { 7, 47, 87, 123, 155, 184, 212, 237 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N33[8]= { 7, 48, 88, 124, 156, 186, 214, 240 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N34[8]= { 7, 48, 89, 125, 158, 188, 216, 242 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N35[8]= { 7, 49, 90, 126, 159, 189, 218, 245 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N36[8]= { 7, 49, 90, 127, 160, 191, 220, 247 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N37[8]= { 7, 49, 91, 128, 162, 193, 222, 249 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N38[8]= { 7, 49, 91, 129, 163, 194, 224, 251 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N39[8]= { 7, 50, 92, 130, 164, 196, 225, 253 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N40[8]= { 7, 50, 93, 131, 165, 197, 227, 255 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N41[7]= { 6, 50, 93, 131, 166, 199, 229 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N42[7]= { 6, 51, 94, 132, 167, 200, 230 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N43[7]= { 6, 51, 94, 133, 168, 201, 232 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N44[7]= { 6, 51, 95, 134, 170, 203, 234 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N45[7]= { 6, 51, 95, 135, 171, 204, 235 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N46[7]= { 6, 52, 96, 135, 172, 205, 237 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N47[7]= { 6, 52, 96, 136, 173, 206, 238 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N48[7]= { 6, 52, 97, 137, 174, 208, 240 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N49[7]= { 6, 52, 97, 138, 175, 209, 241 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N50[7]= { 6, 53, 98, 138, 175, 210, 243 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N51[7]= { 6, 53, 98, 139, 176, 211, 244 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N52[7]= { 6, 53, 99, 140, 177, 212, 245 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N53[7]= { 6, 53, 99, 140, 178, 213, 247 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N54[7]= { 6, 54, 100, 141, 179, 214, 248 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N55[7]= { 6, 54, 100, 142, 180, 216, 249 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N56[7]= { 6, 54, 100, 142, 181, 217, 250 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N57[7]= { 6, 54, 101, 143, 181, 218, 252 @@ -16993,31 +16993,31 @@ const UWord8 hBitsMinus1_N57[7]= const UWord8 hBitsMinus1_N58[7]= { 6, 54, 101, 143, 182, 219, 253 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N59[7]= { 6, 55, 102, 144, 183, 220, 254 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N60[7]= { 6, 55, 102, 145, 184, 221, 255 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N61[6]= { 5, 55, 102, 145, 185, 221 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N62[6]= { 5, 55, 103, 146, 185, 222 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N63[6]= { 5, 55, 103, 146, 186, 223 -}; // Q0 +}; // Q0 const UWord8 hBitsMinus1_N64[6]= { 5, 55, 103, 147, 187, 224 -}; // Q0 +}; // Q0 const Word16 dsHighDiracsTab[PVQ_MAX_BAND_SIZE - DS_INDEX_LINEAR_END ] = { 23, 25, 27, 29, 31, 33, 35, 37, 39, @@ -17025,7 +17025,7 @@ const Word16 dsHighDiracsTab[PVQ_MAX_BAND_SIZE - DS_INDEX_LINEAR_END ] = 83, 91, 99, 107, 115, 123, 131, 139, 147, 163, 179, 195, 211, 227, 243, 259, 275, 291, 323, 355, 387, 419, 451, 483, 512 -}; // Q0 +}; // Q0 const UWord32 intLimCDivInvDQ31[67+1] = { @@ -17038,7 +17038,7 @@ const UWord32 intLimCDivInvDQ31[67+1] = 0x02aaaaab, 0x029cbc15, 0x028f5c29, 0x02828283, 0x02762763, 0x026a43a0, 0x025ed098, 0x0253c826, 0x02492493, 0x023ee090, 0x0234f72d, 0x022b63cc, 0x02222223, 0x02192e2a, 0x02108422, 0x02082083, 0x02000000, 0x01f81f82, 0x01f07c20, 0x01e9131b -}; // Q0 +}; // Q0 const UWord8 obtainEnergyQuantizerDensity_f[57] = { @@ -17049,7 +17049,7 @@ const UWord8 obtainEnergyQuantizerDensity_f[57] = 16,18,20,20,22,24,26,30, 32,34,38,42,46,50,54,58, 64,70,76,82,90,98,108,118, 128 -}; // Q0 +}; // Q0 /* (char)ceil(log2(hBitsN[N][0])) - 2) */ @@ -17063,7 +17063,7 @@ const UWord8 f_log2_n[ PVQ_MAX_BAND_SIZE + 1] = 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01}; // Q0 + 0x01}; // Q0 const UWord8 * const hBitsN[ PVQ_MAX_BAND_SIZE + 1 ]= { @@ -17080,7 +17080,7 @@ hBitsMinus1_N45, hBitsMinus1_N46, hBitsMinus1_N47, hBitsMinus1_N48, hBit hBitsMinus1_N50, hBitsMinus1_N51, hBitsMinus1_N52, hBitsMinus1_N53, hBitsMinus1_N54, hBitsMinus1_N55, hBitsMinus1_N56, hBitsMinus1_N57, hBitsMinus1_N58, hBitsMinus1_N59, hBitsMinus1_N60, hBitsMinus1_N61, hBitsMinus1_N62, hBitsMinus1_N63, hBitsMinus1_N64, -}; // Q0 +}; // Q0 const Word16 lim_neg_inv_tbl_fx[MAX_SPLITS + 1 ] = { /* 1 = optimized inv_tbl_fx constant for div by 1, Q15 */ @@ -17109,16 +17109,16 @@ const UWord32 exactdivodd[ODD_DIV_SIZE] = 438261969U, 4210752251U, 2350076445U, 1483715975U, 3089362441U, 2693454067U, 3238827797U, 3204181951U, 3237744577U, 128207979U, 2738819725U, 3811027319U, 3353604601U, 2519714147U, 1059797125U, 1631000239U, 2014922929U, 724452315U, 4244438269U, 1875962727U, 4198451177U, 3539808211U, 1062196213U, 3571604383U -}; // Q0 +}; // Q0 -const Word16 gain_cb_size[MAX_GAIN_BITS] = {2, 4, 8, 16, 32}; // Q0 +const Word16 gain_cb_size[MAX_GAIN_BITS] = {2, 4, 8, 16, 32}; // Q0 -const Word16 inner_frame_tbl[4] = {L_FRAME8k, L_FRAME16k, L_FRAME32k, L_FRAME48k}; /* corresponds to NB, WB, SWB, FB Q0*/ +const Word16 inner_frame_tbl[4] = {L_FRAME8k, L_FRAME16k, L_FRAME32k, L_FRAME48k}; /* corresponds to NB, WB, SWB, FB Q0*/ const Word16 hq_nominal_scaling_inv[7] = { 0, 8192, 11585, 0, 16384, 0, 20066 }; /*Q13 */ const Word16 hq_nominal_scaling[7] = { 0, 32767, 23170, 0, 16384, 0, 13377 }; /*Q15 */ -const Word16 l_spec_tbl[4] = {L_SPEC8k, L_SPEC16k, L_SPEC32k, L_SPEC48k}; /* corresponds to NB, WB, SWB, FB Q0*/ -const Word16 l_spec_ext_tbl[4] = {0, L_SPEC16k_EXT, L_SPEC32k_EXT, L_SPEC48k_EXT}; /* corresponds to NB, WB, SWB, FB Q0*/ +const Word16 l_spec_tbl[4] = {L_SPEC8k, L_SPEC16k, L_SPEC32k, L_SPEC48k}; /* corresponds to NB, WB, SWB, FB Q0*/ +const Word16 l_spec_ext_tbl[4] = {0, L_SPEC16k_EXT, L_SPEC32k_EXT, L_SPEC48k_EXT}; /* corresponds to NB, WB, SWB, FB Q0*/ const Word16 sinq_16k[3 * L_FRAME16k / 20] =/*Q15 */ { 536, 1608, 2678, 3745, 4808, 5866, 6918, 7962, @@ -17161,29 +17161,29 @@ const Word16 sinq_48k[3 * L_FRAME48k / 20] =/*Q15 */ /* subband width tables */ /* NB short win: 7200/8000/9600, 13200/16400/24400 */ -const Word16 band_width_40_4_6_0_0_0[4] = { 6, 8, 11, 15 }; // Q0 -const Word16 band_width_40_5_6_0_0_0[5] = { 6, 7, 7, 9, 11 }; // Q0 +const Word16 band_width_40_4_6_0_0_0[4] = { 6, 8, 11, 15 }; // Q0 +const Word16 band_width_40_5_6_0_0_0[5] = { 6, 7, 7, 9, 11 }; // Q0 /* NB long win: 7200, 8000, 9600, 13200, 16400 */ -const Word16 band_width_160_13_6_2_0_0[13] = { 6, 6, 6, 6, 7, 8, 9, 10, 13, 15, 19, 24, 31 }; // Q0 -const Word16 band_width_160_14_6_3_0_0[14] = { 6, 6, 6, 6, 6, 7, 8, 9, 10, 12, 15, 18, 22, 29 }; // Q0 -const Word16 band_width_160_17_6_3_0_0[17] = { 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 9, 10, 11, 13, 15, 17, 19 }; // Q0 -const Word16 band_width_160_18_6_4_0_0[18] = { 6, 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 9, 10, 11, 12, 14, 15, 17 }; // Q0 +const Word16 band_width_160_13_6_2_0_0[13] = { 6, 6, 6, 6, 7, 8, 9, 10, 13, 15, 19, 24, 31 }; // Q0 +const Word16 band_width_160_14_6_3_0_0[14] = { 6, 6, 6, 6, 6, 7, 8, 9, 10, 12, 15, 18, 22, 29 }; // Q0 +const Word16 band_width_160_17_6_3_0_0[17] = { 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 9, 10, 11, 13, 15, 17, 19 }; // Q0 +const Word16 band_width_160_18_6_4_0_0[18] = { 6, 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 9, 10, 11, 12, 14, 15, 17 }; // Q0 /* WB short win: 13200/16400/24400 */ -const Word16 band_width_80_7_6_0_0_0[7] = { 6, 7, 8, 10, 12, 16, 21 }; // Q0 +const Word16 band_width_80_7_6_0_0_0[7] = { 6, 7, 8, 10, 12, 16, 21 }; // Q0 /* WB long win: 13200, 16400 */ -const Word16 band_width_320_18_6_3_0_0[18] = { 6, 6, 6, 6, 6, 7, 7, 8, 10, 11, 13, 16, 19, 24, 30, 37, 47, 61 }; // Q0 -const Word16 band_width_320_20_6_3_0_0[20] = { 6, 6, 6, 6, 6, 6, 7, 8, 8, 9, 11, 12, 14, 17, 20, 23, 28, 34, 42, 51 }; // Q0 +const Word16 band_width_320_18_6_3_0_0[18] = { 6, 6, 6, 6, 6, 7, 7, 8, 10, 11, 13, 16, 19, 24, 30, 37, 47, 61 }; // Q0 +const Word16 band_width_320_20_6_3_0_0[20] = { 6, 6, 6, 6, 6, 6, 7, 8, 8, 9, 11, 12, 14, 17, 20, 23, 28, 34, 42, 51 }; // Q0 /* SWB short win: 13200, 16400 */ -const Word16 band_width_142_8_8_0_0_0[8] = {7,8,10,11,15,21,29,41}; // Q0 -const Word16 band_width_160_8_8_0_0_0[8] = { 8, 9, 11,13,17,23,32,47}; // Q0 +const Word16 band_width_142_8_8_0_0_0[8] = {7,8,10,11,15,21,29,41}; // Q0 +const Word16 band_width_160_8_8_0_0_0[8] = { 8, 9, 11,13,17,23,32,47}; // Q0 /* SWB long win: 13200, 16400 */ -const Word16 band_width_568_22_6_2_0_0[22] = { 6, 6, 6, 6, 6, 6, 7, 8, 9, 10, 11, 13, 16, 19, 23, 28, 34, 42, 55, 68, 84, 105}; // Q0 -const Word16 band_width_640_24_6_4_0_0[24] = { 6, 6, 6, 6, 6, 6, 7,7,8,9,10,11,13,15,18,21,26,32,39,48,59, 74,92,115}; // Q0 +const Word16 band_width_568_22_6_2_0_0[22] = { 6, 6, 6, 6, 6, 6, 7, 8, 9, 10, 11, 13, 16, 19, 23, 28, 34, 42, 55, 68, 84, 105}; // Q0 +const Word16 band_width_640_24_6_4_0_0[24] = { 6, 6, 6, 6, 6, 6, 7,7,8,9,10,11,13,15,18,21,26,32,39,48,59, 74,92,115}; // Q0 /* LR-MDCT: NB configuration tables */ const Xcore_Config xcore_config_8kHz_007200bps_long = { 13, L_FRAME8k, band_width_160_13_6_2_0_0, 536870912L, 24576, 24576/*eref*/, 13107, 13107/*bit_alloc_weight*/, 2, 2, 0, 0 /*p2a_th*/, 13107/*pd_thresh*/, 4260/*ld_slope*/, 19661/*ni_coef*/ }; @@ -17215,7 +17215,7 @@ const Word16 Nb[ NB_SFM] = 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 32, 32, 32, 32, 32, 32, 32, 32 -}; // Q0 +}; // Q0 /* log2(Nb) to calculate minimum bits for one pulse in PVQ */ const Word16 LNb[ NB_SFM] = @@ -17223,30 +17223,30 @@ const Word16 LNb[ NB_SFM] = 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 -}; // Q0 +}; // Q0 /*------------------------------------------------------------------------------* * GSC tables *------------------------------------------------------------------------------*/ -const Word16 gsc_sfm_start[MBANDS_GN] = {0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240}; // Q0 +const Word16 gsc_sfm_start[MBANDS_GN] = {0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240}; // Q0 -const Word16 gsc_sfm_end[MBANDS_GN] = {16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256}; // Q0 +const Word16 gsc_sfm_end[MBANDS_GN] = {16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256}; // Q0 -const Word16 gsc_sfm_size[MBANDS_GN] = {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}; // Q0 +const Word16 gsc_sfm_size[MBANDS_GN] = {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}; // Q0 const Word16 sm_table_fx[] = { - 32767, 32126, 31480, 30838, 30196, 29557, 28918, 28279, 27643, 27007, - 26375, 25746, 25120, 24494, 23875, 23255, 22643, 22033, 21427, 20824, - 20228, 19638, 19048, 18468, 17891, 17321, 16758, 16197, 15647, 15103, - 14562, 14031, 13507, 12989, 12481, 11980, 11488, 11000, 10525, 10056, - 9598, 9146, 8706, 8274, 7851, 7438, 7035, 6642, 6259, 5885, - 5521, 5171, 4830, 4499, 4178, 3870, 3572, 3287, 3011, 2746, - 2494, 2254, 2025, 1809, 1602, 1412, 1229, 1062, 904, 760, - 629, 511, 403, 308, 226, 157, 102, 56, 26, 7, -}; // Q15 + 32767, 32126, 31480, 30838, 30196, 29557, 28918, 28279, 27643, 27007, + 26375, 25746, 25120, 24494, 23875, 23255, 22643, 22033, 21427, 20824, + 20228, 19638, 19048, 18468, 17891, 17321, 16758, 16197, 15647, 15103, + 14562, 14031, 13507, 12989, 12481, 11980, 11488, 11000, 10525, 10056, + 9598, 9146, 8706, 8274, 7851, 7438, 7035, 6642, 6259, 5885, + 5521, 5171, 4830, 4499, 4178, 3870, 3572, 3287, 3011, 2746, + 2494, 2254, 2025, 1809, 1602, 1412, 1229, 1062, 904, 760, + 629, 511, 403, 308, 226, 157, 102, 56, 26, 7, +}; // Q15 const Word16 GSC_freq_bits[] = { @@ -17263,21 +17263,21 @@ const Word16 GSC_freq_bits[] = 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_16k40*/ 26, 96, 0, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_22k60*/ 26, 96, 0, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4 /* ACELP_24k40*/ -}; // Q0 +}; // Q0 const Word32 GSC_freq_bits_fx[] =/*Q18*/ { - 5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_5k00*/ - 5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_6k15*/ - 5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_7k20*/ - 5505024, 19660800, -1048576, 6815744, 4194304, 3145728, 2883584, 2359296, 0, 0, 1048576, 1048576, 262144, 262144, 786432, 0, 0, /* ACELP_8k00*/ - 6815744, 20971520, -786432, 7340032, 4718592, 3407872, 3145728, 2359296, 0, 0, 1048576, 1048576, 262144, 262144, 786432, 0, 0, /* ACELP_8k00*/ - 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_11k60*/ - 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_12k15*/ - 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_12k85*/ - 8126464, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_13k20*/ 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_14k80*/ - 8126464, 25165824, -262144, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_13k20*/ 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_16k40*/ - 8126464, 25165824, 0, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_22k60*/ 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_16k40*/ - 8126464, 25165824, 0, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_22k60*/ 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_16k40*/ + 5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_5k00*/ + 5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_6k15*/ + 5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_7k20*/ + 5505024, 19660800, -1048576, 6815744, 4194304, 3145728, 2883584, 2359296, 0, 0, 1048576, 1048576, 262144, 262144, 786432, 0, 0, /* ACELP_8k00*/ + 6815744, 20971520, -786432, 7340032, 4718592, 3407872, 3145728, 2359296, 0, 0, 1048576, 1048576, 262144, 262144, 786432, 0, 0, /* ACELP_8k00*/ + 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_11k60*/ + 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_12k15*/ + 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_12k85*/ + 8126464, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_13k20*/ 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_14k80*/ + 8126464, 25165824, -262144, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_13k20*/ 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_16k40*/ + 8126464, 25165824, 0, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_22k60*/ 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_16k40*/ + 8126464, 25165824, 0, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_22k60*/ 26, 96, -1, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_16k40*/ }; const Word32 GSC_freq_bits_fx_Q18[] =/*Q18*/ @@ -17299,9 +17299,9 @@ const Word32 GSC_freq_bits_fx_Q18[] =/*Q18*/ const Word16 Compl_GSC_freq_bits[] = { 5, 10, 10, 10 /* bitrate > ACELP_16k40 && FS = 16kHz */ -}; // Q0 +}; // Q0 -const Word16 mfreq_bindiv_loc[] = { 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32 }; // Q0 +const Word16 mfreq_bindiv_loc[] = { 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32 }; // Q0 const Word16 mean_gp_fx[] = { 9590 }; /*Q14*/ @@ -17319,507 +17319,507 @@ const Word16 Gain_meanNB_fx[] = const Word16 Gain_mean_dicNB_fx[1 * 64] = /*Q12 */ { - -1309, -931, -568, -396, -54, 807, 1174, 1533, - 1901, 2092, 2286, 2493, 2698, 3130, 2909, 286, - -748, 990, 631, -1119, -1697, -2114, -2788, -5399, - -9841, -1902, -3270, -7975, -7438, -6926, -7192, -2325, - -1504, -2549, -3022, -3532, -3818, -4136, -4751, -5071, - -5756, -6093, -8998, -6389, -8765, -9438, 3369, 3917, - 3619, 4684, -8264, 4255, -4433, -6662, -9230, -7678, - 5859, 118, 457, -227, 1717, 1353, -8499, -9649 + -1309, -931, -568, -396, -54, 807, 1174, 1533, + 1901, 2092, 2286, 2493, 2698, 3130, 2909, 286, + -748, 990, 631, -1119, -1697, -2114, -2788, -5399, + -9841, -1902, -3270, -7975, -7438, -6926, -7192, -2325, + -1504, -2549, -3022, -3532, -3818, -4136, -4751, -5071, + -5756, -6093, -8998, -6389, -8765, -9438, 3369, 3917, + 3619, 4684, -8264, 4255, -4433, -6662, -9230, -7678, + 5859, 118, 457, -227, 1717, 1353, -8499, -9649 }; const Word16 Mean_dic_NB_fx[1 * 10] = /*Q12 */ { - -444, -100, -120, -37, 25, - 70, 148, 63, 170, 229 + -444, -100, -120, -37, 25, + 70, 148, 63, 170, 229 }; const Word16 Gain_dic1_NB_fx[3 * 64] = /*Q12 */ { - -606, -92, 5, - -1965, 294, 666, - -440, 119, 661, - -106, 267, 108, - -1213, 345, -136, - -1251, 618, 566, - -1905, -750, 648, - -1043, -360, -498, - -18, -322, 96, - 334, 116, -247, - -1929, 660, 23, - -1845, 1178, 485, - -180, 836, 167, - -1892, -922, -321, - 416, -437, -344, - 595, -548, 158, - -265, -807, -338, - -1065, -1015, -20, - -626, 595, -333, - -569, 1090, 651, - 27, 587, -331, - -184, -85, -503, - -1902, -1807, 326, - -1861, -159, -989, - -666, 143, -1163, - -1718, 1031, -744, - 847, 301, -59, - 720, -1001, -216, - 1380, -866, -969, - 803, -4, -608, - 233, 408, -998, - 1459, 87, 263, - 345, -615, -1026, - 877, -148, -7, - 68, -1075, 270, - 802, 329, 475, - -1923, -126, -38, - 1275, -419, -349, - 401, 926, 575, - 846, -233, 547, - 693, -1880, 356, - -362, -1683, -219, - 231, -339, 598, - 1227, -616, 267, - 1116, 91, -1316, - -551, -650, 530, - 444, 32, 181, - -384, 1207, -775, - -993, 1163, 41, - 784, -1018, 538, - 635, 636, -424, - 1373, -1367, 149, - 1442, 401, -444, - 1094, 888, 123, - 874, 1113, -1082, - -646, -1112, -1103, - 539, -1632, -683, - 402, 571, 99, - -1778, -1809, -849, - -732, -1691, 700, - -678, 526, 274, - 320, 1227, -118, - -1222, -180, 454, - 173, 349, 530 + -606, -92, 5, + -1965, 294, 666, + -440, 119, 661, + -106, 267, 108, + -1213, 345, -136, + -1251, 618, 566, + -1905, -750, 648, + -1043, -360, -498, + -18, -322, 96, + 334, 116, -247, + -1929, 660, 23, + -1845, 1178, 485, + -180, 836, 167, + -1892, -922, -321, + 416, -437, -344, + 595, -548, 158, + -265, -807, -338, + -1065, -1015, -20, + -626, 595, -333, + -569, 1090, 651, + 27, 587, -331, + -184, -85, -503, + -1902, -1807, 326, + -1861, -159, -989, + -666, 143, -1163, + -1718, 1031, -744, + 847, 301, -59, + 720, -1001, -216, + 1380, -866, -969, + 803, -4, -608, + 233, 408, -998, + 1459, 87, 263, + 345, -615, -1026, + 877, -148, -7, + 68, -1075, 270, + 802, 329, 475, + -1923, -126, -38, + 1275, -419, -349, + 401, 926, 575, + 846, -233, 547, + 693, -1880, 356, + -362, -1683, -219, + 231, -339, 598, + 1227, -616, 267, + 1116, 91, -1316, + -551, -650, 530, + 444, 32, 181, + -384, 1207, -775, + -993, 1163, 41, + 784, -1018, 538, + 635, 636, -424, + 1373, -1367, 149, + 1442, 401, -444, + 1094, 888, 123, + 874, 1113, -1082, + -646, -1112, -1103, + 539, -1632, -683, + 402, 571, 99, + -1778, -1809, -849, + -732, -1691, 700, + -678, 526, 274, + 320, 1227, -118, + -1222, -180, 454, + 173, 349, 530 }; const Word16 Gain_dic2_NB_fx[3 * 32] = /*Q12 */ { - 28, 0, -66, - -557, 4, 206, - 281, -642, 36, - -417, 81, -494, - -380, 684, 450, - 521, -1544, 258, - -1119, 613, -1151, - 514, 24, 797, - 292, -84, -526, - 296, 418, -231, - -419, -68, 976, - 2, -308, 398, - -456, -1007, 263, - -1221, -371, 446, - -221, -390, -181, - -1210, 588, 751, - -1093, 528, -174, - 590, 372, -1271, - -79, -251, -1241, - -1016, -487, -512, - 542, 581, 338, - -265, 456, -105, - 490, -71, 89, - 42, 235, 379, - 31, 1194, -202, - 173, -839, 850, - -46, 500, -802, - 152, 933, 1073, - 980, 345, -263, - 807, -580, -521, - -23, -992, -585, - 876, -576, 411 + 28, 0, -66, + -557, 4, 206, + 281, -642, 36, + -417, 81, -494, + -380, 684, 450, + 521, -1544, 258, + -1119, 613, -1151, + 514, 24, 797, + 292, -84, -526, + 296, 418, -231, + -419, -68, 976, + 2, -308, 398, + -456, -1007, 263, + -1221, -371, 446, + -221, -390, -181, + -1210, 588, 751, + -1093, 528, -174, + 590, 372, -1271, + -79, -251, -1241, + -1016, -487, -512, + 542, 581, 338, + -265, 456, -105, + 490, -71, 89, + 42, 235, 379, + 31, 1194, -202, + 173, -839, 850, + -46, 500, -802, + 152, 933, 1073, + 980, 345, -263, + 807, -580, -521, + -23, -992, -585, + 876, -576, 411 }; const Word16 Gain_dic3_NB_fx[4 * 16] = /*Q12 */ { - -16, 65, -227, 11, - -214, 553, 366, 185, - 137, -338, -300, -625, - -122, 82, 538, -797, - 160, 285, -1103, 35, - -594, 312, -379, -423, - 169, -642, -395, 363, - 351, -1166, 630, -261, - -1190, 217, 416, 187, - -577, 244, -636, 858, - 580, 482, -220, 635, - 475, -188, 372, 27, - -65, -369, 504, 910, - -423, -442, 124, -40, - 480, 575, -41, -651, - 682, 680, 910, 489 + -16, 65, -227, 11, + -214, 553, 366, 185, + 137, -338, -300, -625, + -122, 82, 538, -797, + 160, 285, -1103, 35, + -594, 312, -379, -423, + 169, -642, -395, 363, + 351, -1166, 630, -261, + -1190, 217, 416, 187, + -577, 244, -636, 858, + 580, 482, -220, 635, + 475, -188, 372, 27, + -65, -369, 504, 910, + -423, -442, 124, -40, + 480, 575, -41, -651, + 682, 680, 910, 489 }; const Word16 Gain_dic2_NBHR_fx[3 * 64] = /*Q12 */ { - 29, 0, -94, - -605, -202, -174, - 324, -380, -163, - -126, -301, -306, - -288, 124, 112, - -86, 524, -115, - 234, 18, -464, - -55, -281, 179, - 161, 446, 632, - 366, -82, 97, - 228, -1149, 270, - 293, 286, -143, - -123, -35, -896, - -540, -675, 175, - 331, -483, -687, - -779, 204, -668, - -492, 768, -510, - -1215, -620, -483, - 681, -76, -296, - -671, 396, -45, - -759, 298, 564, - -284, 589, 321, - -1366, -592, 496, - -448, -585, -712, - 12, -756, -90, - 513, 167, -927, - -1172, 1060, -1198, - -477, 748, 1006, - 42, 103, 1277, - -940, 1049, 138, - -924, -14, -1469, - 684, 679, -1580, - 417, -374, -1572, - 607, 270, 256, - 567, 778, 843, - 1414, -223, -542, - 97, 200, 251, - 222, 1074, -547, - -714, -285, 1046, - 386, -684, 984, - 338, 674, 116, - -274, 171, -368, - 581, -1871, 342, - 94, 442, -597, - -293, -1205, 851, - -127, 501, -1247, - 175, 1700, 1357, - -24, 1224, 285, - 707, -952, -293, - 668, 492, -407, - 1164, 751, 201, - 381, -595, 288, - -1570, 481, -531, - -597, -160, 326, - -578, -1311, -40, - -118, -523, 576, - -1513, 527, 757, - -184, 40, 609, - -1215, 98, 68, - -65, -1324, -836, - 821, -299, 204, - 796, 21, 840, - 310, -133, 542, - 1042, -974, 537 + 29, 0, -94, + -605, -202, -174, + 324, -380, -163, + -126, -301, -306, + -288, 124, 112, + -86, 524, -115, + 234, 18, -464, + -55, -281, 179, + 161, 446, 632, + 366, -82, 97, + 228, -1149, 270, + 293, 286, -143, + -123, -35, -896, + -540, -675, 175, + 331, -483, -687, + -779, 204, -668, + -492, 768, -510, + -1215, -620, -483, + 681, -76, -296, + -671, 396, -45, + -759, 298, 564, + -284, 589, 321, + -1366, -592, 496, + -448, -585, -712, + 12, -756, -90, + 513, 167, -927, + -1172, 1060, -1198, + -477, 748, 1006, + 42, 103, 1277, + -940, 1049, 138, + -924, -14, -1469, + 684, 679, -1580, + 417, -374, -1572, + 607, 270, 256, + 567, 778, 843, + 1414, -223, -542, + 97, 200, 251, + 222, 1074, -547, + -714, -285, 1046, + 386, -684, 984, + 338, 674, 116, + -274, 171, -368, + 581, -1871, 342, + 94, 442, -597, + -293, -1205, 851, + -127, 501, -1247, + 175, 1700, 1357, + -24, 1224, 285, + 707, -952, -293, + 668, 492, -407, + 1164, 751, 201, + 381, -595, 288, + -1570, 481, -531, + -597, -160, 326, + -578, -1311, -40, + -118, -523, 576, + -1513, 527, 757, + -184, 40, 609, + -1215, 98, 68, + -65, -1324, -836, + 821, -299, 204, + 796, 21, 840, + 310, -133, 542, + 1042, -974, 537 }; const Word16 Gain_dic3_NBHR_fx[4 * 128] = /*Q12 */ { - 293, 7, -202, -95, - 535, 110, 542, -512, - -578, 65, -560, -345, - 206, 332, 10, -533, - -76, 356, -14, 83, - 149, -372, -195, -490, - -478, -241, -55, 113, - -293, -470, -606, 62, - 797, -1448, 625, -1128, - 173, 464, -1686, -49, - -392, -295, -159, -464, - -715, 420, -146, -984, - -36, 28, -484, 119, - 472, 272, -729, -116, - 68, -87, -628, -429, - 429, -918, -158, -191, - -545, 230, -435, 261, - -128, 15, -791, 612, - 268, -387, -1258, 102, - 378, 238, 301, 3, - -494, 149, 131, -124, - 634, -308, 99, 24, - 572, 711, 754, -1137, - -1109, 400, 1093, 369, - -831, -423, 1583, 1089, - -83, 156, -105, 1078, - -930, 476, 152, 380, - 776, 1162, 788, -43, - 279, 50, 408, 597, - 476, 483, 73, 749, - 903, 686, 80, -411, - 195, -768, 280, 344, - -263, -999, -46, -284, - -66, 263, 315, -1239, - 435, 578, -234, -1169, - 199, -1669, 188, 114, - -57, 419, -509, -633, - 98, -119, 129, -816, - -157, -365, -249, 537, - 67, -624, 121, 1153, - 1444, 142, -584, 38, - 1086, -84, 162, 994, - 392, -384, -124, 533, - 252, 183, -1161, -885, - -431, -829, 102, 432, - -708, 987, -1021, -644, - -64, 120, -1684, 985, - 210, -494, -906, 1302, - 50, -186, 177, 185, - -256, 872, -1004, 387, - 564, -80, -679, 515, - -763, -40, -1174, 228, - -1029, 199, -59, -297, - 30, -47, 198, -264, - -396, -1435, 913, -1018, - -141, 962, 36, 458, - 36, -388, 776, -1000, - -74, 489, 1137, 140, - -970, -766, 666, -117, - 90, 599, 1665, 1405, - -313, -685, -764, -615, - 563, -462, -627, -768, - 792, 560, -1445, 556, - -581, 721, -559, 1137, - -699, -273, 274, -846, - 940, -690, 747, -253, - -177, -541, 1355, -217, - -586, 427, 1196, -868, - 147, 532, -550, 405, - 258, 677, -245, -166, - 772, 1062, -331, 482, - 388, 1870, -576, 1585, - 462, 865, 454, 1212, - 570, 528, -681, 1229, - -386, 607, 599, 865, - -154, -20, -211, -231, - 96, 736, 408, -259, - 763, -1533, 1094, 249, - 705, -1132, 1757, -1082, - 310, -481, 329, -395, - 194, -781, 59, -954, - -933, -957, -25, 1866, - -852, -224, -482, 822, - -1438, 490, 221, 1281, - 392, 677, 539, 347, - 884, -614, 1844, 678, - -773, 484, -928, 2477, - -274, -461, 378, -263, - -283, -312, 583, 342, - 453, -1541, 378, 1266, - 778, 1095, 1290, 824, - -958, -443, -208, -71, - 985, -1001, -123, 473, - 56, -1003, -513, 474, - -259, 1435, 975, 315, - -59, -169, 724, 961, - -210, 1030, 341, -977, - 1054, 2917, -7, -877, - -852, -228, 330, 625, - 9, -524, -97, -14, - 16, -50, 476, 2406, - 264, -238, 768, 56, - 187, 108, -169, 446, - 673, 238, 992, 671, - -218, 285, 485, 181, - 669, -526, 639, 571, - 650, 20, -188, -516, - 1031, 165, 526, 136, - -333, 307, 102, -569, - -157, 309, -934, -121, - -336, 141, 39, 536, - 662, 364, -133, 222, - -1284, 637, -636, 77, - 1241, 846, 467, 638, - 842, 328, 1330, -320, - 152, -1009, 550, -215, - -772, 13, 594, -122, - 336, -410, -547, -2, - 869, -106, 321, -1180, - 516, 1247, -828, -577, - -670, 873, 367, -132, - -415, 630, -287, -164, - -105, 138, 657, -441, - -160, -1085, 940, 704, - -128, -68, -369, -1052, - -1434, 594, 546, -665, - -1849, 75, 175, 174, - -1283, 729, -1590, 1032 + 293, 7, -202, -95, + 535, 110, 542, -512, + -578, 65, -560, -345, + 206, 332, 10, -533, + -76, 356, -14, 83, + 149, -372, -195, -490, + -478, -241, -55, 113, + -293, -470, -606, 62, + 797, -1448, 625, -1128, + 173, 464, -1686, -49, + -392, -295, -159, -464, + -715, 420, -146, -984, + -36, 28, -484, 119, + 472, 272, -729, -116, + 68, -87, -628, -429, + 429, -918, -158, -191, + -545, 230, -435, 261, + -128, 15, -791, 612, + 268, -387, -1258, 102, + 378, 238, 301, 3, + -494, 149, 131, -124, + 634, -308, 99, 24, + 572, 711, 754, -1137, + -1109, 400, 1093, 369, + -831, -423, 1583, 1089, + -83, 156, -105, 1078, + -930, 476, 152, 380, + 776, 1162, 788, -43, + 279, 50, 408, 597, + 476, 483, 73, 749, + 903, 686, 80, -411, + 195, -768, 280, 344, + -263, -999, -46, -284, + -66, 263, 315, -1239, + 435, 578, -234, -1169, + 199, -1669, 188, 114, + -57, 419, -509, -633, + 98, -119, 129, -816, + -157, -365, -249, 537, + 67, -624, 121, 1153, + 1444, 142, -584, 38, + 1086, -84, 162, 994, + 392, -384, -124, 533, + 252, 183, -1161, -885, + -431, -829, 102, 432, + -708, 987, -1021, -644, + -64, 120, -1684, 985, + 210, -494, -906, 1302, + 50, -186, 177, 185, + -256, 872, -1004, 387, + 564, -80, -679, 515, + -763, -40, -1174, 228, + -1029, 199, -59, -297, + 30, -47, 198, -264, + -396, -1435, 913, -1018, + -141, 962, 36, 458, + 36, -388, 776, -1000, + -74, 489, 1137, 140, + -970, -766, 666, -117, + 90, 599, 1665, 1405, + -313, -685, -764, -615, + 563, -462, -627, -768, + 792, 560, -1445, 556, + -581, 721, -559, 1137, + -699, -273, 274, -846, + 940, -690, 747, -253, + -177, -541, 1355, -217, + -586, 427, 1196, -868, + 147, 532, -550, 405, + 258, 677, -245, -166, + 772, 1062, -331, 482, + 388, 1870, -576, 1585, + 462, 865, 454, 1212, + 570, 528, -681, 1229, + -386, 607, 599, 865, + -154, -20, -211, -231, + 96, 736, 408, -259, + 763, -1533, 1094, 249, + 705, -1132, 1757, -1082, + 310, -481, 329, -395, + 194, -781, 59, -954, + -933, -957, -25, 1866, + -852, -224, -482, 822, + -1438, 490, 221, 1281, + 392, 677, 539, 347, + 884, -614, 1844, 678, + -773, 484, -928, 2477, + -274, -461, 378, -263, + -283, -312, 583, 342, + 453, -1541, 378, 1266, + 778, 1095, 1290, 824, + -958, -443, -208, -71, + 985, -1001, -123, 473, + 56, -1003, -513, 474, + -259, 1435, 975, 315, + -59, -169, 724, 961, + -210, 1030, 341, -977, + 1054, 2917, -7, -877, + -852, -228, 330, 625, + 9, -524, -97, -14, + 16, -50, 476, 2406, + 264, -238, 768, 56, + 187, 108, -169, 446, + 673, 238, 992, 671, + -218, 285, 485, 181, + 669, -526, 639, 571, + 650, 20, -188, -516, + 1031, 165, 526, 136, + -333, 307, 102, -569, + -157, 309, -934, -121, + -336, 141, 39, 536, + 662, 364, -133, 222, + -1284, 637, -636, 77, + 1241, 846, 467, 638, + 842, 328, 1330, -320, + 152, -1009, 550, -215, + -772, 13, 594, -122, + 336, -410, -547, -2, + 869, -106, 321, -1180, + 516, 1247, -828, -577, + -670, 873, 367, -132, + -415, 630, -287, -164, + -105, 138, 657, -441, + -160, -1085, 940, 704, + -128, -68, -369, -1052, + -1434, 594, 546, -665, + -1849, 75, 175, 174, + -1283, 729, -1590, 1032 }; const Word16 YG_mean16_fx[1 * 16] = /*Q12 */ { - -396, -192, -168, -136, -60, -17, 45, 39, - 120, 81, 90, 67, 147, 34, 163, 184 + -396, -192, -168, -136, -60, -17, 45, 39, + 120, 81, 90, 67, 147, 34, 163, 184 }; const Word16 YG_dicMR_1_fx[4 * 64] = /*Q12 */ { - -1879, 826, 539, -210, - -120, 267, -137, -142, - -798, -473, 434, 243, - 297, -896, 369, 307, - -1883, -1333, 416, 510, - -1955, -660, -471, 224, - -905, -804, -517, 433, - -961, 20, -258, -224, - 209, 977, -213, -17, - 536, -244, 159, 97, - -265, 775, 412, -327, - 337, -391, -237, -472, - -1962, -1836, -692, 471, - 625, 173, -463, -15, - -965, 263, 62, 600, - -782, 889, -433, 211, - -1791, 852, -453, -776, - -182, -177, -1078, 80, - -364, 350, 280, 293, - -902, 1119, 295, -1194, - 16, 440, -342, 459, - -1825, -1584, -1382, -798, - 723, 57, -1235, -661, - 888, -1638, 277, 234, - 340, 345, 141, -610, - 1280, -23, 17, 144, - -639, -852, -520, -553, - 1032, 843, 149, 435, - 581, 783, 519, -196, - 457, 945, 498, -1289, - -1897, -41, 425, 514, - 787, 161, 506, 385, - -559, 1079, 319, 515, - 500, 340, 60, 106, - 251, -997, -1163, -960, - 261, -1288, -631, 335, - 1241, -620, -387, -662, - 167, 194, 476, 67, - 830, -261, 430, -1201, - -479, -123, 71, -1162, - 225, -1482, 132, -802, - 680, 763, -1010, 429, - 200, -125, 261, 590, - 771, -740, -183, 229, - -1860, -348, 278, -549, - -1768, 967, 281, 594, - -1727, -1697, 87, -764, - 1169, 631, -114, -471, - -1636, -101, -1324, -91, - 821, -745, 458, -264, - 1014, -576, 390, 470, - 1041, -517, -1018, 367, - 826, 17, 426, -326, - -467, -1641, 201, 325, - -1906, 428, -338, 222, - -1021, 630, 419, -75, - -86, -379, -203, 234, - 659, 527, -491, -1507, - -564, -1745, -979, -173, - -1764, -433, -743, -1090, - 242, 709, 269, 497, - 716, 74, -208, 618, - -297, 645, -864, -805, - -46, -326, 412, -296 + -1879, 826, 539, -210, + -120, 267, -137, -142, + -798, -473, 434, 243, + 297, -896, 369, 307, + -1883, -1333, 416, 510, + -1955, -660, -471, 224, + -905, -804, -517, 433, + -961, 20, -258, -224, + 209, 977, -213, -17, + 536, -244, 159, 97, + -265, 775, 412, -327, + 337, -391, -237, -472, + -1962, -1836, -692, 471, + 625, 173, -463, -15, + -965, 263, 62, 600, + -782, 889, -433, 211, + -1791, 852, -453, -776, + -182, -177, -1078, 80, + -364, 350, 280, 293, + -902, 1119, 295, -1194, + 16, 440, -342, 459, + -1825, -1584, -1382, -798, + 723, 57, -1235, -661, + 888, -1638, 277, 234, + 340, 345, 141, -610, + 1280, -23, 17, 144, + -639, -852, -520, -553, + 1032, 843, 149, 435, + 581, 783, 519, -196, + 457, 945, 498, -1289, + -1897, -41, 425, 514, + 787, 161, 506, 385, + -559, 1079, 319, 515, + 500, 340, 60, 106, + 251, -997, -1163, -960, + 261, -1288, -631, 335, + 1241, -620, -387, -662, + 167, 194, 476, 67, + 830, -261, 430, -1201, + -479, -123, 71, -1162, + 225, -1482, 132, -802, + 680, 763, -1010, 429, + 200, -125, 261, 590, + 771, -740, -183, 229, + -1860, -348, 278, -549, + -1768, 967, 281, 594, + -1727, -1697, 87, -764, + 1169, 631, -114, -471, + -1636, -101, -1324, -91, + 821, -745, 458, -264, + 1014, -576, 390, 470, + 1041, -517, -1018, 367, + 826, 17, 426, -326, + -467, -1641, 201, 325, + -1906, 428, -338, 222, + -1021, 630, 419, -75, + -86, -379, -203, 234, + 659, 527, -491, -1507, + -564, -1745, -979, -173, + -1764, -433, -743, -1090, + 242, 709, 269, 497, + 716, 74, -208, 618, + -297, 645, -864, -805, + -46, -326, 412, -296 }; const Word16 YG_dicMR_2_fx[4 * 32] = /*Q12 */ { - 93, 217, -122, 37, - -13, -83, 105, -491, - -398, -592, 399, -160, - 543, -81, -470, 408, - 394, -630, -94, -258, - -665, 133, -136, -125, - 397, -351, 630, -148, - -1166, 406, -865, 554, - -136, -302, -263, 81, - -674, -657, -571, -691, - -206, 381, -699, 122, - 272, -1506, 356, 15, - 451, -961, 638, -1133, - 316, -787, 165, 585, - 312, -144, 185, 274, - 39, -706, -997, 250, - -915, -871, -114, 458, - -834, 348, 364, -1188, - 450, 723, -256, 412, - 369, 468, -1371, 416, - 344, 164, 290, -1094, - 664, 122, 34, -218, - 555, 254, 559, 825, - 312, 492, 496, -27, - -399, 315, 690, -330, - -458, 710, 206, 415, - 290, 89, -662, -467, - -72, 593, -108, -460, - -217, 46, 319, 189, - -1366, 199, 365, 62, - -552, -166, 772, 861, - -159, 120, -215, 775 + 93, 217, -122, 37, + -13, -83, 105, -491, + -398, -592, 399, -160, + 543, -81, -470, 408, + 394, -630, -94, -258, + -665, 133, -136, -125, + 397, -351, 630, -148, + -1166, 406, -865, 554, + -136, -302, -263, 81, + -674, -657, -571, -691, + -206, 381, -699, 122, + 272, -1506, 356, 15, + 451, -961, 638, -1133, + 316, -787, 165, 585, + 312, -144, 185, 274, + 39, -706, -997, 250, + -915, -871, -114, 458, + -834, 348, 364, -1188, + 450, 723, -256, 412, + 369, 468, -1371, 416, + 344, 164, 290, -1094, + 664, 122, 34, -218, + 555, 254, 559, 825, + 312, 492, 496, -27, + -399, 315, 690, -330, + -458, 710, 206, 415, + 290, 89, -662, -467, + -72, 593, -108, -460, + -217, 46, 319, 189, + -1366, 199, 365, 62, + -552, -166, 772, 861, + -159, 120, -215, 775 }; const Word16 YG_dicMR_3_fx[4 * 32] = /*Q12 */ { - -103, -143, -85, -19, - -404, 182, -795, 84, - 398, -594, -55, -256, - 283, 128, -472, 279, - -246, -628, 281, 297, - -853, 468, 358, -915, - 272, 149, 209, -443, - -168, -504, 452, -525, - 624, -427, 779, 117, - 1079, 404, -98, 80, - 136, 165, 142, -1394, - 513, -566, -150, 822, - 124, 646, 199, 272, - -165, -702, -615, 165, - 333, 810, -457, 1038, - -360, 105, -110, 537, - -224, 125, 562, -26, - 699, -1105, 809, -1323, - -1229, 841, -767, 571, - -310, 437, -114, -230, - -1045, 630, 564, 322, - 282, 1170, -723, -306, - -328, -247, -251, -598, - 354, 332, -1593, 499, - 332, -23, 219, 304, - 325, -1511, 378, 299, - -94, -54, 679, 956, - 507, 830, 861, -739, - -895, -135, 16, -34, - 677, 650, 961, 714, - 816, -665, -1741, -671, - 274, 93, -617, -433 + -103, -143, -85, -19, + -404, 182, -795, 84, + 398, -594, -55, -256, + 283, 128, -472, 279, + -246, -628, 281, 297, + -853, 468, 358, -915, + 272, 149, 209, -443, + -168, -504, 452, -525, + 624, -427, 779, 117, + 1079, 404, -98, 80, + 136, 165, 142, -1394, + 513, -566, -150, 822, + 124, 646, 199, 272, + -165, -702, -615, 165, + 333, 810, -457, 1038, + -360, 105, -110, 537, + -224, 125, 562, -26, + 699, -1105, 809, -1323, + -1229, 841, -767, 571, + -310, 437, -114, -230, + -1045, 630, 564, 322, + 282, 1170, -723, -306, + -328, -247, -251, -598, + 354, 332, -1593, 499, + 332, -23, 219, 304, + 325, -1511, 378, 299, + -94, -54, 679, 956, + 507, 830, 861, -739, + -895, -135, 16, -34, + 677, 650, 961, 714, + 816, -665, -1741, -671, + 274, 93, -617, -433 }; const Word16 YG_dicMR_4_fx[4 * 16] = /*Q12 */ { - -163, -44, -108, 32, - 556, 153, 115, 120, - 617, 818, 802, 719, - -639, -665, 122, 664, - 353, -555, -352, -86, - -1162, 833, -1034, 326, - -511, -406, -478, -523, - 491, -1473, 404, -21, - 148, 288, -45, -544, - -61, 172, -791, -44, - 715, -449, 861, 504, - -108, 263, 610, 118, - 962, 826, -1013, -37, - -32, -495, 362, -214, - -37, 661, -75, 289, - -835, 243, 85, -105 + -163, -44, -108, 32, + 556, 153, 115, 120, + 617, 818, 802, 719, + -639, -665, 122, 664, + 353, -555, -352, -86, + -1162, 833, -1034, 326, + -511, -406, -478, -523, + 491, -1473, 404, -21, + 148, 288, -45, -544, + -61, 172, -791, -44, + 715, -449, 861, 504, + -108, 263, 610, 118, + 962, 826, -1013, -37, + -32, -495, 362, -214, + -37, 661, -75, 289, + -835, 243, 85, -105 }; @@ -17830,128 +17830,128 @@ const Word16 mean_m_fx[1 * 1] = /*Q12 */ const Word16 mean_gain_dic_fx[1 * 64] = { - -739, -519, -76, 147, 574, 779, 983, 1185, - 1384, 1580, 1784, 1989, 2204, 2643, 2864, 2422, - 362, -295, -1197, -1936, -2757, -11755, -8216, 3083, - 3311, -1434, -1682, -3341, -9284, -9057, -8616, -7783, - -7359, -6964, -6592, -6233, -5470, -5050, -4651, -3954, - -2470, -963, -2199, -3042, -3643, -4292, -5854, -10199, - 4103, 3548, 4390, 4717, 3817, -10525, -11521, -9570, - -9899, -9171, -10841, -11165, 5500, 5079, 6139, 6993 + -739, -519, -76, 147, 574, 779, 983, 1185, + 1384, 1580, 1784, 1989, 2204, 2643, 2864, 2422, + 362, -295, -1197, -1936, -2757, -11755, -8216, 3083, + 3311, -1434, -1682, -3341, -9284, -9057, -8616, -7783, + -7359, -6964, -6592, -6233, -5470, -5050, -4651, -3954, + -2470, -963, -2199, -3042, -3643, -4292, -5854, -10199, + 4103, 3548, 4390, 4717, 3817, -10525, -11521, -9570, + -9899, -9171, -10841, -11165, 5500, 5079, 6139, 6993 }; /* Q12 */ const Word16 YGain_mean_LR_fx[1 * 12] =/* Q12 */ { - -385, -178, -143, -116, -46, -12, - 64, 50, 118, 68, 133, 151 + -385, -178, -143, -116, -46, -12, + 64, 50, 118, 68, 133, 151 }; const Word16 YGain_dic1_LR_fx[3 * 32] = /*Q12 */ { - -1909, 159, -90, - -155, 416, -15, - -99, -84, 396, - -1832, -848, -320, - -779, 1024, 45, - -1860, -1761, 273, - 81, -341, -309, - -819, -3, -315, - 483, 215, -194, - 242, 937, -76, - -1830, -1753, -1102, - -1589, 868, -657, - -911, 389, 421, - -1834, 915, 390, - -144, 564, -869, - 878, -1544, 301, - 446, 332, 376, - -540, -822, -1001, - 548, -192, 232, - 920, -589, -175, - 869, 717, -564, - 797, -103, -1047, - -335, -1732, -186, - -1840, -345, 566, - 1205, 109, 43, - 985, -456, 570, - 650, -1223, -874, - 928, 752, 390, - -124, 833, 575, - -1811, -249, -1142, - -711, -767, 185, - 344, -876, 267, + -1909, 159, -90, + -155, 416, -15, + -99, -84, 396, + -1832, -848, -320, + -779, 1024, 45, + -1860, -1761, 273, + 81, -341, -309, + -819, -3, -315, + 483, 215, -194, + 242, 937, -76, + -1830, -1753, -1102, + -1589, 868, -657, + -911, 389, 421, + -1834, 915, 390, + -144, 564, -869, + 878, -1544, 301, + 446, 332, 376, + -540, -822, -1001, + 548, -192, 232, + 920, -589, -175, + 869, 717, -564, + 797, -103, -1047, + -335, -1732, -186, + -1840, -345, 566, + 1205, 109, 43, + 985, -456, 570, + 650, -1223, -874, + 928, 752, 390, + -124, 833, 575, + -1811, -249, -1142, + -711, -767, 185, + 344, -876, 267, }; const Word16 YGain_dic2_LR_fx[4 * 32] = /*Q12 */ { - -294, -73, -41, 11, - 276, 330, -1316, 173, - 26, -712, 86, 1, - -841, -539, 246, -479, - 43, -207, 709, 116, - 104, -197, 227, -548, - 261, -228, 165, 606, - 613, 403, -122, -420, - 14, 182, -544, -669, - -734, 392, -492, -131, - -1316, 274, 116, 331, - -1339, 535, -1261, 608, - -346, 277, -426, 729, - -1067, -836, -571, 388, - 643, 503, 484, 532, - -148, 447, 120, -392, - -600, 263, 519, -75, - 686, -346, 379, 23, - 130, 239, 376, -1366, - 68, 656, -361, 92, - 608, 286, -405, 487, - -1031, 507, 523, -971, - 51, -44, -521, 172, - -573, -500, 398, 632, - 240, 147, 104, 51, - -319, -680, -890, -398, - -195, 503, 306, 459, - 335, 368, 662, -389, - 378, -788, -537, 680, - 433, -1129, 472, -883, - 472, -312, -301, -207, - 378, -1346, 433, 408, + -294, -73, -41, 11, + 276, 330, -1316, 173, + 26, -712, 86, 1, + -841, -539, 246, -479, + 43, -207, 709, 116, + 104, -197, 227, -548, + 261, -228, 165, 606, + 613, 403, -122, -420, + 14, 182, -544, -669, + -734, 392, -492, -131, + -1316, 274, 116, 331, + -1339, 535, -1261, 608, + -346, 277, -426, 729, + -1067, -836, -571, 388, + 643, 503, 484, 532, + -148, 447, 120, -392, + -600, 263, 519, -75, + 686, -346, 379, 23, + 130, 239, 376, -1366, + 68, 656, -361, 92, + 608, 286, -405, 487, + -1031, 507, 523, -971, + 51, -44, -521, 172, + -573, -500, 398, 632, + 240, 147, 104, 51, + -319, -680, -890, -398, + -195, 503, 306, 459, + 335, 368, 662, -389, + 378, -788, -537, 680, + 433, -1129, 472, -883, + 472, -312, -301, -207, + 378, -1346, 433, 408, }; const Word16 YGain_dic3_LR_fx[5 * 32] = /*Q12 */ { - -332, -191, -122, -455, -210, - 364, -48, -664, 408, 225, - -576, -342, 367, 52, 270, - -392, -157, -77, 625, -224, - -183, -652, -406, 99, 266, - 24, 65, 74, 525, 613, - -805, 306, -383, -21, 247, - 16, 133, -416, -4, -567, - 294, -750, 443, -367, 228, - 536, 816, 767, 562, 594, - -54, 200, -1108, -582, 227, - 123, -43, 414, -376, -649, - 592, -652, -674, -386, -356, - 100, -58, -45, -108, 103, - -727, -194, -1170, 931, 1096, - 512, 758, -440, -769, -1051, - 362, 787, -276, -139, 149, - -218, 387, 457, -414, 265, - -202, 663, -1104, 882, -338, - -57, 405, 269, 257, -221, - 335, 864, 1164, -611, -618, - 1275, 494, -1783, 119, 1222, - 752, 76, 270, 73, -57, - 376, -1255, 145, 724, 603, - -989, 618, 659, 675, 560, - 128, -147, -138, -368, 963, - 140, -170, 866, 538, 127, - 122, -616, 166, 236, -396, - 374, 279, 407, 650, -1269, - -861, 613, -755, -1334, -972, - -922, 314, 416, -114, -648, - 265, 85, 61, -1110, 45 + -332, -191, -122, -455, -210, + 364, -48, -664, 408, 225, + -576, -342, 367, 52, 270, + -392, -157, -77, 625, -224, + -183, -652, -406, 99, 266, + 24, 65, 74, 525, 613, + -805, 306, -383, -21, 247, + 16, 133, -416, -4, -567, + 294, -750, 443, -367, 228, + 536, 816, 767, 562, 594, + -54, 200, -1108, -582, 227, + 123, -43, 414, -376, -649, + 592, -652, -674, -386, -356, + 100, -58, -45, -108, 103, + -727, -194, -1170, 931, 1096, + 512, 758, -440, -769, -1051, + 362, 787, -276, -139, 149, + -218, 387, 457, -414, 265, + -202, 663, -1104, 882, -338, + -57, 405, 269, 257, -221, + 335, 864, 1164, -611, -618, + 1275, 494, -1783, 119, 1222, + 752, 76, 270, 73, -57, + 376, -1255, 145, 724, 603, + -989, 618, 659, 675, 560, + 128, -147, -138, -368, 963, + 140, -170, 866, 538, 127, + 122, -616, 166, 236, -396, + 374, 279, 407, 650, -1269, + -861, 613, -755, -1334, -972, + -922, 314, 416, -114, -648, + 265, 85, 61, -1110, 45 }; const Word16 YG_mean16HR_fx[] = @@ -18331,33 +18331,33 @@ const Word16 Odx_fft64[64] = { 0,59,54,49,44,39,34,29,24,19,14,9,4,63,58,53,48,43,38,33,28,23,18,13,8,3,62,57,52,47,42,37, 32,27,22,17,12,7,2,61,56,51,46,41,36,31,26,21,16,11,6,1,60,55,50,45,40,35,30,25,20,15,10,5 -}; // Q0 +}; // Q0 -const Word16 Ip_fft64[6] = { 32,1,0,64,32,96 }; // Q0 +const Word16 Ip_fft64[6] = { 32,1,0,64,32,96 }; // Q0 -const Word16 Odx_fft32_15[32] = { 0,17,2,19,4,21,6,23,8,25,10,27,12,29,14,31,16,1,18,3,20,5,22,7,24,9,26,11,28,13,30,15 }; // Q0 +const Word16 Odx_fft32_15[32] = { 0,17,2,19,4,21,6,23,8,25,10,27,12,29,14,31,16,1,18,3,20,5,22,7,24,9,26,11,28,13,30,15 }; // Q0 const Word32 w_fft32_16fx[16] =//Q30 { - 1073741824, 0, 759250113, 759250113, 992008059, 410903236, 410903236, 992008059, - 1053110143, 209476636, 596539003, 892783685, 892783685, 596539003, 209476636, 1053110143 + 1073741824, 0, 759250113, 759250113, 992008059, 410903236, 410903236, 992008059, + 1053110143, 209476636, 596539003, 892783685, 892783685, 596539003, 209476636, 1053110143 }; -const Word16 Ip_fft32[6] = { 16,1,0,32,16,48 }; // Q0 +const Word16 Ip_fft32[6] = { 16,1,0,32,16,48 }; // Q0 -const Word16 Odx_fft32_5[32] = { 0,27,22,17,12,7,2,29,24,19,14,9,4,31,26,21,16,11,6,1,28,23,18,13,8,3,30,25,20,15,10,5 }; // Q0 +const Word16 Odx_fft32_5[32] = { 0,27,22,17,12,7,2,29,24,19,14,9,4,31,26,21,16,11,6,1,28,23,18,13,8,3,30,25,20,15,10,5 }; // Q0 -const Word16 Odx_fft16[16] = {0,11,6,1,12,7,2,13,8,3,14,9,4,15,10,5}; // Q0 +const Word16 Odx_fft16[16] = {0,11,6,1,12,7,2,13,8,3,14,9,4,15,10,5}; // Q0 -const Word16 Ip_fft16[6] = {8,1,0,16,8,24}; // Q0 +const Word16 Ip_fft16[6] = {8,1,0,16,8,24}; // Q0 -const Word16 Ip_fft8[6] = {4,1,0,8,4,12}; // Q0 +const Word16 Ip_fft8[6] = {4,1,0,8,4,12}; // Q0 const Word16 Idx_dortft80[80] = { 0,65,50,35,20,5,70,55,40,25,10,75,60,45,30,15,16,1,66,51,36,21,6,71,56,41,26,11,76,61, 46,31,32,17,2,67,52,37,22,7,72,57,42,27,12,77,62,47,48,33,18,3,68,53,38,23,8,73,58,43, 28,13,78,63,64,49,34,19,4,69,54,39,24,9,74,59,44,29,14,79 -}; // Q0 +}; // Q0 const Word16 Idx_dortft120[120] = { @@ -18366,7 +18366,7 @@ const Word16 Idx_dortft120[120] = 96,81,66,51,36,21,6,111,112,97,82,67,52,37,22,7,8,113,98,83,68,53,38,23, 24,9,114,99,84,69,54,39,40,25,10,115,100,85,70,55,56,41,26,11,116,101,86, 71,72,57,42,27,12,117,102,87,88,73,58,43,28,13,118,103,104,89,74,59,44,29,14,119 -}; // Q0 +}; // Q0 const Word16 Idx_dortft160[160] = { @@ -18379,7 +18379,7 @@ const Word16 Idx_dortft160[160] = 108,13,78,143,48,113,18,83,148,53,118,23,88,153,58,123,28,93, 158,63,64,129,34,99,4,69,134,39,104,9,74,139,44,109,14,79, 144,49,114,19,84,149,54,119,24,89,154,59,124,29,94,159 -}; // Q0 +}; // Q0 const Word16 Idx_dortft320[320] = { @@ -18394,7 +18394,7 @@ const Word16 Idx_dortft320[320] = 58,123,188,253,318,63,64,129,194,259,4,69,134,199,264,9,74,139,204,269,14,79,144,209,274,19,84,149,214,279,24,89,154, 219,284,29,94,159,224,289,34,99,164,229,294,39,104,169,234,299,44,109,174,239,304,49,114,179,244,309,54,119,184,249, 314,59,124,189,254,319 -}; // Q0 +}; // Q0 const Word16 Idx_dortft480[480] = { @@ -18416,25 +18416,25 @@ const Word16 Idx_dortft480[480] = 117,342,87,312,57,282,27,252,477,222,447,448,193,418,163,388,133,358,103,328,73,298,43,268,13,238,463, 208,433,178,403,148,373,118,343,88,313,58,283,28,253,478,223,224,449,194,419,164,389,134,359,104,329,74, 299,44,269,14,239,464,209,434,179,404,149,374,119,344,89,314,59,284,29,254,479 -}; // Q0 +}; // Q0 -const Word16 Ip_fft128[10] = { 64, 1, 0, 128, 64, 192, 32, 160, 96, 224 }; // Q0 +const Word16 Ip_fft128[10] = { 64, 1, 0, 128, 64, 192, 32, 160, 96, 224 }; // Q0 const Word32 w_fft128_16fx[64] = { - 1073741824, 0, 759250112, 759250112, 992008064, 410903232, 410903232, 992008064, - 1053110144, 209476640, 596539008, 892783680, 892783680, 596539008, 209476640, 1053110144, - 1068571456, 105245104, 681174592, 830013632, 946955712, 506158400, 311690816, 1027506880, - 1027506880, 311690816, 506158400, 946955712, 830013632, 681174592, 105245104, 1068571456, - 1072448448, 52686008, 721080960, 795590208, 970651136, 459083776, 361732736, 1010975232, - 1041563136, 260897968, 552013632, 920979072, 862437504, 639627264, 157550640, 1062120192, - 1062120192, 157550640, 639627264, 862437504, 920979072, 552013632, 260897968, 1041563136, - 1010975232, 361732736, 459083776, 970651136, 795590208, 721080960, 52686008, 1072448448, -}; // Q30 + 1073741824, 0, 759250112, 759250112, 992008064, 410903232, 410903232, 992008064, + 1053110144, 209476640, 596539008, 892783680, 892783680, 596539008, 209476640, 1053110144, + 1068571456, 105245104, 681174592, 830013632, 946955712, 506158400, 311690816, 1027506880, + 1027506880, 311690816, 506158400, 946955712, 830013632, 681174592, 105245104, 1068571456, + 1072448448, 52686008, 721080960, 795590208, 970651136, 459083776, 361732736, 1010975232, + 1041563136, 260897968, 552013632, 920979072, 862437504, 639627264, 157550640, 1062120192, + 1062120192, 157550640, 639627264, 862437504, 920979072, 552013632, 260897968, 1041563136, + 1010975232, 361732736, 459083776, 970651136, 795590208, 721080960, 52686008, 1072448448, +}; // Q30 -const Word16 Ip_fft256[10] = {128, 1, 0, 256, 128, 384, 64, 320,192, 448}; // Q0 +const Word16 Ip_fft256[10] = {128, 1, 0, 256, 128, 384, 64, 320,192, 448}; // Q0 -const Word16 Ip_fft512[18] = {256, 1, 0, 512, 256, 768, 128, 640,384, 896, 64, 576, 320, 832, 192, 704,448, 960}; // Q0 +const Word16 Ip_fft512[18] = {256, 1, 0, 512, 256, 768, 128, 640,384, 896, 64, 576, 320, 832, 192, 704,448, 960}; // Q0 const Word16 w_fft512_fx_evs[256] =//Q14 { @@ -18475,13 +18475,13 @@ const Word16 Idx_dortft40[40] = { 0, 25, 10, 35, 20, 5, 30, 15, 16, 1, 26, 11, 36, 21, 6, 31, 32, 17, 2, 27, 12, 37, 22, 7, 8, 33, 18, 3, 28, 13, 38, 23, 24, 9, 34, 19, 4, 29, 14, 39 -}; // Q0 +}; // Q0 -const Word16 Odx_fft8_5[8] = {0, 3, 6, 1, 4, 7, 2, 5}; // Q0 -const Word16 Idx_dortft20[20] = {0, 5, 10, 15, 16, 1, 6, 11, 12, 17, 2, 7, 8, 13, 18, 3, 4, 9, 14, 19}; // Q0 -const Word16 Odx_fft4_5[4] = {0, 3, 2, 1}; // Q0 -const Word16 Ip_fft4[6] = {2,1,0,4,2,6}; // Q0 -const Word16 ip_edct2_64[6] = {16, 64, 0, 32, 16, 48}; // Q0 +const Word16 Odx_fft8_5[8] = {0, 3, 6, 1, 4, 7, 2, 5}; // Q0 +const Word16 Idx_dortft20[20] = {0, 5, 10, 15, 16, 1, 6, 11, 12, 17, 2, 7, 8, 13, 18, 3, 4, 9, 14, 19}; // Q0 +const Word16 Odx_fft4_5[4] = {0, 3, 2, 1}; // Q0 +const Word16 Ip_fft4[6] = {2,1,0,4,2,6}; // Q0 +const Word16 ip_edct2_64[6] = {16, 64, 0, 32, 16, 48}; // Q0 const Word16 w_edct2_64_fx[80] = /*Q14 */ { @@ -18517,7 +18517,7 @@ const Word16 hvq_cb_search_overlap24k[17] = 113, 128, 128, 128, 128, 128, 128, 128, 128 -}; // Q0 +}; // Q0 const Word16 hvq_cb_search_overlap32k[21] = { @@ -18527,7 +18527,7 @@ const Word16 hvq_cb_search_overlap32k[21] = 128, 128, 128, 128, 128, 128, 128, 128, 128 -}; // Q0 +}; // Q0 const Word16 hvq_peak_cb_fx[1024] = /* Q15 */ { @@ -18636,43 +18636,43 @@ const Word16 hvq_peak_cb_fx[1024] = /* Q15 */ 6066, 4720, 25084,-28951 }; -const Word16 hvq_pg_huff_offset[NUM_PG_HUFFLEN] = {0,2,3,8,9,11,13,15,19}; // Q0 -const Word16 hvq_pg_huff_thres[NUM_PG_HUFFLEN] = {0,0x2,0x4,0x18,0x20,0x40,0x80,0x100,0x300}; // Q0 +const Word16 hvq_pg_huff_offset[NUM_PG_HUFFLEN] = {0,2,3,8,9,11,13,15,19}; // Q0 +const Word16 hvq_pg_huff_thres[NUM_PG_HUFFLEN] = {0,0x2,0x4,0x18,0x20,0x40,0x80,0x100,0x300}; // Q0 const Word16 hvq_pg_huff_tab[32] = { 30, 31, 1, 0, 2, 3, 28, 29, 4, 5, 27, 25, 26, 6, 24, 7, 8, 22, 23, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 -}; // Q0 +}; // Q0 const Word16 hvq_cp_huff_len[52] = { 3, 4, 5, 6, 6, 6, 6, 6, 4, 4, 5, 5, 5, 5, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 8, 9, 10, 10, 11, 11, 11, 10, 10, 10, 10, 11, 12, 12, 13, 13, 12, 12, 11, 12 -}; // Q0 +}; // Q0 const Word16 hvq_cp_huff_val[52] = { 7, 8, 6, 3, 4, 5, 6, 7, 9, 10, 7, 8, 9, 10, 11, 12, 13, 11, 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 3, 4, 5, 6, 7, 5, 4, 5, 3, 4, 5, 6, 7, 8, 9, 6, 1, 2, 0, 1, 3, 4, 7, 5 -}; // Q0 +}; // Q0 -const Word16 hvq_cp_layer1_map5[HVQ_CP_MAP_LEN] = { 16, 8, 4, 2, 1, 18, 17, 9 }; // Q0 +const Word16 hvq_cp_layer1_map5[HVQ_CP_MAP_LEN] = { 16, 8, 4, 2, 1, 18, 17, 9 }; // Q0 -const Word16 hvq_cp_huff_thres[HVQ_CP_HUFF_NUM_LEN] = { 0x0, 0x2, 0xC, 0x20, 0x50, 0x60, 0x100, 0x180, 0x600, 0x1000, 0x1C00 }; // Q0 -const Word16 hvq_cp_huff_offset[HVQ_CP_HUFF_NUM_LEN] = { 0, 2, 7, 12, 18, 19, 24, 26, 35, 45, 51 }; // Q0 +const Word16 hvq_cp_huff_thres[HVQ_CP_HUFF_NUM_LEN] = { 0x0, 0x2, 0xC, 0x20, 0x50, 0x60, 0x100, 0x180, 0x600, 0x1000, 0x1C00 }; // Q0 +const Word16 hvq_cp_huff_offset[HVQ_CP_HUFF_NUM_LEN] = { 0, 2, 7, 12, 18, 19, 24, 26, 35, 45, 51 }; // Q0 const Word16 hvq_cp_huff_tab[52] = { 46, 47, 44, 45, 48, 49, 51, 36, 37, 38, 43, 50, 34, 35, 39, 40, 41, 42, 33, 28, 29, 30, 31, 32, 26, 27, 3, 4, 5, 6, 7, 22, 23, 24, 25, 2, 10, 11, 12, 13, 17, 18, 19, 20, 21, 1, 8, 9, 14, 15, 16, 0 -}; // Q0 +}; // Q0 /*----------------------------------------------------------------------------------* * FEC for HQ core *----------------------------------------------------------------------------------*/ -const Word16 Num_bands_NB[MAX_SB_NB] = {8,8,2}; // Q0 +const Word16 Num_bands_NB[MAX_SB_NB] = {8,8,2}; // Q0 const Word16 SmoothingWin_NB875_fx[70] = /*Q15*/ { @@ -18698,430 +18698,430 @@ const Word16 bp1_den_coef_wb_fx[5] = { 16384, 0, -30498, 0, 14262, }; /* Q14 */ const Word16 shape1_num_coef_fx[11] = /* Q15 */ { - 31437, -2443, -13636, 4316, - -10188, 48, 2639, -3575, - -776, 1046, 399 + 31437, -2443, -13636, 4316, + -10188, 48, 2639, -3575, + -776, 1046, 399 }; const Word16 shape1_den_coef_fx[11] = { 32767, /* Q15 */ - 2940, -12237, 4032, -9609, - -1998, 2335, -3900, -1595, - 857, 253 + 2940, -12237, 4032, -9609, + -1998, 2335, -3900, -1595, + 857, 253 }; const Word16 shape2_num_coef_fx[11] = /* Q15 */ { - 30760, 31, -9699, 9516, - -5878, -7249, -10468, 442, - 3278, -63, 1115 + 30760, 31, -9699, 9516, + -5878, -7249, -10468, 442, + 3278, -63, 1115 }; const Word16 shape2_den_coef_fx[11] = { 32767, /* Q15 */ - 16019, -890, 12799, 2346, - -6985, -13192, -5795, -949, - -1492, -304 + 16019, -890, 12799, 2346, + -6985, -13192, -5795, -949, + -1492, -304 }; const Word16 shape3_num_coef_fx[11] = /* Q15 */ { - 30685, -383, -9937, -9605, - -5997, 7611, -10393, -355, - 3239, 12, 1196 + 30685, -383, -9937, -9605, + -5997, 7611, -10393, -355, + 3239, 12, 1196 }; const Word16 shape3_den_coef_fx[11] = { 32767, /* Q15 */ - -16498, -911, -12947, 2286, - 7430, -13385, 6066, -1182, - 1580, -273 + -16498, -911, -12947, 2286, + 7430, -13385, 6066, -1182, + 1580, -273 }; const Word16 txlpf1_num_coef_fx[11] = /* Q13 */ { - 138, 198, 514, 681, 921, - 964, 921, 681, 514, 198, - 138, + 138, 198, 514, 681, 921, + 964, 921, 681, 514, 198, + 138, }; const Word16 txlpf1_den_coef_fx[11] = /* Q13 */ { - 8192,-18945, 31613,-31149, 24494, - -12753, 5528, -1436, 347, -25, - 4, + 8192,-18945, 31613,-31149, 24494, + -12753, 5528, -1436, 347, -25, + 4, }; const Word16 txhpf1_num_coef_fx[11] = /* Q13 */ { - 138, -198, 514, -681, 921, - -964, 921, -681, 514, -198, - 138, + 138, -198, 514, -681, 921, + -964, 921, -681, 514, -198, + 138, }; const Word16 txhpf1_den_coef_fx[11] = /* Q13 */ { - 8192, 18945, 31613, 31149, 24494, - 12753, 5528, 1436, 347, 25, - 4, + 8192, 18945, 31613, 31149, 24494, + 12753, 5528, 1436, 347, 25, + 4, }; /* NELP filter coefficients */ const Word16 bp1_num_coef_nb_fx_order7[8] = { - /* Q = BP1_COEF_NB_QF_ORDER7 = 13 */ - 1481, 6730, 15579, 22923, 22923, 15579, 6730, 1481, + /* Q = BP1_COEF_NB_QF_ORDER7 = 13 */ + 1481, 6730, 15579, 22923, 22923, 15579, 6730, 1481, }; const Word16 bp1_den_coef_nb_fx_order7[8] = { - /* Q = BP1_COEF_NB_QF_ORDER7 = 13 */ - 8192, 16156, 23814, 21855, 14620, 6614, 1907, 268, + /* Q = BP1_COEF_NB_QF_ORDER7 = 13 */ + 8192, 16156, 23814, 21855, 14620, 6614, 1907, 268, }; /* NELP gain tables */ const Word16 UVG1CB_WB_FX[UVG1_CBSIZE][2] = /* Q13 */ { - { -2224, -2114, }, - { 12666, 12314, }, - { 3723, 9690, }, - { 17880, 17978, }, - { 4136, 3946, }, - { 11605, 21280, }, - { 9777, 9340, }, - { 21701, 21627, }, - { 1088, 1679, }, - { 13993, 13697, }, - { 10443, 5214, }, - { 19702, 19692, }, - { 5458, 5317, }, - { 17051, 16918, }, - { 14206, 8503, }, - { 24330, 24271, }, - { -118, -279, }, - { 11615, 14863, }, - { 6898, 6544, }, - { 18913, 18637, }, - { 1142, 6811, }, - { 15995, 16070, }, - { 6921, 13182, }, - { 22857, 22741, }, - { 3017, 2260, }, - { 14952, 14992, }, - { 8176, 8093, }, - { 20721, 20549, }, - { 7441, 2370, }, - { 17897, 13988, }, - { 10986, 10966, }, - { 26098, 25992, }, + { -2224, -2114, }, + { 12666, 12314, }, + { 3723, 9690, }, + { 17880, 17978, }, + { 4136, 3946, }, + { 11605, 21280, }, + { 9777, 9340, }, + { 21701, 21627, }, + { 1088, 1679, }, + { 13993, 13697, }, + { 10443, 5214, }, + { 19702, 19692, }, + { 5458, 5317, }, + { 17051, 16918, }, + { 14206, 8503, }, + { 24330, 24271, }, + { -118, -279, }, + { 11615, 14863, }, + { 6898, 6544, }, + { 18913, 18637, }, + { 1142, 6811, }, + { 15995, 16070, }, + { 6921, 13182, }, + { 22857, 22741, }, + { 3017, 2260, }, + { 14952, 14992, }, + { 8176, 8093, }, + { 20721, 20549, }, + { 7441, 2370, }, + { 17897, 13988, }, + { 10986, 10966, }, + { 26098, 25992, }, }; const Word16 UVG1CB_NB_FX[UVG1_CBSIZE][2] = /* Q13 */ { - { -4791, -5157, }, - { 4824, 4937, }, - { -3443, 3610, }, - { 5539, 15293, }, - { -469, -3986, }, - { 7977, 8157, }, - { 2748, 2492, }, - { 14070, 14014, }, - { -2486, -2863, }, - { 6033, 5892, }, - { 2678, -441, }, - { 11741, 11804, }, - { -256, -847, }, - { 9153, 8922, }, - { -106, 5979, }, - { 16876, 16741, }, - { -3584, -3873, }, - { 3511, 9538, }, - { 401, 416, }, - { 11082, 10550, }, - { -1418, -1725, }, - { 8988, 5255, }, - { 6275, 1137, }, - { 15372, 15247, }, - { -3899, 301, }, - { 6976, 7095, }, - { 1581, 1453, }, - { 12988, 12824, }, - { 2692, -3093, }, - { 9778, 10153, }, - { 3938, 3628, }, - { 18823, 18695, }, + { -4791, -5157, }, + { 4824, 4937, }, + { -3443, 3610, }, + { 5539, 15293, }, + { -469, -3986, }, + { 7977, 8157, }, + { 2748, 2492, }, + { 14070, 14014, }, + { -2486, -2863, }, + { 6033, 5892, }, + { 2678, -441, }, + { 11741, 11804, }, + { -256, -847, }, + { 9153, 8922, }, + { -106, 5979, }, + { 16876, 16741, }, + { -3584, -3873, }, + { 3511, 9538, }, + { 401, 416, }, + { 11082, 10550, }, + { -1418, -1725, }, + { 8988, 5255, }, + { 6275, 1137, }, + { 15372, 15247, }, + { -3899, 301, }, + { 6976, 7095, }, + { 1581, 1453, }, + { 12988, 12824, }, + { 2692, -3093, }, + { 9778, 10153, }, + { 3938, 3628, }, + { 18823, 18695, }, }; const Word16 UVG2CB1_WB_FX[UVG2_CBSIZE][5] = /* Q12 */ { - { 914, 990, 1490, 5954, 2618, }, - { 5599, 4621, 4078, 3493, 3057, }, - { 4930, 4031, 2999, 2150, 1706, }, - { 7722, 3021, 1804, 1478, 1452, }, - { 1171, 1390, 6895, 2592, 1486, }, - { 4155, 4287, 4409, 4515, 4577, }, - { 3633, 3661, 3694, 3711, 3736, }, - { 13212, 5009, 2611, 2175, 2048, }, - { 3716, 2887, 2253, 1965, 1723, }, - { 7141, 4567, 3434, 2970, 2396, }, - { 2856, 3038, 3259, 3481, 3709, }, - { 5929, 5459, 4923, 4448, 4084, }, - { 980, 1024, 1550, 5686, 8038, }, - { 3516, 7354, 10392, 3619, 2856, }, - { 2598, 3093, 3582, 4780, 5965, }, - { 1962, 10993, 5020, 2861, 2587, }, - { 796, 916, 1010, 1175, 7720, }, - { 4445, 4406, 4344, 4249, 4175, }, - { 1454, 6493, 2611, 1758, 1765, }, - { 6296, 7686, 4763, 2945, 2203, }, - { 1502, 1573, 1895, 2981, 5464, }, - { 4750, 4829, 4909, 4929, 4895, }, - { 3644, 3774, 3922, 4037, 4116, }, - { 9051, 7403, 6003, 4746, 4081, }, - { 1558, 1869, 2331, 3000, 3595, }, - { 4671, 4646, 4614, 4553, 4482, }, - { 2262, 2608, 3158, 3890, 4468, }, - { 5556, 5441, 6824, 7146, 5724, }, - { 1470, 1550, 2016, 11169, 3828, }, - { 5488, 6270, 6771, 8202, 9281, }, - { 3477, 3693, 4113, 4460, 4705, }, - { 10877, 17984, 10194, 7291, 2824, }, - { 1327, 1498, 1476, 1667, 2138, }, - { 4463, 4299, 4094, 3880, 3731, }, - { 3188, 3164, 3156, 3104, 3140, }, - { 9757, 5690, 3366, 2296, 1792, }, - { 1731, 1753, 12406, 4082, 2247, }, - { 3866, 4060, 5007, 5274, 5225, }, - { 3998, 3957, 3900, 3839, 3789, }, - { 18040, 9417, 5567, 3465, 2504, }, - { 2160, 2532, 2895, 2577, 2321, }, - { 5052, 4789, 4490, 4203, 3953, }, - { 3381, 3415, 3458, 3496, 3536, }, - { 6166, 5811, 5440, 5035, 4650, }, - { 2839, 3389, 5057, 7558, 10414, }, - { 3875, 4431, 5183, 6310, 7166, }, - { 4311, 4130, 3571, 3070, 8555, }, - { 8791, 8260, 7299, 6243, 5421, }, - { 1191, 1237, 1368, 1814, 11819, }, - { 2486, 5729, 6150, 4222, 3667, }, - { 4018, 3825, 3600, 3388, 3256, }, - { 7504, 5817, 4989, 4065, 3322, }, - { 1430, 1962, 5546, 4096, 4681, }, - { 5393, 5378, 5324, 5230, 5052, }, - { 4041, 4090, 4132, 4159, 4181, }, - { 12469, 9221, 5735, 3617, 2501, }, - { 2482, 2565, 2768, 3088, 3461, }, - { 5209, 5080, 4905, 4706, 4522, }, - { 3139, 3362, 3647, 3910, 4156, }, - { 7139, 6588, 5941, 5251, 4674, }, - { 1719, 1866, 7993, 7634, 3987, }, - { 3587, 5289, 7882, 13519, 16095, }, - { 2409, 2515, 2749, 7316, 4636, }, - { 30391, 18493, 13798, 4799, 2283, }, + { 914, 990, 1490, 5954, 2618, }, + { 5599, 4621, 4078, 3493, 3057, }, + { 4930, 4031, 2999, 2150, 1706, }, + { 7722, 3021, 1804, 1478, 1452, }, + { 1171, 1390, 6895, 2592, 1486, }, + { 4155, 4287, 4409, 4515, 4577, }, + { 3633, 3661, 3694, 3711, 3736, }, + { 13212, 5009, 2611, 2175, 2048, }, + { 3716, 2887, 2253, 1965, 1723, }, + { 7141, 4567, 3434, 2970, 2396, }, + { 2856, 3038, 3259, 3481, 3709, }, + { 5929, 5459, 4923, 4448, 4084, }, + { 980, 1024, 1550, 5686, 8038, }, + { 3516, 7354, 10392, 3619, 2856, }, + { 2598, 3093, 3582, 4780, 5965, }, + { 1962, 10993, 5020, 2861, 2587, }, + { 796, 916, 1010, 1175, 7720, }, + { 4445, 4406, 4344, 4249, 4175, }, + { 1454, 6493, 2611, 1758, 1765, }, + { 6296, 7686, 4763, 2945, 2203, }, + { 1502, 1573, 1895, 2981, 5464, }, + { 4750, 4829, 4909, 4929, 4895, }, + { 3644, 3774, 3922, 4037, 4116, }, + { 9051, 7403, 6003, 4746, 4081, }, + { 1558, 1869, 2331, 3000, 3595, }, + { 4671, 4646, 4614, 4553, 4482, }, + { 2262, 2608, 3158, 3890, 4468, }, + { 5556, 5441, 6824, 7146, 5724, }, + { 1470, 1550, 2016, 11169, 3828, }, + { 5488, 6270, 6771, 8202, 9281, }, + { 3477, 3693, 4113, 4460, 4705, }, + { 10877, 17984, 10194, 7291, 2824, }, + { 1327, 1498, 1476, 1667, 2138, }, + { 4463, 4299, 4094, 3880, 3731, }, + { 3188, 3164, 3156, 3104, 3140, }, + { 9757, 5690, 3366, 2296, 1792, }, + { 1731, 1753, 12406, 4082, 2247, }, + { 3866, 4060, 5007, 5274, 5225, }, + { 3998, 3957, 3900, 3839, 3789, }, + { 18040, 9417, 5567, 3465, 2504, }, + { 2160, 2532, 2895, 2577, 2321, }, + { 5052, 4789, 4490, 4203, 3953, }, + { 3381, 3415, 3458, 3496, 3536, }, + { 6166, 5811, 5440, 5035, 4650, }, + { 2839, 3389, 5057, 7558, 10414, }, + { 3875, 4431, 5183, 6310, 7166, }, + { 4311, 4130, 3571, 3070, 8555, }, + { 8791, 8260, 7299, 6243, 5421, }, + { 1191, 1237, 1368, 1814, 11819, }, + { 2486, 5729, 6150, 4222, 3667, }, + { 4018, 3825, 3600, 3388, 3256, }, + { 7504, 5817, 4989, 4065, 3322, }, + { 1430, 1962, 5546, 4096, 4681, }, + { 5393, 5378, 5324, 5230, 5052, }, + { 4041, 4090, 4132, 4159, 4181, }, + { 12469, 9221, 5735, 3617, 2501, }, + { 2482, 2565, 2768, 3088, 3461, }, + { 5209, 5080, 4905, 4706, 4522, }, + { 3139, 3362, 3647, 3910, 4156, }, + { 7139, 6588, 5941, 5251, 4674, }, + { 1719, 1866, 7993, 7634, 3987, }, + { 3587, 5289, 7882, 13519, 16095, }, + { 2409, 2515, 2749, 7316, 4636, }, + { 30391, 18493, 13798, 4799, 2283, }, }; const Word16 UVG2CB2_WB_FX[UVG2_CBSIZE][5] = /* Q12 */ { - { 1565, 1391, 1635, 5228, 2681, }, - { 2156, 2558, 6205, 5561, 3944, }, - { 2039, 2406, 3094, 3409, 3968, }, - { 5090, 5065, 4989, 4858, 4764, }, - { 1436, 1736, 2816, 2362, 2400, }, - { 4375, 4425, 4465, 4478, 4493, }, - { 4648, 4081, 3550, 2981, 2667, }, - { 1705, 1950, 3679, 7828, 9895, }, - { 2839, 1826, 1443, 1210, 1245, }, - { 1387, 1410, 1768, 8873, 4383, }, - { 4022, 3784, 3565, 3316, 3096, }, - { 9983, 7147, 5225, 3742, 3027, }, - { 6769, 2357, 1531, 1448, 1556, }, - { 4591, 4671, 4735, 4765, 4789, }, - { 4308, 4198, 4052, 3896, 3769, }, - { 2288, 2550, 4922, 8294, 14878, }, - { 1361, 1480, 1511, 1991, 10450, }, - { 2933, 3131, 3694, 4687, 5201, }, - { 3984, 3048, 2479, 2644, 5514, }, - { 5353, 5480, 5488, 5434, 5437, }, - { 3319, 2881, 2528, 2152, 1927, }, - { 4873, 4748, 4578, 4407, 4257, }, - { 6185, 4396, 3751, 3400, 2899, }, - { 2159, 8067, 7534, 5121, 3640, }, - { 2265, 10177, 3803, 2588, 2441, }, - { 2188, 2206, 4293, 12691, 5893, }, - { 3587, 3651, 3760, 3864, 3960, }, - { 13158, 9752, 7171, 5431, 5364, }, - { 5710, 4173, 2928, 2090, 1774, }, - { 3531, 3831, 4641, 5787, 6622, }, - { 4395, 4356, 4281, 4194, 4111, }, - { 2243, 2476, 5814, 3965, 27176, }, - { 1575, 1667, 7544, 3005, 1984, }, - { 2583, 2511, 11684, 5765, 4807, }, - { 3632, 3458, 3277, 3114, 2971, }, - { 8569, 6778, 5866, 5515, 5141, }, - { 3267, 3035, 2940, 2782, 2691, }, - { 3929, 4249, 4577, 4877, 5162, }, - { 4443, 4173, 3864, 3590, 3337, }, - { 3998, 4725, 5728, 6873, 7885, }, - { 4369, 2824, 2237, 1648, 1404, }, - { 1000, 1022, 1477, 2682, 15276, }, - { 3916, 3851, 3766, 3664, 3591, }, - { 13206, 4485, 3230, 3897, 3648, }, - { 10002, 3515, 2393, 2233, 2211, }, - { 4603, 4836, 5071, 5259, 5411, }, - { 3919, 4035, 4177, 4304, 4419, }, - { 3046, 8332, 16475, 11172, 10858, }, - { 1027, 1007, 1196, 1578, 5937, }, - { 1892, 2422, 3227, 3920, 7400, }, - { 3584, 3532, 3508, 3470, 3437, }, - { 5363, 6155, 6805, 6854, 6811, }, - { 4038, 3512, 3030, 2636, 2332, }, - { 6760, 6124, 5235, 4299, 3687, }, - { 4125, 6528, 4068, 3238, 3483, }, - { 5020, 5905, 7082, 8554, 9623, }, - { 1399, 5868, 3069, 1726, 1655, }, - { 4691, 4234, 3974, 3757, 9616, }, - { 3978, 4003, 4003, 3983, 3960, }, - { 2103, 16858, 9252, 4860, 4727, }, - { 8043, 5294, 3970, 3098, 2583, }, - { 4680, 5109, 5576, 5965, 6275, }, - { 4867, 4584, 4276, 3958, 3682, }, - { 1213, 3115, 6552, 22778, 20977, }, + { 1565, 1391, 1635, 5228, 2681, }, + { 2156, 2558, 6205, 5561, 3944, }, + { 2039, 2406, 3094, 3409, 3968, }, + { 5090, 5065, 4989, 4858, 4764, }, + { 1436, 1736, 2816, 2362, 2400, }, + { 4375, 4425, 4465, 4478, 4493, }, + { 4648, 4081, 3550, 2981, 2667, }, + { 1705, 1950, 3679, 7828, 9895, }, + { 2839, 1826, 1443, 1210, 1245, }, + { 1387, 1410, 1768, 8873, 4383, }, + { 4022, 3784, 3565, 3316, 3096, }, + { 9983, 7147, 5225, 3742, 3027, }, + { 6769, 2357, 1531, 1448, 1556, }, + { 4591, 4671, 4735, 4765, 4789, }, + { 4308, 4198, 4052, 3896, 3769, }, + { 2288, 2550, 4922, 8294, 14878, }, + { 1361, 1480, 1511, 1991, 10450, }, + { 2933, 3131, 3694, 4687, 5201, }, + { 3984, 3048, 2479, 2644, 5514, }, + { 5353, 5480, 5488, 5434, 5437, }, + { 3319, 2881, 2528, 2152, 1927, }, + { 4873, 4748, 4578, 4407, 4257, }, + { 6185, 4396, 3751, 3400, 2899, }, + { 2159, 8067, 7534, 5121, 3640, }, + { 2265, 10177, 3803, 2588, 2441, }, + { 2188, 2206, 4293, 12691, 5893, }, + { 3587, 3651, 3760, 3864, 3960, }, + { 13158, 9752, 7171, 5431, 5364, }, + { 5710, 4173, 2928, 2090, 1774, }, + { 3531, 3831, 4641, 5787, 6622, }, + { 4395, 4356, 4281, 4194, 4111, }, + { 2243, 2476, 5814, 3965, 27176, }, + { 1575, 1667, 7544, 3005, 1984, }, + { 2583, 2511, 11684, 5765, 4807, }, + { 3632, 3458, 3277, 3114, 2971, }, + { 8569, 6778, 5866, 5515, 5141, }, + { 3267, 3035, 2940, 2782, 2691, }, + { 3929, 4249, 4577, 4877, 5162, }, + { 4443, 4173, 3864, 3590, 3337, }, + { 3998, 4725, 5728, 6873, 7885, }, + { 4369, 2824, 2237, 1648, 1404, }, + { 1000, 1022, 1477, 2682, 15276, }, + { 3916, 3851, 3766, 3664, 3591, }, + { 13206, 4485, 3230, 3897, 3648, }, + { 10002, 3515, 2393, 2233, 2211, }, + { 4603, 4836, 5071, 5259, 5411, }, + { 3919, 4035, 4177, 4304, 4419, }, + { 3046, 8332, 16475, 11172, 10858, }, + { 1027, 1007, 1196, 1578, 5937, }, + { 1892, 2422, 3227, 3920, 7400, }, + { 3584, 3532, 3508, 3470, 3437, }, + { 5363, 6155, 6805, 6854, 6811, }, + { 4038, 3512, 3030, 2636, 2332, }, + { 6760, 6124, 5235, 4299, 3687, }, + { 4125, 6528, 4068, 3238, 3483, }, + { 5020, 5905, 7082, 8554, 9623, }, + { 1399, 5868, 3069, 1726, 1655, }, + { 4691, 4234, 3974, 3757, 9616, }, + { 3978, 4003, 4003, 3983, 3960, }, + { 2103, 16858, 9252, 4860, 4727, }, + { 8043, 5294, 3970, 3098, 2583, }, + { 4680, 5109, 5576, 5965, 6275, }, + { 4867, 4584, 4276, 3958, 3682, }, + { 1213, 3115, 6552, 22778, 20977, }, }; const Word16 UVG2CB1_NB_FX[UVG2_CBSIZE][5] = /* Q12 */ { - { 773, 785, 785, 785, 860, }, - { 3560, 3521, 3410, 3265, 3167, }, - { 1766, 2982, 10273, 3790, 2248, }, - { 4986, 4753, 4496, 4172, 3922, }, - { 2036, 2030, 2009, 1973, 1897, }, - { 3291, 3554, 3868, 4126, 4345, }, - { 3207, 3122, 3026, 2913, 2797, }, - { 13220, 6844, 3967, 2746, 2466, }, - { 1553, 1627, 1392, 1766, 3679, }, - { 5379, 4640, 3844, 3254, 2635, }, - { 1600, 1622, 2430, 9446, 4214, }, - { 5115, 5200, 5311, 5365, 5343, }, - { 6229, 3008, 1989, 1622, 1597, }, - { 1726, 2114, 7046, 6162, 4301, }, - { 1004, 1056, 1841, 6006, 7101, }, - { 6388, 9659, 4510, 2774, 2113, }, - { 1060, 1153, 1400, 1733, 2121, }, - { 3448, 3523, 3612, 3683, 3770, }, - { 1496, 2045, 2910, 3563, 4058, }, - { 4419, 4592, 4795, 4921, 4978, }, - { 1407, 5314, 2788, 1675, 1350, }, - { 4210, 4225, 4227, 4186, 4169, }, - { 2247, 8245, 4392, 2522, 1709, }, - { 7211, 6741, 6110, 5397, 4680, }, - { 3602, 2286, 1577, 1229, 1148, }, - { 6674, 5227, 3576, 2448, 1901, }, - { 954, 1035, 1079, 1683, 9558, }, - { 4011, 5853, 8979, 7138, 4484, }, - { 2784, 2702, 2637, 2546, 2471, }, - { 4414, 4065, 4627, 4208, 9275, }, - { 2771, 3012, 3357, 3735, 4066, }, - { 19742, 8603, 3943, 2546, 2085, }, - { 1132, 1123, 1107, 1093, 1114, }, - { 3913, 3838, 3733, 3630, 3548, }, - { 948, 1565, 6063, 2654, 1667, }, - { 6159, 5567, 4884, 4241, 3770, }, - { 925, 1164, 1585, 6062, 3090, }, - { 3818, 4037, 4322, 4536, 4726, }, - { 4291, 3894, 3441, 3006, 2733, }, - { 8544, 6487, 4962, 3812, 2970, }, - { 1744, 1758, 1704, 1633, 1576, }, - { 4416, 4259, 4044, 3810, 3628, }, - { 1919, 2159, 3323, 13977, 7898, }, - { 5952, 5731, 5419, 5061, 4732, }, - { 2775, 2812, 2507, 2540, 6585, }, - { 3436, 3960, 4661, 5975, 6274, }, - { 3082, 3150, 3246, 3337, 3404, }, - { 4089, 16018, 8285, 4116, 2704, }, - { 1419, 1425, 1400, 1371, 1363, }, - { 3825, 3890, 3953, 3993, 4015, }, - { 2498, 2689, 2846, 3011, 3213, }, - { 5122, 5024, 4881, 4691, 4524, }, - { 2285, 2325, 2317, 2313, 2271, }, - { 4493, 4529, 4517, 4478, 4443, }, - { 9138, 3969, 2522, 2222, 2415, }, - { 10009, 8719, 7292, 5837, 4532, }, - { 831, 908, 1039, 1656, 6813, }, - { 2070, 5478, 5174, 3911, 3694, }, - { 1577, 1565, 1635, 2583, 13154, }, - { 5590, 5788, 5922, 6752, 7063, }, - { 4061, 3497, 2710, 2099, 1716, }, - { 2750, 3118, 16574, 7891, 3651, }, - { 2598, 3072, 3809, 4906, 5172, }, - { 15348, 10948, 7740, 4979, 3446, }, + { 773, 785, 785, 785, 860, }, + { 3560, 3521, 3410, 3265, 3167, }, + { 1766, 2982, 10273, 3790, 2248, }, + { 4986, 4753, 4496, 4172, 3922, }, + { 2036, 2030, 2009, 1973, 1897, }, + { 3291, 3554, 3868, 4126, 4345, }, + { 3207, 3122, 3026, 2913, 2797, }, + { 13220, 6844, 3967, 2746, 2466, }, + { 1553, 1627, 1392, 1766, 3679, }, + { 5379, 4640, 3844, 3254, 2635, }, + { 1600, 1622, 2430, 9446, 4214, }, + { 5115, 5200, 5311, 5365, 5343, }, + { 6229, 3008, 1989, 1622, 1597, }, + { 1726, 2114, 7046, 6162, 4301, }, + { 1004, 1056, 1841, 6006, 7101, }, + { 6388, 9659, 4510, 2774, 2113, }, + { 1060, 1153, 1400, 1733, 2121, }, + { 3448, 3523, 3612, 3683, 3770, }, + { 1496, 2045, 2910, 3563, 4058, }, + { 4419, 4592, 4795, 4921, 4978, }, + { 1407, 5314, 2788, 1675, 1350, }, + { 4210, 4225, 4227, 4186, 4169, }, + { 2247, 8245, 4392, 2522, 1709, }, + { 7211, 6741, 6110, 5397, 4680, }, + { 3602, 2286, 1577, 1229, 1148, }, + { 6674, 5227, 3576, 2448, 1901, }, + { 954, 1035, 1079, 1683, 9558, }, + { 4011, 5853, 8979, 7138, 4484, }, + { 2784, 2702, 2637, 2546, 2471, }, + { 4414, 4065, 4627, 4208, 9275, }, + { 2771, 3012, 3357, 3735, 4066, }, + { 19742, 8603, 3943, 2546, 2085, }, + { 1132, 1123, 1107, 1093, 1114, }, + { 3913, 3838, 3733, 3630, 3548, }, + { 948, 1565, 6063, 2654, 1667, }, + { 6159, 5567, 4884, 4241, 3770, }, + { 925, 1164, 1585, 6062, 3090, }, + { 3818, 4037, 4322, 4536, 4726, }, + { 4291, 3894, 3441, 3006, 2733, }, + { 8544, 6487, 4962, 3812, 2970, }, + { 1744, 1758, 1704, 1633, 1576, }, + { 4416, 4259, 4044, 3810, 3628, }, + { 1919, 2159, 3323, 13977, 7898, }, + { 5952, 5731, 5419, 5061, 4732, }, + { 2775, 2812, 2507, 2540, 6585, }, + { 3436, 3960, 4661, 5975, 6274, }, + { 3082, 3150, 3246, 3337, 3404, }, + { 4089, 16018, 8285, 4116, 2704, }, + { 1419, 1425, 1400, 1371, 1363, }, + { 3825, 3890, 3953, 3993, 4015, }, + { 2498, 2689, 2846, 3011, 3213, }, + { 5122, 5024, 4881, 4691, 4524, }, + { 2285, 2325, 2317, 2313, 2271, }, + { 4493, 4529, 4517, 4478, 4443, }, + { 9138, 3969, 2522, 2222, 2415, }, + { 10009, 8719, 7292, 5837, 4532, }, + { 831, 908, 1039, 1656, 6813, }, + { 2070, 5478, 5174, 3911, 3694, }, + { 1577, 1565, 1635, 2583, 13154, }, + { 5590, 5788, 5922, 6752, 7063, }, + { 4061, 3497, 2710, 2099, 1716, }, + { 2750, 3118, 16574, 7891, 3651, }, + { 2598, 3072, 3809, 4906, 5172, }, + { 15348, 10948, 7740, 4979, 3446, }, }; const Word16 UVG2CB2_NB_FX[UVG2_CBSIZE][5] = /* Q12 */ { - { 961, 867, 812, 771, 775, }, - { 2544, 2686, 3010, 3605, 5048, }, - { 1524, 1818, 2889, 3029, 3046, }, - { 4195, 4301, 4421, 4497, 4580, }, - { 2026, 1990, 1965, 1943, 1939, }, - { 4338, 4156, 3963, 3750, 3590, }, - { 7732, 2904, 1804, 1407, 1513, }, - { 1613, 2353, 11315, 5764, 4291, }, - { 1519, 1462, 1434, 1341, 1294, }, - { 1627, 1710, 2163, 9654, 5615, }, - { 2322, 7293, 3251, 2020, 2066, }, - { 4967, 5112, 5174, 5203, 5230, }, - { 1590, 1449, 1943, 5947, 3563, }, - { 7747, 5170, 3268, 2392, 2082, }, - { 3970, 3559, 3164, 2774, 2493, }, - { 1993, 2210, 3204, 3717, 23534, }, - { 1185, 1236, 1423, 2115, 4772, }, - { 3935, 3840, 3714, 3583, 3477, }, - { 1640, 1550, 1800, 2609, 10880, }, - { 4067, 4437, 4811, 5108, 5536, }, - { 1472, 1367, 1533, 2132, 7352, }, - { 4310, 4284, 4216, 4117, 4057, }, - { 10817, 4587, 2611, 2066, 2037, }, - { 2089, 2427, 4698, 14635, 7517, }, - { 2529, 1561, 1209, 976, 945, }, - { 2908, 3070, 4055, 5862, 6448, }, - { 2676, 2861, 3115, 3295, 3408, }, - { 2932, 14330, 6533, 3739, 3462, }, - { 3681, 3079, 2559, 2151, 1903, }, - { 5636, 5316, 4978, 4690, 4425, }, - { 2298, 7228, 6976, 4251, 3347, }, - { 2504, 3421, 6784, 8483, 15064, }, - { 1253, 1180, 1136, 1094, 1076, }, - { 3451, 3524, 3600, 3646, 3707, }, - { 1701, 2030, 6574, 4746, 4451, }, - { 4688, 4751, 4762, 4727, 4722, }, - { 2977, 2363, 1883, 1563, 1399, }, - { 5080, 4685, 4275, 3835, 3513, }, - { 5445, 3828, 2851, 2242, 1948, }, - { 1929, 5037, 17760, 8346, 6300, }, - { 1839, 1782, 1680, 1586, 1534, }, - { 3086, 3472, 4031, 4950, 9695, }, - { 3199, 3052, 2896, 2751, 2622, }, - { 5822, 5782, 5727, 5566, 5478, }, - { 1548, 2234, 6748, 2562, 1722, }, - { 6699, 5216, 4475, 3531, 3028, }, - { 3773, 3628, 3460, 3279, 3155, }, - { 1581, 1672, 2929, 20221, 16432, }, - { 1210, 1215, 1389, 1678, 2177, }, - { 3863, 3886, 3937, 3961, 3989, }, - { 1541, 1745, 1829, 3479, 15563, }, - { 4444, 4952, 5573, 6056, 6545, }, - { 2460, 2397, 2284, 2133, 2041, }, - { 4808, 4676, 4493, 4322, 4213, }, - { 15031, 6644, 3315, 2900, 2885, }, - { 4003, 4760, 6946, 8274, 8401, }, - { 5001, 2495, 1594, 1337, 1365, }, - { 3428, 3706, 4073, 4457, 4670, }, - { 3326, 3277, 3222, 3142, 3088, }, - { 6162, 6317, 6494, 6459, 6530, }, - { 2659, 2599, 2537, 2482, 2546, }, - { 8554, 6902, 5233, 4116, 3650, }, - { 4643, 4099, 3616, 3201, 2895, }, - { 9589, 26630, 15412, 12532, 8715, }, + { 961, 867, 812, 771, 775, }, + { 2544, 2686, 3010, 3605, 5048, }, + { 1524, 1818, 2889, 3029, 3046, }, + { 4195, 4301, 4421, 4497, 4580, }, + { 2026, 1990, 1965, 1943, 1939, }, + { 4338, 4156, 3963, 3750, 3590, }, + { 7732, 2904, 1804, 1407, 1513, }, + { 1613, 2353, 11315, 5764, 4291, }, + { 1519, 1462, 1434, 1341, 1294, }, + { 1627, 1710, 2163, 9654, 5615, }, + { 2322, 7293, 3251, 2020, 2066, }, + { 4967, 5112, 5174, 5203, 5230, }, + { 1590, 1449, 1943, 5947, 3563, }, + { 7747, 5170, 3268, 2392, 2082, }, + { 3970, 3559, 3164, 2774, 2493, }, + { 1993, 2210, 3204, 3717, 23534, }, + { 1185, 1236, 1423, 2115, 4772, }, + { 3935, 3840, 3714, 3583, 3477, }, + { 1640, 1550, 1800, 2609, 10880, }, + { 4067, 4437, 4811, 5108, 5536, }, + { 1472, 1367, 1533, 2132, 7352, }, + { 4310, 4284, 4216, 4117, 4057, }, + { 10817, 4587, 2611, 2066, 2037, }, + { 2089, 2427, 4698, 14635, 7517, }, + { 2529, 1561, 1209, 976, 945, }, + { 2908, 3070, 4055, 5862, 6448, }, + { 2676, 2861, 3115, 3295, 3408, }, + { 2932, 14330, 6533, 3739, 3462, }, + { 3681, 3079, 2559, 2151, 1903, }, + { 5636, 5316, 4978, 4690, 4425, }, + { 2298, 7228, 6976, 4251, 3347, }, + { 2504, 3421, 6784, 8483, 15064, }, + { 1253, 1180, 1136, 1094, 1076, }, + { 3451, 3524, 3600, 3646, 3707, }, + { 1701, 2030, 6574, 4746, 4451, }, + { 4688, 4751, 4762, 4727, 4722, }, + { 2977, 2363, 1883, 1563, 1399, }, + { 5080, 4685, 4275, 3835, 3513, }, + { 5445, 3828, 2851, 2242, 1948, }, + { 1929, 5037, 17760, 8346, 6300, }, + { 1839, 1782, 1680, 1586, 1534, }, + { 3086, 3472, 4031, 4950, 9695, }, + { 3199, 3052, 2896, 2751, 2622, }, + { 5822, 5782, 5727, 5566, 5478, }, + { 1548, 2234, 6748, 2562, 1722, }, + { 6699, 5216, 4475, 3531, 3028, }, + { 3773, 3628, 3460, 3279, 3155, }, + { 1581, 1672, 2929, 20221, 16432, }, + { 1210, 1215, 1389, 1678, 2177, }, + { 3863, 3886, 3937, 3961, 3989, }, + { 1541, 1745, 1829, 3479, 15563, }, + { 4444, 4952, 5573, 6056, 6545, }, + { 2460, 2397, 2284, 2133, 2041, }, + { 4808, 4676, 4493, 4322, 4213, }, + { 15031, 6644, 3315, 2900, 2885, }, + { 4003, 4760, 6946, 8274, 8401, }, + { 5001, 2495, 1594, 1337, 1365, }, + { 3428, 3706, 4073, 4457, 4670, }, + { 3326, 3277, 3222, 3142, 3088, }, + { 6162, 6317, 6494, 6459, 6530, }, + { 2659, 2599, 2537, 2482, 2546, }, + { 8554, 6902, 5233, 4116, 3650, }, + { 4643, 4099, 3616, 3201, 2895, }, + { 9589, 26630, 15412, 12532, 8715, }, }; const Word16 frac_4sf_fx[NB_SUBFR + 2] = { 4,8,12,16,16,16 }; /* Q4 */ @@ -19715,7 +19715,7 @@ const Word16 ct2[7][13] = /*12*/ { 9, 3, 4, 5, 9, 0, 0, 0, 5, 0, 5, 5, 4}, /*32*/ { 4, 4, 4, 4, 4, 0, 0, 0, 2, 1, 1, 4, 4}, /*48*/ {18, 18, 18, 18, 18, 0, 0, 0, 5, 2, 1, 4, 15}, -}; // Q0 +}; // Q0 const Word16 ct2_fx[7][14] = { /* accepted configurations */ @@ -19992,7 +19992,7 @@ const SCALE_TCX_SETUP scaleTcxTable[SIZE_SCALE_TABLE_TCX] = * Arithmetic coder *----------------------------------------------------------------------------------*/ -const UWord8 ari_lookup_s17_LC[4096] = // Q0 +const UWord8 ari_lookup_s17_LC[4096] = // Q0 { 0x01,0x04,0x29,0x13,0x0A,0x0D,0x05,0x10, 0x10,0x0D,0x00,0x0D,0x2A,0x2A,0x22,0x25, @@ -20508,7 +20508,7 @@ const UWord8 ari_lookup_s17_LC[4096] = // Q0 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A }; -const UWord16 ari_pk_s17_LC_ext[64][18] = // Q0 +const UWord16 ari_pk_s17_LC_ext[64][18] = // Q0 { { 16384, 16368,16337,16231,16143,16115,16059,15916,15793,15710,15586,15472,15367,15302,15201,15107,15020, @@ -20779,7 +20779,7 @@ const Word16 NumRatioBits[2][17] = { 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2 } -}; // Q0 +}; // Q0 /* 7Q8 */ const Word16 Ratios_WB_2_fx[32] = @@ -21330,7 +21330,7 @@ const Coding * const codesTnsCoeffSWBTCX20[] = { codesTnsCoeff0TCX20, codesTnsCo const Coding * const codesTnsCoeffSWBTCX10[] = { codesTnsCoeff0TCX10, codesTnsCoeff1TCX10, codesTnsCoeff2TCX10, codesTnsCoeff3TCX10, codesTnsCoeff4TCX10, codesTnsCoeff5, codesTnsCoeff6, codesTnsCoeff7 }; const Coding * const codesTnsCoeffWBTCX20[] = { codesTnsCoeff0WBTCX20, codesTnsCoeff1WBTCX20, codesTnsCoeff2WB, codesTnsCoeff3WB, codesTnsCoeff456, codesTnsCoeff456, codesTnsCoeff456, codesTnsCoeff7 }; -const Word16 nTnsCoeffTables = sizeof(codesTnsCoeffSWBTCX20)/sizeof(codesTnsCoeffSWBTCX20[0]); // Q0 +const Word16 nTnsCoeffTables = sizeof(codesTnsCoeffSWBTCX20)/sizeof(codesTnsCoeffSWBTCX20[0]); // Q0 const Coding codesTnsOrderTCX20[] = { @@ -21366,7 +21366,7 @@ const Coding codesTnsOrder[] = { 8, 0, 1 } /* 0 */ }; -const Word16 nTnsOrderCodes = sizeof(codesTnsOrder)/sizeof(codesTnsOrder[0]); // Q0 +const Word16 nTnsOrderCodes = sizeof(codesTnsOrder)/sizeof(codesTnsOrder[0]); // Q0 const ParamsBitMap tnsSWBTCX20FilterCoeffBitMap = { @@ -21503,22 +21503,22 @@ const ParamsBitMap tnsEnabledOnWhiteSWBTCX10BitMap = */ const Word16 tnsCoeff4[16] = { - -32628/*-0.99573418F Q15*/, /* = sin(-8*(PI/2.0)/(8 + 0.5)) */ - -31517/*-0.96182564F Q15*/, /* = sin(-7*(PI/2.0)/(8 + 0.5)) */ - -29333/*-0.89516329F Q15*/, - -26149/*-0.79801723F Q15*/, - -22076/*-0.67369564F Q15*/, - -17250/*-0.52643216F Q15*/, - -11837/*-0.36124167F Q15*/, - -6021/*-0.18374952F Q15*/, /* = sin(-1*(PI/2.0)/(8 + 0.5)) */ - 0/* 0.00000000F Q15*/, /* = sin(0*(PI/2.0)/(8 + 0.5)) */ - 6813/* 0.20791169F Q15*/, /* = sin(1*(PI/2.0)/(8 - 0.5)) */ - 13328/* 0.40673664F Q15*/, - 19261/* 0.58778525F Q15*/, - 24351/* 0.74314483F Q15*/, - 28378/* 0.86602540F Q15*/, - 31164/* 0.95105652F Q15*/, /* = sin(6*(PI/2.0)/(8 - 0.5)) */ - 32588/* 0.99452190F Q15*/ /* = sin(7*(PI/2.0)/(8 - 0.5)) */ + -32628/*-0.99573418F Q15*/, /* = sin(-8*(PI/2.0)/(8 + 0.5)) */ + -31517/*-0.96182564F Q15*/, /* = sin(-7*(PI/2.0)/(8 + 0.5)) */ + -29333/*-0.89516329F Q15*/, + -26149/*-0.79801723F Q15*/, + -22076/*-0.67369564F Q15*/, + -17250/*-0.52643216F Q15*/, + -11837/*-0.36124167F Q15*/, + -6021/*-0.18374952F Q15*/, /* = sin(-1*(PI/2.0)/(8 + 0.5)) */ + 0/* 0.00000000F Q15*/, /* = sin(0*(PI/2.0)/(8 + 0.5)) */ + 6813/* 0.20791169F Q15*/, /* = sin(1*(PI/2.0)/(8 - 0.5)) */ + 13328/* 0.40673664F Q15*/, + 19261/* 0.58778525F Q15*/, + 24351/* 0.74314483F Q15*/, + 28378/* 0.86602540F Q15*/, + 31164/* 0.95105652F Q15*/, /* = sin(6*(PI/2.0)/(8 - 0.5)) */ + 32588/* 0.99452190F Q15*/ /* = sin(7*(PI/2.0)/(8 - 0.5)) */ }; @@ -21526,7 +21526,7 @@ const Word16 tnsCoeff4[16] = * IGF settings for each bitrate *----------------------------------------------------------------------------------*/ -const Word16 swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB] = // Q0 +const Word16 swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB] = // Q0 { /* 0: for 9600 kbs WB */ { @@ -21674,7 +21674,7 @@ const Word16 swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB] = // Q0 } };/*Q0*/ -const Word16 igf_tile_offset_table[IGF_BITRATE_UNKNOWN][2*IGF_MAX_TILES+1] = { // Q0 +const Word16 igf_tile_offset_table[IGF_BITRATE_UNKNOWN][2*IGF_MAX_TILES+1] = { // Q0 { 2, 2, 0, 3, 0}, /* 9600 WB*/ { 2, 2, 0, 3, 0}, /* 13200 WB RF */ { 3, 1, 0, 2, 32, 3, 46}, /* 9600 SWB */ @@ -21715,187 +21715,187 @@ const Word16 igf_tile_offset_table[IGF_BITRATE_UNKNOWN][2*IGF_MAX_TILES+1] = { / const Word16 igf_whitening_TH_ivas_fx[][2][IGF_MAX_TILES] = { - /* 0: for 9600 kbs WB */ - { - /* medium */ { 2949/*0.36f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 11551/*1.41f Q13*/, 11551/*1.41f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 1: for 13200 kbs WB RF */ - { - /* medium */ { 2949/*0.36f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 11551/*1.41f Q13*/, 11551/*1.41f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 2: for 9600 kbs SWB */ - { - /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 3: for 13200 kbs SWB */ - { - /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 4: for 13200 kbs SWB RF */ - { - /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 5: for 16400 kbs SWB */ - { - /* medium */ { 6799/*0.83f Q13*/, 7291/*0.89f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 10732/*1.31f Q13*/, 9748/*1.19f Q13*/, 9748/*1.19f Q13*/, 0/*0.f Q13*/} - }, - /* 6: for 24400 kbs SWB*/ - { - /* medium */ { 6636/*0.81f Q13*/, 6963/*0.85f Q13*/, 6963/*0.85f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 11059/*1.35f Q13*/, 10076/*1.23f Q13*/, 10076/*1.23f Q13*/, 0/*0.f Q13*/} - }, - /* 7: for 32000 kbs SWB */ - { - /* medium */ { 7455/*0.91f Q13*/, 6963/*0.85f Q13*/, 6963/*0.85f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 10977/*1.34f Q13*/, 11059/*1.35f Q13*/, 11059/*1.35f Q13*/, 0/*0.f Q13*/} - }, - /* 8: for 48000 kbs SWB */ - { - /* medium */ { 9421/*1.15f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 9748/*1.19f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 9: for 64000 kbs SWB */ - { - /* medium */ { 9421/*1.15f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 9748/*1.19f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 10: for 16400 kbs FB */ - { - /* medium */ { 5161/*0.63f Q13*/, 2212/*0.27f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 12534/*1.53f Q13*/, 10813/*1.32f Q13*/, 5489/*0.67f Q13*/, 0/*0.f Q13*/} - }, - /* 11: for 24400 kbs FB */ - { - /* medium */ { 6390/*0.78f Q13*/, 2540/*0.31f Q13*/, 2785/*0.34f Q13*/, 2785/*0.34f Q13*/}, - /* strong */ { 12206/*1.49f Q13*/, 11305/*1.38f Q13*/, 5325/*0.65f Q13*/, 5325/*0.65f Q13*/} - }, - /* 12: for 32000 kbs FB */ - { - /* medium */ { 6390/*0.78f Q13*/, 2540/*0.31f Q13*/, 2785/*0.34f Q13*/, 2785/*0.34f Q13*/}, - /* strong */ { 12206/*1.49f Q13*/, 11305/*1.38f Q13*/, 5325/*0.65f Q13*/, 5325/*0.65f Q13*/} - }, - /* 13: for 48000 kbs FB */ - { - /* medium */ { 6554/*0.80f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 8192/*1.00f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 14: for 64000 kbs FB */ - { - /* medium */ { 6554/*0.80f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 8192/*1.00f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 15: for 96000 kbs FB */ - { - /* medium */ { 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 23101/*2.82f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 16: for 128000 kbs FB */ - { - /* medium */ { 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, - /* strong */ { 23101/*2.82f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} - }, - /* 17: for 13200 kbs WB (stereo) */ - { - /* medium */ {6554/*0.800000 Q13*/, 6144/*0.750000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, - /* strong */ {12288/*1.500000 Q13*/, 11878/*1.450000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } - }, - /* 18: for 16400 kbs WB (stereo) */ - { - - /* medium */ {7373/*0.900000 Q13*/, 6963/*0.850000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, - /* strong */ {13107/*1.600000 Q13*/, 12288/*1.500000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } - }, - /* 19: for 13200 kbs SWB (stereo) */ - { - /* medium */ {7291/*0.890000 Q13*/, 7291/*0.890000 Q13*/, 6554/*0.800000 Q13*/, 6554/*0.800000 Q13*/, }, - /* strong */ {10240/*1.250000 Q13*/, 10240/*1.250000 Q13*/, 9748/*1.190000 Q13*/, 9748/*1.190000 Q13*/, } - }, - /* 20: for 16400 kbs SWB (stereo) */ - { - /* medium */ {8602/*1.050000 Q13*/, 8602/*1.050000 Q13*/, 9011/*1.100000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8602/*1.050000 Q13*/, }, - /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13517/*1.650000 Q13*/, 13517/*1.650000 Q13*/, 13107/*1.600000 Q13*/, 12288/*1.500000 Q13*/, } - }, - /* 21: for 24400 kbs SWB (stereo) */ - { - /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, }, - /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, } - }, - /* 22: for 32000 kbs SWB (stereo) */ - { - /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, }, - /* strong */ {14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 13517/*1.650000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, } - }, - /* 23: for 48000 kbs SWB (stereo) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ - { - /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 0/*0.000000 Q13*/ }, - /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } - }, - /* 24: for 48000 kbs SWB (stereo TCX10) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ - { - /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 0/*0.000000 Q13*/ }, - /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } - }, - /* 25: for 64000 kbs SWB (stereo) */ - { - /* medium */ {8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/, 9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/ }, - /* strong */ {12288/*1.500000 Q13*/, 12288/*1.500000 Q13*/, 13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/ } - }, - /* 26: for 80000 kbs SWB (stereo) */ - { - /* medium */ {9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 0/*0.000000 Q13*/ }, - /* strong */ {13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 0/*0.000000 Q13*/ } - }, - /* 27: for 96000 kbs SWB (stereo) */ - { - /* medium */ {9421/*1.150000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, - /* strong */ {9748/*1.190000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } - }, - /* 28: for 24400 kbs FB (stereo) */ - { - /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, - /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } - }, - /* 29: for 32000 kbs FB (stereo) */ - { - /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, - /* strong */ {14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 13517/*1.650000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } - }, - /* 30: for 48000 kbs FB (stereo) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ - { - /* medium */ {6390/*0.780000 Q13*/, 2540/*0.310000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, - /* strong */ {12206/*1.490000 Q13*/, 11305/*1.380000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } - }, - /* 31: for 48000 kbs FB (stereo TCX10) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ - { - /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 4096/*0.500000 Q13*/ }, - /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/ } - }, - /* 32: for 64000 kbs FB (stereo) */ - { - /* medium */ {8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/, 9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 6144/*0.750000 Q13*/ }, - /* strong */ {12288/*1.500000 Q13*/, 12288/*1.500000 Q13*/, 13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 8192/*1.000000 Q13*/ } - }, - /* 33: for 80000 kbs FB (stereo) */ - { - /* medium */ {9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 6144/*0.750000 Q13*/, 0/*0.000000 Q13*/ }, - /* strong */ {13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } - }, - /* 34: for 96000 kbs FB (stereo) */ - { - /* medium */ {7455/*0.910000 Q13*/, 6963/*0.850000 Q13*/ , 0/*0.000000 Q13*/ }, - /* strong */ {10977/*1.340000 Q13*/, 11059/*1.350000 Q13*/, 0/*0.000000 Q13*/ } - }, - /* 35: for 128000 kbs FB (stereo) */ - { - /* medium */ { 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/}, - /* strong */ {23101/*2.820000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/} - } + /* 0: for 9600 kbs WB */ + { + /* medium */ { 2949/*0.36f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 11551/*1.41f Q13*/, 11551/*1.41f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 1: for 13200 kbs WB RF */ + { + /* medium */ { 2949/*0.36f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 11551/*1.41f Q13*/, 11551/*1.41f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 2: for 9600 kbs SWB */ + { + /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 3: for 13200 kbs SWB */ + { + /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 4: for 13200 kbs SWB RF */ + { + /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 5: for 16400 kbs SWB */ + { + /* medium */ { 6799/*0.83f Q13*/, 7291/*0.89f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10732/*1.31f Q13*/, 9748/*1.19f Q13*/, 9748/*1.19f Q13*/, 0/*0.f Q13*/} + }, + /* 6: for 24400 kbs SWB*/ + { + /* medium */ { 6636/*0.81f Q13*/, 6963/*0.85f Q13*/, 6963/*0.85f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 11059/*1.35f Q13*/, 10076/*1.23f Q13*/, 10076/*1.23f Q13*/, 0/*0.f Q13*/} + }, + /* 7: for 32000 kbs SWB */ + { + /* medium */ { 7455/*0.91f Q13*/, 6963/*0.85f Q13*/, 6963/*0.85f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10977/*1.34f Q13*/, 11059/*1.35f Q13*/, 11059/*1.35f Q13*/, 0/*0.f Q13*/} + }, + /* 8: for 48000 kbs SWB */ + { + /* medium */ { 9421/*1.15f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 9748/*1.19f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 9: for 64000 kbs SWB */ + { + /* medium */ { 9421/*1.15f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 9748/*1.19f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 10: for 16400 kbs FB */ + { + /* medium */ { 5161/*0.63f Q13*/, 2212/*0.27f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 12534/*1.53f Q13*/, 10813/*1.32f Q13*/, 5489/*0.67f Q13*/, 0/*0.f Q13*/} + }, + /* 11: for 24400 kbs FB */ + { + /* medium */ { 6390/*0.78f Q13*/, 2540/*0.31f Q13*/, 2785/*0.34f Q13*/, 2785/*0.34f Q13*/}, + /* strong */ { 12206/*1.49f Q13*/, 11305/*1.38f Q13*/, 5325/*0.65f Q13*/, 5325/*0.65f Q13*/} + }, + /* 12: for 32000 kbs FB */ + { + /* medium */ { 6390/*0.78f Q13*/, 2540/*0.31f Q13*/, 2785/*0.34f Q13*/, 2785/*0.34f Q13*/}, + /* strong */ { 12206/*1.49f Q13*/, 11305/*1.38f Q13*/, 5325/*0.65f Q13*/, 5325/*0.65f Q13*/} + }, + /* 13: for 48000 kbs FB */ + { + /* medium */ { 6554/*0.80f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 8192/*1.00f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 14: for 64000 kbs FB */ + { + /* medium */ { 6554/*0.80f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 8192/*1.00f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 15: for 96000 kbs FB */ + { + /* medium */ { 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 23101/*2.82f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 16: for 128000 kbs FB */ + { + /* medium */ { 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 23101/*2.82f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 17: for 13200 kbs WB (stereo) */ + { + /* medium */ {6554/*0.800000 Q13*/, 6144/*0.750000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {12288/*1.500000 Q13*/, 11878/*1.450000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 18: for 16400 kbs WB (stereo) */ + { + + /* medium */ {7373/*0.900000 Q13*/, 6963/*0.850000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {13107/*1.600000 Q13*/, 12288/*1.500000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 19: for 13200 kbs SWB (stereo) */ + { + /* medium */ {7291/*0.890000 Q13*/, 7291/*0.890000 Q13*/, 6554/*0.800000 Q13*/, 6554/*0.800000 Q13*/, }, + /* strong */ {10240/*1.250000 Q13*/, 10240/*1.250000 Q13*/, 9748/*1.190000 Q13*/, 9748/*1.190000 Q13*/, } + }, + /* 20: for 16400 kbs SWB (stereo) */ + { + /* medium */ {8602/*1.050000 Q13*/, 8602/*1.050000 Q13*/, 9011/*1.100000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8602/*1.050000 Q13*/, }, + /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13517/*1.650000 Q13*/, 13517/*1.650000 Q13*/, 13107/*1.600000 Q13*/, 12288/*1.500000 Q13*/, } + }, + /* 21: for 24400 kbs SWB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, }, + /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, } + }, + /* 22: for 32000 kbs SWB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, }, + /* strong */ {14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 13517/*1.650000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, } + }, + /* 23: for 48000 kbs SWB (stereo) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ + { + /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 24: for 48000 kbs SWB (stereo TCX10) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ + { + /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 25: for 64000 kbs SWB (stereo) */ + { + /* medium */ {8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/, 9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/ }, + /* strong */ {12288/*1.500000 Q13*/, 12288/*1.500000 Q13*/, 13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/ } + }, + /* 26: for 80000 kbs SWB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 27: for 96000 kbs SWB (stereo) */ + { + /* medium */ {9421/*1.150000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {9748/*1.190000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 28: for 24400 kbs FB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, + /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } + }, + /* 29: for 32000 kbs FB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, + /* strong */ {14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 13517/*1.650000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } + }, + /* 30: for 48000 kbs FB (stereo) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ + { + /* medium */ {6390/*0.780000 Q13*/, 2540/*0.310000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, + /* strong */ {12206/*1.490000 Q13*/, 11305/*1.380000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } + }, + /* 31: for 48000 kbs FB (stereo TCX10) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ + { + /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 4096/*0.500000 Q13*/ }, + /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/ } + }, + /* 32: for 64000 kbs FB (stereo) */ + { + /* medium */ {8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/, 9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 6144/*0.750000 Q13*/ }, + /* strong */ {12288/*1.500000 Q13*/, 12288/*1.500000 Q13*/, 13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 8192/*1.000000 Q13*/ } + }, + /* 33: for 80000 kbs FB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 6144/*0.750000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 34: for 96000 kbs FB (stereo) */ + { + /* medium */ {7455/*0.910000 Q13*/, 6963/*0.850000 Q13*/ , 0/*0.000000 Q13*/ }, + /* strong */ {10977/*1.340000 Q13*/, 11059/*1.350000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 35: for 128000 kbs FB (stereo) */ + { + /* medium */ { 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/}, + /* strong */ {23101/*2.820000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/} + } }; const Word16 igf_whitening_TH[][2][IGF_MAX_TILES] = { @@ -21988,7 +21988,7 @@ const Word16 igf_whitening_TH[][2][IGF_MAX_TILES] = /* IGF SCF arithmetic coder cumulative frequency tables and offsets */ -const Word16 cf_off_se01_tab[10] = { // Q0 +const Word16 cf_off_se01_tab[10] = { // Q0 +1, /* 9.6 kbs B*/ +1, /* 13.2 kbs WB RF B*/ +1, /* 9.6 kbs SWB B*/ @@ -22001,7 +22001,7 @@ const Word16 cf_off_se01_tab[10] = { // Q0 -1 /* 64.0 kbs B*/ }; -const Word16 cf_off_se02_tab[10][IGF_CTX_COUNT] = { // Q0 +const Word16 cf_off_se02_tab[10][IGF_CTX_COUNT] = { // Q0 { +1, +2, +2, +2, +3, +3, +4}, /* 9.6 kbs B*/ { +1, +2, +2, +2, +3, +3, +4}, /* 13.2 kbs WB RF B*/ { +0, +2, +3, +3, +2, +2, +4}, /* 9.6 kbs SWB B*/ @@ -22014,9 +22014,9 @@ const Word16 cf_off_se02_tab[10][IGF_CTX_COUNT] = { // Q0 { +3, +2, +3, +2, +3, +3, +6} /* 64.0 kbs B*/ }; -const Word16 cf_off_se10_tab = -7; // Q0 +const Word16 cf_off_se10_tab = -7; // Q0 -const Word16 cf_off_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT] = // Q0 +const Word16 cf_off_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT] = // Q0 { { -5, +0, +0, +0, +0, +0, +0}, { +0, +0, +0, +0, +0, +0, +0}, @@ -22027,7 +22027,7 @@ const Word16 cf_off_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT] = // Q0 { +0, +1, +0, +0, +3, +0, +3} }; -const UWord16 cf_se00_tab[IGF_SYMBOLS_IN_TABLE + 1] = // Q0 +const UWord16 cf_se00_tab[IGF_SYMBOLS_IN_TABLE + 1] = // Q0 { 16384, 16356, 16299, 16185, 15904, 15282, 14669, 13598, 11886, 9541, 6613, 3845, 1799, 606, 153, 32, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; @@ -22046,7 +22046,7 @@ const UWord16 cf_se01_tab[10][IGF_SYMBOLS_IN_TABLE + 1] = // Q0 {16384, 16368, 16355, 16334, 16291, 16212, 16071, 15816, 15359, 14523, 13014, 10534, 7345, 4272, 2228, 1149, 626, 357, 215, 139, 93, 67, 53, 43, 36, 28, 22, 0} /* 64.0 kbs B*/ }; -const UWord16 cf_se02_tab[10][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] = // Q0 +const UWord16 cf_se02_tab[10][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] = // Q0 { { /* 9.6 kbs B */ { 16384, 16369, 16348, 16316, 16256, 16172, 16017, 15735, 15246, 14363, 13036, 11139, 8916, 6724, 4757, 3282, 2221, 1549, 1105, 771, 548, 364, 238, 151, 89, 50, 30, 0}, @@ -22142,12 +22142,12 @@ const UWord16 cf_se02_tab[10][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] = // Q0 /* only needed for >= 48 kbps */ -const UWord16 cf_se10_tab[IGF_SYMBOLS_IN_TABLE + 1] = // Q0 +const UWord16 cf_se10_tab[IGF_SYMBOLS_IN_TABLE + 1] = // Q0 { 16384, 15493, 15154, 14810, 14331, 13701, 13086, 12403, 11585, 10923, 10293, 9631, 8943, 8385, 7760, 7182, 6593, 6009, 5540, 5082, 4571, 4133, 3711, 3299, 2887, 2460, 2043, 0 }; -const UWord16 cf_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] = // Q0 +const UWord16 cf_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] = // Q0 { { { 16384, 16313, 16312, 16241, 16206, 16099, 15957, 15386, 14601, 12852, 10282, 7534, 4964, 2966, 1824, 896, 504, 255, 113, 112, 41, 40, 39, 38, 37, 36, 1, 0}, @@ -22583,9 +22583,9 @@ const Word16 SHB_LSF_VQ3_fx[48] =//Q15 -1241, -1225, -976, -52, -98, -216, -422, -599, -688, 127, 137, 0, 52, 301, 412, -278, -422, 9, 199, 137, 72 }; -const Word16 *const cb_LSF_BWE_fx[] = { SHB_LSF_VQ4_fx, SHB_LSF_VQ3_fx }; // Q15 +const Word16 *const cb_LSF_BWE_fx[] = { SHB_LSF_VQ4_fx, SHB_LSF_VQ3_fx }; // Q15 -const Word16 mslvq_SHB_min_bits[] = {14, 12}; /* for 4 bits and 3 bits respectively Q0*/ +const Word16 mslvq_SHB_min_bits[] = {14, 12}; /* for 4 bits and 3 bits respectively Q0*/ const Word16 scales_BWE_fx[] = {//Q13 7634, 13737, @@ -22605,7 +22605,7 @@ const Word16 scales_BWE_fx_new[] = {//Q11 3622, 6606 }; -const Word8 no_lead_BWE[] = { // Q0 +const Word8 no_lead_BWE[] = { // Q0 8, 6, 5, /* 14 bits */ 10,9,5, /* 15 bits*/ 16, 11, 5}; /* 16 bits */ @@ -22628,7 +22628,7 @@ const Word16 scales_BWE_3b_fx_new[] = {//Q11 5765 }; -const Word8 no_lead_BWE_3b[] = { // Q0 +const Word8 no_lead_BWE_3b[] = { // Q0 4, 5, 2, /* 12 bits */ 5, 5, 5, /* 13 bits */ 8, 6, 5 /* 14 bits */ @@ -22650,7 +22650,7 @@ const Word32 LastCoefPred_1bit_fx[36] = {//Q31 11703786, -7301444, 20444044, 22655952, 138448272, 307648512, 9234180 }; -const Word16 config_LSF_BWE[] = { // Q0 +const Word16 config_LSF_BWE[] = { // Q0 4, 16, 1, /* 21 bits */ 4, 16, 1, /* 20 */ 4, 16, 1, /* 19 */ @@ -24235,15 +24235,15 @@ const Word16 dsDiracsTab[65] = const Word16 pwf_fx[17] =//Q12 { - 22938, 16056, 11239, 7868, 5507, 3855, 2699, 1889, - 1322, 926, 648, 454, 317, 222, 156, 109, + 22938, 16056, 11239, 7868, 5507, 3855, 2699, 1889, + 1322, 926, 648, 454, 317, 222, 156, 109, 76 }; const Word32 inverse_table[] =//Q29 { 0, - 134217728, 67108864, 44739242, 33554432, 26843545, 22369621, 19173961, 16777216, 14913080, 13421772, 12201611, 11184810, 10324440, 9586980, 8947848, 8388608, 7895160, 7456540, 7064090, 6710886, 6391320, 6100805, 5835553, 5592405, 5368709, 5162220, 4971026, 4793490, 4628197, 4473924, 4329604, 4194304, 4067203, 3947580, 3834792, 3728270, 3627506, 3532045, 3441480, 3355443, 3273603, 3195660, 3121342, 3050402, 2982616, 2917776, 2855696, 2796202, 2739137, 2684354, 2631720, 2581110, 2532409, 2485513, 2440322, 2396745, 2354696, 2314098, 2274876, 2236962, 2200290, 2164802, 2130440, 2097152, 2064888, 2033601, 2003249, 1973790, 1945184, 1917396, 1890390, 1864135, 1838599, 1813753, 1789569, 1766022, 1743087, 1720740, 1698958, 1677721, 1657008, 1636801, 1617081, 1597830, 1579032, 1560671, 1542732, 1525201, 1508064, 1491308, 1474920, 1458888, 1443201, 1427848, 1412818, 1398101, 1383687, 1369568, 1355734, 1342177, 1328888, 1315860, 1303084, 1290555, 1278264, 1266204, 1254371, 1242756, 1231355, 1220161, 1209168, 1198372, 1187767, 1177348, 1167110, 1157049, 1147160, 1137438, 1127880, 1118481, 1109237, 1100145, 1091201, 1082401, 1073741, 1065220, 1056832, 1048576, 1040447, 1032444, 1024562, 1016800, 1009155, 1001624, 994205, 986895, 979691, 972592, 965595, 958698, 951898, 945195, 938585, 932067, 925639, 919299, 913045, 906876, 900790, 894784, 888859, 883011, 877240, 871543, 865920, 860370, 854889, 849479, 844136, 838860, 833650, 828504, 823421, 818400, 813440, 808540, 803698, 798915, 794187, 789516, 784898, 780335, 775825, 771366, 766958, 762600, 758292, 754032, 749819, 745654, 741534, 737460, 733430, 729444, 725501, 721600, 717741, 713924, 710146, 706409, 702710, 699050, 695428, 691843, 688296, 684784, 681308, 677867, 674460, 671088, 667749, 664444, 661171, 657930, 654720, 651542, 648394, 645277, 642190, 639132, 636102, 633102, 630130, 627185, 624268, 621378, 618514, 615677, 612866, 610080, 607320, 604584, 601873, 599186, 596523, 593883, 591267, 588674, 586103, 583555, 581029, 578524, 576041, 573580, 571139, 568719, 566319, 563940, 561580, 559240, 556920, 554618, 552336, 550072, 547827, 545600, 543391, 541200, 539027, 536870, 534731, 532610, 530504, 528416, 526344, + 134217728, 67108864, 44739242, 33554432, 26843545, 22369621, 19173961, 16777216, 14913080, 13421772, 12201611, 11184810, 10324440, 9586980, 8947848, 8388608, 7895160, 7456540, 7064090, 6710886, 6391320, 6100805, 5835553, 5592405, 5368709, 5162220, 4971026, 4793490, 4628197, 4473924, 4329604, 4194304, 4067203, 3947580, 3834792, 3728270, 3627506, 3532045, 3441480, 3355443, 3273603, 3195660, 3121342, 3050402, 2982616, 2917776, 2855696, 2796202, 2739137, 2684354, 2631720, 2581110, 2532409, 2485513, 2440322, 2396745, 2354696, 2314098, 2274876, 2236962, 2200290, 2164802, 2130440, 2097152, 2064888, 2033601, 2003249, 1973790, 1945184, 1917396, 1890390, 1864135, 1838599, 1813753, 1789569, 1766022, 1743087, 1720740, 1698958, 1677721, 1657008, 1636801, 1617081, 1597830, 1579032, 1560671, 1542732, 1525201, 1508064, 1491308, 1474920, 1458888, 1443201, 1427848, 1412818, 1398101, 1383687, 1369568, 1355734, 1342177, 1328888, 1315860, 1303084, 1290555, 1278264, 1266204, 1254371, 1242756, 1231355, 1220161, 1209168, 1198372, 1187767, 1177348, 1167110, 1157049, 1147160, 1137438, 1127880, 1118481, 1109237, 1100145, 1091201, 1082401, 1073741, 1065220, 1056832, 1048576, 1040447, 1032444, 1024562, 1016800, 1009155, 1001624, 994205, 986895, 979691, 972592, 965595, 958698, 951898, 945195, 938585, 932067, 925639, 919299, 913045, 906876, 900790, 894784, 888859, 883011, 877240, 871543, 865920, 860370, 854889, 849479, 844136, 838860, 833650, 828504, 823421, 818400, 813440, 808540, 803698, 798915, 794187, 789516, 784898, 780335, 775825, 771366, 766958, 762600, 758292, 754032, 749819, 745654, 741534, 737460, 733430, 729444, 725501, 721600, 717741, 713924, 710146, 706409, 702710, 699050, 695428, 691843, 688296, 684784, 681308, 677867, 674460, 671088, 667749, 664444, 661171, 657930, 654720, 651542, 648394, 645277, 642190, 639132, 636102, 633102, 630130, 627185, 624268, 621378, 618514, 615677, 612866, 610080, 607320, 604584, 601873, 599186, 596523, 593883, 591267, 588674, 586103, 583555, 581029, 578524, 576041, 573580, 571139, 568719, 566319, 563940, 561580, 559240, 556920, 554618, 552336, 550072, 547827, 545600, 543391, 541200, 539027, 536870, 534731, 532610, 530504, 528416, 526344, }; const Word16 cos_diff_table[512] =//Q15 @@ -24576,9 +24576,9 @@ const Word32 pow_tilt_32k[64] = { 1029387260, 1121709444, 1222311686, 1331936594, 1451393382, 1581563835, 1723408827, 1877975405 }; -const Word16 L_frame_inv[8] = { 0x4000, 0x369D, 0x3333, 0x2D83, 0x2AAB, 0x28F6, 0, 0x2222 }; // Q14 +const Word16 L_frame_inv[8] = { 0x4000, 0x369D, 0x3333, 0x2D83, 0x2AAB, 0x28F6, 0, 0x2222 }; // Q14 -const Word16 InvIntTable[65] = // Q15 +const Word16 InvIntTable[65] = // Q15 { 0x7FFF, 0x7FFF, 0x4000, 0x2AAB, 0x2000, 0x199A, 0x1555, 0x1249, 0x1000, @@ -24591,7 +24591,7 @@ const Word16 InvIntTable[65] = // Q15 0x023F, 0x0235, 0x022B, 0x0222, 0x0219, 0x0211, 0x0208, 0x0200 }; -const Word16 TecLowBandTable[] = { 0, 2, 4, 6 }; //Q0 +const Word16 TecLowBandTable[] = { 0, 2, 4, 6 }; //Q0 const Word16 TecSC_Fx[] = { 23999/*0.3662f*2.0f Q15*/, 7065/*0.1078f*2.0f Q15*/, 7825/*0.1194f*2.0f Q15*/, @@ -25794,7 +25794,7 @@ const Word16 ivas_fine_gain_pred_sqrt_bw[9] = { 5793, 8192, 10033, 11585, 12953, /*----------------------------------------------------------------------------------* * means of ISFs for WB active speech *----------------------------------------------------------------------------------*/ -const Word16 Mean_isf_wb[M] = /* G722.2 active speech ISF's means Q2.56*/ +const Word16 Mean_isf_wb[M] = /* G722.2 active speech ISF's means Q2.56*/ { 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730, 8750, 9753, 10705, 11728, 12833, 13971, 15043, 4037 @@ -27915,7 +27915,7 @@ const Word16 cos_scale_tbl_800[800] = { /* Q15 */ 32762, 32763, 32764, 32765, 32765, 32766, 32766, 32766 }; -const Word16 scales_ivas_fx[][MAX_NO_SCALES * 2] = /* 2 subvectors Q11*/ +const Word16 scales_ivas_fx[][MAX_NO_SCALES * 2] = /* 2 subvectors Q11*/ { { 3129, diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 7a5519c04..0ba901db7 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -29,22 +29,22 @@ Word32 L_Sqrt_Q0( const Word32 x ); *--------------------------------------------------------------------*/ void stat_noise_uv_mod_fx( - const Word16 coder_type, /* i : Coder type */ + const Word16 coder_type, /* i : Coder type */ Word16 noisiness, /* i : noisiness parameter Q0 */ const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ - Word16 *exc2, /* i/o: excitation buffer Q_exc */ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ + Word16 *exc2, /* i/o: excitation buffer Q_exc */ Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q15 */ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q15 */ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ const Word32 bitrate, /* i : core bitrate */ const Word16 bwidth_fx, /* i : input bandwidth */ Word16 *Q_stat_noise, /* i/o: noise scaling */ @@ -331,26 +331,26 @@ void stat_noise_uv_mod_fx( *--------------------------------------------------------------------*/ void stat_noise_uv_mod_ivas_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q=0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ - Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q=0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ + Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q=15*/ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q=15*/ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : i bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : i bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ ) { Word16 exctilt; /* Q15 */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index bfe9db62d..5a786c10b 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6667,9 +6667,9 @@ void synthesise_fb_high_band_fx( Word16 Q_fb_exc, Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ const Word32 fb_exc_energy, /* i : full band excitation energy */ - const Word16 ratio, /* i : energy ratio */ + const Word16 ratio, /* i : energy ratio */ const Word16 L_frame, /* i : ACELP frame length */ - const Word16 bfi, /* i : fec flag */ + const Word16 bfi, /* i : fec flag */ Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], diff --git a/lib_com/syn_12k8_fx.c b/lib_com/syn_12k8_fx.c index 86d4c6ef7..a69759157 100644 --- a/lib_com/syn_12k8_fx.c +++ b/lib_com/syn_12k8_fx.c @@ -8,29 +8,29 @@ /*===========================================================================*/ -/* FUNCTION : syn_12k8_fx() */ +/* FUNCTION : syn_12k8_fx() */ /*---------------------------------------------------------------------------*/ -/* PURPOSE : perform the synthesis filtering 1/A(z). */ +/* PURPOSE : perform the synthesis filtering 1/A(z). */ /*---------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) st_fx->L_frame :length of the frame */ -/* _ (Word16[]) Aq : LP filter coefficients Q12 */ -/* _ (Word16) exc : input signal Q_exc */ -/* _ (Word16) update_m : update memory flag: 0-->no memory update */ -/* 1 --> update of memory */ -/* _ (Word16) Q_exc : Excitation scaling */ -/* _ (Word16) Q_syn : Synthesis scaling */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) st_fx->L_frame :length of the frame */ +/* _ (Word16[]) Aq : LP filter coefficients Q12 */ +/* _ (Word16) exc : input signal Q_exc */ +/* _ (Word16) update_m : update memory flag: 0-->no memory update */ +/* 1 --> update of memory */ +/* _ (Word16) Q_exc : Excitation scaling */ +/* _ (Word16) Q_syn : Synthesis scaling */ /*---------------------------------------------------------------------------*/ -/* INPUT OUTPUT ARGUMENTS : */ +/* INPUT OUTPUT ARGUMENTS : */ /*---------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) synth : initial filter states Q_syn */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) synth : initial filter states Q_syn */ /*---------------------------------------------------------------------------*/ /* _ (Word16[]) st_fx->mem_syn2_fx: initial filter states Q_syn */ /*---------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*===========================================================================*/ void syn_12k8_fx( Word16 L_frame, diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c index a584de16a..11157adc7 100644 --- a/lib_com/tcx_ltp_fx.c +++ b/lib_com/tcx_ltp_fx.c @@ -428,7 +428,7 @@ static void tcx_ltp_synth_filter( Word16 gain, /* Q15 */ Word16 pitch_res, /* Q0 */ Word16 *zir, /* can be NULL */ - Word16 fade, /* 0=normal, +1=fade-in, -1=fade-out Q0*/ + Word16 fade, /* 0=normal, +1=fade-in, -1=fade-out Q0*/ Word16 filtIdx /* Q0 */ ) { @@ -649,8 +649,8 @@ static void tcx_ltp_synth_filter32( Word16 pitch_fr, /* Q0 */ Word16 gain, /* Q15 */ Word16 pitch_res, /* Q0 */ - Word32 *zir, /* can be NULL Qx*/ - Word16 fade, /* 0=normal, +1=fade-in, -1=fade-out Q0*/ + Word32 *zir, /* can be NULL Qx*/ + Word16 fade, /* 0=normal, +1=fade-in, -1=fade-out Q0*/ Word16 filtIdx /* Q0 */ ) { diff --git a/lib_com/tcx_mdct_fx.c b/lib_com/tcx_mdct_fx.c index 475a0079c..5d13d69f9 100644 --- a/lib_com/tcx_mdct_fx.c +++ b/lib_com/tcx_mdct_fx.c @@ -233,14 +233,14 @@ void TCX_MDCT_Inverse( FOR( i = 0; i < R2; i++ ) { - y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ + y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ move16(); } FOR( i = 0; i < L2; i++ ) { - y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ + y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ move16(); } @@ -249,7 +249,7 @@ void TCX_MDCT_Inverse( Word16 f; f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); - y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ move16(); y[l + m + R2 - 1 - i] = f; move16(); @@ -290,13 +290,13 @@ void TCX_MDST_Inverse_fx( FOR( i = 0; i < R2; i++ ) { - y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ move16(); } FOR( i = 0; i < L2; i++ ) { - y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ move16(); } @@ -367,12 +367,12 @@ void TCX_MDXT_Inverse_fx( FOR( i = 0; i < L2; i++ ) { - y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end exp(fac_e)*/ + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end exp(fac_e)*/ } FOR( i = 0; i < R2; i++ ) { - y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end exp(fac_e)*/ + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end exp(fac_e)*/ move16(); } @@ -381,7 +381,7 @@ void TCX_MDXT_Inverse_fx( f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); - y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ move16(); y[l + m + R2 - 1 - i] = f; diff --git a/lib_com/vlpc_2st_com_fx.c b/lib_com/vlpc_2st_com_fx.c index 3fcdf144d..09828330b 100644 --- a/lib_com/vlpc_2st_com_fx.c +++ b/lib_com/vlpc_2st_com_fx.c @@ -10,8 +10,8 @@ void lsf_weight_2st( - const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ - Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ const Word16 mode /* input: operational mode Q0 */ ) { diff --git a/lib_com/weight_a_fx.c b/lib_com/weight_a_fx.c index 8a6caf04a..8ebcdfcf9 100644 --- a/lib_com/weight_a_fx.c +++ b/lib_com/weight_a_fx.c @@ -35,21 +35,21 @@ void weight_a_subfr_fx( } /*==============================================================================*/ -/* FUNCTION : void weight_a_lc_fx ( ) */ +/* FUNCTION : void weight_a_lc_fx ( ) */ /*------------------------------------------------------------------------------*/ /* PURPOSE : Weighting of LP filter coefficients, ap[i] = a[i] * (gamma^i)*/ /*------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* const Word16 a[], i: LP filter coefficients Q12 */ -/* const Word16 *gammatbl, i: weighting factor Q15 */ -/* const Word16 m i: order of LP filter Q0 */ +/* INPUT ARGUMENTS : */ +/* const Word16 a[], i: LP filter coefficients Q12 */ +/* const Word16 *gammatbl, i: weighting factor Q15 */ +/* const Word16 m i: order of LP filter Q0 */ /*------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* Word16 ap[], o: weighted LP filter coefficients Q12 */ +/* OUTPUT ARGUMENTS : */ +/* Word16 ap[], o: weighted LP filter coefficients Q12 */ /*------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ +/* RETURN ARGUMENTS : */ /*------------------------------------------------------------------------------*/ -/* CALLED FROM : TX/RX */ +/* CALLED FROM : TX/RX */ /*==============================================================================*/ void weight_a_lc_fx( const Word16 a[], /* i: LP filter coefficients Q12 */ @@ -131,9 +131,9 @@ void weight_a_fx( * E_LPC_a_weight_inv * * Parameters: - * a I: LP filter coefficients Q12 + * a I: LP filter coefficients Q12 * ap O: weighted LP filter coefficients Q12 - * inv_gamma I: inverse weighting factor Q14 + * inv_gamma I: inverse weighting factor Q14 * m I: order of LP filter * * Function: diff --git a/lib_com/weight_fx.c b/lib_com/weight_fx.c index eb3f19bf7..824f6b344 100644 --- a/lib_com/weight_fx.c +++ b/lib_com/weight_fx.c @@ -15,9 +15,9 @@ *--------------------------------------------------------------------------*/ static void sfm2mqb_fx( - Word16 spe[], /* i : sub-vectors Q0*/ - Word16 spe2q[], /* o : pbands Q0*/ - const Word16 nb_sfm /* i : number of norms Q0*/ + Word16 spe[], /* i : sub-vectors Q0*/ + Word16 spe2q[], /* o : pbands Q0*/ + const Word16 nb_sfm /* i : number of norms Q0*/ ) { Word16 tmp, i; @@ -117,9 +117,9 @@ static void sfm2mqb_fx( *--------------------------------------------------------------------------*/ static void mqb2sfm_fx( - Word16 spe2q[], /* i : pbands Q0*/ - Word16 spe[], /* o : sub-vectors Q0*/ - const Word16 lnb_sfm /* i : number of norms Q0*/ + Word16 spe2q[], /* i : pbands Q0*/ + Word16 spe[], /* o : sub-vectors Q0*/ + const Word16 lnb_sfm /* i : number of norms Q0*/ ) { Word16 i; diff --git a/lib_com/window_fx.c b/lib_com/window_fx.c index 8f8652543..b028b438a 100644 --- a/lib_com/window_fx.c +++ b/lib_com/window_fx.c @@ -31,7 +31,7 @@ void ham_cos_window( assert( n1 >= 102 ); /* if n1 is too low -> overflow in div_l */ - /* cte = PI2/(Float32)(2*n1 - 1); */ + /* cte = PI2/(Float32)(2*n1 - 1); */ BASOP_SATURATE_WARNING_OFF_EVS cte = L_deposit_l( div_l( PI2_10Q21, sub( shl( n1, 1 ), 1 ) ) ); /*0Q15*/ BASOP_SATURATE_WARNING_ON_EVS @@ -39,7 +39,7 @@ void ham_cos_window( move32(); FOR( i = 0; i < n1; i++ ) { - /* fh_f[i] = 0.54f - 0.46f * (Float32)cos(cc); */ + /* fh_f[i] = 0.54f - 0.46f * (Float32)cos(cc); */ BASOP_SATURATE_WARNING_OFF_EVS fh[i] = sub_sat( P54_0Q15, mult_r( getCosWord16( round_fx_sat( L_shl_sat( cc, 9 ) ) ), P92_0Q15 ) ); /*0Q15*/ move16(); @@ -48,7 +48,7 @@ void ham_cos_window( } assert( n2 >= 26 ); /* if n2 is too low -> overflow in div_l */ - /* cte = PI2/(Float32)(4*n2 - 1); */ + /* cte = PI2/(Float32)(4*n2 - 1); */ cte = L_deposit_l( div_l( PI2_11Q20, sub( shl( n2, 2 ), 1 ) ) ); /*0Q15*/ cc = 0; move32(); @@ -57,7 +57,7 @@ void ham_cos_window( BASOP_SATURATE_WARNING_OFF_EVS FOR( i = n1; i < n1 + n2; i++ ) { - /* fh_f[i] = (Float32)cos(cc); */ + /* fh_f[i] = (Float32)cos(cc); */ fh[i] = shl_sat( getCosWord16( round_fx( L_shl( cc, 10 ) ) ), 1 ); /*0Q15*/ move16(); cc = L_add( cc, cte ); diff --git a/lib_dec/FEC_lsf_estim_fx.c b/lib_dec/FEC_lsf_estim_fx.c index ba248598c..d64b6fe3e 100644 --- a/lib_dec/FEC_lsf_estim_fx.c +++ b/lib_dec/FEC_lsf_estim_fx.c @@ -16,11 +16,11 @@ *-------------------------------------------------------------------*/ void FEC_lsf2lsp_interp( - Decoder_State *st, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *Aq, /* o : calculated A(z) for 4 subframes Q12 */ + Decoder_State *st, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *Aq, /* o : calculated A(z) for 4 subframes Q12 */ Word16 *lsf, /* o : estimated LSF vector Qlog2(2.56)*/ - Word16 *lsp /* o : estimated LSP vector Q15* */ + Word16 *lsp /* o : estimated LSP vector Q15* */ ) { diff --git a/lib_dec/FEC_pitch_estim_fx.c b/lib_dec/FEC_pitch_estim_fx.c index 4ea25cd85..f2522dc51 100644 --- a/lib_dec/FEC_pitch_estim_fx.c +++ b/lib_dec/FEC_pitch_estim_fx.c @@ -9,30 +9,30 @@ /*========================================================================*/ -/* FUNCTION : FEC_pitch_estim_fx() */ +/* FUNCTION : FEC_pitch_estim_fx() */ /*------------------------------------------------------------------------*/ -/* PURPOSE : Estimation of pitch for FEC */ -/* */ +/* PURPOSE : Estimation of pitch for FEC */ +/* */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) st_fx->Opt_AMR_WB: flag indicating AMR-WB IO mode */ -/* _ (Word16) st_fx->L_frame_fx: length of the frame */ -/* _ (Word16) st_fx->clas_dec: frame classification */ -/* _ (Word16) st_fx->last_good: last good clas information */ -/* _ (Word16[]) pitch : pitch values for each subframe Q6 */ -/* _ (Word16[]) old_pitch_buf:pitch values for each subframe Q6 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) st_fx->Opt_AMR_WB: flag indicating AMR-WB IO mode */ +/* _ (Word16) st_fx->L_frame_fx: length of the frame */ +/* _ (Word16) st_fx->clas_dec: frame classification */ +/* _ (Word16) st_fx->last_good: last good clas information */ +/* _ (Word16[]) pitch : pitch values for each subframe Q6 */ +/* _ (Word16[]) old_pitch_buf:pitch values for each subframe Q6 */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /*------------------------------------------------------------------------*/ -/* _ (Word16[]) st_fx->bfi_pitch : initial synthesis filter states */ +/* _ (Word16[]) st_fx->bfi_pitch : initial synthesis filter states */ /* _ (Word16) st_fx->bfi_pitch_frame: LP filter E of last */ /* _ (Word16) st_fx->upd_cnt_fx: update counter */ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ void FEC_pitch_estim_fx( const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index 7f4586083..f26c4bffe 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -13,41 +13,41 @@ #define SCLSYN_LAMBDA ( 9830 /*0.3f Q15*/ ) /*========================================================================*/ -/* FUNCTION : FEC_scale_syn_fx() */ +/* FUNCTION : FEC_scale_syn_fx() */ /*------------------------------------------------------------------------*/ -/* PURPOSE : Smooth the speech energy evolution when */ -/* recovering after a BAD frame */ +/* PURPOSE : Smooth the speech energy evolution when */ +/* recovering after a BAD frame */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) L_frame : length of the frame */ -/* _ (Word16) *update_flg : indication about resynthesis */ -/* _ (Word16) st_fx->clas_dec: frame classification */ -/* _ (Word16) last_good : last good frame classification */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) L_frame : length of the frame */ +/* _ (Word16) *update_flg : indication about resynthesis */ +/* _ (Word16) st_fx->clas_dec: frame classification */ +/* _ (Word16) last_good : last good frame classification */ /* _ (Word16[]) synth : synthesized speech at Fs = 12k8 Hz Q_syn */ -/* _ (Word16[]) pitch : pitch values for each subframe Q0 */ -/* _ (Word32) L_enr_old :energy at the end of previous frame Q0 */ -/* _ (Word16) L_enr_q : transmitted energy for current frame Q0 */ -/* _ (Word16) coder_type : coder type */ +/* _ (Word16[]) pitch : pitch values for each subframe Q0 */ +/* _ (Word32) L_enr_old :energy at the end of previous frame Q0 */ +/* _ (Word16) L_enr_q : transmitted energy for current frame Q0 */ +/* _ (Word16) coder_type : coder type */ /* _ (Word16) st_fx->prev_bfi_fx: previous frame BFI */ /* _ (Word16) st_fx->last_core_brate_fx: previous frame core bitrate */ -/* _ (Word16[]) mem_tmp : temp. initial synthesis filter states Q_syn */ -/* _ (Word16) Q_exc : quantized LSPs from frame end */ -/* _ (Word16) Q_syn : quantized LSPs from frame end */ +/* _ (Word16[]) mem_tmp : temp. initial synthesis filter states Q_syn */ +/* _ (Word16) Q_exc : quantized LSPs from frame end */ +/* _ (Word16) Q_syn : quantized LSPs from frame end */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc : excitation signal without enhancement Q_exc */ -/* _ (Word16[]) exc2 : excitation signal with enhancement Q_exc */ -/* _ (Word16[]) Aq : LP filter coefs (can be modified if BR) Q12 */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc : excitation signal without enhancement Q_exc */ +/* _ (Word16[]) exc2 : excitation signal with enhancement Q_exc */ +/* _ (Word16[]) Aq : LP filter coefs (can be modified if BR) Q12 */ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /*------------------------------------------------------------------------*/ -/* _ (Word16[]) st_fx->mem_syn2 : initial synthesis filter states Q_syn */ +/* _ (Word16[]) st_fx->mem_syn2 : initial synthesis filter states Q_syn */ /* _ (Word16) st_fx->old_enr_LP : LP filter E of last Q5 */ -/* good voiced frame */ +/* good voiced frame */ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ void FEC_scale_syn_fx( @@ -242,7 +242,7 @@ void FEC_scale_syn_fx( pitch_dist = add( pitch_dist, abs_s( sub( pitch[k + 1], pitch[k] ) ) ); /*Q0*/ L_mean_pitch = L_mac( L_mean_pitch, pitch[k + 1], 8192 ); /*Q14*/ } - /*pitch_dist /= (float)(NB_SUBFR-1); */ + /*pitch_dist /= (float)(NB_SUBFR-1); */ pitch_dist = mult_r( shl( pitch_dist, 4 ), 10923 /*1/(float)(NB_SUBFR-1) in Q15*/ ); /*Q4*/ /*mean_pitch /= (float)(NB_SUBFR);*/ mean_pitch = extract_h( L_shl( L_mean_pitch, 4 ) ); /*Q4*/ diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 4b1e04e08..dc801242c 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -936,10 +936,10 @@ static void decod_gen_voic_core_switch_fx( gain_dec_mless_fx( st_fx, L_frame, GENERIC, 0, -1, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code ); } - /* _ (Word16*) gain_pit : quantized pitch gain (Q14) */ - /* _ (Word32*) gain_code : quantized codebook gain (Q16) */ - /* _ (Word16*) gain_inov : gain of the innovation (used for normalization) (Q12) */ - /* _ (Word32*) norm_gain_code : norm. gain of the codebook excitation (Q16) */ + /* _ (Word16*) gain_pit : quantized pitch gain (Q14) */ + /* _ (Word32*) gain_code : quantized codebook gain (Q16) */ + /* _ (Word16*) gain_inov : gain of the innovation (used for normalization) (Q12) */ + /* _ (Word32*) norm_gain_code : norm. gain of the codebook excitation (Q16) */ st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc ); /*Q15*/ move16(); diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c index 3aabbdaa5..680c492db 100644 --- a/lib_dec/ari_dec_fx.c +++ b/lib_dec/ari_dec_fx.c @@ -19,7 +19,7 @@ Word32 ari_decode_overflow_fx( Tastat *s ) } /** - * \brief Start ArCo decoding + * \brief Start ArCo decoding * * \param[i/o] st * \param[o] s diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c index a8ba2bfc3..21f7d4e1c 100644 --- a/lib_dec/avq_dec_fx.c +++ b/lib_dec/avq_dec_fx.c @@ -23,13 +23,13 @@ static void read_cv_fx( Decoder_State *st, UWord16 *I, Word16 *kv, Word16 nq, Wo *-----------------------------------------------------------------*/ void AVQ_demuxdec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ - Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ - const Word16 Nsv, /* i : number of subvectors Q0*/ - Word16 nq[], /* i/o: AVQ nq index Q0*/ - Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ - Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ + Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ + const Word16 Nsv, /* i : number of subvectors Q0*/ + Word16 nq[], /* i/o: AVQ nq index Q0*/ + Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ + Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ ) { Word16 i, j, bits, tmp; @@ -329,9 +329,9 @@ void AVQ_demuxdec_fx( *-----------------------------------------------------------------*/ void AVQ_dec_lpc( - Word16 *indx, /* input: index[] (4 bits per words) Q0*/ - Word16 *nvecq, /* output: vector quantized Q0*/ - Word16 Nsv /* input: number of subvectors (lg=Nsv*8) Q0*/ + Word16 *indx, /* input: index[] (4 bits per words) Q0*/ + Word16 *nvecq, /* output: vector quantized Q0*/ + Word16 Nsv /* input: number of subvectors (lg=Nsv*8) Q0*/ ) { Word16 i, l, n, nq, nk, pos, ival, c[8], kv[8]; diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index bb2158057..d2f1679e8 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -40,12 +40,12 @@ void bass_psfilter_init_fx( hBPF->pst_mem_deemp_err_fx = 0; /* 0 in Q_syn2-1 */ move16(); hBPF->pst_lp_ener_fx = 0; - move16(); /*0 in Q8 */ + move16(); /*0 in Q8 */ set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); set16_fx( hBPF->Track_on_hist, 0, L_TRACK_HIST ); set16_fx( hBPF->vibrato_hist, 0, L_TRACK_HIST ); - set16_fx( hBPF->mem_mean_pit_fx, 1280, L_TRACK_HIST ); /* 80 in Q4 */ - hBPF->psf_att_fx = 32767; /* 1.0 in Q15 */ + set16_fx( hBPF->mem_mean_pit_fx, 1280, L_TRACK_HIST ); /* 80 in Q4 */ + hBPF->psf_att_fx = 32767; /* 1.0 in Q15 */ move16(); return; @@ -80,17 +80,17 @@ void bass_psfilter_init_fx( /*=========================================================================*/ void bass_psfilter_fx( - BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ - const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ - Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ - const Word16 L_frame, /* i : length of the last frame Q0*/ - Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ - const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ - Word16 v_stab_fx, /* i : stability factor Q15*/ - Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ - const Word16 coder_type, /* i : coder_type Q0*/ + BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ + const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ + Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ + const Word16 L_frame, /* i : length of the last frame Q0*/ + Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ + const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ + Word16 v_stab_fx, /* i : stability factor Q15*/ + Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ + const Word16 coder_type, /* i : coder_type Q0*/ Word16 Q_syn, - Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ + Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ ) { Word16 i, j, i_subfr, T, exp, exp2; @@ -685,9 +685,9 @@ void bass_psfilter_fx( /* CALLED FROM : TX/RX */ /*==============================================================================*/ -static Word16 Pit_track_fx( /* o : Pitch */ - Word16 syn[], /* i : synthesis [-PIT_MAX..L_SUBFR] st_fx->Q_syn2 */ - Word16 T /* i : pitch period (>= PIT_MIN) Q0 */ +static Word16 Pit_track_fx( /* o : Pitch */ + Word16 syn[], /* i : synthesis [-PIT_MAX..L_SUBFR] st_fx->Q_syn2 */ + Word16 T /* i : pitch period (>= PIT_MIN) Q0 */ ) { Word16 T2; diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index dec4a7adf..77bb6386f 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -699,7 +699,7 @@ void CNG_dec_fx( void swb_CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn /* i : Q value of ACELP core synthesis */ @@ -782,7 +782,7 @@ void swb_CNG_dec_ivas_fx( static void shb_CNG_decod_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ) @@ -1047,9 +1047,9 @@ static void shb_CNG_decod_fx( } static void shb_CNG_decod_ivas_fx( - Decoder_State *st, /* i/o: State structure */ + Decoder_State *st, /* i/o: State structure */ const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn ) { diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index aa86fc624..8b78def57 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -357,7 +357,7 @@ void open_decoder_LPD_fx( test(); IF( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO ) { - Copy( st->lsp_old_fx, st->lspold_uw, M ); /* Q15 */ + Copy( st->lsp_old_fx, st->lspold_uw, M ); /* Q15 */ Copy( st->lsf_old_fx, st->lsfold_uw, M ); /* Q2.56 */ set16_fx( st->syn, 0, M ); /* Q_syn */ } @@ -1113,10 +1113,10 @@ void acelp_plc_mdct_transition_fx( } void open_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ diff --git a/lib_dec/core_dec_reconf_fx.c b/lib_dec/core_dec_reconf_fx.c index 2eee8cd9f..77da861c1 100644 --- a/lib_dec/core_dec_reconf_fx.c +++ b/lib_dec/core_dec_reconf_fx.c @@ -11,7 +11,7 @@ void reconfig_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ + Decoder_State *st, /* i/o: decoder state structure */ const Word16 bits_frame, /* i : bit budget Q0*/ const Word16 bwidth, /* i : audio bandwidth Q0*/ const Word32 total_brate, /* i : total bitrate Q0*/ diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index 90379c732..7355b912e 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -236,13 +236,13 @@ void mode_switch_decoder_LPD_fx( } void mode_switch_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ - const Word16 frame_size_index, /* i : index determining the frame size Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ + const Word16 frame_size_index, /* i : index determining the frame size Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ Word16 *Q_syn_Overl_TDAC, Word16 *Q_fer_samples, Word16 *Q_syn_Overl, diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 162e45812..5946f577a 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -174,7 +174,7 @@ static Word32 Calc_freq_ener_fx( *---------------------------------------------------------------------*/ void bw_switching_pre_proc_fx( - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ Decoder_State *st_fx /* i/o: decoder state structure */ ) { @@ -875,7 +875,7 @@ ivas_error core_switching_pre_dec_fx( ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ + Word16 *synth, /* i/o: output synthesis Qsynth*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ @@ -1063,7 +1063,7 @@ ivas_error core_switching_post_dec_fx( hHQ_core->Q_old_wtda = Qtmp; move16(); - Copy( st_fx->delay_buf_out_fx, synth, delay_comp ); /* copy the HQ/ACELP delay synchroniation buffer at the beginning of ACELP frame Q0*/ + Copy( st_fx->delay_buf_out_fx, synth, delay_comp ); /* copy the HQ/ACELP delay synchroniation buffer at the beginning of ACELP frame Q0*/ tmp = i_mult2( delta, N_ZERO_8 ); shift = i_mult2( Fs_kHz, 3 ); @@ -1258,7 +1258,7 @@ ivas_error core_switching_post_dec_fx( ivas_error core_switching_post_dec_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ diff --git a/lib_dec/dec2t32_fx.c b/lib_dec/dec2t32_fx.c index 71b284562..87058fe54 100644 --- a/lib_dec/dec2t32_fx.c +++ b/lib_dec/dec2t32_fx.c @@ -8,28 +8,28 @@ /*==========================================================================*/ -/* FUNCTION : void dec_acelp_2t32_fx () */ +/* FUNCTION : void dec_acelp_2t32_fx () */ /*--------------------------------------------------------------------------*/ -/* PURPOSE : */ -/* * 12 bits algebraic codebook decoder. */ -/* * 2 track x 32 positions per track = 64 samples. */ -/* * 12 bits --> 2 pulses in a frame of 64 samples. */ -/* * All pulses can have two (2) possible amplitudes: +1 or -1. */ -/* * Each pulse can have 32 possible positions. */ -/* * See cod2t32.c for more details of the algebraic code. */ +/* PURPOSE : */ +/* * 12 bits algebraic codebook decoder. */ +/* * 2 track x 32 positions per track = 64 samples. */ +/* * 12 bits --> 2 pulses in a frame of 64 samples. */ +/* * All pulses can have two (2) possible amplitudes: +1 or -1. */ +/* * Each pulse can have 32 possible positions. */ +/* * See cod2t32.c for more details of the algebraic code. */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _Word16 i_subfr, i : subframe index */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* _Word16 code[] o : algebraic (fixed) codebook excitation Q12 */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*==========================================================================*/ void dec_acelp_2t32_fx( @@ -72,24 +72,24 @@ void dec_acelp_2t32_fx( } /*==========================================================================*/ -/* FUNCTION : void dec_acelp_1t64_fx () */ +/* FUNCTION : void dec_acelp_1t64_fx () */ /*--------------------------------------------------------------------------*/ -/* PURPOSE : * 7 bits algebraic codebook. */ -/* * 1 track x 64 positions per track = 64 samples. */ +/* PURPOSE : * 7 bits algebraic codebook. */ +/* * 1 track x 64 positions per track = 64 samples. */ /* * The pulse can have 64 possible positions and two (2) possible amplitudes: +1 or -1.*/ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _Word16 i_subfr, i : subframe index */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* _Word16 code[] o : algebraic (fixed) codebook excitation Q12 */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*==========================================================================*/ void dec_acelp_1t64_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 1b56c69cf..69efcb79e 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -22,32 +22,32 @@ static void fcb_decode_PI_fx( Word32 code_index, Word16 sector_6p[], Word16 puls /*==========================================================================*/ -/* FUNCTION : void dec_acelp_4t64_fx () */ +/* FUNCTION : void dec_acelp_4t64_fx () */ /*--------------------------------------------------------------------------*/ -/* PURPOSE : */ -/* * 20, 36 bits algebraic codebook decoder. */ -/* * 4 tracks x 16 positions per track = 64 samples. */ -/* * 20 bits --> 4 pulses in a frame of 64 samples. */ -/* * 36 bits --> 8 pulses in a frame of 64 samples. */ -/* * All pulses can have two (2) possible amplitudes: +1 or -1. */ -/* * Each pulse can have sixteen (16) possible positions. */ -/* * See cod4t64.c for more details of the algebraic code. */ +/* PURPOSE : */ +/* * 20, 36 bits algebraic codebook decoder. */ +/* * 4 tracks x 16 positions per track = 64 samples. */ +/* * 20 bits --> 4 pulses in a frame of 64 samples. */ +/* * 36 bits --> 8 pulses in a frame of 64 samples. */ +/* * All pulses can have two (2) possible amplitudes: +1 or -1. */ +/* * Each pulse can have sixteen (16) possible positions. */ +/* * See cod4t64.c for more details of the algebraic code. */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _Word16 i_subfr i : subframe index */ /* _Word16 nbbits i : number of bits per codebook */ /* _Word16 FCB_5Sx4T_fla i : 5Sx4Track flag for PI */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _Word16 code[] o : algebraic (fixed) codebook excitation Q12 */ +/* OUTPUT ARGUMENTS : */ +/* _Word16 code[] o : algebraic (fixed) codebook excitation Q12 */ /* _Word16 index_buf_4T[] o : 5Sx4Track buffer for PI */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*==========================================================================*/ void dec_acelp_4t64_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 53da3c36a..df70df033 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -46,7 +46,7 @@ ivas_error decod_gen_voic_fx( Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */ Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14 */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14 */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ ) diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index c6cb34ddc..fa76b34c6 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -238,27 +238,27 @@ void transf_cdbk_dec_fx( } /*==========================================================================*/ -/* FUNCTION : Word16 gain_dequant_fx () */ +/* FUNCTION : Word16 gain_dequant_fx () */ /*--------------------------------------------------------------------------*/ -/* PURPOSE : */ -/* * Returns decoded gain quantized between the specified */ -/* * range using the specified number of levels. */ +/* PURPOSE : */ +/* * Returns decoded gain quantized between the specified */ +/* * range using the specified number of levels. */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Word16 index i: quantization index */ -/* Word16 min_val i : value of lower limit */ -/* Word16 max_val i : value of upper limit */ -/* Word16 bits i : number of bits to dequantize */ +/* INPUT ARGUMENTS : */ +/* Word16 index i: quantization index */ +/* Word16 min_val i : value of lower limit */ +/* Word16 max_val i : value of upper limit */ +/* Word16 bits i : number of bits to dequantize */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _Word16 *expg o : */ +/* OUTPUT ARGUMENTS : */ +/* _Word16 *expg o : */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* Word16 gain Q0 */ +/* RETURN ARGUMENTS : */ +/* Word16 gain Q0 */ /*--------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*==========================================================================*/ Word16 gain_dequant_fx( /* o: decoded gain */ Word16 index, /* i: quantization index */ diff --git a/lib_dec/dec_nelp_fx.c b/lib_dec/dec_nelp_fx.c index fe882ffbc..c6f6f5cfd 100644 --- a/lib_dec/dec_nelp_fx.c +++ b/lib_dec/dec_nelp_fx.c @@ -17,8 +17,8 @@ /* _ (Word16[]) tmp_noise_fx : long term temporary noise energy */ /* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe(Q6) */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ /* _ (Word16) bfi : frame error rate */ /*-----------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ @@ -29,11 +29,11 @@ /* _ (Word16[]) tmp_noise_fx : long term temporary noise energy (Q0) */ /* _ (Word16[]) pitch_buf_fx : floating pitch values for each - subframe (Q6) */ + subframe (Q6) */ /* _ (Word16[]) st_fx->dispMem : Noise enhancer - phase dispersion - algorithm memory (Q14) */ -/* _ (Word16) st_fx->tilt_code : tilt of code (Q15) */ -/* _ (Word16) st_fx->prev_gain_pit_dec */ + algorithm memory (Q14) */ +/* _ (Word16) st_fx->tilt_code : tilt of code (Q15) */ +/* _ (Word16) st_fx->prev_gain_pit_dec */ /*-----------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index ad80b53f8..009102c1f 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -8,26 +8,26 @@ #include "prot_fx.h" /* Function prototypes */ /*==========================================================================*/ -/* FUNCTION : void dec_pit_exc_fx() */ +/* FUNCTION : void dec_pit_exc_fx() */ /*--------------------------------------------------------------------------*/ -/* PURPOSE : Decode pitch only contribution */ +/* PURPOSE : Decode pitch only contribution */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16*) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16) coder_type : coding type Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16*) Aq_fx : LP filter coefficient Q12 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) nb_subfr_fx :Number of subframe considered */ /* _ (Word16) Es_pred_fx :predicted scaled innov. energy */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) pitch_buf_fx : floating pitch values for each subframe Q6 */ -/* _ (Word16*) code_fx : innovation Q12 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) pitch_buf_fx : floating pitch values for each subframe Q6 */ +/* _ (Word16*) code_fx : innovation Q12 */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /* Decoder_State_fx *st_fx : decoder state structure */ -/* _ (Word16*) exc_fx : adapt. excitation exc */ +/* _ (Word16*) exc_fx : adapt. excitation exc */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*==========================================================================*/ void dec_pit_exc_fx( diff --git a/lib_dec/dec_ppp_fx.c b/lib_dec/dec_ppp_fx.c index 4b3f4f554..d426b5962 100644 --- a/lib_dec/dec_ppp_fx.c +++ b/lib_dec/dec_ppp_fx.c @@ -8,43 +8,43 @@ #include "prot_fx.h" /* Function prototypes */ /*===================================================================*/ -/* FUNCTION : void decod_ppp_fx () */ +/* FUNCTION : void decod_ppp_fx () */ /*-------------------------------------------------------------------*/ -/* PURPOSE : decode highly voiced frames using PPP */ +/* PURPOSE : decode highly voiced frames using PPP */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ const Word16 Aq_fx[] - Q12 12k8 Lp coefficient */ -/* _ Word16 bfi_fx - Q0 bad frame indicator */ +/* _ const Word16 Aq_fx[] - Q12 12k8 Lp coefficient */ +/* _ Word16 bfi_fx - Q0 bad frame indicator */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ Decoder_State_fx *st_fx: */ +/* _ Decoder_State_fx *st_fx: */ /* _ lastLgainD_fx - Q11 */ /* _ lastHgainD_fx - Q11 */ /* _ lasterbD_fx - Q13 */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ Decoder_State_fx *st_fx: */ -/* _ lsp_old_fx - Q15 */ -/* _ st_fx->dtfs_dec_xxxx */ -/* _ a nd b in st_fx->dtfs_dec_Q */ -/* rest all in Q0 */ +/* _ Decoder_State_fx *st_fx: */ +/* _ lsp_old_fx - Q15 */ +/* _ st_fx->dtfs_dec_xxxx */ +/* _ a nd b in st_fx->dtfs_dec_Q */ +/* rest all in Q0 */ /* _ gainp_ppp Q14 */ /* _ FadeScale_fx - Q15 */ /* _ tilt_code_fx - Q15 */ -/* _ prev_tilt_code_dec_fx - Q15 */ +/* _ prev_tilt_code_dec_fx - Q15 */ /* _ prev_gain_pit_dec_fx - Q14 */ /* _ dm_fx.prev_state - Q0 */ /* _ dm_fx.prev_gain_code - Q16 */ /* _ .dm_fx.prev_gain_pit - Q14 */ -/* _ prev_gain_pit_dec - Q14 */ -/* _ Word16 *pitch_buf_fx - Q6 fixed pitch values for each subframe */ -/* _ Word16 *exc_fx - Q_exc current non-enhanced excitation */ -/* _ Word16 *exc2_fx - Q_exc current enhanced excitation */ +/* _ prev_gain_pit_dec - Q14 */ +/* _ Word16 *pitch_buf_fx - Q6 fixed pitch values for each subframe */ +/* _ Word16 *exc_fx - Q_exc current non-enhanced excitation */ +/* _ Word16 *exc2_fx - Q_exc current enhanced excitation */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ -/* _ None */ +/* _ None */ /*-------------------------------------------------------------------*/ -/* CALLED FROM : RX */ +/* CALLED FROM : RX */ /*===================================================================*/ ivas_error decod_ppp_fx( @@ -54,7 +54,7 @@ ivas_error decod_ppp_fx( Word16 *exc_fx, /* i/o: current non-enhanced excitation */ Word16 *exc2_fx, /* i/o: current enhanced excitation */ Word16 bfi, /* i : bad frame indicator */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ Word16 *voice_factors, /* o : voicing factors */ Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ ) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index a8db9f9cc..fd13ae5ac 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2734,14 +2734,14 @@ static void TCX_MDCT_Inverse_qwin_fx( FOR( i = 0; i < R2; i++ ) { - y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ + y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ move16(); } FOR( i = 0; i < L2; i++ ) { - y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ + y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ move16(); } @@ -2750,7 +2750,7 @@ static void TCX_MDCT_Inverse_qwin_fx( Word16 f; f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); - y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ move16(); y[l + m + R2 - 1 - i] = f; move16(); @@ -2800,13 +2800,13 @@ static void TCX_MDST_Inverse_qwin_fx( FOR( i = 0; i < R2; i++ ) { - y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ move16(); } FOR( i = 0; i < L2; i++ ) { - y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ move16(); } @@ -2885,12 +2885,12 @@ static void TCX_MDXT_Inverse_qwin_fx( FOR( i = 0; i < L2; i++ ) { - y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end exp(fac_e)*/ + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end exp(fac_e)*/ } FOR( i = 0; i < R2; i++ ) { - y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end exp(fac_e)*/ + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end exp(fac_e)*/ move16(); } @@ -2899,7 +2899,7 @@ static void TCX_MDXT_Inverse_qwin_fx( f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); - y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ move16(); y[l + m + R2 - 1 - i] = f; diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 4bee037ef..fe1ceeb23 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -12,29 +12,27 @@ #define Q16_30 ( 30 << Q16 ) /*======================================================================*/ -/* FUNCTION : decod_tran_fx() */ +/* FUNCTION : decod_tran_fx() */ /*----------------------------------------------------------------------*/ -/* PURPOSE : Decode transition (TC) frames */ -/* */ +/* PURPOSE : Decode transition (TC) frames */ +/* */ /*----------------------------------------------------------------------*/ -/* GLOBAL INPUT ARGUMENTS : */ -/* _ (Struct) st_fx : decoder static memory */ -/* _ (Word16) L_frame_fx : length of the frame Q0 */ -/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16) coder_type : coding type Q12 */ -/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ -/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ -/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ +/* GLOBAL INPUT ARGUMENTS : */ +/* _ (Struct) st_fx : decoder static memory */ +/* _ (Word16) L_frame_fx : length of the frame Q0 */ +/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ +/* _ (Word16) coder_type : coding type Q12 */ +/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ +/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ +/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ /*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ /*-----------------------------------------------------------------------*/ - - /*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*=======================================================================*/ void decod_tran_fx( diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index f1ba21979..cf2c7dcfc 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -26,17 +26,17 @@ static void gain_dec_gacelp_uv_fx( *-------------------------------------------------------------------*/ void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ Word16 *gain_buf ) { Word16 gain_pit_fx; /* Quantized pitch gain */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index dfbc8996f..7b3ab145d 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2864,8 +2864,8 @@ void generate_comfort_noise_dec_fx( E_UTIL_deemph2( NOISE_HEADROOM, - noise, /* I/O: signal Qx */ - preemph_fac, /* I: deemphasis factor Qx */ + noise, /* I/O: signal Qx */ + preemph_fac, /* I: deemphasis factor Qx */ N, /* I: vector size */ &tmp /* I/O: memory (signal[-1]) Qx */ ); @@ -3583,8 +3583,8 @@ void generate_comfort_noise_dec_ivas_fx( E_UTIL_deemph2( NOISE_HEADROOM, - noise, /* I/O: signal Qx */ - preemph_fac, /* I: deemphasis factor Qx */ + noise, /* I/O: signal Qx */ + preemph_fac, /* I: deemphasis factor Qx */ N, /* I: vector size */ &tmp /* I/O: memory (signal[-1]) Qx */ ); diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index f7dfbbdd7..ed0c87e5d 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -9,24 +9,24 @@ /*===========================================================================*/ -/* FUNCTION : Es_pred_dec_fx() */ +/* FUNCTION : Es_pred_dec_fx() */ /*---------------------------------------------------------------------------*/ -/* PURPOSE : Decoding of scaled predicted innovation energy to be */ -/* used in all subframes */ +/* PURPOSE : Decoding of scaled predicted innovation energy to be */ +/* used in all subframes */ /*---------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) coder_type : coder type */ -/* _ (Word32) core_brate : core bitrate */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) coder_type : coder type */ +/* _ (Word32) core_brate : core bitrate */ /* _ (Word16*) Es_pred_qua_nb_fx : Gain quantization - quantization table */ -/* for scaled innovation energy prediciton Q8*/ +/* for scaled innovation energy prediciton Q8*/ /*---------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) Es_pred : predicited scaled innovation energy Q8 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) Es_pred : predicited scaled innovation energy Q8 */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*===========================================================================*/ void Es_pred_dec_fx( Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ @@ -63,30 +63,30 @@ void Es_pred_dec_fx( } } /*======================================================================================*/ -/* FUNCTION : void gain_dec_tc_fx () */ +/* FUNCTION : void gain_dec_tc_fx () */ /*--------------------------------------------------------------------------------------*/ /* PURPOSE : Decoding of pitch and codebook gains and updating long term energies */ /*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Word32 core_brate_fx i : core bitrate */ -/* Word16 *code_fx i : algebraic code excitation */ -/* Word16 L_frame_fx i : length of the frame */ -/* Word16 i_subfr_fx i : subframe number */ -/* Word16 tc_subfr_fx i : TC subframe index */ -/* Word16 Es_pred_fx i : predicted scaled innov. energy Q8 */ +/* INPUT ARGUMENTS : */ +/* Word32 core_brate_fx i : core bitrate */ +/* Word16 *code_fx i : algebraic code excitation */ +/* Word16 L_frame_fx i : length of the frame */ +/* Word16 i_subfr_fx i : subframe number */ +/* Word16 tc_subfr_fx i : TC subframe index */ +/* Word16 Es_pred_fx i : predicted scaled innov. energy Q8 */ /*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* Word16 *gain_pit_fx o : pitch gain Q14 */ -/* Word32 *gain_code_fx o : Quantized codeebook gain Q16 */ -/* Word16 *gain_inov_fx o : unscaled innovation gain Q12 */ -/* Word32 *norm_gain_code_fx o : norm. gain of the codebook excit. Q16 */ +/* OUTPUT ARGUMENTS : */ +/* Word16 *gain_pit_fx o : pitch gain Q14 */ +/* Word32 *gain_code_fx o : Quantized codeebook gain Q16 */ +/* Word16 *gain_inov_fx o : unscaled innovation gain Q12 */ +/* Word32 *norm_gain_code_fx o : norm. gain of the codebook excit. Q16 */ /*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*======================================================================================*/ void gain_dec_tc_fx( @@ -195,30 +195,30 @@ void gain_dec_tc_fx( } /*======================================================================================*/ -/* FUNCTION : void gain_dec_tc_ivas_fx () */ +/* FUNCTION : void gain_dec_tc_ivas_fx () */ /*--------------------------------------------------------------------------------------*/ /* PURPOSE : Decoding of pitch and codebook gains and updating long term energies */ /*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Word32 core_brate_fx i : core bitrate */ -/* Word16 *code_fx i : algebraic code excitation */ -/* Word16 L_frame_fx i : length of the frame */ -/* Word16 i_subfr_fx i : subframe number */ -/* Word16 tc_subfr_fx i : TC subframe index */ -/* Word16 Es_pred_fx i : predicted scaled innov. energy Q8 */ +/* INPUT ARGUMENTS : */ +/* Word32 core_brate_fx i : core bitrate */ +/* Word16 *code_fx i : algebraic code excitation */ +/* Word16 L_frame_fx i : length of the frame */ +/* Word16 i_subfr_fx i : subframe number */ +/* Word16 tc_subfr_fx i : TC subframe index */ +/* Word16 Es_pred_fx i : predicted scaled innov. energy Q8 */ /*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* Word16 *gain_pit_fx o : pitch gain Q14 */ -/* Word32 *gain_code_fx o : Quantized codeebook gain Q16 */ -/* Word16 *gain_inov_fx o : unscaled innovation gain Q12 */ -/* Word32 *norm_gain_code_fx o : norm. gain of the codebook excit. Q16 */ +/* OUTPUT ARGUMENTS : */ +/* Word16 *gain_pit_fx o : pitch gain Q14 */ +/* Word32 *gain_code_fx o : Quantized codeebook gain Q16 */ +/* Word16 *gain_inov_fx o : unscaled innovation gain Q12 */ +/* Word32 *norm_gain_code_fx o : norm. gain of the codebook excit. Q16 */ /*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*======================================================================================*/ void gain_dec_tc_ivas_fx( @@ -326,40 +326,39 @@ void gain_dec_tc_ivas_fx( } /*======================================================================================*/ -/* FUNCTION : gain_dec_mless_fx() */ +/* FUNCTION : gain_dec_mless_fx() */ /*--------------------------------------------------------------------------------------*/ -/* PURPOSE : Decoding of pitch and codebook gains without updating long term energies */ +/* PURPOSE : Decoding of pitch and codebook gains without updating long term energies */ /*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) core_brate_fx : core bitrate */ -/* _ (Word16) L_frame_fx : length of the frame */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16) i_subfr_fx : subframe index */ -/* _ (Word16) tc_subfr_fx : TC subframe index */ -/* _ (Word16*[]) code_fx : algebraic code excitation (Q12) */ -/* _ (Word16) Es_pred_fx : predicted scaled innov. energy (Q8) */ +/* INPUT ARGUMENTS : */ +/* _ (Word32) core_brate_fx : core bitrate */ +/* _ (Word16) L_frame_fx : length of the frame */ +/* _ (Word16) coder_type : coding type */ +/* _ (Word16) i_subfr_fx : subframe index */ +/* _ (Word16) tc_subfr_fx : TC subframe index */ +/* _ (Word16*[]) code_fx : algebraic code excitation (Q12) */ +/* _ (Word16) Es_pred_fx : predicted scaled innov. energy (Q8) */ /*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) gain_pit_fx : quantized pitch gain (Q14) */ -/* _ (Word32*) gain_code_fx : quantized codebook gain (Q16) */ -/* _ (Word16*) gain_inov_fx : gain of the innovation (used for normalization) (Q12) */ -/* _ (Word32*) norm_gain_code_fx : norm. gain of the codebook excitation (Q16) */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) gain_pit_fx : quantized pitch gain (Q14) */ +/* _ (Word32*) gain_code_fx : quantized codebook gain (Q16) */ +/* _ (Word16*) gain_inov_fx : gain of the innovation (used for normalization) (Q12) */ +/* _ (Word32*) norm_gain_code_fx : norm. gain of the codebook excitation (Q16) */ /*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ None */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ - -/* _ None */ +/* _ None */ /*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*======================================================================================*/ void gain_dec_mless_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ const Word16 *code_fx, /* i : algebraic code excitation */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ @@ -572,30 +571,29 @@ void gain_dec_mless_fx( } /*==================================================================================*/ -/* FUNCTION : gain_dec_lbr_fx() */ +/* FUNCTION : gain_dec_lbr_fx() */ /*----------------------------------------------------------------------------------*/ -/* PURPOSE : Decoding of pitch and codebook gains in ACELP at 6.6 and 7.5 kbps */ +/* PURPOSE : Decoding of pitch and codebook gains in ACELP at 6.6 and 7.5 kbps */ /*----------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) core_brate : core bitrate */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16) i_subfr : subframe index */ -/* _ (Word16*[]) code_fx : algebraic excitation (Q12) */ +/* INPUT ARGUMENTS : */ +/* _ (Word32) core_brate : core bitrate */ +/* _ (Word16) coder_type : coding type */ +/* _ (Word16) i_subfr : subframe index */ +/* _ (Word16*[]) code_fx : algebraic excitation (Q12) */ /*----------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) gain_pit_fx : quantized pitch gain (Q14) */ -/* _ (Word32*) gain_code_fx : quantized codebook gain (Q16) */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) gain_pit_fx : quantized pitch gain (Q14) */ +/* _ (Word32*) gain_code_fx : quantized codebook gain (Q16) */ /* _ (Word16*) gain_inov_fx : gain of the innovation (used for normalization) (Q12) */ -/* _ (Word32*) norm_gain_code_fx : norm. gain of the codebook excitation (Q12) */ +/* _ (Word32*) norm_gain_code_fx : norm. gain of the codebook excitation (Q12) */ /*----------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ None */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ None */ /*----------------------------------------------------------------------------------*/ - -/* _ None */ +/* _ None */ /*----------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*==================================================================================*/ void gain_dec_lbr_fx( @@ -618,7 +616,7 @@ void gain_dec_lbr_fx( Word16 expg, expg2, e_tmp, exp_gcode0, f_tmp, frac, tmp_fx; const Word16 *b_fx, *cdbk_fx = 0; /* Ecode = ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR; - *gain_inov = 1.0f / (float)sqrt(Ecode); */ + *gain_inov = 1.0f / (float)sqrt(Ecode); */ Word16 shift_L_subfr; shift_L_subfr = 6; move16(); // for *cdbk_fx @@ -971,7 +969,7 @@ void gain_dec_lbr_fx( /* PURPOSE : Update of LP pitch and code gains (FEC) */ /* */ /*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word16) i_subfr : subframe number Q0 */ /* _ (Word16) gain_pit : Decoded gain pitch Q14 */ /* _ (Word32) norm_gain_code : Normalised gain code Q16 */ @@ -1083,7 +1081,7 @@ void lp_gain_updt_fx( /* PURPOSE : Update of LP pitch and code gains (FEC) */ /* */ /*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word16) i_subfr : subframe number Q0 */ /* _ (Word16) gain_pit : Decoded gain pitch Q14 */ /* _ (Word32) norm_gain_code : Normalised gain code Q16 */ diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c index 802cc3b41..539d471c1 100644 --- a/lib_dec/gaus_dec_fx.c +++ b/lib_dec/gaus_dec_fx.c @@ -23,23 +23,23 @@ static void dec_2pos_fx( Word16 index, Word16 *ind1, Word16 *ind2, Word16 *sign1 * - find the excitation *---------------------------------------------------------------------*/ void gaus_dec_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* o : unvoiced excitation Q12 */ - Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ - Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ - Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ - Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ - Word16 *voice_fac, /* o : estimated voicing factor Q15 */ - Word16 *gain_pit, /* o : pitch gain Q14 */ - Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ - Word16 *exc, /* o : excitation signal frame */ - Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ - Word16 *exc2, /* o : Scaled excitation signal frame */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* o : unvoiced excitation Q12 */ + Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ + Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ + Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ + Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ + Word16 *voice_fac, /* o : estimated voicing factor Q15 */ + Word16 *gain_pit, /* o : pitch gain Q14 */ + Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ + Word16 *exc, /* o : excitation signal frame */ + Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ + Word16 *exc2, /* o : Scaled excitation signal frame */ Word16 *bwe_exc_fx, - Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ - Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ + Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ + Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ ) { Word16 i, exp, gain_code; diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c index 4a0bf352f..32d5d6ba3 100644 --- a/lib_dec/gs_dec_amr_wb_fx.c +++ b/lib_dec/gs_dec_amr_wb_fx.c @@ -76,8 +76,8 @@ static void NoiseFill_fx( static void Ener_per_band_fx( const Word16 exc_diff_fx[], /* i : target signal exp(exc_diff_exp)*/ - const Word16 exc_diff_exp, /* i : Exponent of exc_diff_fx */ - Word32 y_gain4_fx[] /* o : Energy per band to quantize Q16*/ + const Word16 exc_diff_exp, /* i : Exponent of exc_diff_fx */ + Word32 y_gain4_fx[] /* o : Energy per band to quantize Q16*/ ) { const Word16 *ptr16; @@ -172,10 +172,10 @@ static void Apply_gain_fx( *-------------------------------------------------------------------*/ static void normalize_spec_fx( - Word16 fac_up_fx, /* i : Core bitrate (Q8)*/ - Word16 fy_norm_fx[], /* i/o: Frequency quantized parameter (Q8)*/ - const Word16 L_frame, /* i : Section lenght Q0*/ - const Word16 Q_out /* i : Q of fy_norm_fx[] */ + Word16 fac_up_fx, /* i : Core bitrate (Q8)*/ + Word16 fy_norm_fx[], /* i/o: Frequency quantized parameter (Q8)*/ + const Word16 L_frame, /* i : Section lenght Q0*/ + const Word16 Q_out /* i : Q of fy_norm_fx[] */ ) { Word16 idx, j; @@ -211,7 +211,7 @@ static void gs_dec_amr_wb_fx( Word16 dct_out_fx[], /* o : dct of pitch only excitation Q_dct_out*/ Word16 Q_dct_out, /* o : Exponent of dct_out_fx */ const Word16 pitch_fx[], /* i : pitch buffer Q6*/ - const Word16 voice_fac, /* i : gain pitch Q15*/ + const Word16 voice_fac, /* i : gain pitch Q15*/ const Word16 clas, /* i : signal frame class Q0*/ const Word16 coder_type /* i : coder type Q0*/ ) @@ -340,24 +340,24 @@ static void gs_dec_amr_wb_fx( * unvoiced and audio signals (used only in AMR-WB IO mode) *-------------------------------------------------------------------*/ void improv_amr_wb_gs_fx( - const Word16 clas, /* i : signal frame class Q0*/ - const Word16 coder_type, /* i : coder type Q0*/ - const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ - Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ - Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type, /* i : coder type Q0*/ + const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ + Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ - const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ + const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ const Word16 locattack, /* i : Flag for a detected attack Q0*/ Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ - const Word16 Q_exc2, /* i : Exponent of Exc2 */ - Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ + const Word16 Q_exc2, /* i : Exponent of Exc2 */ + Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ - const Word16 Q_syn, /* i : Synthesis scaling */ - const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ - const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ - const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ - const Word16 last_coder_type /* i : Last coder_type Q0*/ + const Word16 Q_syn, /* i : Synthesis scaling */ + const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ + const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ + const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ + const Word16 last_coder_type /* i : Last coder_type Q0*/ ) { Word16 i, exp_a, exp_b, exp_diff, j; diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 61fb000e4..d68b0a523 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -9,30 +9,30 @@ #include "prot_fx.h" #include "ivas_cnst.h" /*=========================================================================*/ -/* FUNCTION : void decod_audio_fx(); */ +/* FUNCTION : void decod_audio_fx(); */ /*-------------------------------------------------------------------------*/ -/* PURPOSE : Decode audio (AC) frames */ +/* PURPOSE : Decode audio (AC) frames */ /*-------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16[]) Aq : LP filter coefficient Q12 */ -/* _ (Word16) coder_type : coding type Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16[]) Aq : LP filter coefficient Q12 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _(Word16) Q_exc :Q format of excitation */ /*-------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ -/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* Decoder_State *st_fx : decoder memory structure */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*==========================================================================*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ +/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ +/*-------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* Decoder_State *st_fx : decoder memory structure */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ +/*-------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*=========================================================================*/ void decod_audio_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ + Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ const Word16 *Aq, /* i : LP filter coefficient Q12*/ Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ @@ -41,7 +41,7 @@ void decod_audio_fx( Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ @@ -531,38 +531,38 @@ void decod_audio_fx( } /*==========================================================================*/ -/* FUNCTION : void gsc_dec_fx () */ +/* FUNCTION : void gsc_dec_fx () */ /*--------------------------------------------------------------------------*/ /* PURPOSE : Generic audio signal decoder */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word16) pit_band_idx : bin position of the cut-off frequency Q0 */ -/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ +/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) bits_used : Number of bit used before frequency Q Q0 */ /* _ (Word16) nb_subfr : Number of subframe considered Q0 */ -/* _ (Word16) Qexc : Q format of exc_dct_in */ +/* _ (Word16) Qexc : Q format of exc_dct_in */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* Decoder_State *st_fx:Decoder State Structure */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* Decoder_State *st_fx:Decoder State Structure */ /* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Qexc*/ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _None */ +/* RETURN ARGUMENTS : */ +/* _None */ /*==========================================================================*/ void gsc_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *Q_exc ) diff --git a/lib_dec/hdecnrm_fx.c b/lib_dec/hdecnrm_fx.c index aa6c041cc..61fa36d93 100644 --- a/lib_dec/hdecnrm_fx.c +++ b/lib_dec/hdecnrm_fx.c @@ -12,9 +12,9 @@ /* Huffman decoding for indices of quantized norms */ /*--------------------------------------------------------------------------*/ void hdecnrm_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 numNorms, /* i : number of norms Q0*/ - Word16 *index ) /* o : indices of quantized norms Q0*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 numNorms, /* i : number of norms Q0*/ + Word16 *index ) /* o : indices of quantized norms Q0*/ { Word16 i, j, k, n, m; Word16 temp; @@ -169,8 +169,8 @@ void hdecnrm_context_fx( void hdecnrm_resize_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* (i) number of SFMs Q0*/ - Word16 *index /* (o) norm quantization index vector Q0*/ + const Word16 N, /* (i) number of SFMs Q0*/ + Word16 *index /* (o) norm quantization index vector Q0*/ ) { Word16 i, j, k, m; @@ -294,9 +294,9 @@ void huff_dec_fx( *--------------------------------------------------------------------------*/ void hdecnrm_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : number of norms Q0*/ - Word16 *index /* o : indices of quantized norms Q0*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : number of norms Q0*/ + Word16 *index /* o : indices of quantized norms Q0*/ ) { Word16 i, j, k, n, m; diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index 06ab1d95a..275b068f2 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -79,12 +79,12 @@ void hf_synth_reset_fx( *---------------------------------------------------------------------*/ void hf_synth_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ const Word16 Q_exc, /* i : excitation scaling */ const Word16 Q_syn2 /* i : synthesis scaling */ @@ -122,12 +122,12 @@ static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_subfr, /* i : output sub-frame length Q0*/ - const Word16 Aq[], /* i : quantized Az Q12*/ - const Word16 exc[], /* i : excitation at 12.8 kHz Q_exc*/ - const Word16 Q_exc, /* i : excitation scaling */ - Word16 synth[], /* i : 12.8kHz synthesis signal Q_syn*/ - Word16 synth16k[], /* i/o: 16kHz synthesis signal Q_syn*/ - const Word16 Q_syn /* i : synthesis scaling */ + const Word16 Aq[], /* i : quantized Az Q12*/ + const Word16 exc[], /* i : excitation at 12.8 kHz Q_exc*/ + const Word16 Q_exc, /* i : excitation scaling */ + Word16 synth[], /* i : 12.8kHz synthesis signal Q_syn*/ + Word16 synth16k[], /* i/o: 16kHz synthesis signal Q_syn*/ + const Word16 Q_syn /* i : synthesis scaling */ ) { Word16 i, s; @@ -293,12 +293,12 @@ static void hf_synthesis_fx( } void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ const Word16 Q_exc, /* i : excitation scaling */ const Word16 Q_syn2 /* i : synthesis scaling */ @@ -509,11 +509,11 @@ static void hf_synthesis_ivas_fx( * (gain=4.0) *-------------------------------------------------------------------*/ static void filt_6k_7k_scale_fx( - Word16 signal[], /* i/o: signal Qx*/ - Word16 lg, /* i : length of input Q0*/ - Word16 mem[], /* i/o: memory (size=30) exp*/ - Word16 fact, /* i : multiply factor Q0*/ - Word16 exp /* i : Mem Exponent */ + Word16 signal[], /* i/o: signal Qx*/ + Word16 lg, /* i : length of input Q0*/ + Word16 mem[], /* i/o: memory (size=30) exp*/ + Word16 fact, /* i : multiply factor Q0*/ + Word16 exp /* i : Mem Exponent */ ) { Word16 i, x[L_FRAME48k / NB_SUBFR + ( L_FIR - 1 )]; @@ -645,17 +645,17 @@ void hf_synth_amr_wb_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az : Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ - Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ + const Word16 *Aq, /* i : quantized Az : Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ + Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ - Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ - Word16 fmerit, /* i : classify parameter from FEC : Q14*/ + Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ + Word16 fmerit, /* i : classify parameter from FEC : Q14*/ const Word16 *hf_gain, /* i : decoded HF gain Q0*/ - const Word16 *voice_factors, /* i : voicing factors : Q15*/ - const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ - const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ - const Word16 *lsf_new, /* i : ISF vector : Q2*/ + const Word16 *voice_factors, /* i : voicing factors : Q15*/ + const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ + const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ + const Word16 *lsf_new, /* i : ISF vector : Q2*/ const Word16 Q_exc, /* i : exc scaling */ const Word16 Q_out /* i : Q_syn2-1 */ ) @@ -1202,19 +1202,19 @@ void hf_synth_amr_wb_fx( return; } static void hf_synthesis_amr_wb_fx( - const Word32 core_brate, /* i : core bitrate : Q0*/ - const Word16 output_subfr, /* i : output sub-frame length : Q0*/ - const Word16 Ap[], /* i : quantized Aq : Q12*/ - Word16 exc16k[], /* i : excitation at 16 kHz : qhf*/ + const Word32 core_brate, /* i : core bitrate : Q0*/ + const Word16 output_subfr, /* i : output sub-frame length : Q0*/ + const Word16 Ap[], /* i : quantized Aq : Q12*/ + Word16 exc16k[], /* i : excitation at 16 kHz : qhf*/ Word16 synth_out[], /* i/o: synthesis signal at output Fs : Q_out*/ - Word16 *mem_syn_hf, /* i/o: HF synthesis memory : Q_out*/ - Word16 *delay_syn_hf, /* i/o: HF synthesis memory : Q_out*/ - Word16 *mem_hp_interp, /* i/o: interpol. memory : Q_out*/ - Word16 p_r, /* i : sub-frame gain : Q12*/ - Word16 HF_corr_gain, /* i : HF gain index : Q14*/ + Word16 *mem_syn_hf, /* i/o: HF synthesis memory : Q_out*/ + Word16 *delay_syn_hf, /* i/o: HF synthesis memory : Q_out*/ + Word16 *mem_hp_interp, /* i/o: interpol. memory : Q_out*/ + Word16 p_r, /* i : sub-frame gain : Q12*/ + Word16 HF_corr_gain, /* i : HF gain index : Q14*/ Word16 til, /* Q14 */ Word16 voice_factors, /* Q14 */ - const Word16 exc[], /* i : excitation at 12.8 kHz : Qexc*/ + const Word16 exc[], /* i : excitation at 12.8 kHz : Qexc*/ const Word16 Q_exc, /*exc scaling*/ const Word16 Q_out, /*synth_out scaling*/ Word16 qhf /*exc16k scaling*/ @@ -1429,13 +1429,13 @@ static Word16 EnhanceClass_fx( static void envelope_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO, - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 Aq_dyn_scal[], /* i : de-quant. LPC coefficents, dynamic scaling Q12*/ - Word16 Ap[], /* o : extended LPC coefficents, Q12*/ - Word16 *sub_gain, /* o : sub-frame gain, Q12*/ - Word16 tilt0, /* i : spectrum tilt, Q14*/ - Word16 tilt, /* i : spectrum tilt, Q13*/ - Word16 voice_factor /* i : voice factor, Q15*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 Aq_dyn_scal[], /* i : de-quant. LPC coefficents, dynamic scaling Q12*/ + Word16 Ap[], /* o : extended LPC coefficents, Q12*/ + Word16 *sub_gain, /* o : sub-frame gain, Q12*/ + Word16 tilt0, /* i : spectrum tilt, Q14*/ + Word16 tilt, /* i : spectrum tilt, Q13*/ + Word16 voice_factor /* i : voice factor, Q15*/ ) { diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index e30fb0ec2..442d0a83f 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -862,7 +862,7 @@ void ivas_hq_core_dec_fx( Copy_Scale_sig_16_32_DEPREC( wtda_audio_16, wtda_audio, 2 * L_FRAME48k, 12 ); /* q_wtda + 12 */ IF( !core_switching_flag ) { - st_fx->last_core = ACELP_CORE; /* Restore last core Q0*/ + st_fx->last_core = ACELP_CORE; /* Restore last core Q0*/ move16(); } } diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 27b352cd3..5c05d5d03 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -18,7 +18,7 @@ void ivas_hq_pred_hb_bws_fx( const Word16 *ynrm, /* i : norm quantization index vector Q0*/ const Word16 length, /* i : frame length Q0*/ const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ - const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ + const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ ) { Word16 i; @@ -71,7 +71,7 @@ void hq_pred_hb_bws_fx( const Word16 *ynrm, /* i : norm quantization index vector Q0*/ const Word16 length, /* i : frame length Q0*/ const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ - const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ + const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ ) { Word16 i; @@ -133,7 +133,7 @@ void ivas_hq_hr_dec_fx( Word16 *is_transient, /* o : transient flag Q0 */ Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ - const Word16 core_switching_flag /* i : Core switching flag Q0 */ + const Word16 core_switching_flag /* i : Core switching flag Q0 */ ) { Word16 nb_sfm; @@ -229,7 +229,7 @@ void ivas_hq_hr_dec_fx( hq_generic_exc_clas = swb_bwe_gain_deq_fx( st_fx, HQ_CORE, NULL, SWB_fenv, st_fx->core_brate >= HQ_32k, *hqswb_clas ); /* Use (st->core_brate >= HQ_32k) to be consistent with hq_configure */ IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_SP_EXC ) ) { - bits_left = add( bits_left, 1 ); /* conditional 1 bit saving for representing HQ GENERIC excitation class Q0*/ + bits_left = add( bits_left, 1 ); /* conditional 1 bit saving for representing HQ GENERIC excitation class Q0*/ } map_hq_generic_fenv_norm_fx( *hqswb_clas, SWB_fenv, ynrm, normqlg2, num_env_bands, nb_sfm, hq_generic_offset ); } @@ -399,7 +399,7 @@ void hq_hr_dec_fx( Word16 *is_transient, /* o : transient flag Q0 */ Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ - const Word16 core_switching_flag /* i : Core switching flag Q0 */ + const Word16 core_switching_flag /* i : Core switching flag Q0 */ ) { Word16 nb_sfm; @@ -492,10 +492,10 @@ void hq_hr_dec_fx( test(); IF( EQ_16( *hqswb_clas, HQ_GEN_SWB ) || EQ_16( *hqswb_clas, HQ_GEN_FB ) ) { - hq_generic_exc_clas = swb_bwe_gain_deq_fx( st_fx, HQ_CORE, NULL, SWB_fenv, st_fx->core_brate >= HQ_32k, *hqswb_clas ); /* Use (st->core_brate >= HQ_32k) to be consistent with hq_configure Q0*/ + hq_generic_exc_clas = swb_bwe_gain_deq_fx( st_fx, HQ_CORE, NULL, SWB_fenv, st_fx->core_brate >= HQ_32k, *hqswb_clas ); /* Use (st->core_brate >= HQ_32k) to be consistent with hq_configure Q0*/ if ( EQ_16( hq_generic_exc_clas, HQ_GENERIC_SP_EXC ) ) { - bits_left = add( bits_left, 1 ); /* conditional 1 bit saving for representing HQ GENERIC excitation class Q0*/ + bits_left = add( bits_left, 1 ); /* conditional 1 bit saving for representing HQ GENERIC excitation class Q0*/ } map_hq_generic_fenv_norm_fx( *hqswb_clas, SWB_fenv, ynrm, normqlg2, num_env_bands, nb_sfm, hq_generic_offset ); } diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index e8c7b365e..f2371e643 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -287,7 +287,7 @@ void hq_lr_dec_fx( exp_norm = norm_s( gqlevs_fx ); gqbits_fx = sub( 14, exp_norm ); /* Q0 */ - bit_budget_fx = sub( sub( num_bits, ebits_fx ), round_fx( L_shl( L_mult( Ngq_fx, gqbits_fx ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; Q0*/ + bit_budget_fx = sub( sub( num_bits, ebits_fx ), round_fx( L_shl( L_mult( Ngq_fx, gqbits_fx ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; Q0*/ pbits_fx = 0; @@ -583,7 +583,7 @@ void hq_lr_dec_fx( } ELSE IF( *is_transient_fx == 0 && EQ_16( inner_frame, L_FRAME16k ) ) { - bit_budget_fx = sub( bit_budget_fx, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not Q0*/ + bit_budget_fx = sub( bit_budget_fx, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not Q0*/ FOR( i = 0; i < 2; i++ ) { @@ -884,12 +884,12 @@ void hq_lr_dec_fx( } ELSE { - Copy32( L_y2_ni, L_y2, add( band_end[bands_fx - 1], 1 ) ); /* HQ_TRANSIENT Q12*/ + Copy32( L_y2_ni, L_y2, add( band_end[bands_fx - 1], 1 ) ); /* HQ_TRANSIENT Q12*/ } } ELSE { - Copy32( L_y2_ni, L_y2, add( band_end[bands_fx - 1], 1 ) ); /* NB, WB Q12*/ + Copy32( L_y2_ni, L_y2, add( band_end[bands_fx - 1], 1 ) ); /* NB, WB Q12*/ } test(); @@ -928,10 +928,10 @@ void hq_lr_dec_fx( *--------------------------------------------------------------------------------------*/ static Word16 small_symbol_dec_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure Q0*/ - Word16 *qbidx, /* o : output of dequantized differential energy Q0*/ - const Word16 bands, /* i : number of bands Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ + Decoder_State *st_fx, /* i/o: decoder state structure Q0*/ + Word16 *qbidx, /* o : output of dequantized differential energy Q0*/ + const Word16 bands, /* i : number of bands Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ ) { Word16 i, bits; @@ -1240,9 +1240,9 @@ static Word16 band_energy_dequant_fx( static Word16 p2a_threshold_dequant_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *p2a_flags, /* o : tonaly indicator Q0*/ - const Word16 bands, /* i : number of subbands Q0*/ - const Word16 p2a_bands /* i : number of subbnads for computing tonality Q0*/ + Word16 *p2a_flags, /* o : tonaly indicator Q0*/ + const Word16 bands, /* i : number of subbands Q0*/ + const Word16 p2a_bands /* i : number of subbnads for computing tonality Q0*/ ) { Word16 j, k; diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index 1ab1efe8f..2359ae974 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -13,7 +13,7 @@ /* PURPOSE : Decode the algebraic innovation and do pitch sharpening */ /* */ /*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word32) core_brate : Core bitrate Q0 */ /* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */ /* _ (Word16) L_frame : length of the frame Q0 */ @@ -198,7 +198,7 @@ void inov_decode_fx( /* PURPOSE : Decode the algebraic innovation and do pitch sharpening */ /* */ /*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word32) core_brate : Core bitrate Q0 */ /* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */ /* _ (Word16) L_frame : length of the frame Q0 */ diff --git a/lib_dec/ivas_rom_dec_fx.c b/lib_dec/ivas_rom_dec_fx.c index ae0ccf31c..016335004 100644 --- a/lib_dec/ivas_rom_dec_fx.c +++ b/lib_dec/ivas_rom_dec_fx.c @@ -85,10 +85,10 @@ const Word16 dft_alpha_s2_b2_fx[STEREO_DFT_BAND_MAX] = }; const Word32 dft_bpf_weights_fx[] = { - 1073784832, 1068033792, 1050938752, 1022962432, 984855360, 937628928, 882514816, 820918592, 754369152, - 684457792, 612788736, 540921088, 470318240, 402303136, 338025728, 278428768, 224238096, 175948704, 133830104, - 97937064, 68129992, 44097504, 25391846, 11456825, 1667521, 4637491, 8128225, 9447854, 9195525, 7903813, - 6026913, 3934190, 1908039, 148176, 1226213, 2159294, 2654289, 2754147, 2529735, 2071248 + 1073784832, 1068033792, 1050938752, 1022962432, 984855360, 937628928, 882514816, 820918592, 754369152, + 684457792, 612788736, 540921088, 470318240, 402303136, 338025728, 278428768, 224238096, 175948704, 133830104, + 97937064, 68129992, 44097504, 25391846, 11456825, 1667521, 4637491, 8128225, 9447854, 9195525, 7903813, + 6026913, 3934190, 1908039, 148176, 1226213, 2159294, 2654289, 2754147, 2529735, 2071248 }; const Word32 dft_ap_gains_fx[5][3] = @@ -119,76 +119,76 @@ const Word16 dft_res_pred_weights_fx[][STEREO_DFT_BAND_MAX] = const Word16 dft_win232ms_8k_fx[75] = { - 343, 1029, 1714, 2399, 3083, 3766, 4447, 5126, 5802, 6476, 7148, 7816, 8480, 9141, 9798, 10451, 11099, 11742, 12381, 13013, 13640, 14261, 14876, 15484, 16085, 16680, 17267, - 17846, 18418, 18981, 19537, 20083, 20621, 21150, 21669, 22179, 22680, 23170, 23650, 24120, 24579, 25028, 25465, 25891, 26306, 26710, 27101, 27481, 27849, 28204, 28547, 28878, - 29196, 29501, 29793, 30072, 30338, 30591, 30830, 31056, 31268, 31466, 31651, 31822, 31978, 32121, 32250, 32364, 32464, 32550, 32622, 32680, 32723, 32751, 32766 + 343, 1029, 1714, 2399, 3083, 3766, 4447, 5126, 5802, 6476, 7148, 7816, 8480, 9141, 9798, 10451, 11099, 11742, 12381, 13013, 13640, 14261, 14876, 15484, 16085, 16680, 17267, + 17846, 18418, 18981, 19537, 20083, 20621, 21150, 21669, 22179, 22680, 23170, 23650, 24120, 24579, 25028, 25465, 25891, 26306, 26710, 27101, 27481, 27849, 28204, 28547, 28878, + 29196, 29501, 29793, 30072, 30338, 30591, 30830, 31056, 31268, 31466, 31651, 31822, 31978, 32121, 32250, 32364, 32464, 32550, 32622, 32680, 32723, 32751, 32766 }; const Word16 dft_win232ms_12k8_fx[120] = { - 214, 643, 1072, 1500, 1929, 2357, 2784, 3211, 3638, 4064, 4489, 4914, 5337, 5760, 6182, 6602, 7022, 7440, 7857, 8273, 8687, 9100, 9512, 9921, 10329, 10735, 11140, - 11542, 11942, 12341, 12737, 13131, 13523, 13913, 14300, 14684, 15067, 15446, 15823, 16197, 16569, 16938, 17303, 17666, 18026, 18382, 18736, 19086, 19433, 19777, - 20117, 20454, 20787, 21117, 21443, 21766, 22084, 22399, 22711, 23018, 23321, 23620, 23916, 24207, 24494, 24777, 25055, 25330, 25599, 25865, 26126, 26383, 26635, - 26882, 27125, 27364, 27597, 27826, 28050, 28270, 28484, 28694, 28898, 29098, 29293, 29482, 29667, 29847, 30021, 30190, 30355, 30514, 30667, 30816, 30959, 31097, - 31229, 31357, 31478, 31595, 31706, 31811, 31912, 32006, 32095, 32179, 32257, 32330, 32397, 32458, 32514, 32565, 32610, 32649, 32683, 32711, 32733, 32750, 32761, 32767 + 214, 643, 1072, 1500, 1929, 2357, 2784, 3211, 3638, 4064, 4489, 4914, 5337, 5760, 6182, 6602, 7022, 7440, 7857, 8273, 8687, 9100, 9512, 9921, 10329, 10735, 11140, + 11542, 11942, 12341, 12737, 13131, 13523, 13913, 14300, 14684, 15067, 15446, 15823, 16197, 16569, 16938, 17303, 17666, 18026, 18382, 18736, 19086, 19433, 19777, + 20117, 20454, 20787, 21117, 21443, 21766, 22084, 22399, 22711, 23018, 23321, 23620, 23916, 24207, 24494, 24777, 25055, 25330, 25599, 25865, 26126, 26383, 26635, + 26882, 27125, 27364, 27597, 27826, 28050, 28270, 28484, 28694, 28898, 29098, 29293, 29482, 29667, 29847, 30021, 30190, 30355, 30514, 30667, 30816, 30959, 31097, + 31229, 31357, 31478, 31595, 31706, 31811, 31912, 32006, 32095, 32179, 32257, 32330, 32397, 32458, 32514, 32565, 32610, 32649, 32683, 32711, 32733, 32750, 32761, 32767 }; const Word16 dft_win232ms_16k_fx[150] = { - 171, 514, 857, 1200, 1543, 1886, 2228, 2570, 2912, 3254, 3595, 3936, 4277, 4617, 4956, 5295, 5633, 5971, 6308, 6644, 6980, 7315, 7649, 7982, 8315, 8646, 8977, 9306, - 9635, 9962, 10288, 10614, 10938, 11261, 11582, 11903, 12222, 12539, 12856, 13171, 13484, 13796, 14106, 14415, 14723, 15029, 15333, 15635, 15936, 16235, 16532, 16827, - 17121, 17412, 17702, 17990, 18276, 18559, 18841, 19121, 19399, 19674, 19947, 20219, 20487, 20754, 21019, 21281, 21540, 21798, 22053, 22305, 22556, 22803, 23048, 23291, - 23531, 23769, 24003, 24236, 24465, 24692, 24916, 25138, 25357, 25573, 25786, 25996, 26204, 26408, 26610, 26809, 27004, 27197, 27387, 27574, 27758, 27939, 28117, 28291, - 28463, 28631, 28797, 28959, 29118, 29273, 29426, 29575, 29722, 29864, 30004, 30140, 30273, 30403, 30529, 30652, 30772, 30888, 31001, 31110, 31216, 31319, 31418, 31514, - 31606, 31695, 31780, 31862, 31940, 32015, 32087, 32155, 32219, 32280, 32337, 32390, 32441, 32487, 32530, 32570, 32605, 32638, 32666, 32692, 32713, 32731, 32745, 32756, - 32763, 32767 + 171, 514, 857, 1200, 1543, 1886, 2228, 2570, 2912, 3254, 3595, 3936, 4277, 4617, 4956, 5295, 5633, 5971, 6308, 6644, 6980, 7315, 7649, 7982, 8315, 8646, 8977, 9306, + 9635, 9962, 10288, 10614, 10938, 11261, 11582, 11903, 12222, 12539, 12856, 13171, 13484, 13796, 14106, 14415, 14723, 15029, 15333, 15635, 15936, 16235, 16532, 16827, + 17121, 17412, 17702, 17990, 18276, 18559, 18841, 19121, 19399, 19674, 19947, 20219, 20487, 20754, 21019, 21281, 21540, 21798, 22053, 22305, 22556, 22803, 23048, 23291, + 23531, 23769, 24003, 24236, 24465, 24692, 24916, 25138, 25357, 25573, 25786, 25996, 26204, 26408, 26610, 26809, 27004, 27197, 27387, 27574, 27758, 27939, 28117, 28291, + 28463, 28631, 28797, 28959, 29118, 29273, 29426, 29575, 29722, 29864, 30004, 30140, 30273, 30403, 30529, 30652, 30772, 30888, 31001, 31110, 31216, 31319, 31418, 31514, + 31606, 31695, 31780, 31862, 31940, 32015, 32087, 32155, 32219, 32280, 32337, 32390, 32441, 32487, 32530, 32570, 32605, 32638, 32666, 32692, 32713, 32731, 32745, 32756, + 32763, 32767 }; const Word16 dft_win232ms_32k_fx[300] = { - 85, 257, 428, 600, 772, 943, 1115, 1286, 1457, 1629, 1800, 1971, 2143, 2314, 2485, 2656, 2827, 2998, 3169, 3339, 3510, 3681, 3851, 4021, 4192, 4362, 4532, 4701, 4871, - 5041, 5210, 5380, 5549, 5718, 5887, 6055, 6224, 6392, 6560, 6728, 6896, 7064, 7231, 7399, 7566, 7732, 7899, 8065, 8232, 8398, 8563, 8729, 8894, 9059, 9224, 9388, 9553, - 9717, 9880, 10044, 10207, 10370, 10532, 10695, 10857, 11019, 11180, 11341, 11502, 11662, 11823, 11982, 12142, 12301, 12460, 12618, 12777, 12934, 13092, 13249, 13406, - 13562, 13718, 13874, 14029, 14184, 14338, 14492, 14646, 14799, 14952, 15105, 15257, 15408, 15560, 15710, 15861, 16011, 16160, 16309, 16458, 16606, 16754, 16901, 17048, - 17194, 17340, 17485, 17630, 17774, 17918, 18062, 18204, 18347, 18489, 18630, 18771, 18911, 19051, 19191, 19329, 19468, 19605, 19743, 19879, 20015, 20151, 20286, 20420, - 20554, 20688, 20820, 20953, 21084, 21215, 21346, 21476, 21605, 21734, 21862, 21989, 22116, 22242, 22368, 22493, 22618, 22741, 22865, 22987, 23109, 23231, 23351, 23471, - 23591, 23709, 23828, 23945, 24062, 24178, 24293, 24408, 24522, 24636, 24749, 24861, 24972, 25083, 25193, 25302, 25411, 25519, 25626, 25733, 25839, 25944, 26048, 26152, - 26255, 26357, 26459, 26560, 26660, 26759, 26858, 26956, 27053, 27149, 27245, 27340, 27434, 27528, 27620, 27712, 27803, 27894, 27984, 28072, 28161, 28248, 28334, 28420, - 28505, 28589, 28673, 28756, 28837, 28918, 28999, 29078, 29157, 29235, 29312, 29388, 29464, 29538, 29612, 29685, 29758, 29829, 29900, 29969, 30038, 30106, 30174, 30240, - 30306, 30371, 30435, 30498, 30560, 30622, 30682, 30742, 30801, 30859, 30917, 30973, 31029, 31083, 31137, 31190, 31242, 31294, 31344, 31394, 31442, 31490, 31537, 31583, - 31629, 31673, 31717, 31759, 31801, 31842, 31882, 31921, 31960, 31997, 32033, 32069, 32104, 32138, 32171, 32203, 32234, 32265, 32294, 32323, 32351, 32377, 32403, 32428, - 32453, 32476, 32498, 32520, 32540, 32560, 32579, 32597, 32614, 32630, 32645, 32660, 32673, 32686, 32697, 32708, 32718, 32727, 32735, 32742, 32749, 32754, 32758, 32762, - 32765, 32766, 32767 + 85, 257, 428, 600, 772, 943, 1115, 1286, 1457, 1629, 1800, 1971, 2143, 2314, 2485, 2656, 2827, 2998, 3169, 3339, 3510, 3681, 3851, 4021, 4192, 4362, 4532, 4701, 4871, + 5041, 5210, 5380, 5549, 5718, 5887, 6055, 6224, 6392, 6560, 6728, 6896, 7064, 7231, 7399, 7566, 7732, 7899, 8065, 8232, 8398, 8563, 8729, 8894, 9059, 9224, 9388, 9553, + 9717, 9880, 10044, 10207, 10370, 10532, 10695, 10857, 11019, 11180, 11341, 11502, 11662, 11823, 11982, 12142, 12301, 12460, 12618, 12777, 12934, 13092, 13249, 13406, + 13562, 13718, 13874, 14029, 14184, 14338, 14492, 14646, 14799, 14952, 15105, 15257, 15408, 15560, 15710, 15861, 16011, 16160, 16309, 16458, 16606, 16754, 16901, 17048, + 17194, 17340, 17485, 17630, 17774, 17918, 18062, 18204, 18347, 18489, 18630, 18771, 18911, 19051, 19191, 19329, 19468, 19605, 19743, 19879, 20015, 20151, 20286, 20420, + 20554, 20688, 20820, 20953, 21084, 21215, 21346, 21476, 21605, 21734, 21862, 21989, 22116, 22242, 22368, 22493, 22618, 22741, 22865, 22987, 23109, 23231, 23351, 23471, + 23591, 23709, 23828, 23945, 24062, 24178, 24293, 24408, 24522, 24636, 24749, 24861, 24972, 25083, 25193, 25302, 25411, 25519, 25626, 25733, 25839, 25944, 26048, 26152, + 26255, 26357, 26459, 26560, 26660, 26759, 26858, 26956, 27053, 27149, 27245, 27340, 27434, 27528, 27620, 27712, 27803, 27894, 27984, 28072, 28161, 28248, 28334, 28420, + 28505, 28589, 28673, 28756, 28837, 28918, 28999, 29078, 29157, 29235, 29312, 29388, 29464, 29538, 29612, 29685, 29758, 29829, 29900, 29969, 30038, 30106, 30174, 30240, + 30306, 30371, 30435, 30498, 30560, 30622, 30682, 30742, 30801, 30859, 30917, 30973, 31029, 31083, 31137, 31190, 31242, 31294, 31344, 31394, 31442, 31490, 31537, 31583, + 31629, 31673, 31717, 31759, 31801, 31842, 31882, 31921, 31960, 31997, 32033, 32069, 32104, 32138, 32171, 32203, 32234, 32265, 32294, 32323, 32351, 32377, 32403, 32428, + 32453, 32476, 32498, 32520, 32540, 32560, 32579, 32597, 32614, 32630, 32645, 32660, 32673, 32686, 32697, 32708, 32718, 32727, 32735, 32742, 32749, 32754, 32758, 32762, + 32765, 32766, 32767 }; const Word16 dft_win232ms_48k_fx[450] = { - 57, 171, 285, 400, 514, 629, 743, 857, 972, 1086, 1200, 1315, 1429, 1543, 1657, 1772, 1886, 2000, 2114, 2228, 2342, 2456, 2570, 2684, 2798, 2912, 3026, 3140, 3254, 3368, - 3482, 3595, 3709, 3823, 3936, 4050, 4163, 4277, 4390, 4503, 4617, 4730, 4843, 4956, 5069, 5182, 5295, 5408, 5521, 5633, 5746, 5858, 5971, 6083, 6196, 6308, 6420, 6532, - 6644, 6756, 6868, 6980, 7092, 7203, 7315, 7426, 7538, 7649, 7760, 7871, 7982, 8093, 8204, 8315, 8425, 8536, 8646, 8756, 8867, 8977, 9087, 9196, 9306, 9416, 9525, 9635, - 9744, 9853, 9962, 10071, 10180, 10288, 10397, 10505, 10614, 10722, 10830, 10938, 11045, 11153, 11261, 11368, 11475, 11582, 11689, 11796, 11903, 12009, 12115, 12222, 12328, - 12434, 12539, 12645, 12750, 12856, 12961, 13066, 13171, 13275, 13380, 13484, 13588, 13692, 13796, 13900, 14003, 14106, 14210, 14313, 14415, 14518, 14621, 14723, 14825, - 14927, 15029, 15130, 15231, 15333, 15434, 15534, 15635, 15735, 15836, 15936, 16036, 16135, 16235, 16334, 16433, 16532, 16631, 16729, 16827, 16925, 17023, 17121, 17218, - 17315, 17412, 17509, 17606, 17702, 17798, 17894, 17990, 18085, 18181, 18276, 18371, 18465, 18559, 18654, 18748, 18841, 18935, 19028, 19121, 19214, 19306, 19399, 19491, - 19582, 19674, 19765, 19857, 19947, 20038, 20128, 20219, 20308, 20398, 20487, 20577, 20665, 20754, 20843, 20931, 21019, 21106, 21194, 21281, 21367, 21454, 21540, 21626, - 21712, 21798, 21883, 21968, 22053, 22137, 22221, 22305, 22389, 22472, 22556, 22638, 22721, 22803, 22885, 22967, 23048, 23130, 23210, 23291, 23371, 23451, 23531, 23611, - 23690, 23769, 23847, 23925, 24003, 24081, 24159, 24236, 24313, 24389, 24465, 24541, 24617, 24692, 24767, 24842, 24916, 24991, 25064, 25138, 25211, 25284, 25357, 25429, - 25501, 25573, 25644, 25715, 25786, 25856, 25926, 25996, 26066, 26135, 26204, 26272, 26340, 26408, 26476, 26543, 26610, 26676, 26743, 26809, 26874, 26940, 27004, 27069, - 27133, 27197, 27261, 27324, 27387, 27450, 27512, 27574, 27636, 27697, 27758, 27819, 27879, 27939, 27998, 28058, 28117, 28175, 28233, 28291, 28349, 28406, 28463, 28519, - 28575, 28631, 28687, 28742, 28797, 28851, 28905, 28959, 29012, 29065, 29118, 29170, 29222, 29273, 29325, 29376, 29426, 29476, 29526, 29575, 29624, 29673, 29722, 29769, - 29817, 29864, 29911, 29958, 30004, 30050, 30095, 30140, 30185, 30229, 30273, 30317, 30360, 30403, 30445, 30487, 30529, 30571, 30612, 30652, 30692, 30732, 30772, 30811, - 30850, 30888, 30926, 30964, 31001, 31038, 31074, 31110, 31146, 31181, 31216, 31251, 31285, 31319, 31352, 31385, 31418, 31450, 31482, 31514, 31545, 31576, 31606, 31636, - 31666, 31695, 31724, 31752, 31780, 31808, 31835, 31862, 31889, 31915, 31940, 31966, 31991, 32015, 32040, 32063, 32087, 32110, 32132, 32155, 32176, 32198, 32219, 32239, - 32260, 32280, 32299, 32318, 32337, 32355, 32373, 32390, 32408, 32424, 32441, 32457, 32472, 32487, 32502, 32516, 32530, 32544, 32557, 32570, 32582, 32594, 32605, 32617, - 32627, 32638, 32648, 32657, 32666, 32675, 32684, 32692, 32699, 32706, 32713, 32720, 32726, 32731, 32736, 32741, 32745, 32749, 32753, 32756, 32759, 32761, 32763, 32765, - 32766, 32767, 32767 + 57, 171, 285, 400, 514, 629, 743, 857, 972, 1086, 1200, 1315, 1429, 1543, 1657, 1772, 1886, 2000, 2114, 2228, 2342, 2456, 2570, 2684, 2798, 2912, 3026, 3140, 3254, 3368, + 3482, 3595, 3709, 3823, 3936, 4050, 4163, 4277, 4390, 4503, 4617, 4730, 4843, 4956, 5069, 5182, 5295, 5408, 5521, 5633, 5746, 5858, 5971, 6083, 6196, 6308, 6420, 6532, + 6644, 6756, 6868, 6980, 7092, 7203, 7315, 7426, 7538, 7649, 7760, 7871, 7982, 8093, 8204, 8315, 8425, 8536, 8646, 8756, 8867, 8977, 9087, 9196, 9306, 9416, 9525, 9635, + 9744, 9853, 9962, 10071, 10180, 10288, 10397, 10505, 10614, 10722, 10830, 10938, 11045, 11153, 11261, 11368, 11475, 11582, 11689, 11796, 11903, 12009, 12115, 12222, 12328, + 12434, 12539, 12645, 12750, 12856, 12961, 13066, 13171, 13275, 13380, 13484, 13588, 13692, 13796, 13900, 14003, 14106, 14210, 14313, 14415, 14518, 14621, 14723, 14825, + 14927, 15029, 15130, 15231, 15333, 15434, 15534, 15635, 15735, 15836, 15936, 16036, 16135, 16235, 16334, 16433, 16532, 16631, 16729, 16827, 16925, 17023, 17121, 17218, + 17315, 17412, 17509, 17606, 17702, 17798, 17894, 17990, 18085, 18181, 18276, 18371, 18465, 18559, 18654, 18748, 18841, 18935, 19028, 19121, 19214, 19306, 19399, 19491, + 19582, 19674, 19765, 19857, 19947, 20038, 20128, 20219, 20308, 20398, 20487, 20577, 20665, 20754, 20843, 20931, 21019, 21106, 21194, 21281, 21367, 21454, 21540, 21626, + 21712, 21798, 21883, 21968, 22053, 22137, 22221, 22305, 22389, 22472, 22556, 22638, 22721, 22803, 22885, 22967, 23048, 23130, 23210, 23291, 23371, 23451, 23531, 23611, + 23690, 23769, 23847, 23925, 24003, 24081, 24159, 24236, 24313, 24389, 24465, 24541, 24617, 24692, 24767, 24842, 24916, 24991, 25064, 25138, 25211, 25284, 25357, 25429, + 25501, 25573, 25644, 25715, 25786, 25856, 25926, 25996, 26066, 26135, 26204, 26272, 26340, 26408, 26476, 26543, 26610, 26676, 26743, 26809, 26874, 26940, 27004, 27069, + 27133, 27197, 27261, 27324, 27387, 27450, 27512, 27574, 27636, 27697, 27758, 27819, 27879, 27939, 27998, 28058, 28117, 28175, 28233, 28291, 28349, 28406, 28463, 28519, + 28575, 28631, 28687, 28742, 28797, 28851, 28905, 28959, 29012, 29065, 29118, 29170, 29222, 29273, 29325, 29376, 29426, 29476, 29526, 29575, 29624, 29673, 29722, 29769, + 29817, 29864, 29911, 29958, 30004, 30050, 30095, 30140, 30185, 30229, 30273, 30317, 30360, 30403, 30445, 30487, 30529, 30571, 30612, 30652, 30692, 30732, 30772, 30811, + 30850, 30888, 30926, 30964, 31001, 31038, 31074, 31110, 31146, 31181, 31216, 31251, 31285, 31319, 31352, 31385, 31418, 31450, 31482, 31514, 31545, 31576, 31606, 31636, + 31666, 31695, 31724, 31752, 31780, 31808, 31835, 31862, 31889, 31915, 31940, 31966, 31991, 32015, 32040, 32063, 32087, 32110, 32132, 32155, 32176, 32198, 32219, 32239, + 32260, 32280, 32299, 32318, 32337, 32355, 32373, 32390, 32408, 32424, 32441, 32457, 32472, 32487, 32502, 32516, 32530, 32544, 32557, 32570, 32582, 32594, 32605, 32617, + 32627, 32638, 32648, 32657, 32666, 32675, 32684, 32692, 32699, 32706, 32713, 32720, 32726, 32731, 32736, 32741, 32745, 32749, 32753, 32756, 32759, 32761, 32763, 32765, + 32766, 32767, 32767 }; const Word16 dft_win_8k_fx[70] = { - 367, 1102, 1837, 2570, 3303, 4033, 4762, 5488, 6212, 6932, 7649, 8362, 9071, 9775, 10474, 11168, 11857, 12539, 13215, 13885, 14547, 15203, 15850, 16490, 17121, 17743, - 18357, 18961, 19556, 20141, 20716, 21281, 21834, 22377, 22909, 23428, 23937, 24433, 24916, 25388, 25846, 26292, 26724, 27143, 27548, 27939, 28316, 28679, 29027, 29361, - 29680, 29984, 30273, 30547, 30805, 31048, 31275, 31487, 31682, 31862, 32026, 32173, 32305, 32420, 32518, 32601, 32666, 32716, 32749, 32765 + 367, 1102, 1837, 2570, 3303, 4033, 4762, 5488, 6212, 6932, 7649, 8362, 9071, 9775, 10474, 11168, 11857, 12539, 13215, 13885, 14547, 15203, 15850, 16490, 17121, 17743, + 18357, 18961, 19556, 20141, 20716, 21281, 21834, 22377, 22909, 23428, 23937, 24433, 24916, 25388, 25846, 26292, 26724, 27143, 27548, 27939, 28316, 28679, 29027, 29361, + 29680, 29984, 30273, 30547, 30805, 31048, 31275, 31487, 31682, 31862, 32026, 32173, 32305, 32420, 32518, 32601, 32666, 32716, 32749, 32765 }; diff --git a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c index 2bade4786..57166fae4 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c @@ -46,9 +46,9 @@ /*! r: number of bits read */ static Word16 read_GR2( - const UWord16 *bit_stream, /* i : bitstream to be read Q0*/ - Word16 *ind, /* o : parameters read Q0*/ - const Word16 len /* i : number of params to be read Q0*/ + const UWord16 *bit_stream, /* i : bitstream to be read Q0*/ + Word16 *ind, /* o : parameters read Q0*/ + const Word16 len /* i : number of params to be read Q0*/ ) { Word16 i; @@ -103,9 +103,9 @@ static Word16 read_GR2( /*! r: number of bits read */ static Word16 read_GR1( - const UWord16 *bit_stream, /* i : bitstream to be read Q0*/ - Word16 *ind, /* o : parameters read Q0*/ - const Word16 len /* i : number of params to be read Q0*/ + const UWord16 *bit_stream, /* i : bitstream to be read Q0*/ + Word16 *ind, /* o : parameters read Q0*/ + const Word16 len /* i : number of params to be read Q0*/ ) { Word16 i; @@ -159,9 +159,9 @@ static Word16 read_GR1( /*! r: number of bits read */ Word16 read_GR0( - const UWord16 *bit_stream, /* i : bitstream to be read Q0*/ - Word16 *ind, /* o : parameters read Q0*/ - const Word16 len /* i : number of params to be read Q0*/ + const UWord16 *bit_stream, /* i : bitstream to be read Q0*/ + Word16 *ind, /* o : parameters read Q0*/ + const Word16 len /* i : number of params to be read Q0*/ ) { Word16 i; @@ -240,11 +240,11 @@ static ivas_error find_map( *---------------------------------------------------------------------*/ static void decode_adapt_GR_indices1( - const Word16 *ind, /* i : array of input encoded symbols Q0*/ - const Word16 len, /* i : number of parameters to decode Q0*/ - const Word16 no_symb, /* i : number of possible symbols in GR coding Q0*/ - Word16 *out, /* o : array of decoded parameters Q0*/ - const Word16 *map0 /* i : initial mapping array for the adaptive GR Q0*/ + const Word16 *ind, /* i : array of input encoded symbols Q0*/ + const Word16 len, /* i : number of parameters to decode Q0*/ + const Word16 no_symb, /* i : number of possible symbols in GR coding Q0*/ + Word16 *out, /* o : array of decoded parameters Q0*/ + const Word16 *map0 /* i : initial mapping array for the adaptive GR Q0*/ ) { const Word16 *map; @@ -279,8 +279,8 @@ static void decode_adapt_GR_indices1( /*! r: read value */ Word16 get_value( - const UWord16 *bit_stream, /* i : bitstream Q0*/ - const Word16 nbits /* i : number of bits to be read Q0*/ + const UWord16 *bit_stream, /* i : bitstream Q0*/ + const Word16 nbits /* i : number of bits to be read Q0*/ ) { Word16 i; @@ -358,12 +358,12 @@ Word16 read_BS_GR( /*! r: number of bits read */ Word16 read_BS_adapt_GR_sg( - const UWord16 *bit_stream, /* i : bitstream to be read Q0*/ - const Word16 nb, /* i : starting position in bitstream Q0*/ - Word16 *ind1, /* o : decoded side gain values Q0*/ - const Word16 len, /* i : number of params to be read Q0*/ - Word16 *GR_ord, /* o : GR order used (read from bitstream) Q0*/ - const Word16 *map0 /* i : initial map Q0*/ + const UWord16 *bit_stream, /* i : bitstream to be read Q0*/ + const Word16 nb, /* i : starting position in bitstream Q0*/ + Word16 *ind1, /* o : decoded side gain values Q0*/ + const Word16 len, /* i : number of params to be read Q0*/ + Word16 *GR_ord, /* o : GR order used (read from bitstream) Q0*/ + const Word16 *map0 /* i : initial map Q0*/ ) { Word16 b, ind1_tmp[STEREO_DFT_BAND_MAX], ord; diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 1f0cff110..124f89c5a 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -76,15 +76,15 @@ static void stereo_dft_generate_comfort_noise_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT Stereo decoder handle */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - Decoder_State *st, /* i/o: Core coder decoder state */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ + const Word16 last_element_mode, /* i : last element mode Q0*/ + Decoder_State *st, /* i/o: Core coder decoder state */ Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers q_dft*/ - Decoder_State *st1, /* i/o: Core coder decoder state secondary channel */ - const Word16 targetGain, /* i : ICA target gain Q13*/ - const Word16 chan, /* i : channel number Q0*/ - const Word16 output_frame, /* i : output frame size Q0*/ - Word16 q_dft /* i : Q of DFT */ + Decoder_State *st1, /* i/o: Core coder decoder state secondary channel */ + const Word16 targetGain, /* i : ICA target gain Q13*/ + const Word16 chan, /* i : channel number Q0*/ + const Word16 output_frame, /* i : output frame size Q0*/ + Word16 q_dft /* i : Q of DFT */ ) { Word16 i, j, k; @@ -870,11 +870,11 @@ static void stereo_dft_generate_comfort_noise_fx( * DFT stereo CNG *-------------------------------------------------------------------*/ void stereo_dtf_cng_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ - Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers q_dft*/ - const Word16 output_frame, /* i : output frame size Q0*/ - Word16 q_dft /* i : Q factor of the DFT data */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers q_dft*/ + const Word16 output_frame, /* i : output frame size Q0*/ + Word16 q_dft /* i : Q factor of the DFT data */ ) { Decoder_State **sts; @@ -918,7 +918,7 @@ void stereo_dtf_cng_fx( void stereo_cng_dec_update( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ ) { IF( GT_32( hCPE->hCoreCoder[0]->core_brate, SID_2k40 ) ) @@ -982,8 +982,8 @@ void stereo_cng_compute_PScorr_fx( Word16 *output_Q, Word32 *c_PS_LT_fx, Word16 Q_c_PS_LT_fx, - const Word16 L_frame_0, /* i : L_frame channel 0 Q0*/ - const Word16 L_frame_1 /* i : L_frame channel 1 Q0*/ + const Word16 L_frame_0, /* i : L_frame channel 0 Q0*/ + const Word16 L_frame_1 /* i : L_frame channel 1 Q0*/ ) { Word16 i; @@ -1105,7 +1105,7 @@ void stereo_cng_compute_PScorr_fx( *-------------------------------------------------------------------*/ static void stereo_cng_compute_LRcorr_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ Word32 *output_fx[CPE_CHANNELS], /* i : Output signal OUTPUT_Q*/ const Word16 output_frame, /* i : Output frame length Q0*/ const Word16 tdm_ratio_idx /* i : TDM ratio index Q0*/ @@ -1309,8 +1309,8 @@ static void stereo_cng_compute_LRcorr_fx( static void FindEmEs_fx( const Word32 *ch1_fx, /* i : Left channel OUTPUT_Q*/ const Word32 *ch2_fx, /* i : right channel OUTPUT_Q*/ - const Word16 len, /* i : length Q0*/ - Word32 *lt_es_em_fx /* i/o: LT energy ratio Q24*/ + const Word16 len, /* i : length Q0*/ + Word32 *lt_es_em_fx /* i/o: LT energy ratio Q24*/ ) { Word16 i; @@ -1385,10 +1385,10 @@ static void FindEmEs_fx( *-------------------------------------------------------------------*/ void stereo_cna_update_params_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *output_fx[CPE_CHANNELS], /* i : Output signal OUTPUT_Q*/ - const Word16 output_frame, /* i : Output frame length Q0*/ - const Word16 tdm_ratio_idx /* i : TDM ratio index Q0*/ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *output_fx[CPE_CHANNELS], /* i : Output signal OUTPUT_Q*/ + const Word16 output_frame, /* i : Output frame length Q0*/ + const Word16 tdm_ratio_idx /* i : TDM ratio index Q0*/ ) { Word16 i; @@ -1614,8 +1614,8 @@ void stereo_cna_update_params_fx( *-------------------------------------------------------------------*/ void stereo_cng_init_dec_fx( - STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: stereo CNG decoder structure */ - const Word16 *frameSize /* i : pointer to frameSize of channel 0 to be used for channel 1 Q0*/ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: stereo CNG decoder structure */ + const Word16 *frameSize /* i : pointer to frameSize of channel 0 to be used for channel 1 Q0*/ ) { hStereoCng->prev_sid_nodata = 0; diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 6a369a14c..9b166c41a 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -74,11 +74,11 @@ void stereo_dft_dmx_out_reset_fx( *-------------------------------------------------------------------------*/ void stereo_dft_unify_dmx_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ - Decoder_State *st0, /* i/o: decoder state structure */ - Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers hStereoDft->qDFT*/ - Word32 *input_mem, /* i/o: mem of buffer DFT analysis Q11*/ - const Word16 prev_sid_nodata /* i : Previous SID/No data indicator Q0*/ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ + Decoder_State *st0, /* i/o: decoder state structure */ + Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers hStereoDft->qDFT*/ + Word32 *input_mem, /* i/o: mem of buffer DFT analysis Q11*/ + const Word16 prev_sid_nodata /* i : Previous SID/No data indicator Q0*/ ) { Word16 i, k, b, N_div; diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 186306209..b5e19dad5 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -277,9 +277,9 @@ void stereo_dft_dec_reset_fx( *-------------------------------------------------------------------------*/ static void stereo_dft_dec_open_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 output_Fs, /* i : output sampling rate Q0*/ - const Word16 nchan_transport /* i : number of transport channels Q0*/ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + const Word32 output_Fs, /* i : output sampling rate Q0*/ + const Word16 nchan_transport /* i : number of transport channels Q0*/ ) { /*Sizes*/ @@ -370,11 +370,11 @@ static void stereo_dft_dec_open_fx( *------------------------------------------------------------------------*/ ivas_error stereo_dft_dec_create_fx( - STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 element_brate, /* i : element bitrate Q0*/ - const Word32 output_Fs, /* i : output sampling rate Q0*/ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ - const Word16 nchan_transport /* i : number of transport channels Q0*/ + STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ + const Word32 element_brate, /* i : element bitrate Q0*/ + const Word32 output_Fs, /* i : output sampling rate Q0*/ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ + const Word16 nchan_transport /* i : number of transport channels Q0*/ ) { STEREO_DFT_DEC_DATA_HANDLE hStereoDft_loc; @@ -602,9 +602,9 @@ static void stereo_dft_dequantize_res_gains_f_fx( *-------------------------------------------------------------------------*/ void stereo_dft_dec_update_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC Q0*/ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC Q0*/ ) { Word16 b, i, k_offset; @@ -734,14 +734,14 @@ void stereo_dft_dec_destroy_fx( void stereo_dft_dec_analyze_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 *input_fx, /* i : input signal q*/ - Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ - const Word16 chan, /* i : channel number Q0*/ - const Word16 input_frame, /* i : input frame size Q0*/ - const Word16 output_frame, /* i : output frame size Q0*/ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ - const Word16 k_offset, /* i : offset of DFT Q0*/ - const Word16 delay, /* i : delay in samples FOR input signal Q0*/ + const Word32 *input_fx, /* i : input signal q*/ + Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ + const Word16 chan, /* i : channel number Q0*/ + const Word16 input_frame, /* i : input frame size Q0*/ + const Word16 output_frame, /* i : output frame size Q0*/ + const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ + const Word16 k_offset, /* i : offset of DFT Q0*/ + const Word16 delay, /* i : delay in samples FOR input signal Q0*/ Word16 *q, Word16 *q_out_DFT ) { @@ -1090,11 +1090,11 @@ void stereo_dft_dec_analyze_fx( *-------------------------------------------------------------------------*/ void stereo_dft_dec_synthesize_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i : DFT buffers qDFT*/ - const Word16 chan, /* i : channel number Q0*/ - Word32 output[L_FRAME48k], /* o : output synthesis signal qDFT*/ - const Word16 output_frame /* i : output frame length Q0*/ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i : DFT buffers qDFT*/ + const Word16 chan, /* i : channel number Q0*/ + Word32 output[L_FRAME48k], /* o : output synthesis signal qDFT*/ + const Word16 output_frame /* i : output frame length Q0*/ ) { Word16 i, k; @@ -1704,10 +1704,10 @@ void stereo_dft_dec_smooth_parameters_fx( *-------------------------------------------------------------------------*/ void stereo_dft_dec_res_fx( - CPE_DEC_HANDLE hCPE, /* i/o: decoder CPE handle */ + CPE_DEC_HANDLE hCPE, /* i/o: decoder CPE handle */ Word32 res_buf[STEREO_DFT_N_8k], /* i : residual buffer q_res*/ - Word16 q_res, /* i : q fact of residural buffer */ - Word32 *output /* o : output Q16*/ + Word16 q_res, /* i : q fact of residural buffer */ + Word32 *output /* o : output Q16*/ ) { Word16 i; @@ -1797,7 +1797,7 @@ void stereo_dft_dec_res_fx( IF( prev_bfi ) { /* Ramp up BPF contribution for the first good frame */ - step = (Word16) ( 0x00CD ); // ( 1.0f / L_FRAME8k ); /* Q15 */ + step = (Word16) ( 0x00CD ); // ( 1.0f / L_FRAME8k ); /* Q15 */ move16(); fac = negate( step ); FOR( i = 0; i < L_FRAME8k; i++ ) @@ -1837,18 +1837,18 @@ void stereo_dft_dec_res_fx( *-------------------------------------------------------------------------*/ void stereo_dft_dec_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - Decoder_State *st0, /* i/o: decoder state structure */ - Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers qDFT*/ - Word32 *input_mem, /* i/o: mem of buffer DFT analysis */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure Q0*/ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ - const Word16 sba_mono_flag, /* i : signal mono output for SBA DirAC Q0*/ - ivas_spar_md_dec_state_t *hMdDec, /* i : SPAR MD handle for upmixing */ - const Word16 cross_fade_start_offset, /* i : SPAR mixer delay compensation Q0*/ - const Word32 output_Fs, /* i : Fs for delay calculation Q0*/ - const Word16 nchan_transport, /* i : number of transpor channels Q0*/ - const Word16 num_md_sub_frames /* i : number of MD subframes Q0*/ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + Decoder_State *st0, /* i/o: decoder state structure */ + Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers qDFT*/ + Word32 *input_mem, /* i/o: mem of buffer DFT analysis */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure Q0*/ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ + const Word16 sba_mono_flag, /* i : signal mono output for SBA DirAC Q0*/ + ivas_spar_md_dec_state_t *hMdDec, /* i : SPAR MD handle for upmixing */ + const Word16 cross_fade_start_offset, /* i : SPAR mixer delay compensation Q0*/ + const Word32 output_Fs, /* i : Fs for delay calculation Q0*/ + const Word16 nchan_transport, /* i : number of transpor channels Q0*/ + const Word16 num_md_sub_frames /* i : number of MD subframes Q0*/ ) { Word16 i, k, b, N_div, stop; @@ -2867,13 +2867,13 @@ static void stereo_dft_dequantize_ipd_fx( * *-------------------------------------------------------------------------*/ void stereo_dft_generate_res_pred_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ const Word16 samp_ratio, /* i : sampling ratio Q15*/ Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ Word32 *pPredGain, /* i : residual prediction gains Q31*/ - const Word16 k, /* i : subframe index Q0*/ - Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ + const Word16 k, /* i : subframe index Q0*/ + Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ Word16 *stop, /* o : last FD stereo filling bin Q0*/ const Word16 bfi /* i : BFI flag Q0*/ ) @@ -3657,9 +3657,9 @@ static void stereo_dft_adapt_sf_delay_fx( } void stereo_dft_dec_sid_coh_fx( Decoder_State *st, /* i/o: decoder state structure */ - const Word16 nbands, /* i : number of DFT stereo bands Q0*/ - Word16 *coh_fx, /* i/o: coherence Q15*/ - Word16 *nb_bits /* i/o: number of bits read Q0*/ + const Word16 nbands, /* i : number of DFT stereo bands Q0*/ + Word16 *coh_fx, /* i/o: coherence Q15*/ + Word16 *nb_bits /* i/o: number of bits read Q0*/ ) { Word16 alpha_fx; @@ -3683,10 +3683,10 @@ void stereo_dft_dec_sid_coh_fx( IF( sub( sub( nr_of_sid_stereo_bits, *nb_bits ), STEREO_DFT_N_COH_ALPHA_BITS - STEREO_DFT_PRED_NBITS ) > 0 ) { /* Read coherence from bitstream */ - coh_pred_index = get_next_indice_fx( st, STEREO_DFT_PRED_NBITS ); /* Read predictor index Q0*/ + coh_pred_index = get_next_indice_fx( st, STEREO_DFT_PRED_NBITS ); /* Read predictor index Q0*/ ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_PRED_NBITS ); - alpha_index = get_next_indice_fx( st, STEREO_DFT_N_COH_ALPHA_BITS ); /* Read alpha index Q0*/ + alpha_index = get_next_indice_fx( st, STEREO_DFT_N_COH_ALPHA_BITS ); /* Read alpha index Q0*/ ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_N_COH_ALPHA_BITS ); alpha_step = 0; @@ -3803,17 +3803,17 @@ void stereo_dft_dequantize_itd_fx( *-------------------------------------------------------------------------*/ void stereo_dft_dec_read_BS_fx( - const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ - const Word32 element_brate, /* i : element bitrate Q0*/ - Word32 *total_brate, /* o : total bitrate Q0*/ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ - const Word16 bwidth, /* i : bandwidth Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ + Word32 *total_brate, /* o : total bitrate Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ + const Word16 bwidth, /* i : bandwidth Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ Word32 res_buf_fx[STEREO_DFT_N_8k], /* o : residual buffer Q0*/ - Word16 *nb_bits, /* o : number of bits read Q0*/ + Word16 *nb_bits, /* o : number of bits read Q0*/ Word16 *coh_fx, /* i/o: Coherence Q15*/ - const Word16 ivas_format /* i : ivas format Q0*/ + const Word16 ivas_format /* i : ivas format Q0*/ ) { Word32 sg_tmp_fx[STEREO_DFT_BAND_MAX]; @@ -4078,7 +4078,7 @@ void stereo_dft_dec_read_BS_fx( IF( !hStereoDft->frame_sid_nodata ) { itd_mode = get_next_indice_fx( st, STEREO_DFT_ITD_MODE_NBITS ); /* Q0 */ - ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_ITD_MODE_NBITS ); /*ITD mode flag: 1bit Q0*/ + ( *nb_bits ) = add( ( *nb_bits ), STEREO_DFT_ITD_MODE_NBITS ); /*ITD mode flag: 1bit Q0*/ move16(); hStereoDft->itd_fx[k + k_offset] = 0; move32(); @@ -4396,7 +4396,7 @@ void stereo_dft_dec_read_BS_fx( test(); IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_16( ivas_format, MASA_FORMAT ) ) { - *nb_bits = (Word16) Mult_32_16( L_sub( element_brate, SID_2k40 ), INV_FRAME_PER_SEC_Q15 ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; Q0*/ + *nb_bits = (Word16) Mult_32_16( L_sub( element_brate, SID_2k40 ), INV_FRAME_PER_SEC_Q15 ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; Q0*/ move16(); } { diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index 607892b2a..93588a356 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -58,17 +58,17 @@ * ---------------------------------------------------------------*/ void stereo_dft_res_ecu_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ Word32 *pDFT_RES, /* i/o: residual signal hStereoDft->q_dft*/ Word32 *const DFT_PRED_RES, /* i/o: residual prediction signal hStereoDft->q_dft*/ - const Word16 k, /* i : Subframe index Q0*/ - const Word16 output_frame, /* i : Output frame length Q0*/ - const Word16 prev_bfi, /* i : Previous BFI Q0*/ - const Word32 dmx_nrg, /* i : Down-mix energy Qx*/ - Word16 *num_plocs, /* i/o: Number of peak locations Q0*/ - Word16 *plocs, /* i/o: Peak locations (bin) Q0*/ - Word32 *plocsi, /* i/o: Peak locations (fractional) Qx*/ - Word32 *input_mem /* o : Residual DFT buffer input mem Q11*/ + const Word16 k, /* i : Subframe index Q0*/ + const Word16 output_frame, /* i : Output frame length Q0*/ + const Word16 prev_bfi, /* i : Previous BFI Q0*/ + const Word32 dmx_nrg, /* i : Down-mix energy Qx*/ + Word16 *num_plocs, /* i/o: Number of peak locations Q0*/ + Word16 *plocs, /* i/o: Peak locations (bin) Q0*/ + Word32 *plocsi, /* i/o: Peak locations (fractional) Qx*/ + Word32 *input_mem /* o : Residual DFT buffer input mem Q11*/ ) { Word32 res_buf[L_FRAME8k] = { 0 }; @@ -182,7 +182,7 @@ void stereo_dft_res_ecu_fx( /*! r: interpolated maximum position */ Word32 imax_pos_fx( - const Word32 *y /* i : Input vector for peak interpolation Qx*/ + const Word32 *y /* i : Input vector for peak interpolation Qx*/ ) { Word32 posi, y1, y2, y3, y3_y1, y2i; @@ -451,7 +451,7 @@ static void ivas_peakfinder_fx( move16(); leftMin = x[ii]; /* Qx */ move32(); - peakLoc[*cInd] = tempLoc; /* Add peak to index Q0*/ + peakLoc[*cInd] = tempLoc; /* Add peak to index Q0*/ move16(); peakMag[*cInd] = tempMag; /* Q0 */ move32(); @@ -544,17 +544,17 @@ static void ivas_peakfinder_fx( * ---------------------------------------------------------------*/ void stereo_dft_res_subst_spec_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - Word32 *pDFT_RES, /* i/o: residual signal qDFT*/ - const Word32 *const DFT_PRED_RES, /* i : residual prediction signal qDFT*/ - const Word16 time_offs, /* i : Time offset for phase adjustment Q0*/ - const Word16 L_res, /* i : bandwidth of residual signal Q0*/ - const Word16 L_ana, /* i : Length of FFT analysis Q0*/ - const Word16 k, /* i : Subframe index Q0*/ - Word16 *num_plocs, /* i/o: Number of peak locations Q0*/ - Word16 *plocs, /* i/o: Peak locations (bin) Q0*/ - Word32 *plocsi, /* i/o: Peak locations (fractional) Qx*/ - const Word16 analysis_flag /* i : Flag for running peak analysis Q0*/ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ + Word32 *pDFT_RES, /* i/o: residual signal qDFT*/ + const Word32 *const DFT_PRED_RES, /* i : residual prediction signal qDFT*/ + const Word16 time_offs, /* i : Time offset for phase adjustment Q0*/ + const Word16 L_res, /* i : bandwidth of residual signal Q0*/ + const Word16 L_ana, /* i : Length of FFT analysis Q0*/ + const Word16 k, /* i : Subframe index Q0*/ + Word16 *num_plocs, /* i/o: Number of peak locations Q0*/ + Word16 *plocs, /* i/o: Peak locations (bin) Q0*/ + Word32 *plocsi, /* i/o: Peak locations (fractional) Qx*/ + const Word16 analysis_flag /* i : Flag for running peak analysis Q0*/ ) { Word16 i, idx; @@ -730,11 +730,11 @@ void stereo_dft_res_subst_spec_fx( * ---------------------------------------------------------------*/ void stereo_dft_res_ecu_burst_att_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ Word32 *pDFT_RES, /* i/o: residual signal /att. residual qDFT*/ - const Word32 dmx_nrg, /* i : dmx energy of current frame Qx*/ - const Word16 L_res, /* i : Bandwidth of residual Q0*/ - const Word16 L_ana /* i : Length of FFT analysis Q0*/ + const Word32 dmx_nrg, /* i : dmx energy of current frame Qx*/ + const Word16 L_res, /* i : Bandwidth of residual Q0*/ + const Word16 L_ana /* i : Length of FFT analysis Q0*/ ) { Word32 fac; @@ -769,9 +769,9 @@ void stereo_dft_res_ecu_burst_att_fx( /*! r: total energy of downmix with maximum swb bandwidth max */ Word32 stereo_dft_dmx_swb_nrg_fx( - const Word32 *dmx_k0, /* i : first subframe spectrum q0*/ - const Word32 *dmx_k1, /* i : second subframe spectrum q1*/ - const Word16 frame_length, /* i : frame lanegth Q0*/ + const Word32 *dmx_k0, /* i : first subframe spectrum q0*/ + const Word32 *dmx_k1, /* i : second subframe spectrum q1*/ + const Word16 frame_length, /* i : frame lanegth Q0*/ const Word16 q0, const Word16 q1 ) { diff --git a/lib_dec/ivas_stereo_eclvq_dec_fx.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c index df7158c85..9d777c9b7 100644 --- a/lib_dec/ivas_stereo_eclvq_dec_fx.c +++ b/lib_dec/ivas_stereo_eclvq_dec_fx.c @@ -209,7 +209,7 @@ void ECSQ_decode_fx( } ELSE { - count0 = left0 * ECSQ_tab_inverse[left0 + left1]; /* left0 * round(ECSQ_PROB_TOTAL / (left0 + left1)) Q0*/ + count0 = left0 * ECSQ_tab_inverse[left0 + left1]; /* left0 * round(ECSQ_PROB_TOTAL / (left0 + left1)) Q0*/ sym = rc_uni_dec_read_bit_prob_fast( rc_st_dec, count0, ECSQ_PROB_BITS ); /* Q0 */ } diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index 73cf9ccd0..96458c4f2 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -53,7 +53,7 @@ * ---------------------------------------------------------------*/ void stereo_tca_dec_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word32 *synth_fx[CPE_CHANNELS], /* i/o: output synth qsynth*/ const Word16 output_frame /* i : length of a frame per channel Q0*/ ) @@ -314,9 +314,9 @@ void stereo_tca_dec_fx( #define MAX_TARGET_GAIN_Q29 1904890240 void stereo_tca_scale_R_channel_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *output_fx, /* i/o: output synthesis, R channel q_out*/ - const Word16 output_frame /* i : frame length Q0*/ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *output_fx, /* i/o: output synthesis, R channel q_out*/ + const Word16 output_frame /* i : frame length Q0*/ ) { STEREO_TCA_DEC_HANDLE hStereoTCA; diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index d5b289acf..647ad6e77 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -115,14 +115,14 @@ static Word16 FindScale( void stereo_icBWE_dec_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *synthRef_fx, /* i/o: Reference channel HB synthesis at output Fs Q11 */ - Word32 *synth_fx, /* o : Non reference channel HB synthesis at output Fs Q11 */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *synthRef_fx, /* i/o: Reference channel HB synthesis at output Fs Q11 */ + Word32 *synth_fx, /* o : Non reference channel HB synthesis at output Fs Q11 */ const Word16 *fb_synth_ref_fx, /* i : ref. high-band synthesis 16-20 kHz Q_white_exc*/ - const Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 output_frame, /* i : frame length Q0 */ - Word16 *Q_syn, /* i : Q of synth and synthRef buffers */ - const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ + const Word16 *voice_factors_fx, /* i : voicing factors Q15 */ + const Word16 output_frame, /* i : frame length Q0 */ + Word16 *Q_syn, /* i : Q of synth and synthRef buffers */ + const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ ) { Word16 i, j, k, nbSubFr; @@ -314,7 +314,7 @@ void stereo_icBWE_dec_fx( icbweM2Ref_fx = extract_h( L_add( ONE_IN_Q30, temp ) ); // Q14 gsMapping_fx = extract_h( L_sub( ONE_IN_Q30, temp ) ); // Q14 - winLen_fx = extract_l( Mpy_32_16_1( st->output_Fs, 41 ) ); //(int16_t)((SHB_OVERLAP_LEN * st->output_Fs) / 16000); Q0 + winLen_fx = extract_l( Mpy_32_16_1( st->output_Fs, 41 ) ); //(int16_t)((SHB_OVERLAP_LEN * st->output_Fs) / 16000); Q0 winSlope_fx = div_s( 1, winLen_fx ); /* Q15 */ alpha_fx = winSlope_fx; /* Q15 */ move16(); @@ -935,10 +935,10 @@ void stereo_icBWE_dec_fx( *-------------------------------------------------------------------*/ void stereo_icBWE_decproc_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word32 *output[CPE_CHANNELS], /* i/o: output synthesis Q11*/ Word32 outputHB[CPE_CHANNELS][L_FRAME48k], /* i : HB synthesis Q11*/ - const Word16 last_core, /* i : last core, primary channel Q0*/ + const Word16 last_core, /* i : last core, primary channel Q0*/ const Word16 last_bwidth, /* i : last bandwidth Q0*/ const Word16 output_frame /* i : frame length Q0*/ ) diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index eebfa267c..4d5996bb6 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -508,10 +508,10 @@ void stereo_mdct_core_dec_fx( *--------------------------------------------------------------------*/ static void apply_dmx_weights_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: MDCT Spectrum Q11*/ - Word16 transform_type_left[NB_DIV], /* i : indicate TCX5 for left ch Q0*/ - Word16 transform_type_right[NB_DIV] /* i : indicate TCX5 for right ch Q0*/ + Word16 transform_type_left[NB_DIV], /* i : indicate TCX5 for left ch Q0*/ + Word16 transform_type_right[NB_DIV] /* i : indicate TCX5 for right ch Q0*/ ) { Word16 b, k, l, i, ch; @@ -546,7 +546,7 @@ static void apply_dmx_weights_fx( { /* use TCX20 band config for TCX20 in both channels and mixed frames */ sfbConf = &hCPE->hStereoMdct->stbParamsTCX20; - nsub = nsub2[0] = nsub2[1] = 1; /* overall TCX 20 Q0*/ + nsub = nsub2[0] = nsub2[1] = 1; /* overall TCX 20 Q0*/ move16(); move16(); move16(); diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index efea57f4d..725211758 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -66,12 +66,12 @@ static void inverseBwMS_fx( const Word16 startLine, const Word16 stopLine, Word3 *-------------------------------------------------------------------*/ void parse_stereo_from_bitstream( - STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ - const Word16 isSBAStereoMode, /* i : flag core coding for SBA Q0*/ - Decoder_State *st0, /* i/o: decoder state structure for Bstr */ - Word16 ms_mask[NB_DIV][MAX_SFB] /* o : bandwise MS mask Q0*/ + STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo decoder structure */ + Decoder_State **sts, /* i/o: decoder state structure */ + const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ + const Word16 isSBAStereoMode, /* i : flag core coding for SBA Q0*/ + Decoder_State *st0, /* i/o: decoder state structure for Bstr */ + Word16 ms_mask[NB_DIV][MAX_SFB] /* o : bandwise MS mask Q0*/ ) { Word16 i, k, nSubframes, mdct_stereo_mode; @@ -237,7 +237,7 @@ void parse_stereo_from_bitstream( IF( !mct_on ) { - hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE; /* Equal bits to both channels Q0*/ + hStereoMdct->split_ratio = SMDCT_EQUAL_RATIO_RANGE; /* Equal bits to both channels Q0*/ move16(); hStereoMdct->split_ratio = extract_l( get_next_indice_fx( st0, SMDCT_NBBITS_SPLIT_RATIO ) ); /* Q0 */ @@ -256,11 +256,11 @@ void parse_stereo_from_bitstream( *-------------------------------------------------------------------*/ static void inverseBwMS_fx( - const Word16 startLine, /* i : start line of sfb Q0*/ - const Word16 stopLine, /* i : stop line of sfb Q0*/ - Word32 x0[], /* i/o: mid/left channel coefficients Qx*/ - Word32 x1[], /* i/o: side/right channel coefficients Qx*/ - const Word32 norm_fac /* i : normalization factor Q31*/ + const Word16 startLine, /* i : start line of sfb Q0*/ + const Word16 stopLine, /* i : stop line of sfb Q0*/ + Word32 x0[], /* i/o: mid/left channel coefficients Qx*/ + Word32 x1[], /* i/o: side/right channel coefficients Qx*/ + const Word32 norm_fac /* i : normalization factor Q31*/ ) { Word16 j; @@ -287,10 +287,10 @@ static void inverseBwMS_fx( *-------------------------------------------------------------------*/ void inverseMS_fx( - const Word16 L_frame, /* i : frame length Q0*/ - Word32 x0[], /* i/o: mid/left channel coefficients Qx*/ - Word32 x1[], /* i/o: side/right channel coefficients Qx*/ - const Word32 norm_fac /* i : normalization factor Q31*/ + const Word16 L_frame, /* i : frame length Q0*/ + Word32 x0[], /* i/o: mid/left channel coefficients Qx*/ + Word32 x1[], /* i/o: side/right channel coefficients Qx*/ + const Word32 norm_fac /* i : normalization factor Q31*/ ) { inverseBwMS_fx( 0, L_frame, x0, x1, norm_fac ); @@ -307,20 +307,20 @@ void inverseMS_fx( void stereo_decoder_tcx_fx( STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: MDCT stereo decoder structure */ - Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ - Word32 *spec_r_0[NB_DIV], /* i/o: spectrum right channel Qx*/ - Word32 *spec_l[], /* i/o: spectrum left channel [NB_DIV][N] Qx*/ - Word32 *spec_r[], /* i/o: spectrum right channel [NB_DIV][N] Qx*/ - const Word16 mdct_stereo_mode[], /* i : stereo mode (FB/band wise MS, dual mono Q0*/ - const Word16 core_l, /* i : core for left channel (TCX20/TCX10) Q0*/ - const Word16 core_r, /* i : core for right channel (TCX20/TCX10) Q0*/ - const Word16 igf, /* i : flag for IGF activity Q0*/ - const Word16 L_frameTCX_l, /* i : TCX frame length of left channel Q0*/ - const Word16 L_frameTCX_r, /* i : TCX frame length of right channel Q0*/ - const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ - const Word16 last_core_l, /* i : last core for left channel Q0*/ - const Word16 last_core_r, /* i : last core for right channel Q0*/ - const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision Q0*/ + Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ + Word32 *spec_r_0[NB_DIV], /* i/o: spectrum right channel Qx*/ + Word32 *spec_l[], /* i/o: spectrum left channel [NB_DIV][N] Qx*/ + Word32 *spec_r[], /* i/o: spectrum right channel [NB_DIV][N] Qx*/ + const Word16 mdct_stereo_mode[], /* i : stereo mode (FB/band wise MS, dual mono Q0*/ + const Word16 core_l, /* i : core for left channel (TCX20/TCX10) Q0*/ + const Word16 core_r, /* i : core for right channel (TCX20/TCX10) Q0*/ + const Word16 igf, /* i : flag for IGF activity Q0*/ + const Word16 L_frameTCX_l, /* i : TCX frame length of left channel Q0*/ + const Word16 L_frameTCX_r, /* i : TCX frame length of right channel Q0*/ + const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ + const Word16 last_core_l, /* i : last core for left channel Q0*/ + const Word16 last_core_r, /* i : last core for right channel Q0*/ + const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision Q0*/ ) { Word16 i, k, sfb, nSubframes; @@ -495,10 +495,10 @@ void stereo_decoder_tcx_fx( *-------------------------------------------------------------------*/ void initMdctStereoDecData_fx( - STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const Word16 igf, /* i : flag indicating IGF activity Q0*/ - const H_IGF_GRID igfGrid, /* i : IGF grid configuration Q0*/ - const Word32 element_brate, /* i : element bitrate Q0*/ + STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ + const Word16 igf, /* i : flag indicating IGF activity Q0*/ + const H_IGF_GRID igfGrid, /* i : IGF grid configuration Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ const Word16 bwidth /* i : audio bandwidth Q0*/ ) { @@ -907,9 +907,9 @@ void updateBuffersForDmxMdctStereo_fx( *-------------------------------------------------------------------*/ void applyDmxMdctStereo_fx( - const CPE_DEC_HANDLE hCPE, /* i : CPE handle */ - Word32 *output_fx[CPE_CHANNELS], /* i/o: core decoder output q_out*/ - const Word16 output_frame /* i : output frame length Q0*/ + const CPE_DEC_HANDLE hCPE, /* i : CPE handle */ + Word32 *output_fx[CPE_CHANNELS], /* i/o: core decoder output q_out*/ + const Word16 output_frame /* i : output frame length Q0*/ ) { Word16 crossfade_len, i; diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 8fcbf10cc..76e4d226d 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -343,13 +343,13 @@ static void cpy_tcx_ltp_data_fx( move16(); /* (int16_t) ( ( TCXLTP_MAX_DELAY * output_Fs ) / 48000 ) */ sz = extract_l( Mpy_32_32_r( TCXLTP_MAX_DELAY * output_Fs, 44739 /* 1 / 48000 in Q31 */ ) ); /* Q0 */ - Copy( hTcxLtpDecOld->tcxltp_mem_in, hTcxLtpDecNew->tcxltp_mem_in, sz ); // TODO: One of these will be removed later /* exp(exp_tcxltp_mem_in) */ + Copy( hTcxLtpDecOld->tcxltp_mem_in, hTcxLtpDecNew->tcxltp_mem_in, sz ); // TODO: One of these will be removed later /* exp(exp_tcxltp_mem_in) */ Copy32( hTcxLtpDecOld->tcxltp_mem_in_32, hTcxLtpDecNew->tcxltp_mem_in_32, sz ); /* exp(exp_tcxltp_mem_in) */ hTcxLtpDecNew->exp_tcxltp_mem_in = hTcxLtpDecOld->exp_tcxltp_mem_in; /* exp(exp_tcxltp_mem_in) */ move16(); /* (int16_t) ( ( L_FRAME48k * output_Fs ) / 48000 ) */ sz = extract_l( Mpy_32_32_r( L_FRAME48k * output_Fs, 44739 /* 1 / 48000 in Q31 */ ) ); /* Q0 */ - Copy( hTcxLtpDecOld->tcxltp_mem_out, hTcxLtpDecNew->tcxltp_mem_out, sz ); // TODO: One of these will be removed later /* exp(exp_tcxltp_mem_in) */ + Copy( hTcxLtpDecOld->tcxltp_mem_out, hTcxLtpDecNew->tcxltp_mem_out, sz ); // TODO: One of these will be removed later /* exp(exp_tcxltp_mem_in) */ Copy32( hTcxLtpDecOld->tcxltp_mem_out_32, hTcxLtpDecNew->tcxltp_mem_out_32, sz ); /* exp(exp_tcxltp_mem_in) */ hTcxLtpDecNew->exp_tcxltp_mem_out = hTcxLtpDecOld->exp_tcxltp_mem_out; /* exp(exp_tcxltp_mem_in) */ move16(); @@ -365,13 +365,13 @@ static void cpy_tcx_ltp_data_fx( *-------------------------------------------------------------------*/ ivas_error stereo_memory_dec_fx( - const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ - CPE_DEC_HANDLE hCPE, /* i : CPE decoder structure */ - const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ - const Word32 output_Fs, /* i : output sampling rate Q0*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const MC_MODE mc_mode, /* i : MC mode */ - const Word16 nchan_transport /* i : number of transport channels Q0*/ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + CPE_DEC_HANDLE hCPE, /* i : CPE decoder structure */ + const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ + const Word32 output_Fs, /* i : output sampling rate Q0*/ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const MC_MODE mc_mode, /* i : MC mode */ + const Word16 nchan_transport /* i : number of transport channels Q0*/ ) { DEC_CORE_HANDLE st; @@ -763,7 +763,7 @@ ivas_error stereo_memory_dec_fx( if ( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { - st->last_core = ACELP_CORE; /* needed to set-up TCX core in SetTCXModeInfo() Q0*/ + st->last_core = ACELP_CORE; /* needed to set-up TCX core in SetTCXModeInfo() Q0*/ move16(); } @@ -1151,12 +1151,12 @@ void synchro_synthesis_fx( test(); IF( GE_32( hCPE->last_element_brate, IVAS_32k ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) { - dft_mono_brate_switch = -1; /* switch from residual coding mode or MDCT Stereo Q0*/ + dft_mono_brate_switch = -1; /* switch from residual coding mode or MDCT Stereo Q0*/ move16(); } ELSE IF( LE_32( hCPE->last_element_brate, IVAS_24k4 ) && GT_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) { - dft_mono_brate_switch = 1; /* switch to residual coding mode Q0*/ + dft_mono_brate_switch = 1; /* switch to residual coding mode Q0*/ move16(); } } @@ -1745,7 +1745,7 @@ void stereo_switching_dec( test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && GE_32( hCPE->element_brate, IVAS_32k ) && LE_32( hCPE->last_element_brate, IVAS_24k4 ) ) { - dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ + dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ set32_fx( hCPE->output_mem_fx[0], 0, dft32ms_ovl ); } test(); @@ -1753,7 +1753,7 @@ void stereo_switching_dec( IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && NE_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && hCPE->hCoreCoder[0]->ini_frame > 0 ) { /* windowing the OLA memory */ - dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ + dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ FOR( n = 0; n < CPE_CHANNELS; n++ ) { IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) ) @@ -2084,7 +2084,7 @@ void stereo_td2dft_update_fx( sts = hCPE->hCoreCoder; ovl = NS2SA_FX2( i_mult( sts[n]->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /* Q0 */ move16(); - dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ + dft32ms_ovl = extract_l( Mpy_32_32( imult3216( sts[0]->output_Fs, STEREO_DFT32MS_OVL_MAX ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ move16(); hq_delay_comp = NS2SA_FX2( sts[0]->output_Fs, DELAY_CLDFB_NS ); /* Q0 */ move16(); @@ -2228,8 +2228,8 @@ void stereo_mdct2dft_update_fx( st = hCPE->hCoreCoder[0]; - fade_len = extract_l( Mpy_32_32( imult3216( st->output_Fs, STEREO_MDCT2DFT_FADE_LEN_48k ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ - fade_len_LB = extract_l( Mpy_32_32( imult3216( 3 * STEREO_MDCT2DFT_FADE_LEN_48k * FRAMES_PER_SEC, st->L_frame ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ + fade_len = extract_l( Mpy_32_32( imult3216( st->output_Fs, STEREO_MDCT2DFT_FADE_LEN_48k ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ + fade_len_LB = extract_l( Mpy_32_32( imult3216( 3 * STEREO_MDCT2DFT_FADE_LEN_48k * FRAMES_PER_SEC, st->L_frame ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ SWITCH( st->output_Fs ) { @@ -2389,7 +2389,7 @@ static Word32 ncross_corr_self_fx( *-------------------------------------------------------------------*/ void smooth_dft2td_transition_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word32 *output_fx[CPE_CHANNELS], /* i/o: synthesis @external Fs Q11*/ const Word16 output_frame /* i : output frame lenght Q0*/ ) diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index 7169e31e2..ec135d7a0 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -63,13 +63,13 @@ void stereo_td_init_dec_fx( hStereoTD->tdm_LRTD_flag = 0; move16(); // hStereoTD->prevSP_ratio = 0.5f; - hStereoTD->prevSP_ratio_fx = ONE_IN_Q14; //.5 /* Q15 */ + hStereoTD->prevSP_ratio_fx = ONE_IN_Q14; //.5 /* Q15 */ move16(); // hStereoTD->SP_ratio_LT = 0.0f; hStereoTD->SP_ratio_LT_fx = 0; move32(); // hStereoTD->c_LR_LT = 0.5f; - hStereoTD->c_LR_LT_fx = ONE_IN_Q30; //.5 /* Q31 */ + hStereoTD->c_LR_LT_fx = ONE_IN_Q30; //.5 /* Q31 */ move32(); hStereoTD->flag_skip_DMX = 0; @@ -216,7 +216,7 @@ void tdm_configure_dec_fx( move16(); } - sts[0]->tdm_LRTD_flag = hStereoTD->tdm_LRTD_flag; /* the flag was already read in function stereo_memory_dec() Q0*/ + sts[0]->tdm_LRTD_flag = hStereoTD->tdm_LRTD_flag; /* the flag was already read in function stereo_memory_dec() Q0*/ move16(); sts[1]->tdm_LRTD_flag = hStereoTD->tdm_LRTD_flag; /* Q0 */ move16(); @@ -519,7 +519,7 @@ Word32 inv_time[960 + 1] = { }; static void tdm_upmix_fade_fx( Word32 Left_fx[], /* o : left channel Qx*/ - Word32 Right_fx[], /* o : right channel Qx*/ + Word32 Right_fx[], /* o : right channel Qx*/ const Word32 PCh_2_L_fx[], /* i : primary channel Qx*/ const Word32 SCh_2_R_fx[], /* i : secondary channel Qx*/ const Word32 LR_ratio_mem_fx, /* i : last mixing ratio Q31*/ @@ -627,11 +627,11 @@ static void tdm_upmix_fade_fx( void stereo_tdm_combine_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *PCh_2_L_fx, /* i/o: Primary channel -> output as left channel Qx*/ - Word32 *SCh_2_R_fx, /* i/o: Secondary channel -> output as right channel Qx*/ - const Word16 output_frame, /* i : Number of samples Q0*/ - const Word16 flag_HB, /* i : flag to distinguish between core (0) and HB (1) synthesis Q0*/ - const Word16 tdm_ratio_idx /* i : TDM ratio index Q0*/ + Word32 *PCh_2_L_fx, /* i/o: Primary channel -> output as left channel Qx*/ + Word32 *SCh_2_R_fx, /* i/o: Secondary channel -> output as right channel Qx*/ + const Word16 output_frame, /* i : Number of samples Q0*/ + const Word16 flag_HB, /* i : flag to distinguish between core (0) and HB (1) synthesis Q0*/ + const Word16 tdm_ratio_idx /* i : TDM ratio index Q0*/ ) { Word16 i; @@ -681,7 +681,7 @@ void stereo_tdm_combine_fx( } ELSE { - stereo_tdm_coder_type = 1; /* mode 2 : SM scheme Q0*/ + stereo_tdm_coder_type = 1; /* mode 2 : SM scheme Q0*/ move16(); } } diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index e904281b6..d6811d2df 100755 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -106,14 +106,14 @@ static Word32 maxWithSign_fx( ); static Word16 BidagonalDiagonalisation_fx( - Word32 singularVectors_Left_fx[][MAX_OUTPUT_CHANNELS], /* i/o: left singular vectors (U) singularValues_fx_e*/ + Word32 singularVectors_Left_fx[][MAX_OUTPUT_CHANNELS], /* i/o: left singular vectors (U) singularValues_fx_e*/ Word32 singularValues_fx[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) singularValues_fx_e*/ - Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_fx_e*/ + Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_fx_e*/ Word32 secDiag_fx[MAX_OUTPUT_CHANNELS], /* i/o: secDiag_fx_e*/ - Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ - Word16 *secDiag_fx_e, /* i/o: */ - const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ - const Word16 nChannelsC, /* i : number of columns in the matrix to be decomposed Q0*/ + Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ + Word16 *secDiag_fx_e, /* i/o: */ + const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ + const Word16 nChannelsC, /* i : number of columns in the matrix to be decomposed Q0*/ const Word32 eps_x, /* i : eps_x_e*/ const Word16 eps_x_e /* i : */ ); @@ -155,16 +155,16 @@ static Word32 GivensRotation_fx( Word16 *out_e ); static void ApplyQRTransform_fx( - Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* i/o: left singular vectors (U) singularValues_e*/ + Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* i/o: left singular vectors (U) singularValues_e*/ Word32 singularValues[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) singularValues_e*/ - Word32 singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_e*/ - Word32 secDiag[MAX_OUTPUT_CHANNELS], /* i/o: secDiag_e*/ + Word32 singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_e*/ + Word32 secDiag[MAX_OUTPUT_CHANNELS], /* i/o: secDiag_e*/ Word16 singularValues_e[MAX_OUTPUT_CHANNELS], Word16 secDiag_e[MAX_OUTPUT_CHANNELS], - const Word16 startIndex, /* i : Q0*/ - const Word16 currentIndex, /* i : Q0*/ - const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ - const Word16 nChannelsC /* i : number of columns in the matrix to be decomposed Q0*/ + const Word16 startIndex, /* i : Q0*/ + const Word16 currentIndex, /* i : Q0*/ + const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ + const Word16 nChannelsC /* i : number of columns in the matrix to be decomposed Q0*/ ); /*------------------------------------------------------------------------- @@ -174,11 +174,11 @@ static void ApplyQRTransform_fx( *-------------------------------------------------------------------------*/ void mat2svdMat_fx( - const Word32 *mat, /* i : matrix as column ordered vector Qx*/ - Word32 svdMat[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], /* o : matrix as two-dimensional arry Qx*/ - const Word16 nRows, /* i : number of rows of the matrix Q0*/ - const Word16 mCols, /* i : number of columns of the matrix Q0*/ - const Word16 transpose /* i : flag indication transposition Q0*/ + const Word32 *mat, /* i : matrix as column ordered vector Qx*/ + Word32 svdMat[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], /* o : matrix as two-dimensional arry Qx*/ + const Word16 nRows, /* i : number of rows of the matrix Q0*/ + const Word16 mCols, /* i : number of columns of the matrix Q0*/ + const Word16 transpose /* i : flag indication transposition Q0*/ ) { Word16 i, j; @@ -231,10 +231,10 @@ void mat2svdMat_fx( *---------------------------------------------------------------------*/ void svdMat2mat_fx( - Word32 svdMat[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], /* i : matrix as two-dimensional arry Qx*/ - Word32 *mat, /* o : matrix as column ordered vector Qx*/ - const Word16 nRows, /* i : number of rows of the matrix Q0*/ - const Word16 mCols /* i : number of columns of the matrix Q0*/ + Word32 svdMat[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], /* i : matrix as two-dimensional arry Qx*/ + Word32 *mat, /* o : matrix as column ordered vector Qx*/ + const Word16 nRows, /* i : number of rows of the matrix Q0*/ + const Word16 mCols /* i : number of columns of the matrix Q0*/ ) { Word16 i, j; @@ -261,12 +261,12 @@ void svdMat2mat_fx( Word16 svd_fx( Word32 InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) InputMatrix_e*/ Word16 InputMatrix_e, - Word32 singularVectors_Left_fx[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) singularValues_fx_e*/ + Word32 singularVectors_Left_fx[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) singularValues_fx_e*/ Word32 singularValues_fx[MAX_OUTPUT_CHANNELS], /* o : singular values vector (S) singularValues_fx_e*/ - Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* o : right singular vectors (V) singularValues_fx_e*/ + Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* o : right singular vectors (V) singularValues_fx_e*/ Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], - const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ - const Word16 nChannelsC /* i : number of columns in the matrix to be decomposed Q0*/ + const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ + const Word16 nChannelsC /* i : number of columns in the matrix to be decomposed Q0*/ ) { Word16 iCh, jCh; @@ -368,14 +368,14 @@ Word16 svd_fx( *-------------------------------------------------------------------------*/ static Word16 BidagonalDiagonalisation_fx( - Word32 singularVectors_Left_fx[][MAX_OUTPUT_CHANNELS], /* i/o: left singular vectors (U) singularValues_fx_e*/ + Word32 singularVectors_Left_fx[][MAX_OUTPUT_CHANNELS], /* i/o: left singular vectors (U) singularValues_fx_e*/ Word32 singularValues_fx[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) singularValues_fx_e*/ - Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_fx_e*/ + Word32 singularVectors_Right_fx[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_fx_e*/ Word32 secDiag_fx[MAX_OUTPUT_CHANNELS], /* i/o: secDiag_fx_e*/ - Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ - Word16 *secDiag_new_e, /* i/o: */ - const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ - const Word16 nChannelsC, /* i : number of columns in the matrix to be decomposed Q0*/ + Word16 singularValues_fx_e[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) */ + Word16 *secDiag_new_e, /* i/o: */ + const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ + const Word16 nChannelsC, /* i : number of columns in the matrix to be decomposed Q0*/ const Word32 eps_x, /* i : eps_x_e*/ const Word16 eps_x_e /* i : */ ) @@ -539,16 +539,16 @@ static Word16 BidagonalDiagonalisation_fx( *-------------------------------------------------------------------------*/ static void ApplyQRTransform_fx( - Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* i/o: left singular vectors (U) singularValues_e*/ - Word32 singularValues[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) singularValues_e*/ - Word32 singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_e*/ - Word32 secDiag[MAX_OUTPUT_CHANNELS], /* i/o: secDiag_e*/ + Word32 singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* i/o: left singular vectors (U) singularValues_e*/ + Word32 singularValues[MAX_OUTPUT_CHANNELS], /* i/o: singular values vector (S) singularValues_e*/ + Word32 singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* i/o: right singular vectors (V) singularValues_e*/ + Word32 secDiag[MAX_OUTPUT_CHANNELS], /* i/o: secDiag_e*/ Word16 singularValues_e[MAX_OUTPUT_CHANNELS], Word16 secDiag_e[MAX_OUTPUT_CHANNELS], - const Word16 startIndex, /* i : Q0*/ - const Word16 currentIndex, /* i : Q0*/ - const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ - const Word16 nChannelsC /* i : number of columns in the matrix to be decomposed Q0*/ + const Word16 startIndex, /* i : Q0*/ + const Word16 currentIndex, /* i : Q0*/ + const Word16 nChannelsL, /* i : number of rows in the matrix to be decomposed Q0*/ + const Word16 nChannelsC /* i : number of columns in the matrix to be decomposed Q0*/ ) { Word32 temp; @@ -1221,7 +1221,7 @@ static void singularVectorsAccumulationRight_fx( Word16 norm_y_e, temp_exp1, sing_right_exp[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS] = { 0 }; /* Processing */ - nChannels = nChannelsC; /* nChannelsC Q0*/ + nChannels = nChannelsC; /* nChannelsC Q0*/ /* avoid compiler warning */ t_ii = secDiag[nChannels - 1]; /* exp(secDiag_e[nChannels - 1]) */ diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 6ee4bfe18..e581e1374 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -55,9 +55,9 @@ static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( Decoder_State *st, const * Initialize stereo TCX decoder *-------------------------------------------------------------*/ void stereo_tcx_init_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode /* i : element mode of previous frame Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode /* i : element mode of previous frame Q0*/ ) { TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; @@ -190,18 +190,18 @@ void stereo_tcx_init_dec_fx( *-------------------------------------------------------------------*/ void stereo_tcx_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const FRAME_MODE frameMode, /* i : Decoder frame mode */ - Word16 *signal_out_fx, /* o : synthesis @internal_Fs, Q0*/ - Word16 *signal_outFB_fx, /* o : synthesis @output_Fs, Q0*/ - Word16 pitch_buf_fx[], /* o : Word16 pitch for each subframe, Q6*/ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel Q0*/ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const Word16 nchan_out, /* i : number of output channels Q0*/ - const IVAS_FORMAT ivas_format /* i : IVAS format */ + Decoder_State *st, /* i/o: decoder state structure */ + const FRAME_MODE frameMode, /* i : Decoder frame mode */ + Word16 *signal_out_fx, /* o : synthesis @internal_Fs, Q0*/ + Word16 *signal_outFB_fx, /* o : synthesis @output_Fs, Q0*/ + Word16 pitch_buf_fx[], /* o : Word16 pitch for each subframe, Q6*/ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel Q0*/ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ + const Word16 nchan_out, /* i : number of output channels Q0*/ + const IVAS_FORMAT ivas_format /* i : IVAS format */ ) { Word16 i, k; @@ -269,7 +269,7 @@ void stereo_tcx_core_dec_fx( total_nbbits = extract_l( Mpy_32_32_r( st->total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); bitsRead = 0; move16(); - LSF_Q_prediction = -1; /* to avoid compilation warnings Q0*/ + LSF_Q_prediction = -1; /* to avoid compilation warnings Q0*/ move16(); IF( frameMode == FRAMEMODE_NORMAL ) @@ -404,7 +404,7 @@ void stereo_tcx_core_dec_fx( FOR( k = 0; k < st->numlpc; ++k ) { - Copy( &lsp_fx[( k + 1 ) * M], &lspnew_uw_fx[k * M], M ); /*basop not used for k * M as M is a multiple of 2 Q15*/ + Copy( &lsp_fx[( k + 1 ) * M], &lspnew_uw_fx[k * M], M ); /*basop not used for k * M as M is a multiple of 2 Q15*/ Copy( &lsf_fx[( k + 1 ) * M], &lsfnew_uw_fx[k * M], M ); /* Q2.56 */ } } @@ -800,8 +800,8 @@ void stereo_tcx_core_dec_fx( IF( EQ_16( bfi, 1 ) ) { - Copy( st->lspold_uw, st->lsp_old_fx, M ); /* for recovery Q15*/ - Copy( st->lsfold_uw, st->lsf_old_fx, M ); /* for recovery Q15*/ + Copy( st->lspold_uw, st->lsp_old_fx, M ); /* for recovery Q15*/ + Copy( st->lsfold_uw, st->lsf_old_fx, M ); /* for recovery Q15*/ } ELSE { @@ -977,9 +977,9 @@ void stereo_tcx_core_dec_fx( static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ Word16 *Q_syn_Overl_TDAC, Word16 *Q_fer_samples, Word16 *Q_syn_Overl, @@ -1020,9 +1020,9 @@ static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( return; } static void dec_prm_tcx_ivas_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Word16 param[], /* o : decoded parameters Q0*/ - Word16 param_lpc[], /* o : LPC parameters Q0*/ + Decoder_State *st, /* i/o: decoder memory state */ + Word16 param[], /* o : decoded parameters Q0*/ + Word16 param_lpc[], /* o : LPC parameters Q0*/ Word16 *total_nbbits, /* i/o: number of bits / decoded bits Q0*/ const Word16 last_element_mode, /* i : last element mode Q0*/ Word16 *bitsRead /* o : number of read bits Q0*/ @@ -1069,7 +1069,7 @@ static void dec_prm_tcx_ivas_fx( IF( !st->use_partial_copy && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) #endif { - st->last_core_from_bs = get_next_indice_fx( st, 1 ); /* Store decoder memory of last_core Q0*/ + st->last_core_from_bs = get_next_indice_fx( st, 1 ); /* Store decoder memory of last_core Q0*/ move16(); test(); diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 59543f4da..32b5b3f87 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -48,14 +48,14 @@ *-------------------------------------------------------------------*/ void tdm_low_rate_dec_fx( - Decoder_State *st, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Q_exc*/ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - const Word16 *lsf_new /* i : ISFs at the end of the frame Q8/100 (2.56x)*/ + Decoder_State *st, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Q_exc*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + const Word16 *lsf_new /* i : ISFs at the end of the frame Q8/100 (2.56x)*/ ) { Word16 tmp_nb_bits_tot, pit_band_idx; @@ -205,15 +205,15 @@ void tdm_low_rate_dec_fx( void decod_gen_2sbfr_fx( Decoder_State *st, /* i/o: decoder static memory */ const Word16 sharpFlag, /* i : formant sharpening flag `Q0*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[] /* i : pitch values for primary channel Q6*/ + const Word16 tdm_Pri_pitch_buf[] /* i : pitch values for primary channel Q6*/ ) { Word16 T0, T0_frac, T0_min, T0_max; /* integer pitch variables */ @@ -257,8 +257,8 @@ void decod_gen_2sbfr_fx( * ACELP subframe loop *------------------------------------------------------------------*/ - p_Aq = Aq; /* pointer to interpolated LPC parameters Q12*/ - pt_pitch = pitch_buf; /* pointer to the pitch buffer Q6*/ + p_Aq = Aq; /* pointer to interpolated LPC parameters Q12*/ + pt_pitch = pitch_buf; /* pointer to the pitch buffer Q6*/ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += 2 * L_SUBFR ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 23a353ff0..44fdfc5ce 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -351,9 +351,9 @@ bool IVAS_DEC_isRestartNeeded( /*! r: error code */ ivas_error IVAS_DEC_EnableVoIP( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ - const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const Word16 jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ + const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ ); /*! r: error code */ diff --git a/lib_dec/lp_exc_d_fx.c b/lib_dec/lp_exc_d_fx.c index 2358bfa79..f64bed65f 100644 --- a/lib_dec/lp_exc_d_fx.c +++ b/lib_dec/lp_exc_d_fx.c @@ -9,27 +9,26 @@ /*======================================================================*/ /* FUNCTION : lp_filt_exc_dec_fx() */ -/*-----------------------------------------------------------------------*/ -/* PURPOSE : Low-pass filtering of the adaptive exctitation */ -/* */ -/*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) core_brate : Core bitrate Q0 */ -/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) i_subfr : subframe index Q0 */ +/*----------------------------------------------------------------------*/ +/* PURPOSE : Low-pass filtering of the adaptive exctitation */ +/* */ +/*----------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word32) core_brate : Core bitrate Q0 */ +/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ +/* _ (Word16) i_subfr : subframe index Q0 */ /* _ (Word16) L_subfr : subframe size Q0 */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/*-----------------------------------------------------------------------*/ -/* INPUT OUTPUT ARGUMENTS */ -/* _ (Word16 *) exc : excitation buffer Q0 */ -/*-----------------------------------------------------------------------*/ - -/* */ -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/*----------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/*----------------------------------------------------------------------*/ +/* INPUT OUTPUT ARGUMENTS */ +/* _ (Word16 *) exc : excitation buffer Q0 */ +/*----------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ /*=======================================================================*/ void lp_filt_exc_dec_fx( diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index c032a7454..dde492027 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -108,8 +108,8 @@ void lsf_dec_fx( Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ) { Word16 i; @@ -363,13 +363,13 @@ void lsf_dec_fx( void lsf_end_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 mode2_flag, /* Q0 */ - const Word16 coder_type_org, /* i : coding type Q0*/ - const Word16 bwidth, /* i : input signal bandwidth Q0*/ - const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ - Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ - Word16 *lpc_param, /* i : LPC parameters Q0*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *nb_indices, /* o : number of indices Q0*/ + const Word16 coder_type_org, /* i : coding type Q0*/ + const Word16 bwidth, /* i : input signal bandwidth Q0*/ + const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ + Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ + Word16 *lpc_param, /* i : LPC parameters Q0*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *nb_indices, /* o : number of indices Q0*/ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ) { @@ -807,10 +807,10 @@ void lsf_end_dec_fx( /* _ None */ /*========================================================================*/ void lsf_mid_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ + Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ - Word16 coder_type, /* i : Coder type Q0*/ - Word16 lsp_mid[] /* o : quantized LSPs Q15*/ + Word16 coder_type, /* i : Coder type Q0*/ + Word16 lsp_mid[] /* o : quantized LSPs Q15*/ ) { Word16 j, idx; diff --git a/lib_dec/lsf_msvq_ma_dec_fx.c b/lib_dec/lsf_msvq_ma_dec_fx.c index 1b5d79c68..d90553016 100644 --- a/lib_dec/lsf_msvq_ma_dec_fx.c +++ b/lib_dec/lsf_msvq_ma_dec_fx.c @@ -159,12 +159,12 @@ Word16 lsf_bctcvq_decprm( /* Returns: number of indices */ Word16 D_lsf_tcxlpc( - const Word16 indices[], /* i : VQ indices Q0*/ - Word16 lsf_q[], /* o : quantized LSF Q1*/ - Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk, /* i : codebook selector Q0*/ - Word16 mem_MA[] /* i : MA memory Q1*/ + const Word16 indices[], /* i : VQ indices Q0*/ + Word16 lsf_q[], /* o : quantized LSF Q1*/ + Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk, /* i : codebook selector Q0*/ + Word16 mem_MA[] /* i : MA memory Q1*/ ) { Word16 i; @@ -258,7 +258,7 @@ Word16 dec_lsf_tcxlpc( Word16 lsf_q_ind[M]; Word16 *flag; - flag = *indices; /* Save pointer Q0*/ + flag = *indices; /* Save pointer Q0*/ *flag = 0; move16(); /* Set flag to disabled */ ++*indices; diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index d490dce4a..d672ae9ca 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -298,7 +298,7 @@ void Mode2_delta_pit_dec( /* PURPOSE : calculate pitch value */ /* */ /*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* _ (Word32) core_brate : Core bitrate Q0 */ /* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */ /* _ (Word16) L_frame : length of the frame Q0 */ diff --git a/lib_dec/ppp_dec_fx.c b/lib_dec/ppp_dec_fx.c index 00a333798..8656c7e53 100644 --- a/lib_dec/ppp_dec_fx.c +++ b/lib_dec/ppp_dec_fx.c @@ -202,29 +202,29 @@ static void DTFS_dequant_cw_fx( } } /*===================================================================*/ -/* FUNCTION : void ppp_quarter_decoder_fx () */ +/* FUNCTION : void ppp_quarter_decoder_fx () */ /*-------------------------------------------------------------------*/ -/* PURPOSE : */ +/* PURPOSE : */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ Word16 bfi_fx - Q0 bad frame indicator */ -/* _ const Word16 *curr_lpc_fx - Q12 current frame LPC */ -/* _ Word16 *exc_fx - Q0 previous frame excitation */ -/* _ Word16 prevCW_lag_fx - Q0 Previous lag */ -/* _ (struct DTFS_fx) PREV_CW_D_FX : prototype in polar domain */ +/* _ Word16 bfi_fx - Q0 bad frame indicator */ +/* _ const Word16 *curr_lpc_fx - Q12 current frame LPC */ +/* _ Word16 *exc_fx - Q0 previous frame excitation */ +/* _ Word16 prevCW_lag_fx - Q0 Previous lag */ +/* _ (struct DTFS_fx) PREV_CW_D_FX : prototype in polar domain */ /* (Word16) lag: length of prototype in time domain */ /* (Word16 []) a: amplitude of harmonics, normalized */ /* (Word16) Q: norm factor of a */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ Decoder_State_fx *st_fx: */ -/* _ Word16 *pitch - Q6 floating pitch values for each subframe */ -/* _ Word16 *out_fx - Q0 residual signal */ +/* _ Decoder_State_fx *st_fx: */ +/* _ Word16 *pitch - Q6 floating pitch values for each subframe */ +/* _ Word16 *out_fx - Q0 residual signal */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ Decoder_State_fx *st_fx: */ -/* _ lsp_old_fx - Q15 */ -/* _ st_fx->dtfs_dec_xxxx */ +/* _ Decoder_State_fx *st_fx: */ +/* _ lsp_old_fx - Q15 */ +/* _ st_fx->dtfs_dec_xxxx */ /* _ gainp_ppp Q14 */ /* _ lastLgainD_fx - Q11 */ /* _ lastHgainD_fx - Q11 */ @@ -233,24 +233,24 @@ static void DTFS_dequant_cw_fx( /* (Word16) lag: length of prototype in time domain */ /* (Word16 []) a: amplitude of harmonics, normalized */ /* (Word16) Q: norm factor of a */ -/* _ Word16 *pitch_buf_fx - Q6 fixed pitch values for each subframe */ -/* _ Word16 *exc_fx - Q0 previous frame excitation */ +/* _ Word16 *pitch_buf_fx - Q6 fixed pitch values for each subframe */ +/* _ Word16 *exc_fx - Q0 previous frame excitation */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ -/* _ None */ +/* _ None */ /*-------------------------------------------------------------------*/ -/* CALLED FROM : RX */ +/* CALLED FROM : RX */ /*===================================================================*/ ivas_error ppp_quarter_decoder_fx( - DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ - Word16 prevCW_lag_fx, /* i : Previous lag */ - Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ - Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ - Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ - Word16 bfi, /* i : FER flag */ + DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ + Word16 prevCW_lag_fx, /* i : Previous lag */ + Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ + Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ + Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ + Word16 bfi, /* i : FER flag */ Word16 *S_fx, /* i : sine table, Q15 */ Word16 *C_fx, /* i : cosine table, Q15 */ - DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ + DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ Decoder_State *st_fx ) { DTFS_STRUCTURE *PREVDTFS_FX; diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index 00d70785d..aeb91e670 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -13,26 +13,24 @@ *----------------------------------------------------------------------*/ static void tc_dec_fx( Decoder_State *st_fx, const Word16 L_frame, Word16 exc[], Word16 *T0, Word16 *T0_frac, const Word16 i_subfr, const Word16 tc_subfr, Word16 *position, Word16 bwe_exc[], Word16 *Q_exc ); /*======================================================================*/ -/* FUNCTION : transition_dec_fx() */ +/* FUNCTION : transition_dec_fx() */ /*----------------------------------------------------------------------*/ -/* PURPOSE : Principal function for TC decoding */ -/* */ +/* PURPOSE : Principal function for TC decoding */ +/* */ /*----------------------------------------------------------------------*/ -/* GLOBAL INPUT ARGUMENTS : */ -/* _ (Word16) L_frame : length of the frame Q0 */ -/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ -/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */ -/*-----------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*=======================================================================*/ +/* GLOBAL INPUT ARGUMENTS : */ +/* _ (Word16) L_frame : length of the frame Q0 */ +/* _ (Word16[]) pitch_buf_fx: floating pitch values for each subframe Q6*/ +/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ +/*----------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*======================================================================*/ void transition_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -635,26 +633,24 @@ void transition_dec_fx( /*======================================================================*/ -/* FUNCTION : tc_dec_fx() */ +/* FUNCTION : tc_dec_fx() */ /*----------------------------------------------------------------------*/ -/* PURPOSE : Principal function for TC decoding */ -/* * Principal function for TC decoding. */ -/* * - constructs glottal codebook contribution */ -/* * - uses pitch sharpening */ -/* * - uses gain_trans */ +/* PURPOSE : Principal function for TC decoding */ +/* * Principal function for TC decoding. */ +/* * - constructs glottal codebook contribution */ +/* * - uses pitch sharpening */ +/* * - uses gain_trans */ /*----------------------------------------------------------------------*/ -/* GLOBAL INPUT ARGUMENTS : */ -/* _ (Word16) L_frame : length of the frame Q0 */ +/* GLOBAL INPUT ARGUMENTS : */ +/* _ (Word16) L_frame : length of the frame Q0 */ /*----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */ /*----------------------------------------------------------------------*/ - - /*----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*======================================================================*/ static void tc_dec_fx( diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index 1a813b462..c1e34ec8a 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -8,15 +8,15 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "ivas_prot_fx.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /* Function prototypes */ /*============================================================================*/ -/* FUNCTION : void FEC_encode_fx() */ +/* FUNCTION : void FEC_encode_fx() */ /*----------------------------------------------------------------------------*/ -/* PURPOSE : Encoder supplementary information for FEC */ +/* PURPOSE : Encoder supplementary information for FEC */ /*----------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ +/* INPUT ARGUMENTS : */ /* Word16 *synth i : pointer to synthesized speech for E computation */ /* Word16 coder_type i : type of coder */ /* Word16 clas i : signal clas for current frame */ @@ -25,31 +25,31 @@ /* Word16 L_frame i : Frame length */ /* Word32 total_brate i : total codec bitrate */ /*----------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /*----------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /* Word16 *last_pulse_pos i/o: Position of the last pulse */ -/* Encoder_State *st_fx i/o: state structure */ +/* Encoder_State *st_fx i/o: state structure */ /*----------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*----------------------------------------------------------------------------*/ -/* */ +/* */ /*============================================================================*/ void FEC_encode_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_new, /* i : input scaling */ - const Word16 shift /* i : scaling to get 12bits */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ + const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_synth*/ + const Word16 coder_type, /* i : type of coder Q0*/ + Word16 clas, /* i : signal clas for current frame Q0*/ + const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ + const Word16 *res, /* i : LP residual signal frame Qx*/ + Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ + const Word16 L_frame, /* i : Frame length Q0*/ + const Word32 total_brate, /* i : total codec bitrate Q0*/ + const Word16 Q_new, /* i : input scaling */ + const Word16 shift /* i : scaling to get 12bits */ ) { Word16 tmpS, index; @@ -154,7 +154,7 @@ void FEC_encode_fx( if ( sign == 1 ) { - maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/ + maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/ } push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS ); @@ -197,7 +197,7 @@ void FEC_encode_fx( *-------------------------------------------------------------------*/ void FEC_lsf_estim_enc_fx( - Encoder_State *st_fx, /* i : Encoder static memory */ + Encoder_State *st_fx, /* i : Encoder static memory */ Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ ) { @@ -300,16 +300,16 @@ void FEC_lsf_estim_enc_fx( *-------------------------------------------------------------------*/ void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ + const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ + const Word16 coder_type, /* i : type of coder Q0*/ + Word16 clas, /* i : signal clas for current frame Q0*/ + const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ + const Word16 *res, /* i : LP residual signal frame Qx*/ + Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ + const Word16 L_frame, /* i : Frame length Q0*/ + const Word32 total_brate, /* i : total codec bitrate Q0*/ const Word16 Q_synth /* i : input scaling */ ) { @@ -431,7 +431,7 @@ void FEC_encode_ivas_fx( if ( EQ_16( sign, 1 ) ) { - maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/ + maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/ } push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS ); diff --git a/lib_enc/SNR_calc_fx.c b/lib_enc/SNR_calc_fx.c index 09acfd5dc..ebe2a819a 100644 --- a/lib_enc/SNR_calc_fx.c +++ b/lib_enc/SNR_calc_fx.c @@ -19,15 +19,15 @@ *-------------------------------------------------------------------*/ void calc_lf_snr_fx( - Word32 *lf_snr_smooth, /* o : smoothed lf_snr Q25*/ - Word32 *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr Q25*/ - const Word32 l_speech_snr, /* i : sum of active frames snr Q16*/ - const Word32 l_speech_snr_count, /* i : amount of the active frame Q0*/ - const Word32 l_silence_snr, /* i : sum of the nonactive frames snr Q16*/ - const Word32 l_silence_snr_count, /* i : amount of the nonactive frame Q0*/ + Word32 *lf_snr_smooth, /* o : smoothed lf_snr Q25*/ + Word32 *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr Q25*/ + const Word32 l_speech_snr, /* i : sum of active frames snr Q16*/ + const Word32 l_speech_snr_count, /* i : amount of the active frame Q0*/ + const Word32 l_silence_snr, /* i : sum of the nonactive frames snr Q16*/ + const Word32 l_silence_snr_count, /* i : amount of the nonactive frame Q0*/ const Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/ const Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/ - const Word16 bw_index /* i : band width index Q0*/ + const Word16 bw_index /* i : band width index Q0*/ ) { @@ -72,14 +72,14 @@ void calc_lf_snr_fx( *-------------------------------------------------------------------*/ void calc_lt_snr_fx( VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - Word32 *lt_snr_org_fp, /* o : original long time SNR Q25*/ - Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy Q25*/ - Word32 fg_energy, /* i : foreground energy sum Qx*/ - Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/ - Word32 bg_energy, /* i : background energy sum Qx*/ - Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/ - Word16 bw_index, /* i : band width index Q0*/ - Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0 Q10*/ + Word32 *lt_snr_org_fp, /* o : original long time SNR Q25*/ + Word32 *lt_snr_fp, /* o : long time SNR calculated by fg_energy and bg_energy Q25*/ + Word32 fg_energy, /* i : foreground energy sum Qx*/ + Word16 fg_energy_count, /* i : amount of the foreground energy frame Q0*/ + Word32 bg_energy, /* i : background energy sum Qx*/ + Word16 bg_energy_count, /* i : amount of the background energy frame Q0*/ + Word16 bw_index, /* i : band width index Q0*/ + Word16 lt_noise_sp_center0 /* i : long time noise spectral center by 0 Q10*/ ) { Word16 tmp_lt_noise_sp_center; @@ -172,9 +172,9 @@ void calc_lt_snr_fx( * *-------------------------------------------------------------------*/ void calc_snr_flux_fx( - Word32 tsnr, /* i : time-domain SNR Q25*/ - Word32 *pre_snr, /* i/o: time-domain SNR storage Q25*/ - Word32 *snr_flux_fp /* o : average tsnr Q25*/ + Word32 tsnr, /* i : time-domain SNR Q25*/ + Word32 *pre_snr, /* i/o: time-domain SNR storage Q25*/ + Word32 *snr_flux_fp /* o : average tsnr Q25*/ ) { Word32 i; @@ -229,12 +229,12 @@ void calc_snr_flux_fx( * *-------------------------------------------------------------------*/ void snr_calc( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - const Word16 sacle_sbpower, /* i : the Scaling of sbpower */ - Word32 *snr, /* o : frequency domain SNR Q25*/ - Word32 *tsnr, /* o : time domain SNR Q25*/ - const Word32 frame_energy, /* i : current frame energy sacle_sbpower*/ - const Word32 bwidth /* i : audio band width Q0*/ + VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ + const Word16 sacle_sbpower, /* i : the Scaling of sbpower */ + Word32 *snr, /* o : frequency domain SNR Q25*/ + Word32 *tsnr, /* o : time domain SNR Q25*/ + const Word32 frame_energy, /* i : current frame energy sacle_sbpower*/ + const Word32 bwidth /* i : audio band width Q0*/ ) { Word32 i; @@ -371,14 +371,14 @@ void snr_calc( } Word32 construct_snr_thresh_fx( - Word16 sp_center[], /* i : spectral center Q10*/ - Word32 snr_flux, /* i : snr flux Q25*/ - Word32 lt_snr, /* i : long time time domain snr Q25*/ - Word32 l_snr, /* i : long time frequency domain snr Q25*/ - Word32 continuous_speech_num, /* i : amount of continuous speech frames Q0*/ - Word16 continuous_noise_num, /* i : amount of continuous noise frames Q0*/ - Word32 fg_energy_est_start, /* i : whether if estimated energy Q0*/ - Word16 bw_index /* i : band width index Q0*/ + Word16 sp_center[], /* i : spectral center Q10*/ + Word32 snr_flux, /* i : snr flux Q25*/ + Word32 lt_snr, /* i : long time time domain snr Q25*/ + Word32 l_snr, /* i : long time frequency domain snr Q25*/ + Word32 continuous_speech_num, /* i : amount of continuous speech frames Q0*/ + Word16 continuous_noise_num, /* i : amount of continuous noise frames Q0*/ + Word32 fg_energy_est_start, /* i : whether if estimated energy Q0*/ + Word16 bw_index /* i : band width index Q0*/ ) { diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index ceaa45514..6c1d42252 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -20,17 +20,17 @@ * ACELP core encoder *--------------------------------------------------------------------*/ ivas_error acelp_core_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/ - const Word32 ener_fx, /* i : residual energy from Levinson-Durbin Q6*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors Qx*/ - const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame Q15*/ - Word16 vad_hover_flag_fx, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/ + const Word32 ener_fx, /* i : residual energy from Levinson-Durbin Q6*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word16 epsP_h_fx[M + 1], /* i : LP prediction errors Qx*/ + const Word16 epsP_l_fx[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame Q15*/ + Word16 vad_hover_flag_fx, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/ @@ -700,23 +700,23 @@ ivas_error acelp_core_enc_fx( * ACELP core encoder *--------------------------------------------------------------------*/ ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ Word16 Q_new ) { Word16 i, nBits; /* reserved bits */ diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index a9e567fa7..edd36283a 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -104,10 +104,10 @@ Word16 E_ACELP_toeplitz_mul_fx( } void E_ACELP_weighted_code( - const Word16 code[], /* i: code Q9*/ - const Word16 H[], /* i: impulse response Q*/ - Word16 Q, /* i: Q format of H */ - Word16 y[] /* o: weighted code Q9*/ + const Word16 code[], /* i: code Q9*/ + const Word16 H[], /* i: impulse response Q*/ + Word16 Q, /* i: Q format of H */ + Word16 y[] /* o: weighted code Q9*/ ) { Word16 i, j, k, one, n, nz[L_SUBFR]; @@ -153,9 +153,9 @@ void E_ACELP_weighted_code( } void E_ACELP_conv( - const Word16 xn2[], /* i Qx*/ - const Word16 h2[], /* i Q12*/ - Word16 cn2[] /* o Q0*/ + const Word16 xn2[], /* i Qx*/ + const Word16 h2[], /* i Q12*/ + Word16 cn2[] /* o Q0*/ ) { Word16 i, k; @@ -177,9 +177,9 @@ void E_ACELP_conv( } void E_ACELP_conv_ivas_fx( - const Word16 xn2[], /* i Qnew - 1*/ - const Word16 h2[], /* i Q12*/ - Word16 cn2[] /* o Qnew*/ + const Word16 xn2[], /* i Qnew - 1*/ + const Word16 h2[], /* i Q12*/ + Word16 cn2[] /* o Qnew*/ ) { Word16 i, k; @@ -201,11 +201,11 @@ void E_ACELP_conv_ivas_fx( } } void E_ACELP_build_code( - Word16 nb_pulse, /* i Q0*/ - const Word16 codvec[], /* i Q0*/ - const Word16 sign[], /* i Q0*/ - Word16 code[], /* o Q9*/ - Word16 ind[] /* o Q0*/ + Word16 nb_pulse, /* i Q0*/ + const Word16 codvec[], /* i Q0*/ + const Word16 sign[], /* i Q0*/ + Word16 code[], /* o Q9*/ + Word16 ind[] /* o Q0*/ ) { Word16 i, k, val, index, track, tmp, vec[4]; @@ -225,7 +225,7 @@ void E_ACELP_build_code( FOR( k = 0; k < nb_pulse; ++k ) { - i = codvec[k]; /* read pulse position Q0*/ + i = codvec[k]; /* read pulse position Q0*/ move16(); val = sign[i]; /* read sign Q0*/ move16(); @@ -258,9 +258,9 @@ void E_ACELP_build_code( } void E_ACELP_setup_pulse_search_pos( - const PulseConfig *config, /* i: pulse configuration */ - Word16 k, /* i: interation number Q0*/ - UWord8 ipos[] /* o: pulse search positions Q0*/ + const PulseConfig *config, /* i: pulse configuration */ + Word16 k, /* i: interation number Q0*/ + UWord8 ipos[] /* o: pulse search positions Q0*/ ) { Word16 restpulses, iPulse; diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index def862b84..cad8c5b0b 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -142,16 +142,16 @@ void analy_lp_fx( *-------------------------------------------------------------------*/ void analy_lp_AMR_WB_fx( - const Word16 speech[], /* i : pointer to the speech frame Q_new*/ - Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ - Word16 A[], /* o : A(z) filter coefficients Q14*/ - Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 isp_new[], /* o : current frame ISPs Q15*/ - Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ - Word16 isf_new[], /* o : current frame ISPs Q15*/ - Word16 Top, /* i : open loop pitch lag Q0*/ - Word16 Tnc, /* i : open loop pitch gain Qx*/ + const Word16 speech[], /* i : pointer to the speech frame Q_new*/ + Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ + Word16 A[], /* o : A(z) filter coefficients Q14*/ + Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 isp_new[], /* o : current frame ISPs Q15*/ + Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ + Word16 isf_new[], /* o : current frame ISPs Q15*/ + Word16 Top, /* i : open loop pitch lag Q0*/ + Word16 Tnc, /* i : open loop pitch gain Qx*/ Word16 Q_new, Word16 *Q_r ) { diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 7a1f60e45..631d0a141 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -699,7 +699,7 @@ static void ivas_find_enr( Word16 data[], /* i : fft result */ Word16 q_data, /* i : Q of fft result */ Word32 band[], /* o : per band energy q_band */ - Word16 *q_band, /* o : Q of per band energy */ + Word16 *q_band, /* o : Q of per band energy */ Word32 *ptE, /* o : per bin energy for low frequencies q_ptE */ Word16 *q_ptE, /* o : Q of per bin energy for low frequencies Q0 */ Word64 *LEtot, /* o : total energy q_band+1 */ diff --git a/lib_enc/ari_enc_fx.c b/lib_enc/ari_enc_fx.c index 29ddd838c..e9bd888bd 100644 --- a/lib_enc/ari_enc_fx.c +++ b/lib_enc/ari_enc_fx.c @@ -63,12 +63,12 @@ Word16 ari_put_bit_plus_follow( ) { assert( bit == 0 || bit == 1 ); - ptr[bp++] = bit; /* send initially a zero or one Q0*/ + ptr[bp++] = bit; /* send initially a zero or one Q0*/ move16(); bit = s_xor( bit, 1 ); /* invert bit to send */ FOR( ; bits_to_follow > 0; bits_to_follow-- ) { - ptr[bp++] = bit; /* send inverted bit Q0*/ + ptr[bp++] = bit; /* send inverted bit Q0*/ move16(); } return bp; @@ -171,7 +171,7 @@ Word16 ari_encode_14bits_ext_fx( /* Output an opposite bit */ /* later if in middle half. */ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ - low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ + low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ high = L_sub( high, ari_q1new ); /* Q0 */ } ELSE @@ -248,7 +248,7 @@ static Word16 ari_encode_14bits_high_low( /* Output an opposite bit */ /* later if in middle half. */ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ - low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ + low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ high = L_sub( high, ari_q1new ); /* Q0 */ } ELSE @@ -532,7 +532,7 @@ static Word16 ari_encode_14bits_high_low_ivas_fx( /* Output an opposite bit */ /* later if in middle half. */ bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ - low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ + low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ high = L_sub( high, ari_q1new ); /* Q0 */ } ELSE diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index 4d342eeb4..66b13136b 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -760,10 +760,10 @@ static Word16 quant_3p_3N1_fx( ELSE { index = quant_2p_2N1_fx( pos2, pos3, sub( N, 1 ) ); /* index = quant_2p_2N1_fx(pos2, pos3, (N-1)); */ - /* index += (pos2 & nb_pos) << N; */ + /* index += (pos2 & nb_pos) << N; */ index = add( index, shl( (Word16) ( pos2 & nb_pos ), N ) ); logic16(); - /* index += quant_1p_N1_fx(pos1, N) << (2*N); */ + /* index += quant_1p_N1_fx(pos1, N) << (2*N); */ index = add( index, shl( quant_1p_N1_fx( pos1, N ), shl( N, 1 ) ) ); } return ( index ); @@ -799,7 +799,7 @@ static Word32 quant_4p_4N1_fx( IF( ( ( pos1 ^ pos2 ) & nb_pos ) == 0 ) { index = quant_2p_2N1_fx( pos1, pos2, sub( N, 1 ) ); /* index = quant_2p_2N1_fx(pos1, pos2, (N-1)); */ - /* index += (pos1 & nb_pos) << N; */ + /* index += (pos1 & nb_pos) << N; */ index = L_add( index, L_shl( L_deposit_l( (Word16) ( pos1 & nb_pos ) ), N ) ); logic16(); /* index += quant_2p_2N1_fx(pos3, pos4, N) << (2*N); */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 1e01d8c3c..dd6dc433f 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -225,14 +225,14 @@ void TNSAnalysis_ivas_fx( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ Word16 L_frame, /* i : frame length */ Word16 L_spec, /* i : length of the spectrum */ - Word16 transform_type, /* i : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */ + Word16 transform_type, /* i : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */ Word8 isAfterACELP, /* i : Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */ Word32 spectrum[], /* i : MDCT spectrum Q=Qx*/ TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ Word16 ltp_gain, /* i : ltp gain Q=15*/ STnsData *pTnsData, /* o : Tns data */ Word8 *pfUseTns, /* o : Flag indicating if TNS is used */ - Word16 *predictionGain /* o : TNS prediction gain Q=7 */ + Word16 *predictionGain /* o : TNS prediction gain Q=7 */ ) { Word32 buff[8]; diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index 14a6d6c80..d09c99ff1 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -48,7 +48,7 @@ /*--------------------------------------------------------------------------*/ /* float x (i) in Q_new input to filter */ /* float y (o) in Q_new +2 output of filter */ -/* float *oldy (i/o) previous output of filter */ +/* float *oldy (i/o) previous output of filter */ /* float *oldx (i/o) in Q_memx previous input of filter */ /* short L (i) in Q_memx +2 length (32 or 48 kHz) */ /*--------------------------------------------------------------------------*/ @@ -178,7 +178,7 @@ Word16 detect_transient_fx( E_in_fx = L_add_sat( E_in_fx, Energy_in_fx[blk + 1] ); /*Q0*/ E_out_fx = L_add_sat( E_out_fx, Energy_fx ); /*Q0*/ - Thres_fx = 2185; /*1 /15 Q15*/ + Thres_fx = 2185; /*1 /15 Q15*/ move16(); IF( GT_32( Mult_32_16( Energy_fx, 5461 ), EnergyLT ) ) { @@ -246,7 +246,7 @@ Word16 detect_transient_fx( move16(); } thr = shl( thr, shift ); - /*if(Energy > L_shr(Mult_32_16(EnergyLT,22624),shift_cnt)) //getting in Q0 32*16 = Q_inp1+Q_inp2+1-16 */ + /*if(Energy > L_shr(Mult_32_16(EnergyLT,22624),shift_cnt)) //getting in Q0 32*16 = Q_inp1+Q_inp2+1-16 */ IF( GT_32( Mult_32_16( Energy, thr ), EnergyLT ) ) /*if(Energy > 6.0f * EnergyLT) */ { @@ -256,8 +256,8 @@ Word16 detect_transient_fx( move16(); } } - /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ - /*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */ + /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ + /*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */ EnergyLT = L_add_sat( Mult_32_16( EnergyLT, 24576 /*0.75f in Q15*/ ), Mult_32_16( Energy, shl( 8192 /*0.25 in Q15*/, shift ) ) ); /*2Q_new */ } } @@ -284,7 +284,7 @@ Word16 detect_transient_fx( E_low_fx = L_deposit_l( 0 ); FOR( i = 0; i < position + 1; i++ ) { - /*blk++; */ + /*blk++; */ blk = add( blk, 1 ); E_low_fx = L_add_sat( E_low_fx, Energy_in_fx[i] ); /*Q0*/ } diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 265288f02..321d045d4 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -52,10 +52,10 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ (Word16) vad : vad flag Q0 */ /* _ (Word16[]) speech_fx : Pointer to the speech frame qSpeech */ /* _ (Word16) qSpeech : speech buffer qformat value */ -/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ +/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ /*----------------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ +/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ /* _ (Encoder_State_Fx) st_fx : encoder state structure */ /*----------------------------------------------------------------------------------*/ @@ -604,10 +604,10 @@ void dtx_ivas_fx( /* _ (Word16) vad : vad flag Q0 */ /* _ (Word16[]) speech_fx : Pointer to the speech frame qSpeech */ /* _ (Word16) qSpeech : speech buffer qformat value */ -/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ +/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ /*----------------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ +/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ /* _ (Encoder_State_Fx) st_fx : encoder state structure */ /*----------------------------------------------------------------------------------*/ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index f4e56fdd3..695cf2525 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -43,43 +43,40 @@ static void rem_offset( /*======================================================================*/ -/* FUNCTION : encod_gen_voic_fx() */ +/* FUNCTION : encod_gen_voic_fx() */ /*----------------------------------------------------------------------*/ -/* PURPOSE : encode generic (GC), voiced (VC) and AMR-WB IO frames */ -/* */ +/* PURPOSE : encode generic (GC), voiced (VC) and AMR-WB IO frames */ +/* */ /*----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Struct) st_fx : encoder static memory */ -/* _ (Word16) L_frame_fx : length of the frame Q0 */ - -/* _ (Word16[]) speech_fx : input speech Q0 */ -/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16[]) A_fx : unquantized A(z) filter */ -/* with bandwidth expansion Q12 */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ -/* _ (Word16[]) T_op_fx : open loop pitch Q0 */ -/* _ (Word16[]) voicing_fx : floating pitch values for each subframe Q15*/ -/* _ (Word16[]) res_fx : residual signal Q_new */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */ -/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ -/* _ (Word16) shift : shift */ -/* _ (Word16) Q_new : */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */ -/* _ (Word16[]) syn_fx :core synthesis Q_new */ -/* _ (Word16[]) voice_factors_fx: voicing factors Q15 */ -/* _ (Word16[]) bwe_exc_fx : excitation for SWB TBE Q0 */ -/*-----------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*=======================================================================*/ +/* INPUT ARGUMENTS : */ +/* _ (Struct) st_fx : encoder static memory */ +/* _ (Word16) L_frame_fx : length of the frame Q0 */ +/* _ (Word16[]) speech_fx : input speech Q0 */ +/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ +/* _ (Word16[]) A_fx : unquantized A(z) filter */ +/* with bandwidth expansion Q12 */ +/* _ (Word16) coder_type : coding type */ +/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ +/* _ (Word16[]) T_op_fx : open loop pitch Q0 */ +/* _ (Word16[]) voicing_fx : floating pitch values for each subframe Q15*/ +/* _ (Word16[]) res_fx : residual signal Q_new */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */ +/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ +/* _ (Word16) shift : shift */ +/* _ (Word16) Q_new : */ +/*----------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q0) */ +/* _ (Word16[]) syn_fx :core synthesis Q_new */ +/* _ (Word16[]) voice_factors_fx: voicing factors Q15 */ +/* _ (Word16[]) bwe_exc_fx : excitation for SWB TBE Q0 */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*======================================================================*/ void encod_gen_voic_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -94,7 +91,7 @@ void encod_gen_voic_fx( Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ - Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ + Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 shift, @@ -454,7 +451,7 @@ void encod_gen_voic_ivas_fx( Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ - Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ + Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 shift, diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index a8ce8de56..9f3483ec7 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -114,18 +114,18 @@ void reset_rf_indices_fx( *-------------------------------------------------------------------*/ void coder_acelp_rf_fx( ACELP_config *acelp_cfg, /*input/output: configuration of the ACELP coding*/ - const Word16 coder_type, /* input: coding type Q0*/ - const Word16 A[], /* input: coefficients 4xAz[M+1] Q12*/ - const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] Q12*/ - Word16 speech[], /* input: speech[-M..lg] Q_new-1*/ - const Word16 voicing[], /* input: open-loop LTP gain Q15*/ - const Word16 T_op[], /* input: open-loop LTP lag Q0*/ + const Word16 coder_type, /* input: coding type Q0*/ + const Word16 A[], /* input: coefficients 4xAz[M+1] Q12*/ + const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] Q12*/ + Word16 speech[], /* input: speech[-M..lg] Q_new-1*/ + const Word16 voicing[], /* input: open-loop LTP gain Q15*/ + const Word16 T_op[], /* input: open-loop LTP lag Q0*/ Word16 stab_fac, /* Q15 */ Encoder_State *st, - Word16 target_bits, /* i/o : coder memory state Q0*/ - const Word16 rf_frame_type, /* i : rf_frame_type Q0*/ - Word16 *exc_rf, /* i/o: pointer to RF excitation Q_new*/ - Word16 *syn_rf, /* i/o: pointer to RF synthesis Q_new-1*/ + Word16 target_bits, /* i/o : coder memory state Q0*/ + const Word16 rf_frame_type, /* i : rf_frame_type Q0*/ + Word16 *exc_rf, /* i/o: pointer to RF excitation Q_new*/ + Word16 *syn_rf, /* i/o: pointer to RF synthesis Q_new-1*/ Word16 Q_new, Word16 shift ) { @@ -464,7 +464,7 @@ void coder_acelp_rf_fx( Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ exc_rf[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ move16(); } diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 014ce4603..124ad95ce 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -791,14 +791,14 @@ static void find_cn_fx( * Transform domain contribution encoding *-----------------------------------------------------------------*/ -/* o: quantization index Q0*/ +/* o: quantization index Q0*/ Word16 gain_quant_fx( - Word32 *gain, /* i : quantized gain Q16*/ - Word16 *gain16, /* o : quantized gain expg*/ - const Word16 c_min, /* i : log10 of lower limit in Q14*/ - const Word16 c_max, /* i : log10 of upper limit in Q13*/ - const Word16 bits, /* i : number of bits to quantize Q0*/ - Word16 *expg /* o : output exponent of gain16 */ + Word32 *gain, /* i : quantized gain Q16*/ + Word16 *gain16, /* o : quantized gain expg*/ + const Word16 c_min, /* i : log10 of lower limit in Q14*/ + const Word16 c_max, /* i : log10 of upper limit in Q13*/ + const Word16 bits, /* i : number of bits to quantize Q0*/ + Word16 *expg /* o : output exponent of gain16 */ ) { Word16 index, levels; diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c index c3eb2ae18..8da01e162 100644 --- a/lib_enc/enc_nelp_fx.c +++ b/lib_enc/enc_nelp_fx.c @@ -12,48 +12,47 @@ #include "basop_util.h" /*==============================================================================*/ -/* FUNCTION : encod_nelp_fx() */ +/* FUNCTION : encod_nelp_fx() */ /*------------------------------------------------------------------------------*/ /* PURPOSE : Encode Unvoiced frames in SC-VBR */ /*------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Encoder_State) st_fx: state structure */ -/* _ (Word16[]) speech_fx : input speech Q_new-1 */ -/* _ (Word16[]) Aq_fx : 12k8 Lp coefficient Q12 */ -/* _ (Word16[]) A_fx : unquantized A(z) filter */ -/* with bandwidth expansion Q12 */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16[]) res_fx : residual signal Q_new */ -/* _ (Word16*) Q_new : res qformat */ +/* INPUT ARGUMENTS : */ +/* _ (Encoder_State) st_fx: state structure */ +/* _ (Word16[]) speech_fx : input speech Q_new-1 */ +/* _ (Word16[]) Aq_fx : 12k8 Lp coefficient Q12 */ +/* _ (Word16[]) A_fx : unquantized A(z) filter */ +/* with bandwidth expansion Q12 */ +/* _ (Word16) coder_type : coding type */ +/* _ (Word16[]) res_fx : residual signal Q_new */ +/* _ (Word16*) Q_new : res qformat */ /* _ (Word16) shift */ /*------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) synth_fx : core synthesis */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) synth_fx : core synthesis */ /* _ (Word16[]) tmp_noise_fx: long-term noise energy Q0 */ -/* _ (Word16[]) exc_fx : current non-enhanced excitation Q_new */ -/* _ (Word16[]) exc2_fx : current enhanced excitation Q_new */ -/* _ (Word16[]) pitch_buf_fx: floating pitch values for each subframe Q6 */ +/* _ (Word16[]) exc_fx : current non-enhanced excitation Q_new */ +/* _ (Word16[]) exc2_fx : current enhanced excitation Q_new */ +/* _ (Word16[]) pitch_buf_fx: floating pitch values for each subframe Q6 */ /* _ (Word16*) voice_factors : voicing factors */ /* _ (Word16*) bwe_exc : excitation for SWB TBE */ /*------------------------------------------------------------------------------*/ - /*------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*==============================================================================*/ void encod_nelp_fx( Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *speech_fx, /* i : input speech Q_new-1*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 *speech_fx, /* i : input speech Q_new-1*/ + const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ - Word16 *res_fx, /* o : residual signal Q_new*/ - Word16 *synth_fx, /* o : core synthesis Q_new*/ - Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *res_fx, /* o : residual signal Q_new*/ + Word16 *synth_fx, /* o : core synthesis Q_new*/ + Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ Word16 Q_new, Word16 shift @@ -245,7 +244,7 @@ void encod_nelp_ivas_fx( res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx ); /* scale xn[] and h1[] to avoid overflow in dot_product12() */ - Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits Q_new-1+shift */ + Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits Q_new-1+shift */ IF( i_subfr == 0 ) { diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index b1ad74b0d..7f0e79b2b 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -11,40 +11,39 @@ /*======================================================================*/ -/* FUNCTION : enc_pit_exc_fx() */ +/* FUNCTION : enc_pit_exc_fx() */ /*----------------------------------------------------------------------*/ -/* PURPOSE : Encode pitch only contribution */ -/* */ +/* PURPOSE : Encode pitch only contribution */ +/* */ /*----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Struct) st_fx : encoder static memory */ -/* _ (Word16[]) speech_fx : input speech Qnew-1 */ -/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16[]) A_fx : unquantized A(z) filter */ -/* with bandwidth expansion Q12 */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ -/* _ (Word16[]) T_op_fx : open loop pitch Q0 */ -/* _ (Word16[]) voicing_fx : floating pitch values for each subframe Q15*/ -/* _ (Word16[]) res_fx : residual signal Q_new */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Qnew) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Qnew) */ -/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ +/* INPUT ARGUMENTS : */ +/* _ (Struct) st_fx : encoder static memory */ +/* _ (Word16[]) speech_fx : input speech Qnew-1 */ +/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ +/* _ (Word16[]) A_fx : unquantized A(z) filter */ +/* with bandwidth expansion Q12 */ +/* _ (Word16) coder_type : coding type */ +/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ +/* _ (Word16[]) T_op_fx : open loop pitch Q0 */ +/* _ (Word16[]) voicing_fx : floating pitch values for each subframe Q15*/ +/* _ (Word16[]) res_fx : residual signal Q_new */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Qnew) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Qnew) */ +/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ /* _ (Word16[]) *wH1, : Weighted impulses response mask */ -/* _ (Word16) shift : shift */ -/* _ (Word16) Q_new : */ +/* _ (Word16) shift : shift */ +/* _ (Word16) Q_new : */ /*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Qnew) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Qnew) */ -/* _ (Word16[]) syn_fx :core synthesis */ -/* _ (Word16[]) voice_factors_fx: voicing factors Q15 */ -/* _ (Word16[]) bwe_exc_fx : excitation for SWB TBE Q0 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Qnew) */ +/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Qnew) */ +/* _ (Word16[]) syn_fx :core synthesis */ +/* _ (Word16[]) voice_factors_fx: voicing factors Q15 */ +/* _ (Word16[]) bwe_exc_fx : excitation for SWB TBE Q0 */ /*-----------------------------------------------------------------------*/ - /*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*=======================================================================*/ void enc_pit_exc_fx( @@ -61,9 +60,9 @@ void enc_pit_exc_fx( Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 Q_new, Word16 shift ) { @@ -403,7 +402,7 @@ void enc_pit_exc_fx( Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ move16(); } @@ -414,7 +413,7 @@ void enc_pit_exc_fx( { Ltmp = L_mult( exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ } } @@ -548,9 +547,9 @@ void enc_pit_exc_ivas_fx( Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 Q_new, Word16 shift ) { @@ -895,7 +894,7 @@ void enc_pit_exc_ivas_fx( { Ltmp = L_mult( exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ move16(); } diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index fca36f460..c0e1db3a3 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -19,50 +19,50 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ); /* PURPOSE : */ /*---------------------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (Word16) speech_fx[], i : input speech Q_new */ -/* _ (Word16) Aq_fx[], i : 12k8 Lp coefficient Q12 */ +/* _ (Word16) speech_fx[], i : input speech Q_new */ +/* _ (Word16) Aq_fx[], i : 12k8 Lp coefficient Q12 */ /* _ (Word16) A_fx[], i : unquantized A(z) filter with bandwidth expansion Q12*/ -/* _ (Word16) coder_type, i : coding type */ -/* _ (Word16) T_op_fx[], i : open loop pitch */ -/* _ (Word16) voicing_fx[], i : voicing Q15 */ -/* _ (Word16) *res_fx, i : residual signal Q_new */ -/* _ (Word16) Q_new i : Q factor for res */ -/* _ (Word16) vadsnr_fx i : SNR for current frame Q7 */ +/* _ (Word16) coder_type, i : coding type */ +/* _ (Word16) T_op_fx[], i : open loop pitch */ +/* _ (Word16) voicing_fx[], i : voicing Q15 */ +/* _ (Word16) *res_fx, i : residual signal Q_new */ +/* _ (Word16) Q_new i : Q factor for res */ +/* _ (Word16) vadsnr_fx i : SNR for current frame Q7 */ /*---------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16) *exc2_fx, o : current enhanced excitation Q0 */ -/* _ (Word16) *pitch_buf_fx, o : floating pitch values for each subframe Q6 */ -/* _ (Word16) *synth_fx, o : core synthesis Q-1 */ -/* _ Encoder_State *st_fx: */ -/* _ lastLgainE_fx - Q11 */ -/* _ lastHgainE_fx - Q11 */ -/* _ lasterbE_fx - Q13 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16) *exc2_fx, o : current enhanced excitation Q0 */ +/* _ (Word16) *pitch_buf_fx, o : floating pitch values for each subframe Q6 */ +/* _ (Word16) *synth_fx, o : core synthesis Q-1 */ +/* _ Encoder_State *st_fx: */ +/* _ lastLgainE_fx - Q11 */ +/* _ lastHgainE_fx - Q11 */ +/* _ lasterbE_fx - Q13 */ /*---------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ Encoder_State *st_fx: */ -/* _ st_fx->dtfs_enc_xxxx */ -/* _ a nd b in st_fx->dtfs_enc_Q */ -/* rest all in Q0 */ -/* - bump_up_fx - Q0 */ -/* _ (Word16) *exc_fx, o : current enhanced excitation Q0 */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ Encoder_State *st_fx: */ +/* _ st_fx->dtfs_enc_xxxx */ +/* _ a nd b in st_fx->dtfs_enc_Q */ +/* rest all in Q0 */ +/* - bump_up_fx - Q0 */ +/* _ (Word16) *exc_fx, o : current enhanced excitation Q0 */ /*---------------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ -/* _ None. */ +/* _ None. */ /*---------------------------------------------------------------------------------------*/ /* CALLED FROM : TX */ /*=======================================================================================*/ ivas_error encod_ppp_fx( Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Q_new*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/ - Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *synth_fx, /* o : core synthesis Q-1*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ + const Word16 speech_fx[], /* i : input speech Q_new*/ + const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/ + Word16 *res_fx, /* i : residual signal Q_new*/ + Word16 *synth_fx, /* o : core synthesis Q-1*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ Word16 Q_new, Word16 shift ) { @@ -236,16 +236,16 @@ ivas_error encod_ppp_fx( ivas_error encod_ppp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Q_new*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 speech_fx[], /* i : input speech Q_new*/ + const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ - Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *synth_fx, /* o : core synthesis Q-1*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ + Word16 *res_fx, /* i : residual signal Q_new*/ + Word16 *synth_fx, /* o : core synthesis Q-1*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ Word16 Q_new, Word16 shift ) { diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index 94d869a01..ea9f3d0de 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -1518,10 +1518,10 @@ void writeTCXparam_fx( *--------------------------------------------------------------------*/ void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ ) { UWord16 index; diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index fd97c8bf4..a767a4f13 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -11,43 +11,43 @@ /*=================================================================================*/ -/* FUNCTION : void encod_tran_fx () */ +/* FUNCTION : void encod_tran_fx () */ /*---------------------------------------------------------------------------------*/ -/* PURPOSE : */ +/* PURPOSE : */ /*---------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* (Word16) L_frame_fx : length of the frame Q0 */ -/* (Word16[]) speech_fx : input speech Q0 */ -/* (Word16[]) Aq_fx : 12k8 Lp coefficient Q12 */ -/* (Word16[]) A_fx : unquantized A(z) filter with bandwidth expansion Q12 */ -/* (Word16) coder_type : coding type Q0 */ -/* (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ -/* (Word16[]) T_op_fx : open loop pitch Q0 */ -/* (Word16[]) voicing_fx : voicing Q15 */ -/* (Word16*) res_fx : residual signal Q_new*/ -/* (Word16) gsc_attack_flag : Flag to indicate when an audio attack is deal with TM*/ -/* (Word16) shift : shift factor */ -/* (Word16[]) Q_new : input scaling */ +/* INPUT ARGUMENTS : */ +/* (Word16) L_frame_fx : length of the frame Q0 */ +/* (Word16[]) speech_fx : input speech Q0 */ +/* (Word16[]) Aq_fx : 12k8 Lp coefficient Q12 */ +/* (Word16[]) A_fx : unquantized A(z) filter with bandwidth expansion Q12 */ +/* (Word16) coder_type : coding type Q0 */ +/* (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ +/* (Word16[]) T_op_fx : open loop pitch Q0 */ +/* (Word16[]) voicing_fx : voicing Q15 */ +/* (Word16*) res_fx : residual signal Q_new*/ +/* (Word16) gsc_attack_flag : Flag to indicate when an audio attack is deal with TM*/ +/* (Word16) shift : shift factor */ +/* (Word16[]) Q_new : input scaling */ /*---------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* (Word16*) voice_factors : voicing factors Q15 */ +/* OUTPUT ARGUMENTS : */ +/* (Word16*) voice_factors : voicing factors Q15 */ /*---------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* Encoder_State *st_fx :Encoder state structure */ -/* (Word16*) syn_fx :core synthesis Qnew */ -/* (Word16*) exc_fx :current non-enhanced excitation Q0 */ -/* (Word16*) exc2_fx :current enhanced excitation Q0 */ -/* (Word16*) pitch_buf_fx :floating pitch values for each subframe Q6 */ -/* (Word16*) bwe_exc_fx :excitation for SWB TBE Q0 */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* Encoder_State *st_fx :Encoder state structure */ +/* (Word16*) syn_fx :core synthesis Qnew */ +/* (Word16*) exc_fx :current non-enhanced excitation Q0 */ +/* (Word16*) exc2_fx :current enhanced excitation Q0 */ +/* (Word16*) pitch_buf_fx :floating pitch values for each subframe Q6 */ +/* (Word16*) bwe_exc_fx :excitation for SWB TBE Q0 */ /*---------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*---------------------------------------------------------------------------------*/ Word16 encod_tran_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ const Word16 *res_fx, /* i : residual signal Q_new*/ @@ -422,7 +422,7 @@ Word16 encod_tran_fx( Word16 encod_tran_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ - const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ const Word16 *res_fx, /* i : residual signal Q_new*/ diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 0bb329f63..cd0f707e4 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -19,7 +19,7 @@ void encod_unvoiced_fx( Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *speech_fx, /* i : Input speech Q_new*/ + const Word16 *speech_fx, /* i : Input speech Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ @@ -30,7 +30,7 @@ void encod_unvoiced_fx( Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ const Word16 Q_new, const Word16 shift ) { @@ -213,7 +213,7 @@ void encod_unvoiced_fx( Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */ Ltmp2 = L_shl( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ } tmp2 = L_SUBFR; @@ -251,9 +251,9 @@ void encod_unvoiced_fx( void encod_unvoiced_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *speech_fx, /* i : Input speech Q_new*/ + const Word16 *speech_fx, /* i : Input speech Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ + const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/ const Word16 *res_fx, /* i : residual signal Q_new*/ @@ -262,7 +262,7 @@ void encod_unvoiced_ivas_fx( Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ const Word16 Q_new, const Word16 shift ) { @@ -457,7 +457,7 @@ void encod_unvoiced_ivas_fx( Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */ Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ move16(); } diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index 308c7cc5d..b8203ef68 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -17,18 +17,18 @@ * *-------------------------------------------------------------------*/ void est_energy_fx( - Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band enerBuffer_exp*/ - Word16 enerBuffer_exp, /* i : exponent of energy vector */ - Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly frame_sb_energy_scale*/ - Word32 *frame_energy2_p, /* o : frame energy 2 frame_energy2_Q*/ - Word32 *HB_Power_p, /* o : high frequency energy HB_Power_Q*/ - Word32 *frame_energy_p, /* o : frame energy 1 frame_energy_Q*/ - Word16 *sb_power_Q, /* o : the scaling of sb_power */ - Word16 *frame_energy2_Q, /* o : the scaling of frame_energy */ - Word16 *HB_Power_Q, /* o : the scaling of HB_Power */ - Word16 *frame_energy_Q, /* o : the Scaling of frame_energy */ - Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[] */ - const Word32 bandwidth /* i : band width Q0*/ + Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy vector per band enerBuffer_exp*/ + Word16 enerBuffer_exp, /* i : exponent of energy vector */ + Word32 *frame_sb_energy, /* o : energy of sub-band divided non-uniformly frame_sb_energy_scale*/ + Word32 *frame_energy2_p, /* o : frame energy 2 frame_energy2_Q*/ + Word32 *HB_Power_p, /* o : high frequency energy HB_Power_Q*/ + Word32 *frame_energy_p, /* o : frame energy 1 frame_energy_Q*/ + Word16 *sb_power_Q, /* o : the scaling of sb_power */ + Word16 *frame_energy2_Q, /* o : the scaling of frame_energy */ + Word16 *HB_Power_Q, /* o : the scaling of HB_Power */ + Word16 *frame_energy_Q, /* o : the Scaling of frame_energy */ + Word16 *frame_sb_energy_scale, /* o : the Scaling of frame_sb_energy[] */ + const Word32 bandwidth /* i : band width Q0*/ ) { Word32 i, j; @@ -200,11 +200,11 @@ static void update_sb_bg_energy( * *-------------------------------------------------------------------*/ void background_update_fx( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - Word16 scale, /* i : the scaling of frame energy */ - Word32 frame_energy, /* i : current frame energy scale*/ - Word32 update_flag, /* i : update flag Q0*/ - Word16 music_backgound_f, /* i : background music flag Q0*/ + VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ + Word16 scale, /* i : the scaling of frame energy */ + Word32 frame_energy, /* i : current frame energy scale*/ + Word32 update_flag, /* i : update flag Q0*/ + Word16 music_backgound_f, /* i : background music flag Q0*/ Word32 snr /* Q25 */ ) { diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index eafe13f53..e1c80e879 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -27,27 +27,27 @@ /*======================================================================*/ -/* FUNCTION : Pit_exc_contribution_len_fx() */ +/* FUNCTION : Pit_exc_contribution_len_fx() */ /*----------------------------------------------------------------------*/ /* PURPOSE : Determine up to which band the pit contribution is significant*/ /*----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Struct) st_fx : encoder static memory */ -/* _ (Word16[]) dct_res : DCT of residual Qnew */ -/* _ (Word16[]) dct_pitex : DCT of pitch contribution Qnew */ -/* _ (Word16[]) pitch_buf : Pitch per subframe Q6 */ -/* _ (Word16[]) nb_subfr : Number of subframe considered */ -/* _ (Word16) hangover : hangover for the time contribution switching*/ -/* _ (Word16) Qnew : */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) dct_res : DCT of residual Qnew */ -/* _ (Word16[]) dct_pitex : DCT of pitch contribution Qnew */ -/*-----------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*=======================================================================*/ +/* INPUT ARGUMENTS : */ +/* _ (Struct) st_fx : encoder static memory */ +/* _ (Word16[]) dct_res : DCT of residual Qnew */ +/* _ (Word16[]) dct_pitex : DCT of pitch contribution Qnew */ +/* _ (Word16[]) pitch_buf : Pitch per subframe Q6 */ +/* _ (Word16[]) nb_subfr : Number of subframe considered */ +/* _ (Word16) hangover : hangover for the time contribution switching*/ +/* _ (Word16) Qnew : */ +/*----------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) dct_res : DCT of residual Qnew */ +/* _ (Word16[]) dct_pitex : DCT of pitch contribution Qnew */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*======================================================================*/ /* o : bin where pitch contribution is significant */ Word16 Pit_exc_contribution_len_fx( @@ -56,7 +56,7 @@ Word16 Pit_exc_contribution_len_fx( Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ) { Word16 corr_dct_pit[MBANDS_LOC]; @@ -419,11 +419,11 @@ Word16 Pit_exc_contribution_len_fx( Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin where pitch contribution is significant */ Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *dct_res, /* i : DCT of residual Q_new*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Q_new*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + const Word16 *dct_res, /* i : DCT of residual Q_new*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Q_new*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ) { diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 08c0a88a4..ce5b5405c 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -29,10 +29,10 @@ static void configure_core_coder_loc( Encoder_State *st ); *-------------------------------------------------------------------*/ ivas_error evs_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *data, /* i : input signal Q0*/ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *data, /* i : input signal Q0*/ Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of input samples Q0*/ + const Word16 n_samples /* i : number of input samples Q0*/ ) { Word16 i, input_frame, delay; @@ -314,7 +314,7 @@ ivas_error evs_enc_fx( bwe_exc_extended, voice_factors, pitch_buf, vad_hover_flag, &Q_new, &shift ); #ifndef FIX_I4_OL_PITCH - Copy( pitch_orig, st->pitch, 3 ); /* populate the original OL pitch values back Q0*/ + Copy( pitch_orig, st->pitch, 3 ); /* populate the original OL pitch values back Q0*/ #endif /*---------------------------------------------------------------------* diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 30961c591..6e46631f4 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -177,7 +177,7 @@ void core_signal_analysis_high_bitrate_fx( alw_pitch_lag_12k8_wc = s_min( alw_pitch_lag_12k8[0], alw_pitch_lag_12k8[1] ); /* Q0 */ alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] ); /* Q15 */ } - overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame Q0*/ + overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame Q0*/ move16(); IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) @@ -187,7 +187,7 @@ void core_signal_analysis_high_bitrate_fx( transform_type[0] = TCX_20; transform_type[1] = TCX_20; move16(); - overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame Q0*/ + overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame Q0*/ move16(); IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -247,7 +247,7 @@ void core_signal_analysis_high_bitrate_fx( move16(); } } - overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame Q0*/ + overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame Q0*/ move16(); } IF( NE_16( transform_type[0], TCX_20 ) ) @@ -650,7 +650,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( alw_voicing_wc = s_max( alw_voicing[0], alw_voicing[1] ); // Q15 } - overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame Q0*/ + overlap_mode[0] = last_overlap; /* Overlap between the last and the current frame Q0*/ move16(); IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) @@ -661,7 +661,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( move16(); transform_type[1] = TCX_20; move16(); - overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame Q0*/ + overlap_mode[1] = curr_overlap; /* Overlap between the current and the next frame Q0*/ move16(); IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -721,7 +721,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( move16(); } } - overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame Q0*/ + overlap_mode[2] = curr_overlap; /* Overlap between the current and the next frame Q0*/ move16(); } diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 4f2beb880..163519314 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -176,7 +176,7 @@ void initFdCngEnc_fx( void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bandwidth, /* i: bandwidth Q0*/ + const Word16 bandwidth, /* i: bandwidth Q0*/ const Word32 bitrate /* Q0 */ ) { @@ -559,7 +559,7 @@ void resetFdCngEnc_fx( Returns: void */ -void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ +void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ Word16 band_energies_exp, /* i: exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ Word32 *enerBuffer, /* enerBuffer_exp */ Word16 enerBuffer_exp, @@ -723,17 +723,17 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in void */ Word16 AdjustFirstSID_fx( - Word16 npart, /* i : number of parts Q0*/ - Word32 *msPeriodog, /* i : pointer to periodog vector msPeriodog_exp */ - Word16 msPeriodog_exp, /* i : exponent of periodog vector */ - Word32 *energy_ho, /* i/o : pointer to energy energy_ho_exp*/ - Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */ - Word32 *msNoiseEst, /* i/o : pointer to estimated noise msNoiseEst_exp*/ - Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */ - Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise msNoiseEst_old_exp*/ - Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */ - Word16 *active_frame_counter, /* i/o : pointer to active frame counter Q0*/ - Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */ + Word16 npart, /* i : number of parts Q0*/ + Word32 *msPeriodog, /* i : pointer to periodog vector msPeriodog_exp */ + Word16 msPeriodog_exp, /* i : exponent of periodog vector */ + Word32 *energy_ho, /* i/o : pointer to energy energy_ho_exp*/ + Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */ + Word32 *msNoiseEst, /* i/o : pointer to estimated noise msNoiseEst_exp*/ + Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */ + Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise msNoiseEst_old_exp*/ + Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */ + Word16 *active_frame_counter, /* i/o : pointer to active frame counter Q0*/ + Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */ ) { Word16 i, sc, s1, s2, lambda, lambdaM1, invFac; @@ -866,7 +866,7 @@ Word16 AdjustFirstSID_fx( void */ static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) scaled with 8 bits Q9.7*/ - Word16 u[], /* i : Vector to be encoded (prediction and mean removed) Q9.7*/ + Word16 u[], /* i : Vector to be encoded (prediction and mean removed) Q9.7*/ const Word16 levels[], /* i : Number of levels in each stage Q0*/ Word16 maxC, /* i : Tree search size Q0*/ Word16 stages, /* i : Number of stages Q0*/ @@ -2155,7 +2155,7 @@ Word16 cng_energy_ivas_fx( const Word16 element_mode, /* i : element mode Q0*/ const Word16 bwidth, /* i : audio bandwidh Q0*/ const Word16 CNG_mode, /* i : mode for DTX configuration Q0*/ - const Word16 CNG_att, /* i : attenuation factor for CNG Q7*/ + const Word16 CNG_att, /* i : attenuation factor for CNG Q7*/ const Word16 *exc, /* i : input signal Q_new*/ const Word16 len, /* i : vector length */ const Word16 Q_new /* i : Input scaling */ @@ -2242,7 +2242,7 @@ Word16 cng_energy_ivas_fx( } void perform_noise_estimation_enc_ivas_fx( - Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ + Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ Word16 band_energies_exp, Word32 *enerBuffer, /* enerBuffer_exp */ Word16 enerBuffer_exp, @@ -3339,7 +3339,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx( extend_dctN_input_fx( ms_ptr_fx[0], dct_target_fx, N[0], tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ - Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 Q23*/ + Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 Q23*/ } create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); @@ -3395,7 +3395,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx( { pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ pow = L_add( ms_ptr_fx[ch][p], pow ); /* Q31 - ms_ptr_e */ - pow = Mpy_32_32( pow, 214748365 /* 0.1 in Q31 */ ); /*pow = 0.1 Q31 - ms_ptr_e*/ + pow = Mpy_32_32( pow, 214748365 /* 0.1 in Q31 */ ); /*pow = 0.1 Q31 - ms_ptr_e*/ lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); tmp_e = s_max( tmp_e, e_lr_out[p] ); } diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 2d0929e04..fee21e2cf 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -20,7 +20,7 @@ void find_targets_fx( const Word16 *res, /* i : residual signal Q_new*/ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/ const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/ - Word16 tilt_fac, /* i : tilt factor Q15*/ + Word16 tilt_fac, /* i : tilt factor Q15*/ Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/ Word16 *cn, /* o : target vector in residual domain Q_new*/ Word16 *h1 /* o : impulse response of weighted synthesis filter Q14*/ @@ -167,7 +167,7 @@ void find_targets_ivas_fx( const Word16 *res, /* i : residual signal Q_new*/ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0*/ const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/ - Word16 tilt_fac, /* i : tilt factor Q15*/ + Word16 tilt_fac, /* i : tilt factor Q15*/ Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/ Word16 *cn, /* o : target vector in residual domain Q_new*/ Word16 *h1 /* o : impulse response of weighted synthesis filter Q(14 - norm_s(h1[0]))*/ diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index e26704099..98e5a220a 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -16,19 +16,19 @@ *-------------------------------------------------------------------*/ void find_tilt_fx( - const Word32 fr_bands[], /* i : energy in frequency bands Q_new + Q_SCALE*/ - const Word32 bckr[], /* i : per band background noise energy estimate Q_new + Q_SCALE*/ - Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/ - const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/ - const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/ + const Word32 fr_bands[], /* i : energy in frequency bands Q_new + Q_SCALE*/ + const Word32 bckr[], /* i : per band background noise energy estimate Q_new + Q_SCALE*/ + Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/ + const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/ + const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/ const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE - 2*/ - const Word16 corr_shift, /* i : normalized correlation correction Q15*/ - const Word16 bwidth, /* i : input signal bandwidth Q0*/ - const Word16 max_band, /* i : maximum critical band Q0*/ + const Word16 corr_shift, /* i : normalized correlation correction Q15*/ + const Word16 bwidth, /* i : input signal bandwidth Q0*/ + const Word16 max_band, /* i : maximum critical band Q0*/ Word32 hp_E[], /* o : energy in HF Q_new + Q_SCALE*/ - const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/ - const Word16 Q_new, /* i : scaling factor */ - Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16*/ + const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/ + const Word16 Q_new, /* i : scaling factor */ + Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16*/ Word16 Opt_vbr_mode /* Q0 */ ) { @@ -216,7 +216,7 @@ void find_tilt_fx( Ltmp = L_shl_sat( ee[i], 3 ); IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ { - Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ + Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ ee[i] = L_shl_sat( Ltmp, 3 ); move32(); /* x8 */ } @@ -240,16 +240,16 @@ void find_tilt_fx( * Find LF/HF energy ratio *-------------------------------------------------------------------*/ void find_tilt_ivas_fx( - const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/ - const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/ + const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/ + const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/ const Word32 bckr[], /* i : per band background noise energy estimate q_bckr*/ const Word16 q_bckr, /* i : Q of bckr Q0*/ - Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/ - const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/ - const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/ + Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/ + const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/ + const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/ const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E*/ const Word16 q_lf_E, /* i : Q of lf_E */ - const Word16 corr_shift, /* i : normalized correlation correction Q15*/ + const Word16 corr_shift, /* i : normalized correlation correction Q15*/ const Word16 bwidth, /* i : input signal bandwidth */ const Word16 max_band, /* i : maximum critical band */ Word32 hp_E[], /* o : energy in HF Q_new*/ @@ -413,7 +413,7 @@ void find_tilt_ivas_fx( lp_E = W_extract_h( W_shl( sum, q_lp_E ) ); // q_bckr+1+q_lp_E-32 q_lp_E = sub( add( q_lp_E, q_bckr ), Q31 ); - pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame Q_new - 1 */ + pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame Q_new - 1 */ } ELSE /* Other than high-pitched voiced frames */ { @@ -466,7 +466,7 @@ void find_tilt_ivas_fx( Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ { - Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ + Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */ move32(); /* x8 */ } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 8554b03dd..0a16f1467 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -23,9 +23,9 @@ * energy is trailing off after a spike *-------------------------------------------------------------------*/ -static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/ - const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/ - const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/ +static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/ + const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/ + const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/ ) { Word16 i, j, end, flag; @@ -83,20 +83,20 @@ static Word16 find_ener_decrease_fx( /* o : maximum * Decision about coder type *-------------------------------------------------------------------*/ -Word16 find_uv_fx( /* o : coding type */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ +Word16 find_uv_fx( /* o : coding type */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ + const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ + const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ + const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ const Word16 Q_new, - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ + Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ const Word16 shift, - const Word16 last_core_orig /* i : original last core Q0*/ + const Word16 last_core_orig /* i : original last core Q0*/ ) { Word16 coder_type, i; @@ -574,15 +574,15 @@ Word16 find_uv_fx( /* o : coding type */ *-------------------------------------------------------------------*/ Word16 find_uv_ivas_fx( /* o : coding type */ Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ + const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ + const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ + const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ + const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF q_hp_E*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF q_hp_E*/ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index 155e49904..b3a0dc9e6 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -14,12 +14,12 @@ * find_wsp_fx * * Parameters: - * Az I: A(z) filter coefficients Q12 + * Az I: A(z) filter coefficients Q12 * speech I: pointer to the denoised speech frame Q_new - preemph_bits * wsp O: pointer to the weighted speech frame Q_new - preemph_bits - * mem_wsp I/O: W(z) denominator memory + * mem_wsp I/O: W(z) denominator memory * preemph_fac I: pre-emphasis factor Q15 - * L_frame I: length of the frame + * L_frame I: length of the frame * lookahead I: length of a look-ahead * L_subfr I: length of the sub-frame * @@ -30,17 +30,17 @@ * void */ void find_wsp_fx( - const Word16 Az[], /* i : A(z) filter coefficients Q12*/ - const Word16 speech[], /* i : pointer to the denoised speech frame Q_new-preemph_bits*/ - Word16 wsp[], /* o : poitnter to the weighted speech frame Q_new-preemph_bits*/ - Word16 *mem_wsp, /* i/o: W(Z) denominator memory Q_new-preemph_bits*/ - const Word16 preemph_fac, /* i : pre - emphasis factor Q15*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 lookahead, /* i : look-ahead Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - Word16 *Aw, /* o : weighted A(z) filter coefficients Q12*/ - const Word16 gamma, /* i : weighting factor Q15*/ - const Word16 nb_subfr /* i : number of subframes Q0*/ + const Word16 Az[], /* i : A(z) filter coefficients Q12*/ + const Word16 speech[], /* i : pointer to the denoised speech frame Q_new-preemph_bits*/ + Word16 wsp[], /* o : poitnter to the weighted speech frame Q_new-preemph_bits*/ + Word16 *mem_wsp, /* i/o: W(Z) denominator memory Q_new-preemph_bits*/ + const Word16 preemph_fac, /* i : pre - emphasis factor Q15*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 lookahead, /* i : look-ahead Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + Word16 *Aw, /* o : weighted A(z) filter coefficients Q12*/ + const Word16 gamma, /* i : weighting factor Q15*/ + const Word16 nb_subfr /* i : number of subframes Q0*/ ) { Word16 i_subfr, wtmp; diff --git a/lib_enc/frame_spec_dif_cor_rate_fx.c b/lib_enc/frame_spec_dif_cor_rate_fx.c index 9678acdbf..e80f666d9 100644 --- a/lib_enc/frame_spec_dif_cor_rate_fx.c +++ b/lib_enc/frame_spec_dif_cor_rate_fx.c @@ -20,10 +20,10 @@ * *-------------------------------------------------------------------*/ void frame_spec_dif_cor_rate_fx( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - Word32 *spec_amp, /* i : spectral amplitude scale*/ - Word16 sacle, /* i : the scaling of spec_amp */ - Word16 f_tonality_rate[3] /* o : tonality rate Qx*/ + VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ + Word32 *spec_amp, /* i : spectral amplitude scale*/ + Word16 sacle, /* i : the scaling of spec_amp */ + Word16 f_tonality_rate[3] /* o : tonality rate Qx*/ ) { diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index e84d09e3c..c6e8c7276 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -32,12 +32,12 @@ static Word16 Find_Opt_gainQ_fx( Word16 *coeff, Word16 *exp_coeff, Word16 *gain_ /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* _ Word16 L_frame, i : length of the frame Q0 */ -/* _ Word16 *res, i : residual signal Q_new */ +/* _ Word16 *res, i : residual signal Q_new */ /* _ Word16 *voicing, i : normalized correlation in three 1/2frames Q15*/ -/* _ Word16 coder_type, i : coder_type Q0 */ -/* _ Word16 bwidth, i : input signal bandwidth Q0 */ -/* _ Word32 core_brate, i : core bitrate Q0 */ -/* _ Word16 Q_new i : Scaling in speech Q0 */ +/* _ Word16 coder_type, i : coder_type Q0 */ +/* _ Word16 bwidth, i : input signal bandwidth Q0 */ +/* _ Word32 core_brate, i : core bitrate Q0 */ +/* _ Word16 Q_new i : Scaling in speech Q0 */ /*--------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* _ Word16 *Es_pred, o : predicited scaled innovation energy Q8 */ @@ -51,14 +51,14 @@ static Word16 Find_Opt_gainQ_fx( Word16 *coeff, Word16 *exp_coeff, Word16 *gain_ /*==========================================================================*/ void Es_pred_enc_fx( - Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ - Word16 *indice, /* o : indice of quantization Q0*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 *res, /* i : residual signal Q_new*/ - const Word16 *voicing, /* i : normalized correlation in three 1/2frames Q15*/ - const Word16 nb_bits, /* i : allocated number of bits Q0*/ - const Word16 no_ltp, /* i : no_ltp flag Q0*/ - Word16 Q_new /* i : Scaling in speech Q0*/ + Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ + Word16 *indice, /* o : indice of quantization Q0*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 *res, /* i : residual signal Q_new*/ + const Word16 *voicing, /* i : normalized correlation in three 1/2frames Q15*/ + const Word16 nb_bits, /* i : allocated number of bits Q0*/ + const Word16 no_ltp, /* i : no_ltp flag Q0*/ + Word16 Q_new /* i : Scaling in speech Q0*/ ) { Word16 i, i_subfr, size, tmp16, tmp16_2, Q_res; @@ -88,11 +88,11 @@ void Es_pred_enc_fx( FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) { /* calculate the energy of residual signal */ - tmp16 = mult_r( res[i_subfr + 0], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ + tmp16 = mult_r( res[i_subfr + 0], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ ener_fx = L_mult( tmp16, tmp16 ); FOR( i = 1; i < L_SUBFR; i++ ) { - tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ + tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ ener_fx = L_mac_sat( ener_fx, tmp16, tmp16 ); } @@ -200,24 +200,24 @@ void Es_pred_enc_fx( * - the mean-squared weighted error criterion is used for codebook search *---------------------------------------------------------------------*/ void gain_enc_mless_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 scaling */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ ) { @@ -541,21 +541,21 @@ void gain_enc_mless_fx( *---------------------------------------------------------------------*/ void gain_enc_SQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 Q_xn /* i : xn and y1 scaling */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 Q_xn /* i : xn and y1 scaling */ ) { Word16 index, nBits_pitch, nBits_code; @@ -821,9 +821,9 @@ void gain_enc_SQ_fx( Word16 gain_enc_gaus_fx( Word32 *gain, /* i/o: Code gain to quantize Q16*/ const Word16 bits, /* i : number of bits to quantize Q0*/ - const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ - const Word16 stepSize, /* i : Step size choice Q14*/ - const Word16 inv_stepSize /* i : Step size choice Q15*/ + const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ + const Word16 stepSize, /* i : Step size choice Q14*/ + const Word16 inv_stepSize /* i : Step size choice Q15*/ ) { Word16 index, exp_gain, frac_gain, wtmp; @@ -878,7 +878,7 @@ Word16 gain_enc_gaus_fx( *-----------------------------------------------------------------*/ void gain_enc_tc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ const Word16 i_subfr, /* i : subframe index Q0*/ const Word16 xn_fx[], /* i : target vector Q_xn*/ @@ -889,7 +889,7 @@ void gain_enc_tc_fx( Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ Word16 *gain_inov_fx, /* o : innovation gain Q12*/ Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - const Word16 Q_xn /* i : xn and y1 scaling */ + const Word16 Q_xn /* i : xn and y1 scaling */ ) { Word16 i, index = 0, nBits, num, den, exp_num, exp_den; @@ -1079,8 +1079,8 @@ static Word16 Find_Opt_gainQ_fx( Word32 *gain_code, /* Q16 */ Word16 gcode0, /* exp(exp_gcode0) */ Word16 exp_gcode0, - const Word16 *cdbk, /* i : Codebook used Q14*/ - const Word16 size /* i : size of Codebook used Q0*/ + const Word16 *cdbk, /* i : Codebook used Q14*/ + const Word16 size /* i : size of Codebook used Q0*/ ) { Word16 index, i, j; @@ -1224,7 +1224,7 @@ static Word16 Find_Opt_gainQ_fx( *---------------------------------------------------------------------*/ void gain_enc_lbr_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ const Word16 coder_type, /* i : coding type Q0*/ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -1240,9 +1240,9 @@ void gain_enc_lbr_fx( Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 L_subfr, /* i : subframe length Q0*/ - const Word16 element_mode /* i : mode element Q0*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 L_subfr, /* i : subframe length Q0*/ + const Word16 element_mode /* i : mode element Q0*/ ) { Word16 index = 0, size, nBits, n_pred, ctype; @@ -1695,20 +1695,20 @@ void gain_enc_lbr_fx( *-------------------------------------------------------------------*/ void gain_enc_amr_wb_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 Q_xn, /* i : xn and yy1 format */ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 Q_xn, /* i : xn and yy1 format */ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ ) { diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index fb93a6743..7f192192b 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -40,22 +40,22 @@ static void gauss2v_fx( BSTR_ENC_HANDLE hBstr, const Word16 h[], const Word16 xn *-------------------------------------------------------------------*/ Word16 gaus_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ ) { Word16 nb_bits, idx; @@ -259,7 +259,7 @@ void gauss2v_fx( Den = extract_h( L_shl( Lden, exp_den ) ); delta = shr_sat( div_s( Num, Den ), sub( exp_num, exp_den ) ); /* Q15 */ - delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ + delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); @@ -601,12 +601,12 @@ void gauss2v_fx( /*---------------------------------------------------------------------* * Put selected codevector positions and signs into quantization index *---------------------------------------------------------------------*/ -static Word16 cod_2pos_fx( /* o : codebook quantization index */ - const Word16 ind1, /* i : index of 1st gaussian vector Q0*/ - const Word16 ind2, /* i : index of 2nd gaussian vector Q0*/ - const Word16 sign1, /* i : sign of 1st gaussian vector Qx*/ - const Word16 sign2, /* i : sign of 2nd gaussian vector Qx*/ - const Word16 n /* i : nb. of codebook vectors Q0*/ +static Word16 cod_2pos_fx( /* o : codebook quantization index */ + const Word16 ind1, /* i : index of 1st gaussian vector Q0*/ + const Word16 ind2, /* i : index of 2nd gaussian vector Q0*/ + const Word16 sign1, /* i : sign of 1st gaussian vector Qx*/ + const Word16 sign2, /* i : sign of 2nd gaussian vector Qx*/ + const Word16 n /* i : nb. of codebook vectors Q0*/ ) { Word16 i1, i2, index, s1, s2; diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index 07b88103b..40b004e0f 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -68,7 +68,7 @@ * Pitch Gain clipping initializations *-------------------------------------------------------------------*/ void init_gp_clip_fx( - Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ ) { mem[0] = DIST_ISF_MAX; @@ -272,10 +272,10 @@ void gp_clip_test_isf_fx( *-------------------------------------------------------------------*/ void gp_clip_test_gain_pit_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ - Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ + Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ ) { Word16 gain; @@ -416,10 +416,10 @@ Word16 Mode2_gp_clip_fx( * check the minimum distance of LSFs for pitch gain clipping flag *-------------------------------------------------------------------*/ void gp_clip_test_lsf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 m /* i : dimension of lsf Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 m /* i : dimension of lsf Q0*/ ) { Word16 i; diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 43036184e..f8479275f 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -24,21 +24,21 @@ static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, Word16 Qnew ); *-------------------------------------------------------------------*/ void encod_audio_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 speech[], /* i : input speech Q_new */ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12 */ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12 */ - const Word16 *res, /* i : residual signal Q_new */ - Word16 *synth, /* i/o: core synthesis Q-1 */ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new */ - Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ - Word16 *voice_factors, /* o : voicing factors Q15 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ - const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC) */ - Word16 *lsf_new, /* i : current frame ISF vector Qx2.56 */ - Word16 *tmp_noise, /* o : noise energy Q2*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 speech[], /* i : input speech Q_new */ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12 */ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12 */ + const Word16 *res, /* i : residual signal Q_new */ + Word16 *synth, /* i/o: core synthesis Q-1 */ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new */ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ + Word16 *voice_factors, /* o : voicing factors Q15 */ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ + const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC) */ + Word16 *lsf_new, /* i : current frame ISF vector Qx2.56 */ + Word16 *tmp_noise, /* o : noise energy Q2 */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0 */ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6 */ Word16 Q_new, Word16 shift ) { @@ -392,18 +392,18 @@ void encod_audio_fx( } void encod_audio_ivas_fx( - Encoder_State *st_fx, /* i/o: State structure */ + Encoder_State *st_fx, /* i/o: State structure */ const Word16 speech[], /* i : input speech Q_new */ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12 */ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12 */ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12 */ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12 */ const Word16 *res, /* i : residual signal Q_new */ Word16 *synth, /* i/o: core synthesis Q-1 */ Word16 *exc, /* i/o: current non-enhanced excitation Q_new */ - Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ - Word16 *voice_factors, /* o : voicing factors Q15 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ - const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC) */ - Word16 *lsf_new, /* i : current frame ISF vector Qx2.56 */ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ + Word16 *voice_factors, /* o : voicing factors Q15 */ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ + const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC)*/ + Word16 *lsf_new, /* i : current frame ISF vector Qx2.56 */ Word16 *tmp_noise, /* o : noise energy Q8*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ @@ -769,27 +769,27 @@ void encod_audio_ivas_fx( } /*================================================================================*/ -/* FUNCTION : void gsc_enc_fx () */ +/* FUNCTION : void gsc_enc_fx () */ /*--------------------------------------------------------------------------------*/ /* PURPOSE : Generic audio signal encoder */ /*--------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) res_dct_in : dct of residual signal Q_exc */ -/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) res_dct_in : dct of residual signal Q_exc */ +/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) bits_used : Number of bit used before frequency Q Q0 */ /* _ (Word16) nb_subfr : Number of subframe considered Q0 */ -/* _ (Word16) Qexc : Q format of exc_dct_in */ +/* _ (Word16) Qexc : Q format of exc_dct_in */ /*--------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /* Encoder_State *st_fx:Encoder State Structure */ /* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Q_exc */ /*--------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _None */ +/* RETURN ARGUMENTS : */ +/* _None */ /*================================================================================*/ @@ -1302,24 +1302,24 @@ void gsc_enc_ivas_fx( } /*======================================================================*/ -/* FUNCTION : edyn_fx() */ +/* FUNCTION : edyn_fx() */ /*----------------------------------------------------------------------*/ -/* PURPOSE : Calculate energy dynamics in a vector */ -/* (ratio of energy maximum to energy mean) */ -/* */ +/* PURPOSE : Calculate energy dynamics in a vector */ +/* (ratio of energy maximum to energy mean) */ +/* */ /*----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16 *) vec : ratio of max to mean Qnew */ -/* _ (Word16) lvec : input vector */ -/* _ (Word16) Q_new : */ +/* INPUT ARGUMENTS : */ +/* _ (Word16 *) vec : ratio of max to mean Qnew */ +/* _ (Word16) lvec : input vector */ +/* _ (Word16) Q_new : */ /*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16) dyn : ratio of energy maximum to energy mean (Q7) */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16) dyn : ratio of energy maximum to energy mean (Q7) */ /*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*=======================================================================*/ static Word16 edyn_fx( /* o : ratio of max to mean */ diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 25dfa2534..25887d71c 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -4087,12 +4087,12 @@ void IGFEncResetTCX10BitCounter_fx( void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ - Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx buffer */ + Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx buffer */ const Word16 igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ - Word16 e_mdct, /* i : exponent of pMDCTspectrum */ + Word16 e_mdct, /* i : exponent of pMDCTspectrum */ Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *e_ps, /* i : exponent of pPowerSpectrum */ + Word16 *e_ps, /* i : exponent of pPowerSpectrum */ const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ const Word8 isTNSActive, /* i : flag indicating if the TNS is active */ const Word16 sp_aud_decision0, /* i : first stage switching decision */ diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 536cf1479..5b228c2ed 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -13,47 +13,46 @@ /*==============================================================================*/ -/* FUNCTION : inov_encode_fx() */ +/* FUNCTION : inov_encode_fx() */ /*------------------------------------------------------------------------------*/ -/* PURPOSE : Encode the algebraic innovation */ +/* PURPOSE : Encode the algebraic innovation */ /*------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) core_brate: core bitrate Q0 */ -/* _ (Word16) Opt_AMR_WB: flag indicating AMR-WB IO mode Q0 */ -/* _ (Word16) bwidth : input signal bandwidth Q0 */ -/* _ (Word16) L_frame_fx : length of the frame Q0 */ -/* _ (Word16[]) h2 : weighted filter input response Q12 */ -/* _ (Word16[]) xn2 : target vector Q_new */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) i_subfr : current sub frame indicator Q0 */ -/* _ (Word16[]) exc_fx : pointer to excitation signal frame Q_new */ -/* _ (Word16) L_subfr : subframe length Q0 */ -/* _ (Word16) clip_gain : adaptive gain clipping flag Q0 */ -/* _ (Word16) gain_pit : adaptive excitation gain Q14 */ -/* _ (Word16) sharpFlag : formant sharpening flag Q0 */ -/* _ (Word16) tc_subfr : TC subframe index Q0 */ -/* _ (Word16) p_Aq : LP filter coefficients Q12 */ -/* _ (Word16) Jopt_flag :joint optimization flag Q0 */ -/* _ (Word16) y1 : Filtered adaptive excitation Q_new */ -/* _ (Word16) y2 :zero-memory filtered algebraic excitation Q_new */ -/* _ (Word16) cn : target vector in residual domain Q_new */ -/* _ (Word16) tilt_code : tilt of the excitation of previous subframe Q15 */ -/* _ (Word16) pt_pitch : pointer to current subframe fractional pitchQ6 */ -/* _ (Word16) index_buf_4T :5Sx4Track buffer for PI Q0 */ -/* _ (Word16) shift :shift */ -/* _ (Word16) Q_new : */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) core_brate: core bitrate Q0 */ +/* _ (Word16) Opt_AMR_WB: flag indicating AMR-WB IO mode Q0 */ +/* _ (Word16) bwidth : input signal bandwidth Q0 */ +/* _ (Word16) L_frame_fx: length of the frame Q0 */ +/* _ (Word16[]) h2 : weighted filter input response Q12 */ +/* _ (Word16[]) xn2 : target vector Q_new */ +/* _ (Word16) coder_type: coding type Q0 */ +/* _ (Word16) i_subfr : current sub frame indicator Q0 */ +/* _ (Word16[]) exc_fx : pointer to excitation signal frame Q_new */ +/* _ (Word16) L_subfr : subframe length Q0 */ +/* _ (Word16) clip_gain : adaptive gain clipping flag Q0 */ +/* _ (Word16) gain_pit : adaptive excitation gain Q14 */ +/* _ (Word16) sharpFlag : formant sharpening flag Q0 */ +/* _ (Word16) tc_subfr : TC subframe index Q0 */ +/* _ (Word16) p_Aq : LP filter coefficients Q12 */ +/* _ (Word16) Jopt_flag :joint optimization flag Q0 */ +/* _ (Word16) y1 : Filtered adaptive excitation Q_new */ +/* _ (Word16) y2 :zero-memory filtered algebraic excitation Q_new */ +/* _ (Word16) cn : target vector in residual domain Q_new */ +/* _ (Word16) tilt_code : tilt of the excitation of previous subframe Q15 */ +/* _ (Word16) pt_pitch : pointer to current subframe fractional pitchQ6 */ +/* _ (Word16) index_buf_4T :5Sx4Track buffer for PI Q0 */ +/* _ (Word16) shift :shift */ +/* _ (Word16) Q_new : */ /*------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ -/* _ (Word16) cn : target vector in residual domain Q_new */ -/* _ (Word16) code :algebraic excitation Q9 */ -/* _ (Word16) y2 :zero-memory filtered algebraic excitation Q_new */ -/* _ (Word16) unbits :number of unused bits for PI Q0 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ +/* _ (Word16) cn : target vector in residual domain Q_new */ +/* _ (Word16) code :algebraic excitation Q9 */ +/* _ (Word16) y2 :zero-memory filtered algebraic excitation Q_new */ +/* _ (Word16) unbits :number of unused bits for PI Q0 */ /*------------------------------------------------------------------------------*/ - /*------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*==============================================================================*/ Word16 inov_encode_fx( diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index d03f58ed5..96bbca887 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -60,13 +60,13 @@ ivas_error ivas_core_enc_fx( Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/ Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/ Word16 Q_new[], /* i : Q factor of speech buffers */ - Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/ + Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/ Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/ + Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/ Word16 epsP_fx_q[], /* i : LP prediction errors */ - Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/ + Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/ const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/ Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/ Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/ @@ -74,14 +74,14 @@ ivas_error ivas_core_enc_fx( Word16 *q_re_im_buf, /* i : Q factor of re/im CLDFB buffers */ Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/ Word16 e_old_wsp[], /* i : Q factor of old_wsp buffer */ - const Word16 loc_harm[], /* i : harmonicity flag Q0*/ - const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/ - const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/ + const Word16 loc_harm[], /* i : harmonicity flag Q0*/ + const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/ + const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/ Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ Word16 enerBuffer_fx_exp[], /* o : energy buffer */ - Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/ - const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/ - const Word16 ivas_format, /* i : IVAS format Q0*/ + Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/ + const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/ + const Word16 ivas_format, /* i : IVAS format Q0*/ const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ ) { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 0a12c05ea..efa5e9a0a 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -77,58 +77,58 @@ static Word16 get_zero_flag( Word32 arr[], Word16 len ) } ivas_error pre_proc_front_ivas_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ - const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 n, /* i : channel number Q0*/ + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ + const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 n, /* i : channel number Q0*/ Word16 old_inp_12k8_fx[], /* o : buffer of old input signal (st->Q_inp until preemph, then Q_new, then Q_new-1 towards the end)*/ - Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 *relE_fx, /* o : frame relative energy Q8*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ + Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 *relE_fx, /* o : frame relative energy Q8*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ + Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ Word16 *epsP_fx_q, - Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ - Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ - Word16 *attack_flag, /* o : flag signaling attack Q0*/ - Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/ - Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/ - Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ - Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ + Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ + Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ + Word16 *attack_flag, /* o : flag signaling attack Q0*/ + Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/ + Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/ + Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ + Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ Word16 *q_old_wsp, - Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ - Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ - Word16 *loc_harm, /* o : harmonicity flag Q0*/ - Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ - Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ - Word16 *enerBuffer_fx_exp, /* o : energy buffer */ - Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ - Word16 *fft_buff_fx_q, /* o : FFT buffer */ - const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ - const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ - const Word32 currFlatness_fx, /* i : flatness parameter Q21*/ - const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ - Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ + Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ + Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ + Word16 *loc_harm, /* o : harmonicity flag Q0*/ + Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ + Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ + Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ + Word16 *enerBuffer_fx_exp, /* o : energy buffer */ + Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ + Word16 *fft_buff_fx_q, /* o : FFT buffer */ + const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ + const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ + const Word32 currFlatness_fx, /* i : flatness parameter Q21*/ + const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ + Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ Word16 fr_bands_LR_fx_q[CPE_CHANNELS], - const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ - Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ + const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ + Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ Word16 lf_E_LR_fx_q, - const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ - Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ + const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ + Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ Word16 band_energies_LR_fx_q, - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ - const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ - const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ + const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ + const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ + const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ - const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ + const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ Word16 *Q_new #ifdef DEBUG_MODE_INFO , @@ -595,7 +595,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - Copy_Scale_sig( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( Q_inp_const, st->q_inp ) ); /* memory for TD/DFT stereo switching Q_inp_const*/ + Copy_Scale_sig( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, st->inp_12k8_mem_stereo_sw_fx, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( Q_inp_const, st->q_inp ) ); /* memory for TD/DFT stereo switching Q_inp_const*/ st->mem_preemph_fx_q_inp = st->mem_preemph_DFT_fx_q_inp; /* st->q_inp */ move16(); @@ -1666,7 +1666,7 @@ ivas_error pre_proc_front_ivas_fx( *--------------------------------------------------------------------*/ static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - Word32 enerBuffer_dft_fx[], /* o : energy buffer() exp(enerBuffer_dft_e)*/ + Word32 enerBuffer_dft_fx[], /* o : energy buffer() exp(enerBuffer_dft_e)*/ const Word16 no_channels, /* i : no. of used CLDFB channels Q0*/ const Word32 input_Fs, /* i : input sampling rate Q0*/ Word16 enerBuffer_dft_e[] ) diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 5246e2026..840165824 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -49,30 +49,30 @@ * Decision matrix, Preprocessing at other Fs, core switching decision, ...) *--------------------------------------------------------------------*/ ivas_error pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word32 element_brate, /* i : element bitrate Q0*/ - const Word32 last_element_brate, /* i : last element bitrate Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ - Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ - Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ - Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ - Word16 *epsP_fx_q, /* i : LP prediction errors */ - Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ - Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ - Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ + const Word32 last_element_brate, /* i : last element bitrate Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ + Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ + Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ + Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ + Word16 *epsP_fx_q, /* i : LP prediction errors */ + Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ + Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ + Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ Word16 e_old_wsp, - const Word16 loc_harm, /* i : harmonicity flag Q0*/ - const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ + const Word16 loc_harm, /* i : harmonicity flag Q0*/ + const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */ Word16 e_enerBuffer, Word16 fft_buff_fx[2 * L_FFT], /* Qx */ @@ -527,7 +527,7 @@ ivas_error pre_proc_ivas_fx( sr_core_tmp = L_max( INT_FS_16k, st->sr_core ); } - L_look = NS2SA_FX2( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) Q0*/ + L_look = NS2SA_FX2( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) Q0*/ move16(); inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look; @@ -693,13 +693,13 @@ ivas_error ivas_compute_core_buffers_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/ - Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_old_inp_16k*/ + Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_old_inp_16k*/ const Word16 input_frame, /* i : frame length Q0*/ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 sr_core, /* i : core-coder sampling rate Q0*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r*/ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q14*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ Word32 epsP_fx[M + 1], /* i/o: LP prediction errors Q_r*/ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ @@ -957,7 +957,7 @@ ivas_error ivas_compute_core_buffers_fx( { IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { - Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching Q(-1) */ + Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching Q(-1) */ st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx; /* Q(-1) */ move16(); diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index ce2fa0d93..a277c965b 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -135,7 +135,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( tmp = 0; move16(); } - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = L_shr( st_ivas->hCPE[cpe_id]->element_brate, tmp ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/ + st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = L_shr( st_ivas->hCPE[cpe_id]->element_brate, tmp ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/ move32(); } } diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index da4bec541..d28b39227 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -62,13 +62,13 @@ static void stereo_mode_combined_format_enc_fx( const Encoder_Struct *st_ivas, C *-------------------------------------------------------------------*/ ivas_error ivas_cpe_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 cpe_id, /* i : CPE # identifier Q0*/ - Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx)*/ - Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx)*/ - Word16 q_data_fx, /* i : Q-factor of input signal for both channels */ - const Word16 input_frame, /* i : input frame length per channel Q0*/ - const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 cpe_id, /* i : CPE # identifier Q0*/ + Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx)*/ + Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx)*/ + Word16 q_data_fx, /* i : Q-factor of input signal for both channels */ + const Word16 input_frame, /* i : input frame length per channel Q0*/ + const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ Word16 Q_new_out[] ) { CPE_ENC_HANDLE hCPE; @@ -206,8 +206,8 @@ ivas_error ivas_cpe_enc_fx( IF( st_ivas->hMCT == NULL ) /*already updated before CPE call*/ { - sts[n]->input_bwidth = sts[n]->last_input_bwidth; /* updated in BWD Q0*/ - sts[n]->bwidth = sts[n]->last_bwidth; /* updated in BWD Q0*/ + sts[n]->input_bwidth = sts[n]->last_input_bwidth; /* updated in BWD Q0*/ + sts[n]->bwidth = sts[n]->last_bwidth; /* updated in BWD Q0*/ move16(); move16(); } @@ -691,7 +691,7 @@ ivas_error ivas_cpe_enc_fx( stereo_dft_enc_analyze_fx( sts, CPE_CHANNELS, input_frame, hCPE->hStereoDft, NULL, hCPE->hStereoDft->DFT_fx, hCPE->hStereoDft->DFT_fx_e, hCPE->input_mem_fx, hCPE->q_input_mem ); - sts[0]->total_brate = L_mult0( add( sts[0]->bits_frame_nominal, 10 ), FRAMES_PER_SEC ); /* add small overhead; st[0]->total_brate used in coder_type_modif() Q0*/ + sts[0]->total_brate = L_mult0( add( sts[0]->bits_frame_nominal, 10 ), FRAMES_PER_SEC ); /* add small overhead; st[0]->total_brate used in coder_type_modif() Q0*/ /* Update DFT Stereo memories */ stereo_dft_enc_update_fx( hCPE->hStereoDft, max_bwidth ); @@ -1461,12 +1461,12 @@ ivas_error create_cpe_enc_fx( IF( GT_16( st_ivas->nCPE, 1 ) ) { - st->total_brate = hCPE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/ + st->total_brate = hCPE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/ move32(); } ELSE { - st->total_brate = L_shr( hCPE->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/ + st->total_brate = L_shr( hCPE->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() Q0*/ move32(); } st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 3d1084b1d..42e2f446e 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -74,7 +74,7 @@ void ivas_decision_matrix_enc_fx( Encoder_State *st, /* i : encoder state structure */ const Word32 element_brate, /* i : element bitrate Q0*/ const Word16 fft_buff[], /* i : FFT buffer Qx*/ - const Word32 enerBuffer[], /* i : energy buffer enerBuffer_exp*/ + const Word32 enerBuffer[], /* i : energy buffer enerBuffer_exp*/ Word16 enerBuffer_exp, const Word16 last_element_mode /* i : last element mode Q0*/ ) @@ -573,11 +573,11 @@ void ivas_decision_matrix_enc_fx( *---------------------------------------------------------------------*/ void ivas_signaling_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word32 element_brate, /* i : element bitrate Q0*/ - const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel Q0*/ - const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag in TD stereo Q0*/ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ + const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel Q0*/ + const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag in TD stereo Q0*/ ) { Word16 ind; diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 9886b1cb7..0264a2199 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -316,15 +316,15 @@ ivas_error ivas_dirac_enc_fx( DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - Word32 *data_f_fx[], /* i/o: SBA channels Qx*/ - Word32 **pp_fr_real_fx, /* o : real freq domain values pp_fr_q*/ - Word32 **pp_fr_imag_fx, /* o : imag freq domain values pp_fr_q*/ + Word32 *data_f_fx[], /* i/o: SBA channels Qx*/ + Word32 **pp_fr_real_fx, /* o : real freq domain values pp_fr_q*/ + Word32 **pp_fr_imag_fx, /* o : imag freq domain values pp_fr_q*/ Word16 pp_fr_q, - const Word16 input_frame, /* i : input frame length Q0*/ - const Word16 dtx_vad, /* i : DTX vad flag Q0*/ - const IVAS_FORMAT ivas_format, /* i : ivas format */ + const Word16 input_frame, /* i : input frame length Q0*/ + const Word16 dtx_vad, /* i : DTX vad flag Q0*/ + const IVAS_FORMAT ivas_format, /* i : ivas format */ const Word16 nchan_transport, /* i : number of transport channels */ - const Word16 hodirac_flag, /* i : hodirac flag Q0*/ + const Word16 hodirac_flag, /* i : hodirac flag Q0*/ const Word16 shift ) { Word16 orig_dirac_bands; @@ -535,12 +535,12 @@ ivas_error ivas_dirac_enc_fx( *-------------------------------------------------------------------------*/ static Word16 ivas_dirac_get_mono_flag_fx( - const Word16 *band_grouping, /* i : Band grouping for estimation Q0*/ - Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal e_Cldfb*/ - Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal e_Cldfb*/ - Word16 e_Cldfb, /* i : Exponent of cldfb buffer */ - const Word16 nchan_ana, /* i : number of analysis channels Q0*/ - Word16 *mono_frame_count ) /* i/o: current number of mono frames count Q0*/ + const Word16 *band_grouping, /* i : Band grouping for estimation Q0*/ + Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal e_Cldfb*/ + Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal e_Cldfb*/ + Word16 e_Cldfb, /* i : Exponent of cldfb buffer */ + const Word16 nchan_ana, /* i : number of analysis channels Q0*/ + Word16 *mono_frame_count ) /* i/o: current number of mono frames count Q0*/ { Word16 brange[2]; Word16 i, j, ch_idx; @@ -733,9 +733,9 @@ void computeReferencePower_enc_fx_dirac( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal e_Cldfb*/ Word32 Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal e_Cldfb*/ - Word16 e_Cldfb, /* i : exponent of Cldfb buffer */ + Word16 e_Cldfb, /* i : exponent of Cldfb buffer */ Word32 *reference_power, /* o : Estimated power e_reference*/ - Word16 *e_reference, /* o : exponent of reference_power */ + Word16 *e_reference, /* o : exponent of reference_power */ const Word16 enc_param_start_band, /* i : first band to process Q0*/ const Word16 num_freq_bands, /* i : Number of frequency bands Q0*/ const IVAS_FORMAT ivas_format, /* i : ivas_format */ @@ -1151,7 +1151,7 @@ void ivas_dirac_param_est_enc_fx( } /* fill buffers of length "averaging_length" time slots for intensity and energy */ - hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % hDirAC->no_col_avg_diff ), 1 ); /* averaging_length = 32 Q0*/ + hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % hDirAC->no_col_avg_diff ), 1 ); /* averaging_length = 32 Q0*/ move16(); index = hDirAC->index_buffer_intensity; /* Q0 */ move16(); @@ -1464,7 +1464,7 @@ static void computeIntensityVector_enc_fx( const DIRAC_ENC_HANDLE hDirAC, Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* q_cldfb */ Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* q_cldfb */ - const Word16 enc_param_start_band, /* i : first band to process Q0*/ + const Word16 enc_param_start_band, /* i : first band to process Q0*/ const Word16 num_frequency_bands, /* Q0 */ Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS], /* q_intensity_real */ Word16 q_cldfb, diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index ae7d26e2e..32360fd41 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -60,12 +60,12 @@ static void ivas_band_cov_fx( Word32 **ppIn_FR_real, Word32 **ppIn_FR_imag, Word *------------------------------------------------------------------------*/ ivas_error ivas_spar_covar_enc_open_fx( - ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */ - ivas_filterbank_t *pFb, /* i/o: FB handle */ - const Word32 input_Fs, /* i : input sampling rate Q0*/ - const Word16 nchan_inp, /* i : number of input channels Q0*/ - const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */ - const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ + ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */ + ivas_filterbank_t *pFb, /* i/o: FB handle */ + const Word32 input_Fs, /* i : input sampling rate Q0*/ + const Word16 nchan_inp, /* i : number of input channels Q0*/ + const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ ) { ivas_enc_cov_handler_state_t *hCovState; diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index 4d8f99650..ffd32570f 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -50,9 +50,9 @@ * Principal IVAS encoder routine *-------------------------------------------------------------------*/ ivas_error ivas_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 *data, /* i : input signal Q0*/ - const Word16 n_samples /* i : number of input samples Q0*/ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 *data, /* i : input signal Q0*/ + const Word16 n_samples /* i : number of input samples Q0*/ ) { Word16 i, n, input_frame, n_samples_chan, nchan_inp /*, scale*/; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 99da0175f..35400f652 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -50,25 +50,25 @@ * Standalone front-VAD module *-----------------------------------------------------------------------------------------*/ ivas_error front_vad_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ - Encoder_State *st, /* i/o: encoder state structure */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word16 vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO Q0*/ - Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands q_fr_bands_fx*/ - Word16 q_fr_bands[], /* o : Q of fr_bands_fx */ - Word16 Etot_LR_fx[], /* o : total energy Left & Right channel Q8*/ - Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels q_lf_E*/ - Word16 q_lf_E[], /* o : Q of lf_E_fx */ - Word16 localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels Q0*/ - Word16 vad_hover_flag[], /* o : VAD hangover flag Q0*/ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ + Encoder_State *st, /* i/o: encoder state structure */ + const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ + FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word16 vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO Q0*/ + Word32 fr_bands_fx[][2 * NB_BANDS], /* o : energy in frequency bands q_fr_bands_fx*/ + Word16 q_fr_bands[], /* o : Q of fr_bands_fx */ + Word16 Etot_LR_fx[], /* o : total energy Left & Right channel Q8*/ + Word32 lf_E_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels q_lf_E*/ + Word16 q_lf_E[], /* o : Q of lf_E_fx */ + Word16 localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels Q0*/ + Word16 vad_hover_flag[], /* o : VAD hangover flag Q0*/ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN q_band_energies_LR */ - Word16 *q_band_energies_LR, /* o : Q of band_energies_LR_fx */ - Word32 *PS_out_fx, /* o : energy spectrum q_PS_out*/ - Word16 *q_PS_out, /* o : Q of PS_out_fx Q0*/ - Word16 *Bin_E_out_fx, /* o : log-energy spectrum of the current frame Q7*/ + Word16 *q_band_energies_LR, /* o : Q of band_energies_LR_fx */ + Word32 *PS_out_fx, /* o : energy spectrum q_PS_out*/ + Word16 *q_PS_out, /* o : Q of PS_out_fx Q0*/ + Word16 *Bin_E_out_fx, /* o : log-energy spectrum of the current frame Q7*/ Word16 Q_inp, Word16 *Q_buffer, Word16 Q_add, @@ -452,10 +452,10 @@ void front_vad_destroy_fx( * Standalone front-VAD module for SPAR *-----------------------------------------------------------------------------------------*/ ivas_error front_vad_spar_fx( - SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */ - const Word32 *omni_in, /* i : omnidirectional input signal Q11*/ - ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */ - const Word16 input_frame /* i : input frame length Q0*/ + SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */ + const Word32 *omni_in, /* i : omnidirectional input signal Q11*/ + ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */ + const Word16 input_frame /* i : input frame length Q0*/ ) { FRONT_VAD_ENC_HANDLE hFrontVad; diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 741a78dbc..ce623be9c 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -290,9 +290,9 @@ Word16 getNumChanAnalysis_fx( *-------------------------------------------------------------------*/ void copy_encoder_config_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st_fx, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ + Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ + Encoder_State *st_fx, /* o : encoder state structure */ + const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ ) { IF( flag_all ) @@ -486,7 +486,7 @@ ivas_error ivas_init_encoder_fx( nchan_inp_buff = add( nchan_inp_buff, 1 ); /* Q0 */ } - nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object Q0*/ + nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object Q0*/ } FOR( n = 0; n < nchan_inp_buff; n++ ) diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index bc2c83de1..3474b218b 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -219,8 +219,8 @@ Word16 ivas_ism_dtx_enc_fx( } /* estimate SID metadata bit-budget */ - nBits = add( nBits, 1 ); /* number of objects Q0*/ - nBits = add( nBits, 1 ); /* SID metadata flag Q0*/ + nBits = add( nBits, 1 ); /* number of objects Q0*/ + nBits = add( nBits, 1 ); /* SID metadata flag Q0*/ IF( EQ_16( md_diff_flag[ch], 1 ) ) { nBits = add( nBits, nBits_azimuth ); /* Q0 */ @@ -240,12 +240,12 @@ Word16 ivas_ism_dtx_enc_fx( FOR( ch = 0; ch < nchan_transport - 1; ch++ ) { - nBits_MD_max = sub( nBits_MD_max, nBits_coh ); /* coherence Q0*/ + nBits_MD_max = sub( nBits_MD_max, nBits_coh ); /* coherence Q0*/ } if ( GT_16( nchan_ism, 3 ) ) { - nBits_MD_max = sub( nBits_MD_max, 1 ); /* ism_mode flag Q0*/ + nBits_MD_max = sub( nBits_MD_max, 1 ); /* ism_mode flag Q0*/ } /* too many metadata bits -> switch to active coding */ @@ -430,10 +430,10 @@ void ivas_ism_get_sce_id_dtx_fx( * *-------------------------------------------------------------------*/ void ivas_ism_coh_estim_dtx_enc_fx( - ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ - SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ - const Word16 nchan_transport, /* i : number of transport channels Q0*/ - const Word16 input_frame /* i : input frame length Q0*/ + ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ + SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ + const Word16 nchan_transport, /* i : number of transport channels Q0*/ + const Word16 input_frame /* i : input frame length Q0*/ ) { Encoder_State *st, *st_id0; diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index d3aaa46ca..ea509dd10 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -49,12 +49,12 @@ * ISM CoreCoders encoding routine *-------------------------------------------------------------------*/ ivas_error ivas_ism_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - Word32 *data[], /* i : input signal [channels][samples] Q(q_data)*/ - Word16 q_data, /* i : Q-factor of input signal */ - const Word16 input_frame, /* i : input frame length per channel Q0*/ - Word16 *nb_bits_metadata, /* i : number of metadata bits Q0*/ - const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag Q0*/ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + Word32 *data[], /* i : input signal [channels][samples] Q(q_data)*/ + Word16 q_data, /* i : Q-factor of input signal */ + const Word16 input_frame, /* i : input frame length per channel Q0*/ + Word16 *nb_bits_metadata, /* i : number of metadata bits Q0*/ + const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag Q0*/ ) { SCE_ENC_HANDLE hSCE; diff --git a/lib_enc/ivas_rom_enc_fx.c b/lib_enc/ivas_rom_enc_fx.c index 793546c7a..1b7bed210 100644 --- a/lib_enc/ivas_rom_enc_fx.c +++ b/lib_enc/ivas_rom_enc_fx.c @@ -52,7 +52,7 @@ const Word16 unclr_isel_td[SIZE_UNCLR_ISEL_TD] = /* UNCLR classifier in TD stereo:: mean & scale for feature normalization */ const Word32 unclr_mean_td[SIZE_UNCLR_ISEL_TD] = /*Q15*/ { - 166277, 163748, 209465, 50557, 34744, 239251, 21, 1277892, 44, 19270 + 166277, 163748, 209465, 50557, 34744, 239251, 21, 1277892, 44, 19270 }; const Word32 unclr_scale_td[SIZE_UNCLR_ISEL_TD] = /*Q15*/ diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 93918b81e..ac1b561a8 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -16,7 +16,7 @@ * Compute relative energy, long-term average total noise energy and total active speech energy *-------------------------------------------------------------------*/ void ivas_long_enr_fx( - Encoder_State *st_fx, /* i/o: state structure */ + Encoder_State *st_fx, /* i/o: state structure */ const Word32 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q24 */ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover Q0*/ Word16 high_lpn_flag, /* i : sp/mus LPN flag Q0*/ @@ -153,7 +153,7 @@ void ivas_long_enr_fx( void long_enr_fx( - Encoder_State *st_fx, /* i/o: state structure */ + Encoder_State *st_fx, /* i/o: state structure */ const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q8*/ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover Q0*/ Word16 high_lpn_flag /* i : sp/mus LPN flag Q0*/ diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 4d6084c87..9e6cf3953 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -187,12 +187,12 @@ static Word16 adpt_enr_fx( const Word16 *exc, /* i : excitation vector Q_new */ const Word16 *h1, /* i : impuls response Q15 */ Word16 *y1, /* o : zero-memory filtered adpt. excitation 12 bits */ - const Word16 L_subfr, /* i : vector length */ - Word16 *gain, /* o : subframe adaptive gain Q14 */ + const Word16 L_subfr, /* i : vector length */ + Word16 *gain, /* o : subframe adaptive gain Q14 */ Word16 *g_corr, /* o : correlations for adptive gain mant/exp*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0 */ - const Word16 *xn, /* i : adaptive codebook target 12 bits Q_new-1+shift*/ - Word16 *xn2, /* o : algebraic codebook target 12 bits Q_new-1+shift*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0 */ + const Word16 *xn, /* i : adaptive codebook target 12 bit Q_new-1+shift*/ + Word16 *xn2, /* o : algebraic codebook target 12 bit Q_new-1+shift*/ Word16 *exp_ener, /* o : adaptive excitation energy exp */ Word16 use_prev_sf_pit_gain /* i : flag to use prev sf pitch gain or not */ ) diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index c0e02d6c2..0c3686fb0 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1562,11 +1562,11 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( *--------------------------------------------------------------------------*/ void midlsf_enc_fx( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 lsf[], /* i: lsf coefficients (3Q12) */ - Word16 *idx, /* o: codebook index */ - const Word16 lpcorder, /* i: order of the lpc */ + const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 lsf[], /* i: lsf coefficients (3Q12) */ + Word16 *idx, /* o: codebook index */ + const Word16 lpcorder, /* i: order of the lpc */ const Word32 *Bin_Ener_128_fx, // Q_ener const Word16 Q_ener, const Word8 narrowBand, @@ -1631,9 +1631,9 @@ void midlsf_enc_fx( } err = L_shl_sat( err, 2 ); - /* err = L_shl(err,Wscale); */ + /* err = L_shl(err,Wscale); */ err = Mult_32_16( err, LSF_1_OVER_256SQ ); - /* err = Mult_32_16(err,Wmult); */ + /* err = Mult_32_16(err,Wmult); */ IF( LT_32( err, err_min ) ) { diff --git a/lib_enc/ltd_stable_fx.c b/lib_enc/ltd_stable_fx.c index 036fe2a7e..d5fcefabe 100644 --- a/lib_enc/ltd_stable_fx.c +++ b/lib_enc/ltd_stable_fx.c @@ -72,7 +72,7 @@ void ltd_stable_fx( frame_energy_Sqr32 = L_shl( frame_energy_Sqr32, 16 ); Q_frames_power32 = add( Q_frames_power32, 16 ); - /* +0.1 */ + /* +0.1 */ IF( GE_16( Q_frames_power32, 40 ) ) { zerop001 = L_shr( CNT0P001, 1 ); @@ -317,7 +317,7 @@ void ltd_stable_fx( Qsum_dif32 = add( Qsum_apow32, leadingzero_tmp32 ); Qsum_dif32 = add( Qsum_dif32, leadingzero_tmp32 ); - /* +0.1 */ + /* +0.1 */ IF( GE_16( Qsum_apow32, 44 ) ) { zerop001 = L_shr( CNT0P0001, 1 ); @@ -444,7 +444,7 @@ void ltd_stable_fx( Qsum_dif32 = add( Qsum_apow32, leadingzero_tmp32 ); Qsum_dif32 = add( Qsum_dif32, leadingzero_tmp32 ); - /* +0.1 */ + /* +0.1 */ IF( GE_16( Qsum_apow32, 44 ) ) { zerop001 = L_shr( CNT0P0001, 1 ); diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 10d89ea75..2ed21e321 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -20,19 +20,19 @@ * Perform multi-harmonic analysis, information used for UV and VAD decision *---------------------------------------------------------------------*/ -/* o : frame multi-harmonicity (1-harmonic, 0-not) */ +/* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ const Word16 bwidth, /* i : input signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ Word16 *sp_floor, /* o: noise floor estimate Q7 */ Word16 S_map[] /* o : short-term correlation map Q7 */ ) @@ -361,18 +361,18 @@ Word16 multi_harm_fx( } -/* o : frame multi-harmonicity (1-harmonic, 0-not) */ +/* o : frame multi-harmonicity (1-harmonic, 0-not) */ Word16 multi_harm_ivas_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ const Word16 bwidth, /* i : input signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ Word16 *sp_floor, /* o: noise floor estimate Q7 */ Word16 S_map[] /* o : short-term correlation map Q7 */ ) diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index c20ec2479..0a5d28131 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -19,39 +19,39 @@ static void limit_T0_voiced2( Word16 res, const Word16 *T_op, Word16 *T0_min, Word16 *T0_min_frac, Word16 *T0_max, Word16 *T0_max_frac, Word16 pit_min, Word16 pit_max, Word16 i_subfr ); /*==============================================================================*/ -/* FUNCTION : pit_encode_fx() */ +/* FUNCTION : pit_encode_fx() */ /*------------------------------------------------------------------------------*/ -/* PURPOSE : Close-loop pitch lag search and pitch lag quantization */ -/* Adaptive excitation construction */ +/* PURPOSE : Close-loop pitch lag search and pitch lag quantization */ +/* Adaptive excitation construction */ /*------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) core_brate: core bitrate Q0 */ -/* _ (Word16) Opt_AMR_WB: flag indicating AMR-WB IO mode Q0 */ -/* _ (Word16) bwidth : input signal bandwidth Q0 */ -/* _ (Word16[]) T_op : open loop pitch estimates in current frame Q0 */ -/* _ (Word16) T0_min : lower limit for close-loop search Q0 */ -/* _ (Word16) T0_max : higher limit for close-loop search Q0 */ -/* _ (Word16) T0 : close loop integer pitch Q0 */ -/* _ (Word16) T0_frac : close loop fractional part of the pitch Q0 */ -/* _ (Word16) L_frame_fx : length of the frame Q0 */ -/* _ (Word16[]) h1 : weighted filter input response Q15 */ -/* _ (Word16[]) xn : target vector Q_new */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) i_subfr : current sub frame indicator Q0 */ -/* _ (Word16[]) exc_fx : pointer to excitation signal frame Q_new */ -/* _ (Word16[]) L_subfr : subframe length Q0 */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) core_brate: core bitrate Q0 */ +/* _ (Word16) Opt_AMR_WB: flag indicating AMR-WB IO mode Q0 */ +/* _ (Word16) bwidth : input signal bandwidth Q0 */ +/* _ (Word16[]) T_op : open loop pitch estimates in current frame Q0 */ +/* _ (Word16) T0_min : lower limit for close-loop search Q0 */ +/* _ (Word16) T0_max : higher limit for close-loop search Q0 */ +/* _ (Word16) T0 : close loop integer pitch Q0 */ +/* _ (Word16) T0_frac : close loop fractional part of the pitch Q0 */ +/* _ (Word16) L_frame_fx: length of the frame Q0 */ +/* _ (Word16[]) h1 : weighted filter input response Q15 */ +/* _ (Word16[]) xn : target vector Q_new */ +/* _ (Word16) coder_type: coding type Q0 */ +/* _ (Word16) i_subfr : current sub frame indicator Q0 */ +/* _ (Word16[]) exc_fx : pointer to excitation signal frame Q_new */ +/* _ (Word16[]) L_subfr : subframe length Q0 */ /*------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ -/* _ (Word16) T0_min : lower limit for close-loop search Q0 */ -/* _ (Word16) T0_max : higher limit for close-loop search Q0 */ -/* _ (Word16) T0 : close loop integer pitch Q0 */ -/* _ (Word16) T0_frac : close loop fractional part of the pitch Q0 */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16[]) exc_fx : adapt. excitation exc (Q0) */ +/* _ (Word16) T0_min : lower limit for close-loop search Q0 */ +/* _ (Word16) T0_max : higher limit for close-loop search Q0 */ +/* _ (Word16) T0 : close loop integer pitch Q0 */ +/* _ (Word16) T0_frac : close loop fractional part of the pitch Q0 */ /*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*==============================================================================*/ /* o : Fractional pitch for each subframe */ diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index 5e977c8f7..01f5b6a6b 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -36,40 +36,40 @@ static void erb_diff_fx( const Word16 *prev_erb, Word16 pl, const Word16 *curr_e /* INPUT ARGUMENTS : */ /* _ (Word16 []) curr_lpc_fx: LPC coefficients, Q12 */ /* _ (struct DTFS_STRUCTURE_FX) CURRCW_NQ_FX : prototype in Cartesian domain */ -/* (Word16) lag_fx: length of prototype */ -/* (Word16 []) a/b: harmonics, normalized */ -/* (Word16) Q: norm factor of a */ +/* (Word16) lag_fx: length of prototype */ +/* (Word16 []) a/b: harmonics, normalized */ +/* (Word16) Q: norm factor of a */ /* _ (struct DTFS_STRUCTURE_FX) PREV_CW_E_FX : past dtfs in Cartesian domain */ -/* (Word16) lag: length of prototype */ -/* (Word16 []) a/b: harmonics, normalized */ -/* (Word16) Q: norm factor of a */ -/* _ (Word16) prevCW_lag_fx: Previous lag, Q0 */ -/* _ (Word16 *) exc : Global input (Q0) */ +/* (Word16) lag: length of prototype */ +/* (Word16 []) a/b: harmonics, normalized */ +/* (Word16) Q: norm factor of a */ +/* _ (Word16) prevCW_lag_fx: Previous lag, Q0 */ +/* _ (Word16 *) exc : Global input (Q0) */ /* _ (Word16 []) sinTab, Q15 : sin(2pi/4L*n), n=0,1,...,4L-1 */ /* _ (Word16 []) cosTab, Q15 : cos(2pi/4L*n), n=0,1,...,4L-1 */ /*---------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16) pidx: Power index */ -/* _ (Word16[]) aidx: Amplitude indices, 2 words */ -/* _ (struct DTFS_fx *) CURRCW_Q_FX : quantized prototype in Cartesian domain */ -/* (Word16) lag_fx: length of prototype in time domain */ -/* (Word16 []) a/b: harmonics, normalized */ -/* (Word16) Q: norm factor of a */ -/* _ (struct DTFS_fx *) TARGETCW_FX : Target prototype in Cartesian domain */ -/* (Word16) lag_fx: length of prototype in time domain */ -/* (Word16 []) a/b: harmonics, normalized */ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16) pidx: Power index */ +/* _ (Word16[]) aidx: Amplitude indices, 2 words */ +/* _ (struct DTFS_fx *) CURRCW_Q_FX : quantized prototype in Cartesian domain */ +/* (Word16) lag_fx: length of prototype in time domain */ +/* (Word16 []) a/b: harmonics, normalized */ +/* (Word16) Q: norm factor of a */ +/* _ (struct DTFS_fx *) TARGETCW_FX : Target prototype in Cartesian domain */ +/* (Word16) lag_fx: length of prototype in time domain */ +/* (Word16 []) a/b: harmonics, normalized */ /* (Word16) Q: norm factor of a */ /*---------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /* _ (Word16[]) lasterbE_fx: ERB history for differential */ /* quantization, Q13 */ -/* _ (Word16) lastLgainE_fx: low band power history, log domain, */ +/* _ (Word16) lastLgainE_fx: low band power history, log domain, */ /* Q11 */ -/* _ (Word16) lastHgainE_fx: high band power history, log domain, */ +/* _ (Word16) lastHgainE_fx: high band power history, log domain, */ /* Q11 */ /*---------------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ -/* _ (Word16) returnFlag: flag indicating success/failure */ +/* _ (Word16) returnFlag: flag indicating success/failure */ /* (TRUE/FALSE) */ /*---------------------------------------------------------------------------------------*/ /* CALLED FROM : TX */ @@ -77,15 +77,15 @@ static void erb_diff_fx( const Word16 *prev_erb, Word16 pl, const Word16 *curr_e ivas_error ppp_quarter_encoder_fx( Word16 *returnFlag, /* o : return value */ - DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ - DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ - Word16 prevCW_lag, /* i : previous lag */ - DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ - const Word16 *curr_lpc_fx, /* i : LPCS */ - Word16 *lastLgainE_fx, /* i/o: last low band gain */ - Word16 *lastHgainE_fx, /* i/o: last high band gain */ - Word16 *lasterbE_fx, /* i/o: last ERB vector */ - DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ + DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ + DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ + Word16 prevCW_lag, /* i : previous lag */ + DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ + const Word16 *curr_lpc_fx, /* i : LPCS */ + Word16 *lastLgainE_fx, /* i/o: last low band gain */ + Word16 *lastHgainE_fx, /* i/o: last high band gain */ + Word16 *lasterbE_fx, /* i/o: last ERB vector */ + DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ Word16 *S_fx, /* i : sin table, Q15 */ Word16 *C_fx, /* i : cos table, Q15 */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 5e9950615..811174b4f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4733,9 +4733,9 @@ void copy_encoder_config_fx( void amr_wb_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_sp[], /* i : i signal Q0*/ + const Word16 input_sp[], /* i : i signal Q0*/ Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of i samples Q0*/ + const Word16 n_samples /* i : number of i samples Q0*/ ); void writeLPCparam_fx( diff --git a/lib_enc/qlpc_avq_fx.c b/lib_enc/qlpc_avq_fx.c index 288612e43..734b948d6 100644 --- a/lib_enc/qlpc_avq_fx.c +++ b/lib_enc/qlpc_avq_fx.c @@ -27,7 +27,7 @@ void qlpc_avq_fx( Word16 *nb_indices, /* o : Number of quantization indices Q0 */ Word16 *nbbits, /* o : Number of quantization bits Q0 */ const Word16 core, /* i : TCX10 or TCX20 Q0 */ - const Word32 sr_core /* i : internal sampling rate Q0 */ + const Word32 sr_core /* i : internal sampling rate Q0 */ ) { Word16 i; diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 2d7c49107..d24bf8795 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -370,14 +370,14 @@ void lpc_quantization_ivas_fx( *-------------------------------------------------------------------*/ void Unified_weighting_fx( - const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ + const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ Word16 Q_ener, - const Word16 lsf_fx[], /* i : LSF vector x2.56 */ - Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ - const Word16 narrowBand, /* i : flag for Narrowband Q0*/ - const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ - const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ - const Word16 order /* i : LP order Q0*/ + const Word16 lsf_fx[], /* i : LSF vector x2.56 */ + Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ + const Word16 narrowBand, /* i : flag for Narrowband Q0*/ + const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ + const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ + const Word16 order /* i : LP order Q0*/ ) { Word16 i; diff --git a/lib_enc/range_enc_fx.c b/lib_enc/range_enc_fx.c index 3f157b093..73c3f8ae7 100644 --- a/lib_enc/range_enc_fx.c +++ b/lib_enc/range_enc_fx.c @@ -24,7 +24,7 @@ static void rc_enc_write_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 byte, Word16 bit void rc_enc_init_fx( PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - Word16 tot_bits /* i : Total bit budget Q0*/ + Word16 tot_bits /* i : Total bit budget Q0*/ ) { hPVQ->rc_low = L_deposit_l( 0 ); @@ -52,11 +52,11 @@ void rc_enc_init_fx( * Encode symbol with range coder *-------------------------------------------------------------------*/ void rc_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ ) { UWord32 r, tmp, inv_tot, lsb; @@ -90,11 +90,11 @@ void rc_encode_ivas_fx( return; } void rc_encode_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ ) { UWord32 r, tmp, inv_tot, lsb; @@ -377,10 +377,10 @@ static void rc_enc_shift_fx( * *-------------------------------------------------------------------*/ void rc_enc_bits_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ ) { IF( LE_16( add( rc_get_bits2_fx( hPVQ->rc_num_bits, hPVQ->rc_range ), bits ), hPVQ->rc_tot_bits ) ) @@ -410,10 +410,10 @@ void rc_enc_bits_ivas_fx( return; } void rc_enc_bits_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ ) { IF( LE_16( add( rc_get_bits2_fx( hPVQ->rc_num_bits, hPVQ->rc_range ), bits ), hPVQ->rc_tot_bits ) ) @@ -446,10 +446,10 @@ void rc_enc_bits_fx( * Encode with uniform distribution *-------------------------------------------------------------------*/ void rc_enc_uniform_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ ) { Word16 n; @@ -470,10 +470,10 @@ void rc_enc_uniform_ivas_fx( return; } void rc_enc_uniform_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ ) { Word16 n; @@ -500,9 +500,9 @@ void rc_enc_uniform_fx( * Write a byte to bitstream *-------------------------------------------------------------------*/ static void rc_enc_write_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 byte, /* i : Byte to write Q0*/ - Word16 bits /* i : Number of bits Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 byte, /* i : Byte to write Q0*/ + Word16 bits /* i : Number of bits Q0*/ ) { push_indice( hBstr, IND_RC_START, byte, bits ); @@ -510,9 +510,9 @@ static void rc_enc_write_ivas_fx( return; } static void rc_enc_write_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 byte, /* i : Byte to write Q0*/ - Word16 bits /* i : Number of bits Q0*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 byte, /* i : Byte to write Q0*/ + Word16 bits /* i : Number of bits Q0*/ ) { push_indice( hBstr, IND_RC_START, byte, bits ); diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h index d0ffa9b2d..4d7bae598 100644 --- a/lib_enc/rom_enc.h +++ b/lib_enc/rom_enc.h @@ -45,14 +45,14 @@ /*----------------------------------------------------------------------------------* * General tables *----------------------------------------------------------------------------------*/ -extern const Word16 sqrt_han_window_fx[]; /* Half of the square root hanning window Q15*/ -extern const Word16 tipos[]; /* Starting points for pulse position search in Algebraic innovation codebook Q0*/ -extern const Word16 W_HIST_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy Q16*/ -extern const Word16 W_HIST_S_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy Q12*/ +extern const Word16 sqrt_han_window_fx[]; /* Half of the square root hanning window Q15*/ +extern const Word16 tipos[]; /* Starting points for pulse position search in Algebraic innovation codebook Q0*/ +extern const Word16 W_HIST_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy Q16*/ +extern const Word16 W_HIST_S_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calculation of average excitation energy Q12*/ extern const Word16 bwd_start_bin[]; // Q0 extern const Word16 bwd_end_bin[]; // Q0 -extern const Word16 h_fir_fx[]; /* 2nd order fir filter for wsp, decimation by 2 Q15*/ +extern const Word16 h_fir_fx[]; /* 2nd order fir filter for wsp, decimation by 2 Q15*/ extern const Word16 preemphCompensation_fx[]; // Q11 /*----------------------------------------------------------------------------------* @@ -174,7 +174,7 @@ extern const Word32 LS_MIN_SILENCE_SNR[4]; // Q25 extern const Word16 SNR_SUB_BAND_NUM[4]; // Q0 extern const Word16 BAND_MUL[4]; // Q15 -extern const UWord8 E_ROM_tipos[]; /* ACELP indexing Q0*/ +extern const UWord8 E_ROM_tipos[]; /* ACELP indexing Q0*/ extern const Word16 Weight[86]; extern const Word16 BAND_SCALE_AJ[5]; // Q0 diff --git a/lib_enc/rom_enc_fx.c b/lib_enc/rom_enc_fx.c index c0208b481..f81321529 100644 --- a/lib_enc/rom_enc_fx.c +++ b/lib_enc/rom_enc_fx.c @@ -46,12 +46,12 @@ * VAD ROM tables *----------------------------------------------------------------------------------*/ -const Word16 hangover_hd_tbl[3] = {1, 1, 3}; // Q0 -const Word16 hangover_sf_tbl[6] = {1, 3, 4, 1, 1, 2}; // Q0 -const Word16 bwd_start_bin[BWD_N_BINS_MAX] = {1, 3, 6, 11}; // Q0 -const Word16 bwd_end_bin[BWD_N_BINS_MAX] = {1, 4, 9, 12}; // Q0 +const Word16 hangover_hd_tbl[3] = {1, 1, 3}; // Q0 +const Word16 hangover_sf_tbl[6] = {1, 3, 4, 1, 1, 2}; // Q0 +const Word16 bwd_start_bin[BWD_N_BINS_MAX] = {1, 3, 6, 11}; // Q0 +const Word16 bwd_end_bin[BWD_N_BINS_MAX] = {1, 4, 9, 12}; // Q0 -const Word16 BAND_NUM_TAB[5] = {10,10,20,40,60}; /* {OFFSET, NB, WB, SWB, FB} Q0*/ +const Word16 BAND_NUM_TAB[5] = {10,10,20,40,60}; /* {OFFSET, NB, WB, SWB, FB} Q0*/ typedef struct { Word16 r; @@ -76,16 +76,16 @@ const Word16 M_Wi_fix16[16] = 32609/* 9.9518473e-001f Q15 */,31356/* 9.5694034e-001f Q15 */,28898/* 8.8192126e-001f Q15 */,25329/* 7.7301045e-001f Q15 */,20787/* 6.3439328e-001f Q15 */,15446/* 4.7139674e-001f Q15 */, 9512/* 2.9028468e-001f Q15 */, 3212/* 9.8017140e-002f Q15 */ }; -const Word16 SP_CENTER_BAND_NUM_TAB[5] = {10, 10, 20, 24, 24}; // Q0 +const Word16 SP_CENTER_BAND_NUM_TAB[5] = {10, 10, 20, 24, 24}; // Q0 /* 107374184.f = 32768.f * 32768.f * 0.1 */ -const Word16 NREGION_INDEX_NB[9] = {0,1,2,3,4,5,6,7, 9}; // Q0 -const Word16 NREGION_INDEX_WB[13] = {0,1,2,3,4,5,6,8,10,12,16}; // Q0 -const Word16 NREGION_INDEX_SWB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; // Q0 -const Word16 NREGION_INDEX_FB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; // Q0 +const Word16 NREGION_INDEX_NB[9] = {0,1,2,3,4,5,6,7, 9}; // Q0 +const Word16 NREGION_INDEX_WB[13] = {0,1,2,3,4,5,6,8,10,12,16}; // Q0 +const Word16 NREGION_INDEX_SWB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; // Q0 +const Word16 NREGION_INDEX_FB[16] = {0,1,2,3,4,5,6,8,10,12,16,24,36}; // Q0 const Word16 NREGION_PREOFF[12] = { 0,0,0,0,0,0,1,1,1,2,3,4 }; -const Word16 ENERGY_BAND_NUM[4] = {8,10,12,MAX_SUBBAND_NUM}; // Q0 -const Word16 * const REGION_INDEX[4] = {NREGION_INDEX_NB, NREGION_INDEX_WB,NREGION_INDEX_SWB,NREGION_INDEX_FB}; // Q0 +const Word16 ENERGY_BAND_NUM[4] = {8,10,12,MAX_SUBBAND_NUM}; // Q0 +const Word16 * const REGION_INDEX[4] = {NREGION_INDEX_NB, NREGION_INDEX_WB,NREGION_INDEX_SWB,NREGION_INDEX_FB}; // Q0 const Word32 MAX_LF_SNR_TAB_FX[5] = { 26843545/* 0.8 Q25 */,26843545/* 0.8 Q25 */,53687090/* 1.6 Q25 */,26843545/* 0.8 Q25 */,26843545/* 0.8 Q25 */ }; const Word32 COMVAD_INIT_SNR_DELTA_FX[5] = { 33554431/* 1.0 Q25 */, 20132659/* 0.6 Q25 */, 28856811/* 0.86 Q25 */, 38923139/* 1.16 Q25 */, 33554431/* 1.0 Q25 */ }; const Word32 LT_MIN_SILENCE_SNR_FX[4] = { 150994940/* 4.5 Q25 */, 150994940/* 4.5 Q25 */, 150994940/* 4.5 Q25 */,150994940/* 4.5 Q25 */ }; @@ -106,7 +106,7 @@ const Word16 sqrt_han_window_fx[L_FFT / 2 + 1] = 31785, 31880, 31971, 32057, 32137, 32213, 32285, 32351, 32412, 32469, 32521, 32567, 32609, 32646, 32678, 32705, 32728, 32745, 32757, 32765, 32767 -}; // Q15 +}; // Q15 /*----------------------------------------------------------------------------------* * Starting points for pulse position search in Algebraic innovation codebook @@ -123,22 +123,22 @@ const Word16 tipos[40] = 3, 0, 1, 2, 0, 1, 2, 3, 1, 2, 3, 0 /* end point for 28 pulses &ipos[39], 4th iter */ -}; // Q0 +}; // Q0 /*----------------------------------------------------------------------------------* * Open-loop pitch tables *----------------------------------------------------------------------------------*/ -const Word16 nb_sect_12k8[3] = { 4, 4, 4 }; // Q0 -const Word16 nb_subsect_12k8[3] = { 7, 7, 7 }; // Q0 -const Word16 pit_max_12k8[8] = { 11, 16, 21, 31, 40, 61, 77, 115}; // Q0 +const Word16 nb_sect_12k8[3] = { 4, 4, 4 }; // Q0 +const Word16 nb_subsect_12k8[3] = { 7, 7, 7 }; // Q0 +const Word16 pit_max_12k8[8] = { 11, 16, 21, 31, 40, 61, 77, 115}; // Q0 -const Word16 len_12k8[4] = { 40, 40, 62, 115 }; // Q0 -const Word16 len1_12k8[4] = { 40, 50, 80, 115 }; // Q0 -const Word16 sublen_12k8[7] = { 40, 40, 40, 62, 62, 115, 115 }; // Q0 -const Word16 sublen1_12k8[7] = { 40, 40, 50, 50, 80, 80, 115 }; // Q0 -const Word16 sec_length_12k8[4] = { 7, 15, 30, 54 }; // Q0 -const Word16 sec_length1_12k8[4] = { 10, 19, 37, 38 }; // Q0 -const Word16 h_fir_fx[] = { 4260, 7536, 9175, 7536, 4260 }; // Q15 +const Word16 len_12k8[4] = { 40, 40, 62, 115 }; // Q0 +const Word16 len1_12k8[4] = { 40, 50, 80, 115 }; // Q0 +const Word16 sublen_12k8[7] = { 40, 40, 40, 62, 62, 115, 115 }; // Q0 +const Word16 sublen1_12k8[7] = { 40, 40, 50, 50, 80, 80, 115 }; // Q0 +const Word16 sec_length_12k8[4] = { 7, 15, 30, 54 }; // Q0 +const Word16 sec_length1_12k8[4] = { 10, 19, 37, 38 }; // Q0 +const Word16 h_fir_fx[] = { 4260, 7536, 9175, 7536, 4260 }; // Q15 const Word16 W_HIST_FX[DTX_HIST_SIZE] = { 13107, 10486, 8389, 6711, 5369, 4295, 3436, 687 }; /* Q16 */ const Word16 W_HIST_S_FX[DTX_HIST_SIZE] = { 20480, 11378, 8393, 6938, 6092, 5551, 5183, 5115 }; /* Q12 */ @@ -148,8 +148,8 @@ const Word16 preemphCompensation_fx[NB_BANDS] = { 19960/*9.7461f Q11*/, 19493/* * LSF quantizer *----------------------------------------------------------------------------------*/ -const Word16 lsf_numlevels[TCXLPC_NUMSTAGES] = { 32, 16, 16 }; // Q0 -const Word16 lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES] = { 4 }; // Q0 +const Word16 lsf_numlevels[TCXLPC_NUMSTAGES] = { 32, 16, 16 }; // Q0 +const Word16 lsf_ind_numlevels[TCXLPC_IND_NUMSTAGES] = { 4 }; // Q0 const Word16 lsf_unified_fit_model_nb[4][16] = { @@ -157,7 +157,7 @@ const Word16 lsf_unified_fit_model_nb[4][16] = {20383 , 18855 , 8494 , 8062 , 8105 , 6211 , 5068 , 4408 , 3741 , 3458 , 2732 , 3174 , 2412 , 17421 , -21717 , 0}, {-717 , -617 , -144 , -117 , -229 , -144 , -141 , -98 , -92 , -69 , -51 , -87 , -37 , -3019 , 19864 , 8034}, {-2424 , 8999 , 5723 , 5629 , 4239 , 3423 , 2507 , 2019 , 1245 , 736 , -907 , -2237 , -2558 , -1979 , -652 , 1657} -}; // Q0 +}; // Q0 const Word16 lsf_unified_fit_model_wb[4][16] = { @@ -165,7 +165,7 @@ const Word16 lsf_unified_fit_model_wb[4][16] = {24635 , 19605 , 9294 , 7407 , 6419 , 5459 , 4966 , 4189 , 3394 , 2964 , 2425 , 2110 , 2140 , 1972 , 1540 , 2252}, {-867 , -666 , -168 , -114 , -90 , -122 , -129 , -101 , -65 , -56 , -39 , -35 , -40 , -42 , -35 , -56}, {-2313 , 3035 , 1677 , 2854 , 2334 , 1232 , 1347 , 1034 , 863 , 707 , 886 , 891 , 432 , 357 , 206 , -310} -}; // Q0 +}; // Q0 const Word16 lsf_unified_fit_model_wbhb[4][16] = { @@ -173,52 +173,52 @@ const Word16 lsf_unified_fit_model_wbhb[4][16] = {28135 , 16053 , 10129 , 7366 , 5898 , 5341 , 3290 , 2780 , 3146 , 2423 , 1613 , 1370 , 1294 , 1635 , 1105 , 1431}, {-615 , -308 , -147 , -119 , -104 , -105 , -30 , -28 , -50 , -39 , -15 , -14 , -14 , -21 , -19 , -29}, {1534 , 3569 , 3138 , 4023 , 2105 , 2023 , 2046 , 1264 , 1340 , 1067 , 780 , 547 , 188 , -540 , -722 , -479} -}; // Q0 +}; // Q0 const Word32 Freq_Weight_Com_fx[160] = /*Q31 */ { - 1073741824, 1351646720, 1610612736, 1832992000, 2003629568, 2110896768, 2147483647, 2147483647, - 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, - 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2088915968, 2033457920, 1980868480, - 1930930688, 1883448832, 1838246016, 1795162112, 1754051584, 1714781696, 1677231744, 1641291136, - 1606858368, 1573840768, 1542152704, 1511715456, 1482456448, 1454308608, 1427209600, 1401102080, - 1375932672, 1351651456, 1328212480, 1305572480, 1283691392, 1262531584, 1242058112, 1222238080, - 1203040640, 1184436864, 1166399744, 1148903808, 1131924864, 1115440512, 1099429376, 1083871488, - 1068747648, 1054040128, 1039731904, 1025806912, 1012249984, 999046720, 986183488, 973647232, - 961425728, 949507264, 937880640, 926535296, 915461184, 904648640, 894088512, 883772096, - 873691072, 863837376, 854203520, 844782144, 835566336, 826549440, 817725120, 809087168, - 800629824, 792347392, 784234624, 776286336, 768497472, 760863424, 753379520, 746041408, - 738844864, 731785856, 724860416, 718064832, 711395520, 704848896, 698421760, 692110720, - 685912704, 679824704, 673843840, 667967296, 662192384, 656516416, 650936960, 645451520, - 640057792, 634753472, 629536320, 624404224, 619355136, 614387008, 609497984, 604686208, - 599949760, 595286912, 590696000, 586175360, 581723392, 577338560, 573019328, 568764224, - 564571840, 560440832, 556369856, 552357568, 548402752, 544504128, 540660608, 536870912, - 533133984, 529448736, 525814080, 522228992, 518692448, 515203488, 511761152, 508364480, - 505012640, 501704704, 498439808, 495217120, 492035872, 488895200, 485794400, 482732672, - 479709280, 476723552, 473774752, 470862208, 467985248, 465143232, 462335520, 459561504, - 456820576, 454112160, 451435648, 448790528, 446176224, 443592192, 441037920, 438512896 + 1073741824, 1351646720, 1610612736, 1832992000, 2003629568, 2110896768, 2147483647, 2147483647, + 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, + 2147483647, 2147483647, 2147483647, 2147483647, 2147483647, 2088915968, 2033457920, 1980868480, + 1930930688, 1883448832, 1838246016, 1795162112, 1754051584, 1714781696, 1677231744, 1641291136, + 1606858368, 1573840768, 1542152704, 1511715456, 1482456448, 1454308608, 1427209600, 1401102080, + 1375932672, 1351651456, 1328212480, 1305572480, 1283691392, 1262531584, 1242058112, 1222238080, + 1203040640, 1184436864, 1166399744, 1148903808, 1131924864, 1115440512, 1099429376, 1083871488, + 1068747648, 1054040128, 1039731904, 1025806912, 1012249984, 999046720, 986183488, 973647232, + 961425728, 949507264, 937880640, 926535296, 915461184, 904648640, 894088512, 883772096, + 873691072, 863837376, 854203520, 844782144, 835566336, 826549440, 817725120, 809087168, + 800629824, 792347392, 784234624, 776286336, 768497472, 760863424, 753379520, 746041408, + 738844864, 731785856, 724860416, 718064832, 711395520, 704848896, 698421760, 692110720, + 685912704, 679824704, 673843840, 667967296, 662192384, 656516416, 650936960, 645451520, + 640057792, 634753472, 629536320, 624404224, 619355136, 614387008, 609497984, 604686208, + 599949760, 595286912, 590696000, 586175360, 581723392, 577338560, 573019328, 568764224, + 564571840, 560440832, 556369856, 552357568, 548402752, 544504128, 540660608, 536870912, + 533133984, 529448736, 525814080, 522228992, 518692448, 515203488, 511761152, 508364480, + 505012640, 501704704, 498439808, 495217120, 492035872, 488895200, 485794400, 482732672, + 479709280, 476723552, 473774752, 470862208, 467985248, 465143232, 462335520, 459561504, + 456820576, 454112160, 451435648, 448790528, 446176224, 443592192, 441037920, 438512896 }; const Word32 Freq_Weight_UV_fx[160] = /*Q31 */ { - 1073741824, 1351646720, 1610612736, 1832992000, 2003629568, 2110896768, 2147483647, 2129881344, - 2112565248, 2095528448, 2078764160, 2062265984, 2046027776, 2030043136, 2014306304, 1998811648, - 1983553536, 1968526720, 1953725696, 1939145728, 1924781696, 1910628864, 1896682624, 1882938624, - 1869392256, 1856039424, 1842876032, 1829897984, 1817101568, 1804482816, 1792038016, 1779763840, - 1767656576, 1755713024, 1743929728, 1732303488, 1720831232, 1709510016, 1698336768, 1687308544, - 1676422656, 1665676416, 1655067008, 1644591872, 1634248576, 1624034560, 1613947392, 1603984640, - 1594144256, 1584423936, 1574821376, 1565334528, 1555961216, 1546699520, 1537547520, 1528503040, - 1519564416, 1510729728, 1501997184, 1493365120, 1484831488, 1476395008, 1468053760, 1459806336, - 1451650944, 1443586176, 1435610624, 1427722624, 1419920896, 1412203904, 1404570368, 1397018880, - 1389548288, 1382157056, 1374844032, 1367608064, 1360447744, 1353362048, 1346349824, 1339409920, - 1332541184, 1325742464, 1319012736, 1312351104, 1305756416, 1299227648, 1292763776, 1286363904, - 1280027136, 1273752576, 1267539072, 1261385984, 1255292416, 1249257344, 1243280000, 1237359616, - 1231495424, 1225686400, 1219932032, 1214231424, 1208583808, 1202988544, 1197444736, 1191951872, - 1186509184, 1181116032, 1175771648, 1170475264, 1165226496, 1160024704, 1154868992, 1149758976, - 1144693888, 1139673344, 1134696576, 1129763200, 1124872448, 1120023808, 1115216768, 1110450944, - 1105725568, 1101040384, 1096394624, 1091787904, 1087219712, 1082689664, 1078197248, 1073741824, - 1069323136, 1064940672, 1060593984, 1056282624, 1052006144, 1047764224, 1043556288, 1039382080, - 1035241152, 1031132992, 1027057408, 1023013888, 1019002048, 1015021568, 1011072064, 1007153152, - 1003264576, 999405824, 995576704, 991776768, 988005760, 984263360, 980549120, 976862848, - 973204224, 969572864, 965968512, 962390848, 958839552, 955314432, 951815104, 948341312, + 1073741824, 1351646720, 1610612736, 1832992000, 2003629568, 2110896768, 2147483647, 2129881344, + 2112565248, 2095528448, 2078764160, 2062265984, 2046027776, 2030043136, 2014306304, 1998811648, + 1983553536, 1968526720, 1953725696, 1939145728, 1924781696, 1910628864, 1896682624, 1882938624, + 1869392256, 1856039424, 1842876032, 1829897984, 1817101568, 1804482816, 1792038016, 1779763840, + 1767656576, 1755713024, 1743929728, 1732303488, 1720831232, 1709510016, 1698336768, 1687308544, + 1676422656, 1665676416, 1655067008, 1644591872, 1634248576, 1624034560, 1613947392, 1603984640, + 1594144256, 1584423936, 1574821376, 1565334528, 1555961216, 1546699520, 1537547520, 1528503040, + 1519564416, 1510729728, 1501997184, 1493365120, 1484831488, 1476395008, 1468053760, 1459806336, + 1451650944, 1443586176, 1435610624, 1427722624, 1419920896, 1412203904, 1404570368, 1397018880, + 1389548288, 1382157056, 1374844032, 1367608064, 1360447744, 1353362048, 1346349824, 1339409920, + 1332541184, 1325742464, 1319012736, 1312351104, 1305756416, 1299227648, 1292763776, 1286363904, + 1280027136, 1273752576, 1267539072, 1261385984, 1255292416, 1249257344, 1243280000, 1237359616, + 1231495424, 1225686400, 1219932032, 1214231424, 1208583808, 1202988544, 1197444736, 1191951872, + 1186509184, 1181116032, 1175771648, 1170475264, 1165226496, 1160024704, 1154868992, 1149758976, + 1144693888, 1139673344, 1134696576, 1129763200, 1124872448, 1120023808, 1115216768, 1110450944, + 1105725568, 1101040384, 1096394624, 1091787904, 1087219712, 1082689664, 1078197248, 1073741824, + 1069323136, 1064940672, 1060593984, 1056282624, 1052006144, 1047764224, 1043556288, 1039382080, + 1035241152, 1031132992, 1027057408, 1023013888, 1019002048, 1015021568, 1011072064, 1007153152, + 1003264576, 999405824, 995576704, 991776768, 988005760, 984263360, 980549120, 976862848, + 973204224, 969572864, 965968512, 962390848, 958839552, 955314432, 951815104, 948341312, }; /*----------------------------------------------------------------------------------* @@ -227,20 +227,20 @@ const Word32 Freq_Weight_UV_fx[160] = /*Q31 */ const Word16 w_spmus_fx[HANG_LEN][HANG_LEN] = { /*Q15*/ - {32767, 0, 0, 0, 0, 0, 0, 0,}, - {19661, 13107, 0, 0, 0, 0, 0, 0,}, - {15401, 10813, 6554, 0, 0, 0, 0, 0,}, - {13107, 9830, 6554, 3277, 0, 0, 0, 0,}, - { 9830, 8192, 6554, 4915, 3277, 0, 0, 0,}, - { 7635, 6783, 5898, 5014, 4162, 3277, 0, 0,}, - { 7700, 6717, 5702, 4686, 3670, 2654, 1638, 0,}, - { 6554, 5865, 5145, 4456, 3736, 3047, 2327, 1638} + {32767, 0, 0, 0, 0, 0, 0, 0,}, + {19661, 13107, 0, 0, 0, 0, 0, 0,}, + {15401, 10813, 6554, 0, 0, 0, 0, 0,}, + {13107, 9830, 6554, 3277, 0, 0, 0, 0,}, + { 9830, 8192, 6554, 4915, 3277, 0, 0, 0,}, + { 7635, 6783, 5898, 5014, 4162, 3277, 0, 0,}, + { 7700, 6717, 5702, 4686, 3670, 2654, 1638, 0,}, + { 6554, 5865, 5145, 4456, 3736, 3047, 2327, 1638} }; const Word32 sm_means_fx[N_SMC_FEATURES] = { 114371648, 762918, 258533, 305622, 877131, 1071555, 1272603, 67350312, 1296274, -2461829, 1882791, -41135, -306269, 641721, 5859343, -}; // Q20 +}; // Q20 const Word32 sm_scale_fx[N_SMC_FEATURES] = {//Q20 46789116, 166914, 66905, 70898, 117576, 108472, 96226, 17324576, @@ -257,12 +257,12 @@ const Word32 bcox_add_cnst_fx[N_SMC_FEATURES] = { 0, 0, -1886955264, -1559167616, 0, 0, 0, 0, -1672874752, 0, 0, 0, 0, 0, 0, -}; // Q31 +}; // Q31 const Word32 bcox_lmbd_fx[N_SMC_FEATURES] = { 0, 0, -1426534784, -907320448, 0, 0, 0, 0, -1362524672, 0, 0, 0, 0, 0, 0, -}; // Q31 +}; // Q31 const Word32 pca_mean_fx[N_SMC_FEATURES] = { 0, 0, 0, 0, 0, 0, 0, 0, @@ -541,287 +541,287 @@ const Word32 prec_chol_noise_fx[N_SMC_MIXTURES*(N_PCA_COEF*N_PCA_COEF + N_PCA_CO const Word16 m_speech_fx[N_MIXTURES*N_FEATURES] = { /*Q15*/ - 9436, 29987, 4795, 7076, 11050, 13645, 15206, 15194, 1936, 27952, 25172, 10301, - 10057, 30685, 8381, 9965, 10762, 8680, 11589, 15788, 1641, 26751, 27163, 10992, - 7927, 31230, 7191, 8505, 14304, 16336, 14972, 16077, 2052, 27271, 27694, 10859, - 13914, 17323, 10682, 16458, 17807, 18403, 19368, 12665, 2205, 29598, 29213, 11285, - 12468, 23848, 6880, 10301, 13824, 13066, 14647, 13189, 3451, 28442, 28766, 10410, - 11304, 21566, 7894, 11411, 14194, 15739, 16351, 13744, 6130, 28445, 28034, 11380 + 9436, 29987, 4795, 7076, 11050, 13645, 15206, 15194, 1936, 27952, 25172, 10301, + 10057, 30685, 8381, 9965, 10762, 8680, 11589, 15788, 1641, 26751, 27163, 10992, + 7927, 31230, 7191, 8505, 14304, 16336, 14972, 16077, 2052, 27271, 27694, 10859, + 13914, 17323, 10682, 16458, 17807, 18403, 19368, 12665, 2205, 29598, 29213, 11285, + 12468, 23848, 6880, 10301, 13824, 13066, 14647, 13189, 3451, 28442, 28766, 10410, + 11304, 21566, 7894, 11411, 14194, 15739, 16351, 13744, 6130, 28445, 28034, 11380 }; const Word32 invV_speech_fx[N_MIXTURES*N_FEATURES*N_FEATURES] = { /*Q10*/ - -40443, -14756, -39560, -18113, 8983, -11676, 450, -10588, -49908, 358, 17222, 32914, - -14756, -200610, -27679, -28092, -16846, -6393, 5954, 13058, -67051, -47861, -8575, 18740, - -39560, -27679, -772035, 118158, -48299, 27758, -37782, 74336, -305470, -23323, 181510, 91957, - -18113, -28092, 118158, -228070, 41104, -46248, 21977, 8161, -27789, 78357, 26088, 39736, - 8983, -16846, -48299, 41104, -96670, 41164, -18208, 3995, -14774, 23704, 13802, 17925, - -11676, -6393, 27758, -46248, 41164, -95654, 58562, 3668, 103, 5952, 9479, 11083, - 450, 5954, -37782, 21977, -18208, 58562, -91964, -5597, -47161, -15941, 14870, 11028, - -10588, 13058, 74336, 8161, 3995, 3668, -5597, -102767, 25363, -21490, -48411, 13509, - -49908, -67051, -305470, -27789, -14774, 103, -47161, 25363, -1410848, -57997, 238792, -117641, - 358, -47861, -23323, 78357, 23704, 5952, -15941, -21490, -57997, -221932, -936, 40579, - 17222, -8575, 181510, 26088, 13802, 9479, 14870, -48411, 238792, -936, -157118, -49202, - 32914, 18740, 91957, 39736, 17925, 11083, 11028, 13509, -117641, 40579, -49202, -321159, - -54755, -48603, -918, -25735, 31634, -27972, 23305, -18449, -68162, -3670, -7982, 35965, - -48603, -449238, -11496, -14811, 12790, -11453, 2686, -3752, -86924, -30083, -54695, 17457, - -918, -11496, -258042, 157642, 4617, 27546, -22677, 7281, -221085, -48457, 80126, 16406, - -25735, -14811, 157642, -334462, 64217, 7724, 24309, 20322, -99420, 2896, 76924, 35785, - 31634, 12790, 4617, 64217, -296101, 182629, -27282, 11581, -10495, 16901, 50011, 20823, - -27972, -11453, 27546, 7724, 182629, -274190, 15505, 4345, -7824, 79496, -2218, 12832, - 23305, 2686, -22677, 24309, -27282, 15505, -73195, 2055, -4690, 31413, 15447, 8774, - -18449, -3752, 7281, 20322, 11581, 4345, 2055, -77913, 57514, -8586, -106171, 6233, - -68162, -86924, -221085, -99420, -10495, -7824, -4690, 57514, -1966183, -9074, 512909, -17375, - -3670, -30083, -48457, 2896, 16901, 79496, 31413, -8586, -9074, -185355, -15990, 8445, - -7982, -54695, 80126, 76924, 50011, -2218, 15447, -106171, 512909, -15990, -444405, -71821, - 35965, 17457, 16406, 35785, 20823, 12832, 8774, 6233, -17375, 8445, -71821, -222292, - -96397, -65745, 316, -47258, 43061, -42973, 10442, -19582, -43973, -19682, -21732, 48029, - -65745, -838575, 30816, -43250, 6642, -4487, 11239, 338, -17329, -59741, -114530, -1706, - 316, 30816, -351192, 207585, -68100, 60838, -83672, 14796, -158998, 13313, 122647, 38113, - -47258, -43250, 207585, -322741, 76525, -99711, 59838, 20166, -63534, 7136, 76247, 22923, - 43061, 6642, -68100, 76525, -96244, 54110, -21689, 2401, -36455, -19725, 38782, 6802, - -42973, -4487, 60838, -99711, 54110, -284964, 220150, -642, -44874, -21815, 16040, 3963, - 10442, 11239, -83672, 59838, -21689, 220150, -239817, 2018, -17214, -1904, 16387, 4095, - -19582, 338, 14796, 20166, 2401, -642, 2018, -58537, 20742, -9245, -85094, 8867, - -43973, -17329, -158998, -63534, -36455, -44874, -17214, 20742, -1009892, 28181, 407531, -10963, - -19682, -59741, 13313, 7136, -19725, -21815, -1904, -9245, 28181, -186118, -32487, 5665, - -21732, -114530, 122647, 76248, 38782, 16040, 16387, -85094, 407531, -32487, -511009, -66277, - 48029, -1706, 38113, 22923, 6802, 3963, 4095, 8867, -10963, 5665, -66277, -251113, - -21146, 1393, -2365, 3756, -4538, -1528, 2298, -6668, -7599, -2720, -5226, 3049, - 1393, -46612, -28502, 11801, -5967, 8395, -4182, 13773, 18586, -9799, -6696, -3522, - -2365, -28502, -77446, 55688, -10615, 10476, -6282, 5520, -19365, 8818, -4576, 2603, - 3756, 11801, 55688, -152293, 104577, -8742, 15278, -2773, 16622, -12382, -2828, 5452, - -4538, -5967, -10615, 104577, -245151, 117173, -5020, 3412, -2855, -19929, 9729, 1888, - -1528, 8395, 10476, -8742, 117173, -258943, 136249, -2960, -8257, -20123, -6735, -6316, - 2298, -4182, -6282, 15278, -5020, 136249, -192889, 889, -6047, -74906, 15861, 4026, - -6668, 13773, 5520, -2773, 3412, -2960, 889, -298321, 8558, 5827, -66886, -3080, - -7599, 18586, -19365, 16622, -2855, -8257, -6047, 8558, -837495, -36576, 477123, -58582, - -2720, -9799, 8818, -12382, -19929, -20123, -74906, 5827, -36576, -279826, 29479, 36566, - -5226, -6696, -4576, -2828, 9729, -6735, 15861, -66886, 477123, 29479, -1017755, -75828, - 3049, -3522, 2603, 5452, 1888, -6316, 4026, -3080, -58582, 36566, -75828, -193453, - -30403, -6761, -6085, -8388, 12841, -17600, 8289, -11817, -4054, -3000, -13322, 14944, - -6761, -28452, -12326, -8945, 10515, -8369, -520, 2242, -3287, -20124, 179, 12354, - -6085, -12326, -180408, 89468, -19908, 3017, -41552, 4204, -31158, -23783, 87004, 44784, - -8388, -8945, 89468, -146434, 53166, -28645, 29987, -2506, -12242, 28411, 11874, 403, - 12841, 10515, -19908, 53166, -182342, 131104, -3630, 7016, -11031, -43497, 35570, 41136, - -17600, -8369, 3017, -28645, 131104, -169537, 52490, -4955, 3848, 41489, -7925, -19614, - 8289, -520, -41552, 29987, -3630, 52490, -111006, -916, 3418, 2295, 3395, 1491, - -11817, 2242, 4204, -2506, 7016, -4955, -916, -219477, -4965, -3871, -77054, -1199, - -4054, -3287, -31158, -12242, -11031, 3848, 3418, -4965, -272588, 2948, 184352, -45153, - -3000, -20124, -23783, 28411, -43497, 41489, 2295, -3871, 2948, -160538, -11875, 4491, - -13322, 179, 87004, 11874, 35570, -7925, 3395, -77054, 184352, -11875, -501251, -59166, - 14944, 12354, 44784, 403, 41136, -19614, 1491, -1199, -45153, 4491, -59166, -256669, - -24496, -5820, -2150, 131, 5291, -10279, 6605, -749, -2301, -4257, 6742, 4179, - -5820, -30866, -8866, -12879, -1341, 2042, -4488, 6991, -847, -21654, 3707, 11359, - -2150, -8866, -123923, 90609, -28405, 24864, -28222, 3814, 6439, -12821, 2736, 12974, - 131, -12879, 90609, -147490, 86712, -38319, 26159, 1048, -7654, 17099, 8973, 1271, - 5291, -1341, -28405, 86712, -147877, 74296, -14561, 2055, 18062, 1238, -4181, 14726, - -10279, 2042, 24864, -38319, 74296, -168459, 117891, -874, -17255, 675, 13174, -13101, - 6605, -4488, -28222, 26159, -14561, 117891, -147764, -13296, 2771, -4243, -4809, 1608, - -749, 6991, 3814, 1048, 2055, -874, -13296, -77582, -32335, -4868, 9778, -6784, - -2301, -847, 6439, -7654, 18062, -17255, 2771, -32335, -69840, 11490, 21385, -23633, - -4257, -21654, -12821, 17099, 1238, 675, -4243, -4868, 11490, -151841, -2520, 12898, - 6742, 3707, 2736, 8973, -4181, 13174, -4809, 9778, 21385, -2520, -60529, -3814, - 4179, 11359, 12974, 1271, 14726, -13101, 1608, -6784, -23633, 12898, -3814, -63927 + -40443, -14756, -39560, -18113, 8983, -11676, 450, -10588, -49908, 358, 17222, 32914, + -14756, -200610, -27679, -28092, -16846, -6393, 5954, 13058, -67051, -47861, -8575, 18740, + -39560, -27679, -772035, 118158, -48299, 27758, -37782, 74336, -305470, -23323, 181510, 91957, + -18113, -28092, 118158, -228070, 41104, -46248, 21977, 8161, -27789, 78357, 26088, 39736, + 8983, -16846, -48299, 41104, -96670, 41164, -18208, 3995, -14774, 23704, 13802, 17925, + -11676, -6393, 27758, -46248, 41164, -95654, 58562, 3668, 103, 5952, 9479, 11083, + 450, 5954, -37782, 21977, -18208, 58562, -91964, -5597, -47161, -15941, 14870, 11028, + -10588, 13058, 74336, 8161, 3995, 3668, -5597, -102767, 25363, -21490, -48411, 13509, + -49908, -67051, -305470, -27789, -14774, 103, -47161, 25363, -1410848, -57997, 238792, -117641, + 358, -47861, -23323, 78357, 23704, 5952, -15941, -21490, -57997, -221932, -936, 40579, + 17222, -8575, 181510, 26088, 13802, 9479, 14870, -48411, 238792, -936, -157118, -49202, + 32914, 18740, 91957, 39736, 17925, 11083, 11028, 13509, -117641, 40579, -49202, -321159, + -54755, -48603, -918, -25735, 31634, -27972, 23305, -18449, -68162, -3670, -7982, 35965, + -48603, -449238, -11496, -14811, 12790, -11453, 2686, -3752, -86924, -30083, -54695, 17457, + -918, -11496, -258042, 157642, 4617, 27546, -22677, 7281, -221085, -48457, 80126, 16406, + -25735, -14811, 157642, -334462, 64217, 7724, 24309, 20322, -99420, 2896, 76924, 35785, + 31634, 12790, 4617, 64217, -296101, 182629, -27282, 11581, -10495, 16901, 50011, 20823, + -27972, -11453, 27546, 7724, 182629, -274190, 15505, 4345, -7824, 79496, -2218, 12832, + 23305, 2686, -22677, 24309, -27282, 15505, -73195, 2055, -4690, 31413, 15447, 8774, + -18449, -3752, 7281, 20322, 11581, 4345, 2055, -77913, 57514, -8586, -106171, 6233, + -68162, -86924, -221085, -99420, -10495, -7824, -4690, 57514, -1966183, -9074, 512909, -17375, + -3670, -30083, -48457, 2896, 16901, 79496, 31413, -8586, -9074, -185355, -15990, 8445, + -7982, -54695, 80126, 76924, 50011, -2218, 15447, -106171, 512909, -15990, -444405, -71821, + 35965, 17457, 16406, 35785, 20823, 12832, 8774, 6233, -17375, 8445, -71821, -222292, + -96397, -65745, 316, -47258, 43061, -42973, 10442, -19582, -43973, -19682, -21732, 48029, + -65745, -838575, 30816, -43250, 6642, -4487, 11239, 338, -17329, -59741, -114530, -1706, + 316, 30816, -351192, 207585, -68100, 60838, -83672, 14796, -158998, 13313, 122647, 38113, + -47258, -43250, 207585, -322741, 76525, -99711, 59838, 20166, -63534, 7136, 76247, 22923, + 43061, 6642, -68100, 76525, -96244, 54110, -21689, 2401, -36455, -19725, 38782, 6802, + -42973, -4487, 60838, -99711, 54110, -284964, 220150, -642, -44874, -21815, 16040, 3963, + 10442, 11239, -83672, 59838, -21689, 220150, -239817, 2018, -17214, -1904, 16387, 4095, + -19582, 338, 14796, 20166, 2401, -642, 2018, -58537, 20742, -9245, -85094, 8867, + -43973, -17329, -158998, -63534, -36455, -44874, -17214, 20742, -1009892, 28181, 407531, -10963, + -19682, -59741, 13313, 7136, -19725, -21815, -1904, -9245, 28181, -186118, -32487, 5665, + -21732, -114530, 122647, 76248, 38782, 16040, 16387, -85094, 407531, -32487, -511009, -66277, + 48029, -1706, 38113, 22923, 6802, 3963, 4095, 8867, -10963, 5665, -66277, -251113, + -21146, 1393, -2365, 3756, -4538, -1528, 2298, -6668, -7599, -2720, -5226, 3049, + 1393, -46612, -28502, 11801, -5967, 8395, -4182, 13773, 18586, -9799, -6696, -3522, + -2365, -28502, -77446, 55688, -10615, 10476, -6282, 5520, -19365, 8818, -4576, 2603, + 3756, 11801, 55688, -152293, 104577, -8742, 15278, -2773, 16622, -12382, -2828, 5452, + -4538, -5967, -10615, 104577, -245151, 117173, -5020, 3412, -2855, -19929, 9729, 1888, + -1528, 8395, 10476, -8742, 117173, -258943, 136249, -2960, -8257, -20123, -6735, -6316, + 2298, -4182, -6282, 15278, -5020, 136249, -192889, 889, -6047, -74906, 15861, 4026, + -6668, 13773, 5520, -2773, 3412, -2960, 889, -298321, 8558, 5827, -66886, -3080, + -7599, 18586, -19365, 16622, -2855, -8257, -6047, 8558, -837495, -36576, 477123, -58582, + -2720, -9799, 8818, -12382, -19929, -20123, -74906, 5827, -36576, -279826, 29479, 36566, + -5226, -6696, -4576, -2828, 9729, -6735, 15861, -66886, 477123, 29479, -1017755, -75828, + 3049, -3522, 2603, 5452, 1888, -6316, 4026, -3080, -58582, 36566, -75828, -193453, + -30403, -6761, -6085, -8388, 12841, -17600, 8289, -11817, -4054, -3000, -13322, 14944, + -6761, -28452, -12326, -8945, 10515, -8369, -520, 2242, -3287, -20124, 179, 12354, + -6085, -12326, -180408, 89468, -19908, 3017, -41552, 4204, -31158, -23783, 87004, 44784, + -8388, -8945, 89468, -146434, 53166, -28645, 29987, -2506, -12242, 28411, 11874, 403, + 12841, 10515, -19908, 53166, -182342, 131104, -3630, 7016, -11031, -43497, 35570, 41136, + -17600, -8369, 3017, -28645, 131104, -169537, 52490, -4955, 3848, 41489, -7925, -19614, + 8289, -520, -41552, 29987, -3630, 52490, -111006, -916, 3418, 2295, 3395, 1491, + -11817, 2242, 4204, -2506, 7016, -4955, -916, -219477, -4965, -3871, -77054, -1199, + -4054, -3287, -31158, -12242, -11031, 3848, 3418, -4965, -272588, 2948, 184352, -45153, + -3000, -20124, -23783, 28411, -43497, 41489, 2295, -3871, 2948, -160538, -11875, 4491, + -13322, 179, 87004, 11874, 35570, -7925, 3395, -77054, 184352, -11875, -501251, -59166, + 14944, 12354, 44784, 403, 41136, -19614, 1491, -1199, -45153, 4491, -59166, -256669, + -24496, -5820, -2150, 131, 5291, -10279, 6605, -749, -2301, -4257, 6742, 4179, + -5820, -30866, -8866, -12879, -1341, 2042, -4488, 6991, -847, -21654, 3707, 11359, + -2150, -8866, -123923, 90609, -28405, 24864, -28222, 3814, 6439, -12821, 2736, 12974, + 131, -12879, 90609, -147490, 86712, -38319, 26159, 1048, -7654, 17099, 8973, 1271, + 5291, -1341, -28405, 86712, -147877, 74296, -14561, 2055, 18062, 1238, -4181, 14726, + -10279, 2042, 24864, -38319, 74296, -168459, 117891, -874, -17255, 675, 13174, -13101, + 6605, -4488, -28222, 26159, -14561, 117891, -147764, -13296, 2771, -4243, -4809, 1608, + -749, 6991, 3814, 1048, 2055, -874, -13296, -77582, -32335, -4868, 9778, -6784, + -2301, -847, 6439, -7654, 18062, -17255, 2771, -32335, -69840, 11490, 21385, -23633, + -4257, -21654, -12821, 17099, 1238, 675, -4243, -4868, 11490, -151841, -2520, 12898, + 6742, 3707, 2736, 8973, -4181, 13174, -4809, 9778, 21385, -2520, -60529, -3814, + 4179, 11359, 12974, 1271, 14726, -13101, 1608, -6784, -23633, 12898, -3814, -63927 }; const Word32 lvm_speech_fx[N_MIXTURES] = { /*Q10*/ - 32765, 33549, 33755, 32747, 31627, 26814 + 32765, 33549, 33755, 32747, 31627, 26814 }; const Word16 m_music_fx[N_MIXTURES*N_FEATURES] = { /*Q15*/ - 14804, 25446, 8882, 11624, 12963, 13563, 14794, 20567, 1033, 27373, 23772, 11713, - 15975, 20612, 7737, 12728, 14424, 15237, 16190, 15239, 2277, 30096, 28120, 11522, - 17631, 19827, 9280, 14111, 15555, 16289, 17009, 17271, 1132, 31186, 27733, 12469, - 15863, 24390, 7804, 11176, 11734, 11986, 12857, 23015, 713, 28823, 23782, 13779, - 10022, 22691, 12397, 15249, 15957, 16382, 17058, 15509, 4107, 23807, 22701, 12269, - 16842, 22819, 8062, 11248, 12283, 12978, 13722, 21178, 867, 30480, 25501, 12111 + 14804, 25446, 8882, 11624, 12963, 13563, 14794, 20567, 1033, 27373, 23772, 11713, + 15975, 20612, 7737, 12728, 14424, 15237, 16190, 15239, 2277, 30096, 28120, 11522, + 17631, 19827, 9280, 14111, 15555, 16289, 17009, 17271, 1132, 31186, 27733, 12469, + 15863, 24390, 7804, 11176, 11734, 11986, 12857, 23015, 713, 28823, 23782, 13779, + 10022, 22691, 12397, 15249, 15957, 16382, 17058, 15509, 4107, 23807, 22701, 12269, + 16842, 22819, 8062, 11248, 12283, 12978, 13722, 21178, 867, 30480, 25501, 12111 }; const Word32 invV_music_fx[N_MIXTURES*N_FEATURES*N_FEATURES] = { /*Q10*/ - -7878, -673, -2037, -885, -236, -667, 749, -1726, -20424, -859, 2463, 4011, - -673, -31356, -1591, -3048, -1872, 1277, -3806, 8836, 5555, -2031, -11076, -7329, - -2037, -1591, -65556, 42935, -11408, 12166, 751, 8792, 24077, -15804, -2546, -2517, - -885, -3048, 42935, -88483, 42957, -13081, 4776, 14411, 23734, -5735, 15306, 15210, - -236, -1872, -11408, 42957, -90738, 37950, -1795, 4021, -35266, 12445, 13655, 17403, - -667, 1277, 12166, -13081, 37950, -86289, 37943, 3429, -5655, 5664, 8658, -11, - 749, -3806, 751, 4776, -1795, 37943, -77863, -8515, -74265, 22313, 3842, 645, - -1726, 8836, 8792, 14411, 4021, 3429, -8515, -59311, -121235, 1622, -8500, 4967, - -20424, 5555, 24077, 23734, -35266, -5655, -74265, -121235, -5534279, 175865, 247781, -296138, - -859, -2031, -15804, -5735, 12445, 5664, 22313, 1622, 175865, -104343, -1168, 32220, - 2463, -11076, -2546, 15306, 13655, 8658, 3842, -8500, 247781, -1168, -79522, -45571, - 4011, -7329, -2517, 15210, 17403, -11, 645, 4967, -296138, 32220, -45571, -249005, - -10115, 613, -4406, -403, 731, 898, 350, -1995, -8975, -169, -1296, 1233, - 613, -30663, -12425, -1115, -1862, 2906, -2485, 12887, -8842, -12067, 4833, 3070, - -4406, -12425, -86550, 49625, -11519, 15386, -20054, 20873, -13684, 28341, 23152, -807, - -403, -1115, 49625, -131210, 81002, 1045, 3085, 8149, -11887, -3094, 43855, 14533, - 731, -1862, -11519, 81002, -226160, 115669, 9052, -6427, -19605, -20406, 7481, 6064, - 898, 2906, 15386, 1045, 115669, -281745, 150559, -5530, 271, -5717, 1673, 7674, - 350, -2485, -20054, 3085, 9052, 150559, -200735, -21872, -9366, 10471, -2190, 3083, - -1995, 12887, 20873, 8149, -6427, -5530, -21872, -111299, -29613, -27611, -54741, -9432, - -8975, -8842, -13684, -11887, -19605, 271, -9366, -29613, -616730, 74872, 189453, -79618, - -169, -12067, 28341, -3094, -20406, -5717, 10471, -27611, 74872, -359342, -12919, 29609, - -1296, 4833, 23152, 43855, 7481, 1673, -2190, -54741, 189453, -12919, -407670, -16961, - 1233, 3070, -807, 14533, 6064, 7674, 3083, -9432, -79618, 29609, -16961, -180700, - -12411, 5539, -1902, 92, 2813, 339, -114, -1078, -24097, -2938, -1812, 399, - 5539, -36224, -7229, -766, -2442, 2066, -2896, 8507, 16429, -11423, -12067, -191, - -1902, -7230, -115426, 44336, 11635, 13946, -3573, 22728, -73099, 119214, 70165, 4686, - 92, -766, 44336, -187908, 81624, 24838, 12765, 1471, -43322, -24066, 44669, 3543, - 2813, -2442, 11635, 81624, -295220, 104190, 52986, -3246, -146322, -78690, 34365, -2814, - 339, 2066, 13946, 24838, 104190, -347659, 169287, -4458, -127093, -94499, 42989, 5700, - -114, -2896, -3573, 12765, 52986, 169287, -310084, -18605, -27182, -19113, -2714, 11, - -1078, 8507, 22728, 1471, -3246, -4458, -18605, -69283, 40578, -47905, -135760, -6645, - -24097, 16429, -73099, -43322, -146322, -127093, -27182, 40578, -8241631, -71531, 1853193, -175523, - -2938, -11423, 119214, -24066, -78690, -94499, -19113, -47905, -71531, -1361618, -36609, 26675, - -1812, -12067, 70165, 44669, 34365, 42989, -2714, -135760, 1853193, -36609, -1337597, -83909, - 399, -191, 4686, 3543, -2814, 5700, 11, -6645, -175523, 26675, -83909, -223653, - -8809, 3326, -1275, -1509, 1423, 1222, -767, -3923, -65513, -5992, 9965, 3853, - 3326, -31906, -1905, 4114, -4704, 1138, -584, 10709, 104184, 6118, -30358, -5240, - -1275, -1905, -184413, 67973, -17415, 32246, -7121, 16051, -2994, -52989, 23547, 27770, - -1509, 4114, 67973, -160389, 86351, -8947, 13772, 8224, 3480, 2626, 24337, 1870, - 1423, -4704, -17415, 86351, -198772, 68001, 7361, 14025, 11152, 23137, 12598, 9972, - 1222, 1138, 32246, -8947, 68001, -166130, 57911, 17629, 118765, 39472, 1806, 7267, - -767, -584, -7121, 13772, 7361, 57911, -123203, 2059, 47920, 59494, 10484, -5066, - -3923, 10709, 16051, 8224, 14025, 17629, 2059, -90332, -367027, -30259, -20438, -3054, - -65513, 104184, -2994, 3480, 11152, 118765, 47920, -367027, -16854832, -181537, 903929, -95027, - -5992, 6118, -52989, 2626, 23137, 39472, 59494, -30259, -181537, -320917, -11497, 56536, - 9965, -30358, 23547, 24337, 12598, 1806, 10484, -20438, 903929, -11497, -197437, -16106, - 3853, -5240, 27770, 1870, 9972, 7267, -5066, -3054, -95027, 56536, -16106, -107942, - -14599, -2426, -4488, 2252, 20, -696, -2636, 5531, 1097, 109, 1359, 2742, - -2426, -22977, 1326, -4413, -6555, 199, -2249, 16239, 6914, -6267, 1335, -319, - -4488, 1326, -38846, 40605, -16372, -138, 6341, 2358, -5859, 1498, -1344, -3917, - 2252, -4413, 40605, -94592, 69176, -3799, -16812, -5416, -11189, -3107, 2060, -3508, - 20, -6555, -16372, 69176, -121278, 55283, 86, 3716, 11782, -9657, 3416, 549, - -696, 199, -138, -3799, 55283, -105539, 62225, 5299, 3619, 1933, -2511, 609, - -2636, -2249, 6341, -16812, 86, 62225, -79693, -7236, -9729, -2907, 2795, 57, - 5531, 16239, 2358, -5416, 3716, 5299, -7236, -52597, -40766, -5195, 2995, 11158, - 1097, 6914, -5859, -11189, 11782, 3619, -9729, -40766, -95884, 18462, 2795, -18509, - 109, -6267, 1498, -3107, -9657, 1933, -2907, -5195, 18462, -29138, 3027, 17268, - 1359, 1335, -1344, 2060, 3416, -2511, 2795, 2995, 2795, 3027, -10878, -6828, - 2742, -319, -3917, -3508, 549, 609, 57, 11158, -18509, 17268, -6828, -48324, - -9462, 2969, -1087, -1924, 1418, -350, 396, -3124, -35326, 682, 3248, 5848, - 2969, -29148, -2662, 2400, -3059, 2772, 847, 8375, 60040, -6778, -23223, -7694, - -1087, -2662, -172602, 83798, 2597, 33012, 3851, 12397, 81998, -81017, 15831, 35467, - -1924, 2400, 83798, -204141, 66003, 2928, 18028, 14706, 8557, 16030, 44283, 36177, - 1418, -3059, 2597, 66003, -202589, 47215, 19493, 10544, -4664, 46480, 10895, 18165, - -350, 2772, 33012, 2928, 47215, -198011, 76335, 14223, 123301, 70945, 1870, 8265, - 396, 847, 3851, 18028, 19493, 76335, -177594, -5345, 78880, 114804, -171, 3539, - -3124, 8375, 12397, 14706, 10544, 14223, -5345, -67596, -251454, -55035, -21890, 7263, - -35326, 60040, 81998, 8557, -4664, 123301, 78880, -251454, -12784658, -217014, 810245, -725111, - 682, -6778, -81017, 16030, 46480, 70945, 114804, -55035, -217014, -793758, -8106, 74886, - 3248, -23223, 15831, 44283, 10895, 1870, -171, -21890, 810245, -8106, -319630, -77833, - 5848, -7694, 35467, 36177, 18165, 8265, 3539, 7263, -725111, 74886, -77832, -481222 + -7878, -673, -2037, -885, -236, -667, 749, -1726, -20424, -859, 2463, 4011, + -673, -31356, -1591, -3048, -1872, 1277, -3806, 8836, 5555, -2031, -11076, -7329, + -2037, -1591, -65556, 42935, -11408, 12166, 751, 8792, 24077, -15804, -2546, -2517, + -885, -3048, 42935, -88483, 42957, -13081, 4776, 14411, 23734, -5735, 15306, 15210, + -236, -1872, -11408, 42957, -90738, 37950, -1795, 4021, -35266, 12445, 13655, 17403, + -667, 1277, 12166, -13081, 37950, -86289, 37943, 3429, -5655, 5664, 8658, -11, + 749, -3806, 751, 4776, -1795, 37943, -77863, -8515, -74265, 22313, 3842, 645, + -1726, 8836, 8792, 14411, 4021, 3429, -8515, -59311, -121235, 1622, -8500, 4967, + -20424, 5555, 24077, 23734, -35266, -5655, -74265, -121235, -5534279, 175865, 247781, -296138, + -859, -2031, -15804, -5735, 12445, 5664, 22313, 1622, 175865, -104343, -1168, 32220, + 2463, -11076, -2546, 15306, 13655, 8658, 3842, -8500, 247781, -1168, -79522, -45571, + 4011, -7329, -2517, 15210, 17403, -11, 645, 4967, -296138, 32220, -45571, -249005, + -10115, 613, -4406, -403, 731, 898, 350, -1995, -8975, -169, -1296, 1233, + 613, -30663, -12425, -1115, -1862, 2906, -2485, 12887, -8842, -12067, 4833, 3070, + -4406, -12425, -86550, 49625, -11519, 15386, -20054, 20873, -13684, 28341, 23152, -807, + -403, -1115, 49625, -131210, 81002, 1045, 3085, 8149, -11887, -3094, 43855, 14533, + 731, -1862, -11519, 81002, -226160, 115669, 9052, -6427, -19605, -20406, 7481, 6064, + 898, 2906, 15386, 1045, 115669, -281745, 150559, -5530, 271, -5717, 1673, 7674, + 350, -2485, -20054, 3085, 9052, 150559, -200735, -21872, -9366, 10471, -2190, 3083, + -1995, 12887, 20873, 8149, -6427, -5530, -21872, -111299, -29613, -27611, -54741, -9432, + -8975, -8842, -13684, -11887, -19605, 271, -9366, -29613, -616730, 74872, 189453, -79618, + -169, -12067, 28341, -3094, -20406, -5717, 10471, -27611, 74872, -359342, -12919, 29609, + -1296, 4833, 23152, 43855, 7481, 1673, -2190, -54741, 189453, -12919, -407670, -16961, + 1233, 3070, -807, 14533, 6064, 7674, 3083, -9432, -79618, 29609, -16961, -180700, + -12411, 5539, -1902, 92, 2813, 339, -114, -1078, -24097, -2938, -1812, 399, + 5539, -36224, -7229, -766, -2442, 2066, -2896, 8507, 16429, -11423, -12067, -191, + -1902, -7230, -115426, 44336, 11635, 13946, -3573, 22728, -73099, 119214, 70165, 4686, + 92, -766, 44336, -187908, 81624, 24838, 12765, 1471, -43322, -24066, 44669, 3543, + 2813, -2442, 11635, 81624, -295220, 104190, 52986, -3246, -146322, -78690, 34365, -2814, + 339, 2066, 13946, 24838, 104190, -347659, 169287, -4458, -127093, -94499, 42989, 5700, + -114, -2896, -3573, 12765, 52986, 169287, -310084, -18605, -27182, -19113, -2714, 11, + -1078, 8507, 22728, 1471, -3246, -4458, -18605, -69283, 40578, -47905, -135760, -6645, + -24097, 16429, -73099, -43322, -146322, -127093, -27182, 40578, -8241631, -71531, 1853193, -175523, + -2938, -11423, 119214, -24066, -78690, -94499, -19113, -47905, -71531, -1361618, -36609, 26675, + -1812, -12067, 70165, 44669, 34365, 42989, -2714, -135760, 1853193, -36609, -1337597, -83909, + 399, -191, 4686, 3543, -2814, 5700, 11, -6645, -175523, 26675, -83909, -223653, + -8809, 3326, -1275, -1509, 1423, 1222, -767, -3923, -65513, -5992, 9965, 3853, + 3326, -31906, -1905, 4114, -4704, 1138, -584, 10709, 104184, 6118, -30358, -5240, + -1275, -1905, -184413, 67973, -17415, 32246, -7121, 16051, -2994, -52989, 23547, 27770, + -1509, 4114, 67973, -160389, 86351, -8947, 13772, 8224, 3480, 2626, 24337, 1870, + 1423, -4704, -17415, 86351, -198772, 68001, 7361, 14025, 11152, 23137, 12598, 9972, + 1222, 1138, 32246, -8947, 68001, -166130, 57911, 17629, 118765, 39472, 1806, 7267, + -767, -584, -7121, 13772, 7361, 57911, -123203, 2059, 47920, 59494, 10484, -5066, + -3923, 10709, 16051, 8224, 14025, 17629, 2059, -90332, -367027, -30259, -20438, -3054, + -65513, 104184, -2994, 3480, 11152, 118765, 47920, -367027, -16854832, -181537, 903929, -95027, + -5992, 6118, -52989, 2626, 23137, 39472, 59494, -30259, -181537, -320917, -11497, 56536, + 9965, -30358, 23547, 24337, 12598, 1806, 10484, -20438, 903929, -11497, -197437, -16106, + 3853, -5240, 27770, 1870, 9972, 7267, -5066, -3054, -95027, 56536, -16106, -107942, + -14599, -2426, -4488, 2252, 20, -696, -2636, 5531, 1097, 109, 1359, 2742, + -2426, -22977, 1326, -4413, -6555, 199, -2249, 16239, 6914, -6267, 1335, -319, + -4488, 1326, -38846, 40605, -16372, -138, 6341, 2358, -5859, 1498, -1344, -3917, + 2252, -4413, 40605, -94592, 69176, -3799, -16812, -5416, -11189, -3107, 2060, -3508, + 20, -6555, -16372, 69176, -121278, 55283, 86, 3716, 11782, -9657, 3416, 549, + -696, 199, -138, -3799, 55283, -105539, 62225, 5299, 3619, 1933, -2511, 609, + -2636, -2249, 6341, -16812, 86, 62225, -79693, -7236, -9729, -2907, 2795, 57, + 5531, 16239, 2358, -5416, 3716, 5299, -7236, -52597, -40766, -5195, 2995, 11158, + 1097, 6914, -5859, -11189, 11782, 3619, -9729, -40766, -95884, 18462, 2795, -18509, + 109, -6267, 1498, -3107, -9657, 1933, -2907, -5195, 18462, -29138, 3027, 17268, + 1359, 1335, -1344, 2060, 3416, -2511, 2795, 2995, 2795, 3027, -10878, -6828, + 2742, -319, -3917, -3508, 549, 609, 57, 11158, -18509, 17268, -6828, -48324, + -9462, 2969, -1087, -1924, 1418, -350, 396, -3124, -35326, 682, 3248, 5848, + 2969, -29148, -2662, 2400, -3059, 2772, 847, 8375, 60040, -6778, -23223, -7694, + -1087, -2662, -172602, 83798, 2597, 33012, 3851, 12397, 81998, -81017, 15831, 35467, + -1924, 2400, 83798, -204141, 66003, 2928, 18028, 14706, 8557, 16030, 44283, 36177, + 1418, -3059, 2597, 66003, -202589, 47215, 19493, 10544, -4664, 46480, 10895, 18165, + -350, 2772, 33012, 2928, 47215, -198011, 76335, 14223, 123301, 70945, 1870, 8265, + 396, 847, 3851, 18028, 19493, 76335, -177594, -5345, 78880, 114804, -171, 3539, + -3124, 8375, 12397, 14706, 10544, 14223, -5345, -67596, -251454, -55035, -21890, 7263, + -35326, 60040, 81998, 8557, -4664, 123301, 78880, -251454, -12784658, -217014, 810245, -725111, + 682, -6778, -81017, 16030, 46480, 70945, 114804, -55035, -217014, -793758, -8106, 74886, + 3248, -23223, 15831, 44283, 10895, 1870, -171, -21890, 810245, -8106, -319630, -77833, + 5848, -7694, 35467, 36177, 18165, 8265, 3539, 7263, -725111, 74886, -77832, -481222 }; const Word32 lvm_music_fx[N_MIXTURES] = { /*Q10*/ - 28603, 31076, 35357, 31989, 20938, 34395 + 28603, 31076, 35357, 31989, 20938, 34395 }; const Word16 m_noise_fx[N_MIXTURES*N_FEATURES] = { /*Q15*/ - 14825, 18681, 7930, 11230, 13228, 13602, 14556, 14377, 1133, 29263, 26842, 13270, - 14312, 14992, 9378, 12891, 14075, 14581, 15548, 12386, 1050, 32143, 28322, 12379, - 18179, 16617, 8015, 13153, 13932, 14462, 15329, 11848, 1033, 31841, 28406, 12222, - 15822, 17883, 3231, 8086, 9983, 9933, 11537, 11904, 1018, 29549, 27473, 11111, - 13821, 16109, 8734, 12035, 13351, 13603, 15024, 12957, 1163, 31179, 28243, 11865, - 13845, 15577, 10545, 14292, 15353, 15784, 16567, 12750, 1589, 31695, 28796, 13420 + 14825, 18681, 7930, 11230, 13228, 13602, 14556, 14377, 1133, 29263, 26842, 13270, + 14312, 14992, 9378, 12891, 14075, 14581, 15548, 12386, 1050, 32143, 28322, 12379, + 18179, 16617, 8015, 13153, 13932, 14462, 15329, 11848, 1033, 31841, 28406, 12222, + 15822, 17883, 3231, 8086, 9983, 9933, 11537, 11904, 1018, 29549, 27473, 11111, + 13821, 16109, 8734, 12035, 13351, 13603, 15024, 12957, 1163, 31179, 28243, 11865, + 13845, 15577, 10545, 14292, 15353, 15784, 16567, 12750, 1589, 31695, 28796, 13420 }; const Word32 invV_noise_fx[N_MIXTURES*N_FEATURES*N_FEATURES] = { /*Q10*/ - -11129, -775, -807, 4750, -4310, -1632, 1694, 530, -25134, -2399, 1632, 1938, - -775, -43700, -5296, -23144, -4086, -2008, 9445, 12956, 17119, 10623, -18169, -14373, - -807, -5296, -117924, 78859, -23526, 22681, -7637, 52382, 20661, -1131, 18004, -18669, - 4750, -23144, 78859, -165973, 70704, -954, 10160, 6713, 50481, 19307, -10190, 16924, - -4310, -4086, -23526, 70704, -186160, 114906, -28994, 9999, 17677, -18372, -20805, -12577, - -1632, -2008, 22681, -954, 114906, -235840, 123708, -3753, 21616, 9200, 15641, -10616, - 1694, 9445, -7637, 10160, -28994, 123708, -156081, -1564, -7627, 5159, 14184, -12573, - 530, 12956, 52382, 6713, 9999, -3753, -1564, -116541, -130257, -2892, -51260, -1433, - -25134, 17119, 20661, 50481, 17677, 21616, -7627, -130257, -6857531, -23164, 425725, -172307, - -2399, 10623, -1131, 19307, -18372, 9200, 5159, -2892, -23164, -157605, 9307, 20639, - 1632, -18169, 18004, -10190, -20805, 15641, 14184, -51260, 425725, 9307, -184817, -2232, - 1938, -14373, -18669, 16924, -12577, -10616, -12573, -1433, -172307, 20639, -2232, -94498, - -23585, -1283, 2220, 5814, -1063, -5524, 5040, -408, -7744, 65700, -4948, 1221, - -1283, -102238, 18435, -18156, -6216, 17104, -1870, 25097, 97427, 32242, -77595, -4567, - 2220, 18435, -305438, 139861, 24123, 32851, -45614, 45538, 124040, 301172, -22649, 3625, - 5814, -18156, 139861, -565373, 242575, 46852, 50718, -18774, -159188, 141029, 89911, 9768, - -1063, -6216, 24123, 242575, -798475, 256535, 104095, 9375, -84525, -408528, 98204, 4495, - -5524, 17104, 32851, 46852, 256535, -845586, 312678, -6990, 50242, -543393, -42629, 99, - 5040, -1870, -45614, 50718, 104095, 312678, -732093, 14409, 83177, -140864, -2169, -2321, - -408, 25097, 45538, -18774, 9375, -6990, 14409, -314037, 273543, -30059, -253352, -3462, - -7744, 97427, 124040, -159188, -84525, 50242, 83177, 273543, -19301626, -952154, 3668367, -93870, - 65700, 32242, 301172, 141029, -408528, -543393, -140864, -30059, -952154, -16033274, -164405, -24189, - -4948, -77595, -22649, 89911, 98204, -42629, -2169, -253352, 3668367, -164405, -2501887, -105127, - 1221, -4567, 3625, 9768, 4495, 99, -2321, -3462, -93870, -24189, -105127, -252171, - -11556, 5444, 1053, 1823, -1754, -6509, 3535, -483, 5751, 22898, -4369, 2503, - 5444, -61418, -46603, 523, -4221, 5377, -14703, 2336, 4414, 4601, 17795, 5358, - 1053, -46603, -197022, 61944, 30015, 11139, -14163, 4583, 14704, 174734, 105587, 3797, - 1823, 523, 61944, -579713, 310766, -24876, -8601, -1522, -38055, -308764, 10254, 11526, - -1754, -4221, 30015, 310766, -873205, 294102, 7806, 2338, -28081, -507955, -5526, -1671, - -6509, 5377, 11139, -24876, 294102, -740664, 309186, -19342, -50840, -143800, 27527, 4324, - 3535, -14703, -14163, -8601, 7806, 309186, -508227, 24986, 208442, -230010, -48336, -9651, - -483, 2336, 4583, -1522, 2338, -19342, 24986, -362502, 140055, -118693, -134546, 982, - 5751, 4414, 14704, -38055, -28081, -50840, 208442, 140055, -20820834, -328791, 3081671, -99923, - 22898, 4601, 174734, -308764, -507955, -143800, -230010, -118693, -328791, -7236926, -225976, -47887, - -4369, 17795, 105587, 10254, -5526, 27527, -48336, -134546, 3081671, -225976, -2500626, -124929, - 2503, 5358, 3797, 11526, -1671, 4324, -9651, 982, -99923, -47887, -124929, -277469, - -14533, 3263, -8141, 13301, 5586, 1808, -5289, 472, 7371, -21379, -2460, 596, - 3263, -46002, -56596, 9198, -765, 13994, 5247, 2629, -14758, -21574, 5644, 3817, - -8141, -56596, -895669, 406276, -247505, 72418, -246462, 32532, -190899, -74267, 59747, 10271, - 13301, 9198, 406276, -551172, 137309, 34772, -5367, 41269, 67372, 262339, 42457, 60892, - 5586, -765, -247505, 137309, -964866, 393695, 36960, 5148, 114354, 66434, -19640, 18501, - 1808, 13994, 72418, 34772, 393695, -906317, 366933, 14058, 76374, 284422, 16253, 32973, - -5289, 5247, -246462, -5367, 36960, 366933, -711303, 23465, 84856, 157990, 2319, 21580, - 472, 2629, 32532, 41269, 5148, 14058, 23465, -349612, -74011, -89655, -17686, 7616, - 7371, -14758, -190899, 67372, 114354, 76374, 84856, -74011, -17027780, -264311, 396822, -266476, - -21379, -21574, -74267, 262339, 66434, 284422, 157990, -89655, -264311, -871539, 3553, 2308, - -2460, 5644, 59747, 42457, -19640, 16253, 2319, -17686, 396822, 3553, -334956, -46272, - 596, 3817, 10271, 60892, 18501, 32973, 21580, 7616, -266476, 2308, -46272, -357254, - -21040, -1263, -6696, 8169, -1272, -4427, 4142, -8459, -63196, -17218, 710, 2270, - -1263, -83196, -34319, -27267, 2213, -240, -783, 22287, 136898, 9589, -27942, -6781, - -6696, -34319, -329281, 107754, 677, -33332, -46218, 43055, -204958, -43031, 204918, 20438, - 8169, -27267, 107754, -371373, 103141, 10674, 46337, -3299, -65216, -42038, -5280, 13005, - -1272, 2213, 677, 103141, -420124, 194457, 1575, 22157, -26994, 36729, 47504, 13852, - -4427, -240, -33332, 10674, 194457, -368592, 152851, 14172, 107043, 44274, -23917, -8922, - 4142, -783, -46218, 46337, 1575, 152851, -280668, -8210, 40158, 24389, 13385, 8410, - -8459, 22287, 43055, -3299, 22157, 14172, -8210, -256064, 79772, -1255, -101174, 759, - -63196, 136898, -204958, -65216, -26994, 107043, 40158, 79772, -13100212, 263557, 2000831, -242675, - -17218, 9589, -43031, -42038, 36729, 44274, 24389, -1255, 263557, -1223057, -216580, -23199, - 710, -27942, 204918, -5280, 47504, -23917, 13385, -101174, 2000831, -216580, -1303910, -90175, - 2270, -6781, 20438, 13005, 13852, -8922, 8410, 759, -242675, -23199, -90175, -372746, - -24335, -321, -1426, 1524, 1959, -4164, 7012, -3148, -7859, 9391, 3193, 2194, - -321, -90890, -9068, -27277, 5303, 10922, 2298, 22512, 17201, 4798, 13388, -2773, - -1426, -9068, -180137, 85478, 42242, 14714, -12908, 34197, 67246, 40663, 36965, -9792, - 1524, -27277, 85478, -392290, 221884, 12492, 33161, -14359, 7950, -103145, -29210, -5361, - 1959, 5303, 42242, 221884, -600963, 259592, 30301, 7895, -32577, -115360, 20766, -7273, - -4164, 10922, 14714, 12492, 259592, -611459, 304095, 6323, -42968, -37072, -21092, -15235, - 7012, 2298, -12908, 33161, 30301, 304095, -467758, 26953, -35709, 29107, 35819, -8754, - -3148, 22512, 34197, -14359, 7895, 6323, 26953, -271919, 2988, 852, -128460, -11407, - -7859, 17201, 67246, 7950, -32577, -42968, -35709, 2988, -1773460, -215853, 756954, -99883, - 9391, 4798, 40663, -103145, -115360, -37072, 29107, 852, -215853, -2382074, -108833, 1061, - 3193, 13388, 36965, -29210, 20766, -21092, 35819, -128460, 756954, -108833, -1923617, -116204, - 2194, -2773, -9792, -5361, -7273, -15235, -8754, -11407, -99883, 1061, -116204, -103840 + -11129, -775, -807, 4750, -4310, -1632, 1694, 530, -25134, -2399, 1632, 1938, + -775, -43700, -5296, -23144, -4086, -2008, 9445, 12956, 17119, 10623, -18169, -14373, + -807, -5296, -117924, 78859, -23526, 22681, -7637, 52382, 20661, -1131, 18004, -18669, + 4750, -23144, 78859, -165973, 70704, -954, 10160, 6713, 50481, 19307, -10190, 16924, + -4310, -4086, -23526, 70704, -186160, 114906, -28994, 9999, 17677, -18372, -20805, -12577, + -1632, -2008, 22681, -954, 114906, -235840, 123708, -3753, 21616, 9200, 15641, -10616, + 1694, 9445, -7637, 10160, -28994, 123708, -156081, -1564, -7627, 5159, 14184, -12573, + 530, 12956, 52382, 6713, 9999, -3753, -1564, -116541, -130257, -2892, -51260, -1433, + -25134, 17119, 20661, 50481, 17677, 21616, -7627, -130257, -6857531, -23164, 425725, -172307, + -2399, 10623, -1131, 19307, -18372, 9200, 5159, -2892, -23164, -157605, 9307, 20639, + 1632, -18169, 18004, -10190, -20805, 15641, 14184, -51260, 425725, 9307, -184817, -2232, + 1938, -14373, -18669, 16924, -12577, -10616, -12573, -1433, -172307, 20639, -2232, -94498, + -23585, -1283, 2220, 5814, -1063, -5524, 5040, -408, -7744, 65700, -4948, 1221, + -1283, -102238, 18435, -18156, -6216, 17104, -1870, 25097, 97427, 32242, -77595, -4567, + 2220, 18435, -305438, 139861, 24123, 32851, -45614, 45538, 124040, 301172, -22649, 3625, + 5814, -18156, 139861, -565373, 242575, 46852, 50718, -18774, -159188, 141029, 89911, 9768, + -1063, -6216, 24123, 242575, -798475, 256535, 104095, 9375, -84525, -408528, 98204, 4495, + -5524, 17104, 32851, 46852, 256535, -845586, 312678, -6990, 50242, -543393, -42629, 99, + 5040, -1870, -45614, 50718, 104095, 312678, -732093, 14409, 83177, -140864, -2169, -2321, + -408, 25097, 45538, -18774, 9375, -6990, 14409, -314037, 273543, -30059, -253352, -3462, + -7744, 97427, 124040, -159188, -84525, 50242, 83177, 273543, -19301626, -952154, 3668367, -93870, + 65700, 32242, 301172, 141029, -408528, -543393, -140864, -30059, -952154, -16033274, -164405, -24189, + -4948, -77595, -22649, 89911, 98204, -42629, -2169, -253352, 3668367, -164405, -2501887, -105127, + 1221, -4567, 3625, 9768, 4495, 99, -2321, -3462, -93870, -24189, -105127, -252171, + -11556, 5444, 1053, 1823, -1754, -6509, 3535, -483, 5751, 22898, -4369, 2503, + 5444, -61418, -46603, 523, -4221, 5377, -14703, 2336, 4414, 4601, 17795, 5358, + 1053, -46603, -197022, 61944, 30015, 11139, -14163, 4583, 14704, 174734, 105587, 3797, + 1823, 523, 61944, -579713, 310766, -24876, -8601, -1522, -38055, -308764, 10254, 11526, + -1754, -4221, 30015, 310766, -873205, 294102, 7806, 2338, -28081, -507955, -5526, -1671, + -6509, 5377, 11139, -24876, 294102, -740664, 309186, -19342, -50840, -143800, 27527, 4324, + 3535, -14703, -14163, -8601, 7806, 309186, -508227, 24986, 208442, -230010, -48336, -9651, + -483, 2336, 4583, -1522, 2338, -19342, 24986, -362502, 140055, -118693, -134546, 982, + 5751, 4414, 14704, -38055, -28081, -50840, 208442, 140055, -20820834, -328791, 3081671, -99923, + 22898, 4601, 174734, -308764, -507955, -143800, -230010, -118693, -328791, -7236926, -225976, -47887, + -4369, 17795, 105587, 10254, -5526, 27527, -48336, -134546, 3081671, -225976, -2500626, -124929, + 2503, 5358, 3797, 11526, -1671, 4324, -9651, 982, -99923, -47887, -124929, -277469, + -14533, 3263, -8141, 13301, 5586, 1808, -5289, 472, 7371, -21379, -2460, 596, + 3263, -46002, -56596, 9198, -765, 13994, 5247, 2629, -14758, -21574, 5644, 3817, + -8141, -56596, -895669, 406276, -247505, 72418, -246462, 32532, -190899, -74267, 59747, 10271, + 13301, 9198, 406276, -551172, 137309, 34772, -5367, 41269, 67372, 262339, 42457, 60892, + 5586, -765, -247505, 137309, -964866, 393695, 36960, 5148, 114354, 66434, -19640, 18501, + 1808, 13994, 72418, 34772, 393695, -906317, 366933, 14058, 76374, 284422, 16253, 32973, + -5289, 5247, -246462, -5367, 36960, 366933, -711303, 23465, 84856, 157990, 2319, 21580, + 472, 2629, 32532, 41269, 5148, 14058, 23465, -349612, -74011, -89655, -17686, 7616, + 7371, -14758, -190899, 67372, 114354, 76374, 84856, -74011, -17027780, -264311, 396822, -266476, + -21379, -21574, -74267, 262339, 66434, 284422, 157990, -89655, -264311, -871539, 3553, 2308, + -2460, 5644, 59747, 42457, -19640, 16253, 2319, -17686, 396822, 3553, -334956, -46272, + 596, 3817, 10271, 60892, 18501, 32973, 21580, 7616, -266476, 2308, -46272, -357254, + -21040, -1263, -6696, 8169, -1272, -4427, 4142, -8459, -63196, -17218, 710, 2270, + -1263, -83196, -34319, -27267, 2213, -240, -783, 22287, 136898, 9589, -27942, -6781, + -6696, -34319, -329281, 107754, 677, -33332, -46218, 43055, -204958, -43031, 204918, 20438, + 8169, -27267, 107754, -371373, 103141, 10674, 46337, -3299, -65216, -42038, -5280, 13005, + -1272, 2213, 677, 103141, -420124, 194457, 1575, 22157, -26994, 36729, 47504, 13852, + -4427, -240, -33332, 10674, 194457, -368592, 152851, 14172, 107043, 44274, -23917, -8922, + 4142, -783, -46218, 46337, 1575, 152851, -280668, -8210, 40158, 24389, 13385, 8410, + -8459, 22287, 43055, -3299, 22157, 14172, -8210, -256064, 79772, -1255, -101174, 759, + -63196, 136898, -204958, -65216, -26994, 107043, 40158, 79772, -13100212, 263557, 2000831, -242675, + -17218, 9589, -43031, -42038, 36729, 44274, 24389, -1255, 263557, -1223057, -216580, -23199, + 710, -27942, 204918, -5280, 47504, -23917, 13385, -101174, 2000831, -216580, -1303910, -90175, + 2270, -6781, 20438, 13005, 13852, -8922, 8410, 759, -242675, -23199, -90175, -372746, + -24335, -321, -1426, 1524, 1959, -4164, 7012, -3148, -7859, 9391, 3193, 2194, + -321, -90890, -9068, -27277, 5303, 10922, 2298, 22512, 17201, 4798, 13388, -2773, + -1426, -9068, -180137, 85478, 42242, 14714, -12908, 34197, 67246, 40663, 36965, -9792, + 1524, -27277, 85478, -392290, 221884, 12492, 33161, -14359, 7950, -103145, -29210, -5361, + 1959, 5303, 42242, 221884, -600963, 259592, 30301, 7895, -32577, -115360, 20766, -7273, + -4164, 10922, 14714, 12492, 259592, -611459, 304095, 6323, -42968, -37072, -21092, -15235, + 7012, 2298, -12908, 33161, 30301, 304095, -467758, 26953, -35709, 29107, 35819, -8754, + -3148, 22512, 34197, -14359, 7895, 6323, 26953, -271919, 2988, 852, -128460, -11407, + -7859, 17201, 67246, 7950, -32577, -42968, -35709, 2988, -1773460, -215853, 756954, -99883, + 9391, 4798, 40663, -103145, -115360, -37072, 29107, 852, -215853, -2382074, -108833, 1061, + 3193, 13388, 36965, -29210, 20766, -21092, 35819, -128460, 756954, -108833, -1923617, -116204, + 2194, -2773, -9792, -5361, -7273, -15235, -8754, -11407, -99883, 1061, -116204, -103840 }; const Word32 lvm_noise_fx[N_MIXTURES] = { /*Q10*/ - 29413, 42169, 40240, 39433, 37918, 36348 + 29413, 42169, 40240, 39433, 37918, 36348 }; /* Mel filterbank */ const Word16 mel_fb_start[NB_MEL_BANDS] = { 1, 1, 2, 3, 4, 5, 5, 7, 8, 9, 10, 11, 13, 14, 16, 17, 19, 21, 23, 25, 28, 30, 33, 35, 38, 41, 45, 48, 52, 56, 60, 65, 69, 74, 80, 86, 92, 98, 105, 112 -}; // Q0 +}; // Q0 const Word16 mel_fb_len[NB_MEL_BANDS] = { 1, 2, 2, 2, 1, 2, 3, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 7, 7, 7, 8, 8, 9, 9, 9, 11, 12, 12, 12, 13, 14, 15, 16 -}; // Q0 +}; // Q0 const Word32 mel_fb_fx[246] = { 1306887040, 840596608, 701826176, 1445657472, 297866656, 1849617024, 67613584, 2079870080, @@ -855,7 +855,7 @@ const Word32 mel_fb_fx[246] = 1556051584, 1278092800, 1002327744, 728722176, 457242624, 187856208, 28791110, 311244128, 591432000, 869390912, 1145155968, 1418761472, 1690241024, 1959627392, 2068014592, 1802719104, 1539422848, 1278095872, 1018709056, 761233728, 505641920, 251906256, -}; // Q30 +}; // Q30 const Word32 dct_mtx_fx[NB_MEL_BANDS * NB_MEL_COEF] = { //Q31 479821728, 476863456, 470965184, 462163232, 450511904, 436083040, 418965536, 399264992, @@ -977,56 +977,56 @@ const Word16 huffnorm_e[32] = 1062, 550, 314, 274, 273, 272, 156, 79, 69, 38, 18, 40, 5, 3, 0, 1, 3, 4, 11, 21, 41, 32, 35, 67, 133, 264, 530, 315, 551, 2126, 4254, 4255 -}; // Q0 +}; // Q0 const Word16 huffnorm_n[32] = { 14831, 14830, 7414, 3706, 593, 927, 462, 297, 230, 116, 50, 36, 13, 8, 5, 1, 0, 2, 6, 7, 15, 19, 24, 56, 59, 51, 114, 117, 75, 149, 592, 1852 -}; // Q0 +}; // Q0 const Word16 huffsizn_e[32] = { 13, 12, 11, 11, 11, 11, 10, 9, 9, 8, 7, 6, 5, 4, 3, 2, 2, 3, 4, 5, 6, 8, 8, 9, 10, 11, 12, 11, 12, 14, 15, 15 -}; // Q0 +}; // Q0 const Word16 huffsizn_n[32] = { 14, 14, 13, 12, 10, 10, 9, 9, 8, 7, 7, 6, 5, 4, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6, 6, 7, 7, 7, 7, 8, 10, 11 -}; // Q0 +}; // Q0 const Word16 resize_huffnorm[32] = { 0, 0, 0, 0, 0, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 5, 11, 23, 47, 95, 191, 383, 767, 2047, 0, 0, 0, 0, 0, 0 -}; // Q0 +}; // Q0 const Word16 huffnorm[32] = { 26, 58, 90, 122, 27, 59, 91, 123, 12, 28, 44, 60, 2, 6, 4, 6, 0, 2, 10, 14, 14, 30, 46, 62, 30, 62, 94, 126, 31, 63, 95, 127 -}; // Q0 +}; // Q0 const Word16 pgain_huffnorm[32] = { 1, 1, 2, 3, 3, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4, 5, 3, 2, 3, 3, 4, 5, 0, 1 -}; // Q0 +}; // Q0 const Word16 hessize[8]= { 7, 5, 3, 2, 1, 4, 6, 7 -}; // Q0 +}; // Q0 const Word16 hescode[8]= { 11, 3, 1, 1, 1, 0, 4, 10 -}; // Q0 +}; // Q0 /*----------------------------------------------------------------------------------* * BWD @@ -1053,15 +1053,15 @@ const Word16 hann_window_320_fx[BWD_TOTAL_WIDTH / 2] = 7761, 7796, 7830, 7863, 7894, 7923, 7951, 7978, 8003, 8026, 8048, 8068, 8087, 8105, 8121, 8135, 8147, 8158, 8168, 8176, 8182, 8187, 8190, 8192 -}; // Q13 +}; // Q13 /*----------------------------------------------------------------------------------* * Starting line for the noise measurement in TCX. *----------------------------------------------------------------------------------*/ -const Word16 startLineWB[N_TCX_STARTLINE_NOISE_WB] = { 8, 23, 36, 45, 66, 128 /* 13.2kbps */, 200, 320, 320, 320 /* 48kbps */, 320 }; // Q0 +const Word16 startLineWB[N_TCX_STARTLINE_NOISE_WB] = { 8, 23, 36, 45, 66, 128 /* 13.2kbps */, 200, 320, 320, 320 /* 48kbps */, 320 }; // Q0 -const Word16 startLineSWB[N_TCX_STARTLINE_NOISE_SWB] = { 8, 44, 96 /* 13.2kbps */, 160, 320, 320, 256 /* 48kbps */, 341, 640 }; // Q0 +const Word16 startLineSWB[N_TCX_STARTLINE_NOISE_SWB] = { 8, 44, 96 /* 13.2kbps */, 160, 320, 320, 256 /* 48kbps */, 341, 640 }; // Q0 const Word32 LS_MIN_SILENCE_SNR[4] = { 251658233/* 7.5 Q25 */, 251658233/* 7.5 Q25 */, 228170137/* 6.8 Q25 */,228170137/* 6.8 Q25 */ }; @@ -1081,7 +1081,7 @@ const UWord8 E_ROM_tipos[40] = 3, 0, 1, 2, 0, 1, 2, 3, /* end point for 24 pulses &ipos[35], 4th iter */ 1, 2, 3, 0 /* end point for 36 pulses &ipos[39], 2nd iter */ -}; // Q0 +}; // Q0 /* pow(3 * i + 1, 0.3) / pow(256 - 1, 0.3) */ const Word16 Weight[86] = @@ -1094,7 +1094,7 @@ const Word16 Weight[86] = 0x7D61, 0x7DDA, 0x7E51, 0x7EC8, 0x7F3E, 0x7FB3, 0x7FFF }; -const Word16 BAND_SCALE_AJ[5] = { 3,3,5,6,6 }; /* {OFFSET, NB, WB, SWB, FB} Q0*/ +const Word16 BAND_SCALE_AJ[5] = { 3,3,5,6,6 }; /* {OFFSET, NB, WB, SWB, FB} Q0*/ /* Inv possible delta used in gaus_enc (1.0/(1.0+delta*delta)) and delta = [1,7] */ const Word16 inv_delta_tab[7] = /*Q15*/ diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 5fd11bd31..c3482e65d 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -25,7 +25,7 @@ void Scale_wsp( Word16 *old_wsp, /* i/o: Old weighted speech buffer */ Word16 *mem_decim2, /* i/o: Decimation buffer */ Word16 *old_wsp12k8, /* i/o: wsp memory @ 12.8 kHz used in pitol2 */ - const Word16 Len_p_look /* i : L_frame + look ahead Q0*/ + const Word16 Len_p_look /* i : L_frame + look ahead Q0*/ ) { Word16 max, i, tmp; @@ -72,17 +72,17 @@ void Scale_wsp( * Find scaled preemphasis vector and its scaling factor *-------------------------------------------------------------------*/ void Preemph_scaled( - Word16 new_speech[], /* i : Speech to scale already on 14 bits Q_new*/ - Word16 *Q_new, /* o : Scaling factor */ - Word16 *mem_preemph, /* i/o: Preemph memory Q(-1)*/ - Word16 *Q_max, /* i/o: Q_new limitation */ - const Word16 Preemph_factor, /* i : Preemphasis factor Q15*/ - const Word16 bits, /* i : Bit to remove from the output to (15-bits) */ - const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */ - const Word16 L_Q_mem, /* i : Number of old scaling to take into account Q0*/ - const Word16 Lframe, /* i : Frame length Q0*/ - const Word16 last_coder_type, /* i : coder_type Q0*/ - const Word16 Search_scaling /* i : enable the search of a proper scaling factor Q0*/ + Word16 new_speech[], /* i : Speech to scale already on 14 bits Q_new*/ + Word16 *Q_new, /* o : Scaling factor */ + Word16 *mem_preemph, /* i/o: Preemph memory Q(-1)*/ + Word16 *Q_max, /* i/o: Q_new limitation */ + const Word16 Preemph_factor, /* i : Preemphasis factor Q15*/ + const Word16 bits, /* i : Bit to remove from the output to (15-bits) */ + const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */ + const Word16 L_Q_mem, /* i : Number of old scaling to take into account Q0*/ + const Word16 Lframe, /* i : Frame length Q0*/ + const Word16 last_coder_type, /* i : coder_type Q0*/ + const Word16 Search_scaling /* i : enable the search of a proper scaling factor Q0*/ ) { Word16 i, tmp_fixed; diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 68dc2038e..4efdd6f7c 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -52,14 +52,14 @@ static void convolve_tc2_fx( const Word16 g[], const Word16 h[], Word16 y[], con * * *---------------------------------------------------------------------------------------*/ void set_impulse_fx( - const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ - const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ - Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ - Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ - Word16 *imp_shape, /* o : adaptive codebook index Q0*/ - Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ - Word32 *gain_trans_fx, /* o : transition gain Q7*/ - Word16 Q_new /* i : Current scaling */ + const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ + const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ + Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ + Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ + Word16 *imp_shape, /* o : adaptive codebook index Q0*/ + Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ + Word32 *gain_trans_fx, /* o : transition gain Q7*/ + Word16 Q_new /* i : Current scaling */ ) { Word16 i, j, m; @@ -333,12 +333,12 @@ static void convolve_tc2_fx( * correlation for different vectors' lengths *-------------------------------------------------------------------*/ static void correlate_tc_fx( - const Word16 *x, /* i: target signal Qx*/ - Word16 *y, /* o: correlation between x[] and h[] -Q3*/ - const Word16 *h, /* i: impulse response (of weighted synthesis filter) Q15*/ - const Word16 start, /* i: index of iterest Q0*/ - const Word16 L_1, /* i: vector size Q0*/ - const Word16 L_2 /* i: index of interest Q0*/ + const Word16 *x, /* i: target signal Qx*/ + Word16 *y, /* o: correlation between x[] and h[] -Q3*/ + const Word16 *h, /* i: impulse response (of weighted synthesis filter) Q15*/ + const Word16 start, /* i: index of iterest Q0*/ + const Word16 L_1, /* i: vector size Q0*/ + const Word16 L_2 /* i: index of interest Q0*/ ) { Word16 i, j; diff --git a/lib_enc/spec_center_fx.c b/lib_enc/spec_center_fx.c index 1e908d0c3..4c14c5579 100644 --- a/lib_enc/spec_center_fx.c +++ b/lib_enc/spec_center_fx.c @@ -18,9 +18,9 @@ *-------------------------------------------------------------------*/ void spec_center_fx( - Word32 *sb_power, /* i : energy of sub-band divided uniformly Q31 */ - Word16 *sp_center, /* o : spectral center Q10 */ - const Word32 bw_index, /* i : band width Q0 */ + Word32 *sb_power, /* i : energy of sub-band divided uniformly Q31 */ + Word16 *sp_center, /* o : spectral center Q10 */ + const Word32 bw_index, /* i : band width Q0 */ const Word16 Q_sb_p /* i : the Scaling of sb_power*/ ) { @@ -64,7 +64,7 @@ void spec_center_fx( frame_power_nb = frame_power; move32(); - /*+0.1 */ + /*+0.1 */ Q_t_sc = sub( Q_sb_p, 10 ); IF( GE_16( Q_t_sc, 34 ) ) { @@ -144,7 +144,7 @@ void spec_center_fx( t_sp_center = L_add( L_shr( sb_power_mlt, 8 ), t_sp_center ); frame_power = L_add( sb_power_shr[i], frame_power ); /*1-19 */ } - /*+0.1 */ + /*+0.1 */ Q_t_sc = sub( Q_sb_p, 13 ); IF( GE_16( Q_t_sc, 34 ) ) @@ -218,7 +218,7 @@ void spec_center_fx( frame_power = L_add( sb_power_shr[i], frame_power ); /*1-23 */ } - /*+0.1 */ + /*+0.1 */ Q_t_sc = sub( Q_sb_p, 14 ); IF( GE_16( Q_t_sc, 34 ) ) @@ -314,7 +314,7 @@ void spec_center_fx( { sb_power_mlt = Mpy_32_16_1( sb_power[i], i_t_1[i - 1] ); t_sp_center = L_add( L_shr( sb_power_mlt, 6 ), t_sp_center ); - frame_power = L_add( sb_power_shr[i], frame_power ); /*1-9 */ + frame_power = L_add( sb_power_shr[i], frame_power ); /*1-9 */ } IF( frame_power == 0 ) { diff --git a/lib_enc/spec_flatness_fx.c b/lib_enc/spec_flatness_fx.c index d7bd9a6e9..53381c2f1 100644 --- a/lib_enc/spec_flatness_fx.c +++ b/lib_enc/spec_flatness_fx.c @@ -100,7 +100,7 @@ void spec_flatness_fx( } sums = MUL_F( sums, 0x0888 ); - /*+0.1 */ + /*+0.1 */ IF( GE_16( prods_Q, 34 ) ) { prods = L_shr( prods, sub( prods_Q, 33 ) ); @@ -186,7 +186,7 @@ void spec_flatness_fx( } sums = MUL_F( sums, 0x0666 ); - /*+0.1 */ + /*+0.1 */ IF( GE_16( prods_Q, 34 ) ) { prods = L_shr( prods, sub( prods_Q, 33 ) ); @@ -272,7 +272,7 @@ void spec_flatness_fx( sums = MUL_F( sums, 0x051e ); - /*+0.1 */ + /*+0.1 */ IF( GE_16( prods_Q, 34 ) ) { prods = L_shr( prods, sub( prods_Q, 33 ) ); diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index a62963ff0..51eef2944 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -107,13 +107,13 @@ void stat_noise_uv_enc_fx( void stat_noise_uv_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ + Encoder_State *st_fx, /* i/o: state structure */ const Word32 *LepsP, /* i : LP prediction errors Q=Qx*/ const Word16 *isp_new, /* i : immittance spectral pairs at 4th sfr Q=15*/ const Word16 *isp_mid, /* i : immittance spectral pairs at 2nd sfr Q=15*/ Word16 *Aq, /* i : A(z) quantized for the 4 subframes Q=12 */ Word16 *exc2, /* i/o: excitation buffer Q=Q_stat_noise */ - const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */ + const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */ Word16 *Q_new ) { Word16 noisiness = 0; diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 6a108ce6f..b006a4111 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -16,26 +16,26 @@ /*========================================================================*/ -/* FUNCTION : wb_pre_proc_fx() */ +/* FUNCTION : wb_pre_proc_fx() */ /*------------------------------------------------------------------------*/ /* PURPOSE : Resampling of input signal when input signal sample rate */ -/* is above 16kHz */ +/* is above 16kHz */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Encoder_State *st_fx : Encoder State Structure */ -/* _ (Word16*) input : original input signal */ +/* INPUT ARGUMENTS : */ +/* Encoder_State *st_fx : Encoder State Structure */ +/* _ (Word16*) input : original input signal */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _None */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _None */ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* _ (Word16*) new_wb_speech : original input signal at 16kHz Q-1 */ /*------------------------------------------------------------------------*/ /* st_fx->old_wtda_wb_fx */ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ void wb_pre_proc_fx( @@ -170,26 +170,26 @@ void wb_pre_proc_fx( /*========================================================================*/ -/* FUNCTION : wb_pre_proc_ivas_fx() */ +/* FUNCTION : wb_pre_proc_ivas_fx() */ /*------------------------------------------------------------------------*/ /* PURPOSE : Resampling of input signal when input signal sample rate */ -/* is above 16kHz */ +/* is above 16kHz */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Encoder_State *st_fx : Encoder State Structure */ -/* _ (Word16*) input : original input signal */ +/* INPUT ARGUMENTS : */ +/* Encoder_State *st_fx : Encoder State Structure */ +/* _ (Word16*) input : original input signal */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _None */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _None */ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* _ (Word16*) new_wb_speech : original input signal at 16kHz Q-1 */ /*------------------------------------------------------------------------*/ /* st_fx->old_wtda_wb_fx */ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ void wb_pre_proc_ivas_fx( @@ -469,29 +469,29 @@ void wb_pre_proc_ivas_fx( /*========================================================================*/ -/* FUNCTION : swb_pre_proc_fx() */ +/* FUNCTION : swb_pre_proc_fx() */ /*------------------------------------------------------------------------*/ -/* PURPOSE : Calculate the 6 to 14 kHz (or 7.5 - 15.5 kHz) */ +/* PURPOSE : Calculate the 6 to 14 kHz (or 7.5 - 15.5 kHz) */ /* SHB target signal for SWB TBE or SWB BWE coding */ -/* Common SWB TBE and SWB BWE pre-processing */ +/* Common SWB TBE and SWB BWE pre-processing */ /*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Encoder_State *st_fx : Encoder State Structure Q0 */ +/* INPUT ARGUMENTS : */ +/* Encoder_State *st_fx : Encoder State Structure Q0 */ /* _ (Word16*) input_fx : original input signal Q0 */ /*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _None */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _None */ /*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* _ (Word16*) new_swb_speech_fx : original input signal at 16kHz Q0 */ -/* _ (Word16*) shb_speech_fx : original input signal at 16kHz Q0 */ +/* _ (Word16*) shb_speech_fx : original input signal at 16kHz Q0 */ /*------------------------------------------------------------------------*/ -/* st_fx->old_input_fx */ +/* st_fx->old_input_fx */ /* st_fx->old_wtda_shb_fx */ /*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*========================================================================*/ void swb_pre_proc_fx( diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 3f671f705..177f07ded 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -409,13 +409,13 @@ void CalculateTnsFilt_fx( return; } -Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - Word32 const pSpectrum[], /* i : MDCT spectrum Q=Qx */ - STnsData *pTnsData, /* o : TNS data struct */ - TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */ - Word8 isTCX10, /* i : TCX10 or TCX20? */ - Word16 ltp_gain, /* i : LTP gain Q=15 */ - Word16 *predictionGain /* o : TNS prediction gain Q=7 */ +Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + Word32 const pSpectrum[], /* i : MDCT spectrum Q=Qx */ + STnsData *pTnsData, /* o : TNS data struct */ + TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */ + Word8 isTCX10, /* i : TCX10 or TCX20? */ + Word16 ltp_gain, /* i : LTP gain Q=15 */ + Word16 *predictionGain /* o : TNS prediction gain Q=7 */ ) { Word16 facs[TNS_MAX_NUM_OF_FILTERS][MAX_SUBDIVISIONS]; diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 842b63551..540c24185 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -20,40 +20,40 @@ static void tc_enc_ivas_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 * /*==========================================================================*/ -/* FUNCTION : void transition_enc_fx () */ +/* FUNCTION : void transition_enc_fx () */ /*--------------------------------------------------------------------------*/ /* PURPOSE :Principal function for adaptive excitation construction in TC*/ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* (Word32) core_brate : core bitrate Q0 */ -/* (Word16) bwidth : input signal bandwidth Q0 */ -/* (Word16) i_subfr : subrame index Q0 */ -/* (Word16*) Jopt_flag : joint optimization flag Q0 */ -/* (Word16*) h1_fx : weighted filter input response Q14 */ -/* (Word16*) xn_fx : target signal Q_new*/ -/* (Word16) Q_new : input scaling */ +/* INPUT ARGUMENTS : */ +/* (Word32) core_brate : core bitrate Q0 */ +/* (Word16) bwidth : input signal bandwidth Q0 */ +/* (Word16) i_subfr : subrame index Q0 */ +/* (Word16*) Jopt_flag : joint optimization flag Q0 */ +/* (Word16*) h1_fx : weighted filter input response Q14 */ +/* (Word16*) xn_fx : target signal Q_new */ +/* (Word16) Q_new : input scaling */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* (Word16*) y1_fx : zero-memory filtered adaptive excitation Q12*/ -/* (Word16*) xn2_fx : target vector for innovation search Qnew */ -/* (Word16*) gain_pit_fx : pitch gain (0..GAIN_PIT_MAX) Q14*/ -/* (Word16[])g_corr_fx : correlations and -2 */ -/* (Word16**)pt_pitch_fx : floating pitch values Q6 */ -/* (Word16*) bwe_exc_fx : excitation for SWB TBE Q0 */ +/* OUTPUT ARGUMENTS : */ +/* (Word16*) y1_fx : zero-memory filtered adaptive excitation Q12*/ +/* (Word16*) xn2_fx : target vector for innovation search Qnew */ +/* (Word16*) gain_pit_fx : pitch gain (0..GAIN_PIT_MAX) Q14*/ +/* (Word16[])g_corr_fx : correlations and -2 */ +/* (Word16**)pt_pitch_fx : floating pitch values Q6 */ +/* (Word16*) bwe_exc_fx : excitation for SWB TBE Q0 */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* (Word16*) tc_subfr : TC subframe index Q0 */ -/* (Word16*) position : index of the residual signal maximum Q0 */ -/* (Word16*) T0_min : lower pitch limit Q0 */ -/* (Word16*) T0_max : higher pitch limit Q0 */ -/* (Word16*) T0 : close loop integer pitch Q0 */ -/* (Word16*) T0_frac : close loop fractional part of the pitch Q0*/ -/* (Word16*) exc_fx : pointer to excitation signal frame */ -/* (Word16*) gp_cl_fx : memory of gain of pitch clipping algorithm*/ -/* (Word16*) clip_gain : adaptive gain clipping flag Q0 */ +/* INPUT/OUTPUT ARGUMENTS : */ +/* (Word16*) tc_subfr : TC subframe index Q0 */ +/* (Word16*) position : index of the residual signal maximum Q0 */ +/* (Word16*) T0_min : lower pitch limit Q0 */ +/* (Word16*) T0_max : higher pitch limit Q0 */ +/* (Word16*) T0 : close loop integer pitch Q0 */ +/* (Word16*) T0_frac : close loop fractional part of the pitch Q0*/ +/* (Word16*) exc_fx : pointer to excitation signal frame */ +/* (Word16*) gp_cl_fx : memory of gain of pitch clipping algorithm*/ +/* (Word16*) clip_gain : adaptive gain clipping flag Q0 */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------*/ void transition_enc_fx( diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 77f38bf52..3ee041af2 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -632,15 +632,15 @@ Word16 ivas_dtx_hangover_addition_fx( *-----------------------------------------------------------------*/ /* new simplified and harmonized code */ Word16 wb_vad_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) Q_new+QSCALE*/ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) Q_new+QSCALE*/ Word16 *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */ Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ Word16 *NB_speech_HO, /* o : SC-VBR NB speech HO flag */ Word16 *snr_sum_he, /* o : Output snr_sum as weighted spectral measure*/ Word16 *localVAD_HE_SAD, Word16 *flag_noisy_speech_snr, /* o : */ - const Word16 Q_new, /* i : scaling factor Q0 */ + const Word16 Q_new, /* i : scaling factor Q0 */ VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ Word16 lp_speech_fx, /* i : long term active speech energy average Q8 */ @@ -1852,8 +1852,8 @@ Word16 wb_vad_fx( } Word16 wb_vad_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) Qx + QSCALE */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) Qx + QSCALE */ const Word16 q_fr_bands, /* i : Q of fr_bands */ Word16 *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */ Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ diff --git a/lib_enc/vbr_average_rate_fx.c b/lib_enc/vbr_average_rate_fx.c index f1f75a30a..16f4f9d11 100644 --- a/lib_enc/vbr_average_rate_fx.c +++ b/lib_enc/vbr_average_rate_fx.c @@ -15,27 +15,27 @@ #define RATEWIN 600 /* length of the rate control window. This is 600 active speech frames. This equals roughly 12s of active speech */ /*=================================================================================*/ -/* FUNCTION : update_average_rate_fx */ +/* FUNCTION : update_average_rate_fx */ /*---------------------------------------------------------------------------------*/ -/* PURPOSE : SC-VBR update average data rate */ +/* PURPOSE : SC-VBR update average data rate */ /*---------------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE_FX) */ +/* _ (struct DTFS_STRUCTURE_FX) */ /*---------------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* hSC_VBR->global_avr_rate_fx Q13 */ -/* hSC_VBR->sum_of_rates_fx Q13 */ -/* hSC_VBR->SNR_THLD_fx Q8 */ -/* hSC_VBR->Q_to_F_fx Q0 */ -/* hSC_VBR->pattern_m_fx Q0 */ -/* hSC_VBR->rate_control_fx Q0 */ +/* hSC_VBR->global_avr_rate_fx Q13 */ +/* hSC_VBR->sum_of_rates_fx Q13 */ +/* hSC_VBR->SNR_THLD_fx Q8 */ +/* hSC_VBR->Q_to_F_fx Q0 */ +/* hSC_VBR->pattern_m_fx Q0 */ +/* hSC_VBR->rate_control_fx Q0 */ /*---------------------------------------------------------------------------------*/ -/*/* OUTPUT ARGUMENTS : */ +/*/* OUTPUT ARGUMENTS : */ /* _ None */ /*---------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : _ None. */ /*---------------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*=================================================================================*/ void update_average_rate_fx( SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */ diff --git a/lib_enc/vlpc_2st_cod_fx.c b/lib_enc/vlpc_2st_cod_fx.c index 6db7cd3ef..d2c10f4b8 100644 --- a/lib_enc/vlpc_2st_cod_fx.c +++ b/lib_enc/vlpc_2st_cod_fx.c @@ -17,7 +17,7 @@ * *------------------------------------------------------------------*/ -Word16 vlpc_2st_cod_fx( /* output: number of allocated bits */ +Word16 vlpc_2st_cod_fx( /* output: number of allocated bits */ const Word16 *lsf, /* i : normalized vector to quantize (14Q1*1.28) */ Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage (14Q1*1.28) */ Word16 *indx, /* o : index[] (4 bits per words) Q0 */ -- GitLab From 7ed95c1fbc7cf6a0234e9c6695be431317190f47 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Nov 2025 12:34:08 +0100 Subject: [PATCH 309/351] tabs -> spaces --- lib_com/gs_gains_fx.c | 4 ++-- lib_enc/lp_exc_e_fx.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index eb089cc5b..b1c209040 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -931,7 +931,7 @@ Word16 gsc_gainQ_ivas_fx( /* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ /*--------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ -/* _ (Word16) : : average frequency gain */ +/* _ (Word16) : average frequency gain */ /*==========================================================================*/ Word16 gsc_gaindec_fx( /* o : average frequency gain */ @@ -1090,7 +1090,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ /*--------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ -/* _ (Word16) : : average frequency gain */ +/* _ (Word16) : average frequency gain */ /*==========================================================================*/ Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 9e6cf3953..0035a5f19 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -189,12 +189,12 @@ static Word16 adpt_enr_fx( Word16 *y1, /* o : zero-memory filtered adpt. excitation 12 bits */ const Word16 L_subfr, /* i : vector length */ Word16 *gain, /* o : subframe adaptive gain Q14 */ - Word16 *g_corr, /* o : correlations for adptive gain mant/exp*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0 */ - const Word16 *xn, /* i : adaptive codebook target 12 bit Q_new-1+shift*/ - Word16 *xn2, /* o : algebraic codebook target 12 bit Q_new-1+shift*/ + Word16 *g_corr, /* o : correlations for adptive gain mant/exp */ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0 */ + const Word16 *xn, /* i : adaptive codebook target 12 bits Q_new-1+shift*/ + Word16 *xn2, /* o : algebraic codebook target 12 bits Q_new-1+shift*/ Word16 *exp_ener, /* o : adaptive excitation energy exp */ - Word16 use_prev_sf_pit_gain /* i : flag to use prev sf pitch gain or not */ + Word16 use_prev_sf_pit_gain /* i : flag to use prev sf pitch gain or not */ ) { Word16 ener, i; -- GitLab From c7c69896844d8752d0583abb2ac2ddd35ad03358 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 12 Nov 2025 12:42:10 +0100 Subject: [PATCH 310/351] Realloc replaced with calloc/free combination Using fixed-point absorption coeffs in PI frame --- lib_dec/lib_dec_fx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 298d18697..4d6769668 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3031,14 +3031,17 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( /* If not found */ IF( pAE == NULL ) { - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *ppAE = realloc( st_ivas->pAcousticEnvironments, ( st_ivas->acousticEnvironmentsCount + 1 ) * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *ppAE = malloc( ( st_ivas->acousticEnvironmentsCount + 1 ) * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); IF( ppAE == NULL ) { return IVAS_ERR_FAILED_ALLOC; } + memcpy( ppAE, st_ivas->pAcousticEnvironments, st_ivas->acousticEnvironmentsCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); + free( st_ivas->pAcousticEnvironments ); st_ivas->pAcousticEnvironments = ppAE; + n = st_ivas->acousticEnvironmentsCount++; pAE = &st_ivas->pAcousticEnvironments[n]; move32(); @@ -3485,7 +3488,7 @@ static ivas_error feedAcousticEnvPI( move32(); move32(); - mvr2r( hAcoustEnvPI.absorbCoeffs, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); + Copy32( hRenderConfig->roomAcoustics.AbsCoeff_fx, hAcoustEnvPI.absorbCoeffs_fx, IVAS_ROOM_ABS_COEFF ); } IF( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, acEnv ) ) != IVAS_ERR_OK ) -- GitLab From b7e1c9be7b2113f430e690e3b15bdab33b2dbfc8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 12 Nov 2025 13:04:53 +0100 Subject: [PATCH 311/351] reintroduce #include "options.h" --- apps/decoder.c | 1 + apps/encoder.c | 1 + 2 files changed, 2 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 640fb83af..7b02e26b4 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -31,6 +31,7 @@ *******************************************************************************************************/ #include "lib_dec.h" +#include "options.h" #include #include "cmdl_tools.h" #include "audio_file_writer.h" diff --git a/apps/encoder.c b/apps/encoder.c index 95802ba80..fe64442e1 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -31,6 +31,7 @@ *******************************************************************************************************/ #include +#include "options.h" #ifdef DEBUGGING #include "debug.h" #endif -- GitLab From 1940c7c45bc5cae5578439f0620c7575522cc938 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 12 Nov 2025 13:20:16 +0100 Subject: [PATCH 312/351] And avoiding memcpy() --- lib_dec/lib_dec_fx.c | 46 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4d6769668..e80db73c0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3038,7 +3038,49 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( return IVAS_ERR_FAILED_ALLOC; } - memcpy( ppAE, st_ivas->pAcousticEnvironments, st_ivas->acousticEnvironmentsCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ); + FOR( n = 0; n < st_ivas->acousticEnvironmentsCount; n++ ) + { + pAE = &ppAE[n]; + pAE->aeID = roomAcousticsConfig.aeID; + pAE->nBands = roomAcousticsConfig.nBands; + pAE->acousticPreDelay_fx = roomAcousticsConfig.acousticPreDelay_fx; + pAE->inputPreDelay_fx = roomAcousticsConfig.inputPreDelay_fx; + + Copy32( roomAcousticsConfig.pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 + Copy32( roomAcousticsConfig.pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 + Copy32( roomAcousticsConfig.pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 + + pAE->use_er = roomAcousticsConfig.use_er; + + move16(); + move16(); + move32(); + move32(); + move16(); + + IF( EQ_16( pAE->use_er, 1 ) ) + { + pAE->lowComplexity = roomAcousticsConfig.lowComplexity; + move32(); + + pAE->dimensions.x_fx = roomAcousticsConfig.dimensions.x_fx; + pAE->dimensions.y_fx = roomAcousticsConfig.dimensions.y_fx; + pAE->dimensions.z_fx = roomAcousticsConfig.dimensions.z_fx; + move32(); + move32(); + move32(); + + pAE->ListenerOrigin.x_fx = roomAcousticsConfig.ListenerOrigin.x_fx; + pAE->ListenerOrigin.y_fx = roomAcousticsConfig.ListenerOrigin.y_fx; + pAE->ListenerOrigin.z_fx = roomAcousticsConfig.ListenerOrigin.z_fx; + move32(); + move32(); + move32(); + + Copy32( roomAcousticsConfig.AbsCoeff_fx, pAE->AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); + } + } + free( st_ivas->pAcousticEnvironments ); st_ivas->pAcousticEnvironments = ppAE; @@ -3488,7 +3530,7 @@ static ivas_error feedAcousticEnvPI( move32(); move32(); - Copy32( hRenderConfig->roomAcoustics.AbsCoeff_fx, hAcoustEnvPI.absorbCoeffs_fx, IVAS_ROOM_ABS_COEFF ); + Copy32( hAcoustEnvPI.absorbCoeffs_fx, hRenderConfig->roomAcoustics.AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); } IF( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, acEnv ) ) != IVAS_ERR_OK ) -- GitLab From 2cb946be222c44e9466e094a2d3d8cc1e2adc91d Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 12 Nov 2025 14:21:18 +0100 Subject: [PATCH 313/351] fix ISAR pre-renderer crash due to re-scaling uninitialized part of CLDFB filter bank --- lib_com/options.h | 1 + lib_isar/lib_isar_pre_rend.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 7dea22a60..e3eace5d2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,6 +110,7 @@ #define NONBE_FIX_2205_SATURATE_ALTERNATIVE #define NONBE_FIX_2206_SATURATE_ALTERNATIVE +#define FIX_2226_ISAR_PRE_CRASH_CLDFB_NO_CHANNELS /* Dolby: Fix crash of ISAR pre-renderer due to an attempt of re-scaling uninitialized values in the CLDFB filter bank */ /* ################### End FIXES switches ########################### */ diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 1447658a1..11bb0f808 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -391,7 +391,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( q_final = sub( s_min( Q_buff_re, Q_buff_im ), 2 ); FOR( i = 0; i < hSplitBin->hSplitBinLCLDEnc->iChannels; i++ ) { +#ifdef FIX_2226_ISAR_PRE_CRASH_CLDFB_NO_CHANNELS + FOR( j = 0; j < hSplitBin->hSplitBinLCLDEnc->iNumBlocks; j++ ) +#else FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) +#endif { Scale_sig32( Cldfb_In_BinReal_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_re ) ); Scale_sig32( Cldfb_In_BinImag_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( q_final, Q_buff_im ) ); -- GitLab From 45e07305a55681f7e390f9589573942d7ce7a0e8 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Wed, 12 Nov 2025 14:25:04 +0100 Subject: [PATCH 314/351] Dummy commit -- GitLab From 89cde47d2deb3c56a96ca5fd5919aaa59ae16bb2 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 12 Nov 2025 15:10:43 +0100 Subject: [PATCH 315/351] And copying the right data... --- lib_dec/lib_dec_fx.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e80db73c0..1dfd15527 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3041,16 +3041,16 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( FOR( n = 0; n < st_ivas->acousticEnvironmentsCount; n++ ) { pAE = &ppAE[n]; - pAE->aeID = roomAcousticsConfig.aeID; - pAE->nBands = roomAcousticsConfig.nBands; - pAE->acousticPreDelay_fx = roomAcousticsConfig.acousticPreDelay_fx; - pAE->inputPreDelay_fx = roomAcousticsConfig.inputPreDelay_fx; + pAE->aeID = st_ivas->pAcousticEnvironments[n].aeID; + pAE->nBands = st_ivas->pAcousticEnvironments[n].nBands; + pAE->acousticPreDelay_fx = st_ivas->pAcousticEnvironments[n].acousticPreDelay_fx; + pAE->inputPreDelay_fx = st_ivas->pAcousticEnvironments[n].inputPreDelay_fx; - Copy32( roomAcousticsConfig.pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 - Copy32( roomAcousticsConfig.pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 - Copy32( roomAcousticsConfig.pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 + Copy32( st_ivas->pAcousticEnvironments[n].pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 + Copy32( st_ivas->pAcousticEnvironments[n].pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 + Copy32( st_ivas->pAcousticEnvironments[n].pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 - pAE->use_er = roomAcousticsConfig.use_er; + pAE->use_er = st_ivas->pAcousticEnvironments[n].use_er; move16(); move16(); @@ -3060,24 +3060,24 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( IF( EQ_16( pAE->use_er, 1 ) ) { - pAE->lowComplexity = roomAcousticsConfig.lowComplexity; + pAE->lowComplexity = st_ivas->pAcousticEnvironments[n].lowComplexity; move32(); - pAE->dimensions.x_fx = roomAcousticsConfig.dimensions.x_fx; - pAE->dimensions.y_fx = roomAcousticsConfig.dimensions.y_fx; - pAE->dimensions.z_fx = roomAcousticsConfig.dimensions.z_fx; + pAE->dimensions.x_fx = st_ivas->pAcousticEnvironments[n].dimensions.x_fx; + pAE->dimensions.y_fx = st_ivas->pAcousticEnvironments[n].dimensions.y_fx; + pAE->dimensions.z_fx = st_ivas->pAcousticEnvironments[n].dimensions.z_fx; move32(); move32(); move32(); - pAE->ListenerOrigin.x_fx = roomAcousticsConfig.ListenerOrigin.x_fx; - pAE->ListenerOrigin.y_fx = roomAcousticsConfig.ListenerOrigin.y_fx; - pAE->ListenerOrigin.z_fx = roomAcousticsConfig.ListenerOrigin.z_fx; + pAE->ListenerOrigin.x_fx = st_ivas->pAcousticEnvironments[n].ListenerOrigin.x_fx; + pAE->ListenerOrigin.y_fx = st_ivas->pAcousticEnvironments[n].ListenerOrigin.y_fx; + pAE->ListenerOrigin.z_fx = st_ivas->pAcousticEnvironments[n].ListenerOrigin.z_fx; move32(); move32(); move32(); - Copy32( roomAcousticsConfig.AbsCoeff_fx, pAE->AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); + Copy32( st_ivas->pAcousticEnvironments[n].AbsCoeff_fx, pAE->AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); } } -- GitLab From 78e9c0c33ad10e11227ea0ae48dcd6b772dadffe Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Wed, 12 Nov 2025 15:12:42 +0100 Subject: [PATCH 316/351] Clang update --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 1dfd15527..f584f1c59 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3046,7 +3046,7 @@ ivas_error IVAS_DEC_AddAcousticEnvironment( pAE->acousticPreDelay_fx = st_ivas->pAcousticEnvironments[n].acousticPreDelay_fx; pAE->inputPreDelay_fx = st_ivas->pAcousticEnvironments[n].inputPreDelay_fx; - Copy32( st_ivas->pAcousticEnvironments[n].pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 + Copy32( st_ivas->pAcousticEnvironments[n].pFc_input_fx, pAE->pFc_input_fx, CLDFB_NO_CHANNELS_MAX ); // Q16 Copy32( st_ivas->pAcousticEnvironments[n].pAcoustic_rt60_fx, pAE->pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); // Q26 Copy32( st_ivas->pAcousticEnvironments[n].pAcoustic_dsr_fx, pAE->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 -- GitLab From 89018684fe70af430ecee2c9c8387cfb2958a67c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:21 +0100 Subject: [PATCH 317/351] [cleanup] accept FIX_1320_STACK_CPE_DECODER --- lib_com/cnst.h | 2 - lib_com/options.h | 1 - lib_dec/dec_LPD_fx.c | 8 -- lib_dec/ivas_core_dec_fx.c | 91 ---------------- lib_dec/ivas_cpe_dec_fx.c | 182 -------------------------------- lib_dec/ivas_mdct_core_dec_fx.c | 16 --- lib_dec/ivas_tcx_core_dec_fx.c | 8 -- 7 files changed, 308 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 97dd19f18..ed4bd3f1e 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -668,9 +668,7 @@ enum #define ACELP_TCX_TRANS_NS 1250000 /* Duration of the ACELP->TCX overlap - 1.25 ms */ #define L_FRAME_MAX L_FRAME48k /* Max 20ms frame size @48kHz */ #define L_FRAME_PLUS 1200 /* Max frame size (long TCX frame) */ -#ifdef FIX_1320_STACK_CPE_DECODER #define L_FRAME_PLUS_INTERNAL 800 /* Max frame size (long TCX frame) at maximum internal sampling rate */ -#endif #define L_MDCT_OVLP_MAX NS2SA( 48000, ACELP_LOOK_NS ) /* = Max mdct overlap */ #define N_TCX10_MAX 480 /* Max size of TCX10 MDCT spectrum */ #define BITS_TEC 1 /* number of bits for TEC */ diff --git a/lib_com/options.h b/lib_com/options.h index 67f7d8cc9..6cf49d796 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -117,7 +117,6 @@ #define NONBE_1302_FIX_OMASA_JBM_FLUSH /* VA: issue 1302: fix OMASA JBM bitrate switching flush in binaural output */ #define NONBE_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328 */ #define FIX_1319_STACK_SBA_DECODER /* VA: issue 1319: Optimize the definition of buffer lengths in the SBA decoder */ -#define FIX_1320_STACK_CPE_DECODER /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */ #define NONBE_FIX_1376_MDCT_CONCEALMENT /* FhG: fix concealment artifact in MDCT Stereo with DTX, in case transition frame gets lost */ #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ #define FIX_1377_HANDLE_ERROR_CODE /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */ diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index 6a06df267..de1e3ea0d 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -36,11 +36,7 @@ void decoder_LPD_fx( ) { Word16 *param_lpc; -#ifdef FIX_1320_STACK_CPE_DECODER Word16 synth_buf[OLD_SYNTH_INTERNAL_DEC + L_FRAME_PLUS_INTERNAL + M]; -#else - Word16 synth_buf[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M]; -#endif Word16 *synth; Word16 synth_bufFB[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M]; Word16 *synthFB; @@ -118,11 +114,7 @@ void decoder_LPD_fx( synth = synth_buf + hTcxDec->old_synth_len; /*st->old_synth: Q_0*/ Copy( hTcxDec->old_synth, synth_buf, hTcxDec->old_synth_len ); -#ifdef FIX_1320_STACK_CPE_DECODER set16_fx( synth, 0, L_FRAME_PLUS_INTERNAL + M ); -#else - set16_fx( synth, 0, L_FRAME_PLUS + M ); -#endif synthFB = synth_bufFB + hTcxDec->old_synth_lenFB; Copy( hTcxDec->old_synthFB_fx, synth_bufFB, hTcxDec->old_synth_lenFB ); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index ae955c5ed..84f6391ac 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -76,12 +76,8 @@ ivas_error ivas_core_dec_fx( set16_fx( tmp_buffer_fx, 0, L_FRAME48k ); Word16 tmps, incr; -#ifdef FIX_1320_STACK_CPE_DECODER Word16 flag_bwe_bws, flaf_swb_tbe; Word32 *bwe_exc_extended_fx[CPE_CHANNELS] = { NULL, NULL }; -#else - Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; -#endif Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q15 Word16 core_switching_flag[CPE_CHANNELS]; @@ -296,9 +292,7 @@ ivas_error ivas_core_dec_fx( set16_fx( voice_factors_fx[n], 0, NB_SUBFR16k ); set32_fx( hb_synth_32_fx[n], 0, L_FRAME48k ); set16_fx( hb_synth_16_fx[n], 0, L_FRAME48k ); -#ifdef FIX_1320_STACK_CPE_DECODER bwe_exc_extended_fx[n] = hb_synth_32_fx[n]; /* note: reuse the buffer */ -#endif /*------------------------------------------------------------------* * Decision matrix (selection of technologies) @@ -1003,7 +997,6 @@ ivas_error ivas_core_dec_fx( Word16 Q_input, Q_hb_synth_fx, Q_synth_fx; Word16 Q_syn_hb, sf; -#ifdef FIX_1320_STACK_CPE_DECODER flaf_swb_tbe = 0; move16(); test(); @@ -1019,7 +1012,6 @@ ivas_error ivas_core_dec_fx( flaf_swb_tbe = 1; move16(); } -#endif sf = getScaleFactor32( output_32_fx[n], L_FRAME48k ); @@ -1058,14 +1050,10 @@ ivas_error ivas_core_dec_fx( } /* Memories Re-Scaling */ -#ifdef FIX_1320_STACK_CPE_DECODER IF( !flaf_swb_tbe ) { -#endif Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 -#ifdef FIX_1320_STACK_CPE_DECODER } -#endif Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], output_frame, sub( Q11, Q_synth_fx ) ); // Q11 @@ -1083,42 +1071,19 @@ ivas_error ivas_core_dec_fx( * SWB(FB) BWE decoding *---------------------------------------------------------------------*/ -#ifdef FIX_1320_STACK_CPE_DECODER test(); test(); test(); test(); flag_bwe_bws = ( GE_32( output_Fs, 32000 ) && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && st->bfi == 0 ); move16(); -#endif Q_white_exc = 0; move16(); -#ifdef FIX_1320_STACK_CPE_DECODER test(); test(); IF( flaf_swb_tbe ) -#else - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) || ( NE_16( st->coder_type, AUDIO ) && NE_16( st->coder_type, INACTIVE ) && GE_32( st->core_brate, SID_2k40 ) && EQ_16( st->core, ACELP_CORE ) && !st->con_tcx && GE_32( output_Fs, 32000 ) && GT_16( st->bwidth, NB ) && st->bws_cnt > 0 ) ) -#endif { /* SWB TBE decoder */ ivas_swb_tbe_dec_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, hb_synth_32_fx[n], pitch_buf_fx[n], &Q_white_exc ); @@ -1139,11 +1104,7 @@ ivas_error ivas_core_dec_fx( fb_tbe_dec_ivas_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame ); } } -#ifdef FIX_1320_STACK_CPE_DECODER ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) || flag_bwe_bws ) -#else - ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) || ( GE_32( output_Fs, 32000 ) && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && !st->ppp_mode_dec && !( EQ_16( st->nelp_mode_dec, 1 ) && EQ_16( st->bfi, 1 ) ) ) ) -#endif { /* SWB BWE decoder */ Q_syn_hb = swb_bwe_dec_fx32( st, output_32_fx[n], synth_32_fx[n], hb_synth_32_fx[n], use_cldfb_for_dft, output_frame ); @@ -1153,7 +1114,6 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_32_16( hBWE_FD->L_old_wtda_swb_fx32, hBWE_FD->L_old_wtda_swb_fx, output_frame, sub( hBWE_FD->old_wtda_swb_fx_exp, Q11 ) ); // old_wtda_swb_fx_exp } -#ifdef FIX_1320_STACK_CPE_DECODER test(); test(); test(); @@ -1161,7 +1121,6 @@ ivas_error ivas_core_dec_fx( { set32_fx( hb_synth_32_fx[n], 0, L_FRAME48k ); } -#endif /*---------------------------------------------------------------------* * FEC - recovery after lost HQ core (smoothing of the BWE component) @@ -1253,38 +1212,6 @@ ivas_error ivas_core_dec_fx( } } -#ifndef FIX_1320_STACK_CPE_DECODER - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - /*----------------------------------------------------------------* - * BFI waveform adjustment - *----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->core, ACELP_CORE ) && !st->bfi && st->prev_bfi && GE_32( st->last_total_brate, HQ_48k ) && EQ_16( st->last_codec_mode, MODE2 ) && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st->hPlcInfo->concealment_method, TCX_NONTONAL ) && LT_16( st->hPlcInfo->nbLostCmpt, 4 ) ) - { - tmps = NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ); - IF( st->hTonalMDCTConc->q_lastPcmOut != 0 ) - { - Scale_sig( st->hTonalMDCTConc->secondLastPcmOut, shr( st->hPlcInfo->L_frameTCX, 1 ), negate( st->hTonalMDCTConc->q_lastPcmOut ) ); - Scale_sig( st->hTonalMDCTConc->lastPcmOut, st->hPlcInfo->L_frameTCX, negate( st->hTonalMDCTConc->q_lastPcmOut ) ); - st->hTonalMDCTConc->q_lastPcmOut = 0; - move16(); - } - waveform_adj2_fix( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut, synth_16_fx[n] + tmps, tmps, add( st->hPlcInfo->nbLostCmpt, 1 ), st->bfi ); - - st->hPlcInfo->Pitch_fx = 0; - move16(); - } - } -#endif /*----------------------------------------------------------------* * Transition and synchronization of BWE components *----------------------------------------------------------------*/ @@ -1303,21 +1230,8 @@ ivas_error ivas_core_dec_fx( } ELSE { -#ifndef FIX_1320_STACK_CPE_DECODER - test(); - IF( EQ_16( st->extl, SWB_BWE_HIGHRATE ) || EQ_16( st->extl, FB_BWE_HIGHRATE ) ) - { - /* HR SWB BWE on top of ACELP@16kHz */ - tmps = NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ); - } - ELSE - { -#endif /* TBE on top of ACELP@16kHz */ tmps = NS2SA_FX2( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); -#ifndef FIX_1320_STACK_CPE_DECODER - } -#endif } /* Smooth transitions when switching between different technologies */ @@ -1542,12 +1456,7 @@ ivas_error ivas_core_dec_fx( test(); test(); test(); -#ifdef FIX_1320_STACK_CPE_DECODER IF( st->hTcxDec != NULL && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) -#else - test(); - IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) -#endif { Word16 exp_prev_synth_buffer = 0, exp_old_out = 0, exp_delay_buf_out = 0, exp_ouput = 0, exp_synth_history = 0; move16(); diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 3b6f9d91f..d98255d14 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -51,9 +51,7 @@ static void read_stereo_mode_and_bwidth_fx( CPE_DEC_HANDLE hCPE, const Decoder_S static void stereo_mode_combined_format_dec_fx( const Decoder_Struct *st_ivas, CPE_DEC_HANDLE hCPE ); -#ifdef FIX_1320_STACK_CPE_DECODER static ivas_error stereo_dft_dec_main( CPE_DEC_HANDLE hCPE, const Word32 ivas_total_brate, const Word16 n_channels, Word32 *p_res_buf_fx, Word32 *output[], Word32 outputHB[][L_FRAME48k], const Word16 output_frame, const Word32 output_Fs ); -#endif /*--------------------------------------------------------------------------* @@ -75,12 +73,7 @@ ivas_error ivas_cpe_dec_fx( Word16 last_bwidth; Word16 tdm_ratio_idx; Word32 outputHB_fx[CPE_CHANNELS][L_FRAME48k]; /* buffer for output HB synthesis, both channels */ /* Q11 */ -#ifdef FIX_1320_STACK_CPE_DECODER Word32 *res_buf_fx = NULL; /* Q8 */ -#else - Word16 q_res_buf; - Word32 res_buf_fx[STEREO_DFT_N_8k]; /* Q(q_res_buf) */ -#endif CPE_DEC_HANDLE hCPE; STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; Decoder_State **sts; @@ -91,10 +84,6 @@ ivas_error ivas_cpe_dec_fx( error = IVAS_ERR_OK; move32(); -#ifndef FIX_1320_STACK_CPE_DECODER - q_res_buf = Q8; - move16(); -#endif push_wmops( "ivas_cpe_dec" ); @@ -353,10 +342,8 @@ ivas_error ivas_cpe_dec_fx( } ELSE { -#ifdef FIX_1320_STACK_CPE_DECODER res_buf_fx = outputHB_fx[0]; /* note: temporarily reused buffer */ -#endif test(); IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { @@ -619,177 +606,10 @@ ivas_error ivas_cpe_dec_fx( test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && !( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hConfigDft->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) ) { -#ifdef FIX_1320_STACK_CPE_DECODER IF( NE_32( ( error = stereo_dft_dec_main( hCPE, ivas_total_brate, n_channels, res_buf_fx, output, outputHB_fx, output_frame, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) { return error; } -#else - Word32 DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX]; // q_dft - set32_fx( DFT_fx[0], 0, STEREO_DFT_BUF_MAX ); - set32_fx( DFT_fx[1], 0, STEREO_DFT_BUF_MAX ); - - /* core decoder */ - IF( NE_32( ( error = ivas_core_dec_fx( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB_fx, DFT_fx, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - - // Scaling of DFT's - Word16 shift; - Word32 tmp1, tmp2; - Word16 shift1, shift2; - maximum_abs_32_fx( DFT_fx[0], STEREO_DFT_BUF_MAX, &tmp1 ); - maximum_abs_32_fx( DFT_fx[1], STEREO_DFT_BUF_MAX, &tmp2 ); - - IF( tmp1 == 0 ) - { - shift1 = Q31; - move16(); - } - ELSE - { - shift1 = norm_l( tmp1 ); - } - IF( tmp2 == 0 ) - { - shift2 = Q31; - move16(); - } - ELSE - { - shift2 = norm_l( tmp2 ); - } - shift = s_min( shift1, shift2 ); - - IF( NE_16( shift, 31 ) ) - { - shift = sub( add( hCPE->hStereoDft->q_dft, shift ), Q17 ); /* Q17 for guard bits */ - - IF( GT_16( shift, hCPE->hStereoDft->q_dft ) ) - { - Scale_sig32( DFT_fx[0], STEREO_DFT_BUF_MAX, sub( shift, hCPE->hStereoDft->q_dft ) ); // shift - Scale_sig32( DFT_fx[1], STEREO_DFT_BUF_MAX, sub( shift, hCPE->hStereoDft->q_dft ) ); // shift - hCPE->hStereoDft->q_dft = shift; - move16(); - } - } - ELSE - { - hCPE->hStereoDft->q_dft = Q8; - move16(); - } - - /* DFT Stereo residual decoding */ - test(); - IF( hCPE->hStereoDft->res_cod_band_max > 0 && !st_ivas->bfi ) - { - Word16 q; - Word16 q_out_DFT[2]; - - q = Q11; - move16(); - - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->old_pitch_buf_fx, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, ( ( 2 * NB_SUBFR16k ) + 2 ), -( Q10 ) ); // Q16->Q6 - - stereo_dft_dec_res_fx( hCPE, res_buf_fx, q_res_buf, output[1] ); - - Copy_Scale_sig_16_32_DEPREC( hCPE->hCoreCoder[0]->old_pitch_buf_16_fx, hCPE->hCoreCoder[0]->old_pitch_buf_fx, ( ( 2 * NB_SUBFR16k ) + 2 ), 10 ); // Q6->Q16 - - Scale_sig32( output[1], L_FRAME8k, ( Q11 - Q15 ) ); // Q15 -> Q11 - - q_out_DFT[0] = q_out_DFT[1] = hCPE->hStereoDft->q_dft; - move16(); - move16(); - - stereo_dft_dec_analyze_fx( hCPE, output[1], DFT_fx, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, &q, q_out_DFT ); - - Scale_sig32( DFT_fx[1], STEREO_DFT_BUF_MAX, sub( hCPE->hStereoDft->q_dft, q_out_DFT[1] ) ); // q_dft - } - - /* DFT stereo CNG */ - { - Word16 q_dft; - - q_dft = hCPE->hStereoDft->q_dft; - move16(); - - stereo_dtf_cng_fx( hCPE, ivas_total_brate, DFT_fx, output_frame, q_dft ); - } - - /* decoding */ - IF( EQ_16( hCPE->nchan_out, 1 ) ) - { - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; - move16(); - FOR( Word16 ii = 0; ii < (Word16) ( sizeof( hCPE->hStereoDft->q_DFT_past_DMX_fx ) / sizeof( hCPE->hStereoDft->q_DFT_past_DMX_fx[0] ) ); ii++ ) - { - hCPE->hStereoDft->q_DFT_past_DMX_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - hCPE->hStereoDft->first_frame = 0; - move16(); - } - - scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_res_cod_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_res_cod_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - stereo_dft_unify_dmx_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng->prev_sid_nodata ); - scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q15, hCPE->hStereoDft->q_res_cod_mem_fx ) ); // Q15 - hCPE->hStereoDft->q_res_cod_mem_fx = Q15; - move16(); - } - ELSE - { - { - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; - move16(); - FOR( Word16 ii = 0; ii < (Word16) ( sizeof( hCPE->hStereoDft->q_DFT_past_DMX_fx ) / sizeof( hCPE->hStereoDft->q_DFT_past_DMX_fx[0] ) ); ii++ ) - { - hCPE->hStereoDft->q_DFT_past_DMX_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - hCPE->hStereoDft->first_frame = 0; - move16(); - } - - scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_res_cod_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_res_cod_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - stereo_dft_dec_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); - scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q15, hCPE->hStereoDft->q_res_cod_mem_fx ) ); // Q15 - hCPE->hStereoDft->q_res_cod_mem_fx = Q15; - move16(); - } - - FOR( n = 0; n < hCPE->nchan_out; n++ ) - { - Scale_sig32( output[n], L_FRAME48k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - hCPE->q_output_mem_fx[n] = hCPE->hStereoDft->q_dft; - move16(); - } - - /* synthesis iFFT */ - FOR( n = 0; n < hCPE->nchan_out; n++ ) - { - stereo_dft_dec_synthesize_fx( hCPE, DFT_fx, n, output[n], output_frame ); - } - - // delete below - FOR( n = 0; n < hCPE->nchan_out; n++ ) - { - Scale_sig32( output[n], L_FRAME48k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[n] = Q11; - move16(); - } -#endif } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) { @@ -893,7 +713,6 @@ ivas_error ivas_cpe_dec_fx( return error; } -#ifdef FIX_1320_STACK_CPE_DECODER /*------------------------------------------------------------------------- * stereo_dft_dec_main() @@ -1099,7 +918,6 @@ static ivas_error stereo_dft_dec_main( return IVAS_ERR_OK; } -#endif /*------------------------------------------------------------------------- * create_cpe_dec_fx() diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index b95125885..be931598e 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1104,11 +1104,7 @@ void ivas_mdct_core_reconstruct_fx( Word16 L_frame_global[CPE_CHANNELS], L_frame_globalTCX[CPE_CHANNELS]; /* Synth */ -#ifdef FIX_1320_STACK_CPE_DECODER Word16 synth_buf_fx[OLD_SYNTH_INTERNAL_DEC + L_FRAME_PLUS_INTERNAL + M]; -#else - Word16 synth_buf_fx[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M]; -#endif Word16 *synth_fx; Word16 synth_bufFB_fx[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M]; Word16 *synthFB_fx; @@ -1179,11 +1175,7 @@ void ivas_mdct_core_reconstruct_fx( } q_syn = st->hTcxDec->q_old_synth; move16(); -#ifdef FIX_1320_STACK_CPE_DECODER set16_fx( synth_fx, 0, L_FRAME_PLUS_INTERNAL + M ); -#else - set16_fx( synth_fx, 0, L_FRAME_PLUS + M ); -#endif set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); IF( st->core != ACELP_CORE ) { @@ -1273,11 +1265,7 @@ void ivas_mdct_core_reconstruct_fx( // norm(synth_buf) >= q_syn - q_win // norm(synth_buf) + q_win >= q_syn -#ifdef FIX_1320_STACK_CPE_DECODER sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS_INTERNAL ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) ); -#else - sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) ); -#endif q_syn = add( sub( sf, 1 ), s_min( q_win, q_winFB ) ); st->Q_syn = q_syn; move16(); @@ -1287,11 +1275,7 @@ void ivas_mdct_core_reconstruct_fx( sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) ); st->Q_syn = add( sf, s_min( q_win, q_winFB ) ); -#ifdef FIX_1320_STACK_CPE_DECODER Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS_INTERNAL ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn -#else - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn -#endif Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn // Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->syn, M + 1, sub( st->Q_syn, q_win ) ); diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 6ee4bfe18..e24c76951 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -226,11 +226,7 @@ void stereo_tcx_core_dec_fx( Word16 pit_gain_fx[NB_SUBFR16k]; /*Synth*/ -#ifdef FIX_1320_STACK_CPE_DECODER Word16 synth_buf_fx[OLD_SYNTH_INTERNAL_DEC + L_FRAME_PLUS_INTERNAL + M]; -#else - Word16 synth_buf_fx[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M]; -#endif Word16 *synth_fx; Word16 synth_bufFB_fx[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M]; Word16 *synthFB_fx; @@ -305,11 +301,7 @@ void stereo_tcx_core_dec_fx( synthFB_fx = synth_bufFB_fx + hTcxDec->old_synth_lenFB; Copy_Scale_sig( hTcxDec->old_synth, synth_buf_fx, hTcxDec->old_synth_len, negate( st->Q_syn ) ); /* q_old_synth - st->Q_syn */ Copy( hTcxDec->old_synthFB_fx, synth_bufFB_fx, hTcxDec->old_synth_lenFB ); /* q_old_synthFB */ -#ifdef FIX_1320_STACK_CPE_DECODER set16_fx( synth_fx, 0, L_FRAME_PLUS_INTERNAL + M ); -#else - set16_fx( synth_fx, 0, L_FRAME_PLUS + M ); -#endif set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); /*--------------------------------------------------------------------------------* -- GitLab From 4d598b9db7f71248b9e21b0ad40f9412ba1d01e9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:24 +0100 Subject: [PATCH 318/351] [cleanup] accept FIX_NCHAN_BUFFERS --- lib_com/options.h | 1 - lib_dec/ivas_init_dec_fx.c | 4 - lib_dec/ivas_jbm_dec_fx.c | 4 - lib_dec/ivas_masa_dec_fx.c | 10 -- lib_dec/ivas_mct_dec_fx.c | 5 - lib_dec/ivas_sba_dec_fx.c | 2 - .../ivas_dirac_dec_binaural_functions_fx.c | 5 - lib_rend/ivas_output_init_fx.c | 146 ------------------ 8 files changed, 177 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6cf49d796..4ddcba5fa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,7 +133,6 @@ #define FIX_1384_MSAN_ivas_spar_dec_open /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1288_SPLIT_REND_XSAN /* Dlb: Fix asan, msan and usan issues in split rendering mode*/ -#define FIX_NCHAN_BUFFERS /* VA: issue 1322: Correct the number of float buffers (channels) at the decoder */ #define FIX_RENDERER_STACK /* VA: issue 1322: reduction of renderers' buffers size */ #define JBM_MEMORY_OPT /* VA: issue 916: optimization of RAM in the JBM decoder */ #define NONBE_1324_TC_BUFFER_MEMOERY_KEEP /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 984f02ece..6de48e51d 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3222,12 +3222,8 @@ ivas_error ivas_init_decoder_fx( return error; } #else -#ifdef FIX_NCHAN_BUFFERS k = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); FOR( n = 0; n < k; n++ ) -#else - FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); n++ ) -#endif { /* note: these are intra-frame heap memories */ IF( ( st_ivas->p_output_fx[n] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 853ea9aac..e4fe38732 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1661,16 +1661,12 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( move16(); } -#ifdef FIX_NCHAN_BUFFERS #ifdef JBM_MEMORY_OPT ch = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); #else ch = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #endif FOR( n = 0; n < ch; n++ ) -#else - FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) -#endif { hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */ move16(); diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 2b6ccf1ef..6f1385062 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1689,12 +1689,10 @@ ivas_error ivas_masa_dec_reconfigure_fx( Decoder_State **sts; UWord32 ivas_total_brate, last_ivas_total_brate; Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; -#ifdef FIX_NCHAN_BUFFERS #ifdef FIX_1330_JBM_MEMORY Word16 nchan_out_buff; #else Word16 nchan_out_buff_old, nchan_out_buff; -#endif #endif ivas_error error; Word32 ism_total_brate; @@ -1704,10 +1702,8 @@ ivas_error ivas_masa_dec_reconfigure_fx( move32(); last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; move32(); -#ifdef FIX_NCHAN_BUFFERS #ifndef FIX_1330_JBM_MEMORY nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); -#endif #endif test(); @@ -1976,7 +1972,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( } ELSE { -#ifdef FIX_NCHAN_BUFFERS tc_nchan_to_allocate = BINAURAL_CHANNELS; move16(); test(); @@ -1985,9 +1980,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; move16(); } -#else - tc_nchan_to_allocate = shl( BINAURAL_CHANNELS, 1 ); -#endif } test(); @@ -2054,7 +2046,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( } } -#ifdef FIX_NCHAN_BUFFERS /*-----------------------------------------------------------------* * output audio buffers *-----------------------------------------------------------------*/ @@ -2073,7 +2064,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( } } -#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 8970a0820..86313996d 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1555,7 +1555,6 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { -#ifdef FIX_NCHAN_BUFFERS tc_nchan_allocate_new = BINAURAL_CHANNELS; move16(); test(); @@ -1568,10 +1567,6 @@ static ivas_error ivas_mc_dec_reconfig_fx( { tc_nchan_allocate_new = add( tc_nchan_allocate_new, 1 ); } -#else - tc_nchan_allocate_new = BINAURAL_CHANNELS * 2; - move16(); -#endif tc_nchan_full_new = tc_nchan_allocate_new; move16(); } diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 793ed74d4..e8dab7dc4 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -849,7 +849,6 @@ ivas_error ivas_sba_dec_render_fx( hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); /*Q0*/ -#ifdef FIX_NCHAN_BUFFERS IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { nchan_out = s_max( nchan_internal, st_ivas->hDecoderConfig->nchan_out ); @@ -868,7 +867,6 @@ ivas_error ivas_sba_dec_render_fx( } nchan_out = s_min( nchan_out, ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); -#endif FOR( ch = 0; ch < nchan_out; ch++ ) { output_fx_local[ch] = output_fx[ch]; /*Q11*/ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 705b52fdb..083ea15f3 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -371,7 +371,6 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( Word16 nchan_to_allocate; Word16 n_samples_granularity; -#ifdef FIX_NCHAN_BUFFERS nchan_to_allocate = BINAURAL_CHANNELS; move16(); IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) @@ -383,10 +382,6 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( { nchan_to_allocate = add( nchan_to_allocate, 1 ); } -#else - nchan_to_allocate = 2 * BINAURAL_CHANNELS; - move16(); -#endif if ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { nchan_to_allocate = add( BINAURAL_CHANNELS, st_ivas->nchan_ism ); diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 5969fac17..e3cdefad5 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -318,11 +318,7 @@ Word16 ivas_get_nchan_buffers_dec_fx( output_config = st_ivas->hDecoderConfig->output_config; move16(); -#ifdef FIX_NCHAN_BUFFERS nchan_out_buff = st_ivas->nchan_transport; -#else - nchan_out_buff = MAX_OUTPUT_CHANNELS; -#endif move16(); IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) @@ -336,7 +332,6 @@ Word16 ivas_get_nchan_buffers_dec_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { -#ifdef FIX_NCHAN_BUFFERS nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); test(); @@ -344,49 +339,16 @@ Word16 ivas_get_nchan_buffers_dec_fx( { nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); } -#else - nchan_out_buff = st_ivas->nchan_ism; - move16(); - - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); - } - ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); - } -#endif } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { -#ifdef FIX_NCHAN_BUFFERS Word16 nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); nchan_out_buff = s_max( nchan_internal, st_ivas->hDecoderConfig->nchan_out ); -#else - Word16 nchan_internal; - nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); - nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; - move16(); - - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); - } - ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); - } - nchan_out_buff = s_max( nchan_out_buff, nchan_internal ); -#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { -#ifdef FIX_NCHAN_BUFFERS nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); test(); @@ -395,64 +357,13 @@ Word16 ivas_get_nchan_buffers_dec_fx( nchan_out_buff = 2 * BINAURAL_CHANNELS; move16(); } -#else - nchan_out_buff = CPE_CHANNELS; - move16(); - - test(); - test(); - test(); - test(); - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); - } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - nchan_out_buff = shl( CPE_CHANNELS, 1 ); - } - ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); - } - test(); - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && GT_16( st_ivas->nchan_ism, 0 ) && LT_16( st_ivas->nchan_ism, 5 ) ) /* Last condition needed only in BASOP */ - { - nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS ); - } -#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { -#ifdef FIX_NCHAN_BUFFERS nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, add( st_ivas->nchan_transport, st_ivas->nchan_ism ) ); -#else - nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS ); - - test(); - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - nchan_out_buff = s_max( nchan_out_buff, add( BINAURAL_CHANNELS, st_ivas->nchan_ism ) ); - } - ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); - } -#endif } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { -#ifdef FIX_NCHAN_BUFFERS Word16 nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); @@ -473,51 +384,9 @@ Word16 ivas_get_nchan_buffers_dec_fx( { nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); } -#else - Word16 nchan_internal; - nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); - nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport ); - - IF( st_ivas->hMCT != NULL ) - { - nchan_out_buff = shl( shr( add( nchan_out_buff, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */ - } - - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); - } - ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); - - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) ) - { - nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */ - } - ELSE - { - nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */ - } - } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */ - } - - test(); - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) - { - nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) ); - } - nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); -#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { -#ifdef FIX_NCHAN_BUFFERS nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); IF( st_ivas->hOutSetup.separateChannelEnabled ) @@ -534,19 +403,6 @@ Word16 ivas_get_nchan_buffers_dec_fx( { nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); } -#else - nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; - - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); - } - ELSE IF( NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); - nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); - } -#endif } test(); @@ -646,13 +502,11 @@ ivas_error ivas_output_buff_dec_fx( { FOR( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { -#ifdef FIX_NCHAN_BUFFERS #ifdef DEBUGGING if ( p_output_fx[ch] != NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Memory for floating-point output audio buffer is already allocated!\n" ) ); } -#endif #endif /* note: these are intra-frame heap memories */ IF( ( p_output_fx[ch] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) -- GitLab From cc5a7487e89706c496e195db7560a67f99d0f9cd Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:27 +0100 Subject: [PATCH 319/351] [cleanup] accept FIX_RENDERER_STACK --- lib_com/options.h | 1 - lib_dec/ivas_dirac_dec_fx.c | 23 ------------------- .../ivas_dirac_dec_binaural_functions_fx.c | 21 ----------------- 3 files changed, 45 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4ddcba5fa..7963acd2c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,7 +133,6 @@ #define FIX_1384_MSAN_ivas_spar_dec_open /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1288_SPLIT_REND_XSAN /* Dlb: Fix asan, msan and usan issues in split rendering mode*/ -#define FIX_RENDERER_STACK /* VA: issue 1322: reduction of renderers' buffers size */ #define JBM_MEMORY_OPT /* VA: issue 916: optimization of RAM in the JBM decoder */ #define NONBE_1324_TC_BUFFER_MEMOERY_KEEP /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index e00d4e351..b68f6fd6b 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2076,12 +2076,8 @@ void ivas_dirac_dec_render_fx( move16(); SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word32 *output_fx_local[MAX_OUTPUT_CHANNELS]; -#ifdef FIX_RENDERER_STACK Word32 *p_output_fx[MAX_OUTPUT_CHANNELS]; Word32 output_fx_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; -#else - Word32 output_fx_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k] = { 0 }; -#endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -2089,11 +2085,7 @@ void ivas_dirac_dec_render_fx( FOR( ch = 0; ch < nchan_intern; ch++ ) { output_fx_local[ch] = output_fx_local_buff[ch]; -#ifdef FIX_RENDERER_STACK p_output_fx[ch] = output_fx[ch]; -#else - set_zero_fx( output_fx_local[ch], nSamplesAsked ); -#endif } slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // cL @@ -2122,7 +2114,6 @@ void ivas_dirac_dec_render_fx( FOR( ch = 0; ch < nchan_intern; ch++ ) { -#ifdef FIX_RENDERER_STACK /* move to output */ test(); test(); @@ -2132,26 +2123,12 @@ void ivas_dirac_dec_render_fx( } p_output_fx[ch] += n_samples_sf; -#else - output_fx_local[ch] += n_samples_sf; -#endif } /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } -#ifndef FIX_RENDERER_STACK - FOR( ch = 0; ch < nchan_intern; ch++ ) - { - test(); - test(); - IF( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( ( EQ_16( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, ch ) || EQ_16( add( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, 1 ), ch ) ) ) ) ) - { - Copy32( output_fx_local_buff[ch], output_fx[ch], *nSamplesRendered ); - } - } -#endif /* clang-format off */ IF( EQ_16( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->num_slots ) ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 083ea15f3..9683cd743 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -512,21 +512,13 @@ void ivas_dirac_dec_binaural_render_fx( UWord16 nchan_out; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word32 *output_fx_local[MAX_OUTPUT_CHANNELS]; -#ifndef FIX_RENDERER_STACK - Word32 output_fx_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - Word16 output_length; -#endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_out = BINAURAL_CHANNELS; move16(); FOR( ch = 0; ch < nchan_out; ch++ ) { -#ifdef FIX_RENDERER_STACK output_fx_local[ch] = output_fx[ch]; -#else - output_fx_local[ch] = output_fx_local_buff[ch]; -#endif } slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -545,10 +537,6 @@ void ivas_dirac_dec_binaural_render_fx( last_sf = add( last_sf, 1 ); } -#ifndef FIX_RENDERER_STACK - output_length = 0; - move16(); -#endif FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { n_samples_sf = imult1616( slot_size, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); @@ -560,19 +548,10 @@ void ivas_dirac_dec_binaural_render_fx( output_fx_local[ch] += n_samples_sf; } -#ifndef FIX_RENDERER_STACK - output_length = add( output_length, n_samples_sf ); -#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } -#ifndef FIX_RENDERER_STACK - FOR( ch = 0; ch < nchan_out; ch++ ) - { - Copy32( output_fx_local_buff[ch], output_fx[ch], output_length ); - } -#endif IF( EQ_16( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->num_slots ) ) { hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length; -- GitLab From c0fa39729b8c6c07a810803c3053c9a7e70a4023 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:31 +0100 Subject: [PATCH 320/351] [cleanup] accept FIX_1319_STACK_SBA_DECODER --- lib_com/ivas_prot_fx.h | 5 --- lib_com/options.h | 1 - lib_dec/ivas_dirac_dec_fx.c | 72 ---------------------------------- lib_dec/ivas_spar_decoder_fx.c | 18 --------- 4 files changed, 96 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index db13b368b..149a49a74 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2309,13 +2309,8 @@ void ivas_dirac_dec_render_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ const Word16 nchan_transport, /* i : number of transport channels */ -#ifdef FIX_1319_STACK_SBA_DECODER Word32 *pppQMfFrame_ts_re_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX], Word32 *pppQMfFrame_ts_im_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX] -#else - Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] -#endif ); void ivas_dirac_dec_render_fx( diff --git a/lib_com/options.h b/lib_com/options.h index 7963acd2c..b388d0a67 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,6 @@ #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_1302_FIX_OMASA_JBM_FLUSH /* VA: issue 1302: fix OMASA JBM bitrate switching flush in binaural output */ #define NONBE_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328 */ -#define FIX_1319_STACK_SBA_DECODER /* VA: issue 1319: Optimize the definition of buffer lengths in the SBA decoder */ #define NONBE_FIX_1376_MDCT_CONCEALMENT /* FhG: fix concealment artifact in MDCT Stereo with DTX, in case transition frame gets lost */ #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ #define FIX_1377_HANDLE_ERROR_CODE /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index b68f6fd6b..ff8565917 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2152,7 +2152,6 @@ void ivas_dirac_dec_render_fx( /* clang-format on */ -#ifdef FIX_1319_STACK_SBA_DECODER /*------------------------------------------------------------------------- * Local functions to perform binaural rendering with optimized stack *------------------------------------------------------------------------*/ @@ -2243,7 +2242,6 @@ static void binRenderer_fx( return; } -#endif /*------------------------------------------------------------------------- @@ -2256,13 +2254,8 @@ void ivas_dirac_dec_render_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output_buf_fx[], /* i/o: synthesized core-coder transport channels/DirAC output Q(6-1)*/ const Word16 nchan_transport, /* i : number of transport channels */ -#ifdef FIX_1319_STACK_SBA_DECODER Word32 *pppQMfFrame_ts_re_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX], Word32 *pppQMfFrame_ts_im_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX] -#else - Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], /*Q6*/ - Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] /*Q6*/ -#endif ) { Word16 i, ch, idx_in, idx_lfe; @@ -2274,17 +2267,10 @@ void ivas_dirac_dec_render_sf_fx( Word16 slot_idx_start, slot_idx_start_cldfb_synth, md_idx; /*CLDFB: last output channels reserved to LFT for CICPx*/ -#ifdef FIX_1319_STACK_SBA_DECODER Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_RealBuffer_Binaural_fx[1][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[1][BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#else - Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#endif Word16 index = 0, num_freq_bands = 0; move16(); move16(); @@ -2301,10 +2287,6 @@ void ivas_dirac_dec_render_sf_fx( Word16 surCohRatio_q_fx = 0, temp_q = 0; move16(); move16(); -#ifndef FIX_1319_STACK_SBA_DECODER - Word32 Cldfb_RealBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#endif #ifndef FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES Word16 cldfb_buf_q; #endif @@ -2799,19 +2781,11 @@ void ivas_dirac_dec_render_sf_fx( { q_temp_cldfb = Q11; move16(); -#ifdef FIX_1319_STACK_SBA_DECODER cldfbAnalysis_ts_fx_fixed_q( &( st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx], /* note: it is a tmp. buffer at this point */ Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx], /* note: it is a tmp. buffer at this point */ hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch], &q_temp_cldfb ); -#else - cldfbAnalysis_ts_fx_fixed_q( &st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][offset], - Cldfb_RealBuffer_Temp_fx[ch][slot_idx], - Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch], &q_temp_cldfb ); -#endif } q_cldfb = q_temp_cldfb; move16(); @@ -2819,14 +2793,10 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { -#ifdef FIX_1319_STACK_SBA_DECODER #ifdef FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Binaural_fx[0], Cldfb_ImagBuffer_Binaural_fx[0], &q_cldfb, hSpatParamRendCom->num_freq_bands, subframe_idx ); #else ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Binaural_fx[0], Cldfb_ImagBuffer_Binaural_fx[0], &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); -#endif -#else - ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); #endif } } @@ -2860,13 +2830,8 @@ void ivas_dirac_dec_render_sf_fx( { FOR( ch = 0; ch < nchan_transport; ch++ ) { -#ifdef FIX_1319_STACK_SBA_DECODER Copy32( Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); Copy32( Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); -#else - Copy32( Cldfb_RealBuffer_Temp_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); - Copy32( Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); -#endif } } ELSE @@ -3840,7 +3805,6 @@ void ivas_dirac_dec_render_sf_fx( } /* Perform binaural rendering, output in Q6 format */ -#ifdef FIX_1319_STACK_SBA_DECODER test(); IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -3870,45 +3834,14 @@ void ivas_dirac_dec_render_sf_fx( binRenderer_fx( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx ); } -#else - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) - { - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - FOR( ch = 0; ch < st_ivas->hBinRenderer->nInChannels; ch++ ) - { - Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); - Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hSpatParamRendCom->num_freq_bands ); - } - } - st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; - move16(); - } - } - - /*Binaural output in Q6 format*/ - ivas_binRenderer_fx( st_ivas->hBinRenderer, - ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, - st_ivas->hCombinedOrientationData, - hSpatParamRendCom->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, - Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); -#endif /* Inverse CLDFB*/ FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ Word32 *synth_fx = &output_buf_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands]; -#ifdef FIX_1319_STACK_SBA_DECODER Word32 *RealBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; Word32 *ImagBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; -#else - Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; -#endif FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[0][ch][i]; @@ -3954,13 +3887,8 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { -#ifdef FIX_1319_STACK_SBA_DECODER Word32 *RealBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; Word32 *ImagBuffer_fx[CLDFB_SLOTS_PER_SUBFRAME]; -#else - Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; -#endif Word16 outchannels; idx_in = 0; diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 4161c57fa..af0f9d149 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -1683,25 +1683,15 @@ void ivas_spar_dec_upmixer_sf_fx( ) { Word16 cldfb_band, num_cldfb_bands, numch_in, numch_out; -#ifdef FIX_1319_STACK_SBA_DECODER Word32 *cldfb_in_ts_re_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX]; Word32 *cldfb_in_ts_im_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX]; -#else - Word32 *cldfb_in_ts_re_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; - Word32 *cldfb_in_ts_im_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; -#endif Word16 i, b, ts, out_ch, in_ch; Word16 num_spar_bands, spar_band, nchan_transport; Word16 num_in_ingest, split_band; Word16 slot_size, slot_idx_start; Word16 md_idx; -#ifdef FIX_1319_STACK_SBA_DECODER Word32 *p_tc_fx[HOA3_CHANNELS]; Word32 Pcm_tmp_fx[HOA3_CHANNELS][2 /* Re, Im*/ * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; -#else - Word32 *p_tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; - Word32 Pcm_tmp_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; -#endif Word16 numch_out_dirac; Word32 mixer_mat_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; Word16 b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -1793,21 +1783,13 @@ void ivas_spar_dec_upmixer_sf_fx( * Prepare CLDFB buffers *---------------------------------------------------------------------*/ -#ifdef FIX_1319_STACK_SBA_DECODER set_zero_fx( &Pcm_tmp_fx[0][0], HOA3_CHANNELS * 2 * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES ); -#else - set_zero_fx( &Pcm_tmp_fx[0][0], ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ) * L_FRAME48k ); -#endif /* set-up pointers */ IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) ) { /* at this point, output channels are used as intermediate procesing buffers */ -#ifdef FIX_1319_STACK_SBA_DECODER FOR( in_ch = 0; in_ch < HOA3_CHANNELS; in_ch++ ) -#else - FOR( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; in_ch++ ) -#endif { FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { -- GitLab From 5b8204ff3cad7e3e3bcd46780056a23697b92117 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:34 +0100 Subject: [PATCH 321/351] [cleanup] accept JBM_MEMORY_OPT --- lib_com/ivas_cnst.h | 5 - lib_com/ivas_prot_fx.h | 14 -- lib_com/ivas_tools_fx.c | 37 ------ lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 247 ------------------------------------ lib_dec/ivas_stat_dec.h | 6 - lib_dec/jbm_pcmdsp_apa.h | 5 - lib_dec/jbm_pcmdsp_apa_fx.c | 8 -- lib_dec/lib_dec_fx.c | 85 ------------- 9 files changed, 408 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 335721a0a..a41ff84f5 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -192,13 +192,8 @@ typedef enum #define JBM_CLDFB_SLOTS_IN_SUBFRAME_LOG2 2 /* To be used for shift operation instead of division */ #define MAX_JBM_CLDFB_TIMESLOTS 32 #define DEFAULT_JBM_CLDFB_TIMESLOTS 16 -#ifdef JBM_MEMORY_OPT #define MAX_JBM_L_FRAME48k ( IVAS_MAX_FRAME_SIZE * 2 ) /* 1920: max. time-scaled frame buffer length (per channel) in samples */ #define MAX_JBM_L_FRAME_NS 40000000L /* 40 ms: time-scaled frame size in ns, proportional to MAX_JBM_L_FRAME48k */ -#else -#define MAX_JBM_L_FRAME48k 1920 -#define MAX_JBM_L_FRAME_NS 40000000L -#endif #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH #define MAX_CLDFB_DIGEST_CHANNELS 3 /* == maximum of ParamISM TCs and ParamMC TCs */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 149a49a74..c326ade0f 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2079,7 +2079,6 @@ UWord32 ivas_syn_output_fx( Word16 *synth_out /* o : integer 16 bits synthesis signal */ ); -#ifdef JBM_MEMORY_OPT void ivas_buffer_interleaved_to_deinterleaved_fx( Word32 *audio, /* i/o: audio buffer */ const Word16 n_channels, /* i : number of channels */ @@ -2094,7 +2093,6 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( Word32 *audio_out /* o : interleaved audio buffer */ ); -#endif void stereo_tcx_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ const FRAME_MODE frameMode, /* i : Decoder frame mode */ @@ -4000,14 +3998,6 @@ void inverseMS_fx( const Word32 norm_fac /* i : normalization factor Q31*/ ); -#ifndef JBM_MEMORY_OPT -void ivas_syn_output_f_fx( - Word32 *synth[], /* i/o: Word32 synthesis signal */ - const Word16 output_frame, /* i : output frame length (one channel) */ - const Word16 n_channels, /* i : number of output channels */ - Word32 *synth_out /* o : integer 16 bits synthesis signal */ -); -#endif ivas_error ivas_init_encoder_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -6186,10 +6176,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ -#ifndef JBM_MEMORY_OPT - , - Word32 *data_fx /* i/o: transport channels/output synthesis signal */ -#endif ); void ivas_dec_prepare_renderer_fx( diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 973837ac0..69060e55d 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -149,7 +149,6 @@ UWord32 ivas_syn_output_fx( return noClipping; /*Q0*/ } -#ifdef JBM_MEMORY_OPT /*-------------------------------------------------------------------* * ivas_buffer_interleaved_to_deinterleaved() @@ -228,42 +227,6 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( return; } -#else - -/*-------------------------------------------------------------------* - * ivas_syn_output_f() - * - * Output ivas synthesis signal with compensation for saturation - * returns number of clipped samples - *-------------------------------------------------------------------*/ - -/*! r: number of clipped samples */ -void ivas_syn_output_f_fx( - Word32 *synth[], /* i/o: float synthesis signal Q11*/ - const Word16 output_frame, /* i : output frame length (one channel) Q0*/ - const Word16 n_channels, /* i : number of output channels Q0*/ - Word32 *synth_out /* o : integer 16 bits synthesis signal Q11*/ -) -{ - Word16 i, n; - - /*-----------------------------------------------------------------* - * float to integer conversion with saturation control - *-----------------------------------------------------------------*/ - - FOR( n = 0; n < n_channels; n++ ) - { - FOR( i = 0; i < output_frame; i++ ) - { - synth_out[( ( i * n_channels ) + n )] = synth[n][i]; /*Q11*/ - move16(); - } - } - - return; -} - -#endif /*-------------------------------------------------------------------* * mvr2r_inc() diff --git a/lib_com/options.h b/lib_com/options.h index b388d0a67..a20eb0762 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -132,7 +132,6 @@ #define FIX_1384_MSAN_ivas_spar_dec_open /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1288_SPLIT_REND_XSAN /* Dlb: Fix asan, msan and usan issues in split rendering mode*/ -#define JBM_MEMORY_OPT /* VA: issue 916: optimization of RAM in the JBM decoder */ #define NONBE_1324_TC_BUFFER_MEMOERY_KEEP /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index e4fe38732..ae119ae73 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1520,19 +1520,10 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ -#ifndef JBM_MEMORY_OPT - , - Word32 *data /* i : transport channels */ -#endif ) { -#ifdef JBM_MEMORY_OPT Word32 tmp_buf_fx[MAX_JBM_L_FRAME48k]; Word32 *p_data_fx[FOA_CHANNELS + MAX_NUM_OBJECTS]; -#else - Word32 data_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* buffer for transport channels that will be directly converted with the CLDFB */ - Word32 *p_data_fx[MAX_CLDFB_DIGEST_CHANNELS]; -#endif Word16 n, n_render_timeslots, n_ch_cldfb; #ifdef FIX_1330_JBM_MEMORY Word16 ch, offset, len_offset; @@ -1550,7 +1541,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( IF( st_ivas->hDecoderConfig->Opt_tsm ) { -#ifdef JBM_MEMORY_OPT Word16 n_samples_still_available; Word16 n_ch_full_copy, n_ch_res_copy; @@ -1604,52 +1594,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual ); } } -#else - Word16 n_samples_still_available, m; - Word16 n_ch_full_copy; - Word16 n_ch_res_copy; - - FOR( n = 0; n < n_ch_cldfb; n++ ) - { - p_data_fx[n] = &data_fx[n][0]; - } - - n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); - hTcBuffer->n_samples_buffered = add( add( n_samples_still_available, nSamplesForRendering ), hTcBuffer->n_samples_discard ); - hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) ); - *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available ); - move16(); - move16(); - move16(); - n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); - n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); - - FOR( ch = 0; ch < n_ch_full_copy; ch++ ) - { - set32_fx( hTcBuffer->tc_fx[ch], 0, hTcBuffer->n_samples_discard ); - Copy32( hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); - FOR( m = 0; m < nSamplesForRendering; m++ ) - { - hTcBuffer->tc_fx[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * hTcBuffer->nchan_transport_jbm + ch]; - move32(); - } - } - - IF( n_ch_res_copy > 0 ) - { - FOR( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) - { - Copy32( hTcBuffer->tc_fx[ch], p_data_fx[ch], n_samples_still_available ); - - FOR( m = 0; m < nSamplesForRendering; m++ ) - { - p_data_fx[ch][n_samples_still_available + m] = data[m * hTcBuffer->nchan_transport_jbm + ch]; - move32(); - } - Copy32( p_data_fx[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc_fx[ch], *nSamplesResidual ); - } - } -#endif n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity ); } @@ -1661,11 +1605,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( move16(); } -#ifdef JBM_MEMORY_OPT ch = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); -#else - ch = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); -#endif FOR( n = 0; n < ch; n++ ) { hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */ @@ -1759,11 +1699,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( !st_ivas->hDecoderConfig->Opt_tsm ) { -#ifdef JBM_MEMORY_OPT FOR( n = 0; n < MAX_INTERN_CHANNELS; n++ ) -#else - FOR( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ ) -#endif { st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; } @@ -2643,7 +2579,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { Word16 ch_idx; -#ifdef JBM_MEMORY_OPT /* render available full slots (with new lower granularity) */ FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) { @@ -2655,16 +2590,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); #endif } -#else - /* render what is still there with zero padding */ - FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - /* move it at the beginning of the TC buffer with zero padding */ - Copy32( hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_rendered, hTcBuffer->tc_fx[ch_idx], n_samples_to_render ); - set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); - Copy32( hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_rendered + n_samples_to_render, hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_granularity, n_samples_still_available ); - } -#endif /* simple change of the slot info */ hTcBuffer->num_slots = 1; @@ -3466,7 +3391,6 @@ Word16 ivas_jbm_dec_get_render_granularity_fx( return render_granularity; } -#ifdef JBM_MEMORY_OPT /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_audio_allocate() @@ -3615,7 +3539,6 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( return; } -#endif /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() @@ -3632,17 +3555,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */ ) { -#ifndef JBM_MEMORY_OPT - Word16 nsamp_to_allocate; -#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; Word16 nMaxSlotsPerSubframe; -#ifdef JBM_MEMORY_OPT ivas_error error; -#else - Word16 nchan_residual; - Word16 ch_idx; -#endif Word16 tmp, tmp_e; Word32 tmp32; @@ -3663,9 +3578,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( move16(); hTcBuffer->nchan_buffer_full = nchan_full; move16(); -#ifndef JBM_MEMORY_OPT - nchan_residual = sub( nchan_transport_internal, nchan_full ); -#endif hTcBuffer->n_samples_granularity = n_samples_granularity; move16(); hTcBuffer->n_samples_available = 0; @@ -3684,10 +3596,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( move16(); hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; move16(); -#ifndef JBM_MEMORY_OPT - nsamp_to_allocate = 0; - move16(); -#endif tmp32 = L_mult0( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, hTcBuffer->n_samples_granularity ); // Q0 tmp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, tmp32, &tmp_e ); @@ -3699,75 +3607,10 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); -#ifdef JBM_MEMORY_OPT IF( ( error = ivas_jbm_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) { return error; } -#else - { - Word16 n_samp_full, n_samp_residual; - Word32 offset; - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - n_samp_full = add( NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ), sub( hTcBuffer->n_samples_granularity, 1 ) ); - n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); - } - ELSE - { - /* n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); */ - n_samp_full = extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - n_samp_residual = 0; - move16(); - } - - nsamp_to_allocate = mult0( hTcBuffer->nchan_buffer_full, n_samp_full ); - nsamp_to_allocate = add( nsamp_to_allocate, mult0( nchan_residual, n_samp_residual ) ); - - IF( nsamp_to_allocate == 0 ) - { - hTcBuffer->tc_buffer_fx = NULL; - - FOR( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = NULL; - } - } - ELSE - { - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - /* note: the maximum buffer length is for OSBA DISC mode with ISMs -> 15*(1920+239)=32385 samples */ - IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set32_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate ); - - offset = 0; - move16(); - FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; - offset = L_add( offset, n_samp_full ); - } - FOR( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; - offset = L_add( offset, n_samp_residual ); - } - FOR( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = NULL; - } - } - ELSE - { - hTcBuffer->tc_buffer_fx = NULL; - } - } - } -#endif st_ivas->hTcBuffer = hTcBuffer; @@ -3794,12 +3637,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( Word16 ch_idx, num_tc_buffer_mem, n_samples_still_available; Word32 tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1]; #endif -#ifdef JBM_MEMORY_OPT ivas_error error; -#else - Word16 nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; - Word16 ch_idx; -#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; @@ -3857,13 +3695,9 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( move16(); hTcBuffer->nchan_buffer_full = nchan_full; move16(); -#ifndef JBM_MEMORY_OPT - nchan_residual = sub( nchan_transport_internal, nchan_full ); -#endif hTcBuffer->n_samples_granularity = n_samples_granularity; move16(); -#ifdef JBM_MEMORY_OPT /* reallocate TC audio buffers */ ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer ); @@ -3872,70 +3706,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( { return error; } -#else - /* realloc buffers */ - IF( hTcBuffer->tc_buffer_fx != NULL ) - { - free( hTcBuffer->tc_buffer_fx ); - hTcBuffer->tc_buffer_fx = NULL; - } - - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - n_samp_full = ( add( NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ), sub( hTcBuffer->n_samples_granularity, 1 ) ) ); - n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); - } - ELSE - { - n_samp_full = extract_l( Mult_32_16( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); - n_samp_residual = 0; - move16(); - } - - nsamp_to_allocate = imult1616( hTcBuffer->nchan_buffer_full, n_samp_full ); - nsamp_to_allocate = add( nsamp_to_allocate, imult1616( nchan_residual, n_samp_residual ) ); - - IF( nsamp_to_allocate == 0 ) - { - hTcBuffer->tc_buffer_fx = NULL; - FOR( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = NULL; - } - } - ELSE - { - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR JBM TC Buffer\n" ) ); - } - set32_fx( hTcBuffer->tc_buffer_fx, 0, nsamp_to_allocate ); - - offset = 0; - move16(); - FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; - offset = add( offset, n_samp_full ); - } - FOR( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset]; - offset = add( offset, n_samp_residual ); - } - FOR( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc_fx[ch_idx] = NULL; - } - } - ELSE - { - hTcBuffer->tc_buffer_fx = NULL; - } - } -#endif #ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP /* propagate samples of the TC buffer from the previous frame */ @@ -4016,26 +3786,9 @@ void ivas_jbm_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { -#ifndef JBM_MEMORY_OPT - Word16 i; -#endif IF( *phTcBuffer != NULL ) { -#ifdef JBM_MEMORY_OPT ivas_jbm_dec_tc_audio_deallocate_fx( *phTcBuffer ); -#else - - FOR( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) - { - ( *phTcBuffer )->tc_fx[i] = NULL; - } - - IF( ( *phTcBuffer )->tc_buffer_fx != NULL ) - { - free( ( *phTcBuffer )->tc_buffer_fx ); - ( *phTcBuffer )->tc_buffer_fx = NULL; - } -#endif free( *phTcBuffer ); *phTcBuffer = NULL; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index df8607cb5..3849c8ed4 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1017,15 +1017,9 @@ typedef struct ivas_masa_ism_data_structure typedef struct decoder_tc_buffer_structure { -#ifdef JBM_MEMORY_OPT Word32 *tc_buffer_old_fx[MAX_INTERN_CHANNELS]; /* TC audio samples not rendered in the previous frame */ -#endif Word32 *tc_buffer_fx; /* the buffer itself */ -#ifdef JBM_MEMORY_OPT Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ -#else - Word32 *tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc Q11 for ivas */ -#endif Word16 no_channels; /*Stores no of channels in tc_fx with values*/ Word16 q_tc_fx; TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 98dd104c2..af937febb 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -50,13 +50,8 @@ */ /* size of IO buffers (a_in[], a_out[]) for apa_exec() */ -#ifdef JBM_MEMORY_OPT #define APA_BUF_PER_CHANNEL ( IVAS_MAX_FRAME_SIZE * 2 ) /* == twice the max. frame length */ #define APA_MAX_NUM_CHANNELS ( 12 ) /* == MAX_TRANSPORT_CHANNELS */ -#else -#define APA_BUF_PER_CHANNEL ( IVAS_MAX_FRAME_SIZE * 3 ) -#define APA_MAX_NUM_CHANNELS 16 -#endif #define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS ) /* min/max sampling rate [Hz] */ diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index bc9ef573f..c5919ffe9 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -694,11 +694,7 @@ UWord8 apa_exec_fx( ) { UWord16 i; -#ifdef JBM_MEMORY_OPT Word16 frm_in[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */ /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate and number of channels */ -#else - Word16 frm_in[APA_BUF]; /* TODO(mcjbm): this buffer could be smaller - always allocates space for 16 channels */ -#endif UWord16 l_frm_out; Word16 l_rem; Word32 dl_scaled, dl_copied, l_frm_out_target; @@ -914,11 +910,7 @@ UWord8 apa_exec_ivas_fx( ) { UWord16 i; -#ifdef JBM_MEMORY_OPT Word16 frm_in[APA_BUF]; /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate and number of channels */ -#else - Word16 frm_in[APA_BUF]; /* TODO(mcjbm): this buffer could be smaller - always allocates space for 16 channels */ -#endif UWord16 l_frm_out; Word16 l_rem; Word32 dl_scaled, dl_copied, l_frm_out_target; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 82d52ca00..02e1cc76c 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -85,9 +85,6 @@ struct IVAS_DEC Word16 tsm_max_scaling; Word16 timeScalingDone; /* have we done already one TSM in a 20ms frame? */ Word16 tsm_quality; /*Q14*/ -#ifndef JBM_MEMORY_OPT - Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ -#endif PCMDSP_APA_HANDLE hTimeScaler; bool needNewFrame; bool hasBeenFedFrame; @@ -166,9 +163,6 @@ ivas_error IVAS_DEC_Open( hIvasDec = *phIvasDec; hIvasDec->hVoIP = NULL; -#ifndef JBM_MEMORY_OPT - hIvasDec->apaExecBuffer_fx = NULL; -#endif hIvasDec->hTimeScaler = NULL; hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; @@ -442,12 +436,6 @@ void IVAS_DEC_Close( apa_exit( &( *phIvasDec )->hTimeScaler ); -#ifndef JBM_MEMORY_OPT - IF( ( *phIvasDec )->apaExecBuffer_fx != NULL ) - { - free( ( *phIvasDec )->apaExecBuffer_fx ); - } -#endif IF( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); @@ -4185,7 +4173,6 @@ ivas_error IVAS_DEC_ReadFormat( return IVAS_ERR_OK; } -#ifdef JBM_MEMORY_OPT /*---------------------------------------------------------------------* * apa_exec_evs_wrapper( ) @@ -4231,7 +4218,6 @@ static ivas_error apa_exec_evs_wrapper( return IVAS_ERR_OK; } -#endif /*---------------------------------------------------------------------* @@ -4268,12 +4254,8 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } st_ivas = hIvasDec->st_ivas; -#ifdef JBM_MEMORY_OPT test(); isInitialized_voip = hIvasDec->hTimeScaler != NULL; -#else - isInitialized_voip = hIvasDec->apaExecBuffer_fx != NULL; -#endif test(); IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) /* wait for the first good frame */ @@ -4338,50 +4320,16 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_UNKNOWN; } -#ifdef JBM_MEMORY_OPT /* convert deinterleaved decoded TC audio channels buffer to an interleaved one */ ivas_buffer_deinterleaved_to_interleaved_fx( st_ivas->p_output_fx, nTransportChannels, hIvasDec->nSamplesFrame, st_ivas->hTcBuffer->tc_buffer_fx ); -#else - ivas_syn_output_f_fx( st_ivas->p_output_fx, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer_fx ); -#endif IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { -#ifdef JBM_MEMORY_OPT apa_exec_evs_wrapper( hIvasDec, nTransportChannels, &nTimeScalerOutSamples ); -#else - Word16 tmp_apaExecBuffer[APA_BUF]; - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { -#ifdef JBM_MEMORY_OPT - tmp_apaExecBuffer[i] = extract_l( L_shr( st_ivas->hTcBuffer->tc_buffer_fx[i], Q11 ) ); // Q0 -#else - tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 -#endif - } - - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { -#ifdef JBM_MEMORY_OPT - st_ivas->hTcBuffer->tc_buffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 -#else - hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 -#endif - } -#endif } ELSE { -#ifdef JBM_MEMORY_OPT IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, st_ivas->hTcBuffer->tc_buffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, st_ivas->hTcBuffer->tc_buffer_fx, &nTimeScalerOutSamples ) != 0 ) -#else - IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) -#endif { return IVAS_ERR_UNKNOWN; } @@ -4391,11 +4339,9 @@ ivas_error IVAS_DEC_GetSamplesDecoder( nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); hIvasDec->timeScalingDone = 1; move16(); -#ifdef JBM_MEMORY_OPT /* convert interleaved time-scaled TC audio channels buffer to deinterleaved one */ ivas_buffer_interleaved_to_deinterleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, nSamplesTcsScaled, NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) ); -#endif } else { @@ -4406,11 +4352,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( * Feed decoded transport channels samples to the renderer *-----------------------------------------------------------------*/ -#ifdef JBM_MEMORY_OPT ivas_jbm_dec_feed_tc_to_renderer_fx( st_ivas, nSamplesTcsScaled, &nResidualSamples ); -#else - ivas_jbm_dec_feed_tc_to_renderer_fx( st_ivas, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ); -#endif IF( st_ivas->hDecoderConfig->Opt_tsm ) { @@ -6267,9 +6209,6 @@ static ivas_error apa_setup( const bool isInitialized_voip, const UWord16 nTransportChannels ) { -#ifndef JBM_MEMORY_OPT - Word16 apa_buffer_size; -#endif UWord16 l_ts; l_ts = (UWord16) hIvasDec->st_ivas->hTcBuffer->n_samples_granularity; @@ -6283,12 +6222,6 @@ static ivas_error apa_setup( Word32 startQuality; startQuality = L_shl( L_deposit_l( hIvasDec->tsm_quality ), Q2 ); /* Q14 --> Q16*/ -#ifndef JBM_MEMORY_OPT - apa_buffer_size = APA_BUF_PER_CHANNEL; - - move16(); - /* get current renderer type*/ -#endif hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; IF( EQ_32( hDecoderConfig->output_Fs, 8000 ) ) @@ -6339,14 +6272,6 @@ static ivas_error apa_setup( return IVAS_ERR_INIT_ERROR; } } -#ifndef JBM_MEMORY_OPT - IF( ( hIvasDec->apaExecBuffer_fx = malloc( sizeof( Word32 ) * L_mult0( apa_buffer_size, (Word16) nTransportChannels ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); - } - - set_zero2_fx( hIvasDec->apaExecBuffer_fx, L_mult0( apa_buffer_size, (Word16) nTransportChannels ) ); -#endif } ELSE { @@ -6354,16 +6279,6 @@ static ivas_error apa_setup( { return IVAS_ERR_INIT_ERROR; } -#ifndef JBM_MEMORY_OPT - apa_buffer_size = APA_BUF_PER_CHANNEL; - move16(); - free( hIvasDec->apaExecBuffer_fx ); - IF( ( hIvasDec->apaExecBuffer_fx = malloc( sizeof( Word32 ) * L_mult0( apa_buffer_size, (Word16) nTransportChannels ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); - } - set_zero2_fx( hIvasDec->apaExecBuffer_fx, L_mult0( apa_buffer_size, (Word16) nTransportChannels ) ); -#endif } hIvasDec->nTransportChannelsOld = nTransportChannels; -- GitLab From 05a433c0b1fa2f714b826194a32b1137adbb29da Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:43 +0100 Subject: [PATCH 322/351] [cleanup] accept NONBE_FIX_1172_OBJ_EDIT_JBM --- lib_com/options.h | 1 - lib_dec/lib_dec_fx.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a20eb0762..ac4c6af9b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -157,7 +157,6 @@ #define OBJ_EDIT_BASOP #define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ -#define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ #define FIX_2193_ISM_GAINS_WITH_OE /* FhG: fix issue 2193: use edited angles in ISM gain calculation */ #define FIX_2192_OBJ_EDITING_EXT_METADATA /* Eri: Add support for extended metadata in object editing */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 02e1cc76c..dec6a9242 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4961,18 +4961,6 @@ ivas_error IVAS_DEC_SetEditableParameters( st_ivas->hIsmMetaData[obj]->edited_radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; move32(); #endif -#ifndef NONBE_FIX_1172_OBJ_EDIT_JBM - st_ivas->hIsmMetaData[obj]->azimuth_fx = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; - move32(); - st_ivas->hIsmMetaData[obj]->elevation_fx = hIvasEditableParameters.ism_metadata[obj].elevation_fx; - move32(); - st_ivas->hIsmMetaData[obj]->yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; - move32(); - st_ivas->hIsmMetaData[obj]->pitch_fx = hIvasEditableParameters.ism_metadata[obj].pitch_fx; - move32(); - st_ivas->hIsmMetaData[obj]->radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; - move32(); -#endif #ifdef FIX_GAIN_EDIT_LIMITS test(); IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) ) -- GitLab From 8ccb25782a03a5f894d41fbf53af0444e4b2957f Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:53 +0100 Subject: [PATCH 323/351] [cleanup] accept NONBE_1302_FIX_OMASA_JBM_FLUSH --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 9 --------- 2 files changed, 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ac4c6af9b..4165167e7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -114,7 +114,6 @@ /* #################### Start BASOP porting switches ############################ */ #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_1302_FIX_OMASA_JBM_FLUSH /* VA: issue 1302: fix OMASA JBM bitrate switching flush in binaural output */ #define NONBE_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328 */ #define NONBE_FIX_1376_MDCT_CONCEALMENT /* FhG: fix concealment artifact in MDCT Stereo with DTX, in case transition frame gets lost */ #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ae119ae73..6391010ab 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2737,13 +2737,11 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( IF( EQ_16( ism_mode_old, ISM_MASA_MODE_DISC ) ) { Word32 *tc_local_fx[MAX_NUM_OBJECTS]; -#ifdef NONBE_1302_FIX_OMASA_JBM_FLUSH Word16 last_dirac_md_idx; UWord16 nSamplesAvailableNext; ISM_MODE ism_mode_orig; RENDERER_TYPE renderer_type_orig; Word32 ivas_total_brate; -#endif /* copy from ISM delay buffer to the correct place in TCs */ move16(); @@ -2753,7 +2751,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); /*Q11*/ } -#ifdef NONBE_1302_FIX_OMASA_JBM_FLUSH /* to render flushed samples, use configuration from the last received frame */ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; renderer_type_orig = st_ivas->renderer_type; @@ -2780,12 +2777,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->ism_mode = ism_mode_orig; st_ivas->renderer_type = renderer_type_orig; st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; -#else - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif } } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) -- GitLab From e2e3cfc0352ce9ef86ad9fba5060f76f4ae9b1c8 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:56 +0100 Subject: [PATCH 324/351] [cleanup] accept NONBE_1324_TC_BUFFER_MEMOERY_KEEP --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 8 -------- lib_dec/ivas_omasa_dec_fx.c | 2 -- 3 files changed, 11 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4165167e7..5925e3511 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -131,7 +131,6 @@ #define FIX_1384_MSAN_ivas_spar_dec_open /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1288_SPLIT_REND_XSAN /* Dlb: Fix asan, msan and usan issues in split rendering mode*/ -#define NONBE_1324_TC_BUFFER_MEMOERY_KEEP /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ #define CODE_IMPROVEMENTS diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 6391010ab..a86e7cd1e 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -804,10 +804,8 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11 } -#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP st_ivas->hCPE[0]->q_output_mem_fx[0] = output_q; st_ivas->hCPE[0]->q_output_mem_fx[1] = output_q; -#endif } } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) @@ -3624,17 +3622,14 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ ) { -#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP Word16 ch_idx, num_tc_buffer_mem, n_samples_still_available; Word32 tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1]; -#endif ivas_error error; DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; move16(); -#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP num_tc_buffer_mem = 0; move16(); n_samples_still_available = 0; @@ -3655,7 +3650,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( } } -#endif /* if granularity changes, adapt subframe_nb_slots */ IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) ) { @@ -3698,14 +3692,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( return error; } -#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP /* propagate samples of the TC buffer from the previous frame */ FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ ) { Copy32( tc_buffer_mem[ch_idx], hTcBuffer->tc_buffer_old_fx[ch_idx], n_samples_still_available ); } -#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 7df8ddfef..e74865e86 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -757,7 +757,6 @@ ivas_error ivas_omasa_dec_config_fx( /* ISM renderer handle + ISM data handle */ ivas_omasa_separate_object_renderer_close( st_ivas ); } -#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP IF( EQ_32( old_renderer_type, RENDERER_MONO_DOWNMIX ) ) { @@ -769,7 +768,6 @@ ivas_error ivas_omasa_dec_config_fx( Scale_sig32( hTcBuffer->tc_buffer_old_fx[k], n_samples_still_available, st_ivas->hCPE[0]->q_output_mem_fx[0] - Q11 ); } } -#endif } IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ) -- GitLab From 4ef47437a2635a694bac9affe141c408ad87d3e9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:49:59 +0100 Subject: [PATCH 325/351] [cleanup] accept FIX_938_COMPILER_WARNING --- lib_com/options.h | 1 - lib_dec/ivas_mdct_core_dec_fx.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5925e3511..86ffa03f2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,6 @@ #define FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add split rendering support to decoder in VoIP mode */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #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 FIX_938_COMPILER_WARNING /* FhG: Fix compiler warning in ivas_mdct_core_reconstruct() */ #define FIX_1376_MISSING_ISM_METADATA /* FhG: IVAS_rend: throw error if there exists an ISM input without a corresponding metadata file path */ #define FIX_1385_INIT_IGF_STOP_FREQ /* FhG: Initialize infoIGFStopFreq in init_igf_dec() */ #define FIX_1387_INIT_PRM_SQQ /* FhG: initialize pointer prm_sqQ, which might be uninitialized in case of bfi == 1 */ diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index be931598e..0b3f4651f 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1406,16 +1406,9 @@ void ivas_mdct_core_reconstruct_fx( Copy_Scale_sig_16_32_no_sat( st->p_bpf_noise_buf, st->p_bpf_noise_buf_32, st->L_frame, Q11 ); // Q0 -> Q11 } -#ifndef FIX_938_COMPILER_WARNING - IF( signal_outFB_fx[ch] != NULL ) - { -#endif Copy( synthFB_fx, signal_outFB_fx[ch], st->hTcxDec->L_frameTCX ); e_sig[ch] = sub( 15, q_syn + st->Q_syn_factor ); move16(); -#ifndef FIX_938_COMPILER_WARNING - } -#endif /* updates */ st->last_voice_factor_fx = 0; -- GitLab From 774d52d6f64892fbfbb2d01a7dd8cdddbb4da221 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:03 +0100 Subject: [PATCH 326/351] [cleanup] accept FIX_1288_SPLIT_REND_XSAN --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 86ffa03f2..dfe2be993 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,7 +129,6 @@ #define FIX_1384_MSAN_stereo_tcx_core_enc /* VA: issue 1384: fix use-of-uninitialized value in stereo_tcx_core_enc() */ #define FIX_1384_MSAN_ivas_spar_dec_open /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ -#define FIX_1288_SPLIT_REND_XSAN /* Dlb: Fix asan, msan and usan issues in split rendering mode*/ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ #define CODE_IMPROVEMENTS -- GitLab From 78384026c2f1ebfa2ff1fb6b9457b23a3b4985e5 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:18 +0100 Subject: [PATCH 327/351] [cleanup] accept NONBE_1352_HARMONIZE_OSBA_LOUDNESS --- apps/renderer.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 6f5bebe8a..f527fdf4d 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -3893,20 +3893,10 @@ static void parseCombinedFormatInput( inConfig->numAmbisonicsBuses = 1; inConfig->ambisonicsBuses[0].audioConfig = audioConfig; inConfig->ambisonicsBuses[0].inputChannelIndex = inConfig->numAudioObjects; -#ifdef NONBE_1352_HARMONIZE_OSBA_LOUDNESS inConfig->ambisonicsBuses[0].gain_dB = 0.f; -#else - inConfig->ambisonicsBuses[0].gain_dB = -6.f; -#endif *configString += 4; /* Modify input gain for objects too */ -#ifndef NONBE_1352_HARMONIZE_OSBA_LOUDNESS - for ( int16_t i = 0; i < inConfig->numAudioObjects; ++i ) - { - inConfig->audioObjects[i].gain_dB = -6.f; - } -#endif } else if ( audioConfig == IVAS_AUDIO_CONFIG_MASA1 || audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) { -- GitLab From d1d9fb04b549fa1ee403af077173a9f12981834b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:21 +0100 Subject: [PATCH 328/351] [cleanup] accept CODE_IMPROVEMENTS --- lib_com/options.h | 1 - lib_rend/ivas_rom_rend_fx.c | 6 ---- lib_rend/lib_rend_fx.c | 59 ------------------------------------- lib_util/mime_io.c | 4 --- lib_util/rtpdump.c | 8 ----- lib_util/tinywavein_c.h | 8 ----- lib_util/tinywaveout_c.h | 38 ------------------------ 7 files changed, 124 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index dfe2be993..0c713a611 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -131,7 +131,6 @@ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ -#define CODE_IMPROVEMENTS #define NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* Nokia: issue 1339: Apply scaling to the object-part of OMASA for binaural rendering in IVAS_rend. */ #define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */ #define FIX_1383_HEAD_TRACK_SANITIZER /* Nok: issue 1383: Fix head tracking struc values reading in renderer */ diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index 0579e68a4..fd56885f9 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -81,15 +81,9 @@ const Word32 ap_lattice_coeffs_2_fx[132] /* Q31 */ = { 1360843264, 1462880896, const Word32 ap_lattice_coeffs_3_fx[66] /* Q31 */ = { 1360843264, 1462880896, -106124344, 615715776, 313579872, 290773568, -880779712, -444026592, -1410828032, -218497872, 936944960, 729753600, -282142848, -1661606912, -647739072, 703431872, 713452032, 442076704, 1541038592, -1186205568, -322414592, 117158120, 514363136, -1392593792, -1550156800, 406684000, 146426176, 13348758, 165409920, 83060376, 909276800, -233341280, 927820288, -890434752, 596656832, 898691840, 167097856, -607873152, -766668864, 9951439, -950562176, -799540352, 866157440, 521887904, 675097984, 954584384, 746287104, 1065244224, 232804400, 1007990144, -365686400, 700745408, 369704352, 945610048, 125449552, 729442240, -418684160, 1054884800, -604078592, -92599496, -1036132928, -719417728, -721895936, 421913952, -353525216, 950242176}; const Word32 * const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS] = { -#ifdef CODE_IMPROVEMENTS ap_lattice_coeffs_1_fx, ap_lattice_coeffs_2_fx, ap_lattice_coeffs_3_fx, -#else - &ap_lattice_coeffs_1_fx[0], - &ap_lattice_coeffs_2_fx[0], - &ap_lattice_coeffs_3_fx[0], -#endif }; const Word16 ap_split_frequencies_fx[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]/*Q14*/ = { diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b1953ce96..07abd25f5 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4199,7 +4199,6 @@ static ivas_error getConstInputById( return IVAS_ERR_OK; } -#ifdef CODE_IMPROVEMENTS static void *getInputByIndex_fx( void *inputsArray, const size_t index, @@ -4224,57 +4223,31 @@ static void *getInputByIndex_fx( /* include a final return to make the linter happy and avoid problems with wmc_tool (see #1355) */ return NULL; } -#endif static ivas_error findFreeInputSlot_fx( -#ifdef CODE_IMPROVEMENTS void *inputs, const IVAS_REND_AudioConfigType inputType, -#else - const void *inputs, - const int32_t inputStructSize, -#endif const Word32 maxInputs, Word32 *inputIndex ) { -#ifdef CODE_IMPROVEMENTS /* Using a void pointer and a separately provided type is a hack for this function to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). Assumptions: - input_base is always the first member in the input struct - memory alignments of original input type and input_base are the same */ -#else - /* Using a void pointer and a separately provided size is a hack for this function - to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). - Assumptions: - - input_base is always the first member in the input struct - - provided size is correct - */ -#endif Word32 i; bool canAddInput; -#ifndef CODE_IMPROVEMENTS - const UWord8 *pByte; -#endif const input_base *pInputBase; canAddInput = false; move16(); /* Find first unused input in array */ -#ifdef CODE_IMPROVEMENTS FOR( i = 0; i < maxInputs; ++i ) -#else - FOR( i = 0, pByte = inputs; i < maxInputs; ++i, pByte += inputStructSize ) -#endif { -#ifdef CODE_IMPROVEMENTS pInputBase = (const input_base *) getInputByIndex_fx( inputs, i, inputType ); -#else - pInputBase = (const input_base *) pByte; -#endif IF( EQ_32( pInputBase->inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { @@ -4549,11 +4522,7 @@ ivas_error IVAS_REND_AddInput_fx( ivas_error error; Word32 maxNumInputsOfType; void *inputsArray; -#ifdef CODE_IMPROVEMENTS IVAS_REND_AudioConfigType inputType; -#else - Word32 inputStructSize; -#endif ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, RENDER_CONFIG_DATA *, hrtf_handles *hrtfs ); void ( *setInputDelay )( void *, bool ); Word32 inputIndex; @@ -4588,19 +4557,12 @@ ivas_error IVAS_REND_AddInput_fx( } -#ifdef CODE_IMPROVEMENTS inputType = getAudioConfigType( inConfig ); SWITCH( inputType ) -#else - SWITCH( getAudioConfigType( inConfig ) ) -#endif { case IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED: maxNumInputsOfType = RENDERER_MAX_ISM_INPUTS; inputsArray = hIvasRend->inputsIsm; -#ifndef CODE_IMPROVEMENTS - inputStructSize = sizeof( *hIvasRend->inputsIsm ); -#endif activateInput = setRendInputActiveIsm; setInputDelay = setRendInputDelayIsm; move32(); @@ -4609,9 +4571,6 @@ ivas_error IVAS_REND_AddInput_fx( case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: maxNumInputsOfType = RENDERER_MAX_MC_INPUTS; inputsArray = hIvasRend->inputsMc; -#ifndef CODE_IMPROVEMENTS - inputStructSize = sizeof( *hIvasRend->inputsMc ); -#endif activateInput = setRendInputActiveMc; setInputDelay = setRendInputDelayMc; move32(); @@ -4620,9 +4579,6 @@ ivas_error IVAS_REND_AddInput_fx( case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: maxNumInputsOfType = RENDERER_MAX_SBA_INPUTS; inputsArray = hIvasRend->inputsSba; -#ifndef CODE_IMPROVEMENTS - inputStructSize = sizeof( *hIvasRend->inputsSba ); -#endif activateInput = setRendInputActiveSba; setInputDelay = setRendInputDelaySba; move32(); @@ -4631,9 +4587,6 @@ ivas_error IVAS_REND_AddInput_fx( case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: maxNumInputsOfType = RENDERER_MAX_MASA_INPUTS; inputsArray = hIvasRend->inputsMasa; -#ifndef CODE_IMPROVEMENTS - inputStructSize = sizeof( *hIvasRend->inputsMasa ); -#endif activateInput = setRendInputActiveMasa; setInputDelay = setRendInputDelayMasa; move32(); @@ -4644,31 +4597,19 @@ ivas_error IVAS_REND_AddInput_fx( } /* Find first free input in array corresponding to input type */ -#ifdef CODE_IMPROVEMENTS IF( NE_32( ( error = findFreeInputSlot_fx( inputsArray, inputType, maxNumInputsOfType, &inputIndex ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = findFreeInputSlot_fx( inputsArray, inputStructSize, maxNumInputsOfType, &inputIndex ) ), IVAS_ERR_OK ) ) -#endif { return error; } *inputId = makeInputId( inConfig, inputIndex ); move16(); -#ifdef CODE_IMPROVEMENTS IF( NE_32( ( error = activateInput( getInputByIndex_fx( inputsArray, inputIndex, inputType ), inConfig, *inputId, hIvasRend->hRendererConfig, &hIvasRend->hHrtfs ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, hIvasRend->hRendererConfig, &hIvasRend->hHrtfs ) ), IVAS_ERR_OK ) ) -#endif { return error; } -#ifdef CODE_IMPROVEMENTS setInputDelay( getInputByIndex_fx( inputsArray, inputIndex, inputType ), splitPreRendCldfb ); -#else - setInputDelay( (Word8 *) inputsArray + inputStructSize * inputIndex, splitPreRendCldfb ); -#endif /* set global maximum delay after adding an input */ setMaxGlobalDelayNs( hIvasRend ); diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index 87ce9d131..3e837ca45 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -317,11 +317,7 @@ static bool readByte( FILE *file, uint8_t *value ) static bool readLong( FILE *file, uint16_t *value ) { char buffer[4] = { 0 }; -#ifdef CODE_IMPROVEMENTS if ( fread( buffer, 1, 4, file ) != 1U ) -#else - if ( fread( buffer, 4, 1, file ) != 1U ) -#endif { return false; } diff --git a/lib_util/rtpdump.c b/lib_util/rtpdump.c index 5c9faf59a..cbb6fb1f6 100644 --- a/lib_util/rtpdump.c +++ b/lib_util/rtpdump.c @@ -81,11 +81,7 @@ static unsigned char *parseByte( unsigned char *buffer, unsigned char *value ) static int readLong( FILE *file, unsigned int *value ) { char buffer[4] = { 0 }; -#ifdef CODE_IMPROVEMENTS if ( fread( buffer, 1, 4, file ) != 1U ) -#else - if ( fread( buffer, 4, 1, file ) != 1U ) -#endif { return -1; } @@ -101,11 +97,7 @@ static int readLong( FILE *file, unsigned int *value ) static int readShort( FILE *file, unsigned short *value ) { char buffer[2] = { 0 }; -#ifdef CODE_IMPROVEMENTS if ( fread( buffer, 1, 2, file ) != 1U ) -#else - if ( fread( buffer, 2, 1, file ) != 1U ) -#endif { return -1; } diff --git a/lib_util/tinywavein_c.h b/lib_util/tinywavein_c.h index 179c676a8..1ff6f26bb 100644 --- a/lib_util/tinywavein_c.h +++ b/lib_util/tinywavein_c.h @@ -54,22 +54,14 @@ #define __TWI_SUCCESS ( 0 ) #define __TWI_ERROR ( -1 ) -#ifdef CODE_IMPROVEMENTS typedef struct tinyWaveInHandle -#else -typedef struct __tinyWaveInHandle -#endif { FILE *theFile; fpos_t dataChunkPos; uint32_t position; uint32_t length; uint32_t bps; -#ifdef CODE_IMPROVEMENTS } tinyWaveInHandle, WAVEFILEIN; -#else -} __tinyWaveInHandle, WAVEFILEIN; -#endif typedef struct { diff --git a/lib_util/tinywaveout_c.h b/lib_util/tinywaveout_c.h index 70373e3cc..a3982ba19 100644 --- a/lib_util/tinywaveout_c.h +++ b/lib_util/tinywaveout_c.h @@ -70,27 +70,15 @@ #endif #endif -#ifdef CODE_IMPROVEMENTS typedef struct tinyWaveOutHeader -#else -typedef struct __tinyWaveOutHeader -#endif { uint32_t riffType; /* 'RIFF' */ uint32_t riffSize; /* file size */ uint32_t waveType; /* 'WAVE' */ -#ifdef CODE_IMPROVEMENTS } tinyWaveOutHeader; -#else -} __tinyWaveOutHeader; -#endif -#ifdef CODE_IMPROVEMENTS typedef struct tinyWaveOutFmtChunk -#else -typedef struct __tinyWaveOutFmtChunk -#endif { uint32_t formatType; uint32_t formatSize; @@ -103,32 +91,16 @@ typedef struct __tinyWaveOutFmtChunk uint16_t bitsPerSample; /* wav fmt ext hdr here */ -#ifdef CODE_IMPROVEMENTS } tinyWaveOutFmtChunk; -#else -} __tinyWaveOutFmtChunk; -#endif -#ifdef CODE_IMPROVEMENTS typedef struct tinyWaveOutDataChunk -#else -typedef struct __tinyWaveOutDataChunk -#endif { uint32_t dataType; uint32_t dataSize; -#ifdef CODE_IMPROVEMENTS } tinyWaveOutDataChunk; -#else -} __tinyWaveOutDataChunk; -#endif -#ifdef CODE_IMPROVEMENTS typedef struct tinyWaveOutHandle -#else -typedef struct __tinyWaveOutHandle -#endif { FILE *theFile; uint32_t dataSize; @@ -137,11 +109,7 @@ typedef struct __tinyWaveOutHandle uint32_t dataChunkOffset; uint32_t bps; uint32_t clipCount; -#ifdef CODE_IMPROVEMENTS } tinyWaveOutHandle, WAVEFILEOUT; -#else -} __tinyWaveOutHandle, WAVEFILEOUT; -#endif /*--- local protos --------------------------------------------------*/ static __inline uint32_t BigEndian32( char, char, char, char ); @@ -164,15 +132,9 @@ static WAVEFILEOUT *CreateBWF( /* ,const uint32_t writeWaveExt */ ) { WAVEFILEOUT *self; -#ifdef CODE_IMPROVEMENTS tinyWaveOutHeader whdr; tinyWaveOutFmtChunk wfch; tinyWaveOutDataChunk wdch; -#else - __tinyWaveOutHeader whdr; - __tinyWaveOutFmtChunk wfch; - __tinyWaveOutDataChunk wdch; -#endif uint32_t blockAlignment = 0; uint32_t ByteCnt = 0; /* Byte counter for fwrite */ -- GitLab From 423f6601f6888dd7e517c0bdb77abba084311cf4 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:24 +0100 Subject: [PATCH 329/351] [cleanup] accept NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS --- apps/renderer.c | 11 ----------- lib_com/options.h | 1 - 2 files changed, 12 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index f527fdf4d..a4e828cb6 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -76,9 +76,7 @@ #define IVAS_MAX16B_FX 32767 #define IVAS_MIN16B_FX ( -32768 ) -#ifdef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS #define OMASA_TDREND_MATCHING_GAIN_DB ( -2.0f ) -#endif #if !defined( DEBUGGING ) && !defined( WMOPS ) static @@ -1304,30 +1302,22 @@ int main( } } -#ifndef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS - /* Set the total number of objects */ -#endif if ( args.inConfig.numAudioObjects > 0 ) { -#ifdef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* Set the total number of objects */ -#endif if ( ( error = IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_SetTotalNumberOfObjects(): %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#ifdef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* Set the metadata delay for objects */ -#endif IF( ( error = IVAS_REND_SetIsmMetadataDelay( hIvasRend, args.syncMdDelay ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_SetIsmMetadataDelay(): %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#ifdef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* For OMASA input and BINAURAL output, apply a gain to objects to match the loudness with MASA part */ if ( args.inConfig.numMasaBuses > 0 && args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL ) @@ -1337,7 +1327,6 @@ int main( args.inConfig.audioObjects[i].gain_dB += OMASA_TDREND_MATCHING_GAIN_DB; } } -#endif } IVAS_REND_LfePanMtx lfePanMatrix; diff --git a/lib_com/options.h b/lib_com/options.h index 0c713a611..6b3aa8834 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -131,7 +131,6 @@ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ -#define NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* Nokia: issue 1339: Apply scaling to the object-part of OMASA for binaural rendering in IVAS_rend. */ #define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */ #define FIX_1383_HEAD_TRACK_SANITIZER /* Nok: issue 1383: Fix head tracking struc values reading in renderer */ #define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ -- GitLab From c32cc04255d0870ab07a3decb70303adabe6e90c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:28 +0100 Subject: [PATCH 330/351] [cleanup] accept NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING --- lib_com/options.h | 1 - lib_rend/ivas_omasa_ana_fx.c | 87 ------------------------------------ 2 files changed, 88 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6b3aa8834..f5a25fe8e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -131,7 +131,6 @@ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ -#define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */ #define FIX_1383_HEAD_TRACK_SANITIZER /* Nok: issue 1383: Fix head tracking struc values reading in renderer */ #define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ #define FIX_1330_JBM_MEMORY_FIX /* VA: basop issue: 2179 fix non-BE difference in FIX_1330_JBM_MEMORY */ diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index ea4dadb73..9c209f036 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -676,13 +676,10 @@ static void ivas_omasa_dmx_fx( } set16_fx( data_e, 0, 4 ); set16_fx( in_e, 0, 960 ); -#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING max_e = 0; -#endif FOR( i = 0; i < nchan_ism; i++ ) { -#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING IF( EQ_16( nchan_transport, 1 ) ) { FOR( j = 0; j < input_frame; j++ ) @@ -749,66 +746,8 @@ static void ivas_omasa_dmx_fx( move32(); } } -#else - azimuth_fx = extract_l( L_shr( ism_azimuth_fx[i], Q22 ) ); // Q0 - elevation_fx = extract_l( L_shr( ism_elevation_fx[i], Q22 ) ); // Q0 - - ivas_ism_get_stereo_gains_fx( azimuth_fx, elevation_fx, &gains_fx[0], &gains_fx[1] ); - - /* Downmix using the panning gains */ - FOR( j = 0; j < nchan_transport; j++ ) - { - test(); - IF( abs_s( gains_fx[j] ) > 0 || L_abs( prev_gains_fx[i][j] ) > 0 ) - { - FOR( k = 0; k < input_frame; k++ ) - { - g1_fx = interpolator_fx[k]; // Q15 - move16(); - scale = BASOP_Util_Add_MantExp( 16384, 1, negate( g1_fx ), 0, &g2_fx ); - - tmp1 = mult( g1_fx, gains_fx[j] ); - tmp2 = mult( g2_fx, (Word16) L_shr( prev_gains_fx[i][j], 16 ) ); // Q: ( ( ( 15 - scale ) + ( Q31 - Q16 ) ) - Q15 ) -> ( 15 - scale ) - scale = BASOP_Util_Add_MantExp( tmp1, 0, tmp2, scale, &tmp1 ); - - L_tmp = data_in_f_fx[i][k]; // data_in_q - move32(); - tmp_e = sub( 31, *data_in_q ); - move16(); - - L_tmp = Mpy_32_16_1( L_tmp, tmp1 ); - scale = add( scale, tmp_e ); - - data_out_f_fx[j][k] = BASOP_Util_Add_Mant32Exp( data_out_f_fx[j][k], data_e[j], L_tmp, scale, &in_e[k] ); - move32(); - } - max_e = in_e[0]; - move16(); - FOR( l = 1; l < L_FRAME48k; l++ ) - { - IF( LT_16( max_e, in_e[l] ) ) - { - max_e = in_e[l]; - move16(); - } - } - - FOR( l = 0; l < L_FRAME48k; l++ ) - { - data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) - move32(); - } - data_e[j] = max_e; - move16(); - } - - prev_gains_fx[i][j] = L_deposit_h( gains_fx[j] ); // Q31 - move32(); - } -#endif } -#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING IF( NE_16( nchan_transport, 1 ) ) { max_e = data_e[0]; @@ -831,41 +770,15 @@ static void ivas_omasa_dmx_fx( } } } -#else - max_e = data_e[0]; - move16(); - FOR( i = 1; i < nchan_transport; i++ ) - { - IF( LT_16( max_e, data_e[i] ) ) - { - max_e = data_e[i]; - move16(); - } - } - - FOR( i = 0; i < nchan_transport; i++ ) - { - FOR( j = 0; j < input_frame; j++ ) - { - data_out_f_fx[i][j] = L_shr( data_out_f_fx[i][j], sub( max_e, data_e[i] ) ); // exponent: max_e, Q: ( 15 - max_e ) - move32(); - } - } -#endif FOR( i = 0; i < nchan_transport; i++ ) { Copy32( data_out_f_fx[i], data_in_f_fx[i], input_frame ); -#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING IF( NE_16( nchan_transport, 1 ) ) { *data_in_q = sub( 31, max_e ); move16(); } -#else - *data_in_q = sub( 31, max_e ); - move16(); -#endif } return; -- GitLab From be4afbbdab668c024d7ce7da6ee4fee9963d6b01 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:40 +0100 Subject: [PATCH 331/351] [cleanup] accept FIX_1376_MISSING_ISM_METADATA --- apps/renderer.c | 8 -------- lib_com/options.h | 1 - 2 files changed, 9 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index a4e828cb6..264cc07b1 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -663,7 +663,6 @@ static void setupWithSingleFormatInput( positionProvider->numObjects = args.inConfig.numAudioObjects; for ( int16_t i = 0; i < positionProvider->numObjects; ++i ) { -#ifdef FIX_1376_MISSING_ISM_METADATA /* Check if path to metadata file was given */ if ( isEmptyString( args.inMetadataFilePaths[i] ) ) { @@ -672,18 +671,11 @@ static void setupWithSingleFormatInput( } /* It is allowed on CLI to have no metadata for an ISM input - skip opening if string contains "NULL" */ -#else - /* It is allowed on CLI to have no metadata for an ISM input - skip opening if string is empty or contains "NULL" */ -#endif char charBuf[FILENAME_MAX]; strncpy( charBuf, args.inMetadataFilePaths[i], min( FILENAME_MAX, RENDERER_MAX_CLI_ARG_LENGTH ) - 1 ); charBuf[min( FILENAME_MAX, RENDERER_MAX_CLI_ARG_LENGTH ) - 1] = '\0'; to_upper( charBuf ); -#ifdef FIX_1376_MISSING_ISM_METADATA if ( strncmp( charBuf, "NULL", 4 ) == 0 ) -#else - if ( isEmptyString( args.inMetadataFilePaths[i] ) || strncmp( charBuf, "NULL", 4 ) == 0 ) -#endif { continue; } diff --git a/lib_com/options.h b/lib_com/options.h index f5a25fe8e..aab65f877 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,6 @@ #define FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add split rendering support to decoder in VoIP mode */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #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 FIX_1376_MISSING_ISM_METADATA /* FhG: IVAS_rend: throw error if there exists an ISM input without a corresponding metadata file path */ #define FIX_1385_INIT_IGF_STOP_FREQ /* FhG: Initialize infoIGFStopFreq in init_igf_dec() */ #define FIX_1387_INIT_PRM_SQQ /* FhG: initialize pointer prm_sqQ, which might be uninitialized in case of bfi == 1 */ #define FIX_1349_TNS_CRASH /* FhG: Fix crash in TNS entropy coding, in case order of joint TNS coding is reduced to 0 */ -- GitLab From 15f4cc016b664161c434e3d615d11cf934cc60bc Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:46 +0100 Subject: [PATCH 332/351] [cleanup] accept FIX_1330_JBM_MEMORY --- lib_com/ivas_prot_fx.h | 10 ------- lib_com/ivas_tools_fx.c | 6 ---- lib_com/options.h | 1 - lib_dec/ivas_cpe_dec_fx.c | 8 ------ lib_dec/ivas_init_dec_fx.c | 27 ------------------ lib_dec/ivas_ism_dec_fx.c | 21 -------------- lib_dec/ivas_ism_renderer_fx.c | 37 ------------------------ lib_dec/ivas_jbm_dec_fx.c | 52 ---------------------------------- lib_dec/ivas_masa_dec_fx.c | 11 ------- lib_dec/ivas_mct_dec_fx.c | 11 ------- lib_dec/ivas_omasa_dec_fx.c | 43 ---------------------------- lib_dec/ivas_osba_dec_fx.c | 34 ---------------------- lib_dec/ivas_sba_dec_fx.c | 16 ----------- lib_dec/ivas_stat_dec.h | 2 -- lib_rend/ivas_output_init_fx.c | 35 ----------------------- 15 files changed, 314 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c326ade0f..1adc3d5de 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1044,12 +1044,7 @@ void ivas_omasa_separate_object_render_jbm_fx( const UWord16 nSamplesRendered, /* i : number of samples rendered */ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal */ Word32 *output_fx[], /* o : rendered time signal */ -#ifdef FIX_1330_JBM_MEMORY const Word16 subframes_rendered /* i : number of subframes rendered */ -#else - const Word16 subframes_rendered, /* i : number of subframes rendered */ - const Word16 slots_rendered /* i : number of CLDFB slots rendered */ -#endif ); void get_panning_gain_fx( @@ -4004,14 +3999,9 @@ ivas_error ivas_init_encoder_fx( ivas_error ivas_output_buff_dec_fx( Word32 *p_output_fx[], /* i/o: output audio buffers */ -#ifdef FIX_1330_JBM_MEMORY const Word16 nchan_out_buff, /* i : number of output channels */ const Word16 Opt_tsm, /* i : TSM option flag */ DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ -#else - const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */ - const Word16 nchan_out_buff /* i : number of output channels */ - #endif ); ivas_error ivas_dec_get_format_fx( diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 69060e55d..d8ea700fc 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -201,25 +201,19 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( ) { Word16 ch, m; -#ifdef FIX_1330_JBM_MEMORY Word32 buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* temp buffer needed when "*audio[]" and "*audio_out[]" are the same */ FOR( ch = 0; ch < n_channels; ch++ ) { Copy32( audio[ch], buffer[ch], frame_length ); } -#endif FOR( ch = 0; ch < n_channels; ch++ ) { FOR( m = 0; m < frame_length; m++ ) { -#ifdef FIX_1330_JBM_MEMORY audio_out[m * n_channels + ch] = buffer[ch][m]; -#else - audio_out[m * n_channels + ch] = audio[ch][m]; -#endif move32(); } } diff --git a/lib_com/options.h b/lib_com/options.h index aab65f877..2d3d51d4b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -131,7 +131,6 @@ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ #define FIX_1383_HEAD_TRACK_SANITIZER /* Nok: issue 1383: Fix head tracking struc values reading in renderer */ -#define FIX_1330_JBM_MEMORY /* VA: issue 1330: memory savings in the JBM decoder */ #define FIX_1330_JBM_MEMORY_FIX /* VA: basop issue: 2179 fix non-BE difference in FIX_1330_JBM_MEMORY */ #define FIX_1411_IGF_CRASH_BW_SWITCHING /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/ #define FIX_1419_MONO_STEREO_UMX /* FhG: fix for issue 1419 : support upmix to all output formats for mono and stereo */ diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index d98255d14..e5b8837f0 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -887,11 +887,7 @@ static ivas_error stereo_dft_dec_main( FOR( n = 0; n < hCPE->nchan_out; n++ ) { -#ifdef FIX_1330_JBM_MEMORY Scale_sig32( output[n], output_frame, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft -#else - Scale_sig32( output[n], L_FRAME48k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft -#endif scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[n] = hCPE->hStereoDft->q_dft; move16(); @@ -905,11 +901,7 @@ static ivas_error stereo_dft_dec_main( FOR( n = 0; n < hCPE->nchan_out; n++ ) { -#ifdef FIX_1330_JBM_MEMORY Scale_sig32( output[n], output_frame, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 -#else - Scale_sig32( output[n], L_FRAME48k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 -#endif scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[n] = Q11; move16(); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 6de48e51d..90b5c7baa 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1693,9 +1693,7 @@ ivas_error ivas_init_decoder_fx( Word16 sce_id, cpe_id; Word16 numCldfbAnalyses, numCldfbSyntheses; Word16 granularity, n_channels_transport_jbm; -#ifdef FIX_1330_JBM_MEMORY Word16 nchan_out_buff; -#endif Word32 output_Fs, ivas_total_brate, tmp_br, tmp32; Word32 delay_ns; AUDIO_CONFIG output_config; @@ -3215,28 +3213,11 @@ ivas_error ivas_init_decoder_fx( * Allocate output audio buffers *-----------------------------------------------------------------*/ -#ifdef FIX_1330_JBM_MEMORY nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) { return error; } -#else - k = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); - FOR( n = 0; n < k; n++ ) - { - /* note: these are intra-frame heap memories */ - IF( ( st_ivas->p_output_fx[n] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output audio buffer!\n" ) ); - } - set32_fx( st_ivas->p_output_fx[n], 0, 48000 / FRAMES_PER_SEC ); - } - FOR( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) - { - st_ivas->p_output_fx[n] = NULL; - } -#endif return error; } @@ -3717,15 +3698,7 @@ void ivas_destroy_dec_fx( /* output audio buffers */ FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { -#ifdef FIX_1330_JBM_MEMORY st_ivas->p_output_fx[i] = NULL; -#else - IF( st_ivas->p_output_fx[i] != NULL ) - { - free( st_ivas->p_output_fx[i] ); - st_ivas->p_output_fx[i] = NULL; - } -#endif } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 5d8e1f705..4537b3840 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -59,11 +59,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Word16 tc_nchan_tc_new; Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; -#ifdef FIX_1330_JBM_MEMORY Word16 nchan_out_buff; -#else - Word16 nchan_out_buff, nchan_out_buff_old; -#endif nCPE_old = st_ivas->nCPE; move16(); @@ -78,9 +74,6 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; move16(); -#ifndef FIX_1330_JBM_MEMORY - nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); -#endif IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) ) { @@ -309,18 +302,6 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( return error; } -#ifndef FIX_1330_JBM_MEMORY - /*-----------------------------------------------------------------* - * output audio buffers - *-----------------------------------------------------------------*/ - - nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); - - IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ @@ -373,7 +354,6 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } -#ifdef FIX_1330_JBM_MEMORY /*-----------------------------------------------------------------* * output audio buffers @@ -384,7 +364,6 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { return error; } -#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 85d333c94..d8e5e069e 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -218,25 +218,11 @@ void ivas_ism_render_sf_fx( ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 ); } -#ifndef FIX_1330_JBM_MEMORY - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - FOR( i = 0; i < num_objects; i++ ) - { - p_tc_fx[i] = &st_ivas->hTcBuffer->tc_fx[i][tc_offset]; // Q11 - } - } - ELSE - { -#endif FOR( i = 0; i < num_objects; i++ ) { Copy32( &output_fx[i][tc_offset], tc_local_fx[i], n_samples_to_render ); p_tc_fx[i] = tc_local_fx[i]; } -#ifndef FIX_1330_JBM_MEMORY - } -#endif FOR( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { @@ -511,12 +497,7 @@ void ivas_omasa_separate_object_render_jbm_fx( const UWord16 nSamplesRendered, /* i : number of samples rendered */ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal Q11*/ Word32 *output_fx[], /* o : rendered time signal Q11*/ -#ifdef FIX_1330_JBM_MEMORY const Word16 subframes_rendered /* i : number of subframes rendered */ -#else - const Word16 subframes_rendered, /* i : number of subframes rendered */ - const Word16 slots_rendered /* i : number of CLDFB slots rendered */ -#endif ) { VBAP_HANDLE hVBAPdata; @@ -565,34 +546,16 @@ void ivas_omasa_separate_object_render_jbm_fx( move16(); } -#ifndef FIX_1330_JBM_MEMORY - offsetSamples = i_mult( slots_rendered, hSpatParamRendCom->slot_size ); -#endif FOR( j = 0; j < nchan_out_woLFE + num_lfe; j++ ) { output_fx_local[j] = output_fx[j]; } -#ifndef FIX_1330_JBM_MEMORY - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - FOR( obj = 0; obj < num_objects; obj++ ) - { - input_fx[obj] = &st_ivas->hTcBuffer->tc_fx[obj + 2][offsetSamples]; - move32(); - } - } - ELSE - { -#endif FOR( obj = 0; obj < num_objects; obj++ ) { input_fx[obj] = input_fx_in[obj]; move32(); } -#ifndef FIX_1330_JBM_MEMORY - } -#endif slots_to_render = idiv1616( nSamplesRendered, hSpatParamRendCom->slot_size ); first_sf = subframes_rendered; diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index a86e7cd1e..018bdeeec 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1523,11 +1523,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( Word32 tmp_buf_fx[MAX_JBM_L_FRAME48k]; Word32 *p_data_fx[FOA_CHANNELS + MAX_NUM_OBJECTS]; Word16 n, n_render_timeslots, n_ch_cldfb; -#ifdef FIX_1330_JBM_MEMORY Word16 ch, offset, len_offset; -#else - Word16 ch; -#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; @@ -1552,7 +1548,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); -#ifdef FIX_1330_JBM_MEMORY /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffers pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */ @@ -1571,7 +1566,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } } -#endif FOR( ch = 0; ch < n_ch_full_copy; ch++ ) { Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering ); @@ -2123,12 +2117,6 @@ ivas_error ivas_jbm_dec_render_fx( FOR( i = 0; i < nchan_in; i++ ) { scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor -#ifndef FIX_1330_JBM_MEMORY - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor - } -#endif } } ELSE @@ -2141,45 +2129,22 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { -#ifdef FIX_1330_JBM_MEMORY IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) -#else - IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) -#endif { return error; } } ELSE { -#ifdef FIX_1330_JBM_MEMORY IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), - IVAS_ERR_OK ) ) -#endif { return error; } // Todo main-pc update: This might be needed also in the split rendering path -#ifndef FIX_1330_JBM_MEMORY - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - IF( NE_16( exp, *st_ivas->hCrendWrapper->p_io_qfactor ) ) - { - FOR( i = 0; i < nchan_in; i++ ) - { - scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, exp ) ); - } - } - } -#endif ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); } @@ -2197,13 +2162,6 @@ ivas_error ivas_jbm_dec_render_fx( { scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11 } -#ifndef FIX_1330_JBM_MEMORY - IF( st_ivas->hDecoderConfig->Opt_tsm && crendInPlaceRotation ) - { - n = 0; - move16(); - } -#endif FOR( i = n; i < nchan_in; i++ ) { @@ -3399,9 +3357,7 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( IF( Opt_tsm ) { n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS ); -#ifdef FIX_1330_JBM_MEMORY n_samp_full = s_max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */ -#endif #ifdef FIX_2174_JBM_BASOP_ALIGNMENT n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 ); #else @@ -3475,10 +3431,8 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate_fx( } } -#ifdef FIX_1330_JBM_MEMORY hTcBuffer->tc_buffer2_fx = NULL; -#endif return IVAS_ERR_OK; } @@ -3516,14 +3470,12 @@ static void ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL; } } -#ifdef FIX_1330_JBM_MEMORY IF( hTcBuffer->tc_buffer2_fx != NULL ) { free( hTcBuffer->tc_buffer2_fx ); hTcBuffer->tc_buffer2_fx = NULL; } -#endif } return; @@ -3744,12 +3696,8 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( FOR( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { -#ifdef FIX_1330_JBM_MEMORY output_fx[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered; move32(); -#else - Copy32( st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output_fx[ch_idx], *nSamplesRendered ); -#endif } st_ivas->hTcBuffer->subframes_rendered = last_sf; diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 6f1385062..b41036a5d 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1689,11 +1689,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( Decoder_State **sts; UWord32 ivas_total_brate, last_ivas_total_brate; Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; -#ifdef FIX_1330_JBM_MEMORY Word16 nchan_out_buff; -#else - Word16 nchan_out_buff_old, nchan_out_buff; -#endif ivas_error error; Word32 ism_total_brate; Word16 pos_idx; @@ -1702,9 +1698,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( move32(); last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; move32(); -#ifndef FIX_1330_JBM_MEMORY - nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); -#endif test(); test(); @@ -2054,11 +2047,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) /* note: switching with OMASA is addressed in ivas_omasa_dec_config() */ { nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); -#ifdef FIX_1330_JBM_MEMORY IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) -#else - IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 86313996d..49b4edb18 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -902,19 +902,12 @@ static ivas_error ivas_mc_dec_reconfig_fx( Word16 tc_nchan_tc_new; Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; -#ifdef FIX_1330_JBM_MEMORY Word16 nchan_out_buff; -#else - Word16 nchan_out_buff_old, nchan_out_buff; -#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); nchan_transport_old = st_ivas->nchan_transport; move16(); -#ifndef FIX_1330_JBM_MEMORY - nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); -#endif last_mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ /* temporally set the current mc_mode back to the previous one to make sure the following call to @@ -1644,11 +1637,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); -#ifdef FIX_1330_JBM_MEMORY IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) -#else - IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index e74865e86..455f82c88 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -497,11 +497,7 @@ ivas_error ivas_omasa_dec_config_fx( Word32 brate_SCE, brate_CPE; ISM_MODE ism_mode_old; IVAS_FORMAT ivas_format_orig; -#ifdef FIX_1330_JBM_MEMORY Word16 nchan_out_buff; -#else - Word16 nchan_out_buff, nchan_out_buff_old; -#endif ivas_error error; RENDERER_TYPE old_renderer_type; @@ -522,10 +518,6 @@ ivas_error ivas_omasa_dec_config_fx( st_ivas->ivas_format = st_ivas->last_ivas_format; move16(); ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); -#ifndef FIX_1330_JBM_MEMORY - nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); - move16(); -#endif st_ivas->ivas_format = ivas_format_orig; move16(); @@ -832,11 +824,7 @@ ivas_error ivas_omasa_dec_config_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); -#ifdef FIX_1330_JBM_MEMORY IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) -#else - IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -1113,17 +1101,9 @@ void ivas_omasa_dirac_rend_jbm_fx( ) { Word16 subframes_rendered; -#ifndef FIX_1330_JBM_MEMORY - Word16 slots_rendered; -#endif Word16 n; Word32 data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; -#ifndef FIX_1330_JBM_MEMORY - test(); - IF( !st_ivas->hDecoderConfig->Opt_tsm ) - { -#endif *nSamplesRendered = s_min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); test(); @@ -1134,11 +1114,7 @@ void ivas_omasa_dirac_rend_jbm_fx( #ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #else -#ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) -#else - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) -#endif #endif { /* Gain separated object, if edited */ @@ -1163,11 +1139,7 @@ void ivas_omasa_dirac_rend_jbm_fx( #ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #else -#ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) -#else - IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) -#endif #endif { v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 @@ -1176,11 +1148,7 @@ void ivas_omasa_dirac_rend_jbm_fx( } /* Gain MASA part, if edited in G192. MASA gaining with VOIP is done in ivas_dec_prepare_renderer() */ -#ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->masa_gain_is_edited ) -#else - IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) -#endif { FOR( n = 0; n < CPE_CHANNELS; n++ ) { @@ -1189,16 +1157,9 @@ void ivas_omasa_dirac_rend_jbm_fx( } } } -#ifndef FIX_1330_JBM_MEMORY - } -#endif subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; move16(); -#ifndef FIX_1330_JBM_MEMORY - slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; - move16(); -#endif ivas_dirac_dec_render_fx( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_fx ); @@ -1207,11 +1168,7 @@ void ivas_omasa_dirac_rend_jbm_fx( scale_sig32( st_ivas->hIsmRendererData->prev_gains_fx[ind1], MAX_OUTPUT_CHANNELS, -1 ); // Q30 -> Q29 } -#ifdef FIX_1330_JBM_MEMORY ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered ); -#else - ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered, slots_rendered ); -#endif FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) { diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index f81a8e8a2..20cd3d414 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -296,69 +296,35 @@ ivas_error ivas_osba_render_sf_fx( ) { Word16 n; -#ifdef FIX_1330_JBM_MEMORY Word32 output_sba[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word32 *p_output_sba[MAX_OUTPUT_CHANNELS]; -#else - Word32 output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - Word32 *p_output_ism[MAX_OUTPUT_CHANNELS]; -#endif ivas_error error; FOR( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { -#ifdef FIX_1330_JBM_MEMORY p_output_sba[n] = output_sba[n]; -#else - p_output_ism[n] = &output_ism[n][0]; -#endif } -#ifndef FIX_1330_JBM_MEMORY - if ( !st_ivas->hDecoderConfig->Opt_tsm ) - { - Word16 tc_offset; - tc_offset = st_ivas->hTcBuffer->n_samples_rendered; - for ( n = 0; n < st_ivas->nchan_ism; n++ ) - { - v_shr( &p_output[n][tc_offset], Q11 - Q11, &output_ism[n][tc_offset], nSamplesAsked ); // Q11 - } - } -#endif -#ifdef FIX_1330_JBM_MEMORY IF( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output_sba ) ) != IVAS_ERR_OK ) -#else - IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ), IVAS_ERR_OK ) ) -#endif { return error; } IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { -#ifdef FIX_1330_JBM_MEMORY ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered ); -#else - ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered ); -#endif } FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) { IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { -#ifdef FIX_1330_JBM_MEMORY v_add_fx_no_hdrm( p_output[n], p_output_sba[n], p_output[n], *nSamplesRendered ); -#else - v_add_fx_no_hdrm( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered ); -#endif } -#ifdef FIX_1330_JBM_MEMORY ELSE { Copy32( p_output_sba[n], p_output[n], *nSamplesRendered ); } -#endif } return IVAS_ERR_OK; diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index e8dab7dc4..a7f2931b2 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -118,12 +118,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( Word32 ivas_total_brate; Word32 last_ivas_total_brate; Word16 num_channels, num_md_sub_frames; -#ifdef FIX_1330_JBM_MEMORY Word16 nchan_out_buff; -#else - Word16 nchan_out_buff, nchan_out_buff_old; - Word16 sba_analysis_order_old_flush; -#endif DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; ISM_MODE ism_mode_old; @@ -136,19 +131,12 @@ ivas_error ivas_sba_dec_reconfigure_fx( move32(); last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; move32(); -#ifndef FIX_1330_JBM_MEMORY - sba_analysis_order_old_flush = st_ivas->sba_analysis_order; - move16(); -#endif /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ -#ifndef FIX_1330_JBM_MEMORY - nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate ); -#endif ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -707,11 +695,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ -#ifdef FIX_1330_JBM_MEMORY IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) -#else - IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3849c8ed4..46c0d760a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1038,10 +1038,8 @@ typedef struct decoder_tc_buffer_structure Word16 num_slots; Word16 n_samples_discard; /* number of samples to discard from the beginning of the output */ -#ifdef FIX_1330_JBM_MEMORY Word32 *tc_buffer2_fx; /* non-scaled buffer of output audio - needed only when '*tc_buffer* is not long enough */ -#endif } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; typedef struct jbm_metadata_structure diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index e3cdefad5..7c5b53b29 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -423,17 +423,11 @@ Word16 ivas_get_nchan_buffers_dec_fx( ivas_error ivas_output_buff_dec_fx( Word32 *p_output_fx[], /* i/o: output audio buffers */ -#ifdef FIX_1330_JBM_MEMORY const Word16 nchan_out_buff, /* i : number of output channels */ const Word16 Opt_tsm, /* i : TSM option flag */ DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ -#else - const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */ - const Word16 nchan_out_buff /* i : number of output channels */ -#endif ) { -#ifdef FIX_1330_JBM_MEMORY Word16 ch, nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset; FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) @@ -495,35 +489,6 @@ ivas_error ivas_output_buff_dec_fx( offset = add( offset, n_samp_full ); } } -#else - Word16 ch; - - IF( GT_16( nchan_out_buff, nchan_out_buff_old ) ) - { - FOR( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) - { -#ifdef DEBUGGING - if ( p_output_fx[ch] != NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Memory for floating-point output audio buffer is already allocated!\n" ) ); - } -#endif - /* note: these are intra-frame heap memories */ - IF( ( p_output_fx[ch] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output audio buffer!\n" ) ); - } - } - } - ELSE - { - FOR( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) - { - free( p_output_fx[ch] ); - p_output_fx[ch] = NULL; - } - } -#endif return IVAS_ERR_OK; } -- GitLab From 1b990784754ff6a7b9353b576a160cae3cd363a6 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:49 +0100 Subject: [PATCH 333/351] [cleanup] accept FIX_1370_EXTERNAL_ORIENTATION_CHECK --- lib_com/ivas_error.h | 4 ---- lib_com/options.h | 1 - lib_util/rotation_file_reader.c | 2 -- 3 files changed, 7 deletions(-) diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 64209e04e..563fdeb36 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -128,9 +128,7 @@ typedef enum IVAS_ERR_BITSTREAM_READER_INVALID_FORMAT, IVAS_ERR_NO_FILE_OPEN, IVAS_ERR_SAMPLING_RATE_UNKNOWN, -#ifdef FIX_1370_EXTERNAL_ORIENTATION_CHECK IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT, -#endif /*----------------------------------------* * renderer (lib_rend only) * @@ -278,10 +276,8 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Invalid input format"; case IVAS_ERR_INVALID_INDEX: return "Invalid index"; -#ifdef FIX_1370_EXTERNAL_ORIENTATION_CHECK case IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT: return "Euler angles were detected in the input but only Quaternions are supported"; -#endif default: break; } diff --git a/lib_com/options.h b/lib_com/options.h index 2d3d51d4b..6689dc9a6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,7 +128,6 @@ #define FIX_1384_MSAN_stereo_tcx_core_enc /* VA: issue 1384: fix use-of-uninitialized value in stereo_tcx_core_enc() */ #define FIX_1384_MSAN_ivas_spar_dec_open /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ -#define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ #define FIX_1383_HEAD_TRACK_SANITIZER /* Nok: issue 1383: Fix head tracking struc values reading in renderer */ #define FIX_1330_JBM_MEMORY_FIX /* VA: basop issue: 2179 fix non-BE difference in FIX_1330_JBM_MEMORY */ diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 9746c69ac..4385a9f83 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -197,14 +197,12 @@ ivas_error ExternalOrientationFileReading( } ( externalOrientationReader->frameCounter )++; -#ifdef FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Only Quaternion orientations are supported, raise an error if Euler angles are detected in the input */ if ( w == -3.0f ) { return IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT; } -#endif pQuaternion->w_fx = float_to_fix( w, Q29 ); pQuaternion->x_fx = float_to_fix( x, Q29 ); -- GitLab From 496b858f460f1bc7838e35f1f86baecb66f71efa Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:50:59 +0100 Subject: [PATCH 334/351] [cleanup] accept FIX_1372_OSBA_OBJECT_EDITING --- lib_com/options.h | 1 - lib_dec/ivas_sba_dec_fx.c | 2 -- lib_dec/ivas_spar_decoder_fx.c | 6 ------ 3 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6689dc9a6..d9e1af7cf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,7 +145,6 @@ #define TMP_FIX_OMASA_SR_BE // temporary fix to keep OMASA split-rendering BE #define NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES // Nokia: Fix 1399_1400 issue in float, this is essential for the BASOP porting #define OBJ_EDIT_BASOP -#define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ #define FIX_2193_ISM_GAINS_WITH_OE /* FhG: fix issue 2193: use edited angles in ISM gain calculation */ #define FIX_2192_OBJ_EDITING_EXT_METADATA /* Eri: Add support for extended metadata in object editing */ diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index a7f2931b2..c4a1b0de1 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -841,13 +841,11 @@ ivas_error ivas_sba_dec_render_fx( { nchan_out = s_max( nchan_internal, sub( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ) ); } -#ifdef FIX_1372_OSBA_OBJECT_EDITING ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { nchan_out = BINAURAL_CHANNELS; move16(); } -#endif } nchan_out = s_min( nchan_out, ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index af0f9d149..864d05438 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -1735,13 +1735,7 @@ void ivas_spar_dec_upmixer_sf_fx( p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[( i + nchan_ism )] + prod; /*Q11*/ } -#ifdef FIX_1372_OSBA_OBJECT_EDITING IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) -#else - test(); - test(); - IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) -#endif { FOR( i = 0; i < nchan_ism; i++ ) { -- GitLab From b2851e3cee96da79bf7b2000a6261bb8d59980a3 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:51:05 +0100 Subject: [PATCH 335/351] [cleanup] accept NONBE_FIX_1376_MDCT_CONCEALMENT --- lib_com/options.h | 1 - lib_dec/ivas_mdct_core_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d9e1af7cf..e0b4f431b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,7 +115,6 @@ #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_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328 */ -#define NONBE_FIX_1376_MDCT_CONCEALMENT /* FhG: fix concealment artifact in MDCT Stereo with DTX, in case transition frame gets lost */ #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ #define FIX_1377_HANDLE_ERROR_CODE /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */ #define FIX_1053_REVERB_RECONFIGURATION diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 0b3f4651f..b2af4c96b 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1678,7 +1678,6 @@ void ivas_mdct_core_tns_ns_fx( q_x = add( q_x, 1 ); } -#ifdef NONBE_FIX_1376_MDCT_CONCEALMENT /* 2025-09-07, mul: in case of PLC, applying SNS up to L_spec might not be enough: In case the transition frame from DTX after an inactive period is lost, L_spec is assumed to represent a regular TCX frame, @@ -1686,9 +1685,6 @@ void ivas_mdct_core_tns_ns_fx( in case this is not necessary, x[] is filled with zeros, and the multiplication is not causing any additional harm */ v_multc_fx( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( s_max( L_spec[ch], L_frameTCX[ch] ), st->hTcxCfg->psychParamsCurrent->nBins ) ); -#else - v_multc_fx( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( L_spec[ch], st->hTcxCfg->psychParamsCurrent->nBins ) ); -#endif q_2 = sub( add( q_x, q_sns_int_scf ), 31 ); Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, sub( q_2, q_x ) ); -- GitLab From 593b17fb21909814a02948045f777bbcae72a626 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:51:08 +0100 Subject: [PATCH 336/351] [cleanup] accept NONBE_1377_REND_DIRATT_CONF --- apps/renderer.c | 2 -- lib_com/options.h | 1 - lib_rend/ivas_objectRenderer_fx.c | 18 ------------------ lib_rend/ivas_prot_rend_fx.h | 2 -- lib_rend/lib_rend.h | 2 -- lib_rend/lib_rend_fx.c | 24 ------------------------ 6 files changed, 49 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 264cc07b1..8256f1e46 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1354,7 +1354,6 @@ int main( { masaIds[i] = 0u; } -#ifdef NONBE_1377_REND_DIRATT_CONF #ifdef FIX_1377_HANDLE_ERROR_CODE if ( ( error = IVAS_REND_SetObjectIDs( hIvasRend ) ) != IVAS_ERR_OK ) { @@ -1363,7 +1362,6 @@ int main( } #else IVAS_REND_SetObjectIDs( hIvasRend ); -#endif #endif for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i ) diff --git a/lib_com/options.h b/lib_com/options.h index e0b4f431b..34abbfeeb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,7 +115,6 @@ #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_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328 */ -#define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ #define FIX_1377_HANDLE_ERROR_CODE /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */ #define FIX_1053_REVERB_RECONFIGURATION #define FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add split rendering support to decoder in VoIP mode */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index c2e6b73fc..dd99c0070 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -631,16 +631,10 @@ ivas_error TDREND_Update_object_positions_fx( const ISM_METADATA_HANDLE *hIsmMetaData /* i : Input metadata for ISM objects */ ) { -#ifndef NONBE_1377_REND_DIRATT_CONF - TDREND_DirAtten_t *DirAtten_p; -#endif Word16 nS; Word32 Pos_fx[3]; // Q25 Word32 Dir_fx[3]; // Q30 ivas_error error; -#ifndef NONBE_1377_REND_DIRATT_CONF - DirAtten_p = hBinRendererTd->DirAtten_p; -#endif /* For each source, write the frame data to the source object*/ FOR( nS = 0; nS < num_src; nS++ ) @@ -665,12 +659,6 @@ ivas_error TDREND_Update_object_positions_fx( { return error; } -#ifndef NONBE_1377_REND_DIRATT_CONF - IF( NE_32( ( error = TDREND_MIX_SRC_SetDirAtten_fx( hBinRendererTd, nS, DirAtten_p ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain_fx ) ) != IVAS_ERR_OK ) // TODO: Check Gain has correct Q-value { return error; @@ -825,9 +813,7 @@ ivas_error ivas_td_binaural_open_ext_fx( RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ LSSETUP_CUSTOM_STRUCT *customLsInput, const Word32 outFs, -#ifdef NONBE_1377_REND_DIRATT_CONF const Word16 object_id, /* i: Object ID */ -#endif Word16 *SrcInd, Word16 *num_src ) { @@ -877,11 +863,7 @@ ivas_error ivas_td_binaural_open_ext_fx( if ( NULL != hRendCfg ) { -#ifdef NONBE_1377_REND_DIRATT_CONF directivity_fx = hRendCfg->directivity_fx + 3 * object_id; /* Address calculation -- no BASOPs */ -#else - directivity_fx = hRendCfg->directivity_fx; -#endif distAtt_fx = hRendCfg->distAtt_fx; } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index e257ccd12..a1e6f5167 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -683,9 +683,7 @@ ivas_error ivas_td_binaural_open_ext_fx( RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ LSSETUP_CUSTOM_STRUCT *customLsInput, const Word32 output_Fs, -#ifdef NONBE_1377_REND_DIRATT_CONF const Word16 object_id, /* i : Object ID */ -#endif Word16 *SrcInd, Word16 *num_src ); diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 4959a3a3c..1dd238afd 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -152,11 +152,9 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( const IVAS_CUSTOM_LS_DATA layout /* i : custom loudspeaker layout for input */ ); -#ifdef NONBE_1377_REND_DIRATT_CONF ivas_error IVAS_REND_SetObjectIDs( IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ); -#endif ivas_error IVAS_REND_SetInputGain_fx( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 07abd25f5..76045fab5 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -138,9 +138,7 @@ typedef struct Word32 nonDiegeticPanGain_fx; /* Q31 */ OMASA_ANA_HANDLE hOMasa; UWord16 total_num_objects; -#ifdef NONBE_1377_REND_DIRATT_CONF Word16 object_id; -#endif Word16 ism_metadata_delay_ms_fx; /* Q0 */ } input_ism; @@ -1854,11 +1852,7 @@ static ivas_error setRendInputActiveIsm( test(); IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { -#ifdef NONBE_1377_REND_DIRATT_CONF IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, inputIsm->object_id, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -1891,11 +1885,7 @@ static ivas_error setRendInputActiveIsm( /* Open TD renderer wrappers */ FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { -#ifdef NONBE_1377_REND_DIRATT_CONF IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->splitTdRendWrappers[i], inConfig, hRendCfg, NULL, *inputIsm->base.ctx.pOutSampleRate, inputIsm->object_id, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->splitTdRendWrappers[i], inConfig, hRendCfg, NULL, *inputIsm->base.ctx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -1929,11 +1919,7 @@ static ivas_error setRendInputActiveIsm( } ELSE { -#ifdef NONBE_1377_REND_DIRATT_CONF IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, inputIsm->object_id, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -2871,11 +2857,7 @@ static ivas_error initMcBinauralRendering( { Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src; -#ifdef NONBE_1377_REND_DIRATT_CONF IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputMc->tdRendWrapper, inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate, 0, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputMc->tdRendWrapper, inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -2911,11 +2893,7 @@ static ivas_error initMcBinauralRendering( /* Open TD renderer wrappers */ FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { -#ifdef NONBE_1377_REND_DIRATT_CONF IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputMc->splitTdRendWrappers[i], inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate, 0, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputMc->splitTdRendWrappers[i], inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -4695,7 +4673,6 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( return IVAS_ERR_OK; } -#ifdef NONBE_1377_REND_DIRATT_CONF /*-------------------------------------------------------------------* * IVAS_REND_SetObjectIDs() @@ -4723,7 +4700,6 @@ ivas_error IVAS_REND_SetObjectIDs( return IVAS_ERR_OK; } -#endif /*-------------------------------------------------------------------* * IVAS_REND_SetInputGain() -- GitLab From a9f1139a626adabc51cab67f7c0bd1d487629abc Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 10:53:57 +0100 Subject: [PATCH 337/351] clang-format --- lib_dec/ivas_core_dec_fx.c | 4 +-- lib_dec/ivas_cpe_dec_fx.c | 6 ++-- lib_dec/ivas_dirac_dec_fx.c | 3 +- lib_dec/ivas_ism_renderer_fx.c | 22 ++++++------ lib_dec/ivas_mdct_core_dec_fx.c | 8 ++--- lib_dec/ivas_omasa_dec_fx.c | 62 ++++++++++++++++----------------- lib_dec/ivas_stat_dec.h | 6 ++-- lib_dec/jbm_pcmdsp_apa.h | 2 +- lib_dec/jbm_pcmdsp_apa_fx.c | 2 +- lib_rend/ivas_output_init_fx.c | 2 +- lib_rend/lib_rend_fx.c | 2 +- 11 files changed, 59 insertions(+), 60 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 84f6391ac..23f75172a 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1230,8 +1230,8 @@ ivas_error ivas_core_dec_fx( } ELSE { - /* TBE on top of ACELP@16kHz */ - tmps = NS2SA_FX2( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); + /* TBE on top of ACELP@16kHz */ + tmps = NS2SA_FX2( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); } /* Smooth transitions when switching between different technologies */ diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index e5b8837f0..7a134d59b 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -73,7 +73,7 @@ ivas_error ivas_cpe_dec_fx( Word16 last_bwidth; Word16 tdm_ratio_idx; Word32 outputHB_fx[CPE_CHANNELS][L_FRAME48k]; /* buffer for output HB synthesis, both channels */ /* Q11 */ - Word32 *res_buf_fx = NULL; /* Q8 */ + Word32 *res_buf_fx = NULL; /* Q8 */ CPE_DEC_HANDLE hCPE; STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft; Decoder_State **sts; @@ -887,7 +887,7 @@ static ivas_error stereo_dft_dec_main( FOR( n = 0; n < hCPE->nchan_out; n++ ) { - Scale_sig32( output[n], output_frame, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + Scale_sig32( output[n], output_frame, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[n] = hCPE->hStereoDft->q_dft; move16(); @@ -901,7 +901,7 @@ static ivas_error stereo_dft_dec_main( FOR( n = 0; n < hCPE->nchan_out; n++ ) { - Scale_sig32( output[n], output_frame, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + Scale_sig32( output[n], output_frame, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 scale_sig32( hCPE->output_mem_fx[n], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[n] = Q11; move16(); diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index ff8565917..11d80c14f 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2255,8 +2255,7 @@ void ivas_dirac_dec_render_sf_fx( Word32 *output_buf_fx[], /* i/o: synthesized core-coder transport channels/DirAC output Q(6-1)*/ const Word16 nchan_transport, /* i : number of transport channels */ Word32 *pppQMfFrame_ts_re_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX], - Word32 *pppQMfFrame_ts_im_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX] -) + Word32 *pppQMfFrame_ts_im_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX] ) { Word16 i, ch, idx_in, idx_lfe; DIRAC_DEC_HANDLE hDirAC; diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index d8e5e069e..2e2a257a1 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -218,11 +218,11 @@ void ivas_ism_render_sf_fx( ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 ); } - FOR( i = 0; i < num_objects; i++ ) - { - Copy32( &output_fx[i][tc_offset], tc_local_fx[i], n_samples_to_render ); - p_tc_fx[i] = tc_local_fx[i]; - } + FOR( i = 0; i < num_objects; i++ ) + { + Copy32( &output_fx[i][tc_offset], tc_local_fx[i], n_samples_to_render ); + p_tc_fx[i] = tc_local_fx[i]; + } FOR( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { @@ -497,7 +497,7 @@ void ivas_omasa_separate_object_render_jbm_fx( const UWord16 nSamplesRendered, /* i : number of samples rendered */ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal Q11*/ Word32 *output_fx[], /* o : rendered time signal Q11*/ - const Word16 subframes_rendered /* i : number of subframes rendered */ + const Word16 subframes_rendered /* i : number of subframes rendered */ ) { VBAP_HANDLE hVBAPdata; @@ -551,11 +551,11 @@ void ivas_omasa_separate_object_render_jbm_fx( output_fx_local[j] = output_fx[j]; } - FOR( obj = 0; obj < num_objects; obj++ ) - { - input_fx[obj] = input_fx_in[obj]; - move32(); - } + FOR( obj = 0; obj < num_objects; obj++ ) + { + input_fx[obj] = input_fx_in[obj]; + move32(); + } slots_to_render = idiv1616( nSamplesRendered, hSpatParamRendCom->slot_size ); first_sf = subframes_rendered; diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index b2af4c96b..e7507607f 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1276,7 +1276,7 @@ void ivas_mdct_core_reconstruct_fx( st->Q_syn = add( sf, s_min( q_win, q_winFB ) ); Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS_INTERNAL ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn // Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->syn, M + 1, sub( st->Q_syn, q_win ) ); @@ -1406,9 +1406,9 @@ void ivas_mdct_core_reconstruct_fx( Copy_Scale_sig_16_32_no_sat( st->p_bpf_noise_buf, st->p_bpf_noise_buf_32, st->L_frame, Q11 ); // Q0 -> Q11 } - Copy( synthFB_fx, signal_outFB_fx[ch], st->hTcxDec->L_frameTCX ); - e_sig[ch] = sub( 15, q_syn + st->Q_syn_factor ); - move16(); + Copy( synthFB_fx, signal_outFB_fx[ch], st->hTcxDec->L_frameTCX ); + e_sig[ch] = sub( 15, q_syn + st->Q_syn_factor ); + move16(); /* updates */ st->last_voice_factor_fx = 0; diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 455f82c88..0c6c13d19 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1104,59 +1104,59 @@ void ivas_omasa_dirac_rend_jbm_fx( Word16 n; Word32 data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; - *nSamplesRendered = s_min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); + *nSamplesRendered = s_min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); - test(); - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - Copy32( &output_fx[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); + test(); + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + Copy32( &output_fx[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); #ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #else IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #endif + { + /* Gain separated object, if edited */ + FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { - /* Gain separated object, if edited */ - FOR( n = 0; n < st_ivas->nchan_ism; n++ ) + test(); + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) { - test(); - IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] && EQ_16( st_ivas->hMasaIsmData->idx_separated_ism, n ) ) - { - v_multc_fx_16( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[0], *nSamplesRendered ); // Q = 8 - Scale_sig32( data_separated_objects[0], *nSamplesRendered, Q3 ); // Q = 11 - } + v_multc_fx_16( data_separated_objects[0], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[0], *nSamplesRendered ); // Q = 8 + Scale_sig32( data_separated_objects[0], *nSamplesRendered, Q3 ); // Q = 11 } } } - ELSE + } + ELSE + { + FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { - FOR( n = 0; n < st_ivas->nchan_ism; n++ ) - { - Copy32( &output_fx[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); + Copy32( &output_fx[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); - /* Gain discrete objects, if edited */ + /* Gain discrete objects, if edited */ #ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES - IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #else IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #endif - { - v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 - Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 - } + { + v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 + Scale_sig32( data_separated_objects[n], *nSamplesRendered, Q3 ); // Q = 11 } + } - /* Gain MASA part, if edited in G192. MASA gaining with VOIP is done in ivas_dec_prepare_renderer() */ - IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->masa_gain_is_edited ) + /* Gain MASA part, if edited in G192. MASA gaining with VOIP is done in ivas_dec_prepare_renderer() */ + IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->masa_gain_is_edited ) + { + FOR( n = 0; n < CPE_CHANNELS; n++ ) { - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - v_multc_fx_16( output_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_fx[n], *nSamplesRendered ); // Q = 8 - Scale_sig32( output_fx[n], *nSamplesRendered, Q3 ); // Q = 11 - } + v_multc_fx_16( output_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_fx[n], *nSamplesRendered ); // Q = 8 + Scale_sig32( output_fx[n], *nSamplesRendered, Q3 ); // Q = 11 } } + } subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; move16(); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 46c0d760a..b2e5ecc9b 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1018,9 +1018,9 @@ typedef struct ivas_masa_ism_data_structure typedef struct decoder_tc_buffer_structure { Word32 *tc_buffer_old_fx[MAX_INTERN_CHANNELS]; /* TC audio samples not rendered in the previous frame */ - Word32 *tc_buffer_fx; /* the buffer itself */ - Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ - Word16 no_channels; /*Stores no of channels in tc_fx with values*/ + Word32 *tc_buffer_fx; /* the buffer itself */ + Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ + Word16 no_channels; /*Stores no of channels in tc_fx with values*/ Word16 q_tc_fx; TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ Word16 nchan_transport_jbm; /* number of TCs after TC decoding */ diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index af937febb..2c3bc84c8 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -52,7 +52,7 @@ /* size of IO buffers (a_in[], a_out[]) for apa_exec() */ #define APA_BUF_PER_CHANNEL ( IVAS_MAX_FRAME_SIZE * 2 ) /* == twice the max. frame length */ #define APA_MAX_NUM_CHANNELS ( 12 ) /* == MAX_TRANSPORT_CHANNELS */ -#define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS ) +#define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS ) /* min/max sampling rate [Hz] */ #define APA_MIN_RATE 1000 diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index c5919ffe9..14cf7dff3 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -130,7 +130,7 @@ struct apa_state_t #ifdef FIX_2173_UBSAN_IN_JBM_PCMDSP_APA Word16 last_pitch; /* last pitch/sync position */ #else - UWord16 last_pitch; /* last pitch/sync position */ + UWord16 last_pitch; /* last pitch/sync position */ #endif UWord16 bad_frame_count; /* # frames before quality threshold is lowered */ UWord16 good_frame_count; /* # scaled frames */ diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 7c5b53b29..053cb43c1 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -422,7 +422,7 @@ Word16 ivas_get_nchan_buffers_dec_fx( *-------------------------------------------------------------------*/ ivas_error ivas_output_buff_dec_fx( - Word32 *p_output_fx[], /* i/o: output audio buffers */ + Word32 *p_output_fx[], /* i/o: output audio buffers */ const Word16 nchan_out_buff, /* i : number of output channels */ const Word16 Opt_tsm, /* i : TSM option flag */ DECODER_TC_BUFFER_HANDLE hTcBuffer /* i : TSM buffer handle */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 76045fab5..b70cdcadb 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4574,7 +4574,7 @@ ivas_error IVAS_REND_AddInput_fx( return IVAS_ERR_INVALID_INPUT_FORMAT; } - /* Find first free input in array corresponding to input type */ + /* Find first free input in array corresponding to input type */ IF( NE_32( ( error = findFreeInputSlot_fx( inputsArray, inputType, maxNumInputsOfType, &inputIndex ) ), IVAS_ERR_OK ) ) { return error; -- GitLab From 3a3c2c9945c7ef8c32a5db3e9e0326f057c19f91 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 12 Nov 2025 16:19:39 +0100 Subject: [PATCH 338/351] add missing switch define for BE_FIX_1391_COVERAGE_SPAR_DYN__CHANNEL to options.h --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index 67f7d8cc9..6bb833e26 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,6 +154,7 @@ #define NONBE_1412_AVOID_ROUNDING_AZ_ELEV /* FhG: Avoid rounding when passing azimuth and elevation to efap_determine_gains() */ #define FIX_1318_ROOM_SIZE_CMD_LINE /* Philips/Nokia/FhG: Default room sizes support */ #define NONBE_FIX_1442_MASA_EXT_REND_ORIENT_IDX /* Nokia: Fix issue 1442 of wrong index to combinedOrientationData */ +#define BE_FIX_1391_COVERAGE_SPAR_DYN__CHANNEL /* Dolby: Fix coverage of SBA SPAR Dynamic active W not getting hit by the tests */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) -- GitLab From 8658c4279c6da2c3fba3558731689c7921d73274 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 12 Nov 2025 22:49:26 +0100 Subject: [PATCH 339/351] add missing code under #ifndef TMP_FIX_OMASA_SR_BE ... #endif and disable TMP_FIX_OMASA_SR_BE --- lib_com/options.h | 2 +- lib_dec/ivas_jbm_dec_fx.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6a092898a..d9c957143 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,7 +141,7 @@ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) -#define TMP_FIX_OMASA_SR_BE // temporary fix to keep OMASA split-rendering BE +/*#define TMP_FIX_OMASA_SR_BE*/ // temporary fix to keep OMASA split-rendering BE - mul, 20251112: disabled, since this causes diffs to ivas-codec/main #define NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES // Nokia: Fix 1399_1400 issue in float, this is essential for the BASOP porting #define OBJ_EDIT_BASOP #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 018bdeeec..f8664b60b 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4383,8 +4383,14 @@ void ivas_dec_prepare_renderer_fx( Scale_sig32( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 } } - delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); - // TODO: check if tis is a bug in main already +#ifndef TMP_FIX_OMASA_SR_BE + test(); + IF( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#endif + { + delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); + // TODO: check if tis is a bug in main already + } } test(); -- GitLab From f212fb4eee4a7ebbac6f28eed0beb4f2cb40038a Mon Sep 17 00:00:00 2001 From: Ripinder Singh Date: Thu, 13 Nov 2025 09:59:14 +1100 Subject: [PATCH 340/351] Fix split rendering configuration on decoder restart * Port of fix from float MR2391 for BASOP * Reorganize the decoderVoip preprocessor as it leads to too many copies otherwise Signed-off-by: Ripinder Singh --- apps/decoder.c | 69 ++++++++++++++++++++++++++++++++++------------- lib_com/options.h | 1 + 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 7b02e26b4..4fb8053df 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -178,19 +178,27 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +static ivas_error decodeVoIP( + DecArguments arg, + BS_READER_HANDLE hBsReader, + IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, + RotFileReader *headRotReader, + RotFileReader *externalOrientationFileReader, + RotFileReader *refRotReader, + Vector3PairFileReader *referenceVectorReader, + ObjectEditFileReader *objectEditFileReader, #ifdef FIX_1119_SPLIT_RENDERING_VOIP -#ifdef DECODER_FORMAT_SWITCHING -static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); -#else -static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, #endif -#else -#ifdef DDECODER_FORMAT_SWITCHING -static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); -#else -static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#ifdef FIX_SPLIT_RENDERING_ON_DECODER_RESTART + IVAS_RENDER_CONFIG_DATA *renderConfig, #endif +#ifdef DECODER_FORMAT_SWITCHING + IVAS_DEC_HANDLE *phIvasDec, +#else + IVAS_DEC_HANDLE hIvasDec, #endif + int16_t *pcmBuf ); static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader ); @@ -232,6 +240,9 @@ int main( IVAS_ROOM_ACOUSTICS_CONFIG_DATA **pAE = NULL; uint32_t aeCount = 0; #endif +#ifdef FIX_SPLIT_RENDERING_ON_DECODER_RESTART + IVAS_RENDER_CONFIG_DATA renderConfig = { 0 }; +#endif #ifdef WMOPS reset_wmops(); reset_mem( USE_BYTES ); @@ -530,7 +541,9 @@ int main( if ( arg.renderConfigEnabled ) { +#ifndef FIX_SPLIT_RENDERING_ON_DECODER_RESTART IVAS_RENDER_CONFIG_DATA renderConfig; +#endif /* sanity check */ if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && @@ -730,19 +743,19 @@ int main( if ( arg.voipMode ) { + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, #ifdef FIX_1119_SPLIT_RENDERING_VOIP -#ifdef DECODER_FORMAT_SWITCHING - error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &hIvasDec, pcmBuf ); -#else - error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf ); + &splitRendBits, #endif -#else -#ifdef DDECODER_FORMAT_SWITCHING - error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &hIvasDec, pcmBuf ); -#else - error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hIvasDec, pcmBuf ); +#ifdef FIX_SPLIT_RENDERING_ON_DECODER_RESTART + &renderConfig, #endif +#ifdef DECODER_FORMAT_SWITCHING + &hIvasDec, +#else + hIvasDec, #endif + pcmBuf ); } else { @@ -3008,6 +3021,9 @@ static ivas_error decodeVoIP( #ifdef FIX_1119_SPLIT_RENDERING_VOIP ISAR_SPLIT_REND_BITS_DATA *splitRendBits, #endif +#ifdef FIX_SPLIT_RENDERING_ON_DECODER_RESTART + IVAS_RENDER_CONFIG_DATA *renderConfig, +#endif #ifdef DECODER_FORMAT_SWITCHING IVAS_DEC_HANDLE *phIvasDec, #else @@ -3249,8 +3265,12 @@ static ivas_error decodeVoIP( &hIvasDec, newCodecInPacket, &arg, +#ifdef FIX_SPLIT_RENDERING_ON_DECODER_RESTART + renderConfig, +#else NULL, /* ToDo : Provide rendererConfig */ - NULL /* ToDo : Provide LS Custom Data */ +#endif + NULL /* ToDo : Provide LS Custom Data */ ); if ( error != IVAS_ERR_OK ) { @@ -4374,6 +4394,7 @@ ivas_error restartDecoder( goto cleanup; } +#ifndef FIX_SPLIT_RENDERING_ON_DECODER_RESTART if ( arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) @@ -4390,6 +4411,7 @@ ivas_error restartDecoder( arg->enableHeadRotation = true; } +#endif if ( arg->voipMode ) { @@ -4406,6 +4428,15 @@ ivas_error restartDecoder( goto cleanup; } +#ifdef FIX_SPLIT_RENDERING_ON_DECODER_RESTART + /* ISAR frame size is set from command line, not renderer config file. + * This will be ignored if output format is not split rendering. */ + if ( renderConfig != NULL ) + { + renderConfig->split_rend_config.isar_frame_size_ms = (int16_t) arg->renderFramesize /* given in number of 5ms subframes */ * 5; + } +#endif + if ( arg->renderConfigEnabled && renderConfig != NULL ) { if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, *renderConfig ) ) != IVAS_ERR_OK ) diff --git a/lib_com/options.h b/lib_com/options.h index 6a092898a..b4a928e23 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -157,6 +157,7 @@ #define REVERSE_ISM_PI_DATA /* Add reading and packing/unpacking of reverse ISM PI data */ #define PI_LATENCY /* Support for PI latency */ #define DECODER_FORMAT_SWITCHING /* Re-initialize the decoder when the format/subformat of the incoming stream is changed */ +#define FIX_SPLIT_RENDERING_ON_DECODER_RESTART /* Re-configure split rendering on decoder restart */ /* #################### End BASOP porting switches ############################ */ -- GitLab From 8b535ee6c5949a9f9f89dec3f39f528599877ae2 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 09:19:43 +0200 Subject: [PATCH 341/351] Remove extra operation to numpidata --- lib_dec/lib_dec_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f584f1c59..398bb1069 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -7134,7 +7134,6 @@ ivas_error IVAS_DEC_FeedPiDataToDecoder( { UWord32 piDataType = piData->data.noPiData.piDataType; move32(); - numPiData = UL_subNsD( numPiData, 1 ); /* Subtraction of WHILE variable */ SWITCH( piDataType ) { -- GitLab From 297028fc8274f22c19a68d5ffd90479432e7e06f Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 13 Nov 2025 08:52:59 +0100 Subject: [PATCH 342/351] Fix crashes from issue #2232. Look at CLDFB states additionally to the input for dynamic scale. Similar to MR !2555 , issues #2217 and #2219 --- lib_com/options.h | 2 ++ lib_isar/isar_splitRendererPost.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 6a092898a..61127a55d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,6 +109,8 @@ #define NONBE_FIX_2206_SATURATE_ALTERNATIVE #define FIX_2226_ISAR_PRE_CRASH_CLDFB_NO_CHANNELS /* Dolby: Fix crash of ISAR pre-renderer due to an attempt of re-scaling uninitialized values in the CLDFB filter bank */ +#define NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES /* FhG: Adjust scaleFactor according to st->cldfbSyn->cldfb_state_fx too to avoid overflow in cldfbSynthesis_ivas_fx() */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 1d734bed0..0bfd5fc25 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1819,6 +1819,9 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); +#ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES + scaleFactor = s_min( scaleFactor, getScaleFactor32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length ) ); +#endif } scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) -- GitLab From b6521f05a79bc1a4647e192b5208f71699da94c1 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 13 Nov 2025 09:48:05 +0100 Subject: [PATCH 343/351] Split Rendering codec frame size support in RTP ToC SR byte --- apps/decoder.c | 13 +++++++ apps/isar_post_rend.c | 78 +++++++++++++++++++++++++++++++++++++ lib_com/options.h | 2 + lib_util/ivas_rtp_api.h | 3 ++ lib_util/ivas_rtp_file.c | 4 ++ lib_util/ivas_rtp_file.h | 2 + lib_util/ivas_rtp_payload.c | 26 +++++++++++++ 7 files changed, 128 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 7b02e26b4..4e8eb8899 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1910,12 +1910,16 @@ static ivas_error initOnFirstGoodFrame( fParamsSR = fopen( srParamsFile, "w" ); if ( NULL != fParamsSR ) { +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + fprintf( fParamsSR, "DOF = %d;\nLC3PLUS_HIGHRES = %d;\n", poseCorrection, lc3plusHighRes ); +#else fprintf( fParamsSR, "CODEC = %s;\nDOF = %d;\nFRAMESIZE = %d;\nRENDERSIZE = %d;\nLC3PLUS_HIGHRES = %d;\n", splitRendCodec == ISAR_SPLIT_REND_CODEC_LC3PLUS ? "LC3PLUS" : "LCLD", poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, lc3plusHighRes ); +#endif fclose( fParamsSR ); fParamsSR = NULL; } @@ -3050,7 +3054,11 @@ static ivas_error decodeVoIP( #ifdef IVAS_RTPDUMP IVAS_RTP ivasRtp = { 0 }; IVAS_RTP srRtp = { 0 }; +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + IVAS_RTP_SR_INFO srInfo = { true, false, 0, 20, IVAS_SR_TRANSPORT_LCLD }; +#else IVAS_RTP_SR_INFO srInfo = { true, false, 0, IVAS_SR_TRANSPORT_LCLD }; +#endif int32_t initialTsOffsetSystemAndRTP = 0; #else FILE *f_rtpstream = NULL; @@ -3128,8 +3136,10 @@ static ivas_error decodeVoIP( case IVAS_DEC_INPUT_FORMAT_RTPDUMP: case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF: #ifdef IVAS_RTPDUMP +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE #ifdef RTP_S4_251135_CR26253_0016_REV1 if ( ( error = IVAS_RTP_READER_Init( &ivasRtp, 0, arg.inputBitstreamFilename, arg.piOutputFilename, arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL, arg.outputWavFilename ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = IVAS_RTP_READER_Init( &ivasRtp, arg.inputBitstreamFilename, arg.piOutputFilename, arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL, arg.outputWavFilename ) ) != IVAS_ERR_OK ) #endif @@ -3745,6 +3755,9 @@ static ivas_error decodeVoIP( { srInfo.bitrateKbps = splitRendBits->bits_written * 1000 / splitRendBits->codec_frame_size_ms; srInfo.codec = ( splitRendBits->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) ? IVAS_SR_TRANSPORT_LC3PLUS : IVAS_SR_TRANSPORT_LCLD; +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + srInfo.codecFrameSizeMs = (uint32_t) splitRendBits->codec_frame_size_ms; +#endif if ( ( error = IVAS_RTP_WriteNextFrame( &srRtp, splitRendBits->bits_buf, &srInfo, (int16_t) splitRendBits->bits_written, false, false ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError %s while pushing SR audio bitstream to RTP pack\n", ivas_error_to_string( error ) ); diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 391db768c..a2933f432 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -749,6 +749,9 @@ static void trim( char *str ) static ivas_error parseSRParamsFile( const char *srParamsFilePath, +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + const char *rtpFilePath, +#endif ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, int16_t *codec_frame_size_ms, @@ -775,6 +778,24 @@ static ivas_error parseSRParamsFile( trim( key ); trim( value ); +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + if ( 0 == strncmp( key, "DOF", 3 ) ) + { + int val = atoi( value ); + if ( val == 0 || val == 1 ) + { + *poseCorrection = ( val == 0 ) ? ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE : ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; + } + } + else if ( 0 == strncmp( key, "LC3PLUS_HIGHRES", 15 ) ) + { + int val = atoi( value ); + if ( val == 0 || val == 1 ) + { + *lc3plusHighRes = (int16_t) val; + } + } +#else if ( 0 == strncmp( key, "CODEC", 5 ) ) { *codec = ( 0 == strncmp( value, "LCLD", 4 ) ) ? ISAR_SPLIT_REND_CODEC_LCLD : *codec; @@ -812,10 +833,52 @@ static ivas_error parseSRParamsFile( *lc3plusHighRes = (int16_t) val; } } +#endif } } fclose( fParamSR ); + +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + { + /* Peek the RTP stream to ascertain the codec and codec_frame_size */ + ivas_error error = IVAS_ERR_OK; + IVAS_RTP srRtp = { 0 }; + if ( ( error = IVAS_RTP_READER_Init( &srRtp, rtpFilePath, NULL, false, NULL ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "error in IVAS_RTP_READER_Init() for sr RTP peek: %d\n", error ); + return error; + } + + /* read a frame */ + while ( 1 ) + { + bool qBit = false; + IVAS_RTP_SR_INFO srInfo = { 0 }; + uint8_t au[( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3]; + int16_t auSize = 0; + uint16_t rtpSequenceNumber = 0; + uint32_t rtpTimeStamp = 0, nextPacketRcvTime_ms = 0; + + error = IVAS_RTP_ReadNextFrame( &srRtp, au, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &srInfo, &qBit ); + if ( error != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_RTP_ReadNextFrame, error code: %d\n", error ); + return error; + } + + if ( srInfo.valid ) + { + *codec = ( srInfo.codec == IVAS_SR_TRANSPORT_LCLD ) ? ISAR_SPLIT_REND_CODEC_LCLD : ISAR_SPLIT_REND_CODEC_LC3PLUS; + *codec_frame_size_ms = (int16_t) srInfo.codecFrameSizeMs; + *isar_frame_size_ms = *codec_frame_size_ms; /* for rtp force codec framesize as isar renderer frame size */ + break; + } + } + IVAS_RTP_Term( &srRtp ); + } +#endif + return IVAS_ERR_OK; } #endif @@ -949,6 +1012,9 @@ int main( if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].srRtp ) ) { error = parseSRParamsFile( args.srParamsFilePath, +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + args.inputFilePath, +#endif &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, @@ -960,12 +1026,21 @@ int main( goto cleanup; } +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE if ( ( error = IVAS_RTP_READER_Init( &srRTP, (uint32_t) bitsBuffer.config.codec_frame_size_ms, args.inputFilePath, NULL, false, NULL ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_RTP_READER_Init( &srRTP, args.inputFilePath, NULL, false, NULL ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "error in IVAS_RTP_READER_Init(): %d\n", error ); goto cleanup; } audioReader = NULL; + +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + /* Force owerwrite of command line provided rendersize to align with codec frame size */ + args.render_framesize = bitsBuffer.config.isar_frame_size_ms / 5; +#endif } /*if split renderer is running in post renderer mode*/ else if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) @@ -1202,6 +1277,9 @@ int main( if ( error == IVAS_ERR_END_OF_FILE ) { numSamplesRead = 0; +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + break; +#endif } else { diff --git a/lib_com/options.h b/lib_com/options.h index 6a092898a..dda9d78d7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,6 +108,8 @@ #define NONBE_FIX_2205_SATURATE_ALTERNATIVE #define NONBE_FIX_2206_SATURATE_ALTERNATIVE #define FIX_2226_ISAR_PRE_CRASH_CLDFB_NO_CHANNELS /* Dolby: Fix crash of ISAR pre-renderer due to an attempt of re-scaling uninitialized values in the CLDFB filter bank */ +#define RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE /* Dolby: CR for split rendering codec framesize signalling in Toc Byte */ + /* ################### End FIXES switches ########################### */ diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h index 8e551c5ff..bf3261f35 100644 --- a/lib_util/ivas_rtp_api.h +++ b/lib_util/ivas_rtp_api.h @@ -275,6 +275,9 @@ typedef struct bool valid; /* Valid Split Rendering Info for/in the ToC */ bool diegetic; /* SR content digetic */ uint32_t bitrateKbps; /* SR bitrate in kbps */ +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + uint32_t codecFrameSizeMs; /* SR transport codec framesize in ms (5/10/20) */ +#endif IVAS_RTP_SR_TRANSPORT codec; /* SR Transport Codec used*/ } IVAS_RTP_SR_INFO; #endif /* RTP_S4_251135_CR26253_0016_REV1 */ diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index dd4d235ef..a1101c785 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -920,8 +920,10 @@ ivas_error IVAS_RTP_WRITER_Init( ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, /* i/o : IVAS RTP File reader handle */ +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE #ifdef RTP_S4_251135_CR26253_0016_REV1 uint32_t srCodecFrameSizeMs, /* i : SR Codec Framesize in ms */ +#endif #endif const char *inputBitstreamFilename, /* i : Input rtpdump filename */ const char *piOutputFilename, /* i : Output PI data json filename */ @@ -934,8 +936,10 @@ ivas_error IVAS_RTP_READER_Init( memset( rtp, 0, sizeof( IVAS_RTP ) ); rtp->unpackCfg.maxFramesPerPacket = IVAS_MAX_FRAMES_PER_RTP_PACKET; +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE #ifdef RTP_S4_251135_CR26253_0016_REV1 rtp->unpackCfg.srCodecFrameSizeMs = srCodecFrameSizeMs; +#endif #endif rtp->rtpPacket.buffer = rtp->packet; rtp->rtpPacket.capacity = sizeof( rtp->packet ); diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index 78126b393..a52708266 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -75,8 +75,10 @@ ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, const char *outputBitstreamFilen #else ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, const char *outputBitstreamFilename, uint32_t numFramesPerPacket ); #endif +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE #ifdef RTP_S4_251135_CR26253_0016_REV1 ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, uint32_t srCodecFrameSizeMs, const char *inputBitstreamFilename, const char *piOutputFilename, bool isExtOutput, const char *outputWavFilename ); +#endif #else ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, const char *inputBitstreamFilename, const char *piOutputFilename, bool isExtOutput, const char *outputWavFilename ); #endif diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 30ba918d7..0b6fa113d 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -852,7 +852,16 @@ static ivas_error getSRToCByte( uint8_t *tocByte /* o : toc byte 2 */ ) { +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + uint8_t bitIdx, codecId, digetic, codecFrameSize; + + if ( srInfo->codecFrameSizeMs != 5 && srInfo->codecFrameSizeMs != 10 && srInfo->codecFrameSizeMs != 20 ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported codec framesize for SR provided" ); + } +#else uint8_t bitIdx, codecId, digetic; +#endif if ( srInfo->bitrateKbps < 256000 || srInfo->bitrateKbps > 512000 ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported bitrate for SR" ); @@ -862,7 +871,12 @@ static ivas_error getSRToCByte( codecId = (uint8_t) srInfo->codec; digetic = srInfo->diegetic ? 1 : 0; +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + codecFrameSize = ( srInfo->codecFrameSizeMs == 20 ) ? 3 : (uint8_t) ( srInfo->codecFrameSizeMs / 5 ); + *tocByte = ( digetic << 6 ) | ( codecId << 5 ) | ( bitIdx << 3 ) | ( codecFrameSize << 1 ); +#else *tocByte = ( digetic << 6 ) | ( codecId << 5 ) | ( bitIdx << 3 ); +#endif return IVAS_ERR_OK; } @@ -1412,8 +1426,10 @@ static uint32_t parseSubsequentEByte( const IVAS_DATA_BUFFER *payload, uint32_t return nBytes; } +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE #ifdef RTP_S4_251135_CR26253_0016_REV1 static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBytes, uint32_t *numFrames, TOC_INFO *toc, uint32_t maxNumberOfToCBytes, uint32_t srCodecFrameSizeMs ) +#endif #else static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBytes, uint32_t *numFrames, TOC_INFO *toc, uint32_t maxNumberOfToCBytes ) #endif @@ -1474,6 +1490,9 @@ static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBy if ( nBytes < payload->length ) { uint8_t SR_BR; +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + static const uint8_t codecFrameSizeMap[4] = { 0, 5, 10, 20 }; +#endif byte = payload->buffer[nBytes++]; SR_BR = ( byte >> 3 ) & MASK_2BIT; if ( SR_BR == 0 ) @@ -1484,7 +1503,12 @@ static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBy toc->srInfo.diegetic = ( byte >> 6 ) & MASK_1BIT; toc->srInfo.codec = IVAS_SR_TRANSPORT_LCLD + ( ( byte >> 5 ) & MASK_1BIT ); toc->srInfo.bitrateKbps = ( SR_BR + 1 ) * 128000u; +#ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE + toc->srInfo.codecFrameSizeMs = codecFrameSizeMap[( byte >> 1 ) & MASK_2BIT]; + toc->auNumBits = toc->srInfo.bitrateKbps * toc->srInfo.codecFrameSizeMs / 1000; +#else toc->auNumBits = toc->srInfo.bitrateKbps * srCodecFrameSizeMs / 1000; +#endif } else { @@ -1666,8 +1690,10 @@ ivas_error IVAS_RTP_UNPACK_PushPayload( nBytes = parseSubsequentEByte( payload, nBytes, hUnpack->requests, &piDataIndicated ); /* Unpack the ToC Bytes => Extract number of frames in packet */ +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE #ifdef RTP_S4_251135_CR26253_0016_REV1 error = parseToCByte( payload, &nBytes, &numFrames, toc, sizeof( toc ) / sizeof( toc[0] ), hUnpack->initConfig.srCodecFrameSizeMs ); +#endif #else error = parseToCByte( payload, &nBytes, &numFrames, toc, sizeof( toc ) / sizeof( toc[0] ) ); #endif -- GitLab From 56065fc203a61ae46705df118b133e65c11280b3 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 13 Nov 2025 09:48:37 +0100 Subject: [PATCH 344/351] Dummy commit -- GitLab From 9afe7b7ee7570eeb5708517f7f88e0d1b368dec7 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 13 Nov 2025 09:51:48 +0100 Subject: [PATCH 345/351] clang format --- lib_util/ivas_rtp_api.h | 6 +++--- lib_util/ivas_rtp_payload.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h index bf3261f35..a296e8ab3 100644 --- a/lib_util/ivas_rtp_api.h +++ b/lib_util/ivas_rtp_api.h @@ -272,9 +272,9 @@ typedef enum typedef struct { - bool valid; /* Valid Split Rendering Info for/in the ToC */ - bool diegetic; /* SR content digetic */ - uint32_t bitrateKbps; /* SR bitrate in kbps */ + bool valid; /* Valid Split Rendering Info for/in the ToC */ + bool diegetic; /* SR content digetic */ + uint32_t bitrateKbps; /* SR bitrate in kbps */ #ifdef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE uint32_t codecFrameSizeMs; /* SR transport codec framesize in ms (5/10/20) */ #endif diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 0b6fa113d..2f8d3aca9 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -1426,7 +1426,7 @@ static uint32_t parseSubsequentEByte( const IVAS_DATA_BUFFER *payload, uint32_t return nBytes; } -#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE #ifdef RTP_S4_251135_CR26253_0016_REV1 static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBytes, uint32_t *numFrames, TOC_INFO *toc, uint32_t maxNumberOfToCBytes, uint32_t srCodecFrameSizeMs ) #endif @@ -1690,7 +1690,7 @@ ivas_error IVAS_RTP_UNPACK_PushPayload( nBytes = parseSubsequentEByte( payload, nBytes, hUnpack->requests, &piDataIndicated ); /* Unpack the ToC Bytes => Extract number of frames in packet */ -#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE +#ifndef RTP_SR_CODEC_FRAME_SIZE_IN_TOC_BYTE #ifdef RTP_S4_251135_CR26253_0016_REV1 error = parseToCByte( payload, &nBytes, &numFrames, toc, sizeof( toc ) / sizeof( toc[0] ), hUnpack->initConfig.srCodecFrameSizeMs ); #endif -- GitLab From d31e5945b2ee68aaf1a6461b56e758381eb1c533 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 11:42:07 +0200 Subject: [PATCH 346/351] Add description for RTP streaming format --- readme.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/readme.txt b/readme.txt index 5adec9098..583499993 100644 --- a/readme.txt +++ b/readme.txt @@ -705,3 +705,15 @@ obj__relele=0|1 if 1, obj__ele is interpreted as a relative modific If a parameter is not specified, that parameter is not edited. An empty line in the file corresponds to not editing any parameter in the item. Example files are available in folder /scripts/object_edit. + + +RTP streaming file +------------------- +IVAS supports a simple packing and unpacking for streaming file for the RTP. In this format a single RTP_streaming_packet +contains the length of an RTP packet followed by the actual RTP packet which is recorded as-is. This format is produced +by the encoder when using the -rtpdump switch and the decoder assumes this format in the input when -VOIP_hf_only=1 is set. + +typedef struct { + u_int32 length; /* size of the RTP packet in bytes */ + (u_int8 * length) RTP_packet; /* RTP packet (sized length * byte) */ +} RTP_streaming_packet; -- GitLab From 9a1e89c1d3921ceb45e194b3bf8a6ef2be56721f Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 11:59:55 +0200 Subject: [PATCH 347/351] Clang format --- apps/decoder.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index aaca85081..7ffc98379 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3263,15 +3263,15 @@ static ivas_error decodeVoIP( { IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS; if ( ( error = restartDecoder( - &hIvasDec, - newDecModeInPacket, - &arg, + &hIvasDec, + newDecModeInPacket, + &arg, #ifdef FIX_SPLIT_RENDERING_ON_DECODER_RESTART - renderConfig, + renderConfig, #else - NULL, /* ToDo : Provide rendererConfig */ + NULL, /* ToDo : Provide rendererConfig */ #endif - NULL /* ToDo : Provide LS Custom Data */ + NULL /* ToDo : Provide LS Custom Data */ ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newDecModeInPacket ); -- GitLab From 77a30532025bd6520e354f89a5808e455da198dc Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 13 Nov 2025 11:44:45 +0100 Subject: [PATCH 348/351] Use L_norm_arr instead of getScaleFactor32 for CLDFB dynamic scale to avoid low precision for first frame. Apply same headroom search to CLDFB states to second occurance to the problem being fixed in previous changes. --- lib_isar/isar_splitRendererPost.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 0bfd5fc25..9ff9761f9 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1818,9 +1818,11 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( { RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; - scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); #ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES - scaleFactor = s_min( scaleFactor, getScaleFactor32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length ) ); + scaleFactor = s_min( scaleFactor, s_min( L_norm_arr( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); + scaleFactor = s_min( scaleFactor, L_norm_arr( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_length ) ); +#else + scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); #endif } scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits @@ -1883,7 +1885,12 @@ void isar_rend_CldfbSplitPostRendProcess( { RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; +#ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES + scaleFactor = s_min( scaleFactor, s_min( L_norm_arr( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); + scaleFactor = s_min( scaleFactor, L_norm_arr( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_length ) ); +#else scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); +#endif } scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits -- GitLab From 835b7cec147d6f72b9ee870ba59f4ed6e618ed51 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 13 Nov 2025 13:44:24 +0100 Subject: [PATCH 349/351] Use num_cldfb_bands instead of CLDFB_NO_CHANNELS_MAX for searching headroom and rescaling as suggested by @malenovskyvl --- lib_isar/isar_splitRendererPost.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 9ff9761f9..272dc45c8 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1819,7 +1819,7 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; #ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES - scaleFactor = s_min( scaleFactor, s_min( L_norm_arr( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); + scaleFactor = s_min( scaleFactor, s_min( L_norm_arr( RealBuffer_fx[slot_idx], num_cldfb_bands ), L_norm_arr( ImagBuffer_fx[slot_idx], num_cldfb_bands ) ) ); scaleFactor = s_min( scaleFactor, L_norm_arr( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_length ) ); #else scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); @@ -1828,8 +1828,13 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { +#ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES + Scale_sig32( RealBuffer_fx[slot_idx], num_cldfb_bands, scaleFactor ); + Scale_sig32( ImagBuffer_fx[slot_idx], num_cldfb_bands, scaleFactor ); +#else Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); Scale_sig32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); +#endif } Q_cldfb = add( scaleFactor, Q_in ); Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); @@ -1886,7 +1891,7 @@ void isar_rend_CldfbSplitPostRendProcess( RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch_idx][slot_idx]; ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; #ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES - scaleFactor = s_min( scaleFactor, s_min( L_norm_arr( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); + scaleFactor = s_min( scaleFactor, s_min( L_norm_arr( RealBuffer_fx[slot_idx], num_cldfb_bands ), L_norm_arr( ImagBuffer_fx[slot_idx], num_cldfb_bands ) ) ); scaleFactor = s_min( scaleFactor, L_norm_arr( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_length ) ); #else scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); @@ -1896,8 +1901,13 @@ void isar_rend_CldfbSplitPostRendProcess( scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { +#ifdef NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES + Scale_sig32( RealBuffer_fx[slot_idx], num_cldfb_bands, scaleFactor ); + Scale_sig32( ImagBuffer_fx[slot_idx], num_cldfb_bands, scaleFactor ); +#else Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); Scale_sig32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); +#endif } Q_cldfb = scaleFactor + Q_cldfb_in; Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); -- GitLab From 75afe1e7cd52bc6c7775e16f71f7d4e8a5bbf253 Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 17:11:45 +0200 Subject: [PATCH 350/351] Add own random generator for rtp --- apps/decoder.c | 13 +++++++++++++ apps/encoder.c | 13 +++++++++++++ apps/encoder_fmtsw.c | 13 +++++++++++++ lib_com/options.h | 2 ++ lib_util/ivas_rtp_file.c | 7 +++++++ lib_util/ivas_rtp_file.h | 1 + 6 files changed, 49 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index c31d4cd5c..e9f0c396a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -68,9 +68,13 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS +#define RANDOM_INITSEED_DEC ( 0xFADE ) +#else #ifdef FIXED_RTP_SEQUENCE_NUM #define RANDOM_INITSEED_DEC ( 0xFEEDFADE ) #endif +#endif #ifdef DEBUGGING #define MIN_NUM_BITS_ACTIVE_FRAME 56 @@ -1888,6 +1892,14 @@ static ivas_error initOnFirstGoodFrame( int16_t splitRendIsarFrameSizeMs; int16_t lc3plusHighRes; +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS + /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we + use fixed seed for random num generator for regression based tests. Any realtime + application should implement this initialization seperately */ + uint16_t rtpDecSeed = RANDOM_INITSEED_DEC; + uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) << 16; + uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ); +#else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we use fixed seed for random num generator for regression based tests. Any realtime @@ -1895,6 +1907,7 @@ static ivas_error initOnFirstGoodFrame( srand( RANDOM_INITSEED_DEC ); uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif #endif if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) diff --git a/apps/encoder.c b/apps/encoder.c index 3e2bd7778..10cf2fd48 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -74,9 +74,13 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS +#define RANDOM_INITSEED_ENC ( 0xDEAF ) +#else #ifdef FIXED_RTP_SEQUENCE_NUM #define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) #endif +#endif #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ @@ -230,6 +234,14 @@ int main( IVAS_RTP ivasRtp = { 0 }; #endif +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS + /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we + use fixed seed for random num generator for regression based tests. Any realtime + application should implement this initialization seperately */ + uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; + uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16; + uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ); +#else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we use fixed seed for random num generator for regression based tests. Any realtime @@ -237,6 +249,7 @@ int main( srand( RANDOM_INITSEED_ENC ); uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif #endif /*------------------------------------------------------------------------------------------* diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index df8236361..d54912f03 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -77,9 +77,13 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS +#define RANDOM_INITSEED_ENC ( 0xDEAF ) +#else #ifdef FIXED_RTP_SEQUENCE_NUM #define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) #endif +#endif #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ @@ -355,6 +359,14 @@ int encoder_main( /* IVAS_RTP ivasRtp = { 0 }; */ #endif +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS + /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we + use fixed seed for random num generator for regression based tests. Any realtime + application should implement this initialization seperately */ + uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; + uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16; + uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ); +#else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we use fixed seed for random num generator for regression based tests. Any realtime @@ -362,6 +374,7 @@ int encoder_main( srand( RANDOM_INITSEED_ENC ); uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif #endif /*------------------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index eb172a83c..b1d98931d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,6 +113,8 @@ #define NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES /* FhG: Adjust scaleFactor according to st->cldfbSyn->cldfb_state_fx too to avoid overflow in cldfbSynthesis_ivas_fx() */ +#define NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS /* Nokia: fix basop issue 2233: Fix differing rtpdump streams */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index a1101c785..6ded4e78e 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -1154,3 +1154,10 @@ ivas_error IVAS_RTP_ReadNextFrame( return IVAS_ERR_OK; } + +uint16_t IVAS_RTP_OwnRandom( uint16_t *seed ) +{ + *seed = (uint16_t) ( *seed * 31821L + 13849L ); + + return ( *seed ); +} diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index a52708266..fc92a4d02 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -94,6 +94,7 @@ ivas_error IVAS_RTP_ReadNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t *auSizeBi void IVAS_RTP_LogPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent ); void IVAS_RTP_WriteExtPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent, uint16_t numObj ); const char *IVAS_RTP_GetExtPiFilePath( IVAS_RTP *rtp ); +uint16_t IVAS_RTP_OwnRandom( uint16_t *seed ); #endif /* IVAS_RTP_FILE_H */ -- GitLab From 7c33fe35d9c6d2bf46f12df7dbe3bb666ce5311a Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 18:24:21 +0200 Subject: [PATCH 351/351] Fix sanitizer issues --- apps/decoder.c | 4 ++-- apps/encoder.c | 4 ++-- apps/encoder_fmtsw.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index e9f0c396a..1310ef4d8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1897,8 +1897,8 @@ static ivas_error initOnFirstGoodFrame( use fixed seed for random num generator for regression based tests. Any realtime application should implement this initialization seperately */ uint16_t rtpDecSeed = RANDOM_INITSEED_DEC; - uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) << 16; - uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ); + uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) << 16 ); + uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpDecSeed ); #else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we diff --git a/apps/encoder.c b/apps/encoder.c index 10cf2fd48..551eee9af 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -239,8 +239,8 @@ int main( use fixed seed for random num generator for regression based tests. Any realtime application should implement this initialization seperately */ uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; - uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16; - uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ); + uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16 ); + uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpEncSeed ); #else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index d54912f03..10d81fc2f 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -364,8 +364,8 @@ int encoder_main( use fixed seed for random num generator for regression based tests. Any realtime application should implement this initialization seperately */ uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; - uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16; - uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ); + uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16 ); + uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpEncSeed ); #else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we -- GitLab