diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index 2d06d29aa90604e44237a3feaf6dc21c57fa4850..12f77b3461b2cd30cd3cf9645c8e423c797c86d4 100644
--- a/Workspace_msvc/lib_dec.vcxproj
+++ b/Workspace_msvc/lib_dec.vcxproj
@@ -139,10 +139,7 @@
false
-
- false
-
-
+
diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters
index 8a4fc4605a1170b9da66c90a81b8bdd4134573c7..25079058ca86d0ba17ed45fb351d4ddfa144612a 100644
--- a/Workspace_msvc/lib_dec.vcxproj.filters
+++ b/Workspace_msvc/lib_dec.vcxproj.filters
@@ -119,12 +119,6 @@
decoder_all_c
-
- decoder_all_c
-
-
- decoder_all_c
-
decoder_all_c
@@ -518,6 +512,9 @@
decoder_ivas_c
+
+ decoder_all_c
+
diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c
index e9abb7651e854e529e6ebfbb5a43857cb5d4696a..3bfcd0c20a7a8696fbc479e6363951de2f377807 100644
--- a/lib_com/bits_alloc_fx.c
+++ b/lib_com/bits_alloc_fx.c
@@ -434,174 +434,12 @@ static Word16 fcb_table(
}
/*-------------------------------------------------------------------*
- * acelp_FCB_allocator()
+ * acelp_FCB_allocator_fx()
*
* Routine to allocate fixed innovation codebook bit-budget
*--------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
-static ivas_error acelp_FCB_allocator(
- Word16 *nBits, /* i/o: available bit-budget */
- Word16 fixed_cdk_index[], /* o : codebook index Q0 */
- Word16 nb_subfr, /* i : number of subframes */
- const Word16 L_subfr, /* i : subframe length */
- const Word16 coder_type, /* i : coder type */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 fix_first /* i : flag to indicate whether the first subframe bit-budget was fixed */
-)
-{
- Word16 cdbk, sfr, step;
- Word16 nBits_tmp;
- Word16 *p_fixed_cdk_index;
- Word16 max_n;
- ivas_error error;
- // PMT("Not floating point computation, but fixed point operator are still missing ")
-
- error = IVAS_ERR_OK;
- move32();
-
- cdbk = coder_type; /* just to avoid warning when DEBUGGING is deactivated */
- move16();
-
- p_fixed_cdk_index = fixed_cdk_index;
-
- /* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse not in the first subframe */
- test();
- IF( GE_16( tc_subfr, L_SUBFR ) && fix_first )
- {
- Word16 i;
-
- FOR( i = 0; i < nb_subfr; 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;
- move16();
- IF( fix_first )
- {
- *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( GT_16( L_subfr, L_SUBFR ) ) /* access fast_FCB_bits_2sfr */
- {
- max_n = 6;
- move16();
- }
- ELSE
- {
- max_n = ACELP_FIXED_CDK_NB;
- move16();
- }
- FOR( cdbk = 0; cdbk < max_n; cdbk++ )
- {
- IF( GT_32( L_mult0( fcb_table( cdbk, L_subfr ), nb_subfr ), L_deposit_l( *nBits ) ) )
- {
- BREAK;
- }
- }
- cdbk = sub( cdbk, 1 );
-
-#ifdef DEBUGGING
- if ( cdbk < 0 && coder_type != TRANSITION )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bit-budget for fixed innovation codebook (frame = %d). Exiting! \n" );
- }
- if ( ( L_subfr == L_SUBFR && cdbk >= ACELP_FIXED_CDK_NB ) || ( L_subfr == 2 * L_SUBFR && fcb_table( cdbk, L_subfr ) == 128 /*stop value*/ ) )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too high bit-budget for fixed innovation codebook (frame = %d). Exiting! \n" );
- }
-#endif
-
- set16_fx( p_fixed_cdk_index, cdbk, nb_subfr );
- nBits_tmp = 0;
- move16();
- IF( cdbk >= 0 )
- {
- nBits_tmp = fcb_table( cdbk, L_subfr );
- }
- ELSE
- {
- nBits_tmp = 0;
- move16();
- }
- *nBits = sub( *nBits, i_mult( nBits_tmp, nb_subfr ) );
- move16();
-
- /* try to increase the FCB bit-budget of the first subframe(s) */
- IF( LT_16( cdbk, ACELP_FIXED_CDK_NB - 1 ) )
- {
- step = sub( fcb_table( add( cdbk, 1 ), L_subfr ), nBits_tmp );
- WHILE( *nBits >= step )
- {
- ( *p_fixed_cdk_index )++;
- *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 = 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] = add( fixed_cdk_index[sfr], 1 );
- move16();
- *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 = add( sfr, 1 );
- fixed_cdk_index[sfr] = add( fixed_cdk_index[sfr], 1 );
- move16();
- *nBits = sub( *nBits, step );
- move16();
- }
- }
- }
- /* TRANSITION coding: allocate highest FCBQ bit-budget to the subframe with the glottal-shape codebook */
- 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( 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] );
- }
- }
-
- /* when subframe length > L_SUBFR, number of bits instead of codebook index is signalled */
- IF( GT_16( L_subfr, L_SUBFR ) )
- {
- Word16 i, j;
- FOR( i = 0; i < nb_subfr; i++ )
- {
- j = fixed_cdk_index[i];
- move16();
- fixed_cdk_index[i] = fast_FCB_bits_2sfr[j];
- move16();
- }
- }
-
- return error;
-}
-#endif
-static ivas_error acelp_FCB_allocator_ivas(
+static ivas_error acelp_FCB_allocator_fx(
Word16 *nBits, /* i/o: available bit-budget */
Word16 fixed_cdk_index[], /* o : codebook index Q0 */
Word16 nb_subfr, /* i : number of subframes */
@@ -754,1141 +592,16 @@ static ivas_error acelp_FCB_allocator_ivas(
return error;
}
+
/*-------------------------------------------------------------------*
- * config_acelp1()
+ * config_acelp1_fx()
*
* Configure ACELP bit allocation
* - should be in range of <6700; 24350> for ACELP@12.8kHz
* - per channel bitrate minimum is 13250 kbps for ACELP@16kHz
*--------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
-ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
- const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
- const Word16 tc_subfr, /* i : TC subfr ID */
- const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
- Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- Word16 *unbits, /* o : number of unused bits */
- const Word16 element_mode, /* i : element mode */
- Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 idchan, /* i : stereo channel ID */
- const Word16 active_cnt, /* i : Active frame counter */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
-)
-{
- Word16 i, bits, nb_subfr;
- Word16 flag_hardcoded, coder_type_sw, fix_first;
- Word32 core_brate;
-#ifdef DEBUGGING
- (void) active_cnt;
-#endif
- 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;
- move16();
- IF( EQ_16( coder_type, UNVOICED ) )
- {
- 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();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Set the number of subframes
- *-----------------------------------------------------------------*/
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- nb_subfr = NB_SUBFR;
- move16();
-
-#ifdef 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 ) )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bitrate (%d bps) for ACELP@12k8 in frame %d. Exiting!\n", core_brate_inp );
- }
-
- if ( core_brate_inp > ACELP_12k8_HIGH_LIMIT && core == ACELP_CORE )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too high bitrate (%d bps) for ACELP@12k8 in frame %d. Exiting!\n", core_brate_inp );
- }
-#endif
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- nb_subfr = NB_SUBFR16k;
- move16();
-
-#ifdef DEBUGGING
- if ( core_brate_inp < ACELP_16k_LOW_LIMIT && core == ACELP_CORE )
- {
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bitrate (%d bps) for ACELP@16k in frame %d. Exiting!\n", core_brate_inp );
- }
-#endif
- }
-
- coder_type_sw = coder_type;
- move16();
- IF( core != ACELP_CORE )
- {
- /* used in acelp_core_switch_enc() */
- nb_subfr = 1;
- move16();
- if ( EQ_16( L_frame, L_FRAME ) )
- {
- coder_type_sw = TRANSITION;
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Check if the core_brate is hard coded (to keep BE for mono core) or not
- *-----------------------------------------------------------------*/
-
- flag_hardcoded = 0;
- move16();
- i = 0;
- move16();
-
- WHILE( i < SIZE_BRATE_INTERMED_TBL )
- {
- IF( EQ_32( core_brate_inp, brate_intermed_tbl[i] ) )
- {
- flag_hardcoded = 1;
- move16();
- BREAK;
- }
-
- IF( LT_32( core_brate_inp, brate_intermed_tbl[i] ) )
- {
- flag_hardcoded = 0;
- move16();
- BREAK;
- }
-
- i = add( i, 1 );
- }
-
- 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 = 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
- *-----------------------------------------------------------------*/
- test();
- test();
- IF( !( EQ_16( coder_type, TRANSITION ) && NE_16( tc_subfr, -1 ) ) || EQ_16( enc_dec, DEC ) )
- {
- /* Set the bit-budget */
- bits = extract_l( Mpy_32_32( core_brate_inp, ONE_BY_FRAMES_PER_SEC_Q31 ) ); // Q0
-
- test();
- test();
- IF( EQ_16( coder_type, TRANSITION ) && EQ_16( enc_dec, DEC ) && EQ_16( tc_call, 1 ) )
- {
- bits = add( bits, *nBits_es_Pred ); /* equalize for 4th signaling bit estimated at the encoder in TC_0_192 */
- }
-
- /* Subtract signalling bits */
- test();
- test();
- IF( EQ_16( enc_dec, DEC ) && EQ_16( idchan, 1 ) && element_mode > EVS_MONO )
- {
- bits = sub( bits, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS );
-
- IF( EQ_16( tdm_LRTD_flag, 1 ) )
- {
- bits = add( bits, STEREO_BITS_TCA );
- }
-
- /* subtract TBE/BWE flag */
- 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 = sub( bits, 1 );
- }
- }
- ELSE
- {
- /* Subtract signalling bits */
- bits = sub( bits, signalling_bits );
- }
-
- 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 = add( bits, 1 );
- }
-
- /*-----------------------------------------------------------------*
- * LSF Q bit-budget
- *-----------------------------------------------------------------*/
- 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( EQ_16( L_frame, L_FRAME ) )
- {
- 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( ( 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 && EQ_16( coder_type, AUDIO ) && LT_32( brate_intermed_tbl[i], ACELP_9k60 ) )
- {
- /* primary channel: do nothing */
- }
- 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( LE_32( total_brate, 9600 ) || EQ_16( coder_type, UNVOICED ) )
- {
- acelp_cfg->lsf_bits = 31;
- move16();
- }
- ELSE IF( LE_32( total_brate, 20000 ) )
- {
- acelp_cfg->lsf_bits = 36;
- move16();
- }
- ELSE
- {
- acelp_cfg->lsf_bits = 41;
- move16();
- }
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- acelp_cfg->lsf_bits = 41;
- move16();
- }
- }
-
- 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();
-
- 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 = sub( bits, acelp_cfg->mid_lsf_bits );
- }
- ELSE IF( EQ_16( tdm_lp_reuse_flag, 1 ) && EQ_16( idchan, 1 ) && NE_16( active_cnt, 1 ) )
- {
- bits = sub( bits, TDM_IC_LSF_PRED_BITS );
- }
- /* gain Q bit-budget - part 1: 'Es_pred' of memory-less gain Q */
- 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 ) ) ) /* mid bitrates in GC and VC, low+mid bitrates in TC */ ||
- ( coder_type == INACTIVE && !inactive_coder_type_flag ) /* AVQ inactive */
- )
- {
- *nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, -1 )];
- move16();
- bits = sub( bits, *nBits_es_Pred );
- }
- ELSE IF( *uc_two_stage_flag )
- {
- *nBits_es_Pred = 4;
- move16();
- bits = sub( bits, *nBits_es_Pred );
- }
- }
- ELSE
- {
- bits = *unbits;
- move16();
- }
-
- test();
- IF( EQ_16( coder_type, TRANSITION ) && tc_call == 0 )
- {
- *unbits = bits;
- return error;
- }
-
- /*-----------------------------------------------------------------*
- * Low-rate mode - bits are allocated in tdm_low_rate_enc()
- *-----------------------------------------------------------------*/
- 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;
- }
-
- /*-----------------------------------------------------------------*
- * Supplementary information for FEC
- *-----------------------------------------------------------------*/
-
- acelp_cfg->FEC_mode = 0;
- move16();
- test();
- test();
- IF( GE_32( core_brate, ACELP_11k60 ) && ( idchan == 0 || element_mode == EVS_MONO ) )
- {
- acelp_cfg->FEC_mode = 1;
- move16();
-
- test();
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && NE_16( coder_type, VOICED ) )
- {
- bits = sub( bits, FEC_BITS_CLS );
- }
-
- IF( NE_16( coder_type, TRANSITION ) )
- {
- IF( GE_32( total_brate, ACELP_16k40 ) )
- {
- acelp_cfg->FEC_mode = 2;
- move16();
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) )
- {
- bits = sub( bits, FEC_BITS_ENR );
- }
- }
-
- IF( GE_32( total_brate, ACELP_32k ) )
- {
- acelp_cfg->FEC_mode = 3;
- move16();
-
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) )
- {
- bits = sub( bits, FEC_BITS_POS );
- }
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * LP filtering of the adaptive excitation
- *-----------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- test();
- test();
- IF( idchan > 0 && element_mode > EVS_MONO )
- {
- acelp_cfg->ltf_mode = FULL_BAND;
- move16();
- }
- ELSE IF( EQ_16( coder_type, UNVOICED ) )
- {
- acelp_cfg->ltf_mode = FULL_BAND;
- move16();
- }
- ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) ) && LT_32( core_brate, ACELP_11k60 ) )
- {
- acelp_cfg->ltf_mode = LOW_PASS;
- move16();
- }
- ELSE IF( GE_32( core_brate, ACELP_11k60 ) && ( NE_16( coder_type, AUDIO ) && !( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME ) ) ) )
- {
- test();
- test();
- IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && inactive_coder_type_flag ) /* GSC Inactive @16kHz */
- {
- acelp_cfg->ltf_mode = FULL_BAND;
- move16();
- }
- ELSE
- {
- acelp_cfg->ltf_mode = NORMAL_OPERATION;
- move16();
- IF( coder_type != TRANSITION )
- {
- bits = sub( bits, nb_subfr );
- }
- }
- }
- ELSE
- {
- acelp_cfg->ltf_mode = FULL_BAND;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * UC bit-budget
- *-----------------------------------------------------------------*/
- 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 = sub( bits, NBITS_NOISENESS ); /* noiseness */
- }
- IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) )
- {
- bits = sub( bits, 3 * NB_SUBFR ); /* tilt factor */
- }
-
- /*-----------------------------------------------------------------*
- * TC bit-budget
- *-----------------------------------------------------------------*/
-
- fix_first = 0;
- move16();
- IF( EQ_16( coder_type, TRANSITION ) )
- {
- if ( EQ_16( tc_call, 2 ) )
- {
- fix_first = 1;
- move16();
- }
-
- /* TC signalling */
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- IF( EQ_16( tc_subfr, TC_0_0 ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 1 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, 3 ); /* LP filtering flag */
- }
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_64 ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 4 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, 3 ); /* LP filtering flag */
- }
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_128 ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 4 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, 2 ); /* LP filtering flag */
- }
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_192 ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 3 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, 1 ); /* LP filtering flag */
- }
- }
- ELSE IF( EQ_16( tc_subfr, L_SUBFR ) )
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 3 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, idiv1616( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */
- }
- }
- ELSE
- {
- IF( enc_dec == ENC )
- {
- bits = sub( bits, 4 ); /* TC signalling */
- }
-
- IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) )
- {
- bits = sub( bits, idiv1616_1( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */
- }
- }
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- IF( enc_dec == ENC )
- {
- IF( LE_16( tc_subfr, 2 * L_SUBFR ) )
- {
- bits = sub( bits, 2 ); /* TC signalling */
- }
- ELSE
- {
- bits = sub( bits, 3 ); /* TC signalling */
- }
- }
-
- // bits -= ( L_FRAME16k - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */
- bits = sub( bits, idiv1616_1( sub( L_FRAME16k - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */
- }
-
- /* glottal-shape codebook bits */
- bits = sub( bits, 3 + 6 + 1 + 3 );
- }
-
- /*-----------------------------------------------------------------*
- * pitch, innovation, gains bit-budget
- *-----------------------------------------------------------------*/
-
- acelp_cfg->fcb_mode = 0;
- 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++ )
- {
- acelp_cfg->pitch_bits[i] = 0;
- move16();
- IF( tdm_Pitch_reuse_flag == 0 )
- {
- 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_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- bits = sub( bits, acelp_cfg->gains_mode[i] );
- }
- acelp_cfg->fcb_mode = 1;
- move16();
-
-#ifdef DEBUGGING
- if ( bits >= 55 )
- {
- printf( "too much bits -> %d, LPC = %d and pitch = %d\n", bits, tdm_lp_reuse_flag, tdm_Pitch_reuse_flag );
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
- }
- else
-#endif
- 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 && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || /* @12.8kHz core except of GSC */
- ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) /* @16kHz core GC, TC, AVQ inactive */ ||
- EQ_16( core, HQ_CORE ) /* ACELP -> HQ switching in EVS */
- )
- {
- /* pitch Q & gain Q bit-budget - part 2*/
- FOR( i = 0; i < nb_subfr; i++ )
- {
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- test();
- IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) )
- {
- acelp_cfg->pitch_bits[i] = 0;
- move16();
- }
- ELSE
- {
- 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_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- test();
- IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) )
- {
- acelp_cfg->pitch_bits[i] = 0;
- move16();
- }
- ELSE
- {
- 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_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
- move16();
- }
-
- bits = sub( bits, acelp_cfg->pitch_bits[i] );
-
- test();
- IF( coder_type == INACTIVE && EQ_16( acelp_cfg->gains_mode[i], 6 ) /* VQ vs. SQ threshold @32 kbps */ )
- {
- bits = sub( bits, 5 );
- }
- ELSE
- {
- if ( EQ_16( *uc_two_stage_flag, 1 ) )
- {
- acelp_cfg->gains_mode[i] = 7;
- move16();
- }
-
- bits = sub( bits, acelp_cfg->gains_mode[i] );
- }
- }
-
- /* algebraic codebook bit-budget */
- test();
- test();
- test();
- test();
- test();
- test();
- IF( flag_hardcoded /* EVS */ ||
- ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
- ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
- {
- FOR( i = 0; i < nb_subfr; i++ )
- {
- 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_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )];
- move16();
- }
- 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_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )];
- move16();
- }
- bits = sub( bits, acelp_cfg->fixed_cdk_index[i] );
- }
- }
- ELSE IF( !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
- {
- test();
- IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) )
- {
- i = idiv1616( bits, NB_SUBFR );
- IF( s_and( i, 1 ) == 0 )
- {
- i = sub( i, 1 ); /* must be odd */
- }
- i = s_min( i, 13 );
-#ifdef DEBUG_MODE_TD
- if ( i < 0 )
- IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR::: UC negative index should not happen at frame %d\n" );
-#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 = sub( bits, i_mult( i, NB_SUBFR ) );
- }
- ELSE
- {
-
- acelp_cfg->fcb_mode = 1;
- move16();
- test();
- test();
- IF( EQ_16( element_mode, IVAS_CPE_TD ) )
- {
- 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( 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( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 2 ) ) ) )
- {
- 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( 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 */
- {
-#ifdef 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( NE_16( 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
- {
- acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
- }
- }
- }
-
- /* AVQ codebook */
- test();
- test();
- test();
- IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ ||
- ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ )
- {
- FOR( i = 0; i < nb_subfr; i++ )
- {
- IF( flag_hardcoded )
- {
- 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 = sub( bits, acelp_cfg->AVQ_cdk_bits[i] );
- }
- }
-
- bits = sub( bits, G_AVQ_BITS );
- }
-
- 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 = sub( bits, 1 );
- }
-
- IF( !flag_hardcoded )
- {
- Word16 bit_tmp;
-
- bit_tmp = idiv1616( bits, nb_subfr );
- set16_fx( acelp_cfg->AVQ_cdk_bits, bit_tmp, nb_subfr );
- bits = sub( bits, i_mult( bit_tmp, nb_subfr ) );
-
- bit_tmp = bits % nb_subfr;
- move16();
- acelp_cfg->AVQ_cdk_bits[0] = add( acelp_cfg->AVQ_cdk_bits[0], bit_tmp );
- move16();
- bits = sub( bits, bit_tmp );
- }
- }
- }
- ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) /* LBR secondary channel in TD stereo */ ||
- ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) /* GSC @12.8kHz */ ||
- ( coder_type == INACTIVE && inactive_coder_type_flag ) /* AVQ inactive */ )
- {
- Word32 Local_BR, Pitch_BR;
- Word16 Pitch_CT;
-
- /* as defined at the beginning of [enc,dec]_pit_exc() */
- 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;
- move32();
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- Local_BR = ACELP_14k80;
- 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 )
- {
- Local_BR = ACELP_7k20;
- move32();
- Pitch_CT = GENERIC;
- move16();
- Pitch_BR = ACELP_7k20;
- move32();
- if ( EQ_16( L_frame, L_FRAME16k ) )
- {
- Pitch_BR = core_brate;
- move32();
- }
- }
- ELSE
- {
- Local_BR = ACELP_7k20;
- move32();
- Pitch_CT = AUDIO;
- move16();
- Pitch_BR = core_brate;
- move32();
-
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- Local_BR = ACELP_13k20;
- move32();
- Pitch_CT = GENERIC;
- move16();
- }
- }
-
- FOR( i = 0; i < nb_subfr; i++ )
- {
- 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_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
- {
- 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();
- }
- }
- }
-
- 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;
- }
-
- /*-----------------------------------------------------------------*
- * unused bits handling
- *-----------------------------------------------------------------*/
-
- acelp_cfg->ubits = 0; /* these bits could be reused for something else */
- move16();
-
- test();
- IF( flag_hardcoded && NE_32( core_brate, PPP_NELP_2k80 ) )
- {
- test();
- test();
- /* unused bits */
- IF( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_24k40 ) ) )
- {
- acelp_cfg->ubits = 0;
- move16();
- }
- 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
- {
- acelp_cfg->ubits = 0;
- move16();
- }
-
- bits = sub( bits, acelp_cfg->ubits );
- }
-
- /* sanity check */
- test();
- test();
- test();
- IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || EQ_16( nb_subfr, NB_SUBFR16k ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ ||
- ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* IVAS GSC @16kHz */
- {
- acelp_cfg->ubits = 0;
- move16();
- }
- ELSE IF( flag_hardcoded && core == ACELP_CORE && bits != 0 )
- {
-#ifdef DEBUGGING
- IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits );
-#endif
- }
- ELSE IF( bits > 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
- {
- test();
- test();
- test();
- test();
- IF( idchan > 0 && EQ_16( element_mode, IVAS_CPE_TD ) )
- {
- IF( !tdm_lp_reuse_flag )
- {
- acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */
- move16();
- bits = 0;
- move16();
- }
- ELSE
- {
- Word16 nb_prm = 4;
- move16();
- if ( EQ_16( tdm_low_rate_mode, 1 ) )
- {
- nb_prm = 2;
- move16();
- }
- /* First add remaining bits on gains */
- bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, GAINSPRM, acelp_cfg->gains_mode ) );
-
- /* Then, Increase pitch bit budget */
- test();
- IF( tdm_Pitch_reuse_flag == 0 && bits > 0 )
- {
- bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, PITCHPRM, acelp_cfg->pitch_bits ) );
- }
-
- /* Increase mid-lsf bit budget */
- test();
- IF( tdm_lp_reuse_flag == 0 && bits > 0 )
- {
- 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 ) );
- }
- }
-
-#ifdef DEBUGGING
- if ( idchan > 0 && bits > 0 && ( coder_type > UNVOICED || tdm_low_rate_mode == 0 ) )
- {
- IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING !! Unused bits in secondary channel at frame %d\n" );
- }
-#endif
- }
-
- 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 = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */
- move16();
-
- test();
- IF( GT_16( acelp_cfg->lsf_bits, 46 ) )
- {
- acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 46 );
- move16();
- acelp_cfg->lsf_bits = 46;
- move16();
- }
- ELSE IF( GT_16( acelp_cfg->lsf_bits, 42 ) && EQ_16( L_frame, L_FRAME ) )
- {
- acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 42 );
- move16();
- acelp_cfg->lsf_bits = 42;
- move16();
- }
- }
- ELSE
- {
- acelp_cfg->ubits = bits;
- move16();
- }
- }
- ELSE IF( bits < 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) )
- {
-#ifdef DEBUGGING
- IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits );
-#endif
- }
- }
-
- return error;
-}
-
-/*-------------------------------------------------------------------*
- * config_acelp1_IVAS()
- *
- * Configure ACELP bit allocation
- * - should be in range of <6700; 24350> for ACELP@12.8kHz
- * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz
- *--------------------------------------------------------------------*/
-#endif
-ivas_error config_acelp1_IVAS(
+ivas_error config_acelp1_fx(
const Word16 enc_dec, /* i : encoder/decoder flag */
const Word32 total_brate, /* i : total bitrate */
const Word32 core_brate_inp, /* i : core bitrate */
@@ -2511,11 +1224,11 @@ ivas_error config_acelp1_IVAS(
IF( GE_16( bits, 16 ) )
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
}
ELSE
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 );
acelp_cfg->fixed_cdk_index[1] = -1;
move16();
}
@@ -2634,17 +1347,17 @@ ivas_error config_acelp1_IVAS(
{
IF( GE_16( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), nb_subfr ) ) ) /* enough bits for all fcb */
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
ELSE IF( GE_16( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 1 ) ) ) )
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 1 ), L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 1 ), L_SUBFR, coder_type, tc_subfr, fix_first );
acelp_cfg->fixed_cdk_index[3] = -1;
move16();
}
ELSE IF( GE_32( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 2 ) ) ) )
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &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;
@@ -2654,7 +1367,7 @@ ivas_error config_acelp1_IVAS(
}
ELSE IF( GE_32( bits, ACELP_FIXED_CDK_BITS( 0 ) ) )
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &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;
@@ -2680,11 +1393,11 @@ ivas_error config_acelp1_IVAS(
{
bits = 100; /* 9 kbps for fcb */
move16();
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
ELSE
{
- acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
+ acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first );
}
}
}
diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c
index 582fd3c8a763b3b305570f79ea874eab67d1e067..119811275e34a99e7b2f22226dc8385c9709fc6f 100644
--- a/lib_com/gs_inact_switching_fx.c
+++ b/lib_com/gs_inact_switching_fx.c
@@ -33,144 +33,24 @@
/*------------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/*------------------------------------------------------------------------*/
-
/*------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
-void Inac_swtch_ematch_fx(
- Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
- Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
- Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
- const Word16 coder_type, /* i : Coding mode */
- const Word16 L_frame, /* i : Frame lenght */
- const Word32 core_brate, /* i : Core bit rate */
- const Word16 Q_exc /* i : input and output format of exc2 */
- ,
- const Word16 bfi /* i : frame lost indicator */
- ,
- const Word16 last_core, /* i : Last core used */
- const Word16 last_codec_mode /* i : Last codec mode */
-)
-{
- Word16 Ener_per_bd[MBANDS_GN];
- Word16 ftmp;
- Word16 *pt_exc;
- Word16 j, i;
-
- Word16 exp, frac;
- Word32 L_tmp;
-
- /*--------------------------------------------------------------------------
- * average energy per band
- *--------------------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( coder_type, AUDIO ) && bfi == 0 )
- {
- Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 );
-
- /* reset long-term energy per band */
- FOR( i = 0; i < MBANDS_GN; i++ )
- {
- lt_ener_per_band[i] = Ener_per_bd[i];
- move16();
- }
- }
- ELSE IF( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || ( last_core != ACELP_CORE ) || NE_16( last_codec_mode, MODE1 ) )
- {
- /* Find spectrum and energy per band for GC and VC frames */
- edct_16fx( exc2, dct_exc_tmp, L_frame, 5, EVS_MONO );
-
- Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 );
-
- /* reset long-term energy per band */
- FOR( i = 0; i < MBANDS_GN; i++ )
- {
- lt_ener_per_band[i] = Ener_per_bd[i];
- move16();
- }
- }
- ELSE IF( ( coder_type == INACTIVE ) && LE_32( core_brate, ACELP_24k40 ) )
- {
- /* Find spectrum and energy per band for inactive frames */
- edct_16fx( exc2, dct_exc_tmp, L_frame, 5, EVS_MONO );
- Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 );
-
- /* More agressive smoothing in the first 50 frames */
- pt_exc = dct_exc_tmp;
- move16();
- FOR( i = 0; i < MBANDS_GN; i++ )
- {
- /* Compute smoothing gain to apply with gain limitation */
- L_tmp = L_mult( ALPHA0_FX, lt_ener_per_band[i] ); /*Q(15+12+1)=Q(28) */
- L_tmp = L_mac( L_tmp, BETA0_FX, Ener_per_bd[i] ); /*Q28 */
- lt_ener_per_band[i] = round_fx( L_tmp ); /*Q12 */
- move16();
-
- ftmp = sub( lt_ener_per_band[i], Ener_per_bd[i] ); /*Q12 */
-
- /* ftmp = (float)pow(10, ftmp);= pow(2,3.321928*ftmp);*/
-
- L_tmp = L_mult( 27213, ftmp ); /*Q(13+12+1)=Q26 ; 27213=3.321928 in Q13 */
- L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of ftmp */
- ftmp = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
-
- exp = sub( exp, 14 );
- IF( LT_16( i, 2 ) )
- {
- FOR( j = 0; j < 8; j++ )
- {
- L_tmp = L_mult( *pt_exc, ftmp ); /* Q_exc*Q0 -> Q(Q_exc+1) */
- L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/
- *pt_exc = round_fx_sat( L_tmp );
- move16();
- pt_exc++;
- }
- }
- ELSE
- {
- FOR( j = 0; j < 16; j++ )
- {
- L_tmp = L_mult( *pt_exc, ftmp ); /* Q_exc*Q0 -> Q(Q_exc+1) */
- L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/
- *pt_exc = round_fx_sat( L_tmp ); /*Q_exc*/
- move16();
- pt_exc++;
- }
- }
- }
-
- /* Going back to time */
- edct_16fx( dct_exc_tmp, exc2, L_frame, 5, EVS_MONO );
- }
-
- return;
-}
-#endif
-void Inac_switch_ematch_ivas_fx(
+void Inac_switch_ematch_fx(
Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
const Word16 coder_type, /* i : Coding mode */
- const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
const Word16 L_frame, /* i : Frame lenght */
const Word16 Q_exc, /* i : input and output format of exc2 */
const Word16 bfi, /* i : frame lost indicator */
const Word16 last_core, /* i : Last core used */
const Word16 last_codec_mode, /* i : Last codec mode */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
- const Word16 element_mode /* i : element mode */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
+ const Word16 element_mode /* i : element mode */
)
{
Word16 Ener_per_bd[MBANDS_GN16k];
@@ -251,7 +131,6 @@ void Inac_switch_ematch_ivas_fx(
exp = sub( exp, 14 );
IF( LT_16( i, 2 ) )
{
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( element_mode, EVS_MONO ) )
{
FOR( j = 0; j < 8; j++ )
@@ -264,7 +143,6 @@ void Inac_switch_ematch_ivas_fx(
}
}
ELSE
-#endif
{
FOR( j = 0; j < 8; j++ )
{
@@ -278,7 +156,6 @@ void Inac_switch_ematch_ivas_fx(
}
ELSE
{
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( element_mode, EVS_MONO ) )
{
FOR( j = 0; j < 16; j++ )
@@ -291,7 +168,6 @@ void Inac_switch_ematch_ivas_fx(
}
}
ELSE
-#endif
{
FOR( j = 0; j < 16; j++ )
{
@@ -306,9 +182,7 @@ void Inac_switch_ematch_ivas_fx(
}
/* Going back to time */
-#ifdef REMOVE_EVS_DUPLICATES
IF( GT_16( element_mode, EVS_MONO ) )
-#endif
{
Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc
Scale_sig( exc2, 240, 1 ); // Q_exc
diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c
index 1198fb793dd4899997bf5d09bf60e965aa95b08b..208f205693ce9d67d04e96870bfcf4a15ea12d12 100644
--- a/lib_com/gs_noisefill_fx.c
+++ b/lib_com/gs_noisefill_fx.c
@@ -1332,8 +1332,6 @@ void highband_exc_dct_in_ivas_fx(
}
}
-
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( element_mode, EVS_MONO ) )
{
Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc );
@@ -1346,7 +1344,6 @@ void highband_exc_dct_in_ivas_fx(
}
ELSE
{
-#endif
Word16 Q_tmp = *Q_exc;
move16();
Word16 Q_old = *Q_exc;
@@ -1373,9 +1370,7 @@ void highband_exc_dct_in_ivas_fx(
{
Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
}
-#ifdef REMOVE_EVS_DUPLICATES
}
-#endif
/*--------------------------------------------------------------------------------------*
* add the correction layer to the LF bins,
@@ -1416,13 +1411,10 @@ void highband_exc_dct_in_ivas_fx(
Q_hb_exc = 0;
move16();
envelop_modify_fx( exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ, *Q_exc, &Q_hb_exc );
-#ifdef REMOVE_EVS_DUPLICATES
+
test();
test();
IF( GT_16( *Q_exc, Q_hb_exc ) && GT_16( element_mode, EVS_MONO ) && exc_wo_nf != NULL )
-#else
- IF( GT_16( *Q_exc, Q_hb_exc ) )
-#endif
{
Scale_sig( exc_wo_nf, L_frame, sub( Q_hb_exc, *Q_exc ) );
*Q_exc = Q_hb_exc;
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index 5bdbd7d73831113cddd92ef2210d1b5136a0a7f3..8b6cdcac91760e658892ed170ac55ea2b067430a 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -3968,7 +3968,7 @@ ivas_error ivas_core_dec_fx(
const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
);
-void decod_gen_2sbfr_ivas_fx(
+void decod_gen_2sbfr_fx(
Decoder_State *st, /* i/o: decoder static memory */
const Word16 sharpFlag, /* i : formant sharpening flag `Q0*/
const Word16 *Aq, /* i : LP filter coefficient Q12*/
diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c
index d60d0e9992655631130a8b5557d4ea8b176377e4..a41e10713968dd99b7d8fac5b16f4f448eb24163 100644
--- a/lib_com/lsf_tools_fx.c
+++ b/lib_com/lsf_tools_fx.c
@@ -2863,40 +2863,39 @@ Word16 qlsf_ARSN_tcvq_Dec_16k_fx(
}
/*======================================================================*/
-/* FUNCTION : lsf_syn_mem_backup_fx */
+/* FUNCTION : lsf_syn_mem_backup_fx */
/*----------------------------------------------------------------------*/
/* PURPOSE : back-up synthesis filter memory and LSF qunatizer memories */
/*----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16*) lsp_new : LSP vector to quantize */
-/* _ (Word16*) lsf_new : quantized LSF vector */
-/* _ (Word16*) lsp_mid : mid-frame LSP vector */
-/* _ (Encoder_State) st_fx : Encoder state Structure */
-/*-----------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _None */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16) clip_var : pitch clipping state var */
-/* _ (Word16*) mem_AR : quantizer memory for AR model */
-/* _ (Word16*) mem_MA : quantizer memory for MA model */
-/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */
-/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */
-/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */
+/* INPUT ARGUMENTS : */
+/* _ (Word16*) lsp_new : LSP vector to quantize */
+/* _ (Word16*) lsf_new : quantized LSF vector */
+/* _ (Word16*) lsp_mid : mid-frame LSP vector */
+/* _ (Encoder_State) st_fx : Encoder state Structure */
+/*----------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _None */
+/*----------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16) clip_var : pitch clipping state var */
+/* _ (Word16*) mem_AR : quantizer memory for AR model */
+/* _ (Word16*) mem_MA : quantizer memory for MA model */
+/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */
+/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */
+/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */
/* _ (Word16) mCb1 :counter for stationary frame after a transition frame */
-/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */
-/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */
-/* _ (Word16*) mem_syn_bck : synthesis filter memory */
-/* _ (Word16) mem_w0_bck : memory of the weighting filter */
-/* _ (Word16) streaklimit : LSF quantizer */
-/* _ (Word16) pstreaklen : LSF quantizer */
-/*-----------------------------------------------------------------------*/
-
-/* _ None */
-/*-----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*=======================================================================*/
+/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */
+/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */
+/* _ (Word16*) mem_syn_bck : synthesis filter memory */
+/* _ (Word16) mem_w0_bck : memory of the weighting filter */
+/* _ (Word16) streaklimit : LSF quantizer */
+/* _ (Word16) pstreaklen : LSF quantizer */
+/*----------------------------------------------------------------------*/
+/* _ None */
+/*----------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*======================================================================*/
void lsf_syn_mem_backup_fx(
Encoder_State *st_fx, /* o: state structure */
@@ -2904,23 +2903,22 @@ void lsf_syn_mem_backup_fx(
Word32 *gc_threshold_fx, /* i: Q16 */
Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
Word16 *next_force_sf_bck_fx, /* i: */
-
- Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
- Word16 *lsf_new, /* i: quantized LSF vector Q15 */
- Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
- Word16 *clip_var, /* i: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */
- Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */
- Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
- Word16 *lsf_new_bck, /* o: quantized LSF vector - backup Q15 */
- Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
- Word16 *mCb1, /* o: counter for stationary frame after a transition frame */
- Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets q_bin */
- Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets q_bin */
- Word16 *mem_syn_bck, /* i: synthesis filter memory q */
- Word16 *mem_w0_bck, /* i: memory of the weighting filter q */
- Word16 *streaklimit, /* i:LSF quantizer Q15 */
- Word16 *pstreaklen /* i:LSF quantizer */
+ Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
+ Word16 *lsf_new, /* i: quantized LSF vector Q15 */
+ Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
+ Word16 *clip_var, /* i: pitch clipping state var Q(2.56) */
+ Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */
+ Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */
+ Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
+ Word16 *lsf_new_bck, /* o: quantized LSF vector - backup Q15 */
+ Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
+ Word16 *mCb1, /* o: counter for stationary frame after a transition frame */
+ Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets q_bin */
+ Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets q_bin */
+ Word16 *mem_syn_bck, /* i: synthesis filter memory q */
+ Word16 *mem_w0_bck, /* i: memory of the weighting filter q */
+ Word16 *streaklimit, /* i:LSF quantizer Q15 */
+ Word16 *pstreaklen /* i:LSF quantizer */
)
{
Word16 i;
@@ -2985,25 +2983,31 @@ void lsf_syn_mem_backup_fx(
return;
}
+
+/*-------------------------------------------------------------------*
+ * lsf_syn_mem_backup_fx()
+ *
+ *
+ *--------------------------------------------------------------------*/
+
void lsf_syn_mem_backup_ivas_fx(
Encoder_State *st_fx, /* i: state structure */
Word16 *btilt_code_fx, /* i: tilt code Q15 */
Word32 *gc_threshold_fx, /* i: Q16 */
Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
Word16 *next_force_sf_bck_fx, /* o: */
-
- Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
- Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
- Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
- Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
- Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *streaklimit, /* Q15 */
+ Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
+ Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
+ Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
+ Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
+ Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
+ Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
+ Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
+ Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
+ Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
+ Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 *streaklimit, /* Q15 */
Word16 *pstreaklen )
{
Word16 i;
@@ -3079,66 +3083,68 @@ void lsf_update_memory(
move16();
mem_MA[i] = sub( sub( qlsf[i], lsf_means[narrowband][i] ), mult_r( MU_MA_FX, old_mem_MA[i] ) );
}
+
+ return;
}
+
/*======================================================================*/
-/* FUNCTION : lsf_syn_mem_restore_fx */
+/* FUNCTION : lsf_syn_mem_restore_fx */
/*----------------------------------------------------------------------*/
/* PURPOSE : restore synthesis filter memory and LSF quantizer memories*/
/*----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) clip_var : pitch clipping state var */
-/* _ (Word16*) mem_AR : quantizer memory for AR model */
-/* _ (Word16*) mem_MA : quantizer memory for MA model */
-/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */
-/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */
-/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */
+/* INPUT ARGUMENTS : */
+/* _ (Word16) clip_var : pitch clipping state var */
+/* _ (Word16*) mem_AR : quantizer memory for AR model */
+/* _ (Word16*) mem_MA : quantizer memory for MA model */
+/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */
+/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */
+/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */
/* _ (Word16) mCb1 :counter for stationary frame after a transition frame */
-/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */
-/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */
-/* _ (Word16*) mem_syn_bck : synthesis filter memory */
-/* _ (Word16) mem_w0_bck : memory of the weighting filter */
-/* _ (Word16) streaklimit : LSF quantizer */
-/* _ (Word16) pstreaklen : LSF quantizer */
-/*-----------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _None */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) lsp_new : LSP vector to quantize */
-/* _ (Word16*) lsf_new : quantized LSF vector */
-/* _ (Word16*) lsp_mid : mid-frame LSP vector */
-/* _ (Encoder_State) st_fx : Encoder state Structure */
-/*-----------------------------------------------------------------------*/
-
-/* _ None */
-/*-----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*=======================================================================*/
+/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */
+/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */
+/* _ (Word16*) mem_syn_bck : synthesis filter memory */
+/* _ (Word16) mem_w0_bck : memory of the weighting filter */
+/* _ (Word16) streaklimit : LSF quantizer */
+/* _ (Word16) pstreaklen : LSF quantizer */
+/*----------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _None */
+/*----------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) lsp_new : LSP vector to quantize */
+/* _ (Word16*) lsf_new : quantized LSF vector */
+/* _ (Word16*) lsp_mid : mid-frame LSP vector */
+/* _ (Encoder_State) st_fx : Encoder state Structure */
+/*----------------------------------------------------------------------*/
+/* _ None */
+/*----------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*======================================================================*/
+
void lsf_syn_mem_restore_fx(
Encoder_State *st_fx, /* o: state structure */
Word16 btilt_code_fx, /* i: Q15 */
Word32 gc_threshold_fx, /* i: Q16 */
Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
Word16 next_force_sf_bck_fx, /* i: */
-
- Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
- Word16 *lsf_new, /* o: quantized LSF vector Q15 */
- Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
- Word16 clip_var, /* i: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */
- Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */
- Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
- Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */
- Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
- Word16 mCb1, /* i: counter for stationary frame after a transition frame */
- Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 streaklimit, /* i:LSF quantizer Q15 */
- Word16 pstreaklen /* i:LSF quantizer */
+ Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
+ Word16 *lsf_new, /* o: quantized LSF vector Q15 */
+ Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
+ Word16 clip_var, /* i: pitch clipping state var Q(2.56) */
+ Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */
+ Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */
+ Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
+ Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */
+ Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
+ Word16 mCb1, /* i: counter for stationary frame after a transition frame */
+ Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
+ Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
+ Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 streaklimit, /* i:LSF quantizer Q15 */
+ Word16 pstreaklen /* i:LSF quantizer */
)
{
Word16 i;
diff --git a/lib_com/options.h b/lib_com/options.h
index 737e0850164e52c4baec6b4bc0dd77b96308a2d5..72cf7456be6f7089fe59111a9831dec7c7f36aa6 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -99,6 +99,4 @@
#define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */
#define TEST_HR
-#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */
-
#endif
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index ecd190f699cf5c2904906df6f2edb9d350c0a71c..6d3e28de2b6a6c8763cb66bcb057873efe64b24e 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -3284,52 +3284,33 @@ void synthesise_fb_high_band_fx(
#endif
);
-#ifndef REMOVE_EVS_DUPLICATES
void prep_tbe_exc_fx(
- const Word16 L_frame_fx, /* i : length of the frame */
- const Word16 i_subfr_fx, /* i : subframe index */
- const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
- const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 voice_fac_fx, /* i : voicing factor Q15*/
- Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
- Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
- const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
- const Word16 code_preQ_fx[], /* i : prequantizer excitation */
- const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
- Word16 T0, /* i : integer pitch variables Q0 */
- Word16 T0_frac, /* i : Fractional pitch variables Q0*/
- const Word16 coder_type, /* i : coding type */
- Word32 core_brate /* i :core bitrate */
-);
-#endif
-
-void prep_tbe_exc_ivas_fx(
- const Word16 L_frame_fx, /* i : length of the frame */
- const Word16 L_subfr,
- const Word16 i_subfr_fx, /* i : subframe index */
- const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
- const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 voice_fac_fx, /* i : voicing factor Q15*/
- Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
- Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
- const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
- const Word16 code_preQ_fx[], /* i : prequantizer excitation */
- const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
- Word16 T0, /* i : integer pitch variables Q0 */
- Word16 T0_frac, /* i : Fractional pitch variables Q0*/
- const Word16 coder_type, /* i : coding type */
- Word32 core_brate, /* i : core bitrate */
- const Word16 element_mode, /* i : element mode */
- const Word16 idchan, /* i : channel ID */
- const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
- const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
-);
-
-Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */
- const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
- Word16 *tilt_mem /* i/o: Tilt smoothing memory */
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 i_subfr_fx, /* i : subframe index */
+ const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
+ const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
+ const Word16 code_fx[], /* i : algebraic excitation Q9*/
+ const Word16 voice_fac_fx, /* i : voicing factor Q15*/
+ Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
+ Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
+ const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
+ const Word16 code_preQ_fx[], /* i : prequantizer excitation */
+ const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
+ const Word16 T0, /* i : integer pitch variables Q0 */
+ const Word16 T0_frac, /* i : Fractional pitch variables Q0*/
+ const Word16 coder_type, /* i : coding type */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
+ const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
+);
+
+/*! r: Formant filter strength [0,1] */
+Word16 swb_formant_fac_fx(
+ const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
+ Word16 *tilt_mem /* i/o: Tilt smoothing memory */
);
void wb_tbe_extras_reset_fx(
@@ -4833,35 +4814,6 @@ Word16 BITS_ALLOC_config_acelp(
const Word16 narrowband,
const Word16 nb_subfr );
-#ifndef REMOVE_EVS_DUPLICATES
-ivas_error config_acelp1(
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word32 total_brate, /* i : total bitrate */
- const Word32 core_brate_inp, /* i : core bitrate */
- const Word16 core, /* i : core */
- const Word16 extl, /* i : extension layer */
- const Word32 extl_brate, /* i : extension layer bitrate */
- const Word16 L_frame, /* i : frame length at internal Fs */
- const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */
- ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */
- const Word16 signalling_bits, /* i : number of signalling bits */
- const Word16 coder_type, /* i : coder type */
- const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
- const Word16 tc_subfr, /* i : TC subfr ID */
- const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */
- Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */
- Word16 *unbits, /* o : number of unused bits */
- const Word16 element_mode, /* i : element mode */
- Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */
- const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 idchan, /* i : stereo channel ID */
- const Word16 active_cnt, /* i : Active frame counter */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
-);
-#endif
Word16 set_ACELP_flag(
const Word16 element_mode, /* i : element mode */
const Word32 element_brate, /* i : element bitrate */
@@ -5808,35 +5760,19 @@ void tcx_ltp_post_fx32(
Word32 *tcx_buf, /* sig_q */
Word16 sig_q );
-#ifndef REMOVE_EVS_DUPLICATES
-// gs_inact_switching_fx.c
-void Inac_swtch_ematch_fx(
- Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
- Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
- Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
- const Word16 coder_type, /* i : Coding mode */
- const Word16 L_frame, /* i : Frame lenght */
- const Word32 core_brate, /* i : Core bit rate */
- const Word16 Q_exc, /* i : i and output format of exc2 */
- const Word16 bfi, /* i : frame lost indicator */
- const short last_core, /* i : Last core used */
- const short last_codec_mode /* i : Last codec mode */
-);
-#endif
-
-void Inac_switch_ematch_ivas_fx(
+void Inac_switch_ematch_fx(
Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
const Word16 coder_type, /* i : Coding mode */
- const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
+ const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */
const Word16 L_frame, /* i : Frame lenght */
const Word16 Q_exc, /* i : input and output format of exc2 */
const Word16 bfi, /* i : frame lost indicator */
const Word16 last_core, /* i : Last core used */
const Word16 last_codec_mode, /* i : Last codec mode */
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/
- const Word16 element_mode /* i : element mode */
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
+ const Word16 element_mode /* i : element mode */
);
// igf_base_fx.c
@@ -6069,32 +6005,16 @@ void td_bwe_dec_init_fx(
const Word32 output_Fs /* i : output sampling rate */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// lsf_dec_fx.c
void lsf_dec_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 tc_subfr, /* i : TC subframe index Q0*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
- Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
- Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
- const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/
- ,
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
-);
-#endif
-void lsf_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 tc_subfr, /* i : TC subframe index Q0*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
- Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
- Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
- const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/
- ,
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
+ Decoder_State *st_fx, /* i/o: State structure */
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
+ Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
+ Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
+ Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
+ Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/
+ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
);
/*! r: index of the maximum value in the input vector */
@@ -6257,21 +6177,9 @@ void lsf_mid_dec_fx(
Word16 lsp_mid[] /* o : quantized LSPs Q15*/
);
-#ifndef REMOVE_EVS_DUPLICATES
-// cng_dec_fx.c
void CNG_dec_fx(
Decoder_State *st_fx, /* i/o: State structure */
- const Word16 last_element_mode, /* i : last element mode Q0 */
- Word16 Aq[], /* o : LP coefficients Q12 */
- Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
- Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
- Word16 *allow_cn_step, /* o : allow CN step Q0 */
- Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */
- Word32 *q_env );
-#endif
-void CNG_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 last_element_mode, /* i : last element mode Q0 */
+ const Word16 last_element_mode, /* i : last element mode Q0 */
Word16 Aq[], /* o : LP coefficients Q12 */
Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
@@ -6656,12 +6564,12 @@ void hf_synth_amr_wb_fx(
// dec_post_fx
void Init_post_filter_fx(
PFSTAT_HANDLE hPFstat /* i : core decoder parameters */
-); /* (i) : core decoder parameters */
+); /* i : core decoder parameters */
void nb_post_filt_fx(
const Word16 L_frame, /* i : frame length */
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
Word16 *psf_lp_noise, /* i : Long term noise Q8 */
const Word16 tmp_noise, /* i : noise energy Q0 */
Word16 *Synth, /* i : 12k8 synthesis Qsyn */
@@ -6672,27 +6580,15 @@ void nb_post_filt_fx(
const Word16 disable_hpf /* i : flag to diabled HPF */
);
-#ifndef REMOVE_EVS_DUPLICATES
void formant_post_filt_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
Word16 *synth_in, /* i : 12k8 synthesis */
- Word16 *Aq, /* i : LP filter coefficient */
- Word16 *synth_out, /* i/o: i signal */
- Word16 L_frame,
- Word32 lp_noise, /* (i) : background noise energy (15Q16) */
- Word32 rate, /* (i) : bit-rate */
- const Word16 off_flag /* i : off flag */
-);
-#endif
-void formant_post_filt_ivas_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- Word16 *synth_in, /* i : 12k8 synthesis */
- Word16 *Aq, /* i : LP filter coefficient */
- Word16 *synth_out, /* i/o: i signal */
- Word16 L_frame,
- Word32 lp_noise, /* (i) : background noise energy (15Q16) */
- Word32 rate, /* (i) : bit-rate */
- const Word16 off_flag /* i : off flag */
+ Word16 *Aq, /* i : LP filter coefficient Q12 */
+ Word16 *synth_out, /* i/o: input signal */
+ const Word16 L_frame, /* i : frame length */
+ const Word32 lp_noise, /* (i) : background noise energy (15Q16) */
+ const Word32 brate, /* (i) : bit-rate */
+ const Word16 off_flag /* i : off flag */
);
void Filt_mu_fx(
Word16 *sig_in, /* i : signal (beginning at sample -1) */
@@ -6858,65 +6754,34 @@ void PulseResynchronization_fx(
Word32 /*float*/ const pitchEnd /*i Q16*/
);
-#ifndef REMOVE_EVS_DUPLICATES
-// gs_dec_fx.c
void decod_audio_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
- const Word16 *Aq, /* i : LP filter coefficient Q12*/
- Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
- Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
- Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/
- ,
- Word16 *gain_buf /*Q14*/
-);
-#endif
-void decod_audio_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
- const Word16 *Aq, /* i : LP filter coefficient Q12*/
- Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
- Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
- Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/
- ,
- Word16 *gain_buf, /*Q14*/
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
+ const Word16 *Aq, /* i : LP filter coefficient Q12*/
+ Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
+ Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
+ Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/
const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/
);
-#ifndef REMOVE_EVS_DUPLICATES
void gsc_dec_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
- const Word16 pit_band_idx, /* i : bin position of the cut-off frequency Q0*/
- const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/
- const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/
- const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
- const Word16 coder_type, /* i : coding type Q0*/
- Word16 *last_bin, /* i : last bin of bit allocation Q0*/
- const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
- Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
- Word16 Q_exc );
-#endif
-void gsc_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
+ Decoder_State *st_fx, /* i/o: State structure */
+ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/
const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/
const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/
const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
const Word16 coder_type, /* i : coding type Q0*/
Word16 *last_bin, /* i : last bin of bit allocation Q0*/
- const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
- Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
+ const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
+ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
Word16 *Q_exc );
void GSC_dec_init(
@@ -6927,18 +6792,15 @@ void GSC_dec_init_ivas_fx(
GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */
);
-
-// gain_dec_fx.c
-
void Es_pred_dec_fx(
- Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
- const Word16 enr_idx, /* i : indice */
- const Word16 nb_bits, /* i : number of bits */
- const Word16 no_ltp /* i : no LTP flag */
+ Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
+ const Word16 enr_idx, /* i : indice */
+ const Word16 nb_bits, /* i : number of bits */
+ const Word16 no_ltp /* i : no LTP flag */
);
void gain_dec_tc_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
+ Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 *code_fx, /* i : algebraic code excitation */
const Word16 i_subfr_fx, /* i : subframe number */
const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
@@ -6973,7 +6835,6 @@ void gain_dec_mless_fx(
Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/
);
-#ifndef REMOVE_EVS_DUPLICATES
void gain_dec_lbr_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 coder_type, /* i : coding type */
@@ -6984,25 +6845,8 @@ void gain_dec_lbr_fx(
Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/
Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/
Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[] /* i/o: gain_pitch from previous subframes */
- ,
- const Word16 L_subfr /* i : subfr lenght */
-);
-#endif
-
-void gain_dec_lbr_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *code_fx, /* i : algebraic excitation Q9 */
- Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/
- Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
- Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/
- Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes */
- Word16 gp_mem[] /* i/o: gain_pitch from previous subframes */
- ,
- const Word16 L_subfr /* i : subfr lenght */
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
+ const Word16 L_subfr /* i : subfr lenght */
);
void lp_gain_updt_fx(
@@ -7023,13 +6867,14 @@ void lp_gain_updt_ivas_fx(
const Word16 L_frame /* i : length of the frame */
);
-Word32 gain_dec_gaus_fx( /* o : quantized codebook gain Q16 */
- Word16 index, /* i : quantization index */
- const Word16 bits, /* i : number of bits to quantize */
- const Word16 lowBound, /* i : lower bound of quantizer (dB) */
- const Word16 topBound, /* i : upper bound of quantizer (dB) */
- const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
- Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
+/*! r: quantized codebook gain Q16 */
+Word32 gain_dec_gaus_fx(
+ Word16 index, /* i : quantization index */
+ const Word16 bits, /* i : number of bits to quantize */
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) */
+ const Word16 topBound, /* i : upper bound of quantizer (dB) */
+ const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
+ Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
);
void gain_dec_SQ_fx(
@@ -7123,23 +6968,7 @@ void re8_PPV_fx(
Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// dec_pit_exc_fx.c
void dec_pit_exc_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 coder_type, /* i : coding type */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *code_fx, /* o : innovation */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- const Word16 nb_subfr_fx /* i : Number of subframe considered */
- ,
- Word16 *gain_buf /*Q14*/
-);
-#endif
-void dec_pit_exc_ivas_fx(
Decoder_State *st_fx, /* i/o: decoder static memory */
const Word16 *Aq_fx, /* i : LP filter coefficient */
const Word16 coder_type, /* i : coding type */
@@ -7149,7 +6978,7 @@ void dec_pit_exc_ivas_fx(
Word16 *exc_fx, /* i/o: adapt. excitation exc */
Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
const Word16 nb_subfr_fx, /* i : Number of subframe considered */
- Word16 *gain_buf, /*Q14*/
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
);
@@ -7193,24 +7022,8 @@ void Mode2_delta_pit_dec(
Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */
);
-#ifndef REMOVE_EVS_DUPLICATES
-Word16 pit_decode_fx( /* o : floating pitch value */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : coding type */
- Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
- Word16 *T0, /* o : close loop integer pitch */
- Word16 *T0_frac, /* o : close loop fractional part of the pitch */
- Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
- Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
- const Word16 L_subfr /* i : subframe length */
-);
-#endif
/* o : floating pitch value */
-Word16 pit_decode_ivas_fx(
+Word16 pit_decode_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word32 core_brate, /* i : core bitrate */
const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
@@ -7571,19 +7384,7 @@ void configureFdCngDec_fx(
const Word16 Last_L_frame,
const Word16 element_mode );
-#ifndef REMOVE_EVS_DUPLICATES
-/* Apply the CLDFB-based CNG */
Word16 ApplyFdCng_fx(
- Word16 *timeDomainInput, /* i : pointer to time domain i */
- Word16 Q,
- Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */
- Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */
- Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */
- Decoder_State *st,
- const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */
- Word16 is_music );
-#endif
-Word16 ApplyFdCng_ivas_fx(
Word16 *timeDomainInput, /* i : pointer to time domain input */
Word16 Q,
Word32 *powerSpectrum,
@@ -8172,14 +7973,11 @@ void FEC_pitch_estim_fx(
const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */
Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */
Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */
- Word16 *upd_cnt /* i/o: update counter */
- ,
- const Word16 coder_type, /* i : coder_type */
- Word16 element_mode /* i : element mode */
+ Word16 *upd_cnt, /* i/o: update counter */
+ const Word16 coder_type, /* i : coder_type */
+ Word16 element_mode /* i : element mode */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// FEC_scale_sync_fx.c
void FEC_scale_syn_fx(
const Word16 L_frame, /* i : length of the frame */
Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
@@ -8206,69 +8004,37 @@ void FEC_scale_syn_fx(
Word16 *mem_syn, /* o: initial synthesis filter states */
Word16 Q_exc,
Word16 Q_syn,
+ const Word16 element_mode, /* i : element mode */
const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
- const Word16 force_scaling /* i: force scaling */
-);
-#endif
-void FEC_scale_syn_ivas_fx(
- const Word16 L_frame, /* i : length of the frame */
- Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
- Word16 clas, /* i/o: frame classification */
- const Word16 last_good, /* i: last good frame classification */
- Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */
- const Word16 *pitch, /* i: pitch values for each subframe */
- Word32 L_enr_old, /* i: energy at the end of previous frame */
- Word32 L_enr_q, /* i: transmitted energy for current frame */
- const Word16 coder_type, /* i: coder type */
- const Word16 LSF_Q_prediction, /* i : LSF prediction mode */
- Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */
- Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */
- Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */
- const Word16 bfi, /* i: current frame BFI */
- const Word32 total_brate, /* i: total bitrate */
- const Word16 prev_bfi, /* i: previous frame BFI */
- const Word32 last_core_brate, /* i: previous frame core bitrate */
- Word16 *exc, /* i/o: excitation signal without enhancement */
- Word16 *exc2, /* i/o: excitation signal with enhancement */
- Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */
- Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */
- const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */
- Word16 *mem_syn, /* o: initial synthesis filter states */
- Word16 Q_exc,
- Word16 Q_syn,
-#ifdef REMOVE_EVS_DUPLICATES
- const Word16 element_mode, /* i : element mode */
-#endif
- const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
- const Word16 force_scaling /* i: force scaling */
+ const Word16 force_scaling /* i : force scaling */
);
// LD_music_post_filter_fx.c
void LD_music_post_filter_fx(
- MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */
- const Word16 dtc_in[], /* i : i synthesis Qdct */
- Word16 dtc_out[], /* o : output synthesis Qdct */
- const Word32 core_brate, /* i : core bitrate Q0 */
- Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */
- const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */
- const Word16 Last_coder_type, /* i : i scaling Q0 */
- const Word16 Qdct /* i : i scaling Q0 */
+ MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */
+ const Word16 dtc_in[], /* i : i synthesis Qdct */
+ Word16 dtc_out[], /* o : output synthesis Qdct */
+ const Word32 core_brate, /* i : core bitrate Q0 */
+ Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */
+ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */
+ const Word16 Last_coder_type, /* i : i scaling Q0 */
+ const Word16 Qdct /* i : i scaling Q0 */
);
void Prep_music_postP_fx(
- Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/
- Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/
- Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */
- const Word16 last_core, /* i : last core */
- const Word16 element_mode, /* i : element mode */
- const Word16 *pitch_buf, /* i : current frame pitch information Q6*/
- Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/
- const Word16 Q_exc, /* i : excitation scaling */
- Word16 *qdct /* o : Scaling factor of dct coefficient */
+ Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/
+ Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/
+ Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */
+ const Word16 last_core, /* i : last core */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 *pitch_buf, /* i : current frame pitch information Q6*/
+ Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/
+ const Word16 Q_exc, /* i : excitation scaling */
+ Word16 *qdct /* o : Scaling factor of dct coefficient */
);
void Post_music_postP_fx(
- Word16 dct_buffer_in[], /* i/o: excitation buffer */
+ Word16 dct_buffer_in[], /* i/o: excitation buffer */
Word16 *exc2, /* i/o: Current excitation to be overwriten */
const Word16 *mem_tmp, /* i : previous frame synthesis memory */
Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */
@@ -8278,15 +8044,14 @@ void Post_music_postP_fx(
Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */
Word16 *Q_syn, /* i : Current frame synthesis scaling */
Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/
- const Word16 IsIO, /* i: Flag to indicate IO mode */
- Word16 *mem_deemph, /* i/o: speech deemph filter memory */
- Word16 *st_pst_old_syn_fx, /* i/o: psfiler */
- Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */
+ const Word16 IsIO, /* i : Flag to indicate IO mode */
+ Word16 *mem_deemph, /* i/o: speech deemph filter memory */
+ Word16 *st_pst_old_syn_fx, /* i/o: psfiler */
+ Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */
Word16 *mem_agc,
- PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */
- const Word16 *tmp_buffer /* tmp_buffer in Q-1 */
- ,
- Word16 *mem_tmp2 /* Temporary memory used with scale_syn */
+ PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */
+ const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */
+ Word16 *mem_tmp2 /* Temporary memory used with scale_syn */
);
void music_postfilt_init(
@@ -8503,29 +8268,17 @@ Word16 FEC_enhACB_fx(
const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */
const Word16 bfi_pitch /* i : Q6 pitch used for concealment */
);
-Word16 FEC_synchro_exc_fx( /* o : do_WI flag */
- const Word16 L_frame, /* i : length of the frame */
- Word16 *exc, /* i/o: exc vector to modify */
- const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */
- const Word16 true_puls_pos, /* i : Present pulse location */
- const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */
+
+/*! r: do_WI flag */
+Word16 FEC_synchro_exc_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 *exc, /* i/o: exc vector to modify */
+ const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */
+ const Word16 true_puls_pos, /* i : Present pulse location */
+ const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// dec_uv_fx.c
void decod_unvoiced_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
- const Word16 coder_type, /* Q0 i : coding type */
- Word16 *tmp_noise_fx, /* Q5 o : long term temporary noise energy */
- Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* Q15 o : voicing factors */
- Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
- Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
- Word16 *gain_buf );
-#endif
-void decod_unvoiced_ivas_fx(
Decoder_State *st_fx, /* i/o: decoder static memory */
const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
@@ -8568,38 +8321,20 @@ void gaus_L2_dec(
Word16 *seed_acelp /*i/o : random seed Q0 */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// dec_gen_voic_fx.c
ivas_error decod_gen_voic_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 L_frame_fx, /* i : length of the frame */
- const Word16 sharpFlag_fx, /* i : formant sharpening flag */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 do_WI_fx, /* i : do interpolation after a FER */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits, /* number of unused bits */
- Word16 *gain_buf /*Q14*/
-);
-#endif
-ivas_error decod_gen_voic_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 sharpFlag_fx, /* i : formant sharpening flag */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- const Word16 do_WI_fx, /* i : do interpolation after a FER */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *voice_factors_fx, /* o : voicing factors */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- Word16 *unbits, /* number of unused bits */
- Word16 *gain_buf,
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 sharpFlag_fx, /* i : formant sharpening flag */
+ const Word16 *Aq_fx, /* i : LP filter coefficient */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ const Word16 do_WI_fx, /* i : do interpolation after a FER */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16 *voice_factors_fx, /* o : voicing factors */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ Word16 *unbits, /* number of unused bits */
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
);
@@ -9501,33 +9236,6 @@ void d_gain_pred_fx(
Word16 **pt_indice /* i/o: pointer to the buffer of indices */
);
-#ifndef REMOVE_EVS_DUPLICATES
-// acelp_core_dec_fx.c
-ivas_error acelp_core_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 output[], /* o : synthesis @internal Fs */
- Word16 synth_out[], /* o : synthesis */
- Word16 save_hb_synth[], /* o : HB synthesis */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
- Word16 *voice_factors, /* o : voicing factors */
- Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis for SWB BWE */
- Word16 sharpFlag,
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */
- Word16 *unbits, /* o : number of unused bits */
- Word16 *sid_bw /* o : 0-NB/WB, 1-SWB SID */
- ,
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
- const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */
- const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
- const Word16 nchan_out, /* i : number of output channels */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const Word16 read_sid_info /* i : read SID info flag */
-);
-#endif
// evs_dec_fx.c
ivas_error evs_dec_fx(
Decoder_State *st_fx, /* i/o : Decoder state structure */
@@ -10603,7 +10311,7 @@ Word16 swb_bwe_dec_fx32(
Word16 output_frame /* i : frame length */
);
-ivas_error acelp_core_dec_ivas_fx(
+ivas_error acelp_core_dec_fx(
Decoder_State *st, /* i/o: decoder state structure */
Word16 output_fx[], /* o : synthesis @internal Fs */
Word16 synth_fx16[], /* o : synthesis */
@@ -10900,6 +10608,7 @@ Word16 ari_decode_14bits_pow_ivas(
Word16 *res,
Tastat *s,
UWord16 base );
+
Word16 ari_decode_14bits_sign_ivas(
Word16 *ptr,
Word16 bp,
@@ -10913,22 +10622,21 @@ void lsf_syn_mem_backup_ivas_fx(
Word32 *gc_threshold_fx, /* i: Q16 */
Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
Word16 *next_force_sf_bck_fx, /* o: */
-
- Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
- Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
- Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
- Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
- Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *streaklimit, /* Q15 */
+ Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
+ Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
+ Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
+ Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
+ Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
+ Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
+ Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
+ Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
+ Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
+ Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
+ Word16 *streaklimit, /* Q15 */
Word16 *pstreaklen );
-ivas_error config_acelp1_IVAS(
+ivas_error config_acelp1_fx(
const Word16 enc_dec, /* i : encoder/decoder flag */
const Word32 total_brate, /* i : total bitrate */
const Word32 core_brate_inp, /* i : core bitrate */
diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c
index d3f6716318bf1655e5b84fbac5b86d77feebf631..11f532bbef780135a2efb2a8ec8e439bd35af5f4 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -7253,180 +7253,34 @@ void Estimate_mix_factors_fx(
/* INPUT/OUTPUT ARGUMENTS : */
/* _ (Word16[]) bwe_exc_fx : excitation for TBE (Q_exc) */
/*--------------------------------------------------------------------------------------*/
-
/* _ None */
/*--------------------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*======================================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void prep_tbe_exc_fx(
- const Word16 L_frame_fx, /* i : length of the frame */
- const Word16 i_subfr_fx, /* i : subframe index */
- const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
- const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 voice_fac_fx, /* i : voicing factor Q15*/
- Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
- Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
- const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
- const Word16 code_preQ_fx[], /* i : prequantizer excitation */
- const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
- Word16 T0, /* i : integer pitch variables Q0 */
- Word16 T0_frac, /* i : Fractional pitch variables Q0*/
- const Word16 coder_type, /* i : coding type */
- Word32 core_brate )
-{
- Word16 i;
- Word16 tmp_code_fx[2 * L_SUBFR * HIBND_ACB_L_FAC];
- Word16 tmp_code_preInt_fx[L_SUBFR];
- Word16 gain_code16 = 0;
- move16();
- Word16 tmp /*, tmp1, tmp2*/;
- /*Word16 random_code[L_SUBFR * HIBND_ACB_L_FAC];*/
- Word16 pitch;
-
- Word32 L_tmp, Ltemp1, Ltemp2;
- Word32 tempQ31;
- Word16 tempQ15;
- Word16 L_subfr = L_SUBFR;
- move16();
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
- /**voice_factors = VF_0th_PARAM + VF_1st_PARAM * voice_fac + VF_2nd_PARAM * voice_fac * voice_fac;
- = VF_0th_PARAM + voice_fac * (VF_1st_PARAM + VF_2nd_PARAM * voice_fac )
- *voice_factors = min( max_val(0.0f, *voice_factors), 1.0f); */
- tempQ31 = L_deposit_h( VF_1st_PARAM_FX );
- tempQ15 = mac_r( tempQ31, VF_2nd_PARAM_FX, voice_fac_fx );
- tempQ31 = L_deposit_h( VF_0th_PARAM_FX );
- *voice_factors_fx = mac_r( tempQ31, voice_fac_fx, tempQ15 );
- move16();
- tmp = MAX_16;
- move16();
-
- pitch = shl_o( add( shl_o( T0, 2, &Overflow ), T0_frac ), 5, &Overflow ); /* Q7 */
-
- test();
- test();
- IF( ( ( EQ_16( coder_type, VOICED ) ) || ( GT_16( pitch, 14784 /* 115.5 in Q7 */ ) ) ) && ( GT_32( core_brate, ACELP_8k00 ) ) )
- {
- tmp = MAX_16;
- move16();
- *voice_factors_fx = mult_r( *voice_factors_fx, tmp );
- move16();
- }
-
- *voice_factors_fx = s_min( s_max( *voice_factors_fx, 0 ), MAX_16 );
- move16();
- IF( EQ_16( L_frame_fx, L_FRAME ) )
- {
- interp_code_5over2_fx( code_fx, tmp_code_fx, L_subfr ); /* code: Q9, tmp_code: Q9 */
- gain_code16 = round_fx_o( L_shl_o( gain_code_fx, Q_exc, &Overflow ), &Overflow ); /*Q_exc */
- FOR( i = 0; i < L_subfr * HIBND_ACB_L_FAC; i++ )
- {
- L_tmp = L_mult( gain_code16, tmp_code_fx[i] ); /* Q9 + Q_exc + 1*/
- L_tmp = L_shl_sat( L_tmp, 5 ); /* Q9 + Q_exc + Q6*/
- L_tmp = L_mac_sat( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] ); /*Q15+Q_exc */
- L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /*16+Q_exc */ /* saturation can occur here */
- bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx_o( L_tmp, &Overflow ); /*Q_exc */
- move16();
- }
- }
- ELSE
- {
- IF( gain_preQ_fx != 0 )
- {
- FOR( i = 0; i < L_subfr; i++ )
- {
- /*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */
- Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */
- Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /*Q2 * Q10 -> Q12 */
-
- Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */
- Ltemp2 = L_shl_o( Ltemp2, add( Q_exc, 4 ) /*Q_exc+16-13*/, &Overflow ); /*Q_exc+16 */
-
- tmp_code_preInt_fx[i] = round_fx_o( L_add_o( Ltemp1, Ltemp2, &Overflow ), &Overflow ); /* Q_exc */
- move16();
- }
- }
- ELSE
- {
- FOR( i = 0; i < L_subfr; i++ )
- {
- /*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */
- Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */
- Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */
- tmp_code_preInt_fx[i] = round_fx_o( Ltemp1, &Overflow ); /* Q_exc */
- move16();
- }
- }
-
- interp_code_4over2_fx( tmp_code_preInt_fx, tmp_code_fx, L_subfr ); /* o: tmp_code in Q_exc */
- FOR( i = 0; i < L_subfr * 2; i++ )
- {
- L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * 2] ); /*Q14+Q_exc+1 */
- tmp = round_fx_o( L_shl_o( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/, &Overflow ), &Overflow ); /* tmp in Q_exc */
- bwe_exc_fx[i + i_subfr_fx * 2] = add_o( tmp, tmp_code_fx[i], &Overflow ); /*Q_exc */
- move16();
- }
- }
-
- return;
-}
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 i_subfr_fx, /* i : subframe index */
+ const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
+ const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
+ const Word16 code_fx[], /* i : algebraic excitation Q9*/
+ const Word16 voice_fac_fx, /* i : voicing factor Q15*/
+ Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
+ Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
+ const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
+ const Word16 code_preQ_fx[], /* i : prequantizer excitation */
+ const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
+ const Word16 T0, /* i : integer pitch variables Q0 */
+ const Word16 T0_frac, /* i : Fractional pitch variables Q0*/
+ const Word16 coder_type, /* i : coding type */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
+ const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
-/*======================================================================================*/
-/* FUNCTION : prep_tbe_exc_ivas_fx() */
-/*--------------------------------------------------------------------------------------*/
-/* PURPOSE : Prepare TBE excitation */
-/*--------------------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) L_frame_fx : length of the frame */
-/* _ (Word16) i_subfr_fx : subframe index */
-/* _ (Word16) gain_pit_fx : Pitch gain (14) */
-/* _ (Word32) gain_code_fx : algebraic codebook gain (Q(16+Q_exc)) */
-/* _ (Word16*[]) code_fx : algebraic excitation (Q9) */
-/* _ (Word16) voice_fac_fx : voicing factor (Q15) */
-/* _ (Word16) gain_preQ_fx : prequantizer excitation gain */
-/* _ (Word16[]) code_preQ_fx : prequantizer excitation */
-/*--------------------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*[]) voice_factors_fx : TBE voicing factor (Q15) */
-/*--------------------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word16[]) bwe_exc_fx : excitation for TBE (Q_exc) */
-/*--------------------------------------------------------------------------------------*/
-
-/* _ None */
-/*--------------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*======================================================================================*/
-#endif
-void prep_tbe_exc_ivas_fx(
- const Word16 L_frame_fx, /* i : length of the frame */
- const Word16 L_subfr,
- const Word16 i_subfr_fx, /* i : subframe index */
- const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
- const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 voice_fac_fx, /* i : voicing factor Q15*/
- Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
- Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
- const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
- const Word16 code_preQ_fx[], /* i : prequantizer excitation */
- const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
- Word16 T0, /* i : integer pitch variables Q0 */
- Word16 T0_frac, /* i : Fractional pitch variables Q0*/
- const Word16 coder_type, /* i : coding type */
- Word32 core_brate, /* i : core bitrate */
- const Word16 element_mode, /* i : element mode */
- const Word16 idchan, /* i : channel ID */
- const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
- const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
)
{
Word16 i;
@@ -7543,6 +7397,7 @@ void prep_tbe_exc_ivas_fx(
return;
}
+
/*=============================================================================*/
/* FUNCTION : void swb_formant_fac_fx ( ) */
/*------------------------------------------------------------------------------*/
@@ -7562,9 +7417,10 @@ void prep_tbe_exc_ivas_fx(
/* CALLED FROM : */
/*==============================================================================*/
-Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */
- const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
- Word16 *tilt_mem /* i/o: Tilt smoothing memory (Q12) */
+/*! r: Formant filter strength [0,1] */
+Word16 swb_formant_fac_fx(
+ const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
+ Word16 *tilt_mem /* i/o: Tilt smoothing memory (Q12) */
)
{
Word16 formant_fac;
@@ -7584,7 +7440,6 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength
tmp = sub( tmp, SWB_TILT_LOW_FX ); /* Q12 */
formant_fac = mult_r( tmp, SWB_TILT_DELTA_FX ); /* Q12 */
-
IF( GT_16( formant_fac, 4096 /* 1 in Q12 */ ) )
{
formant_fac = 4096; /* 1 in Q12 */
@@ -7604,6 +7459,12 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength
}
+/*-------------------------------------------------------------------*
+ * wb_tbe_extras_reset_fx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
void wb_tbe_extras_reset_fx(
Word16 mem_genSHBexc_filt_down_wb2[],
Word16 mem_genSHBexc_filt_down_wb3[] )
@@ -7620,7 +7481,6 @@ void wb_tbe_extras_reset_fx(
* Determine TBE bit consumption per frame from bitrate *
*-------------------------------------------------------------------*/
-
Word16 get_tbe_bits_fx(
const Word32 total_brate, /* o : TBE bit consumption per frame */
const Word16 bwidth, /* i : overall bitrate */
diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c
index a23c9aa90bf6b582ad1425094a242689ec6f4058..48d91a87a1956594ba84a662e33c8cc73d52d89f 100644
--- a/lib_dec/FEC_fx.c
+++ b/lib_dec/FEC_fx.c
@@ -510,19 +510,10 @@ void FEC_exc_estim_fx(
move16();
/* st_fx->L_frame / L_SUBFR */
tmp = shr( st_fx->L_frame, 6 );
+
/* Replication of the last spectrum, with a slight downscaling of its dynamic */
-#ifdef REMOVE_EVS_DUPLICATES
- gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc );
-#else
- IF( st_fx->element_mode == EVS_MONO )
- {
- gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc );
- }
- ELSE
- {
- gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc );
- }
-#endif
+ gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc );
+
*tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
move16();
/* Transform back to time domain */
diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c
index 714a60166865e38fd8efe3676fef761aa8b67345..7f4586083e938d9eecb623b325a54dcecad9e71a 100644
--- a/lib_dec/FEC_scale_syn_fx.c
+++ b/lib_dec/FEC_scale_syn_fx.c
@@ -50,7 +50,6 @@
/* _ None */
/*========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void FEC_scale_syn_fx(
const Word16 L_frame, /* i : length of the frame */
Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
@@ -77,574 +76,7 @@ void FEC_scale_syn_fx(
Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/
Word16 Q_exc,
Word16 Q_syn,
- const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
- const Word16 force_scaling /* i: force scaling */
-)
-{
- Word16 i;
- Word32 L_enr1, L_enr2;
- Word16 gain1, gain2, enr_LP;
- Word16 tmp, tmp2, exp, exp2;
- Word16 tmp3;
- Word32 L_tmp;
- Word16 scaling;
- Word32 ener_max, L_enr2_av, L_ener2_max;
- Word16 h1[L_FRAME / 2], tilt, pitch_dist, mean_pitch;
- Word16 k;
- Word32 L_mean_pitch;
-
- enr_LP = 0;
- move16();
- gain2 = 0;
- move16();
- gain1 = 0;
- move16();
- *update_flg = 0;
- move16();
- L_enr_old = L_max( 1, L_enr_old ); /* to avoid division by zero (*L_enr_old is always >= 0) */
- scaling = 16384;
- move16(); /* Q14*/
-
- /*-----------------------------------------------------------------*
- * Find the synthesis filter impulse response on voiced
- *-----------------------------------------------------------------*/
- test();
- IF( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) )
- {
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- enr_LP = Enr_1_Az_fx( Aq + ( NB_SUBFR - 1 ) * ( M + 1 ), L_SUBFR );
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- enr_LP = Enr_1_Az_fx( Aq + ( NB_SUBFR16k - 1 ) * ( M + 1 ), L_SUBFR ); /*Q3*/
- }
- }
-
- /*-----------------------------------------------------------------*
- * Define when to scale the synthesis
- *-----------------------------------------------------------------*/
-
- IF( bfi )
- {
- *scaling_flag = 1;
- move16(); /* Always check synthesis on bad frames */
- }
- ELSE IF( prev_bfi )
- {
- test();
- IF( ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) || ( EQ_16( LSF_Q_prediction, MOVING_AVERAGE ) ) )
- {
- *scaling_flag = 2;
- move16(); /* Decoded LSFs affected */
- }
- ELSE IF( NE_16( coder_type, TRANSITION ) )
- {
- *scaling_flag = 1;
- move16(); /* SN, but not TC mode - LSF still affected by the interpolation */
- }
- ELSE
- {
- *scaling_flag = 0;
- move16(); /* LSF still possibly affected due to interpolation */
- }
- scaling = 24576; /*1.5 Q14*/
- move16();
- }
- ELSE
- {
- test();
- IF( ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) && ( EQ_16( *scaling_flag, 2 ) ) )
- {
- *scaling_flag = 2;
- move16(); /* Continue with energy control till the end of AR prediction */
- }
- ELSE IF( *scaling_flag > 0 )
- {
- ( *scaling_flag ) = sub( *scaling_flag, 1 ); /* If scaling flag was equal to 2, add one control frame to account for the LSF interpolation */
- move16();
- }
- scaling = 32767; /*2.0 Q14*/
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Find the energy/gain at the end of the frame
- *-----------------------------------------------------------------*/
-
- frame_ener_fx( L_frame, clas, synth, pitch[( L_frame >> 6 ) - 1], &L_enr2 /*Q0*/, 1, Q_syn, 3, 0 );
-
-
- test();
- test();
- IF( bfi || ( EQ_32( total_brate, ACELP_7k20 ) ) || ( EQ_32( total_brate, ACELP_8k00 ) ) )
- {
- /* previous frame erased and no TC frame */
- IF( *scaling_flag > 0 )
- {
- /*enr2 += 0.01f;*/
- L_enr2 = L_max( L_enr2, 1 ); /* L_enr2 is in Q0 */
-
- IF( bfi ) /* In all bad frames, limit the gain to 1 */
- {
- /* gain2 = (float)sqrt( enr_old / enr2 );*/
- L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr2, 0, &exp2 );
- gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
-
- /*if( gain2 > 1.0f )gain2 = 1.0f;*/
- gain2 = s_min( gain2, 16384 );
-
- /* find the energy/gain at the beginning of the frame */
- frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1 /*Q0*/, 1, Q_syn, 3, 0 );
-
- /*enr1 += 0.1f;*/
- L_enr1 = L_max( L_enr1, 1 ); /* L_enr2 is in Q0 */
-
- /*gain1 = (float)sqrt( enr_old / enr1 );*/
- L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 );
- gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
-
- /*if( gain1 > 1.0f )gain1 = 1.0f;*/
- gain1 = s_min( gain1, 16384 ); /*Q14*/
- }
- ELSE /* good frame */
- {
- IF( L_enr_q == 0 ) /* If E info (FEC protection bits) is not available in the bitstream */
- {
- L_enr_q = L_enr2; /*Q0*/
- set16_fx( h1, 0, L_FRAME / 2 );
- h1[0] = 1024; /*1.0f in Q10*/
- move16();
- /*syn_filt( Aq+(3*(M+1)), M, h1, h1, L_FRAME/2, h1+(M+1), 0 );*/
- E_UTIL_synthesis( 1, Aq + ( 3 * ( M + 1 ) ), h1, h1, L_FRAME / 2, h1 + ( M + 1 ), 0, M );
-
- /*Compute tilt */
- /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/
- /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/
- /*tilt = rr1 / rr0;*/
- tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/
- pitch_dist = 0;
- move16();
- L_mean_pitch = L_mult( pitch[0], 8192 /*1.0f in Q13*/ ); /*Q14*/
- FOR( k = 0; k < ( NB_SUBFR - 1 ); k++ )
- {
- pitch_dist = add( pitch_dist, abs_s( sub( pitch[k + 1], pitch[k] ) ) ); /*Q0*/
- L_mean_pitch = L_mac( L_mean_pitch, pitch[k + 1], 8192 ); /*Q14*/
- }
- /*pitch_dist /= (float)(NB_SUBFR-1); */
- pitch_dist = mult_r( shl( pitch_dist, 4 ), 10923 /*1/(float)(NB_SUBFR-1) in Q15*/ ); /*Q4*/
- /*mean_pitch /= (float)(NB_SUBFR);*/
- mean_pitch = extract_h( L_shl( L_mean_pitch, 4 ) ); /*Q4*/
-
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( GT_16( tilt, 22938 ) ) && /* HF resonnant filter */
- ( ( GT_16( pitch_dist, 8 << 4 ) ) || ( LT_16( mean_pitch, PIT_MIN << 4 ) ) ) && /* pitch unstable or very short */
- ( ( prev_bfi ) || ( ( EQ_16( coder_type, GENERIC ) ) && ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) ) ) )
- {
- /*if( enr_q > scaling * enr_old ){enr_q = scaling * enr_old;}*/
- L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/
- }
- ELSE
- {
- ener_max = *lp_ener_FEC_max; /*Q0*/
- move32();
- test();
- if ( EQ_16( clas, VOICED_TRANSITION ) || ( GE_16( clas, INACTIVE_CLAS ) ) )
- {
- ener_max = *lp_ener_FEC_av; /*Q0*/
- move32();
- }
- /*if( enr_old > ener_max )ener_max = enr_old;*/
- ener_max = L_max( ener_max, L_enr_old );
-
- /*if( enr_q > scaling * ener_max ){enr_q = scaling * ener_max;}*/
- L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( ener_max, scaling ), 1 ) ); /* scaling in Q14*/
- }
- }
- /*gain2 = (float)sqrt( enr_q / enr2 );*/
- L_enr_q = L_max( L_enr_q, 1 ); /* L_enr2 is in Q0 */
- L_tmp = Sqrt_Ratio32( L_enr_q, 0, L_enr2, 0, &exp2 );
- gain2 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
-
- /*-----------------------------------------------------------------*
- * Find the energy/gain at the beginning of the frame to ensure smooth transition after erasure(s)
- *-----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( clas == UNVOICED_CLAS || EQ_16( clas, INACTIVE_CLAS ) ) ) ||
- EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || last_core_brate == FRAME_NO_DATA ) &&
- prev_bfi )
- {
- /* voiced -> unvoiced signal transition */
- /* CNG -> active signal transition */
- gain1 = gain2; /*Q14*/
- move16();
- }
- ELSE
- {
- /* find the energy at the beginning of the frame */
- frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1 /*Q0*/, 1, Q_syn, 3, 0 );
-
- /*enr1 += 0.1f;*/
- L_enr1 = L_max( L_enr1, 1 ); /* L_enr1 is in Q0 */
-
- /*gain1 = (float)sqrt( enr_old / enr1 );*/
- L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 );
- gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
-
- /*if( gain1 > 1.2f )gain1 = 1.2f;*/
- /* prevent clipping */
- gain1 = s_min( gain1, 19661 /*1.2f in Q14*/ );
-
- /* prevent amplifying the unvoiced or inactive part of the frame in case an offset is followed by an onset */
- test();
- test();
- if ( EQ_16( clas, ONSET ) && GT_16( gain1, gain2 ) && prev_bfi )
- {
- gain1 = gain2; /*Q14*/
- move16();
- }
- }
-
- L_enr2 = L_enr_q; /*Q0*/
- move32(); /* Set the end frame energy to the scaled energy, to be used in the lp_ener_FEC */
- }
-
- /*------------------------------------------------------------------------------*
- * Smooth the energy evolution by exponentially evolving from gain1 to gain2
- *------------------------------------------------------------------------------*/
-
- /*gain2 *= ( 1.0f - AGC );*/
- L_tmp = L_mult( gain2, (Word16) ( 32768 /*Q15*/ - AGC_FX ) ); /*Q30*/
- FOR( i = 0; i < L_frame; i++ )
- {
- /*gain1 = gain1 * AGC + gain2;*/
- gain1 = mac_r( L_tmp, gain1, AGC_FX ); /* in Q14 */
- /*exc[i] *= gain1;*/
- exc[i] = mac_r( L_mult( exc[i], gain1 ), exc[i], gain1 );
- move16();
- /*exc2[i] *= gain1;*/
- exc2[i] = mac_r_sat( L_mult( exc2[i], gain1 ), exc2[i], gain1 );
- move16();
- }
- /* smoothing is done in excitation domain, so redo synthesis */
- Copy( mem_tmp, mem_syn, M ); /* Q_syn */
- syn_12k8_fx( L_frame, Aq, exc2, synth, mem_syn, 1, Q_exc, Q_syn );
- *update_flg = 1;
- move16();
- }
- }
- ELSE
- {
- /* previous frame erased and no TC frame */
- test();
- IF( prev_bfi && NE_16( coder_type, TRANSITION ) )
- {
- IF( L_enr_q == 0 )
- {
- L_enr_q = L_max( 1, L_enr2 ); /* sets to 'L_enr2' in 1 clock */
- set16_fx( h1, 0, L_FRAME / 2 );
- h1[0] = 1024; /*1.0f in Q10*/
- move16();
- /*syn_filt( Aq+(3*(M+1)), M, h1, h1, L_FRAME/2, h1+(M+1), 0 );*/
- E_UTIL_synthesis( 1, Aq + ( 3 * ( M + 1 ) ), h1, h1, L_FRAME / 2, h1 + ( M + 1 ), 0, M );
- /*Compute tilt */
- /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/
- /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/
- /*tilt = rr1 / rr0;*/
- tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( ( EQ_32( total_brate, ACELP_13k20 ) ) || ( EQ_32( total_brate, ACELP_12k85 ) ) || ( EQ_32( total_brate, ACELP_12k15 ) ) || ( EQ_32( total_brate, ACELP_11k60 ) ) ||
- ( EQ_32( total_brate, ACELP_9k60 ) ) ) &&
- ( GT_16( tilt, 22938 ) ) && /* HF resonnant filter */
- ( ( ( clas == UNVOICED_CLAS ) ) || ( EQ_16( clas, INACTIVE_CLAS ) ) ) ) ) /* unvoiced classification */
- {
- /*if( enr_q > scaling * enr_old )enr_q = scaling * enr_old;*/
- L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/
- }
- ELSE IF( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) )
- {
- /* Voiced-voiced recovery */
- test();
- IF( *old_enr_LP != 0 && GT_16( enr_LP, shl_sat( *old_enr_LP, 1 ) ) )
- {
- /* enr_q /= enr_LP */
- exp = norm_l( L_enr_q );
- tmp = extract_h( L_shl( L_enr_q, exp ) );
-
- exp2 = norm_s( enr_LP );
- tmp2 = shl( enr_LP, exp2 );
-
- exp = sub( exp2, exp );
-
- tmp3 = sub( tmp, tmp2 );
- IF( tmp3 > 0 )
- {
- tmp = shr( tmp, 1 );
- exp = add( exp, 1 );
- }
- tmp = div_s( tmp, tmp2 );
-
- /* L_enr_q *= 2 * *old_enr_LP */
- L_enr_q = L_shl( L_mult( tmp, shl( *old_enr_LP, 1 ) ), exp );
- }
-
- ELSE
- {
- test();
- IF( avoid_lpc_burst_on_recovery && GT_16( enr_LP, 160 /*20.0f in Q3*/ ) )
- {
- exp = norm_s( enr_LP );
- tmp = shl( enr_LP, exp );
-
- exp2 = 7;
- move16();
- tmp2 = 160 << 7; /* 160 = 20.0f in Q3 */
- move16();
- exp = sub( exp2, exp );
-
- IF( GT_16( tmp, tmp2 ) )
- {
- tmp = shr( tmp, 1 );
- exp = add( exp, 1 );
- }
- tmp = div_s( tmp, tmp2 ); /* tmp*2^exp = enr_LP/20.0 */
- L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* L_tmp*2^exp = sqrt(20.0/enr_LP) */
- L_enr_q = L_shl( Mpy_32_32( L_enr_q, L_tmp ), exp );
- }
- }
- }
-
- test();
- test();
- test();
- test();
- IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) || force_scaling )
- {
-
- IF( GT_32( L_enr_q, L_enr_old ) ) /* Prevent energy to increase on voiced */
- {
- L_enr_q = L_add( Mpy_32_16_1( L_enr_old, 32767 - SCLSYN_LAMBDA ), Mpy_32_16_1( L_enr_q, SCLSYN_LAMBDA ) ); /*Q0*/
- }
- }
- }
-
- L_enr_q = L_max( 1, L_enr_q );
-
- /* gain2 = (float)sqrt( enr_q / enr2 );*/
- exp = norm_l( L_enr_q );
- tmp = extract_h( L_shl( L_enr_q, exp ) );
-
- exp2 = norm_l( L_enr2 );
- tmp2 = extract_h( L_shl( L_enr2, exp2 ) );
-
- exp2 = sub( exp, exp2 ); /* Denormalize and substract */
-
- tmp3 = sub( tmp2, tmp );
- IF( tmp3 > 0 )
- {
- tmp2 = shr( tmp2, 1 );
- exp2 = add( exp2, 1 );
- }
-
- tmp = div_s( tmp2, tmp );
-
- L_tmp = L_deposit_h( tmp );
- L_tmp = Isqrt_lc( L_tmp, &exp2 );
- gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
- /*-----------------------------------------------------------------*
- * Clipping of the smoothing gain at the frame end
- *-----------------------------------------------------------------*/
-
- gain2 = s_min( gain2, 19661 /*1.2f in Q14*/ ); /* Gain modification clipping */
- if ( LT_32( L_enr_q, 2 ) )
- {
- gain2 = s_min( gain2, 16384 /*1.0f in Q14*/ ); /* Gain modification clipping */
- }
-
- /*-----------------------------------------------------------------*
- * Find the energy/gain at the beginning of the frame to ensure smooth transition after erasure(s)
- *-----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( clas, SIN_ONSET ) ) /* slow increase */
- {
- gain1 = shr( gain2, 1 ); /*0.5f * gain2*/
- }
- /*------------------------------------------------------------*
- * voiced->unvoiced transition recovery
- *------------------------------------------------------------*/
- ELSE IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( clas == UNVOICED_CLAS || EQ_16( clas, INACTIVE_CLAS ) ) ) || /* voiced->unvoiced transition recovery */
- EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || last_core_brate == FRAME_NO_DATA ) /* CNG -> active signal transition */
- {
- gain1 = gain2; /*Q14*/
- move16();
- }
- ELSE
- {
- /*--------------------------------------------------------*
- * Find the energy at the beginning of the frame
- *--------------------------------------------------------*/
- tmp = frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1, 0, Q_syn, 3, 0 );
-
- /*gain1 = (float)sqrt( enr_old / enr1 );*/
- exp = norm_l( L_enr_old );
- tmp = extract_h( L_shl( L_enr_old, exp ) );
- exp2 = norm_l( L_enr1 );
- tmp2 = extract_h( L_shl( L_enr1, exp2 ) );
-
- exp2 = sub( exp, exp2 ); /* Denormalize and substract */
-
- tmp3 = sub( tmp2, tmp );
-
- IF( tmp3 > 0 )
- {
- tmp2 = shr( tmp2, 1 );
- exp2 = add( exp2, 1 );
- }
-
- tmp = div_s( tmp2, tmp );
-
- L_tmp = L_deposit_h( tmp );
- L_tmp = Isqrt_lc( L_tmp, &exp2 );
- gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */
- /* exp2 is always <= 1 */
-
- gain1 = s_min( gain1, 19661 /*1.2F in Q14*/ );
-
- test();
- test();
- if ( avoid_lpc_burst_on_recovery && ( GT_16( enr_LP, 160 ) ) && ( LE_16( enr_LP, shl_sat( *old_enr_LP, 1 ) ) ) )
- {
- gain1 = s_min( gain1, 16384 /*1.0f in Q14*/ );
- }
-
- /*--------------------------------------------------------*
- * Prevent a catastrophy in case of offset followed by onset
- *--------------------------------------------------------*/
- test();
- if ( ( EQ_16( clas, ONSET ) ) && ( GT_16( gain1, gain2 ) ) )
- {
- gain1 = gain2; /*Q14*/
- move16();
- }
- }
- /*-----------------------------------------------------------------*
- * Smooth the energy evolution by exponentially evolving from
- * gain1 to gain2
- *-----------------------------------------------------------------*/
-
- L_tmp = L_mult( gain2, (Word16) ( 32768 /*Q15*/ - AGC_FX ) );
-
- FOR( i = 0; i < L_frame; i++ )
- {
- gain1 = mac_r( L_tmp, gain1, AGC_FX ); /* in Q14 */
- exc[i] = mac_r_sat( L_mult_sat( exc[i], gain1 ), exc[i], gain1 );
- move16();
- exc2[i] = mac_r_sat( L_mult_sat( exc2[i], gain1 ), exc2[i], gain1 );
- move16();
- }
-
- Copy( mem_tmp, mem_syn, M ); /* Q_syn */
- syn_12k8_fx( L_frame, Aq, exc2, synth, mem_syn, 1, Q_exc, Q_syn );
- *update_flg = 1;
- move16();
- }
- }
- /*-----------------------------------------------------------------*
- * Update low-pass filtered energy for voiced frames
- *-----------------------------------------------------------------*/
-
- test();
- test();
- IF( !bfi && ( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) )
- {
- IF( EQ_16( clas, VOICED_TRANSITION ) )
- {
- L_enr2_av = L_enr2; /*Q0*/
- move32();
- frame_ener_fx( L_frame, VOICED_CLAS, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_ener2_max /*Q0*/, 1, Q_syn, 3, 0 );
- }
- ELSE
- {
- L_ener2_max = L_enr2; /*Q0*/
- move32();
- frame_ener_fx( L_frame, UNVOICED_CLAS, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_enr2_av /*Q0*/, 1, Q_syn, 3, 0 );
- }
-
- /**lp_ener_FEC_av = 0.2f * enr2_av + 0.8f * *lp_ener_FEC_av; move32();*/
- *lp_ener_FEC_av = Madd_32_16( Mult_32_16( *lp_ener_FEC_av, 31130 /*0.95f in Q15*/ ), L_enr2_av, 1638 /*0.05F Q15*/ ); /*Q0*/
- move32();
- /**lp_ener_FEC_max = 0.2f * enr2_max + 0.8f * *lp_ener_FEC_max; move32();*/
- *lp_ener_FEC_max = Madd_32_16( Mult_32_16( *lp_ener_FEC_max, 31130 /*0.95f in Q15*/ ), L_ener2_max, 1638 /*0.05F Q15*/ ); /*Q0*/
- move32();
- }
-
- /*-----------------------------------------------------------------*
- * Update the LP filter energy for voiced frames
- *-----------------------------------------------------------------*/
- test();
- if ( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) )
- {
- *old_enr_LP = enr_LP; /*Q3*/
- move16();
- }
-
- return;
-}
-#endif
-void FEC_scale_syn_ivas_fx(
- const Word16 L_frame, /* i : length of the frame */
- Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
- Word16 clas, /* i/o: frame classification */
- const Word16 last_good, /* i: last good frame classification */
- Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz Q_syn*/
- const Word16 *pitch, /* i: pitch values for each subframe Q0*/
- Word32 L_enr_old, /* i: energy at the end of previous frame */
- Word32 L_enr_q, /* i: transmitted energy for current frame */
- const Word16 coder_type, /* i: coder type */
- const Word16 LSF_Q_prediction, /* i : LSF prediction mode */
- Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */
- Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy Q0*/
- Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy Q0*/
- const Word16 bfi, /* i: current frame BFI */
- const Word32 total_brate, /* i: total bitrate */
- const Word16 prev_bfi, /* i: previous frame BFI */
- const Word32 last_core_brate, /* i: previous frame core bitrate */
- Word16 *exc, /* i/o: excitation signal without enhancement */
- Word16 *exc2, /* i/o: excitation signal with enhancement */
- Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) Q12*/
- Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame Q3*/
- const Word16 *mem_tmp, /* i: temp. initial synthesis filter states Q_syn*/
- Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/
- Word16 Q_exc,
- Word16 Q_syn,
-#ifdef REMOVE_EVS_DUPLICATES
- const Word16 element_mode, /* i : element mode */
-#endif
+ const Word16 element_mode, /* i : element mode */
const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */
const Word16 force_scaling /* i: force scaling */
)
@@ -742,12 +174,8 @@ void FEC_scale_syn_ivas_fx(
tmp = sub( 3, getScaleFactor16( synth, L_frame ) );
-#ifdef REMOVE_EVS_DUPLICATES
test();
IF( tmp > 0 && GT_16( element_mode, EVS_MONO ) )
-#else
- IF( tmp > 0 )
-#endif
{
Word16 synth_tmp[L_FRAME16k];
Copy_Scale_sig( synth, synth_tmp, L_frame, -tmp ); // Q_synth - tmp
diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c
index 3570ce86d0732eea55107318f3f29db347a99b52..2c72bba78a2920fabc8d5555f5b7716dd4882bbe 100644
--- a/lib_dec/acelp_core_dec_fx.c
+++ b/lib_dec/acelp_core_dec_fx.c
@@ -1,156 +1,233 @@
+/******************************************************************************************************
+
+ (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
/*====================================================================================
- EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
====================================================================================*/
-
#include
#include
-#include "options.h" /* Compilation switches */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx.h" /* Function prototypes */
+#include
+#include "options.h"
+#include "cnst.h"
+#include "rom_com.h"
+#include "prot_fx.h"
+#include "ivas_cnst.h"
+#include "ivas_rom_com.h"
+#include "wmc_auto.h"
#include "ivas_prot_fx.h"
-#include "ivas_cnst.h" /* Common constants */
-#include "cnst.h" /* Common constants */
-
-#ifndef REMOVE_EVS_DUPLICATES
-/*==========================================================================*/
-/* FUNCTION : void acelp_core_dec_fx () */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : ACELP core decoder */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ Word16 coder_type i : coder type */
-
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ Word16 *voice_factors o : voicing factors Q15 */
-/* _ Word16 old_syn_12k8_16k[] o : intermediate ACELP Q_syn2-1 */
-/* synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
-/* _ Word16 synth_out[] o : synthesis Q_syn2-1 */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ Decoder_State_fx *st_fx: */
-/* _ Word16 bwe_exc_extended[] i/o: bandwidth extended excitation Q0*/
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*--------------------------------------------------------------------------*/
-/* CALLED FROM : RX */
-/*==========================================================================*/
+
+
+/*-------------------------------------------------------------------*
+ * acelp_core_dec_fx()
+ *
+ * ACELP core decoder
+ *-------------------------------------------------------------------*/
ivas_error acelp_core_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 output[], /* o : synthesis @internal Fs */
- Word16 synth_out[], /* o : synthesis Q_syn2-1*/
- Word16 save_hb_synth[], /* o : HB synthesis */
- Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q0*/
- Word16 *voice_factors, /* o : voicing factors Q15 */
- Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis for SWB BWE Q_syn2-1*/
- Word16 sharpFlag,
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/
- Word16 *unbits, /* o : number of unused bits */
- Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */
- const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */
- const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
- const Word16 nchan_out, /* i : number of output channels */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const Word16 read_sid_info /* i : read SID info flag */
+ Decoder_State *st, /* i/o: decoder state structure */
+ Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/
+ Word16 synth_fx16[], /* o : synthesis Q_syn2*/
+ Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_exc*/
+ Word16 *voice_factors_fx, /* o : voicing factors Q15*/
+ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE Q_syn2-1*/
+ const Word16 sharpFlag, /* i : formant sharpening flag */
+ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : Word16 pitch for each subframe Q6*/
+ Word16 *unbits, /* o : number of unused bits */
+ Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
+ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle Qlog2(2.56)*/
+ const Word16 tdm_lspQ_PCh_fx[M], /* i : Q LSPs for primary channel Q15*/
+ const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */
+ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
+ const Word16 last_element_mode, /* i : last element mode */
+ const Word32 last_element_brate, /* i : last element bitrate */
+ const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
+ const Word16 nchan_out, /* i : number of output channels */
+ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
+ const Word16 read_sid_info /* i : read SID info flag */
)
{
- Word16 old_exc_fx[L_EXC_DEC] = { 0 }, *exc_fx; /* excitation signal buffer (Q0) */
- Word16 syn_fx_tmp[L_FRAME_16k + L_SUBFR], *syn_fx; /* synthesis signal buffer */
- Word16 temp_buf[L_FRAME16k + L_SYN_MEM];
- Word16 output_frame; /* frame length at output sampling freq. */
- Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */
- Word32 enr_q_fx; /* E information for FER protection */
- Word16 tmp_noise_fx; /* Long term temporary noise energy */
- Word16 i, int_fs;
- Word16 tc_subfr_fx;
- Word16 allow_cn_step_fx;
+ Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/;
+ Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */
+ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */
+ Word16 output_frame; /* frame length at output sampling freq. */
+ Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */
+ Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */
+ Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */
+ Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */
+ Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */
+ Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */
+ Word32 enr_q_fx; /* E information for FER protection */
+ Word16 tmp_noise_fx; /* Long term temporary noise energy */
+ Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */
+ Word16 FEC_pitch_fx; /* FEC pitch */
+ Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */
+ Word16 *bwe_exc_fx; /* Excitation for SWB TBE */
+ Word16 i, j, int_fs;
+ Word16 tc_subfr;
+ Word16 allow_cn_step;
Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM];
-
- Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )] = { 0 }; /*Q12*/
- Word16 Es_pred_fx; /*Q8*/
- Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )] = { 0 }; /* excitation buffer Q_exc*/
- Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */
- Word16 *bwe_exc_fx;
- Word16 lsf_new_fx[M]; /* LSFs at the end of the frame */
- Word16 lsp_new_fx[M]; /* LSPs at the end of the frame */
- Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */
- Word16 FEC_pitch_fx; /*Q6*/
Word16 last_pulse_pos;
Word16 T0_tmp;
- Word16 do_WI_fx;
+ Word16 do_WI;
Word16 dct_buffer_fx[DCT_L_POST];
Word16 exc_buffer_fx[DCT_L_POST];
- Word16 dct_exc_tmp[L_FRAME16k];
- Word16 qdct;
- Word16 delta_mem_scale;
- Word16 bpf_error_signal[L_FRAME16k];
- CLDFB_SCALE_FACTOR scaleFactor;
- Word32 workBuffer[128 * 3];
- Word32 q_env[20];
- Word16 exc3_fx[L_FRAME16k];
- Word16 syn1_fx_tmp[L_FRAME16k + 2], *syn1_fx;
- Word32 *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX];
- Word16 gain_buf[NB_SUBFR16k]; /*Q14*/
+ Word16 dct_exc_tmp_fx[L_FRAME16k];
+ Word16 nb_bits; /* number of bits */
+ Word16 indice; /* parameter indices to write */
+ Word16 gain_buf_fx[NB_SUBFR16k];
Word16 syn_fx_tmp2[L_FRAME_16k];
Word16 pitch_buf_tmp[NB_SUBFR16k];
- Word16 k;
Word16 update_flg;
- Word32 realBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 imagBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word16 LSF_Q_prediction; /* o : LSF prediction mode */
+ Word32 q_env_fx[20];
+ Word16 exc3_fx[L_FRAME16k];
+ Word16 syn1_tmp_fx[L_FRAME16k + 2], *syn1_fx;
+ Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX];
+ Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word16 LSF_Q_prediction; /* LSF prediction mode */
Word16 avoid_lpc_burst_on_recovery;
- Word16 uc_two_stage_flag, dec;
- Word16 nb_bits, indice;
+ Word16 tmpF_fx;
+ Word16 uc_two_stage_flag;
Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
- MUSIC_POSTFILT_HANDLE hMusicPF;
- BPF_DEC_HANDLE hBPF;
- TD_BWE_DEC_HANDLE hBWE_TD;
- FD_BWE_DEC_HANDLE hBWE_FD;
- TCX_DEC_HANDLE hTcxDec;
+ Word16 *old_exc_s_fx; /* Start of last excitation frame */
+ Word16 *p_tdm_Pri_pitch_buf_fx;
+ Word16 tmp, exp, local_element_mode;
ivas_error error;
- (void) ( tdm_lspQ_PCh );
- (void) ( tdm_lsfQ_PCh );
- (void) ( use_cldfb_for_dft );
- (void) ( last_element_mode );
- (void) ( last_element_brate );
- (void) ( flag_sec_CNA );
- (void) ( nchan_out );
- (void) ( save_hb_synth );
- (void) ( output );
- (void) ( read_sid_info );
- (void) hStereoCng;
- hMusicPF = st_fx->hMusicPF;
- hBPF = st_fx->hBPF;
- hBWE_TD = st_fx->hBWE_TD;
- hBWE_FD = st_fx->hBWE_FD;
- hTcxDec = st_fx->hTcxDec;
+ Word32 bpf_error_signal_fx[L_FRAME16k];
+ Word16 bpf_error_signal_16fx[L_FRAME16k];
+ Word16 Q_real;
+ Word32 max_real, max_imag, max_val;
+
+ set32_fx( bpf_error_signal_fx, 0, L_FRAME16k );
+ set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k );
+ set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) );
+ set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) );
+
error = IVAS_ERR_OK;
move32();
- // IF ( EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) && EQ_16(nchan_out, 1) && EQ_16(st_fx->idchan, 1) && LE_32(last_element_brate, IVAS_SID_4k4) )
+
test();
test();
test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) )
+ IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) )
{
/* In MDCT-Stereo DTX with mono output, we can skip CNG for the second channel, except for the first inactive frame following an active period */
return error;
}
+ push_wmops( "acelp_core_dec" );
+
+ /* output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); */
+ output_frame = extract_l( Mpy_32_32( st->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+
+ /*----------------------------------------------------------------*
+ * stereo SID and CNG frames processing
+ *----------------------------------------------------------------*/
+
+ test();
+ test();
+ IF( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) )
+ {
+ IF( EQ_16( st->cng_type, FD_CNG ) )
+ {
+ configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
+
+ Word16 old_NoiseEstExp;
+ old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
+ move16();
+
+ /* Only run parameter decoding in SID frames */
+ IF( EQ_32( st->core_brate, SID_2k40 ) )
+ {
+ FdCng_decodeSID_ivas_fx( st );
+
+ Word16 n1, n2;
+ n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART );
+ n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART );
+
+ Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) );
+ scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) );
+ scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) );
+ st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e;
+ move16();
+ }
+
+ FOR( i = 0; i < NPART; i++ )
+ {
+ st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
+ STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
+ move32();
+ }
+
+ ApplyFdCng_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 );
+ }
+ ELSE
+ {
+ configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
+
+ /* decode CNG parameters */
+ CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
+
+ /* comfort noise generation */
+ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode );
+
+ Copy( Aq_fx, st->Aq_cng, M + 1 ); /*Q12*/
+
+ /* update old LSP and LSF vector */
+ Copy( lsf_new_fx, st->lsf_old_fx, M ); /*Qlog2(2.56)*/
+ Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Q15*/
+ }
+
+ set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */
+ set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */
+
+ /* CN generation done in DFT domain */
+ pop_wmops();
+
+ return error;
+ }
+
+ /*----------------------------------------------------------------*
+ * Active frames processing
+ *----------------------------------------------------------------*/
+
+ /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
{
- set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer[i] = realBufferTmp[i];
- move32();
- imagBuffer[i] = imagBufferTmp[i];
- move32();
+ set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
+ realBuffer_fx[i] = realBufferTmp_fx[i];
+ imagBuffer_fx[i] = imagBufferTmp_fx[i];
}
/*----------------------------------------------------------------*
@@ -159,54 +236,61 @@ ivas_error acelp_core_dec_fx(
LSF_Q_prediction = -1;
move16();
- set16_fx( syn_fx_tmp, 0, L_SUBFR );
- syn_fx = syn_fx_tmp + L_SUBFR;
- syn1_fx_tmp[0] = 0;
+ set16_fx( syn_tmp_fx, 0, L_SUBFR );
+ psyn_fx = syn_tmp_fx + L_SUBFR;
+ syn1_tmp_fx[0] = 0;
move16();
- syn1_fx_tmp[1] = 0;
+ syn1_tmp_fx[1] = 0;
move16();
- syn1_fx = syn1_fx_tmp + 2;
- /*output_frame = (Word16)(st_fx->output_Fs_fx / 50); move16();*/
- output_frame = st_fx->output_frame_fx;
- move16();
- st_fx->bpf_off = 0;
+ syn1_fx = syn1_tmp_fx + 2;
+ st->bpf_off = 0;
move16();
+
test();
test();
test();
test();
test();
test();
- IF( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && LE_32( st_fx->last_core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && LE_32( st_fx->last_core_brate, SID_2k40 ) ) )
+ IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->last_core_brate, SID_2k40 ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) )
{
/* in case of HQ->ACELP switching, do not apply BPF */
- st_fx->bpf_off = 1;
+ st->bpf_off = 1;
move16();
- /* in case of core switching, reset post-filter memories */
- if ( st_fx->hPFstat != NULL )
+ if ( st->hPFstat != NULL )
{
- st_fx->hPFstat->on = 0;
+ /* in case of core switching, reset post-filter memories */
+ st->hPFstat->on = 0;
move16();
}
- /* reset the GSC pre echo energy threshold in case of switching */
- if ( st_fx->hGSCDec != NULL )
+ if ( st->hGSCDec != NULL )
{
- st_fx->hGSCDec->Last_frame_ener_fx = MAX_32;
+ /* reset the GSC pre echo energy threshold in case of switching */
+ st->hGSCDec->Last_frame_ener_fx = MAX_32;
move32();
}
}
- IF( st_fx->prev_bfi > 0 )
+
+ test();
+ if ( st->hGSCDec != NULL && ( st->prev_bfi > 0 ) )
{
/* reset the GSC pre echo energy threshold in case of FEC */
- if ( st_fx->hGSCDec != NULL )
- {
- st_fx->hGSCDec->Last_frame_ener_fx = MAX_32;
- move32();
- }
+ st->hGSCDec->Last_frame_ener_fx = MAX_32;
+ move32();
+ }
+
+ test();
+ test();
+ test();
+ test();
+ IF( st->hFdCngDec != NULL && ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) )
+ {
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN );
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN );
}
- st_fx->clas_dec = st_fx->last_good;
+ st->clas_dec = st->last_good;
move16();
enr_q_fx = 0;
move32();
@@ -214,21 +298,22 @@ ivas_error acelp_core_dec_fx(
move16();
tmp_noise_fx = 0;
move16();
- Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc
+ Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
exc_fx = old_exc_fx + L_EXC_MEM_DEC;
- IF( st_fx->hWIDec != NULL )
+ IF( st->hWIDec != NULL )
{
- Copy( st_fx->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM );
+ Copy( st->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM );
}
ELSE
{
set16_fx( old_exc2_fx, 0, L_EXC_MEM );
}
exc2_fx = old_exc2_fx + L_EXC_MEM;
- IF( st_fx->hBWE_TD != NULL )
+
+ IF( st->hBWE_TD != NULL )
{
- Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); // Q_exc
+ Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/
bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2;
}
ELSE
@@ -238,271 +323,270 @@ ivas_error acelp_core_dec_fx(
last_pulse_pos = 0;
move16();
- do_WI_fx = 0;
+ do_WI = 0;
move16();
- st_fx->GSC_noisy_speech = 0;
+ st->GSC_noisy_speech = 0;
move16();
- st_fx->relax_prev_lsf_interp = 0;
+ st->relax_prev_lsf_interp = 0;
move16();
+ set16_fx( gain_buf_fx, 0, NB_SUBFR16k );
- set16_fx( gain_buf, 0, NB_SUBFR16k );
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- st_fx->gamma = GAMMA1;
+ st->gamma = GAMMA1;
move16();
- st_fx->preemph_fac = PREEMPH_FAC;
+ st->inv_gamma = GAMMA1_INV;
move16();
- int_fs = INT_FS_FX;
+ st->preemph_fac = PREEMPH_FAC;
+ move16();
+ int_fs = INT_FS_12k8;
move16();
}
ELSE
{
- st_fx->gamma = GAMMA16k;
+ st->gamma = GAMMA16k;
+ move16();
+ st->inv_gamma = GAMMA16k_INV;
move16();
- st_fx->preemph_fac = PREEMPH_FAC_16k;
+ st->preemph_fac = PREEMPH_FAC_16k;
move16();
int_fs = INT_FS_16k;
move16();
}
- /* reset post-filter in case post-filtering was off in previous frame */
- IF( st_fx->hPFstat != NULL )
+ test();
+ /* reset post-filter in case of switching */
+ if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) )
{
- if ( st_fx->hPFstat->on == 0 )
- {
- st_fx->hPFstat->reset = 1;
- move16();
- }
+ st->hPFstat->reset = 1;
+ move16();
}
+
avoid_lpc_burst_on_recovery = 0;
move16();
test();
test();
- if ( st_fx->last_con_tcx && NE_16( st_fx->L_frameTCX_past, st_fx->L_frame ) && st_fx->last_core != 0 )
+ if ( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) )
{
avoid_lpc_burst_on_recovery = 1;
move16();
}
- /* TD stereo parameters */
test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && st_fx->idchan == 1 )
+
+ /* TD stereo parameters */
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
{
tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag;
- tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
- tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
- move16();
move16();
+ tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
move16();
+ tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
move16();
+ p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx;
}
ELSE
{
tdm_lp_reuse_flag = 0;
- tdm_low_rate_mode = 0;
move16();
+ tdm_low_rate_mode = 0;
move16();
test();
- if ( EQ_16( st_fx->element_mode, IVAS_SCE ) && st_fx->low_rate_mode )
+ if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
{
tdm_low_rate_mode = 1;
move16();
}
tdm_Pitch_reuse_flag = 0;
move16();
+ p_tdm_Pri_pitch_buf_fx = NULL;
}
+
/*----------------------------------------------------------------*
* Updates in case of internal sampling rate switching
*----------------------------------------------------------------*/
+
test();
test();
- IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
+ IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
{
- IF( st_fx->hPFstat->on != 0 )
+ Word16 dec;
+
+ IF( ( st->hPFstat->on != 0 ) )
{
Word16 mem_syn_r_size_old, mem_syn_r_size_new;
-
- mem_syn_r_size_old = shr( st_fx->last_L_frame, 4 );
- mem_syn_r_size_new = shr( st_fx->L_frame, 4 );
- lerp( st_fx->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st_fx->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st_fx->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st_fx->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old );
+ mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); /* 1.25/20.f = 2048 (Q15)*/
+ mem_syn_r_size_new = mult_r( 2048, st->L_frame ); /* 1.25/20.f = 2048 (Q15)*/
+ lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
+ lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
}
+
/* convert quantized LSP vector */
- st_fx->rate_switching_reset = lsp_convert_poly_fx( st_fx->lsp_old_fx, st_fx->L_frame, 0 );
+ st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
move16();
+
/* convert old quantized LSF vector */
- lsp2lsf_fx( st_fx->lsp_old_fx, st_fx->lsf_old_fx, M, int_fs );
+ lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs );
/* FEC - update adaptive LSF mean vector */
- Copy( st_fx->lsf_old_fx, st_fx->lsfoldbfi1_fx, M ); // Qlog2(2.56)
- Copy( st_fx->lsf_old_fx, st_fx->lsfoldbfi0_fx, M ); // Qlog2(2.56)
- Copy( st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, M ); // Qlog2(2.56)
+ Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); /*Qlog2(2.56)*/
+ Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); /*Qlog2(2.56)*/
+ Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); /*Qlog2(2.56)*/
/* Reset LPC mem */
- IF( EQ_32( st_fx->sr_core, INT_FS_16k ) )
+ IF( EQ_32( st->sr_core, INT_FS_16k ) )
{
- Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56)
+ Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/
}
ELSE
{
- Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56)
+ Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/
}
- set16_fx( st_fx->mem_MA_fx, 0, M );
+ set16_fx( st->mem_MA_fx, 0, M );
+ /* update synthesis filter memories */
dec = DEC;
move16();
- IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ if ( st->element_mode != EVS_MONO )
{
dec = DEC_IVAS;
move16();
}
-
- /* update synthesis filter memories */
- synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec );
-
- Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc
- Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/
-
- Copy( st_fx->mem_syn2_fx, st_fx->mem_syn3_fx, M );
+ ivas_synth_mem_updt2_fx( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec );
+ Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
+ Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/
+ Copy( st->mem_syn2_fx, st->mem_syn3_fx, M ); /*Q_syn*/
}
- IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) )
+ /* update buffer of old subframe pitch values */
+ IF( NE_16( st->last_L_frame, st->L_frame ) )
{
- /* update buffer of old subframe pitch values */
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
-
- IF( EQ_16( st_fx->last_L_frame, L_FRAME32k ) )
+ IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
{
- /* (float)12800/(float)32000; */
- k = 13107; // Q15
+ tmpF_fx = 13107; // Q15
move16();
}
- ELSE IF( EQ_16( st_fx->last_L_frame, 512 ) )
+ ELSE IF( EQ_16( st->last_L_frame, 512 ) )
{
- /* (float)12800/(float)25600; */
- k = 16384; // Q15
+ tmpF_fx = 16384; // Q15
move16();
}
ELSE /* st->last_L_frame == L_FRAME16k */
{
- /* (float)12800/(float)16000; */
- k = 26214; // Q15
+ tmpF_fx = 26214; // Q15
move16();
}
FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ )
{
- st_fx->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ); // Q(15+15+1-16)
+ st->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16
move32();
}
FOR( i = 2 * NB_SUBFR16k - NB_SUBFR; i < 2 * NB_SUBFR16k; i++ )
{
- st_fx->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ); // Q15
+ st->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16
move32();
}
}
ELSE
{
-
- IF( EQ_16( st_fx->last_L_frame, L_FRAME32k ) )
+ exp = 0;
+ move16();
+ IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
{
- /* (float)16000/(float)32000; */
- k = -16384; // -0.5 in Q15
+ tmpF_fx = 16384; // Q15
move16();
}
- ELSE IF( EQ_16( st_fx->last_L_frame, 512 ) )
+ ELSE IF( EQ_16( st->last_L_frame, 512 ) )
{
- /* tmpF = (float)16000/(float)25600; */
- k = -12288; //-0.375 in Q15
+ tmpF_fx = 20480; // Q15
move16();
}
ELSE /* st->last_L_frame == L_FRAME12k8 */
{
- /* tmpF = (float)16000/(float)12800; */
- k = 8192; //.25 in Q15
+ tmpF_fx = 20480; // Q14
+ move16();
+ exp = 1;
move16();
}
-
FOR( i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i-- )
{
- st_fx->old_pitch_buf_fx[i + 2] = L_add( st_fx->old_pitch_buf_fx[i], Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ) ); // Q15
+ st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15
move32();
}
- st_fx->old_pitch_buf_fx[NB_SUBFR + 1] = st_fx->old_pitch_buf_fx[NB_SUBFR + 2];
+ st->old_pitch_buf_fx[NB_SUBFR + 1] = st->old_pitch_buf_fx[NB_SUBFR + 2];
move32();
FOR( i = NB_SUBFR - 1; i >= 0; i-- )
{
- st_fx->old_pitch_buf_fx[i + 1] = L_add( st_fx->old_pitch_buf_fx[i], Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ) ); // Q15
+ st->old_pitch_buf_fx[i + 1] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15
move32();
}
- st_fx->old_pitch_buf_fx[0] = st_fx->old_pitch_buf_fx[1];
+ st->old_pitch_buf_fx[0] = st->old_pitch_buf_fx[1];
move32();
}
}
- IF( NE_16( st_fx->bfi_pitch_frame, st_fx->L_frame ) )
+ IF( NE_16( st->bfi_pitch_frame, st->L_frame ) )
{
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
-
- IF( EQ_16( st_fx->bfi_pitch_frame, L_FRAME32k ) )
+ IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
{
- /* (float)12800/(float)32000; */
- k = 13107; // Q15
+ tmpF_fx = 13107; // Q15
move16();
}
- ELSE IF( EQ_16( st_fx->bfi_pitch_frame, 512 ) )
+ ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
{
- /* (float)12800/(float)25600; */
- k = 16384; // Q15
+ tmpF_fx = 16384; // Q15
move16();
}
ELSE /* st->bfi_pitch_frame == L_FRAME16k */
{
- /* (float)12800/(float)16000; */
- k = 26214; // Q15
+ tmpF_fx = 26214; // Q15
move16();
}
- st_fx->bfi_pitch_fx = mult_r( k, st_fx->bfi_pitch_fx );
+ st->bfi_pitch_fx = mult_r( st->bfi_pitch_fx, tmpF_fx );
move16();
- st_fx->bfi_pitch_frame = L_FRAME;
+ st->bfi_pitch_frame = L_FRAME;
move16();
}
ELSE
{
-
- IF( EQ_16( st_fx->bfi_pitch_frame, L_FRAME32k ) )
+ exp = 0;
+ move16();
+ IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
{
- /* (float)16000/(float)32000; */
- k = -16384; //-0.5 in Q15
+ tmpF_fx = 16384; // Q15
move16();
}
- ELSE IF( EQ_16( st_fx->bfi_pitch_frame, 512 ) )
+ ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
{
- /* tmpF = (float)16000/(float)25600; */
- k = -12288; // -0.375 in Q15
+ tmpF_fx = 20480; // Q15
move16();
}
ELSE /* st->bfi_pitch_frame == L_FRAME12k8 */
{
- /* tmpF = (float)16000/(float)12800; */
- k = 8192; // .25 in Q15
+ tmpF_fx = 20480; // Q14
+ move16();
+ exp = 1;
move16();
}
- st_fx->bfi_pitch_fx = add( st_fx->bfi_pitch_fx, mult_r( st_fx->bfi_pitch_fx, k ) );
+
+ st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx );
move16();
- st_fx->bfi_pitch_frame = L_FRAME16k;
+ st->bfi_pitch_frame = L_FRAME16k;
move16();
}
}
test();
test();
- if ( EQ_16( st_fx->last_bwidth, NB ) && NE_16( st_fx->bwidth, NB ) && st_fx->ini_frame != 0 )
+ if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) )
{
- st_fx->rate_switching_reset = 1;
+ st->rate_switching_reset = 1;
move16();
}
@@ -510,36 +594,35 @@ ivas_error acelp_core_dec_fx(
* GOOD frame
*----------------------------------------------------------------------*/
- IF( !st_fx->bfi )
+ IF( !st->bfi )
{
/*----------------------------------------------------------------*
* Decoding of TC subframe classification
*----------------------------------------------------------------*/
- tc_subfr_fx = -1;
+ tc_subfr = -1;
move16();
- IF( EQ_16( st_fx->coder_type, TRANSITION ) )
+ IF( EQ_16( st->coder_type, TRANSITION ) )
{
- tc_subfr_fx = tc_classif_fx( st_fx, st_fx->L_frame );
+ tc_subfr = tc_classif_fx( st, st->L_frame );
}
/*----------------------------------------------------------------*
* Decoding of GSC IVAS mode
*----------------------------------------------------------------*/
- st_fx->GSC_IVAS_mode = 0;
- move16();
+
test();
test();
test();
test();
- IF( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 && !( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode )
+ IF( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode )
{
test();
test();
- IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) ) )
+ IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && EQ_16( st->inactive_coder_type_flag, 1 ) ) )
{
- st_fx->GSC_IVAS_mode = get_next_indice( st_fx, 2 );
+ st->GSC_IVAS_mode = get_next_indice_fx( st, 2 );
move16();
}
}
@@ -547,88 +630,215 @@ ivas_error acelp_core_dec_fx(
/*----------------------------------------------------------------*
* Decoding of inactive CNG frames
*----------------------------------------------------------------*/
+
test();
- IF( st_fx->core_brate == FRAME_NO_DATA || EQ_32( st_fx->core_brate, SID_2k40 ) )
+ IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
{
/* decode CNG parameters */
- IF( st_fx->cng_type == LP_CNG )
+ IF( st->cng_type == LP_CNG )
{
-
- CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env );
+ CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
+ Copy( Aq_fx, st->Aq_cng, add( M, 1 ) );
/* comfort noise generation */
- CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate,
- &st_fx->first_CNG, &( st_fx->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step_fx, &st_fx->hTdCngDec->last_allow_cn_step, st_fx->prev_Q_exc, st_fx->Q_exc, st_fx->hTdCngDec->num_ho,
- q_env, st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem1_fx, sid_bw, &st_fx->hTdCngDec->cng_ener_seed1, exc3_fx, st_fx->Opt_AMR_WB, st_fx->element_mode );
+ local_element_mode = st->element_mode;
+ move16();
- Copy( Aq_fx, st_fx->Aq_cng, M + 1 ); // Q12
+ test();
+ test();
+ if ( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) )
+ {
+ local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */
+ move16();
+ }
+ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, local_element_mode );
}
ELSE
{
test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- FdCng_decodeSID_fx( st_fx->hFdCngDec->hFdCngCom, st_fx );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st );
+ }
+ ELSE
+ {
+ Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
+ move16();
+
+ FdCng_decodeSID_ivas_fx( st );
+
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
+ Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx
+ }
+
*sid_bw = 0;
move16();
}
- generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 );
+ IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
+ {
+ assert( nchan_out == 1 );
+
+ FOR( i = 0; i < NPART; i++ )
+ {
+ st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
+ STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
+ move32();
+ }
+
+ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
+
+ Word16 new_sidNoiseEstExp = 31 - Q4;
+ move16();
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
+ Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
+ st->hFdCngDec->hFdCngCom->sidNoiseEstExp = new_sidNoiseEstExp;
+ move16();
+ Word16 new_cngNoiseLevelExp = 31 - Q4;
+ move16();
+ Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, new_cngNoiseLevelExp ) ); // Q(31-cngNoiseLevelExp)
+ st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp;
+ move16();
+
+ test();
+ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) );
+
+ IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
+ {
+ Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); // Q(31-cngNoiseLevelExp)
+ st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
+ move16();
+ }
+ }
+
+ IF( !read_sid_info )
+ {
+ Word32 noise_lvl_highest_fx;
+
+ noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) - 1];
+ move32();
+
+ FOR( Word16 b = ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); b < st->hFdCngDec->hFdCngCom->stopBand; b++ )
+ {
+ st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx;
+ move32();
+ }
+ }
+
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 );
+ }
+ ELSE
+ {
+ generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out );
+ }
- FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
+ FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
- Copy( exc2_fx, exc3_fx, st_fx->L_frame );
+ Copy( exc2_fx, exc3_fx, st->L_frame );
}
- delta_mem_scale = 3;
+ Word16 delta_mem_scale = 3;
move16();
test();
- if ( LT_32( st_fx->lp_ener_fx, 40 ) && ( st_fx->cng_type == LP_CNG ) ) /* very low energy frames, less than 0.3125 */
+ if ( LT_32( st->lp_ener_fx, 40 ) && st->cng_type == LP_CNG ) /* very low energy frames, less than 0.3125 */
{
delta_mem_scale = 0;
move16();
}
- i = st_fx->Q_exc;
+ i = st->Q_exc;
move16();
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame,
- st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE );
- Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale,
- &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 0, 0, NULL );
- Copy_Scale_sig( exc2_fx, exc2_fx, st_fx->L_frame, sub( st_fx->Q_exc, i ) ); // Q_exc
+
+ test();
+ IF( st->hMusicPF && st->hGSCDec )
+ {
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS?
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
+ st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
+ }
+ ELSE
+ {
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
+ L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
+ }
+ }
+
+ IF( st->hPFstat != NULL )
+ {
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale,
+ &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 0, 0, NULL );
+ }
+ ELSE
+ {
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale,
+ &st->mem_deemph_fx, NULL, NULL, &st->agc_mem_fx[1], NULL, 0, 0, NULL );
+ }
+
+ Copy_Scale_sig( exc2_fx, exc2_fx, st->L_frame, sub( st->Q_exc, i ) ); // Q_exc
/* update past excitation signals for LD music post-filter */
- IF( hMusicPF != NULL )
+ IF( st->hMusicPF != NULL )
{
- Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+
/* Update music post processing values */
/* Filter energies update */
- FOR( i = 0; i < DCT_L_POST; i++ )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/
- hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) );
- move16();
+ FOR( i = 0; i < DCT_L_POST; i++ )
+ {
+ st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < DCT_L_POST; i++ )
+ {
+ st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15
+ move16();
+ }
}
}
+
/* synthesis at 12.8kHz sampling rate */
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc3_fx, syn1_fx, st_fx->mem_syn3_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
+ move16();
+ syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
+ syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn );
/* reset the decoder */
- CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors );
+ CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx );
+
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ /* update st_fx->mem_syn1 for ACELP core switching */
+ Copy( st->mem_syn3_fx, st->mem_syn1_fx, M );
+ }
+ ELSE
+ {
+ st->Q_syn_cng = st->Q_syn;
+ move16();
+ st->Q_exc_cng = st->Q_exc;
+ move16();
- /* update st_fx->mem_syn1 for ACELP core switching */
- Copy( st_fx->mem_syn3_fx, st_fx->mem_syn1_fx, M );
+ /* update st->mem_syn1 for ACELP core switching */
+ Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1)
+ }
/* update old synthesis for classification */
- Copy( syn1_fx + st_fx->L_frame - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
-
+ Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
/* save and delay synthesis to be used by SWB BWE */
- Copy_Scale_sig( syn1_fx, temp_buf_fx, st_fx->L_frame, sub( -1, st_fx->Q_syn ) ); // Q_syn -> Q(-1)
- IF( hBWE_FD != NULL )
+ Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1)
+ IF( st->hBWE_FD != NULL )
{
- save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
+ save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
}
}
@@ -638,21 +848,24 @@ ivas_error acelp_core_dec_fx(
ELSE
{
+
/*-----------------------------------------------------------------*
* Configure ACELP bit allocation
*-----------------------------------------------------------------*/
+
nb_bits = 0;
- st_fx->acelp_cfg.FEC_mode = 0;
- uc_two_stage_flag = 0;
move16();
+ st->acelp_cfg.FEC_mode = 0;
move16();
+ uc_two_stage_flag = 0;
move16();
+
test();
- IF( !st_fx->nelp_mode_dec && !st_fx->ppp_mode_dec )
+ IF( !st->nelp_mode_dec && !st->ppp_mode_dec )
{
Word16 tc_subfr_tmp;
- tc_subfr_tmp = tc_subfr_fx;
+ tc_subfr_tmp = tc_subfr;
move16();
if ( LT_16( tc_subfr_tmp, L_SUBFR ) )
{
@@ -660,19 +873,19 @@ ivas_error acelp_core_dec_fx(
move16();
}
- if ( EQ_16( tc_subfr_fx, TC_0_192 ) )
+ if ( EQ_16( tc_subfr, TC_0_192 ) )
{
nb_bits = -1;
move16();
}
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
test();
test();
- IF( EQ_16( st_fx->coder_type, TRANSITION ) && LT_16( tc_subfr_fx, L_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) )
{
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, TRANSITION, -1, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
}
}
@@ -682,51 +895,126 @@ ivas_error acelp_core_dec_fx(
test();
test();
- IF( st_fx->hTdCngDec != NULL && ( st_fx->last_core_brate == FRAME_NO_DATA || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) )
+ IF( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
{
- Copy( st_fx->lspCNG_fx, st_fx->lsp_old_fx, M ); // Q15
-
- lsp2lsf_fx( st_fx->lspCNG_fx, st_fx->lsf_old_fx, M, int_fs );
+ Copy( st->lspCNG_fx, st->lsp_old_fx, M ); /*Q15*/
+ lsp2lsf_fx( st->lspCNG_fx, st->lsf_old_fx, M, int_fs );
}
/*-----------------------------------------------------------------*
* Reset higher ACELP pre-quantizer in case of switching
*-----------------------------------------------------------------*/
- IF( !st_fx->use_acelp_preq )
+ IF( !st->use_acelp_preq )
{
- st_fx->mem_preemp_preQ_fx = 0;
+ st->mem_preemp_preQ_fx = 0;
move16();
- st_fx->last_nq_preQ = 0;
+ st->last_nq_preQ = 0;
+ move16();
+ st->last_code_preq = 0;
move16();
}
- st_fx->use_acelp_preq = 0;
+ st->use_acelp_preq = 0;
move16();
/*-----------------------------------------------------------------*
* LSF de-quantization and interpolation
*-----------------------------------------------------------------*/
- lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode,
- tdm_lsfQ_PCh );
+ IF( !tdm_lp_reuse_flag )
+ {
+ lsf_dec_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh_fx );
+ }
+ ELSE
+ {
+ const Word16 *pt_interp_2_fx;
+
+ IF( NE_16( st->active_cnt, 1 ) )
+ {
+ Word16 beta_index;
+
+ beta_index = get_next_indice_fx( st, TDM_IC_LSF_PRED_BITS );
+ tdm_SCh_lsf_reuse_fx( DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index );
+ }
+ ELSE
+ {
+ Copy( tdm_lspQ_PCh_fx, lsp_new_fx, M );
+ Copy( tdm_lsfQ_PCh_fx, lsf_new_fx, M );
+ }
+
+ IF( st->rate_switching_reset )
+ {
+ /* extrapolation in case of unstable LSF convert */
+ Copy( lsp_new_fx, st->lsp_old_fx, M );
+ Copy( lsf_new_fx, st->lsf_old_fx, M );
+ }
+
+ pt_interp_2_fx = interpol_frac_fx;
+ test();
+ if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) )
+ {
+ pt_interp_2_fx = interpol_frac2_fx;
+ }
+
+ IF( EQ_16( st->active_cnt, 1 ) )
+ {
+ Copy( lsp_new_fx, st->lsp_old_fx, M );
+ lsp2lsf_fx( lsp_new_fx, st->lsf_old_fx, M, st->sr_core );
+ }
+
+ /* LSP interpolation and conversion of LSPs to A(z) */
+ int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 );
+
+ /* Check LSF stability (distance between old LSFs and current LSFs) */
+ st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame );
+ move16();
+ }
+
+ test();
+ IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory from last HQ frame */
+ old_exc_s_fx = st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame );
+ tmpF_fx = *old_exc_s_fx;
+ st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */
+ move16();
+ PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx );
+ Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M );
+ Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */
+ Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 );
+ Scale_sig( old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, st->Q_exc ); /* Q0 -> Q_exc */
+ }
+
+ test();
+ IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
+ {
+ /* Prepare ACB memory of old_bwe_exc */
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
+ }
+ ELSE
+ {
+ lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC << 1, L_EXC_MEM_DEC );
+ }
+ }
/*-----------------------------------------------------------------*
* FEC - first good frame after lost frame(s) (possibility to correct the ACB)
*-----------------------------------------------------------------*/
- IF( st_fx->acelp_cfg.FEC_mode > 0 )
+ IF( st->acelp_cfg.FEC_mode > 0 )
{
last_pulse_pos = 0;
move16();
/* decode the last glottal pulse position */
- T0_tmp = FEC_pos_dec_fx( st_fx, &last_pulse_pos, &enr_q_fx, nb_bits );
-
+ T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits );
test();
test();
- IF( NE_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->last_con_tcx ) )
+ IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) )
{
test();
test();
@@ -734,16 +1022,13 @@ ivas_error acelp_core_dec_fx(
test();
test();
test();
- test();
- IF( EQ_16( st_fx->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st_fx->prev_bfi, 1 ) )
+ IF( EQ_16( st->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st->prev_bfi, 1 ) )
{
- st_fx->Q_exc =
- FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st_fx->L_frame, st_fx->Q_exc );
- move16();
+ FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc );
}
- ELSE IF( ( EQ_16( st_fx->coder_type, GENERIC ) || EQ_16( st_fx->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st_fx->old_bfi_cnt, 1 ) && EQ_16( output_frame, L_FRAME16k ) && st_fx->hWIDec != NULL )
+ ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL )
{
- do_WI_fx = FEC_enhACB_fx( st_fx->L_frame, st_fx->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st_fx->bfi_pitch_fx );
+ do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx );
}
}
}
@@ -752,16 +1037,16 @@ ivas_error acelp_core_dec_fx(
* In case of first frame after an erasure and transition from voiced to unvoiced or inactive
* redo the LPC interpolation
*------------------------------------------------------------*/
+
test();
test();
test();
test();
test();
test();
- IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt > 0 && NE_16( st_fx->clas_dec, VOICED_CLAS ) && NE_16( st_fx->clas_dec, ONSET ) &&
- st_fx->relax_prev_lsf_interp == 0 && !( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) )
+ IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) )
{
- int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
+ int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
}
/*---------------------------------------------------------------*
@@ -770,7 +1055,7 @@ ivas_error acelp_core_dec_fx(
IF( nb_bits > 0 )
{
- indice = get_next_indice( st_fx, nb_bits );
+ indice = get_next_indice_fx( st, nb_bits );
Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag );
}
@@ -780,79 +1065,107 @@ ivas_error acelp_core_dec_fx(
test();
test();
- IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
+ IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
{
- /* SC-VBR - NELP frames */
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
- st_fx->Q_exc = 0;
+ IF( LE_16( st->coder_type, UNVOICED ) )
+ {
+ tdm_low_rate_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx );
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
+ }
+ ELSE /* GENERIC */
+ {
+ decod_gen_2sbfr_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
+
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
+ {
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
+ }
+ }
+ }
+ ELSE IF( st->nelp_mode_dec )
+ {
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
+ st->Q_exc = 0;
move16();
- decod_nelp_fx( st_fx, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors, bwe_exc_fx, &st_fx->Q_exc, st_fx->bfi, gain_buf );
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type );
+ /* SC-VBR - NELP frames */
+ decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
+
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
}
- ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) )
+ ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
{
/* UNVOICED frames */
- decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf );
+ decod_unvoiced_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx );
+
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
- ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) )
+ ELSE IF( st->ppp_mode_dec )
{
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
- st_fx->Q_exc = 0;
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
+ st->Q_exc = 0;
move16();
+
/* SC-VBR - PPP frames */
- IF( NE_32( ( error = decod_ppp_fx( st_fx, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st_fx->bfi, gain_buf, voice_factors, bwe_exc_fx ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ), IVAS_ERR_OK ) )
{
return error;
}
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type );
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
}
- ELSE IF( EQ_16( st_fx->coder_type, TRANSITION ) )
+ ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
{
- decod_tran_fx( st_fx, st_fx->L_frame, tc_subfr_fx, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf );
+ decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx );
}
- ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) )
+ ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) )
{
- decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf );
- tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
+ /* AUDIO and INACTIVE frames (coded by GSC technology) */
+ decod_audio_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx,
+ tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
+
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
ELSE
{
- IF( NE_32( ( error = decod_gen_voic_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf /*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf*/ ) ), IVAS_ERR_OK ) )
+ /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
+ IF( NE_32( ( error = decod_gen_voic_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
}
}
/* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 );
+ syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
+
/* save and delay synthesis to be used by SWB BWE */
- IF( hBWE_FD != NULL )
+ IF( st->hBWE_FD != NULL )
{
- save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
+ save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
}
/*-----------------------------------------------------------------*
* Apply energy matching when switching to inactive frames
*-----------------------------------------------------------------*/
- Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode );
+ Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
+
/*------------------------------------------------------------*
* Decode information and modify the excitation signal of stationary unvoiced frames
*------------------------------------------------------------*/
+
test();
test();
test();
test();
- IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( st_fx->nelp_mode_dec, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
+ IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
{
- stat_noise_uv_dec_fx( st_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag );
+ stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag );
}
/*------------------------------------------------------------*
@@ -861,80 +1174,92 @@ ivas_error acelp_core_dec_fx(
*------------------------------------------------------------*/
/* update past excitation signals for LD music post-filter */
- IF( hMusicPF != NULL )
+ IF( st->hMusicPF != NULL )
{
- Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
- Copy( hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 );
+ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 );
}
+
test();
test();
test();
- test();
- IF( hMusicPF != NULL && ( ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) || ( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->L_frame, L_FRAME ) ) ) )
+ IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) )
{
-
- Word16 last_coder_type = st_fx->last_coder_type;
+ Word16 last_coder_type = st->last_coder_type;
move16();
+
test();
test();
test();
- if ( ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st_fx->GSC_IVAS_mode, 1 ) && st_fx->GSC_noisy_speech == 0 ) )
+ if ( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) )
{
last_coder_type = AUDIO;
move16();
}
- /* Extrapolation of the last future part, windowing and high resolution DCT transform */
- qdct = 0;
+
+ Word16 qdct = 0;
move16();
-#ifdef _DIFF_FLOAT_FIX_ /* FLoat point using last_core which fits with the inner part of the function */
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_core, st_fx->element_mode, pitch_buf_fx,
- hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &qdct );
-#else
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_coder_type, st_fx->element_mode, pitch_buf_fx,
- hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &qdct );
-#endif
+
+ /* Extrapolation of the last future part, windowing and high resolution DCT transform */
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate'
+ Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx,
+ st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
+ }
+ ELSE
+ {
+ Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
+ }
+
/* LD music post-filter */
- LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate,
- &hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct );
+ LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct );
/* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */
- Post_music_postP_fx( dct_buffer_fx, exc2_fx, st_fx->mem_syn2_fx, st_fx->mem_syn2_fx, Aq_fx, syn_fx, &st_fx->Q_exc, &st_fx->prev_Q_syn,
- &st_fx->Q_syn, st_fx->mem_syn_clas_estim_fx, 0, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx,
- &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, temp_buf_fx, mem_tmp_fx );
+ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS
+ {
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/
+ }
+
+ Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn,
+ &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx,
+ &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx );
}
ELSE
{
/* Core synthesis at 12.8kHz or 16kHz */
i = 1;
move16();
- if ( st_fx->coder_type == INACTIVE )
+ test();
+ if ( st->coder_type == INACTIVE && st->element_mode == EVS_MONO )
{
i = 0;
move16();
}
+
/* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- k = 0;
+ Word16 k = 0;
move16();
test();
test();
- if ( ( st_fx->coder_type == INACTIVE ) && st_fx->flag_cna && GE_16( round_fx( L_shl( st_fx->lp_noise, 1 ) ), 15 << 7 ) )
+ if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
{
k = 1;
move16();
}
- Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
- hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, i, k, temp_buf_fx );
- Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M ); // Q_syn
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
+ st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx );
+
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/
+ syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
- IF( hMusicPF != NULL )
+ IF( st->hMusicPF != NULL )
{
FOR( i = 0; i < DCT_L_POST; i++ )
{
- /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/
- hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) );
+ st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
move16();
}
}
@@ -944,43 +1269,35 @@ ivas_error acelp_core_dec_fx(
* FEC - Estimate the classification information
*------------------------------------------------------------*/
- FEC_clas_estim_fx( st_fx, st_fx->Opt_AMR_WB, st_fx->L_frame, &st_fx->clas_dec, st_fx->coder_type, pitch_buf_fx,
- syn_fx, &st_fx->lp_ener_FER_fx, &st_fx->decision_hyst,
- NULL, NULL, NULL, NULL, 0, NULL, st_fx->Q_syn, temp_buf_fx,
- st_fx->mem_syn_clas_estim_fx, &st_fx->classifier_Q_mem_syn,
- 0, 0, 0, st_fx->last_core_brate, st_fx->acelp_cfg.FEC_mode );
+ FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst,
+ NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode );
+
/*------------------------------------------------------------*
* FEC - Estimate pitch
*------------------------------------------------------------*/
- FEC_pitch_estim_fx( st_fx->Opt_AMR_WB, st_fx->last_core, st_fx->L_frame, st_fx->clas_dec, st_fx->last_good, pitch_buf_fx, st_fx->old_pitch_buf_fx,
- &st_fx->bfi_pitch_fx, &st_fx->bfi_pitch_frame, &st_fx->upd_cnt, st_fx->coder_type, st_fx->element_mode );
+ FEC_pitch_estim_fx( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx,
+ &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode );
/*------------------------------------------------------------*
* FEC - Smooth the speech energy evolution when recovering after a BAD frame
* (smoothing is performed in the excitation domain and signal is resynthesized after)
*------------------------------------------------------------*/
- k = 0;
- move16();
- FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR )
- {
- pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9)
- move16();
- k = add( k, 1 );
- }
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
- FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction,
- &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );
+ FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
+ &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
+ exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 );
test();
test();
test();
test();
- IF( ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && LE_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) )
+ /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
+ IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
{
- frame_ener_fx( st_fx->L_frame, st_fx->clas_dec, syn_fx, pitch_buf_tmp[sub( shr( st_fx->L_frame, 6 ), 1 )], &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 );
+ frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[( ( st->L_frame ) >> 6 ) - 1], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
}
}
@@ -989,206 +1306,188 @@ ivas_error acelp_core_dec_fx(
/*----------------------------------------------------------------*
* BAD frame
*----------------------------------------------------------------*/
+
ELSE
{
/* SC-VBR */
- if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
+ if ( EQ_16( st->last_nelp_mode_dec, 1 ) )
{
- st_fx->nelp_mode_dec = 1;
+ st->nelp_mode_dec = 1;
move16();
}
- /* long burst frame erasures */
test();
test();
- if ( GT_16( st_fx->nbLostCmpt, 5 ) && GE_16( st_fx->clas_dec, VOICED_CLAS ) && LT_16( st_fx->clas_dec, INACTIVE_CLAS ) )
+ /* long burst frame erasures */
+ if ( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) )
{
- st_fx->last_good = VOICED_TRANSITION;
+ st->last_good = VOICED_TRANSITION;
move16();
}
/* LSF estimation and A(z) calculation */
- lsf_dec_bfi( MODE1, lsf_new_fx, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx,
- st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good,
- st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth );
-
- FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
+ lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth );
- IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
+ FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
+ IF( EQ_16( st->nelp_mode_dec, 1 ) )
{
/* SC-VBR */
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
- st_fx->Q_exc = 0;
+ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
+ st->Q_exc = 0;
move16();
- decod_nelp_fx( st_fx, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors, bwe_exc_fx, &st_fx->Q_exc, st_fx->bfi, gain_buf );
+ decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
FEC_pitch_fx = pitch_buf_fx[3];
move16();
-
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type );
+ Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
}
ELSE
{
/* calculation of excitation signal */
+ FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx );
- FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc_fx, exc2_fx, dct_exc_tmp, pitch_buf_fx, voice_factors, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st_fx->Q_exc, &tmp_noise_fx );
-
- Rescale_exc( NULL, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0,
- &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, st_fx->L_frame, st_fx->last_coder_type );
+ Rescale_exc( NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32) 0,
+ &( st->Q_exc ), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type );
- tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
+ tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
/* SC-VBR */
- st_fx->prev_gain_pit_dec_fx = st_fx->lp_gainp_fx;
- move16(); /*Q14*/
+ st->prev_gain_pit_dec_fx = st->lp_gainp_fx;
+ move16();
}
/* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 ); /*old_syn_12k8_16k directly in q-1*/
+ syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
/* save and delay synthesis to be used by SWB BWE */
- IF( hBWE_FD != NULL )
+ IF( st->hBWE_FD != NULL )
{
- save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx );
+ save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
}
+
/* Apply energy matching when switching to inactive frames */
- Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode );
+ Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
- /* udate past excitation signals for LD music post-filter */
- IF( hMusicPF != NULL )
+ /* update past excitation signals for LD music post-filter */
+ IF( st->hMusicPF != NULL )
{
- Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+ Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
+ Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
+
/* Update music post processing values */
/* Filter energies update */
FOR( i = 0; i < DCT_L_POST; i++ )
{
- /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/
- hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) );
+ st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( 1228 << 16, 22938, st->hMusicPF->filt_lfE_fx[i] ) );
move16();
}
+
/* Update circular buffer, keep last energy difference unchanged */
FOR( i = 1; i < MAX_LT; i++ )
{
- hMusicPF->LDm_lt_diff_etot_fx[i - 1] = hMusicPF->LDm_lt_diff_etot_fx[i];
+ st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i];
move16();
}
}
+
/* synthesis at 12k8 Hz sampling rate */
/* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- k = 0;
+ Word16 k = 0;
move16();
test();
test();
- if ( ( st_fx->coder_type == INACTIVE ) && st_fx->flag_cna && GE_16( round_fx( L_shl( st_fx->lp_noise, 1 ) ), 15 << 7 ) )
+ if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
{
k = 1;
move16();
}
- Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
- hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, k, temp_buf_fx );
+ Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
+ st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx );
test();
- IF( ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) )
+ IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
{
- Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M ); // Q_syn
+ Copy( st->mem_syn2_fx, mem_tmp_fx, M );
}
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
+ syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
/* update buffer for classifier */
- IF( st_fx->hWIDec != NULL )
+ IF( st->hWIDec != NULL )
{
- Copy( exc2_fx + st_fx->L_frame - L_EXC_MEM, st_fx->hWIDec->old_exc2_fx, L_EXC_MEM );
- Copy( syn_fx + st_fx->L_frame - L_EXC_MEM, st_fx->hWIDec->old_syn2_fx, L_EXC_MEM );
+ Copy( exc2_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_exc2_fx, L_EXC_MEM );
+ Copy( psyn_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_syn2_fx, L_EXC_MEM );
}
- st_fx->prev_Q_exc_fr = st_fx->Q_exc;
+ st->prev_Q_exc_fr = st->Q_exc;
move16();
- st_fx->prev_Q_syn_fr = st_fx->Q_syn;
+ st->prev_Q_syn_fr = st->Q_syn;
move16();
+ Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM_CLAS_ESTIM ), st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
- Copy( syn_fx + st_fx->L_frame - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
+ /*------------------------------------------------------------*
+ * FEC - Smooth the speech energy evolution when recovering after a BAD frame
+ * (smoothing is performed in the excitation domain and signal is resynthesized after)
+ *------------------------------------------------------------*/
test();
- IF( ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) )
+ IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
{
- k = 0;
- move16();
- FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR )
- {
- pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9)
- move16();
- k = add( k, 1 );
- }
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
- /*------------------------------------------------------------*
- * FEC - Smooth the speech energy evolution when recovering after a BAD frame
- * (smoothing is performed in the excitation domain and signal is resynthesized after)
- *------------------------------------------------------------*/
-
- FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction,
- &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );
+ FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
+ &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
+ exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 );
}
/* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
- /* fer_energy( st_fx->L_frame, st_fx->last_good, syn_fx, FEC_pitch_fx, &st_fx->enr_old_fx, st_fx->L_frame ); */
- frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 );
+ frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
- IF( st_fx->nelp_mode_dec != 1 )
+ IF( NE_16( st->nelp_mode_dec, 1 ) )
{
/* modify the excitation signal of stationary unvoiced frames */
- stat_noise_uv_mod_fx( st_fx->coder_type, 0, st_fx->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st_fx->Q_exc, 1, &st_fx->ge_sm_fx,
- &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx,
- &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge );
+ stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx,
+ &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx,
+ &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge );
}
-
- /* SC-VBR */
- st_fx->hSC_VBR->FadeScale_fx = mult( st_fx->hSC_VBR->FadeScale_fx, 24576 ); /*24576 in Q15*/
- move16();
}
- IF( hBWE_TD != NULL )
+
+ IF( st->hBWE_TD != NULL )
{
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- Copy( Aq_fx + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
+ Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
}
ELSE
{
- Copy( Aq_fx + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12
+ Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
}
}
+
/*--------------------------------------------------------*
* Apply NB postfilter in case of 8kHz output
*--------------------------------------------------------*/
+
test();
- IF( EQ_16( st_fx->last_bwidth, NB ) && st_fx->hPFstat != NULL )
+ IF( st->last_bwidth == NB && st->hPFstat != NULL )
{
- k = 0;
- move16();
- FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR )
- {
- pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9)
- move16();
- k = add( k, 1 );
- }
+ Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
- IF( EQ_16( st_fx->bwidth, NB ) )
+ IF( st->bwidth == NB )
{
- st_fx->hPFstat->on = 1;
+ st->hPFstat->on = 1;
move16();
- nb_post_filt_fx( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 );
+ nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 );
}
ELSE
{
- st_fx->hPFstat->on = 0;
+ st->hPFstat->on = 0;
move16();
- nb_post_filt_fx( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 );
+ nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 );
}
}
ELSE
{
- st_fx->psf_lp_noise_fx = round_fx( L_shl( st_fx->lp_noise, 1 ) );
+ st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) );
move16();
}
@@ -1196,137 +1495,255 @@ ivas_error acelp_core_dec_fx(
* Perform fixed deemphasis through 1/(1 - g*z^-1)
*-----------------------------------------------------------------*/
- /* Update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( syn_fx + st_fx->L_frame - L_SYN_MEM, st_fx->mem_syn_r, L_SYN_MEM );
- deemph_fx( syn_fx, st_fx->preemph_fac, st_fx->L_frame, &( st_fx->mem_deemph_fx ) );
- unscale_AGC( syn_fx, st_fx->Q_syn, syn_fx_tmp2, st_fx->agc_mem_fx, st_fx->L_frame );
- Copy( syn_fx_tmp2, syn_fx, st_fx->L_frame );
-
- /* Update MODE2 memories*/
- IF( hTcxDec != NULL )
+ /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
+ Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM );
+ deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) );
+ unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame );
+ Copy( syn_fx_tmp2, psyn_fx, st->L_frame );
+ IF( st->hTcxDec != NULL )
{
- Copy_Scale_sig( syn_fx + shr( st_fx->L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st_fx->L_frame, 1 ), sub( -1, st_fx->Q_syn ) ); /*Q-1*/
+ Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/
+ st->hTcxDec->Q_old_syn_Overl = -1;
}
- Copy_Scale_sig( syn_fx + st_fx->L_frame - M - 1, st_fx->syn, M + 1, sub( 0, st_fx->Q_syn ) ); /*Q0*/
+ Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/
/*------------------------------------------------------------------*
* Formant post-filter
*-----------------------------------------------------------------*/
- IF( st_fx->hPFstat != NULL )
+ test();
+ test();
+ test();
+ test();
+ IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || st->element_mode > EVS_MONO ) && LE_32( st->core_brate, ACELP_32k ) )
{
- test();
- test();
- test();
- IF( GE_16( st_fx->last_bwidth, WB ) && ( GT_32( st_fx->core_brate, ACELP_24k40 ) || ( st_fx->element_mode > EVS_MONO ) ) && LE_32( st_fx->core_brate, ACELP_32k ) )
- {
- Copy( syn_fx, temp_buf + L_SYN_MEM, L_FRAME16k );
- st_fx->hPFstat->on = 1;
- move16();
- formant_post_filt_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 );
- }
- ELSE IF( GE_16( st_fx->last_bwidth, WB ) )
+ st->hPFstat->on = 1;
+ move16();
+ Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k );
+ set16_fx( st->hPFstat->mem_zero, 0, M );
+
+ formant_post_filt_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 );
+ }
+ ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) )
+ {
+ IF( st->hPFstat->on )
{
- IF( st_fx->hPFstat->on )
- {
- Copy( st_fx->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf, M );
- Copy( syn_fx, temp_buf + M, L_SUBFR );
- Residu3_fx( Aq_fx, temp_buf + M, temp_buf + M + L_SUBFR, L_SUBFR, 1 );
- E_UTIL_synthesis( 1, Aq_fx, temp_buf + M + L_SUBFR, temp_buf, L_SUBFR, st_fx->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
- scale_st_fx( syn_fx, temp_buf, &st_fx->hPFstat->gain_prec, L_SUBFR );
- Copy( temp_buf, syn_fx, L_SUBFR / 2 );
- blend_subfr2_fx( temp_buf + L_SUBFR / 2, syn_fx + L_SUBFR / 2, syn_fx + L_SUBFR / 2 );
- }
- st_fx->hPFstat->on = 0;
- move16();
+ Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M );
+ Copy( psyn_fx, temp_buf_fx + M, L_SUBFR );
+
+ Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 );
+ E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
+ scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR );
+ Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) );
+ blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 );
}
+ st->hPFstat->on = 0;
+ move16();
}
+
/*----------------------------------------------------------------*
* Comfort noise addition
*----------------------------------------------------------------*/
test();
test();
- IF( ( st_fx->hFdCngDec != NULL || EQ_16( st_fx->idchan, 1 ) ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
test();
test();
test();
test();
test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || st_fx->flag_cna || ( EQ_16( st_fx->cng_type, FD_CNG ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || ( ( st_fx->cng_type == LP_CNG ) && LE_32( st_fx->total_brate, SID_2k40 ) ) )
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) )
{
/*VAD only for non inactive frame*/
test();
- st_fx->VAD = st_fx->VAD && ( st_fx->coder_type != INACTIVE );
+ st->VAD = st->VAD && st->coder_type != INACTIVE;
move16();
test();
test();
test();
test();
test();
- IF( st_fx->idchan == 0 && ( st_fx->flag_cna || ( EQ_16( st_fx->cng_type, FD_CNG ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ||
- ( EQ_16( st_fx->cng_type, LP_CNG ) && LE_32( st_fx->total_brate, SID_2k40 ) ) ) )
+ IF( st->idchan == 0 && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) )
{
/*Noisy speech detector*/
- noisy_speech_detection_fx( st_fx->hFdCngDec, st_fx->VAD, syn_fx, st_fx->Q_syn );
+ noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn );
- st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
+ st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
move16();
- IF( st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
+ IF( st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
{
- st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
+ st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
move16();
}
+ move32();
}
- if ( st_fx->idchan == 0 )
+
+ if ( st->idchan == 0 )
{
- st_fx->lp_noise = st_fx->hFdCngDec->lp_noise;
+ st->lp_noise = st->hFdCngDec->lp_noise;
move32();
}
- /*Noise estimate*/
- IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) /* && !st->cng_ism_flag IVAS_CODE */ )
+
+ test();
+ IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag )
{
- ApplyFdCng_fx( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) );
+ /* Noise estimate */
+ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
}
- /* CNA: Generate additional comfort noise to mask potential coding artefacts */
- }
- test();
- test();
- test();
- test();
- IF( st_fx->flag_cna && NE_16( st_fx->coder_type, AUDIO ) )
- {
- generate_masking_noise_fx( syn_fx, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, st_fx->hFdCngDec->hFdCngCom->frameSize, 0 );
- }
- ELSE IF( st_fx->flag_cna && EQ_16( st_fx->coder_type, AUDIO ) && st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) )
- {
- FOR( i = 0; i < st_fx->hFdCngDec->hFdCngCom->frameSize / 2; i++ )
+ IF( !st->cna_dirac_flag )
{
- syn_fx[i] = add( syn_fx[i], shr_r( mult_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->hFdCngDec->hFdCngCom->frameSize / 4], st_fx->hFdCngDec->hFdCngCom->fftlenFac ), -st_fx->Q_syn ) );
- move16();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ /* CNA: Generate additional comfort noise to mask potential coding artefacts */
+ IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
+ {
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
+ {
+ IF( hStereoCng->flag_cna_fade )
+ {
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
+ hStereoCng->flag_cna_fade = 0;
+ move16();
+ }
+ ELSE
+ {
+ test();
+ IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) )
+ {
+ /* Clear memory for secondary channel CNA */
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) );
+ }
+
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out );
+ }
+ }
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ {
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 );
+ }
+ ELSE
+ {
+ IF( st->idchan == 0 )
+ {
+ IF( NE_16( st->element_mode, last_element_mode ) )
+ {
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
+ }
+
+ Word32 psyn_32_fx[L_FRAME16k];
+ Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6
+ Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15
+
+ generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out );
+
+ Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn
+ Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0
+ }
+ }
+ }
+ }
+ ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) )
+ {
+ test();
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
+ {
+ generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
+ hStereoCng->flag_cna_fade = 1;
+ move16();
+ }
+ ELSE
+ {
+ FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ )
+ {
+ psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), negate( st->Q_syn ) ) );
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ IF( hStereoCng != NULL )
+ {
+ hStereoCng->flag_cna_fade = 1;
+ move16();
+ hStereoCng->enableSecCNA = 0;
+ move16();
+ }
+ }
+
+ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
+ {
+ test();
+ test();
+ test();
+ /*Noise estimate*/
+ IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) )
+ {
+ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
+ }
+ }
}
}
- test();
- test();
- test();
- test();
- test();
- IF( st_fx->flag_cna == 0 && EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( st_fx->last_flag_cna, 1 ) && ( ( st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
+ IF( !st->cna_dirac_flag )
{
- FOR( i = 0; i < st_fx->L_frame / 2; i++ )
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) )
{
- syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], negate( st_fx->Q_syn ) ) );
- move16();
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ // VE: TBV - is it correct in EVS? in FLP, it is:
+ // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 );
+ // v_add( temp_buf, syn, syn, st->L_frame / 2 );
+ FOR( i = 0; i < st->L_frame / 2; i++ )
+ {
+ psyn_fx[i] = add( psyn_fx[i], shr_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->L_frame / 4], negate( st->Q_syn ) ) );
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ )
+ {
+ psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) );
+ move16();
+ }
+ }
}
- }
- test();
- IF( st_fx->flag_cna == 0 || EQ_16( st_fx->coder_type, AUDIO ) )
- {
- set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen );
+ test();
+ test();
+ test();
+ IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
+ {
+ IF( st->idchan == 0 )
+ {
+ set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
+ }
+ IF( hStereoCng != NULL && ( st->idchan == 0 ) )
+ {
+ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen );
+ }
+ }
}
}
@@ -1335,45 +1752,44 @@ ivas_error acelp_core_dec_fx(
* Bass post-filter
*----------------------------------------------------------------*/
- /* check if the CLDFB works on the right sample rate */
- IF( ( st_fx->cldfbAna->usb * st_fx->cldfbAna->no_col ) != st_fx->L_frame )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- /* resample to ACELP internal sampling rate */
- Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) );
- resampleCldfb( st_fx->cldfbAna, newCldfbBands, st_fx->L_frame, 0 );
- resampleCldfb( st_fx->cldfbBPF, newCldfbBands, st_fx->L_frame, 0 );
+ CLDFB_SCALE_FACTOR scaleFactor;
+ Word32 workBuffer[128 * 3];
- IF( st_fx->ini_frame > 0 )
+ /* check if the CLDFB works on the right sample rate */
+ IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame )
{
- st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels );
- move16();
+ /* resample to ACELP internal sampling rate */
+ Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) );
+ resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 );
+ resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 );
+
+ IF( st->ini_frame > 0 )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
+ move16();
+ }
}
- }
- test();
- IF( !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->bpf_off ) )
- {
test();
- IF( NE_16( st_fx->L_frame, st_fx->last_L_frame ) && NE_16( st_fx->last_codec_mode, MODE2 ) )
+ IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
{
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- retro_interp5_4_fx( hBPF->pst_old_syn_fx );
+ retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
}
- ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
+ ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
{
- retro_interp4_5_fx( syn_fx, hBPF->pst_old_syn_fx );
+ retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
}
}
- bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn_fx, st_fx->L_frame, pitch_buf_fx, st_fx->bpf_off,
- st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type, st_fx->Q_syn, bpf_error_signal );
- }
- test();
- IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
- {
+ bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
+ st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
+
/* analysis of the synthesis at internal sampling rate */
- cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
+ cldfbAnalysis_fx( st->cldfbAna, realBuffer_fx, imagBuffer_fx, &scaleFactor, psyn_fx, negate( st->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
scaleFactor.hb_scale = scaleFactor.lb_scale;
move16();
@@ -1381,25 +1797,26 @@ ivas_error acelp_core_dec_fx(
/* analysis and add the BPF error signal */
i = 0;
move16();
- if ( st_fx->bpf_off == 0 )
+ if ( st->bpf_off == 0 )
{
i = CLDFB_NO_COL_MAX;
move16();
}
- addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate( st_fx->Q_syn ),
- i, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &scaleFactor );
+
+ addBassPostFilter_fx( bpf_error_signal_16fx, realBuffer_fx, imagBuffer_fx, st->cldfbBPF, workBuffer, negate( st->Q_syn ),
+ i, st->cldfbAna->no_col, st->cldfbAna->no_channels, &scaleFactor );
/* set output mask for upsampling */
- IF( EQ_16( st_fx->bwidth, NB ) )
+ IF( EQ_16( st->bwidth, NB ) )
{
/* set NB mask for upsampling */
- st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, 10 );
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
move16();
}
- ELSE IF( NE_16( st_fx->cldfbSyn->bandsToZero, sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ) ) )
+ ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
{
/* in case of BW switching, re-init to default */
- st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels );
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
move16();
}
@@ -1407,47 +1824,447 @@ ivas_error acelp_core_dec_fx(
scaleFactor.hb_scale = scaleFactor.lb_scale;
move16();
+ test();
+ test();
+ test();
+ IF( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
+ {
+ generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, &scaleFactor.hb_scale, st );
+
+ st->cldfbSyn->bandsToZero = 0;
+ move16();
+ IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
+ move16();
+ }
+ st->cldfbSyn->lsb = st->cldfbAna->no_channels;
+ move16();
+ }
+
+ /* synthesis of the combined signal */
+ st->Q_syn2 = st->Q_syn;
+ move16();
+ cldfbSynthesis_fx( st->cldfbSyn, realBuffer_fx, imagBuffer_fx, &scaleFactor, synth_fx16, negate( st->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
+
+ /* Bring CLDFB output to Q0 */
+ Scale_sig( synth_fx16, output_frame, negate( st->Q_syn2 ) );
+ st->Q_syn2 = 0;
+ move16();
+
+ /* save synthesis - needed in case of core switching */
+ Copy( synth_fx16, st->previoussynth_fx, output_frame );
+ }
+ ELSE
+ {
+ /* check if the CLDFB works on the right sample rate */
+ IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) )
+ {
+ resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
+ resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
+
+ IF( st->ini_frame > 0 )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
+ move16();
+ }
+ }
+
+ /* analyze pitch coherence for bass post-filter */
+ Word32 pitch_buf_fx_q20[12];
+ Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4)
+ Word16 lim = shr( st->L_frame, 6 );
+ FOR( Word16 lp = 0; lp < lim; lp++ )
+ {
+ pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 );
+ move32();
+ }
+ bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 );
+ Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx
test();
- IF( !st_fx->cng_sba_flag || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) )
{
test();
- test();
- test();
- IF( ( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && ( EQ_16( st_fx->cng_type, FD_CNG ) ) && ( LT_16( st_fx->hFdCngDec->hFdCngCom->numCoreBands, st_fx->cldfbSyn->no_channels ) ) )
+ IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
{
- generate_comfort_noise_dec_hf_fx( realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx );
+ IF( EQ_16( st->L_frame, L_FRAME ) )
+ {
+ retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
+ }
+ ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
+ {
+ retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
+ }
+ }
+
+ bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
+ st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
+ }
- st_fx->cldfbSyn->bandsToZero = 0;
+ Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx;
+ set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR );
+ syn_32_fx = syn_tmp_32_fx + L_SUBFR;
+ test();
+ IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
+ {
+ /* analysis of the synthesis at internal sampling rate */
+ Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX];
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ pRealSave_fx[i] = realBufferSave_fx[i];
+ pImagSave_fx[i] = imagBufferSave_fx[i];
+ }
+ IF( st->p_bpf_noise_buf_32 )
+ {
+ Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
+ Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
+ Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11
+ }
+
+ FOR( i = 0; i < st->L_frame; i++ )
+ {
+ syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12
+ move32();
+ }
+
+ Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
+ st->cldfbAna->Q_cldfb_state = Q12;
+ move16();
+
+ cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna );
+
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
+ st->cldfbAna->Q_cldfb_state = Q11;
+ move16();
+ /* analysis and add the BPF error signal */
+ Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
+ Word16 q_bpf_error_signal;
+ Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
+
+ q_bpf_error_signal = Q6;
+ move16();
+ Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ }
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
+ st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
+ move16();
+ tmp = -1;
+ move16();
+ if ( st->bpf_off )
+ {
+ tmp = 0;
+ move16();
+ }
+
+ addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
+
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10
+ st->cldfbBPF->Q_cldfb_state = Q10;
+ move16();
+ /* set output mask for upsampling */
+ IF( EQ_16( st->bwidth, NB ) )
+ {
+ /* set NB mask for upsampling */
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
move16();
- IF( LT_16( st_fx->hFdCngDec->hFdCngCom->regularStopBand, st_fx->cldfbSyn->no_channels ) )
+ }
+ ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
+ {
+ /* in case of BW switching, re-init to default */
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
+ move16();
+ }
+ test();
+ IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
+ {
+ test();
+ test();
+ test();
+ /*WB/SWB-FD_CNG*/
+ IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
{
- st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->hFdCngDec->hFdCngCom->regularStopBand );
+ Word16 tmpBufferScale = 0;
move16();
+ generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag );
+
+ FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ )
+ {
+ Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
+ Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
+ }
+
+ IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
+ {
+ st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
+ move16();
+ }
+ ELSE
+ {
+ st->cldfbSyn->bandsToZero = 0;
+ move16();
+ }
}
- st_fx->cldfbSyn->lsb = st_fx->cldfbAna->no_channels;
+ }
+
+ IF( save_hb_synth_fx16 != NULL )
+ {
+ /* save and then zero-out lowband */
+ max_real = 0;
+ max_imag = 0;
+ move32();
+ move32();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ }
+ }
+ max_val = L_max( max_real, max_imag );
+ Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ }
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
+ scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1)
+#endif /* OPT_STEREO_32KBPS_V1 */
+ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ realBufferSave_fx[i][j] = realBuffer_fx[i][j];
+ imagBufferSave_fx[i][j] = imagBuffer_fx[i][j];
+ move32();
+ move32();
+ IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) )
+ {
+ realBuffer_fx[i][j] = 0;
+ imagBuffer_fx[i][j] = 0;
+ move32();
+ move32();
+ }
+ }
+ }
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+ Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0
+ Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSynHB->Q_cldfb_state = Q10;
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ /* restore lowband */
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ realBuffer_fx[i][j] = realBufferSave_fx[i][j];
+ imagBuffer_fx[i][j] = imagBufferSave_fx[i][j];
+ move32();
+ move32();
+ }
+ }
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1
+ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn );
+ Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSynHB->Q_cldfb_state = Q10;
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ }
+ ELSE
+ {
+ /* synthesis of the combined signal */
+ max_real = 0;
+ max_imag = 0;
+ move32();
+ move32();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ }
+ }
+ max_val = L_max( max_real, max_imag );
+ Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ }
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
+ scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
+#endif /* OPT_STEREO_32KBPS_V1 */
+ st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 );
+ move16();
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSyn->Q_cldfb_state = Q10;
move16();
}
+
+ /* save synthesis - needed in case of core switching */
+ Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0
}
- /* synthesis of the combined signal */
- st_fx->Q_syn2 = st_fx->Q_syn;
- move16();
+ ELSE
+ {
+ Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */
+
+ /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */
+ FOR( i = 0; i < st->L_frame; i++ )
+ {
+ syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) );
+ move32();
+ }
+
+ Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
+ st->cldfbAna->Q_cldfb_state = Q12;
+ move16();
+
+ cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna );
+
+ Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
+ st->cldfbAna->Q_cldfb_state = Q11;
+ move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */
+ Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
+ Word16 q_bpf_error_signal;
+ Word16 cldfb_state_offset;
+ cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
+
+ // Get Q-factor
+ q_bpf_error_signal = Q6;
+ move16();
+ Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
+ }
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
+ st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
+ move16();
+ tmp = 0;
+ move16();
+ if ( !st->bpf_off )
+ {
+ tmp = nSamples;
+ move16();
+ }
+
+ addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
+
+ Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10
+ st->cldfbBPF->Q_cldfb_state = Q10;
+ move16();
+ /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */
+ max_real = 0;
+ max_imag = 0;
+ move32();
+ move32();
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
+ {
+ max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
+ max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
+ }
+ }
+ max_val = L_max( max_real, max_imag );
+ Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
+ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
+ {
+ scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
+ }
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+#ifdef OPT_STEREO_32KBPS_V1
+ scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
+#else /* OPT_STEREO_32KBPS_V1 */
+ scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
+#endif /* OPT_STEREO_32KBPS_V1 */
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifdef OPT_AVOID_STATE_BUF_RESCALE
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn );
+#else /* OPT_AVOID_STATE_BUF_RESCALE */
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn );
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+
+#ifndef OPT_AVOID_STATE_BUF_RESCALE
+ Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
+ Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
+ st->cldfbSyn->Q_cldfb_state = Q10;
+ move16();
+#endif /* OPT_AVOID_STATE_BUF_RESCALE */
+ IF( st->p_bpf_noise_buf_32 )
+ {
+ Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
+ Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
+
+ Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11
+ }
+
+ set32_fx( synth_fx, 0, output_frame );
+ }
+
+ /* Copy output signal */
+ Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0
+ IF( st->element_mode > EVS_MONO )
{
- cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
+ Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/
}
- /* Bring CLDFB output to Q0 */
- Scale_sig( synth_out, output_frame, negate( st_fx->Q_syn2 ) );
- st_fx->Q_syn2 = 0;
- move16();
- /* save synthesis - needed in case of core switching */
- Copy( synth_out, st_fx->previoussynth_fx, output_frame );
+ st->Q_syn2 = 0;
+ move16();
}
/*-----------------------------------------------------------------*
* Bandwidth extension 6kHz-7kHz
*-----------------------------------------------------------------*/
- IF( st_fx->hBWE_zero != NULL )
+
+ IF( st->hBWE_zero != NULL )
{
test();
test();
@@ -1456,14 +2273,27 @@ ivas_error acelp_core_dec_fx(
test();
test();
test();
- IF( ( EQ_16( st_fx->L_frame, L_FRAME ) && NE_16( st_fx->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) &&
- ( EQ_16( st_fx->extl, -1 ) || EQ_16( st_fx->extl, SWB_CNG ) || ( EQ_16( st_fx->extl, WB_BWE ) && st_fx->extl_brate == 0 && NE_16( st_fx->coder_type, AUDIO ) ) ) ) )
+ IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) &&
+ ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) )
{
- hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2 );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
+ }
+ ELSE
+ {
+ Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0
+ hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
+ Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 );
+ }
}
ELSE
{
- hf_synth_reset_fx( st_fx->hBWE_zero );
+ hf_synth_reset_fx( st->hBWE_zero );
+ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment
+ {
+ set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
+ }
}
}
@@ -1471,8 +2301,7 @@ ivas_error acelp_core_dec_fx(
* Populate parameters for SWB TBE
*-----------------------------------------------------------------*/
- /* Apply a non linearity to the SHB excitation */
- IF( hBWE_TD != NULL )
+ IF( st->hBWE_TD != NULL )
{
test();
test();
@@ -1486,11 +2315,11 @@ ivas_error acelp_core_dec_fx(
test();
test();
test();
- IF( ( !st_fx->bfi && ( st_fx->prev_bfi ) ) || ( ( EQ_16( st_fx->last_vbr_hw_BWE_disable_dec, 1 ) ) && ( st_fx->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, WB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && !st_fx->tdm_LRTD_flag ) )
+ IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
{
- hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move32();
- set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
+ set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
}
test();
@@ -1498,42 +2327,70 @@ ivas_error acelp_core_dec_fx(
test();
test();
test();
- IF( !st_fx->ppp_mode_dec && ( st_fx->idchan == 0 || NE_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && st_fx->tdm_LRTD_flag ) ) )
+ IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
{
- non_linearity_fx( bwe_exc_fx, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st_fx->Q_exc,
- st_fx->coder_type, voice_factors, st_fx->L_frame );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
+ }
+ ELSE
+ {
+ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
+ non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
+ Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
+ }
}
test();
- IF( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
+ if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
{
- hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
+ st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move32();
}
}
+
/*----------------------------------------------------------------------*
* Updates
*----------------------------------------------------------------------*/
- updt_dec_fx( st_fx, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors, old_bwe_exc_fx, gain_buf );
+ updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx );
test();
test();
- IF( GT_32( st_fx->core_brate, SID_2k40 ) && st_fx->hTdCngDec != NULL && st_fx->hFdCngDec != NULL )
+ IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL )
{
/* update CNG parameters in active frames */
- cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &st_fx->hTdCngDec->ho_circ_ptr, st_fx->hTdCngDec->ho_ener_circ_fx, &st_fx->hTdCngDec->ho_circ_size, st_fx->hTdCngDec->ho_lsp_circ_fx,
- st_fx->Q_exc, DEC, st_fx->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st_fx->last_active_brate );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
+ st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
+ }
+ ELSE
+ {
+ cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size,
+ st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode,
+ st->hFdCngDec->hFdCngCom->CngBandwidth );
+ }
+
/* Set 16k LSP flag for CNG buffer */
- st_fx->hTdCngDec->ho_16k_lsp[st_fx->hTdCngDec->ho_circ_ptr] = 0;
+ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
move16();
- if ( NE_16( st_fx->L_frame, L_FRAME ) )
+ if ( NE_16( st->L_frame, L_FRAME ) )
{
- st_fx->hTdCngDec->ho_16k_lsp[st_fx->hTdCngDec->ho_circ_ptr] = 1;
+ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
move16();
}
}
- return IVAS_ERR_OK;
+ IF( NE_16( st->element_mode, EVS_MONO ) )
+ {
+ IF( save_hb_synth_fx16 )
+ {
+ Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0
+ }
+ Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2
+ }
+
+ pop_wmops();
+ return error;
}
-#endif
diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c
deleted file mode 100644
index ad8ca9b504ddd874b3086a35b4517494ecda4b9d..0000000000000000000000000000000000000000
--- a/lib_dec/acelp_core_dec_ivas_fx.c
+++ /dev/null
@@ -1,2429 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-/*====================================================================================
- EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
- ====================================================================================*/
-#include
-#include
-#include
-#include "options.h"
-#include "cnst.h"
-#include "rom_com.h"
-#include "prot_fx.h"
-#include "ivas_cnst.h"
-#include "ivas_rom_com.h"
-#include "wmc_auto.h"
-#include "ivas_prot_fx.h"
-
-
-/*-------------------------------------------------------------------*
- * acelp_core_dec_ivas_fx()
- *
- * ACELP core decoder
- *-------------------------------------------------------------------*/
-
-ivas_error acelp_core_dec_ivas_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/
- Word16 synth_fx16[], /* o : synthesis Q_syn2*/
- Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/
- Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_exc*/
- Word16 *voice_factors_fx, /* o : voicing factors Q15*/
- Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE Q_syn2-1*/
- const Word16 sharpFlag, /* i : formant sharpening flag */
- Word16 pitch_buf_fx[NB_SUBFR16k], /* o : Word16 pitch for each subframe Q6*/
- Word16 *unbits, /* o : number of unused bits */
- Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */
- STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle Qlog2(2.56)*/
- const Word16 tdm_lspQ_PCh_fx[M], /* i : Q LSPs for primary channel Q15*/
- const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */
- const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */
- const Word16 last_element_mode, /* i : last element mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */
- const Word16 nchan_out, /* i : number of output channels */
- STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */
- const Word16 read_sid_info /* i : read SID info flag */
-)
-{
- Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/;
- Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */
- Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */
- Word16 output_frame; /* frame length at output sampling freq. */
- Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */
- Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */
- Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */
- Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */
- Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */
- Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */
- Word32 enr_q_fx; /* E information for FER protection */
- Word16 tmp_noise_fx; /* Long term temporary noise energy */
- Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */
- Word16 FEC_pitch_fx; /* FEC pitch */
- Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */
- Word16 *bwe_exc_fx; /* Excitation for SWB TBE */
- Word16 i, j, int_fs;
- Word16 tc_subfr;
- Word16 allow_cn_step;
- Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM];
- Word16 last_pulse_pos;
- Word16 T0_tmp;
- Word16 do_WI;
- Word16 dct_buffer_fx[DCT_L_POST];
- Word16 exc_buffer_fx[DCT_L_POST];
- Word16 dct_exc_tmp_fx[L_FRAME16k];
- Word16 nb_bits; /* number of bits */
- Word16 indice; /* parameter indices to write */
- Word16 gain_buf_fx[NB_SUBFR16k];
- Word16 syn_fx_tmp2[L_FRAME_16k];
- Word16 pitch_buf_tmp[NB_SUBFR16k];
- Word16 update_flg;
- Word32 q_env_fx[20];
- Word16 exc3_fx[L_FRAME16k];
- Word16 syn1_tmp_fx[L_FRAME16k + 2], *syn1_fx;
- Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX];
- Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word16 LSF_Q_prediction; /* LSF prediction mode */
- Word16 avoid_lpc_burst_on_recovery;
- Word16 tmpF_fx;
- Word16 uc_two_stage_flag;
- Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
- Word16 *old_exc_s_fx; /* Start of last excitation frame */
- Word16 *p_tdm_Pri_pitch_buf_fx;
- Word16 tmp, exp, local_element_mode;
- ivas_error error;
- Word32 bpf_error_signal_fx[L_FRAME16k];
- Word16 bpf_error_signal_16fx[L_FRAME16k];
- Word16 Q_real;
- Word32 max_real, max_imag, max_val;
-
- set32_fx( bpf_error_signal_fx, 0, L_FRAME16k );
- set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k );
- set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) );
- set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) );
-
- error = IVAS_ERR_OK;
- move32();
-
- test();
- test();
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) )
- {
- /* In MDCT-Stereo DTX with mono output, we can skip CNG for the second channel, except for the first inactive frame following an active period */
- return error;
- }
-
- push_wmops( "acelp_core_dec" );
-
- /* output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); */
- output_frame = extract_l( Mpy_32_32( st->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
-
- /*----------------------------------------------------------------*
- * stereo SID and CNG frames processing
- *----------------------------------------------------------------*/
-
- test();
- test();
- IF( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) )
- {
- IF( EQ_16( st->cng_type, FD_CNG ) )
- {
- configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
-
- Word16 old_NoiseEstExp;
- old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
- move16();
-
- /* Only run parameter decoding in SID frames */
- IF( EQ_32( st->core_brate, SID_2k40 ) )
- {
- FdCng_decodeSID_ivas_fx( st );
-
- Word16 n1, n2;
- n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART );
- n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART );
-
- Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) );
- scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) );
- scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) );
- st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e;
- move16();
- }
- FOR( i = 0; i < NPART; i++ )
- {
- st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
- STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
- move32();
- }
-
- ApplyFdCng_ivas_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 );
- }
- ELSE
- {
- configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode );
-
- /* decode CNG parameters */
- CNG_dec_ivas_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
-
- /* comfort noise generation */
- CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode );
-
- Copy( Aq_fx, st->Aq_cng, M + 1 ); /*Q12*/
-
- /* update old LSP and LSF vector */
- Copy( lsf_new_fx, st->lsf_old_fx, M ); /*Qlog2(2.56)*/
- Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Q15*/
- }
-
- set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */
- set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */
-
- /* CN generation done in DFT domain */
- pop_wmops();
-
- return error;
- }
-
- /*----------------------------------------------------------------*
- * Active frames processing
- *----------------------------------------------------------------*/
-
- /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer_fx[i] = realBufferTmp_fx[i];
- imagBuffer_fx[i] = imagBufferTmp_fx[i];
- }
-
- /*----------------------------------------------------------------*
- * Initialization
- *----------------------------------------------------------------*/
-
- LSF_Q_prediction = -1;
- move16();
- set16_fx( syn_tmp_fx, 0, L_SUBFR );
- psyn_fx = syn_tmp_fx + L_SUBFR;
- syn1_tmp_fx[0] = 0;
- move16();
- syn1_tmp_fx[1] = 0;
- move16();
- syn1_fx = syn1_tmp_fx + 2;
- st->bpf_off = 0;
- move16();
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->last_core_brate, SID_2k40 ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) )
- {
- /* in case of HQ->ACELP switching, do not apply BPF */
- st->bpf_off = 1;
- move16();
- if ( st->hPFstat != NULL )
- {
- /* in case of core switching, reset post-filter memories */
- st->hPFstat->on = 0;
- move16();
- }
-
- if ( st->hGSCDec != NULL )
- {
- /* reset the GSC pre echo energy threshold in case of switching */
- st->hGSCDec->Last_frame_ener_fx = MAX_32;
- move32();
- }
- }
-
- test();
- if ( st->hGSCDec != NULL && ( st->prev_bfi > 0 ) )
- {
- /* reset the GSC pre echo energy threshold in case of FEC */
- st->hGSCDec->Last_frame_ener_fx = MAX_32;
- move32();
- }
-
- test();
- test();
- test();
- test();
- IF( st->hFdCngDec != NULL && ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) )
- {
- set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN );
- set16_fx( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN );
- }
-
- st->clas_dec = st->last_good;
- move16();
- enr_q_fx = 0;
- move32();
- Es_pred_fx = 0;
- move16();
- tmp_noise_fx = 0;
- move16();
- Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
- exc_fx = old_exc_fx + L_EXC_MEM_DEC;
-
- IF( st->hWIDec != NULL )
- {
- Copy( st->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM );
- }
- ELSE
- {
- set16_fx( old_exc2_fx, 0, L_EXC_MEM );
- }
- exc2_fx = old_exc2_fx + L_EXC_MEM;
-
- IF( st->hBWE_TD != NULL )
- {
- Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/
- bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2;
- }
- ELSE
- {
- bwe_exc_fx = NULL;
- }
-
- last_pulse_pos = 0;
- move16();
- do_WI = 0;
- move16();
- st->GSC_noisy_speech = 0;
- move16();
- st->relax_prev_lsf_interp = 0;
- move16();
- set16_fx( gain_buf_fx, 0, NB_SUBFR16k );
-
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- st->gamma = GAMMA1;
- move16();
- st->inv_gamma = GAMMA1_INV;
- move16();
- st->preemph_fac = PREEMPH_FAC;
- move16();
- int_fs = INT_FS_12k8;
- move16();
- }
- ELSE
- {
- st->gamma = GAMMA16k;
- move16();
- st->inv_gamma = GAMMA16k_INV;
- move16();
- st->preemph_fac = PREEMPH_FAC_16k;
- move16();
- int_fs = INT_FS_16k;
- move16();
- }
-
- test();
- /* reset post-filter in case of switching */
- if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) )
- {
- st->hPFstat->reset = 1;
- move16();
- }
-
- avoid_lpc_burst_on_recovery = 0;
- move16();
- test();
- test();
- if ( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) )
- {
- avoid_lpc_burst_on_recovery = 1;
- move16();
- }
- test();
-
- /* TD stereo parameters */
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
- {
- tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag;
- move16();
- tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
- move16();
- tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
- move16();
- p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx;
- }
- ELSE
- {
- tdm_lp_reuse_flag = 0;
- move16();
- tdm_low_rate_mode = 0;
- move16();
- test();
- if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode )
- {
- tdm_low_rate_mode = 1;
- move16();
- }
- tdm_Pitch_reuse_flag = 0;
- move16();
- p_tdm_Pri_pitch_buf_fx = NULL;
- }
-
- /*----------------------------------------------------------------*
- * Updates in case of internal sampling rate switching
- *----------------------------------------------------------------*/
-
- test();
- test();
- IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) )
- {
- Word16 dec;
-
- IF( ( st->hPFstat->on != 0 ) )
- {
- Word16 mem_syn_r_size_old, mem_syn_r_size_new;
- mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); /* 1.25/20.f = 2048 (Q15)*/
- mem_syn_r_size_new = mult_r( 2048, st->L_frame ); /* 1.25/20.f = 2048 (Q15)*/
- lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old );
- }
-
- /* convert quantized LSP vector */
- st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 );
- move16();
-
- /* convert old quantized LSF vector */
- lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs );
-
- /* FEC - update adaptive LSF mean vector */
- Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); /*Qlog2(2.56)*/
- Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); /*Qlog2(2.56)*/
- Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); /*Qlog2(2.56)*/
-
- /* Reset LPC mem */
- IF( EQ_32( st->sr_core, INT_FS_16k ) )
- {
- Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/
- }
- ELSE
- {
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/
- }
- set16_fx( st->mem_MA_fx, 0, M );
-
- /* update synthesis filter memories */
- dec = DEC;
- move16();
- if ( st->element_mode != EVS_MONO )
- {
- dec = DEC_IVAS;
- move16();
- }
- ivas_synth_mem_updt2_fx( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec );
- Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/
- Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/
- Copy( st->mem_syn2_fx, st->mem_syn3_fx, M ); /*Q_syn*/
- }
-
- /* update buffer of old subframe pitch values */
- IF( NE_16( st->last_L_frame, st->L_frame ) )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
- {
- tmpF_fx = 13107; // Q15
- move16();
- }
- ELSE IF( EQ_16( st->last_L_frame, 512 ) )
- {
- tmpF_fx = 16384; // Q15
- move16();
- }
- ELSE /* st->last_L_frame == L_FRAME16k */
- {
- tmpF_fx = 26214; // Q15
- move16();
- }
-
- FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ )
- {
- st->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16
- move32();
- }
-
- FOR( i = 2 * NB_SUBFR16k - NB_SUBFR; i < 2 * NB_SUBFR16k; i++ )
- {
- st->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16
- move32();
- }
- }
- ELSE
- {
- exp = 0;
- move16();
- IF( EQ_16( st->last_L_frame, L_FRAME32k ) )
- {
- tmpF_fx = 16384; // Q15
- move16();
- }
- ELSE IF( EQ_16( st->last_L_frame, 512 ) )
- {
- tmpF_fx = 20480; // Q15
- move16();
- }
- ELSE /* st->last_L_frame == L_FRAME12k8 */
- {
- tmpF_fx = 20480; // Q14
- move16();
- exp = 1;
- move16();
- }
- FOR( i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i-- )
- {
- st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15
- move32();
- }
- st->old_pitch_buf_fx[NB_SUBFR + 1] = st->old_pitch_buf_fx[NB_SUBFR + 2];
- move32();
-
- FOR( i = NB_SUBFR - 1; i >= 0; i-- )
- {
- st->old_pitch_buf_fx[i + 1] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15
- move32();
- }
- st->old_pitch_buf_fx[0] = st->old_pitch_buf_fx[1];
- move32();
- }
- }
-
- IF( NE_16( st->bfi_pitch_frame, st->L_frame ) )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
- {
- tmpF_fx = 13107; // Q15
- move16();
- }
- ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
- {
- tmpF_fx = 16384; // Q15
- move16();
- }
- ELSE /* st->bfi_pitch_frame == L_FRAME16k */
- {
- tmpF_fx = 26214; // Q15
- move16();
- }
- st->bfi_pitch_fx = mult_r( st->bfi_pitch_fx, tmpF_fx );
- move16();
- st->bfi_pitch_frame = L_FRAME;
- move16();
- }
- ELSE
- {
- exp = 0;
- move16();
- IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) )
- {
- tmpF_fx = 16384; // Q15
- move16();
- }
- ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) )
- {
- tmpF_fx = 20480; // Q15
- move16();
- }
- ELSE /* st->bfi_pitch_frame == L_FRAME12k8 */
- {
- tmpF_fx = 20480; // Q14
- move16();
- exp = 1;
- move16();
- }
-
- st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx );
- move16();
- st->bfi_pitch_frame = L_FRAME16k;
- move16();
- }
- }
-
- test();
- test();
- if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) )
- {
- st->rate_switching_reset = 1;
- move16();
- }
-
- /*----------------------------------------------------------------------*
- * GOOD frame
- *----------------------------------------------------------------------*/
-
- IF( !st->bfi )
- {
-
- /*----------------------------------------------------------------*
- * Decoding of TC subframe classification
- *----------------------------------------------------------------*/
-
- tc_subfr = -1;
- move16();
- IF( EQ_16( st->coder_type, TRANSITION ) )
- {
- tc_subfr = tc_classif_fx( st, st->L_frame );
- }
-
- /*----------------------------------------------------------------*
- * Decoding of GSC IVAS mode
- *----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- IF( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode )
- {
- test();
- test();
- IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && EQ_16( st->inactive_coder_type_flag, 1 ) ) )
- {
- st->GSC_IVAS_mode = get_next_indice_fx( st, 2 );
- move16();
- }
- }
-
- /*----------------------------------------------------------------*
- * Decoding of inactive CNG frames
- *----------------------------------------------------------------*/
-
- test();
- IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
- {
- /* decode CNG parameters */
- IF( st->cng_type == LP_CNG )
- {
- CNG_dec_ivas_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx );
- Copy( Aq_fx, st->Aq_cng, add( M, 1 ) );
-
- /* comfort noise generation */
- local_element_mode = st->element_mode;
- move16();
-
- test();
- test();
- if ( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) )
- {
- local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */
- move16();
- }
- CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, local_element_mode );
- }
- ELSE
- {
- test();
- IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st );
- }
- ELSE
-#endif
- {
- Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp;
- move16();
-
- FdCng_decodeSID_ivas_fx( st );
-
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
- Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx
- }
-
- *sid_bw = 0;
- move16();
- }
-
- IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- assert( nchan_out == 1 );
-
- FOR( i = 0; i < NPART; i++ )
- {
- st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ),
- STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] );
- move32();
- }
-
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
-
- Word16 new_sidNoiseEstExp = 31 - Q4;
- move16();
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
- Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp)
- st->hFdCngDec->hFdCngCom->sidNoiseEstExp = new_sidNoiseEstExp;
- move16();
- Word16 new_cngNoiseLevelExp = 31 - Q4;
- move16();
- Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, new_cngNoiseLevelExp ) ); // Q(31-cngNoiseLevelExp)
- st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp;
- move16();
-
- test();
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) );
-
- IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 )
- {
- Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); // Q(31-cngNoiseLevelExp)
- st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0;
- move16();
- }
- }
-
- IF( !read_sid_info )
- {
- Word32 noise_lvl_highest_fx;
-
- noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) - 1];
- move32();
-
- FOR( Word16 b = ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); b < st->hFdCngDec->hFdCngCom->stopBand; b++ )
- {
- st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx;
- move32();
- }
- }
-
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 );
- }
- ELSE
-#endif
- {
- generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out );
- }
-
- FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx );
-
- Copy( exc2_fx, exc3_fx, st->L_frame );
- }
-
- Word16 delta_mem_scale = 3;
- move16();
- test();
- if ( LT_32( st->lp_ener_fx, 40 ) && st->cng_type == LP_CNG ) /* very low energy frames, less than 0.3125 */
- {
- delta_mem_scale = 0;
- move16();
- }
- i = st->Q_exc;
- move16();
-
- test();
- IF( st->hMusicPF && st->hGSCDec )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS?
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
- st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
- }
- ELSE
-#endif
- {
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame,
- L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE );
- }
- }
-
- IF( st->hPFstat != NULL )
- {
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale,
- &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 0, 0, NULL );
- }
- ELSE
- {
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale,
- &st->mem_deemph_fx, NULL, NULL, &st->agc_mem_fx[1], NULL, 0, 0, NULL );
- }
-
- Copy_Scale_sig( exc2_fx, exc2_fx, st->L_frame, sub( st->Q_exc, i ) ); // Q_exc
-
- /* update past excitation signals for LD music post-filter */
- IF( st->hMusicPF != NULL )
- {
- Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
-
- /* Update music post processing values */
- /* Filter energies update */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
- move16();
- }
- }
- ELSE
-#endif
- {
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15
- move16();
- }
- }
- }
-
- /* synthesis at 12.8kHz sampling rate */
- move16();
- syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
- syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn );
-
- /* reset the decoder */
- CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx );
-
-
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- /* update st_fx->mem_syn1 for ACELP core switching */
- Copy( st->mem_syn3_fx, st->mem_syn1_fx, M );
- }
- ELSE
-#endif
- {
- st->Q_syn_cng = st->Q_syn;
- move16();
- st->Q_exc_cng = st->Q_exc;
- move16();
-
- /* update st->mem_syn1 for ACELP core switching */
- Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1)
- }
-
- /* update old synthesis for classification */
- Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
-
- /* save and delay synthesis to be used by SWB BWE */
- Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1)
- IF( st->hBWE_FD != NULL )
- {
- save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- }
- }
-
- /*----------------------------------------------------------------*
- * Decoding of all other frames
- *----------------------------------------------------------------*/
-
- ELSE
- {
-
- /*-----------------------------------------------------------------*
- * Configure ACELP bit allocation
- *-----------------------------------------------------------------*/
-
- nb_bits = 0;
- move16();
- st->acelp_cfg.FEC_mode = 0;
- move16();
- uc_two_stage_flag = 0;
- move16();
-
- test();
- IF( !st->nelp_mode_dec && !st->ppp_mode_dec )
- {
- Word16 tc_subfr_tmp;
-
- tc_subfr_tmp = tc_subfr;
- move16();
- if ( LT_16( tc_subfr_tmp, L_SUBFR ) )
- {
- tc_subfr_tmp = 0;
- move16();
- }
-
- if ( EQ_16( tc_subfr, TC_0_192 ) )
- {
- nb_bits = -1;
- move16();
- }
-
- config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
-
- test();
- test();
- IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) )
- {
- config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
- }
- }
-
- /*-----------------------------------------------------------------*
- * After CNG period, use the most up-to-date LSPs
- *-----------------------------------------------------------------*/
-
- test();
- test();
- IF( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) )
- {
- Copy( st->lspCNG_fx, st->lsp_old_fx, M ); /*Q15*/
- lsp2lsf_fx( st->lspCNG_fx, st->lsf_old_fx, M, int_fs );
- }
-
- /*-----------------------------------------------------------------*
- * Reset higher ACELP pre-quantizer in case of switching
- *-----------------------------------------------------------------*/
-
- IF( !st->use_acelp_preq )
- {
- st->mem_preemp_preQ_fx = 0;
- move16();
- st->last_nq_preQ = 0;
- move16();
- st->last_code_preq = 0;
- move16();
- }
-
- st->use_acelp_preq = 0;
- move16();
-
- /*-----------------------------------------------------------------*
- * LSF de-quantization and interpolation
- *-----------------------------------------------------------------*/
-
- IF( !tdm_lp_reuse_flag )
- {
- lsf_dec_ivas_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh_fx );
- }
- ELSE
- {
- const Word16 *pt_interp_2_fx;
-
- IF( NE_16( st->active_cnt, 1 ) )
- {
- Word16 beta_index;
-
- beta_index = get_next_indice_fx( st, TDM_IC_LSF_PRED_BITS );
- tdm_SCh_lsf_reuse_fx( DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index );
- }
- ELSE
- {
- Copy( tdm_lspQ_PCh_fx, lsp_new_fx, M );
- Copy( tdm_lsfQ_PCh_fx, lsf_new_fx, M );
- }
-
- IF( st->rate_switching_reset )
- {
- /* extrapolation in case of unstable LSF convert */
- Copy( lsp_new_fx, st->lsp_old_fx, M );
- Copy( lsf_new_fx, st->lsf_old_fx, M );
- }
-
- pt_interp_2_fx = interpol_frac_fx;
- test();
- if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) )
- {
- pt_interp_2_fx = interpol_frac2_fx;
- }
-
- IF( EQ_16( st->active_cnt, 1 ) )
- {
- Copy( lsp_new_fx, st->lsp_old_fx, M );
- lsp2lsf_fx( lsp_new_fx, st->lsf_old_fx, M, st->sr_core );
- }
-
- /* LSP interpolation and conversion of LSPs to A(z) */
- int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 );
-
- /* Check LSF stability (distance between old LSFs and current LSFs) */
- st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame );
- move16();
- }
-
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory from last HQ frame */
- old_exc_s_fx = st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame );
- tmpF_fx = *old_exc_s_fx;
- st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */
- move16();
- PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx );
- Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M );
- Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */
- Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 );
- Scale_sig( old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, st->Q_exc ); /* Q0 -> Q_exc */
- }
-
- test();
- IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO )
- {
- /* Prepare ACB memory of old_bwe_exc */
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC );
- }
- ELSE
- {
- lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC << 1, L_EXC_MEM_DEC );
- }
- }
-
- /*-----------------------------------------------------------------*
- * FEC - first good frame after lost frame(s) (possibility to correct the ACB)
- *-----------------------------------------------------------------*/
-
- IF( st->acelp_cfg.FEC_mode > 0 )
- {
- last_pulse_pos = 0;
- move16();
-
- /* decode the last glottal pulse position */
- T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits );
-
- test();
- test();
- IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st->prev_bfi, 1 ) )
- {
- FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc );
- }
- ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL )
- {
- do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx );
- }
- }
- }
-
- /*------------------------------------------------------------*
- * In case of first frame after an erasure and transition from voiced to unvoiced or inactive
- * redo the LPC interpolation
- *------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) )
- {
- int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
- }
-
- /*---------------------------------------------------------------*
- * Decoding of the scaled predicted innovation energy
- *---------------------------------------------------------------*/
-
- IF( nb_bits > 0 )
- {
- indice = get_next_indice_fx( st, nb_bits );
- Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag );
- }
-
- /*------------------------------------------------------------*
- * Decode excitation according to coding type
- *------------------------------------------------------------*/
-
- test();
- test();
- IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */
- {
- IF( LE_16( st->coder_type, UNVOICED ) )
- {
- tdm_low_rate_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx );
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- ELSE /* GENERIC */
- {
- decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- }
- }
- ELSE IF( st->nelp_mode_dec )
- {
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
- st->Q_exc = 0;
- move16();
-
- /* SC-VBR - NELP frames */
- decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
-
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
- }
- ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
- {
- /* UNVOICED frames */
- decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx );
-
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- ELSE IF( st->ppp_mode_dec )
- {
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
- st->Q_exc = 0;
- move16();
-
- /* SC-VBR - PPP frames */
- IF( NE_32( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
- }
- ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
- {
- decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx );
- }
- ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) )
- {
- /* AUDIO and INACTIVE frames (coded by GSC technology) */
- decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx,
- tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx );
-
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- ELSE
- {
- /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
- IF( NE_32( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
- }
- }
-
- /* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
-
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- }
-
- /*-----------------------------------------------------------------*
- * Apply energy matching when switching to inactive frames
- *-----------------------------------------------------------------*/
-
- Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
-
- /*------------------------------------------------------------*
- * Decode information and modify the excitation signal of stationary unvoiced frames
- *------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
- {
- stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag );
- }
-
- /*------------------------------------------------------------*
- * Save filter memory in case the synthesis is redone after scaling
- * Synthesis at 12k8 Hz sampling rate
- *------------------------------------------------------------*/
-
- /* update past excitation signals for LD music post-filter */
- IF( st->hMusicPF != NULL )
- {
- Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
- Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 );
- }
-
- test();
- test();
- test();
- IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) )
- {
- Word16 last_coder_type = st->last_coder_type;
- move16();
-
- test();
- test();
- test();
- if ( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) )
- {
- last_coder_type = AUDIO;
- move16();
- }
-
- Word16 qdct = 0;
- move16();
-
- /* Extrapolation of the last future part, windowing and high resolution DCT transform */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate'
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx,
- st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
- }
- ELSE
-#endif
- {
- Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct );
- }
-
- /* LD music post-filter */
- LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct );
-
- /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS
-#endif
- {
- Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/
- }
-
- Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn,
- &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx,
- &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx );
- }
- ELSE
- {
- /* Core synthesis at 12.8kHz or 16kHz */
- i = 1;
- move16();
- test();
- if ( st->coder_type == INACTIVE && st->element_mode == EVS_MONO )
- {
- i = 0;
- move16();
- }
-
- /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- Word16 k = 0;
- move16();
- test();
- test();
- if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
- {
- k = 1;
- move16();
- }
-
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
- st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx );
-
- Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/
- syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
-
- IF( st->hMusicPF != NULL )
- {
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) );
- move16();
- }
- }
- }
-
- /*------------------------------------------------------------*
- * FEC - Estimate the classification information
- *------------------------------------------------------------*/
-
- FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst,
- NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode );
-
- /*------------------------------------------------------------*
- * FEC - Estimate pitch
- *------------------------------------------------------------*/
-
- FEC_pitch_estim_fx( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx,
- &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode );
-
- /*------------------------------------------------------------*
- * FEC - Smooth the speech energy evolution when recovering after a BAD frame
- * (smoothing is performed in the excitation domain and signal is resynthesized after)
- *------------------------------------------------------------*/
-
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
-
- FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
- &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
-#ifdef REMOVE_EVS_DUPLICATES
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 );
-#else
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
-#endif
-
- test();
- test();
- test();
- test();
- /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
- IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
- {
- frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[( ( st->L_frame ) >> 6 ) - 1], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
- }
- }
-
- } /* End of GOOD FRAME */
-
- /*----------------------------------------------------------------*
- * BAD frame
- *----------------------------------------------------------------*/
-
- ELSE
- {
- /* SC-VBR */
- if ( EQ_16( st->last_nelp_mode_dec, 1 ) )
- {
- st->nelp_mode_dec = 1;
- move16();
- }
-
- test();
- test();
- /* long burst frame erasures */
- if ( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) )
- {
- st->last_good = VOICED_TRANSITION;
- move16();
- }
-
- /* LSF estimation and A(z) calculation */
- lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth );
-
- FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx );
- IF( EQ_16( st->nelp_mode_dec, 1 ) )
- {
- /* SC-VBR */
- Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0
- st->Q_exc = 0;
- move16();
-
- decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx );
- FEC_pitch_fx = pitch_buf_fx[3];
- move16();
- Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type );
- }
- ELSE
- {
- /* calculation of excitation signal */
- FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx );
-
- Rescale_exc( NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32) 0,
- &( st->Q_exc ), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type );
-
- tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/
-
- /* SC-VBR */
- st->prev_gain_pit_dec_fx = st->lp_gainp_fx;
- move16();
- }
-
- /* synthesis for ACELP core switching and SWB BWE */
- syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 );
-
- /* save and delay synthesis to be used by SWB BWE */
- IF( st->hBWE_FD != NULL )
- {
- save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
- }
-
- /* Apply energy matching when switching to inactive frames */
- Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode );
-
- /* update past excitation signals for LD music post-filter */
- IF( st->hMusicPF != NULL )
- {
- Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 );
- Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME );
-
- /* Update music post processing values */
- /* Filter energies update */
- FOR( i = 0; i < DCT_L_POST; i++ )
- {
- st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( 1228 << 16, 22938, st->hMusicPF->filt_lfE_fx[i] ) );
- move16();
- }
-
- /* Update circular buffer, keep last energy difference unchanged */
- FOR( i = 1; i < MAX_LT; i++ )
- {
- st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i];
- move16();
- }
- }
-
- /* synthesis at 12k8 Hz sampling rate */
- /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */
- Word16 k = 0;
- move16();
- test();
- test();
- if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) )
- {
- k = 1;
- move16();
- }
-
- Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx,
- st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx );
-
- test();
- IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
- {
- Copy( st->mem_syn2_fx, mem_tmp_fx, M );
- }
- syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn );
-
- /* update buffer for classifier */
- IF( st->hWIDec != NULL )
- {
- Copy( exc2_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_exc2_fx, L_EXC_MEM );
- Copy( psyn_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_syn2_fx, L_EXC_MEM );
- }
- st->prev_Q_exc_fr = st->Q_exc;
- move16();
- st->prev_Q_syn_fr = st->Q_syn;
- move16();
- Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM_CLAS_ESTIM ), st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM );
-
- /*------------------------------------------------------------*
- * FEC - Smooth the speech energy evolution when recovering after a BAD frame
- * (smoothing is performed in the excitation domain and signal is resynthesized after)
- *------------------------------------------------------------*/
-
- test();
- IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
- {
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
-
- FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
- &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
-#ifdef REMOVE_EVS_DUPLICATES
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 );
-#else
- exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
-#endif
- }
-
- /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
- frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 );
-
- IF( NE_16( st->nelp_mode_dec, 1 ) )
- {
- /* modify the excitation signal of stationary unvoiced frames */
- stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx,
- &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx,
- &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge );
- }
- }
-
- IF( st->hBWE_TD != NULL )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- ELSE
- {
- Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) );
- }
- }
-
- /*--------------------------------------------------------*
- * Apply NB postfilter in case of 8kHz output
- *--------------------------------------------------------*/
-
- test();
- IF( st->last_bwidth == NB && st->hPFstat != NULL )
- {
- Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
-
- IF( st->bwidth == NB )
- {
- st->hPFstat->on = 1;
- move16();
- nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 );
- }
- ELSE
- {
- st->hPFstat->on = 0;
- move16();
- nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 );
- }
- }
- ELSE
- {
- st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) );
- move16();
- }
-
- /*------------------------------------------------------------------*
- * Perform fixed deemphasis through 1/(1 - g*z^-1)
- *-----------------------------------------------------------------*/
-
- /* update old synthesis buffer - needed for ACELP internal sampling rate switching */
- Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM );
- deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) );
- unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame );
- Copy( syn_fx_tmp2, psyn_fx, st->L_frame );
- IF( st->hTcxDec != NULL )
- {
- Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/
- st->hTcxDec->Q_old_syn_Overl = -1;
- }
- Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/
-
- /*------------------------------------------------------------------*
- * Formant post-filter
- *-----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || st->element_mode > EVS_MONO ) && LE_32( st->core_brate, ACELP_32k ) )
- {
- st->hPFstat->on = 1;
- move16();
- Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k );
- set16_fx( st->hPFstat->mem_zero, 0, M );
-
- formant_post_filt_ivas_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 );
- }
- ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) )
- {
- IF( st->hPFstat->on )
- {
- Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M );
- Copy( psyn_fx, temp_buf_fx + M, L_SUBFR );
-
- Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 );
- E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
- scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR );
- Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) );
- blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 );
- }
- st->hPFstat->on = 0;
- move16();
- }
-
- /*----------------------------------------------------------------*
- * Comfort noise addition
- *----------------------------------------------------------------*/
-
- test();
- test();
- IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) )
- {
- /*VAD only for non inactive frame*/
- test();
- st->VAD = st->VAD && st->coder_type != INACTIVE;
- move16();
- test();
- test();
- test();
- test();
- test();
- IF( st->idchan == 0 && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) )
- {
- /*Noisy speech detector*/
- noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn );
-
- st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ );
- move16();
- IF( st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 )
- {
- st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ );
- move16();
- }
- move32();
- }
-
- if ( st->idchan == 0 )
- {
- st->lp_noise = st->hFdCngDec->lp_noise;
- move32();
- }
-
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag )
- {
- /* Noise estimate */
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
- }
-
- IF( !st->cna_dirac_flag )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- /* CNA: Generate additional comfort noise to mask potential coding artefacts */
- IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
- {
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
- {
- IF( hStereoCng->flag_cna_fade )
- {
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
- hStereoCng->flag_cna_fade = 0;
- move16();
- }
- ELSE
- {
- test();
- IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) )
- {
- /* Clear memory for secondary channel CNA */
- set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) );
- }
-
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out );
- }
- }
- ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 );
- }
- ELSE
-#endif
- {
- IF( st->idchan == 0 )
- {
- IF( NE_16( st->element_mode, last_element_mode ) )
- {
- set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
- }
- Word32 psyn_32_fx[L_FRAME16k];
- Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6
- Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15
- generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out );
- Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn
- Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0
- }
- }
- }
- }
- ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) )
- {
- test();
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) )
- {
- generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out );
- hStereoCng->flag_cna_fade = 1;
- move16();
- }
- ELSE
- {
- FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ )
- {
- psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), negate( st->Q_syn ) ) );
- move16();
- }
- }
- }
- ELSE
- {
- IF( hStereoCng != NULL )
- {
- hStereoCng->flag_cna_fade = 1;
- move16();
- hStereoCng->enableSecCNA = 0;
- move16();
- }
- }
-
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- test();
- test();
- test();
- /*Noise estimate*/
- IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) )
- {
- ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) );
- }
- }
- }
- }
-
- IF( !st->cna_dirac_flag )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- // VE: TBV - is it correct in EVS? in FLP, it is:
- // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 );
- // v_add( temp_buf, syn, syn, st->L_frame / 2 );
- FOR( i = 0; i < st->L_frame / 2; i++ )
- {
- psyn_fx[i] = add( psyn_fx[i], shr_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->L_frame / 4], negate( st->Q_syn ) ) );
- move16();
- }
- }
- ELSE
-#endif
- {
- FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ )
- {
- psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) );
- move16();
- }
- }
- }
-
- test();
- test();
- test();
- IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) )
- {
- IF( st->idchan == 0 )
- {
- set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen );
- }
- IF( hStereoCng != NULL && ( st->idchan == 0 ) )
- {
- set16_fx( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen );
- }
- }
- }
- }
-
- /*----------------------------------------------------------------*
- * Resample to the output sampling rate (8/16/32/48 kHz)
- * Bass post-filter
- *----------------------------------------------------------------*/
-
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- CLDFB_SCALE_FACTOR scaleFactor;
- Word32 workBuffer[128 * 3];
-
- /* check if the CLDFB works on the right sample rate */
- IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame )
- {
- /* resample to ACELP internal sampling rate */
- Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) );
- resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 );
- resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 );
-
- IF( st->ini_frame > 0 )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- move16();
- }
- }
-
- test();
- IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
- }
- ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
- }
- }
-
- bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
- st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
-
- /* analysis of the synthesis at internal sampling rate */
- cldfbAnalysis_fx( st->cldfbAna, realBuffer_fx, imagBuffer_fx, &scaleFactor, psyn_fx, negate( st->Q_syn ), CLDFB_NO_COL_MAX, workBuffer );
-
- scaleFactor.hb_scale = scaleFactor.lb_scale;
- move16();
-
- /* analysis and add the BPF error signal */
- i = 0;
- move16();
- if ( st->bpf_off == 0 )
- {
- i = CLDFB_NO_COL_MAX;
- move16();
- }
-
- addBassPostFilter_fx( bpf_error_signal_16fx, realBuffer_fx, imagBuffer_fx, st->cldfbBPF, workBuffer, negate( st->Q_syn ),
- i, st->cldfbAna->no_col, st->cldfbAna->no_channels, &scaleFactor );
-
- /* set output mask for upsampling */
- IF( EQ_16( st->bwidth, NB ) )
- {
- /* set NB mask for upsampling */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
- move16();
- }
- ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
- {
- /* in case of BW switching, re-init to default */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- move16();
- }
-
- /*WB/SWB-FD_CNG*/
- scaleFactor.hb_scale = scaleFactor.lb_scale;
- move16();
-
- test();
- test();
- test();
- IF( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
- {
- generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, &scaleFactor.hb_scale, st );
-
- st->cldfbSyn->bandsToZero = 0;
- move16();
- IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
- move16();
- }
- st->cldfbSyn->lsb = st->cldfbAna->no_channels;
- move16();
- }
-
- /* synthesis of the combined signal */
- st->Q_syn2 = st->Q_syn;
- move16();
- cldfbSynthesis_fx( st->cldfbSyn, realBuffer_fx, imagBuffer_fx, &scaleFactor, synth_fx16, negate( st->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer );
-
- /* Bring CLDFB output to Q0 */
- Scale_sig( synth_fx16, output_frame, negate( st->Q_syn2 ) );
- st->Q_syn2 = 0;
- move16();
-
- /* save synthesis - needed in case of core switching */
- Copy( synth_fx16, st->previoussynth_fx, output_frame );
- }
- ELSE
-#endif
- {
- /* check if the CLDFB works on the right sample rate */
- IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) )
- {
- resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
- resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) );
-
- IF( st->ini_frame > 0 )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- move16();
- }
- }
-
- /* analyze pitch coherence for bass post-filter */
-
- Word32 pitch_buf_fx_q20[12];
-
- Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4)
- Word16 lim = shr( st->L_frame, 6 );
- FOR( Word16 lp = 0; lp < lim; lp++ )
- {
- pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 );
- move32();
- }
- bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 );
- Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx
-
- test();
- IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) )
- {
- test();
- IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) )
- {
- IF( EQ_16( st->L_frame, L_FRAME ) )
- {
- retro_interp5_4_fx( st->hBPF->pst_old_syn_fx );
- }
- ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) )
- {
- retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx );
- }
- }
-
- bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off,
- st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
- }
-
- Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx;
- set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR );
- syn_32_fx = syn_tmp_32_fx + L_SUBFR;
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft )
- {
- /* analysis of the synthesis at internal sampling rate */
- Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
- Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX];
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- pRealSave_fx[i] = realBufferSave_fx[i];
- pImagSave_fx[i] = imagBufferSave_fx[i];
- }
- IF( st->p_bpf_noise_buf_32 )
- {
- Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
- Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
- Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11
- }
-
- FOR( i = 0; i < st->L_frame; i++ )
- {
- syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12
- move32();
- }
-
- Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
- st->cldfbAna->Q_cldfb_state = Q12;
- move16();
- cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
- st->cldfbAna->Q_cldfb_state = Q11;
- move16();
- /* analysis and add the BPF error signal */
- Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
- Word16 q_bpf_error_signal;
- Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
-
- q_bpf_error_signal = Q6;
- move16();
- Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- }
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
- st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
- move16();
- tmp = -1;
- move16();
- if ( st->bpf_off )
- {
- tmp = 0;
- move16();
- }
-
- addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10
- st->cldfbBPF->Q_cldfb_state = Q10;
- move16();
- /* set output mask for upsampling */
- IF( EQ_16( st->bwidth, NB ) )
- {
- /* set NB mask for upsampling */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 );
- move16();
- }
- ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) )
- {
- /* in case of BW switching, re-init to default */
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels );
- move16();
- }
- test();
- IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) )
- {
- test();
- test();
- test();
- /*WB/SWB-FD_CNG*/
- IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) )
- {
- Word16 tmpBufferScale = 0;
- move16();
- generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag );
-
- FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ )
- {
- Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
- Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0
- }
-
- IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) )
- {
- st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand );
- move16();
- }
- ELSE
- {
- st->cldfbSyn->bandsToZero = 0;
- move16();
- }
- }
- }
-
- IF( save_hb_synth_fx16 != NULL )
- {
- /* save and then zero-out lowband */
- max_real = 0;
- max_imag = 0;
- move32();
- move32();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
- }
- }
- max_val = L_max( max_real, max_imag );
- Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- }
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
-#ifdef OPT_STEREO_32KBPS_V1
- scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
-#else /* OPT_STEREO_32KBPS_V1 */
- scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1)
-#endif /* OPT_STEREO_32KBPS_V1 */
- st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- realBufferSave_fx[i][j] = realBuffer_fx[i][j];
- imagBufferSave_fx[i][j] = imagBuffer_fx[i][j];
- move32();
- move32();
- IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) )
- {
- realBuffer_fx[i][j] = 0;
- imagBuffer_fx[i][j] = 0;
- move32();
- move32();
- }
- }
- }
-
-#ifdef OPT_AVOID_STATE_BUF_RESCALE
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );
-#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB );
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
- Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0
- Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSynHB->Q_cldfb_state = Q10;
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
- /* restore lowband */
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- realBuffer_fx[i][j] = realBufferSave_fx[i][j];
- imagBuffer_fx[i][j] = imagBufferSave_fx[i][j];
- move32();
- move32();
- }
- }
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1
- st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 );
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
-#ifdef OPT_AVOID_STATE_BUF_RESCALE
- cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn );
-#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn );
- Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSynHB->Q_cldfb_state = Q10;
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
- }
- ELSE
- {
- /* synthesis of the combined signal */
- max_real = 0;
- max_imag = 0;
- move32();
- move32();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
- }
- }
- max_val = L_max( max_real, max_imag );
- Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- }
-#ifdef OPT_STEREO_32KBPS_V1
- scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
-#else /* OPT_STEREO_32KBPS_V1 */
- scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
-#endif /* OPT_STEREO_32KBPS_V1 */
- st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 );
- move16();
-
-#ifdef OPT_AVOID_STATE_BUF_RESCALE
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn );
-#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn );
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
- scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
- scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSyn->Q_cldfb_state = Q10;
- move16();
- }
-
- /* save synthesis - needed in case of core switching */
- Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0
- }
- ELSE
- {
- Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */
-
- /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */
- FOR( i = 0; i < st->L_frame; i++ )
- {
- syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) );
- move32();
- }
-
- Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12
- st->cldfbAna->Q_cldfb_state = Q12;
- move16();
- cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna );
-
- Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11
- st->cldfbAna->Q_cldfb_state = Q11;
- move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */
- Word32 tmp_bpf_error_signal_fx[L_FRAME16k];
- Word16 q_bpf_error_signal;
- Word16 cldfb_state_offset;
- cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels );
-
- // Get Q-factor
- q_bpf_error_signal = Q6;
- move16();
- Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0
- }
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6)
- st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal;
- move16();
- tmp = 0;
- move16();
- if ( !st->bpf_off )
- {
- tmp = nSamples;
- move16();
- }
- addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF );
-
-
- Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10
- st->cldfbBPF->Q_cldfb_state = Q10;
- move16();
- /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */
- max_real = 0;
- max_imag = 0;
- move32();
- move32();
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
- {
- max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) );
- max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) );
- }
- }
- max_val = L_max( max_real, max_imag );
- Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */;
- FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
- {
- scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real
- }
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
-#ifdef OPT_STEREO_32KBPS_V1
- scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1)
-#else /* OPT_STEREO_32KBPS_V1 */
- scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1)
-#endif /* OPT_STEREO_32KBPS_V1 */
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
-#ifdef OPT_AVOID_STATE_BUF_RESCALE
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn );
-#else /* OPT_AVOID_STATE_BUF_RESCALE */
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn );
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
-
-#ifndef OPT_AVOID_STATE_BUF_RESCALE
- Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0
- Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10
- st->cldfbSyn->Q_cldfb_state = Q10;
- move16();
-#endif /* OPT_AVOID_STATE_BUF_RESCALE */
- IF( st->p_bpf_noise_buf_32 )
- {
- Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1
- Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame );
-
- Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11
- }
-
- set32_fx( synth_fx, 0, output_frame );
- }
-
- /* Copy output signal */
- Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0
- IF( st->element_mode > EVS_MONO )
- {
- Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/
- }
-
- st->Q_syn2 = 0;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Bandwidth extension 6kHz-7kHz
- *-----------------------------------------------------------------*/
-
- IF( st->hBWE_zero != NULL )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) &&
- ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
- }
- ELSE
-#endif
- {
- Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0
- hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
- Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 );
- }
- }
- ELSE
- {
- hf_synth_reset_fx( st->hBWE_zero );
-#ifdef REMOVE_EVS_DUPLICATES
- IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment
-#endif
- {
- set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * Populate parameters for SWB TBE
- *-----------------------------------------------------------------*/
-
- IF( st->hBWE_TD != NULL )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET );
- }
-
- test();
- test();
- test();
- test();
- test();
- IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
- {
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
- }
- ELSE
-#endif
- {
- Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
- non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
- Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
- }
- }
-
- test();
- if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
- {
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- }
- }
-
- /*----------------------------------------------------------------------*
- * Updates
- *----------------------------------------------------------------------*/
-
- updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx );
-
- test();
- test();
- IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL )
- {
- /* update CNG parameters in active frames */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
- st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
- }
- ELSE
-#endif
- {
- cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size,
- st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode,
- st->hFdCngDec->hFdCngCom->CngBandwidth );
- }
-
- /* Set 16k LSP flag for CNG buffer */
- st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
- move16();
- if ( NE_16( st->L_frame, L_FRAME ) )
- {
- st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1;
- move16();
- }
- }
-
-#ifdef REMOVE_EVS_DUPLICATES
- IF( NE_16( st->element_mode, EVS_MONO ) )
-#endif
- {
- IF( save_hb_synth_fx16 )
- {
- Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0
- }
- Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2
- }
-
- pop_wmops();
- return error;
-}
diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c
index 6d3d0b381d267a6ab7cf897abbe95b921fb96043..363db82020cf81eefbdb2258c27eb77877faf380 100644
--- a/lib_dec/acelp_core_switch_dec_fx.c
+++ b/lib_dec/acelp_core_switch_dec_fx.c
@@ -128,11 +128,7 @@ ivas_error acelp_core_switch_dec_fx(
* Excitation decoding
*----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
-#else
- config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
-#endif
+ config_acelp1_fx( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 );
decod_gen_voic_core_switch_fx( st_fx, L_frame_for_cs, 0, Aq, exc, cbrate, &st_fx->Q_exc );
@@ -920,11 +916,7 @@ static void decod_gen_voic_core_switch_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- pitch = pit_decode_ivas_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/
-#else
- pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/
-#endif
+ pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/
/*--------------------------------------------------------------*
* Find the adaptive codebook vector.
diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c
index 971af2b56cd9494bb1da49c8da0bc59656773376..96ae82ddee71c1e6a9a0115bce5ce2e84dea8334 100644
--- a/lib_dec/amr_wb_dec_fx.c
+++ b/lib_dec/amr_wb_dec_fx.c
@@ -373,11 +373,7 @@ ivas_error amr_wb_dec_fx(
IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
{
/* decode CNG parameters */
-#ifdef REMOVE_EVS_DUPLICATES
- CNG_dec_ivas_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env );
-#else
CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env );
-#endif
/* comfort noise generation */
CNG_exc_fx( st_fx->core_brate, L_FRAME, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate,
@@ -630,15 +626,9 @@ ivas_error amr_wb_dec_fx(
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
- FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE,
- &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 );
-#else
FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE,
&st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate,
- exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 );
-#endif
+ exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 );
frame_ener_fx( L_FRAME, st_fx->clas_dec, syn_fx, pitch_buf_tmp[3], &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 );
}
@@ -717,17 +707,10 @@ ivas_error amr_wb_dec_fx(
* (smoothing is performed in the excitation domain and signal is resynthesized after)
*------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1,
- MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate,
- st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx,
- st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, 0, 0 );
-#else
FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1,
MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate,
st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx,
- st_fx->Q_exc, st_fx->Q_syn, 0, 0 );
-#endif
+ st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, 0, 0 );
/* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */
frame_ener_fx( L_FRAME, st_fx->last_good, syn_fx, shr( FEC_pitch_fx, 6 ), &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 );
@@ -785,11 +768,7 @@ ivas_error amr_wb_dec_fx(
st_fx->hPFstat->on = 1;
move16();
test();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 );
-#else
formant_post_filt_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 );
-#endif
}
/*----------------------------------------------------------------*
@@ -813,11 +792,9 @@ ivas_error amr_wb_dec_fx(
st_fx->VAD = 0;
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
- ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 );
-#else
- ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, NULL, NULL, st_fx, 0, 0 );
-#endif
+
+ ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 );
+
st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type;
move16();
diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c
index ce6ad65683a6cbb3e6a2ab5844fcfb94678c0f20..fdb6488db8232ce7f77edebb2a5ea5fbb61a84b6 100644
--- a/lib_dec/cng_dec_fx.c
+++ b/lib_dec/cng_dec_fx.c
@@ -22,19 +22,19 @@ static void shb_CNG_decod_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word
static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn );
/*-----------------------------------------------------------------*
+ * CNG_dec_fx()
+ *
* Decode residual signal energy
*-----------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
void CNG_dec_fx(
Decoder_State *st_fx, /* i/o: State structure */
- const Word16 last_element_mode, /* i : last element mode Q0 */
+ const Word16 last_element_mode, /* i : last element mode Q0 */
Word16 Aq[], /* o : LP coefficients Q12 */
Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
Word16 *allow_cn_step, /* o : allow CN step Q0 */
- Word16 *sid_bw /* i : 0-NB/WB, 1-SWB SID Q0 */
- ,
+ Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */
Word32 *q_env )
{
Word16 istep;
@@ -72,7 +72,6 @@ void CNG_dec_fx(
Word16 exp_pow;
Word16 tmp_loop;
Word16 enr_new, Aq_tmp[M + 1];
-
Word16 LSF_Q_prediction; /* o : LSF prediction mode - just temporary variable in CNG */
TD_CNG_DEC_HANDLE hTdCngDec;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
@@ -108,681 +107,9 @@ void CNG_dec_fx(
}
ELSE
{
- lsf_dec_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0,
- NULL );
- /* check IF LSPs may trigger too much synthesis energy */
-
- E_LPC_f_lsp_a_conversion( lsp_new, Aq_tmp, M );
- enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR );
-
- IF( shr( enr_new, 14 ) > 0 )
- {
- /* Use old LSP vector */
- Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */
- Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */
- }
- }
- }
- ELSE
- {
- /* Use old LSP vector */
- Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */
- Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */
- }
-
- /* Initialize the CNG spectral envelope in case of the very first CNG frame */
- IF( st_fx->first_CNG == 0 )
- {
- Copy( st_fx->lsp_old_fx, st_fx->lspCNG_fx, M ); /* Q15 */
- }
-
- /*-----------------------------------------------------------------*
- * Decode residual signal energy
- *-----------------------------------------------------------------*/
-
- *allow_cn_step = 0;
- move16();
- test();
- IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- istep = ISTEP_AMR_WB_SID_FX; /* Q15 */
- move16();
- if ( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- istep = ISTEP_SID_FX; /* Q15 */
- move16();
- }
-
- /* initialize the energy quantization parameters */
- num_bits = 6;
- move16();
- if ( st_fx->Opt_AMR_WB == 0 )
- {
- num_bits = 7;
- move16();
- }
-
- /* decode the energy index */
- L_enr_index = get_next_indice_fx( st_fx, num_bits );
-
- IF( LE_32( st_fx->last_core_brate, SID_2k40 ) || EQ_16( st_fx->prev_bfi, 1 ) )
- {
- tmp1 = add( hTdCngDec->old_enr_index, 20 );
- }
- ELSE
- {
- tmp1 = add( hTdCngDec->old_enr_index, 40 );
- }
- IF( GT_16( L_enr_index, tmp1 ) && hTdCngDec->old_enr_index >= 0 ) /* Likely bit error and not startup */
- {
- L_enr_index = tmp1;
- move16();
- L_enr_index = s_min( L_enr_index, 127 ); /* Q0 */
- IF( st_fx->Opt_AMR_WB )
- {
- L_enr_index = s_min( L_enr_index, 63 ); /* Q0 */
- }
- }
-
- test();
- test();
- test();
- IF( GT_32( st_fx->last_core_brate, SID_1k75 ) &&
- NE_16( st_fx->first_CNG, 0 ) &&
- GE_16( hTdCngDec->old_enr_index, 0 ) &&
- GT_16( L_enr_index, add( hTdCngDec->old_enr_index, 1 ) ) )
- {
- *allow_cn_step = 1;
- move16();
- }
-
- hTdCngDec->old_enr_index = L_enr_index;
- move16();
- if ( !L_enr_index )
- {
- L_enr_index = -5;
- move16();
- }
- /* st_fx->Enew = L_enr_index / step - 2.0f;*/
- L_ener = L_mult( L_enr_index, istep ); /* Q16 (0+15) */
- /* subtract by 2 not done to leave Energy in Q2 */
-
- /* extract integral and fractional parts */
- ener_fra = L_Extract_lc( L_ener, &ener_int );
- ener_int = add( ener_int, 4 ); /* Q2 to Q6 */
-
- /* find the new energy value */
- hTdCngDec->Enew_fx = Pow2( ener_int, ener_fra );
- move32();
-
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- burst_ho_cnt = get_next_indice_fx( st_fx, 3 ); /* 3bit */
-
- *sid_bw = get_next_indice_fx( st_fx, 1 );
- move16();
- IF( *sid_bw == 0 )
- {
- env_idx[0] = get_next_indice_fx( st_fx, 6 );
- move16();
-
- /* get quantized res_env_details */
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- q_env[i] = L_deposit_l( CNG_details_codebook_fx[env_idx[0]][i] );
- move32();
- }
- }
- }
- /* Reset CNG history IF CNG frame length is changed */
- test();
- test();
- IF( EQ_16( st_fx->bwidth, WB ) && NE_16( st_fx->first_CNG, 0 ) && NE_16( st_fx->L_frame, st_fx->last_CNG_L_frame ) )
- {
- hTdCngDec->ho_hist_size = 0;
- move16();
- }
- }
-
- /*---------------------------------------------------------------------*
- * CNG spectral envelope update
- * Find A(z) coefficients
- *---------------------------------------------------------------------*/
- test();
- test();
- test();
- IF( LE_32( st_fx->last_core_brate, SID_2k40 ) )
- {
- /* Reset hangover counter if not first SID period */
- if ( GT_32( st_fx->core_brate, FRAME_NO_DATA ) )
- {
- hTdCngDec->num_ho = 0;
- move16();
- }
- /* Update LSPs IF last SID energy not outliers or insufficient number of hangover frames */
- test();
- IF( LT_16( hTdCngDec->num_ho, 3 ) || LT_32( Mult_32_16( hTdCngDec->Enew_fx, 21845 /*1/1.5f, Q15*/ ), st_fx->lp_ener_fx ) )
- {
- FOR( i = 0; i < M; i++ )
- {
- /* AR low-pass filter */
- st_fx->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, st_fx->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] );
- move16(); /* Q15 (15+15+1-16) */
- }
- }
- }
- ELSE
- {
- /* Update CNG_mode IF allowed */
- test();
- test();
- test();
- IF( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !st_fx->first_CNG || GE_16( hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) )
- {
- IF( GT_32( st_fx->last_active_brate, ACELP_16k40 ) )
- {
- st_fx->CNG_mode = -1;
- move16();
- }
- ELSE
- {
- st_fx->CNG_mode = get_cng_mode( st_fx->last_active_brate );
- move16();
- }
- }
-
- /* If first sid after active burst update LSF history from circ buffer */
- burst_ho_cnt = s_min( burst_ho_cnt, hTdCngDec->ho_circ_size ); /* MODE1_DTX_IN_CODEC_B_FIX Q0*/
- hTdCngDec->act_cnt = 0;
- move16();
- s_ptr = add( sub( hTdCngDec->ho_circ_ptr, burst_ho_cnt ), 1 );
- IF( s_ptr < 0 )
- {
- s_ptr = add( s_ptr, hTdCngDec->ho_circ_size );
- }
-
- FOR( ll = burst_ho_cnt; ll > 0; ll-- )
- {
- hTdCngDec->ho_hist_ptr = add( hTdCngDec->ho_hist_ptr, 1 ); /* Q0 */
- move16();
- if ( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) )
- {
- hTdCngDec->ho_hist_ptr = 0;
- move16();
- }
-
- /* Conversion between 12.8k and 16k LSPs */
- test();
- test();
- test();
- IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) && hTdCngDec->ho_16k_lsp[s_ptr] == 0 ) || ( EQ_16( st_fx->L_frame, L_FRAME ) && EQ_16( hTdCngDec->ho_16k_lsp[s_ptr], 1 ) ) )
- {
- /* Conversion from 16k LPSs to 12k8 */
- lsp_convert_poly_fx( &( hTdCngDec->ho_lsp_circ_fx[s_ptr * M] ), st_fx->L_frame, 0 );
- }
- /* update the circular buffers */
- Copy( &( hTdCngDec->ho_lsp_circ_fx[s_ptr * M] ), &( hTdCngDec->ho_lsp_hist_fx[hTdCngDec->ho_hist_ptr * M] ), M ); /* Qx */
- Copy32( &( hTdCngDec->ho_ener_circ_fx[s_ptr] ), &( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] ), 1 ); /* Q6 */
- hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
- move32();
- Copy32( &( hTdCngDec->ho_env_circ_fx[s_ptr * NUM_ENV_CNG] ), &( hTdCngDec->ho_env_hist_fx[hTdCngDec->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG ); /* Qx */
-
- hTdCngDec->ho_hist_size = add( hTdCngDec->ho_hist_size, 1 );
- move16();
-
- if ( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) )
- {
- hTdCngDec->ho_hist_size = HO_HIST_SIZE;
- move16();
- }
-
- s_ptr = add( s_ptr, 1 );
- if ( EQ_16( s_ptr, hTdCngDec->ho_circ_size ) )
- {
- s_ptr = 0;
- move16();
- }
- }
-
- IF( hTdCngDec->ho_hist_size > 0 ) /* can be -1 at init MODE1_DTX_IN_CODEC_B_FIX */
- {
- /* *allow_cn_step |= ( st_fx->ho_ener_hist[st_fx->ho_hist_ptr] > 4.0f * st_fx->lp_ener );*/
- L_tmp1 = L_shr( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr], 2 );
- L_tmp1 = L_sub( L_tmp1, st_fx->lp_ener_fx );
+ lsf_dec_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0, NULL );
- test();
- test();
- IF( ( L_tmp1 > 0 && ( st_fx->first_CNG || st_fx->element_mode == EVS_MONO ) ) )
- {
- *allow_cn_step = s_or( *allow_cn_step, 1 );
- move16();
- }
- }
- IF( EQ_16( last_element_mode, IVAS_CPE_TD ) )
- {
- *allow_cn_step = 1;
- move16();
- }
- test();
- IF( EQ_16( *allow_cn_step, 0 ) && GT_16( hTdCngDec->ho_hist_size, 0 ) )
- {
- /* Use average of energies below last energy */
- ptr = hTdCngDec->ho_hist_ptr;
- move16();
- Copy( &( hTdCngDec->ho_lsp_hist_fx[ptr * M] ), tmp, M ); /* Qx */
- m1 = 0;
- move16();
- IF( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x1 ) == 0 )
- {
- Copy32( &hTdCngDec->ho_env_hist_fx[ptr * NUM_ENV_CNG], tmp_env, NUM_ENV_CNG );
- m1 = 1;
- move16();
- }
- L_enr = Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */
-
- weights = W_DTX_HO_FX[0]; /* Q15 */
- move16();
-
- m = 1;
- move16();
- FOR( k = 1; k < hTdCngDec->ho_hist_size; k++ )
- {
- ptr--;
- if ( ptr < 0 )
- {
- ptr = HO_HIST_SIZE - 1;
- move16();
- }
-
- test();
- IF( LT_32( Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], ONE_OVER_BUF_H_NRG_FX ), hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] ) &&
- GT_32( hTdCngDec->ho_ener_hist_fx[ptr], Mult_32_16( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr], BUF_L_NRG_FX ) ) )
- {
- /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr];*/
- L_tmp1 = Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], W_DTX_HO_FX[k] ); /* Q6+15-15->Q6 */
- L_enr = L_add( L_enr, L_tmp1 ); /* Q6 */
-
- /*weights += W_DTX_HO[k];*/
- weights = add( weights, W_DTX_HO_FX[k] ); /* Q15 */
-
- Copy( &hTdCngDec->ho_lsp_hist_fx[ptr * M], &tmp[m * M], M ); /* Qx */
- IF( EQ_32( L_and( hTdCngDec->ho_sid_bw, L_shl( (Word32) 0x1, k ) ), 0 ) )
- {
- Copy32( &hTdCngDec->ho_env_hist_fx[ptr * NUM_ENV_CNG], &tmp_env[m1 * NUM_ENV_CNG], NUM_ENV_CNG ); /* Qx */
- m1++;
- }
- m++;
- }
- }
-
- /*enr /= weights;*/
- exp = norm_s( weights );
- tmp1 = div_s( shl( 1, sub( 14, exp ) ), weights ); /* Q(15+14-exp-15) */
- L_tmp1 = Mult_32_16( L_enr, tmp1 ); /* Q(14-exp+6-15)->Q(5-exp) */
- L_enr = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */
-
- st_fx->lp_ener_fx = L_enr; /* Q6 */
- move32();
- set32_fx( max_val, 0, 2 );
- set16_fx( max_idx, 0, 2 );
-
- FOR( i = 0; i < m; i++ )
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964;
- move16(); /*X2.56 */
- tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56*/
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536*/
- }
- ELSE
- {
- lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k_FX );
- ftmp_fx = 1205;
- move16(); /*QX2.56*/
- tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56*/
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536*/
- }
-
- tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56*/
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/
- FOR( j = 0; j < M - 1; j++ )
- {
- tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56*/
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/
- }
-
- C[i] = Mpy_32_16_1( L_tmp, 1928 ); /*QX6.5536*/
- move32();
-
- IF( GT_32( C[i], max_val[0] ) )
- {
- max_val[1] = max_val[0];
- move32();
- max_idx[1] = max_idx[0];
- move16();
- max_val[0] = C[i];
- move32();
- max_idx[0] = i;
- move16();
- }
- ELSE IF( GT_32( C[i], max_val[1] ) )
- {
- max_val[1] = C[i];
- move32();
- max_idx[1] = i;
- move16();
- }
- }
-
- IF( EQ_16( m, 1 ) )
- {
- Copy( tmp, lsp_tmp, M ); /* Qx */
- }
- ELSE IF( LT_16( m, 4 ) )
- {
- FOR( i = 0; i < M; i++ )
- {
- L_tmp1 = 0;
- move32();
- FOR( j = 0; j < m; j++ )
- {
- L_tmp1 = L_add( L_tmp1, L_deposit_l( tmp[j * M + i] ) );
- }
-
- L_tmp1 = L_sub( L_tmp1, L_deposit_l( tmp[max_idx[0] * M + i] ) );
- tmpv = div_s( 1, sub( m, 1 ) ); /*Q15*/
- L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/
- lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/
- move16();
- }
- }
- ELSE
- {
- FOR( i = 0; i < M; i++ )
- {
- L_tmp1 = 0;
- move32();
- FOR( j = 0; j < m; j++ )
- {
- L_tmp1 = L_add( L_tmp1, L_deposit_l( tmp[j * M + i] ) );
- }
-
- L_tmp1 = L_sub( L_tmp1, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15*/
- tmpv = div_s( 1, sub( m, 2 ) ); /*Q15*/
- L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/
- lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/
- move16();
- }
- }
-
- dist = 0;
- move16(); /*Q15*/
- max_dev = 0;
- move16(); /*Q15*/
- FOR( i = 0; i < M; i++ )
- {
- dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15*/
- dist = add_o( dist, dev, &Overflow ); /*Q15*/
- if ( GT_16( dev, max_dev ) )
- {
- max_dev = dev;
- move16();
- }
- }
-
- test();
- IF( GT_16( dist, 13107 ) || GT_16( max_dev, 3277 ) ) /* 0.4 and 0.1 in Q15 */
- {
- FOR( i = 0; i < M; i++ )
- {
- st_fx->lspCNG_fx[i] = lsp_tmp[i];
- move16(); /*Q15*/
- }
- }
- ELSE
- {
- FOR( i = 0; i < M; i++ )
- {
- /* AR low-pass filter */
- st_fx->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) ); /* Q15 */
- move16();
- }
- }
- IF( m1 > 0 )
- {
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- L_tmp = L_deposit_l( 0 );
- FOR( j = 0; j < m1; j++ )
- {
- /* env[i] += tmp_env[j*NUM_ENV_CNG+i];*/
- L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] );
- }
- /* env[i] /= (float)m1; */
- /* env[i] = env[i] - 2*st_fx->lp_ener_fx; */
- IF( EQ_16( m1, 1 ) )
- {
- L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */
- }
- ELSE
- {
- tmp1 = div_s( 1, m1 );
- L_tmp = Mult_32_16( L_tmp, tmp1 ); /* Q6 */
- L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */
- }
- env[i] = L_tmp; /* Q6 */
- move32();
- }
-
- Copy32( env, hTdCngDec->lp_env_fx, NUM_ENV_CNG ); /* Q6 */
- }
- }
- ELSE
- {
- Copy( lsp_new, st_fx->lspCNG_fx, M ); /* use newly analyzed ISFs */ /* Q15 */
- }
- }
-
- test();
- IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* Update hangover memory during CNG */
- test();
- IF( ( *allow_cn_step == 0 ) && LT_32( hTdCngDec->Enew_fx, L_add_sat( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) )
- {
- /* update the pointer to circular buffer of old LSP vectors */
- hTdCngDec->ho_hist_ptr++;
- move16();
- if ( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) )
- {
- hTdCngDec->ho_hist_ptr = 0;
- move16();
- }
-
- /* update the circular buffer of old LSP vectors with the new LSP vector */
- Copy( lsp_new, &( hTdCngDec->ho_lsp_hist_fx[( hTdCngDec->ho_hist_ptr ) * M] ), M ); /* Q15 */
-
- /* update the hangover energy buffer */
- hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] = hTdCngDec->Enew_fx; /* Q6 */
- move32();
- test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) && ( *sid_bw == 0 ) )
- {
- /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/
- exp = norm_l( hTdCngDec->Enew_fx );
- L_tmp = L_shl( hTdCngDec->Enew_fx, exp ); /*Q(exp+6)*/
- L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /*Q(exp+6+5-15=exp-4)*/
- L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /*Q6*/
- exp = norm_l( L_tmp );
- fra = Log2_norm_lc( L_shl( L_tmp, exp ) );
- exp = sub( sub( 30, exp ), 6 );
- L_tmp = L_Comp( exp, fra );
- enr1 = L_shr( L_tmp, 10 ); /* Q6 */
-
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- /* get quantized envelope */
- /* env[i] = pow(2.0f,(enr1 - q_env[i])) + 2*st->Enew;*/
- L_tmp = L_sub( enr1, q_env[i] ); /* Q6 */
- L_tmp = L_shl( L_tmp, 10 ); /* 16 */
- temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx );
-
- exp_pow = sub( 14, temp_hi_fx );
- L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */
- env[i] = L_shl( L_tmp, sub( 6, exp_pow ) ); /* Q6 */
- move32();
- L_tmp = L_add( hTdCngDec->Enew_fx, hTdCngDec->Enew_fx );
- env[i] = L_add( env[i], L_tmp ); /* Q6 */
- move32();
- }
- hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); /* Q0 */
- move32();
- Copy32( env, &( hTdCngDec->ho_env_hist_fx[hTdCngDec->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG ); /* Q6 */
- }
- ELSE IF( ( *sid_bw != 0 ) )
- {
- hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); /* Q0 */
- move32();
- hTdCngDec->ho_sid_bw = L_or( hTdCngDec->ho_sid_bw, 0x1L ); /* Q0 */
- move32();
- }
-
- hTdCngDec->ho_hist_size = add( hTdCngDec->ho_hist_size, 1 );
- move16();
- if ( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) )
- {
- hTdCngDec->ho_hist_size = HO_HIST_SIZE;
- move16();
- }
- }
- /* Update the frame length memory */
- st_fx->last_CNG_L_frame = st_fx->L_frame;
- move16();
-
- if ( NE_32( st_fx->core_brate, SID_1k75 ) )
- {
- hTdCngDec->num_ho = m;
- move16();
- }
- }
-
- IF( st_fx->element_mode == EVS_MONO )
- {
- st_fx->last_CNG_L_frame = st_fx->L_frame;
- move16();
-
- IF( NE_32( st_fx->core_brate, SID_1k75 ) )
- {
- hTdCngDec->num_ho = m;
- move16();
- }
- }
- IF( st_fx->Opt_AMR_WB )
- {
- E_LPC_f_isp_a_conversion( st_fx->lspCNG_fx, Aq, M );
- }
- ELSE
- {
- E_LPC_f_lsp_a_conversion( st_fx->lspCNG_fx, Aq, M );
- }
-
- tmp_loop = shr( st_fx->L_frame, 6 );
- FOR( i = 1; i < tmp_loop; i++ ) /* L_frame/L_SUBFR */
- {
- Copy( Aq, &Aq[i * ( M + 1 )], add( M, 1 ) ); /* Q12 */
- }
-
- return;
-}
-#endif
-void CNG_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 last_element_mode, /* i : last element mode Q0 */
- Word16 Aq[], /* o : LP coefficients Q12 */
- Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
- Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
- Word16 *allow_cn_step, /* o : allow CN step Q0 */
- Word16 *sid_bw /* i : 0-NB/WB, 1-SWB SID Q0 */
- ,
- Word32 *q_env )
-{
- Word16 istep;
- Word16 i, L_enr_index;
- Word32 L_ener;
- Word16 ener_fra, ener_int;
- Word16 num_bits;
- Word16 weights, ptr, j, k;
- Word16 m1;
- Word16 m = 0;
- move16();
- Word16 tmp[HO_HIST_SIZE * M];
- Word16 burst_ho_cnt = 0;
- move16();
- Word16 ll, s_ptr;
- Word32 L_enr, L_tmp1;
- Word16 tmp1, exp;
- Word16 lsf_tmp[M];
- Word32 C[M];
- Word32 max_val[2];
- Word16 max_idx[2];
- Word16 ftmp_fx;
- Word16 lsp_tmp[M];
- Word16 dev;
- Word16 max_dev;
- Word16 dist;
- Word16 tmpv;
- Word16 env_idx[2];
- Word32 enr1;
- Word32 env[NUM_ENV_CNG];
- Word32 tmp_env[HO_HIST_SIZE * NUM_ENV_CNG];
- Word32 L_tmp;
- Word16 fra;
- Word16 temp_lo_fx, temp_hi_fx;
- Word16 exp_pow;
- Word16 tmp_loop;
- Word16 enr_new, Aq_tmp[M + 1];
-
- Word16 LSF_Q_prediction; /* o : LSF prediction mode - just temporary variable in CNG */
- TD_CNG_DEC_HANDLE hTdCngDec;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
- hTdCngDec = st_fx->hTdCngDec;
-
- m = 0;
- move16();
- /*-----------------------------------------------------------------*
- * Decode CNG spectral envelope (only in SID frame)
- *-----------------------------------------------------------------*/
- test();
- IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* de-quantize the LSF vector */
- IF( st_fx->Opt_AMR_WB != 0 )
- {
- /* Flt function */
- isf_dec_amr_wb_fx( st_fx, Aq, lsf_new, lsp_new );
- /* check IF ISPs may trigger too much synthesis energy */
-
- E_LPC_f_isp_a_conversion( lsp_new, Aq_tmp, M );
- enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR );
-
- IF( ( shr( enr_new, 14 ) > 0 ) )
- {
- /* Use old LSP vector */
- Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */
- Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */
- }
- }
- ELSE
- {
- lsf_dec_ivas_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0,
- NULL );
/* check IF LSPs may trigger too much synthesis energy */
-
E_LPC_f_lsp_a_conversion( lsp_new, Aq_tmp, M );
enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR );
diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c
index c04ee9dc5082eef864b4dfec58ea16d9cbf18ed3..b638a36e55bbc3de081e4667c74e8cc8c5be9b66 100644
--- a/lib_dec/dec_LPD_fx.c
+++ b/lib_dec/dec_LPD_fx.c
@@ -556,11 +556,7 @@ void decoder_LPD_fx(
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
-#else
- int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
-#endif
}
ELSE
{
diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c
index ad89ca55681d4cf0e62f3f8d45501c6a256cb241..9c366e3f3190c2138e9940a69e30a447609a0d1f 100644
--- a/lib_dec/dec_ace_fx.c
+++ b/lib_dec/dec_ace_fx.c
@@ -532,27 +532,24 @@ void decoder_acelp_fx(
move16();
IF( st->igf != 0 )
{
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc,
- gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 );
-#else
- prep_tbe_exc_fx( st->L_frame,
- i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc,
- gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate );
-#endif
+ prep_tbe_exc_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc,
+ gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 );
}
/*---------------------------------------------------------*
* Enhance the excitation *
*---------------------------------------------------------*/
+
E_UTIL_enhancer( st->voice_fac, stab_fac, st->past_gcode, gain_inov, &( st->gc_threshold_fx ), code, &exc2[i_subfr],
gain_pit, &st->dm_fx.prev_gain_code, st->dm_fx.prev_gain_pit, &st->dm_fx.prev_state, st->coder_type,
acelp_cfg.fixed_cdk_index[idx], L_SUBFR, st->L_frame, st->Q_exc );
} /* !RF_NELP frame partial copy */
+
/*----------------------------------------------------------*
* - compute the synthesis speech *
*----------------------------------------------------------*/
+
rescale_mem( &st->Q_exc, &prev_Q_syn, &st->Q_syn, mem_syn, syn, M, i_subfr );
E_UTIL_synthesis( sub( st->Q_exc, st->Q_syn ), p_A, &exc2[i_subfr], &syn[i_subfr], L_SUBFR, mem_syn, 1, M );
@@ -678,16 +675,11 @@ void decoder_acelp_fx(
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
- FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0,
- st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
- exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, force_scale_syn );
-#else
FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0,
st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
- exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, force_scale_syn );
-#endif
+ exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, force_scale_syn );
}
+
/* update ACELP synthesis memory */
Copy( mem_syn, st->mem_syn2_fx, M );
Copy( syn + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM );
diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c
index b03b6d69ce178133505548a585ae5cdb7f18cd9c..500fe34bab921a2c385caf751d34616d63e0045f 100644
--- a/lib_dec/dec_amr_wb_fx.c
+++ b/lib_dec/dec_amr_wb_fx.c
@@ -71,11 +71,7 @@ void decod_amr_wb_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- *pt_pitch_fx = pit_decode_ivas_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL );
-#else
- *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR );
-#endif
+ *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL );
/*--------------------------------------------------------------*
* Find the adaptive codebook vector
diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c
index 7411d59f208638edf6ce07eaec052efb33052555..3e42d953561ca8a04f7ffddc2076c6560c30bf1a 100644
--- a/lib_dec/dec_gen_voic_fx.c
+++ b/lib_dec/dec_gen_voic_fx.c
@@ -18,8 +18,7 @@
/*----------------------------------------------------------------------*/
/* GLOBAL INPUT ARGUMENTS : */
/* _ (Struct) st_fx : decoder static memory */
-/* _ (Word16) L_frame : length of the frame */
-
+/* _ (Word16) L_frame : length of the frame */
/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */
/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */
/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/
@@ -29,503 +28,30 @@
/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
/*----------------------------------------------------------------------*/
-
-
/*----------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*======================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
ivas_error decod_gen_voic_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 sharpFlag_fx, /* i : formant sharpening flag */
- const Word16 *Aq_fx, /* i : LP filter coefficient Q12 */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */
- const Word16 do_WI_fx, /* i : do interpolation after a FER */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6 */
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */
- Word16 *unbits, /* number of unused bits */
- Word16 *gain_buf /*Q14*/
-)
-{
-
-
- Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
- Word16 gain_pit_fx = 0; /* pitch gain Q14 */
- move16();
- Word32 gain_code_fx = 0; /* gain/normalized gain of the algebraic excitation Q16 */
- move32();
- Word32 norm_gain_code_fx = 0; /* normalized gain of the algebraic excitation Q16 */
- move32();
- Word16 gain_inov_fx = 0; /* Innovation gain Q12 */
- move16();
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */
- Word16 voice_fac_fx; /* voicing factor Q15 */
- Word16 code_fx[L_SUBFR]; /* algebraic codevector Q12 */
-
- const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
- Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */
- Word16 i_subfr_fx, i; /* tmp variables */
- Word16 error_fx = 0;
- move16();
- Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
- move16();
- Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
- Word32 norm_gain_preQ_fx;
- Word16 pitch_limit_flag_fx;
-
- Word16 tmp1_fx, gain_code16;
- Word32 L_tmp_GC;
- Word32 L_tmp;
-
- Word16 harm_flag_acelp;
-
- Word16 shft_prev, ph_offset_fx;
- Word32 prev_res_nrg;
- Word32 prev_spch_nrg;
- Word32 curr_res_nrg;
- Word32 curr_spch_nrg;
- Word16 rint_bfi_pitch, rint_pitch;
- Word16 fraca, fracb, expa, expb, scale, exp1;
- Word16 *p_exc;
- Word16 mem_tmp_fx[M];
- Word16 syn_tmp_fx[L_FRAME16k];
- Word16 shft_curr;
- Word16 *p_syn;
- Word16 sp_enratio, Qsp_enratio;
- Word16 enratio, Qenratio;
- DTFS_STRUCTURE *PREVP, *CURRP;
- Word16 S_fx[PIT_MAX * 4 + 1], C_fx[PIT_MAX * 4 + 1];
- Word16 dummy2[2];
- Word16 out_fx[L_FRAME16k];
-
- Word16 pf_temp1[MAXLAG_WI]; /*may not need more than MAXLAG_WI/2+1 */
- Word16 pf_temp2[MAXLAG_WI];
- Word16 pf_temp[MAXLAG_WI];
- Word16 pf_n2[MAXLAG_WI];
- MUSIC_POSTFILT_HANDLE hMusicPF;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move32();
-#endif
-
- hMusicPF = st_fx->hMusicPF;
-
- GSC_DEC_HANDLE hGSCDec;
- hGSCDec = st_fx->hGSCDec;
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move32();
-
- T0_fx = PIT_MIN;
- move16();
- T0_frac_fx = 0;
- move16();
-
- /* read harmonicity flag */
- harm_flag_acelp = 0;
- move16();
- test();
- test();
- IF( ( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) ) && EQ_16( st_fx->coder_type, GENERIC ) )
- {
- harm_flag_acelp = (Word16) get_next_indice( st_fx, 1 );
- }
-
- /*------------------------------------------------------------------*
- * ACELP subframe loop
- *------------------------------------------------------------------*/
-
- p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */
- pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */
- norm_gain_preQ_fx = 0;
- move32();
- gain_preQ_fx = 0;
- move16();
- set16_fx( code_preQ_fx, 0, L_SUBFR );
-
- FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR )
- {
- /*----------------------------------------------------------------------*
- * Decode pitch lag
- *----------------------------------------------------------------------*/
-
- *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx,
- &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR );
- move16(); /*Q6*/
-
- /*--------------------------------------------------------------*
- * Find the adaptive codebook vector
- *--------------------------------------------------------------*/
-
- pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx );
-
- /*--------------------------------------------------------------*
- * LP filtering of the adaptive excitation
- *--------------------------------------------------------------*/
- lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr_fx, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc_fx );
- /*-----------------------------------------------------------------*
- * Transform-domain contribution decoding (active frames)
- *-----------------------------------------------------------------*/
-
- test();
- IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && ( st_fx->coder_type != INACTIVE ) )
- {
- gain_code_fx = 0;
- move16();
- transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits );
- }
-
- /*--------------------------------------------------------------*
- * Innovation decoding
- *--------------------------------------------------------------*/
-
- inov_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, sharpFlag_fx, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_SUBFR );
-
- /*--------------------------------------------------------------*
- * Gain decoding
- * Estimate spectrum tilt and voicing
- *--------------------------------------------------------------*/
-
- IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
- {
- gain_dec_lbr_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR );
- }
- ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
- {
- gain_dec_SQ_fx( st_fx, i_subfr_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- }
- ELSE
- {
- gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- }
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); // Q15
- move16();
-
- /*-----------------------------------------------------------------*
- * Transform domain contribution decoding
- *-----------------------------------------------------------------*/
- test();
- IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) && ( st_fx->coder_type == INACTIVE ) )
- {
- transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits );
- }
-
- /* update LP filtered gains for the case of frame erasures */
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
-
- /*----------------------------------------------------------------------*
- * Find the total excitation
- *----------------------------------------------------------------------*/
-
- IF( EQ_16( L_frame, L_FRAME ) ) /* Rescaling for 12.8k core */
- {
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * HIBND_ACB_L_FAC], hGSCDec->last_exc_dct_in_fx,
- L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type );
- }
- ELSE /* Rescaling for 16k core */
- {
-
- L_tmp_GC = L_max( gain_code_fx, L_shl( gain_preQ_fx, 16 ) ); /* Chose the maximum of gain_code or the prequantizer excitation x4 to keep some room*/
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * 2], hGSCDec->last_exc_dct_in_fx,
- L_SUBFR, L_SUBFR * 2, L_tmp_GC, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type );
- }
-
- gain_code16 = round_fx( L_shl( gain_code_fx, st_fx->Q_exc ) ); /*Q_exc*/
-
- /*-----------------------------------------------------------------*
- * Add the ACELP pre-quantizer contribution
- *-----------------------------------------------------------------*/
-
- IF( gain_preQ_fx != 0 )
- {
- IF( st_fx->element_mode == EVS_MONO )
- {
- tmp1_fx = add( 15 - Q_AVQ_OUT_DEC - 2, st_fx->Q_exc );
- }
- ELSE
- {
- tmp1_fx = add( 15 - Q_AVQ_OUT - 2, st_fx->Q_exc );
- }
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- Word32 Ltmp1;
- /* Contribution from AVQ layer */
- Ltmp1 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/
- Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */
-
- /* Compute exc2 */
- L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); // Q_exc+Q14+1+1
- exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); // Q_exc
- move16();
- /* gain_pit in Q14 */
- L_tmp = L_mult( gain_code16, code_fx[i] ); // Q_exc+Q9+1
- L_tmp = L_shl_sat( L_tmp, 5 ); // Q_exc+Q9+1+5
- L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); // Q_exc+Q15 +1
- L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
-
- exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); // Q_exc
- move16();
- }
- }
- ELSE
- {
- Acelp_dec_total_exc( exc_fx, exc2_fx, gain_code16, gain_pit_fx, i_subfr_fx, code_fx, L_SUBFR );
- }
-
- /*-----------------------------------------------------------------*
- * Prepare TBE excitation
- *-----------------------------------------------------------------*/
-
- Word16 idx = 0;
- move16();
- IF( i_subfr_fx != 0 )
- {
- idx = idiv1616( i_subfr_fx, L_SUBFR );
- }
-
- prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate );
-
-
- /*----------------------------------------------------------------*
- * Excitation enhancements (update of total excitation signal)
- *----------------------------------------------------------------*/
-
- test();
- IF( GT_32( st_fx->core_brate, ACELP_32k ) || ( st_fx->coder_type == INACTIVE ) )
- {
- Copy( exc_fx + i_subfr_fx, exc2_fx + i_subfr_fx, L_SUBFR );
- }
- ELSE
- {
- enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx,
- norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
- }
-
- p_Aq_fx += ( M + 1 );
- pt_pitch_fx++;
- gain_buf[idx] = gain_pit_fx; // Q14
- move16();
- }
-
- /* FEC fast recovery */
-
- IF( do_WI_fx )
- {
- /* shft_prev = L_EXC_MEM - rint_new_fx(st_fx->bfi_pitch_fx);*/
- L_tmp = L_shl( L_deposit_l( st_fx->bfi_pitch_fx ), 10 ); /*Q16*/
- rint_bfi_pitch = rint_new_fx( L_tmp ); /*Q0*/
- shft_prev = sub( L_EXC_MEM, rint_bfi_pitch ); /*Q0*/
-
- p_exc = st_fx->hWIDec->old_exc2_fx + shft_prev;
- p_syn = st_fx->hWIDec->old_syn2_fx + shft_prev;
- move16();
- move16();
-
- prev_res_nrg = L_deposit_l( 1 );
- prev_spch_nrg = L_deposit_l( 1 );
- FOR( i = 0; i < rint_bfi_pitch; i++ )
- {
- prev_res_nrg = L_mac0_sat( prev_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->prev_Q_exc_fr */
- prev_spch_nrg = L_mac0_sat( prev_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->prev_Q_syn_fr */
- p_exc++;
- p_syn++;
- }
-
- Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M );
-
- syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_tmp_fx, mem_tmp_fx, 1, st_fx->Q_exc, st_fx->Q_syn );
-
- L_tmp = L_shl( L_deposit_l( pitch_buf_fx[NB_SUBFR16k - 1] ), 10 ); /*Q16*/
- rint_pitch = rint_new_fx( L_tmp ); /*Q0*/
- shft_curr = sub( st_fx->L_frame, rint_pitch ); /*Q0*/
-
- p_exc = exc2_fx + shft_curr;
- p_syn = syn_tmp_fx + shft_curr;
-
- curr_res_nrg = L_deposit_l( 1 );
- curr_spch_nrg = L_deposit_l( 1 );
- FOR( i = 0; i < rint_pitch; i++ )
- {
- curr_res_nrg = L_mac0_sat( curr_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->Q_exc */
- curr_spch_nrg = L_mac0_sat( curr_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->Q_syn */
- p_exc++;
- p_syn++;
- }
-
- /* enratio = (curr_res_nrg / prev_res_nrg); */
- IF( prev_res_nrg > 0 )
- {
- expa = norm_l( prev_res_nrg );
- fraca = extract_h( L_shl( prev_res_nrg, expa ) ); /* 2*st_fx->prev_Q_exc_fr -16+expa +1*/
- expa = sub( 30, add( expa, ( shl( st_fx->prev_Q_exc_fr, 1 ) ) ) );
-
- expb = norm_l( curr_res_nrg );
- fracb = round_fx_sat( L_shl_sat( curr_res_nrg, expb ) ); /* 2*st_fx->Q_exc +expb+1 -16*/
- expb = sub( 30, add( expb, shl( st_fx->Q_exc, 1 ) ) );
-
- scale = shr( sub( fraca, fracb ), 15 );
- fracb = shl( fracb, scale ); // Q(15-expb)+scale
- expb = sub( expb, scale );
-
- enratio = div_s( fracb, fraca ); // Q(15-(expb-expa))
- exp1 = sub( expb, expa );
- Qenratio = sub( 15, exp1 );
- }
- ELSE
- {
- enratio = 0;
- move16();
- Qenratio = 0;
- move16();
- }
-
- /* sp_enratio = curr_spch_nrg/prev_spch_nrg */
- IF( prev_spch_nrg > 0 )
- {
- expa = norm_l( prev_spch_nrg );
- fraca = extract_h( L_shl( prev_spch_nrg, expa ) ); /* 2*st_fx->prev_Q_syn_fr +expa+1-16*/
- expa = sub( 30, add( expa, shl( st_fx->prev_Q_syn_fr, 1 ) ) );
-
- expb = norm_l( curr_spch_nrg );
- fracb = round_fx_sat( L_shl_sat( curr_spch_nrg, expb ) ); /* 2*st_fx->Q_syn +expb-16 */
- expb = sub( 30, add( expb, shl( st_fx->Q_syn, 1 ) ) );
-
- scale = shr( sub( fraca, fracb ), 15 );
- fracb = shl( fracb, scale ); // Q(15-expb) +scale
- expb = sub( expb, scale );
-
- sp_enratio = div_s( fracb, fraca ); // Q(15-(expb-expa))
- exp1 = sub( expb, expa );
- Qsp_enratio = sub( 15, exp1 );
- }
- ELSE
- {
- sp_enratio = 0;
- move16();
- Qsp_enratio = 0;
- move16();
- }
-
- test();
- test();
- test();
- test();
- IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/
- LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/
- GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/
- LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/
- LT_16( pitch_buf_fx[NB_SUBFR16k - 1], 9600 ) ) /*Q6*/
- {
- IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = DTFS_new_fx( &CURRP ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- GetSinCosTab_fx( rint_bfi_pitch, S_fx, C_fx );
- DTFS_to_fs_fx( st_fx->hWIDec->old_exc2_fx + shft_prev, rint_bfi_pitch, PREVP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx );
- PREVP->Q = add( PREVP->Q, st_fx->prev_Q_exc_fr );
- move16();
-
- GetSinCosTab_fx( rint_pitch, S_fx, C_fx );
- DTFS_to_fs_fx( exc2_fx + shft_curr, rint_pitch, CURRP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx );
- CURRP->Q = add( CURRP->Q, st_fx->Q_exc );
- move16();
-
- ph_offset_fx = 0;
- move16();
- IF( NE_32( ( error = WIsyn_fx( *PREVP, CURRP, dummy2, &( ph_offset_fx ), out_fx, (Word16) st_fx->L_frame, 1, S_fx, C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
-
- Copy_Scale_sig( out_fx, exc2_fx, st_fx->L_frame, st_fx->Q_exc ); // Q_exc
- Copy_Scale_sig( out_fx, exc_fx, st_fx->L_frame, st_fx->Q_exc ); // Q_exc
-
- /* update bwe_exc for SWB-TBE */
- FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR )
- {
- interp_code_4over2_fx( exc_fx + i_subfr_fx, bwe_exc_fx + shl( i_subfr_fx, 1 ), L_SUBFR );
- }
-
- free( PREVP );
- free( CURRP );
- }
- }
-
- /* SC-VBR */
- st_fx->prev_gain_pit_dec_fx = gain_pit_fx;
- move16(); /*Q14*/
- st_fx->prev_tilt_code_dec_fx = st_fx->tilt_code_fx;
- move16(); /*Q15*/
-
- return error;
-}
-
-/*======================================================================*/
-/* FUNCTION : decod_gen_voic_ivas_fx() */
-/*----------------------------------------------------------------------*/
-/* PURPOSE : Decode generic (GC), voiced (VC) and AMR-WB IO frames */
-/* */
-/*----------------------------------------------------------------------*/
-/* GLOBAL INPUT ARGUMENTS : */
-/* _ (Struct) st_fx : decoder static memory */
-/* _ (Word16) L_frame : length of the frame */
-
-/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */
-/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */
-/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/
-/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */
-/*----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
-/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
-/*----------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*======================================================================*/
-#endif
-ivas_error decod_gen_voic_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 sharpFlag_fx, /* i : formant sharpening flag */
- const Word16 *Aq_fx, /* i : LP filter coefficient Q12*/
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */
- const Word16 do_WI_fx, /* i : do interpolation after a FER */
- Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe Q6*/
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */
- Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */
- Word16 *unbits, /* number of unused bits */
- Word16 *gain_buf,
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 sharpFlag_fx, /* i : formant sharpening flag */
+ const Word16 *Aq_fx, /* i : LP filter coefficient Q12 */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */
+ const Word16 do_WI_fx, /* i : do interpolation after a FER */
+ Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe Q6 */
+ Word16 *voice_factors_fx, /* o : voicing factors Q15 */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */
+ Word16 *unbits, /* number of unused bits */
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14 */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
+ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
)
{
-
-
- Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
+ Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
Word16 gain_pit_fx; /* pitch gain Q14 */
Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */
Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */
@@ -536,7 +62,7 @@ ivas_error decod_gen_voic_ivas_fx(
Word16 code_fx[L_SUBFR]; /* algebraic codevector Q12 */
const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
- Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */
+ Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */
Word16 i_subfr_fx, i; /* tmp variables */
Word16 error_fx;
Word16 gain_preQ_fx; /* Gain of prequantizer excitation */
@@ -633,10 +159,8 @@ ivas_error decod_gen_voic_ivas_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
- /**pt_pitch_fx = pit_decode_fx(st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx,
- &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR);*/
- *pt_pitch_fx = pit_decode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx,
- &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx,
+ &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
move16(); /*Q6*/
/*--------------------------------------------------------------*
@@ -677,7 +201,7 @@ ivas_error decod_gen_voic_ivas_fx(
IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
{
- gain_dec_lbr_ivas_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR );
+ gain_dec_lbr_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR );
}
ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
{
@@ -700,13 +224,11 @@ ivas_error decod_gen_voic_ivas_fx(
}
/* update LP filtered gains for the case of frame erasures */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
}
ELSE
-#endif
{
lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
}
@@ -790,10 +312,6 @@ ivas_error decod_gen_voic_ivas_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- /*prep_tbe_exc_fx(L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate);*/
-
Word16 idx;
idx = 0;
move16();
@@ -802,10 +320,10 @@ ivas_error decod_gen_voic_ivas_fx(
idx = idiv1616( i_subfr_fx, L_SUBFR );
}
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
+ &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
+ st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*----------------------------------------------------------------*
@@ -819,14 +337,12 @@ ivas_error decod_gen_voic_ivas_fx(
}
ELSE
{
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx,
norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
}
ELSE
-#endif
{
enhancer_ivas_fx2( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx,
norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c
index fe7d2daafc2174eaadae31ab929f3b1e57b176fa..a18029cdccfe8bb1a5a2c0bd01a939c414b1adc9 100644
--- a/lib_dec/dec_pit_exc_fx.c
+++ b/lib_dec/dec_pit_exc_fx.c
@@ -14,13 +14,13 @@
/*--------------------------------------------------------------------------*/
/* INPUT ARGUMENTS : */
/* _ (Word16*) Aq_fx : LP filter coefficient Q12 */
-/* _ (Word16) coder_type : coding type Q0 */
+/* _ (Word16) coder_type : coding type Q0 */
/* _ (Word16) nb_subfr_fx :Number of subframe considered */
/* _ (Word16) Es_pred_fx :predicted scaled innov. energy */
/*--------------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/* _ (Word16*) pitch_buf_fx : floating pitch values for each subframe Q6 */
-/* _ (Word16*) code_fx : innovation Q12 */
+/* _ (Word16*) code_fx : innovation Q12 */
/*--------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
/* Decoder_State_fx *st_fx : decoder state structure */
@@ -30,438 +30,29 @@
/* _ None */
/*==========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void dec_pit_exc_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* i : LP filter coefficient */
- const Word16 coder_type, /* i : coding type */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
- Word16 *code_fx, /* o : innovation */
- Word16 *exc_fx, /* i/o: adapt. excitation exc */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
- const Word16 nb_subfr_fx /* i : Number of subframe considered */
- ,
- Word16 *gain_buf /*Q14*/
-)
-{
- Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
- Word16 gain_pit_fx; /* pitch gain Q14 */
- Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */
- Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */
- Word16 gain_inov_fx; /* Innovation gain Q12 */
- Word16 voice_fac_fx; /* voicing factor Q15 */
- Word16 L_subfr_fx, pit_idx_fx;
- const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
- Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */
- Word16 i_subfr_fx, i; /* tmp variables */
- Word32 Local_BR_fx, Pitch_BR_fx;
- Word16 pitch_limit_flag, Pitch_CT_fx;
- Word16 exc2_bidon[L_SUBFR];
- Word16 *pt_gain; /* Pointer to floating gain values for each subframe */
-
- Word16 gain_code16, gain_pitx2;
- Word32 L_tmp;
- Word16 nbits;
- GSC_DEC_HANDLE hGSCDec;
- gain_pit_fx = 0;
- move16();
- hGSCDec = st_fx->hGSCDec;
-
- MUSIC_POSTFILT_HANDLE hMusicPF;
- hMusicPF = st_fx->hMusicPF;
-
- Word16 use_fcb;
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- move16();
-#endif
-
- use_fcb = 0;
- move16();
- test();
- test();
- IF( ( st_fx->GSC_IVAS_mode > 0 ) && ( EQ_16( st_fx->GSC_noisy_speech, 1 ) || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) )
- {
- Local_BR_fx = ACELP_8k00;
- Pitch_CT_fx = GENERIC;
- Pitch_BR_fx = ACELP_8k00;
- move32();
- move32();
- move16();
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Local_BR_fx = ACELP_14k80;
- move32();
- if ( st_fx->GSC_IVAS_mode > 0 )
- {
- Local_BR_fx = ACELP_9k60;
- move32();
- }
- Pitch_BR_fx = st_fx->core_brate;
- move32();
- }
- }
- ELSE IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) )
- {
- Local_BR_fx = ACELP_7k20;
- move32();
- Pitch_CT_fx = GENERIC;
- move16();
- Pitch_BR_fx = ACELP_7k20;
- move32();
- if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Pitch_BR_fx = st_fx->core_brate;
- move32();
- }
- }
- ELSE
- {
- Local_BR_fx = ACELP_7k20;
- move32();
- Pitch_CT_fx = AUDIO;
- move16();
- Pitch_BR_fx = st_fx->core_brate;
- move32();
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Pitch_BR_fx = ACELP_13k20;
- move32();
- Pitch_CT_fx = GENERIC;
- move16();
- }
- }
- L_subfr_fx = mult_r( st_fx->L_frame, div_s( 1, nb_subfr_fx ) ); /* TV2Opt : this could be less complex with 2 ifs*/
-
-
- gain_code_fx = 0;
- move16();
- pitch_limit_flag = 1;
- move16(); /* always extended pitch Q range */
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && ( ( EQ_16( st_fx->L_frame, L_FRAME ) && GE_32( st_fx->core_brate, ACELP_13k20 ) ) || ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, GSC_H_RATE_STG ) ) || st_fx->GSC_IVAS_mode == 0 ) ) ) && EQ_16( L_subfr_fx, L_SUBFR ) ) )
- {
- use_fcb = 1;
- move16();
- }
- ELSE IF( ( st_fx->GSC_IVAS_mode > 0 ) && EQ_16( L_subfr_fx, 2 * L_SUBFR ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) )
- {
- use_fcb = 2;
- st_fx->acelp_cfg.fcb_mode = 1;
- move16();
- move16();
- set16_fx( st_fx->acelp_cfg.gains_mode, 6, 4 );
- set16_fx( st_fx->acelp_cfg.pitch_bits, 9, 4 );
- set16_fx( st_fx->acelp_cfg.fixed_cdk_index, 14, 5 );
- }
- /*------------------------------------------------------------------*
- * ACELP subframe loop
- *------------------------------------------------------------------*/
- p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */
- pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */
- pt_gain = gain_buf; /* pointer to the gain buffer */
- FOR( i_subfr_fx = 0; i_subfr_fx < st_fx->L_frame; i_subfr_fx += L_subfr_fx )
- {
- /*----------------------------------------------------------------------*
- * Decode pitch lag
- *----------------------------------------------------------------------*/
- *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx );
- move16();
-
- /*--------------------------------------------------------------*
- * Find the adaptive codebook vector.
- *--------------------------------------------------------------*/
-
- pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- /*--------------------------------------------------------------*
- * Innovation decoding
- *--------------------------------------------------------------*/
-
- IF( EQ_16( use_fcb, 1 ) )
- {
- inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx );
- /*--------------------------------------------------------------*
- * Gain decoding
- * Estimate spectrum tilt and voicing
- *--------------------------------------------------------------*/
-
- gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
-
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 );
- move16();
- }
- ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */
- {
- inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx );
- /*--------------------------------------------------------------*
- * Gain decoding
- * Estimate spectrum tilt and voicing
- *--------------------------------------------------------------*/
-
- gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
-
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 );
- move16();
- }
- ELSE
- {
- nbits = 5;
- move16();
- if ( LT_32( st_fx->core_brate, MIN_RATE_FCB ) )
- {
- nbits = 4;
- move16();
- }
-
- set16_fx( code_fx, 0, L_SUBFR );
- gain_code_fx = L_deposit_l( 0 );
- st_fx->tilt_code_fx = 0;
- move16();
- pit_idx_fx = (Word16) get_next_indice( st_fx, nbits );
- move16();
-
- gain_pit_fx = add( 9590, dic_gp_fx[pit_idx_fx] );
- move16(); /*Q14 0.5853 in Q14 9590*/
-
- if ( st_fx->BER_detect ) /* Bitstream is corrupted, use the past pitch gain */
- {
- gain_pit_fx = st_fx->lp_gainp_fx;
- move16();
- }
- gain_code_fx = L_mult0( s_max( sub( 32767, shl_o( gain_pit_fx, 1, &Overflow ) ), 16384 ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/
- }
-
- /*----------------------------------------------------------------------*
- * Find the total excitation
- *----------------------------------------------------------------------*/
-
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[( i_subfr_fx * ( 2 * HIBND_ACB_L_FAC ) ) / 2], hGSCDec->last_exc_dct_in_fx,
- L_subfr_fx, shr( imult1616( L_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 ), gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type );
-
- gain_code16 = round_fx( L_shl( gain_code_fx, st_fx->Q_exc ) ); /*Q_exc*/
-
- IF( use_fcb != 0 )
- {
- Acelp_dec_total_exc( exc_fx, exc2_bidon - i_subfr_fx, gain_code16, gain_pit_fx, i_subfr_fx, code_fx, L_subfr_fx );
- }
- ELSE
- {
- IF( norm_s( s_or( gain_pit_fx, 1 ) ) == 0 )
- {
- FOR( i = 0; i < L_subfr_fx; i++ )
- {
- L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/
- exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/
- move16();
- }
- }
- ELSE
- {
- gain_pitx2 = shl( gain_pit_fx, 1 ); /*Q15*/
-
- FOR( i = 0; i < L_subfr_fx; i++ )
- {
- L_tmp = L_mult( gain_pitx2, exc_fx[i + i_subfr_fx] ); /*Q16+Q_exc*/
- exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/
- move16();
- }
- }
- }
-
- IF( EQ_16( L_subfr_fx, L_FRAME16k ) )
- {
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = gain_pit_fx;
- move16();
- st_fx->lp_gainc_fx = 0;
- move32();
-
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- move16();
- move16();
- move16();
- move16();
- p_Aq_fx += 5 * ( M + 1 );
- }
- ELSE IF( EQ_16( L_subfr_fx, L_FRAME16k / 2 ) )
- {
- IF( i_subfr_fx == 0 )
- {
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- p_Aq_fx += 2 * ( M + 1 );
- move16();
-
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = extract_h( L_mult( 6554, gain_pit_fx ) ); /*Q14 (3/15 in Q15 9830)*/
- st_fx->lp_gainc_fx = 0;
- move16();
- move16();
- }
- ELSE
- {
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- pt_pitch_fx++;
- p_Aq_fx += 3 * ( M + 1 );
- move16();
- move16();
-
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = extract_h( L_mult( 26214, gain_pit_fx ) ); /*Q14 (12/15 in Q15 9830)*/
- st_fx->lp_gainc_fx = 0;
- move16();
- move16();
- }
- }
- ELSE IF( EQ_16( L_subfr_fx, 128 ) ) /*2*L_SUBFR*/
- {
- p_Aq_fx += 2 * ( M + 1 );
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- move16();
- pt_pitch_fx++;
- *pt_gain = gain_pit_fx;
- move16();
- pt_gain++;
- *pt_gain = *( pt_gain - 1 );
- move16();
- pt_gain++;
- IF( i_subfr_fx == 0 )
- {
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = extract_h( L_mult( 9830, gain_pit_fx ) ); /*Q14 (3/10 in Q15 9830)*/
- st_fx->lp_gainc_fx = 0;
- move16();
- move16();
- }
- ELSE
- {
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = extract_h( L_mult( 22938, gain_pit_fx ) ); /*Q14 (7/10 in Q15 22938)*/
- st_fx->lp_gainc_fx = 0;
- move16();
- move16();
- }
- }
- ELSE IF( EQ_16( L_subfr_fx, 256 ) ) /*4*L_SUBFR*/
- {
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- move16();
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- move16();
- pt_pitch_fx++;
- *pt_pitch_fx = *( pt_pitch_fx - 1 );
- move16();
- pt_pitch_fx++;
- *pt_gain = gain_pit_fx;
- move16();
- pt_gain++;
- *pt_gain = *( pt_gain - 1 );
- move16();
- pt_gain++;
- *pt_gain = *( pt_gain - 1 );
- move16();
- pt_gain++;
- *pt_gain = *( pt_gain - 1 );
- move16();
- pt_gain++;
- p_Aq_fx += 4 * ( M + 1 );
-
- /* update gains for FEC - equivalent to lp_gain_updt() */
- st_fx->lp_gainp_fx = gain_pit_fx;
- move16();
- st_fx->lp_gainc_fx = 0;
- move16();
- }
- ELSE
- {
- p_Aq_fx += ( M + 1 );
- move16();
- pt_pitch_fx++;
- move16();
- *pt_gain = gain_pit_fx;
- move16();
- pt_gain++;
-
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame );
- }
- }
-
- return;
-}
-
-/*==========================================================================*/
-/* FUNCTION : void dec_pit_exc_ivas_fx() */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : Decode pitch only contribution */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16*) Aq_fx : LP filter coefficient Q12 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _ (Word16) nb_subfr_fx :Number of subframe considered */
-/* _ (Word16) Es_pred_fx :predicted scaled innov. energy */
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) pitch_buf_fx : Word16 pitch values for each subframe Q6 */
-/* _ (Word16*) code_fx : innovation */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State_fx *st_fx : decoder state structure */
-/* _ (Word16*) exc_fx : adapt. excitation exc */
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*==========================================================================*/
-#endif
-void dec_pit_exc_ivas_fx(
Decoder_State *st_fx, /* i/o: decoder static memory */
const Word16 *Aq_fx, /* i : LP filter coefficient */
const Word16 coder_type, /* i : coding type */
const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */
+ Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */
Word16 *code_fx, /* o : innovation */
Word16 *exc_fx, /* i/o: adapt. excitation exc */
Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
const Word16 nb_subfr_fx, /* i : Number of subframe considered */
- Word16 *gain_buf, /*Q14*/
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */
)
{
- Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
- Word16 gain_pit_fx; /* pitch gain Q14 */
- Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */
+ Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */
+ Word16 gain_pit_fx; /* pitch gain Q14 */
+ Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */
Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */
- Word16 gain_inov_fx; /* Innovation gain Q12 */
+ Word16 gain_inov_fx; /* Innovation gain Q12 */
Word16 voice_fac_fx; /* voicing factor Q15 */
Word16 L_subfr_fx, pit_idx_fx;
- const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
+ const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */
Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */
Word16 i_subfr_fx, i; /* tmp variables */
Word32 Local_BR_fx, Pitch_BR_fx;
@@ -578,13 +169,14 @@ void dec_pit_exc_ivas_fx(
p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */
pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */
pt_gain = gain_buf; /* pointer to the gain buffer */
+
FOR( i_subfr_fx = 0; i_subfr_fx < st_fx->L_frame; i_subfr_fx += L_subfr_fx )
{
/*----------------------------------------------------------------------*
* Decode pitch lag
*----------------------------------------------------------------------*/
- *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
move16();
/*--------------------------------------------------------------*
@@ -621,7 +213,7 @@ void dec_pit_exc_ivas_fx(
* Estimate spectrum tilt and voicing
*--------------------------------------------------------------*/
- gain_dec_lbr_ivas_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
+ gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 );
move16();
diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c
index 281281ed6ae0cf151cb9e18a59eb45fcd86aff86..37d088a8f98d7049e8ed7d130e26f5e2deab8e22 100644
--- a/lib_dec/dec_post_fx.c
+++ b/lib_dec/dec_post_fx.c
@@ -33,10 +33,7 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco
static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor );
-#ifndef REMOVE_EVS_DUPLICATES
static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 );
-#endif
-static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 );
static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl );
@@ -82,7 +79,7 @@ void Init_post_filter_fx(
*--------------------------------------------------------------------------*/
void nb_post_filt_fx(
const Word16 L_frame, /* i : frame length */
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
Word16 *psf_lp_noise, /* i : Long term noise Q8 */
const Word16 tmp_noise, /* i : noise energy Q0 */
Word16 *Synth, /* i : 12k8 synthesis Qsyn */
@@ -257,22 +254,20 @@ static void Dec_postfilt_fx(
* Main routine to perform formant post filtering
*--------------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
void formant_post_filt_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
Word16 *synth_in, /* i : 12k8 synthesis */
- Word16 *Aq, /* i : LP filter coefficient Q12 */
+ Word16 *Aq, /* i : LP filter coefficient Q12 */
Word16 *synth_out, /* i/o: input signal */
- Word16 L_frame,
- Word32 lp_noise, /* (i) : background noise energy (15Q16) */
- Word32 brate, /* (i) : bit-rate */
- const Word16 off_flag /* i : off flag */
+ const Word16 L_frame, /* i : frame length */
+ const Word32 lp_noise, /* (i) : background noise energy (15Q16) */
+ const Word32 brate, /* (i) : bit-rate */
+ const Word16 off_flag /* i : off flag */
)
{
Word16 i_subfr;
Word16 *p_Aq;
- Word16 post_G1, post_G2; // Q15
-
+ Word16 post_G1, post_G2;
/*default parameter for noisy speech and high bit-rates*/
IF( EQ_16( L_frame, L_FRAME ) )
@@ -381,134 +376,13 @@ void formant_post_filt_fx(
Dec_formant_postfilt_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 );
p_Aq += ( M + 1 );
}
-}
-#endif
-void formant_post_filt_ivas_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- Word16 *synth_in, /* i : 12k8 synthesis */
- Word16 *Aq, /* i : LP filter coefficient Q12 */
- Word16 *synth_out, /* i/o: input signal */
- Word16 L_frame,
- Word32 lp_noise, /* (i) : background noise energy (15Q16) */
- Word32 brate, /* (i) : bit-rate */
- const Word16 off_flag /* i : off flag */
-)
-{
- Word16 i_subfr;
- Word16 *p_Aq;
- Word16 post_G1, post_G2;
-
-
- /*default parameter for noisy speech and high bit-rates*/
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- post_G2 = 22938 /*0.7f Q15*/;
- move16();
- IF( LT_32( lp_noise, LP_NOISE_THRESH ) )
- {
- /*Clean speech*/
- IF( LT_32( brate, ACELP_13k20 ) )
- {
- /*Low rates*/
-
- post_G1 = 26214 /*0.8f Q15*/;
- move16();
- }
- ELSE IF( LT_32( brate, ACELP_24k40 ) )
- {
- /*Low rates*/
-
- post_G1 = 24576 /*0.75f Q15*/;
- move16();
- }
- ELSE
- {
- post_G1 = 23593 /*0.72f Q15*/;
- move16();
- }
- }
- ELSE /*Noisy speech*/
- {
- post_G1 = 22938 /*0.7f Q15*/;
- move16();
- if ( LT_32( brate, ACELP_15k85 ) )
- {
- /*Low rates*/
- post_G1 = 24576 /*0.75f Q15*/;
- move16();
- }
- }
- }
- ELSE
- {
- post_G2 = 24904 /*0.76f Q15*/;
- move16();
- test();
- IF( GE_32( lp_noise, LP_NOISE_THRESH ) )
- {
- post_G1 = 24904 /*0.76f Q15*/;
- }
- ELSE IF( EQ_32( brate, ACELP_13k20 ) )
- {
- post_G1 = 26870 /*0.82f Q15*/;
- move16();
- }
- ELSE IF( EQ_32( brate, ACELP_16k40 ) )
- {
- post_G1 = 26214 /*0.80f Q15*/;
- move16();
- }
- ELSE IF( EQ_32( brate, ACELP_24k40 ) || EQ_32( brate, ACELP_32k ) )
- {
- post_G1 = 25559 /*0.78f Q15*/;
- move16();
- }
- ELSE
- {
- post_G1 = 24904 /*0.76f Q15*/;
- move16();
- }
- }
- /* Switch off post-filter */
- if ( off_flag != 0 )
- {
- post_G1 = post_G2;
- move16();
- }
-
- /* Reset post filter */
- IF( hPFstat->reset != 0 )
- {
- post_G1 = MAX16B;
- move16();
- post_G2 = MAX16B;
- move16();
- hPFstat->reset = 0;
- move16();
- Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM );
- Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_stp, L_SYN_MEM );
- hPFstat->gain_prec = 16384; // 1.Q14
- move16();
- Copy( synth_in, synth_out, L_frame );
-
- return;
- }
+ return;
+}
- /* input memory*/
- Copy( hPFstat->mem_pf_in, synth_in - L_SYN_MEM, L_SYN_MEM );
- Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM );
- move16();
- p_Aq = Aq; // Q12
- FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR )
- {
- Dec_formant_postfilt_ivas_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 );
- p_Aq += ( M + 1 );
- }
-}
/*----------------------------------------------------------------------------
- * Dec_formant_postfilt_fx
+ * Dec_formant_postfilt_fx()
*
* Post - adaptive postfilter main function
* Short term postfilter :
@@ -522,93 +396,14 @@ void formant_post_filt_ivas_fx(
* k1 = 1st parcor calculated on {hi}
* gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0
*----------------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
-static void Dec_formant_postfilt_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/
- Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
- Word16 *sig_out, /* o : postfiltered output */
- Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/
- Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/
-)
-{
- /* Local variables and arrays */
- Word16 apond1[M + 1]; /* s.t. denominator coeff. Q12*/
- Word16 apond2[LONG_H_ST]; // Q12
- Word16 res2[L_SUBFR]; // Q14
- Word16 resynth[L_SUBFR + 1]; // Qy
- Word16 parcor0; // Q15
- Word16 i, max;
- Word16 scale_down;
-
- /* Compute weighted LPC coefficients */
- weight_a_fx( coeff, apond1, gamma1, M );
- weight_a_fx( coeff, apond2, gamma2, M );
- set16_fx( &apond2[M + 1], 0, LONG_H_ST - ( M + 1 ) );
- max = abs_s( signal_ptr[0] ); // Q14
- FOR( i = 1; i < L_SUBFR; i++ )
- {
- max = s_max( max, abs_s( signal_ptr[i] ) );
- }
- scale_down = 0;
- move16();
- if ( GT_16( max, 16384 /*1.Q14*/ ) )
- {
- scale_down = 1;
- move16();
- }
-
- /* Compute A(gamma2) residual */
- IF( !scale_down )
- {
- Residu3_fx( apond2, signal_ptr, res2, L_SUBFR, 1 );
- }
- ELSE
- {
- Residu3_fx( apond2, signal_ptr, res2, L_SUBFR, 0 );
- Scale_sig( hPFstat->mem_stp, L_SYN_MEM, -1 );
- }
-
- /* Controls short term pst filter gain and compute parcor0 */
- calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero );
-
- /* 1/A(gamma1) filtering, mem_stp is updated */
- resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) );
- move16();
-
- E_UTIL_synthesis( 1, apond1, res2, &( resynth[1] ), L_SUBFR, hPFstat->mem_stp + L_SYN_MEM - M, 0, M );
-
- IF( !scale_down )
- {
- Copy( &( resynth[1] ) + L_SUBFR - L_SYN_MEM, hPFstat->mem_stp, L_SYN_MEM );
- }
- ELSE
- {
- Copy_Scale_sig( &( resynth[1] ) + L_SUBFR - L_SYN_MEM, hPFstat->mem_stp, L_SYN_MEM, 1 );
- }
-
- /* Tilt filtering */
- Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR );
- IF( scale_down )
- {
- Scale_sig( sig_out, L_SUBFR, 1 );
- }
-
- /* Gain control */
- scale_st_fx( signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR );
-
-
- return;
-}
-#endif
-static void Dec_formant_postfilt_ivas_fx(
- PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
- Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/
- Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
- Word16 *sig_out, /* o : postfiltered output */
- Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/
- Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/
+static void Dec_formant_postfilt_fx(
+ PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
+ Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/
+ Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
+ Word16 *sig_out, /* o : postfiltered output */
+ Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/
+ Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/
)
{
/* Local variables and arrays */
diff --git a/lib_dec/dec_ppp_fx.c b/lib_dec/dec_ppp_fx.c
index 4849e147a04c9f10f351aa1c9ae5d89750637be4..4b3f4f554ec8100ae08fb5f6f7bac0383f398224 100644
--- a/lib_dec/dec_ppp_fx.c
+++ b/lib_dec/dec_ppp_fx.c
@@ -6,6 +6,7 @@
#include
#include "options.h" /* Compilation switches */
#include "prot_fx.h" /* Function prototypes */
+
/*===================================================================*/
/* FUNCTION : void decod_ppp_fx () */
/*-------------------------------------------------------------------*/
@@ -45,20 +46,20 @@
/*-------------------------------------------------------------------*/
/* CALLED FROM : RX */
/*===================================================================*/
+
ivas_error decod_ppp_fx(
- Decoder_State *st_fx, /* i/o: state structure */
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
- Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation */
- Word16 *exc2_fx, /* i/o: current enhanced excitation */
- Word16 bfi, /* i : bad frame indicator */
- Word16 *gain_buf,
+ Decoder_State *st_fx, /* i/o: state structure */
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
+ Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation */
+ Word16 *exc2_fx, /* i/o: current enhanced excitation */
+ Word16 bfi, /* i : bad frame indicator */
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
Word16 *voice_factors, /* o : voicing factors */
Word16 *bwe_exc_fx /* o : excitation for SWB TBE */
)
{
Word16 k;
-
Word16 LPC_de_curr_fx[M + 1], p_Aq_curr_fx[M], p_Aq_old_fx[M + 1];
Word16 excQ_ppp_fx[L_FRAME], pitch_fx[NB_SUBFR], LPC_de_old_fx[M + 1];
ivas_error error;
diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c
index c5b06724aff2a85b1596a4b8fd8b60c3086039db..de3a1ff3fb8f8521004f0d0cb1d3dd1260e57e19 100644
--- a/lib_dec/dec_tran_fx.c
+++ b/lib_dec/dec_tran_fx.c
@@ -254,16 +254,10 @@ void decod_tran_fx(
tmp_idx_2 = idiv1616( i_subfr, L_SUBFR );
}
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
-#else
- prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
+ prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
&voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx,
- st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate );
-#endif
+ st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*----------------------------------------------------------------*
* Excitation enhancements (update of total excitation signal)
diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c
index fcc2600a3eefe302fc6cfb62c79dc5ca481d75eb..f1ba21979228b1e0634efef8bf139c511869fc4f 100644
--- a/lib_dec/dec_uv_fx.c
+++ b/lib_dec/dec_uv_fx.c
@@ -25,96 +25,7 @@ static void gain_dec_gacelp_uv_fx(
* Decode unvoiced (UC) frames
*-------------------------------------------------------------------*/
-#ifndef REMOVE_EVS_DUPLICATES
void decod_unvoiced_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
- const Word16 coder_type, /* Q0 i : coding type */
- Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */
- Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/
- Word16 *voice_factors_fx, /* Q15 o : voicing factors */
- Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
- Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
- Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
- Word16 *gain_buf )
-{
- Word16 gain_pit_fx; /* Quantized pitch gain */
- Word32 gain_code_fx; /* Quantized algebraic codeebook gain */
- Word16 gain_inov_fx; /* inovation gain */
- Word32 norm_gain_code_fx; /* normalized algebraic codeebook gain */
- Word16 voice_fac_fx; /* Voicing factor */
- Word16 code_fx[L_SUBFR]; /* algebraic codevector */
- Word16 i_subfr_fx;
- const Word16 *p_Aq_fx;
- Word16 *pt_pitch_fx;
-
- gain_pit_fx = 0;
- move16();
-
- test();
- IF( EQ_16( st_fx->last_ppp_mode_dec, 1 ) || EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
- {
- /* SC_VBR - reset the decoder, to avoid memory not updated issue for this unrealistic case */
- CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors_fx );
- }
-
- p_Aq_fx = Aq_fx;
- move16(); /*Q12*/ /* pointer to interpolated LPC parameters */
- pt_pitch_fx = pitch_buf_fx;
- move16(); /* pointer to the pitch buffer */
-
- FOR( i_subfr_fx = 0; i_subfr_fx < L_FRAME; i_subfr_fx += L_SUBFR )
- {
- /*----------------------------------------------------------------*
- * Unvoiced subframe processing
- *----------------------------------------------------------------*/
-
- gaus_dec_fx( st_fx, i_subfr_fx, code_fx, &norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, &gain_inov_fx, &st_fx->tilt_code_fx,
- &voice_fac_fx, &gain_pit_fx, pt_pitch_fx, exc_fx, &gain_code_fx, exc2_fx, bwe_exc_fx, &( st_fx->Q_exc ), st_fx->Q_subfr );
-
- *tmp_noise_fx = extract_h( norm_gain_code_fx ); /*Q16*/
- move16();
-
- /*----------------------------------------------------------------*
- * Excitation enhancements (update of total excitation signal)
- *----------------------------------------------------------------*/
-
- enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx,
- norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
-
- Word16 tmp_idx = 0;
- move16();
- IF( i_subfr_fx != 0 )
- {
- tmp_idx = idiv1616( i_subfr_fx, L_SUBFR );
- }
- voice_factors_fx[tmp_idx] = 0;
- move16();
-
- interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[( ( i_subfr_fx * 2 * HIBND_ACB_L_FAC ) >> 1 )], L_SUBFR );
-
- p_Aq_fx += ( M + 1 );
- pt_pitch_fx++;
- st_fx->tilt_code_dec_fx[tmp_idx] = st_fx->tilt_code_fx;
- move16();
- }
-
- /* SC-VBR */
- st_fx->prev_gain_pit_dec_fx = gain_pit_fx;
- move16();
-
- set16_fx( gain_buf, 0, NB_SUBFR );
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * decod_unvoiced()
- *
- * Decode unvoiced (UC) frames
- *-------------------------------------------------------------------*/
-#endif
-void decod_unvoiced_ivas_fx(
Decoder_State *st_fx, /* i/o: decoder static memory */
const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
@@ -208,13 +119,11 @@ void decod_unvoiced_ivas_fx(
move16();
/* update LP filtered gains for the case of frame erasures */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
}
ELSE
-#endif
{
lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
}
@@ -250,6 +159,7 @@ void decod_unvoiced_ivas_fx(
}
// Scale_sig(code_fx, L_SUBFR, 3); //Q12
}
+
*tmp_noise_fx = extract_h( norm_gain_code_fx ); /*Q16*/
move16();
@@ -257,14 +167,12 @@ void decod_unvoiced_ivas_fx(
* Excitation enhancements (update of total excitation signal)
*----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx,
norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
}
ELSE
-#endif
{
enhancer_ivas_fx( MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx,
norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx /*Q9/Q12?*/, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc );
@@ -276,12 +184,6 @@ void decod_unvoiced_ivas_fx(
IF( i_subfr_fx != 0 )
{
tmp_idx = idiv1616( i_subfr_fx, L_SUBFR );
-#ifdef REMOVE_EVS_DUPLICATES
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
- {
- tmp_idx = idiv1616( i_subfr_fx, L_SUBFR );
- }
-#endif
}
voice_factors_fx[tmp_idx] = 0;
move16();
diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c
index 9f08a281bd375d2c2c3df823a08c5760e2598362..9c81fddf347529f42c78a49bbaae321ffc589306 100644
--- a/lib_dec/evs_dec_fx.c
+++ b/lib_dec/evs_dec_fx.c
@@ -332,11 +332,7 @@ ivas_error evs_dec_fx(
IF( EQ_16( st_fx->core, ACELP_CORE ) )
{
/* ACELP core decoder */
-#ifdef REMOVE_EVS_DUPLICATES
- IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK )
-#else
IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK )
-#endif
{
return error;
}
@@ -957,11 +953,9 @@ ivas_error evs_dec_fx(
}
st_fx->lp_noise = hFdCngDec->lp_noise; /*Q9.23*/
move32();
-#ifdef REMOVE_EVS_DUPLICATES
- ApplyFdCng_ivas_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
-#else
- ApplyFdCng_fx( output_sp, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
-#endif
+
+ ApplyFdCng_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 );
+
/* Generate additional comfort noise to mask potential coding artefacts */
test();
IF( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && st_fx->flag_cna )
diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c
index 3fe93854ea4b3f7f71238cc386af2698cd7d4ae1..cc83eeca320bd3c993587d97b9320ebfc768e0c4 100644
--- a/lib_dec/fd_cng_dec_fx.c
+++ b/lib_dec/fd_cng_dec_fx.c
@@ -555,463 +555,7 @@ void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec )
error
*/
-#ifndef REMOVE_EVS_DUPLICATES
Word16 ApplyFdCng_fx(
- Word16 *timeDomainInput, /* i : pointer to time domain input Q*/
- Word16 Q,
- Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer cldfbBufferScale*/
- Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer cldfbBufferScale*/
- Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */
- Decoder_State *st,
- const Word16 concealWholeFrame, /* i : binary flag indicating frame loss Q0*/
- Word16 is_music /*Q0*/ )
-{
- Word16 j, k, nBins;
- Word16 s, s1, s2, num, denom;
- Word32 *cngNoiseLevel;
- Word16 *cngNoiseLevel_exp;
- Word32 L_tmp;
- Word16 L_tmp_exp;
- Word16 facTab[NPART];
- Word16 facTabExp[NPART];
- Word16 tmp_loop;
- Word32 L_c;
- Word16 lsp_cng[M];
- HANDLE_FD_CNG_DEC hFdCngDec;
- HANDLE_FD_CNG_COM hFdCngCom;
-#ifdef BASOP_NOGLOB_DECLARE_LOCAL
- Flag Overflow = 0;
- Flag Carry = 0;
- move16();
- move16();
-#endif
-
- hFdCngDec = st->hFdCngDec;
- hFdCngCom = hFdCngDec->hFdCngCom;
-
-
- if ( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) )
- {
- hFdCngCom->inactive_frame_counter = 0;
- move16();
- }
- IF( EQ_16( st->element_mode, IVAS_CPE_TD ) )
- {
- hFdCngDec->flag_dtx_mode = hFdCngDec->flag_dtx_mode || st->first_CNG;
- test();
- move16();
- }
- cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*Q31 - hFdCngCom->cngNoiseLevelExp*/
- move32();
- cngNoiseLevel_exp = &hFdCngCom->cngNoiseLevelExp;
- move16();
- nBins = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
-
- SWITCH( st->m_frame_type )
- {
- case ACTIVE_FRAME:
-
- /**************************
- * ACTIVE_FRAME at DECODER *
- **************************/
-
- hFdCngCom->inactive_frame_counter = 0;
- move16();
- hFdCngCom->sid_frame_counter = 0;
- move16();
-
- /* set noise estimation inactive during concealment, as no update with noise generated by concealment should be performed. */
- /* set noise estimation inactive during concealment, no update with noise generated by concealment should be performed. */
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF(
- ( concealWholeFrame == 0 ) &&
- ( LT_16( *timeDomainInput, MAXVAL_WORD16 ) ) && GT_16( *timeDomainInput, MINVAL_WORD16 ) && ( LT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MAXVAL_WORD16 ) ) && GT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MINVAL_WORD16 ) && ( ( ( hFdCngDec->flag_dtx_mode == 0 ) && ( st->VAD != 0 ) ) == 0 ) && ( ( ( st->cng_type == LP_CNG ) && ( hFdCngDec->flag_dtx_mode != 0 ) ) == 0 ) && ( is_music == 0 ) && ( st->BER_detect == 0 ) )
- {
- /* Perform noise estimation at the decoder */
- perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
-
- /* Update the shaping parameters */
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 );
- }
- hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp;
- move16();
-
-
- /* Update CNG levels */
- test();
- IF( hFdCngDec->flag_dtx_mode != 0 && EQ_16( st->cng_type, FD_CNG ) )
- {
- /* This needs to be done only once per inactive phase */
- bandcombinepow(
- hFdCngDec->bandNoiseShape,
- hFdCngDec->bandNoiseShape_exp,
- nBins,
- hFdCngCom->part,
- hFdCngCom->nFFTpart,
- hFdCngCom->psize_inv,
- hFdCngDec->partNoiseShape,
- &hFdCngDec->partNoiseShape_exp );
-
-
- j = 0;
- move16();
- s2 = -( WORD32_BITS - 1 );
- move16();
- FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- assert( hFdCngDec->partNoiseShape[k] >= 0 );
- assert( hFdCngCom->sidNoiseEst[k] >= 0 );
-
- /* add DELTA as it is done in FLC version, in order to avoid num > denom */
- facTab[k] = 0;
- move16();
- IF( hFdCngDec->partNoiseShape[k] != 0 )
- {
- s1 = norm_l( hFdCngCom->sidNoiseEst[k] );
- L_tmp = L_shl( hFdCngCom->sidNoiseEst[k], s1 ); /*Q31 - hFdCngCom->sidNoiseEstExp + s1*/
- L_tmp_exp = sub( hFdCngCom->sidNoiseEstExp, s1 );
- L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp );
- L_tmp = L_shr( L_tmp, 1 );
- s = add( L_tmp_exp, 1 );
- num = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/
-
- s1 = norm_l( hFdCngDec->partNoiseShape[k] );
- L_tmp = L_shl( hFdCngDec->partNoiseShape[k], s1 ); /*Q31 - hFdCngDec->partNoiseShape_exp + s1*/
- L_tmp_exp = sub( hFdCngDec->partNoiseShape_exp, s1 );
- L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp );
- s = sub( s, L_tmp_exp );
- denom = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/
-
- facTab[k] = div_s( num, denom ); /*Q15 - s*/
- move16();
- facTabExp[k] = s;
- move16();
- }
- /* Set unique exponent, if mantissa is equal to zero */
- if ( facTab[k] == 0 )
- {
- facTabExp[k] = -( WORD32_BITS - 1 );
- move16();
- }
- s2 = s_max( s2, facTabExp[k] );
- }
-
- FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- s = sub( facTabExp[k], s2 );
- s = s_max( s_min( s, WORD32_BITS - 1 ), -( WORD32_BITS - 1 ) );
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
- move32();
- }
- }
-
- /* adapt scaling for rest of the buffer */
- IF( NE_16( s2, -( WORD32_BITS - 1 ) ) )
- {
- s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) );
- FOR( ; k < hFdCngCom->npart; k++ )
- {
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
- move32();
- }
- }
-
- *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 );
- move16();
- }
- }
- ELSE
- {
- /* This sets the new CNG levels until a SID update overwrites it */
- test();
- test();
- test();
- IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( EQ_16( st->element_mode, IVAS_CPE_TD ) && !hFdCngDec->flag_dtx_mode && !st->VAD ) )
- {
- Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, nBins ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
- *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
- move16();
- }
- }
- /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
- tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
- L_tmp = L_deposit_h( 0 );
- L_c = L_deposit_h( 0 );
- FOR( j = 0; j < tmp_loop; j++ )
- {
-
- Carry = 0;
- move16();
- L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/
- Overflow = 0;
- move16();
-
- IF( *( cngNoiseLevel + j ) < 0 )
- {
- L_c = L_msuNs( L_c, 0, 0 ); /*Q-1*/
- }
- IF( *( cngNoiseLevel + j ) >= 0 )
- {
- L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
- }
- }
- L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
- L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );
-
- L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/
-
- L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
- L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */
- L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/
-
- st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
- st->cngTDLevel_e = L_tmp_exp;
- move16();
- }
- ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- IF( hFdCngCom->active_frame_counter > 0 )
- {
- /* Perform noise estimation in active frames in the decoder for downward updates */
- perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
- }
- }
- test();
- test();
- L_tmp = 0;
- FOR( j = hFdCngCom->startBand; j < hFdCngCom->stopFFTbin; j++ )
- {
- L_tmp = L_add( L_tmp, L_shr( cngNoiseLevel[j], 16 ) );
- }
- L_tmp_exp = add( *cngNoiseLevel_exp, 16 );
- test();
- test();
- IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) && ( GT_32( L_shl_o( L_tmp, L_tmp_exp, &Overflow ), 21474836 ) /*0.01f Q31*/ ) )
- {
- /* update isf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/
- lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0 );
- E_LPC_a_lsp_conversion( hFdCngCom->A_cng, lsp_cng, st->lspold_cng, M );
- Copy( lsp_cng, st->lspold_cng, M ); /*Q15*/
-
- lsp2lsf_fx( lsp_cng, st->lsf_cng, M, st->sr_core );
- st->plcBackgroundNoiseUpdated = 1;
- move16();
- }
- BREAK;
-
- case SID_FRAME:
-
- hFdCngDec->flag_dtx_mode = 1;
- move16();
- /* no break */
-
- case ZERO_FRAME:
-
- test();
- IF( st != NULL && st->cng_type == LP_CNG )
- {
- /* Perform noise estimation on inactive phase at the decoder */
- perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
- /* Update the shaping parameters */
-
- test();
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 );
- }
- hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp;
- move16();
- /* This sets the new CNG levels until a SID update overwrites it */
- Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it Q31 - hFdCngDec->bandNoiseShape_exp*/
- *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
- move16();
- /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
- tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
- L_tmp = L_deposit_h( 0 );
- L_c = L_deposit_h( 0 );
- FOR( j = 0; j < tmp_loop; j++ )
- {
-
- Carry = 0;
- move16();
- L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/
- Overflow = 0;
- move16();
-
- IF( *( cngNoiseLevel + j ) < 0 )
- {
- L_c = L_msuNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
- }
- IF( *( cngNoiseLevel + j ) >= 0 )
- {
- L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
- }
- }
- L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
- L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );
-
- L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/
-
- L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
- L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */
- L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/
-
- st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); /*Q15 - L_tmp_exp*/
- move16();
- st->cngTDLevel_e = L_tmp_exp;
- move16();
- BREAK;
- }
- hFdCngCom->inactive_frame_counter = add( hFdCngCom->inactive_frame_counter, 1 );
- move16();
-
- /*************************************
- * SID_FRAME or ZERO_FRAME at DECODER *
- *************************************/
-
- /* Detect first non-active frame */
- IF( EQ_16( hFdCngCom->inactive_frame_counter, 1 ) )
- {
- /* Compute the fine spectral structure of the comfort noise shape using the decoder-side noise estimates */
- bandcombinepow(
- hFdCngDec->bandNoiseShape,
- hFdCngDec->bandNoiseShape_exp,
- nBins,
- hFdCngCom->part,
- hFdCngCom->nFFTpart,
- hFdCngCom->psize_inv,
- hFdCngDec->partNoiseShape,
- &hFdCngDec->partNoiseShape_exp );
- }
-
- IF( EQ_16( st->m_frame_type, SID_FRAME ) )
- {
- IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) )
- {
- /* At initialization, interpolate the bin/band-wise levels from the partition levels */
- scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband,
- hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 );
- *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
- move16();
- }
- ELSE
- {
- if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- }
-
- /* Interpolate the CLDFB band levels from the SID (partition) levels */
- IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) )
- {
- scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband,
- hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 );
- *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
- move16();
- }
-
- s2 = -( WORD32_BITS - 1 );
- move16();
- /* Shape the SID noise levels in each FFT bin */
- j = 0;
- move16();
- FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- assert( hFdCngDec->partNoiseShape[k] >= 0 );
-
- /* add DELTA as it is done in FLC version, in order to avoid num > denom */
- facTab[k] = 0;
- move16();
- IF( hFdCngDec->partNoiseShape[k] != 0 )
- {
- s1 = norm_l( hFdCngCom->sidNoiseEst[k] );
- L_tmp = L_shl( hFdCngCom->sidNoiseEst[k], s1 ); /*Q31 - hFdCngCom->sidNoiseEstExp + s1*/
- L_tmp_exp = sub( hFdCngCom->sidNoiseEstExp, s1 );
- L_tmp = BASOP_Util_Add_Mant32Exp( hFdCngCom->sidNoiseEst[k], hFdCngCom->sidNoiseEstExp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp );
- L_tmp = L_shr( L_tmp, 1 );
- s = add( L_tmp_exp, 1 );
- num = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/
-
- s1 = norm_l( hFdCngDec->partNoiseShape[k] );
- L_tmp = L_shl( hFdCngDec->partNoiseShape[k], s1 ); /*Q31 - hFdCngDec->partNoiseShape_exp + s1*/
- L_tmp_exp = sub( hFdCngDec->partNoiseShape_exp, s1 );
- L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp );
- s = sub( s, L_tmp_exp );
- denom = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/
-
- facTab[k] = div_s( num, denom ); /*Q15 - s*/
- move16();
- facTabExp[k] = s;
- move16();
- }
- /* Set unique exponent, if mantissa is equal to zero */
- if ( facTab[k] == 0 )
- {
- facTabExp[k] = -( WORD32_BITS - 1 );
- move16();
- }
- s2 = s_max( s2, facTabExp[k] );
- }
-
- FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
- {
- s = sub( facTabExp[k], s2 );
- s = s_max( s_min( s, WORD32_BITS - 1 ), -( WORD32_BITS - 1 ) );
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
- move32();
- }
- }
- /* adapt scaling for rest of the buffer */
- s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) );
- FOR( ; k < hFdCngCom->npart; k++ )
- {
- FOR( ; j <= hFdCngCom->part[k]; j++ )
- {
- cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/
- move32();
- }
- }
- *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 );
- move16();
- }
- }
-
- IF( EQ_16( st->codec_mode, MODE2 ) )
- {
- /* Generate comfort noise during SID or zero frames */
- generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
- }
-
- BREAK;
-
- default:
- return -1;
- }
-
-
- return 0;
-}
-#endif
-Word16 ApplyFdCng_ivas_fx(
Word16 *timeDomainInput, /* i : pointer to time domain input Q*/
Word16 Q,
Word32 *powerSpectrum, /*Q_power_spectrum*/
@@ -1113,27 +657,22 @@ Word16 ApplyFdCng_ivas_fx(
( !st->BER_detect ) )
{
/* Perform noise estimation at the decoder */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
}
ELSE
-#endif
{
perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
}
/* Update the shaping parameters */
test();
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 );
}
- ELSE
-#endif
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
{
scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 );
}
@@ -1369,13 +908,11 @@ Word16 ApplyFdCng_ivas_fx(
IF( hFdCngCom->active_frame_counter > 0 )
{
/* Perform noise estimation in active frames in the decoder for downward updates */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
}
ELSE
-#endif
{
perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
}
@@ -1436,44 +973,37 @@ Word16 ApplyFdCng_ivas_fx(
IF( st != NULL && EQ_16( st->cng_type, LP_CNG ) )
{
/* Perform noise estimation on inactive phase at the decoder */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec );
}
ELSE
-#endif
{
perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD );
}
/* Update the shaping parameters */
-
test();
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 );
}
- ELSE
-#endif
- IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ ELSE IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) )
{
scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 );
}
hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp;
move16();
+
/* This sets the new CNG levels until a SID update overwrites it */
Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it */ /*Q31 - hFdCngDec->bandNoiseShape_exp*/
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
*cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp;
move16();
}
ELSE
-#endif
{
Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) );
Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) );
@@ -1554,16 +1084,15 @@ Word16 ApplyFdCng_ivas_fx(
IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) )
{
/* At initialization, interpolate the bin/band-wise levels from the partition levels */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 );
}
ELSE
-#endif
{
scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 );
}
+
*cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
move16();
}
@@ -1576,13 +1105,11 @@ Word16 ApplyFdCng_ivas_fx(
/* Interpolate the CLDFB band levels from the SID (partition) levels */
IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) )
{
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 );
}
ELSE
-#endif
{
scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 );
}
@@ -1649,7 +1176,6 @@ Word16 ApplyFdCng_ivas_fx(
}
}
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
/* adapt scaling for rest of the buffer */
@@ -1666,7 +1192,6 @@ Word16 ApplyFdCng_ivas_fx(
move16();
}
ELSE
-#endif
{
Word16 shift1 = L_norm_arr( cngNoiseLevel, j );
Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) );
@@ -1755,13 +1280,11 @@ Word16 ApplyFdCng_ivas_fx(
IF( EQ_16( st->codec_mode, MODE2 ) )
{
/* Generate comfort noise during SID or zero frames */
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
}
ELSE
-#endif
{
generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 );
}
diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c
index 00eca187d71f2ca2891b1ee44c4af13bf099355c..db325cd80b92a8be09722e96ce43d699613736e6 100644
--- a/lib_dec/gain_dec_fx.c
+++ b/lib_dec/gain_dec_fx.c
@@ -602,7 +602,6 @@ void gain_dec_mless_fx(
/* _ None */
/*==================================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void gain_dec_lbr_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 coder_type, /* i : coding type */
@@ -653,375 +652,6 @@ void gain_dec_lbr_fx(
ctype = shl( sub( coder_type, 1 ), 1 );
- /*-----------------------------------------------------------------*
- * calculate prediction of gcode
- * search for the best codeword
- *-----------------------------------------------------------------*/
- IF( i_subfr == 0 )
- {
- b_fx = b_1sfr_fx;
- move16();
- n_pred = 2;
- move16();
- cdbk_fx = gp_gamma_1sfr_6b_fx;
- SWITCH( nBits )
- {
- case 8:
- {
- cdbk_fx = gp_gamma_1sfr_8b_fx; /* Q14/Q9*/
- BREAK;
- }
- case 7:
- {
- cdbk_fx = gp_gamma_1sfr_7b_fx; /* Q14/Q9*/
- BREAK;
- }
- case 6:
- {
- cdbk_fx = gp_gamma_1sfr_6b_fx; /* Q14/Q9*/
- BREAK;
- }
- }
-
- /* calculate predicted gain */
- aux_fx[0] = 4096; /*Q12*/
- move16();
- aux_fx[1] = shl( ctype, 12 ); /*Q12*/
- move16();
-
- /* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode));
- gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode));
- gcode0 = (float)pow(10, 0.05(20 * dotp(b, aux, n_pred) - 10 * (float)log10(Ecode))); */
-
- e_tmp = norm_l( L_tmp2 );
- f_tmp = Log2_norm_lc( L_shl( L_tmp2, e_tmp ) ); /*Q15*/
- e_tmp = sub( expg2, add( 1, e_tmp ) );
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/
-
- L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
- L_tmp = Mult_32_16( L_tmp, 160 ); /*Q13, 20 in Q3*/
- L_tmp = L_sub( L_tmp, L_tmp1 ); /*Q13*/
-
- gcode0_fx = round_fx( L_shl( L_tmp, 11 ) ); /* Q8 */
-
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, gcode0/20)
- * = pow(2, 3.321928*gcode0/20)
- * = pow(2, 0.166096*gcode0)
- *-----------------------------------------------------------------*/
-
- L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */
- L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
-
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
-
- /* retrieve the codebook index and calculate both gains */
- /*index = (Word16)get_indice( st_fx,"gain", i_subfr, ACELP_CORE);move16();*/
- index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/
- move16();
-
- *gain_pit_fx = cdbk_fx[index * 2]; /*Q14*/
- move16();
-
- L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/
- move16();
-
- gc_mem[0] = *gain_code_fx; /*Q16*/
- move32();
- gp_mem[0] = *gain_pit_fx; /*Q14*/
- move16();
- }
- ELSE IF( EQ_16( i_subfr, L_SUBFR ) || EQ_16( L_subfr, 2 * L_SUBFR ) )
- {
- b_fx = b_2sfr_fx; /*Q12*/
- move16();
- n_pred = 4;
- move16();
-
- cdbk_fx = gp_gamma_1sfr_6b_fx; /*Q14/Q9 */
- SWITCH( nBits )
- {
- case 7:
- {
- cdbk_fx = gp_gamma_2sfr_7b_fx; /* Q14/Q9*/
- BREAK;
- }
- case 6:
- {
- cdbk_fx = gp_gamma_2sfr_6b_fx; /* Q14/Q9*/
- BREAK;
- }
- }
-
- /* calculate predicted gain */
- aux_fx[0] = 4096; /*Q12*/
- move16();
- aux_fx[1] = shl( ctype, 12 ); /*Q12*/
- move16();
-
- /*aux_fx[2] = (float)log10(gc_mem[0]);
- = log2(gc_mem[0])*log10(2);*/
- e_tmp = norm_l( gc_mem[0] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- aux_fx[3] = shr( gp_mem[0], 2 ); /*Q12*/
- move16();
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, dotp(b, aux, n_pred)
- * = pow(2, 3.321928*dotp(b, aux, n_pred)
- *-----------------------------------------------------------------*/
- L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
- L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */
- L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
-
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
-
- /* retrieve the codebook index and calculate both gains */
- index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/
- move16();
-
- *gain_pit_fx = cdbk_fx[index * 2]; /*Q14*/
- move16();
-
- L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/
- move16();
-
- gc_mem[1] = *gain_code_fx; /*Q16*/
- move32();
- gp_mem[1] = *gain_pit_fx; /*Q14*/
- move16();
- }
- ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
- {
- b_fx = b_3sfr_fx;
- move16();
- n_pred = 6;
- move16();
-
- cdbk_fx = gp_gamma_3sfr_6b_fx; /*Q14/Q9 */
-
- if ( EQ_16( nBits, 7 ) )
- {
- cdbk_fx = gp_gamma_3sfr_7b_fx; /*Q14*/
- // PMT("verify if gp_gamma_3sfr_7b_fx is correct")
- }
-
- /* calculate predicted gain */
- aux_fx[0] = 4096; /*Q12*/
- move16();
- aux_fx[1] = shl( ctype, 12 ); /*Q12*/
- move16();
-
- /*aux_fx[2] = (float)log10(gc_mem[0]);
- = log2(gc_mem[0])*log10(2);*/
- e_tmp = norm_l( gc_mem[0] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- /*aux[3] = (float)log10(gc_mem[1]);
- = log2(gc_mem[1])*log10(2);*/
- e_tmp = norm_l( gc_mem[1] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[1], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[1])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- aux_fx[4] = shr( gp_mem[0], 2 ); /*Q12*/
- move16();
- aux_fx[5] = shr( gp_mem[1], 2 ); /*Q12*/
- move16();
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, dotp(b, aux, n_pred)
- * = pow(2, 3.321928*dotp(b, aux, n_pred)
- *-----------------------------------------------------------------*/
- L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
- L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */
- L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
-
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
-
- /* retrieve the codebook index and calculate both gains */
- index = (Word16) get_next_indice_fx( st_fx, nBits );
- move16();
-
- *gain_pit_fx = cdbk_fx[( index * 2 )]; /*Q14*/
- move16();
-
- L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/
- move32();
- gc_mem[2] = *gain_code_fx; /*Q16*/
- move32();
- gp_mem[2] = *gain_pit_fx; /*Q14*/
- move16();
- }
- ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
- {
- b_fx = b_4sfr_fx; /*Q12*/
- n_pred = 8;
- move16();
-
-
- cdbk_fx = gp_gamma_4sfr_6b_fx; /*Q14*/
-#ifdef IVAS_GAIN_MOD
- IF( EQ_16( nBits, 7 ) )
- {
- cdbk_fx = gp_gamma_4sfr_7b_fx;
- PMT( "verify if gp_gamma_4sfr_7b_fx is correct" )
- }
-#endif
-
- /* calculate predicted gain */
- aux_fx[0] = 4096; /*Q12*/
- move16();
- aux_fx[1] = shl( ctype, 12 ); /*Q12*/
- move16();
-
- /*aux[2] = (float)log10(gc_mem[0]);
- = log2(gc_mem[0])*log10(2);*/
- e_tmp = norm_l( gc_mem[0] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- /*aux[3] = (float)log10(gc_mem[1]);
- = log2(gc_mem[1])*log10(2);*/
- e_tmp = norm_l( gc_mem[1] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[1], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[1])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- /*aux[4] = (float)log10(gc_mem[2]);
- = log2(gc_mem[2])*log10(2);*/
- e_tmp = norm_l( gc_mem[2] );
- f_tmp = Log2_norm_lc( L_shl( gc_mem[2], e_tmp ) ); /*Q15*/
- e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[2])=16*/
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */
- aux_fx[4] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */
- move16();
-
- aux_fx[5] = shr( gp_mem[0], 2 ); /*Q12*/
- move16();
- aux_fx[6] = shr( gp_mem[1], 2 ); /*Q12*/
- move16();
- aux_fx[7] = shr( gp_mem[2], 2 ); /*Q12*/
- move16();
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, dotp(b, aux, n_pred)
- * = pow(2, 3.321928*dotp(b, aux, n_pred)
- *-----------------------------------------------------------------*/
- L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
- L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */
- L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
-
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
-
- /* retrieve the codebook index and calculate both gains */
- index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/
- move16();
- *gain_pit_fx = cdbk_fx[( index * 2 )]; /*Q14*/
- move16();
-
- L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/
- move32();
- }
-
- /* *norm_gain_code = *gain_code / *gain_inov; */
- expg = sub( norm_s( *gain_inov_fx ), 1 );
- expg = s_max( expg, 0 );
-
- tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx ); /*Q15*/
- *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); /*Q16*/
- move32();
-
- return;
-}
-#endif
-void gain_dec_lbr_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 coder_type, /* i : coding type */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 *code_fx, /* i : algebraic excitation Q9 */
- Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/
- Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
- Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/
- Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/
- Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/
- Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/
- const Word16 L_subfr /* i : subfr lenght */
-)
-{
- Word16 index, nBits, n_pred, ctype;
- Word16 gcode0_fx, aux_fx[10];
- Word32 L_tmp, L_tmp1, L_tmp2;
- Word16 expg, expg2, e_tmp, exp_gcode0, f_tmp, frac, tmp_fx;
- const Word16 *b_fx, *cdbk_fx = 0;
- /* Ecode = ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR;
- *gain_inov = 1.0f / (float)sqrt(Ecode); */
- Word16 shift_L_subfr;
- shift_L_subfr = 6;
- move16(); // for *cdbk_fx
- move16();
- if ( GT_16( L_subfr, L_SUBFR ) )
- {
- shift_L_subfr = add( shift_L_subfr, 1 );
- }
- L_tmp = Dot_product12( code_fx, code_fx, L_subfr, &expg ); /*Q31 - expg*/
- expg = sub( expg, add( 18, shift_L_subfr ) ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */
-
- expg2 = expg;
- move16();
- L_tmp2 = L_tmp; /* sets to 'L_tmp' in 1 clock */
- move32();
- L_tmp = Isqrt_lc( L_tmp, &expg ); /*Q31 - expg*/
-
- *gain_inov_fx = extract_h( L_shl_sat( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */
- move16();
-
- /*-----------------------------------------------------------------*
- * select the codebook, size and number of bits
- * set the gains searching range
- *-----------------------------------------------------------------*/
- nBits = st_fx->acelp_cfg.gains_mode[shr( i_subfr, shift_L_subfr )];
- move16();
-
- ctype = shl( sub( coder_type, 1 ), 1 );
-
/*-----------------------------------------------------------------*
* calculate prediction of gcode
* search for the best codeword
@@ -1583,24 +1213,28 @@ void lp_gain_updt_ivas_fx(
}
/*-------------------------------------------------*
- * Gain_dec_gaus_vbr
+ * gain_dec_gaus_fx()
*
* Decode gains of purely unvoiced sounds
*-------------------------------------------------*/
-Word32 gain_dec_gaus_fx( /* o : quantized codebook gain Q16 */
- Word16 index, /* i : quantization index */
- const Word16 bits, /* i : number of bits to quantize */
- const Word16 lowBound, /* i : lower bound of quantizer (dB) */
- const Word16 topBound, /* i : upper bound of quantizer (dB) */
- const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
- Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
+
+/*! r: quantized codebook gain Q16 */
+Word32 gain_dec_gaus_fx(
+ Word16 index, /* i : quantization index */
+ const Word16 bits, /* i : number of bits to quantize */
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) */
+ const Word16 topBound, /* i : upper bound of quantizer (dB) */
+ const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
+ Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
)
{
Word16 stepSize, gain, expg, frac, expi, tmp_igi;
Word32 L_tmp, L_enr_q, L_gain;
Word16 stepSize_Exp;
+
stepSize_Exp = 14;
move16();
+
/*------------------------------------------------------------------------------------------*
* Quantize linearly the log E
*------------------------------------------------------------------------------------------*/
diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c
index cf0fabc7647160864d050f62946949c15a7cd602..70639810c96f45a36538bd07ca0c86d911e3e6fa 100644
--- a/lib_dec/gs_dec_fx.c
+++ b/lib_dec/gs_dec_fx.c
@@ -23,7 +23,7 @@
/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */
/*--------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State *st_fx : decoder memory structure */
+/* Decoder_State *st_fx : decoder memory structure */
/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
/*--------------------------------------------------------------------------*/
@@ -31,439 +31,17 @@
/* _ None */
/*==========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void decod_audio_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
- const Word16 *Aq, /* i : LP filter coefficient Q12*/
- Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
- Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
- Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/
- ,
- Word16 *gain_buf /*Q14*/
-)
-{
- Word16 tmp_nb_bits_tot, pit_band_idx;
- Word16 code[4 * L_SUBFR];
- Word16 Diff_len, nb_subfr, i;
- Word16 nb_frame_flg;
- Word16 Es_pred = 0;
- Word16 Len, max_len;
- Word16 gsc_attack_flag;
-
- Word16 low_pit;
- Word16 last_bin;
- Word16 nbits;
-
- Word16 exc_wo_nf[L_FRAME16k];
- GSC_DEC_HANDLE hGSCDec;
- hGSCDec = st_fx->hGSCDec;
-
-
- /*---------------------------------------------------------------*
- * Initialization
- *---------------------------------------------------------------*/
- move16(); // corresponding to initialization of Es_pred
- Diff_len = 0;
- move16();
-
- /* decode GSC attack flag (used to reduce possible pre-echo) */
- gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */
- move16();
-
- /* decode GSC SWB speech flag */
- test();
- IF( st_fx->coder_type != INACTIVE && GE_32( st_fx->total_brate, ACELP_13k20 ) )
- {
- st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */
- move16();
- }
-
- /* safety check in case of bit errors */
- test();
- test();
- IF( st_fx->GSC_noisy_speech && LT_16( st_fx->bwidth, SWB ) && st_fx->GSC_IVAS_mode == 0 )
- {
- st_fx->BER_detect = 1; /* Q0 */
- move16();
- st_fx->GSC_noisy_speech = 0; /* Q0 */
- move16();
- }
-
- /* set bit-allocation */
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#else
- config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
-#endif
-
- /*---------------------------------------------------------------*
- * Decode energy dynamics
- *---------------------------------------------------------------*/
-
- IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) )
- {
- nb_subfr = NB_SUBFR; /* Q0 */
- move16();
- hGSCDec->cor_strong_limit = 0;
- move16();
- hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */
- move16();
- }
- ELSE
- {
- IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
- {
- hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2 ); /* Q0 */
- move16();
- }
- ELSE
- {
- hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 3 ), NOISE_LEVEL_SP0 ); /* Q0 */
- move16();
- }
-
- /*---------------------------------------------------------------*
- * Decode number of subframes
- *---------------------------------------------------------------*/
-
-
- hGSCDec->cor_strong_limit = 1; /* Q0 */
- move16();
- nb_subfr = SWNB_SUBFR;
- move16();
-
- IF( GE_32( st_fx->core_brate, ACELP_9k60 ) )
- {
- nbits = 1;
- move16();
- nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
- move16();
-
- IF( s_and( nb_frame_flg, 0x1 ) == 0 )
- {
- nb_subfr = 2 * SWNB_SUBFR; /* Q0 */
- move16();
- hGSCDec->cor_strong_limit = 0;
- move16();
- }
- }
- }
-
- /*---------------------------------------------------------------*
- * Decode the last band where the adaptive (pitch) contribution is significant
- *---------------------------------------------------------------*/
-
- IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) )
- {
- nbits = 3; /* Q0 */
- move16();
- test();
- if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type == INACTIVE )
- {
- nbits = 1; /* Q0 */
- move16();
- }
- }
- ELSE
- {
- nbits = 4; /* Q0 */
- move16();
- }
- test();
- IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE )
- {
- pit_band_idx = 1; /* Q0 */
- move16();
- }
- ELSE
- {
- pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */
- move16();
- }
-
- IF( pit_band_idx != 0 )
- {
- IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
- {
- pit_band_idx = 7 + BAND1k2; /* Q0 */
- move16(); /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */
- }
- ELSE
- {
- pit_band_idx = add( pit_band_idx, BAND1k2 ); /* Q0 */
- }
-
- /* detect bit errors in the bitstream */
- IF( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */
- {
- pit_band_idx = 13; /* Q0 */
- move16();
- st_fx->BER_detect = 1; /* Q0 */
- move16();
- }
- Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */
- move16();
- }
- hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */
- move16();
-
-
- /*--------------------------------------------------------------------------------------*
- * Decode adaptive (pitch) excitation contribution
- * Reset unvaluable part of the adaptive (pitch) excitation contribution
- *--------------------------------------------------------------------------------------*/
- IF( GT_16( pit_band_idx, BAND1k2 ) )
- {
- /*---------------------------------------------------------------*
- * Decode adaptive (pitch) excitation contribution
- *---------------------------------------------------------------*/
- test();
- IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) )
- {
- Word16 indice;
- nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */
- move16();
- if ( st_fx->element_mode > EVS_MONO )
- {
- nbits = 5;
- move16();
- }
-
- indice = get_next_indice_fx( st_fx, nbits ); /* Q0 */
-
- Es_pred_dec_fx( &Es_pred, indice, nbits, 0 );
- }
-
- dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf );
-
- IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
- {
- minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit );
- low_pit = shr( low_pit, 6 ); /*Q6 -> Q0 */
-
- IF( LT_16( low_pit, 64 ) )
- {
- pit_band_idx = 9 + BAND1k2; /* Q0 */
- move16();
- if ( st_fx->bwidth == NB )
- {
- pit_band_idx = 7 + BAND1k2; /* Q0 */
- move16();
- }
- }
- ELSE IF( LT_16( low_pit, 128 ) )
- {
- pit_band_idx = 5 + BAND1k2; /* Q0 */
- move16();
- }
- ELSE
- {
- pit_band_idx = 3 + BAND1k2; /* Q0 */
- move16();
- }
-
- Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */
- move16();
- hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */
- move16();
- }
-
- /*---------------------------------------------------------------*
- * DCT transform
- *---------------------------------------------------------------*/
- edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
-
- /*---------------------------------------------------------------*
- * Reset unvaluable part of the adaptive (pitch) excitation contribution
- *---------------------------------------------------------------*/
-
- max_len = sub( st_fx->L_frame, Diff_len ); /* Q0 */
-
- if ( st_fx->bwidth == NB )
- {
- max_len = sub( 160, Diff_len ); /* Q0 */
- }
-
- Len = 80;
- move16();
- if ( LT_16( max_len, 80 ) )
- {
- Len = max_len; /* Q0 */
- move16();
- }
-
- test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) )
- {
- FOR( i = 0; i < max_len; i++ )
- {
- dct_epit[i + Diff_len] = 0;
- move16();
- }
- }
- ELSE
- {
- FOR( i = 0; i < Len; i++ )
- {
- dct_epit[i + Diff_len] = mult_r( dct_epit[i + Diff_len], sm_table_fx[i] ); /* Qx */
- move16();
- }
-
- FOR( ; i < max_len; i++ )
- {
- dct_epit[i + Diff_len] = 0;
- move16();
- }
- }
- // PMT("in the rare case of 4 subfr, bfi_pitch_fx might be wrong")
- st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); /* Q6 */
- move16();
- st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */
- move16();
-
- Diff_len = add( Diff_len, 1 ); /* Q0 */
- st_fx->bpf_off = 0;
- move16();
- }
- ELSE
- {
- /* No adaptive (pitch) excitation contribution */
- st_fx->bpf_off = 1; /* Q0 */
- move16();
- set16_fx( dct_epit, 0, st_fx->L_frame );
-
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- set16_fx( pitch_buf, L_SUBFR16k * 64, NB_SUBFR16k );
- }
- ELSE
- {
- set16_fx( pitch_buf, L_SUBFR * 64, NB_SUBFR );
- }
-
- set16_fx( gain_buf, 0, NB_SUBFR16k );
-
- st_fx->bfi_pitch_fx = L_SUBFR * 64;
- move16();
- st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */
- move16();
- st_fx->lp_gainp_fx = 0;
- move16();
- st_fx->lp_gainc_fx = 0;
- move16();
- st_fx->tilt_code_fx = 0;
- move16();
- pit_band_idx = 0;
- move16();
- Diff_len = 0;
- move16();
- }
-
- /*--------------------------------------------------------------------------------------*
- * GSC decoder
- *--------------------------------------------------------------------------------------*/
-
- /* find the current total number of bits used */
-
- tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */
- move16();
-
- if ( st_fx->extl_brate > 0 )
- {
- /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
- tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */
- }
-
- test();
- if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) )
- {
- tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */
- }
-
- gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc );
- /*--------------------------------------------------------------------------------------*
- * iDCT transform
- *--------------------------------------------------------------------------------------*/
-
- edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
- edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode );
- /*----------------------------------------------------------------------*
- * Remove potential pre-echo in case an onset has been detected
- *----------------------------------------------------------------------*/
-
- pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame );
-
- /*--------------------------------------------------------------------------------------*
- * Update BWE excitation
- *--------------------------------------------------------------------------------------*/
-
- IF( st_fx->hBWE_TD != NULL )
- {
- set16_fx( voice_factors, 0, NB_SUBFR16k );
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- interp_code_4over2_fx( exc, bwe_exc, st_fx->L_frame );
- }
- ELSE
- {
- interp_code_5over2_fx( exc, bwe_exc, L_FRAME );
- }
- }
- /*--------------------------------------------------------------------------------------*
- * Updates
- *--------------------------------------------------------------------------------------*/
-
- Copy( exc, exc2, st_fx->L_frame ); /* Q_exc */
- Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_exc */
-
- /*--------------------------------------------------------------------------------------*
- * Channel aware mode parameters
- *--------------------------------------------------------------------------------------*/
-
- set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k );
-
- return;
-}
-
-/*=========================================================================*/
-/* FUNCTION : void decod_audio_ivas_fx(); */
-/*-------------------------------------------------------------------------*/
-/* PURPOSE : Decode audio (AC) frames */
-/*-------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16[]) Aq : LP filter coefficient Q12 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _(Word16) Q_exc :Q format of excitation */
-/*-------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16[]) pitch_buf_fx : Word16 pitch values for each subframe Q6*/
-/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State *st_fx : decoder memory structure */
-/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */
-/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*==========================================================================*/
-#endif
-void decod_audio_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder static memory */
- Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
- const Word16 *Aq, /* i : LP filter coefficient Q12*/
- Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
- Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
- Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/
- ,
- Word16 *gain_buf, /*Q14*/
+ Decoder_State *st_fx, /* i/o: decoder static memory */
+ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/
+ const Word16 *Aq, /* i : LP filter coefficient Q12*/
+ Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/
+ Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/
+ Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
+ Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/
const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/
const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
@@ -525,7 +103,7 @@ void decod_audio_ivas_fx(
}
/* set bit-allocation */
- config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
/*---------------------------------------------------------------*
* Decode energy dynamics
@@ -735,7 +313,7 @@ void decod_audio_ivas_fx(
Es_pred_dec_fx( &Es_pred, indice, nbits, 0 );
}
- dec_pit_exc_ivas_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
+ dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf );
IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
{
@@ -894,7 +472,7 @@ void decod_audio_ivas_fx(
Word16 Q_exc_old = st_fx->Q_exc;
move16();
- gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc );
+ gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc );
IF( NE_16( Q_exc_old, st_fx->Q_exc ) )
{
@@ -976,250 +554,17 @@ void decod_audio_ivas_fx(
/* _None */
/*==========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void gsc_dec_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
- const Word16 pit_band_idx, /* i : bin position of the cut-off frequency Q0*/
- const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/
- const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/
- const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
- const Word16 coder_type, /* i : coding type Q0*/
- Word16 *last_bin, /* i : last bin of bit allocation Q0*/
- const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
- Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
- Word16 Q_exc )
-{
- Word16 i, j, bit, nb_subbands, pvq_len;
- Word16 bitallocation_band[MBANDS_GN_BITALLOC16k];
- Word16 bitallocation_exc[2];
- Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k];
- Word16 max_ener_band[MBANDS_GN_BITALLOC16k];
- Word16 exc_diffQ[L_FRAME16k];
- Word16 bits_per_bands[MBANDS_GN_BITALLOC16k];
- Word16 concat_out[L_FRAME16k];
- Word16 inpulses_fx[NB_SFM];
- Word16 imaxpulse_fx[NB_SFM];
- Word16 mean_gain;
- Word16 Mbands_gn = 16;
- Word16 Qexc_diffQ = Q_PVQ_OUT;
- Word32 L_tmp;
- Word16 Q_tmp;
- Word16 seed_init;
- GSC_DEC_HANDLE hGSCDec;
- hGSCDec = st_fx->hGSCDec;
- move16();
- move16();
-
- move16(); // for Mbands_gn
- move16(); // for Qexc_diffQ
- set16_fx( inpulses_fx, 0, NB_SFM );
- set16_fx( imaxpulse_fx, 0, NB_SFM );
-
- /*--------------------------------------------------------------------------------------*
- * Initialization
- *--------------------------------------------------------------------------------------*/
- bit = bits_used;
- move16();
-
- set16_fx( exc_diffQ, 0, st_fx->L_frame );
-
- /*--------------------------------------------------------------------------------------*
- * Gain decoding
- *--------------------------------------------------------------------------------------*/
-
- test();
- IF( st_fx->bfi || st_fx->BER_detect )
- {
- /* copy old gain */
- Copy( hGSCDec->old_y_gain_fx, Ener_per_bd_iQ, Mbands_gn ); /* Q_old_gain */
- mean_gain = mult_r( st_fx->lp_gainc_fx, 3277 ); /*Q3*/
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- Ener_per_bd_iQ[i] = add( Ener_per_bd_iQ[i], shl( mean_gain, 9 ) ); /*Q12*/
- move16();
- }
-
- st_fx->lp_gainc_fx = mult_r( st_fx->lp_gainc_fx, 32112 ); /*Q3*/
- move16();
- }
- ELSE
- {
- mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q12 */
-
- st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
- move16();
- }
-
- *last_bin = 0;
- move16();
- test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
- {
- bitallocation_exc[0] = 0;
- move16();
- bitallocation_exc[1] = 0;
- move16();
- }
-
- set16_fx( bitallocation_band, 0, MBANDS_GN );
-
- test();
- IF( ( EQ_16( st_fx->bfi, 1 ) ) || st_fx->BER_detect )
- {
- /*--------------------------------------------------------------------------------------*
- * Copy old spectrum
- * reduce spectral dynamic
- * save spectrum
- *--------------------------------------------------------------------------------------*/
-
- test();
- IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) )
- {
- FOR( i = 0; i < st_fx->L_frame; i++ )
- {
- L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/
- L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /* Q10 */
- hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/
- move16();
- }
- }
-
- Copy( hGSCDec->Last_GSC_spectrum_fx, exc_diffQ, st_fx->L_frame ); /* Q10 */
-
- FOR( i = 0; i < st_fx->L_frame; i++ )
- {
- hGSCDec->Last_GSC_spectrum_fx[i] = mult_r( hGSCDec->Last_GSC_spectrum_fx[i], 24576 ); /*Q10*/
- move16();
- }
- }
- ELSE
- {
- /*--------------------------------------------------------------------------------------*
- * PVQ decoder
- *--------------------------------------------------------------------------------------*/
-
- bands_and_bit_alloc_fx( hGSCDec->cor_strong_limit, hGSCDec->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ,
- max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech,
- st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
-
- {
- pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
- Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
- }
- seed_init = 0;
- move16();
-
- /* Reorder Q bands */
- FOR( j = 0; j < nb_subbands; j++ )
- {
- Copy( concat_out + shl( j, 4 ), exc_diffQ + shl( max_ener_band[j], 4 ), 16 ); /* Q_PVQ_OUT */
-
- *last_bin = s_max( *last_bin, max_ener_band[j] ); /* Q0 */
- move16();
-
- bitallocation_band[max_ener_band[j]] = 1; /* Q0 */
- move16();
-
- seed_init = add( seed_init, inpulses_fx[j] ); /* Q0 */
- }
- test();
- IF( NE_16( st_fx->last_coder_type, AUDIO ) /* First audio frame */
- && NE_16( st_fx->last_coder_type, UNVOICED ) ) /* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */
- {
- FOR( j = 0; j < nb_subbands * 16; j++ )
- {
- IF( concat_out[j] > 0 )
- {
- seed_init = extract_l( L_shl( seed_init, 3 ) ); /* Q0 */
- }
- if ( concat_out[j] < 0 )
- {
- seed_init = add( seed_init, 3 ); /* Q0 */
- move16();
- }
- }
-
- hGSCDec->seed_tcx = seed_init; /* Q0 */
- move16();
- }
- test();
- IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB )
- {
- if ( exc_diffQ[L_FRAME8k - 2] != 0 )
- {
- bitallocation_exc[0] = 1; /* Q0 */
- move16();
- }
-
- if ( exc_diffQ[L_FRAME8k - 1] != 0 )
- {
- bitallocation_exc[1] = 1; /* Q0 */
- move16();
- }
- }
-
- Copy( exc_diffQ, hGSCDec->Last_GSC_spectrum_fx, st_fx->L_frame ); /* Q_PVQ_OUT */
-
- /*--------------------------------------------------------------------------------------*
- * Skip adaptive (pitch) contribution frequency band (no noise added over the time contribution)
- * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal
- * Gain is based on the inter-correlation gain between the pulses found and residual signal
- *--------------------------------------------------------------------------------------*/
-
- freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame );
- }
-
- /*--------------------------------------------------------------------------------------*
- * Estimate noise level
- *--------------------------------------------------------------------------------------*/
-
- highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ,
- &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new,
- hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type,
- st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
-
- exc_dct_in[0] = 0;
- move16();
-
- return;
-}
-
-/*==========================================================================*/
-/* FUNCTION : void gsc_dec_ivas_fx () */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : Generic audio signal decoder */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) pit_band_idx : bin position of the cut-off frequency Q0 */
-/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _ (Word16) bits_used : Number of bit used before frequency Q Q0 */
-/* _ (Word16) nb_subfr : Number of subframe considered Q0 */
-/* _ (Word16) Qexc : Q format of exc_dct_in */
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ None */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State *st_fx:Decoder State Structure */
-/* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Qexc*/
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _None */
-/*==========================================================================*/
-#endif
-void gsc_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
+ Decoder_State *st_fx, /* i/o: State structure */
+ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/
const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/
const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/
const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
const Word16 coder_type, /* i : coding type Q0*/
Word16 *last_bin, /* i : last bin of bit allocation Q0*/
- const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
- Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
+ const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/
+ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
Word16 *Q_exc )
{
Word16 i, j, bit, nb_subbands, pvq_len;
@@ -1310,13 +655,11 @@ void gsc_dec_ivas_fx(
i--;
}
-#ifdef REMOVE_EVS_DUPLICATES
IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
}
ELSE
-#endif
{
mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
}
diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c
index 38ec5b943407e373e2c2ad240e48d8987892cf30..40012175640da7963da6eb8fbda62bc83507ad23 100644
--- a/lib_dec/ivas_core_dec_fx.c
+++ b/lib_dec/ivas_core_dec_fx.c
@@ -516,7 +516,7 @@ ivas_error ivas_core_dec_fx(
Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, add( M, 1 ), sub( norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ), 3 ) ); // Qx
}
- IF( NE_32( ( error = acelp_core_dec_ivas_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
{
return error;
}
diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
index 890e5fc9ef6db902a60454e094612449ceac424c..89cb92a4d08c1b9f834610892fdd5ce2dc73c68c 100644
--- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c
+++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
@@ -1097,8 +1097,8 @@ static void run_min_stats_fx(
{
arr_tmp = power_spec;
}
- ApplyFdCng_ivas_fx( NULL, 0, arr_tmp, power_spec_q, NULL, NULL, NULL, st, st->bfi, 0 );
- /*=================================================*/
+
+ ApplyFdCng_fx( NULL, 0, arr_tmp, power_spec_q, NULL, NULL, NULL, st, st->bfi, 0 );
}
/* restore VAD (see above) */
diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c
index aa5a379e87c316892f9f161dd48749c31e46ede7..0be01f7b88612b359fb0b5b88b1fda3028fdeceb 100644
--- a/lib_dec/ivas_tcx_core_dec_fx.c
+++ b/lib_dec/ivas_tcx_core_dec_fx.c
@@ -875,11 +875,11 @@ void stereo_tcx_core_dec_fx(
{
Word16 buffer[L_FRAME16k];
lerp( signal_outFB_fx, buffer, st->L_frame, hTcxDec->L_frameTCX );
- ApplyFdCng_ivas_fx( buffer, 0 /* Q of buffer */, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
+ ApplyFdCng_fx( buffer, 0 /* Q of buffer */, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
}
ELSE
{
- ApplyFdCng_ivas_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
+ ApplyFdCng_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
}
}
@@ -915,7 +915,7 @@ void stereo_tcx_core_dec_fx(
test();
IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->idchan == 0 )
{
- ApplyFdCng_ivas_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
+ ApplyFdCng_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 );
}
}
@@ -923,6 +923,7 @@ void stereo_tcx_core_dec_fx(
return;
}
+
static void stereo_tcx_dec_mode_switch_reconf_ivas_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c
index 3191a8b4abcdcd54fb80589a75dbfa64a9b3b950..6419f851707619786e1b829b5736688777677897 100644
--- a/lib_dec/ivas_td_low_rate_dec_fx.c
+++ b/lib_dec/ivas_td_low_rate_dec_fx.c
@@ -40,6 +40,13 @@
#include "prot_fx.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
+
+/*-------------------------------------------------------------------*
+ * tdm_low_rate_dec_fx()
+ *
+ * Low-bitrate decoder
+ *-------------------------------------------------------------------*/
+
void tdm_low_rate_dec_fx(
Decoder_State *st, /* i/o: decoder static memory */
Word16 dct_epit[], /* o : GSC excitation in DCT domain Q_exc*/
@@ -127,7 +134,7 @@ void tdm_low_rate_dec_fx(
tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */
}
- gsc_dec_ivas_fx( st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, &st->Q_exc );
+ gsc_dec_fx( st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, &st->Q_exc );
/*--------------------------------------------------------------------------------------*
* iDCT transform
@@ -188,19 +195,15 @@ void tdm_low_rate_dec_fx(
return;
}
+
/*---------------------------------------------------------------------*
* decod_gen_2sbfr()
*
* Decode generic (GC), 2 subframes mode
*---------------------------------------------------------------------*/
-/*---------------------------------------------------------------------*
- * decod_gen_2sbfr_ivas_fx()
- *
- * Decode generic (GC), 2 subframes mode
- *---------------------------------------------------------------------*/
-void decod_gen_2sbfr_ivas_fx(
- Decoder_State *st, /* i/o: decoder static memory */
+void decod_gen_2sbfr_fx(
+ Decoder_State *st, /* i/o: decoder static memory */
const Word16 sharpFlag, /* i : formant sharpening flag `Q0*/
const Word16 *Aq, /* i : LP filter coefficient Q12*/
Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/
@@ -222,12 +225,12 @@ void decod_gen_2sbfr_ivas_fx(
move32();
Word16 gain_inov = 0; /* Innovation gain */
move16();
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */
+ Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
+ Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */
Word16 voice_fac; /* voicing factor */
Word16 code[2 * L_SUBFR]; /* algebraic codevector */
const Word16 *p_Aq; /* Pointer to frame LP coefficient */
- Word16 *pt_pitch; /* pointer to Word16 pitch */
+ Word16 *pt_pitch; /* pointer to Word16 pitch */
Word16 i_subfr; /* tmp variables */
Word16 L_frame;
Word16 pitch_limit_flag;
@@ -263,7 +266,7 @@ void decod_gen_2sbfr_ivas_fx(
* Decode pitch lag
*----------------------------------------------------------------------*/
- *pt_pitch = pit_decode_ivas_fx( st, st->core_brate, 0, L_frame, i_subfr, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, 2 * L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
+ *pt_pitch = pit_decode_fx( st, st->core_brate, 0, L_frame, i_subfr, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, 2 * L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
test();
test();
@@ -295,7 +298,7 @@ void decod_gen_2sbfr_ivas_fx(
* Estimate spectrum tilt and voicing
*--------------------------------------------------------------*/
- gain_dec_lbr_ivas_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR );
+ gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR );
st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */
move16();
@@ -312,10 +315,12 @@ void decod_gen_2sbfr_ivas_fx(
Word16 gain_code16 = round_fx( L_shl( gain_code, st->Q_exc ) ); /*Q_exc*/
Acelp_dec_total_exc( exc, exc2, gain_code16, gain_pit, i_subfr, code, 2 * L_SUBFR );
+
/*-----------------------------------------------------------------*
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- prep_tbe_exc_ivas_fx( L_frame, 2 * L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
+
+ prep_tbe_exc_fx( L_frame, 2 * L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/]; /* Q15 */
move16();
@@ -323,6 +328,7 @@ void decod_gen_2sbfr_ivas_fx(
* Excitation enhancements (update of total excitation signal)
* called twice because adapting it to double the subfr length would need lot of modifications
*----------------------------------------------------------------*/
+
enhancer_ivas_fx2( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code, exc2, gain_pit, &st->dm_fx, st->Q_exc );
enhancer_ivas_fx2( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code + L_SUBFR, exc2 + L_SUBFR, gain_pit, &st->dm_fx, st->Q_exc );
diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c
index 9b7f77c79845d42f4fcd81d0220c0cebeb68854a..913543db8c6b90d0f51beb13a097845f34b0b746 100644
--- a/lib_dec/lsf_dec_fx.c
+++ b/lib_dec/lsf_dec_fx.c
@@ -8,9 +8,11 @@
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h" /* Function prototypes */
#include "ivas_prot_fx.h"
+
/*-------------------------------------------------------------------*
* Local functions
*-------------------------------------------------------------------*/
+
static void dqlsf_CNG_fx( Decoder_State *st_fx, Word16 *lsf_q );
/*--------------------------------------------------------------------------------------*
@@ -88,7 +90,6 @@ static void dqlsf_CNG_fx(
/* _ (Word16*) lsp_new : LP filter coefficient Q15 */
/* _ (Word16*) lsp_mid : LP filter coefficient Q15 */
/*---------------------------------------------------------------------------*/
-
/* _ (Word16[]) st_fx->lsf_adaptive_mean_fx : FEC - adaptive mean LSF */
/* vector for FEC Q(x2.56) */
/* _ (Word16[]) st_fx->mem_AR_fx : AR memory of LSF quantizer */
@@ -99,271 +100,16 @@ static void dqlsf_CNG_fx(
/* _ None */
/*===========================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
void lsf_dec_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 tc_subfr, /* i : TC subframe index Q0*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
- Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
- Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
- const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/
- ,
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
-)
-{
- Word16 i;
- Word16 no_param_lpc;
- Word16 param_lpc[NPRM_LPC_NEW];
- Word32 L_tmp;
- Word16 nBits = 0;
- move16();
- Word16 tmp_old[M + 1], tmp_new[M + 1];
- Word16 enr_old = 0, enr_new = 0;
- move16();
- move16();
- Word16 lsf_diff, coder_type;
-
- /* initialize */
- coder_type = st_fx->coder_type;
- if ( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- coder_type = INACTIVE; /* Q0 */
- move16();
- }
- test();
- if ( EQ_16( coder_type, AUDIO ) && st_fx->GSC_IVAS_mode > 0 )
- {
- coder_type = GENERIC; /* Q0 */
- move16();
- }
- no_param_lpc = 0;
- nBits = 0;
- move16();
- move16();
-
- /* Find the number of bits for LSF quantization */
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- nBits = LSF_BITS_CNG; /* Q0 */
- move16();
- }
- ELSE
- {
- test();
- IF( st_fx->nelp_mode_dec == 0 && st_fx->ppp_mode_dec == 0 )
- {
- nBits = st_fx->acelp_cfg.lsf_bits; /* Q0 */
- move16();
- }
- ELSE IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
- {
- IF( EQ_16( coder_type, UNVOICED ) )
- {
- nBits = 30; /* Q0 */
- move16();
- if ( st_fx->bwidth == NB )
- {
- nBits = 32; /* Q0 */
- move16();
- }
- }
- }
- ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) )
- {
- nBits = 26; /* Q0 */
- move16();
- }
- }
-
- /* LSF de-quantization */
- lsf_end_dec_fx( st_fx, 0, coder_type, st_fx->bwidth, nBits, lsf_new, param_lpc, LSF_Q_prediction, &no_param_lpc,
- tdm_lsfQ_PCh );
-
- /* convert quantized LSFs to LSPs */
-
- lsf2lsp_fx( lsf_new, lsp_new, M, st_fx->sr_core );
- /* set seed_acelp used in UC mode */
- test();
- IF( EQ_16( coder_type, UNVOICED ) && GT_16( st_fx->element_mode, EVS_MONO ) )
- {
- st_fx->seed_acelp = 0;
- move16();
- FOR( i = no_param_lpc - 1; i >= 0; i-- )
- {
- /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/
- st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L /* Q0 */, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L /* Q0 */ ) ); /* Q0 */
- move16();
- }
- }
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* return if SID frame (conversion to A(z) done in the calling function) */
- return;
- }
-
- /*-------------------------------------------------------------------------------------*
- * FEC - update adaptive LSF mean vector
- *-------------------------------------------------------------------------------------*/
-
- FOR( i = 0; i < M; i++ )
- {
- L_tmp = L_mult( lsf_new[i], 10922 ); /*Q(x2.56+16)*/
- L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi1_fx[i], 10922 ); /*Q(x2.56+16)*/
- L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi0_fx[i], 10922 ); /*Q(x2.56+16)*/
- st_fx->lsf_adaptive_mean_fx[i] = round_fx( L_tmp ); /*Q(x2.56)*/
- move16();
- }
-
- test();
- test();
- IF( ( st_fx->prev_bfi && ( EQ_16( coder_type, TRANSITION ) ) && ( EQ_16( tc_subfr, sub( st_fx->L_frame, L_SUBFR ) ) ) ) )
- {
- lsf_diff = 1205;
- move16(); /*int_fs / (float)(2*(M+1)); = 470.588 -> 1205 in Q2.56 */
- if ( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- lsf_diff = 964;
- move16(); /*int_fs / (float)(2*(M+1)); = 376.47 -> 964 in Q2.56 */
- }
- st_fx->lsf_old_fx[0] = lsf_diff;
- move16();
-
- FOR( i = 1; i < M; i++ )
- {
- st_fx->lsf_old_fx[i] = add( st_fx->lsf_old_fx[i - 1], lsf_diff ); /* Q2.56 */
- move16();
- }
- lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, st_fx->sr_core );
- }
- /*-------------------------------------------------------------------------------------*
- * Mid-frame LSF decoding
- * LSP interpolation and conversion of LSPs to A(z)
- *-------------------------------------------------------------------------------------*/
- IF( st_fx->rate_switching_reset )
- {
- /*extrapolation in case of unstable LSF convert*/
- Copy( lsp_new, st_fx->lsp_old_fx, M ); /* Q15 */
- Copy( lsf_new, st_fx->lsf_old_fx, M ); /* Q2.56 */
- }
- {
- /* Mid-frame LSF decoding */
- lsf_mid_dec_fx( st_fx, lsp_new, coder_type, lsp_mid );
- }
- test();
- test();
- IF( !( st_fx->prev_bfi && ( EQ_16( coder_type, TRANSITION ) ) && ( EQ_16( tc_subfr, sub( st_fx->L_frame, L_SUBFR ) ) ) ) )
- {
- IF( st_fx->prev_bfi )
- {
- /* check, if LSP interpolation can be relaxed */
- E_LPC_f_lsp_a_conversion( st_fx->lsp_old_fx, tmp_old, M );
- enr_old = Enr_1_Az_fx( tmp_old, 2 * L_SUBFR ); /* Q3 */
-
- E_LPC_f_lsp_a_conversion( lsp_new, tmp_new, M );
- enr_new = Enr_1_Az_fx( tmp_new, 2 * L_SUBFR ); /* Q3 */
-
- IF( LT_16( enr_new, mult_r( 9830 /*0.3 Q15*/, enr_old ) ) )
- {
- /* OLD CODE : if( st->safety_net == 1), replaced with a decision similar to MODE2 */
- st_fx->relax_prev_lsf_interp = -1;
- move16();
- test();
- test();
- test();
- test();
- if ( st_fx->clas_dec == UNVOICED_CLAS || EQ_16( st_fx->clas_dec, SIN_ONSET ) || st_fx->clas_dec == INACTIVE_CLAS || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) )
- {
- st_fx->relax_prev_lsf_interp = 1;
- move16();
- }
- }
- }
- }
- test();
- IF( EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->core == ACELP_CORE )
- {
- /* update old LSPs/LSFs in case of HQ->ACELP core switching */
- Copy( lsp_mid, st_fx->lsp_old_fx, M ); /* Q15 */
- lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, st_fx->sr_core ); /* Q15 */
- }
- test();
- IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) )
- {
- // PMT("To be verified")
- IF( EQ_16( st_fx->active_cnt, 1 ) )
- {
- Copy( lsp_mid, st_fx->lsp_old_fx, M ); /* Q15 */
- lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, st_fx->sr_core ); /* Q15 */
- Copy( lsp_new, lsp_mid, M ); /* Q15 */
- }
-
- /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */
- int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 );
- }
- ELSE
- {
- /* LSP interpolation and conversion of LSPs to A(z) */
- int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp );
- }
- /*------------------------------------------------------------------*
- * Check LSF stability (distance between old LSFs and current LSFs)
- *------------------------------------------------------------------*/
-
- IF( st_fx->element_mode == EVS_MONO )
- {
- st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); /*Q15*/
- move16();
- }
- ELSE
- {
- st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); /* Q15 */
- move16();
- }
-
- return;
-}
-
-/*===========================================================================*/
-/* FUNCTION : lsf_dec_ivas_fx() */
-/*---------------------------------------------------------------------------*/
-/* PURPOSE : LSF decoder */
-/*---------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Struct) st_fx : decoder static memory */
-/* _ (Word16) L_frame : length of the frame */
-/* _ (Word16) coder_type : coding type */
-/* _ (Word16) bwidth : input signal bandwidth */
-/*---------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) Aq : LP filter coefficient Q12 */
-/* _ (Word16*) lsf_new : LP filter coefficient Q(x2.56) */
-/* _ (Word16*) lsp_new : LP filter coefficient Q15 */
-/* _ (Word16*) lsp_mid : LP filter coefficient Q15 */
-/*---------------------------------------------------------------------------*/
-
-/* _ (Word16[]) st_fx->lsf_adaptive_mean_fx : FEC - adaptive mean LSF */
-/* vector for FEC Q(x2.56) */
-/* _ (Word16[]) st_fx->mem_AR_fx : AR memory of LSF quantizer */
-/* (past quantized LSFs without mean) Q(x2.56) */
-/* _ (Word16) st_fx->stab_fac_fx : LSF stability factor Q15 */
-/*---------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*===========================================================================*/
-#endif
-void lsf_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 tc_subfr, /* i : TC subframe index Q0*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
- Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
- Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
- const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/
- ,
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
+ Decoder_State *st_fx, /* i/o: State structure */
+ const Word16 tc_subfr, /* i : TC subframe index Q0*/
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
+ Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/
+ Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/
+ Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/
+ Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/
+ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/
+ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/
)
{
Word16 i;
diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c
index e8cebedbdd98861e9398f70087cbbd5f11f8214d..38ec41cb209c196f3333a972a2195ff8f4c0aa46 100644
--- a/lib_dec/pit_dec_fx.c
+++ b/lib_dec/pit_dec_fx.c
@@ -319,246 +319,22 @@ void Mode2_delta_pit_dec(
/* _ (Word16 ) pitch : close loop integer pitch Q6 */
/*=======================================================================*/
-#ifndef REMOVE_EVS_DUPLICATES
-Word16 pit_decode_fx( /* o : floating pitch value */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : coding type */
- Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
- Word16 *T0, /* o : close loop integer pitch */
- Word16 *T0_frac, /* o : close loop fractional part of the pitch */
- Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
- Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
- const Word16 L_subfr /* i : subframe length */
-)
-{
- Word16 pitch; /*Q2*/
- Word16 pitch_index, nBits, pit_flag;
-
- pitch_index = 0;
- move16();
-
- /*----------------------------------------------------------------*
- * Set pit_flag = 0 for every subframe with absolute pitch search
- *----------------------------------------------------------------*/
- pit_flag = i_subfr;
- move16();
-
- if ( EQ_16( i_subfr, PIT_DECODE_2XL_SUBFR ) )
- {
- pit_flag = 0;
- move16();
- }
-
- /*-------------------------------------------------------*
- * Retrieve the pitch index
- *-------------------------------------------------------*/
- IF( !Opt_AMR_WB )
- {
- /*----------------------------------------------------------------*
- * pitch Q: Set limit_flag to 0 for restrained limits, and 1 for extended limits
- *----------------------------------------------------------------*/
- test();
- test();
- IF( i_subfr == 0 )
- {
- *limit_flag = 1;
- move16();
-
- if ( EQ_16( coder_type, VOICED ) )
- {
- *limit_flag = 2;
- move16(); /* double-extended limits */
- }
- test();
- if ( EQ_16( coder_type, GENERIC ) && EQ_32( core_brate, ACELP_7k20 ) )
- {
- *limit_flag = 0;
- move16();
- }
- }
- ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) && EQ_32( coder_type, GENERIC ) && LE_32( core_brate, ACELP_13k20 ) )
- {
- if ( GT_16( *T0, shr( add( PIT_FR1_EXTEND_8b, PIT_MIN ), 1 ) ) )
- {
- *limit_flag = 0;
- move16();
- }
- }
-
- /*-------------------------------------------------------*
- * Retrieve the number of Q bits
- *-------------------------------------------------------*/
-
- nBits = 0;
- move16();
- IF( NE_16( coder_type, AUDIO ) )
- {
- /* find the number of bits */
- nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )];
- move16();
- pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
- }
-
- /*-------------------------------------------------------*
- * Pitch decoding in AUDIO mode
- * (both ACELP@12k8 and ACELP@16k cores)
- *-------------------------------------------------------*/
- IF( EQ_16( coder_type, AUDIO ) )
- {
- test();
- if ( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 )
- {
- pit_flag = L_SUBFR;
- move16();
- }
- if ( pit_flag == 0 )
- {
- nBits = 10;
- move16();
- }
- if ( pit_flag != 0 )
- {
- nBits = 6;
- move16();
- }
-
- pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
-
- test();
- test();
- IF( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 && GE_16( pitch_index, 32 ) ) /* safety check in case of bit errors */
- {
- pitch_index = shr( pitch_index, 1 );
- st_fx->BER_detect = 1;
- move16();
- }
-
- pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
- ELSE IF( EQ_16( coder_type, VOICED ) )
- {
- /*-------------------------------------------------------*
- * Pitch decoding in VOICED mode
- * (ACELP@12k8 core only)
- *-------------------------------------------------------*/
- if ( EQ_16( i_subfr, 2 * L_SUBFR ) )
- {
- pit_flag = i_subfr;
- move16();
- }
-
- pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
- ELSE
- {
- /*-------------------------------------------------------*
- * Pitch decoding in GENERIC mode
- * (both ACELP@12k8 and ACELP@16k cores)
- *-------------------------------------------------------*/
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- pit_Q_dec_fx( 0, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
- ELSE
- {
- pit16k_Q_dec_fx( pitch_index, nBits, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
- }
- }
-
- /*-------------------------------------------------------*
- * Pitch decoding in AMR-WB IO mode
- *-------------------------------------------------------*/
-
- ELSE
- {
- *limit_flag = 0;
- move16();
- test();
- test();
- IF( i_subfr == 0 || ( EQ_16( i_subfr, 2 * L_SUBFR ) && EQ_32( core_brate, ACELP_8k85 ) ) )
- {
- nBits = 8;
- move16();
- }
- ELSE
- {
- nBits = 5;
- move16();
- }
- IF( GT_32( core_brate, ACELP_8k85 ) )
- {
- nBits = 6;
- move16();
- test();
- if ( i_subfr == 0 || EQ_16( i_subfr, 2 * L_SUBFR ) )
- {
- nBits = 9;
- move16();
- }
- }
-
- pitch_index = (Word16) get_next_indice_fx( st_fx, nBits );
-
- pit_Q_dec_fx( 1, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect );
- }
-
- /*-------------------------------------------------------*
- * Compute floating pitch output
- *-------------------------------------------------------*/
-
- pitch = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); /* save subframe pitch values Q6 */
-
- return pitch;
-}
-
-/*======================================================================*/
-/* FUNCTION : pit_decode_ivas_fx() */
-/*-----------------------------------------------------------------------*/
-/* PURPOSE : calculate pitch value */
-/* */
-/*-----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word32) core_brate : Core bitrate Q0 */
-/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */
-/* _ (Word16) L_frame : length of the frame Q0 */
-/* _ (Word16) i_subfr : length of the frame Q0 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _ (Word16) L_subfr : subframe length */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16 *) T0 : close loop integer pitch */
-/* _ (Word16 *) T0_frac : close loop fractional part of the pitch */
-/* _ (Word16 ) pitch : pitch value Q6 */
-/*-----------------------------------------------------------------------*/
-/* INPUT OUTPUT ARGUMENTS */
-/* _ (Word16 *) T0_min : delta search min for sf 2 & 4 */
-/* _ (Word16 *) T0_max : delta search max for sf 2 & 4 */
-/*-----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ (Word16 ) pitch : close loop integer pitch Q6 */
-/*=======================================================================*/
-
-#endif
-Word16 pit_decode_ivas_fx( /* o : floating pitch value */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- Word16 i_subfr, /* i : subframe index */
- const Word16 coder_type, /* i : coding type */
- Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
- Word16 *T0, /* o : close loop integer pitch */
- Word16 *T0_frac, /* o : close loop fractional part of the pitch */
- Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
- Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
- const Word16 L_subfr, /* i : subframe length */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
+/*! r: floating pitch value */
+Word16 pit_decode_fx(
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 i_subfr, /* i : subframe index */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
+ Word16 *T0, /* o : close loop integer pitch */
+ Word16 *T0_frac, /* o : close loop fractional part of the pitch */
+ Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
+ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
+ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */
)
{
Word16 pitch; /*Q2*/
diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c
index b5d56d8fb9359db6b4daf5012bd70cc2349ac2bf..cbcb225bc1c845d937119028fb6fcc025a19cfeb 100644
--- a/lib_dec/post_dec_fx.c
+++ b/lib_dec/post_dec_fx.c
@@ -139,21 +139,13 @@ void post_decoder(
{
st->hPFstat->on = 1;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 );
-#else
formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 );
-#endif
}
ELSE
{
st->hPFstat->on = 0;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 );
-#else
formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 );
-#endif
}
}
@@ -176,10 +168,10 @@ void post_decoder(
/* Update synth2 memory */
Copy( synth_buf2 + L_frame, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX );
-
return;
}
+
void post_decoder_ivas_fx(
Decoder_State *st,
Word16 synth_buf[], // Q0
@@ -310,21 +302,13 @@ void post_decoder_ivas_fx(
{
st->hPFstat->on = 1;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 );
-#else
formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 );
-#endif
}
ELSE
{
st->hPFstat->on = 0;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 );
-#else
formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 );
-#endif
}
}
diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c
index 4c3f7152cbde53f21bea6b4713f6a276a04b3236..ceba860a13880c6421e7c382a9adec73eb18d95d 100644
--- a/lib_enc/acelp_core_enc_fx.c
+++ b/lib_enc/acelp_core_enc_fx.c
@@ -394,14 +394,10 @@ ivas_error acelp_core_enc_fx(
test();
IF( !nelp_mode && !ppp_mode )
{
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag,
- tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx,
- tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag,
+ tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx,
+ tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
}
/*-----------------------------------------------------------------*
@@ -464,19 +460,16 @@ ivas_error acelp_core_enc_fx(
{
tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch[0], res_fx );
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
-#endif
- -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag,
- tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
+ -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag,
+ tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
}
/*---------------------------------------------------------------*
* Calculation of prediction for scaled innovation energy
* (for memory-less gain quantizer)
*---------------------------------------------------------------*/
+
IF( nb_bits > 0 )
{
Es_pred_enc_fx( &Es_pred_fx, &indice, st_fx->L_frame, res_fx, st_fx->voicing_fx, nb_bits, 0, Q_new );
@@ -521,13 +514,9 @@ ivas_error acelp_core_enc_fx(
lsp_mid_bck_fx, mCb1_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen_fx );
/* Configure ACELP bit allocation */
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
-#endif
- -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0,
- st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
+ -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0,
+ st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
/* redo LSF quantization */
lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new );
@@ -1185,7 +1174,7 @@ ivas_error acelp_core_enc_ivas_fx(
test();
IF( !nelp_mode && !ppp_mode )
{
- config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
}
/*-----------------------------------------------------------------*
@@ -1322,7 +1311,7 @@ ivas_error acelp_core_enc_ivas_fx(
{
tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx );
- config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
}
/*---------------------------------------------------------------*
@@ -1381,7 +1370,7 @@ ivas_error acelp_core_enc_ivas_fx(
lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen );
/* Configure ACELP bit allocation */
- config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
+ config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
/* redo LSF quantization */
lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new );
@@ -1390,6 +1379,7 @@ ivas_error acelp_core_enc_ivas_fx(
calc_residu_fx( st, inp, res_fx, Aq );
st->hTdCngEnc->burst_ho_cnt = 0;
move16();
+
/* VOICED frames in SC-VBR */
encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
}
diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c
index bad70b08c5fbc5124a710340c33a608708bbd0fa..76fa6f151d2f431e7062f1a41b00a099016082d7 100644
--- a/lib_enc/acelp_core_switch_enc_fx.c
+++ b/lib_enc/acelp_core_switch_enc_fx.c
@@ -10,32 +10,17 @@
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
+
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
-static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx,
- const Word16 L_frame_fx,
- const Word16 inp_fx[],
- const Word16 Aq_fx[],
- const Word16 A_fx[],
- const Word16 T_op[],
- Word16 *exc_fx,
- const Word32 core_bitrate_fx,
- Word16 shift,
- Word16 Q_new );
-static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx,
- const Word16 L_frame_fx,
- const Word16 inp_fx[],
- const Word16 Aq_fx[],
- const Word16 A_fx[],
- const Word16 T_op[],
- Word16 *exc_fx,
- const Word32 core_bitrate_fx,
- Word16 shift,
- Word16 Q_new );
+static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new );
+
+static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new );
static void bwe_switch_enc_fx( Encoder_State *st_fx, const Word16 *new_speech );
+
static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, const Word16 *new_speech );
static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len, Word16 delta );
@@ -150,12 +135,8 @@ void acelp_core_switch_enc_fx(
* Excitation encoding
*----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
-#else
- config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
-#endif
- GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
+ GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
@@ -278,8 +259,8 @@ void acelp_core_switch_enc_ivas_fx(
* Excitation encoding
*----------------------------------------------------------------*/
- config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
- GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
+ GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c
index 78a02eeecf117fbc823f78c8b250a13ccd8b3b14..9b6ff2108359dcb6242fd83232ab5972e2236e01 100644
--- a/lib_enc/analy_lp_fx.c
+++ b/lib_enc/analy_lp_fx.c
@@ -3,17 +3,16 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com_fx.h" /* Static table prototypes */
-#include "rom_com.h" /* Static table prototypes */
-#include "rom_enc.h" /* Static table prototypes */
-//#include "prot_fx.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "rom_com.h" /* Static table prototypes */
+#include "rom_enc.h" /* Static table prototypes */
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
/*-------------------------------------------------------------------*
- * analy_lp()
+ * analy_lp_fx()
*
* Perform LP analysis
*
@@ -23,26 +22,26 @@
* - find interpolated LSPs and convert back to A(z) for all subframes
* - update LSPs for the next frame
*-------------------------------------------------------------------*/
-void analy_lp_ivas_fx(
- const Word16 speech[], /* i :(Q_new) pointer to the speech frame */
- const Word16 L_frame, /* i :(q0) length of the frame */
- const Word16 L_look, /* i :(q0) look-ahead */
- Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */
- Word16 A[], /* o :(q14) A(z) filter coefficients */
- Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */
- Word16 lsp_new[], /* o :(q15) current frame LSPs */
- Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */
- Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */
- const Word16 Top[2], /* i :(q0) open loop pitch lag */
- const Word16 Tnc[2], /* i :(q15) open loop pitch gain */
- const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
-#ifdef REMOVE_EVS_DUPLICATES
- const Word16 element_mode, /* i : element mode */
-#endif
- const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
- Word16 Q_new, /*i: stores Q for speech*/
- Word16 *Q_r /*stores q for ener*/ )
+
+void analy_lp_fx(
+ const Word16 speech[], /* i :(Q_new) pointer to the speech frame */
+ const Word16 L_frame, /* i :(q0) length of the frame */
+ const Word16 L_look, /* i :(q0) look-ahead */
+ Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */
+ Word16 A[], /* o :(q14) A(z) filter coefficients */
+ Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */
+ Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */
+ Word16 lsp_new[], /* o :(q15) current frame LSPs */
+ Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */
+ Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */
+ const Word16 Top[2], /* i :(q0) open loop pitch lag */
+ const Word16 Tnc[2], /* i :(q15) open loop pitch gain */
+ const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
+ Word16 Q_new, /* i : stores Q for speech */
+ Word16 *Q_r /*stores q for ener*/
+)
{
Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */
Word16 r_l[M + 1]; /* Autocorrelations of windowed speech LSB */
@@ -77,9 +76,7 @@ void analy_lp_ivas_fx(
/* Autocorrelations */
autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 );
-#ifdef REMOVE_EVS_DUPLICATES
IF( NE_16( element_mode, EVS_MONO ) )
-#endif
{
/*if ( r[0] < 100.0f && no_thr == 0 )*/
/*r[0] = 100.0f*/
@@ -132,101 +129,6 @@ void analy_lp_ivas_fx(
return;
}
-#ifndef REMOVE_EVS_DUPLICATES
-void analy_lp_fx(
- const Word16 speech[], /* i : pointer to the speech frame Q_new*/
- const Word16 L_frame, /* i : length of the frame Q0*/
- const Word16 L_look, /* i : look-ahead Q0*/
- Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
- Word16 A[], /* o : A(z) filter coefficients Q14*/
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
- Word16 lsp_new[], /* o : current frame LSPs Q15*/
- Word16 lsp_mid[], /* o : current mid-frame LSPs Q15*/
- Word16 lsp_old[], /* i/o: previous frame unquantized LSPs Q15*/
- const Word16 Top[2], /* i : open loop pitch lag Q0*/
- const Word16 Tnc[2], /* i : open loop pitch gain Q15*/
- const Word32 Core_sr, /* i : Internal core sampling rate Q0*/
- const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/
- Word16 Q_new,
- Word16 *Q_r )
-{
- Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */
- Word16 r_l[M + 1]; /* Autocorrelations of windowed speech LSB */
- Word32 LepsP[M + 1];
- Word16 i, i_subfr, wind_length = 0;
- Word16 *lsp;
- const Word16 *wind = NULL;
- const Word16 *pt;
- Word16 half_frame;
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- wind_length = L_LP;
- move16();
- wind = Assym_window_W16fx; /* Q15 */
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- wind_length = L_LP_16k;
- move16();
- wind = assym_window_16k_fx; /* Q15 */
- }
- lsp = lsp_mid; /* Q15 */
- half_frame = shr( L_frame, 1 );
-
- FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ )
- {
- pt = speech + sub( add( half_frame, L_look ), wind_length );
- half_frame = shl( half_frame, 1 );
-
- /* Autocorrelations */
- autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 );
-
- /* Lag windowing */
- adapt_lag_wind( r_h, r_l, M, Top[i_subfr], Tnc[i_subfr], Core_sr );
-
- /* Levinson-Durbin */
- E_LPC_lev_dur( r_h, r_l, A, LepsP, M, NULL );
- FOR( i = 0; i <= M; i++ )
- {
- L_Extract( LepsP[i], &epsP_h[i], &epsP_l[i] );
- }
- /*Q_r[... might not be needed from external...*/
- Q_r[1 - i_subfr] = add( Q_r[1 - i_subfr], shl( Q_new, 1 ) );
- move16();
-
- /* Conversion of A(z) to LSPs */
- E_LPC_a_lsp_conversion( A, lsp, lsp_old, M );
-
- lsp = lsp_new; /* Q15 */
- }
- IF( EQ_16( sec_chan_low_rate, 1 ) )
- {
- /* LSP interpolation */
-#ifdef REMOVE_EVS_DUPLICATES
- int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 );
-#else
- int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 );
-#endif
- }
- ELSE
- {
- /* LSP interpolation */
-#ifdef REMOVE_EVS_DUPLICATES
- int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
-#else
- int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
-#endif
- }
- Copy( lsp_new, lsp_old, M ); /* Q15 */
- *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
- move32();
-
- return;
-}
-#endif
-
/*-------------------------------------------------------------------*
* analy_lp_AMR_WB()
*
diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c
index b5c18d44b7cbbba2fbaeb1cb78cdee15c7d0ac39..e1914aeb5bb7b2e51f123b8f0ca042512c174644 100644
--- a/lib_enc/cod_ace_fx.c
+++ b/lib_enc/cod_ace_fx.c
@@ -366,14 +366,9 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
IF( st->igf != 0 )
{
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate,
- st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
-#else
- prep_tbe_exc_fx( L_frame, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate );
-#endif
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
+ bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate,
+ st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
}
/*---------------------------------------------------------*
diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c
index 3ff99812fe54ed13cec640fd05bea203e4c2f10c..a485a1bf39cca3e3b503ba25c80494a3c8d25231 100644
--- a/lib_enc/enc_gen_voic_fx.c
+++ b/lib_enc/enc_gen_voic_fx.c
@@ -363,20 +363,15 @@ void encod_gen_voic_fx(
exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */
}
}
+
/*-----------------------------------------------------------------*
* Prepare TBE excitation
*-----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
- T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
-#else
- prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
&voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
- T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate );
-#endif
+ T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
@@ -405,9 +400,11 @@ void encod_gen_voic_fx(
hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
move16();
}
+
return;
}
+
void encod_gen_voic_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 speech_fx[], /* i : input speech Qnew -1 */
@@ -763,10 +760,10 @@ void encod_gen_voic_ivas_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
- T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
+ &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new,
+ T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c
index dde834b2b826069aff6ab1de01383cf957dabb81..9802dc15b82071197c49514f3cfd2167ca4d2698 100644
--- a/lib_enc/enc_tran_fx.c
+++ b/lib_enc/enc_tran_fx.c
@@ -308,13 +308,8 @@ Word16 encod_tran_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
-#ifdef REMOVE_EVS_DUPLICATES
- prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
-#else
- prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate );
-#endif
+ prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
+ bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
@@ -719,9 +714,9 @@ Word16 encod_tran_ivas_fx(
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
+ prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
+ bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate,
+ st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Synthesize speech to update mem_syn[].
diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c
index 76640e7a7d61274ba3fd0c311fb97a09579ae337..f1e6b219389dbee185693731b14b3f870d21e022 100644
--- a/lib_enc/ivas_core_pre_proc_front_fx.c
+++ b/lib_enc/ivas_core_pre_proc_front_fx.c
@@ -1104,12 +1104,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r );
-#else
- analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx,
- INT_FS_12k8, i, *Q_new, Q_r );
-#endif
+ analy_lp_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r );
FOR( Word16 idx = 0; idx < M + 1; idx++ )
{
diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c
index 41e40945625cb45f02ea83690c37ae05e0726d29..938ab9964f486fa5d721c01f325c3b217d1617c2 100644
--- a/lib_enc/ivas_core_pre_proc_fx.c
+++ b/lib_enc/ivas_core_pre_proc_fx.c
@@ -1140,20 +1140,11 @@ ivas_error ivas_compute_core_buffers_fx(
IF( Q_new )
{
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r );
-#else
- analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, sub( *Q_new, 1 ), Q_r );
-#endif
+ analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r );
}
ELSE
{
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r );
-
-#else
- analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, -1, Q_r );
-#endif
+ analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r );
}
/*--------------------------------------------------------------*
diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c
index b3c563863e5ddfe94303a84817bf3a2551068477..f2b3adece71326893968901d387f63af6cbe1d61 100644
--- a/lib_enc/ivas_front_vad_fx.c
+++ b/lib_enc/ivas_front_vad_fx.c
@@ -629,11 +629,7 @@ ivas_error front_vad_spar_fx(
hFrontVad->q_buffer_12k8 = Q_inp_12k8;
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r );
-#else
- analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */, Q_inp_12k8, Q_r );
-#endif
+ analy_lp_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r );
FOR( Word16 i = 0; i <= M; i++ )
{
diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c
index 77ddb35aaf38b39ea89084727e9e325ef7dccb92..d10527a241855fcf154159a26d233abe764773e3 100644
--- a/lib_enc/ivas_td_low_rate_enc_fx.c
+++ b/lib_enc/ivas_td_low_rate_enc_fx.c
@@ -365,11 +365,12 @@ void encod_gen_2sbfr(
move16();
move16();
}
+
/*-----------------------------------------------------------------*
* Prepare TBE excitation
*-----------------------------------------------------------------*/
- prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_new, T0, T0_frac, coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
+ prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_new, T0, T0_frac, coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );
voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR]; /* Q15 */
move16();
@@ -378,6 +379,7 @@ void encod_gen_2sbfr(
* Synthesize speech to update mem_syn_flt[].
* Update A(z) filters
*-----------------------------------------------------------------*/
+
Syn_filt_s( 1, p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 );
p_Aw += 2 * ( M + 1 );
p_Aq += 2 * ( M + 1 );
diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c
index 8fe425d740baaa1f32abe09edb9ca45d3b1c7a9e..23ed7d0c2489486806792721a6538f2ce3d37f2f 100644
--- a/lib_enc/lsf_enc_fx.c
+++ b/lib_enc/lsf_enc_fx.c
@@ -289,13 +289,16 @@ void lsf_enc_fx(
{
int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 );
}
+
/*------------------------------------------------------------------*
* Check LSF stability (distance between old LSFs and current LSFs)
*------------------------------------------------------------------*/
+
IF( NE_32( st_fx->core_brate, SID_2k40 ) )
{
st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame );
}
+
return;
}
diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c
index e8d4a072251e13f9a3cc95c6c33dc51dda43d0cf..f7ebc8298cbff4ec232d23900b37bf55e03dea18 100644
--- a/lib_enc/pre_proc_fx.c
+++ b/lib_enc/pre_proc_fx.c
@@ -414,11 +414,7 @@ void pre_proc_fx(
alw_voicing[1] = st->voicing_fx[2];
move16();
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r );
-#else
- analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r );
-#endif
+ analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r );
lsp2lsf_fx( lsp_new, lsf_new, M, INT_FS_12k8 );
stab_fac = lsf_stab_fx( lsf_new, st->lsf_old1_fx, 0, L_FRAME );
@@ -1131,11 +1127,7 @@ void pre_proc_fx(
Copy( st->lsp_old1_fx, st->lspold_enc_fx, M );
}
-#ifdef REMOVE_EVS_DUPLICATES
- analy_lp_ivas_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r );
-#else
- analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r );
-#endif
+ analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r );
/*--------------------------------------------------------------*
* Compute Weighted Input
diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h
index 1d85ae6de51b4add0b24f24bec1e6e80f2d3a0d0..968ab00826d1a7ef74c10e78d99fabbb2a8227d6 100644
--- a/lib_enc/prot_fx_enc.h
+++ b/lib_enc/prot_fx_enc.h
@@ -41,9 +41,8 @@
#include "ivas_error_utils.h"
#include "complex_basop.h"
#include "ivas_stat_enc.h"
-/*----------------------------------------------------------------------------------*
- * Prototypes of RAM counting tool macros
- *----------------------------------------------------------------------------------*/
+
+
ivas_error acelp_core_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/
@@ -68,57 +67,37 @@ ivas_error acelp_core_enc_fx(
);
-void analy_lp_ivas_fx(
- const Word16 speech[], /* i :(Q_new) pointer to the speech frame */
- const Word16 L_frame, /* i :(q0) length of the frame */
- const Word16 L_look, /* i :(q0) look-ahead */
- Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */
- Word16 A[], /* o :(q14) A(z) filter coefficients */
- Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */
- Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */
- Word16 lsp_new[], /* o :(q15) current frame LSPs */
- Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */
- Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */
- const Word16 Top[2], /* i :(q0) open loop pitch lag */
- const Word16 Tnc[2], /* i :(q15) open loop pitch gain */
- const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
-#ifdef REMOVE_EVS_DUPLICATES
- const Word16 element_mode, /* i : element mode */
-#endif
- const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
- Word16 Q_new, /*i: stores Q for speech*/
- Word16 *Q_r /*stores q for ener*/ );
-
-#ifndef REMOVE_EVS_DUPLICATES
void analy_lp_fx(
- const Word16 speech[], /* i : pointer to the speech frame Q_new*/
- const Word16 L_frame, /* i : length of the frame Q0*/
- const Word16 L_look, /* i : look-ahead Q0*/
- Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/
- Word16 A[], /* o : A(z) filter coefficients Q14*/
- Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/
- Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/
- Word16 lsp_new[], /* o : current frame LSPs Q15*/
- Word16 lsp_mid[], /* o : current mid-frame LSPs Q15*/
- Word16 lsp_old[], /* i/o: previous frame unquantized LSPs Q15*/
- const Word16 Top[2], /* i : open loop pitch lag Q0*/
- const Word16 Tnc[2], /* i : open loop pitch gain Q15*/
- const Word32 Core_sr, /* i : Internal core sampling rate Q0*/
- const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/
- Word16 Q_new,
- Word16 *Q_r );
-#endif
-
-void AVQ_cod_fx( /* o: comfort noise gain factor */
- const Word16 xri[], /* i: vector to quantize */
- Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */
- const Word16 NB_BITS, /* i: number of allocated bits */
- const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */
- const Word16 Q_in_ref /* i: Scaling i */
+ const Word16 speech[], /* i :(Q_new) pointer to the speech frame */
+ const Word16 L_frame, /* i :(q0) length of the frame */
+ const Word16 L_look, /* i :(q0) look-ahead */
+ Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */
+ Word16 A[], /* o :(q14) A(z) filter coefficients */
+ Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */
+ Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */
+ Word16 lsp_new[], /* o :(q15) current frame LSPs */
+ Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */
+ Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */
+ const Word16 Top[2], /* i :(q0) open loop pitch lag */
+ const Word16 Tnc[2], /* i :(q15) open loop pitch gain */
+ const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
+ Word16 Q_new, /* i : stores Q for speech */
+ Word16 *Q_r /*stores q for ener*/
+);
+
+/*1 r: comfort noise gain factor */
+void AVQ_cod_fx(
+ const Word16 xri[], /* i: vector to quantize */
+ Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */
+ const Word16 NB_BITS, /* i: number of allocated bits */
+ const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */
+ const Word16 Q_in_ref /* i: Scaling i */
);
void AVQ_encmux_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
const Word16 extl, /* i : extension layer */
Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed
by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
@@ -130,7 +109,7 @@ void AVQ_encmux_fx(
);
void AVQ_encmux_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
const Word16 extl, /* i : extension layer */
Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed
by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
@@ -151,15 +130,15 @@ void bw_detect_fx(
const Word16 mct_on, /* i : flag MCT mode */
const Word16 Q_spec );
-void core_switching_post_enc_fx( /*done */
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/
- const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/
- const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */
- Word16 Qshift,
- Word16 Q_new,
- const Word16 Qsp, /* i/o : Q from acelp synthsis */
- Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */
+void core_switching_post_enc_fx(
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/
+ const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/
+ const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */
+ Word16 Qshift,
+ Word16 Q_new,
+ const Word16 Qsp, /* i/o : Q from acelp synthsis */
+ Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */
);
void core_switching_pre_enc_fx(
@@ -170,8 +149,9 @@ void core_switching_pre_enc_fx(
const Word16 last_element_mode /* i : last_element_mode Q0*/
);
-Word16 correlation_shift_fx( /* o : noise dependent voicing correction Q15 */
- const Word16 totalNoise_fx /* i/o: noise estimate over all critical bands Q8 */
+/*! r: noise dependent voicing correction Q15 */
+Word16 correlation_shift_fx(
+ const Word16 totalNoise_fx /* i/o: noise estimate over all critical bands Q8 */
);
void dtx_fx(
diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c
index c724ffd6c228d4441fdbae27526ddf6faf631270..d0d62769791a9dfe181c3452d45ef076c2b5167c 100644
--- a/lib_enc/transition_enc_fx.c
+++ b/lib_enc/transition_enc_fx.c
@@ -212,13 +212,9 @@ void transition_enc_fx(
IF( EQ_16( *tc_subfr, TC_0_0 ) )
{
/* this is called only to compute unused bits */
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
- st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
+ st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
}
*clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) );
@@ -328,13 +324,9 @@ void transition_enc_fx(
IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
{
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
- unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
+ unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
}
/*-----------------------------------------------------------------*
@@ -1040,14 +1032,9 @@ void transition_enc_ivas_fx(
IF( EQ_16( *tc_subfr, TC_0_0 ) )
{
/* this is called only to compute unused bits */
-
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
- st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP,
+ st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/
);
}
@@ -1158,13 +1145,9 @@ void transition_enc_ivas_fx(
IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
{
-#ifdef REMOVE_EVS_DUPLICATES
- config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#else
- config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
-#endif
- st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
- unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
+ config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
+ st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL,
+ unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
}
/*-----------------------------------------------------------------*