From 0720795c88f3b6781397dac31451ba38e891f00e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 23 Jul 2024 17:28:29 +0530 Subject: [PATCH 1/5] BASOP and instrumentation changes, optimizations [x] Added W_mac_32_32 basop. [x] Replaced some of the basops where MAC operation were performed with W_mac_32_32 operation. [x] lib_com BASOP and instrumentation changes --- lib_com/basop_util.c | 16 + lib_com/basop_util.h | 2 + lib_com/bitallocsum_fx.c | 2 + lib_com/bits_alloc_fx.c | 864 +++++++++++++++++--------- lib_com/bitstream.c | 56 +- lib_com/bitstream_fx.c | 678 +++++++++++++------- lib_com/cb_shape_fx.c | 6 +- lib_com/cldfb.c | 650 ++++++++++--------- lib_com/cldfb_evs.c | 208 ++++--- lib_com/cng_exc_fx.c | 72 ++- lib_com/cnst.h | 2 - lib_com/codec_tcx_common.c | 36 +- lib_com/enh64.c | 49 ++ lib_com/enh64.h | 1 + lib_com/ivas_stereo_td_bit_alloc.c | 4 +- lib_dec/dec_tcx_fx.c | 4 +- lib_dec/ivas_corecoder_dec_reconfig.c | 6 +- lib_dec/ivas_init_dec.c | 4 +- lib_dec/ivas_stereo_switching_dec.c | 12 +- lib_dec/jbm_jb4sb.c | 2 +- lib_dec/lib_dec_fx.c | 2 +- lib_enc/lib_enc.c | 4 +- lib_rend/ivas_masa_merge.c | 2 +- lib_rend/ivas_mcmasa_ana.c | 2 +- lib_rend/ivas_objectRenderer_sfx.c | 27 +- lib_rend/ivas_omasa_ana.c | 2 +- lib_rend/ivas_prot_rend.h | 3 +- lib_rend/lib_rend.c | 4 +- 28 files changed, 1745 insertions(+), 975 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 4044484d3..e22f0f6e7 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1583,6 +1583,22 @@ Word16 idiv1616( Word16 x, Word16 y ) return y; } +Word16 idiv1616_1( Word16 x, Word16 y ) +{ + IF( L_mult0( x, y ) < 0 ) + { + return negate( idiv1616( abs_s( x ), abs_s( y ) ) ); + } + ELSE IF( L_mult0( x, y ) > 0 ) + { + return idiv1616( x, y ); + } + ELSE + { + return 0; + } +} + Word32 norm_llQ31( /* o : normalized result Q31 */ Word32 L_c, /* i : upper bits of accu Q-1 */ Word32 L_sum, /* i : lower bits of accu, unsigned Q31 */ diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 380c8316b..d633a33f9 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -582,6 +582,8 @@ Word16 idiv1616U( Word16 x, Word16 y ); Word16 idiv1616( Word16 x, Word16 y ); +Word16 idiv1616_1( Word16 x, Word16 y ); + /*------------------------------------------------------------------* * Dot_product16HQ: * diff --git a/lib_com/bitallocsum_fx.c b/lib_com/bitallocsum_fx.c index c3803eb94..c8ad205e1 100644 --- a/lib_com/bitallocsum_fx.c +++ b/lib_com/bitallocsum_fx.c @@ -35,6 +35,7 @@ void bitallocsum_fx( total = add( total, tmp ); } *sum = total; + move16(); IF( LE_16( length, L_FRAME32k ) ) { @@ -49,6 +50,7 @@ void bitallocsum_fx( move16(); diff = sub( diff, 1 ); *sum = add( *sum, 1 ); + move16(); } i = add( i, 1 ); if ( GE_16( i, nb_sfm ) ) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index da120dc82..cbcf41090 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -66,7 +66,7 @@ void BITS_ALLOC_init_config_acelp( /*ACELP ICB config*/ test(); - IF( EQ_16( rate_mode_index, 0 ) || NE_16( narrowBand, 0 ) ) + IF( ( rate_mode_index == 0 ) || ( narrowBand != 0 ) ) { move16(); move16(); @@ -148,16 +148,16 @@ Word16 BITS_ALLOC_config_acelp( { move16(); pConfigAcelp->formant_enh = 1; - if ( EQ_16( coder_type, INACTIVE ) ) + if ( coder_type == INACTIVE ) { move16(); pConfigAcelp->formant_enh = 0; } } - IF( s_and( (Word16) EQ_16( band_index, 1 ), (Word16) EQ_16( nb_subfr, 4 ) ) ) + IF( L_and( EQ_16( band_index, 1 ), EQ_16( nb_subfr, 4 ) ) ) { - IF( EQ_16( coder_type, INACTIVE ) ) + IF( coder_type == INACTIVE ) { pConfigAcelp->pre_emphasis = 0; move16(); @@ -212,7 +212,9 @@ Word16 BITS_ALLOC_config_acelp( IF( GT_16( coder_type, ACELP_MODE_MAX ) ) /* keep pitch sharpening for RF_ALLPRED mode */ { pConfigAcelp->pitch_sharpening = 0; + move16(); pConfigAcelp->phase_scrambling = 0; + move16(); } /*Allocate bits and different modes*/ @@ -237,9 +239,10 @@ Word16 BITS_ALLOC_config_acelp( move16(); pConfigAcelp->ltf_bits = ACELP_LTF_BITS[pConfigAcelp->ltf_mode]; - if ( s_and( (Word16) EQ_16( nb_subfr, 5 ), (Word16) EQ_16( pConfigAcelp->ltf_bits, 4 ) ) ) + IF( L_and( EQ_16( nb_subfr, 5 ), EQ_16( pConfigAcelp->ltf_bits, 4 ) ) ) { pConfigAcelp->ltf_bits = add( pConfigAcelp->ltf_bits, 1 ); + move16(); } bits = add( bits, pConfigAcelp->ltf_bits ); @@ -252,9 +255,10 @@ Word16 BITS_ALLOC_config_acelp( /* skip subframe 1, 3 gain encoding, and use from subframe 0, and 3, respectively */ test(); test(); - IF( GE_16( coder_type, ACELP_MODE_MAX ) && ( EQ_16( i, 1 ) || EQ_16( i, 3 ) ) ) + if ( GE_16( coder_type, ACELP_MODE_MAX ) && ( EQ_16( i, 1 ) || EQ_16( i, 3 ) ) ) { pConfigAcelp->gains_mode[i] = 0; + move16(); } bits = add( bits, ACELP_GAINS_BITS[pConfigAcelp->gains_mode[i]] ); @@ -266,7 +270,7 @@ Word16 BITS_ALLOC_config_acelp( /*Innovation*/ - if ( LT_16( bits_frame, bits ) ) + IF( LT_16( bits_frame, bits ) ) { printf( "Warning: bits per frame too low\n" ); return -1; @@ -279,10 +283,15 @@ Word16 BITS_ALLOC_config_acelp( ELSE IF( EQ_16( coder_type, RF_GENPRED ) ) { pConfigAcelp->fixed_cdk_index[0] = 0; /* 7 bits */ + move16(); pConfigAcelp->fixed_cdk_index[1] = -1; + move16(); pConfigAcelp->fixed_cdk_index[2] = 0; /* 7 bits */ + move16(); pConfigAcelp->fixed_cdk_index[3] = -1; + move16(); pConfigAcelp->fixed_cdk_index[4] = -1; + move16(); bits = add( bits, 14 ); } ELSE IF( EQ_16( coder_type, RF_NOPRED ) ) @@ -338,14 +347,14 @@ static Word16 BITS_ALLOC_adjust_generic( FOR( k = 0; k < pulseconfig_size - 1; k++ ) { - IF( i_mult2( pulseconfigbits[k], nb_subfr ) > bits_subframe2 ) + IF( GT_16( i_mult2( pulseconfigbits[k], nb_subfr ), bits_subframe2 ) ) { k = sub( k, 1 ); /* previous mode did not exceed bit-budget */ BREAK; } } - if ( i_mult2( pulseconfigbits[k], nb_subfr ) > bits_subframe2 ) + if ( GT_16( i_mult2( pulseconfigbits[k], nb_subfr ), bits_subframe2 ) ) { k = sub( k, 1 ); /* previous mode did not exceed bit-budget */ } @@ -360,14 +369,14 @@ static Word16 BITS_ALLOC_adjust_generic( bits_currsubframe = sub( add( i_mult2( sfr, bits_subframe2 ), bits_subframe2 ), bitsused ); /* try increasing mode while below threshold */ - WHILE( ( LT_16( k, pulseconfig_size - 1 ) ) && ( LE_16( i_mult2( pulseconfigbits[add( k, 1 )], nb_subfr ), bits_currsubframe ) ) ) + WHILE( ( LT_16( k, sub( pulseconfig_size, 1 ) ) ) && ( LE_16( i_mult2( pulseconfigbits[k + 1], nb_subfr ), bits_currsubframe ) ) ) { test(); k = add( k, 1 ); } /* try decreasing mode until below threshold */ - WHILE( i_mult2( pulseconfigbits[k], nb_subfr ) > bits_currsubframe ) + WHILE( GT_16( i_mult2( pulseconfigbits[k], nb_subfr ), bits_currsubframe ) ) { k = sub( k, 1 ); @@ -415,9 +424,11 @@ static Word16 fcb_table( // PMT("Not floating point computation, but fixed point operator are still missing ") out = PulseConfTable[n].bits; - if ( L_subfr > L_SUBFR ) + move16(); + if ( GT_16( L_subfr, L_SUBFR ) ) { out = fast_FCB_bits_2sfr[n]; + move16(); } return ( out ); @@ -447,50 +458,61 @@ static ivas_error acelp_FCB_allocator( // PMT("Not floating point computation, but fixed point operator are still missing ") error = IVAS_ERR_OK; + move32(); cdbk = coder_type; /* just to avoid warning when DEBUGGING is deactivated */ + move16(); p_fixed_cdk_index = fixed_cdk_index; + move16(); /* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse not in the first subframe */ - if ( tc_subfr >= L_SUBFR && fix_first ) + test(); + IF( GE_16( tc_subfr, L_SUBFR ) && fix_first ) { Word16 i; - for ( i = 0; i < nb_subfr; i++ ) + FOR( i = 0; i < nb_subfr; i++ ) { - *nBits -= ACELP_FIXED_CDK_BITS( fixed_cdk_index[i] ); + *nBits = sub( *nBits, ACELP_FIXED_CDK_BITS( fixed_cdk_index[i] ) ); + move16(); } return error; } /* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse in the first subframe */ sfr = 0; - if ( fix_first ) + move16(); + IF( fix_first ) { - *nBits -= ACELP_FIXED_CDK_BITS( fixed_cdk_index[0] ); + *nBits = sub( *nBits, ACELP_FIXED_CDK_BITS( fixed_cdk_index[0] ) ); + move16(); sfr = 1; + move16(); p_fixed_cdk_index++; nb_subfr = 3; + move16(); } /* distribute the bit-budget equally between subframes */ - if ( L_subfr > L_SUBFR ) /* access fast_FCB_bits_2sfr */ + IF( GT_16( L_subfr, L_SUBFR ) ) /* access fast_FCB_bits_2sfr */ { max_n = 6; + move16(); } - else + ELSE { max_n = ACELP_FIXED_CDK_NB; + move16(); } - for ( cdbk = 0; cdbk < max_n; cdbk++ ) + FOR( cdbk = 0; cdbk < max_n; cdbk++ ) { - if ( fcb_table( cdbk, L_subfr ) * nb_subfr > *nBits ) + IF( GT_32( L_mult0( fcb_table( cdbk, L_subfr ), nb_subfr ), L_deposit_l( *nBits ) ) ) { - break; + BREAK; } } - cdbk--; + cdbk = sub( cdbk, 1 ); #if defined DEBUGGING if ( cdbk < 0 && coder_type != TRANSITION ) @@ -505,64 +527,74 @@ static ivas_error acelp_FCB_allocator( set16_fx( p_fixed_cdk_index, cdbk, nb_subfr ); nBits_tmp = 0; - if ( cdbk >= 0 ) + move16(); + IF( cdbk >= 0 ) { nBits_tmp = fcb_table( cdbk, L_subfr ); + move16(); } - else + ELSE { nBits_tmp = 0; + move16(); } - *nBits -= nBits_tmp * nb_subfr; + *nBits = sub( *nBits, i_mult( nBits_tmp, nb_subfr ) ); + move16(); /* try to increase the FCB bit-budget of the first subframe(s) */ - if ( cdbk < ACELP_FIXED_CDK_NB - 1 ) + IF( LT_16( cdbk, ACELP_FIXED_CDK_NB - 1 ) ) { - step = fcb_table( cdbk + 1, L_subfr ) - nBits_tmp; - while ( *nBits >= step ) + step = sub( fcb_table( add( cdbk, 1 ), L_subfr ), nBits_tmp ); + WHILE( GE_16( *nBits, step ) ) { ( *p_fixed_cdk_index )++; - *nBits -= step; + *nBits = sub( *nBits, step ); + move16(); p_fixed_cdk_index++; } /* try to increase the FCB of the first subframe in cases when the next step is lower than the current step */ - step = fcb_table( fixed_cdk_index[sfr] + 1, L_subfr ) - fcb_table( fixed_cdk_index[sfr], L_subfr ); - if ( *nBits >= step && cdbk >= 0 ) + step = sub( fcb_table( add( fixed_cdk_index[sfr], 1 ), L_subfr ), fcb_table( fixed_cdk_index[sfr], L_subfr ) ); + test(); + IF( GE_16( *nBits, step ) && cdbk >= 0 ) { fixed_cdk_index[sfr]++; - *nBits -= step; - - if ( *nBits >= step && fixed_cdk_index[sfr + 1] == fixed_cdk_index[sfr] - 1 ) + *nBits = sub( *nBits, step ); + move16(); + test(); + IF( GE_16( *nBits, step ) && EQ_16( fixed_cdk_index[sfr + 1], sub( fixed_cdk_index[sfr], 1 ) ) ) { sfr++; fixed_cdk_index[sfr]++; - *nBits -= step; + *nBits = sub( *nBits, step ); + move16(); } } } /* TRANSITION coding: allocate highest FCBQ bit-budget to the subframe with the glottal-shape codebook */ - if ( tc_subfr >= L_SUBFR ) + IF( GE_16( tc_subfr, L_SUBFR ) ) { Word16 tempr; SWAP( fixed_cdk_index[0], fixed_cdk_index[tc_subfr / L_SUBFR] ); /* TRANSITION coding: allocate second highest FCBQ bit-budget to the last subframe */ - if ( tc_subfr / L_SUBFR < nb_subfr - 1 ) + IF( idiv1616( tc_subfr, L_SUBFR ) < sub( nb_subfr, 1 ) ) { - SWAP( fixed_cdk_index[( tc_subfr - L_SUBFR ) / L_SUBFR], fixed_cdk_index[nb_subfr - 1] ); + SWAP( fixed_cdk_index[sub( tc_subfr, L_SUBFR ) / L_SUBFR], fixed_cdk_index[nb_subfr - 1] ); } } /* when subframe length > L_SUBFR, number of bits instead of codebook index is signalled */ - if ( L_subfr > L_SUBFR ) + IF( GT_16( L_subfr, L_SUBFR ) ) { Word16 i, j; - for ( i = 0; i < nb_subfr; i++ ) + FOR( i = 0; i < nb_subfr; i++ ) { j = fixed_cdk_index[i]; + move16(); fixed_cdk_index[i] = fast_FCB_bits_2sfr[j]; + move16(); } } @@ -620,17 +652,25 @@ ivas_error config_acelp1( ivas_error error; error = IVAS_ERR_OK; + move32(); // PMT("Not floating point computation, but fixed point operator are still missing ") /*-----------------------------------------------------------------* * Set the flag indicating two-stage Unvoiced (UC) frame *-----------------------------------------------------------------*/ *uc_two_stage_flag = 0; - if ( coder_type == UNVOICED ) + move16(); + IF( EQ_16( coder_type, UNVOICED ) ) { - if ( total_brate >= MIN_UNVOICED_TWO_STAGE_BRATE && element_mode > EVS_MONO && ( idchan == 0 || ( ( total_brate >= 8500 || extl_brate == 0 ) && tdm_LRTD_flag == 1 ) ) ) + test(); + test(); + test(); + test(); + test(); + if ( GE_32( total_brate, MIN_UNVOICED_TWO_STAGE_BRATE ) && element_mode > EVS_MONO && ( idchan == 0 || ( ( GE_32( total_brate, 8500 ) || extl_brate == 0 ) && EQ_16( tdm_LRTD_flag, 1 ) ) ) ) { *uc_two_stage_flag = 1; + move16(); } } @@ -638,9 +678,10 @@ ivas_error config_acelp1( * Set the number of subframes *-----------------------------------------------------------------*/ - if ( L_frame == L_FRAME ) + IF( EQ_16( L_frame, L_FRAME ) ) { nb_subfr = NB_SUBFR; + move16(); #if defined DEBUGGING if ( ( ( core_brate_inp < 5900 && coder_type > UNVOICED ) && !( core_brate_inp < MIN_TC_BRATE && coder_type == TRANSITION ) ) && !( idchan > 0 && element_mode == IVAS_CPE_TD ) && !( element_mode == IVAS_SCE && tdm_low_rate_mode ) ) @@ -654,9 +695,10 @@ ivas_error config_acelp1( } #endif } - else /* L_frame == L_FRAME16k */ + ELSE /* L_frame == L_FRAME16k */ { nb_subfr = NB_SUBFR16k; + move16(); #if defined DEBUGGING if ( core_brate_inp < ACELP_16k_LOW_LIMIT && core == ACELP_CORE ) @@ -667,13 +709,16 @@ ivas_error config_acelp1( } coder_type_sw = coder_type; - if ( core != ACELP_CORE ) + move16(); + IF( core != ACELP_CORE ) { /* used in acelp_core_switch_enc() */ nb_subfr = 1; - if ( L_frame == L_FRAME ) + move16(); + if ( EQ_16( L_frame, L_FRAME ) ) { coder_type_sw = TRANSITION; + move16(); } } @@ -682,171 +727,230 @@ ivas_error config_acelp1( *-----------------------------------------------------------------*/ flag_hardcoded = 0; + move16(); i = 0; + move16(); - while ( i < SIZE_BRATE_INTERMED_TBL ) + WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) { - if ( core_brate_inp == brate_intermed_tbl[i] ) + IF( EQ_32( core_brate_inp, brate_intermed_tbl[i] ) ) { flag_hardcoded = 1; - break; + move16(); + BREAK; } - if ( core_brate_inp < brate_intermed_tbl[i] ) + IF( LT_32( core_brate_inp, brate_intermed_tbl[i] ) ) { flag_hardcoded = 0; - break; + move16(); + BREAK; } i++; } - if ( element_mode == IVAS_CPE_TD && coder_type == AUDIO && - core_brate_inp <= STEREO_GSC_BIT_RATE_ALLOC && brate_intermed_tbl[i] == ACELP_9k60 ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */ + test(); + test(); + test(); + if ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( coder_type, AUDIO ) && + LE_32( core_brate_inp, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */ { - i--; + i = sub( i, 1 ); } core_brate = brate_intermed_tbl[i]; + move32(); if ( element_mode > EVS_MONO ) { flag_hardcoded = 0; /* use automatic and flexible ACELP bit-budget allocation */ + move16(); } + test(); if ( core != ACELP_CORE && element_mode == EVS_MONO ) /* needed for mode1 core switching in EVS mono */ { flag_hardcoded = 1; + move16(); } /*-----------------------------------------------------------------* * ACELP bit allocation *-----------------------------------------------------------------*/ - - if ( !( coder_type == TRANSITION && tc_subfr != -1 ) || enc_dec == DEC ) + test(); + test(); + IF( !( EQ_16( coder_type, TRANSITION ) && NE_16( tc_subfr, -1 ) ) || EQ_16( enc_dec, DEC ) ) { /* Set the bit-budget */ - bits = (Word16) ( core_brate_inp / FRAMES_PER_SEC ); + bits = extract_l( Mpy_32_32( core_brate_inp, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - if ( coder_type == TRANSITION && enc_dec == DEC && tc_call == 1 ) + test(); + test(); + if ( EQ_16( coder_type, TRANSITION ) && EQ_16( enc_dec, DEC ) && EQ_16( tc_call, 1 ) ) { - bits += *nBits_es_Pred; /* equalize for 4th signaling bit estimated at the encoder in TC_0_192 */ + bits = add( bits, *nBits_es_Pred ); /* equalize for 4th signaling bit estimated at the encoder in TC_0_192 */ } /* Subtract signalling bits */ - if ( enc_dec == DEC && idchan == 1 && element_mode > EVS_MONO ) + test(); + test(); + IF( EQ_16( enc_dec, DEC ) && EQ_16( idchan, 1 ) && element_mode > EVS_MONO ) { - bits -= TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS; + bits = sub( bits, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); - if ( tdm_LRTD_flag == 1 ) + if ( EQ_16( tdm_LRTD_flag, 1 ) ) { - bits += STEREO_BITS_TCA; + bits = add( bits, STEREO_BITS_TCA ); } /* subtract TBE/BWE flag */ - if ( extl_brate > 0 && ( extl == WB_TBE || extl == SWB_TBE || extl == FB_TBE || extl == WB_BWE || extl == SWB_BWE || extl == FB_BWE ) ) + test(); + test(); + test(); + test(); + test(); + test(); + if ( extl_brate > 0 && ( EQ_16( extl, WB_TBE ) || EQ_16( extl, SWB_TBE ) || EQ_16( extl, FB_TBE ) || EQ_16( extl, WB_BWE ) || EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) ) { - bits--; + bits = sub( bits, 1 ); } } - else + ELSE { /* Subtract signalling bits */ - bits -= signalling_bits; + bits = sub( bits, signalling_bits ); } - if ( extl_brate > 0 && ( extl == WB_TBE || extl == SWB_TBE || extl == FB_TBE || extl == WB_BWE || extl == SWB_BWE || extl == FB_BWE ) ) + test(); + test(); + test(); + test(); + test(); + test(); + if ( extl_brate > 0 && ( EQ_16( extl, WB_TBE ) || EQ_16( extl, SWB_TBE ) || EQ_16( extl, FB_TBE ) || EQ_16( extl, WB_BWE ) || EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) ) { /* extension layer signalling bit is counted in the extension layer bitbudget */ - bits++; + bits = add( bits, 1 ); } /*-----------------------------------------------------------------* * LSF Q bit-budget *-----------------------------------------------------------------*/ - - if ( !tdm_lp_reuse_flag || idchan == 0 ) + test(); + test(); + test(); + IF( !tdm_lp_reuse_flag || idchan == 0 ) { /* LSF Q bit-budget */ acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )]; + move16(); - if ( !flag_hardcoded ) + IF( !flag_hardcoded ) { - if ( L_frame == L_FRAME ) + IF( EQ_16( L_frame, L_FRAME ) ) { - if ( element_mode == IVAS_SCE && tdm_low_rate_mode ) + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( element_mode, IVAS_SCE ) && tdm_low_rate_mode ) { acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )]; + move16(); } - else if ( ( total_brate < 7200 || coder_type == INACTIVE || coder_type == AUDIO ) && idchan == 1 ) + ELSE IF( ( LT_32( total_brate, 7200 ) || coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( idchan, 1 ) ) { /* TD stereo, secondary channel: do nothing */ acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )]; + move16(); } - else if ( element_mode > EVS_MONO && coder_type == AUDIO && brate_intermed_tbl[i] < ACELP_9k60 ) + ELSE IF( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) && LT_32( brate_intermed_tbl[i], ACELP_9k60 ) ) { /* primary channel: do nothing */ } - else if ( element_mode > EVS_MONO && coder_type == AUDIO /*&& brate_intermed_tbl[i] >= ACELP_9k60*/ ) + ELSE IF( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) /*&& brate_intermed_tbl[i] >= ACELP_9k60*/ ) { acelp_cfg->lsf_bits = 42; + move16(); } - else if ( total_brate <= 9600 || coder_type == UNVOICED ) + ELSE IF( LE_32( total_brate, 9600 ) || EQ_16( coder_type, UNVOICED ) ) { acelp_cfg->lsf_bits = 31; + move16(); } - else if ( total_brate <= 20000 ) + ELSE IF( LE_32( total_brate, 20000 ) ) { acelp_cfg->lsf_bits = 36; + move16(); } - else + ELSE { acelp_cfg->lsf_bits = 41; + move16(); } } - else /* L_frame == L_FRAME16k */ + ELSE /* L_frame == L_FRAME16k */ { acelp_cfg->lsf_bits = 41; + move16(); } } - bits -= acelp_cfg->lsf_bits; + bits = sub( bits, acelp_cfg->lsf_bits ); /* mid-LSF Q bit-budget */ acelp_cfg->mid_lsf_bits = mid_LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )]; + move16(); - if ( element_mode > EVS_MONO && coder_type == AUDIO /*&& brate_intermed_tbl[i] < ACELP_9k60*/ ) + test(); + if ( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) /*&& brate_intermed_tbl[i] < ACELP_9k60*/ ) { acelp_cfg->mid_lsf_bits = 5; + move16(); /* primary channel: do nothing */ } - bits -= acelp_cfg->mid_lsf_bits; + bits = sub( bits, acelp_cfg->mid_lsf_bits ); } #if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE - else if ( tdm_lp_reuse_flag == 1 && idchan == 1 && active_cnt != 1 ) + ELSE IF( EQ_16( tdm_lp_reuse_flag, 1 ) && EQ_16( idchan, 1 ) && NE_16( active_cnt, 1 ) ) { - bits -= TDM_IC_LSF_PRED_BITS; + bits = sub( bits, TDM_IC_LSF_PRED_BITS ); } #endif /* gain Q bit-budget - part 1 */ - if ( ( coder_type != UNVOICED && coder_type != AUDIO && coder_type != INACTIVE && !( core_brate <= ACELP_8k00 && coder_type != TRANSITION ) ) || ( coder_type == INACTIVE && total_brate > MAX_GSC_INACTIVE_BRATE ) ) + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) || ( coder_type == INACTIVE && GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) ) { *nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, -1 )]; - bits -= *nBits_es_Pred; + move16(); + bits = sub( bits, *nBits_es_Pred ); } - else if ( *uc_two_stage_flag ) + ELSE IF( *uc_two_stage_flag ) { *nBits_es_Pred = 4; - bits -= *nBits_es_Pred; + move16(); + bits = sub( bits, *nBits_es_Pred ); } } - else + ELSE { bits = *unbits; + move16(); } - if ( coder_type == TRANSITION && tc_call == 0 ) + test(); + IF( EQ_16( coder_type, TRANSITION ) && tc_call == 0 ) { *unbits = bits; return error; @@ -855,14 +959,19 @@ ivas_error config_acelp1( /*-----------------------------------------------------------------* * Low-rate mode - bits are allocated in tdm_low_rate_enc() *-----------------------------------------------------------------*/ - - if ( element_mode == IVAS_SCE && tdm_low_rate_mode ) + test(); + IF( EQ_16( element_mode, IVAS_SCE ) && tdm_low_rate_mode ) { acelp_cfg->FEC_mode = 0; acelp_cfg->ltf_mode = FULL_BAND; *nBits_es_Pred = 0; *unbits = 0; acelp_cfg->ubits = 0; + move16(); + move16(); + move16(); + move16(); + move16(); return error; } @@ -872,34 +981,43 @@ ivas_error config_acelp1( *-----------------------------------------------------------------*/ acelp_cfg->FEC_mode = 0; - if ( core_brate >= ACELP_11k60 && ( idchan == 0 || element_mode == EVS_MONO ) ) + move16(); + test(); + test(); + IF( GE_32( core_brate, ACELP_11k60 ) && ( idchan == 0 || element_mode == EVS_MONO ) ) { acelp_cfg->FEC_mode = 1; + move16(); - if ( coder_type > UNVOICED && coder_type < AUDIO && coder_type != VOICED ) + test(); + test(); + if ( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && NE_16( coder_type, VOICED ) ) { - bits -= FEC_BITS_CLS; + bits = sub( bits, FEC_BITS_CLS ); } - if ( coder_type != TRANSITION ) + IF( NE_16( coder_type, TRANSITION ) ) { - if ( total_brate >= ACELP_16k40 ) + IF( GE_32( total_brate, ACELP_16k40 ) ) { acelp_cfg->FEC_mode = 2; - - if ( coder_type > UNVOICED && coder_type < AUDIO ) + move16(); + test(); + if ( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) ) { - bits -= FEC_BITS_ENR; + bits = sub( bits, FEC_BITS_ENR ); } } - if ( total_brate >= ACELP_32k ) + IF( GE_32( total_brate, ACELP_32k ) ) { acelp_cfg->FEC_mode = 3; + move16(); - if ( coder_type > UNVOICED && coder_type < AUDIO ) + test(); + if ( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) ) { - bits -= FEC_BITS_POS; + bits = sub( bits, FEC_BITS_POS ); } } } @@ -908,50 +1026,68 @@ ivas_error config_acelp1( /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation *-----------------------------------------------------------------*/ - - if ( idchan > 0 && element_mode > EVS_MONO ) + test(); + test(); + test(); + test(); + test(); + test(); + IF( idchan > 0 && element_mode > EVS_MONO ) { acelp_cfg->ltf_mode = FULL_BAND; + move16(); } - else if ( coder_type == UNVOICED ) + ELSE IF( EQ_16( coder_type, UNVOICED ) ) { acelp_cfg->ltf_mode = FULL_BAND; + move16(); } - else if ( ( coder_type == GENERIC || coder_type == TRANSITION ) && core_brate < ACELP_11k60 ) + ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) ) && core_brate < ACELP_11k60 ) { acelp_cfg->ltf_mode = LOW_PASS; + move16(); } - else if ( core_brate >= ACELP_11k60 && ( coder_type != AUDIO && !( coder_type == INACTIVE && L_frame == L_FRAME ) ) ) + ELSE IF( GE_32( core_brate, ACELP_11k60 ) && ( NE_16( coder_type, AUDIO ) && !( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME ) ) ) ) { - if ( coder_type == INACTIVE && L_frame == L_FRAME16k && total_brate <= MAX_GSC_INACTIVE_BRATE ) /* GSC Inactive @16kHz */ + test(); + test(); + IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) /* GSC Inactive @16kHz */ { acelp_cfg->ltf_mode = FULL_BAND; + move16(); } - else + ELSE { acelp_cfg->ltf_mode = NORMAL_OPERATION; + move16(); if ( coder_type != TRANSITION ) { - bits -= nb_subfr; + bits = sub( bits, nb_subfr ); } } } - else + ELSE { acelp_cfg->ltf_mode = FULL_BAND; + move16(); } /*-----------------------------------------------------------------* * UC bit-budget *-----------------------------------------------------------------*/ - - if ( ( ( coder_type == UNVOICED && !( *uc_two_stage_flag ) ) || ( coder_type == INACTIVE && core_brate <= ACELP_9k60 ) ) && ( idchan == 0 || element_mode == EVS_MONO ) ) + test(); + test(); + test(); + test(); + test(); + test(); + if ( ( ( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_9k60 ) ) ) && ( idchan == 0 || element_mode == EVS_MONO ) ) { - bits -= NBITS_NOISENESS; /* noiseness */ + bits = sub( bits, NBITS_NOISENESS ); /* noiseness */ } - if ( coder_type == UNVOICED && !( *uc_two_stage_flag ) ) + if ( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) { - bits -= ( 3 * NB_SUBFR ); /* tilt factor */ + bits = sub( bits, 3 * NB_SUBFR ); /* tilt factor */ } /*-----------------------------------------------------------------* @@ -959,108 +1095,110 @@ ivas_error config_acelp1( *-----------------------------------------------------------------*/ fix_first = 0; - if ( coder_type == TRANSITION ) + move16(); + IF( EQ_16( coder_type, TRANSITION ) ) { - if ( tc_call == 2 ) + if ( EQ_16( tc_call, 2 ) ) { fix_first = 1; + move16(); } /* TC signalling */ - if ( L_frame == L_FRAME ) + IF( EQ_16( L_frame, L_FRAME ) ) { - if ( tc_subfr == TC_0_0 ) + IF( EQ_16( tc_subfr, TC_0_0 ) ) { if ( enc_dec == ENC ) { - bits -= 1; /* TC signalling */ + bits = sub( bits, 1 ); /* TC signalling */ } - if ( acelp_cfg->ltf_mode == NORMAL_OPERATION ) + if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) { - bits -= 3; /* LP filtering flag */ + bits = sub( bits, 3 ); /* LP filtering flag */ } } - else if ( tc_subfr == TC_0_64 ) + ELSE IF( EQ_16( tc_subfr, TC_0_64 ) ) { if ( enc_dec == ENC ) { - bits -= 4; /* TC signalling */ + bits = sub( bits, 4 ); /* TC signalling */ } - if ( acelp_cfg->ltf_mode == NORMAL_OPERATION ) + if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) { - bits -= 3; /* LP filtering flag */ + bits = sub( bits, 3 ); /* LP filtering flag */ } } - else if ( tc_subfr == TC_0_128 ) + ELSE IF( EQ_16( tc_subfr, TC_0_128 ) ) { if ( enc_dec == ENC ) { - bits -= 4; /* TC signalling */ + bits = sub( bits, 4 ); /* TC signalling */ } - if ( acelp_cfg->ltf_mode == NORMAL_OPERATION ) + if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) { - bits -= 2; /* LP filtering flag */ + bits = sub( bits, 2 ); /* LP filtering flag */ } } - else if ( tc_subfr == TC_0_192 ) + ELSE IF( EQ_16( tc_subfr, TC_0_192 ) ) { if ( enc_dec == ENC ) { - bits -= 3; /* TC signalling */ + bits = sub( bits, 3 ); /* TC signalling */ } - if ( acelp_cfg->ltf_mode == NORMAL_OPERATION ) + if ( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) { - bits -= 1; /* LP filtering flag */ + bits = sub( bits, 1 ); /* LP filtering flag */ } } - else if ( tc_subfr == L_SUBFR ) + ELSE IF( EQ_16( tc_subfr, L_SUBFR ) ) { if ( enc_dec == ENC ) { - bits -= 3; /* TC signalling */ + bits = sub( bits, 3 ); /* TC signalling */ } - if ( acelp_cfg->ltf_mode == NORMAL_OPERATION ) + IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) { - bits -= ( L_FRAME - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */ + bits = sub( bits, idiv1616( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ } } - else + ELSE { if ( enc_dec == ENC ) { - bits -= 4; /* TC signalling */ + bits = sub( bits, 4 ); /* TC signalling */ } - if ( acelp_cfg->ltf_mode == NORMAL_OPERATION ) + IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) { - bits -= ( L_FRAME - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */ + bits = sub( bits, idiv1616_1( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ } } } - else /* L_frame == L_FRAME16k */ + ELSE /* L_frame == L_FRAME16k */ { - if ( enc_dec == ENC ) + IF( enc_dec == ENC ) { - if ( tc_subfr <= 2 * L_SUBFR ) + IF( LE_16( tc_subfr, 2 * L_SUBFR ) ) { - bits -= 2; /* TC signalling */ + bits = sub( bits, 2 ); /* TC signalling */ } - else + ELSE { - bits -= 3; /* TC signalling */ + bits = sub( bits, 3 ); /* TC signalling */ } } - bits -= ( L_FRAME16k - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */ + bits = sub( bits, idiv1616( sub( L_FRAME16k - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ } /* glottal-shape codebook bits */ - bits -= ( 3 + 6 + 1 + 3 ); + bits = sub( bits, 3 + 6 + 1 + 3 ); } /*-----------------------------------------------------------------* @@ -1068,24 +1206,43 @@ ivas_error config_acelp1( *-----------------------------------------------------------------*/ acelp_cfg->fcb_mode = 0; - - if ( element_mode == IVAS_CPE_TD && tdm_low_rate_mode == 1 && coder_type != INACTIVE && coder_type != UNVOICED ) /* GENERIC low rate mode for secondary channel */ + move16(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( tdm_low_rate_mode, 1 ) && coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) /* GENERIC low rate mode for secondary channel */ { set16_fx( acelp_cfg->pitch_bits, 0, NB_SUBFR16k ); set16_fx( acelp_cfg->gains_mode, 0, NB_SUBFR16k ); - for ( i = 0; i < 2; i++ ) + FOR( i = 0; i < 2; i++ ) { acelp_cfg->pitch_bits[i] = 0; - if ( tdm_Pitch_reuse_flag == 0 ) + move16(); + IF( tdm_Pitch_reuse_flag == 0 ) { - acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, 2 * i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )]; - bits -= acelp_cfg->pitch_bits[i]; + acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i_mult( 2 * L_SUBFR, i ), TC_SUBFR2IDX_fx( tc_subfr ) )]; + move16(); + bits = sub( bits, acelp_cfg->pitch_bits[i] ); } - acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )]; - bits -= acelp_cfg->gains_mode[i]; + acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )]; + bits = sub( bits, acelp_cfg->gains_mode[i] ); } acelp_cfg->fcb_mode = 1; + move16(); #ifdef DEBUGGING if ( bits >= 55 ) @@ -1095,89 +1252,111 @@ ivas_error config_acelp1( } else #endif - if ( bits >= 16 ) - { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); - } - else + IF( GE_16( bits, 16 ) ) + { + acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); + } + ELSE { acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); acelp_cfg->fixed_cdk_index[1] = -1; + move16(); } acelp_cfg->fixed_cdk_index[2] = -1; + move16(); acelp_cfg->fixed_cdk_index[3] = -1; + move16(); } - else if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || ( nb_subfr == NB_SUBFR16k && ( total_brate > MAX_GSC_INACTIVE_BRATE || coder_type != INACTIVE ) ) || core == HQ_CORE ) + ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) || coder_type != INACTIVE ) ) || EQ_16( core, HQ_CORE ) ) { /* pitch Q & gain Q bit-budget - part 2*/ - for ( i = 0; i < nb_subfr; i++ ) + FOR( i = 0; i < nb_subfr; i++ ) { - if ( L_frame == L_FRAME ) + IF( EQ_16( L_frame, L_FRAME ) ) { - if ( tdm_Pitch_reuse_flag == 1 && idchan == 1 ) + IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) ) { acelp_cfg->pitch_bits[i] = 0; + move16(); } - else + ELSE { - acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )]; + acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )]; + move16(); } - acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type_sw, i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )]; + acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type_sw, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )]; + move16(); } - else /* L_frame == L_FRAME16k */ + ELSE /* L_frame == L_FRAME16k */ { - if ( tdm_Pitch_reuse_flag == 1 && idchan == 1 ) + test(); + IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) ) { acelp_cfg->pitch_bits[i] = 0; + move16(); } - else + ELSE { - acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; + acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; + move16(); } - acelp_cfg->gains_mode[i] = gain_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type_sw, i * L_SUBFR, TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; + acelp_cfg->gains_mode[i] = gain_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type_sw, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; + move16(); } - bits -= acelp_cfg->pitch_bits[i]; + bits = sub( bits, acelp_cfg->pitch_bits[i] ); - if ( coder_type == INACTIVE && acelp_cfg->gains_mode[i] == 6 /* VQ vs. SQ threshold @32 kbps */ ) + test(); + IF( coder_type == INACTIVE && EQ_16( acelp_cfg->gains_mode[i], 6 ) /* VQ vs. SQ threshold @32 kbps */ ) { - bits -= 5; + bits = sub( bits, 5 ); } - else + ELSE { - if ( *uc_two_stage_flag == 1 ) + if ( EQ_16( *uc_two_stage_flag, 1 ) ) { acelp_cfg->gains_mode[i] = 7; + move16(); } - bits -= acelp_cfg->gains_mode[i]; + bits = sub( bits, acelp_cfg->gains_mode[i] ); } } /* algebraic codebook bit-budget */ - if ( flag_hardcoded || ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( total_brate > MAX_GSC_INACTIVE_BRATE && coder_type == INACTIVE ) ) + test(); + test(); + test(); + test(); + test(); + test(); + IF( flag_hardcoded || ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) ) { - for ( i = 0; i < nb_subfr; i++ ) + FOR( i = 0; i < nb_subfr; i++ ) { - if ( L_frame == L_FRAME ) + IF( EQ_16( L_frame, L_FRAME ) ) { - acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_fx( tc_subfr ) )]; + acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )]; + move16(); } - else /* L_frame == L_FRAME16k */ + ELSE /* L_frame == L_FRAME16k */ { - acelp_cfg->fixed_cdk_index[i] = FCB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; + acelp_cfg->fixed_cdk_index[i] = FCB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; + move16(); } - bits -= acelp_cfg->fixed_cdk_index[i]; + bits = sub( bits, acelp_cfg->fixed_cdk_index[i] ); } } - else if ( !( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) ) + ELSE IF( !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) ) { - if ( coder_type == UNVOICED && !( *uc_two_stage_flag ) ) + test(); + IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) { - i = bits / NB_SUBFR; + i = idiv1616( bits, NB_SUBFR ); + move16(); if ( i % 2 == 0 ) { - i--; /* must be odd */ + i = sub( i, 1 ); /* must be odd */ } i = s_min( i, 13 ); #ifdef DEBUG_MODE_TD @@ -1186,55 +1365,71 @@ ivas_error config_acelp1( #endif i = s_max( i, 0 ); /* If i == 0-> random noise generator will be used as FCB */ set16_fx( acelp_cfg->fixed_cdk_index, i, NB_SUBFR ); - bits -= ( i * NB_SUBFR ); + bits = sub( bits, i_mult( i, NB_SUBFR ) ); } - else + ELSE { acelp_cfg->fcb_mode = 1; - if ( element_mode == IVAS_CPE_TD ) + move16(); + test(); + test(); + IF( EQ_16( element_mode, IVAS_CPE_TD ) ) { - if ( bits >= ACELP_FIXED_CDK_BITS( 0 ) * ( nb_subfr ) ) /* enough bits for all fcb */ + IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), ( nb_subfr ) ) ) ) /* enough bits for all fcb */ { acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); } - else if ( bits >= ACELP_FIXED_CDK_BITS( 0 ) * ( nb_subfr - 1 ) ) + ELSE IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 1 ) ) ) ) { acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr - 1, L_SUBFR, coder_type, tc_subfr, fix_first ); acelp_cfg->fixed_cdk_index[3] = -1; + move16(); } - else if ( bits >= ACELP_FIXED_CDK_BITS( 0 ) * ( nb_subfr - 2 ) ) + ELSE IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 2 ) ) ) ) { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr - 2, L_SUBFR, coder_type, tc_subfr, fix_first ); + acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first ); acelp_cfg->fixed_cdk_index[2] = acelp_cfg->fixed_cdk_index[1]; + move16(); acelp_cfg->fixed_cdk_index[1] = -1; + move16(); acelp_cfg->fixed_cdk_index[3] = -1; + move16(); } - else if ( bits >= ACELP_FIXED_CDK_BITS( 0 ) ) + ELSE IF( GE_16( bits, ACELP_FIXED_CDK_BITS( 0 ) ) ) { acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first ); acelp_cfg->fixed_cdk_index[1] = acelp_cfg->fixed_cdk_index[0]; + move16(); acelp_cfg->fixed_cdk_index[0] = -1; + move16(); acelp_cfg->fixed_cdk_index[2] = -1; + move16(); acelp_cfg->fixed_cdk_index[3] = -1; + move16(); } - else /* No FCB */ + ELSE /* No FCB */ { #if defined DEBUGGING IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING!!!, No bit allocated to FCB, check frame %d\n" ); #endif acelp_cfg->fixed_cdk_index[0] = -1; + move16(); acelp_cfg->fixed_cdk_index[1] = -1; + move16(); acelp_cfg->fixed_cdk_index[2] = -1; + move16(); acelp_cfg->fixed_cdk_index[3] = -1; + move16(); } } - else if ( element_mode != IVAS_CPE_TD && GSC_IVAS_mode > 0 && L_frame == L_FRAME16k ) + ELSE IF( element_mode != IVAS_CPE_TD && GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) { bits = 100; /* 9 kbps for fcb */ + move16(); acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); } - else + ELSE { acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); } @@ -1242,102 +1437,136 @@ ivas_error config_acelp1( } /* AVQ codebook */ - if ( ( core_brate_inp >= MIN_BRATE_AVQ_EXC && coder_type != INACTIVE ) || ( total_brate > MAX_GSC_INACTIVE_BRATE && coder_type == INACTIVE ) ) + test(); + test(); + test(); + IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) || ( GT_32( total_brate, MAX_GSC_INACTIVE_BRATE ) && coder_type == INACTIVE ) ) { - for ( i = 0; i < nb_subfr; i++ ) + FOR( i = 0; i < nb_subfr; i++ ) { - if ( flag_hardcoded ) + IF( flag_hardcoded ) { - acelp_cfg->AVQ_cdk_bits[i] = AVQ_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i * L_SUBFR, TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; + acelp_cfg->AVQ_cdk_bits[i] = AVQ_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; + move16(); { - bits -= acelp_cfg->AVQ_cdk_bits[i]; + bits = sub( bits, acelp_cfg->AVQ_cdk_bits[i] ); } } - bits -= G_AVQ_BITS; + bits = sub( bits, G_AVQ_BITS ); } - if ( core_brate_inp >= MIN_BRATE_AVQ_EXC && core_brate_inp <= MAX_BRATE_AVQ_EXC_TD && coder_type == GENERIC ) + test(); + test(); + if ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && LE_32( core_brate_inp, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( coder_type, GENERIC ) ) { /* harm. flag ACELP AVQ */ - bits--; + bits = sub( bits, 1 ); } - if ( !flag_hardcoded ) + IF( !flag_hardcoded ) { Word16 bit_tmp; - bit_tmp = bits / nb_subfr; + bit_tmp = idiv1616( bits, nb_subfr ); set16_fx( acelp_cfg->AVQ_cdk_bits, bit_tmp, nb_subfr ); - bits -= bit_tmp * nb_subfr; + bits = sub( bits, i_mult( bit_tmp, nb_subfr ) ); bit_tmp = bits % nb_subfr; - acelp_cfg->AVQ_cdk_bits[0] += bit_tmp; - bits -= bit_tmp; + move16(); + acelp_cfg->AVQ_cdk_bits[0] = add( acelp_cfg->AVQ_cdk_bits[0], bit_tmp ); + move16(); + bits = sub( bits, bit_tmp ); } } } - else if ( ( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) || ( ( coder_type == INACTIVE || coder_type == AUDIO ) && nb_subfr == NB_SUBFR ) || ( coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) ) + ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) || ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) || ( coder_type == INACTIVE && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) ) { Word32 Local_BR, Pitch_BR; Word16 Pitch_CT; /* as defined at the beginning of [enc,dec]_pit_exc() */ - if ( GSC_IVAS_mode > 0 && ( GSC_noisy_speech || core_brate > GSC_H_RATE_STG ) ) + test(); + test(); + IF( GSC_IVAS_mode > 0 && ( GSC_noisy_speech || GT_32( core_brate, GSC_H_RATE_STG ) ) ) { Local_BR = ACELP_8k00; + move32(); Pitch_CT = GENERIC; + move16(); Pitch_BR = ACELP_8k00; - if ( L_frame == L_FRAME16k ) + move32(); + IF( EQ_16( L_frame, L_FRAME16k ) ) { Local_BR = ACELP_14k80; - if ( GSC_IVAS_mode > 0 && core_brate < IVAS_24k4 ) + move32(); + test(); + if ( GSC_IVAS_mode > 0 && LT_32( core_brate, IVAS_24k4 ) ) { Local_BR = ACELP_9k60; + move32(); } Pitch_BR = core_brate; + move32(); } } - else if ( GSC_noisy_speech ) + ELSE IF( GSC_noisy_speech ) { Local_BR = ACELP_7k20; + move32(); Pitch_CT = GENERIC; + move16(); Pitch_BR = ACELP_7k20; - if ( L_frame == L_FRAME16k ) + move32(); + if ( EQ_16( L_frame, L_FRAME16k ) ) { Pitch_BR = core_brate; + move32(); } } - else + ELSE { Local_BR = ACELP_7k20; + move32(); Pitch_CT = AUDIO; + move16(); Pitch_BR = core_brate; + move32(); - if ( L_frame == L_FRAME16k ) + IF( EQ_16( L_frame, L_FRAME16k ) ) { Local_BR = ACELP_13k20; + move32(); Pitch_CT = GENERIC; + move16(); } } - for ( i = 0; i < nb_subfr; i++ ) + FOR( i = 0; i < nb_subfr; i++ ) { - if ( L_frame == L_FRAME16k ) + IF( EQ_16( L_frame, L_FRAME16k ) ) { - acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( Pitch_BR, Pitch_CT, i * L_SUBFR, 0 )]; - acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i * L_SUBFR, 0 )]; + acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( Pitch_BR, Pitch_CT, i_mult( i, L_SUBFR ), 0 )]; + move16(); + acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )]; + move16(); } - else + ELSE { - acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( Pitch_BR, Pitch_CT, i * L_SUBFR, 0 )]; - acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i * L_SUBFR, 0 )]; - acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, LOCAL_CT, i * L_SUBFR, 0 )]; + acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( Pitch_BR, Pitch_CT, i_mult( i, L_SUBFR ), 0 )]; + move16(); + acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )]; + move16(); + acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )]; + move16(); } } } - if ( coder_type == TRANSITION && ( tc_call == 1 && tc_subfr == 0 && L_frame == L_FRAME ) ) + test(); + test(); + test(); + IF( EQ_16( coder_type, TRANSITION ) && ( EQ_16( tc_call, 1 ) && tc_subfr == 0 && EQ_16( L_frame, L_FRAME ) ) ) { return error; } @@ -1347,70 +1576,101 @@ ivas_error config_acelp1( *-----------------------------------------------------------------*/ acelp_cfg->ubits = 0; /* these bits could be reused for something else */ + move16(); - if ( flag_hardcoded && core_brate != PPP_NELP_2k80 ) + test(); + IF( flag_hardcoded && NE_32( core_brate, PPP_NELP_2k80 ) ) { /* unused bits */ - if ( coder_type == AUDIO || ( coder_type == INACTIVE && core_brate <= ACELP_24k40 ) ) + IF( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_24k40 ) ) ) { acelp_cfg->ubits = 0; + move16(); } - else if ( L_frame == L_FRAME ) + ELSE IF( EQ_16( L_frame, L_FRAME ) ) { acelp_cfg->ubits = reserved_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, TC_SUBFR2IDX_fx( tc_subfr ) )]; + move16(); } - else + ELSE { acelp_cfg->ubits = 0; + move16(); } - bits -= acelp_cfg->ubits; + bits = sub( bits, acelp_cfg->ubits ); } /* sanity check */ - if ( ( coder_type != INACTIVE && nb_subfr == NB_SUBFR && coder_type != AUDIO ) || nb_subfr == NB_SUBFR16k ) + test(); + test(); + test(); + IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || EQ_16( nb_subfr, NB_SUBFR16k ) ) { - if ( ( L_frame == L_FRAME16k && coder_type == INACTIVE && total_brate <= MAX_GSC_INACTIVE_BRATE ) || ( GSC_IVAS_mode > 0 && L_frame == L_FRAME16k ) ) /* GSC Inactive @16kHz */ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && LE_32( total_brate, MAX_GSC_INACTIVE_BRATE ) ) || ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* GSC Inactive @16kHz */ { acelp_cfg->ubits = 0; + move16(); } - else if ( flag_hardcoded && core == ACELP_CORE && bits != 0 ) + ELSE IF( flag_hardcoded && core == ACELP_CORE && bits != 0 ) { #if defined DEBUGGING IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits ); #endif } - else if ( bits > 0 && !( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) ) + ELSE IF( bits > 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) ) { - if ( idchan > 0 && element_mode == IVAS_CPE_TD ) + test(); + test(); + test(); + test(); + IF( idchan > 0 && EQ_16( element_mode, IVAS_CPE_TD ) ) { #if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE - if ( !tdm_lp_reuse_flag ) + IF( !tdm_lp_reuse_flag ) { - acelp_cfg->lsf_bits += bits; /* increase LSF Q bits */ + acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */ + move16(); bits = 0; + move16(); } - else + ELSE { Word16 nb_prm = 4; - if ( tdm_low_rate_mode == 1 ) + move16(); + if ( EQ_16( tdm_low_rate_mode, 1 ) ) { nb_prm = 2; + move16(); } /* First add remaining bits on gains */ - bits -= allocate_unused( core_brate, coder_type, bits, nb_prm, 0, GAINSPRM, acelp_cfg->gains_mode ); + bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, GAINSPRM, acelp_cfg->gains_mode ) ); /* Then, Increase pitch bit budget */ - if ( tdm_Pitch_reuse_flag == 0 && bits > 0 ) + test(); + IF( tdm_Pitch_reuse_flag == 0 && bits > 0 ) { - bits -= allocate_unused( core_brate, coder_type, bits, nb_prm, 0, PITCHPRM, acelp_cfg->pitch_bits ); + bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, PITCHPRM, acelp_cfg->pitch_bits ) ); } /* Increase mid-lsf bit budget */ - if ( tdm_lp_reuse_flag == 0 && bits > 0 ) + test(); + IF( tdm_lp_reuse_flag == 0 && bits > 0 ) { - bits -= allocate_unused( core_brate, coder_type, bits, 1, 0, MID_LSFSPRM, &acelp_cfg->mid_lsf_bits ); - bits -= allocate_unused( core_brate, coder_type, bits, 1, 0, LSFPRM, &acelp_cfg->lsf_bits ); + bits = sub( bits, allocate_unused( core_brate, coder_type, bits, 1, 0, MID_LSFSPRM, &acelp_cfg->mid_lsf_bits ) ); + bits = sub( bits, allocate_unused( core_brate, coder_type, bits, 1, 0, LSFPRM, &acelp_cfg->lsf_bits ) ); } } #else @@ -1448,27 +1708,34 @@ ivas_error config_acelp1( #endif } - else if ( core == ACELP_CORE && coder_type >= UNVOICED && coder_type <= GENERIC && L_frame == L_FRAME ) + ELSE IF( core == ACELP_CORE && GE_16( coder_type, UNVOICED ) && LE_16( coder_type, GENERIC ) && EQ_16( L_frame, L_FRAME ) ) { - acelp_cfg->lsf_bits += bits; /* increase LSF Q bits */ + acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */ + move16(); - if ( acelp_cfg->lsf_bits > 46 ) + test(); + IF( GT_16( acelp_cfg->lsf_bits, 46 ) ) { - acelp_cfg->ubits = acelp_cfg->lsf_bits - 46; + acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 46 ); + move16(); acelp_cfg->lsf_bits = 46; + move16(); } - else if ( acelp_cfg->lsf_bits > 42 && L_frame == L_FRAME ) + ELSE IF( GT_16( acelp_cfg->lsf_bits, 42 ) && EQ_16( L_frame, L_FRAME ) ) { - acelp_cfg->ubits = acelp_cfg->lsf_bits - 42; + acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 42 ); + move16(); acelp_cfg->lsf_bits = 42; + move16(); } } - else + ELSE { acelp_cfg->ubits = bits; + move16(); } } - else if ( bits < 0 && !( coder_type == UNVOICED && tdm_low_rate_mode == 1 && element_mode == IVAS_CPE_TD ) ) + ELSE IF( bits < 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) ) { #if defined DEBUGGING IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits ); @@ -1495,75 +1762,92 @@ static Word16 allocate_unused( Word16 *prm_bit_mode ) { 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 ) + IF( prm_type == GAINSPRM ) { max_bit_per_pos = 6; - if ( core_brate > ACELP_8k00 ) + move16(); + IF( GT_32( core_brate, ACELP_8k00 ) ) { max_bit_per_pos = 7; + move16(); } - else if ( coder_type != UNVOICED ) + ELSE IF( NE_16( coder_type, UNVOICED ) ) { - if ( subfr >= 1 ) + IF( GE_16( subfr, 1 ) ) { max_bit_per_pos = 7; + move16(); } - else if ( subfr == 0 ) + ELSE IF( subfr == 0 ) { max_bit_per_pos = 8; + move16(); } } - else if ( coder_type == UNVOICED ) + ELSE IF( EQ_16( coder_type, UNVOICED ) ) { max_bit_per_pos = 9; /* No real limit on UC gain bit budget of the secondary channel */ + move16(); } } - else if ( prm_type == PITCHPRM ) + ELSE IF( EQ_16( prm_type, PITCHPRM ) ) { max_bit_per_pos = 6; - if ( subfr == 0 || subfr == 2 || nb_prm == 2 ) + move16(); + test(); + test(); + if ( subfr == 0 || EQ_16( subfr, 2 ) || EQ_16( nb_prm, 2 ) ) { max_bit_per_pos = 10; + move16(); } - if ( coder_type == UNVOICED ) + if ( EQ_16( coder_type, UNVOICED ) ) { max_bit_per_pos = 0; /* Should not allocate bits in case of unvoiced coder type */ + move16(); } } - else if ( prm_type == MID_LSFSPRM ) + ELSE IF( EQ_16( prm_type, MID_LSFSPRM ) ) { max_bit_per_pos = 5; + move16(); } - else if ( prm_type == LSFPRM ) + ELSE IF( EQ_16( prm_type, LSFPRM ) ) { max_bit_per_pos = 42; + move16(); } - else + ELSE { #ifdef DEBUG_MODE_TD IVAS_ERROR( IVAS_ERR_WRONG_MODE, "unknown mode in bit_alloc.c" ); #endif } - max_bit_per_pos = s_min( unused_bits, max_bit_per_pos - prm_bit_mode[subfr] ); - if ( max_bit_per_pos < 0 ) + max_bit_per_pos = s_min( unused_bits, sub( max_bit_per_pos, prm_bit_mode[subfr] ) ); + test(); + IF( max_bit_per_pos < 0 ) { return 0; } - else if ( max_bit_per_pos >= 0 && subfr == ( nb_prm - 1 ) ) + ELSE IF( max_bit_per_pos >= 0 && EQ_16( subfr, sub( nb_prm, 1 ) ) ) { - prm_bit_mode[subfr] += max_bit_per_pos; + prm_bit_mode[subfr] = add( prm_bit_mode[subfr], max_bit_per_pos ); + move16(); } - else + ELSE { - prm_bit_mode[subfr] += max_bit_per_pos; - bit_added += allocate_unused( core_brate, coder_type, unused_bits - max_bit_per_pos, nb_prm, subfr + 1, prm_type, &prm_bit_mode[0] ); + prm_bit_mode[subfr] = add( prm_bit_mode[subfr], max_bit_per_pos ); + move16(); + bit_added = add( bit_added, allocate_unused( core_brate, coder_type, sub( unused_bits, max_bit_per_pos ), nb_prm, add( subfr, 1 ), prm_type, &prm_bit_mode[0] ) ); } - return bit_added + max_bit_per_pos; + return add( bit_added, max_bit_per_pos ); } @@ -1590,7 +1874,7 @@ Word16 set_ACELP_flag( test(); test(); test(); - IF( EQ_16( element_mode, IVAS_CPE_DFT ) && EQ_16( idchan, 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) ) + IF( EQ_16( element_mode, IVAS_CPE_DFT ) && ( idchan == 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) ) { return 1; } @@ -1599,7 +1883,7 @@ Word16 set_ACELP_flag( test(); test(); test(); - IF( GE_32( element_brate, IVAS_24k4 ) && EQ_16( idchan, 0 ) && ( EQ_16( tdm_LRTD_flag, 0 ) || GT_32( element_brate, IVAS_24k4 ) ) ) + IF( GE_32( element_brate, IVAS_24k4 ) && ( idchan == 0 ) && ( ( tdm_LRTD_flag == 0 ) || GT_32( element_brate, IVAS_24k4 ) ) ) { return 1; } @@ -1722,7 +2006,7 @@ Word16 set_ACELP_flag_IVAS( test(); test(); test(); - IF( EQ_16( element_mode, IVAS_CPE_DFT ) && EQ_16( idchan, 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) ) + IF( EQ_16( element_mode, IVAS_CPE_DFT ) && ( idchan == 0 ) && LE_32( total_brate, SID_2k40 ) && EQ_16( bwidth, WB ) && EQ_16( cng_type, LP_CNG ) ) { return 1; } @@ -1731,7 +2015,7 @@ Word16 set_ACELP_flag_IVAS( test(); test(); test(); - IF( GE_32( element_brate, IVAS_24k4 ) && EQ_16( idchan, 0 ) && ( EQ_16( tdm_LRTD_flag, 0 ) || GT_32( element_brate, IVAS_24k4 ) ) ) + IF( GE_32( element_brate, IVAS_24k4 ) && ( idchan == 0 ) && ( ( tdm_LRTD_flag == 0 ) || GT_32( element_brate, IVAS_24k4 ) ) ) { return 1; } diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 988d51489..9f9159a34 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1947,6 +1947,38 @@ uint16_t get_indice( *-------------------------------------------------------------------*/ /*! r: value of the indice */ +#ifdef IVAS_FLOAT_FIXED +UWord16 get_indice_st( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 pos, /* i : absolute position in the bitstream */ + const Word16 nb_bits /* i : number of bits to quantize the indice */ +) +{ + UWord16 value; + Word16 i; + + assert( nb_bits <= 16 ); + + /* detect corrupted bitstream */ + IF( GT_32( L_deposit_l( add( pos, nb_bits ) ), Mpy_32_32( element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ) ) + { + st->BER_detect = 1; + move16(); + return ( 0 ); + } + + value = 0; + move16(); + FOR( i = 0; i < nb_bits; i++ ) + { + value = shl( value, 1 ); + value = add( value, st->bit_stream[add( pos, i )] ); + } + + return value; +} +#else uint16_t get_indice_st( Decoder_State *st, /* i/o: decoder state structure */ const int32_t element_brate, /* i : element bitrate */ @@ -1975,7 +2007,8 @@ uint16_t get_indice_st( return value; } - +#endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * get_indice_1() * @@ -1999,7 +2032,7 @@ uint16_t get_indice_1( return st->bit_stream[pos]; } - +#endif #define WMC_TOOL_SKIP /*-------------------------------------------------------------------* @@ -2031,15 +2064,24 @@ void reset_indices_enc( * * Reset the buffer of decoder indices *-------------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED void reset_indices_dec( Decoder_State *st ) { st->next_bit_pos = 0; + move16(); return; } +#else +void reset_indices_dec( + Decoder_State *st ) +{ + st->next_bit_pos = 0; + return; +} +#endif /*-------------------------------------------------------------------* * write_indices_to_stream() * @@ -2269,7 +2311,7 @@ ivas_error write_indices_ivas( return error; } - +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * convertSerialToBytestream( ) * @@ -2318,7 +2360,7 @@ void convertBytestreamToSerial( serial[i] = ( bytestream[( i >> 3 )] >> ( 7 - ( i & 7 ) ) ) & 0x1; } } - +#endif /*-------------------------------------------------------------------* * decoder_selectCodec() * @@ -3053,7 +3095,7 @@ ivas_error read_indices( return error; } - +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * get_rfFrameType() * @@ -3471,5 +3513,5 @@ void dtx_read_padding_bits( return; } - +#endif #undef WMC_TOOL_SKIP diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index f10493eea..f7dd3942b 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -121,18 +121,22 @@ static void pack_bit( UWord8 *omask /* i/o: output mask to indicate where in the octet the bit is to be written */ ) { - if ( *omask == 0x80 ) + if ( EQ_16( *omask, 0x80 ) ) { **pt = 0; + move16(); } - if ( bit != 0 ) + IF( bit != 0 ) { - **pt = **pt | *omask; + **pt = (UWord8) s_or( **pt, *omask ); + move16(); } - *omask >>= 1; - if ( *omask == 0 ) + *omask = (UWord8) shr( *omask, 1 ); + move16(); + IF( *omask == 0 ) { *omask = 0x80; + move16(); ( *pt )++; } @@ -151,11 +155,13 @@ static Word16 unpack_bit( { Word16 bit; - bit = ( **pt & *mask ) != 0; - *mask >>= 1; - if ( *mask == 0 ) + bit = s_and( **pt, *mask ) != 0; + *mask = (UWord8) shr( *mask, 1 ); + move16(); + IF( *mask == 0 ) { *mask = 0x80; + move16(); ( *pt )++; } return bit; @@ -212,6 +218,7 @@ Word16 rate2EVSmode( if ( is_amr_wb != NULL ) { *is_amr_wb = 0; + move16(); } switch ( brate ) { @@ -250,6 +257,7 @@ Word16 rate2EVSmode( if ( is_amr_wb != NULL ) { *is_amr_wb = 1; + move16(); } return rate2AMRWB_IOmode( brate ); } @@ -274,6 +282,7 @@ void push_indice_fx( { /* indice with the same name as the previous one */ i = hBstr->next_ind_fx; + move16(); } ELSE { @@ -294,9 +303,11 @@ void push_indice_fx( /* updates */ hBstr->next_ind_fx = add( i, 1 ); + move16(); hBstr->last_ind_fx = id; move16(); hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); + move16(); return; } @@ -319,10 +330,11 @@ void push_next_indice_fx( hBstr->ind_list[hBstr->next_ind_fx].nb_bits = nb_bits; move16(); hBstr->next_ind_fx = add( hBstr->next_ind_fx, 1 ); - + move16(); /* update the total number of bits already written */ hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); + move16(); return; } @@ -375,7 +387,9 @@ void push_next_bits_fx( } } hBstr->next_ind_fx = (Word16) ( ptr - hBstr->ind_list ); + move16(); hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); + move16(); } /*-------------------------------------------------------------------* @@ -397,7 +411,7 @@ UWord16 get_next_indice_fx( /* o : value of the indice */ value = 0; move16(); - nbits_total = (Word16) ( st_fx->total_brate / FRAMES_PER_SEC ); + nbits_total = extract_l( Mpy_32_32( st_fx->total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* detect corrupted bitstream */ IF( GT_16( add( st_fx->next_bit_pos, nb_bits ), nbits_total ) ) { @@ -409,11 +423,12 @@ UWord16 get_next_indice_fx( /* o : value of the indice */ FOR( i = 0; i < nb_bits; i++ ) { value = lshl( value, 1 ); - value = add( value, st_fx->bit_stream[st_fx->next_bit_pos + i] ); + value = add( value, st_fx->bit_stream[add( st_fx->next_bit_pos, i )] ); } /* update the position in the bitstream */ st_fx->next_bit_pos = add( st_fx->next_bit_pos, nb_bits ); + move16(); return value; } @@ -428,7 +443,7 @@ UWord16 get_next_indice_1_fx( /* o : value of the indice * ) { Word16 nbits_total; - nbits_total = (Word16) ( st_fx->total_brate / FRAMES_PER_SEC ); + nbits_total = extract_l( Mpy_32_32( st_fx->total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* detect corrupted bitstream */ test(); test(); @@ -458,6 +473,7 @@ void get_next_indice_tmp_fx( { /* update the position in the bitstream */ st_fx->next_bit_pos = add( st_fx->next_bit_pos, nb_bits ); + move16(); } /*-------------------------------------------------------------------* @@ -490,7 +506,7 @@ UWord16 get_indice_fx( /* o : value of the indice */ FOR( i = 0; i < nb_bits; i++ ) { value = lshl( value, 1 ); - value = add( value, st_fx->bit_stream[pos + i] ); + value = add( value, st_fx->bit_stream[add( pos, i )] ); } return value; @@ -508,7 +524,7 @@ UWord16 get_indice_1_fx( /* o : value of the indice */ ) { Word16 nbits_total; - nbits_total = (Word16) ( st_fx->total_brate / FRAMES_PER_SEC ); + nbits_total = extract_l( Mpy_32_32( st_fx->total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* detect corrupted bitstream */ IF( GT_16( add( pos, 1 ), nbits_total ) ) { @@ -584,57 +600,64 @@ void write_indices_fx( Word32 mask; UWord8 header; Word16 isAmrWb = 0; + move16(); - if ( st_fx->bitstreamformat == G192 ) + IF( st_fx->bitstreamformat == G192 ) { /*-----------------------------------------------------------------* * Encode Sync Header and Frame Length *-----------------------------------------------------------------*/ pt_stream = stream; - for ( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i ) + FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i ) { stream[i] = 0; + move16(); } - *pt_stream++ = (Word16) SYNC_GOOD_FRAME; + *pt_stream++ = SYNC_GOOD_FRAME; + move16(); *pt_stream++ = hBstr->nb_bits_tot; + move16(); /*----------------------------------------------------------------* * Bitstream packing (conversion of individual indices into a serial stream) * Writing the serial stream into file *----------------------------------------------------------------*/ - for ( i = 0; i < MAX_NUM_INDICES; i++ ) + FOR( i = 0; i < MAX_NUM_INDICES; i++ ) { - if ( hBstr->ind_list[i].nb_bits != -1 ) + IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) ) { /* mask from MSB to LSB */ - mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 ); + mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) ); /* write bit by bit */ - for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) + FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) { - if ( hBstr->ind_list[i].value & mask ) + IF( L_and( hBstr->ind_list[i].value, mask ) ) { *pt_stream++ = G192_BIN1; + move16(); } - else + ELSE { *pt_stream++ = G192_BIN0; + move16(); } - mask >>= 1; + mask = L_shr( mask, 1 ); } } } } - else + ELSE { /* Create and write ToC header */ /* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */ - header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot * 50, &isAmrWb ) ); + header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( L_mult0( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) ); + move16(); fwrite( &header, sizeof( UWord8 ), 1, file ); /* Write speech bits */ - fwrite( pFrame, sizeof( UWord8 ), ( pFrame_size + 7 ) >> 3, file ); + fwrite( pFrame, sizeof( UWord8 ), shr( add( pFrame_size, 7 ), 3 ), file ); } /* Clearing of indices */ @@ -645,19 +668,22 @@ void write_indices_fx( } - if ( st_fx->bitstreamformat == G192 ) + IF( st_fx->bitstreamformat == G192 ) { /* write the serial stream into file */ fwrite( stream, sizeof( unsigned short ), 2 + stream[1], file ); } /* reset index pointers */ hBstr->nb_bits_tot = 0; + move16(); hBstr->next_ind_fx = 0; + move16(); hBstr->last_ind_fx = -1; + move16(); return; } - +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * write_indices_buf_fx() * @@ -689,7 +715,7 @@ void write_indices_buf_fx( stream[i] = 0; } //*pt_stream++ = (Word16) SYNC_GOOD_FRAME; - //*pt_stream++ = hBstr->nb_bits_tot_fx; + //*pt_stream++ = hBstr->nb_bits_tot; *num_bits = hBstr->nb_bits_tot; /*----------------------------------------------------------------* @@ -761,7 +787,7 @@ void write_indices_buf_fx( return; } - +#endif /*-------------------------------------------------------------------* * indices_to_serial() * @@ -782,65 +808,74 @@ void indices_to_serial( UWord8 omask = 0x80; UWord8 *pt_pFrame = pFrame; Word16 isAmrWb = 0; + move16(); + move16(); + move16(); + move16(); - if ( st_fx->Opt_AMR_WB ) + IF( st_fx->Opt_AMR_WB ) { cmi = rate2EVSmode( st_fx->total_brate, &isAmrWb ); - core_mode = rate2EVSmode( hBstr->nb_bits_tot * 50, &isAmrWb ); + core_mode = rate2EVSmode( L_mult0( hBstr->nb_bits_tot, 50 ), &isAmrWb ); j = 0; - for ( i = 0; i < MAX_NUM_INDICES; i++ ) + move16(); + FOR( i = 0; i < MAX_NUM_INDICES; i++ ) { - if ( hBstr->ind_list[i].nb_bits != -1 ) + IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) ) { /* mask from MSB to LSB */ - mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 ); + mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) ); /* temporarily save bit */ - for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) + FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) { - amrwb_bits[j++] = ( hBstr->ind_list[i].value & mask ) > 0; - mask >>= 1; + amrwb_bits[j++] = L_and( hBstr->ind_list[i].value, mask ) > 0; + move16(); + mask = L_shr( mask, 1 ); } } } } *pFrame_size = hBstr->nb_bits_tot; + move16(); /*----------------------------------------------------------------* * Bitstream packing (conversion of individual indices into a serial stream) *----------------------------------------------------------------*/ j = 0; - for ( i = 0; i < MAX_NUM_INDICES; i++ ) + move16(); + FOR( i = 0; i < MAX_NUM_INDICES; i++ ) { - if ( hBstr->ind_list[i].nb_bits != -1 ) + IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) ) { /* mask from MSB to LSB */ - mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 ); + mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) ); /* write bit by bit */ - for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) + FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) { - if ( st_fx->Opt_AMR_WB ) + IF( st_fx->Opt_AMR_WB ) { pack_bit( amrwb_bits[sort_ptr[core_mode][j++]], &pt_pFrame, &omask ); } - else + ELSE { pack_bit( hBstr->ind_list[i].value & mask, &pt_pFrame, &omask ); - j++; + j = add( j, 1 ); } - mask >>= 1; + mask = L_shr( mask, 1 ); } } } - if ( st_fx->Opt_AMR_WB && core_mode == AMRWB_IO_SID ) /* SID UPD frame always written now .... */ + test(); + IF( st_fx->Opt_AMR_WB && EQ_16( core_mode, AMRWB_IO_SID ) ) /* SID UPD frame always written now .... */ { /* insert STI bit and CMI */ pack_bit( 1, &pt_pFrame, &omask ); - for ( mask = 0x08; mask > 0; mask >>= 1 ) + FOR( mask = 0x08; mask > 0; mask >>= 1 ) { pack_bit( cmi & mask, &pt_pFrame, &omask ); } @@ -869,7 +904,8 @@ void indices_to_serial_generic( nb_bits_tot = 0; move16(); - omask = ( 0x80 >> ( *pFrame_size & 0x7 ) ); + omask = (UWord8) shr( 0x80, s_and( *pFrame_size, 0x7 ) ); + move16(); pt_pFrame += shr( *pFrame_size, 3 ); /*----------------------------------------------------------------* @@ -877,27 +913,26 @@ void indices_to_serial_generic( *----------------------------------------------------------------*/ j = 0; move16(); - for ( i = 0; i < num_indices; i++ ) - { - if ( ind_list[i].nb_bits != -1 ) - { + FOR( i = 0; i < num_indices; i++ ){ + IF( NE_16( ind_list[i].nb_bits, -1 ) ){ /* mask from MSB to LSB */ - mask = 1 << ( ind_list[i].nb_bits - 1 ); + mask = L_shl( 1, sub( ind_list[i].nb_bits, 1 ) ); - /* write bit by bit */ - for ( k = 0; k < ind_list[i].nb_bits; k++ ) - { - pack_bit( ind_list[i].value & mask, &pt_pFrame, &omask ); - j++; - mask >>= 1; - } - nb_bits_tot = add( nb_bits_tot, ind_list[i].nb_bits ); - } + /* write bit by bit */ + FOR( k = 0; k < ind_list[i].nb_bits; k++ ) + { + pack_bit( ind_list[i].value & mask, &pt_pFrame, &omask ); + j++; + mask = L_shr( mask, 1 ); } + nb_bits_tot = add( nb_bits_tot, ind_list[i].nb_bits ); +} +} - *pFrame_size = add( *pFrame_size, nb_bits_tot ); +*pFrame_size = add( *pFrame_size, nb_bits_tot ); +move16(); - return; +return; } @@ -924,7 +959,7 @@ static void decoder_selectCodec( st->Opt_AMR_WB = 1; move16(); } - ELSE IF( NE_32( total_brate, FRAME_NO_DATA ) ) + ELSE IF( total_brate != FRAME_NO_DATA ) { st->Opt_AMR_WB = 0; move16(); @@ -1008,7 +1043,7 @@ static void decoder_selectCodec( IF( st->ini_frame == 0 ) { - IF( EQ_16( st->codec_mode, -1 ) ) + if ( EQ_16( st->codec_mode, -1 ) ) { st->codec_mode = MODE1; move16(); @@ -1020,7 +1055,7 @@ static void decoder_selectCodec( /* set SID/CNG type */ IF( EQ_32( total_brate, SID_2k40 ) ) { - IF( bit0 == G192_BIN0 ) + IF( EQ_16( bit0, G192_BIN0 ) ) { st->cng_type = LP_CNG; move16(); @@ -1032,6 +1067,7 @@ static void decoder_selectCodec( ELSE { st->cng_type = FD_CNG; + move16(); test(); if ( EQ_16( st->last_codec_mode, MODE2 ) && EQ_32( st->last_total_brate, 13200 ) ) { @@ -1040,6 +1076,7 @@ static void decoder_selectCodec( } } st->hTdCngDec->last_cng_type_fx = st->cng_type; /* CNG type switching at the first correctly received SID frame */ + move16(); } @@ -1058,7 +1095,7 @@ void dec_prm_core( Decoder_State *st ) st->core = -1; move16(); - IF( EQ_32( st->total_brate, FRAME_NO_DATA ) ) + IF( st->total_brate == FRAME_NO_DATA ) { st->m_frame_type = ZERO_FRAME; move16(); @@ -1087,10 +1124,12 @@ void dec_prm_core( Decoder_State *st ) /* Get bandwidth mode */ st->bwidth = get_next_indice( st, FrameSizeConfig[frame_size_index].bandwidth_bits ); + move16(); st->bwidth = add( st->bwidth, FrameSizeConfig[frame_size_index].bandwidth_min ); + move16(); - if ( GT_16( st->bwidth, FB ) ) + IF( GT_16( st->bwidth, FB ) ) { st->bwidth = FB; move16(); @@ -1098,7 +1137,8 @@ void dec_prm_core( Decoder_State *st ) move16(); } - if ( GT_16( st->bwidth, SWB ) && LT_32( st->total_brate, ACELP_16k40 ) ) + test(); + IF( GT_16( st->bwidth, SWB ) && LT_32( st->total_brate, ACELP_16k40 ) ) { st->bwidth = SWB; move16(); @@ -1150,7 +1190,7 @@ void decision_matrix_core_dec( move16(); test(); - IF( EQ_32( st->total_brate, FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) ) + IF( ( st->total_brate == FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) ) { st->core = ACELP_CORE; move16(); @@ -1177,6 +1217,7 @@ void decision_matrix_core_dec( { /* read the ACELP/HQ core selection bit */ st->core = imult1616( get_next_indice( st, 1 ), HQ_CORE ); + move16(); } ELSE { @@ -1188,7 +1229,7 @@ void decision_matrix_core_dec( * Read ACELP signalling bits from the bitstream *-----------------------------------------------------------------*/ - IF( EQ_16( st->core, ACELP_CORE ) ) + IF( st->core == ACELP_CORE ) { /* find the section in the ACELP signalling table corresponding to bitrate */ start_idx = 0; @@ -1208,6 +1249,7 @@ void decision_matrix_core_dec( /* retrieve the signalling indice */ ind = acelp_sig_tbl[add( start_idx, get_next_indice( st, nBits ) )]; st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7 ) ); + move16(); /* convert signalling indice into signalling information */ if ( EQ_32( L_and( ind, 0x7 ), LR_MDCT ) ) @@ -1360,7 +1402,7 @@ static void mdct_switching_dec( /* Rewind bitstream */ st->next_bit_pos = next_bit_pos_save; move16(); - IF( st->bfi != 0 ) + if ( st->bfi != 0 ) { st->core = core_save; move16(); @@ -1418,6 +1460,7 @@ Word16 BRATE2IDX16k_fx( Word32 brate ) if ( EQ_32( brate, ACELP_16k40 ) ) { brate = ACELP_14k80; + move16(); } /* This is a Fast Bit Rate Value to Index Value Binary Search */ @@ -1449,8 +1492,8 @@ Word32 BIT_ALLOC_IDX_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ) temp = BRATE2IDX_fx( brate ); L_temp = L_mac0( L_temp, 4 * 256, temp ); - if ( tc >= 0 ) - L_temp = L_mac0( L_temp, ( 10 - 4 ) * 256, temp ); + IF( tc >= 0 ) + L_temp = L_mac0( L_temp, ( 10 - 4 ) * 256, temp ); /* So either 'temp' x 4 when 'tc < 0', 'temp' x 10 otherwise */ L_temp = L_mac0( L_temp, 1 * 256, s_max( 0, tc ) ); @@ -1480,8 +1523,8 @@ Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 t temp = BRATE2IDX16k_fx( brate ); L_temp = L_mac0( L_temp, 3, temp ); - if ( tc >= 0 ) - L_temp = L_mac0( L_temp, ( 7 - 3 ), temp ); + IF( tc >= 0 ) + L_temp = L_mac0( L_temp, ( 7 - 3 ), temp ); /* So either 'temp' x 3 when 'tc < 0', 'temp' x 7 otherwise */ L_temp = L_mac0( L_temp, 1, s_max( 0, tc ) ); @@ -1521,25 +1564,29 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem Word16 num_bits_read; st->bfi = 0; + move16(); st->BER_detect = 0; + move16(); st->mdct_sw_enable = 0; + move16(); st->mdct_sw = 0; + move16(); reset_indices_dec_fx( st ); /* read the Sync Header field from the bitstream */ /* in case rew_flag is set, read until first good frame is encountered */ - do + DO { /* read the Sync header */ - if ( fread( &utmp, sizeof( unsigned short ), 1, file ) != 1 ) + IF( NE_32( fread( &utmp, sizeof( unsigned short ), 1, file ), 1 ) ) { - if ( ferror( file ) ) + IF( ferror( file ) ) { /* error during reading */ fprintf( stderr, "\nError reading the bitstream !" ); exit( -1 ); } - else + ELSE { /* end of file reached */ return 0; @@ -1547,39 +1594,39 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem } /* set the BFI indicator according the value of Sync Header */ - if ( EQ_16( utmp, SYNC_BAD_FRAME ) ) + IF( EQ_16( utmp, SYNC_BAD_FRAME ) ) { st->bfi = 1; + move16(); } - - - else + ELSE { st->bfi = 0; + move16(); } /* read the Frame Length field from the bitstream */ - if ( fread( &num_bits, sizeof( unsigned short ), 1, file ) != 1 ) + IF( NE_32( fread( &num_bits, sizeof( unsigned short ), 1, file ), 1 ) ) { - if ( ferror( file ) ) + IF( ferror( file ) ) { /* error during reading */ fprintf( stderr, "\nError reading the bitstream !" ); exit( -1 ); } - else + ELSE { /* end of file reached */ return 0; } } /* convert the frame length to total bitrate */ - total_brate = (long) ( num_bits * 50 ); + total_brate = L_mult0( num_bits, 50 ); /* read ITU-T G.192 serial stream of indices from file to the local buffer */ /* Validate that the G.192 length is within the defined bit rate range to not allow writing past the end of the "stream" buffer */ - if ( num_bits > MAX_BITS_PER_FRAME ) + IF( GT_16( num_bits, MAX_BITS_PER_FRAME ) ) { fprintf( stderr, "\nError, too large G.192 frame (size(%d))! Exiting ! \n", num_bits ); exit( -1 ); @@ -1587,7 +1634,7 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem /* verify that a valid num bits value is present in the G.192 file */ /* only AMRWB or EVS bit rates or 0(NO DATA) are allowed in G.192 file frame reading */ - if ( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ + IF( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ { fprintf( stderr, "\nError, illegal bit rate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); exit( -1 ); @@ -1595,63 +1642,77 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem pt_stream = stream; num_bits_read = (Word16) fread( pt_stream, sizeof( unsigned short ), num_bits, file ); + move16(); - if ( num_bits_read != num_bits ) + IF( NE_16( num_bits_read, num_bits ) ) { fprintf( stderr, "\nError, invalid number of bits read ! Exiting ! \n" ); exit( -1 ); } - - } while ( rew_flag && ( st->bfi || LT_32( total_brate, 2800 ) ) ); + test(); + } + WHILE( rew_flag && ( st->bfi || LT_32( total_brate, 2800 ) ) ); /* G.192 RX DTX handler*/ - if ( !rew_flag ) + IF( !rew_flag ) { /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */ /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */ curr_ft_good_sp = 0; + move16(); curr_ft_bad_sp = 0; + move16(); - if ( total_brate > SID_2k40 ) + IF( GT_32( total_brate, SID_2k40 ) ) { - if ( st->bfi == 0 ) + IF( st->bfi == 0 ) { curr_ft_good_sp = 1; + move16(); } - else + ELSE { curr_ft_bad_sp = 1; + move16(); } } sid_update = 0; + move16(); sid_upd_bad = 0; + move16(); - if ( total_brate == SID_1k75 || total_brate == SID_2k40 ) + test(); + IF( total_brate == SID_1k75 || total_brate == SID_2k40 ) { - if ( st->bfi == 0 ) + IF( st->bfi == 0 ) { sid_update = 1; + move16(); } - else + ELSE { sid_upd_bad = 1; /* may happen in CS , corrupt but detected sid frame */ + move16(); } } /* all zero indeces/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */ /* all zero indeces/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */ - if ( total_brate == SID_1k75 && sid_update == 1 ) + test(); + IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) ) { /* valid sid_update received, check for very risky but formally valid content */ Word16 sum = 0; - for ( k = 0; k < num_bits; ++k ) + move16(); + FOR( k = 0; k < num_bits; ++k ) { - sum += ( pt_stream[k] == G192_BIN1 ); /* check of 35 zeroes, 35 ones */ + sum = add( sum, extract_l( EQ_16( pt_stream[k], G192_BIN1 ) ) ); /* check of 35 zeroes, 35 ones */ } if ( sum == 0 ) { /* all zeros */ sid_upd_bad = 1; /* initial signal as corrupt (BER likley) */ + move16(); } } @@ -1662,14 +1723,21 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR . */ - if ( sid_upd_bad ) + IF( sid_upd_bad ) { sid_upd_bad = 0; + move16(); total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */ + move32(); } g192_sid_first = 0; - if ( st->core == AMR_WB_CORE && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi == 0 ) + move16(); + + test(); + test(); + test(); + if ( EQ_16( st->core, AMR_WB_CORE ) && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi == 0 ) { g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */ /* @@ -1678,43 +1746,58 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO, , due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding */ + move16(); } speech_bad = 0; - if ( total_brate > SID_2k40 && st->bfi != 0 ) /* CS-type of CRC failure frame */ + move16(); + + test(); + if ( GT_32( total_brate, SID_2k40 ) && st->bfi != 0 ) /* CS-type of CRC failure frame */ { speech_bad = 1; /* initial assumption, CNG_state decides what to do */ + move16(); } speech_lost = 0; + move16(); + + test(); if ( total_brate == 0 && st->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ { speech_lost = 1; /* initial assumption, CNG_state decides what to do */ + move16(); } /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame as this frame was never transmitted, one can not know it is good and has a a length of zero ) */ - if ( st->CNG_fx != 0 ) + IF( st->CNG_fx != 0 ) { /* We were in CNG synthesis */ if ( curr_ft_good_sp != 0 ) { /* only a good speech frame makes you leave CNG synthesis */ st->CNG_fx = 0; + move16(); } } - else + ELSE { /* We were in SPEECH synthesis */ /* only a received SID frame can make the decoder enter into CNG synthsis */ + test(); + test(); if ( g192_sid_first || sid_update || sid_upd_bad ) { st->CNG_fx = 1; + move16(); } } /* handle the g.192 _simulated_ untransmitted frame, setting for decoder SPEECH synthesis */ + test(); + test(); if ( ( st->CNG_fx == 0 ) && ( total_brate == 0 && st->bfi == 0 ) ) { st->bfi = 1; @@ -1723,14 +1806,21 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem } /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ + test(); + test(); + test(); if ( ( ( st->CNG_fx != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { st->bfi = 0; + move16(); total_brate = 0; + move32(); } /* update for next frame's G.192 file format's SID_FIRST detection (primarily for AMRWBIO) */ + test(); st->prev_ft_speech_fx = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) ); + move16(); /* st->total brate= total_brate ; updated in a good frame below */ } /* rew_flag */ @@ -1739,7 +1829,8 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem #ifdef DEBUGGING st->bfi |= file_read_FECpattern(); #endif - if ( st->bfi == 0 && !rew_flag ) + test(); + IF( st->bfi == 0 && !rew_flag ) { /* select MODE1 or MODE2 */ decoder_selectCodec( st, total_brate, *pt_stream ); @@ -1747,10 +1838,11 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem Mpy_32_16_ss( total_brate, 5243, &L_tmp, &utmp ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ st->total_num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ + move16(); /* in case rew_flag is set, rewind the file and return */ /* (used in io_enc() to print out info about technologies and to initialize the codec) */ - if ( rew_flag ) + IF( rew_flag ) { rewind( file ); st->total_brate = total_brate; @@ -1759,24 +1851,27 @@ Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem } /* GOOD frame */ - if ( st->bfi == 0 ) + IF( st->bfi == 0 ) { /* GOOD frame - convert ITU-T G.192 words to short values */ bit_stream_ptr = st->bit_stream; - for ( k = 0; k < num_bits; ++k ) + FOR( k = 0; k < num_bits; ++k ) { - *bit_stream_ptr++ = ( *pt_stream++ == G192_BIN1 ); + *bit_stream_ptr++ = (UWord16) EQ_32( *pt_stream++, G192_BIN1 ); + move16(); } /*add two zero bytes for arithmetic coder flush*/ - for ( k = 0; k < 2 * 8; ++k ) + FOR( k = 0; k < 2 * 8; ++k ) { *bit_stream_ptr++ = 0; + move16(); } /*a change of the total bitrate should not be known to the decoder, if the received frame was lost*/ st->total_brate = total_brate; + move32(); mdct_switching_dec( st ); } @@ -1815,87 +1910,115 @@ static Word32 read_indices_mime_handle_dtx( Word16 speech_bad = 0; Word16 sid_upd_bad = 0, sid_update = 0; Word16 amrwb_sid_first = 0; /* derived from sti SID_FIRST indicator in AMRWB payload */ + move16(); + move16(); + move16(); + move16(); + move16(); /* keep st->CNG , st_bfi and total_brate updated for proper synthesis in DTX and FER */ - if ( GT_32( total_brate, SID_2k40 ) ) + IF( GT_32( total_brate, SID_2k40 ) ) { - if ( st->bfi != 1 ) /* so far derived from q bit in AMRWB/AMRWBIO cases */ + if ( NE_16( st->bfi, 1 ) ) /* so far derived from q bit in AMRWB/AMRWBIO cases */ { curr_ft_good_sp = 1; + move16(); } } /* handle q_bit and lost_sp clash , assume worst case */ - if ( speech_lost != 0 ) /* overrides a good q_bit */ + IF( speech_lost != 0 ) /* overrides a good q_bit */ { curr_ft_good_sp = 0; + move16(); st->bfi = 1; /* override qbit */ + move16(); } /* now_bfi_fx has been set based on q_bit and ToC fields */ /* SID_UPDATE check */ - if ( total_brate == SID_1k75 || total_brate == SID_2k40 ) + test(); + IF( total_brate == SID_1k75 || total_brate == SID_2k40 ) { - if ( st->bfi == 0 ) + IF( st->bfi == 0 ) { /* typically from q bit */ sid_update = 1; + move16(); } - else + ELSE { sid_upd_bad = 1; /* may happen in saving from e.g. a CS-connection */ + move16(); } } - if ( isAMRWB_IOmode && total_brate == 0 && sti == 0 ) + test(); + test(); + IF( isAMRWB_IOmode && total_brate == 0 && sti == 0 ) { - if ( st->bfi ) + IF( st->bfi ) { sid_upd_bad = 1; /* corrupt sid_first, signaled as bad sid */ + move16(); } - else + ELSE { amrwb_sid_first = 1; /* 1-sti */ + move16(); } } - if ( sid_upd_bad != 0 && ( ( isAMRWB_IOmode != 0 && st->Opt_AMR_WB == 0 ) || /* switch to AMRWBIO */ - ( isAMRWB_IOmode != 1 && st->Opt_AMR_WB == 1 ) /* switch from AMRWBIO */ - ) ) + test(); + test(); + test(); + test(); + IF( sid_upd_bad != 0 && ( ( isAMRWB_IOmode != 0 && st->Opt_AMR_WB == 0 ) || /* switch to AMRWBIO */ + ( NE_16( isAMRWB_IOmode, 1 ) && EQ_16( st->Opt_AMR_WB, 1 ) ) /* switch from AMRWBIO */ + ) ) { /* do not allow a normal start of CNG synthesis if this SID(with BER or FER) is a switch to/from AMRWBIO */ sid_upd_bad = 0; /* revert this detection due to AMRWBIO/EVS mode switch */ + move16(); total_brate = 0; + move32(); no_data = 1; + move16(); assert( st->bfi == 1 ); /* bfi stays 1 */ } - if ( GT_32( total_brate, SID_2k40 ) && st->bfi == 1 ) /* typically from q bit */ + test(); + if ( GT_32( total_brate, SID_2k40 ) && EQ_16( st->bfi, 1 ) ) /* typically from q bit */ { speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */ + move16(); } /* all frame types decoded */ /* update CNG synthesis state */ /* Decoder can only enter CNG-synthesis for CNG frame types (sid_upd, sid_bad, sid_first) */ - if ( st->CNG_fx != 0 ) + IF( st->CNG_fx != 0 ) { /* We were in CNG synthesis */ if ( curr_ft_good_sp != 0 ) { /* only a good speech frame makes decoder leave CNG synthesis */ st->CNG_fx = 0; + move16(); } } - else + ELSE { /* We were in SPEECH synthesis */ /* only a received SID frame can make the decoder enter into CNG synthesis */ + test(); + test(); if ( amrwb_sid_first || sid_update || sid_upd_bad ) { st->CNG_fx = 1; + move16(); } } @@ -1903,20 +2026,28 @@ static Word32 read_indices_mime_handle_dtx( /* in SPEECH synthesis, make sure to activate speech plc for a received no_data frame, no_data frames may be injected by the network or by the dejitter buffer */ /* modify bfi_flag to stay/move into the correct decoder PLC section */ + test(); if ( ( st->CNG_fx == 0 ) && ( no_data != 0 ) ) { /* treat no_data received in speech synthesis as SP_LOST frames, SPEECH PLC code will now become active */ st->bfi = 1; + move16(); /* total_brate= 0; always zero for no_data */ } /* in CNG */ /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ - if ( ( st->CNG_fx != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ - sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */ + test(); + test(); + test(); + test(); + IF( ( st->CNG_fx != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ + sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */ { - st->bfi = 0; /* mark as good to not start speech PLC */ + st->bfi = 0; /* mark as good to not start speech PLC */ + move16(); total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */ + move32(); } @@ -1929,22 +2060,33 @@ static Word32 read_indices_mime_handle_dtx( /* handle available AMRWB/AMRWBIO MIME header ToC rate-info at startup */ - if ( ( st->bfi == 1 && st->ini_frame == 0 ) && - ( ( st->amrwb_rfc4867_flag != 0 ) || ( st->amrwb_rfc4867_flag == 0 && isAMRWB_IOmode != 0 ) ) ) /*AMRWB ToC */ + test(); + test(); + test(); + test(); + IF( ( EQ_16( st->bfi, 1 ) && st->ini_frame == 0 ) && + ( ( st->amrwb_rfc4867_flag != 0 ) || ( st->amrwb_rfc4867_flag == 0 && isAMRWB_IOmode != 0 ) ) ) /*AMRWB ToC */ { Word32 init_rate; init_rate = total_brate; /* default , may have been modified from original ToC value */ - if ( speech_lost != 0 || no_data != 0 ) + move32(); + + test(); + IF( speech_lost != 0 || no_data != 0 ) { init_rate = ACELP_12k65; /* make sure the decoder starts up in a selected AMRWB mode */ + move32(); } - else if ( speech_bad != 0 ) + ELSE IF( speech_bad != 0 ) { init_rate = AMRWB_IOmode2rate[core_mode]; /* read from from ToC */ + move32(); } st->total_brate = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */ + move32(); st->core_brate = init_rate; + move32(); } return total_brate; @@ -1964,27 +2106,31 @@ static void read_indices_mime_handle_sti_and_all_zero_bits( { Word16 k; - if ( sti == 0 ) + IF( sti == 0 ) { *total_brate = 0; /* signal received SID_FIRST as a good frame with no bits */ - for ( k = 0; k < 35; k++ ) + move32(); + FOR( k = 0; k < 35; k++ ) { - st->bfi |= st->bit_stream[k]; /* partity check of 35 zeroes, any single 1 gives BFI */ + st->bfi = s_or( st->bfi, st->bit_stream[k] ); /* partity check of 35 zeroes, any single 1 gives BFI */ + move16(); } } /* all zero bit SID_update results in a valid LP filter with extremely high LP-filter-gain */ /* all zero bits signal may be a result of CS bit errors or erronesouly injected by gateways or bad dejitter handlers */ - if ( sti == 1 ) + IF( EQ_16( sti, 1 ) ) { /*sid_update received */ Word16 sum = 0; - for ( k = 0; k < 35; k++ ) + move16(); + FOR( k = 0; k < 35; k++ ) { - sum += st->bit_stream[k]; /* check of 35 zeroes */ + sum = add( sum, st->bit_stream[k] ); /* check of 35 zeroes */ } if ( sum == 0 ) { st->bfi = 1; /* eventually becomes SID_UPD_BAD */ + move16(); } } } @@ -2015,22 +2161,31 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem Word16 speech_lost = 0, no_data = 0; Word16 num_bytes_read; + move16(); + move16(); + move16(); + move16(); + st->BER_detect = 0; + move16(); st->bfi = 0; + move16(); st->mdct_sw_enable = 0; + move16(); st->mdct_sw = 0; + move16(); reset_indices_dec_fx( st ); /* read the FT Header field from the bitstream */ - if ( fread( &header, sizeof( UWord8 ), 1, file ) != 1 ) + IF( NE_32( fread( &header, sizeof( UWord8 ), 1, file ), 1 ) ) { - if ( ferror( file ) ) + IF( ferror( file ) ) { /* error during reading */ fprintf( stderr, "\nError reading the bitstream !" ); exit( -1 ); } - else + ELSE { /* end of file reached */ return 0; @@ -2039,8 +2194,9 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem /* init local RXDTX flags */ sti = -1; + move16(); - if ( st->amrwb_rfc4867_flag != 0 ) + IF( st->amrwb_rfc4867_flag != 0 ) { /* RFC 4867 5.3 .... @@ -2054,12 +2210,16 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem Section 4.3.2. The P bits are padding and MUST be set to 0, and MUST be ignored. */ isAMRWB_IOmode = 1; - qbit = ( header >> 2 ) & 0x01; /* b2 bit (b7 is the F bit ) */ + move16(); + qbit = s_and( shr( header, 2 ), 0x01 ); /* b2 bit (b7 is the F bit ) */ + move16(); st->bfi = !qbit; - core_mode = ( ( header >> 3 ) & 0x0F ); /* b6..b3 */ - total_brate = AMRWB_IOmode2rate[core_mode]; /* get the frame length from the header */ + move16(); + core_mode = s_and( shr( header, 3 ), 0x0F ); /* b6..b3 */ + total_brate = AMRWB_IOmode2rate[core_mode]; /* get the frame length from the header */ + move32(); } - else + ELSE { /*0 1 2 3 4 5 6 7 MS-bit ---> LS-bit +-+-+-+-+-+-+-+-+ @@ -2071,40 +2231,47 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem x is the q-bit if E=1, q==1(good), Q==0(bad, maybe bit errors in payload ) H,F always 0 in RTP format. */ - isAMRWB_IOmode = ( header & 0x20 ) > 0; /* get EVS mode-from header */ /* b2 */ - core_mode = ( header & 0x0F ); /* b4,b5,b6,b7 */ + isAMRWB_IOmode = extract_l( GT_16( s_and( header, 0x20 ), 0 ) ); /* get EVS mode-from header */ /* b2 */ + core_mode = s_and( header, 0x0F ); /* b4,b5,b6,b7 */ - if ( isAMRWB_IOmode ) + IF( isAMRWB_IOmode ) { - qbit = ( header & 0x10 ) > 0; /* get Q bit, valid for IO rates */ /* b3 */ + qbit = extract_l( GT_16( s_and( header, 0x10 ), 0 ) ); /* get Q bit, valid for IO rates */ /* b3 */ total_brate = AMRWB_IOmode2rate[core_mode]; + move32(); } - else + ELSE { qbit = 1; /* assume good q_bit for the unused EVS-mode bit, complete ToC validity checked later */ + move16(); total_brate = PRIMARYmode2rate[core_mode]; + move32(); } st->bfi = !qbit; + move16(); } /* set up RX-DTX-handler input */ - if ( core_mode == 14 ) + if ( EQ_16( core_mode, 14 ) ) { /* SP_LOST */ speech_lost = 1; + move16(); } - if ( core_mode == 15 ) + if ( EQ_16( core_mode, 15 ) ) { /* NO_DATA unsent CNG frame OR any frame marked or injected as no_data by e.g a signaling layer or dejitter buffer */ no_data = 1; + move16(); } Mpy_32_16_ss( total_brate, 5243, &L_tmp, &utmp ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ st->total_num_bits = num_bits; + move16(); - if ( total_brate < 0 ) + IF( total_brate < 0 ) { /* validate that total_brate (derived from RTP packet or a file header) is one of the defined bit rates */ fprintf( stderr, "\n Error. Illegal total bit rate (= %d) in MIME ToC header \n", total_brate ); @@ -2112,26 +2279,33 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem } /* Check correctness of ToC headers */ - if ( st->amrwb_rfc4867_flag == 0 ) + IF( st->amrwb_rfc4867_flag == 0 ) { /* EVS ToC header (FT field(b2-b7), H bit (b0), F bit (b1) , (EVS-modebit(b2)=0 unused(Qbit)(b3)==0) */ - if ( ( isAMRWB_IOmode == 0 ) && ( ( num_bits < 0 ) || ( ( header & 0x80 ) > 0 ) || ( ( header & 0x40 ) > 0 ) || ( header & 0x30 ) != 0x00 ) ) + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( isAMRWB_IOmode == 0 ) && ( ( num_bits < 0 ) || ( s_and( header, 0x80 ) > 0 ) || ( s_and( header, 0x40 ) > 0 ) || s_and( header, 0x30 ) != 0x00 ) ) { /* incorrect FT header */ fprintf( stderr, "\nError in EVS FT ToC header(%02x) ! ", header ); exit( -1 ); } - else if ( ( isAMRWB_IOmode != 0 ) && ( ( num_bits < 0 ) || ( ( header & 0x80 ) > 0 ) || ( ( header & 0x40 ) > 0 ) ) ) /* AMRWBIO */ + ELSE IF( ( isAMRWB_IOmode != 0 ) && ( ( num_bits < 0 ) || ( s_and( header, 0x80 ) > 0 ) || ( s_and( header, 0x40 ) > 0 ) ) ) /* AMRWBIO */ { /* incorrect IO FT header */ fprintf( stderr, "\nError in EVS(AMRWBIO) FT ToC header(%02x) ! ", header ); exit( -1 ); } } - else + ELSE { /* legacy AMRWB ToC, is only using Padding bits which MUST be ignored */ - if ( num_bits < 0 ) + IF( num_bits < 0 ) { /* incorrect FT header */ fprintf( stderr, "\nError in AMRWB RFC4867 Toc(FT) header(%02x) !", header ); @@ -2140,8 +2314,8 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem } /* read serial stream of indices from file to the local buffer */ - num_bytes_read = (Word16) fread( pFrame, sizeof( UWord8 ), ( num_bits + 7 ) >> 3, file ); - if ( num_bytes_read != ( num_bits + 7 ) >> 3 ) + num_bytes_read = extract_l( fread( pFrame, sizeof( UWord8 ), shr( add( num_bits, 7 ), 3 ), file ) ); + IF( NE_16( num_bytes_read, shr( add( num_bits, 7 ), 3 ) ) ) { fprintf( stderr, "\nError, invalid number of bytes read ! Exiting ! \n" ); exit( -1 ); @@ -2149,10 +2323,13 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem /* in case rew_flag is set, rewind the file and return */ /* (used in io_dec() to attempt print out info about technologies and to initialize the codec ) */ - if ( rew_flag ) + IF( rew_flag ) { st->total_brate = total_brate; /* used for the codec banner output */ - if ( st->bfi == 0 && speech_lost == 0 && no_data == 0 ) + move32(); + test(); + test(); + IF( st->bfi == 0 && speech_lost == 0 && no_data == 0 ) { decoder_selectCodec( st, total_brate, unpack_bit( &pt_pFrame, &mask ) ? G192_BIN1 : G192_BIN0 ); } @@ -2162,51 +2339,56 @@ Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem /* unpack speech data */ bit_stream_ptr = st->bit_stream; - for ( k = 0; k < num_bits; k++ ) + FOR( k = 0; k < num_bits; k++ ) { - if ( isAMRWB_IOmode ) + IF( isAMRWB_IOmode ) { st->bit_stream[sort_ptr[core_mode][k]] = unpack_bit( &pt_pFrame, &mask ); + move16(); bit_stream_ptr++; } - else + ELSE { *bit_stream_ptr++ = unpack_bit( &pt_pFrame, &mask ); + move16(); } } /* unpack auxiliary bits */ /* Note: the cmi bits are unpacked for demo purposes; */ - if ( isAMRWB_IOmode && total_brate == SID_1k75 ) + test(); + IF( isAMRWB_IOmode && EQ_32( total_brate, SID_1k75 ) ) { sti = unpack_bit( &pt_pFrame, &mask ); - cmi = unpack_bit( &pt_pFrame, &mask ) << 3; - cmi |= unpack_bit( &pt_pFrame, &mask ) << 2; - cmi |= unpack_bit( &pt_pFrame, &mask ) << 1; - cmi |= unpack_bit( &pt_pFrame, &mask ); + cmi = shl( unpack_bit( &pt_pFrame, &mask ), 3 ); + cmi = s_or( cmi, shl( unpack_bit( &pt_pFrame, &mask ), 2 ) ); + cmi = s_or( cmi, shl( unpack_bit( &pt_pFrame, &mask ), 1 ) ); + cmi = s_or( cmi, unpack_bit( &pt_pFrame, &mask ) ); read_indices_mime_handle_sti_and_all_zero_bits( st, &total_brate, sti ); } /*add two zero bytes for arithmetic coder flush*/ - for ( k = 0; k < 2 * 8; ++k ) + FOR( k = 0; k < 2 * 8; ++k ) { *bit_stream_ptr++ = 0; + move16(); } /* MIME RX_DTX handler */ - if ( !rew_flag ) + IF( !rew_flag ) { total_brate = read_indices_mime_handle_dtx( st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data ); } - if ( st->bfi == 0 ) + IF( st->bfi == 0 ) { /* select MODE1 or MODE2 in MIME */ decoder_selectCodec( st, total_brate, *st->bit_stream ? G192_BIN1 : G192_BIN0 ); /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */ st->total_brate = total_brate; + move32(); mdct_switching_dec( st ); } /* else{ bfi stay in past synthesis mode(SP,CNG) } */ @@ -2226,7 +2408,9 @@ static void berCheck( ) { /* In case of RF flag = 1, and valid RF packet with primary and partial copy */ - if ( ( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, FB ) ) || ( GE_16( *coder_type, TRANSITION ) ) ) + test(); + test(); + IF( ( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, FB ) ) || ( GE_16( *coder_type, TRANSITION ) ) ) { if ( EQ_16( st->use_partial_copy, 1 ) ) { @@ -2271,13 +2455,17 @@ void getPartialCopyInfo( /* reset number of target bits in case of rate switching */ st->rf_target_bits = 0; + move16(); /* Get the number of bits used for RF*/ IF( EQ_16( st->rf_flag, 1 ) ) { *coder_type = s_and( ind, 0x7 ); + move16(); st->bwidth = s_and( shr( ind, 3 ), 0x7 ); + move16(); *sharpFlag = s_and( shr( ind, 6 ), 0x1 ); + move16(); st->codec_mode = MODE2; move16(); get_rfTargetBits( st->rf_frame_type, &( st->rf_target_bits ) ); @@ -2285,17 +2473,22 @@ void getPartialCopyInfo( IF( EQ_16( st->bfi, FRAMEMODE_FUTURE ) ) { st->use_partial_copy = 1; + move16(); /* now set the frame mode to normal mode */ test(); IF( GE_16( st->rf_frame_type, RF_TCXFD ) && LE_16( st->rf_frame_type, RF_TCXTD2 ) ) { st->bfi = 1; + move16(); st->core = 1; + move16(); } ELSE { st->bfi = FRAMEMODE_NORMAL; + move16(); st->core = 0; + move16(); } } /* check for bit errors */ @@ -2322,14 +2515,16 @@ void get_rfFlag( /* Init */ *rf_flag = 0; + move16(); /* check for rf_flag in the packet and extract the rf_frame_type and rf_fec_offset */ test(); test(); - IF( EQ_32( st->total_brate, ACELP_13k20 ) && ( EQ_16( st->bfi, FRAMEMODE_NORMAL ) || EQ_16( st->bfi, FRAMEMODE_FUTURE ) ) ) + IF( EQ_32( st->total_brate, ACELP_13k20 ) && ( ( st->bfi == FRAMEMODE_NORMAL ) || EQ_16( st->bfi, FRAMEMODE_FUTURE ) ) ) { /* find the section in the ACELP signalling table corresponding to bitrate */ start_idx = 0; + move16(); WHILE( NE_32( acelp_sig_tbl[start_idx], st->total_brate ) ) { start_idx++; @@ -2341,21 +2536,26 @@ void get_rfFlag( /* retrieve the number of bits */ nBits_tmp = (Word16) acelp_sig_tbl[start_idx++]; + move16(); /* retrieve the signalling indice */ - ind_tmp = (Word16) acelp_sig_tbl[start_idx + get_indice( st, 0, nBits_tmp )]; + ind_tmp = (Word16) acelp_sig_tbl[add( start_idx, get_indice( st, 0, nBits_tmp ) )]; + move16(); /* convert signalling indice into RF flag. */ *rf_flag = s_and( shr( ind_tmp, 7 ), 0x1 ); + move16(); if ( ind ) { *ind = ind_tmp; + move16(); } if ( nBits ) { *nBits = nBits_tmp; + move16(); } } } @@ -2372,16 +2572,17 @@ void get_rfFrameType( ) { Word16 num_bits = 0; + move16(); IF( EQ_16( st->rf_flag, 1 ) ) { /*num_bits = st->total_brate/50;*/ - if ( EQ_32( st->total_brate, ACELP_13k20 ) ) + IF( EQ_32( st->total_brate, ACELP_13k20 ) ) { num_bits = 264; move16(); /* @13.2kbps */ } - else + ELSE { UWord16 lsb; Word32 L_tmp; @@ -2390,11 +2591,13 @@ void get_rfFrameType( } /* the last three bits in a packet is the RF frame type */ - *rf_frame_type = get_indice( st, num_bits - 3, 3 ); + *rf_frame_type = get_indice( st, sub( num_bits, 3 ), 3 ); + move16(); } ELSE { *rf_frame_type = 0; + move16(); } } @@ -2414,12 +2617,12 @@ void get_rf_fec_offset( IF( EQ_16( st->rf_flag, 1 ) ) { /*num_bits = st->total_brate/50;*/ - if ( EQ_32( st->total_brate, ACELP_13k20 ) ) + IF( EQ_32( st->total_brate, ACELP_13k20 ) ) { num_bits = 264; move16(); /* @13.2kbps */ } - else + ELSE { UWord16 lsb; Word32 L_tmp; @@ -2428,16 +2631,17 @@ void get_rf_fec_offset( } /* the two bits before the rf frame type contain the fec offset */ - tmp = get_indice( st, num_bits - 5, 2 ); + tmp = get_indice( st, sub( num_bits, 5 ), 2 ); - if ( tmp == 0 ) + IF( tmp == 0 ) { *rf_fec_offset = 2; move16(); } - else + ELSE { *rf_fec_offset = add( shl( tmp, 1 ), 1 ); + move16(); } } ELSE @@ -2465,31 +2669,39 @@ void get_rfTargetBits( { case RF_NO_DATA: *rf_target_bits = 5; + move16(); BREAK; case RF_TCXFD: *rf_target_bits = 27; + move16(); BREAK; case RF_TCXTD1: *rf_target_bits = 16; + move16(); BREAK; case RF_TCXTD2: *rf_target_bits = 16; + move16(); BREAK; case RF_ALLPRED: /* Es_pred bits 3 bits, LTF: 1, pitch: 8,5,5,5, FCB: 0, gain: 7,0,7,0, Diff GFr: 4*/ *rf_target_bits = 63; + move16(); BREAK; case RF_NOPRED: /* Es_pred bits 3 bits, LTF: 0, pitch: 0, FCB: 7,7,7,7, gain: 6,0,6,0, Diff GFr: 2*/ *rf_target_bits = 66; + move16(); BREAK; case RF_GENPRED: /* Es_pred bits 3 bits, LTF: 1, pitch: 8,0,8,0, FCB: 6,7,5,5, gain: 5,0,5,0, Diff GFr: 0*/ *rf_target_bits = 70; + move16(); BREAK; case RF_NELP: /* gain: 19, Diff GFr: 5 */ *rf_target_bits = 45; + move16(); BREAK; } } @@ -2515,9 +2727,11 @@ void get_NextCoderType_fx( FOR( k = 0; k < ACELP_13k20 / 50; k++ ) { - bit_stream[k] = ( bitsteam[k / 8] >> ( 7 - ( k % 8 ) ) ) & 0x1; + bit_stream[k] = (UWord8) s_and( shr( bitsteam[k / 8], sub( 7, ( k % 8 ) ) ), 0x1 ); + move16(); } start_idx = 0; + move16(); WHILE( NE_32( acelp_sig_tbl[start_idx], ACELP_13k20 ) ) { start_idx = add( start_idx, 1 ); @@ -2530,13 +2744,15 @@ void get_NextCoderType_fx( tmp = 0; move16(); nBits_tmp = (Word16) acelp_sig_tbl[start_idx++]; + move16(); FOR( k = 0; k < nBits_tmp; k++ ) { tmp = lshl( tmp, 1 ); tmp = add( tmp, bit_stream[k] ); } /* retrieve the signalling indice */ - *next_coder_type = s_and( (Word16) acelp_sig_tbl[start_idx + tmp], 0x7 ); + *next_coder_type = s_and( (Word16) acelp_sig_tbl[add( start_idx, tmp )], 0x7 ); + move16(); } /*-------------------------------------------------------------------* @@ -2564,84 +2780,110 @@ void read_indices_from_djb_fx( Word32 total_brate; Word16 speech_lost = 0; + move16(); + move16(); + move16(); + move16(); + st->bfi = 0; + move16(); st->BER_detect = 0; + move16(); st->mdct_sw_enable = 0; + move16(); st->mdct_sw = 0; + move16(); reset_indices_dec_fx( st ); st->bfi = !qbit; - total_brate = (Word32) (num_bits) *50; + move16(); + total_brate = L_mult0( num_bits, 50 ); st->total_num_bits = num_bits; + move16(); - if ( num_bits == 0 ) /* guess type of missing frame for SP_LOST and NO_DATA */ + IF( num_bits == 0 ) /* guess type of missing frame for SP_LOST and NO_DATA */ { speech_lost = st->CNG_fx == 0; + move16(); + move16(); no_data = st->CNG_fx != 0; + move16(); + move16(); } - if ( partialframe || st->prev_use_partial_copy ) + test(); + IF( partialframe || st->prev_use_partial_copy ) { st->next_coder_type = next_coder_type; + move16(); } - else + ELSE { st->next_coder_type = INACTIVE; + move16(); } - if ( partialframe == 1 ) + if ( EQ_16( partialframe, 1 ) ) { st->bfi = 2; + move16(); } /* unpack speech data */ bit_stream_ptr = st->bit_stream; /* convert bitstream from compact bytes to short values and store it in decoder state */ - for ( k = 0; k < num_bits; k++ ) + FOR( k = 0; k < num_bits; k++ ) { - if ( st->bitstreamformat == VOIP_RTPDUMP && isAMRWB_IOmode ) + test(); + IF( st->bitstreamformat == VOIP_RTPDUMP && isAMRWB_IOmode ) { st->bit_stream[sort_ptr[core_mode][k]] = unpack_bit( &pt_stream, &mask ); + move16(); bit_stream_ptr++; } - else + ELSE { *bit_stream_ptr++ = unpack_bit( &pt_stream, &mask ); + move16(); } } /* unpack auxiliary bits */ - if ( isAMRWB_IOmode && total_brate == SID_1k75 ) + test(); + IF( isAMRWB_IOmode && EQ_32( total_brate, SID_1k75 ) ) { - if ( st->bitstreamformat == VOIP_RTPDUMP ) + IF( EQ_16( st->bitstreamformat, VOIP_RTPDUMP ) ) { /* A.2.2.1.3: AMR-WB SID_1k75 frame is followed by STI bit and CMI bits */ sti = unpack_bit( &pt_stream, &mask ); } - else + ELSE { /* VOIP_G192_RTP does not contain STI and CMI */ sti = 1; + move16(); } read_indices_mime_handle_sti_and_all_zero_bits( st, &total_brate, sti ); } /* add two zero bytes for arithmetic coder flush */ - for ( k = 0; k < 8 * 2; ++k ) + FOR( k = 0; k < 8 * 2; ++k ) { *bit_stream_ptr++ = 0; + move16(); } total_brate = read_indices_mime_handle_dtx( st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data ); /* st->CNG_fx set inside */ - if ( st->bfi != 1 ) + IF( NE_16( st->bfi, 1 ) ) { /* select Mode 1 or Mode 2 */ decoder_selectCodec( st, total_brate, *st->bit_stream ? G192_BIN1 : G192_BIN0 ); /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */ st->total_brate = total_brate; + move32(); mdct_switching_dec( st ); } @@ -2668,15 +2910,17 @@ static UWord16 get_indice_preview( bitstreamShortPtr = bitstreamShort; FOR( i = 0; i < bitstreamSize; i++ ) { - *bitstreamShortPtr++ = ( bitstream[i / 8] >> ( 7 - ( i % 8 ) ) ) & 0x1; + *bitstreamShortPtr++ = s_and( shr( bitstream[i / 8], sub( 7, ( i % 8 ) ) ), 0x1 ); + move16(); } assert( nb_bits <= 16 ); value = 0; + move16(); FOR( i = 0; i < nb_bits; i++ ) { value = shl( value, 1 ); - value = add( value, bitstreamShort[pos + i] ); + value = add( value, bitstreamShort[add( pos, i )] ); } return value; } @@ -2698,14 +2942,18 @@ void evs_dec_previewFrame( Word16 rf_flag; rf_flag = 0; + move16(); *partialCopyFrameType = 0; + move16(); *partialCopyOffset = 0; - total_brate = bitstreamSize * 50; + move16(); + total_brate = L_mult0( bitstreamSize, 50 ); IF( EQ_32( total_brate, ACELP_13k20 ) ) { /* find the section in the ACELP signalling table corresponding to bitrate */ start_idx = 0; + move16(); WHILE( NE_32( acelp_sig_tbl[start_idx], total_brate ) ) { start_idx = add( start_idx, 1 ); @@ -2716,9 +2964,11 @@ void evs_dec_previewFrame( start_idx = add( start_idx, 1 ); /* retrieve the number of bits */ nBits = (Word16) acelp_sig_tbl[start_idx++]; + move16(); /* retrieve the signalling indice */ - ind = acelp_sig_tbl[start_idx + get_indice_preview( bitstream, bitstreamSize, 0, nBits )]; + ind = acelp_sig_tbl[add( start_idx, get_indice_preview( bitstream, bitstreamSize, 0, nBits ) )]; + move32(); /* convert signalling indice into RF flag. */ rf_flag = s_and( extract_l( L_shr( ind, 7 ) ), 0x1 ); @@ -2726,14 +2976,15 @@ void evs_dec_previewFrame( IF( rf_flag != 0 ) { /* read the fec offset at which the partial copy is received */ - ind = get_indice_preview( bitstream, bitstreamSize, ( bitstreamSize - 5 ), 2 ); + ind = get_indice_preview( bitstream, bitstreamSize, sub( bitstreamSize, 5 ), 2 ); IF( ind == 0 ) *partialCopyOffset = 2; ELSE IF( EQ_32( ind, 1 ) ) *partialCopyOffset = 3; ELSE IF( EQ_32( ind, 2 ) ) *partialCopyOffset = 5; ELSE IF( EQ_32( ind, 3 ) ) *partialCopyOffset = 7; - + move16(); /* the last three bits in a packet is the RF frame type */ *partialCopyFrameType = get_indice_preview( bitstream, bitstreamSize, bitstreamSize - 3, 3 ); + move16(); } } } @@ -2748,6 +2999,7 @@ void dtx_read_padding_bits_fx( tmp = st->total_brate; move32(); st->total_brate = L_add( st->total_brate, L_mult0( num_bits, FRAMES_PER_SEC ) ); + move32(); get_next_indice_fx( st, num_bits ); st->total_brate = tmp; move32(); diff --git a/lib_com/cb_shape_fx.c b/lib_com/cb_shape_fx.c index 880b60205..fcd9e06e4 100644 --- a/lib_com/cb_shape_fx.c +++ b/lib_com/cb_shape_fx.c @@ -28,7 +28,7 @@ static void E_GAIN_f_pitch_sharpening( Word16 *x, Word16 pit_lag, Word16 L_subfr FOR( i = pit_lag; i < L_subfr; i++ ) { /*x[i] += x[i - pit_lag] * F_PIT_SHARP;*/ - tmp = mult_r( x[i - pit_lag], 27853 /*F_PIT_SHARP Q15*/ ); + tmp = mult_r( x[sub( i, pit_lag )], 27853 /*F_PIT_SHARP Q15*/ ); x[i] = add( x[i], tmp ); move16(); } @@ -100,7 +100,7 @@ void cb_shape_fx( { weight_a_fx( p_Aq, A_num, g1, M ); weight_a_fx( p_Aq, A_den, g2, M ); - set16_fx( buff, 0, M + L_subfr ); + set16_fx( buff, 0, add( M, L_subfr ) ); IF( formantTiltFlag ) { Copy( A_num, buff + M, M + 1 ); @@ -108,7 +108,7 @@ void cb_shape_fx( E_UTIL_synthesis( 1, A_den, buff + M, buff + M, L_subfr, buff, 0, M ); /*Compute tilt of formant enhancement*/ - tilt = extract_l( L_shr( get_gain( buff + M + 1, buff + M, L_subfr - 1 ), 1 ) ); + tilt = extract_l( L_shr( get_gain( buff + M + 1, buff + M, sub( L_subfr, 1 ) ), 1 ) ); /*Combine tilt of code and fe*/ tmp = 0; diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 4b618f556..e81ab78ec 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -271,6 +271,7 @@ void cldfbAnalysis_ivas_fx( Word16 i, k; Word16 L2, M1, M2, M4; Word16 no_col = h_cldfb->no_col; + move16(); Word32 r1_fx, r2_fx, rr12_fx, ir12_fx; Word32 i1_fx, i2_fx, ri12_fx, ii12_fx; @@ -294,7 +295,7 @@ void cldfbAnalysis_ivas_fx( IF( GT_16( samplesToProcess, -1 ) ) { Copy32( timeIn_fx, timeBuffer_fx + offset, samplesToProcess ); - set32_fx( timeBuffer_fx + offset + samplesToProcess, 0, sub( frameSize, samplesToProcess ) ); + set32_fx( timeBuffer_fx + add( offset, samplesToProcess ), 0, sub( frameSize, samplesToProcess ) ); } ELSE { @@ -308,11 +309,12 @@ void cldfbAnalysis_ivas_fx( } M1 = h_cldfb->no_channels; + move16(); M2 = shr( M1, 1 ); M4 = shr( M1, 2 ); L2 = shl( M1, 1 ); - IF( M2 & 1 ) + if ( s_and( M2, 1 ) ) { M4 = add( M4, 1 ); } @@ -329,29 +331,29 @@ void cldfbAnalysis_ivas_fx( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ - r1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx - - r2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // Qx - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // Qx - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // Qx - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // Qx - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // Qx - - i1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx - - i2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx + + r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx + + i1_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx + + i2_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 @@ -364,7 +366,7 @@ void cldfbAnalysis_ivas_fx( // cplxMult( &rBuffer_fx[2 * k], &rBuffer_fx[2 * k + 1], rr12_fx, ri12_fx, rot_vctr_re_fx[k], rot_vctr_im_fx[k] ); rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // Qx - 3 move32(); - rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // Qx - 3 + rBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // Qx - 3 move32(); /* folding + pre modulation of DCT IV */ @@ -373,36 +375,36 @@ void cldfbAnalysis_ivas_fx( // cplxMult( &iBuffer_fx[2 * k], &iBuffer_fx[2 * k + 1], ir12_fx, ii12_fx, rot_vctr_re_fx[k], rot_vctr_im_fx[k] ); iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // Qx - 3 move32(); - iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // Qx - 3 + iBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // Qx - 3 move32(); } FOR( k = M4; k < M2; k++ ) { /* prototype filter */ - r1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx - - r2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx - - i1_fx = Msub_32_16( 0, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx - - i2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx + + r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx + + i1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx + + i2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // Qx + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // Qx r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 @@ -415,7 +417,7 @@ void cldfbAnalysis_ivas_fx( // cplxMult( &rBuffer_fx[2 * k], &rBuffer[2 * k + 1], rr12, ri12, rot_vctr_re[k], rot_vctr_im[k] ); rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // Qx - 3 move32(); - rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // Qx - 3 + rBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // Qx - 3 move32(); /* folding + pre modulation of DCT IV */ @@ -424,7 +426,7 @@ void cldfbAnalysis_ivas_fx( // cplxMult( &iBuffer[2 * k], &iBuffer[2 * k + 1], ir12, ii12, rot_vctr_re[k], rot_vctr_im[k] ); iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // Qx - 3 move32(); - iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // Qx - 3 + iBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // Qx - 3 move32(); } @@ -436,9 +438,9 @@ void cldfbAnalysis_ivas_fx( FOR( k = 0; k < M2; k++ ) { // cplxMult( &realBuffer[i][M1 - 1 - ( 2 * k )], &realBuffer[i][2 * k], rBuffer[2 * k], rBuffer[2 * k + 1], rot_vctr_re[k], rot_vctr_im[k] ); - realBuffer_fx[i][M1 - 1 - ( 2 * k )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // Qx - 5 + realBuffer_fx[i][sub( sub( M1, 1 ), shl( k, 1 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ); // Qx - 5 move32(); - realBuffer_fx[i][2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // Qx - 5 + realBuffer_fx[i][2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ); // Qx - 5 move32(); } @@ -451,14 +453,14 @@ void cldfbAnalysis_ivas_fx( { /* do it inplace */ // cplxMult( &imagBuffer[i][2 * k], &imagBuffer[i][M1 - 1 - ( 2 * k )], iBuffer[2 * k], iBuffer[2 * k + 1], rot_vctr_re[k], rot_vctr_im[k] ); - imagBuffer_fx[i][2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // QX - 5 + imagBuffer_fx[i][2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ); // QX - 5 move32(); - imagBuffer_fx[i][M1 - 1 - ( 2 * k )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // Qx - 5 + imagBuffer_fx[i][sub( sub( M1, 1 ), shl( k, 1 ) )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ); // Qx - 5 move32(); } - timeBuffer_fx += L2 * 5; - timeBuffer_fx += h_cldfb->no_channels - h_cldfb->p_filter_length; + timeBuffer_fx += i_mult( L2, 5 ); + timeBuffer_fx += sub( h_cldfb->no_channels, h_cldfb->p_filter_length ); } /* update memory */ @@ -703,6 +705,7 @@ void cldfbAnalysis_ts_fx( Word16 i, k; Word16 L2, M1, M2, M4; Word16 no_col = h_cldfb->no_col; + move16(); Word32 r1_fx, r2_fx, rr12_fx, ir12_fx; Word32 i1_fx, i2_fx, ri12_fx, ii12_fx; @@ -717,40 +720,45 @@ void cldfbAnalysis_ts_fx( Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize; - offset = h_cldfb->p_filter_length - h_cldfb->no_channels; - frameSize = h_cldfb->no_channels * h_cldfb->no_col; + offset = sub( h_cldfb->p_filter_length, h_cldfb->no_channels ); + frameSize = i_mult( h_cldfb->no_channels, h_cldfb->no_col ); /* prepare input buffer */ timeBuffer_fx = buffer_fx; Copy32( h_cldfb->cldfb_state_fx, timeBuffer_fx, offset ); - if ( samplesToProcess > -1 ) + IF( GT_16( samplesToProcess, -1 ) ) { Copy32( timeIn_fx, timeBuffer_fx + offset, samplesToProcess ); - set32_fx( timeBuffer_fx + offset + samplesToProcess, 0, ( frameSize - samplesToProcess ) ); + set32_fx( timeBuffer_fx + add( offset, samplesToProcess ), 0, sub( frameSize, samplesToProcess ) ); } - else + ELSE { Copy32( timeIn_fx, timeBuffer_fx + offset, frameSize ); } h_cldfb->Q_cldfb_state = *q_cldfb; + move16(); /* only process needed cols */ - if ( samplesToProcess > -1 ) + IF( samplesToProcess > -1 ) { - no_col = min( no_col, ( samplesToProcess + h_cldfb->no_channels - 1 ) / h_cldfb->no_channels ); + no_col = min( no_col, idiv1616( sub( add( samplesToProcess, h_cldfb->no_channels ), 1 ), h_cldfb->no_channels ) ); assert( no_col == 1 ); } M1 = h_cldfb->no_channels; - M2 = M1 >> 1; - M4 = M1 >> 2; - L2 = M1 << 1; + move16(); + M2 = shr( M1, 1 ); + move16(); + M4 = shr( M1, 2 ); + move16(); + L2 = shl( M1, 1 ); + move16(); - if ( M2 & 1 ) + if ( s_and( M2, 1 ) ) { - M4 += 1; + M4 = add( M4, 1 ); } rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx; // q = 29 @@ -760,35 +768,36 @@ void cldfbAnalysis_ts_fx( ptr_pf_fx = h_cldfb->p_filter; ptr_pf_sf = h_cldfb->p_filter_sf; + move16(); - for ( i = 0; i < no_col; i++ ) + FOR( i = 0; i < no_col; i++ ) { - for ( k = 0; k < M4; k++ ) + FOR( k = 0; k < M4; k++ ) { /* prototype filter */ - r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q - - r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ) ); // q - - i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q - - i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q + r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + i1_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + i2_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 @@ -799,43 +808,47 @@ void cldfbAnalysis_ts_fx( rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + rBuffer_fx[add( 2 * k, 1 )] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + move32(); + move32(); ///* folding + pre modulation of DCT IV */ ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + iBuffer_fx[add( 2 * k, 1 )] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + move32(); + move32(); } - for ( k = M4; k < M2; k++ ) + FOR( k = M4; k < M2; k++ ) { /* prototype filter */ - r1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q - r1_fx = L_sub( r1_fx, Mpy_32_16_1( timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q - - r2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q - r2_fx = L_sub( r2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q - - i1_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ) ); // q - i1_fx = L_sub( i1_fx, Mpy_32_16_1( timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ) ); // q - - i2_fx = L_sub( 0, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ) ); // q - i2_fx = L_sub( i2_fx, Mpy_32_16_1( timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ) ); // q + r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + i1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + i2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 @@ -846,72 +859,88 @@ void cldfbAnalysis_ts_fx( rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + rBuffer_fx[add( 2 * k, 1 )] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + move32(); + move32(); /* folding + pre modulation of DCT IV */ ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + iBuffer_fx[add( 2 * k, 1 )] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + move32(); + move32(); } *q_cldfb = sub( *q_cldfb, 3 ); + move16(); /* FFT of DST IV */ Word16 q_shift; - q_shift = sub( s_min( getScaleFactor32( rBuffer_fx, 2 * M2 ), getScaleFactor32( iBuffer_fx, 2 * M2 ) ), find_guarded_bits_fx( M2 ) ); + q_shift = sub( s_min( getScaleFactor32( rBuffer_fx, shl( M2, 1 ) ), getScaleFactor32( iBuffer_fx, shl( M2, 1 ) ) ), find_guarded_bits_fx( M2 ) ); *q_cldfb = add( *q_cldfb, q_shift ); - for ( Word16 ind = 0; ind < 2 * M2; ind++ ) + move16(); + FOR( Word16 ind = 0; ind < shl( M2, 1 ); ind++ ) { rBuffer_fx[ind] = L_shl( rBuffer_fx[ind], q_shift ); + move32(); } - for ( Word16 ind = 0; ind < 2 * M2; ind++ ) + FOR( Word16 ind = 0; ind < shl( M2, 1 ); ind++ ) { iBuffer_fx[ind] = L_shl( iBuffer_fx[ind], q_shift ); + move32(); } fft_cldfb_fx( rBuffer_fx, M2 ); /* post modulation of DST IV */ - for ( k = 0; k < M2; k++ ) + FOR( k = 0; k < M2; k++ ) { /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ - realBuffer_fx[M1 - 1 - ( 2 * k )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 + realBuffer_fx[sub( sub( M1, 1 ), shl( k, 1 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ) ); // q - 5 + realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ) ); // q - 5 + move32(); + move32(); } *q_cldfb = sub( *q_cldfb, 2 ); + move16(); /* FFT of DCT IV */ fft_cldfb_fx( iBuffer_fx, M2 ); - q_shift = s_min( getScaleFactor32( rBuffer_fx, 2 * M2 ), getScaleFactor32( iBuffer_fx, 2 * M2 ) ); + q_shift = s_min( getScaleFactor32( rBuffer_fx, shl( M2, 1 ) ), getScaleFactor32( iBuffer_fx, shl( M2, 1 ) ) ); *q_cldfb = add( *q_cldfb, q_shift ); - for ( Word16 ind = 0; ind < 2 * M2; ind++ ) + move16(); + FOR( Word16 ind = 0; ind < shl( M2, 1 ); ind++ ) { rBuffer_fx[ind] = L_shl( rBuffer_fx[ind], q_shift ); + move32(); } - for ( Word16 ind = 0; ind < 2 * M2; ind++ ) + FOR( Word16 ind = 0; ind < shl( M2, 1 ); ind++ ) { iBuffer_fx[ind] = L_shl( iBuffer_fx[ind], q_shift ); + move32(); } /* post modulation of DCT IV */ - for ( k = 0; k < M2; k++ ) + FOR( k = 0; k < M2; k++ ) { /* do it inplace */ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ - imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - imagBuffer_fx[M1 - 1 - ( 2 * k )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 + imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ) ); // q - 5 + imagBuffer_fx[sub( sub( M1, 1 ), shl( k, 1 ) )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ) ); // q - 5 + move32(); + move32(); } - if ( h_cldfb->prototype == CLDFB_PROTOTYPE_5_00MS ) + IF( EQ_32( h_cldfb->prototype, CLDFB_PROTOTYPE_5_00MS ) ) { /* rotation due to delay*/ /*if(h_cldfb->da != M1)*/ - if ( rot_vctr_delay_re_fx != NULL ) + IF( rot_vctr_delay_re_fx != NULL ) { - for ( k = 0; k < M1; k++ ) + FOR( k = 0; k < M1; k++ ) { Word32 cplx_aux_fx; /* delay */ @@ -924,20 +953,22 @@ void cldfbAnalysis_ts_fx( cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5 imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5 realBuffer_fx[k] = cplx_aux_fx; + move32(); + move32(); } } } - timeBuffer_fx += L2 * 5; - timeBuffer_fx += h_cldfb->no_channels - h_cldfb->p_filter_length; + timeBuffer_fx += i_mult( L2, 5 ); + timeBuffer_fx += sub( h_cldfb->no_channels, h_cldfb->p_filter_length ); } /* update memory */ - if ( samplesToProcess > -1 ) + IF( GT_16( samplesToProcess, -1 ) ) { Copy32( buffer_fx + samplesToProcess, h_cldfb->cldfb_state_fx, offset ); } - else + ELSE { Copy32( buffer_fx + frameSize, h_cldfb->cldfb_state_fx, offset ); } @@ -959,7 +990,7 @@ void cldfbAnalysis_ts_fx_fixed_q( Word16 i, k; Word16 L2, M1, M2, M4; Word16 no_col = h_cldfb->no_col; - + move16(); Word32 r1_fx, r2_fx, rr12_fx, ir12_fx; Word32 i1_fx, i2_fx, ri12_fx, ii12_fx; Word32 rBuffer_fx[2 * CLDFB_NO_CHANNELS_MAX]; @@ -973,39 +1004,44 @@ void cldfbAnalysis_ts_fx_fixed_q( Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize; - offset = h_cldfb->p_filter_length - h_cldfb->no_channels; - frameSize = h_cldfb->no_channels * h_cldfb->no_col; + offset = sub( h_cldfb->p_filter_length, h_cldfb->no_channels ); + frameSize = i_mult( h_cldfb->no_channels, h_cldfb->no_col ); /* prepare input buffer */ timeBuffer_fx = buffer_fx; Copy32( h_cldfb->cldfb_state_fx, timeBuffer_fx, offset ); h_cldfb->Q_cldfb_state = *q_cldfb; + move16(); - if ( samplesToProcess > -1 ) + IF( GT_16( samplesToProcess, -1 ) ) { Copy32( timeIn_fx, timeBuffer_fx + offset, samplesToProcess ); - set32_fx( timeBuffer_fx + offset + samplesToProcess, 0, ( frameSize - samplesToProcess ) ); + set32_fx( timeBuffer_fx + add( offset, samplesToProcess ), 0, sub( frameSize, samplesToProcess ) ); } - else + ELSE { Copy32( timeIn_fx, timeBuffer_fx + offset, frameSize ); } /* only process needed cols */ - if ( samplesToProcess > -1 ) + IF( GT_16( samplesToProcess, -1 ) ) { - no_col = min( no_col, ( samplesToProcess + h_cldfb->no_channels - 1 ) / h_cldfb->no_channels ); + no_col = min( no_col, idiv1616( sub( add( samplesToProcess, h_cldfb->no_channels ), 1 ), h_cldfb->no_channels ) ); assert( no_col == 1 ); } M1 = h_cldfb->no_channels; - M2 = M1 >> 1; - M4 = M1 >> 2; - L2 = M1 << 1; + M2 = shr( M1, 1 ); + M4 = shr( M1, 2 ); + L2 = shl( M1, 1 ); + move16(); + move16(); + move16(); + move16(); - if ( M2 & 1 ) + if ( s_and( M2, 1 ) ) { - M4 += 1; + M4 = add( M4, 1 ); } rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx; // q = 29 @@ -1015,35 +1051,36 @@ void cldfbAnalysis_ts_fx_fixed_q( ptr_pf_fx = h_cldfb->p_filter; ptr_pf_sf = h_cldfb->p_filter_sf; + move16(); - for ( i = 0; i < no_col; i++ ) + FOR( i = 0; i < no_col; i++ ) { - for ( k = 0; k < M4; k++ ) + FOR( k = 0; k < M4; k++ ) { /* prototype filter */ - r1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - - r2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q - - i1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q - - i2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, M2 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + i1_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + i2_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, i_mult( 3, M2 ) ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 @@ -1054,43 +1091,47 @@ void cldfbAnalysis_ts_fx_fixed_q( rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ - rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 - rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 + rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 + rBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 + move32(); + move32(); ///* folding + pre modulation of DCT IV */ ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ - iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 - iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 + iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 + iBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 + move32(); + move32(); } - for ( k = M4; k < M2; k++ ) + FOR( k = M4; k < M2; k++ ) { /* prototype filter */ - r1_fx = Msub_32_16( 0, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q - r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[L2 - M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - - r2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q - r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[L2 - 5 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q - - i1_fx = Msub_32_16( 0, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q - i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[L2 + M2 - 1 - ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - - i2_fx = Msub_32_16( 0, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 0 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 1 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 2 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 3 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q - i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[L2 - 3 * M2 + ( 2 * k ) + 4 * L2], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + r1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( sub( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + r2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + r2_fx = Msub_32_16( r2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 5, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + i1_fx = Msub_32_16( 0, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + i1_fx = Msub_32_16( i1_fx, timeBuffer_fx[add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( sub( sub( add( L2, M2 ), 1 ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q + + i2_fx = Msub_32_16( 0, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 0, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 1, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 2, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 3, L2 ) ) )] ); // q + i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) )], ptr_pf_fx[( add( add( sub( L2, i_mult( 3, M2 ) ), shl( k, 1 ) ), i_mult( 4, L2 ) ) )] ); // q r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 @@ -1101,50 +1142,60 @@ void cldfbAnalysis_ts_fx_fixed_q( rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ - rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 - rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 + rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 + rBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 + move32(); + move32(); /* folding + pre modulation of DCT IV */ ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ - iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 - iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 + iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 + iBuffer_fx[add( 2 * k, 1 )] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 + move32(); + move32(); } *q_cldfb = sub( *q_cldfb, 3 ); + move16(); /* FFT of DST IV */ fft_cldfb_fx( rBuffer_fx, M2 ); /* post modulation of DST IV */ - for ( k = 0; k < M2; k++ ) + FOR( k = 0; k < M2; k++ ) { /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ - realBuffer_fx[M1 - 1 - ( 2 * k )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 - realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 + realBuffer_fx[sub( sub( M1, 1 ), shl( k, 1 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ); // q - 5 + realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ); // q - 5 + move32(); + move32(); } *q_cldfb = sub( *q_cldfb, 2 ); + move16(); /* FFT of DCT IV */ fft_cldfb_fx( iBuffer_fx, M2 ); /* post modulation of DCT IV */ - for ( k = 0; k < M2; k++ ) + FOR( k = 0; k < M2; k++ ) { /* do it inplace */ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ - imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 - imagBuffer_fx[M1 - 1 - ( 2 * k )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 + imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[add( 2 * k, 1 )], rot_vctr_im_fx[k] ); // q - 5 + imagBuffer_fx[sub( sub( M1, 1 ), shl( k, 1 ) )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[add( 2 * k, 1 )], rot_vctr_re_fx[k] ); // q - 5 + move32(); + move32(); } - if ( h_cldfb->prototype == CLDFB_PROTOTYPE_5_00MS ) + IF( EQ_32( h_cldfb->prototype, CLDFB_PROTOTYPE_5_00MS ) ) { /* rotation due to delay*/ /*if(h_cldfb->da != M1)*/ - if ( rot_vctr_delay_re_fx != NULL ) + IF( rot_vctr_delay_re_fx != NULL ) { - for ( k = 0; k < M1; k++ ) + FOR( k = 0; k < M1; k++ ) { Word32 cplx_aux_fx; /* delay */ @@ -1157,20 +1208,22 @@ void cldfbAnalysis_ts_fx_fixed_q( cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5 imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5 realBuffer_fx[k] = cplx_aux_fx; + move32(); + move32(); } } } - timeBuffer_fx += L2 * 5; - timeBuffer_fx += h_cldfb->no_channels - h_cldfb->p_filter_length; + timeBuffer_fx += i_mult( L2, 5 ); + timeBuffer_fx += sub( h_cldfb->no_channels, h_cldfb->p_filter_length ); } /* update memory */ - if ( samplesToProcess > -1 ) + IF( GT_16( samplesToProcess, -1 ) ) { Copy32( buffer_fx + samplesToProcess, h_cldfb->cldfb_state_fx, offset ); } - else + ELSE { Copy32( buffer_fx + frameSize, h_cldfb->cldfb_state_fx, offset ); } @@ -1412,7 +1465,7 @@ void cldfbSynthesis_ivas_fx( /* only process needed cols */ IF( GT_16( samplesToProcess, -1 ) ) { - no_col = min( no_col, ( samplesToProcess + h_cldfb->no_channels - 1 ) / h_cldfb->no_channels ); + no_col = min( no_col, idiv1616( sub( add( samplesToProcess, h_cldfb->no_channels ), 1 ), h_cldfb->no_channels ) ); move16(); } @@ -1423,7 +1476,7 @@ void cldfbSynthesis_ivas_fx( rot_vctr_delay_im_fx = h_cldfb->rot_vec_syn_delay_im_fx; synthesisBuffer_fx = buffer_fx; - Copy32( h_cldfb->cldfb_state_fx, synthesisBuffer_fx + ( M1 * no_col ), h_cldfb->p_filter_length ); + Copy32( h_cldfb->cldfb_state_fx, synthesisBuffer_fx + i_mult( M1, no_col ), h_cldfb->p_filter_length ); p_filter = h_cldfb->p_filter; p_filter_sf = h_cldfb->p_filter_sf; @@ -1431,7 +1484,7 @@ void cldfbSynthesis_ivas_fx( ptr_time_out_fx = timeOut_fx; /*synthesisBuffer += M1 * h_cldfb->no_col;*/ - synthesisBuffer_fx += M1 * no_col; + synthesisBuffer_fx += i_mult( M1, no_col ); FOR( k = 0; k < no_col; k++ ) { @@ -1461,9 +1514,9 @@ void cldfbSynthesis_ivas_fx( } FOR( i = Mz; i < M1; i++ ) { - realBuffer_fx[k][i] = L_deposit_l( 0 ); + realBuffer_fx[k][i] = 0; move32(); - imagBuffer_fx[k][i] = L_deposit_l( 0 ); + imagBuffer_fx[k][i] = 0; move32(); } @@ -1471,16 +1524,16 @@ void cldfbSynthesis_ivas_fx( { /* pre modulation of DST IV */ /*cplxMult(&rBuffer[2*i], &rBuffer[2*i+1], realBuffer[k][2*i], realBuffer[k][M1-1-2*i], rot_vctr_re[i], rot_vctr_im[i]);*/ - rBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_re_fx[i] ), realBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_im_fx[i] ); // Qx + rBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_re_fx[i] ), realBuffer_fx[k][sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_im_fx[i] ); // Qx move32(); - rBuffer_fx[2 * i + 1] = Madd_32_32( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_im_fx[i] ), realBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_re_fx[i] ); // Qx + rBuffer_fx[add( 2 * i, 1 )] = Madd_32_32( Mpy_32_32( realBuffer_fx[k][2 * i], rot_vctr_im_fx[i] ), realBuffer_fx[k][sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_re_fx[i] ); // Qx move32(); /* pre modulation of DCT IV */ /*cplxMult(&iBuffer[2*i], &iBuffer[2*i+1],-imagBuffer[k][2*i], imagBuffer[k][M1-1-2*i], rot_vctr_re[i], rot_vctr_im[i]);*/ - iBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_re_fx[i] ), imagBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_im_fx[i] ); // Qx + iBuffer_fx[2 * i] = Msub_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_re_fx[i] ), imagBuffer_fx[k][sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_im_fx[i] ); // Qx move32(); - iBuffer_fx[2 * i + 1] = Madd_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_im_fx[i] ), imagBuffer_fx[k][M1 - 1 - 2 * i], rot_vctr_re_fx[i] ); // Qx + iBuffer_fx[add( 2 * i, 1 )] = Madd_32_32( Mpy_32_32( ( L_negate( imagBuffer_fx[k][2 * i] ) ), rot_vctr_im_fx[i] ), imagBuffer_fx[k][sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_re_fx[i] ); // Qx move32(); } @@ -1494,69 +1547,69 @@ void cldfbSynthesis_ivas_fx( FOR( i = 0; i < M41; i++ ) { /* post modulation of DST IV */ - rr12_fx = Msub_32_32( Mpy_32_32( rBuffer_fx[M1 - 2 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ), rBuffer_fx[M1 - 1 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ); // Qx - ri12_fx = Madd_32_32( Mpy_32_32( rBuffer_fx[M1 - 2 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ), rBuffer_fx[M1 - 1 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ); // Qx + rr12_fx = Msub_32_32( Mpy_32_32( rBuffer_fx[sub( sub( M1, 2 ), shl( i, 1 ) )], rot_vctr_re_fx[sub( sub( M2, 1 ), i )] ), rBuffer_fx[sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_im_fx[sub( sub( M2, 1 ), i )] ); // Qx + ri12_fx = Madd_32_32( Mpy_32_32( rBuffer_fx[sub( sub( M1, 2 ), shl( i, 1 ) )], rot_vctr_im_fx[sub( sub( M2, 1 ), i )] ), rBuffer_fx[sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_re_fx[sub( sub( M2, 1 ), i )] ); // Qx /* post modulation of DCT IV */ - ir12_fx = Msub_32_32( Mpy_32_32( iBuffer_fx[M1 - 2 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ), iBuffer_fx[M1 - 1 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ); // Qx - ii12_fx = Madd_32_32( Mpy_32_32( iBuffer_fx[M1 - 2 - 2 * i], rot_vctr_im_fx[M2 - 1 - i] ), iBuffer_fx[M1 - 1 - 2 * i], rot_vctr_re_fx[M2 - 1 - i] ); // Qx + ir12_fx = Msub_32_32( Mpy_32_32( iBuffer_fx[sub( sub( M1, 2 ), shl( i, 1 ) )], rot_vctr_re_fx[sub( sub( M2, 1 ), i )] ), iBuffer_fx[sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_im_fx[sub( sub( M2, 1 ), i )] ); // Qx + ii12_fx = Madd_32_32( Mpy_32_32( iBuffer_fx[sub( sub( M1, 2 ), shl( i, 1 ) )], rot_vctr_im_fx[sub( sub( M2, 1 ), i )] ), iBuffer_fx[sub( sub( M1, 1 ), shl( i, 1 ) )], rot_vctr_re_fx[sub( sub( M2, 1 ), i )] ); // Qx - new_samples_fx[M1 + M2 + 1 + 2 * i] = L_negate( L_add( rr12_fx, ii12_fx ) ); // Qx + new_samples_fx[add( add( add( M1, M2 ), 1 ), shl( i, 1 ) )] = L_negate( L_add( rr12_fx, ii12_fx ) ); // Qx move32(); - new_samples_fx[M2 - 2 - 2 * i] = L_negate( L_add( ri12_fx, ir12_fx ) ); // Qx + new_samples_fx[sub( sub( M2, 2 ), shl( i, 1 ) )] = L_negate( L_add( ri12_fx, ir12_fx ) ); // Qx move32(); - new_samples_fx[M1 + M2 - 2 - 2 * i] = L_sub( rr12_fx, ii12_fx ); // Qx + new_samples_fx[sub( sub( add( M1, M2 ), 2 ), shl( i, 1 ) )] = L_sub( rr12_fx, ii12_fx ); // Qx move32(); - new_samples_fx[M2 + 1 + 2 * i] = L_sub( ir12_fx, ri12_fx ); // Qx + new_samples_fx[add( add( M2, 1 ), shl( i, 1 ) )] = L_sub( ir12_fx, ri12_fx ); // Qx move32(); } FOR( i = 0; i < M42; i++ ) { /* post modulation of DST IV */ - rr12_fx = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_re_fx[i] ), rBuffer_fx[2 * i + 1], rot_vctr_im_fx[i] ); // Qx - ri12_fx = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_im_fx[i] ), rBuffer_fx[2 * i + 1], rot_vctr_re_fx[i] ); // Qx + rr12_fx = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_re_fx[i] ), rBuffer_fx[add( 2 * i, 1 )], rot_vctr_im_fx[i] ); // Qx + ri12_fx = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * i], rot_vctr_im_fx[i] ), rBuffer_fx[add( 2 * i, 1 )], rot_vctr_re_fx[i] ); // Qx /* post modulation of DCT IV */ - ir12_fx = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_re_fx[i] ), iBuffer_fx[2 * i + 1], rot_vctr_im_fx[i] ); // Qx - ii12_fx = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_im_fx[i] ), iBuffer_fx[2 * i + 1], rot_vctr_re_fx[i] ); // Qx + ir12_fx = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_re_fx[i] ), iBuffer_fx[add( 2 * i, 1 )], rot_vctr_im_fx[i] ); // Qx + ii12_fx = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * i], rot_vctr_im_fx[i] ), iBuffer_fx[add( 2 * i, 1 )], rot_vctr_re_fx[i] ); // Qx - new_samples_fx[M1 + M2 + 2 * i] = L_add( ri12_fx, ir12_fx ); // Qx + new_samples_fx[add( add( M1, M2 ), shl( i, 1 ) )] = L_add( ri12_fx, ir12_fx ); // Qx move32(); - new_samples_fx[M2 - 1 - 2 * i] = L_add( rr12_fx, ii12_fx ); // Qx + new_samples_fx[sub( sub( M2, 1 ), shl( i, 1 ) )] = L_add( rr12_fx, ii12_fx ); // Qx move32(); - new_samples_fx[M1 + M2 - 1 - 2 * i] = L_sub( ir12_fx, ri12_fx ); // Qx + new_samples_fx[sub( sub( add( M1, M2 ), 1 ), shl( i, 1 ) )] = L_sub( ir12_fx, ri12_fx ); // Qx move32(); - new_samples_fx[M2 + 2 * i] = L_sub( rr12_fx, ii12_fx ); // Qx + new_samples_fx[add( M2, shl( i, 1 ) )] = L_sub( rr12_fx, ii12_fx ); // Qx move32(); } /* synthesis prototype filter */ FOR( i = 0; i < L2; i++ ) { - accu0 = Madd_32_16( synthesisBuffer_fx[0 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 0 * L2 + i )] ), p_filter_sf ); // Qx - 1 - accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ); // Qx - 1 - accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ); // Qx - 1 - accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ); // Qx - 1 - accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ); // Qx - 1 + accu0 = Madd_32_16( synthesisBuffer_fx[i], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[i] ), p_filter_sf ); // Qx - 1 + accu1 = Madd_32_16( synthesisBuffer_fx[add( L2, i )], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[add( L2, i )] ), p_filter_sf ); // Qx - 1 + accu2 = Madd_32_16( synthesisBuffer_fx[add( i_mult( 2, L2 ), i )], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[add( i_mult( 2, L2 ), i )] ), p_filter_sf ); // Qx - 1 + accu3 = Madd_32_16( synthesisBuffer_fx[add( i_mult( 3, L2 ), i )], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[add( i_mult( 3, L2 ), i )] ), p_filter_sf ); // Qx - 1 + accu4 = Madd_32_16( synthesisBuffer_fx[add( i_mult( 4, L2 ), i )], Mpy_32_16_1( new_samples_fx[sub( sub( L2, 1 ), i )], p_filter[add( i_mult( 4, L2 ), i )] ), p_filter_sf ); // Qx - 1 - synthesisBuffer_fx[0 * L2 + i] = accu0; + synthesisBuffer_fx[i] = accu0; move32(); - synthesisBuffer_fx[1 * L2 + i] = accu1; + synthesisBuffer_fx[add( L2, i )] = accu1; move32(); - synthesisBuffer_fx[2 * L2 + i] = accu2; + synthesisBuffer_fx[add( i_mult( 2, L2 ), i )] = accu2; move32(); - synthesisBuffer_fx[3 * L2 + i] = accu3; + synthesisBuffer_fx[add( i_mult( 3, L2 ), i )] = accu3; move32(); - synthesisBuffer_fx[4 * L2 + i] = accu4; + synthesisBuffer_fx[add( i_mult( 4, L2 ), i )] = accu4; move32(); } FOR( i = 0; i < M1; i++ ) { - ptr_time_out_fx[M1 - 1 - i] = synthesisBuffer_fx[4 * L2 + M1 + i]; + ptr_time_out_fx[sub( sub( M1, 1 ), i )] = synthesisBuffer_fx[add( i_mult( 4, L2 ), add( M1, i ) )]; move32(); } @@ -1627,18 +1680,23 @@ void configureCldfb_ivas_fx( { 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 ); - Word32 n_sampling_rate = sampling_rate * 2; - Word32 val = L_add( Mpy_32_16_1( n_sampling_rate, 41 /* INV_CLDFB_BANDWIDTH in Q15 */ ), 1 ); - val = L_shr( val, 1 ); - h_cldfb->no_channels = extract_l( val ); + h_cldfb->no_channels = extract_l( Mpy_32_32_r( sampling_rate, INV_CLDFB_BANDWIDTH_Q31 ) ); + move16(); h_cldfb->zeros = 0; + move16(); h_cldfb->anaScalefactor = 0; + move16(); h_cldfb->synScalefactor = 0; - h_cldfb->p_filter_length = 10 * h_cldfb->no_channels; + move16(); + h_cldfb->p_filter_length = i_mult( 10, h_cldfb->no_channels ); + move16(); cldfb_init_proto_and_twiddles( h_cldfb ); @@ -1699,12 +1757,12 @@ ivas_error openCldfb_ivas_fx( hs->Q_cldfb_state = Q11; /* TODO: remove the floating point dependency */ - IF( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL ) + /*IF( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } + }*/ - set_f( hs->cldfb_state, 0.0f, buf_len ); + // set_f( hs->cldfb_state, 0.0f, buf_len ); *h_cldfb = hs; move16(); @@ -1731,6 +1789,7 @@ ivas_error openCldfb_ivas( hs->prototype = prototype; configureCldfb_ivas( hs, sampling_rate ); + hs->memory_flt = NULL; hs->memory_length = 0; @@ -1754,9 +1813,12 @@ ivas_error openCldfb_ivas( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); } hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer - hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ + move16(); + hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ + move16(); set32_fx( hs->cldfb_state_fx, 0, buf_len ); hs->Q_cldfb_state = Q11; + move16(); #endif // IVAS_FLOAT_FIXED @@ -1858,7 +1920,9 @@ ivas_error openCldfb_ivas_enc( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); } hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer - hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ + move16(); + hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ + move16(); set32_fx( hs->cldfb_state_fx, 0, buf_len ); set16_fx( hs->FilterStates, 0, i_mult( 9 + 16, hs->no_channels ) ); set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) ); @@ -1875,7 +1939,7 @@ ivas_error openCldfb_ivas_enc( * * Change sample rate of filter bank *--------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void resampleCldfb_ivas( HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ const int32_t newSamplerate ) @@ -1895,7 +1959,7 @@ void resampleCldfb_ivas( return; } -#ifdef IVAS_FLOAT_FIXED +#else void resampleCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ const Word32 newSamplerate ) @@ -2073,6 +2137,7 @@ void deleteCldfb_ivas( { HANDLE_CLDFB_FILTER_BANK hs = *h_cldfb; + test(); IF( h_cldfb == NULL || *h_cldfb == NULL ) { return; @@ -2083,7 +2148,7 @@ void deleteCldfb_ivas( free( hs->cldfb_state ); } #ifdef IVAS_FLOAT_FIXED - if ( hs->cldfb_state_fx ) + IF( hs->cldfb_state_fx ) { free( hs->cldfb_state_fx ); } @@ -2117,10 +2182,10 @@ void deleteCldfb_ivas_fx( free( hs->cldfb_state_fx ); } #ifdef IVAS_FLOAT_FIXED // TODO : Will be removed later - IF( hs->cldfb_state ) - { - free( hs->cldfb_state ); - } + // IF( hs->cldfb_state ) + //{ + // free( hs->cldfb_state ); + // } #endif free( hs ); @@ -2941,7 +3006,7 @@ ivas_error cldfb_save_memory_ivas_fx( { UWord16 offset = sub( hs->p_filter_length, hs->no_channels ); - IF( hs->memory_flt != NULL || NE_16( hs->memory_length, 0 ) ) + IF( hs->memory_flt != NULL || ( hs->memory_length != 0 ) ) { /* memory already stored; Free memory first */ return IVAS_ERR_OK; @@ -2972,8 +3037,7 @@ ivas_error cldfb_save_memory_ivas_fx( return IVAS_ERR_OK; } -#endif // IVAS_FLOAT_FIXED - +#else ivas_error cldfb_save_memory_ivas( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ ) @@ -3005,7 +3069,7 @@ ivas_error cldfb_save_memory_ivas( return IVAS_ERR_OK; } - +#endif /*-------------------------------------------------------------------* * cldfb_restore_memory_ivas() @@ -3019,13 +3083,14 @@ void cldfb_restore_memory_ivas_fx( { UWord16 offset = sub( hs->p_filter_length, hs->no_channels ); UWord16 size; + test(); IF( hs->memory_flt == NULL || EQ_16( hs->memory_length, 0 ) ) { /* memory not allocated */ return; } - IF( EQ_16( hs->type, CLDFB_ANALYSIS ) ) + IF( hs->type == CLDFB_ANALYSIS ) { size = offset; move16(); @@ -3045,7 +3110,9 @@ void cldfb_restore_memory_ivas_fx( L_lerp_fx_q11( hs->cldfb_state_fx, hs->cldfb_state_fx, size, hs->memory_length ); } hs->cldfb_state_length = size; + move16(); hs->memory_length = 0; + move16(); #if 1 // Remove later free( hs->memory_flt ); hs->memory_flt = NULL; @@ -3055,8 +3122,7 @@ void cldfb_restore_memory_ivas_fx( return; } -#endif // IVAS_FLOAT_FIXED - +#else void cldfb_restore_memory_ivas( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ ) @@ -3094,7 +3160,7 @@ void cldfb_restore_memory_ivas( return; } - +#endif /*-------------------------------------------------------------------* * cldfb_reset_memory_ivas() @@ -3134,16 +3200,20 @@ void cldfb_reset_memory_fx( IF( hs->type == CLDFB_ANALYSIS ) { memory_length = offset; + move16(); } ELSE { memory_length = hs->p_filter_length; + move16(); } hs->cldfb_state_length = memory_length; + move16(); /* save the memory */ set32_fx( hs->cldfb_state_fx, 0, memory_length ); hs->Q_cldfb_state = Q11; + move16(); return; } diff --git a/lib_com/cldfb_evs.c b/lib_com/cldfb_evs.c index 2a27fbb24..bad77d7f1 100644 --- a/lib_com/cldfb_evs.c +++ b/lib_com/cldfb_evs.c @@ -229,19 +229,21 @@ static void calcModulation( Word32 *rYR, { cmplx CL_x, CL_z; cmplx_s C_c; - int i; - int lc = m >> 1; + Word32 i; + Word32 lc = L_shr( m, 1 ); const Word16 *cr = rRotVctr; const Word16 *ci = iRotVctr; - for ( i = 0; i < lc; i++ ) + FOR( i = 0; i < lc; i++ ) { CL_x = CL_form( *rXR, *rXI ); C_c = C_form( *cr, *ci ); CL_z = CL_mult_32x16( CL_x, C_c ); *rYR = CL_Extract_real( CL_z ); + move64(); *rYI = CL_Extract_imag( CL_z ); + move64(); rYR += srYR; rYI += srYI; rXR += srXR; @@ -250,7 +252,9 @@ static void calcModulation( Word32 *rYR, CL_x = CL_form( *iXR, *iXI ); CL_z = CL_mult_32x16( CL_x, C_c ); *iYR = CL_Extract_real( CL_z ); + move64(); *iYI = CL_Extract_imag( CL_z ); + move64(); iYR += siYR; iYI += siYI; iXR += siXR; @@ -297,14 +301,14 @@ static void calcModulationAndFolding( Word16 *rY, const Word16 *r11, *r12, *r21, *r22; - y11 = &rY[m + m2 + 1]; - y12 = &rY[m2 - 2]; - y13 = &rY[m + m2 - 2]; + y11 = &rY[add( add( m, m2 ), 1 )]; + y12 = &rY[sub( m2, 2 )]; + y13 = &rY[sub( add( m, m2 ), 2 )]; y14 = &rY[m2 + 1]; - y21 = &rY[m + m2]; + y21 = &rY[add( m, m2 )]; y22 = &rY[m2 - 1]; - y23 = &rY[m + m2 - 1]; + y23 = &rY[sub( add( m, m2 ), 1 )]; y24 = &rY[m2]; x11 = &rX[m - 2]; @@ -415,6 +419,7 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, stride = 1; /* constant */ + move16(); m = cldfbBank->no_channels; move16(); L2 = shl( m, 1 ); @@ -446,12 +451,12 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, p_stride = CLDFB_NO_POLY; pFilter = &cldfbBank->p_filter[p_stride - CLDFB_NO_POLY]; - pFilter1 = &pFilter[p_stride * L3M1]; - pFilter2 = &pFilter[p_stride * L3]; - pFilter3 = &pFilter[p_stride * m2]; - pFilter4 = &pFilter[p_stride * M2M1]; - pFilter5 = &pFilter[p_stride * L4M1]; - pFilter6 = &pFilter[p_stride * M0M2]; + pFilter1 = &pFilter[i_mult( p_stride, L3M1 )]; + pFilter2 = &pFilter[i_mult( p_stride, L3 )]; + pFilter3 = &pFilter[i_mult( p_stride, m2 )]; + pFilter4 = &pFilter[i_mult( p_stride, M2M1 )]; + pFilter5 = &pFilter[i_mult( p_stride, L4M1 )]; + pFilter6 = &pFilter[i_mult( p_stride, M0M2 )]; nSamples = i_mult( nTimeSlots, cldfbBank->no_channels ); nSamplesUpd = i_mult( cldfbBank->no_col, cldfbBank->no_channels ); @@ -464,7 +469,7 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, move16(); FOR( i = 0; i < offset; i += cldfbBank->no_channels ) { - cldfbBank->FilterStates_e[k] = cldfbBank->FilterStates_e[k + cldfbBank->no_col]; + cldfbBank->FilterStates_e[k] = cldfbBank->FilterStates_e[add( k, cldfbBank->no_col )]; move16(); assert( (size_t) k < sizeof( cldfbBank->FilterStates_e ) / sizeof( cldfbBank->FilterStates_e[0] ) ); scale = s_max( scale, cldfbBank->FilterStates_e[k] ); @@ -516,80 +521,80 @@ void cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, FOR( i = 0; i < M4; i++ ) { /* prototype filter */ - r1 = L_msu0( 0, pFilter1[0 - p_stride * 2 * i], pStates1[0 * L2 - 2 * i] ); - r1 = L_msu0( r1, pFilter1[1 - p_stride * 2 * i], pStates1[1 * L2 - 2 * i] ); - r1 = L_msu0( r1, pFilter1[2 - p_stride * 2 * i], pStates1[2 * L2 - 2 * i] ); - r1 = L_msu0( r1, pFilter1[3 - p_stride * 2 * i], pStates1[3 * L2 - 2 * i] ); - r1 = L_msu0( r1, pFilter1[4 - p_stride * 2 * i], pStates1[4 * L2 - 2 * i] ); - - r2 = L_msu0( 0, pFilter2[0 + p_stride * 2 * i], pStates2[0 * L2 + 2 * i] ); - r2 = L_msu0( r2, pFilter2[1 + p_stride * 2 * i], pStates2[1 * L2 + 2 * i] ); - r2 = L_msu0( r2, pFilter2[2 + p_stride * 2 * i], pStates2[2 * L2 + 2 * i] ); - r2 = L_msu0( r2, pFilter2[3 + p_stride * 2 * i], pStates2[3 * L2 + 2 * i] ); - r2 = L_msu0( r2, pFilter2[4 + p_stride * 2 * i], pStates2[4 * L2 + 2 * i] ); - - i1 = L_msu0( 0, pFilter3[0 + p_stride * 2 * i], pStates3[0 * L2 + 2 * i] ); - i1 = L_msu0( i1, pFilter3[1 + p_stride * 2 * i], pStates3[1 * L2 + 2 * i] ); - i1 = L_msu0( i1, pFilter3[2 + p_stride * 2 * i], pStates3[2 * L2 + 2 * i] ); - i1 = L_msu0( i1, pFilter3[3 + p_stride * 2 * i], pStates3[3 * L2 + 2 * i] ); - i1 = L_msu0( i1, pFilter3[4 + p_stride * 2 * i], pStates3[4 * L2 + 2 * i] ); - - i2 = L_msu0( 0, pFilter4[0 - p_stride * 2 * i], pStates4[0 * L2 - 2 * i] ); - i2 = L_msu0( i2, pFilter4[1 - p_stride * 2 * i], pStates4[1 * L2 - 2 * i] ); - i2 = L_msu0( i2, pFilter4[2 - p_stride * 2 * i], pStates4[2 * L2 - 2 * i] ); - i2 = L_msu0( i2, pFilter4[3 - p_stride * 2 * i], pStates4[3 * L2 - 2 * i] ); - i2 = L_msu0( i2, pFilter4[4 - p_stride * 2 * i], pStates4[4 * L2 - 2 * i] ); + r1 = L_msu0( 0, pFilter1[sub( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 0, L2 ), shl( i, 1 ) )] ); + r1 = L_msu0( r1, pFilter1[sub( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 1, L2 ), shl( i, 1 ) )] ); + r1 = L_msu0( r1, pFilter1[sub( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 2, L2 ), shl( i, 1 ) )] ); + r1 = L_msu0( r1, pFilter1[sub( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 3, L2 ), shl( i, 1 ) )] ); + r1 = L_msu0( r1, pFilter1[sub( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 4, L2 ), shl( i, 1 ) )] ); + + r2 = L_msu0( 0, pFilter2[add( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 0, L2 ), shl( i, 1 ) )] ); + r2 = L_msu0( r2, pFilter2[add( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 1, L2 ), shl( i, 1 ) )] ); + r2 = L_msu0( r2, pFilter2[add( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 2, L2 ), shl( i, 1 ) )] ); + r2 = L_msu0( r2, pFilter2[add( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 3, L2 ), shl( i, 1 ) )] ); + r2 = L_msu0( r2, pFilter2[add( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates2[add( i_mult( 4, L2 ), shl( i, 1 ) )] ); + + i1 = L_msu0( 0, pFilter3[add( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 0, L2 ), shl( i, 1 ) )] ); + i1 = L_msu0( i1, pFilter3[add( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 1, L2 ), shl( i, 1 ) )] ); + i1 = L_msu0( i1, pFilter3[add( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 2, L2 ), shl( i, 1 ) )] ); + i1 = L_msu0( i1, pFilter3[add( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 3, L2 ), shl( i, 1 ) )] ); + i1 = L_msu0( i1, pFilter3[add( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 4, L2 ), shl( i, 1 ) )] ); + + i2 = L_msu0( 0, pFilter4[sub( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 0, L2 ), shl( i, 1 ) )] ); + i2 = L_msu0( i2, pFilter4[sub( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 1, L2 ), shl( i, 1 ) )] ); + i2 = L_msu0( i2, pFilter4[sub( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 2, L2 ), shl( i, 1 ) )] ); + i2 = L_msu0( i2, pFilter4[sub( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 3, L2 ), shl( i, 1 ) )] ); + i2 = L_msu0( i2, pFilter4[sub( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates4[sub( i_mult( 4, L2 ), shl( i, 1 ) )] ); /* folding */ rBuffer[2 * i] = L_sub( r1, r2 ); move32(); - rBuffer[2 * i + 1] = L_negate( L_add( i1, i2 ) ); + rBuffer[add( shl( i, 1 ), 1 )] = L_negate( L_add( i1, i2 ) ); move32(); /* folding */ iBuffer[2 * i] = L_add( r1, r2 ); move32(); - iBuffer[2 * i + 1] = L_sub( i1, i2 ); + iBuffer[add( shl( i, 1 ), 1 )] = L_sub( i1, i2 ); move32(); } FOR( i = M4; i < m2; i++ ) { /* prototype filter */ - r1 = L_msu0( 0, pFilter1[0 - p_stride * 2 * i], pStates1[0 * L2 - 2 * i] ); - r1 = L_msu0( r1, pFilter1[1 - p_stride * 2 * i], pStates1[1 * L2 - 2 * i] ); - r1 = L_msu0( r1, pFilter1[2 - p_stride * 2 * i], pStates1[2 * L2 - 2 * i] ); - r1 = L_msu0( r1, pFilter1[3 - p_stride * 2 * i], pStates1[3 * L2 - 2 * i] ); - r1 = L_msu0( r1, pFilter1[4 - p_stride * 2 * i], pStates1[4 * L2 - 2 * i] ); - - r2 = L_msu0( 0, pFilter6[0 + p_stride * 2 * i], pStates6[0 * L2 + 2 * i] ); - r2 = L_msu0( r2, pFilter6[1 + p_stride * 2 * i], pStates6[1 * L2 + 2 * i] ); - r2 = L_msu0( r2, pFilter6[2 + p_stride * 2 * i], pStates6[2 * L2 + 2 * i] ); - r2 = L_msu0( r2, pFilter6[3 + p_stride * 2 * i], pStates6[3 * L2 + 2 * i] ); - r2 = L_msu0( r2, pFilter6[4 + p_stride * 2 * i], pStates6[4 * L2 + 2 * i] ); - - i1 = L_msu0( 0, pFilter5[0 - p_stride * 2 * i], pStates5[0 * L2 - 2 * i] ); - i1 = L_msu0( i1, pFilter5[1 - p_stride * 2 * i], pStates5[1 * L2 - 2 * i] ); - i1 = L_msu0( i1, pFilter5[2 - p_stride * 2 * i], pStates5[2 * L2 - 2 * i] ); - i1 = L_msu0( i1, pFilter5[3 - p_stride * 2 * i], pStates5[3 * L2 - 2 * i] ); - i1 = L_msu0( i1, pFilter5[4 - p_stride * 2 * i], pStates5[4 * L2 - 2 * i] ); - - i2 = L_msu0( 0, pFilter3[0 + p_stride * 2 * i], pStates3[0 * L2 + 2 * i] ); - i2 = L_msu0( i2, pFilter3[1 + p_stride * 2 * i], pStates3[1 * L2 + 2 * i] ); - i2 = L_msu0( i2, pFilter3[2 + p_stride * 2 * i], pStates3[2 * L2 + 2 * i] ); - i2 = L_msu0( i2, pFilter3[3 + p_stride * 2 * i], pStates3[3 * L2 + 2 * i] ); - i2 = L_msu0( i2, pFilter3[4 + p_stride * 2 * i], pStates3[4 * L2 + 2 * i] ); + r1 = L_msu0( 0, pFilter1[sub( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 0, L2 ), shl( i, 1 ) )] ); + r1 = L_msu0( r1, pFilter1[sub( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 1, L2 ), shl( i, 1 ) )] ); + r1 = L_msu0( r1, pFilter1[sub( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 2, L2 ), shl( i, 1 ) )] ); + r1 = L_msu0( r1, pFilter1[sub( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 3, L2 ), shl( i, 1 ) )] ); + r1 = L_msu0( r1, pFilter1[sub( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates1[sub( i_mult( 4, L2 ), shl( i, 1 ) )] ); + + r2 = L_msu0( 0, pFilter6[add( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 0, L2 ), shl( i, 1 ) )] ); + r2 = L_msu0( r2, pFilter6[add( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 1, L2 ), shl( i, 1 ) )] ); + r2 = L_msu0( r2, pFilter6[add( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 2, L2 ), shl( i, 1 ) )] ); + r2 = L_msu0( r2, pFilter6[add( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 3, L2 ), shl( i, 1 ) )] ); + r2 = L_msu0( r2, pFilter6[add( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates6[add( i_mult( 4, L2 ), shl( i, 1 ) )] ); + + i1 = L_msu0( 0, pFilter5[sub( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 0, L2 ), shl( i, 1 ) )] ); + i1 = L_msu0( i1, pFilter5[sub( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 1, L2 ), shl( i, 1 ) )] ); + i1 = L_msu0( i1, pFilter5[sub( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 2, L2 ), shl( i, 1 ) )] ); + i1 = L_msu0( i1, pFilter5[sub( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 3, L2 ), shl( i, 1 ) )] ); + i1 = L_msu0( i1, pFilter5[sub( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates5[sub( i_mult( 4, L2 ), shl( i, 1 ) )] ); + + i2 = L_msu0( 0, pFilter3[add( 0, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 0, L2 ), shl( i, 1 ) )] ); + i2 = L_msu0( i2, pFilter3[add( 1, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 1, L2 ), shl( i, 1 ) )] ); + i2 = L_msu0( i2, pFilter3[add( 2, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 2, L2 ), shl( i, 1 ) )] ); + i2 = L_msu0( i2, pFilter3[add( 3, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 3, L2 ), shl( i, 1 ) )] ); + i2 = L_msu0( i2, pFilter3[add( 4, i_mult( p_stride, shl( i, 1 ) ) )], pStates3[add( i_mult( 4, L2 ), shl( i, 1 ) )] ); /* folding */ rBuffer[2 * i] = L_add( r1, r2 ); move32(); - rBuffer[2 * i + 1] = L_sub( i1, i2 ); + rBuffer[add( shl( i, 1 ), 1 )] = L_sub( i1, i2 ); move32(); /* folding */ iBuffer[2 * i] = L_sub( r1, r2 ); move32(); - iBuffer[2 * i + 1] = L_add( i1, i2 ); + iBuffer[add( shl( i, 1 ), 1 )] = L_add( i1, i2 ); move32(); } @@ -721,7 +726,7 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, iBuffer = &pWorkBuffer[m]; nBuffer = (Word16 *) ( &pWorkBuffer[L2] ); - rAnalysisS = &pWorkBuffer[3 * m]; + rAnalysisS = &pWorkBuffer[i_mult( 3, m )]; iAnalysisS = &pWorkBuffer[4 * m]; rRotVctr = cldfbBank->rRotVctr; @@ -783,7 +788,9 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, FOR( ; i < m; i += 2 ) { rAnalysisS[i] = L_deposit_l( 0 ); + move32(); iAnalysisS[i] = L_deposit_l( 0 ); + move32(); } } @@ -811,7 +818,9 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, FOR( ; i < m; i += 2 ) { rAnalysisS[i] = L_deposit_l( 0 ); + move32(); iAnalysisS[i] = L_deposit_l( 0 ); + move32(); } } } @@ -836,14 +845,14 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, calcModulationAndFolding( nBuffer, rBuffer, iBuffer, rRotVctr, iRotVctr, cldfbBank->synGain, scale, m, m2 ); /* prototype filter */ - pStates = &cldfbBank->FilterStates[k * L2]; + pStates = &cldfbBank->FilterStates[i_mult( k, L2 )]; pFilterS = &cldfbBank->p_filter[0]; pFilterM = &cldfbBank->p_filter[shr( cldfbBank->p_filter_length, 1 )]; FOR( i = 0; i < channels0; i++ ) { pStatesI = &pStates[i]; - pStatesR = &pStates[i + channels3]; + pStatesR = &pStates[add( i, channels3 )]; acc = L_mult( *pStatesI, *pFilterS++ ); acc = L_mac( acc, *pStatesR, *pFilterM++ ); @@ -865,21 +874,22 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, pStatesI += channels4; acc = L_mac( acc, *pStatesI, *pFilterS++ ); - acc = L_mac( acc, nBuffer[channels1 - i], *pFilterM++ ); + acc = L_mac( acc, nBuffer[sub( channels1, i )], *pFilterM++ ); BASOP_SATURATE_WARNING_OFF_EVS #ifdef BASOP_NOGLOB - timeOut[( offset1 - i ) * stride] = round_fx_sat( L_shl_sat( acc, outScale ) ); + timeOut[i_mult( sub( offset1, i ), stride )] = round_fx_sat( L_shl_sat( acc, outScale ) ); #else timeOut[( offset1 - i ) * stride] = round_fx( L_shl( acc, outScale ) ); #endif BASOP_SATURATE_WARNING_ON_EVS + move16(); } FOR( ; i < cldfbBank->no_channels; i++ ) { - pStatesI = &pStates[i + channels2]; - pStatesR = &pStates[i + channels2 + channels3]; + pStatesI = &pStates[add( i, channels2 )]; + pStatesR = &pStates[add( add( i, channels2 ), channels3 )]; acc = L_mult( *pStatesI, *pFilterS++ ); acc = L_mac( acc, *pStatesR, *pFilterM++ ); @@ -904,22 +914,23 @@ void cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank, BASOP_SATURATE_WARNING_OFF_EVS #ifdef BASOP_NOGLOB - timeOut[( offset2 - i ) * stride] = round_fx_sat( L_shl_sat( acc, outScale ) ); + timeOut[i_mult( sub( offset2, i ), stride )] = round_fx_sat( L_shl_sat( acc, outScale ) ); #else timeOut[( offset2 - i ) * stride] = round_fx( L_shl( acc, outScale ) ); #endif BASOP_SATURATE_WARNING_ON_EVS + move16(); } FOR( i = 0; i < cldfbBank->no_channels; i++ ) { - pStates[statesSizeM1 + i] = nBuffer[channels1 - i]; + pStates[add( statesSizeM1, i )] = nBuffer[sub( channels1, i )]; move16(); - pStates[statesSizeM2 + i] = nBuffer[channels1 + m - i]; + pStates[add( statesSizeM2, i )] = nBuffer[sub( add( channels1, m ), i )]; move16(); } - timeOut = &timeOut[m * stride]; + timeOut = &timeOut[i_mult( m, stride )]; } /* move filter states */ @@ -944,6 +955,7 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */ move16(); assert( h_cldfb->no_channels >= 10 ); h_cldfb->no_col = div_l( frameSize, shr( h_cldfb->no_channels, 1 ) ); + move16(); /* was cldfbInitFilterBank()*/ h_cldfb->anaScalefactor = 0; @@ -963,6 +975,7 @@ void configureCldfb( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */ move16(); h_cldfb->flags = s_or( h_cldfb->flags, CLDFB_FLAG_2_5MS_SETUP ); + move16(); h_cldfb->filterScale = CLDFB_CLDFB80_PFT_SCALE; move16(); @@ -1004,7 +1017,7 @@ ivas_error openCldfb( HANDLE_CLDFB_FILTER_BANK hs; hs = (HANDLE_CLDFB_FILTER_BANK) count_malloc( sizeof( CLDFB_FILTER_BANK ) ); - if ( hs == NULL ) + IF( hs == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); } @@ -1047,7 +1060,7 @@ ivas_error openCldfb( move16(); } } - ELSE IF( hs->type == CLDFB_SYNTHESIS ) + ELSE IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) { IF( hs->FilterStates != 0 ) { @@ -1101,8 +1114,8 @@ void resampleCldfb( HANDLE_CLDFB_FILTER_BANK hs, IF( firstFrame == 0 ) { /*low complexity-resampling only stored previous samples that are needed for next frame modulation */ - lerp( hs->FilterStates + ( noChannelsOld * hs->no_col ), hs->FilterStates + ( noChannelsOld * hs->no_col ), timeOffset, timeOffsetOld ); - Copy( hs->FilterStates + ( noChannelsOld * hs->no_col ), hs->FilterStates + frameSize, timeOffset ); + lerp( hs->FilterStates + i_mult( noChannelsOld, hs->no_col ), hs->FilterStates + i_mult( noChannelsOld, hs->no_col ), timeOffset, timeOffsetOld ); + Copy( hs->FilterStates + i_mult( noChannelsOld, hs->no_col ), hs->FilterStates + frameSize, timeOffset ); } return; @@ -1158,6 +1171,8 @@ AnalysisPostSpectrumScaling_Fx( HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle rSubband16[i][j] = round_fx( L_shl( rSubband32[i][j], headRoom ) ); iSubband16[i][j] = round_fx( L_shl( iSubband32[i][j], headRoom ) ); #endif + move32(); + move32(); } } @@ -1194,6 +1209,7 @@ void analysisCldfbEncoder_fx( Word16 *ppBuf_Imag16[CLDFB_NO_COL_MAX]; Word32 workBuffer[256]; Word16 num_slots = 1; + move16(); FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { @@ -1271,6 +1287,7 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) // Word16 freqTable[2] = {20, 40}; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif FOR( k = 0; k < numberCols; k++ ) @@ -1309,12 +1326,13 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) FOR( j = 0; j < numberBands; j++ ) { energyValuesSum[j] = L_deposit_l( 0 ); + move32(); energyValuesSumE[j] = 31; move16(); FOR( k = 0; k < CLDFB_NO_COL_MAX; k++ ) { nrg = L_shr_r( energyValues[k][j], sub( energyValuesSumE[j], 31 ) ); - IF( L_sub( maxWord32, nrg ) < energyValuesSum[j] ) + IF( LT_32( L_sub( maxWord32, nrg ), energyValuesSum[j] ) ) { energyValuesSumE[j] = add( energyValuesSumE[j], 1 ); move16(); @@ -1326,9 +1344,10 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) move32(); } test(); - IF( j == 0 || GT_16( energyValuesSumE[j], *energyValuesSum_Exp ) ) + if ( j == 0 || GT_16( energyValuesSumE[j], *energyValuesSum_Exp ) ) { *energyValuesSum_Exp = energyValuesSumE[j]; + move16(); } } FOR( j = 0; j < numberBands; j++ ) @@ -1418,6 +1437,7 @@ CLDFB_getNumChannels( Word32 sampleRate ) { Word16 nChannels = 0; + move16(); SWITCH( sampleRate ) @@ -1509,7 +1529,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->p_filter = cldfb_protoFilter_2_5ms[0]; hs->scale = cldfb_scale_2_5ms[0]; move16(); - IF( hs->type == CLDFB_SYNTHESIS ) + IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) { hs->synScalefactor = add( cldfb_synScale[0], hs->filterScale ); move16(); @@ -1519,7 +1539,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->anaScalefactor = add( cldfb_anaScale[0], hs->filterScale ); move16(); } - break; + BREAK; case 16: hs->rRotVctr = rRotVectr_16; @@ -1533,7 +1553,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->anaScalefactor = add( cldfb_anaScale[1], hs->filterScale ); move16(); } - break; + BREAK; case 20: hs->rRotVctr = rRotVectr_20; @@ -1543,7 +1563,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->p_filter = cldfb_protoFilter_2_5ms[2]; hs->scale = cldfb_scale_2_5ms[2]; move16(); - IF( hs->type == CLDFB_SYNTHESIS ) + IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) { hs->synScalefactor = add( cldfb_synScale[2], hs->filterScale ); move16(); @@ -1553,7 +1573,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->anaScalefactor = add( cldfb_anaScale[2], hs->filterScale ); move16(); } - break; + BREAK; case 32: hs->rRotVctr = rRotVectr_32; @@ -1567,7 +1587,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->anaScalefactor = add( cldfb_anaScale[3], hs->filterScale ); move16(); } - break; + BREAK; case 40: hs->rRotVctr = rRotVectr_40; @@ -1577,7 +1597,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->p_filter = cldfb_protoFilter_2_5ms[4]; hs->scale = cldfb_scale_2_5ms[4]; move16(); - IF( hs->type == CLDFB_SYNTHESIS ) + IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) { hs->synScalefactor = add( cldfb_synScale[4], hs->filterScale ); move16(); @@ -1587,7 +1607,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->anaScalefactor = add( cldfb_anaScale[4], hs->filterScale ); move16(); } - break; + BREAK; case 60: hs->rRotVctr = rRotVectr_60; @@ -1597,7 +1617,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->p_filter = cldfb_protoFilter_2_5ms[5]; hs->scale = cldfb_scale_2_5ms[5]; move16(); - IF( hs->type == CLDFB_SYNTHESIS ) + IF( EQ_16( hs->type, CLDFB_SYNTHESIS ) ) { hs->synScalefactor = add( cldfb_synScale[5], hs->filterScale ); move16(); @@ -1607,7 +1627,7 @@ cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle hs->anaScalefactor = add( cldfb_anaScale[5], hs->filterScale ); move16(); } - break; + BREAK; } } @@ -1623,7 +1643,7 @@ ivas_error cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */ { - if ( hs->memory != NULL || hs->memory_length != 0 ) + IF( hs->memory != NULL || hs->memory_length != 0 ) { /* memory already stored; Free memory first */ return IVAS_ERR_OK; @@ -1636,7 +1656,7 @@ cldfb_save_memory( HANDLE_CLDFB_FILTER_BANK hs ) /* i: cldfb handle */ Copy( hs->FilterStates_e, hs->memory + hs->memory_length, CLDFB_MEM_EXPONENTS ); hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS] = hs->FilterStates_eg; move16(); - if ( hs->memory == NULL ) + IF( hs->memory == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); } diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index e2475bbad..b43b17448 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -85,7 +85,7 @@ void CNG_exc_fx( IF( *first_CNG == 0 ) { - IF( EQ_32( core_brate, FRAME_NO_DATA ) ) + IF( core_brate == FRAME_NO_DATA ) { /* needed only in decoder when the very first SID frame was erased and this frame is FRAME_NO_DATA frame */ /*fenew = dotp( fexc, fexc, pit_max )/pit_max;*/ @@ -101,7 +101,7 @@ void CNG_exc_fx( move32(); } - if ( EQ_16( element_mode, EVS_MONO ) ) + if ( element_mode == EVS_MONO ) { *lp_ener = *Enew; move32(); @@ -113,7 +113,7 @@ void CNG_exc_fx( *---------------------------------------------------------------------*/ test(); test(); - IF( NE_32( last_core_brate, SID_1k75 ) && NE_32( last_core_brate, FRAME_NO_DATA ) && NE_32( last_core_brate, SID_2k40 ) ) + IF( NE_32( last_core_brate, SID_1k75 ) && ( last_core_brate != FRAME_NO_DATA ) && NE_32( last_core_brate, SID_2k40 ) ) { /* Partially reset CNG energy after active speech period */ test(); @@ -170,7 +170,7 @@ if ( EQ_16( allow_cn_step, 1 ) ) move16(); } /* If not mono, skip CNG here */ -if ( GT_16( element_mode, IVAS_SCE ) ) +IF( GT_16( element_mode, IVAS_SCE ) ) { return; } @@ -233,9 +233,9 @@ FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) FOR( i = 0; i < L_SUBFR; i++ ) { /* exc2[i] *= enr */ - L_tmp = L_mult( exc2[i_subfr + i], tmp ); /* Q-4 * Q_exc+19 -> Q_exc +16 */ + L_tmp = L_mult( exc2[add( i_subfr, i )], tmp ); /* Q-4 * Q_exc+19 -> Q_exc +16 */ #ifdef BASOP_NOGLOB - exc2[i_subfr + i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); + exc2[add( i_subfr, i )] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); #else exc2[i_subfr + i] = round_fx( L_shl( L_tmp, exp ) ); #endif @@ -315,7 +315,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) /* fft_rel(fft_io, L_FFT, LOG2_L_FFT); */ fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT ); /* ??????? */ ptR = &fft_io[1]; - ptI = &fft_io[sub( L_FFT, 1 )]; + ptI = &fft_io[L_FFT - 1]; FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ @@ -351,20 +351,23 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) if ( denv[i] < 0 ) { - denv[i] = L_deposit_l( 0 ); + denv[i] = 0; + move32(); } } set32_fx( itmp, 0, NUM_ENV_CNG ); set16_fx( fft_io, 0, L_FFT ); ptR = &fft_io[1]; - ptI = &fft_io[sub( L_FFT, 1 )]; + ptI = &fft_io[L_FFT - 1]; FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* *ptR = own_random( cng_ener_seed1 ); */ /* *ptI = own_random( cng_ener_seed1 ); */ *ptR = Random( cng_ener_seed1 ); + move16(); *ptI = Random( cng_ener_seed1 ); + move16(); /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ L_tmp = L_mult0( *ptR, *ptR ); /* Q0 */ @@ -395,7 +398,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) } } ptR = &fft_io[1]; - ptI = &fft_io[sub( L_FFT, 1 )]; + ptI = &fft_io[L_FFT - 1]; FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* *ptR *= sqrt(itmp[i]/env[i]); */ @@ -428,13 +431,14 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) #else *ptR = extract_h( L_shl( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/ #endif + move16(); L_tmp2 = Mult_32_16( L_tmp, *ptI ); /*Q(16-exp)*/ #ifdef BASOP_NOGLOB *ptI = extract_h( L_shl_sat( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/ #else *ptI = extract_h( L_shl( L_tmp2, add( exp, Q_exc ) ) ); /*Q_exc*/ #endif - + move16(); ptR++; ptI--; } @@ -509,7 +513,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) test(); test(); test(); - IF( NE_32( last_core_brate, SID_2k40 ) && NE_32( last_core_brate, SID_1k75 ) && NE_32( last_core_brate, FRAME_NO_DATA ) && EQ_32( core_brate, SID_2k40 ) ) + IF( NE_32( last_core_brate, SID_2k40 ) && NE_32( last_core_brate, SID_1k75 ) && ( last_core_brate != FRAME_NO_DATA ) && EQ_32( core_brate, SID_2k40 ) ) { #ifdef BASOP_NOGLOB IF( GT_32( L_tmp, L_shl_sat( 1, sub( 31, exp ) ) ) ) @@ -525,8 +529,9 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) FOR( i = 0; i < L_SUBFR; i++ ) { /* fft_io[i] *= enr */ - L_tmp = L_mult( fft_io[i_subfr + i], tmp ); /* Q_exc + 16 - exp */ - fft_io[i_subfr + i] = round_fx( L_shl( L_tmp, exp ) ); /*Q_exc*/ + L_tmp = L_mult( fft_io[add( i_subfr, i )], tmp ); /* Q_exc + 16 - exp */ + fft_io[add( i_subfr, i )] = round_fx( L_shl( L_tmp, exp ) ); /*Q_exc*/ + move16(); } } @@ -674,6 +679,7 @@ void cng_params_postupd_fx( Word32 last_active_brate; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif ptr = add( sub( ho_circ_ptr, *cng_buf_cnt ), 1 ); @@ -686,7 +692,9 @@ void cng_params_postupd_fx( { exc2 = &cng_exc2_buf[ptr * L_FFT]; Q_exc = cng_Qexc_buf[ptr]; + move16(); last_active_brate = cng_brate_buf[ptr]; + move32(); /* calculate the spectrum of residual signal */ Copy( exc2, fft_io, L_FFT ); @@ -758,10 +766,12 @@ void cng_params_postupd_fx( if ( EQ_16( ptr, HO_HIST_SIZE ) ) { ptr = 0; + move16(); } } *cng_buf_cnt = 0; + move16(); return; } @@ -810,11 +820,13 @@ void cng_params_upd_fx( Word16 exp_pow; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif /* update the pointer to circular buffer of old LSP vectors */ *ho_circ_ptr = add( *ho_circ_ptr, 1 ); + move16(); if ( EQ_16( *ho_circ_ptr, HO_HIST_SIZE ) ) { @@ -837,7 +849,6 @@ void cng_params_upd_fx( scale = norm_s( maxv ); pt_exc2 = exc2; - move16(); L_ener = L_deposit_l( 0 ); IF( EQ_16( L_frame, L_FRAME ) ) { @@ -891,10 +902,11 @@ void cng_params_upd_fx( ho_ener_circ[*ho_circ_ptr] = L_ener; move32(); - IF( EQ_16( enc_dec_flag, ENC ) ) + IF( enc_dec_flag == ENC ) { /* Store residual signal for postponed FFT-processing*/ *cng_buf_cnt = add( *cng_buf_cnt, 1 ); + move16(); if ( GT_16( *cng_buf_cnt, HO_HIST_SIZE ) ) { *cng_buf_cnt = HO_HIST_SIZE; @@ -974,6 +986,7 @@ void cng_params_upd_fx( Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); } *ho_circ_size = add( *ho_circ_size, 1 ); + move16(); if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) ) { *ho_circ_size = HO_HIST_SIZE; @@ -1016,15 +1029,17 @@ void cng_params_upd_ivas_fx( Word16 exp1; Word16 CNG_mode; Word16 tmp = 0; + move16(); Word16 temp_lo_fx, temp_hi_fx; Word16 exp_pow; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif - /* update the pointer to circular buffer of old LSP vectors */ *ho_circ_ptr = add( *ho_circ_ptr, 1 ); + move16(); if ( EQ_16( *ho_circ_ptr, HO_HIST_SIZE ) ) { @@ -1047,7 +1062,6 @@ void cng_params_upd_ivas_fx( scale = norm_s( maxv ); pt_exc2 = exc2; - move16(); L_ener = L_deposit_l( 0 ); IF( EQ_16( L_frame, L_FRAME ) ) { @@ -1101,10 +1115,11 @@ void cng_params_upd_ivas_fx( ho_ener_circ[*ho_circ_ptr] = L_ener; move32(); - IF( EQ_16( enc_dec_flag, ENC ) ) + IF( enc_dec_flag == ENC ) { /* Store residual signal for postponed FFT-processing*/ *cng_buf_cnt = add( *cng_buf_cnt, 1 ); + move16(); if ( GT_16( *cng_buf_cnt, HO_HIST_SIZE ) ) { *cng_buf_cnt = HO_HIST_SIZE; @@ -1148,16 +1163,23 @@ void cng_params_upd_ivas_fx( Copy32( sp, env, NUM_ENV_CNG ); Word16 shift = 0; - if ( element_mode == IVAS_SCE || element_mode == IVAS_CPE_DFT ) + move16(); + test(); + IF( EQ_16( element_mode, IVAS_SCE ) || EQ_16( element_mode, IVAS_CPE_DFT ) ) { Word32 att_fx = 0; Word16 index = 0; + move32(); + move16(); apply_scale_ivas_fx( &att_fx, bwidth, last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO, &index ); att_fx = pow_10_q23[index]; // Q23 - tmp = extract_h( att_fx ); // Q7 + move32(); + tmp = extract_h( att_fx ); // Q7 + move16(); shift = 8; + move16(); } - else + ELSE { CNG_mode = get_cng_mode( last_active_brate ); /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */ @@ -1187,6 +1209,7 @@ void cng_params_upd_ivas_fx( scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift ); } *ho_circ_size = add( *ho_circ_size, 1 ); + move16(); if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) ) { *ho_circ_size = HO_HIST_SIZE; @@ -1212,22 +1235,27 @@ Word16 get_cng_mode( IF( GT_32( last_active_brate, ACELP_13k20 ) ) { CNG_mode = 4; + move16(); } ELSE IF( GT_32( last_active_brate, ACELP_9k60 ) ) { CNG_mode = 3; + move16(); } ELSE IF( GT_32( last_active_brate, ACELP_8k00 ) ) { CNG_mode = 2; + move16(); } ELSE IF( GT_32( last_active_brate, ACELP_7k20 ) ) { CNG_mode = 1; + move16(); } ELSE { CNG_mode = 0; + move16(); } return ( CNG_mode ); diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 4bcab73ec..f1ce84dde 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -573,11 +573,9 @@ enum *----------------------------------------------------------------------------------*/ #define FRAMES_PER_SEC 50 -#ifdef IVAS_FLOAT_FIXED #define MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC 200 //(FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) #define ONE_BY_FRAMES_PER_SEC_Q31 ( 42949673 ) #define FRAMES_PER_SEC_BY_2 (FRAMES_PER_SEC >> 1) -#endif #define INV_FRAME_PER_SEC_Q15 656 #define INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 164 #define FRAME_SIZE_NS 20000000L diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index f956cba9b..e2fbbb9f3 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -36,7 +36,7 @@ Word16 tcxGetNoiseFillingTilt( { firstLine = shr( L_frame, 3 ); - Copy_Scale_sig( A, As, lpcorder + 1, sub( norm_s( A[0] ), 2 ) ); + Copy_Scale_sig( A, As, add( lpcorder, 1 ), sub( norm_s( A[0] ), 2 ) ); tmp = get_gain( As + 1, As, lpcorder ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB @@ -67,6 +67,7 @@ void tcxFormantEnhancement( Word16 xn_buf_e, xn_one, m, e; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif k = shr( L_frame, 6 ); /* FDNS_NPTS = 64 */ @@ -143,7 +144,7 @@ void tcxFormantEnhancement( fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); + xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) ); #else xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); #endif @@ -192,7 +193,7 @@ void tcxFormantEnhancement( fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - xn_buf[l + j] = s_min( xn_one, shl_sat( mult( xn_buf[l + j], fac ), fac_e ) ); + xn_buf[add( l, j )] = s_min( xn_one, shl_sat( mult( xn_buf[add( l, j )], fac ), fac_e ) ); #else xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); #endif @@ -240,6 +241,7 @@ void tcxFormantEnhancement_with_shift( Word16 xn_buf_e, xn_one, m, e; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif k = shr( L_frame, 6 ); /* FDNS_NPTS = 64 */ @@ -294,16 +296,16 @@ void tcxFormantEnhancement_with_shift( move16(); tmp = sub( e, fac_e ); - IF( GT_16( tmp, 0 ) ) + IF( tmp > 0 ) { fac0 = shr( fac0, tmp ); } - IF( LT_16( tmp, 0 ) ) + IF( tmp < 0 ) { fac1 = shl( fac1, tmp ); } - IF( GT_16( tmp, 0 ) ) + IF( tmp > 0 ) { fac_e = e; move16(); @@ -320,7 +322,7 @@ void tcxFormantEnhancement_with_shift( fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); + xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) ); #else xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); #endif @@ -369,7 +371,7 @@ void tcxFormantEnhancement_with_shift( fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) ); + xn_buf[add( l, j )] = s_min( xn_one, shl_o( mult( xn_buf[add( l, j )], fac ), fac_e, &Overflow ) ); #else xn_buf[l + j] = s_min( xn_one, shl( mult( xn_buf[l + j], fac ), fac_e ) ); #endif @@ -426,7 +428,7 @@ void tcxInvertWindowGrouping( test(); test(); - if ( ( frame_cnt != 0 ) && ( bfi == 0 ) && NE_16( last_core, ACELP_CORE ) ) /* fix sub-window overlap */ + if ( ( frame_cnt != 0 ) && ( bfi == 0 ) && ( last_core != ACELP_CORE ) ) /* fix sub-window overlap */ { hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; move16(); @@ -458,7 +460,7 @@ void tcxInvertWindowGrouping( move32(); } - p = spectrum + L_frame - 1; + p = spectrum + sub( L_frame, 1 ); FOR( i = sub( L_frame, 1 ); i > L_win; i -= 2 ) { *p-- = spectrum[i]; @@ -474,8 +476,8 @@ void tcxInvertWindowGrouping( IF( LT_16( L_spec, L_frame ) ) { Copy32( spectrum + 8, spectrum + 16, sub( shr( L_spec, 1 ), 8 ) ); - Copy32( spectrum + L_frame / 2, spectrum + 8, 8 ); - Copy32( spectrum + L_frame / 2 + 8, spectrum + L_spec / 2 + 8, sub( shr( L_spec, 1 ), 8 ) ); + Copy32( spectrum + shr( L_frame, 1 ), spectrum + 8, 8 ); + Copy32( spectrum + add( shr( L_frame, 1 ), 8 ), spectrum + add( shr( L_spec, 1 ), 8 ), sub( shr( L_spec, 1 ), 8 ) ); } ELSE { @@ -641,7 +643,7 @@ void tcx5SpectrumInterleaving_fx( FOR( i = 0; i < tcx5Size; i++ ) { interleaveBuf[2 * i] = spectrum[i]; - interleaveBuf[2 * i + 1] = spectrum[tcx5Size + i]; + interleaveBuf[add( 2 * i, 1 )] = spectrum[add( tcx5Size, i )]; } Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) ); @@ -668,7 +670,7 @@ void tcx5SpectrumDeinterleaving_fx( FOR( i = 0; i < tcx5Size; i++ ) { interleaveBuf[i] = spectrum[2 * i]; - interleaveBuf[tcx5Size + i] = spectrum[2 * i + 1]; + interleaveBuf[add( tcx5Size, i )] = spectrum[add( 2 * i, 1 )]; } Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) ); @@ -692,7 +694,7 @@ void tcx5TnsGrouping_fx( { Copy32( spectrum + 8, spectrum + 16, sub( L_spec, 8 ) ); Copy32( spectrum + L_frame, spectrum + 8, 8 ); - Copy32( spectrum + L_frame + 8, spectrum + L_spec + 8, sub( L_spec, 8 ) ); + Copy32( spectrum + add( L_frame, 8 ), spectrum + add( L_spec, 8 ), sub( L_spec, 8 ) ); } ELSE { @@ -721,11 +723,11 @@ void tcx5TnsUngrouping_fx( /* undo rearrangement of LF sub-window lines prior to TNS analysis */ IF( LT_16( L_spec, L_frame ) ) { - Copy32( spectrum + L_spec + 8, spectrum + L_frame + 8, sub( L_spec, 8 ) ); + Copy32( spectrum + L_spec + 8, spectrum + add( L_frame, 8 ), sub( L_spec, 8 ) ); Copy32( spectrum + 8, spectrum + L_frame, 8 ); Copy32( spectrum + 16, spectrum + 8, sub( L_spec, 8 ) ); set32_fx( spectrum + L_spec, 0, sub( L_frame, L_spec ) ); - set32_fx( spectrum + L_frame + L_spec, 0, sub( L_frame, L_spec ) ); + set32_fx( spectrum + add( L_frame, L_spec ), 0, sub( L_frame, L_spec ) ); } ELSE { diff --git a/lib_com/enh64.c b/lib_com/enh64.c index f0b804076..b59a9ef6c 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -1062,6 +1062,55 @@ Word64 W_msu_16_16( Word64 L64_var1, Word16 var2, Word16 var3 ) return L64_var_out; } +/*________________________________________________________________________________________________ +| | +| Function Name : W_mac_32_32 | +| | +| Purpose : | +| | +| Multiply var1 by var2 and shift the result left by 1 and add the 64 bit result to L64_acc, | +| return a 64 bit result. | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_acc | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. | +| | +| var1 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= var1 <= 0x7fff 0000. | +| | +| var2 | +| 32 bit signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= var2 <= 0x7fff 0000. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L64_var_out | +| 64 bit long long signed integer (Word64) whose value falls in the | +| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. | +|_________________________________________________________________________________________________| +*/ +Word64 W_mac_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) +{ + Word64 L64_var_out = W_mult_32_32( L_var2, L_var3 ); + L64_var_out = W_add( L64_var1, L64_var_out ); + +#if ( WMOPS ) + multiCounter[currCounter].W_mult_32_32--; + /* multiCounter[currCounter].W_add--; */ +#endif + + return L64_var_out; +} + /*___________________________________________________________________________ | | diff --git a/lib_com/enh64.h b/lib_com/enh64.h index 9016a27ae..efc58e83e 100644 --- a/lib_com/enh64.h +++ b/lib_com/enh64.h @@ -36,6 +36,7 @@ Word64 W_msu0_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); Word64 W_mult_16_16( Word16 var1, Word16 var2 ); Word64 W_mac_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); Word64 W_msu_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); +Word64 W_mac_32_32( Word64 L64_acc, Word32 var1, Word32 var2 ); Word64 W_deposit32_l( Word32 L_var1 ); Word64 W_deposit32_h( Word32 L_var1 ); diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index 36f2cfc81..ed136930d 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -533,7 +533,7 @@ void tdm_bit_alloc( Word32 res_fix = 0; move32(); res_fix = Mpy_32_32( 644245095, L_sub( element_brate_wo_meta, 500 ) ); - res_fix = imult3216( Mpy_32_16_1( L_abs( res_fix ), 328 ), 100 ); + res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 ), 100 ); if ( res_fix < 0 ) { res_fix = L_negate( res_fix ); @@ -548,7 +548,7 @@ void tdm_bit_alloc( Word32 res_fix = 0; move32(); res_fix = Mpy_32_32( 1073741824, L_sub( element_brate_wo_meta, 500 ) ); - res_fix = imult3216( Mpy_32_16_1( L_abs( res_fix ), 328 ), 100 ); + res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 ), 100 ); if ( res_fix < 0 ) { res_fix = L_negate( res_fix ); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 064ae2849..485308d6c 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3224,7 +3224,7 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < overlap; i++ ) { - xn_buf_fx[i] = add( xn_buf_fx[i], old_syn_overl_fx[i] ); + xn_buf_fx[i] = add_sat( xn_buf_fx[i], old_syn_overl_fx[i] ); move16(); } } @@ -3292,7 +3292,7 @@ void IMDCT_ivas_fx( FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ ) { xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); + xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); move16(); move16(); } diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index a66795dca..1ab53f387 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -977,7 +977,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( &( st_ivas->cldfbAnaDec[1] ) ); + deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[1] ) ); numCldfbAnalyses_old = sub( numCldfbAnalyses_old, 1 ); } /* resample CLDFB analysis instances */ @@ -995,7 +995,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* delete superfluous CLDFB synthesis instances */ FOR( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ ) { - deleteCldfb_ivas( &( st_ivas->cldfbAnaDec[i] ) ); + deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) ); } } ELSE IF( LT_16( numCldfbAnalyses_old, numCldfbAnalyses ) ) @@ -1015,7 +1015,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* delete superfluous CLDFB synthesis instances */ FOR( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ ) { - deleteCldfb_ivas( &( st_ivas->cldfbSynDec[i] ) ); + deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) ); } } ELSE IF( LT_16( numCldfbSyntheses_old, numCldfbSyntheses ) ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 193324414..0640c495f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -4791,7 +4791,7 @@ void ivas_destroy_dec_fx( { IF( st_ivas->cldfbAnaDec[i] != NULL ) { - deleteCldfb_ivas( &( st_ivas->cldfbAnaDec[i] ) ); + deleteCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ) ); } } @@ -4799,7 +4799,7 @@ void ivas_destroy_dec_fx( { IF( st_ivas->cldfbSynDec[i] != NULL ) { - deleteCldfb_ivas( &( st_ivas->cldfbSynDec[i] ) ); + deleteCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ) ); } } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 774c1a8e0..6ec395ccc 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -3228,9 +3228,9 @@ void stereo_switching_dec( { /* reset CLDFB memories */ #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - cldfb_reset_memory_ivas( sts[0]->cldfbAna ); - cldfb_reset_memory_ivas( sts[0]->cldfbBPF ); - cldfb_reset_memory_ivas( sts[0]->cldfbSyn ); + // cldfb_reset_memory_ivas( sts[0]->cldfbAna ); + // cldfb_reset_memory_ivas( sts[0]->cldfbBPF ); + // cldfb_reset_memory_ivas( sts[0]->cldfbSyn ); #endif cldfb_reset_memory_fx( sts[0]->cldfbAna ); @@ -3295,9 +3295,9 @@ void stereo_switching_dec( /* reset CLDFB memories */ #ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - cldfb_reset_memory_ivas( sts[1]->cldfbAna ); - cldfb_reset_memory_ivas( sts[1]->cldfbBPF ); - cldfb_reset_memory_ivas( sts[1]->cldfbSyn ); + // cldfb_reset_memory_ivas( sts[1]->cldfbAna ); + // cldfb_reset_memory_ivas( sts[1]->cldfbBPF ); + // cldfb_reset_memory_ivas( sts[1]->cldfbSyn ); #endif cldfb_reset_memory_fx( sts[1]->cldfbAna ); diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 394452fb8..3ba8a4331 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -1490,7 +1490,7 @@ static void JB4_popFromBuffer( partialCopyDu = (JB4_DATAUNIT_HANDLE) JB4_INPUTBUFFER_Element( h->inputBuffer, searchpos ); IF( EQ_64( partialCopyDu->timeStamp, W_add( nextDataUnit->timeStamp, partialCopyDu->duration ) ) ) { - get_NextCoderType( partialCopyDu->data, &nextDataUnit->nextCoderType ); + get_NextCoderType_fx( partialCopyDu->data, &nextDataUnit->nextCoderType ); BREAK; } } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c2b52ecd1..18a062f60 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2870,7 +2870,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( } /* check if frame contains a partial copy and get its offset */ - evs_dec_previewFrame_float( au, auSize, &partialCopyFrameType, &partialCopyOffset ); + evs_dec_previewFrame( au, auSize, &partialCopyFrameType, &partialCopyOffset ); /* create data unit for primary copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 230c58c44..6ca4545f2 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1760,7 +1760,7 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( return error; } - +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * IVAS_ENC_EncodeFrameToCompact() * @@ -1787,7 +1787,7 @@ ivas_error IVAS_ENC_EncodeFrameToCompact( return IVAS_ERR_OK; } - +#endif /*---------------------------------------------------------------------* * IVAS_ENC_SetBandwidth() diff --git a/lib_rend/ivas_masa_merge.c b/lib_rend/ivas_masa_merge.c index 8652e2c71..9f7d8f7f1 100644 --- a/lib_rend/ivas_masa_merge.c +++ b/lib_rend/ivas_masa_merge.c @@ -822,7 +822,7 @@ void masaPrerendClose_fx( FOR( i = 0; i < ( *hMasaPrerendPtr )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas( &( ( *hMasaPrerendPtr )->cldfbAnaEnc[i] ) ); + deleteCldfb_ivas_fx( &( ( *hMasaPrerendPtr )->cldfbAnaEnc[i] ) ); } free( ( *hMasaPrerendPtr )->hMasaOut ); diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index 8149ee639..5666cba22 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -663,7 +663,7 @@ void ivas_mcmasa_ana_close( FOR( i = 0; i < ( *hMcMasa )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas( &( ( *hMcMasa )->cldfbAnaEnc[i] ) ); + deleteCldfb_ivas_fx( &( ( *hMcMasa )->cldfbAnaEnc[i] ) ); } /* intensity 3-dim */ diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 382632999..cbd860f49 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -286,6 +286,7 @@ void TDREND_Apply_ITD_fx( * The sinc resampling reads SFX_SPAT_BIN_SINC_M (5) samples outside of * the target frame. *---------------------------------------------------------------------*/ + #ifndef IVAS_FLOAT_FIXED static void sincResample( const float *input, /*i : Input signal */ @@ -350,7 +351,6 @@ static void sincResample( return; } - #else static void sincResample_fx( const Word32 *input_fx, /*i : Input signal Qx */ @@ -366,7 +366,7 @@ static void sincResample_fx( Word16 t_step_e; Word32 t_frac_fx; Word16 t_frac_e; - Word32 tmp_fx; + Word64 tmp64_fx; const Word32 *p_mid_fx; const Word32 *p_forward_fx; const Word32 *p_backward_fx; @@ -413,20 +413,20 @@ static void sincResample_fx( p_sinc_forward_fx = SincTable_fx + sub( SFX_SPAT_BIN_NUM_SUBSAMPLES, snc0 ); p_sinc_backward_fx = SincTable_fx + add( SFX_SPAT_BIN_NUM_SUBSAMPLES, snc0 ); - tmp_fx = Mpy_32_32( *p_mid_fx, SincTable_fx[snc0] ); /* Middle point */ + tmp64_fx = W_mult_32_32( *p_mid_fx, SincTable_fx[snc0] ); /* Middle point */ FOR( j = 0; j < SFX_SPAT_BIN_SINC_M - 1; j++ ) { - tmp_fx = L_add( tmp_fx, L_add( Mpy_32_32( *p_forward_fx, *p_sinc_forward_fx ), Mpy_32_32( *p_backward_fx, *p_sinc_backward_fx ) ) ); + tmp64_fx = W_add( tmp64_fx, W_mac_32_32( W_mult_32_32( *p_forward_fx, *p_sinc_forward_fx ), *p_backward_fx, *p_sinc_backward_fx ) ); p_sinc_forward_fx += SFX_SPAT_BIN_NUM_SUBSAMPLES; p_sinc_backward_fx += SFX_SPAT_BIN_NUM_SUBSAMPLES; p_forward_fx++; p_backward_fx--; } - tmp_fx = L_add( tmp_fx, Mpy_32_32( *p_forward_fx, *p_sinc_forward_fx ) ); /* Integer index always rounded down --> 4 steps backward, 5 steps forward */ + tmp64_fx = W_mac_32_32( tmp64_fx, *p_forward_fx, *p_sinc_forward_fx ); /* Integer index always rounded down --> 4 steps backward, 5 steps forward */ - output_fx[i] = tmp_fx; + output_fx[i] = W_extract_h( tmp64_fx ); move32(); /* Advance fractional time */ @@ -445,6 +445,7 @@ static void sincResample_fx( * --------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void TDREND_firfilt( float *signal, /* i/o: Input signal / Filtered signal */ float *filter, /* i/o: FIR filter */ @@ -497,8 +498,7 @@ void TDREND_firfilt( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void TDREND_firfilt_fx( Word32 *signal_fx, /* i/o: Input signal / Filtered signal Qx */ Word32 *filter_fx, /* i/o: FIR filter Qy */ @@ -521,6 +521,7 @@ void TDREND_firfilt_fx( Word32 tmp_fx; Word16 step_fx, gain_tmp_fx, gain_delta_fx; Word16 tmp_e; + Word64 tmp64_fx; gain_delta_fx = sub( Gain_fx, prevGain_fx ); // Q14 step_fx = BASOP_Util_Divide1616_Scale( gain_delta_fx, subframe_length, &tmp_e ); @@ -537,8 +538,8 @@ void TDREND_firfilt_fx( /* Convolution */ FOR( i = 0; i < subframe_length; i++ ) { - tmp_fx = 0; - move32(); + tmp64_fx = 0; + move64(); tmp_e = 0; move16(); p_tmp_fx = p_signal_fx + i; @@ -547,12 +548,14 @@ void TDREND_firfilt_fx( FOR( j = 0; j < filterlength; j++ ) { - tmp_fx = L_add( tmp_fx, Mpy_32_32( *p_filter_fx, *p_tmp_fx ) ); + tmp64_fx = W_mac_32_32( tmp64_fx, *p_filter_fx, *p_tmp_fx ); p_filter_fx++; p_tmp_fx--; } - tmp_fx = L_shl( tmp_fx, filter_e ); // This is done to keep the output Q same as input Q for signal + // This is done to keep the output Q same as input Q for signal + tmp64_fx = W_shl( tmp64_fx, filter_e ); + tmp_fx = W_extract_h( tmp64_fx ); /* Apply linear gain interpolation in case of abrupt gain changes */ gain_tmp_fx = add( gain_tmp_fx, step_fx ); diff --git a/lib_rend/ivas_omasa_ana.c b/lib_rend/ivas_omasa_ana.c index 476cbbe3e..630865169 100644 --- a/lib_rend/ivas_omasa_ana.c +++ b/lib_rend/ivas_omasa_ana.c @@ -379,7 +379,7 @@ void ivas_omasa_ana_close( FOR( i = 0; i < ( *hOMasa )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); + deleteCldfb_ivas_fx( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); } FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 4868919f8..dc331271f 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1640,6 +1640,7 @@ void TDREND_Apply_ITD_fx( ); #endif +#ifndef IVAS_FLOAT_FIXED void TDREND_firfilt( float *signal, /* i/o: Input signal / Filtered signal */ float *filter, /* i/o: FIR filter */ @@ -1651,7 +1652,7 @@ void TDREND_firfilt( const float Gain, /* i : Gain */ const float prevGain /* i : Previous gain */ ); -#ifdef IVAS_FLOAT_FIXED +#else void TDREND_firfilt_fx( Word32 *signal_fx, /* i/o: Input signal / Filtered signal Qx */ Word32 *filter_fx, /* i/o: FIR filter Qy */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3db18bcf1..45d03afd3 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -15051,7 +15051,7 @@ static void freeMasaExtRenderer( { IF( hMasaExtRend->cldfbAnaRend[i] != NULL ) { - deleteCldfb_ivas( &hMasaExtRend->cldfbAnaRend[i] ); + deleteCldfb_ivas_fx( &hMasaExtRend->cldfbAnaRend[i] ); } } @@ -15059,7 +15059,7 @@ static void freeMasaExtRenderer( { IF( hMasaExtRend->cldfbSynRend[i] != NULL ) { - deleteCldfb_ivas( &hMasaExtRend->cldfbSynRend[i] ); + deleteCldfb_ivas_fx( &hMasaExtRend->cldfbSynRend[i] ); } } -- GitLab From a58dd2e5238e15ac0af4124fa9987478c340ac31 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 23 Jul 2024 17:51:35 +0530 Subject: [PATCH 2/5] EVS encoder build fix --- lib_com/bitstream_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index f7dd3942b..1dc907e43 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -683,7 +683,6 @@ void write_indices_fx( return; } -#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * write_indices_buf_fx() * @@ -787,7 +786,6 @@ void write_indices_buf_fx( return; } -#endif /*-------------------------------------------------------------------* * indices_to_serial() * -- GitLab From 3a9afe2eb58b190e199175526392c876f31c0bd2 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 23 Jul 2024 19:48:48 +0530 Subject: [PATCH 3/5] EVS bit exactness fix --- lib_com/bits_alloc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index cbcf41090..1e1fd7552 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -1194,7 +1194,7 @@ ivas_error config_acelp1( } } - bits = sub( bits, idiv1616( sub( L_FRAME16k - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ + bits -= ( L_FRAME16k - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */ } /* glottal-shape codebook bits */ -- GitLab From 74002a2c8a0cd3ab8e5732b6c28e8705c7f0d2ce Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 23 Jul 2024 21:24:11 +0530 Subject: [PATCH 4/5] Added switch for new BASOP introduced --- lib_com/enh64.c | 3 ++- lib_com/enh64.h | 3 ++- lib_com/options.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_com/enh64.c b/lib_com/enh64.c index b59a9ef6c..f5b11d525 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -1062,6 +1062,7 @@ Word64 W_msu_16_16( Word64 L64_var1, Word16 var2, Word16 var3 ) return L64_var_out; } +#ifdef STL_BASOP_UPDATES /*________________________________________________________________________________________________ | | | Function Name : W_mac_32_32 | @@ -1110,7 +1111,7 @@ Word64 W_mac_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) return L64_var_out; } - +#endif /*___________________________________________________________________________ | | diff --git a/lib_com/enh64.h b/lib_com/enh64.h index efc58e83e..b9798401d 100644 --- a/lib_com/enh64.h +++ b/lib_com/enh64.h @@ -36,8 +36,9 @@ Word64 W_msu0_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); Word64 W_mult_16_16( Word16 var1, Word16 var2 ); Word64 W_mac_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); Word64 W_msu_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); +#ifdef STL_BASOP_UPDATES Word64 W_mac_32_32( Word64 L64_acc, Word32 var1, Word32 var2 ); - +#endif // STL_BASOP_UPDATES Word64 W_deposit32_l( Word32 L_var1 ); Word64 W_deposit32_h( Word32 L_var1 ); diff --git a/lib_com/options.h b/lib_com/options.h index 34e869556..daaeaf4ff 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,7 +156,7 @@ #define FIX_802__NON_BE_DECODING /* Fix possible difference float and fixed point when computing the GSC bit allocation */ #define FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING /* VA: ISSUES 802 and 1137 Made sure that float and fixed point GCS bit allocation is the same during IVAS modes */ - +#define STL_BASOP_UPDATES /* BASOPS which are not part of STL 2023 library, might be proposed in next update */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ -- GitLab From 995ba50833190dda0447acf2581c0a75bc513612 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 23 Jul 2024 21:32:11 +0530 Subject: [PATCH 5/5] Added comments for W_mac_32_32 BASOP which is not part of STL library. --- lib_com/enh64.c | 3 +-- lib_com/enh64.h | 5 +++-- lib_com/options.h | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_com/enh64.c b/lib_com/enh64.c index f5b11d525..66068baba 100644 --- a/lib_com/enh64.c +++ b/lib_com/enh64.c @@ -1062,7 +1062,7 @@ Word64 W_msu_16_16( Word64 L64_var1, Word16 var2, Word16 var3 ) return L64_var_out; } -#ifdef STL_BASOP_UPDATES +/* Below BASOP is not part of STL 2023 library, might be proposed in next update */ /*________________________________________________________________________________________________ | | | Function Name : W_mac_32_32 | @@ -1111,7 +1111,6 @@ Word64 W_mac_32_32( Word64 L64_var1, Word32 L_var2, Word32 L_var3 ) return L64_var_out; } -#endif /*___________________________________________________________________________ | | diff --git a/lib_com/enh64.h b/lib_com/enh64.h index b9798401d..8abfd0e80 100644 --- a/lib_com/enh64.h +++ b/lib_com/enh64.h @@ -36,9 +36,10 @@ Word64 W_msu0_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); Word64 W_mult_16_16( Word16 var1, Word16 var2 ); Word64 W_mac_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); Word64 W_msu_16_16( Word64 L64_acc, Word16 var1, Word16 var2 ); -#ifdef STL_BASOP_UPDATES + +/* BASOP W_mac_32_32 is not part of STL 2023 library, might be proposed in next update */ Word64 W_mac_32_32( Word64 L64_acc, Word32 var1, Word32 var2 ); -#endif // STL_BASOP_UPDATES + Word64 W_deposit32_l( Word32 L_var1 ); Word64 W_deposit32_h( Word32 L_var1 ); diff --git a/lib_com/options.h b/lib_com/options.h index daaeaf4ff..d4311a564 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,7 +156,6 @@ #define FIX_802__NON_BE_DECODING /* Fix possible difference float and fixed point when computing the GSC bit allocation */ #define FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING /* VA: ISSUES 802 and 1137 Made sure that float and fixed point GCS bit allocation is the same during IVAS modes */ -#define STL_BASOP_UPDATES /* BASOPS which are not part of STL 2023 library, might be proposed in next update */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ -- GitLab