From cc206a23b2943dd2b5cb96d12639c910e7f1797a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:04:24 +0100 Subject: [PATCH 01/26] [cleanup] accept FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR --- apps/decoder.c | 2 -- lib_com/options.h | 1 - lib_dec/lib_dec_fx.c | 26 -------------------------- 3 files changed, 29 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 35d7e6c3e..12f6b1786 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -448,12 +448,10 @@ int main( goto cleanup; } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) ) { fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } -#endif } /*------------------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..445c53844 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR /* Dolby: Fix for issue 1449: renderer frame size unclear in ISAR */ #define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1495_INCORRECT_FREAD_CALL /* Eri: Switched size and number of elements in fread call. */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4a99ce5f2..ff3d435c2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1582,22 +1582,9 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11 } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); #endif -#else - IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) - { -#ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); -#endif - } - ELSE - { - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 ); - } -#endif ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, pcmBuf_out ); } @@ -4928,22 +4915,9 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL ) scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11 } -#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR #ifndef DISABLE_LIMITER ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); #endif -#else - IF( EQ_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_FRAMESIZE_5MS ) ) - { -#ifndef DISABLE_LIMITER - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); -#endif - } - ELSE - { - ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 ); - } -#endif ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf ); } -- GitLab From eedccddd717b7c05c46d5a6e848a3b7dbd9bdd00 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:05:06 +0100 Subject: [PATCH 02/26] [cleanup] accept FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR --- lib_com/options.h | 1 - lib_isar/isar_lcld_decoder.c | 37 ------------------------------------ lib_isar/isar_lcld_prot.h | 29 ---------------------------- 3 files changed, 67 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 445c53844..c08c717ee 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,7 +86,6 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ -#define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR /* Dolby: Remove unused psNoiseGen from ISAR */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1495_INCORRECT_FREAD_CALL /* Eri: Switched size and number of elements in fread call. */ #define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index e296a2e0d..d34c56dac 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -106,9 +106,6 @@ struct LCLD_DECODER PredictionDecoder *psPredictionDecoder; -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - NoiseGen *psNoiseGen; -#endif }; static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, Word32 num, const UWord16 ( *ppuiEncTable )[2], Word32 iSize, Word32 iReadLength, UWord32 *iTables ); @@ -605,9 +602,6 @@ ivas_error CreateLCLDDecoder( { return error; } -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - psLCLDDecoder->psNoiseGen = NULL; /* CreateNoiseGen(); No noise fill for now*/ -#endif *psLCLDDecoder_out = psLCLDDecoder; return IVAS_ERR_OK; @@ -769,12 +763,6 @@ void DeleteLCLDDecoder( psLCLDDecoder->psPredictionDecoder = NULL; } -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - IF( psLCLDDecoder->psNoiseGen != NULL ) - { - DeleteNoiseGen( psLCLDDecoder->psNoiseGen ); - } -#endif free( psLCLDDecoder ); } @@ -794,10 +782,6 @@ static void ApplyRMSEnvelope_fx( const Word32 iNumBands, const Word32 *piBandwid static void ReplaceSign_fx( const Word32 iNumBlocks, const Word32 iNumLCLDBands, Word32 **ppiSignReal, Word32 **ppiSignImag, Word32 **ppfReal, Word32 **ppfImag, const Word32 *piBandwidths ); static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - , - NoiseGen *psNoiseGen -#endif ); static void InvMSCoding_fx( const Word32 iNumBlocks, const Word32 iNumBands, const Word32 *piBandwidths, const Word32 iMSMode, const Word32 *piMSFlags, const Word32 *piLRPhaseDiffs, const Word32 *piMSPredCoefs, Word32 ***pppfReal, Word32 ***pppfImag ); @@ -1021,10 +1005,6 @@ Word32 DecodeLCLDFrame( psLCLDDecoder->pppiQLCLDReal[n], psLCLDDecoder->pppiQLCLDImag[n], pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - , - psLCLDDecoder->psNoiseGen -#endif ); ReplaceSign_fx( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, @@ -1296,10 +1276,6 @@ static void InvQuantizeSpectrum_fx( Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - , - NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */ -#endif ) { Word32 b, k, n; @@ -1339,19 +1315,6 @@ static void InvQuantizeSpectrum_fx( iFBOffset++; } } -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - ELSE IF( psNoiseGen != NULL ) - { - FOR( m = 0; m < piBandwidths[b]; m++ ) - { - ppfReal[iBlockOffest][iFBOffset] = Mpy_32_16_1( GetNoise_fx( psNoiseGen ), 22938 ); // Q(14 + 15 -15 )=Q14 - move32(); - ppfImag[iBlockOffest][iFBOffset] = Mpy_32_16_1( GetNoise_fx( psNoiseGen ), 22938 ); // Q(14+ 15 -15 )=Q14 - move32(); - iFBOffset++; - } - } -#endif ELSE { iFBOffset = L_add( iFBOffset, piBandwidths[b] ); diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index d16d32326..56dd08f6b 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -170,35 +170,6 @@ Word32 CountMSBits( ); -#ifndef FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR - -/*----------------------------------------------------------------------------------* - * NoiseGen prototypes - *----------------------------------------------------------------------------------*/ - -typedef struct NOISE_GEN -{ - Word32 iNoiseBufferLength; - Word32 iNoiseBufferMask; - Word32 iNoiseBufferIndex; - float *pfNoiseBuffer; -} NoiseGen; - -void DeleteNoiseGen( - NoiseGen *psNoiseGen -); - -inline Word32 GetNoise_fx( NoiseGen *psNoiseGen ) -{ - Word32 fNoiseSample; - - fNoiseSample = (Word32) (psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex] * (1<<14)); - psNoiseGen->iNoiseBufferIndex++; - psNoiseGen->iNoiseBufferIndex &= psNoiseGen->iNoiseBufferMask; - - return fNoiseSample; -} -#endif /*----------------------------------------------------------------------------------* * PereptualModel prototypes -- GitLab From 74331d14c2e98ddcb6225b98f65306805faa8798 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:05:52 +0100 Subject: [PATCH 03/26] [cleanup] accept FIX_1495_INCORRECT_FREAD_CALL --- lib_com/options.h | 1 - lib_util/hrtf_file_reader.c | 60 ------------------------------------- 2 files changed, 61 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c08c717ee..f65927487 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1495_INCORRECT_FREAD_CALL /* Eri: Switched size and number of elements in fread call. */ #define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ #define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ #define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 9ece3ecb3..3742459f8 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -302,11 +302,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), modelITD->elevDim3 - 2, f_hrtf ); for ( j = 0; j < modelITD->elevDim3 - 2; j++ ) { @@ -321,11 +317,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); for ( j = 0; j < ( modelITD->azimDim3 + 1 ) / 2 - 2; j++ ) { @@ -340,11 +332,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( v_tmp16 == NULL ) { @@ -380,11 +368,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -420,11 +404,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -469,17 +449,9 @@ static ivas_error TDREND_LoadBSplineBinary( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif HrFiltSet_p->latency_s_Q_fx = Q31 - factor_Q; -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &HrFiltSet_p->latency_s_fx, sizeof( Word32 ), 1, f_hrtf ); -#else - fread( &HrFiltSet_p->latency_s_fx, 1, sizeof( Word32 ), f_hrtf ); -#endif model = &( HrFiltSet_p->ModelParams ); /* Set ROM flag for correct deallocation */ @@ -524,11 +496,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), model->elevDim3 - 2, f_hrtf ); for ( j = 0; j < model->elevDim3 - 2; j++ ) { @@ -554,11 +522,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); for ( j = 0; j < model->azimDim3_dyn[i] + 1; j++ ) { @@ -574,11 +538,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif model->AlphaL_e = Q15 - factor_Q; // model->AlphaL_dyn_e = 1; /* force to 6 to be corrected */ @@ -621,11 +581,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( v_tmp16 == NULL ) { @@ -675,11 +631,7 @@ static ivas_error TDREND_LoadBSplineBinary( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); for ( j = 0; j < tmp; j++ ) { @@ -694,11 +646,7 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#ifdef FIX_1495_INCORRECT_FREAD_CALL fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); -#else - fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf ); -#endif model->EL_e = Q31 - factor_Q; model->ER_e = model->EL_e; @@ -943,11 +891,7 @@ static ivas_error TDREND_MIX_LoadHRTF( /* try if it is old format for BE tests*/ fseek( f_hrtf, 0, SEEK_SET ); -#ifdef FIX_1495_INCORRECT_FREAD_CALL if ( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ) == 0 ) -#else - if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) -#endif { header_check_result = IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } @@ -1019,11 +963,7 @@ static ivas_error TDREND_MIX_LoadHRTF( if ( is_tdrend ) { -#ifdef FIX_1495_INCORRECT_FREAD_CALL if ( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ) == 0 ) -#else - if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) -#endif { return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } -- GitLab From ead89d582281b3180c377710c7257f9577831d54 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:06:48 +0100 Subject: [PATCH 04/26] [cleanup] accept FIX_1486_INIT_OUTPUT_POINTERS --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f65927487..7e9f29bd1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1486_INIT_OUTPUT_POINTERS /* FhG: always initialize pointers in renderer flush */ #define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ #define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ #define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index dd0ca93f3..d703a4104 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2553,9 +2553,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS]; Word16 nchan_in, nchan_out; -#ifdef FIX_1486_INIT_OUTPUT_POINTERS Word16 ch_idx; -#endif IF( !st_ivas->hDecoderConfig->Opt_tsm ) @@ -2563,12 +2561,10 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( return IVAS_ERR_OK; } -#ifdef FIX_1486_INIT_OUTPUT_POINTERS FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) { p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; } -#endif *nSamplesRendered = 0; move16(); @@ -2595,9 +2591,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( IF( n_slots_still_available ) { -#ifndef FIX_1486_INIT_OUTPUT_POINTERS - Word16 ch_idx; -#endif /* render available full slots (with new lower granularity) */ FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ ) @@ -2627,12 +2620,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); -#ifndef FIX_1486_INIT_OUTPUT_POINTERS - FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) - { - p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; - } -#endif test(); IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) @@ -2883,11 +2870,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) ) { #ifndef DISABLE_LIMITER -#ifndef FIX_1486_INIT_OUTPUT_POINTERS - Word16 ch_idx, exp = 11; -#else Word16 exp = 11; -#endif move16(); FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { -- GitLab From 1153441fb4f3cdbe744c3dd17880883bd877d825 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:07:39 +0100 Subject: [PATCH 05/26] [cleanup] accept FIX_1494_SET_SPLITBFI_UNUSED --- apps/renderer.c | 36 ------------------------------------ lib_com/options.h | 1 - lib_rend/lib_rend.h | 5 ----- lib_rend/lib_rend_fx.c | 28 ---------------------------- 4 files changed, 70 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 80a37b2a6..c8d14a347 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -167,9 +167,6 @@ typedef struct int16_t numInMetadataFiles; char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - char splitRendBFIFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; -#endif char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char referenceRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -220,9 +217,6 @@ typedef enum CmdLnOptionId_listFormats, CmdLnOptionId_inputGain, CmdLnOptionId_outputMetadata, -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - CmdLnOptionId_SplitRendBFIFile, -#endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, CmdLnOptionId_framing, @@ -281,14 +275,6 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "om", .description = "coded metadata file for BINAURAL_SPLIT_PCM output mode", }, -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - { - .id = CmdLnOptionId_SplitRendBFIFile, - .match = "post_rend_bfi_file", - .matchShort = "prbfi", - .description = "Split rendering option: bfi file", - }, -#endif { .id = CmdLnOptionId_refRotFile, .match = "reference_rotation_file", @@ -764,9 +750,6 @@ int main( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[RENDERER_MAX_INPUT_CHANNELS]; IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[RENDERER_MAX_INPUT_CHANNELS]; int16_t cldfb_in_flag, CLDFBframeSize_smpls; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - SplitRendBFIFileReader *splitRendBFIReader = NULL; -#endif Vector3PairFileReader *referenceVectorReader = NULL; hrtfFileReader *hrtfFileReader = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL; @@ -896,13 +879,6 @@ int main( } } -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - if ( !isEmptyString( args.splitRendBFIFilePath ) ) - { - convert_backslash( args.splitRendBFIFilePath ); - SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); - } -#endif if ( !isEmptyString( args.externalOrientationFilePath ) ) { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) @@ -2184,9 +2160,6 @@ cleanup: } split_rend_reader_writer_close( &hSplitRendFileReadWrite ); -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - SplitRendBFIFileReader_close( &splitRendBFIReader ); -#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { @@ -2798,9 +2771,6 @@ static CmdlnArgs defaultArgs( clearString( args.headRotationFilePath ); clearString( args.outMetadataFilePath ); -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - clearString( args.splitRendBFIFilePath ); -#endif clearString( args.referenceVectorFilePath ); clearString( args.referenceRotationFilePath ); clearString( args.customHrtfFilePath ); @@ -2907,12 +2877,6 @@ static void parseOption( assert( numOptionValues == 1 ); strncpy( args->outMetadataFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - case CmdLnOptionId_SplitRendBFIFile: - assert( numOptionValues == 1 ); - strncpy( args->splitRendBFIFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); - break; -#endif case CmdLnOptionId_referenceVectorFile: assert( numOptionValues == 1 ); strncpy( args->referenceVectorFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index 7e9f29bd1..b36bdfd0a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1494_SET_SPLITBFI_UNUSED /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */ #define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ #define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ #define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 3ce6d0bb3..1cb307790 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -344,11 +344,6 @@ ivas_error IVAS_REND_SetReferenceVector( const IVAS_VECTOR3 refPos /* i : Reference position */ ); -#ifndef FIX_1494_SET_SPLITBFI_UNUSED -ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, - const Word16 bfi); -#endif ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 5d5179c53..232c38ee5 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -94,9 +94,6 @@ typedef struct const EFAP_WRAPPER *pEfapOutWrapper; IVAS_REND_HeadRotData *pHeadRotData; // for now removing the const qualifier TODO: will modify later const RENDER_CONFIG_HANDLE *hhRendererConfig; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - const Word16 *pSplitRendBFI; -#endif const SPLIT_REND_WRAPPER *pSplitRendWrapper; const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData; const IVAS_DefaultReverbSize *pSelectedRoomReverbSize; @@ -218,9 +215,6 @@ struct IVAS_REND EFAP_WRAPPER efapOutWrapper; IVAS_LSSETUP_CUSTOM_STRUCT customLsOut; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - Word16 splitRendBFI; -#endif SPLIT_REND_WRAPPER *splitRendWrapper; IVAS_REND_AudioBuffer splitRendEncBuffer; IVAS_REND_HeadRotData headRotData; @@ -1369,9 +1363,6 @@ static rendering_context getRendCtx( ctx.pEfapOutWrapper = &hIvasRend->efapOutWrapper; ctx.pHeadRotData = &hIvasRend->headRotData; ctx.hhRendererConfig = &hIvasRend->hRendererConfig; -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; -#endif ctx.pSplitRendWrapper = hIvasRend->splitRendWrapper; ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData; ctx.pSelectedRoomReverbSize = &hIvasRend->selectedRoomReverbSize; @@ -5729,25 +5720,6 @@ ivas_error IVAS_REND_DisableHeadRotation( return IVAS_ERR_OK; } -#ifndef FIX_1494_SET_SPLITBFI_UNUSED - -/*-------------------------------------------------------------------* - * IVAS_REND_SetSplitRendBFI() - * - * - *-------------------------------------------------------------------*/ - -ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const Word16 bfi /* i : Bad Frame Indicator */ -) -{ - hIvasRend->splitRendBFI = bfi; - - return IVAS_ERR_OK; -} - -#endif /*-------------------------------------------------------------------* -- GitLab From f2a77cbe828a1391a118dc7350f900be8dc52200 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:08:21 +0100 Subject: [PATCH 06/26] [cleanup] accept FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE --- lib_com/options.h | 1 - lib_dec/ivas_spar_md_dec_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b36bdfd0a..46bde94f8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */ #define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ #define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 15e156557..9bce073cd 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -631,12 +631,10 @@ ivas_error ivas_spar_md_dec_init( hMdDec->first_valid_frame = 1; move16(); -#ifdef FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE hMdDec->spar_md.res_ind = 0; hMdDec->spar_md.prior_dyn_active_w_flag = 0; move16(); move16(); -#endif return IVAS_ERR_OK; } -- GitLab From 0c5409600fb8cfadc5bbb92baca5490e1d4f46a8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:09:39 +0100 Subject: [PATCH 07/26] [cleanup] accept HARM_LSF_ENC --- lib_com/int_lsp_fx.c | 84 -- lib_com/options.h | 1 - lib_com/prot_fx.h | 11 - lib_com/stat_noise_uv_mod_fx.c | 4 - lib_dec/acelp_core_dec_fx.c | 4 - lib_dec/dec_LPD_fx.c | 4 - lib_dec/lsf_dec_fx.c | 8 - lib_enc/acelp_core_enc_fx.c | 20 - lib_enc/analy_lp_fx.c | 8 - lib_enc/cng_enc_fx.c | 8 - lib_enc/ivas_tcx_core_enc_fx.c | 5 - lib_enc/lsf_enc_fx.c | 1303 ++------------------------------ lib_enc/prot_fx_enc.h | 51 -- lib_enc/qlpc_stoch_fx.c | 183 ----- 14 files changed, 77 insertions(+), 1617 deletions(-) diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c index d591389c0..ab84c76bb 100644 --- a/lib_com/int_lsp_fx.c +++ b/lib_com/int_lsp_fx.c @@ -132,12 +132,10 @@ void int_lsp4_fx( { pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/ } -#ifdef HARM_LSF_ENC ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) ) { pt_int_coeffs = interpol_frac2_mid_fx; /*Q15*/ } -#endif ELSE { pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/ @@ -183,85 +181,3 @@ void int_lsp4_fx( return; } -#ifndef HARM_LSF_ENC - -void int_lsp4_ivas_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ - const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ - const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ - Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ - const Word16 m, /* i : order of LP filter */ - Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ -) -{ - Word16 lsp[M16k]; - Word16 i, j, k; - Word32 L_tmp; - const Word16 *pt_int_coeffs; - - IF( EQ_16( L_frame, L_FRAME ) ) - { - IF( EQ_16( relax_prev_lsf_interp, 1 ) ) - { - pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) ) - { - pt_int_coeffs = interpol_frac_mid_FEC_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) ) - { - pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) ) - { - // This condition not present in int_lsp4_fx - pt_int_coeffs = interpol_frac2_mid_fx; /*Q15*/ - } - ELSE - { - pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/ - } - } - ELSE /* L_frame == L_FRAME16k */ - { - IF( EQ_16( relax_prev_lsf_interp, 1 ) ) - { - pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) ) - { - pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; /*Q15*/ - } - ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) ) - { - pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; /*Q15*/ - } - ELSE - { - pt_int_coeffs = interpol_frac_mid_16k_fx; /*Q15*/ - } - } - k = sub( shr( L_frame, 6 ), 1 ); - FOR( j = 0; j < k; j++ ) - { - FOR( i = 0; i < m; i++ ) - { - L_tmp = L_mult( lsp_old[i], *pt_int_coeffs ); /*Q31 */ - L_tmp = L_mac( L_tmp, lsp_mid[i], *( pt_int_coeffs + 1 ) ); /*Q31 */ - lsp[i] = mac_r( L_tmp, lsp_new[i], *( pt_int_coeffs + 2 ) ); - move16(); - } - pt_int_coeffs += 3; - - E_LPC_f_lsp_a_conversion( lsp, Aq, m ); - Aq += add( m, 1 ); - } - - /* Last subframe */ - E_LPC_f_lsp_a_conversion( lsp_new, Aq, m ); - - return; -} -#endif diff --git a/lib_com/options.h b/lib_com/options.h index 46bde94f8..4a44696c0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define HARM_LSF_ENC /* VA: basop issue 2301: Remove duplicated code in LSF quantizer */ #define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index fac7485fb..2c9412b24 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1644,17 +1644,6 @@ void int_lsp4_fx( Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ ); -#ifndef HARM_LSF_ENC -void int_lsp4_ivas_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 lsp_old[], /* i : LSPs from past frame Q15*/ - const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/ - const Word16 lsp_new[], /* i : LSPs from present frame Q15*/ - Word16 *Aq, /* o : LP coefficients in both subframes Q12*/ - const Word16 m, /* i : order of LP filter */ - Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ -); -#endif void de_interleave_spectrum_fx( Word32 *coefs, /* i/o: i and output coefficients Q? */ const Word16 length /* i : length of spectrum Q0 */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 6f364ce99..33c5545ce 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -614,11 +614,7 @@ void stat_noise_uv_mod_ivas_fx( mult( sub( 32767, beta ), lspnew_s[i] ) ); } -#ifdef HARM_LSF_ENC int_lsp4_fx( L_FRAME, oldlsp_mix, midlsp_mix, newlsp_mix, Aq, M, 0 ); -#else - int_lsp4_ivas_fx( L_FRAME, oldlsp_mix, midlsp_mix, newlsp_mix, Aq, M, 0 ); -#endif Copy( lspnew_s, lspold_s, M ); } ELSE /* (unvoiced_vad != 0) */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index b65b49a42..c893ca4d2 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1035,11 +1035,7 @@ ivas_error acelp_core_dec_fx( 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 ) ) ) { -#ifdef HARM_LSF_ENC int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); -#else - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); -#endif } /*---------------------------------------------------------------* diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index 07372eae0..c24d338cb 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 HARM_LSF_ENC int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); -#else - int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); -#endif } ELSE { diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index bfb92005a..32c8c9958 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -300,20 +300,12 @@ void lsf_dec_fx( } /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ -#ifdef HARM_LSF_ENC int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); -#else - int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); -#endif } ELSE { /* LSP interpolation and conversion of LSPs to A(z) */ -#ifdef HARM_LSF_ENC int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp ); -#else - int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp ); -#endif } /*------------------------------------------------------------------* diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 104e9bc96..1aa59f93f 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -431,11 +431,7 @@ ivas_error acelp_core_enc_fx( if ( !tdm_lp_reuse_flag ) { -#ifdef HARM_LSF_ENC lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, NULL, Q_new ); -#else - 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 ); -#endif } /*---------------------------------------------------------------* @@ -509,11 +505,7 @@ ivas_error acelp_core_enc_fx( 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, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ -#ifdef HARM_LSF_ENC lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, 0, -1, NULL, Q_new ); -#else - 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 ); -#endif /* recalculation of LP residual (filtering through A[z] filter) */ calc_residu_fx( st_fx, inp_fx, res_fx, Aq_fx ); @@ -943,19 +935,11 @@ ivas_error acelp_core_enc_ivas_fx( IF( st->rate_switching_reset ) { /*extrapolation in case of unstable LSP*/ -#ifdef HARM_LSF_ENC int_lsp4_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 ); -#else - int_lsp4_ivas_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 ); -#endif } ELSE { -#ifdef HARM_LSF_ENC int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 ); -#else - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 ); -#endif } /* Reset LPC mem */ @@ -1188,11 +1172,7 @@ ivas_error acelp_core_enc_ivas_fx( IF( !tdm_lp_reuse_flag ) { -#ifdef HARM_LSF_ENC lsf_enc_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); -#else - lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); -#endif } ELSE { diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index e61f7f76b..162b87ea4 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -115,20 +115,12 @@ void analy_lp_fx( IF( EQ_16( sec_chan_low_rate, 1 ) ) { /* LSP interpolation */ -#ifdef HARM_LSF_ENC int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); -#else - int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); -#endif } ELSE { /* LSP interpolation */ -#ifdef HARM_LSF_ENC int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); -#else - int_lsp4_ivas_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 */ diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 1bc7cab41..2903c2d09 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -340,11 +340,7 @@ void CNG_enc_fx( } ELSE { -#ifdef HARM_LSF_ENC lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); -#else - lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, Q_new ); -#endif } /* Reset CNG history if CNG frame length is changed */ @@ -1561,11 +1557,7 @@ void CNG_enc_fx( } ELSE { -#ifdef HARM_LSF_ENC lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); -#else - lsf_enc_ivas_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); -#endif } /* Reset CNG history if CNG frame length is changed */ diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 1b2833473..6bd3aca8c 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -420,13 +420,8 @@ void stereo_tcx_core_enc( move16(); } -#ifdef HARM_LSF_ENC lpc_quantization_fx( st, lsp_new_fx, lsp_mid_fx, lsp_q_fx, lsf_q_fx, lspmid_q_fx, NULL, st->clip_var_fx, AUDIO, 0, /*No acelp->no need to compute any mid-LPC*/ param_lpc, nbits_lpc, bits_param_lpc, &no_param_lpc, Q_ener ); -#else - lpc_quantization_ivas_fx( st, lsp_new_fx, lsp_mid_fx, lsp_q_fx, lsf_q_fx, lspmid_q_fx, AUDIO, 0, /*No acelp->no need to compute any mid-LPC*/ - param_lpc, nbits_lpc, bits_param_lpc, &no_param_lpc, Q_ener ); -#endif /*--------------------------------------------------------------* * Rate switching diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 946330614..3995f1ab7 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -24,23 +24,13 @@ * Local function prototypes *---------------------------------------------------------------------*/ -#ifdef HARM_LSF_ENC static void lsfq_CNG_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, const Word16 *lsf, const Word16 *wghts, Word16 *qlsf, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales ); -#else -static void lsfq_CNG_fx( BSTR_ENC_HANDLE hBstr, const Word16 *lsf, const Word16 *wghts, Word16 *qlsf, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales ); -#endif static Word32 vq_lvq_lsf_enc( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word32 p_offset_scale1[][MAX_NO_SCALES + 1], Word32 p_offset_scale2[][MAX_NO_SCALES + 1], Word16 p_no_scales[][2], Word16 *resq, Word16 *lsfq ); static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word16 *resq, Word16 *lsfq ); -#ifdef HARM_LSF_ENC static void lsf_mid_enc_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); -#else -static void lsf_mid_enc_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); - -static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word32 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); -#endif /*===========================================================================*/ @@ -77,14 +67,9 @@ void lsf_enc_fx( Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ Word16 *Aq, /* o : quantized A(z) for 4 subframes */ -#ifndef HARM_LSF_ENC - const Word16 Nb_ACELP_frames, -#endif const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ -#ifdef HARM_LSF_ENC const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ -#endif const Word16 Q_new ) { Word16 nBits = 0; @@ -92,10 +77,8 @@ void lsf_enc_fx( Word16 int_fs; Word16 force_sf = 0; move16(); -#ifdef HARM_LSF_ENC Word16 no_param_lpc; Word16 param_lpc[NPRM_LPC_NEW]; -#endif Word16 fec_lsf[M], stab, i; Word32 L_tmp; Word16 coder_type, ppp_mode, nelp_mode; @@ -119,9 +102,7 @@ void lsf_enc_fx( move16(); } -#ifdef HARM_LSF_ENC no_param_lpc = 0; -#endif move16(); IF( st_fx->Opt_SC_VBR ) @@ -148,7 +129,6 @@ void lsf_enc_fx( lsp2lsf_fx( lsp_new, lsf_new, M, int_fs ); /* check resonance for pitch clipping algorithm */ -#ifdef HARM_LSF_ENC IF( st_fx->element_mode == EVS_MONO ) { gp_clip_test_lsf_fx( st_fx->element_mode, lsf_new, st_fx->clip_var_fx, 0 ); @@ -157,9 +137,6 @@ void lsf_enc_fx( { gp_clip_test_lsf_ivas_fx( st_fx->element_mode, st_fx->core_brate, lsf_new, st_fx->clip_var_fx, 0 ); } -#else - gp_clip_test_lsf_fx( st_fx->element_mode, lsf_new, st_fx->clip_var_fx, 0 ); -#endif /* Find the number of bits for LSF quantization */ @@ -199,11 +176,7 @@ void lsf_enc_fx( force_sf = 0; move16(); test(); -#ifdef HARM_LSF_ENC if ( LT_16( st_fx->Nb_ACELP_frames, 3 ) && NE_32( st_fx->core_brate, SID_2k40 ) ) -#else - if ( LT_16( Nb_ACELP_frames, 3 ) && NE_32( st_fx->core_brate, SID_2k40 ) ) -#endif { /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */ force_sf = 1; @@ -223,13 +196,8 @@ void lsf_enc_fx( * Frame end LSF quantization *-------------------------------------------------------------------------------------*/ -#ifdef HARM_LSF_ENC lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, force_sf, param_lpc, &no_param_lpc, NULL, st_fx->coder_type_raw, tdm_lsfQ_PCh ); -#else - lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, - force_sf, NULL, NULL, NULL, st_fx->coder_type_raw ); -#endif /* convert quantized LSFs back to LSPs */ lsf2lsp_fx( lsf_new, lsp_new, M, int_fs ); @@ -242,7 +210,6 @@ void lsf_enc_fx( } /* set seed_acelp used in UC mode */ -#ifdef HARM_LSF_ENC test(); IF( EQ_16( coder_type, UNVOICED ) && ( st_fx->element_mode > EVS_MONO ) ) { @@ -255,7 +222,6 @@ void lsf_enc_fx( move16(); } } -#endif IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) { @@ -278,7 +244,6 @@ void lsf_enc_fx( FEC_lsf_estim_enc_fx( st_fx, fec_lsf ); /* in case of FEC in decoder - calculate LSF stability */ -#ifdef HARM_LSF_ENC IF( st_fx->element_mode == EVS_MONO ) { stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 @@ -287,9 +252,6 @@ void lsf_enc_fx( { stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 } -#else - stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 -#endif test(); test(); @@ -333,11 +295,7 @@ void lsf_enc_fx( } /* Mid-frame LSF encoding */ -#ifdef HARM_LSF_ENC lsf_mid_enc_fx( st_fx->element_mode, st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); -#else - lsf_mid_enc_fx( st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); -#endif test(); IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) ) @@ -372,7 +330,6 @@ void lsf_enc_fx( IF( NE_32( st_fx->core_brate, SID_2k40 ) ) { -#ifdef HARM_LSF_ENC 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 ); @@ -381,280 +338,11 @@ void lsf_enc_fx( { st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); // Q15 } -#else - st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); -#endif } return; } -#ifndef HARM_LSF_ENC -void lsf_enc_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized Q15*/ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector Q15*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const Word16 Q_new ) -{ - Word16 nBits; - Word16 force_sf; - Word16 fec_lsf[M], stab, i; - Word16 no_param_lpc; - - Word16 param_lpc[NPRM_LPC_NEW]; - Word32 L_tmp; - Word16 coder_type, ppp_mode, nelp_mode; - - nBits = 0; - force_sf = 0; - move16(); - move16(); - - test(); - IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) ) - { - coder_type = INACTIVE; - move16(); - } - ELSE - { - coder_type = st->coder_type; - move16(); - } - - test(); - if ( EQ_16( coder_type, AUDIO ) && GSC_IVAS_mode > 0 ) - { - coder_type = GENERIC; - move16(); - } - - no_param_lpc = 0; - move16(); - - IF( st->Opt_SC_VBR ) - { - ppp_mode = st->hSC_VBR->ppp_mode; - nelp_mode = st->hSC_VBR->nelp_mode; - move16(); - move16(); - } - ELSE - { - ppp_mode = 0; - nelp_mode = 0; - move16(); - move16(); - } - - /* convert LSPs to LSFs */ - lsp2lsf_fx( lsp_new, lsf_new, M, st->sr_core ); - - /* check resonance for pitch clipping algorithm */ - gp_clip_test_lsf_ivas_fx( st->element_mode, st->core_brate, lsf_new, st->clip_var_fx, 0 ); - - /* Find the number of bits for LSF quantization */ - nBits = 0; - move16(); - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - nBits = LSF_BITS_CNG; - move16(); - } - ELSE - { - test(); - IF( ( nelp_mode == 0 ) && ( ppp_mode == 0 ) ) - { - nBits = st->acelp_cfg.lsf_bits; - move16(); - } - ELSE IF( EQ_16( nelp_mode, 1 ) ) - { - IF( st->bwidth == NB ) - { - nBits = 32; - move16(); - } - ELSE IF( EQ_16( st->bwidth, WB ) ) - { - nBits = 30; - move16(); - } - } - ELSE IF( EQ_16( ppp_mode, 1 ) ) - { - nBits = 26; - move16(); - } - } - force_sf = 0; - move16(); - /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */ - test(); - if ( LT_16( st->Nb_ACELP_frames, 3 ) && NE_32( st->core_brate, SID_2k40 ) ) - { - force_sf = 1; - move16(); - } - - /* in case of unstable filter in decoder FEC, choose safety-net to help FEC */ - IF( EQ_16( st->next_force_safety_net, 1 ) ) - { - force_sf = 1; - move16(); - st->next_force_safety_net = 0; - move16(); - } - - /*-------------------------------------------------------------------------------------* - * Frame end LSF quantization - *-------------------------------------------------------------------------------------*/ - lsf_end_enc_ivas_fx( st, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, - force_sf, param_lpc, &no_param_lpc, NULL, st->coder_type_raw, tdm_lsfQ_PCh ); - - /* convert quantized LSFs back to LSPs */ - lsf2lsp_fx( lsf_new, lsp_new, M, st->sr_core ); - - test(); - IF( EQ_16( st->last_core, HQ_CORE ) && ( st->core == ACELP_CORE ) ) - { - /* don't use old LSF values if this is the first ACELP frame after HQ frames */ - Copy( lsf_new, st->lsf_old_fx, M ); - } - - /* set seed_acelp used in UC mode */ - test(); - IF( EQ_16( coder_type, UNVOICED ) && ( st->element_mode > EVS_MONO ) ) - { - st->seed_acelp = 0; - move16(); - FOR( i = no_param_lpc - 1; i >= 0; i-- ) - { - /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ - st->seed_acelp = add( i_mult( add( shr( st->seed_acelp, 1 ), param_lpc[i] ), 31821 ), 13849 ); - move16(); - } - } - - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - /* return if SID frame (conversion to A(z) done in the calling function) */ - return; - } - - /*-------------------------------------------------------------------------------------* - * FEC - enforce safety-net in the next frame in case of unstable filter - *-------------------------------------------------------------------------------------*/ - - IF( NE_16( st->last_L_frame, st->L_frame ) ) - { - /* FEC - in case of core switching, use old LSFs */ - Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); // Q15 - Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); // Q15 - Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); // Q15 - } - - FEC_lsf_estim_enc_fx( st, fec_lsf ); - - /* in case of FEC in decoder - calculate LSF stability */ - stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st->L_frame ); // Q15 - - test(); - test(); - test(); - /* If decoder FEC frame may be unstable force safety-net usage */ - IF( ( EQ_16( st->L_frame, L_FRAME16k ) ) && ( LT_16( stab, STAB_FAC_LIMIT_FX ) ) && ( EQ_16( coder_type, GENERIC ) ) ) - { - st->next_force_safety_net = 1; - move16(); - } - ELSE IF( ( LT_16( stab, STAB_FAC_LIMIT_FX ) ) && ( EQ_16( st->clas, VOICED_CLAS ) || ( LT_16( st->clas, VOICED_CLAS ) && EQ_16( coder_type, AUDIO ) ) ) ) - { - st->next_force_safety_net = 1; - move16(); - } - - - /* 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->lsfoldbfi1_fx[i], 10922 ); /*Q(x2.56+16)*/ - L_tmp = L_mac( L_tmp, st->lsfoldbfi0_fx[i], 10922 ); /*Q(x2.56+16)*/ - st->lsf_adaptive_mean_fx[i] = extract_h( L_tmp ); /*Q(x2.56)*/ - } - - /* FEC - update LSF memories */ - Copy( st->lsfoldbfi0_fx, st->lsfoldbfi1_fx, M ); - Copy( lsf_new, st->lsfoldbfi0_fx, M ); - - - /*-------------------------------------------------------------------------------------* - * Mid-frame LSF encoding - * LSP interpolation and conversion of LSPs to A(z) - *-------------------------------------------------------------------------------------*/ - IF( st->rate_switching_reset ) - { - /*extrapolation in case of unstable LSF convert*/ - Copy( lsp_new, st->lsp_old_fx, M ); // Q15 - Copy( lsf_new, st->lsf_old_fx, M ); // Q15 - } - /* Mid-frame LSF encoding */ - lsf_mid_enc_ivas_fx( st->hBstr, st->acelp_cfg.mid_lsf_bits, st->sr_core, st->lsp_old_fx, lsp_new, lsp_mid, coder_type, st->bwidth, st->Bin_E_old_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); - - test(); - IF( EQ_16( st->last_core, HQ_CORE ) && EQ_16( st->core, ACELP_CORE ) ) - { - /* don't use old LSP/LSF values if this is the first ACELP frame after HQ frames */ - Copy( lsp_mid, st->lsp_old_fx, M ); - lsp2lsf_fx( lsp_mid, st->lsf_old_fx, M, st->sr_core ); - } - - /* LSP interpolation and conversion of LSPs to A(z) */ - test(); - IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) ) - { - IF( EQ_16( st->active_cnt, 1 ) ) - { - Copy( lsp_mid, st->lsp_old_fx, M ); // Q15 - lsp2lsf_fx( lsp_mid, st->lsf_old_fx, M, st->sr_core ); - Copy( lsp_new, lsp_mid, M ); // Q15 - } - - /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ -#ifdef HARM_LSF_ENC - int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); -#else - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); -#endif - } - ELSE - { -#ifdef HARM_LSF_ENC - int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); -#else - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); -#endif - } - - /*------------------------------------------------------------------* - * Check LSF stability (distance between old LSFs and current LSFs) - *------------------------------------------------------------------*/ - - IF( NE_32( st->core_brate, SID_2k40 ) ) - { - st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st->lsf_old_fx, 0, st->L_frame ); // Q15 - } - - return; -} -#endif /*-------------------------------------------------------------------* * lsfq_CNG_fx() @@ -668,9 +356,7 @@ void lsf_enc_ivas_fx( *-------------------------------------------------------------------*/ static void lsfq_CNG_fx( -#ifdef HARM_LSF_ENC const Word16 element_mode, /* i : element mode */ -#endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle*/ const Word16 *lsf, /*x2.56 unquantized LSF vector */ const Word16 *wghts, /*Q10 LSF weights */ @@ -746,7 +432,6 @@ static void lsfq_CNG_fx( /* quantize the difference with LVQ */ /* MSVQ_ROM to be updated */ -#ifdef HARM_LSF_ENC IF( element_mode == EVS_MONO ) { mslvq_cng_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts, p_no_scales ); @@ -760,12 +445,6 @@ static void lsfq_CNG_fx( index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG_IVAS + idx_cv, idx_lvq, 0 ); } -#else - mslvq_cng_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts, p_no_scales ); - - index_lvq_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG + idx_cv, idx_lvq, - p_offset_scale1, p_offset_scale2, p_no_scales ); -#endif Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M ); @@ -779,118 +458,27 @@ static void lsfq_CNG_fx( return; } -#ifndef HARM_LSF_ENC -static void lsfq_CNG_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *lsf, /*x2.56 unquantized LSF vector */ - const Word16 *wghts, /*Q10 LSF weights */ - Word16 *qlsf /*x2.56 quantized LSF vecotor */ + +/*-------------------------------------------------------------------* + * qlsf_Mode_Select_fx() + * + * Mode selection for LSF quantizer + *-------------------------------------------------------------------*/ + +static Word16 qlsf_Mode_Select_fx( + const Word16 *w, /* i : weighting vector Q8 */ + const Word16 *pred1, /* i : prediction vector x2.56 */ + const Word16 streaklimit, /* i : predictive streak limit Q15 */ + const Word32 op_loop_thr /* i : Open-loop Threshold */ ) { - Word16 i, j, idx_cv, idx_lvq[3]; - Word32 min_dist, dist; - Word16 dd[M], ddq[M]; - const Word16 *p_cb; - Word16 first_cb, last_cb; - Word16 idx_lead_cng[2], idx_scale_cng[2]; - Word16 tmp; + Word16 pred_pow2[M]; + Word32 temp32, En = 0; + Word16 safety_net; + Word16 i, cs, cl; - idx_cv = 0; - move16(); - - /* quantize first stage with 4 bits - The sampling frequency of the LP-CNG frame can be determined by checking the value of the highest order LSF - coefficient (last coefficient of lsf). If the last LSF coefficient (lsf[M-1]) is larger than 6350 - the decoded frame is WB2 with sampling rate of 16 kHz, otherwise it is sampled at 12.8kHz and contains - either NB or WB LSF data. */ - IF( GT_16( lsf[M - 1], WB_LIMIT_LSF_FX ) ) /* 16kHz sampled LSF vector*/ - { - p_cb = &CNG_SN1_fx[0]; - move16(); - first_cb = 0; - move16(); - last_cb = 6; - move16(); - } - ELSE /* 12.8kHz sampled LSF vector*/ - { - p_cb = &CNG_SN1_fx[6 * M]; - move16(); - first_cb = 6; - move16(); - last_cb = M; - move16(); - } - - - min_dist = L_add( MAXINT32, 0 ); - FOR( i = first_cb; i < last_cb; i++ ) - { - tmp = sub( *p_cb, shl( lsf[0], 1 ) ); /*x2.56 */ - dist = Mult_32_16( L_mult0( wghts[0], *p_cb ), tmp ); /*Q8 + x2.56 -Q15 + x2.56 = Q-7 + x2.56+x.256 */ - p_cb++; - FOR( j = 1; j < M; j++ ) - { - tmp = sub( *p_cb, lsf[j] ); - tmp = sub( tmp, lsf[j] ); - - dist = L_add( dist, Mult_32_16( L_mult0( wghts[j], *p_cb ), tmp ) ); - p_cb++; - } - IF( LT_32( dist, min_dist ) ) - { - min_dist = dist; - move16(); /*Q-4 */ - idx_cv = i; - move16(); - } - } - - /* calculate difference */ - FOR( i = 0; i < M; i++ ) - { - dd[i] = sub( lsf[i], CNG_SN1_fx[idx_cv * M + i] ); /*x2.56 */ - move16(); - } - - /* quantize the difference with LVQ */ - /* MSVQ_ROM to be updated */ - mslvq_cng_ivas_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts ); - - index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG_IVAS + idx_cv, idx_lvq, 0 ); - Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M ); - - /* write the VQ index to the bitstream */ - push_indice( hBstr, IND_ISF_0_0, idx_cv, 4 ); - - /* write the LVQ index to the bitstream */ - push_indice( hBstr, IND_ISF_0_1, idx_lvq[0], LEN_INDICE ); - push_indice( hBstr, IND_ISF_0_1, idx_lvq[1], LSF_BITS_CNG - 4 - LEN_INDICE ); - - return; -} -#endif - -/*-------------------------------------------------------------------* - * qlsf_Mode_Select_fx() - * - * Mode selection for LSF quantizer - *-------------------------------------------------------------------*/ - -static Word16 qlsf_Mode_Select_fx( - const Word16 *w, /* i : weighting vector Q8 */ - const Word16 *pred1, /* i : prediction vector x2.56 */ - const Word16 streaklimit, /* i : predictive streak limit Q15 */ - const Word32 op_loop_thr /* i : Open-loop Threshold */ -) -{ - Word16 pred_pow2[M]; - Word32 temp32, En = 0; - Word16 safety_net; - Word16 i, cs, cl; - - /* calculate the prediction residual */ - cl = 0; + /* calculate the prediction residual */ + cl = 0; move16(); FOR( i = 0; i < M; i++ ) { @@ -906,582 +494,71 @@ static Word16 qlsf_Mode_Select_fx( En = L_mac_sat( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ } - cs = shl( cs, 1 ); - En = L_shr( En, cs ); - temp32 = Mult_32_16( op_loop_thr, streaklimit ); - - /* choose the mode */ - IF( GT_32( En, temp32 ) ) - { - /* Safety-net */ - safety_net = 1; - move16(); - } - ELSE - { - /* Predictive */ - safety_net = 0; - move16(); - } - return safety_net; -} - - -/*========================================================================*/ -/* FUNCTION : lsf_end_enc_fx() */ -/*------------------------------------------------------------------------*/ -/* PURPOSE : Quantization of LSF parameters */ -/*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16*) lsf : LSF in the frequency domain (0..6400) x2.56 */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16) bwidth : input signal bandwidth */ -/* _ (Word16) nBits : number of bits used for ISF quantization */ -/* _ (Word16*) stable_isp : most recent stable ISP (can be */ -/* removed after passing to LSF) Q15 */ -/* _ (Word16*) stable_lsp : most recent stable LSP Q15 */ -/* _ (Word32*) grid : Table of 100 grid points for evaluating */ -/* Chebyshev polynomials Q31 */ -/* _ (Word16) int_fs : sampling frequency */ -/* _ (Word32) core_brate : Coding Bit Rate */ -/* _ (Word16) force_sf : Force safety-net usage if possible */ -/* _ (Word32*) Bin_Ener : FFT Bin energy 128 *2 sets Q_ener */ -/* _ (Word16) Q_ener : Q format of Bin_Ener */ -/* _ (Word32*) offset_scale1: offsets for LSF LVQ structure 1st */ -/* 8-dim subvector Q0 */ -/* _ (Word32*) offset_scale2: offsets for LSF LVQ structure 2nd */ -/* 8-dim subvector Q0 */ -/* _ (Word32*) offset_scale1_p: offsets for LSF LVQ structure, pred. */ -/* case, 1st 8-dim subvector Q0 */ -/* _ (Word32*) offset_scale2_p: offsets for LSF LVQ structure, */ -/* pred. case, 2nd 8-dim subvector Q0 */ -/* _ (Word16*) no_scales : LSF LVQ structure Q0 */ -/* _ (Word16*) no_scales_p : LSF LVQ structure Q0 */ -/*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16*) mem_AR : quantizer memory for AR model x2.56 */ -/*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) qlsf : quantized LSFs in the cosine domain x2.56 */ -/*------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*========================================================================*/ -#ifndef HARM_LSF_ENC -void lsf_end_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ - Word16 *qlsf, /* o : quantized LSF x2.56*/ - const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ - const Word16 coder_type_org, /* i : coding type */ - Word16 Q_ener, /* i : Q valuen for Bin_Ener */ - Word16 force_sf, /* i : Force safety-net usage if coding type supports */ - Word16 *lpc_param, - Word16 *no_indices, - Word16 *bits_param_lpc, - Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ -) -{ - Word16 i; - Word16 Idx0[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for safety-net quantizer */ - Word16 Idx1[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for predictive quantizer */ - Word16 indice[MAX_VQ_STAGES + 3]; /* Temp. array of indice for vector de-quantizer */ - Word16 mode_lvq = 0, mode_lvq_p = 0; /* LVQ mode and predictive LVQ mode */ - Word16 bits0[MAX_VQ_STAGES], bits1[MAX_VQ_STAGES]; - const Word16 *Bit_alloc1 = NULL; - Word32 Err[2]; /* Quantization error for safety-net(0) and predictive(1) quantizers */ - Word16 Tmp[M]; /* Temporary target vector (mean and prediction removed) */ - Word16 pred0[M]; /* Prediction for the safety-net quantizer (usually mean) */ - Word16 pred1[M]; /* Prediction for the predictive quantizer */ - Word16 pred2[M]; /* Prediction for the predictive quantizer */ - Word16 wghts[M]; /* Weighting used for quantizer (currently GSM based) */ - Word16 stages0; /* Amount of stages used by safety-net quantizer */ - Word16 stages1; /* Amount of stages used by predictive quantizer */ - Word16 levels0[MAX_VQ_STAGES]; /* Sizes of different codebook stages for safety-net quantizer */ - Word16 levels1[MAX_VQ_STAGES]; /* Sizes of different codebook stages for predictive quantizer */ - Word16 predmode; /* 0: safety-net only, 1: predictive only, 2: best of the two */ - Word16 safety_net, cumleft, num_bits; - Word16 *Idx, stages, *bits; - Word16 Tmp2[M], Tmp1[M]; - Word32 abs_threshold; /* Absolute threshold depending on signal bandwidth, that indicates - very good perceptual LSF quantization performance */ - Word16 lsfq[M * 2], resq[M * 2]; - Word16 coder_type; /* coder type (from LSF quantizer point of view) */ - Word16 nBits; /* Number of bits */ - Word16 TCQIdx0[M + 2]; /* Optimal codebook indices for VQ-TCQ quantizer */ - Word16 *TCQIdx; - Word16 tmp; - Word16 flag_1bit_gran; - BSTR_ENC_HANDLE hBstr = st->hBstr; - - flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO ); - - nBits = nBits_in; - move16(); - /* Update LSF coder_type for LSF quantizer for some special cases */ - test(); - test(); - test(); - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) ) - { - IF( EQ_16( coder_type_raw, VOICED ) ) - { - coder_type = VOICED; - move16(); /* Reflect Inactive mode */ - if ( EQ_16( flag_1bit_gran, 1 ) ) - { - nBits = sub( nBits, 1 ); /* This is for real Generic*/ - } - } - ELSE - { - nBits = sub( nBits, 1 ); /* This is for real Generic*/ - coder_type = coder_type_org; - move16(); - } - } - ELSE - { - coder_type = coder_type_org; - move16(); - } - - /*----------------------------------------------------------------------------------- -* - * Calculate the number of stages and levels for each stage based on allowed bit budget - * Set absolute threshold for codebook-type decision logic depending on signal bandwidth - *------------------------------------------------------------------------------------ -*/ - IF( EQ_16( st->bwidth, NB ) ) - { - abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); - } - ELSE - { - abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); - } - /* Calculate LSF weighting coefficients */ - Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], Q_ener, lsf, wghts, (Word16) EQ_16( st->bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), st->sr_core, M ); - - /*--------------------------------------------------------------------------------* - * LSF quantization of SID frames - *--------------------------------------------------------------------------------*/ - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - lsfq_CNG_fx( hBstr, lsf, wghts, qlsf, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->no_scales_fx[0][0] ); - sort_fx( qlsf, 0, M - 1 ); - reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core ); - - return; - } - /* Find allowed predictor mode for current coder_type. (SN only (0), SN/AR switched (2) or MA predictive (1) */ - find_pred_mode( &predmode, coder_type, st->bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate ); - - /*----------------------------------------------------------------* - * Calculate number of stages and levels for each stage based on the allowed bit allocation - * (subtract one bit for LSF predictor selection) - *----------------------------------------------------------------*/ - lsf_allocate_fx( sub( nBits, shr( predmode, 1 ) ), mode_lvq, mode_lvq_p, &stages0, &stages1, levels0, levels1, bits0, bits1 ); - - - /*--------------------------------------------------------------------------------* - * LSF quantization of all other frames but SID frames - * Select safety-net or predictive mode - *--------------------------------------------------------------------------------*/ - - Err[0] = MAXINT32; - move32(); - Err[1] = MAXINT32; - move32(); - /* for mem_MA update */ - FOR( i = 0; i < M; i++ ) - { - pred1[i] = add( ModeMeans_fx[mode_lvq][i], mult_r( MU_MA_FX, st->mem_MA_fx[i] ) ); - move16(); - } - - IF( predmode == 0 ) - { - /* Subtract only mean */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - Vr_subt( lsf, pred0, Tmp, M ); - - /* LVQ quantization (safety-net only) */ - Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, - st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); - safety_net = 1; - move16(); - st->pstreaklen = 0; - move16(); /* predictive LSF quantizer streak is ended with safety-net */ - } - ELSE IF( EQ_16( predmode, 1 ) ) /* only MA prediction */ - { - Vr_subt( lsf, pred1, Tmp1, M ); - Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, - st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, resq, lsfq ); - - safety_net = 0; - move16(); - } - ELSE - { - /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in - case of possible frame erasure. AR-predictive usage for VOICED mode is allowed to be higher than other modes. */ - test(); - test(); - test(); - IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) ) - { - /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ - st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); // Q15 - move16(); - } - - IF( st->pstreaklen == 0 ) - { - /* reset the consecutive AR-predictor multiplier */ - st->streaklimit_fx = 32767; /*1.0 in Q15 */ - move16(); - } - - /* VOICED_WB@16kHz */ - test(); - IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 ) - { - /* Subtract mean and AR prediction */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - /* subtract only mean */ - Vr_subt( lsf, pred0, Tmp, M ); - - FOR( i = 0; i < M; i++ ) - { - /* subtract mean and AR prediction */ - pred2[i] = mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ); - Tmp2[i] = sub( Tmp[i], pred2[i] ); - pred2[i] = add( pred2[i], pred0[i] ); - } - - /* select safety_net or predictive */ - safety_net = qlsf_Mode_Select_fx( wghts, Tmp2, st->streaklimit_fx, OP_LOOP_THR_HVO ); - IF( EQ_16( force_sf, 1 ) ) - { - safety_net = 1; - move16(); - } - - IF( safety_net ) - { - /* Safety-net - BC-TCQ quantization : SN */ - Err[0] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); - st->pstreaklen = 0; - move16(); - } - ELSE - { - /* predictive - BC-TCQ quantization : AR */ - Err[1] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp2, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); - st->pstreaklen = add( st->pstreaklen, 1 ); - } - } - /* all other frames (not VOICED@16kHz) */ - ELSE - { - /* Subtract mean and AR prediction */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - /* subtract only mean */ - Vr_subt( lsf, pred0, Tmp, M ); - - FOR( i = 0; i < M; i++ ) - { - /* subtract mean and AR prediction */ - pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) ); - Tmp2[i] = sub( lsf[i], pred2[i] ); - } - - /* safety-net */ - Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); - /* Predictive quantizer is calculated only if it can be selected */ - test(); - IF( !force_sf || GT_32( Err[0], abs_threshold ) ) - { - Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, - st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); - } - test(); - test(); - /* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following: - if the non-predictive (safety-net) quantization error (Err[0]) is low enough (spectral distortion is low) it is selected - or if the predictively quantized error (Err[1]) is by at least adaptive margin smaller than non-predictive quantizer. - or if the in case of frame erasure the resulting concealed predictive LSF would be unstable safety-net is selected */ - IF( force_sf || LT_32( Mult_32_16( Err[0], ( st->streaklimit_fx ) ), L_add( Err[1], Mult_32_16( Err[1], PREFERSFNET_FX ) ) ) || LT_32( Err[0], abs_threshold ) ) - { - safety_net = 1; - move16(); - st->pstreaklen = 0; - move16(); /* Reset the consecutive predictive frame counter */ - } - ELSE - { - safety_net = 0; - move16(); /* Increase the consecutive predictive frame counter by one */ - st->pstreaklen = add( st->pstreaklen, 1 ); - } - } - } - - /*--------------------------------------------------------------------------* \ - * Write indices to array \ - *--------------------------------------------------------------------------*/ - - IF( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->core, ACELP_CORE ) ) - { - /* write coder_type bit for VOICED@16kHz or GENERIC@16kHz */ - test(); - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) ) - { - /* VOICED =2 and GENERIC=3, so "coder_type-2" means VOICED =0 and GENERIC=1*/ - push_indice( hBstr, IND_LSF_PREDICTOR_SELECT_BIT, sub( coder_type, 2 ), 1 ); - } - - /* write predictor selection bit */ - IF( EQ_16( predmode, 2 ) ) - { - push_indice( st->hBstr, IND_LSF_PREDICTOR_SELECT_BIT, safety_net, 1 ); - } - - test(); - IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 ) - { - /* BC-TCVQ (only for VOICED@16kHz) */ - TCQIdx = &TCQIdx0[1]; - Bit_alloc1 = &BC_TCVQ_BIT_ALLOC_40B[1]; - FOR( i = 0; i < ( M / 2 ) + 3; i++ ) - { - push_indice( hBstr, IND_LSF, TCQIdx[i], Bit_alloc1[i] ); - } - } - ELSE - { - cumleft = nBits; - move16(); - IF( EQ_16( predmode, 2 ) ) - { - /* subtract predictor selection bit */ - cumleft = sub( nBits, 1 ); - } - - IF( safety_net ) - { - stages = stages0; - move16(); - Idx = Idx0; - move16(); - bits = bits0; - move16(); - } - ELSE - { - stages = stages1; - move16(); - Idx = Idx1; - move16(); - bits = bits1; - move16(); - } - - tmp = sub( stages, 1 ); - FOR( i = 0; i < tmp; i++ ) - { - indice[i] = Idx[i]; - move16(); - num_bits = bits[i]; - move16(); - cumleft -= num_bits; - move16(); - push_indice( hBstr, IND_LSF, indice[i], num_bits ); - } - - WHILE( cumleft > 0 ) - { - indice[i] = Idx[i]; - move16(); - - IF( GT_16( cumleft, LEN_INDICE ) ) - { - num_bits = LEN_INDICE; - move16(); - } - ELSE - { - num_bits = cumleft; - move16(); - } - - cumleft = sub( cumleft, num_bits ); - push_indice( hBstr, IND_LSF, indice[i], num_bits ); - i = add( i, 1 ); - } - } - } - ELSE - { - test(); - IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) ) - { - /* BC-TCVQ (only for VOICED@16kHz) */ - /* Number of quantization indices */ - *no_indices = 10; - move16(); - FOR( i = 0; i < *no_indices; i++ ) - { - lpc_param[i] = TCQIdx0[i]; - move16(); - bits_param_lpc[i] = BC_TCVQ_BIT_ALLOC_40B[i]; // Q0 - move16(); - } - } - ELSE - { - /* Number of quantization indices */ - - /* there are 31 bits */ - IF( EQ_16( safety_net, 1 ) ) - { - Idx = Idx0; - move16(); - *no_indices = add( stages0, 1 ); - FOR( i = 0; i < stages0; i++ ) - { - lpc_param[i] = Idx[i]; - move16(); - indice[i] = Idx[i]; - move16(); - bits_param_lpc[i] = bits0[i]; - move16(); - } - lpc_param[stages0] = Idx[stages0]; - move16(); - indice[stages0] = Idx[stages0]; - move16(); - tmp = sub( stages0, 1 ); - bits_param_lpc[tmp] = LEN_INDICE; - move16(); - bits_param_lpc[stages0] = sub( bits0[tmp], LEN_INDICE ); - } - ELSE - { - *no_indices = add( stages1, 1 ); - Idx = Idx1; - move16(); - FOR( i = 0; i < stages1; i++ ) - { - lpc_param[i] = ( Idx[i] ); - move16(); - indice[i] = Idx[i]; - move16(); - bits_param_lpc[i] = bits1[i]; - move16(); - } - lpc_param[stages1] = ( Idx[stages1] ); - move16(); - indice[stages1] = Idx[stages1]; - move16(); - tmp = sub( stages1, 1 ); - bits_param_lpc[tmp] = LEN_INDICE; - move16(); - bits_param_lpc[stages1] = sub( bits1[tmp], LEN_INDICE ); - } - IF( EQ_16( predmode, 2 ) ) - { - FOR( i = *no_indices; i > 0; i-- ) - { - tmp = sub( i, 1 ); - lpc_param[i] = lpc_param[tmp]; - move16(); - bits_param_lpc[i] = bits_param_lpc[tmp]; - move16(); - } - lpc_param[0] = safety_net; - move16(); /* put the safety net info on the last param */ - bits_param_lpc[0] = 1; - move16(); - *no_indices = add( *no_indices, 1 ); - } - } - } - - - /*--------------------------------------------------------------------------* - * De-quantize encoded LSF vector - *--------------------------------------------------------------------------*/ - - IF( safety_net ) - { - /* Safety-net */ - test(); - IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 ) - { - /* BC-TCQ */ - Copy( lsfq, st->mem_MA_fx, M ); - Vr_add( lsfq, pred0, qlsf, M ); - } - ELSE - { - { - vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1], - &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], - &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); - Vr_add( qlsf, pred0, qlsf, M ); - Vr_subt( qlsf, pred1, st->mem_MA_fx, M ); - } - } - } - ELSE - { - test(); - IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 ) - { - /* BC-TCVQ */ - Copy( lsfq, st->mem_MA_fx, M ); - Vr_add( lsfq, pred2, qlsf, M ); - } - ELSE - { - /* LVQ */ - vq_dec_lvq_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1], - &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], - &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); - IF( EQ_16( predmode, 1 ) ) - { - Copy( qlsf, st->mem_MA_fx, M ); - Vr_add( qlsf, pred1, qlsf, M ); - } - ELSE - { - Vr_add( qlsf, pred2, qlsf, M ); - Vr_subt( qlsf, pred1, st->mem_MA_fx, M ); - } - } - } + cs = shl( cs, 1 ); + En = L_shr( En, cs ); + temp32 = Mult_32_16( op_loop_thr, streaklimit ); - /* Sort the quantized vector to ascending order */ - sort_fx( qlsf, 0, M - 1 ); + /* choose the mode */ + IF( GT_32( En, temp32 ) ) + { + /* Safety-net */ + safety_net = 1; + move16(); + } + ELSE + { + /* Predictive */ + safety_net = 0; + move16(); + } + return safety_net; +} - /* Verify stability by adding minimum separation */ - reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core ); - /* Update AR-predictor memories */ - Copy( qlsf, st->mem_AR_fx, M ); +/*========================================================================*/ +/* FUNCTION : lsf_end_enc_fx() */ +/*------------------------------------------------------------------------*/ +/* PURPOSE : Quantization of LSF parameters */ +/*------------------------------------------------------------------------*/ +/* INPUT ARGUMENTS : */ +/* _ (Word16*) lsf : LSF in the frequency domain (0..6400) x2.56 */ +/* _ (Word16) coder_type : coding type */ +/* _ (Word16) bwidth : input signal bandwidth */ +/* _ (Word16) nBits : number of bits used for ISF quantization */ +/* _ (Word16*) stable_isp : most recent stable ISP (can be */ +/* removed after passing to LSF) Q15 */ +/* _ (Word16*) stable_lsp : most recent stable LSP Q15 */ +/* _ (Word32*) grid : Table of 100 grid points for evaluating */ +/* Chebyshev polynomials Q31 */ +/* _ (Word16) int_fs : sampling frequency */ +/* _ (Word32) core_brate : Coding Bit Rate */ +/* _ (Word16) force_sf : Force safety-net usage if possible */ +/* _ (Word32*) Bin_Ener : FFT Bin energy 128 *2 sets Q_ener */ +/* _ (Word16) Q_ener : Q format of Bin_Ener */ +/* _ (Word32*) offset_scale1: offsets for LSF LVQ structure 1st */ +/* 8-dim subvector Q0 */ +/* _ (Word32*) offset_scale2: offsets for LSF LVQ structure 2nd */ +/* 8-dim subvector Q0 */ +/* _ (Word32*) offset_scale1_p: offsets for LSF LVQ structure, pred. */ +/* case, 1st 8-dim subvector Q0 */ +/* _ (Word32*) offset_scale2_p: offsets for LSF LVQ structure, */ +/* pred. case, 2nd 8-dim subvector Q0 */ +/* _ (Word16*) no_scales : LSF LVQ structure Q0 */ +/* _ (Word16*) no_scales_p : LSF LVQ structure Q0 */ +/*------------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _ (Word16*) mem_AR : quantizer memory for AR model x2.56 */ +/*------------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) qlsf : quantized LSFs in the cosine domain x2.56 */ +/*------------------------------------------------------------------------*/ - return; -} -#endif +/*------------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*========================================================================*/ -#ifdef HARM_LSF_ENC void lsf_end_enc_fx( -#else -void lsf_end_enc_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ Word16 *qlsf, /* o : quantized LSF x2.56*/ @@ -1530,7 +607,6 @@ void lsf_end_enc_ivas_fx( Word16 pred3[M]; Word16 dummy, dummy_v[5]; -#ifdef HARM_LSF_ENC flag_1bit_gran = 0; move16(); if ( GT_16( st->element_mode, EVS_MONO ) ) @@ -1538,9 +614,6 @@ void lsf_end_enc_ivas_fx( flag_1bit_gran = 1; move16(); } -#else - flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO ); -#endif nBits = nBits_in; move16(); @@ -1583,11 +656,7 @@ void lsf_end_enc_ivas_fx( #ifdef FIX_2302_LSF_CDBK_THRESHOLD abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); #else -#ifdef HARM_LSF_ENC abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); -#else - abs_threshold = SFNETLOWLIMIT_NB / 2; -#endif #endif } ELSE @@ -1597,12 +666,10 @@ void lsf_end_enc_ivas_fx( #else abs_threshold = SFNETLOWLIMIT_WB / 2; move32(); -#ifdef HARM_LSF_ENC if ( flag_1bit_gran == 0 ) { abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); } -#endif #endif } @@ -1615,11 +682,7 @@ void lsf_end_enc_ivas_fx( IF( EQ_32( st->core_brate, SID_2k40 ) ) { -#ifdef HARM_LSF_ENC lsfq_CNG_fx( st->element_mode, hBstr, lsf, wghts, qlsf, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->no_scales_fx[0][0] ); -#else - lsfq_CNG_ivas_fx( hBstr, lsf, wghts, qlsf ); -#endif sort_fx( qlsf, 0, M - 1 ); reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core ); @@ -1670,14 +733,12 @@ void lsf_end_enc_ivas_fx( Vr_subt( lsf, pred0, Tmp, M ); /* LVQ quantization (safety-net only) */ -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); } ELSE -#endif { Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq ); } @@ -1691,14 +752,12 @@ void lsf_end_enc_ivas_fx( { Vr_subt( lsf, pred1, Tmp1, M ); -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, resq, lsfq ); } ELSE -#endif { Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, resq, lsfq ); } @@ -1773,13 +832,11 @@ void lsf_end_enc_ivas_fx( ELSE { /* Switched Safety-Net/AR prediction */ -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); } ELSE -#endif { Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq ); } @@ -1788,14 +845,12 @@ void lsf_end_enc_ivas_fx( test(); IF( !force_sf || GT_32( Err[0], abs_threshold ) ) { -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); } ELSE -#endif { Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, &resq[M], &lsfq[M] ); } @@ -2101,7 +1156,6 @@ void lsf_end_enc_ivas_fx( } ELSE { -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1], @@ -2109,7 +1163,6 @@ void lsf_end_enc_ivas_fx( &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); } ELSE -#endif { vq_dec_lvq_ivas_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1] ); } @@ -2131,7 +1184,6 @@ void lsf_end_enc_ivas_fx( ELSE { /* LVQ */ -#ifdef HARM_LSF_ENC IF( flag_1bit_gran == 0 ) { vq_dec_lvq_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1], @@ -2139,7 +1191,6 @@ void lsf_end_enc_ivas_fx( &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] ); } ELSE -#endif { vq_dec_lvq_ivas_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1] ); } @@ -3685,9 +2736,7 @@ static void FFT_Mid_Interpol_16k_fx( static void lsf_mid_enc_fx( -#ifdef HARM_LSF_ENC const Word16 element_mode, /* i : element mode */ -#endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 nb_bits, /* i : number of bits */ const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/ @@ -3715,7 +2764,6 @@ static void lsf_mid_enc_fx( lsp2lsf_fx( qlsp0, qlsf0, M, int_fs ); lsp2lsf_fx( qlsp1, qlsf1, M, int_fs ); -#ifdef HARM_LSF_ENC IF( element_mode == EVS_MONO ) { /* calculate weights */ @@ -3730,14 +2778,6 @@ static void lsf_mid_enc_fx( Unified_weighting_fx( Bin_Ener_old, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); move16(); } -#else - /* calculate weights */ - FFT_Mid_Interpol_16k_fx( Bin_Ener_old, &Bin_Ener[L_FFT / 2], Bin_Ener_mid ); - - /* LSF weighting */ - Unified_weighting_fx( Bin_Ener_mid, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); - move16(); -#endif /* codebook selection, number of bits, size of the codebook */ test(); @@ -3760,14 +2800,12 @@ static void lsf_mid_enc_fx( move16(); BREAK; } -#ifdef HARM_LSF_ENC case 1: { ratio = tbl_mid_voi_wb_1b_fx; // Q13 move16(); BREAK; } -#endif } } ELSE IF( EQ_16( coder_type, UNVOICED ) ) @@ -3785,14 +2823,12 @@ static void lsf_mid_enc_fx( move16(); BREAK; } -#ifdef HARM_LSF_ENC case 4: { ratio = tbl_mid_gen_wb_4b_fx; // Q13 move16(); BREAK; } -#endif case 2: { ratio = tbl_mid_gen_wb_2b_fx; @@ -3896,188 +2932,3 @@ static void lsf_mid_enc_fx( return; } -#ifndef HARM_LSF_ENC - -static void lsf_mid_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 nb_bits, /* i : number of bits */ - const Word32 int_fs, /* i : internal (ACELP) sampling frequency*/ - const Word16 qlsp0[], /* i : quantized LSPs from frame beginning Q15*/ - const Word16 qlsp1[], /* i : quantized LSPs from frame end Q15*/ - Word16 lsp[], /* i/o: mid-frame LSP Q15*/ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - Word32 Bin_Ener[], /* i : per bin log energy spectrum Q_ener*/ - Word16 Q_ener, /* i : Q value of Bin_ener */ - Word16 ppp_mode, - Word16 nelp_mode ) -{ - Word16 lsf[M], qlsf[M], qlsf1[M], qlsf0[M], wghts[M]; - Word32 err, err_min; - Word16 j, k, idx, size = 0; - Word32 L_tmp; - Word16 tmp, k1; - const Word16 *ratio = NULL; - - /* convert LSPs to LSFs */ - lsp2lsf_fx( lsp, lsf, M, int_fs ); - lsp2lsf_fx( qlsp0, qlsf0, M, int_fs ); - lsp2lsf_fx( qlsp1, qlsf1, M, int_fs ); - - /* LSF weighting */ - Unified_weighting_fx( Bin_Ener, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M ); - move16(); - /* codebook selection, number of bits, size of the codebook */ - test(); - IF( ppp_mode == 0 && nelp_mode == 0 ) - { - /* codebook selection */ - IF( EQ_16( coder_type, VOICED ) ) - { - SWITCH( nb_bits ) - { - case 5: - { - ratio = tbl_mid_voi_wb_5b_fx; // Q13 - move16(); - BREAK; - } - case 4: - { - ratio = tbl_mid_voi_wb_4b_fx; // Q13 - move16(); - BREAK; - } - case 1: - { - ratio = tbl_mid_voi_wb_1b_fx; // Q13 - move16(); - BREAK; - } - } - } - ELSE IF( EQ_16( coder_type, UNVOICED ) ) - { - ratio = tbl_mid_unv_wb_5b_fx; // Q13 - } - ELSE - { - /* GENERIC, TRANSITION, AUDIO and INACTIVE */ - SWITCH( nb_bits ) - { - case 5: - { - ratio = tbl_mid_gen_wb_5b_fx; // Q13 - move16(); - BREAK; - } - case 4: - { - ratio = tbl_mid_gen_wb_4b_fx; // Q13 - move16(); - BREAK; - } - case 2: - { - ratio = tbl_mid_gen_wb_2b_fx; // Q13 - move16(); - BREAK; - } - } - } - - size = (Word16) pow2[nb_bits]; - move16(); - } - ELSE IF( EQ_16( ppp_mode, 1 ) ) - { - ratio = tbl_mid_voi_wb_1b_fx; // Q13 - move16(); - nb_bits = 1; - move16(); - size = 2; - move16(); - } - ELSE IF( EQ_16( nelp_mode, 1 ) ) - { - ratio = tbl_mid_unv_wb_4b_fx; // Q13 - move16(); - nb_bits = 4; - move16(); - size = 16; - move16(); - } - - /* loop over codevectors */ - err_min = MAXINT32; - move16(); - idx = 0; - move16(); - k1 = 0; - move16(); - FOR( k = 0; k < size; k++ ) - { - err = L_deposit_l( 0 ); - - FOR( j = 0; j < M; j++ ) - { - /* qlsf[j] = (1.0f - ratio[k*M+j]) * qlsf0[j] + ratio[k*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[k1 + j] ), qlsf0[j] ); - L_tmp = L_mac( L_tmp, ratio[k1 + j], qlsf1[j] ); - qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); - - test(); - test(); - IF( j > 0 && LT_16( j, M ) && LT_16( qlsf[j], add( qlsf[j - 1], LSF_GAP_MID_FX ) ) ) - { - qlsf[j] = add( qlsf[j - 1], LSF_GAP_MID_FX ); - move16(); - } - - tmp = sub( lsf[j], qlsf[j] ); - /* err += wghts[j] * ftemp * ftemp; */ - /* tmp is usually very small, we can have some extra precision with very rare saturation */ - tmp = shl_sat( tmp, 4 ); - tmp = mult_r_sat( tmp, tmp ); - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); - } - /* err = L_shl(err,Wscale); */ - err = Mult_32_16( err, LSF_1_OVER_256SQ ); - /* err = Mult_32_16(err,Wmult); */ - - IF( LT_32( err, err_min ) ) - { - err_min = L_add( err, 0 ); - idx = k; - move16(); - } - k1 += M; - move16(); - } - - /* calculate the quantized LSF vector */ - FOR( j = 0; j < M; j++ ) - { - /* qlsf[j] = (1.0f - ratio[idx*M+j]) * qlsf0[j] + ratio[idx*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[idx * M + j] ), qlsf0[j] ); - L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] ); - qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); - - test(); - test(); - IF( j > 0 && LT_16( j, M ) && LT_16( qlsf[j], add( qlsf[j - 1], LSF_GAP_MID_FX ) ) ) - { - qlsf[j] = add( qlsf[j - 1], LSF_GAP_MID_FX ); - move16(); - } - } - - reorder_lsf_fx( qlsf, LSF_GAP_MID_FX, M, int_fs ); - - /* convert LSFs back to LSPs */ - lsf2lsp_fx( qlsf, lsp, M, int_fs ); - push_indice( hBstr, IND_MID_FRAME_LSF_INDEX, idx, nb_bits ); - - return; -} -#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 7e172b31d..969649190 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -908,25 +908,7 @@ void LPDmem_enc_init_fx( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); -#ifndef HARM_LSF_ENC void lsf_end_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ - Word16 *qlsf, /* o : quantized LSF */ - const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ - const Word16 coder_type_org, /* i : coding type */ - Word16 Q_ener, /* i : Q valuen for Bin_Ener */ - Word16 force_sf, /* i : Force safety-net usage if coding type supports */ - Word16 *lpc_param, - Word16 *no_indices, - Word16 *bits_param_lpc, - Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ -); - -void lsf_end_enc_ivas_fx( -#else -void lsf_end_enc_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ Word16 *qlsf, /* o : quantized LSF */ @@ -1554,22 +1536,6 @@ void lpc_quantization_fx( Word16 *no_param_lpc, /* Q0 */ const Word16 Q_ener ); -#ifndef HARM_LSF_ENC -void lpc_quantization_ivas_fx( - Encoder_State *st, - const Word16 lsp[], /* Q15 */ - const Word16 lspmid[], /* Q15 */ - Word16 lsp_q[], /* Q15 */ - Word16 lsf_q[], /* 14Q1*1.28 */ - Word16 lspmid_q[], /* Q15 */ - const Word16 coder_type, /* Q0 */ - const Word16 acelp_midLpc, /* Q0 */ - Word16 param_lpc[], /* Q0 */ - Word16 nbits_lpc[], /* Q0 */ - Word16 *bits_param_lpc, /* Q0 */ - Word16 *no_param_lpc, /* Q0 */ - const Word16 Q_ener ); -#endif void Mode2_pit_encode_fx( const Word16 coder_type, /* i : coding model */ const Word16 i_subfr, /* i : subframe index */ @@ -1846,28 +1812,11 @@ void lsf_enc_fx( Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ Word16 *Aq, /* o : quantized A(z) for 4 subframes */ -#ifndef HARM_LSF_ENC - const Word16 Nb_ACELP_frames, -#endif const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ -#ifdef HARM_LSF_ENC const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ -#endif const Word16 Q_new ); -#ifndef HARM_LSF_ENC -void lsf_enc_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector */ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const Word16 Q_new ); -#endif void Es_pred_enc_fx( Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ Word16 *indice, /* o : indice of quantization Q0*/ diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 0e0672abd..0d02d4742 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -117,26 +117,16 @@ void lpc_quantization_fx( test(); IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, UNVOICED ) ) { -#ifdef HARM_LSF_ENC lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); -#else - lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC ); -#endif nb_indices = *no_param_lpc; // Q0 move16(); } ELSE { -#ifdef HARM_LSF_ENC lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); -#else - lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type ); -#endif nb_indices = *no_param_lpc; // Q0 move16(); @@ -206,179 +196,6 @@ void lpc_quantization_fx( return; } -#ifndef HARM_LSF_ENC -void lpc_quantization_ivas_fx( - Encoder_State *st, - const Word16 lsp[], /* Q15 */ - const Word16 lspmid[], /* Q15 */ - Word16 lsp_q[], /* Q15 */ - Word16 lsf_q[], /* 14Q1*1.28 */ - Word16 lspmid_q[], /* Q15 */ - const Word16 coder_type, /* Q0 */ - const Word16 acelp_midLpc, /* Q0 */ - Word16 param_lpc[], /* Q0 */ - Word16 nbits_lpc[], /* Q0 */ - Word16 *bits_param_lpc, /* Q0 */ - Word16 *no_param_lpc, /* Q0 */ - const Word16 Q_ener ) -{ - Word16 nb_indices; - Word16 lsfmid_q[M]; /* 14Q1*1.28 */ - Word16 lsfmid_idx; - Word16 i, force_sf; - Word16 lsf[M], lsfmid[M]; - Word16 fec_lsf[M], stab; - - nb_indices = 0; - move16(); - - /****** High-rate LPC quantizer *******/ - - IF( st->lpcQuantization == 0 ) - { - E_LPC_lsp_lsf_conversion( lsp, lsf, M ); - - IF( ( EQ_16( st->core, TCX_10_CORE ) ) ) - { - E_LPC_lsp_lsf_conversion( lspmid, lsfmid, M ); - } - - /* LPC quantizer */ - qlpc_avq_fx( lsf, lsfmid, lsf_q, lsfmid_q, param_lpc, &nb_indices, nbits_lpc, st->core, st->sr_core ); - - E_LPC_lsf_lsp_conversion( lsf_q, lsp_q, M ); - - IF( EQ_16( st->core, TCX_10_CORE ) ) - { - E_LPC_lsf_lsp_conversion( lsfmid_q, lspmid_q, M ); - } - - assert( nb_indices <= NPRM_LPC_NEW ); - } - - /****** Low-rate LPC quantizer *******/ - - ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) - { - - lsp2lsf_fx( lsp, lsf, M, extract_l( st->sr_core ) ); - - force_sf = 0; - move16(); - /*Force safety net when possible in case of transitions*/ - test(); - test(); - IF( GE_32( st->tc_cnt, 1 ) || LE_32( st->last_core_brate, SID_2k40 ) || ( EQ_16( st->next_force_safety_net, 1 ) ) ) - { - force_sf = 1; - move16(); - st->next_force_safety_net = 0; - move16(); - } - - test(); - IF( EQ_16( st->next_force_safety_net, 1 ) && EQ_16( st->Opt_RF_ON, 1 ) ) - { - force_sf = 1; - st->next_force_safety_net = 0; - move16(); - move16(); - } - - test(); - IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, UNVOICED ) ) - { -#ifdef HARM_LSF_ENC - lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); -#else - lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL ); -#endif - - nb_indices = *no_param_lpc; // Q0 - move16(); - } - ELSE - { -#ifdef HARM_LSF_ENC - lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); -#else - lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener, - force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL ); -#endif - - nb_indices = *no_param_lpc; // Q0 - move16(); - } - - - FEC_lsf_estim_enc_fx( st, fec_lsf ); - - /* FEC - calculate LSF stability */ - stab = lsf_stab_fx( lsf_q, fec_lsf, 0, st->L_frame ); /*Q15*/ - - - test(); - test(); - test(); - IF( LT_16( stab, add( STAB_FAC_LIMIT_FX, 6553 /* =0.2 in Q15*/ ) ) && - ( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) ) && EQ_16( st->Opt_RF_ON, 1 ) ) - { - st->next_force_safety_net = 1; - move16(); - } - - lsf2lsp_fx( lsf_q, lsp_q, M, st->sr_core ); - - *nbits_lpc = ENDLSF_NBITS; - move16(); - } - ELSE - { - assert( 0 ); - } - - st->seed_acelp = 0; - move16(); - FOR( i = nb_indices - 1; i >= 0; i-- ) - { - st->seed_acelp = extract_l( L_mac0( L_mac0( 13849, shr( st->seed_acelp, 1 ), 31821 ), param_lpc[i], 31821 ) ); // Q0 - move16(); - } - - /* Mid-frame LPC quantization */ - - test(); - IF( st->lpcQuantization && acelp_midLpc ) - { - - IF( st->rate_switching_reset == 0 ) - { - lsp2lsf_fx( lspmid, lsfmid, M, extract_l( st->sr_core ) ); - - midlsf_enc_fx( st->lsf_old_fx, lsf_q, lsfmid, &lsfmid_idx, M, st->Bin_E_old_fx, Q_ener, (Word8) st->narrowBand, st->sr_core, coder_type ); - param_lpc[nb_indices] = lsfmid_idx; // Q0 - move16(); - nb_indices = add( nb_indices, 1 ); - midlsf_dec( st->lsf_old_fx, lsf_q, lsfmid_idx, lsfmid_q, coder_type, NULL, 0, 1 ); - - reorder_lsf_fx( lsfmid_q, LSF_GAP_MID_FX, M, st->sr_core ); - lsf2lsp_fx( lsfmid_q, lspmid_q, M, st->sr_core ); - } - ELSE - { - param_lpc[nb_indices] = 0; - move16(); - nb_indices = add( nb_indices, 1 ); // Q0 - } - } - - - return; -} -#endif /*-------------------------------------------------------------------* * Unified_weighting() -- GitLab From 3ea265be89cd299f4b9bb1ce2d256ac48878fd38 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:11:00 +0100 Subject: [PATCH 08/26] [cleanup] accept CLEANUP_HQ_CORE --- lib_com/hq2_core_com_fx.c | 166 --- lib_com/ivas_prot_fx.h | 2 - lib_com/options.h | 1 - lib_com/prot_fx.h | 40 - lib_dec/FEC_HQ_core_fx.c | 280 ---- lib_dec/hq_core_dec_fx.c | 124 -- lib_enc/hq_core_enc_fx.c | 4 - lib_enc/hq_lr_enc_fx.c | 2473 ++++------------------------------- lib_enc/prot_fx_enc.h | 30 - lib_enc/swb_bwe_enc_lr_fx.c | 285 ---- lib_enc/tcq_core_enc_fx.c | 486 ------- 11 files changed, 256 insertions(+), 3635 deletions(-) diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index db2397897..1331b31a1 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -208,172 +208,6 @@ void mdct_spectrum_denorm_fx( return; } -#ifndef CLEANUP_HQ_CORE -void mdct_spectrum_denorm_ivas_fx( - const Word32 inp_vector[], /* i : Q0 : */ - Word32 L_y2[], /* i/o : Qs : decoded spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */ - const Word32 L_band_energy[], /* i : Qbe : band energy */ - const Word16 npulses[], /* i : Q0 : number of coded spectrum */ - const Word16 bands, /* i : Q0 : number of subbands */ - const Word16 ld_slope_fx, /* i : Q15 : */ - const Word16 pd_thresh_fx /* i : Q15 : */ -) -{ - Word16 i, k; - Word32 L_Eyy; - Word32 L_tmp, L_temp; - Word16 temp_fx, temp_lo_fx, temp_hi_fx; - Word32 L_inp_tmp[L_FRAME48k]; - Word16 exp_norm; - Word16 exp_safe; - Word16 exp_normn, exp_normd; - - Word16 pd_fx; - Word16 Qpd; - - Word16 div_pd_fx; - Word16 Qdivpd; - Word32 L_div_pd; - - Word16 frac, exp; - - Word16 gain_tweak_fx; - Word16 Qtweak; - - Word16 exp_shift; - - Word16 QEyy; - Word16 pow_fx; - Word16 Qpow; - Word16 Qdiv; - Word16 Qgamma; - Word16 gamma_fx; - - Word16 cond_fx; - - exp_safe = 4; /* safe bit for overflow */ - move16(); - - FOR( k = 0; k < bands; k++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - L_inp_tmp[i] = L_mult( extract_l( inp_vector[i] ), extract_l( inp_vector[i] ) ); - move32(); /* Q0+Q0+1 */ - L_tmp = L_or( L_tmp, L_inp_tmp[i] ); - } - exp_norm = norm_l( L_tmp ); - exp_norm = sub( exp_norm, exp_safe ); - - L_Eyy = L_deposit_l( 0 ); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - /*Eyy += (float) inp_vector[i] * inp_vector[i]; */ - L_Eyy = L_add( L_Eyy, L_shl( L_inp_tmp[i], exp_norm ) ); /* Q1+exp_norm */ - } - QEyy = add( 1, exp_norm ); - - IF( L_Eyy > 0x0L ) - { - /* Set gamma to be pulse gain which results in perfect quantized subband energy */ - /*gamma = (float) sqrt (pow (2.0f, band_energy[k]) / Eyy); */ - - /* Pow part (pow(2.0f, band_energy) ) */ - L_temp = L_shr( L_band_energy[k], sub( SWB_BWE_LR_Qbe, 16 ) ); - temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); - Qpow = sub( 14, temp_hi_fx ); - pow_fx = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qpow */ - - /* Div part ( pow (2.0f, band_energy[i])/Eyy ) */ - exp_normn = norm_s( pow_fx ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_l( L_Eyy ); - temp_fx = div_s( shl( pow_fx, exp_normn ), extract_h( L_shl( L_Eyy, exp_normd ) ) ); /* ((Qpow + exp_norm) - (QEyy + exp_normd)) + 31 */ - Qdiv = add( sub( add( Qpow, exp_normn ), add( QEyy, exp_normd ) ), 31 ); - - exp_norm = norm_s( temp_fx ); - temp_fx = shl( temp_fx, exp_norm ); /* Qdiv + exp_norm */ - Qdiv = add( Qdiv, exp_norm ); - - /* Sqrt part sqrt(pow (2.0f, band_energy[i])/Eyy) */ - Qgamma = add( Qdiv, 16 ); - IF( s_and( Qdiv, 1 ) == 0 ) /* Qdiv % 2 == 0 */ - { - L_temp = Sqrt_l( L_shr( L_deposit_h( temp_fx ), 1 ), &exp_norm ); - L_temp = L_shr( L_temp, exp_norm ); - Qgamma = sub( shr( Qgamma, 1 ), 1 ); - gamma_fx = round_fx( L_temp ); - } - ELSE - { - L_temp = Sqrt_l( L_deposit_h( temp_fx ), &exp_norm ); - L_temp = L_shr( L_temp, exp_norm ); - Qgamma = shr( Qgamma, 1 ); - gamma_fx = round_fx( L_temp ); - } - - /* Adjust gamma based on pulse density (0 bit MSE gain estimator) */ - /*pd = (float) npulses[k] / band_width[k]; */ - exp_normn = norm_s( npulses[k] ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( band_width[k] ); - pd_fx = div_s( shl( npulses[k], exp_normn ), shl( band_width[k], exp_normd ) ); /* 15 + (exp_normn + exp_normd) */ - Qpd = add( sub( exp_normn, exp_normd ), 15 ); - - cond_fx = sub( shl_sat( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); /* Q15 */ - move16(); /* allow overflow happen. */ - IF( cond_fx < 0 ) - { - /*gain_tweak = (float) pow (2.0f, (ld_slope * log2_f (pd / pd_thresh))); */ - /* Div part */ - exp_normn = norm_s( pd_fx ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( pd_thresh_fx ); - div_pd_fx = div_s( shl( pd_fx, exp_normn ), shl( pd_thresh_fx, exp_normd ) ); /* Qpd+exp_normn - (15 + exp_normd) + 15 */ - Qdivpd = add( sub( add( Qpd, exp_normn ), add( 15, exp_normd ) ), 15 ); - - /* Log2 part */ - exp_norm = norm_s( div_pd_fx ); - L_div_pd = L_deposit_h( shl( div_pd_fx, exp_norm ) ); /* Qdivpd + exp_norm + 16 */ - Qdivpd = add( add( Qdivpd, exp_norm ), 16 ); - - frac = Log2_norm_lc( L_div_pd ); - exp = sub( 30, Qdivpd ); - L_tmp = L_Comp( exp, frac ); /* Q16 */ - - /* Mult part */ - L_tmp = Mpy_32_16_1( L_tmp, ld_slope_fx ); - - /* Pow part */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - Qtweak = sub( 14, temp_hi_fx ); - gain_tweak_fx = extract_l( Pow2( 14, temp_lo_fx ) ); - - /*gamma *= gain_tweak; */ - L_tmp = L_mult( gamma_fx, gain_tweak_fx ); /* Qgamma+Qtweak+1 */ - exp_norm = norm_l( L_tmp ); - gamma_fx = round_fx_sat( L_shl( L_tmp, exp_norm ) ); - Qgamma = sub( add( add( Qgamma, Qtweak ), exp_norm ), 15 ); /*Qgamma+Qtweak+1+exp_norm-16; */ - } - - exp_shift = sub( SWB_BWE_LR_Qs - 1, Qgamma ); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - /*y2[i] = gamma * inp_vector[i]; */ - L_tmp = L_mult( gamma_fx, extract_l( inp_vector[i] ) ); /* Qgamma+0+1=Qgamma+1 */ - L_y2[i] = L_shl( L_tmp, exp_shift ); /* SWB_BWE_LR_Qs */ - move32(); - } - } - } - - return; -} -#endif /*==========================================================================*/ /* FUNCTION : void hq2_core_configure_fx() */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 0fb526b41..7ffa702b9 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1596,7 +1596,6 @@ void ivas_hq_core_dec_fx( Word16 *Q_output ); -#ifdef CLEANUP_HQ_CORE void ivas_HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 *t_audio_q_fx, /*Q12*/ @@ -1612,7 +1611,6 @@ void ivas_HQ_FEC_Mem_update_fx( Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ Word16 output_frame ); -#endif /* o : Consumed bits Q0 */ Word16 ivas_hq_classifier_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ diff --git a/lib_com/options.h b/lib_com/options.h index 4a44696c0..02b867f60 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define CLEANUP_HQ_CORE /* VA: basop issue 2300: Remove unused code in core-coder: HQ core */ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 2c9412b24..1637d7baa 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2242,20 +2242,6 @@ void mdct_spectrum_denorm_fx( const Word16 pd_thresh_fx /* i : Q15 : */ ); -#ifndef CLEANUP_HQ_CORE -void mdct_spectrum_denorm_ivas_fx( - const Word32 inp_vector[], /* i : Q0 : */ - Word32 L_y2[], /* i/o : Qs : decoded spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */ - const Word32 L_band_energy[], /* i : Qbe : band energy */ - const Word16 npulses[], /* i : Q0 : number of coded spectrum */ - const Word16 bands, /* i : Q0 : numbers of subbands */ - const Word16 ld_slope_fx, /* i : Q15 : */ - const Word16 pd_thresh_fx /* i : Q15 : */ -); -#endif void hq2_core_configure_fx( const Word16 frame_length, /* Q0 */ const Word16 num_bits, /* Q0 */ @@ -3837,32 +3823,6 @@ void swb_bwe_enc_lr_fx( Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ ); -#ifndef CLEANUP_HQ_CORE -void swb_bwe_enc_lr_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ -); -#endif void isf_enc_amr_wb_fx( Encoder_State *st, /* i/o: state structure */ Word16 *isf_new, /* i/o: quantized ISF vector */ diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 3eeffcdd4..641f60059 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -399,286 +399,6 @@ void HQ_FEC_processing_fx( return; } -#ifndef CLEANUP_HQ_CORE -void ivas_HQ_FEC_Mem_update_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /*Q12*/ - Word32 *normq_fx, /*Q14*/ - Word16 *ynrm, - Word16 *Num_bands_p, - Word16 is_transient, - Word16 hqswb_clas, - Word16 c_switching_flag, - Word16 nb_sfm, - Word16 num_Sb, - Word16 *mean_en_high_fx, /*Q5*/ - Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - Word16 output_frame ) -{ - Word16 Min_ind; - Word32 Min_value; - Word16 Max_ind; - Word16 stat_mode_curr; - - Word16 i, j, k; - Word16 offset; - Word16 exp, exp1, exp2, tmp_fx; - Word32 *norm_values_fx; // Q12 - Word32 L_tmp, tmp_energy_fx = 0 /*Q8*/, Max_coeff_fx /*Q12*/; - Word32 en_high_fx[MAX_SB_NB]; // Q12 - HQ_NBFEC_HANDLE hHQ_nbfec; - HQ_DEC_HANDLE hHQ_core; - hHQ_nbfec = st_fx->hHQ_nbfec; - hHQ_core = st_fx->hHQ_core; - move32(); // for tmp_energy_fx - IF( EQ_16( output_frame, L_FRAME8k ) ) - { - - IF( is_transient ) - { - set16_fx( hHQ_nbfec->prev_sign_switch_2, 0, HQ_FEC_SIGN_SFM ); - set16_fx( hHQ_nbfec->prev_sign_switch, 0, HQ_FEC_SIGN_SFM ); - } - ELSE - { - FOR( j = 0; j < HQ_FEC_SIGN_SFM; j++ ) - { - hHQ_nbfec->prev_sign_switch[j] = hHQ_nbfec->prev_sign_switch_2[j]; - move16(); - hHQ_nbfec->prev_sign_switch_2[j] = 0; - move16(); - - FOR( i = 0; i < HQ_FEC_BAND_SIZE; i++ ) - { - test(); - test(); - test(); - IF( ( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE] > 0 && t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE] < 0 ) || ( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE] < 0 && t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE] > 0 ) ) - { - hHQ_nbfec->prev_sign_switch[j] = add( hHQ_nbfec->prev_sign_switch[j], 1 ); - move16(); - hHQ_nbfec->prev_sign_switch_2[j] = add( hHQ_nbfec->prev_sign_switch_2[j], 1 ); - move16(); - } - } - } - } - /* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */ - test(); - IF( ( EQ_16( hqswb_clas, HQ_HVQ ) ) || ( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) ) - { - /* First group */ - logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) ); - j = ynrm[0]; - move16(); - offset = WID_G1; - move16(); - - FOR( i = 1; i < SFM_G1; i++ ) - { - logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) ); - offset = add( offset, WID_G1 ); - } - - /* Second group */ - FOR( i = SFM_G1; i < SFM_G1 + 2; i++ ) - { - logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) ); - offset = add( offset, WID_G2 ); - } - } - - /* Memory update for the LGF log2 Norm */ - FOR( i = 0; i < nb_sfm; i++ ) - { - normq_fx[i] = dicn_fx[ynrm[i]]; - move32(); - } - k = 0; - move16(); - FOR( i = 0; i < num_Sb; i++ ) - { - norm_values_fx = &hHQ_nbfec->ynrm_values_fx[i][0]; - Copy32( norm_values_fx, &norm_values_fx[1], MAX_PGF - 1 ); - - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < Num_bands_p[i]; j++ ) - { - L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/ - k = add( k, 1 ); - } - tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/ - norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/ - move32(); - tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/ - } - test(); - test(); - IF( ( c_switching_flag ) || ( ( st_fx->last_core == ACELP_CORE ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) ) - { - FOR( i = 0; i < MAX_SB_NB; i++ ) - { - FOR( j = 1; j < MAX_PGF; j++ ) - { - hHQ_nbfec->ynrm_values_fx[i][j] = hHQ_nbfec->ynrm_values_fx[i][0]; - move32(); - } - } - } - set16_fx( hHQ_nbfec->Norm_gain_fx, 32767, SFM_N_NB ); /*15*/ - /* st->energy_MA_Curr[1]=Energy of the current frame */ - tmp_fx = inv_tbl_fx[nb_sfm]; - move16(); /*15*/ - L_tmp = Mult_32_16( tmp_energy_fx, tmp_fx ); /*8 + 15 - 15*/ - - hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl( L_tmp, 16 - 8 ) ); - move16(); - /* Moving Average */ - hHQ_nbfec->energy_MA_Curr_fx[0] = s_max( 1, add( mult_r( 26214, hHQ_nbfec->energy_MA_Curr_fx[0] ), mult_r( 6554, hHQ_nbfec->energy_MA_Curr_fx[1] ) ) ); - move16(); - - /*st->diff_energy = (float)fabs((st->energy_MA_Curr[1] - st->energy_MA_Curr[0])/st->energy_MA_Curr[0]); */ - hHQ_nbfec->diff_energy_fx = abs_s( sub( hHQ_nbfec->energy_MA_Curr_fx[1], hHQ_nbfec->energy_MA_Curr_fx[0] ) ); - move16(); - exp1 = sub( norm_l( hHQ_nbfec->diff_energy_fx ), 1 ); - exp2 = norm_l( hHQ_nbfec->energy_MA_Curr_fx[0] ); - hHQ_nbfec->diff_energy_fx = div_s( extract_h( L_shl( hHQ_nbfec->diff_energy_fx, exp1 ) ), extract_h( L_shl( hHQ_nbfec->energy_MA_Curr_fx[0], exp2 ) ) ); - move16(); - exp = add( 15, sub( exp1, exp2 ) ); - hHQ_nbfec->diff_energy_fx = shl( hHQ_nbfec->diff_energy_fx, sub( 11, exp ) ); /*11*/ - move16(); - - /* Classify the stationary mode : 12% */ - IF( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_12P_fx ) ) - { - stat_mode_curr = 1; - move16(); - } - ELSE - { - stat_mode_curr = 0; - move16(); - } - - /* Apply Hysteresis to prevent frequent mode changing */ - if ( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) ) - { - hHQ_nbfec->stat_mode_out = stat_mode_curr; - move16(); - } - - hHQ_nbfec->stat_mode_old = stat_mode_curr; - move16(); - - /* Find max. band index (Minimum value means maximum energy) */ - Min_ind = 0; - move16(); - Min_value = L_deposit_l( 100 ); - FOR( i = 0; i < num_Sb; i++ ) - { - IF( GT_32( Min_value, ynrm[i] ) ) - { - Min_value = ynrm[i]; - move16(); - Min_ind = i; - move16(); - } - } - - /* Find max. coeff in band 0 */ - Max_ind = 0; - move16(); - IF( Min_ind == 0 ) - { - Max_coeff_fx = L_deposit_l( 0 ); - FOR( i = 0; i < 8; i++ ) - { - L_tmp = L_abs( t_audio_q_fx[i] ); // Q12 - IF( LT_32( Max_coeff_fx, L_tmp ) ) - { - Max_coeff_fx = L_add( L_tmp, 0 ); - Max_ind = i; - move16(); - } - } - } - - /* Find energy difference from band 16 */ - k = 1; - move16(); - - FOR( i = k; i < num_Sb; i++ ) - { - en_high_fx[i] = L_deposit_l( 0 ); - FOR( j = 0; j < 2; j++ ) - { - /*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/ - en_high_fx[i] = L_add( en_high_fx[i], L_shr( hHQ_nbfec->ynrm_values_fx[i][j + 1], 1 ) ); /*Q12*/ - move32(); - } - } - - *mean_en_high_fx = 0; - move16(); - FOR( i = k; i < num_Sb; i++ ) - { - /* *mean_en_high += (float)(en_high[i]/st->ynrm_values[i][0]);*/ - exp1 = sub( norm_l( en_high_fx[i] ), 1 ); - exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); - tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); - exp = add( 15, sub( exp1, exp2 ) ); - *mean_en_high_fx = add_sat( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ) ); - move16(); - } - *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); - move16(); - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi ) && ( !is_transient ) && ( !hHQ_core->old_is_transient[1] ) && ( EQ_16( hHQ_nbfec->prev_last_core, HQ_CORE ) ) && ( EQ_16( st_fx->last_core, HQ_CORE ) ) ) - { - hHQ_nbfec->phase_mat_flag = 1; - move16(); - test(); - if ( ( Min_ind == 0 ) && ( LT_16( Max_ind, 3 ) ) ) - { - hHQ_nbfec->phase_mat_flag = 0; - move16(); - } - } - ELSE - { - hHQ_nbfec->phase_mat_flag = 0; - move16(); - } - - hHQ_nbfec->old_Min_ind = Min_ind; - move16(); - - FOR( i = 0; i < L_FRAME8k; i++ ) - { - hHQ_nbfec->old_coeffs_fx[i] = t_audio_q_fx[i]; - move32(); - } - } - - hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1]; - move16(); - hHQ_core->old_is_transient[1] = hHQ_core->old_is_transient[0]; - move16(); - hHQ_core->old_is_transient[0] = is_transient; - move16(); - - return; -} -#endif void HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 *t_audio_q_fx, /*Q12*/ diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 50dd36f09..e34527da0 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -484,22 +484,13 @@ void ivas_hq_core_dec_fx( Word32 normq_fx[NB_SFM]; Word16 mean_en_high_fx; Word16 SWB_fenv_fx[SWB_FENV + DIM_FB]; -#ifndef CLEANUP_HQ_CORE - const Word16 *sfmsize, *sfm_start, *sfm_end; -#endif Word16 gapsynth_fx[L_FRAME48k]; Word16 tmp, tmp_loop; Word32 L_tmp; UWord16 lsb; Word16 L_spec; -#ifndef CLEANUP_HQ_CORE - HQ_NBFEC_HANDLE hHQ_nbfec; -#endif HQ_DEC_HANDLE hHQ_core; -#ifndef CLEANUP_HQ_CORE - hHQ_nbfec = st_fx->hHQ_nbfec; -#endif hHQ_core = st_fx->hHQ_core; TCX_DEC_HANDLE hTcxDec; @@ -530,9 +521,6 @@ void ivas_hq_core_dec_fx( move16(); Q_G_audio = Q12; move16(); -#ifndef CLEANUP_HQ_CORE - sfm_start = sfm_end = NULL; -#endif num_Sb = nb_sfm = 0; move16(); move16(); @@ -574,18 +562,7 @@ void ivas_hq_core_dec_fx( } ELSE { -#ifdef CLEANUP_HQ_CORE /* this cannot happen in IVAS */ -#else - core_switching_hq_prepare_dec_fx( st_fx, &num_bits, output_frame ); - - /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ - if ( GT_16( num_bits, HQ_48k / 50 ) ) - { - num_bits = (Word16) ( HQ_48k / 50 ); - move16(); - } -#endif } } IF( hq_recovery_flag ) @@ -638,12 +615,6 @@ void ivas_hq_core_dec_fx( } } -#ifndef CLEANUP_HQ_CORE - IF( EQ_16( output_frame, L_FRAME8k ) ) - { - hq_configure_bfi_fx( &nb_sfm, &num_Sb, num_bands_p, &sfmsize, &sfm_start, &sfm_end ); - } -#endif /*-------------------------------------------------------------------------- * transform-domain decoding *--------------------------------------------------------------------------*/ @@ -659,13 +630,6 @@ void ivas_hq_core_dec_fx( &hHQ_core->last_fec, hHQ_core->ph_ecu_HqVoicing, &hHQ_core->ph_ecu_active, gapsynth_fx, st_fx->prev_bfi, hHQ_core->old_is_transient, hHQ_core->mag_chg_1st_fx, hHQ_core->Xavg_fx, &hHQ_core->beta_mute_fx, output_frame, st_fx ); } -#ifndef CLEANUP_HQ_CORE - ELSE - { - HQ_FEC_processing_fx( st_fx, t_audio_q, is_transient, hHQ_nbfec->ynrm_values_fx, hHQ_nbfec->r_p_values_fx, num_Sb, nb_sfm, num_bands_p, - output_frame, sfm_start, sfm_end ); - } -#endif hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1]; /* Q0 */ move16(); @@ -691,21 +655,8 @@ void ivas_hq_core_dec_fx( { IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) { -#ifdef CLEANUP_HQ_CORE /* this cannot happen in IVAS */ -#else - IF( EQ_16( st_fx->prev_bfi, 1 ) ) - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - } - - /* HQ low rate decoder */ - hq_lr_dec_fx( st_fx, t_audio_q, inner_frame, num_bits, &is_transient ); -#endif is_transient = 0; move16(); hqswb_clas = is_transient; /* Q0 */ @@ -754,13 +705,8 @@ void ivas_hq_core_dec_fx( } } -#ifdef CLEANUP_HQ_CORE HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas, core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); -#else - ivas_HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas, - core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame ); -#endif } /*-------------------------------------------------------------------------- @@ -944,45 +890,6 @@ void ivas_hq_core_dec_fx( move16(); } -#ifndef CLEANUP_HQ_CORE - IF( EQ_16( output_frame, L_FRAME8k ) ) - { - test(); - IF( EQ_16( st_fx->bfi, 0 ) && st_fx->prev_bfi == 0 ) - { - Copy_Scale_sig( hHQ_core->old_out_fx + N_ZERO_NB, hHQ_nbfec->prev_oldauOut_fx, output_frame - N_ZERO_NB, negate( hHQ_core->Q_old_wtda ) ); /* 31 - exp_old_out - Q_old_wtda */ - } - ELSE IF( EQ_16( st_fx->prev_bfi, 1 ) ) - { - set16_fx( hHQ_nbfec->prev_oldauOut_fx, 0, output_frame ); - } - - test(); - test(); - test(); - test(); - IF( ( EQ_16( st_fx->prev_bfi, 1 ) || EQ_16( st_fx->bfi, 1 ) ) && EQ_16( hHQ_core->old_is_transient[2], 0 ) && EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->last_codec_mode, MODE1 ) ) - { - time_domain_FEC_HQ_fx( st_fx, wtda_audio, synth, mean_en_high_fx, output_frame, Q_synth ); - } - ELSE - { - window_ola_fx( wtda_audio, synth, Q_synth, hHQ_core->old_out_fx, &hHQ_core->Q_old_wtda, output_frame, - st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx ); - hHQ_nbfec->phase_mat_next = 0; - move16(); - } - - test(); - test(); - IF( ( EQ_16( st_fx->bfi, 0 ) && EQ_16( st_fx->prev_bfi, 0 ) ) || !( GE_16( output_frame, L_FRAME16k ) ) ) - { - preecho_sb_fx( st_fx->core_brate, wtda_audio, Q_audio, synth, *Q_synth, output_frame, &hHQ_core->memfilt_lb_fx, - &hHQ_core->mean_prev_hb_fx, &hHQ_core->smoothmem_fx, &hHQ_core->mean_prev_fx, &hHQ_core->mean_prev_nc_fx, &hHQ_core->wmold_hb_fx, &hHQ_core->prevflag, &hHQ_core->pastpre, st_fx->bwidth ); - } - } - ELSE -#endif { test(); IF( EQ_16( st_fx->bfi, 1 ) && GE_16( output_frame, L_FRAME16k ) ) @@ -1018,29 +925,6 @@ void ivas_hq_core_dec_fx( } } -#ifndef CLEANUP_HQ_CORE - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->hPlcInfo->concealment_method, TCX_NONTONAL ) && LT_32( st_fx->hPlcInfo->nbLostCmpt, 4 ) ) - { - st_fx->hPlcInfo->recovery_gain = shl_sat( st_fx->hPlcInfo->recovery_gain, *Q_synth ); /* Q15 */ - move16(); - IF( st_fx->hTonalMDCTConc->q_lastPcmOut != 0 ) - { - Scale_sig( st_fx->hTonalMDCTConc->secondLastPcmOut, shr( st_fx->hPlcInfo->L_frameTCX, 1 ), negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) ); - Scale_sig( st_fx->hTonalMDCTConc->lastPcmOut, st_fx->hPlcInfo->L_frameTCX, negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) ); - st_fx->hTonalMDCTConc->q_lastPcmOut = 0; - move16(); - } - waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth, 0, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi ); - } -#endif IF( GE_16( output_frame, L_FRAME16k ) ) { IF( EQ_16( hHQ_core->ph_ecu_HqVoicing, 1 ) ) @@ -1067,14 +951,6 @@ void ivas_hq_core_dec_fx( move16(); } -#ifndef CLEANUP_HQ_CORE - IF( EQ_16( output_frame, L_FRAME8k ) ) - { - Copy32( wtda_audio, hHQ_nbfec->oldIMDCTout_fx, L_FRAME8k / 2 ); /* q_wtda */ - Copy( &hHQ_nbfec->old_auOut_2fr_fx[output_frame], hHQ_nbfec->old_auOut_2fr_fx, output_frame ); /* Q_old_auOut */ - Copy_Scale_sig( synth, &hHQ_nbfec->old_auOut_2fr_fx[output_frame], output_frame, negate( *Q_synth ) ); /* Q0 */ - } -#endif /* prepare synthesis output buffer (as recent as possible) for HQ FEC */ { diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index 46f8546fd..6c4aa6bf4 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -505,11 +505,7 @@ void hq_core_enc_ivas_fx( move16(); IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) { -#ifdef CLEANUP_HQ_CORE /* this cannot happen in IVAS */ -#else - hq_lr_enc_ivas_fx( st, t_audio_fx, inner_frame, &num_bits, is_transient ); -#endif } ELSE { diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 8111d21c3..b2b7ac9cb 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -22,33 +22,6 @@ static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_a static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L_ybuf[] /*Q12*/, Word32 L_y2[] /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 k_sort[], const Word16 bands, const Word32 L_qint /*Q29*/, const Word16 Ngq, const Word16 gqlevs, const Word16 gqbits ); -#ifndef CLEANUP_HQ_CORE -static Word16 p2a_threshold_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 band_width[], const Word16 bands, const Word16 p2a_bands, const Word16 p2a_th /*Q11*/, Word16 *p2a_flags ); -static void mdct_spectrum_fine_gain_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_ybuf[], /* i : Q12 : input spectrum */ - Word32 L_y2[], /* i/o: Q12 : decoded spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 k_sort[], /* i : Q0 : sort table by band_energy */ - const Word16 bands, /* i : Q0 : nubmber of subbands */ - const Word32 L_qint, /* i : Q29 : */ - const Word16 Ngq, /* i : Q0 : */ - const Word16 gqlevs, /* i : Q0 : quantized level */ - const Word16 gqbits /* i : Q0 : quantized bits */ -); - -static Word16 band_energy_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word32 *L_t_audio, /* Q12 */ - const Word16 band_start[], /* Q0 */ - const Word16 band_end[], /* Q0 */ - Word32 L_band_energy[], /* Q14 */ - const Word16 bands_fx, /* Q0 */ - const Word32 L_qint, /* Q29 */ - const Word16 eref_fx, /* Q10 */ - const Word16 is_transient /* Q0 */ ); -#endif /*--------------------------------------------------------------------------* @@ -128,78 +101,6 @@ static void spt_shorten_domain_set_fx( return; } -#ifndef CLEANUP_HQ_CORE -static void spt_shorten_domain_set_ivas_fx( - Encoder_State *st_fx, /* i: encoder state structure */ - const Word32 L_t_audio[], /* i: input spectrum Q12*/ - const Word16 p2a_flags[], /* i: p2a anlysis information Q0*/ - const Word16 new_band_start[], /* i: new band start position Q0*/ - const Word16 new_band_end[], /* i: new band end position Q0*/ - const Word16 new_band_width[], /* i: new subband band width Q0*/ - const Word16 bands, /* i: total number of subbands Q0*/ - Word16 band_start[], /* i/o: band start position Q0*/ - Word16 band_end[], /* i/o: band end position Q0*/ - Word16 band_width[], /* i: sub band band width Q0*/ - Word16 *bit_budget /* i/o: bit budget Q0*/ -) -{ - Word16 i, j, k; - Word16 kpos; - Word32 L_max_y2; - Word16 max_y2_pos; - Word16 spt_shorten_flag[SPT_SHORTEN_SBNUM]; - HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; - - kpos = 0; - j = 0; - move16(); - move16(); - FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ ) - { - IF( EQ_16( p2a_flags[k], 1 ) ) - { - spt_shorten_flag[j] = 0; - move16(); - IF( hHQ_core->prev_SWB_peak_pos[kpos] != 0 ) - { - L_max_y2 = L_deposit_l( 0 ); - max_y2_pos = 0; - move16(); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - IF( LT_32( L_max_y2, L_abs( L_t_audio[i] ) ) ) - { - L_max_y2 = L_abs( L_t_audio[i] ); /* Q12 */ - move32(); - max_y2_pos = i; - move16(); - } - } - test(); - IF( GE_16( max_y2_pos, new_band_start[j] ) && LE_16( max_y2_pos, new_band_end[j] ) ) - { - band_start[k] = new_band_start[j]; /* Q0 */ - move16(); - band_end[k] = new_band_end[j]; /* Q0 */ - move16(); - band_width[k] = new_band_width[j]; /* Q0 */ - move16(); - spt_shorten_flag[j] = 1; - move16(); - } - } - push_indice( st_fx->hBstr, IND_HQ2_SPT_SHORTEN, spt_shorten_flag[j], 1 ); - *bit_budget = sub( *bit_budget, 1 ); /* Q0 */ - move16(); - } - - kpos += 1; - j += 1; - } - - return; -} -#endif /*--------------------------------------------------------------------------* * hq_lr_enc_fx() @@ -1100,1400 +1001,107 @@ void hq_lr_enc_fx( return; } -#ifndef CLEANUP_HQ_CORE -void hq_lr_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 L_t_audio[], /* i/o: transform-domain coefs. Q12*/ - const Word16 inner_frame, /* i : inner frame length Q0*/ - Word16 *num_bits, /* i/o: number of available bits Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ -) -{ - Word16 i; - Word16 bit_budget, pbits; - Word16 bands, length, ni_seed, gqlevs, gqbits, Ngq, p2a_bands; - Word16 p2a_flags[BANDS_MAX]; - Word16 band_start[BANDS_MAX], band_end[BANDS_MAX], band_width[BANDS_MAX]; - Word32 L_band_energy[BANDS_MAX]; - Word16 ebits_fx; - - Word32 Rk_fx[BANDS_MAX]; - Word16 k1_step_fx, k2_step_fx; - Word16 k1_fx, k2_fx; - - Word32 L_qint; /* Q29 */ - Word16 eref_fx; /* Q10 */ - Word16 bit_alloc_weight_fx; /* Q13 */ - Word16 k_sort[BANDS_MAX]; - Word16 npulses[BANDS_MAX]; - Word32 inp_vector[L_FRAME48k]; - - Word16 ld_slope_fx /*, Qldslope=15*/; - Word16 p2a_th_fx /*, Qp2ath=11*/; - Word16 pd_thresh_fx /*, Qpdth=15*/; - Word16 ni_coef_fx /*, Qnicoef=14*/; - - Word32 L_y2[L_FRAME48k]; - Word32 L_y2_ni[L_FRAME48k]; - - Word16 hqswb_clas; - Word16 lowlength; - Word16 highlength; - Word16 exp_norm; - Word32 L_m[L_FRAME32k]; - - Word16 har_bands; - - Word16 lowband, highband, bw_low = 0, bw_high = 20; - move16(); - move16(); - - Word32 bwe_br; - Word16 trans_bit, p2a_flags_tmp[BANDS_MAX]; - Word16 adjustFlag = 0; - move16(); - Word16 prev_SWB_peak_pos_tmp[SPT_SHORTEN_SBNUM]; - Word16 k, j; - Word16 flag_spt; - Word16 org_band_start[SPT_SHORTEN_SBNUM]; - Word16 org_band_end[SPT_SHORTEN_SBNUM]; - Word16 org_band_width[SPT_SHORTEN_SBNUM]; - Word16 new_band_start[SPT_SHORTEN_SBNUM]; - Word16 new_band_end[SPT_SHORTEN_SBNUM]; - Word16 new_band_width[SPT_SHORTEN_SBNUM]; - Word16 bws_cnt = 0; - move16(); - Word32 L_tmp, L_tmp2, L_tmp3; - Word16 exp, tmp, exp2, tmp1, tmp2, tmp3, alpha_fx, frac1; - Word32 enerH_fx; - Word32 enerL_fx; - Word32 Ep_fx[BANDS_MAX]; - Word32 Ep_avrg_fx, Ep_vari_fx; - Word32 Ep_avrgL_fx; - Word32 Ep_peak_fx; - Word32 Ep_tmp_fx[BANDS_MAX]; - Word16 gama_fx; /*Q15 0.85f; */ - Word16 beta_fx; /*Q14 1.05f; */ - Word32 L_band_energy_tmp[BANDS_MAX]; - UWord16 lo; - Word16 Q_band_energy; - BSTR_ENC_HANDLE hBstr = st->hBstr; - HQ_ENC_HANDLE hHQ_core = st->hHQ_core; - set32_fx( L_y2, 0x0L, L_FRAME48k ); - set32_fx( inp_vector, 0, inner_frame ); - flag_spt = 0; - move16(); - set16_fx( prev_SWB_peak_pos_tmp, 0, SPT_SHORTEN_SBNUM ); - adjustFlag = 0; - move16(); - bw_low = 0; - move16(); - bw_high = 20; - move16(); - enerL_fx = L_deposit_l( 0 ); - enerH_fx = L_deposit_l( 0 ); +/*--------------------------------------------------------------------------* + * small_symbol_enc_tran() + * + * Huffman encoding of differential energies, estimating or packing bits + * if flag_pack = 0, LC mode info. is output else LC mode info. is input + * if flag_pack = 0, estimatng else packing bits + *--------------------------------------------------------------------------*/ +static Word16 small_symbol_enc_tran_fx( /* o : bits */ + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ + const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ + const Word16 BANDS, /* i : number of bands Q0*/ + Word16 *hLCmode, /* i/o: LC mode info Q0*/ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ + const Word16 is_transient /* Q0 */ ) +{ + Word16 i, bits; + Word16 difidx[BANDS_MAX]; - bwe_br = st->core_brate; - hqswb_clas = HQ_NORMAL; - move16(); + FOR( i = 0; i < BANDS; i++ ) + { + difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */ + move16(); + } - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) + FOR( i = 0; i < BANDS; ++i ) { - IF( EQ_16( is_transient, 1 ) ) - { - hqswb_clas = HQ_TRANSIENT; /* Q0 */ - move16(); - } - ELSE + test(); + IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 ) { - hqswb_clas = peak_avrg_ratio_fx( st->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs ); /* Q0 */ + /* Huffman cannot encode this vector */ + return -1; } + } - /* write the classification information into the bitstream */ - push_indice( hBstr, IND_HQ2_SWB_CLAS, hqswb_clas, 2 ); - ( *num_bits ) = sub( *num_bits, 2 ); - move16(); - IF( EQ_16( hqswb_clas, HQ_NORMAL ) ) - { - flag_spt = 1; - move16(); - } + /* Preparing lossless coding input */ + IF( flag_pack == 0 ) + { + /* estimating # of bits */ + bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */ + bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ } ELSE { - /* write the transient bit into the bitstream */ - push_indice( st->hBstr, IND_HQ2_SWB_CLAS, is_transient, 1 ); - - /* subtract one bit for the transient flag */ - ( *num_bits ) = sub( *num_bits, 1 ); + bits = 0; move16(); + encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); } - /* Configure encoder for different bandwidths, bitrates, etc. */ + return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ +} - hq2_core_configure_fx( inner_frame, *num_bits, is_transient, &bands, &length, band_width, band_start, band_end, - &L_qint, &eref_fx, &bit_alloc_weight_fx, &gqlevs, &Ngq, &p2a_bands, &p2a_th_fx, &pd_thresh_fx, &ld_slope_fx, &ni_coef_fx, bwe_br ); +/*--------------------------------------------------------------------------* + * small_symbol_enc() + * + * Huffman encoding of differential energies, estimating or packing bits + * if flag_pack = 0, LC mode info. is output else LC mode info. is input + * if flag_pack = 0, estimatng else packing bits + *--------------------------------------------------------------------------*/ + +/* o : bits */ +static Word16 small_symbol_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ + const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ + const Word16 BANDS, /* i : number of bands Q0*/ + Word16 *hLCmode, /* i/o: LC mode info Q0*/ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ + const Word16 is_transient /* Q0 */ ) +{ + Word16 i, bits; + Word16 difidx[BANDS_MAX], LSB[BANDS_MAX]; - highlength = band_end[( bands - 1 )]; /* Q0 */ - move16(); - har_bands = bands; /* Q0 */ + /* Preparing lossless coding input */ + difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */ move16(); - - test(); - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && is_transient == 0 && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) + FOR( i = 1; i < BANDS; ++i ) { - /* reserve bits for HQ_NORMAL2 and HQ_HARMONIC modes */ - test(); - IF( EQ_16( hqswb_clas, HQ_NORMAL ) || EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - ( *num_bits ) = sub( *num_bits, get_usebit_npswb_fx( hqswb_clas ) ); - move16(); - } + difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */ + move16(); } - test(); - test(); - IF( ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) && EQ_16( st->bwidth, SWB ) ) + FOR( i = 0; i < BANDS; ++i ) { - IF( NE_16( hHQ_core->prev_hqswb_clas, HQ_NORMAL ) ) + test(); + IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 ) { - j = 0; - move16(); - FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ ) - { - hHQ_core->prev_SWB_peak_pos[j] = 0; - move16(); - j += 1; - } + /* Huffman cannot encode this vector */ + return -1; } } - test(); - IF( GT_16( inner_frame, length ) && is_transient ) + /* splitting MSB and LSB */ + FOR( i = 0; i < BANDS; ++i ) { - /* If so, collapse transient frame (4 short transforms) to remove uncoded coefficients */ - - k1_step_fx = shr( length, 2 ); /* k1 = length/NUM_TIME_SWITCHING_BLOCKS Q0*/ - k2_step_fx = shr( inner_frame, 2 ); /* k2 = inner_frame/NUM_TIME_SWITCHING_BLOCKS Q0*/ - k1_fx = k1_step_fx; /* Q0 */ - k2_fx = k2_step_fx; /* Q0 */ + LSB[i] = s_and( difidx[i], 1 ); /* Q0 */ move16(); + difidx[i] = shr( difidx[i], 1 ); /* Q0 */ move16(); - FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) - { - /*k1 = i*length/NUM_TIME_SWITCHING_BLOCKS; */ - /*k2 = i*inner_frame/NUM_TIME_SWITCHING_BLOCKS; */ - - Copy32( &L_t_audio[k2_fx], &L_t_audio[k1_fx], k1_step_fx ); /* Q12 */ - - k1_fx = add( k1_fx, k1_step_fx ); - k2_fx = add( k2_fx, k2_step_fx ); - } - } - - /* Spectral energy calculation/quantization */ - - ebits_fx = band_energy_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, L_band_energy, bands, - L_qint, eref_fx, is_transient ); /* Q0 */ - - /* First pass bit budget for TCQ of spectral band information */ - exp_norm = norm_s( gqlevs ); /* gqbits_fx = (short int) log2_f ((float) gqlevs_fx); */ - gqbits = sub( 14, exp_norm ); - - bit_budget = sub( sub( *num_bits, ebits_fx ), round_fx( L_shl( L_mult( Ngq, gqbits ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; Q0*/ - - - pbits = 0; - move16(); - - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) - { - IF( EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - set16_fx( p2a_flags, 1, har_bands ); - } - ELSE - { - /* High band tonality detector based on per band peak-to-average ratio */ - pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags ); /* Q0 */ - bit_budget = sub( bit_budget, pbits ); - - IF( EQ_16( hqswb_clas, HQ_NORMAL ) ) - { - return_bits_normal2_fx( &bit_budget, p2a_flags, bands, bits_lagIndices_modeNormal ); - } - } - } - ELSE - { - /* High band tonality detector based on per band peak-to-average ratio */ - pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags ); /* Q0 */ - bit_budget = sub( bit_budget, pbits ); - } - - IF( EQ_16( flag_spt, 1 ) ) - { - /* initialize the desired parameters for SPT */ - spt_shorten_domain_band_save_fx( bands, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width ); - spt_shorten_domain_pre_fx( band_start, band_end, hHQ_core->prev_SWB_peak_pos, bands, bwe_br, new_band_start, new_band_end, new_band_width ); - spt_shorten_domain_set_ivas_fx( st, L_t_audio, p2a_flags, new_band_start, new_band_end, new_band_width, bands, band_start, band_end, band_width, &bit_budget ); - } - -#define WMC_TOOL_SKIP - /* Estimate number of bits per band */ - Q_band_energy = SWB_BWE_LR_Qbe; - move16(); - FOR( i = 0; i < bands; i++ ) - { - L_tmp = L_shl( L_band_energy[i], sub( 16, Q_band_energy ) ); /*Q16 */ - - frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ - L_tmp = Pow2( 30, frac1 ); - exp = sub( exp, 30 ); - Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ - move32(); - } - - FOR( i = 0; i < bands; i++ ) - { - L_tmp2 = Ep_fx[i]; /* Q -6 */ - L_tmp = L_max( 1, L_tmp2 ); - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); /* Q -6 + exp - 16 */ - - L_tmp3 = L_deposit_l( band_width[i] ); /* Q0 */ - exp2 = norm_l( L_tmp3 ); - tmp2 = extract_h( L_shl( L_tmp3, exp2 ) ); /* exp2 - 16 */ - - exp2 = sub( exp, exp2 ); /* Denormalize and substract */ - - tmp3 = sub( tmp2, tmp ); - IF( tmp3 > 0 ) - { - tmp2 = shr( tmp2, 1 ); - } - IF( tmp3 > 0 ) - { - exp2 = add( exp2, 1 ); - } - tmp = div_s( tmp2, tmp ); /* Q15 */ - L_tmp = L_deposit_h( tmp ); /* Q31 */ - L_tmp = Isqrt_lc1( L_tmp, &exp2 ); /*Q(31-exp2) */ - move32(); - Ep_tmp_fx[i] = L_shr( L_tmp, sub( 15, exp2 ) ); /*Q16 */ - move32(); - } -#undef WMC_TOOL_SKIP - - test(); - test(); - test(); - test(); - test(); - test(); - IF( is_transient == 0 && EQ_16( inner_frame, L_FRAME8k ) && LE_32( st->core_brate, ACELP_13k20 ) ) - { -#define WMC_TOOL_SKIP - lowband = 6; - move16(); - trans_bit = 2; - move16(); - bit_budget = sub( bit_budget, trans_bit ); - gama_fx = 27852; /*Q15 0.85f */ - beta_fx = 17203; /*Q14 1.05f */ - move16(); - move16(); - set_s( &p2a_flags_tmp[bands - trans_bit], 0, 2 ); - - IF( EQ_32( st->core_brate, ACELP_13k20 ) ) - { - beta_fx = 13107; /* Q14 1.25f */ - move16(); - gama_fx = 31130; /* 0.95f Q15 */ - move16(); - mvs2s( &p2a_flags[( bands - trans_bit )], &p2a_flags_tmp[( bands - trans_bit )], trans_bit ); - } - - /* calculate the the low band/high band energy and the variance/avrage of the envelopes */ - Ep_vari_fx = 0; - move32(); - Ep_avrg_fx = 0; - move32(); - Ep_avrgL_fx = 0; - move32(); - Ep_peak_fx = 0; - move32(); - FOR( i = 0; i < bands; i++ ) - { - IF( sub( i, lowband ) >= 0 ) - { - Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[( i - 1 )] ) ) ); /*Q15 */ - Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ - } - ELSE - { - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ - IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) - { - Ep_peak_fx = Ep_tmp_fx[i]; /*Q15 */ - move32(); - } - } - } - /* modify the last p2a_bands subbands band_energies */ - k = bands; - move16(); - mvl2l( L_band_energy, L_band_energy_tmp, k ); /*Q_band_energy */ - Mpy_32_16_ss( Ep_peak_fx, 24576, &L_tmp, &lo ); - Mpy_32_16_ss( Ep_peak_fx, shl( sub( bands, lowband ), 9 ), &L_tmp2, &lo ); - Mpy_32_16_ss( Ep_avrg_fx, 1126, &L_tmp3, &lo ); - - test(); - test(); - test(); - IF( ( ( L_sub( L_tmp, L_shr( Ep_avrgL_fx, 1 ) ) < 0 && EQ_32( st->core_brate, ACELP_13k20 ) ) || LT_32( st->core_brate, ACELP_13k20 ) ) && - L_sub( L_tmp2, L_tmp3 ) < 0 && L_sub( L_tmp2, L_shr( Ep_avrg_fx, 7 ) ) > 0 ) - { - FOR( i = lowband; i < bands; i++ ) - { - Mpy_32_16_ss( Ep_avrg_fx, 24576, &L_tmp, &lo ); - IF( L_sub( L_shr( Ep_tmp_fx[i], 1 ), L_tmp ) < 0 ) - { - Mpy_32_16_ss( Ep_peak_fx, sub( bands, lowband ), &L_tmp, &lo ); - tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-4 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - /*when the divisor is zero, happens rarely*/ - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +4 = 15) */ - L_tmp2 = L_add( L_tmp, 13107 ); /*15 */ - tmp2 = extract_l( L_min( L_max( L_tmp2, 16384 ), gama_fx ) ); /*15 = 15 */ - Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_band_energy_tmp[i], &lo ); - } - } - } - ELSE - { - j = 0; - move16(); - FOR( i = ( bands - trans_bit ); i < bands; i++ ) - { - alpha_fx = 16384; /*Q14 */ - move16(); - IF( sub( p2a_flags_tmp[i], 1 ) == 0 ) - { - Mpy_32_16_ss( Ep_tmp_fx[i], sub( bands, lowband ), &L_tmp, &lo ); - tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-4 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - /*when the divisor is zero, happens rarely*/ - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_vari_fx, 3277, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ - - tmp2 = extract_h( Ep_avrg_fx ); /*Q13-16=-3 */ - IF( tmp2 != 0 ) - { - exp = norm_s( tmp2 ); - tmp2 = shl( tmp2, exp ); /*Q(exp) */ - tmp2 = div_s( 16384, tmp2 ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp2 = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_vari_fx, 6554, &L_tmp2, &lo ); - Mpy_32_16_ss( L_tmp2, tmp2, &L_tmp2, &lo ); - L_tmp2 = L_shl( L_tmp2, sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ - L_tmp = L_min( L_tmp, L_tmp2 ); /*14 */ - tmp = extract_l( L_min( L_tmp, 13107 ) ); /*14 */ - alpha_fx = add( 16384, tmp ); /* Q14 */ - } - IF( sub( hHQ_core->last_bitalloc_max_band[j++], 1 ) == 0 ) - { - Mpy_32_16_ss( Ep_tmp_fx[i], sub( bands, lowband ), &L_tmp, &lo ); - tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-2 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); - L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ - L_tmp = L_max( L_tmp, 16384 ); /*14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ - } - ELSE - { - tmp2 = extract_h( Ep_avrg_fx ); /*13 -16 =-3 */ - IF( tmp2 != 0 ) - { - exp = norm_s( tmp2 ); - tmp2 = shl( tmp2, exp ); /*Q(exp) */ - tmp2 = div_s( 16384, tmp2 ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - /*when the divisor is zero, happens rarely*/ - tmp2 = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_tmp_fx[i], tmp2, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ - Mpy_32_16_ss( L_tmp, shl( sub( bands, lowband ), 9 ), &L_tmp, &lo ); - L_tmp = L_max( L_tmp, 13926 ); /*14 */ - tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =14 */ - } - Mpy_32_16_ss( L_band_energy_tmp[i], alpha_fx, &L_tmp, &lo ); - L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q(Q_band_energy+14-15 +1= Q_band_energy) */ - move32(); - } - } - lowband = 3; - move16(); - Ep_avrg_fx = 0; - move32(); - Ep_avrgL_fx = 0; - move32(); - Ep_peak_fx = 0; - move32(); - FOR( i = 0; i < bands; i++ ) - { - IF( sub( i, lowband ) >= 0 ) - { - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ - } - ELSE - { - Ep_avrgL_fx = L_add( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */ - IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) - { - Ep_peak_fx = Ep_tmp_fx[i]; /*Q13 */ - move32(); - } - } - } - Mpy_32_16_ss( Ep_peak_fx, 28262, &L_tmp, &lo ); - Mpy_32_16_ss( Ep_avrgL_fx, 24576, &L_tmp2, &lo ); - - test(); - test(); - IF( L_sub( L_shr( Ep_avrg_fx, 2 ), L_tmp2 ) > 0 && L_sub( L_shr( Ep_avrg_fx, 4 ), L_tmp2 ) < 0 && L_sub( L_tmp, Ep_avrgL_fx ) > 0 ) - { - adjustFlag = 1; - move16(); - FOR( i = 0; i < lowband; i++ ) - { - tmp = extract_h( Ep_avrgL_fx ); /*Q-4 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - /*when the divisor is zero, happens rarely*/ - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo ); - L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ - tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ - Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_tmp, &lo ); - L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ - move32(); - } - } -#undef WMC_TOOL_SKIP - - - hq2_bit_alloc_fx( L_band_energy_tmp, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient ); - - /* encode the last p2a_bands-1 subbands bit-allocation index of the previous frame */ - FOR( i = 0; i < 2; i++ ) - { - push_indice( hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 ); - } - } - ELSE IF( is_transient == 0 && EQ_16( inner_frame, L_FRAME16k ) ) - { -#define WMC_TOOL_SKIP - bit_budget = sub( bit_budget, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not */ - FOR( i = 0; i < bands; i++ ) - { - Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ - move32(); - } - IF( EQ_32( st->core_brate, ACELP_13k20 ) ) - { - lowband = 8; - move16(); - highband = 15; - move16(); - bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */ - bw_high = sub( add( band_end[( bands - 1 )], 1 ), band_start[highband] ); /* Q0 */ - } - ELSE - { - lowband = 8; - move16(); - highband = 16; - move16(); - bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */ - bw_high = sub( add( band_end[( bands - 1 )], 1 ), band_start[highband] ); /* Q0 */ - } - /* calculate the the low band/high band energy and the variance/avrage of the envelopes */ - enerL_fx = 0; - move32(); - enerH_fx = 0; - move32(); - Ep_vari_fx = 0; - move32(); - Ep_avrg_fx = 0; - move32(); - FOR( i = 0; i < bands; i++ ) - { - test(); - IF( sub( i, lowband ) >= 0 && add( sub( i, bands ), p2a_bands ) < 0 ) - { - Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ - } - - IF( sub( i, highband ) >= 0 ) - { - enerH_fx = L_add( enerH_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ - } - ELSE IF( sub( i, lowband ) >= 0 ) - { - enerL_fx = L_add( enerL_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */ - } - } - /* modify the last p2a_bands subbands band_energies */ - k = bands; - move16(); - mvl2l( L_band_energy, L_band_energy_tmp, k ); /*Q_band_energy */ - - L_tmp = L_max( enerH_fx, enerL_fx ); - tmp = s_max( bw_low, bw_high ); - i = norm_l( L_tmp ); - j = norm_s( tmp ); - Mpy_32_16_ss( L_shl( enerH_fx, i ), shl( bw_low, j ), &L_tmp, &lo ); - Mpy_32_16_ss( L_shl( enerL_fx, i ), shl( bw_high, j ), &L_tmp2, &lo ); - L_tmp2 = L_sub( L_tmp, L_tmp2 ); - - FOR( i = ( bands - p2a_bands ); i < bands; i++ ) - { - test(); - IF( sub( p2a_flags[i], 1 ) == 0 || L_tmp2 > 0 ) - { - tmp = sub( bands, p2a_bands ); - tmp = sub( tmp, lowband ); /*Q0 */ - - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ - IF( tmp1 != 0 ) - { - exp = norm_s( tmp1 ); - tmp1 = shl( tmp1, exp ); /*Q(exp) */ - tmp1 = div_s( 16384, tmp1 ); /*Q(15+14-exp = 29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp1 = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_tmp_fx[i], tmp1, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, 16384, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 32, exp ) ); /*Q15 */ - tmp = extract_l( L_min( L_tmp, 6554 ) ); /*Q15 */ - Mpy_32_16_ss( Ep_vari_fx, tmp1, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 15, exp ) ); /*Q15 */ - tmp = extract_l( L_shr( L_min( L_tmp, 13107 ), 1 ) ); /*Q14 */ - alpha_fx = add( tmp, 16384 ); /*Q14 */ - } - ELSE - { - alpha_fx = 16384; /* Q14 */ - move16(); - } - - IF( add( sub( i, bands ), p2a_bands ) > 0 ) - { - tmp = sub( bands, p2a_bands ); - IF( sub( hHQ_core->last_bitalloc_max_band[( i - ( tmp + 1 ) )], 1 ) == 0 ) - { - tmp = sub( tmp, lowband ); - Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo ); - tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q14 */ - tmp = extract_l( L_min( L_max( L_tmp, 16384 ), 20480 ) ); /*Q14 */ - L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ - alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14*/ - } - ELSE - { - tmp = sub( tmp, lowband ); - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ - IF( tmp1 != 0 ) - { - exp = norm_s( tmp1 ); - tmp1 = shl( tmp1, exp ); /*Q(exp) */ - tmp1 = div_s( 16384, tmp1 ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp1 = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_tmp_fx[i], tmp1, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 29, exp ) ); /*Q14 */ - tmp = extract_l( L_min( L_max( L_tmp, 13926 ), 16384 ) ); /*Q14 */ - L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ - alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ - } - } - Mpy_32_16_ss( L_band_energy_tmp[i], alpha_fx, &L_tmp, &lo ); - L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q Q_band_energy */ - move32(); - } - lowband = 6; - move16(); - Ep_avrg_fx = 0; - move32(); - Ep_avrgL_fx = 0; - move32(); - Ep_peak_fx = 0; - move32(); - FOR( i = 0; i < bands; i++ ) - { - IF( sub( i, lowband ) >= 0 ) - { - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ - } - ELSE - { - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ - IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) - { - Ep_peak_fx = Ep_tmp_fx[i]; /* Q15 */ - move32(); - } - } - } - - Mpy_32_16_ss( Ep_peak_fx, 24576, &L_tmp, &lo ); - Mpy_32_16_ss( Ep_peak_fx, 19661, &L_tmp2, &lo ); - Mpy_32_16_ss( Ep_avrgL_fx, 24576, &L_tmp3, &lo ); - - test(); - test(); - test(); - test(); - test(); - IF( ( L_sub( L_shr( Ep_avrgL_fx, 1 ), Ep_avrg_fx ) > 0 && L_sub( L_tmp, L_shr( Ep_avrgL_fx, 2 ) ) > 0 && L_sub( L_shr( Ep_avrgL_fx, 1 ), L_tmp2 ) < 0 ) || - ( L_sub( L_shr( Ep_avrg_fx, 1 ), Ep_avrgL_fx ) > 0 && L_sub( L_shr( Ep_avrg_fx, 3 ), L_tmp3 ) < 0 && L_sub( L_tmp, L_shr( Ep_avrgL_fx, 2 ) ) > 0 ) ) - { - adjustFlag = 1; - move16(); - FOR( i = 0; i < lowband; i++ ) - { - tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ - IF( tmp != 0 ) - { - exp = norm_s( tmp ); - tmp = shl( tmp, exp ); /*Q(exp) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */ - exp = sub( 29, exp ); - } - ELSE - { - tmp = 0x7fff; - move16(); - exp = 0; - move16(); - } - Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo ); - Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); - L_tmp = L_shl( L_tmp, sub( 28, exp ) ); /*Q14 0.5 */ - tmp = extract_l( L_min( L_tmp, 19661 ) ); /*Q14 */ - Mpy_32_16_ss( L_band_energy_tmp[i], tmp, &L_tmp, &lo ); - L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ - move32(); - } - } -#undef WMC_TOOL_SKIP - - hq2_bit_alloc_fx( L_band_energy_tmp, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient ); - - /* encode the last p2a_bands-1 subbands bit-allocation index of the previous frame */ - FOR( i = 0; i < 2; i++ ) - { - push_indice( hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 ); - } - } - ELSE IF( EQ_16( st->bwidth, SWB ) && EQ_16( hqswb_clas, HQ_HARMONIC ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) - { - /* bit allocation for harmonic mode */ - hq2_bit_alloc_har_fx( L_band_energy, bit_budget, bands, Rk_fx, p2a_bands, bwe_br, p2a_flags, band_width ); - } - ELSE - { - - /* estimate number of bits per band */ - hq2_bit_alloc_fx( L_band_energy, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient ); - } - - tcq_core_LR_enc_ivas_fx( hBstr, inp_vector, L_t_audio, L_y2, bit_budget, bands, band_start, band_end, band_width, Rk_fx, npulses, k_sort, p2a_flags, p2a_bands, hHQ_core->last_bitalloc_max_band, inner_frame, adjustFlag, is_transient ); - - test(); - test(); - IF( ( EQ_16( inner_frame, L_FRAME8k ) && LE_32( st->core_brate, ACELP_13k20 ) ) || EQ_16( inner_frame, L_FRAME16k ) ) - { - j = 0; - FOR( i = 2; i > 0; i-- ) - { - IF( npulses[bands - i] > 0 ) - { - hHQ_core->last_bitalloc_max_band[j] = 1; - move16(); - } - ELSE - { - hHQ_core->last_bitalloc_max_band[j] = 0; - move16(); - } - j++; - } - } - - /* Denormalize the coded MDCT spectrum */ - mdct_spectrum_denorm_ivas_fx( inp_vector, L_y2, band_start, band_end, band_width, L_band_energy, npulses, bands, ld_slope_fx, pd_thresh_fx ); - - /* Apply fine gain quantization to denormalized coded spectrum */ - mdct_spectrum_fine_gain_enc_ivas_fx( st, L_t_audio, L_y2, band_start, band_end, k_sort, bands, L_qint, Ngq, gqlevs, gqbits ); - - /* reStore the subband information*/ - IF( EQ_16( flag_spt, 1 ) ) - { - spt_shorten_domain_band_restore_fx( bands, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width ); - } - - /* Inject noise into components having relatively low pulse energy per band */ - ni_seed = add( add( add( npulses[0], npulses[1] ), npulses[2] ), npulses[3] ); /* Q0 */ - - Copy32( L_y2, L_y2_ni, band_end[bands - 1] + 1 ); /* Q12 */ - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) ) - { - test(); - IF( EQ_16( hqswb_clas, HQ_NORMAL ) || EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - preset_hq2_swb_fx( hqswb_clas, band_end, &har_bands, p2a_bands, length, bands, &lowlength, &highlength, L_m ); - - swb_bwe_enc_lr_ivas_fx( st, L_y2, SWB_BWE_LR_Qs, L_t_audio, L_m, bwe_br, - bands, band_start, band_end, L_band_energy, SWB_BWE_LR_Qbe, p2a_flags, hqswb_clas, lowlength, highlength, - hHQ_core->prev_frm_index, har_bands, &hHQ_core->prev_frm_hfe2, &hHQ_core->prev_stab_hfe2, band_width, L_y2_ni, &ni_seed ); - - post_hq2_swb_fx( L_m, lowlength, highlength, hqswb_clas, har_bands, bands, p2a_flags, band_start, band_end, L_y2, npulses ); - - IF( EQ_16( hqswb_clas, HQ_NORMAL ) ) - { - spt_swb_peakpos_tmp_save_fx( L_y2, bands, band_start, band_end, prev_SWB_peak_pos_tmp ); - FOR( k = 0; k < SPT_SHORTEN_SBNUM; k++ ) - { - test(); - IF( p2a_flags[bands - SPT_SHORTEN_SBNUM + k] == 0 || npulses[bands - SPT_SHORTEN_SBNUM + k] == 0 ) - { - prev_SWB_peak_pos_tmp[k] = 0; - move16(); - } - } - } - Copy32( L_y2_ni, L_y2, lowlength ); /* Q12 */ - } - ELSE - { - Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* HQ_TRANSIENT Q12*/ - } - } - ELSE - { - Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* NB, WB Q12*/ - } - - updat_prev_frm_fx( L_y2, L_t_audio, bwe_br, length, inner_frame, bands, st->bwidth, is_transient, hqswb_clas, &hHQ_core->prev_hqswb_clas, hHQ_core->prev_SWB_peak_pos, prev_SWB_peak_pos_tmp, &hHQ_core->prev_frm_hfe2, &hHQ_core->prev_stab_hfe2, bws_cnt ); - - IF( NE_16( st->bwidth, SWB ) ) - { - /* reset HQ classifier memories */ - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - } - - - test(); - test(); - test(); - IF( NE_16( hqswb_clas, HQ_HARMONIC ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) && EQ_16( st->bwidth, SWB ) ) - { - hHQ_core->prev_frm_index[0] = -1; - move16(); - hHQ_core->prev_frm_index[1] = -1; - move16(); - } - - /* update number of unused bits */ - *num_bits = 0; - move16(); - - hHQ_core->hvq_hangover = 0; - move16(); - - return; -} -#endif - -/*--------------------------------------------------------------------------* - * small_symbol_enc_tran() - * - * Huffman encoding of differential energies, estimating or packing bits - * if flag_pack = 0, LC mode info. is output else LC mode info. is input - * if flag_pack = 0, estimatng else packing bits - *--------------------------------------------------------------------------*/ - -static Word16 small_symbol_enc_tran_fx( /* o : bits */ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) -{ - Word16 i, bits; - Word16 difidx[BANDS_MAX]; - - FOR( i = 0; i < BANDS; i++ ) - { - difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */ - move16(); - } - - FOR( i = 0; i < BANDS; ++i ) - { - test(); - IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 ) - { - /* Huffman cannot encode this vector */ - return -1; - } - } - - /* Preparing lossless coding input */ - IF( flag_pack == 0 ) - { - /* estimating # of bits */ - bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */ - bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ - } - ELSE - { - bits = 0; - move16(); - encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); - } - - return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} - -#ifndef CLEANUP_HQ_CORE -static Word16 small_symbol_enc_tran_ivas_fx( /* o : bits */ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) -{ - Word16 i, bits; - Word16 difidx[BANDS_MAX]; - - FOR( i = 0; i < BANDS; i++ ) - { - difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */ - move16(); - } - - FOR( i = 0; i < BANDS; ++i ) - { - test(); - IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 ) - { - /* Huffman cannot encode this vector */ - return -1; - } - } - - /* Preparing lossless coding input */ - IF( flag_pack == 0 ) - { - /* estimating # of bits */ - bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */ - bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ - } - ELSE - { - bits = 0; - move16(); - encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); - } - - return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} -#endif - -/*--------------------------------------------------------------------------* - * small_symbol_enc() - * - * Huffman encoding of differential energies, estimating or packing bits - * if flag_pack = 0, LC mode info. is output else LC mode info. is input - * if flag_pack = 0, estimatng else packing bits - *--------------------------------------------------------------------------*/ - -/* o : bits */ -static Word16 small_symbol_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) -{ - Word16 i, bits; - Word16 difidx[BANDS_MAX], LSB[BANDS_MAX]; - - /* Preparing lossless coding input */ - difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */ - move16(); - - FOR( i = 1; i < BANDS; ++i ) - { - difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */ - move16(); - } - - FOR( i = 0; i < BANDS; ++i ) - { - test(); - IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 ) - { - /* Huffman cannot encode this vector */ - return -1; - } - } - - /* splitting MSB and LSB */ - FOR( i = 0; i < BANDS; ++i ) - { - LSB[i] = s_and( difidx[i], 1 ); /* Q0 */ - move16(); - difidx[i] = shr( difidx[i], 1 ); /* Q0 */ - move16(); - } - - /* Preparing lossless coding input */ - IF( flag_pack == 0 ) - { - /* estimating # of bits */ - /* Encoding MSB bits */ - bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */ - bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ - - /* Encoding LSB bit packing */ - bits = add( bits, BANDS ); /* Q0 */ - } - ELSE - { - /* Encoding MSB bits */ - bits = 0; - move16(); - encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); - - /* Encoding LSB bit packing */ - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB ); - } - } - - return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} - -#ifndef CLEANUP_HQ_CORE -static Word16 small_symbol_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) -{ - Word16 i, bits; - Word16 difidx[BANDS_MAX], LSB[BANDS_MAX]; - - /* Preparing lossless coding input */ - difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */ - move16(); - - FOR( i = 1; i < BANDS; ++i ) - { - difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */ - move16(); - } - - FOR( i = 0; i < BANDS; ++i ) - { - test(); - IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 ) - { - /* Huffman cannot encode this vector */ - return -1; - } - } - - /* splitting MSB and LSB */ - FOR( i = 0; i < BANDS; ++i ) - { - LSB[i] = s_and( difidx[i], 1 ); /* Q0 */ - move16(); - difidx[i] = shr( difidx[i], 1 ); /* Q0 */ - move16(); - } - - /* Preparing lossless coding input */ - IF( flag_pack == 0 ) - { - /* estimating # of bits */ - /* Encoding MSB bits */ - bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */ - bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies Q0*/ - - /* Encoding LSB bit packing */ - bits = add( bits, BANDS ); /* Q0 */ - } - ELSE - { - /* Encoding MSB bits */ - bits = 0; - move16(); - encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); - - /* Encoding LSB bit packing */ - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB ); - } - } - - return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} -#endif - -/* o : bits Q0 */ -static Word16 large_symbol_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode0, /* i/o: LC mode info Q0*/ - const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/ -) -{ - Word16 i, bits, tmp; - Word16 LSB1[BANDS_MAX]; - Word16 min_q, max_q, offset0; - Word16 min_bits, min_bits_pos; - Word16 tdifidx0[BANDS_MAX], tdifidx1[BANDS_MAX]; - Word16 basic_shift; - Word16 bitsmode0, bitsmode1; - Word16 lsbdepth1; - Word16 cnt_outlyer, pos_outlyer, cnt_outlyer0; - - min_q = 513; /* Q0 */ - move16(); - max_q = -1; - move16(); - - cnt_outlyer0 = 0; - move16(); - cnt_outlyer = 0; - move16(); - bitsmode0 = 0; - move16(); - bitsmode1 = 0; - move16(); - pos_outlyer = 0; - move16(); - lsbdepth1 = 0; - move16(); - - test(); - test(); - IF( flag_pack == 0 || ( EQ_16( flag_pack, 1 ) && *hLCmode0 == 0 ) ) - { - test(); - test(); - IF( GT_16( qbidx[0], sub( ABS_ENG_OFFSET, 1 ) ) || LT_16( qbidx[0], -ABS_ENG_OFFSET ) ) - { - cnt_outlyer0 = 2; - move16(); - } - ELSE IF( GT_16( qbidx[0], 3 ) || LT_16( qbidx[0], -4 ) ) - { - cnt_outlyer0 = 1; - move16(); - } - ELSE - { - cnt_outlyer0 = 0; - move16(); - } - - cnt_outlyer = 0; - move16(); - pos_outlyer = -1; - move16(); - FOR( i = 1; i < BANDS; ++i ) - { - test(); - IF( GT_16( qbidx[i], 3 ) || LT_16( qbidx[i], -4 ) ) - { - cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */ - pos_outlyer = i; - move16(); - } - - test(); - IF( GT_16( qbidx[i], ( ABS_ENG_OFFSET - 1 ) ) || LT_16( qbidx[i], -ABS_ENG_OFFSET ) ) - { - cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */ - } - } - - test(); - test(); - IF( cnt_outlyer0 == 0 && LE_16( cnt_outlyer, 1 ) ) - { - bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */ - move16(); - IF( EQ_16( cnt_outlyer, 1 ) ) - { - /* 01 */ - bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */ - } - - FOR( i = 0; i < pos_outlyer; ++i ) - { - tdifidx0[i] = qbidx[i]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i ) - { - tdifidx0[i] = qbidx[i]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - ELSE IF( EQ_16( cnt_outlyer0, 1 ) && LE_16( cnt_outlyer, 1 ) ) - { - bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */ - move16(); - tdifidx0[0] = qbidx[0]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, BITS_ABS_ENG ); - IF( EQ_16( cnt_outlyer, 1 ) ) - { - /* 11 */ - bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */ - } - ELSE - { - pos_outlyer = 0; - move16(); - } - - FOR( i = 1; i < pos_outlyer; ++i ) - { - tdifidx0[i] = qbidx[i]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i ) - { - tdifidx0[i] = qbidx[i]; /* Q0 */ - move16(); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - ELSE - { - bitsmode0 = 20000; - move16(); - } - } - - test(); - IF( flag_pack == 0 || EQ_16( *hLCmode0, 1 ) ) - { - /* components 0 range : -256~255 */ - max_q = MINIMUM_ENERGY_LOWBRATE; - move16(); - min_q = MAXIMUM_ENERGY_LOWBRATE; - move16(); - FOR( i = 0; i < BANDS; ++i ) - { - max_q = s_max( qbidx[i], max_q ); - min_q = s_min( qbidx[i], min_q ); - } - - /* Counting bits for transmitting all components using same method */ - FOR( i = 0;; ++i ) - { - /*if (max_q <= ((2<<(i+1))-1) && min_q >= -(2<<(i+1))) */ - test(); - IF( LE_16( max_q, sub( shl( 2, add( i, 1 ) ), 1 ) ) && GE_16( min_q, -shl( 2, add( i, 1 ) ) ) ) - { - BREAK; - } - } - basic_shift = i; - move16(); - - min_bits = 1000; /* Q0 */ - move16(); - min_bits_pos = basic_shift; /* Q0 */ - move16(); - tmp = add( basic_shift, 3 ); - FOR( offset0 = basic_shift; offset0 < tmp; offset0++ ) - { - max_q = MINIMUM_ENERGY_LOWBRATE; - move16(); - min_q = MAXIMUM_ENERGY_LOWBRATE; - move16(); - - bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ - FOR( i = 0; i < BANDS; ++i ) - { - bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) ); - } - - IF( GT_16( min_bits, bitsmode1 ) ) - { - min_bits_pos = offset0; /* Q0 */ - move16(); - min_bits = bitsmode1; /* Q0 */ - move16(); - } - } - - bitsmode1 = min_bits; - move16(); - lsbdepth1 = min_bits_pos; - move16(); - - FOR( i = 0; i < BANDS; ++i ) - { - LSB1[i] = s_and( qbidx[i], sub( shl( 1, lsbdepth1 ), 1 ) ); - tdifidx1[i] = shr( qbidx[i], lsbdepth1 ); - move16(); - move16(); - } } /* Preparing lossless coding input */ @@ -2501,128 +1109,33 @@ static Word16 large_symbol_enc_fx( { /* estimating # of bits */ /* Encoding MSB bits */ - IF( LT_16( bitsmode0, bitsmode1 ) ) - { - bits = bitsmode0; /* Q0 */ - move16(); - *hLCmode0 = 0; - move16(); - } - ELSE - { - bits = bitsmode1; /* Q0 */ - move16(); - *hLCmode0 = 1; - move16(); - } + bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */ + bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */ + + /* Encoding LSB bit packing */ + bits = add( bits, BANDS ); /* Q0 */ } ELSE - { - /* Encoding MSB bits */ - IF( *hLCmode0 == 0 ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE, 0, BITS_DE_8SMODE ); - bits = BITS_DE_8SMODE; - move16(); - IF( cnt_outlyer0 == 0 ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 0, BITS_DE_8SMODE_N0 ); - bits = add( bits, BITS_DE_8SMODE_N0 ); - IF( EQ_16( cnt_outlyer, 1 ) ) - { - /* 01 */ - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); - bits = add( bits, BITS_DE_8SPOS ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - } - ELSE - { - /* 00 */ - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - } - - FOR( i = 0; i < pos_outlyer; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - ELSE IF( EQ_16( cnt_outlyer0, 1 ) ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 ); - bits = add( bits, BITS_DE_8SMODE_N0 ); - IF( EQ_16( cnt_outlyer, 1 ) ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); - bits = add( bits, BITS_DE_8SPOS ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - } - ELSE - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); /* Q0 */ - } - - FOR( i = 1; i < pos_outlyer; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = pos_outlyer + 1; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - } - ELSE - { - bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE ); - push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH ); - - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] ); - bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */ - } + { + /* Encoding MSB bits */ + bits = 0; + move16(); + encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); - IF( lsbdepth1 > 0 ) - { - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 ); - } - /*bits += BANDS * lsbdepth1; */ - bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */ - } + /* Encoding LSB bit packing */ + FOR( i = 0; i < BANDS; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB ); } } - return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ + return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } -#ifndef CLEANUP_HQ_CORE -static Word16 large_symbol_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + +/* o : bits Q0 */ +static Word16 large_symbol_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ const Word16 BANDS, /* i : number of bands Q0*/ Word16 *hLCmode0, /* i/o: LC mode info Q0*/ @@ -2709,7 +1222,7 @@ static Word16 large_symbol_enc_ivas_fx( IF( EQ_16( cnt_outlyer, 1 ) ) { /* 01 */ - bitsmode0 = add( bitsmode0, add( BITS_DE_8SPOS, BITS_ABS_ENG ) ); /* Q0 */ + bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */ } FOR( i = 0; i < pos_outlyer; ++i ) @@ -2719,7 +1232,7 @@ static Word16 large_symbol_enc_ivas_fx( bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ } - FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i ) + FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i ) { tdifidx0[i] = qbidx[i]; /* Q0 */ move16(); @@ -2732,7 +1245,7 @@ static Word16 large_symbol_enc_ivas_fx( move16(); tdifidx0[0] = qbidx[0]; /* Q0 */ move16(); - bitsmode0 = add( bitsmode0, BITS_ABS_ENG ); /* Q0 */ + bitsmode0 = add( bitsmode0, BITS_ABS_ENG ); IF( EQ_16( cnt_outlyer, 1 ) ) { /* 11 */ @@ -2751,7 +1264,7 @@ static Word16 large_symbol_enc_ivas_fx( bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */ } - FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i ) + FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i ) { tdifidx0[i] = qbidx[i]; /* Q0 */ move16(); @@ -2760,7 +1273,7 @@ static Word16 large_symbol_enc_ivas_fx( } ELSE { - bitsmode0 = 20000; /* Q0 */ + bitsmode0 = 20000; move16(); } } @@ -2804,11 +1317,10 @@ static Word16 large_symbol_enc_ivas_fx( min_q = MAXIMUM_ENERGY_LOWBRATE; move16(); - bitsmode1 = ( BITS_DE_8SMODE + BITS_MAX_DEPTH ); /* Q0 */ - move16(); + bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ FOR( i = 0; i < BANDS; ++i ) { - bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) ); /* Q0 */ + bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) ); } IF( GT_16( min_bits, bitsmode1 ) ) @@ -2820,9 +1332,9 @@ static Word16 large_symbol_enc_ivas_fx( } } - bitsmode1 = min_bits; /* Q0 */ + bitsmode1 = min_bits; move16(); - lsbdepth1 = min_bits_pos; /* Q0 */ + lsbdepth1 = min_bits_pos; move16(); FOR( i = 0; i < BANDS; ++i ) @@ -2896,288 +1408,94 @@ static Word16 large_symbol_enc_ivas_fx( } } ELSE IF( EQ_16( cnt_outlyer0, 1 ) ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 ); - bits = add( bits, BITS_DE_8SMODE_N0 ); /* Q0 */ - IF( EQ_16( cnt_outlyer, 1 ) ) - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); - bits = add( bits, BITS_DE_8SPOS ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); - } - ELSE - { - push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); - bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); - bits = add( bits, BITS_ABS_ENG ); /* Q0 */ - } - - FOR( i = 1; i < pos_outlyer; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - - FOR( i = pos_outlyer + 1; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); - bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ - } - } - } - ELSE - { - bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); - push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE ); - push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH ); - - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] ); - bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */ - } - - IF( lsbdepth1 > 0 ) - { - FOR( i = 0; i < BANDS; ++i ) - { - push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 ); - } - /*bits += BANDS * lsbdepth1; */ - bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */ - } - } - } - - return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ -} -#endif - -/*-------------------------------------------------------------------* - * band_energy_quant() - * - * - *-------------------------------------------------------------------*/ - -static Word16 band_energy_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */ - const Word16 band_start[], /* i : Q0 : band start table */ - const Word16 band_end[], /* i : Q0 : band end table */ - Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */ - const Word16 bands_fx, /* i : Q0 : number of bands */ - const Word32 L_qint, /* i : Q29 */ - const Word16 eref_fx, /* i : Q10 */ - const Word16 is_transient_fx /* i : Q0 : indicator for HQ_TRANSIENT */ -) -{ - Word16 i, k; - Word16 ebits; - Word16 hLCmode0, hLCmode1, deng_bits; - Word16 deng_cmode = 0; - Word16 hbits; - move16(); - - Word32 L_E; - Word16 QE; - - Word16 rev_qint_fx; /* 1/qint */ - Word16 Qrev_qint; /* Q value for 1/qint */ - - Word16 bq0_fx; - Word16 bq1_fx[BANDS_MAX]; - Word16 bq2_fx[BANDS_MAX]; - - Word16 bq1_temp_fx[BANDS_MAX]; - Word16 bq2_temp_fx[BANDS_MAX]; - - Word32 L_tmp; - Word16 temp_fx; - Word16 frac, exp; - Word16 exp_safe; - Word16 exp_norm; - Word16 exp_norm2; - Word16 exp_normd; - - /* Calculate the band energies */ - exp_safe = 4; - move16(); /* 4: never overflow happen at L_E */ - FOR( k = 0; k < bands_fx; k++ ) - { - L_tmp = L_deposit_l( 1295 ); /* 1295 = sqrt(0.1) (Qs) */ - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Qs */ - } - exp_norm = norm_l( L_tmp ); - exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */ - - QE = add( shl( sub( add( SWB_BWE_LR_Qs, exp_norm ), 16 ), 1 ), 1 ); - L_E = L_shl( 590L, sub( QE, 15 ) ); /* 590 0.018f(Q15 -> QE) */ - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - /*E += yos[i] * yos[i]; */ - temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Qs+exp_norm-16 */ - L_E = L_mac( L_E, temp_fx, temp_fx ); /* (Qs+exp_norm-16)*2+1 */ - } - - /*band_energy[k] = (float) log2_f (E + 1.0e-1f); */ - exp_norm2 = norm_l( L_E ); - exp = add( add( shl( sub( add( SWB_BWE_LR_Qs, exp_norm ), 16 ), 1 ), 1 ), exp_norm2 ); - L_E = L_shl( L_E, exp_norm2 ); /* (Qs+exp_norm-16)*2 + 1 + exp_norm2 */ - frac = Log2_norm_lc( L_E ); - exp = sub( 30, exp ); - L_tmp = L_Comp( exp, frac ); - L_band_energy[k] = L_shr( L_tmp, 2 ); /* Q16->Qbe(Q14) */ - move32(); - } - - IF( is_transient_fx ) - { - reverse_transient_frame_energies_fx( L_band_energy, bands_fx ); - } - - - /* Quantize the reference and band energies */ - exp_normd = norm_l( L_qint ); - rev_qint_fx = div_s( 0x4000, round_fx( L_shl( L_qint, exp_normd ) ) ); /* Q14-(29+exp_normd-16)+15 */ - Qrev_qint = sub( 14 - ( 29 - 16 ) + 15, exp_normd ); - - bq0_fx = round_fx( L_shl( L_mult( eref_fx, rev_qint_fx ), sub( 5, Qrev_qint ) ) ); /* 16-(10+Qrev_qint+1) */ - FOR( k = 0; k < bands_fx; k++ ) - { - /*bq1[k] = round_f (band_energy[k] / qint); */ - L_tmp = Mpy_32_16_1( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */ - bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* Q0 */ - move16(); - } - - IF( is_transient_fx ) - { - - Copy( bq1_fx, bq1_temp_fx, bands_fx ); /* Q0 */ - - /* Calculate the differential energies */ - diffcod_lrmdct_fx( bands_fx, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient_fx ); - } - - /* Calculate the differential energies */ - bq2_fx[0] = sub( bq1_fx[0], bq0_fx ); /* Q0 */ - move16(); - FOR( k = 1; k < bands_fx; k++ ) - { - bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] ); /* Q0 */ - move16(); - } - - /* Modifying qbidx to be located in the range -256~255 */ - FOR( i = 0; i < bands_fx; ++i ) - { - IF( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) ) - { - bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */ - move16(); - } - IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) ) - { - bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */ - move16(); - } - } - - /* Get number of bits by Huffman0 coding */ - ebits = large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 0 ); /* Q0 */ - - IF( is_transient_fx ) - { - /* Get number of bits by Huffman coding */ - hbits = small_symbol_enc_tran_fx( hBstr, bq2_temp_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */ - } - ELSE - { - /* Get number of bits by Huffman coding */ - hbits = small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */ - } - - /* comparing used bits */ - test(); - IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) ) - { - deng_cmode = 0; - move16(); - push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); - large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 1 ); - deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */ - } - ELSE - { - /* setting energy difference coding mode and storing it */ - deng_cmode = 1; - move16(); - push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); + { + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 ); + bits = add( bits, BITS_DE_8SMODE_N0 ); + IF( EQ_16( cnt_outlyer, 1 ) ) + { + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 ); + bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ + push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS ); + bits = add( bits, BITS_DE_8SPOS ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + bits = add( bits, BITS_ABS_ENG ); + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + bits = add( bits, BITS_ABS_ENG ); + } + ELSE + { + push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 ); + bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */ + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG ); + bits = add( bits, BITS_ABS_ENG ); /* Q0 */ + } - deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */ + FOR( i = 1; i < pos_outlyer; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); + bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ + } - /* packing indice */ - IF( is_transient_fx ) - { - Copy( bq2_temp_fx, bq2_fx, bands_fx ); /* Q0 */ - small_symbol_enc_tran_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx ); + FOR( i = pos_outlyer + 1; i < BANDS; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] ); + bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */ + } + } } ELSE { - small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx ); - } - } - - /* Reconstruct quantized spectrum */ - bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */ - move16(); - FOR( k = 1; k < bands_fx; k++ ) - { - bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */ - move16(); - } + bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */ + push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE ); + push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH ); - FOR( k = 0; k < bands_fx; k++ ) - { - L_band_energy[k] = Mpy_32_16_1( L_qint, bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */ - move32(); - } + FOR( i = 0; i < BANDS; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] ); + bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */ + } - IF( is_transient_fx ) - { - reverse_transient_frame_energies_fx( L_band_energy, bands_fx ); + IF( lsbdepth1 > 0 ) + { + FOR( i = 0; i < BANDS; ++i ) + { + push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 ); + } + /*bits += BANDS * lsbdepth1; */ + bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */ + } + } } - return ( deng_bits ); /* Q0 */ + return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/ } -#ifndef CLEANUP_HQ_CORE -static Word16 band_energy_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */ - const Word16 band_start[], /* i : Q0 : band start table */ - const Word16 band_end[], /* i : Q0 : band end table */ - Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */ - const Word16 bands, /* i : Q0 : number of bands */ - const Word32 L_qint, /* i : Q29 */ - const Word16 eref_fx, /* i : Q10 */ - const Word16 is_transient /* i : Q0 : indicator for HQ_TRANSIENT */ + +/*-------------------------------------------------------------------* + * band_energy_quant() + * + * + *-------------------------------------------------------------------*/ + +static Word16 band_energy_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */ + const Word16 band_start[], /* i : Q0 : band start table */ + const Word16 band_end[], /* i : Q0 : band end table */ + Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */ + const Word16 bands_fx, /* i : Q0 : number of bands */ + const Word32 L_qint, /* i : Q29 */ + const Word16 eref_fx, /* i : Q10 */ + const Word16 is_transient_fx /* i : Q0 : indicator for HQ_TRANSIENT */ ) { Word16 i, k; Word16 ebits; Word16 hLCmode0, hLCmode1, deng_bits; Word16 deng_cmode = 0; - move16(); Word16 hbits; + move16(); + Word32 L_E; Word16 QE; @@ -3197,13 +1515,12 @@ static Word16 band_energy_quant_ivas_fx( Word16 exp_safe; Word16 exp_norm; Word16 exp_norm2; - Word16 exp_normd; - /* Calculate the band energies */ + /* Calculate the band energies */ exp_safe = 4; move16(); /* 4: never overflow happen at L_E */ - FOR( k = 0; k < bands; k++ ) + FOR( k = 0; k < bands_fx; k++ ) { L_tmp = L_deposit_l( 1295 ); /* 1295 = sqrt(0.1) (Qs) */ FOR( i = band_start[k]; i <= band_end[k]; i++ ) @@ -3233,254 +1550,135 @@ static Word16 band_energy_quant_ivas_fx( move32(); } - IF( is_transient ) + IF( is_transient_fx ) { - reverse_transient_frame_energies_fx( L_band_energy, bands ); + reverse_transient_frame_energies_fx( L_band_energy, bands_fx ); } -#define WMC_TOOL_SKIP + + /* Quantize the reference and band energies */ exp_normd = norm_l( L_qint ); rev_qint_fx = div_s( 0x4000, round_fx( L_shl( L_qint, exp_normd ) ) ); /* Q14-(29+exp_normd-16)+15 */ Qrev_qint = sub( 14 - ( 29 - 16 ) + 15, exp_normd ); bq0_fx = round_fx( L_shl( L_mult( eref_fx, rev_qint_fx ), sub( 5, Qrev_qint ) ) ); /* 16-(10+Qrev_qint+1) */ - FOR( k = 0; k < bands; k++ ) + FOR( k = 0; k < bands_fx; k++ ) { /*bq1[k] = round_f (band_energy[k] / qint); */ - L_tmp = L_mls( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */ + L_tmp = Mpy_32_16_1( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */ bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* Q0 */ move16(); } -#undef WMC_TOOL_SKIP - IF( is_transient ) + IF( is_transient_fx ) { - Copy( bq1_fx, bq1_temp_fx, bands ); /* Q0 */ + Copy( bq1_fx, bq1_temp_fx, bands_fx ); /* Q0 */ /* Calculate the differential energies */ - diffcod_lrmdct_fx( bands, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient ); /* Q0 */ + diffcod_lrmdct_fx( bands_fx, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient_fx ); } /* Calculate the differential energies */ bq2_fx[0] = sub( bq1_fx[0], bq0_fx ); /* Q0 */ move16(); - FOR( k = 1; k < bands; k++ ) + FOR( k = 1; k < bands_fx; k++ ) { bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] ); /* Q0 */ move16(); } - /* Modifying qbidx to be located in the range -256~255 */ - FOR( i = 0; i < bands; ++i ) + FOR( i = 0; i < bands_fx; ++i ) { IF( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) ) { bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */ move16(); - } - IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) ) - { - bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */ - move16(); - } - } - - /* Get number of bits by Huffman0 coding */ - ebits = large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 0 ); /* Q0 */ - - IF( is_transient ) - { - /* Get number of bits by Huffman coding */ - hbits = small_symbol_enc_tran_ivas_fx( hBstr, bq2_temp_fx, bands, &hLCmode1, 0, is_transient ); /* Q0 */ - } - ELSE - { - /* Get number of bits by Huffman coding */ - hbits = small_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 0, is_transient ); /* Q0 */ - } - - test(); - IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) ) - { - deng_cmode = 0; - move16(); - push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); - large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 1 ); - deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */ - } - ELSE - { - /* setting energy difference coding mode and storing it */ - deng_cmode = 1; - move16(); - push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); - - deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */ - - /* packing indice */ - IF( is_transient ) - { - Copy( bq2_temp_fx, bq2_fx, bands ); /* Q0 */ - small_symbol_enc_tran_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 1, is_transient ); - } - ELSE - { - small_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 1, is_transient ); - } - } - - /* Reconstruct quantized spectrum */ - bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */ - move16(); - FOR( k = 1; k < bands; k++ ) - { - bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */ - move16(); - } - - FOR( k = 0; k < bands; k++ ) - { -#define WMC_TOOL_SKIP - L_band_energy[k] = L_mls( L_qint, (Word16) bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */ - move32(); -#undef WMC_TOOL_SKIP - } - - IF( is_transient ) - { - reverse_transient_frame_energies_fx( L_band_energy, bands ); - } - - return ( deng_bits ); /* Q0 */ -} -#endif - -/*-------------------------------------------------------------------* - * p2a_threshold_quant() - * - * - *-------------------------------------------------------------------*/ - -static Word16 p2a_threshold_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: : bit stream */ - const Word32 *L_t_audio, /* i : Q12 : input spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */ - const Word16 bands, /* i : Q0 : number of subbands */ - const Word16 p2a_bands, /* i : Q0 : tonality indicator */ - const Word16 p2a_th_fx, /* i : Q11 : threshold tonal or not */ - Word16 *p2a_flags_fx /* i/o: Q0 : tonality flag */ -) -{ - Word16 i, j, k; - Word32 L_a, L_p, L_e; - Word16 Qa; - Word32 L_tmp; - Word16 temp_fx; - Word16 exp_norm; - Word16 exp_safe; - Word16 exp_normn, exp_normd; - - Word16 norm_a_fx, Qnorm_a; - Word16 pa_fx, Qpa; - - Word16 exp, frac; - - Word32 L_p2a; - Word16 p2a_fx; - - exp_safe = 4; /* never happen overflow. */ - move16(); - - set16_fx( p2a_flags_fx, 1, bands ); - move16(); - - j = 0; - move16(); - FOR( k = ( bands - p2a_bands ); k < bands; k++ ) - { - L_a = L_deposit_l( 0 ); - L_p = L_deposit_l( 0 ); - - L_tmp = L_deposit_l( 0 ); - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Q12 */ - } - exp_norm = norm_l( L_tmp ); - exp_norm = sub( exp_norm, exp_safe ); - - FOR( i = band_start[k]; i <= band_end[k]; i++ ) - { - temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Q12+exp_norm-16 -> exp_norm-4 */ - L_e = L_mult( temp_fx, temp_fx ); /* 2*(exp_norm-4)+1 */ - - IF( GT_32( L_e, L_p ) ) - { - L_p = L_add( L_e, 0 ); - } - L_a = L_add( L_a, L_e ); - } - Qa = sub( shl( exp_norm, 1 ), 7 ); /* (exp_norm-4)*2+1 */ - - IF( L_a > 0x0L ) - { - /* a /= band_width[k]; */ - exp_normn = norm_l( L_a ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( band_width[k] ); - norm_a_fx = div_l( L_shl( L_a, exp_normn ), shl( band_width[k], exp_normd ) ); /* (Qa+exp_normn)-exp_normd-1); */ - Qnorm_a = sub( sub( add( Qa, exp_normn ), exp_normd ), 1 ); - - /*p2a = 10.0f * (float) log10 (p / a); */ - p2a_fx = 0; - move16(); - IF( norm_a_fx > 0 ) - { - exp_normn = norm_l( L_p ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( norm_a_fx ); - pa_fx = div_l( L_shl( L_p, exp_normn ), shl( norm_a_fx, exp_normd ) ); /* Qpa + exp_normn + Qnorm_a + exp_normd - 1 */ - Qpa = sub( sub( add( Qa, exp_normn ), add( Qnorm_a, exp_normd ) ), 1 ); + } + IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) ) + { + bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */ + move16(); + } + } - L_tmp = L_deposit_h( pa_fx ); - Qpa = add( Qpa, 16 ); - exp = norm_l( L_tmp ); - frac = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( 30, exp ); - exp = sub( exp, Qpa ); - L_tmp = L_Comp( exp, frac ); + /* Get number of bits by Huffman0 coding */ + ebits = large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 0 ); /* Q0 */ - /* 10/( log(10)/log(2) ) = 3.01029995663981195211 24660(Q13) */ - L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ + IF( is_transient_fx ) + { + /* Get number of bits by Huffman coding */ + hbits = small_symbol_enc_tran_fx( hBstr, bq2_temp_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */ + } + ELSE + { + /* Get number of bits by Huffman coding */ + hbits = small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */ + } - p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ - } + /* comparing used bits */ + test(); + IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) ) + { + deng_cmode = 0; + move16(); + push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); + large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 1 ); + deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */ + } + ELSE + { + /* setting energy difference coding mode and storing it */ + deng_cmode = 1; + move16(); + push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE ); - IF( LE_16( p2a_fx, p2a_th_fx ) ) - { - p2a_flags_fx[k] = 0; - move16(); - } + deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */ + + /* packing indice */ + IF( is_transient_fx ) + { + Copy( bq2_temp_fx, bq2_fx, bands_fx ); /* Q0 */ + small_symbol_enc_tran_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx ); } ELSE { - p2a_flags_fx[k] = 0; - move16(); + small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx ); } + } - push_indice( hBstr, IND_HQ2_P2A_FLAGS, p2a_flags_fx[k], 1 ); - j = add( j, 1 ); + /* Reconstruct quantized spectrum */ + bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */ + move16(); + FOR( k = 1; k < bands_fx; k++ ) + { + bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */ + move16(); } - return ( j ); /* Q0 */ + FOR( k = 0; k < bands_fx; k++ ) + { + L_band_energy[k] = Mpy_32_16_1( L_qint, bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */ + move32(); + } + + IF( is_transient_fx ) + { + reverse_transient_frame_energies_fx( L_band_energy, bands_fx ); + } + + return ( deng_bits ); /* Q0 */ } -#ifndef CLEANUP_HQ_CORE -static Word16 p2a_threshold_quant_ivas_fx( + +/*-------------------------------------------------------------------* + * p2a_threshold_quant() + * + * + *-------------------------------------------------------------------*/ + +static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, /* i/o: : bit stream */ const Word32 *L_t_audio, /* i : Q12 : input spectrum */ const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ @@ -3513,6 +1711,7 @@ static Word16 p2a_threshold_quant_ivas_fx( move16(); set16_fx( p2a_flags_fx, 1, bands ); + move16(); j = 0; move16(); @@ -3532,7 +1731,7 @@ static Word16 p2a_threshold_quant_ivas_fx( FOR( i = band_start[k]; i <= band_end[k]; i++ ) { temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Q12+exp_norm-16 -> exp_norm-4 */ - L_e = L_mult( temp_fx, temp_fx ); /* (exp_norm-4)*2 + 1 */ + L_e = L_mult( temp_fx, temp_fx ); /* 2*(exp_norm-4)+1 */ IF( GT_32( L_e, L_p ) ) { @@ -3594,7 +1793,7 @@ static Word16 p2a_threshold_quant_ivas_fx( return ( j ); /* Q0 */ } -#endif + /*-------------------------------------------------------------------* * mdct_spectrum_fine_gain_enc() @@ -3759,163 +1958,3 @@ static void mdct_spectrum_fine_gain_enc_fx( return; } -#ifndef CLEANUP_HQ_CORE - -static void mdct_spectrum_fine_gain_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_ybuf[], /* i : Q12 : input spectrum */ - Word32 L_y2[], /* i/o: Q12 : decoded spectrum */ - const Word16 band_start[], /* i : Q0 : table of start freq for every subband */ - const Word16 band_end[], /* i : Q0 : table of end freq for every subband */ - const Word16 k_sort[], /* i : Q0 : sort table by band_energy */ - const Word16 bands, /* i : Q0 : nubmber of subbands */ - const Word32 L_qint, /* i : Q29 : */ - const Word16 Ngq, /* i : Q0 : */ - const Word16 gqlevs, /* i : Q0 : quantized level */ - const Word16 gqbits /* i : Q0 : quantized bits */ -) -{ - Word16 i, k; - - Word16 delta_fx, Qdelta; - Word32 L_delta; - Word32 L_q; - - Word16 gain_table_fx[MAX_GQLEVS]; - Word16 Qgt; - Word16 gamma_fx; - Word16 Qgamma; - - Word16 exp_safe; - Word16 exp_normn, exp_normd; - Word16 exp_norm; - - Word32 L_temp; - Word16 temp_lo_fx, temp_hi_fx, temp_fx, temp2_fx; - - Word32 L_Eyy, L_Exy; - /*Word16 QE; */ - - Word16 d_fx; - Word16 dmin_fx; - Word16 imin_fx; - - /* Fine gain quantization on only the most significant energy bands */ - - /*delta = qint / gqlevs; */ - exp_normn = norm_l( L_qint ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_s( gqlevs ); - delta_fx = div_l( L_shl( L_qint, exp_normn ), shl( gqlevs, exp_normd ) ); - Qdelta = add( sub( exp_normn, exp_normd ), 28 ); /* 29+exp_normn-(exp_normd)-1; */ - L_delta = L_shl( L_deposit_h( delta_fx ), sub( 13, Qdelta ) ); /* Q29 */ - /*q = (-qint + delta) / 2.0f; */ - L_q = L_shr( L_sub( L_delta, L_qint ), 1 ); /* Q29 */ - - FOR( i = 0; i < gqlevs; i++ ) - { - /*gain_table[i] = (float) pow (2.0f, q * 0.5f); */ - L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) ); /* Q16 */ - temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); - Qgt = sub( 14, temp_hi_fx ); - gain_table_fx[i] = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qgt */ - move16(); - - /*q += delta; */ - L_q = L_add( L_q, L_delta ); - gain_table_fx[i] = shl( gain_table_fx[i], sub( 14, Qgt ) ); /* Qgt -> Q14 */ - move16(); - } - - FOR( k = sub( bands, Ngq ); k < bands; k++ ) - { - /*Eyy = 0.0f; */ - /*Exy = 0.0f; */ - /*for (i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++) */ - /*{ */ - /* Eyy += y2[i] * y2[i]; */ - /* Exy += ybuf[i] * y2[i]; */ - /*} */ - exp_safe = 4; - move16(); /* 4 is too large. but never happen overflow */ - L_temp = L_deposit_l( 0 ); - FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ ) - { - L_temp = L_or( L_temp, L_abs( L_y2[i] ) ); /* Q12 */ - L_temp = L_or( L_temp, L_abs( L_ybuf[i] ) ); /* Q12 */ - } - exp_norm = norm_l( L_temp ); - exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */ - - L_Eyy = L_deposit_l( 0 ); - L_Exy = L_deposit_l( 0 ); - /*QE = add(shl(add(Qs-16, exp_norm), 1), 1); //(Qs+exp_norm-16)*2+1; */ - FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ ) - { - /*Eyy += y2[i] * y2[i]; */ - temp_fx = round_fx( L_shl( L_y2[i], exp_norm ) ); /* Q12 + exp_norm - 16 */ - L_Eyy = L_mac( L_Eyy, temp_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */ - - /*Exy += ybuf[i] * y2[i]; */ - temp2_fx = round_fx( L_shl( L_ybuf[i], exp_norm ) ); /* Q12 + exp_norm - 16 */ - L_Exy = L_mac( L_Exy, temp2_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */ - } - - test(); - IF( L_Eyy > 0x0L && L_Exy > 0x0L ) - { - /*gamma = Exy / Eyy; */ - exp_normn = norm_l( L_Exy ); - exp_normn = sub( exp_normn, 1 ); - exp_normd = norm_l( L_Eyy ); - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ - Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ - gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ - - dmin_fx = 32767; - move16(); - imin_fx = -1; - move16(); - FOR( i = 0; i < gqlevs; i++ ) - { - d_fx = abs_s( sub( gamma_fx, gain_table_fx[i] ) ); /* Q14 */ - IF( LT_16( d_fx, dmin_fx ) ) - { - dmin_fx = d_fx; /* Q14 */ - move16(); - imin_fx = i; /* Q0 */ - move16(); - } - } - - gamma_fx = gain_table_fx[imin_fx]; /* Q14 */ - move16(); - - FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ ) - { - /*y2[i] *= gamma; */ - /* This IF statement for keeping same mantissa evenif y2 is plus or minus */ - IF( L_y2[i] >= 0x0 ) - { - L_y2[i] = L_shl( Mpy_32_16_1( L_y2[i], gamma_fx ), 1 ); /* Q12 */ - move32(); - } - ELSE - { - L_y2[i] = L_negate( L_shl( Mpy_32_16_1( L_abs( L_y2[i] ), gamma_fx ), 1 ) ); /* Q12 */ - move32(); - } - } - } - ELSE - { - imin_fx = 0; - move16(); - } - - push_indice( st_fx->hBstr, IND_HQ2_SUBBAND_GAIN, imin_fx, gqbits ); - } - - return; -} -#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 969649190..74343fd20 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3905,15 +3905,6 @@ void hq_lr_enc_fx( const Word16 is_transient_fx /* i : Q0 : transient flag */ ); -#ifndef CLEANUP_HQ_CORE -void hq_lr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ -); -#endif void hq_hr_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure fx */ Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ @@ -4089,27 +4080,6 @@ ivas_error tcq_core_LR_enc_fx( const Word16 adjustFlag, const Word16 is_transient ); -#ifndef CLEANUP_HQ_CORE -ivas_error tcq_core_LR_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word32 inp_vector[], - const Word32 coefs_norm_fx[], - Word32 coefs_quant_fx[], - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *Rk_fx, - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); -#endif /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ Word16 encode_envelope_indices_fx( BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 639e470fe..843efcf49 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -1024,205 +1024,6 @@ static void EncodeSWBSubbands_fx( return; } -#ifndef CLEANUP_HQ_CORE -static void EncodeSWBSubbands_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word32 *L_spectra, /* i/o: MDCT domain spectrum */ - Word16 QsL, /* i : Q value for L_spectra */ - const Word16 fLenLow_fx, /* i : lowband length */ - const Word16 fLenHigh_fx, /* i : highband length */ - const Word16 nBands_fx, /* i : number of subbands */ - const Word16 nBands_search_fx, /* i : number of subbands to be searched for BWE */ - const Word16 *sbWidth_fx, /* i : subband lengths */ - const Word16 *subband_offsets_fx, /* i : Subband offset for BWE */ - Word16 *lagIndices_fx, /* o : lowband index for each subband */ - const Word16 BANDS_fx, /* i : noise estimate from WB part */ - const Word16 *band_start_fx, /* i : Number subbands/Frame */ - const Word16 *band_end_fx, /* i : Band Start of each SB */ - Word32 *L_band_energy, /* i : Band end of each SB, :Qbe */ - Word16 Qbe, /* i : Q value of band energy */ - const Word16 *p2a_flags_fx, /* i : BAnd energy of each SB */ - const Word16 hqswb_clas_fx, /* i : lowband synthesis */ - Word16 *prev_frm_index_fx, /* i : clas information */ - const Word16 har_bands_fx, /* i/o: Index of the previous Frame */ - const Word16 *subband_search_offset_fx, /* i : Number of harmonic LF bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band width */ - const Word32 L_spectra_ni[], /* i : Qs noise injected spectra */ - Word16 *ni_seed_fx /* i/o: random seed */ -) -{ - Word16 i, k; - Word16 sspectra_fx[L_FRAME32k]; - Word16 sspectra_ni_fx[L_FRAME32k]; - Word16 sspectra_diff_fx[L_FRAME32k]; - Word16 Qss; /* Q value of Smoothed Spectrum low-subband */ - Word32 L_be_tonal[SWB_HAR_RAN1]; /* Q */ - Word16 ss_min_fx; /* Qss */ - Word32 L_th_g[NB_SWB_SUBBANDS]; - Word16 QbeL; - GainItem_fx pk_sf_fx[(NB_SWB_SUBBANDS) *8]; - Word16 pul_res_fx[NB_SWB_SUBBANDS]; - - GainItem_fx Nbiggest_fx[NB_SWB_SUBBANDS * N_NBIGGEST_PULSEARCH]; - - Word32 L_xSynth_har[L_FRAME32k]; /* Qs */ - - Word16 lagGains_fx[NB_SWB_SUBBANDS]; - Word16 QlagGains[NB_SWB_SUBBANDS]; - Word16 har_freq_est1, har_freq_est2; - Word16 flag_dis; - Word16 pos_max_hfe2; - HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; - - har_freq_est1 = 0; - move16(); - har_freq_est2 = 0; - move16(); - flag_dis = 1; - move16(); - pos_max_hfe2 = 0; - move16(); - - set16_fx( sspectra_fx, 0, fLenLow_fx ); - set16_fx( sspectra_ni_fx, 0, fLenLow_fx ); - set32_fx( L_xSynth_har, 0, L_FRAME32k ); - set16_fx( pul_res_fx, 0, NB_SWB_SUBBANDS ); - - - IF( EQ_16( hqswb_clas_fx, HQ_HARMONIC ) ) - { - pos_max_hfe2 = har_est_fx( L_spectra, fLenLow_fx, &har_freq_est1, &har_freq_est2, &flag_dis, prev_frm_hfe2, subband_search_offset_fx, sbWidth_fx, prev_stab_hfe2 ); - noise_extr_corcod_fx( L_spectra, L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, fLenLow_fx, hHQ_core->prev_hqswb_clas, &hHQ_core->prev_ni_ratio_fx, &Qss ); - /* Find best indices for each group */ - getswbindices_har_fx( - L_spectra, - QsL, sspectra_ni_fx, - nBands_search_fx, lagIndices_fx, prev_frm_index_fx, fLenLow_fx, subband_offsets_fx, sbWidth_fx, subband_search_offset_fx ); - - /* Write the indices into the bitstream */ - FOR( k = 0; k < nBands_search_fx; k++ ) - { - push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_mode0_Har[k] ); - } - - IF( flag_dis == 0 ) - { - test(); - IF( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) ) - { - har_freq_est2 = add( har_freq_est2, lagIndices_fx[0] ); - move16(); - } - } - - gethar_noisegn_fx( st_fx->hBstr, L_spectra, QsL, sspectra_diff_fx, Qss, L_xSynth_har, - sbWidth_fx, lagIndices_fx, BANDS_fx, har_bands_fx, fLenLow_fx, fLenHigh_fx, - subband_offsets_fx, subband_search_offset_fx, band_start_fx, band_end_fx, band_width_fx, - L_band_energy, Qbe, L_be_tonal, &QbeL, sspectra_fx, - har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx ); - - - Gettonl_scalfact_fx( L_xSynth_har, QsL, L_spectra_ni, fLenLow_fx, fLenHigh_fx, har_bands_fx, BANDS_fx, L_band_energy, Qbe, band_start_fx, band_end_fx, - p2a_flags_fx, L_be_tonal, QbeL, pk_sf_fx, Qss, pul_res_fx ); - - IF( flag_dis == 0 ) - { - *prev_frm_hfe2 = 0; - move16(); - } - ELSE - { - *prev_frm_hfe2 = har_freq_est2; - move16(); - } - - FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ ) - { - FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ) - { - L_spectra[i] = L_xSynth_har[i - fLenLow_fx]; - move32(); /* QsL */ - } - } - } - ELSE - { - ss_min_fx = spectrumsmooth_noiseton_fx( L_spectra, /*QsL,*/ L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, &Qss, fLenLow_fx, ni_seed_fx ); - - /* Get lag indices */ - GetSWBIndices_fx( sspectra_fx, /*Qss,*/ L_spectra + fLenLow_fx, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx, - Nbiggest_fx, subband_offsets_fx, sspectra_fx ); - - /* Bitstream operations */ - FOR( k = 0; k < nBands_fx; k++ ) - { - IF( EQ_16( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k], 1 ) ) - { - lagIndices_fx[k] = 0; - move16(); - lagGains_fx[k] = 0; - move16(); - QlagGains[k] = 15; - move16(); - } - ELSE - { - push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_modeNormal[k] ); - } - } - - convert_lagIndices_pls2smp_fx( lagIndices_fx, nBands_fx, lagIndices_fx, sspectra_fx, sbWidth_fx, fLenLow_fx ); - - GetlagGains_fx( sspectra_ni_fx, Qss, &L_band_energy[BANDS_fx - NB_SWB_SUBBANDS], Qbe, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx, lagGains_fx, QlagGains ); - FOR( k = 0; k < NB_SWB_SUBBANDS; k++ ) - { - lagGains_fx[k] = mult_r( lagGains_fx[k], 29491 ); /* lagGains[k]*0.9f; */ - move16(); - } - - FOR( k = 0; k < NB_SWB_SUBBANDS; k++ ) - { - L_th_g[k] = L_deposit_l( 0 ); - move32(); - IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k] == 0 ) - { - L_th_g[k] = L_shl( L_mult( lagGains_fx[k], ss_min_fx ), sub( QsL, add( add( QlagGains[k], Qss ), 1 ) ) ); /* QlagGain+Qss -> QsL */ - move32(); - } - } - - GetSynthesizedSpecThinOut_fx( sspectra_ni_fx, Qss, L_xSynth_har, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, lagGains_fx, QlagGains, fLenLow_fx ); - - /*Level adjustment for the missing bands*/ - noiseinj_hf_fx( L_xSynth_har, QsL, L_th_g, L_band_energy, Qbe, hHQ_core->prev_En_sb_fx, p2a_flags_fx, BANDS_fx, band_start_fx, band_end_fx, fLenLow_fx, fLenHigh_fx ); - - - FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ ) - { - IF( p2a_flags_fx[k] == 0 ) - { - FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ) - { - L_spectra[i] = L_xSynth_har[i - fLenLow_fx]; - move32(); /* Qob */ - } - } - ELSE - { - FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ ) - { - L_spectra[i] = L_spectra_ni[i]; - move32(); - } - } - } - } - - return; -} -#endif /*--------------------------------------------------------------------------* * swb_bwe_enc_lr() @@ -1312,89 +1113,3 @@ void swb_bwe_enc_lr_fx( return; } -#ifndef CLEANUP_HQ_CORE - -void swb_bwe_enc_lr_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, /* i : Q value */ - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ -) -{ - Word16 k; - Word16 nBands_fx; - Word16 nBands_search_fx; - Word16 wBands_fx[NB_SWB_SUBBANDS]; - Word16 lagIndices_fx[NB_SWB_SUBBANDS]; - Word16 swb_lowband_fx, swb_highband_fx, allband_fx; - - const Word16 *subband_offsets_fx; - const Word16 *subband_search_offset_fx; - - Word32 *p_L_m; - - subband_search_offset_fx = subband_search_offsets_13p2kbps_Har; - subband_offsets_fx = subband_offsets_sub5_13p2kbps_Har; - - hf_parinitiz_fx( L_total_brate, hqswb_clas_fx, lowlength_fx, highlength_fx, wBands_fx, &subband_search_offset_fx, &subband_offsets_fx, &nBands_fx, &nBands_search_fx, &swb_lowband_fx, &swb_highband_fx ); - allband_fx = add( swb_lowband_fx, swb_highband_fx ); - move16(); - - /* Prepare m[], low part from WB core, high part from 32k input */ - Copy32( L_m_core, L_m, swb_lowband_fx ); - Copy32( &L_m_orig[swb_lowband_fx], &L_m[swb_lowband_fx], swb_highband_fx ); - - EncodeSWBSubbands_ivas_fx( - st_fx, - L_m, QsL, - swb_lowband_fx, swb_highband_fx, nBands_fx, nBands_search_fx, wBands_fx, subband_offsets_fx, - lagIndices_fx, - BANDS_fx, band_start_fx, band_end_fx, - L_band_energy, Qbe, - p2a_flags_fx, - hqswb_clas_fx, prev_frm_index_fx, har_bands_fx, subband_search_offset_fx, - prev_frm_hfe2, prev_stab_hfe2, - band_width_fx, L_y2_ni, ni_seed_fx ); - - p_L_m = &L_m[sub( allband_fx, 1 )]; - *p_L_m = Mult_32_16( *p_L_m, 2028 ); - move32(); - p_L_m--; /* 0.0625 = 2028 (Q15) */ - *p_L_m = Mult_32_16( *p_L_m, 4096 ); - move32(); - p_L_m--; /* 0.125 = 4096 (Q15) */ - *p_L_m = Mult_32_16( *p_L_m, 8192 ); - move32(); - p_L_m--; /* 0.25 = 8192 (Q15) */ - *p_L_m = Mult_32_16( *p_L_m, 16384 ); - move32(); - p_L_m--; /* 0.5 = 16384 (Q15) */ - - /* set low frequencies to zero */ - FOR( k = 0; k < swb_lowband_fx; k++ ) - { - L_m[k] = L_deposit_l( 0 ); - move32(); - } - - return; -} -#endif diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index ffe9b86f7..517c1c0b4 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -493,489 +493,3 @@ ivas_error tcq_core_LR_enc_fx( return error; } -#ifndef CLEANUP_HQ_CORE - -ivas_error tcq_core_LR_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word32 inp_vector_fx[], /* x5 */ - const Word32 coefs_norm_fx[], /* Q12 */ - Word32 coefs_quant_fx[], /* Q12 */ - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *R_fx, /* Q16 */ - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ) -{ - Word16 i, j, k, size, nb_bytes; - - Word16 USQ_TCQ[NB_SFM]; /* TCQ is selected by default*/ - Word16 coefs_norm_dec_fx[L_FRAME32k]; /* New output buffer (TCQ+USQ)*/ - Word32 savedstates[TCQ_MAX_BAND_SIZE]; - ARCODEC arenc_fx, *parenc_fx; - TCQ_BITSTREAM bs_fx, *pbs_fx; - Word16 k_num[2]; - Word32 bit_surplus_fx[2]; - - Word16 flag_wbnb = 0; - Word16 lsbtcq_bits = TCQ_AMP; - Word16 tcq_arbits = 2; - Word16 nzb = 0; - Word16 nzbands = 0; - Word16 bcount = 0; - Word32 bsub_fx = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move32(); - Word32 abuffer_fx[MAX_PULSES]; - Word16 mbuffer_fx[MAX_PULSES]; - Word32 sbuffer_fx[MAX_PULSES]; - Word16 dpath[280]; - Word32 Rk_sort_fx[NB_SFM]; - Word32 step_scale_fx[NB_SFM]; - Word16 pulses_fx, nzp_fx; - - Word32 gain_fx, crosscorr_fx, selfcorr_fx; - Word16 hi, lo, exp; - Word32 surplus_fx, delta_fx, est_frame_bits_fx; - - Word32 leftbits = 0; - Word32 sepbits = 0; - Word32 divider = 0; - move32(); - move32(); - move32(); - ivas_error error; - - error = IVAS_ERR_OK; - move16(); - set16_fx( dpath, 0, 280 ); - set32_fx( abuffer_fx, 0, MAX_PULSES ); - set32_fx( sbuffer_fx, 0, MAX_PULSES ); - set16_fx( mbuffer_fx, 0, MAX_PULSES ); - /* initialization */ - set32_fx( Rk_sort_fx, 0, NB_SFM ); - set16_fx( USQ_TCQ, 0, NB_SFM ); - set16_fx( coefs_norm_dec_fx, 0, L_FRAME32k ); - - InitLSBTCQ_fx( &bcount ); - - test(); - test(); - IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && is_transient == 0 ) - { - flag_wbnb = 1; - move16(); - lsbtcq_bits = 0; - move16(); - tcq_arbits = 0; - move16(); - } - - /* TCQ Index initialize */ - parenc_fx = &arenc_fx; - pbs_fx = &bs_fx; - - pbs_fx->curPos = 7; - move16(); - pbs_fx->numbits = L_deposit_l( 0 ); - pbs_fx->numByte = L_deposit_l( 0 ); - move32(); - move32(); - FOR( i = 0; i < MAX_SIZEBUF_PBITSTREAM; i++ ) - { - pbs_fx->buf[i] = 0; - move16(); - } - ar_encoder_start_fx( parenc_fx, pbs_fx, L_deposit_l( bit_budget ) ); - - /* Bits distribution analysis */ - FOR( i = 0; i < BANDS; i++ ) - { - IF( GE_32( ar_div( R_fx[i], sfmsize[i] ), 49152 ) ) - { - /* USQ used for high importance bands*/ - USQ_TCQ[i] = 1; - move16(); - } - ELSE - { - /* TCQ used for usual bands */ - USQ_TCQ[i] = 0; - move16(); - } - - IF( R_fx[i] > 0 ) - { - /* nzbands++; */ - nzbands = add( nzbands, 1 ); - } - } - - FOR( j = 0; j < BANDS; j++ ) - { - IF( R_fx[j] > 0 ) - { - nzb = add( nzb, 1 ); - } - } - - bsub_fx = L_shl( add( tcq_arbits, lsbtcq_bits ), 16 ); /* Q16 */ - IF( bsub_fx > 0 ) - { - bsub_fx = L_add( bsub_fx, 2048 ); - } - FOR( j = BANDS - 1; j >= 0; j-- ) - { - IF( R_fx[j] > 0 ) - { - R_fx[j] = L_sub( R_fx[j], ar_div( bsub_fx, nzb ) ); - move32(); - - IF( R_fx[j] < 0 ) - { - bsub_fx = L_sub( bsub_fx, L_add( ar_div( bsub_fx, nzb ), R_fx[j] ) ); - R_fx[j] = L_deposit_l( 0 ); - move32(); - } - ELSE - { - bsub_fx = L_sub( bsub_fx, ar_div( bsub_fx, nzb ) ); - } - /* nzb--; */ - nzb = sub( nzb, 1 ); - } - } - - /* Sort the bit allocation table (R) in ascending order, figure out number of pulses per band */ - srt_vec_ind_fx( R_fx, Rk_sort_fx, k_sort, BANDS ); - - /* Quantize spectral band shapes using TCQ */ - /* Select ISC */ - set32_fx( coefs_quant_fx, 0, add( sfm_end[BANDS - 1], 1 ) ); - Copy32( coefs_norm_fx, coefs_quant_fx, add( sfm_end[BANDS - 1], 1 ) ); - - delta_fx = L_deposit_l( 0 ); - est_frame_bits_fx = L_deposit_l( 0 ); - - test(); - test(); - IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && is_transient == 0 ) - { - surplus_fx = -131072; - move32(); - bit_allocation_second_fx( R_fx, Rk_sort_fx, BANDS, sfmsize, k_sort, k_num, p2a_flags, p2a_bands, last_bitalloc, input_frame ); - - nzbands = 0; - move16(); - FOR( j = 0; j < BANDS; j++ ) - { - test(); - IF( NE_16( j, k_num[0] ) && NE_16( j, k_num[1] ) ) - { - leftbits = L_add( leftbits, R_fx[k_sort[j]] ); - IF( R_fx[k_sort[j]] > 0 ) - { - nzbands = add( nzbands, 1 ); - } - } - ELSE - { - sepbits = L_add( sepbits, R_fx[k_sort[j]] ); - } - } - /* Separate the position information from the input signal(coefs_norm) */ - /* Gather the NZ coefficients*/ - FOR( k = 0; k < BANDS; k++ ) /* Loop through non-zero blocks */ - { - test(); - IF( NE_16( k, k_num[0] ) && NE_16( k, k_num[1] ) ) - { - test(); - test(); - IF( R_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 0 ) /* Then have non-zero block AND WILL BE ENCODED BY TCQ */ - { - /* Encode Position Info, NZ Info, Signs */ - size = sfmsize[k_sort[k]]; - move16(); - - /* Determine scale step, ISC and TCQ quantizer */ - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, - L_add( R_fx[k_sort[k]], delta_fx ), - /* R_fx[k_sort[k]], */ - &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 0, &nzp_fx, 0, 0, 0, 0 ); - leftbits = L_sub( leftbits, L_add( R_fx[k_sort[k]], delta_fx ) ); - npulses[k_sort[k]] = pulses_fx; - move16(); - - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_tcq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, savedstates, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - nzbands = sub( nzbands, 1 ); - } - /* Have USQ coded band */ - ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) ) - { - size = sfmsize[k_sort[k]]; - move16(); - - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, - L_add( R_fx[k_sort[k]], delta_fx ), - /* R_fx[k_sort[k]], */ - &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, 0, 0, 0, 0 ); - leftbits = L_sub( leftbits, L_add( R_fx[k_sort[k]], delta_fx ) ); - npulses[k_sort[k]] = pulses_fx; - move16(); - - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - nzbands = sub( nzbands, 1 ); - } - ELSE /* Then have zero block */ - { - npulses[k_sort[k]] = 0; - move16(); - size = sfmsize[k_sort[k]]; - move16(); - } - - delta_fx = L_deposit_l( 0 ); - test(); - IF( R_fx[k_sort[k]] > 0 && surplus_fx < 0 ) - { - /* delta_fx = L_deposit_h( div_l( surplus_fx, nzbands ) ); */ - IF( LE_16( nzbands, 1 ) ) - { - divider = 0; - move32(); - } - ELSE - { - divider = 2; - move32(); - } - - IF( L_add( L_add( surplus_fx, sepbits ), ar_div( leftbits, divider ) ) < 0 ) - { - /* Overflow possible => start to distribute negative surplus */ - delta_fx = ar_div( surplus_fx + sepbits, nzbands ); - } - ELSE - { - delta_fx = 0; - move32(); - } - surplus_fx = L_sub( surplus_fx, delta_fx ); - } - } - } - - test(); - test(); - test(); - IF( ( GT_32( surplus_fx, 524288 ) && EQ_16( input_frame, L_FRAME8k ) ) || ( GT_32( surplus_fx, 786432 ) && EQ_16( input_frame, L_FRAME16k ) ) ) - { - bit_surplus_fx[0] = Mult_32_16( surplus_fx, 24576 ); /* Q16 */ - move32(); - bit_surplus_fx[1] = Mult_32_16( surplus_fx, 8192 ); /* Q16 */ - move32(); - } - ELSE - { - bit_surplus_fx[0] = surplus_fx; - move32(); - bit_surplus_fx[1] = L_deposit_l( 0 ); - move32(); - } - - FOR( k = 0; k < BANDS; k++ ) - { - FOR( j = 0; j < 2; j++ ) - { - IF( EQ_16( k, k_num[j] ) ) - { - R_fx[k_sort[k]] = L_add( R_fx[k_sort[k]], bit_surplus_fx[j] ); - move32(); - - test(); - test(); - IF( R_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 0 ) /* Then have non-zero block AND WILL BE ENCODED BY TCQ */ - { - /* Encode Position Info, NZ Info, Signs */ - size = sfmsize[k_sort[k]]; - move16(); - - /* Determine scale step, ISC and TCQ quantizer */ - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]], &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 0, &nzp_fx, 0, 0, 0, 0 ); - - npulses[k_sort[k]] = pulses_fx; - move16(); - - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_tcq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, savedstates, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - } - /* Have USQ coded band */ - ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) ) - { - size = sfmsize[k_sort[k]]; - move16(); - - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]], &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, 0, 0, 0, 0 ); - - npulses[k_sort[k]] = pulses_fx; - move16(); - - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - } - ELSE /* Then have zero block */ - { - npulses[k_sort[k]] = 0; - move16(); - size = sfmsize[k_sort[k]]; - move16(); - } - } - } - } - } - ELSE - { - surplus_fx = L_deposit_l( 0 ); - - /* Separate the position information from the input signal(coefs_norm) */ - /* Gather the NZ coefficients*/ - FOR( k = 0; k < BANDS; k++ ) /* Loop through non-zero blocks */ - { - IF( R_fx[k_sort[k]] > 0 ) - { - size = sfmsize[k_sort[k]]; - move16(); - GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]] + delta_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, &bcount, abuffer_fx, mbuffer_fx, sbuffer_fx ); - - npulses[k_sort[k]] = pulses_fx; - move16(); - encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx ); - encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx ); - encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx ); - - /* nzbands--; */ - nzbands = sub( nzbands, 1 ); - } - ELSE /* Then have zero block */ - { - npulses[k_sort[k]] = 0; - move16(); - size = sfmsize[k_sort[k]]; - move16(); - } - - /* Surplus distribution */ - /* if( surplus > 0.0f && nzbands > 0 ) */ - test(); - IF( surplus_fx > 0 && nzbands > 0 ) - { - /* delta = surplus / nzbands; - surplus -= delta; */ - - delta_fx = ar_div( surplus_fx, nzbands ); - surplus_fx = L_sub( surplus_fx, delta_fx ); - } - } - } - - TCQLSB_fx( bcount, /*abuffer, */ abuffer_fx, /*mbuffer, */ mbuffer_fx, /*sbuffer, */ sbuffer_fx, dpath ); - - /* Save TCQ path to bitstream */ - SaveTCQdata_fx( parenc_fx, dpath, lsbtcq_bits ); - - /* Add tcq sequence to decoding buffer */ - InitLSBTCQ_fx( &bcount ); - - ar_encoder_done_fx( parenc_fx ); - - /* Loop through non-zero blocks */ - FOR( i = 0; i < L_FRAME32k; i++ ) - { - coefs_norm_dec_fx[i] = extract_l( L_mult0( coefs_norm_dec_fx[i], 5 ) ); - move16(); - } - - IF( !flag_wbnb ) - { - FOR( k = 0; k < BANDS; k++ ) - { - IF( R_fx[k_sort[k]] > 0 ) - { - size = sfmsize[k_sort[k]]; - move16(); - RestoreTCQ_fx( &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &bcount, mbuffer_fx ); - } - } - } - - nb_bytes = shr( bit_budget, 3 ); - - j = sub( bit_budget, shl( nb_bytes, 3 ) ); - FOR( i = 0; i < nb_bytes; i++ ) - { - push_indice( hBstr, IND_HQ2_SUBBAND_TCQ, pbs_fx->buf[i], 8 ); - } - IF( j > 0 ) - { - push_indice( hBstr, IND_HQ2_SUBBAND_TCQ, shr( pbs_fx->buf[nb_bytes], sub( 8, j ) ), j ); - } - /* Clear decoding buffer */ - set32_fx( coefs_quant_fx, 0, sfm_end[BANDS - 1] + 1 ); - - /* New analysis of decoded frame */ - FOR( i = 0; i < BANDS; i++ ) - { - IF( R_fx[k_sort[i]] > 0 ) - { - gain_fx = L_deposit_l( 0 ); - - crosscorr_fx = L_deposit_l( 0 ); - selfcorr_fx = L_deposit_l( 0 ); - - FOR( j = 0; j < sfmsize[k_sort[i]]; j++ ) - { - crosscorr_fx = L_add( crosscorr_fx, Mult_32_16( coefs_norm_fx[sfm_start[k_sort[i]] + j], shl( coefs_norm_dec_fx[sfm_start[k_sort[i]] + j], 2 ) ) ); /*1 */ - selfcorr_fx = L_mac0( selfcorr_fx, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j], coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ); - } - - exp = sub( norm_l( crosscorr_fx ), 1 ); - gain_fx = ar_div( L_shl( crosscorr_fx, exp ), selfcorr_fx ); /* 1 + exp */ - gain_fx = L_shl_sat( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */ - lo = L_Extract_lc( gain_fx, &hi ); - /* Use optimal gain */ - FOR( j = 0; j < sfmsize[k_sort[i]]; j++ ) - { - inp_vector_fx[sfm_start[k_sort[i]] + j] = coefs_norm_dec_fx[sfm_start[k_sort[i]] + j]; - move32(); - coefs_quant_fx[sfm_start[k_sort[i]] + j] = L_add( L_shl( L_mult0( hi, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 12 ), - L_shr( L_mult0( lo, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 3 ) ); /* Q12 */ - move32(); - } - } - } - - - return error; -} -#endif -- GitLab From 515174be40efa14a4d6f476bf10dddf9eeaa9919 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:12:02 +0100 Subject: [PATCH 09/26] [cleanup] accept REMOVE_UNUSED_CODE_IVAS_DEC --- lib_com/ivas_prot_fx.h | 8 - lib_com/options.h | 1 - lib_dec/ivas_ism_dtx_dec_fx.c | 6 - lib_dec/ivas_jbm_dec_fx.c | 637 ------------------------- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 52 -- 5 files changed, 704 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7ffa702b9..7962a009b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1571,10 +1571,6 @@ void ivas_sba_dirac_stereo_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ const Word16 output_frame /* i : output frame length per channel */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - , - const Word16 mcmasa /* i : McMASA flag */ -#endif ); ivas_error ivas_osba_render_sf_fx( @@ -4271,10 +4267,6 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const Word16 sce_id_dtx, /* i : SCE DTX ID */ const Word16 nchan_transport /* i : number of transport channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - , - Word16 *Q_cngNoiseLevel -#endif ); ivas_error stereo_dft_enc_create_fx( diff --git a/lib_com/options.h b/lib_com/options.h index 02b867f60..e8c6b548e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index b98640b7a..d283832b3 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -161,16 +161,11 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const Word16 sce_id_dtx, /* i : SCE DTX ID */ const Word16 nchan_transport /* i : number of transport channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - , - Word16 *Q_cngNoiseLevel /* i : stores Q factor of hFdCngCom->cngNoiseLevel for various channels*/ -#endif ) { Word32 fac_fx, cng_noise_nrg_obj_fx, cng_noise_nrg_dominant_fx; Word16 ch, cng_noise_level_len, Q_cng_noise_nrg_dominant, exp; HANDLE_FD_CNG_COM hFdCngCom; -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 Q_cngNoiseLevel[MAX_SCE]; FOR( ch = 0; ch < nchan_transport; ch++ ) @@ -189,7 +184,6 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( move16(); } } -#endif hFdCngCom = hSCE[sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom; cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index d703a4104..55788b01c 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -77,11 +77,7 @@ ivas_error ivas_dec_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 ch, n, output_frame, nchan_out, i, s; -#else - Word16 ch, n, output_frame, nchan_out, i, ii; -#endif Decoder_State *st; /* used for bitstream handling */ Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */ Word16 nchan_remapped; @@ -91,11 +87,6 @@ ivas_error ivas_dec_fx( ivas_error error; Word16 num_md_sub_frames; Word32 ism_total_brate; -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 s; - CPE_DEC_HANDLE hCPE; - SCE_DEC_HANDLE hSCE; -#endif push_wmops( "ivas_dec" ); /*----------------------------------------------------------------* @@ -127,41 +118,16 @@ ivas_error ivas_dec_fx( *----------------------------------------------------------------*/ test(); -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - test(); - IF( st_ivas->bfi != 0 && st_ivas->ini_frame == 0 ) - { - /* zero output when first frame(s) is lost */ - FOR( n = 0; n < nchan_out; n++ ) - { - set32_fx( p_output_fx[n], 0, output_frame ); - } - } - ELSE -#endif IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; move32(); -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); - set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); - set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); -#endif IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); // Q11 - } -#endif /* HP filtering */ FOR( n = 0; n < s_min( nchan_out, st_ivas->nchan_transport ); n++ ) { @@ -175,38 +141,13 @@ ivas_error ivas_dec_fx( IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata ); -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[st_ivas->hISMDTX.sce_id_dtx], 0, L_FRAME48k ); -#endif IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 Q_cngNoiseLevel[MAX_SCE]; - FOR( ch = 0; ch < 4; ch++ ) - { - IF( st_ivas->hSCE[ch] != NULL ) - { - Word16 shift = getScaleFactor32( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - if ( LT_16( sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) - { - shift = sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); - } - scale_sig32( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-(cngNoiseLevelExp -shift) ) - st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); - Q_cngNoiseLevel[ch] = sub( 31, st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); - move16(); - move16(); - } - } - - ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); -#else ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); -#endif ivas_param_ism_dec_dequant_md_fx( st_ivas ); } @@ -234,9 +175,6 @@ ivas_error ivas_dec_fx( test(); IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && EQ_16( n, st_ivas->hISMDTX.sce_id_dtx ) ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[n], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ), IVAS_ERR_OK ) ) { return error; @@ -254,11 +192,7 @@ ivas_error ivas_dec_fx( { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); -#else - Scale_sig32( p_output_fx[0], L_FRAME48k, 3 ); -#endif } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) ) { @@ -312,15 +246,8 @@ ivas_error ivas_dec_fx( } /* core-decoding of transport channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = Q11; - move16(); -#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[0], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; @@ -328,21 +255,10 @@ ivas_error ivas_dec_fx( } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); - set32_fx( &p_output_fx[1][0], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); // Q11 - } -#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -388,213 +304,8 @@ ivas_error ivas_dec_fx( ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); -#else - { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[i], output_frame ) - 11 ) /* Guard bits */; - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) - } - hCPE->hStereoDft->q_dft = add( Q11, s ); - move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - move16(); - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - - q = hCPE->hStereoDft->q_dft; - move16(); - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - IF( LE_16( st_ivas->nchan_transport, 1 ) ) - { - st = hCPE->hCoreCoder[0]; - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && ( st->last_core == ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ - { - IF( !st->tcxonly ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - } - } - ELSE /* ACELP core */ - { - test(); - test(); - IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */ - { - test(); - test(); - test(); - test(); - IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - } - } - } - - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hCPE->hStereoDft->q_dft, hSCE->q_save_hb_synth_fx ) ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hCPE->hStereoDft->q_dft, hSCE->q_save_synth_fx ) ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - } - - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, st_ivas->ivas_format == MC_FORMAT ); - - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); - } - - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 - } - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB - } - IF( hCPE->hStereoDft != NULL ) - { - IF( LE_16( st_ivas->nchan_transport, 1 ) ) - { - st = hCPE->hCoreCoder[0]; - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && st->core == ACELP_CORE && EQ_16( st->con_tcx, 1 ) ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( st->last_core != ACELP_CORE || ( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ - { - IF( !st->tcxonly ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - } - } - ELSE /* ACELP core */ - { - test(); - test(); - IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */ - { - test(); - test(); - test(); - test(); - IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - } - } - } - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - test(); - } - - st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - move16(); - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } -#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) { @@ -673,11 +384,7 @@ ivas_error ivas_dec_fx( ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC FOR( i = 0; i < CPE_CHANNELS; i++ ) -#else - FOR( i = 0; i < 2; i++ ) -#endif { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); } @@ -730,34 +437,6 @@ ivas_error ivas_dec_fx( move16(); } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - /* set ISM parameters and decode ISM metadata in OMASA format */ - Word16 q_output = 11; - move16(); - - // NOTE: the following is done to calculate the number of hIsmMetaData indices - Word16 tmp_nchan_ism; - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) - { - tmp_nchan_ism = 1; - move16(); - } - ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - tmp_nchan_ism = 0; - move16(); - } - ELSE - { - tmp_nchan_ism = st_ivas->nchan_ism; - move16(); - } - - FOR( n = 0; n < tmp_nchan_ism; n++ ) - { - set32_fx( p_output_fx[n], 0, L_FRAME48k ); - } -#endif /* MASA metadata decoding */ IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { @@ -788,16 +467,6 @@ ivas_error ivas_dec_fx( return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - /* shifting both the channels from variable q_output to constant Q-factor (Q11) */ - FOR( Word16 k = 0; k < output_frame; k++ ) - { - p_output_fx[0][k] = L_shr( p_output_fx[0][k], sub( Q11, q_output ) ); - move32(); - p_output_fx[1][k] = L_shr( p_output_fx[1][k], sub( Q11, q_output ) ); - move32(); - } -#endif IF( EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) { Copy32( p_output_fx[0], p_output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */ @@ -808,21 +477,13 @@ ivas_error ivas_dec_fx( hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 output_q = Q11; -#else - Word16 output_q = 11; -#endif move16(); IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC output_q = Q8; -#else - output_q = 8; -#endif move16(); } ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) @@ -892,40 +553,19 @@ ivas_error ivas_dec_fx( } /* core-decoding of transport channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); -#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[0], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC // this is just to keep formatting correct (clang-format otherwise brekas the indentation) ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) { IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ) { return error; } -#else - ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ){ - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ){ - return error; - } -#endif -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } -#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -956,116 +596,7 @@ ivas_error ivas_dec_fx( ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); -#else - { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], output_frame ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); // Q(11+s) - } - hCPE->hStereoDft->q_dft = add( Q11, s ); - move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - move16(); - } - - q = hCPE->hStereoDft->q_dft; - move16(); - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - } - - ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); - - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); - } - - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 - } - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - move16(); - } - - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } -#endif } /* HP filtering */ @@ -1147,11 +678,7 @@ ivas_error ivas_dec_fx( { ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); // Q11 -#else - Scale_sig32( p_output_fx[0], L_FRAME48k, Q11 - Q8 ); // Q11 -#endif /* add W */ FOR( n = 0; n < nchan_out; n++ ) @@ -1176,11 +703,7 @@ ivas_error ivas_dec_fx( /* LFE channel decoder */ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 -#else - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 -#endif IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) { @@ -1237,11 +760,7 @@ ivas_error ivas_dec_fx( /* LFE channel decoder */ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11 -#else - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 -#endif ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); @@ -1299,21 +818,10 @@ ivas_error ivas_dec_fx( IF( EQ_16( st_ivas->nCPE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); -#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } -#endif } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { @@ -1352,30 +860,16 @@ ivas_error ivas_dec_fx( IF( st_ivas->hOutSetup.separateChannelEnabled ) { /* Decode the transport audio signals */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); -#endif IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } -#endif /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ n = LFE_CHANNEL - 1; move16(); /* Decode the separated channel to output[n] to be combined with the synthesized channels */ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[n], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; @@ -1402,15 +896,8 @@ ivas_error ivas_dec_fx( } ELSE { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - Word16 q_output = 11; - move16(); -#endif IF( EQ_16( st_ivas->nSCE, 1 ) ) { -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - set32_fx( p_output_fx[0], 0, L_FRAME48k ); -#endif IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; @@ -1422,136 +909,12 @@ ivas_error ivas_dec_fx( { return error; } -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } -#endif } } IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */ { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame ); -#else - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[i], output_frame ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) - } - - hCPE->hStereoDft->q_dft = add( Q11, s ); - move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - - move16(); - move16(); - } - - q = hCPE->hStereoDft->q_dft; - move16(); - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - IF( st_ivas->hSpar != NULL ) - { - st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - move16(); - } - - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->q_output_mem_fx[ii] ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - } - - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); - - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 - } - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); - FOR( i = 0; i < CPE_CHANNELS; ++i ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - move16(); - } - IF( st_ivas->hSpar != NULL ) - { - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) - { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } -#endif } /* HP filtering */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index dfc51cc74..18f94bc9f 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1232,18 +1232,12 @@ void ivas_sba_dirac_stereo_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ const Word16 output_frame /* i : output frame length per channel Q0*/ -#ifndef REMOVE_UNUSED_CODE_IVAS_DEC - , - const Word16 mcmasa /* i : McMASA flag Q0*/ -#endif ) { Word16 dtx_flag, fd_cng_flag; Word16 sba_mono_flag; Word16 memOffset; -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word32 output_Fs; -#endif Word32 tmp_buf[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; Word32 tmp_synth[L_FRAME16k]; Word32 hb_gain[NB_DIV]; @@ -1256,7 +1250,6 @@ void ivas_sba_dirac_stereo_dec_fx( SCE_DEC_HANDLE hSCE; CPE_DEC_HANDLE hCPE; STEREO_DFT_DEC_DATA_HANDLE hStereoDft; -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Word16 mcmasa; mcmasa = 0; @@ -1406,49 +1399,23 @@ void ivas_sba_dirac_stereo_dec_fx( /*----------------------------------------------------------------* * Processing *----------------------------------------------------------------*/ -#endif -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC FOR( i = 0; i < CPE_CHANNELS; i++ ) -#else - FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) -#endif { set32_fx( DFT[i], 0, STEREO_DFT_BUF_MAX ); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC q = hStereoDft->q_dft; move16(); q_dft[0] = hStereoDft->q_dft; move16(); q_dft[1] = hStereoDft->q_dft; move16(); -#else - hSCE = st_ivas->hSCE[0]; - hCPE = st_ivas->hCPE[0]; - hStereoDft = hCPE->hStereoDft; - - q = hCPE->hStereoDft->q_dft; - move16(); - q_dft[0] = hCPE->hStereoDft->q_dft; - move16(); - q_dft[1] = hCPE->hStereoDft->q_dft; - move16(); -#endif -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/ -#else - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ -#endif IF( hSCE != NULL ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/ -#else - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ -#endif hSCE->q_prev_hb_synth_fx = hStereoDft->q_dft; move16(); } @@ -1479,11 +1446,7 @@ void ivas_sba_dirac_stereo_dec_fx( test(); test(); -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); -#else - hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); -#endif stereo_dft_dec_update_fx( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); @@ -1530,13 +1493,8 @@ void ivas_sba_dirac_stereo_dec_fx( } /* DFT Stereo upmix */ -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); -#else - stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, - st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); -#endif /* DFT synthesis */ stereo_dft_dec_synthesize_fx( hCPE, DFT, 0, output[0], output_frame ); @@ -1594,23 +1552,14 @@ void ivas_sba_dirac_stereo_dec_fx( set32_fx( output[ch], 0, output_frame ); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ -#else - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ -#endif IF( hSCE != NULL ) { -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/ -#else - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ -#endif hSCE->q_prev_hb_synth_fx = Q11; move16(); } -#ifdef REMOVE_UNUSED_CODE_IVAS_DEC /*----------------------------------------------------------------* * Adjust scaling of buffers *----------------------------------------------------------------*/ @@ -1710,7 +1659,6 @@ void ivas_sba_dirac_stereo_dec_fx( hCPE->q_output_mem_fx[ii] = Q11; move16(); } -#endif return; } -- GitLab From 98c5071a9bd7aa41bf8b24e91a0339d7c00e3eb5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:17:43 +0100 Subject: [PATCH 10/26] [cleanup] accept FIX_2294_CLANG_18_WARNINGS_ENC --- lib_com/options.h | 1 - lib_enc/avq_cod_fx.c | 4 ---- lib_enc/ext_sig_ana_fx.c | 4 ---- lib_enc/ivas_core_enc_fx.c | 2 -- lib_enc/ivas_cpe_enc_fx.c | 2 -- 5 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e8c6b548e..fe4c2e092 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 943e2d2a2..e54dfeda2 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -609,11 +609,7 @@ void AVQ_cod_lpc_fx( Word16 i, l, pos; Word32 I; Word32 x1[8]; -#ifdef FIX_2294_CLANG_18_WARNINGS_ENC UWord16 I16 = 0; -#else - UWord16 I16; -#endif /* quantize all subvector using estimated gain */ diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 76f90c260..331817147 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1132,11 +1132,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { Word16 Q; -#ifdef FIX_2294_CLANG_18_WARNINGS_ENC Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, L_subframe, 16 ); -#else - Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, N_MAX + L_MDCT_OVLP_MAX, 16 ); -#endif Q = add( q_mdstWin, 16 ); move16(); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 206a3e25c..7ad9cfcc4 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -116,9 +116,7 @@ ivas_error ivas_core_enc_fx( { set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET ); set16_fx( old_syn_12k8_16k_fx[i], 0, L_FRAME16k ); -#ifdef FIX_2294_CLANG_18_WARNINGS_ENC set16_fx( voice_factors_fx[i], 0, NB_SUBFR16k ); -#endif } push_wmops( "ivas_core_enc" ); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index ef7e3f83e..ca73c2752 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -340,14 +340,12 @@ ivas_error ivas_cpe_enc_fx( Word16 q_band_energies_LR; Word16 q_fr_bands[2], q_lf_E[2]; -#ifdef FIX_2294_CLANG_18_WARNINGS_ENC q_band_energies_LR = 0; q_lf_E[0] = 0; q_lf_E[1] = 0; move16(); move16(); move16(); -#endif IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx, &q_band_energies_LR, NULL, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ), -- GitLab From 01232dd2076fbfe950a3af61f9f6b7aba4e2886e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:18:33 +0100 Subject: [PATCH 11/26] [cleanup] accept REMOVE_CAM_FROM_IVAS --- lib_com/options.h | 1 - lib_enc/decision_matrix_enc_fx.c | 76 -------------- lib_enc/enc_prm_fx.c | 173 ------------------------------- lib_enc/evs_enc_fx.c | 4 - lib_enc/ivas_core_enc_fx.c | 7 -- lib_enc/prot_fx_enc.h | 11 -- 6 files changed, 272 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index fe4c2e092..7bd18d8f7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,6 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ #define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c index f73a524ce..0b51816dc 100644 --- a/lib_enc/decision_matrix_enc_fx.c +++ b/lib_enc/decision_matrix_enc_fx.c @@ -760,82 +760,6 @@ void signalling_enc_fx( void signaling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ) -#ifndef REMOVE_CAM_FROM_IVAS -{ - Word16 i; - Word16 sfr; - RF_ENC_HANDLE hRF = st->hRF; - - /* write partial copy into bitstream */ - IF( EQ_16( st->rf_mode, 1 ) ) - { - enc_prm_rf_ivas_fx( st, hRF->rf_indx_frametype[st->rf_fec_offset], st->rf_fec_offset ); - hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; /*Q0*/ - move16(); - } - - /* Shift the RF indices such that the partial copy associated with - (n-fec_offset)th frame is included in the bitstream in nth frame. */ - IF( hRF != NULL ) - { - FOR( i = st->rf_fec_offset; i >= 0; i-- ) - { - /* rf frame type */ - hRF->rf_indx_frametype[i + 1] = hRF->rf_indx_frametype[i]; - move16(); - /* rf target bits buffer */ - hRF->rf_targetbits_buff[i + 1] = hRF->rf_targetbits_buff[i]; - move16(); - /* lsf indx */ - hRF->rf_indx_lsf[i + 1][0] = hRF->rf_indx_lsf[i][0]; - hRF->rf_indx_lsf[i + 1][1] = hRF->rf_indx_lsf[i][1]; - hRF->rf_indx_lsf[i + 1][2] = hRF->rf_indx_lsf[i][2]; - move16(); - move16(); - move16(); - /* ES pred energy */ - hRF->rf_indx_EsPred[i + 1] = hRF->rf_indx_EsPred[i]; - move16(); - /* LTF mode, sfr params: pitch, fcb and gain */ - FOR( sfr = 0; sfr < st->nb_subfr; sfr++ ) - { - hRF->rf_indx_ltfMode[i + 1][sfr] = hRF->rf_indx_ltfMode[i][sfr]; - hRF->rf_indx_pitch[i + 1][sfr] = hRF->rf_indx_pitch[i][sfr]; - hRF->rf_indx_fcb[i + 1][sfr] = hRF->rf_indx_fcb[i][sfr]; - hRF->rf_indx_gain[i + 1][sfr] = hRF->rf_indx_gain[i][sfr]; - move16(); - move16(); - move16(); - move16(); - } - - /* shift the nelp indices */ - hRF->rf_indx_nelp_iG1[i + 1] = hRF->rf_indx_nelp_iG1[i]; - hRF->rf_indx_nelp_iG2[i + 1][0] = hRF->rf_indx_nelp_iG2[i][0]; - hRF->rf_indx_nelp_iG2[i + 1][1] = hRF->rf_indx_nelp_iG2[i][1]; - hRF->rf_indx_nelp_fid[i + 1] = hRF->rf_indx_nelp_fid[i]; - move16(); - move16(); - move16(); - move16(); - /* tbe gain Fr shift */ - hRF->rf_indx_tbeGainFr[i + 1] = hRF->rf_indx_tbeGainFr[i]; - hRF->rf_clas[i + 1] = hRF->rf_clas[i]; - hRF->rf_gain_tcx[i + 1] = hRF->rf_gain_tcx[i]; - hRF->rf_tcxltp_param[i + 1] = hRF->rf_tcxltp_param[i]; - move16(); - move16(); - move16(); - move16(); - } - } - return; -} - -void signalling_enc_rf_fx( - Encoder_State *st /* i : encoder state structure */ -) -#endif { Word16 i; Word16 sfr; diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index 74b27351a..dae4570cc 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -99,179 +99,6 @@ static void enc_prm_hm_ivas_fx( * * * encode RF parameters for ACELP and TCX partial copy * *-----------------------------------------------------------------*/ -#ifndef REMOVE_CAM_FROM_IVAS -void enc_prm_rf_ivas_fx( - Encoder_State *st, - const Word16 rf_frame_type, /* Q0 */ - const Word16 fec_offset /* Q0 */ -) -{ - Word16 sfr, nb_subfr, n, index; - Word16 ltp_mode, ltf_mode, gains_mode; - RF_ENC_HANDLE hRF = st->hRF; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - BSTR_ENC_HANDLE hBstr = st->hBstr; - - - nb_subfr = st->nb_subfr; /* Q0 */ - move16(); - /* partial copy bitstream writing */ - test(); - IF( GE_16( rf_frame_type, RF_TCXFD ) && LE_16( rf_frame_type, RF_TCXTD2 ) ) - { - /* TCX frames partial copy write */ - - /* LSF indices */ - IF( EQ_16( rf_frame_type, RF_TCXFD ) ) - { - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], lsf_numbits[0] ); /* VQ 1 */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], lsf_numbits[1] ); /* VQ 2 */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][2], lsf_numbits[2] ); /* VQ 3 */ - } - - /* classification */ - test(); - IF( EQ_16( hRF->rf_clas[fec_offset], UNVOICED_CLAS ) ) - { - index = 0; - move16(); - } - ELSE IF( ( EQ_16( hRF->rf_clas[fec_offset], VOICED_TRANSITION ) ) || ( EQ_16( hRF->rf_clas[fec_offset], UNVOICED_TRANSITION ) ) ) - { - index = 1; - move16(); - } - ELSE IF( EQ_16( hRF->rf_clas[fec_offset], VOICED_CLAS ) ) - { - index = 2; - move16(); - } - ELSE - { - index = 3; - move16(); - } - push_next_indice( hBstr, index, 2 ); - - IF( EQ_16( rf_frame_type, RF_TCXFD ) ) - { - /* TCX global gain = 7 bits */ - push_next_indice( hBstr, hRF->rf_gain_tcx[fec_offset], 7 ); - /*window info - 1 bit for long overlap - 2 if minimum or half overlap*/ - } - ELSE - { - /*gains adapt - gains inov*/ - - /*LPC on full rate -> excitation */ - /* pitch and gain */ - /* LTP data */ - test(); - test(); - IF( ( EQ_16( rf_frame_type, RF_TCXTD1 ) || EQ_16( rf_frame_type, RF_TCXTD2 ) ) && hTcxEnc->tcxltp != 0 ) - { - push_next_indice( hBstr, hRF->rf_tcxltp_param[fec_offset], 9 ); - } - } - } - ELSE IF( EQ_16( rf_frame_type, 7 ) ) /* NELP bitstream writing */ - { - /* LSF indices */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */ - - /* NELP gain indices */ - push_next_indice( hBstr, hRF->rf_indx_nelp_iG1[fec_offset], 5 ); - push_next_indice( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][0], 6 ); - push_next_indice( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][1], 6 ); - - /* NELP filter selection index */ - push_next_indice( hBstr, hRF->rf_indx_nelp_fid[fec_offset], 2 ); - - /* tbe gainFr */ - push_next_indice( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 5 ); - } - ELSE IF( GE_16( rf_frame_type, 4 ) ) /* rf_frame_type ALL_PRED: 4, NO_PRED: 5, GEN_PRED: 6 */ - { - /* LSF indices */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */ - push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */ - - /* ES pred */ - push_next_indice( hBstr, hRF->rf_indx_EsPred[fec_offset], 3 ); - - ltp_mode = ACELP_LTP_MODE[1][1][rf_frame_type]; - ltf_mode = ACELP_LTF_MODE[1][1][rf_frame_type]; - gains_mode = ACELP_GAINS_MODE[1][1][rf_frame_type]; - move16(); - move16(); - move16(); - /* Subframe parameters */ - FOR( sfr = 0; sfr < nb_subfr; sfr++ ) - { - /* Pitch lag (5, or 8 bits) */ - n = ACELP_LTP_BITS_SFR[ltp_mode][sfr]; - move16(); - IF( n != 0 ) - { - push_next_indice( hBstr, hRF->rf_indx_pitch[fec_offset][sfr], n ); - } - - /* Adaptive codebook filtering (1 bit) */ - IF( EQ_16( ltf_mode, 2 ) ) - { - push_next_indice( hBstr, hRF->rf_indx_ltfMode[fec_offset][sfr], 1 ); - } - - /*Innovative codebook*/ - test(); - test(); - test(); - IF( ( EQ_16( rf_frame_type, RF_NOPRED ) ) || - ( EQ_16( rf_frame_type, RF_GENPRED ) && - ( sfr == 0 || EQ_16( sfr, 2 ) ) ) ) - { - push_next_indice( hBstr, hRF->rf_indx_fcb[fec_offset][sfr], 7 ); - } - - /* Gains (5b, 6b or 7b / subfr) */ - test(); - IF( sfr == 0 || EQ_16( sfr, 2 ) ) - { - n = ACELP_GAINS_BITS[gains_mode]; - move16(); - push_next_indice( hBstr, hRF->rf_indx_gain[fec_offset][sfr], n ); - } - } - /* tbe gainFr */ - push_next_indice( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 2 ); - } - - /***************/ - /*IMPORTANT: The last three bits are always the rf_frame_type in the bitstream (for both acelp and tcx partial copy); - the rf_frame_type indicates the length of the partial copy payload at the decoder. - The 2 bits before the rf_frame_type contains the fec_offset */ - - /***************/ - /* write FEC offset just before the rf_frame_type */ - test(); - test(); - IF( EQ_16( fec_offset, 2 ) ) - { - push_next_indice( hBstr, 0, 2 ); - } - ELSE IF( EQ_16( fec_offset, 3 ) || EQ_16( fec_offset, 5 ) || EQ_16( fec_offset, 7 ) ) - { - push_next_indice( hBstr, shr( sub( fec_offset, 1 ), 1 ), 2 ); - } - - /* write RF frame type last in the bitstream */ - push_next_indice( hBstr, rf_frame_type, 3 ); -} -#endif void enc_prm_rf_fx( Encoder_State *st, diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 34abe9537..3d64f4eb0 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -535,15 +535,11 @@ ivas_error evs_enc_fx( * Channel-aware mode - write signaling information into the bitstream *---------------------------------------------------------------------*/ -#ifdef REMOVE_CAM_FROM_IVAS signaling_enc_rf_fx( st ); /*---------------------------------------------------------------------* * Updates *---------------------------------------------------------------------*/ -#else - signalling_enc_rf_fx( st ); -#endif #ifdef HARM_CORECODER_UPDT updt_enc_common_fx( st, Q_new ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 7ad9cfcc4..5f84252c1 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -866,13 +866,6 @@ ivas_error ivas_core_enc_fx( st->q_inp = q_inp[1]; move16(); -#ifndef REMOVE_CAM_FROM_IVAS - /*---------------------------------------------------------------------* - * Channel-aware mode - write signaling information into the bitstream - *---------------------------------------------------------------------*/ - - signaling_enc_rf_fx( st ); -#endif /*---------------------------------------------------------------------* * Common updates *---------------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 74343fd20..cbe995f22 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2644,12 +2644,6 @@ void enc_prm_rf_fx( const Word16 rf_frame_type, const Word16 fec_offset ); -#ifndef REMOVE_CAM_FROM_IVAS -void enc_prm_rf_ivas_fx( - Encoder_State *st, - const Word16 rf_frame_type, - const Word16 fec_offset ); -#endif void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, @@ -2850,11 +2844,6 @@ void signaling_enc_rf_fx( Encoder_State *st /* i : encoder state structure */ ); -#ifndef REMOVE_CAM_FROM_IVAS -void signalling_enc_rf_fx( - Encoder_State *st /* i : encoder state structure */ -); -#endif void IGFEncResetTCX10BitCounter_fx( const IGF_ENC_INSTANCE_HANDLE hInstance /**< in: | instance handle of IGF Encoder */ ); -- GitLab From c4bc44745ff42095941c8d1f5a70071c3b2033e9 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:20:16 +0100 Subject: [PATCH 12/26] [cleanup] accept OPT_BE_2311_HARM_GSC_GAIN --- lib_com/gs_gains_fx.c | 164 ------------------------------------------ lib_com/options.h | 1 - lib_com/prot_fx.h | 11 --- lib_dec/gs_dec_fx.c | 11 --- 4 files changed, 187 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 98b086e41..61e7144e8 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -967,164 +967,6 @@ Word16 gsc_gainQ_ivas_fx( return mean_4g_fx[0]; } #endif -#ifndef OPT_BE_2311_HARM_GSC_GAIN -/*==========================================================================*/ -/* FUNCTION : Word16 gsc_gaindec_fx() */ -/*--------------------------------------------------------------------------*/ -/* PURPOSE : Generic signal frequency band decoding and application */ -/*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) pvq_bits_fx : core used Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) core_fx : core used Q0 */ -/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */ -/*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) y_gainQ_fx : quantized gain per band */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ (Word16) : average frequency gain */ -/*==========================================================================*/ -Word16 gsc_gaindec_fx( /* o : average frequency gain */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 y_gainQ_fx[], /* o : quantized gain per band */ - const Word32 core_brate_fx, /* i : core used */ - Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth_fx /* i : input signal bandwidth */ -) -{ - Word16 idx_g_fx, i; - Word16 mean_4g_fx; - Word16 y_gain_tmp3_fx[MBANDS_GN]; - - test(); - test(); - IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && EQ_16( bwidth_fx, NB ) ) - { - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) ); - VDQ_vec_fx( &mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 ); - - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) ); - VDQ_vec_fx( y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 ); - - IF( LT_32( core_brate_fx, ACELP_9k60 ) ) - { - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 5 ) ); - VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3 ); - - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 4 ) ); - VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4 ); - } - ELSE - { - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) ); - VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3 ); - - idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 7 ) ); - VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 ); - } - test(); - IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) ) - { - /* Some energy is needed in high band for stat_noise_uv_enc - to be functional in inactive speech */ - y_gainQ_fx[10] = mean_fx( y_gainQ_fx + 6, 3 ); - move16(); - y_gainQ_fx[11] = mean_fx( y_gainQ_fx + 7, 3 ); - move16(); - y_gainQ_fx[12] = mean_fx( y_gainQ_fx + 8, 3 ); - move16(); - y_gainQ_fx[13] = mean_fx( y_gainQ_fx + 9, 3 ); - move16(); - y_gainQ_fx[14] = mean_fx( y_gainQ_fx + 10, 3 ); - move16(); - y_gainQ_fx[15] = mean_fx( y_gainQ_fx + 11, 3 ); - move16(); - } - ELSE - { - set16_fx( y_gainQ_fx + 10, 0, MBANDS_GN - 10 ); - } - } - ELSE - { - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); - - VDQ_vec_fx( &mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 ); - - IF( LE_32( core_brate_fx, ACELP_9k60 ) ) - { - /*--------------------------------------------------------------------------------------* - * UQ of the first 8 bands and half of the last 8 bands - *--------------------------------------------------------------------------------------*/ - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 ); - - /*----------------------------------------------------------------------* - * Interpolation of the last 4 Q bands to create bands 8-16 - * And scaling - *----------------------------------------------------------------------*/ - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - - VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 ); - - Copy( y_gainQ_fx + 8, y_gain_tmp3_fx, 4 ); - set16_fx( y_gainQ_fx + 12, 0, 4 ); - - fft_rel_fx( y_gainQ_fx + 8, 4, 2 ); - - y_gainQ_fx[15] = y_gainQ_fx[11]; - move16(); - y_gainQ_fx[11] = 0; - move16(); - ifft_rel_fx( y_gainQ_fx + 8, 8, 3 ); - FOR( i = 8; i < 16; i++ ) - { - y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ - move16(); - } - /*----------------------------------------------------------------------* - * Copy the true Q values in the specific bands - *----------------------------------------------------------------------*/ - y_gainQ_fx[8] = y_gain_tmp3_fx[0]; - move16(); - y_gainQ_fx[10] = y_gain_tmp3_fx[1]; - move16(); - y_gainQ_fx[12] = y_gain_tmp3_fx[2]; - move16(); - y_gainQ_fx[14] = y_gain_tmp3_fx[3]; - move16(); - } - ELSE - { - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 ); - VDQ_vec_fx( y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 ); - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4 ); - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); - VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4 ); - - idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 ); - VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4 ); - } - } - - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); - - return mean_4g_fx; -} -#endif /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ @@ -1147,12 +989,8 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai /* _ (Word16) : average frequency gain */ /*==========================================================================*/ -#ifndef OPT_BE_2311_HARM_GSC_GAIN -Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */ -#else /*! r: average frequency gain */ Word16 gsc_gaindec_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ const Word32 core_brate_fx, /* i : core used */ @@ -1325,13 +1163,11 @@ Word16 gsc_gaindec_fx( } #ifndef OPT_NBE_2311_HARM_GSC_GAIN -#ifdef OPT_BE_2311_HARM_GSC_GAIN IF( st_fx->element_mode == EVS_MONO ) { GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); } ELSE -#endif { /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); diff --git a/lib_com/options.h b/lib_com/options.h index 7bd18d8f7..a527e0dd5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define OPT_BE_2311_HARM_GSC_GAIN /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */ #define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1637d7baa..281b88faf 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1504,17 +1504,6 @@ Word16 gsc_gaindec_fx( const Word16 bwidth_fx /* i : i signal bandwidth */ ); -#ifndef OPT_BE_2311_HARM_GSC_GAIN -/*! r: average frequency gain */ -Word16 gsc_gaindec_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 y_gainQ_fx[], /* o : quantized gain per band */ - const Word32 core_brate_fx, /* i : core used */ - Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth_fx /* i : input signal bandwidth */ -); -#endif #ifndef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 05b111fbe..a314bb232 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -667,18 +667,7 @@ void gsc_dec_fx( i--; } -#ifndef OPT_BE_2311_HARM_GSC_GAIN - 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 - { - 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 */ - } -#else 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 */ -#endif st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); -- GitLab From 594a1deb7c8930147169ab5a16c6429032fc1bab Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:21:03 +0100 Subject: [PATCH 13/26] [cleanup] accept HARM_CORECODER_UPDT --- lib_com/options.h | 1 - lib_com/prot_fx.h | 30 -- lib_dec/amr_wb_dec_fx.c | 4 - lib_dec/evs_dec_fx.c | 8 - lib_dec/ivas_core_dec_fx.c | 4 - lib_dec/ivas_mct_dec_fx.c | 4 - lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 - lib_dec/updt_dec_fx.c | 390 ------------------------- lib_enc/amr_wb_enc_fx.c | 4 - lib_enc/core_enc_updt_fx.c | 57 ---- lib_enc/evs_enc_fx.c | 4 - lib_enc/ivas_core_enc_fx.c | 4 - lib_enc/ivas_mct_enc_fx.c | 4 - lib_enc/long_enr_fx.c | 15 - lib_enc/prot_fx_enc.h | 3 - lib_enc/updt_enc_fx.c | 229 --------------- 16 files changed, 765 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a527e0dd5..7d73f2d34 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define HARM_CORECODER_UPDT /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */ #define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ #define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 281b88faf..b83e22afa 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5282,15 +5282,6 @@ Word32 sign_l( const Word32 x /* i : input value of x */ ); -#ifndef HARM_CORECODER_UPDT -void ivas_updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word32 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ -); -#endif /* Random generator with Gaussian distribution with mean 0 and std 1 */ Word32 rand_gauss( Word16 *seed ); @@ -7754,23 +7745,12 @@ void updt_IO_switch_dec_fx( Decoder_State *st_fx /* o : Decoder static variables structure */ ); -#ifndef HARM_CORECODER_UPDT -void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ - const Word16 Qpost /* i : Synthesis Q value */ -); -#endif void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ -#ifdef HARM_CORECODER_UPDT const Word16 *synth16, /* i : decoded synthesis Qpostd */ const Word32 *synth, /* i : decoded synthesis Qpostd */ -#else - const Word16 *synth, /* i : decoded synthesis */ -#endif const Word16 Qpostd /* i : Synthesis Q value */ ); @@ -10437,16 +10417,6 @@ void swb_pre_proc_ivas_fx( CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ ); -#ifndef HARM_CORECODER_UPDT -void core_encode_update_ivas_fx( - Encoder_State *st /* i/o: Encoder state structure */ -); - -void updt_enc_common_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Q_new /* i : CUrrent frame scaling */ -); -#endif /* o : Q(2x - 31 - gb) */ Word32 sum2_f_32_fx( const Word32 *vec, /* i : input vector, Qx */ diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index db508ec27..f05299be6 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -997,11 +997,7 @@ ivas_error amr_wb_dec_fx( st_fx->last_flag_cna = flag_cna; move16(); -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( st_fx, -1, -1, NULL, NULL, 0 ); -#else - updt_dec_common_fx( st_fx, -1, -1, NULL, 0 ); -#endif /*----------------------------------------------------------------* * Overlap of ACELP synthesis with old MDCT memory diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 8a227b191..e7b378a6d 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -1387,11 +1387,7 @@ ivas_error evs_dec_fx( move16(); } -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( st_fx, -1, concealWholeFrameTmp, output_sp, NULL, Qpostd ); -#else - updt_dec_common_fx( st_fx, -1, concealWholeFrameTmp, output_sp, Qpostd ); -#endif } ELSE { @@ -1401,11 +1397,7 @@ ivas_error evs_dec_fx( move16(); } -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( st_fx, hq_core_type, concealWholeFrameTmp, output_sp, NULL, Qpostd ); -#else - updt_dec_common_fx( st_fx, hq_core_type, concealWholeFrameTmp, output_sp, Qpostd ); -#endif } pop_wmops(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 9331f95f9..efd629036 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1525,11 +1525,7 @@ ivas_error ivas_core_dec_fx( save_synthesis_hq_fec_fx( st, NULL, output_fx_loc, output_frame, 0, hCPE ); /* Updates */ -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, NULL, output_32_fx[n], Q11 ); -#else - ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_32_fx[n], Q11 ); -#endif Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( exp_max ) ); // Q0 diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 5e2264916..d3a4b7f74 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -385,11 +385,7 @@ ivas_error ivas_mct_dec_fx( save_synthesis_hq_fec_fx( sts[n], NULL, output_fx_, output_frame, 0, hCPE ); /* CoreCoder common updates */ -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, NULL, output_fx[( cpe_id * CPE_CHANNELS ) + n], Q11 ); -#else - ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[( cpe_id * CPE_CHANNELS ) + n], 11 ); -#endif } /* n_channels loop */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 18f94bc9f..0f18a6eab 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1467,11 +1467,7 @@ void ivas_sba_dirac_stereo_dec_fx( stereo_dft_dec_core_switching_fx( hCPE, output[0] /*hSCE->save_output*/, hSCE->save_synth_fx, hSCE->save_hb_synth_fx, DFT, output_frame, 0, dtx_flag, &q, &q_dft[0] ); /* do updates here after skipping this in SCE decoder (needs to be done after core switching) */ -#ifdef HARM_CORECODER_UPDT updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, NULL, hSCE->save_synth_fx, q ); -#else - ivas_updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, hSCE->save_synth_fx, q ); -#endif q_synth = sub( getScaleFactor32( tmp_synth, hSCE->hCoreCoder[0]->L_frame ), 10 ); scale_sig32( tmp_synth, hSCE->hCoreCoder[0]->L_frame, q_synth ); /*hSCE->q_save_synth_fx + q_synth*/ diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 7f42e6b69..7489e9278 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -396,29 +396,21 @@ void updt_IO_switch_dec_fx( * Updates for BW switching *-------------------------------------------------------------------*/ -#ifdef HARM_CORECODER_UPDT static void updt_bw_switching_fx( -#else -void updt_bw_switching_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *synth, /* i : synthesis signal Qpost */ -#ifdef HARM_CORECODER_UPDT const Word32 *synth32, /* i : synthesis signal32 Qpost */ -#endif const Word16 Qpost /* i : Synthesis Q value */ ) { test(); IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) { -#ifdef HARM_CORECODER_UPDT IF( st_fx->element_mode != EVS_MONO ) { st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth32, Qpost, L_FRAME32k ); } ELSE -#endif { st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); // Q27 - 16 = Q11 } @@ -466,354 +458,6 @@ void updt_bw_switching_fx( * * Common updates for MODE1 and MODE2 *-------------------------------------------------------------------*/ -#ifndef HARM_CORECODER_UPDT -void updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth, /* i : decoded synthesis Qpostd */ - const Word16 Qpostd /* i : Synthesis Q value */ - -) -{ - Word16 i; - Word32 L_tmp; - - TCX_DEC_HANDLE hTcxDec; - hTcxDec = st_fx->hTcxDec; - - st_fx->last_codec_mode = st_fx->codec_mode; - move16(); - st_fx->last_extl = st_fx->extl; - move16(); - st_fx->last_L_frame = st_fx->L_frame; - move16(); - - st_fx->prev_old_bfi = st_fx->prev_bfi; - move16(); - st_fx->prev_bfi = st_fx->bfi; - move16(); - if ( NE_16( st_fx->core, AMR_WB_CORE ) ) - { - st_fx->old_bfi_cnt = st_fx->nbLostCmpt; - move16(); - } - move16(); - st_fx->last_con_tcx = st_fx->con_tcx; - move16(); - st_fx->con_tcx = 0; - - move16(); - if ( st_fx->hHQ_nbfec != NULL ) - { - st_fx->hHQ_nbfec->prev_last_core = st_fx->last_core; - } - if ( st_fx->hTcxDec != NULL ) - { - hTcxDec->tcxConceal_recalc_exc = 0; - move16(); - } - test(); - test(); - IF( ( GE_16( st_fx->rf_frame_type, RF_TCXFD ) && LE_16( st_fx->rf_frame_type, RF_TCXTD2 ) && st_fx->use_partial_copy && st_fx->bfi ) || !st_fx->bfi ) - { - test(); - test(); - test(); - test(); - if ( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL ) - { - hTcxDec->tcxConceal_recalc_exc = 1; - move16(); - } - st_fx->last_good = st_fx->clas_dec; - move16(); - } - IF( st_fx->use_partial_copy ) - { - st_fx->prev_rf_frame_type = st_fx->rf_frame_type; - move16(); - } - ELSE - { - st_fx->prev_rf_frame_type = INACTIVE; - move16(); - } - - if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( NE_16( st_fx->bfi, 1 ) || st_fx->use_partial_copy != 0 ) ) - { - st_fx->rf_flag_last = st_fx->rf_flag; - move16(); - } - - IF( EQ_16( st_fx->codec_mode, MODE1 ) ) - { - test(); - if ( !st_fx->bfi && ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) ) - { - move16(); - st_fx->last_active_brate = st_fx->total_brate; - } - - move16(); - move16(); - st_fx->last_core = st_fx->core; - if ( st_fx->hHQ_core != NULL ) - { - st_fx->hHQ_core->last_hq_core_type = hq_core_type_fx; - } - } - ELSE IF( EQ_16( st_fx->codec_mode, MODE2 ) ) - { - test(); - if ( ( !st_fx->bfi ) && ( st_fx->last_is_cng == 0 ) ) - { - move16(); - st_fx->last_active_brate = st_fx->total_brate; - } - /* INFO: moved from update_decoder_LPD_cng() */ - if ( NE_16( st_fx->m_frame_type, ACTIVE_FRAME ) ) - { - move16(); - st_fx->last_is_cng = 1; - } - - - if ( !st_fx->bfi ) - { - st_fx->last_core = st_fx->core; - } - move16(); - move16(); - st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ - } - move16(); - st_fx->last_core_brate = st_fx->core_brate; - - /* save synthesis for core switching */ - test(); - IF( EQ_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->core, AMR_WB_CORE ) ) - { - Copy_Scale_sig( synth + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec ); - } - test(); - test(); - test(); - IF( ( ( LE_32( st_fx->core_brate, SID_2k40 ) ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && EQ_16( st_fx->codec_mode, MODE2 ) ) ) - - { - /* reset LP memories */ - set16_fx( st_fx->mem_MA_fx, 0, M ); - IF( EQ_32( st_fx->sr_core, INT_FS_16k ) ) - { - Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); - } - ELSE - { - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - } - } - IF( EQ_16( st_fx->codec_mode, MODE2 ) ) - { - test(); - IF( EQ_16( st_fx->use_partial_copy, 1 ) && EQ_16( st_fx->rf_frame_type, RF_NELP ) ) - { - st_fx->last_nelp_mode_dec = 1; - move16(); - } - ELSE - { - st_fx->last_nelp_mode_dec = 0; - move16(); - } - } - - st_fx->prev_use_partial_copy = st_fx->use_partial_copy; - move16(); - - st_fx->prev_tilt_code_dec_fx = 0; - move16(); - - st_fx->prev_Q_exc = st_fx->Q_exc; - move16(); - - L_tmp = L_mult( st_fx->tilt_code_dec_fx[0], 4096 ); - FOR( i = 1; i < NB_SUBFR; i++ ) - { - L_tmp = L_mac( L_tmp, st_fx->tilt_code_dec_fx[i], 4096 ); - } - st_fx->prev_tilt_code_dec_fx = round_fx( L_tmp ); - - IF( EQ_16( st_fx->core, HQ_CORE ) ) - { - st_fx->prev_coder_type = GENERIC; - move16(); - } - ELSE IF( NE_16( st_fx->core, AMR_WB_CORE ) ) - { - st_fx->prev_coder_type = st_fx->coder_type; - move16(); - } - - test(); - IF( ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) && EQ_16( st_fx->first_CNG, 1 ) && st_fx->hTdCngDec != NULL ) - { - if ( GE_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) - { - st_fx->hTdCngDec->act_cnt = 0; - move16(); - } - - st_fx->hTdCngDec->act_cnt = add( st_fx->hTdCngDec->act_cnt, 1 ); - - test(); - if ( ( EQ_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) && ( st_fx->hTdCngDec->ho_hist_size > 0 ) ) - { - st_fx->hTdCngDec->ho_hist_size = sub( st_fx->hTdCngDec->ho_hist_size, 1 ); - } - - st_fx->hTdCngDec->act_cnt2 = add( st_fx->hTdCngDec->act_cnt2, 1 ); - if ( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) - { - st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD; - move16(); - } - } - - test(); - test(); - if ( LE_32( st_fx->core_brate, SID_2k40 ) && st_fx->first_CNG == 0 && ( EQ_16( st_fx->cng_type, LP_CNG ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) - { - st_fx->first_CNG = 1; - move16(); - } - - /* update bandwidth switching parameters */ - st_fx->last_flag_cna = st_fx->flag_cna; - move16(); - if ( st_fx->hFdCngDec != NULL ) - { - st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type; - move16(); - } - - if ( GT_16( st_fx->element_mode, EVS_MONO ) ) - { - st_fx->m_old_frame_type = st_fx->m_frame_type; - move16(); - } - test(); - test(); - /* update bandwidth switching parameters */ - IF( EQ_16( st_fx->core, AMR_WB_CORE ) ) - { - st_fx->last_bwidth = WB; - - st_fx->prev_bws_cnt = 0; - st_fx->bws_cnt = 0; - st_fx->bws_cnt1 = 0; - move16(); - move16(); - move16(); - move16(); - } - ELSE IF( EQ_16( st_fx->codec_mode, MODE1 ) && ( ( GT_32( st_fx->core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, EVS_MONO ) ) ) ) - { - updt_bw_switching_fx( st_fx, synth, Qpostd ); - } - ELSE - { - st_fx->last_bwidth = st_fx->bwidth; - st_fx->prev_bws_cnt = st_fx->bws_cnt; - move32(); - move16(); - } - - /* synchronisation of CNG seeds*/ - test(); - test(); - test(); - test(); - IF( st_fx->hTdCngDec != NULL && ( st_fx->bfi || ( NE_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_32( st_fx->core_brate, SID_2k40 ) ) ) && NE_16( st_fx->core, AMR_WB_CORE ) ) - { - Random( &( st_fx->hTdCngDec->cng_seed ) ); - Random( &( st_fx->hTdCngDec->cng_ener_seed ) ); - } - - test(); - test(); - test(); - IF( st_fx->hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) ) - { - /* update the parameters used in waveform adjustment */ - concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); - } - - st_fx->last_total_brate_ber = st_fx->total_brate; - move32(); - IF( st_fx->bfi == 0 ) - { - st_fx->last_total_brate = st_fx->total_brate; - st_fx->last_bits_frame_nominal = st_fx->bits_frame_nominal; - move32(); - move32(); - } - st_fx->last_low_rate_mode = st_fx->low_rate_mode; - move16(); - if ( LT_16( st_fx->ini_frame, MAX_FRAME_COUNTER ) ) - { - st_fx->ini_frame = add( st_fx->ini_frame, 1 ); - } - - return; -} - - -static void ivas_updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 *synth, /* i : fixed point synthesis signal Qpost */ - const Word16 Qpost ) -{ - test(); - IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) ) - { - st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ); - } - - st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q - move32(); - st_fx->prev_enerLL_fx = st_fx->enerLL_fx; // enerLL_fx_Q - move32(); - st_fx->last_bwidth = st_fx->bwidth; - move32(); - - IF( EQ_16( st_fx->core, ACELP_CORE ) ) - { - st_fx->last_inner_frame = L_FRAME32k; - move16(); - test(); - if ( EQ_16( st_fx->bwidth, WB ) && ( st_fx->bws_cnt == 0 ) ) - { - st_fx->last_inner_frame = L_FRAME16k; - move16(); - } - } - ELSE - { - test(); - test(); - test(); - IF( !( GE_16( st_fx->last_inner_frame, L_FRAME16k ) && LE_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && st_fx->bws_cnt > 0 && LT_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) ) - { - st_fx->last_inner_frame = inner_frame_tbl[st_fx->bwidth]; - move16(); - } - } - st_fx->prev_bws_cnt = st_fx->bws_cnt; - move16(); - return; -} -#endif static Word32 sum_32_32_fx( const Word32 *x, const Word16 length ) // Qx { @@ -826,20 +470,12 @@ static Word32 sum_32_32_fx( const Word32 *x, const Word16 length ) // Qx return W_round64_L( sum ); } -#ifdef HARM_CORECODER_UPDT void updt_dec_common_fx( -#else -void ivas_updt_dec_common_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ -#ifdef HARM_CORECODER_UPDT const Word16 *synth16, /* i : decoded synthesis Qpostd */ const Word32 *synth, /* i : decoded synthesis Qpostd */ -#else - const Word32 *synth, /* i : decoded synthesis Qpostd */ -#endif const Word16 Qpostd /* i : Synthesis Q value */ ) @@ -916,11 +552,7 @@ void ivas_updt_dec_common_fx( test(); test(); -#ifdef HARM_CORECODER_UPDT if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( NE_16( st_fx->bfi, 1 ) || st_fx->use_partial_copy != 0 ) ) -#else - if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( st_fx->bfi != 0 || st_fx->use_partial_copy != 0 ) ) -#endif { st_fx->rf_flag_last = st_fx->rf_flag; move16(); @@ -937,7 +569,6 @@ void ivas_updt_dec_common_fx( st_fx->last_active_brate = st_fx->total_brate; } -#ifdef HARM_CORECODER_UPDT IF( st_fx->element_mode == EVS_MONO ) { st_fx->last_core = st_fx->core; @@ -954,15 +585,6 @@ void ivas_updt_dec_common_fx( st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ move16(); } -#else - move16(); - move16(); - if ( !st_fx->bfi || st_fx->element_mode == EVS_MONO ) - { - st_fx->last_core = st_fx->core; - } - st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */ -#endif if ( st_fx->hHQ_core != NULL ) { @@ -1000,11 +622,7 @@ void ivas_updt_dec_common_fx( test(); IF( EQ_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->core, AMR_WB_CORE ) ) { -#ifdef HARM_CORECODER_UPDT Copy_Scale_sig( synth16 + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec ); -#else - Copy_Scale_sig_32_16( synth + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec ); -#endif } test(); @@ -1113,12 +731,10 @@ void ivas_updt_dec_common_fx( st_fx->hTdCngDec->ho_hist_size = sub( st_fx->hTdCngDec->ho_hist_size, 1 ); } -#ifdef HARM_CORECODER_UPDT if ( EQ_16( st_fx->element_mode, EVS_MONO ) ) { st_fx->hTdCngDec->act_cnt2 = add( st_fx->hTdCngDec->act_cnt2, 1 ); } -#endif if ( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) { st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD; @@ -1169,11 +785,7 @@ void ivas_updt_dec_common_fx( } ELSE IF( EQ_16( st_fx->codec_mode, MODE1 ) && ( ( GT_32( st_fx->core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, EVS_MONO ) ) ) ) { -#ifdef HARM_CORECODER_UPDT updt_bw_switching_fx( st_fx, synth16, synth, Qpostd ); -#else - ivas_updt_bw_switching_fx( st_fx, synth, Qpostd ); -#endif } ELSE { @@ -1200,13 +812,11 @@ void ivas_updt_dec_common_fx( IF( hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) ) { /* update the parameters used in waveform adjustment */ -#ifdef HARM_CORECODER_UPDT IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { concealment_update2_x( (const Word16 *) synth16, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); } ELSE -#endif { concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX ); } diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index c1865862f..f6dbe7938 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -595,11 +595,7 @@ void amr_wb_enc_fx( updt_enc_fx( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf ); /* update main codec parameters */ -#ifdef HARM_CORECODER_UPDT updt_enc_common_fx( st, Q_new ); -#else - updt_enc_common_fx( st, Etot, Q_new ); -#endif #ifdef DEBUG_MODE_INFO dbgwrite( &st->codec_mode, sizeof( short ), 1, input_frame, "res/codec" ); diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c index 9ec6eda6f..f6aba6f61 100644 --- a/lib_enc/core_enc_updt_fx.c +++ b/lib_enc/core_enc_updt_fx.c @@ -11,57 +11,6 @@ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -#ifndef HARM_CORECODER_UPDT -void core_encode_update_fx( Encoder_State *st ) -{ - Word16 n; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /*--------------------------------------------------------------* - * Update Buffers - *---------------------------------------------------------------*/ - - /* Update Input Signal Buffers */ - - n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); - - Copy( st->buf_speech_enc + st->L_frame, st->buf_speech_enc, n ); - Copy( st->buf_speech_enc_pe + st->L_frame, st->buf_speech_enc_pe, n ); - - - IF( !st->tcxonly ) - { - n = add( st->L_frame, shr( st->L_frame, 2 ) ); - Copy( st->buf_wspeech_enc + st->L_frame, st->buf_wspeech_enc, n ); - } - - - IF( hTcxEnc != NULL ) - { - IF( ( st->core == ACELP_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core, AMR_WB_CORE ) ) - { - Copy( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame ); - } - } - n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); - Copy( st->buf_synth + st->L_frame, st->buf_synth, add( st->L_frame, L_SUBFR ) ); - if ( hTcxEnc != NULL ) - { - Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n ); - } - /* Update previous mode */ - - test(); - test(); - test(); - IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && EQ_16( st->codec_mode, MODE2 ) ) ) - { - /* reset LP memories */ - set16_fx( st->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - } -} -#endif /*-------------------------------------------------------------------* * core_encode_update_cng_fx() @@ -202,11 +151,7 @@ void core_encode_update_cng_fx( * Common updates of buffers *-------------------------------------------------------------------*/ -#ifdef HARM_CORECODER_UPDT void core_encode_update_fx( -#else -void core_encode_update_ivas_fx( -#endif Encoder_State *st /* i/o: Encoder state structure */ ) { @@ -232,13 +177,11 @@ void core_encode_update_ivas_fx( test(); IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) ) { -#ifdef HARM_CORECODER_UPDT IF( st->element_mode == EVS_MONO ) { Copy( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame ); } ELSE -#endif { Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e) diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 3d64f4eb0..5fd5a8963 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -541,11 +541,7 @@ ivas_error evs_enc_fx( * Updates *---------------------------------------------------------------------*/ -#ifdef HARM_CORECODER_UPDT updt_enc_common_fx( st, Q_new ); -#else - updt_enc_common_fx( st, Etot, Q_new ); -#endif if ( EQ_16( st->mdct_sw, MODE1 ) ) { diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 5f84252c1..cd1e34af4 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -872,11 +872,7 @@ ivas_error ivas_core_enc_fx( IF( !MCT_flag ) /* for MCT do this later, otherwise there can be a problem because TCX quant happens later and might get the wrong last_core on a bit rate switch */ { -#ifdef HARM_CORECODER_UPDT updt_enc_common_fx( st, Q_new[n] ); -#else - updt_enc_common_ivas_fx( st, Q_new[n] ); -#endif } IF( st->hBWE_FD != NULL ) diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 58552eb7f..091b8c6b2 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -484,11 +484,7 @@ ivas_error ivas_mct_enc_fx( move16(); /* common encoder updates */ -#ifdef HARM_CORECODER_UPDT updt_enc_common_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] ); -#else - updt_enc_common_ivas_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] ); -#endif } } diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 45660c619..61354bf87 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -145,11 +145,6 @@ void ivas_long_enr_fx( move32(); } -#ifndef HARM_CORECODER_UPDT - /*-----------------------------------------------------------------* - * Initialize parameters for energy tracking and signal dynamics - *-----------------------------------------------------------------*/ -#endif return; } @@ -170,9 +165,6 @@ void long_enr_fx( * and total active speech energy *-----------------------------------------------------------------*/ -#ifndef HARM_CORECODER_UPDT - { -#endif IF( LT_16( st_fx->ini_frame, 4 ) ) { st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */ @@ -215,15 +207,8 @@ void long_enr_fx( } } -#ifdef HARM_CORECODER_UPDT /* Update */ st_fx->hNoiseEst->Etot_last_fx = Etot; -#else -} -/*-----------------------------------------------------------------* - * Initialize parameters for energy tracking and signal dynamics - *-----------------------------------------------------------------*/ -#endif return; } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index cbe995f22..5f773c341 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -828,9 +828,6 @@ void sc_vbr_enc_init_fx( void updt_enc_common_fx( Encoder_State *st, /* i/o: encoder state structure */ -#ifndef HARM_CORECODER_UPDT - const Word16 Etot, /* i : total energy */ -#endif const Word16 Q_new /* i : CUrrent frame scaling */ ); diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 95026eead..d0826c429 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -306,231 +306,6 @@ void updt_IO_switch_enc_fx( *-------------------------------------------------------------------*/ void updt_enc_common_fx( -#ifndef HARM_CORECODER_UPDT - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Etot, /* i : total energy */ - const Word16 Q_new /* i : CUrrent frame scaling */ -) -{ - /*---------------------------------------------------------------------* - * Updates - main main codec parameters - *---------------------------------------------------------------------*/ - - st->last_sr_core = st->sr_core; - move32(); - st->last_codec_mode = st->codec_mode; - move16(); - st->last_L_frame = st->L_frame; - move16(); - st->last_core = st->core; - move16(); - - st->last_core_brate = st->core_brate; - move32(); - st->last_total_brate = st->total_brate; - move32(); - st->last_extl = st->extl; - move16(); - st->last_input_bwidth = st->input_bwidth; - move16(); - st->last_bwidth = st->bwidth; - move16(); - IF( GT_16( st->element_mode, EVS_MONO ) ) - { - st->hNoiseEst->Etot_last_32fx = L_deposit_h( Etot ); - } - ELSE - { - st->hNoiseEst->Etot_last_fx = Etot; - } - move16(); - st->last_coder_type_raw = st->coder_type_raw; - move16(); - - st->prev_Q_new = Q_new; - move16(); - - test(); - IF( GT_32( st->core_brate, SID_2k40 ) && st->hDtxEnc != NULL ) - { - st->hDtxEnc->last_active_brate = st->total_brate; - move32(); - } - - IF( st->hBWE_TD != NULL ) - { - st->hBWE_TD->prev_coder_type = st->coder_type; - move16(); - IF( EQ_16( st->core, HQ_CORE ) ) - { - /* in the HQ core, coder_type is not used so it could have been set to anything */ - st->hBWE_TD->prev_coder_type = GENERIC; - move16(); - } - } - - test(); - IF( st->Opt_DTX_ON && st->hTdCngEnc != NULL ) - { - IF( GT_32( st->core_brate, SID_2k40 ) ) - { - IF( EQ_16( st->hDtxEnc->first_CNG, 1 ) ) - { - IF( GE_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) ) - { - st->hTdCngEnc->act_cnt = 0; - move16(); - } - st->hTdCngEnc->act_cnt = add( st->hTdCngEnc->act_cnt, 1 ); - move16(); - - test(); - IF( EQ_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) && st->hTdCngEnc->ho_hist_size > 0 ) - { - st->hTdCngEnc->ho_hist_size = sub( st->hTdCngEnc->ho_hist_size, 1 ); - move16(); - } - } - - test(); - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->hDtxEnc->first_CNG, 1 ) ) - { - st->hTdCngEnc->act_cnt2 = add( st->hTdCngEnc->act_cnt2, 1 ); - st->hTdCngEnc->act_cnt2 = s_min( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ); - move16(); - move16(); - - test(); - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) - { - } - } - } - - test(); - test(); - test(); - IF( ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) && st->hDtxEnc->first_CNG == 0 && EQ_16( st->cng_type, LP_CNG ) ) - { - st->hDtxEnc->first_CNG = 1; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Increase the counter of initialization frames - * Limit the max number of init. frames - *-----------------------------------------------------------------*/ - - if ( LT_16( st->ini_frame, MAX_FRAME_COUNTER ) ) - { - st->ini_frame = add( st->ini_frame, 1 ); - move16(); - } - - /* synchronisation of CNG seeds */ - test(); - test(); - test(); - IF( st->hTdCngEnc != NULL && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) && NE_16( st->core, AMR_WB_CORE ) ) - { - Random( &( st->hTdCngEnc->cng_seed ) ); - Random( &( st->hTdCngEnc->cng_ener_seed ) ); - } - - /*---------------------------------------------------------------------* - * Updates - MODE2 - *---------------------------------------------------------------------*/ - - IF( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->mdct_sw, MODE2 ) ) - { - st->codec_mode = MODE2; - move16(); - - st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 ); - move32(); - - // st->L_frame = extract_l(Mult_32_16(st->sr_core, INV_FRAME_PER_SEC_Q15)); /*(int16_t)(st->sr_core / FRAMES_PER_SEC);*/ - - IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) - { - st->preemph_fac = PREEMPH_FAC; - st->gamma = GAMMA1; - st->L_frame = L_FRAME; - move16(); - move16(); - move16(); - } - ELSE - { - st->preemph_fac = PREEMPH_FAC_16k; - st->gamma = GAMMA16k; - st->L_frame = L_FRAME16k; - move16(); - move16(); - move16(); - } - - st->igf = getIgfPresent_fx( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode ); - move16(); - } - - /* update FER clas */ - IF( NE_16( st->core, AMR_WB_CORE ) ) - { - st->last_clas = st->clas; - move16(); - } - - /* Update Core */ - core_encode_update_fx( st ); - - /*---------------------------------------------------------------------* - * RF mode updates - *---------------------------------------------------------------------*/ - - IF( st->rf_mode ) - { - IF( st->hSC_VBR != NULL ) - { - st->hSC_VBR->last_nelp_mode = 0; - move16(); - IF( EQ_16( st->hRF->rf_frame_type, RF_NELP ) ) - { - st->hSC_VBR->last_nelp_mode = 1; - move16(); - } - } - } - - st->rf_mode_last = st->rf_mode; - move16(); - - IF( st->Opt_RF_ON ) - { - st->L_frame = L_FRAME; - st->rf_mode = 1; - move16(); - move16(); - } - - /*---------------------------------------------------------------------* - * Other updates - *---------------------------------------------------------------------*/ - - test(); - IF( GT_16( st->element_mode, EVS_MONO ) && st->hTcxEnc != NULL ) - { - } - return; -} - -void updt_enc_common_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 Q_new /* i : CUrrent frame scaling */ ) @@ -708,11 +483,7 @@ void updt_enc_common_ivas_fx( } /* Update Core */ -#ifdef HARM_CORECODER_UPDT core_encode_update_fx( st ); -#else - core_encode_update_ivas_fx( st ); -#endif /*---------------------------------------------------------------------* * RF mode updates -- GitLab From ff8c5ae99ccaaa31955e38df5bd3be4b722ef7c3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:22:21 +0100 Subject: [PATCH 14/26] [cleanup] accept HARM_CORE_SW --- lib_com/ivas_prot_fx.h | 12 - lib_com/options.h | 1 - lib_com/prot_fx.h | 64 -- lib_dec/acelp_core_switch_dec_fx.c | 252 ----- lib_dec/amr_wb_dec_fx.c | 4 - lib_dec/core_switching_dec_fx.c | 1480 +--------------------------- lib_dec/evs_dec_fx.c | 12 - lib_dec/ivas_core_dec_fx.c | 40 - lib_dec/ivas_mct_dec_fx.c | 4 - lib_dec/swb_tbe_dec_fx.c | 6 - lib_enc/amr_wb_enc_fx.c | 4 - lib_enc/core_switching_enc_fx.c | 572 ----------- lib_enc/evs_enc_fx.c | 4 - lib_enc/ivas_core_enc_fx.c | 8 - lib_enc/prot_fx_enc.h | 4 - 15 files changed, 51 insertions(+), 2416 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7962a009b..2f280d47d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2961,18 +2961,6 @@ void stereo_icBWE_preproc_fx( Word16 shb_speech_nonref[], /* o : SHB speech non-ref channel */ Word16 q_shb_speech_nonref /* i : Q SHB speech non-ref channel */ ); -#ifndef HARM_CORE_SW - -void core_switching_pre_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz */ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz */ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ - const Word16 active_cnt, /* i : active frame counter */ - const Word16 last_element_mode /* i : last_element_mode */ -); -#endif Word16 ivas_acelp_tcx20_switching_fx( Encoder_State *st, /* i/o: encoder state structure */ Word16 *inp_fx, /* i : new input signal */ diff --git a/lib_com/options.h b/lib_com/options.h index 7d73f2d34..ec24990e5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define HARM_CORE_SW /* VA: basop issue 2314: Remove duplicated code in the core switching */ #define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ #define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ #define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index b83e22afa..bde8b871d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7054,13 +7054,6 @@ ivas_error acelp_core_switch_dec_bfi_fx( const Word16 coder_type /* i : coder type */ ); -#ifndef HARM_CORE_SW -ivas_error acelp_core_switch_dec_bfi_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ -); -#endif void pred_lt4( const Word16 excI[], /* in : excitation buffer Q_exc*/ Word16 excO[], /* out: excitation buffer Q_exc*/ @@ -7652,26 +7645,14 @@ void hq_configure_bfi_fx( void bandwidth_switching_detect_fx( Decoder_State *st_fx /* i/o: encoder state structure */ ); -#ifndef HARM_CORE_SW - -void bandwidth_switching_detect_ivas_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -); -#endif void bw_switching_pre_proc_fx( -#ifdef HARM_CORE_SW Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 last_element_brate, /* i : last element bitrate */ const Word16 nchan_out, /* i : number of output channels */ const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ -#else - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ -#endif ); ivas_error core_switching_pre_dec_fx( -#ifdef HARM_CORE_SW Decoder_State *st, /* i/o: decoder state structure */ const Word16 output_frame, /* i : frame length */ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ @@ -7681,24 +7662,9 @@ ivas_error core_switching_pre_dec_fx( const Word16 Q_old_synthFB, Word16 *Q_olapBufferSynth, Word16 *Q_olapBufferSynth2 -#else - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ -#endif ); ivas_error core_switching_post_dec_fx( -#ifndef HARM_CORE_SW - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ -); - -ivas_error core_switching_post_dec_ivas_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ @@ -9420,15 +9386,6 @@ void stereo_dft_dec_open( const Word16 nchan_transport /* i : number of transport channels */ ); -#ifndef HARM_CORE_SW -void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ); -#endif UWord32 mvl2s_r( const Word32 x[], /* i : input vector */ const Word16 q, @@ -10237,11 +10194,7 @@ void ivas_swb_tbe_dec_fx( const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ -#ifdef HARM_CORE_SW const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ -#else - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ -#endif Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ Word16 *pitch_buf_fx, /* i : Q6 */ @@ -10288,18 +10241,6 @@ void wtda_fx32( const Word16 L /* i : length */ ); -#ifndef HARM_CORE_SW -ivas_error core_switching_pre_dec_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 output_frame, /* i : frame length */ - const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 last_element_mode, /* i : last_element_mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - Word16 Q_old_synthFB, - Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 ); -#endif void hp20_fx_32( Word32 signal_fx[], const Word16 lg, @@ -10765,11 +10706,6 @@ ivas_error IGF_Reconfig_fx( const Word16 rf_mode /* i : flag to signal the RF mode */ ); -#ifndef HARM_CORE_SW -void core_switching_post_enc_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ -); -#endif void residu_ivas_fx( const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ const Word16 a_exp, diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index d2353fd73..dd477874f 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -351,256 +351,8 @@ ivas_error acelp_core_switch_dec_fx( * * ACELP core decoder in the first ACELP->HQ switching frame in case of BAD frame *-------------------------------------------------------------------*/ -#ifndef HARM_CORE_SW -ivas_error acelp_core_switch_dec_bfi_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ -) -{ - Word16 old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */ - Word16 syn[L_FRAME16k]; /* synthesis signal buffer */ - Word16 lsf_new[M]; /* LSFs at the end of the frame */ - Word16 lsp_new[M]; /* LSPs at the end of the frame */ - Word16 Aq[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ - Word16 old_exc2[L_FRAME16k + L_EXC_MEM], *exc2; /* total excitation buffer */ - Word16 tmp_noise; /* Long term temporary noise energy */ - Word16 FEC_pitch; /* FEC pitch */ - Word16 old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ - Word16 *bwe_exc; /* Excitation for SWB TBE */ - Word16 tmp1[NBPSF_PIT_MAX]; - Word16 tmp2[M]; - Word16 tmp3; - Word16 tmp4[L_TRACK_HIST]; - Word16 tmp5[L_TRACK_HIST]; - Word16 tmp6[L_TRACK_HIST]; - Word16 tmp7; - Word32 tmp8; - Word16 voice_factors[NB_SUBFR16k]; - Word16 pitch_buf[NB_SUBFR16k]; - Word16 Q_exc; - Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI]; - Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX]; - Word16 i; - CLDFB_SCALE_FACTOR scaleFactor; - Word32 workBuffer[128 * 3]; - MUSIC_POSTFILT_HANDLE hMusicPF; - BPF_DEC_HANDLE hBPF; - ivas_error error; - - hMusicPF = st_fx->hMusicPF; - hBPF = st_fx->hBPF; - error = IVAS_ERR_OK; - move32(); - - FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH_BFI; i++ ) - { - set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer[i] = realBufferTmp[i]; - imagBuffer[i] = imagBufferTmp[i]; - } - - /*----------------------------------------------------------------* - * Initialization - *----------------------------------------------------------------*/ - Q_exc = st_fx->Q_exc; - move16(); - st_fx->bpf_off = 1; - move16(); - st_fx->clas_dec = st_fx->last_good; - move16(); - tmp_noise = 0; - move16(); - - Copy( st_fx->old_exc_fx, old_exc, L_EXC_MEM_DEC ); // Q_exc - exc = old_exc + L_EXC_MEM_DEC; - IF( st_fx->hWIDec != NULL ) - { - Copy( st_fx->hWIDec->old_exc2_fx, old_exc2, L_EXC_MEM ); - } - ELSE - { - set16_fx( old_exc2, 0, L_EXC_MEM ); - } - exc2 = old_exc2 + L_EXC_MEM; - IF( st_fx->hBWE_TD != NULL ) - { - Copy( st_fx->hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 ); // Q_exc - bwe_exc = old_bwe_exc + PIT16k_MAX * 2; - } - ELSE - { - bwe_exc = NULL; - } - - st_fx->GSC_noisy_speech = 0; - move16(); - st_fx->relax_prev_lsf_interp = 0; - move16(); - - /* SC-VBR */ - if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) ) - { - st_fx->nelp_mode_dec = 1; - move16(); - } - - Copy( st_fx->mem_AR_fx, tmp1, M ); - Copy( st_fx->mem_MA_fx, tmp2, M ); - - /* LSF estimation and A(z) calculation */ - lsf_dec_bfi( MODE1, lsf_new, 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, lsf_new, lsp_new ); - - Copy( tmp1, st_fx->mem_AR_fx, M ); - Copy( tmp2, st_fx->mem_MA_fx, M ); - - /*----------------------------------------------------------------* - * Excitation decoding - *----------------------------------------------------------------*/ - - IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) - { - Word16 gain_buf[NB_SUBFR16k]; - Scale_sig( exc - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0 - st_fx->Q_exc = 0; - move16(); - /* SC-VBR */ - decod_nelp_fx( st_fx, &tmp_noise, pitch_buf, exc, exc2, voice_factors, bwe_exc, &Q_exc, st_fx->bfi, gain_buf ); - FEC_pitch = pitch_buf[3]; - move16(); - Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &Q_exc, st_fx->Q_subfr, exc2, L_FRAME, coder_type ); - st_fx->Q_exc = Q_exc; - move16(); - } - ELSE - { - tmp1[0] = st_fx->bfi_pitch_fx; - move16(); - tmp1[1] = st_fx->bfi_pitch_frame; - move16(); - tmp1[2] = st_fx->lp_gainp_fx; - move16(); - tmp1[3] = st_fx->lp_gainc_fx; - move16(); - tmp1[4] = st_fx->upd_cnt; - move16(); - tmp1[5] = st_fx->seed; - move16(); - - /* calculation of excitation signal */ - FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc, exc2, syn /* dummy buffer */, pitch_buf, voice_factors, &FEC_pitch, bwe_exc, lsf_new, &Q_exc, &tmp_noise ); - Rescale_exc( NULL, exc, bwe_exc, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0, - &Q_exc, st_fx->Q_subfr, exc2, st_fx->L_frame, st_fx->last_coder_type ); - - st_fx->seed = tmp1[5]; - move16(); - st_fx->bfi_pitch_fx = tmp1[0]; - move16(); - st_fx->bfi_pitch_frame = tmp1[1]; - move16(); - st_fx->lp_gainp_fx = tmp1[2]; - move16(); - st_fx->lp_gainc_fx = tmp1[3]; - move16(); - st_fx->upd_cnt = tmp1[4]; - move16(); - } - - /*------------------------------------------------------------------* - * Synthesis - *-----------------------------------------------------------------*/ - - Rescale_mem( 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, 0, NULL ); - Copy( st_fx->mem_syn2_fx, tmp1, M ); - syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn ); - - tmp8 = st_fx->enr_old_fx; - move32(); - frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr( add( FEC_pitch, 32 ), 6 ), &tmp8, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); - - /*------------------------------------------------------------------* - * Perform fixed deemphasis through 1/(1 - g*z^-1) - *-----------------------------------------------------------------*/ - tmp1[0] = st_fx->mem_deemph_fx; - move16(); /*if in acelp_core_dec_fx deemph_fx is used*/ - /*tmp1 = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/ - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp1[0] ); /*Q0*/ - } - ELSE - { - deemph_fx( syn, PREEMPH_FAC_16k, L_FRAME16k, &tmp1[0] ); /*Q0*/ - } - - /*----------------------------------------------------------------* - * Bass post-filter - *----------------------------------------------------------------*/ - - st_fx->bpf_off = 1; - move16(); - Copy( hBPF->pst_old_syn_fx, tmp1, NBPSF_PIT_MAX ); - - tmp3 = st_fx->stab_fac_smooth_fx; - move16(); - Copy( hBPF->mem_mean_pit_fx, tmp4, L_TRACK_HIST ); - Copy( hBPF->Track_on_hist, tmp5, L_TRACK_HIST ); - Copy( hBPF->vibrato_hist, tmp6, L_TRACK_HIST ); - tmp7 = hBPF->psf_att_fx; - move16(); - - bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn, st_fx->L_frame, pitch_buf, - st_fx->bpf_off, st_fx->stab_fac_fx, &tmp3, coder_type, st_fx->Q_syn, old_exc /* tmp buffer*/ ); - - Copy( tmp1, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX ); - Copy( tmp4, hBPF->mem_mean_pit_fx, L_TRACK_HIST ); - Copy( tmp5, hBPF->Track_on_hist, L_TRACK_HIST ); - Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST ); - hBPF->psf_att_fx = tmp7; - move16(); - /*----------------------------------------------------------------* - * Resamping to the output sampling frequency - *----------------------------------------------------------------*/ - /* CLDFB analysis of the synthesis at internal sampling rate */ - IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbAna ) ), IVAS_ERR_OK ) ) - { - return error; - } - cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer ); - cldfb_restore_memory( st_fx->cldfbAna ); - - scaleFactor.hb_scale = scaleFactor.lb_scale; - move16(); - - /* CLDFB synthesis of the combined signal */ - IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) ) - { - return error; - } - cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, - negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer ); - - /* output to Q0 */ - Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); // Q0 - - cldfb_restore_memory( st_fx->cldfbSyn ); - - return error; -} -#endif -#ifdef HARM_CORE_SW ivas_error acelp_core_switch_dec_bfi_fx( -#else -ivas_error acelp_core_switch_dec_bfi_ivas_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 synth_out[], /* o : synthesis Q_syn */ const Word16 coder_type /* i : coder type */ @@ -768,9 +520,7 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( move16(); Rescale_mem( 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, 0, NULL ); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) -#endif { Scale_sig( st_fx->mem_syn_r, L_SYN_MEM, sub( st_fx->Q_syn, Prev_Q_syn_r ) ); // Q_syn } @@ -828,7 +578,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( * Resamping to the output sampling frequency *----------------------------------------------------------------*/ -#ifdef HARM_CORE_SW IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { CLDFB_SCALE_FACTOR scaleFactor; @@ -858,7 +607,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( cldfb_restore_memory( st_fx->cldfbSyn ); } ELSE -#endif { /* CLDFB analysis of the synthesis at internal sampling rate */ Qtmp = sub( 11, st_fx->Q_syn ); diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index f05299be6..3806f8c2a 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -172,11 +172,7 @@ ivas_error amr_wb_dec_fx( } /* Updates in case of EVS -> AMR-WB IO switching */ -#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index e55c64f7f..1454f8c41 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -11,7 +11,6 @@ #include "ivas_prot_fx.h" -#ifdef HARM_CORE_SW /*---------------------------------------------------------------------* * Local prototypes *---------------------------------------------------------------------*/ @@ -20,131 +19,6 @@ static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_fra static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); -#else -/*---------------------------------------------------------------------* - * bandwidth_switching_detect_fx() - * - * - *---------------------------------------------------------------------*/ - -static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp ); -static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); - -void bandwidth_switching_detect_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -) -{ - test(); - test(); - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ - st_fx->prev_bws_cnt = 0; - st_fx->bws_cnt = 0; - st_fx->bws_cnt1 = 0; - move16(); - move16(); - move16(); - - return; - } - /* update band-width switching counter */ - test(); - test(); - test(); - IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) - { - st_fx->bws_cnt1 = 0; - move16(); - } - ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) - { - st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); /* Q0 */ - move16(); - } - ELSE IF( st_fx->bws_cnt1 > 0 ) - { - IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 ); /* Q0 */ - move16(); - } - ELSE - { - st_fx->bws_cnt = 0; - move16(); - } - - IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt1 = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->bwidth, SWB ) ) - { - st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); /* Q0 */ - move16(); - } - ELSE - { - st_fx->bws_cnt1 = 0; - move16(); - } - } - } - - /* update band-width switching counter */ - test(); - test(); - test(); - IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) - { - st_fx->bws_cnt = 0; - move16(); - } - ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) ) - { - st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); /* Q0 */ - move16(); - } - ELSE IF( st_fx->bws_cnt > 0 ) - { - IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 ); /* Q0 */ - move16(); - } - ELSE - { - st_fx->bws_cnt1 = 0; - move16(); - } - - IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->bwidth, WB ) ) - { - st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt = 0; - move16(); - } - } - } - - return; -} -#endif /*---------------------------------------------------------------------* * Calc_freq_ener_fx() @@ -186,15 +60,10 @@ static Word32 Calc_freq_ener_fx( *---------------------------------------------------------------------*/ void bw_switching_pre_proc_fx( -#ifdef HARM_CORE_SW Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 last_element_brate, /* i : last element bitrate */ const Word16 nchan_out, /* i : number of output channels */ const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ -#else - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ -#endif ) { Word16 i; @@ -203,7 +72,6 @@ void bw_switching_pre_proc_fx( IF( st_fx->element_mode > EVS_MONO ) { -#ifdef HARM_CORE_SW test(); test(); test(); @@ -226,7 +94,6 @@ void bw_switching_pre_proc_fx( } return; -#endif } test(); @@ -262,972 +129,50 @@ void bw_switching_pre_proc_fx( L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ move32(); - } - ELSE - { - IF( st_fx->hHQ_core->old_is_transient[0] ) - { - L_tmp = L_deposit_l( 0 ); - FOR( i = 0; i < 32; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ - } - L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ - st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ - move32(); - L_tmp = L_deposit_l( 0 ); - FOR( ; i < 64; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ - } - L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ - st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ - move32(); - } - ELSE - { - L_tmp = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ - } - L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ - st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ - move32(); - L_tmp = L_deposit_l( 0 ); - FOR( ; i < L_FRAME; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ - } - L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ - st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ - move32(); - } - } - - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( st_fx->last_bwidth == 0 && LE_16( st_fx->extl, SWB_CNG ) ) - { - st_fx->prev_ener_shb_fx = 0; - move16(); - set16_fx( st_fx->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV ); - } - ELSE IF( ( ( st_fx->core == ACELP_CORE && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) ) - { - st_fx->attenu_fx = 3277; /* Q15 */ - move16(); - } - - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && !( EQ_16( st_fx->last_extl, WB_TBE ) || EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && GT_32( st_fx->core_brate, ACELP_8k00 ) ) ) - { - st_fx->prev_fractive = 0; - move16(); - } - - return; -} - -#ifndef HARM_CORE_SW -/*---------------------------------------------------------------------* - * core_switching_pre_dec_fx() - * - * Preprocessing/preparation for ACELP/HQ core switching - *---------------------------------------------------------------------*/ -ivas_error core_switching_pre_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ -) -{ - Word16 oldLenClasBuff, newLenClasBuff, i; - BPF_DEC_HANDLE hBPF; - TD_BWE_DEC_HANDLE hBWE_TD; - FD_BWE_DEC_HANDLE hBWE_FD; - HQ_DEC_HANDLE hHQ_core; - TCX_DEC_HANDLE hTcxDec; - ivas_error error; - - hBWE_TD = st_fx->hBWE_TD; - hBWE_FD = st_fx->hBWE_FD; - hHQ_core = st_fx->hHQ_core; - hBPF = st_fx->hBPF; - hTcxDec = st_fx->hTcxDec; - - error = IVAS_ERR_OK; - move32(); - test(); - test(); - test(); - /* Codec switching */ - IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && st_fx->element_mode > EVS_MONO ) ) - { - st_fx->mem_deemph_fx = st_fx->syn[M]; /* Q_syn */ - move16(); - set16_fx( st_fx->agc_mem_fx, 0, 2 ); /* Q0 */ - Scale_sig( &( st_fx->mem_deemph_fx ), 1, st_fx->Q_syn ); /* Brings mem_deemph to Qsyn */ - - Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/ - - st_fx->bpf_off = 1; - move16(); - Scale_sig( st_fx->hPFstat->mem_pf_in, L_SUBFR, st_fx->Q_syn ); /* Post_filter mem */ /* st_fx->Q_syn*/ - Scale_sig( st_fx->hPFstat->mem_res2, DECMEM_RES2, st_fx->Q_syn ); /* NB post_filter mem */ /* st_fx->Q_syn */ - Scale_sig( st_fx->hPFstat->mem_stp, L_SUBFR, st_fx->Q_syn ); /* Post_filter mem */ /* st_fx->Q_syn */ - IF( hBPF != NULL ) - { - set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ - hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st_fx->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ - hBPF->pst_mem_deemp_err_fx = 0; - move16(); - move16(); - } - move16(); - st_fx->psf_lp_noise_fx = round_fx( L_shl( st_fx->lp_noise, 1 ) ); /* 2 * lp_noise_q - 16 */ - - /* reset old HB synthesis buffer */ - IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) - { - st_fx->old_bwe_delay = NS2SA_FX2( st_fx->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); /* Q0 */ - } - ELSE - { - st_fx->old_bwe_delay = NS2SA_FX2( st_fx->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); /* Q0 */ - } - move16(); - set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - - /* reset upd_cnt */ - st_fx->upd_cnt = MAX_UPD_CNT; - move16(); - st_fx->igf = 0; - move16(); - - - test(); - IF( hBWE_TD != NULL && NE_16( st_fx->last_core, ACELP_CORE ) ) - { - hBWE_TD->prev_hb_synth_fx_exp = 31; - move16(); - /* reset BWE memories */ - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); /* Q_exc */ - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - move32(); - } - - test(); - IF( GE_32( st_fx->output_Fs, 16000 ) && st_fx->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st_fx->hBWE_zero ); - } - IF( st_fx->hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - IF( st_fx->hHQ_core != NULL ) - { - set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - IF( GT_32( st_fx->output_Fs, 16000 ) ) - { - set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); - } - - /* pre-echo */ - hHQ_core->pastpre = 0; - move16(); - } - /* reset the GSC pre echo energy threshold in case of switching */ - IF( st_fx->hGSCDec != NULL ) - { - st_fx->hGSCDec->Last_frame_ener_fx = MAX_32; - } - move32(); - - test(); - IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) - { - IF( st_fx->element_mode == EVS_MONO ) - { - st_fx->last_core = HQ_CORE; - move16(); - Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /* st_fx->q_prev_synth_buffer_fx */ - } - IF( hHQ_core != NULL ) - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - } - } - - IF( st_fx->prev_bfi != 0 ) - { - Word16 delay_comp; - - /*switch off Hq Voicing as it was not uodated in MODE2*/ - IF( hHQ_core != NULL ) - { - hHQ_core->oldHqVoicing = 0; - hHQ_core->HqVoicing = 0; - move16(); - move16(); - } - - delay_comp = NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ); - - test(); - test(); - IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) ) - { - - Word16 no_col; - Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH]; - Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; - CLDFB_SCALE_FACTOR scaleFactor; - Word32 workBuffer[128 * 3]; - - FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; 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(); - } - - no_col = s_min( st_fx->cldfbAna->no_col, idiv1616( sub( add( delay_comp, st_fx->cldfbAna->no_channels ), 1 ), st_fx->cldfbAna->no_channels ) ); /* Q0 */ - - /* CLDFB analysis of the synthesis at internal sampling rate */ - IF( ( error = cldfb_save_memory( st_fx->cldfbAna ) ) != IVAS_ERR_OK ) - { - return error; - } - cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, hTcxDec->syn_Overl, 0, no_col, workBuffer ); - cldfb_restore_memory( st_fx->cldfbAna ); - - scaleFactor.hb_scale = scaleFactor.lb_scale; - move16(); - - /* CLDFB synthesis of the combined signal */ - IF( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ) != IVAS_ERR_OK ) - { - return error; - } - cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, hHQ_core->fer_samples_fx, 0, no_col, workBuffer ); - cldfb_restore_memory( st_fx->cldfbSyn ); - } - - test(); - test(); - IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) ) - { - lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( st_fx->output_frame_fx, 1 ), shr( st_fx->last_L_frame, 1 ) ); - /*Set to zero the remaining part*/ - set16_fx( hHQ_core->fer_samples_fx + delay_comp + shr( st_fx->output_frame_fx, 1 ), 0, shr( st_fx->output_frame_fx, 1 ) - delay_comp ); - } - } - - st_fx->use_acelp_preq = 0; - move16(); - st_fx->reset_mem_AR = 0; - move16(); - } - - /*FEC*/ - IF( LE_16( st_fx->L_frame, L_FRAME16k ) ) - { - test(); - IF( LE_16( st_fx->last_L_frame, L_FRAME16k ) && NE_16( st_fx->core, HQ_CORE ) ) - { - IF( NE_16( st_fx->L_frame, st_fx->last_L_frame ) ) - { - IF( GT_16( st_fx->L_frame, st_fx->last_L_frame ) ) - { - oldLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->last_L_frame, getInvFrameLen( st_fx->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); - newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - } - ELSE - { - oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - newLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->L_frame, getInvFrameLen( st_fx->last_L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); - } - lerp( &st_fx->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st_fx->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); - } - } - ELSE - { - set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); - st_fx->classifier_Q_mem_syn = 0; - move16(); - } - } - - /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores - within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ - test(); - test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) - { - st_fx->last_ppp_mode_dec = 0; - move16(); - st_fx->last_nelp_mode_dec = 0; - move16(); - } - - test(); - test(); - test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) - { - st_fx->act_count = 3; - move16(); - st_fx->uv_count = 0; - move16(); - } - - test(); - test(); - IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ) - { - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - st_fx->hPFstat->reset = 1; - move16(); - } - - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* Q2.56 */ - Copy( TRWB2_Ave_fx, st_fx->lsfoldbfi1_fx, M ); /* Q2.56 */ - Copy( TRWB2_Ave_fx, st_fx->lsfoldbfi0_fx, M ); /* Q2.56*/ - Copy( TRWB2_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); /* Q2.56 */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); - } - ELSE - { - Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ /* Q2.56 */ - Copy( TRWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); /* Q2.56 */ - Copy( TRWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); /* Q2.56 */ - Copy( TRWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); /* Q2.56 */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); - } - - - set16_fx( st_fx->agc_mem_fx, 0, 2 ); - st_fx->mem_deemph_fx = 0; - move16(); - IF( !st_fx->last_con_tcx ) - { - set16_fx( st_fx->mem_syn2_fx, 0, M ); - } - set16_fx( st_fx->mem_syn1_fx, 0, M ); - IF( hBWE_TD != NULL ) - { - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move16(); - } - /* Reset ACELP parameters */ - set16_fx( st_fx->mem_MA_fx, 0, M ); - IF( EQ_32( st_fx->sr_core, INT_FS_16k ) ) - { - Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); /* Q2.56 */ - } - ELSE - { - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); /* Q2.56 */ - } - st_fx->tilt_code_fx = 0; - move16(); - st_fx->gc_threshold_fx = 0; - move16(); - st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); /* Q16 */ - move32(); - set16_fx( st_fx->dm_fx.prev_gain_pit, 0, 6 ); - st_fx->dm_fx.prev_state = 0; - move16(); - - st_fx->last_coder_type = GENERIC; - move16(); - - frame_ener_fx( output_frame, UNVOICED_CLAS, st_fx->previoussynth_fx, -1, &st_fx->enr_old_fx, 1, 0, 0, 0 ); - st_fx->lp_gainp_fx = 0; - move16(); - - /* the sqrt below needs to be changed to use basop Sqrt16 */ - /*st_fx->lp_gainc_fx = (float)sqrt( st_fx->lp_ener_fx ); */ - IF( st_fx->lp_ener_fx != 0 ) - { - Word32 L_tmp; - Word16 tmp, exp; - exp = norm_l( st_fx->lp_ener_fx ); /* In Q6 */ - tmp = extract_h( L_shl( st_fx->lp_ener_fx, exp ) ); - exp = sub( exp, 30 - 6 ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); - - st_fx->lp_gainc_fx = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */ - move16(); - } - - - st_fx->last_voice_factor_fx = 0; - move16(); - st_fx->Last_GSC_noisy_speech_flag = 0; - move16(); - - /* reset CLDFB memories */ - cldfb_reset_memory( st_fx->cldfbAna ); - cldfb_reset_memory( st_fx->cldfbBPF ); - cldfb_reset_memory( st_fx->cldfbSyn ); - - /* reset TBE memories */ - test(); - test(); - - IF( !st_fx->last_con_tcx && !( ( EQ_16( st_fx->last_core, HQ_CORE ) ) && st_fx->element_mode > EVS_MONO ) ) - { - set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC ); - } - ELSE IF( LT_16( st_fx->L_frame, L_FRAME16k ) ) - { - /* resample from 16kHz to 12.8kHZ */ - synth_mem_updt2( st_fx->L_frame, L_FRAME16k, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, DEC ); - } - - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - } - - test(); - IF( GE_32( st_fx->output_Fs, 16000L ) && st_fx->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st_fx->hBWE_zero ); - } - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - - test(); - test(); - test(); - test(); - test(); - IF( hHQ_core != NULL && EQ_16( st_fx->core, HQ_CORE ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) || ( st_fx->element_mode != EVS_MONO && NE_16( st_fx->last_core, HQ_CORE ) ) ) ) - { - set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - hHQ_core->prev_stab_hfe2 = 0; - move16(); - move16(); - IF( GT_32( st_fx->output_Fs, 16000 ) ) - { - set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); - } - - if ( st_fx->element_mode != EVS_MONO ) - { - } - else - { - set16_fx( hHQ_core->old_out_fx, 0, output_frame ); - hHQ_core->Q_old_wtda_LB = 15; - hHQ_core->Q_old_wtda = 15; - move16(); - } - } - - test(); - /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ - IF( hHQ_core != NULL ) - { - hHQ_core->pastpre = sub( hHQ_core->pastpre, 1 ); /* Q0 */ - move16(); - IF( hHQ_core->pastpre <= 0 ) - { - reset_preecho_dec_fx( hHQ_core ); - } - } - IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) ) - { - st_fx->VAD = 0; - move16(); - st_fx->m_frame_type = ZERO_FRAME; - move16(); - } - ELSE IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - st_fx->VAD = 0; - move16(); - st_fx->m_frame_type = SID_FRAME; - move16(); - } - ELSE - { - st_fx->VAD = 1; - move16(); - st_fx->m_frame_type = ACTIVE_FRAME; - move16(); - } - - /*switch on CNA on active frames*/ - IF( st_fx->element_mode == EVS_MONO ) /* for IVAS modes, st->flag_cna is set earlier */ - { - test(); - test(); - test(); - test(); - test(); - test(); - IF( NE_16( st_fx->core, AMR_WB_CORE ) && st_fx->VAD && LE_32( st_fx->total_brate, CNA_MAX_BRATE ) ) - { - st_fx->flag_cna = 1; - move16(); - } - ELSE IF( EQ_16( st_fx->core, AMR_WB_CORE ) && st_fx->VAD && LE_32( st_fx->total_brate, ACELP_8k85 ) ) - { - st_fx->flag_cna = 1; - move16(); - } - ELSE IF( st_fx->VAD || ( EQ_16( st_fx->cng_type, FD_CNG ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) - { - st_fx->flag_cna = 0; - move16(); - } - } - if ( EQ_16( st_fx->core, AMR_WB_CORE ) ) - { - st_fx->cng_type = LP_CNG; - move16(); - } - - test(); - test(); - test(); - test(); - IF( st_fx->hFdCngDec && ( ( NE_16( st_fx->last_L_frame, st_fx->L_frame ) ) || - ( NE_16( st_fx->hFdCngDec->hFdCngCom->frameSize, st_fx->L_frame ) ) || - st_fx->ini_frame == 0 || NE_16( st_fx->bwidth, st_fx->last_bwidth ) ) ) - { - - IF( NE_16( st_fx->core, AMR_WB_CORE ) ) - { - Word32 tmp; - - tmp = st_fx->total_brate; - move32(); - test(); - if ( EQ_16( st_fx->rf_flag, 1 ) && EQ_32( st_fx->total_brate, ACELP_13k20 ) ) - { - tmp = ACELP_9k60; - move32(); - } - configureFdCngDec_fx( st_fx->hFdCngDec, st_fx->bwidth, tmp, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode ); - } - ELSE - { - configureFdCngDec_fx( st_fx->hFdCngDec, 1, ACELP_8k00, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode ); - - if ( st_fx->VAD ) - { - st_fx->hFdCngDec->hFdCngCom->CngBitrate = st_fx->total_brate; - move32(); - } - } - - test(); - test(); - IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && LE_16( st_fx->L_frame, L_FRAME16k ) && LE_16( st_fx->last_L_frame, L_FRAME16k ) ) - { - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - } - - lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); - test(); - IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) ) - { - lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - FOR( i = 0; i < shl( st_fx->L_frame, 1 ); i++ ) - { - st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 /* Q15*/ ); /* q_olapBuffer */ - move16(); - } - } - ELSE - { - FOR( i = 0; i < shl( st_fx->L_frame, 1 ); i++ ) - { - st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 1 ), 26214 /* Q14*/ ); /* q_olapBuffer */ - move16(); - } - } - } - } - } - - return error; -} - - -/*---------------------------------------------------------------------* - * core_switching_post_dec() - * - * Postprocessing for ACELP/HQ core switching - *---------------------------------------------------------------------*/ - -ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ -) -{ - Word16 i, delay_comp, delta; - Word16 tmpF, tmp, Fs_kHz, shift, *ptmp1, *ptmp2; - Word32 L_tmp; - Word16 synth_subfr_out[SWITCH_MAX_GAP], synth_subfr_bwe[SWITCH_MAX_GAP]; - Word16 mem_synth[NS2SA( 16000, DELAY_CLDFB_NS ) + 2]; - Word16 Qtmp; - Word16 Qsubfr; - TD_BWE_DEC_HANDLE hBWE_TD; - FD_BWE_DEC_HANDLE hBWE_FD; - HQ_DEC_HANDLE hHQ_core; - ivas_error error; - - (void) ( last_element_mode ); - hBWE_TD = st_fx->hBWE_TD; - hBWE_FD = st_fx->hBWE_FD; - hHQ_core = st_fx->hHQ_core; - error = IVAS_ERR_OK; - move32(); - - /* Rescale synthesis in Q0 to avoid multiple rescaling after */ - tmp = Find_Max_Norm16( synth, output_frame ); - Scale_sig( synth, output_frame, tmp ); - *Qsynth = add( *Qsynth, tmp ); - move16(); - - test(); - test(); - test(); - IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) - { - if ( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) - { - return error; - } /*the output at Q0*/ - } - - /* set multiplication factor according to the sampling rate */ - tmp = extract_l( L_shr( st_fx->output_Fs, 13 ) ); /* Q0 */ - Fs_kHz = shl( add( tmp, 1 ), 3 ); /* Q0 */ - - delta = 1; - move16(); - if ( GE_16( output_frame, L_FRAME16k ) ) - { - delta = shr( Fs_kHz, 3 ); /* Q0 */ - } - - /* set delay compensation between HQ synthesis and ACELP synthesis */ - delay_comp = i_mult2( delta, HQ_DELAY_COMP ); /* Q0 */ - - IF( EQ_16( st_fx->core, HQ_CORE ) ) - { - st_fx->use_acelp_preq = 0; - move16(); - /* rescaling to the min exp of the 2 */ - /* Qtmp=s_min(*Qsynth,st_fx->Q_old_postdec); - Scale_sig(synth, output_frame, sub(Qtmp,*Qsynth)); - Scale_sig(st_fx->delay_buf_out_fx, delay_comp, sub(Qtmp,st_fx->Q_old_postdec));*/ - - hBWE_FD->mem_deemph_old_syn_fx = 0; - move16(); - - test(); - test(); - test(); - IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) - { - if ( ( error = acelp_core_switch_dec_fx( st_fx, synth_subfr_out, synth_subfr_bwe, output_frame, core_switching_flag, mem_synth, &Qsubfr ) ) != IVAS_ERR_OK ) - { - return error; - } - } - test(); - test(); - IF( core_switching_flag && EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->prev_bfi ) - { - Copy( st_fx->delay_buf_out_fx, synth_subfr_out, delay_comp ); /* hHQ_core->Q_old_postdec */ - Qsubfr = hHQ_core->Q_old_postdec; - move16(); - } - - /* delay HQ synthesis to synchronize with ACELP synthesis */ - /* rescaling to the min exp of the 2 */ - Qtmp = s_min( *Qsynth, hHQ_core->Q_old_postdec ); - Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qtmp */ - *Qsynth = Qtmp; - move16(); - Scale_sig( st_fx->delay_buf_out_fx, delay_comp, sub( Qtmp, hHQ_core->Q_old_postdec ) ); /* Qtmp */ - hHQ_core->Q_old_postdec = Qtmp; - move16(); - delay_signal_fx( synth, output_frame, st_fx->delay_buf_out_fx, delay_comp ); /* Qsynth, Q0 */ - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) - { - /* mem_over_hp_fx : Qsubfr */ - core_switching_OLA_fx( mem_synth, st_fx->last_L_frame, st_fx->output_Fs, synth, synth_subfr_out, synth_subfr_bwe, output_frame, st_fx->bwidth, Qsynth, &Qsubfr ); - } - ELSE IF( core_switching_flag && EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->prev_bfi ) /* HQ | ACELP | TRANSITION with ACELP frame lost */ - { - /* Overlapp between old->out (stocked in st_fx->fer_samples)and good HQ frame on L/2 */ - ptmp1 = &synth[delay_comp]; /* Qsynth */ - shift = i_mult2( Fs_kHz, 10 ); - tmp = i_mult2( delta, shr( N16_CORE_SW, 1 ) ); - - Scale_sig( hHQ_core->fer_samples_fx, output_frame, *Qsynth ); /* Qsynth */ - ptmp2 = &hHQ_core->fer_samples_fx[tmp]; - tmp = div_s( 1, shift ); /*Q15*/ - tmpF = 0; - move16(); - - FOR( i = 0; i < shift; i++ ) - { - L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ - *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ - ptmp1++; - ptmp2++; - tmpF = add( tmpF, tmp ); - } - } - ELSE IF( ( !core_switching_flag && EQ_16( st_fx->core, HQ_CORE ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* ACELP | TRANSITION | HQ with TRANSITION lost */ - || ( core_switching_flag && st_fx->prev_bfi && NE_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) ) ) - { - /* Overlapp between CELP estimation (BFI) and good HQ frame on L/2 */ - shift = i_mult2( Fs_kHz, 10 ); - tmp = div_s( 1, shift ); /*Q15*/ - tmpF = 0; - move16(); - ptmp1 = synth; - Scale_sig( hHQ_core->fer_samples_fx, output_frame, *Qsynth ); /* Qsynth */ - ptmp2 = hHQ_core->fer_samples_fx; - FOR( i = 0; i < shift; i++ ) - { - L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/ - *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/ - move16(); - tmpF = add( tmpF, tmp ); - ptmp1++; - ptmp2++; - } - } - - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - move32(); - IF( !( EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && EQ_32( st_fx->core_brate, HQ_32k ) ) ) - { - set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - } - Copy_Scale_sig( synth, st_fx->previoussynth_fx, output_frame, negate( *Qsynth ) ); /*scaling of st_fx->previoussynth_fx set at Q0*/ - - /*Set post-filtering flag to zero*/ - st_fx->hPFstat->on = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->last_core, HQ_CORE ) ) /* MDCT to ACELP transition */ - { - Qtmp = s_min( s_min( *Qsynth, hHQ_core->Q_old_postdec ), hHQ_core->Q_old_wtda ); - - Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qsynth */ - Scale_sig( st_fx->delay_buf_out_fx, delay_comp, sub( Qtmp, hHQ_core->Q_old_postdec ) ); /* Qtmp */ - Scale_sig( hHQ_core->old_out_fx, L_FRAME48k, sub( Qtmp, hHQ_core->Q_old_wtda ) ); /* Qtmp */ - *Qsynth = Qtmp; - move16(); - hHQ_core->Q_old_postdec = Qtmp; - move16(); - hHQ_core->Q_old_wtda = Qtmp; - move16(); - - Copy( st_fx->delay_buf_out_fx, synth, delay_comp ); /* copy the HQ/ACELP delay synchroniation buffer at the beginning of ACELP frame Q0*/ - - tmp = i_mult2( delta, N_ZERO_8 ); - shift = i_mult2( Fs_kHz, 3 ); - test(); - IF( st_fx->prev_bfi && hHQ_core->HqVoicing ) - { - Copy_Scale_sig( hHQ_core->fer_samples_fx, &hHQ_core->old_out_fx[tmp], shift, *Qsynth ); /* Qsynth */ - } - - ptmp2 = &hHQ_core->old_out_fx[tmp]; - tmp = div_s( 1, shift ); - ptmp1 = &synth[delay_comp]; - tmpF = 0; - move16(); - FOR( i = 0; i < shift; i++ ) - { - *ptmp1 = add( mult_r( tmpF, *ptmp1 ), mult_r( sub( 32767, tmpF ), *ptmp2++ ) ); /* Q0 */ - move16(); - ptmp1++; - tmpF = add( tmpF, tmp ); - } - } - - set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP ); - hHQ_core->oldHqVoicing = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - } - - /* reset SWB BWE buffers */ - test(); - test(); - test(); - IF( st_fx->bws_cnt == 0 || ( st_fx->bws_cnt > 0 && NE_16( st_fx->coder_type, INACTIVE ) && NE_16( st_fx->coder_type, AUDIO ) ) ) - { - st_fx->attenu_fx = 3277; /* Q15 */ - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || ( NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) || - ( ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_extl, SWB_TBE ) ) && st_fx->extl < 0 && NE_16( st_fx->core, HQ_CORE ) ) || ( st_fx->last_core == ACELP_CORE && st_fx->core == ACELP_CORE && ( ( NE_16( st_fx->prev_coder_type, INACTIVE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) || ( NE_16( st_fx->prev_coder_type, AUDIO ) && EQ_16( st_fx->coder_type, AUDIO ) ) ) && st_fx->bws_cnt > 0 ) ) - { - set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame ); - hBWE_FD->old_wtda_swb_fx_exp = 0; - move16(); - if ( NE_16( st_fx->last_extl, WB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - } - - hBWE_FD->prev_Energy_fx = 0; - move16(); - hBWE_FD->prev_L_swb_norm = 8; - move16(); - hBWE_FD->prev_frica_flag = 0; - move16(); - set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k ); - hBWE_FD->prev_td_energy_fx = 0; - move16(); - hBWE_FD->prev_weight_fx = 6554; - move16(); /*0.2 in Q15*/ - hBWE_FD->prev_fb_ener_adjust_fx = 0; - move16(); - } - - /* reset WB BWE buffers */ - test(); - IF( NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) ) - { - set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame ); - - test(); - IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) + } + ELSE + { + IF( st_fx->hHQ_core->old_is_transient[0] ) { - hBWE_FD->prev_mode = NORMAL; - move16(); + L_tmp = L_deposit_l( 0 ); + FOR( i = 0; i < 32; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ + } + L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ + st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ + move32(); + L_tmp = L_deposit_l( 0 ); + FOR( ; i < 64; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ + } + L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */ + st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ + move32(); + } + ELSE + { + L_tmp = L_deposit_l( 0 ); + FOR( i = 0; i < L_FRAME / 2; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ + } + L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ + st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ + move32(); + L_tmp = L_deposit_l( 0 ); + FOR( ; i < L_FRAME; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */ + } + L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */ + st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */ + move32(); } - hBWE_FD->prev_Energy_wb_fx = 0; - move16(); - hBWE_FD->prev_L_swb_norm = 8; - move16(); - set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k ); - hBWE_FD->prev_flag = 0; - move16(); } - /* reset SWB TBE buffers */ - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); + test(); test(); test(); @@ -1235,78 +180,34 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); - IF( ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || EQ_16( st_fx->extl, SWB_CNG ) ) && - ( NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || EQ_16( st_fx->last_core, HQ_CORE ) ) ) || - ( LT_16( st_fx->bwidth, st_fx->last_bwidth ) && NE_16( st_fx->last_extl, SWB_TBE ) ) || st_fx->old_ppp_mode || ( ( EQ_16( st_fx->prev_coder_type, AUDIO ) || EQ_16( st_fx->prev_coder_type, INACTIVE ) ) && st_fx->bws_cnt > 0 ) || ( st_fx->bws_cnt == 0 && EQ_16( st_fx->prev_bws_cnt, N_WS2N_FRAMES ) ) ) + IF( st_fx->last_bwidth == 0 && LE_16( st_fx->extl, SWB_CNG ) ) { - swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); - - set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 ); - swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 ); - - IF( EQ_16( output_frame, L_FRAME16k ) ) - { - /* reset in case that SWB TBE layer is transmitted, but the output is 16kHz sampled */ - set16_fx( hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - set32_fx( hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - } - set16_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN ); - set32_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx_32, 0, INTERP_3_2_MEM_LEN ); + st_fx->prev_ener_shb_fx = 0; + move16(); + set16_fx( st_fx->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV ); } - ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && - ( NE_32( st_fx->last_total_brate, st_fx->total_brate ) || NE_16( st_fx->last_bwidth, st_fx->bwidth ) || - NE_16( st_fx->last_codec_mode, MODE1 ) || NE_16( st_fx->rf_flag, st_fx->rf_flag_last ) ) ) + ELSE IF( ( ( st_fx->core == ACELP_CORE && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) ) { - set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->gain_prec_swb_fx = 16384; - move16(); /*Q14 = 1 */ + st_fx->attenu_fx = 3277; /* Q15 */ + move16(); } - /* Interp_3_2 CNG buffers reset */ test(); test(); test(); - IF( st_fx->hTdCngDec != NULL && EQ_32( st_fx->output_Fs, 48000 ) && ( ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) && ( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) ) ) - { - set16_fx( st_fx->hTdCngDec->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN ); - } - - /* reset FB TBE buffers */ test(); test(); - IF( EQ_16( st_fx->extl, FB_TBE ) && ( NE_16( st_fx->last_extl, FB_TBE ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) ) ) + IF( EQ_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && !( EQ_16( st_fx->last_extl, WB_TBE ) || EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && GT_32( st_fx->core_brate, ACELP_8k00 ) ) ) { - set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->fb_tbe_demph_fx = 0; + st_fx->prev_fractive = 0; move16(); - fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); } - /* reset WB TBE buffers */ - test(); - IF( NE_16( st_fx->last_extl, WB_TBE ) && EQ_16( st_fx->extl, WB_TBE ) ) - { - wb_tbe_extras_reset_fx( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); - wb_tbe_extras_reset_synth_fx( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_32and48k_WB_upsample_fx, hBWE_TD->mem_resamp_HB_fx ); - - set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); - set16_fx( hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); - set32_fx( hBWE_TD->mem_csfilt_fx, 0, 2 ); - } - - return error; + return; } -#endif -#ifdef HARM_CORE_SW + ivas_error core_switching_post_dec_fx( -#else -ivas_error core_switching_post_dec_ivas_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ @@ -1353,11 +254,7 @@ ivas_error core_switching_post_dec_ivas_fx( test(); IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) { -#ifdef HARM_CORE_SW IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) -#else - IF( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) -#endif { return error; } /*the output at Q0*/ @@ -1426,9 +323,7 @@ ivas_error core_switching_post_dec_ivas_fx( /* delay HQ synthesis to synchronize with ACELP synthesis */ /* rescaling to the min exp of the 2 */ -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) -#endif { Word16 NonZero = 1; move16(); @@ -1781,7 +676,6 @@ ivas_error core_switching_post_dec_ivas_fx( move16(); } -#ifdef HARM_CORE_SW IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM ); @@ -1790,7 +684,6 @@ ivas_error core_switching_post_dec_ivas_fx( hHQ_core->prev_stab_hfe2 = 0; move16(); } -#endif } } ELSE @@ -2234,34 +1127,22 @@ static void smoothTransitionDtxToTcx_fx( * Preprocessing/preparation for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW ivas_error core_switching_pre_dec_fx( -#else -ivas_error core_switching_pre_dec_ivas_fx( -#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 output_frame, /* i : frame length */ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ const Word16 nchan_out, /* i : number of output channels */ const Word16 last_element_mode, /* i : last_element_mode */ const Word32 last_element_brate, /* i : last element bitrate */ -#ifdef HARM_CORE_SW const Word16 Q_old_synthFB, -#else - Word16 Q_old_synthFB, -#endif Word16 *Q_olapBufferSynth, Word16 *Q_olapBufferSynth2 ) { Word32 tmp_fx; /*Q-12*/ Word16 i, oldLenClasBuff, newLenClasBuff; ivas_error error; -#ifdef HARM_CORE_SW Word16 tmp, exp = Q25; Word32 L_tmp; -#else - Word16 exp = 25; -#endif move16(); BPF_DEC_HANDLE hBPF; TD_BWE_DEC_HANDLE hBWE_TD; @@ -2298,15 +1179,10 @@ ivas_error core_switching_pre_dec_ivas_fx( Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/ Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ -#ifndef HARM_CORE_SW - set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ -#endif } IF( hBPF != NULL ) { -#ifdef HARM_CORE_SW set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ -#endif hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ hBPF->pst_mem_deemp_err_fx = 0; move16(); @@ -2353,9 +1229,7 @@ ivas_error core_switching_pre_dec_ivas_fx( #endif { hf_synth_reset_fx( st->hBWE_zero ); -#ifdef HARM_CORE_SW 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 ); } @@ -2400,12 +1274,7 @@ ivas_error core_switching_pre_dec_ivas_fx( st->last_core = HQ_CORE; move16(); -#ifdef HARM_CORE_SW Copy( hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer_fx, NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /* st->q_prev_synth_buffer_fx */ -#else - Copy32( hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - // Copy_Scale_sig_32_16( hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 -#endif } IF( hHQ_core != NULL ) @@ -2438,7 +1307,6 @@ ivas_error core_switching_pre_dec_ivas_fx( delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { test(); @@ -2484,7 +1352,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } } ELSE -#endif { /*TODO To be tested:control not entering the block*/ test(); @@ -2555,7 +1422,6 @@ ivas_error core_switching_pre_dec_ivas_fx( { IF( NE_16( st->L_frame, st->last_L_frame ) ) { -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { IF( GT_16( st->L_frame, st->last_L_frame ) ) @@ -2572,7 +1438,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } } ELSE -#endif { IF( GT_16( st->L_frame, st->last_L_frame ) ) { @@ -2593,10 +1458,8 @@ ivas_error core_switching_pre_dec_ivas_fx( ELSE { set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); -#ifdef HARM_CORE_SW st->classifier_Q_mem_syn = 0; move16(); -#endif } } @@ -2722,7 +1585,6 @@ ivas_error core_switching_pre_dec_ivas_fx( st->last_coder_type = GENERIC; move16(); -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); @@ -2744,7 +1606,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } } ELSE -#endif { fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ st->lp_gainp_fx = 0; @@ -2761,7 +1622,6 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); /* reset CLDFB memories */ -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { cldfb_reset_memory( st->cldfbAna ); @@ -2769,7 +1629,6 @@ ivas_error core_switching_pre_dec_ivas_fx( cldfb_reset_memory( st->cldfbSyn ); } ELSE -#endif { cldfb_reset_memory_fx( st->cldfbAna ); cldfb_reset_memory_fx( st->cldfbBPF ); @@ -2802,9 +1661,7 @@ ivas_error core_switching_pre_dec_ivas_fx( #endif { hf_synth_reset_fx( st->hBWE_zero ); -#ifdef HARM_CORE_SW 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 ); } @@ -2875,23 +1732,11 @@ ivas_error core_switching_pre_dec_ivas_fx( /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ Word16 offset; offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); -#ifdef HARM_CORE_SW Word32 old_synthFB_fx[L_FRAME_PLUS * 2]; -#else - Word32 *old_synthFB_fx; - IF( ( old_synthFB_fx = (Word32 *) malloc( hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); - } -#endif Copy_Scale_sig_16_32_no_sat( hTcxDec->old_synthFB_fx, old_synthFB_fx, hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 Copy32( old_synthFB_fx + hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); st->cldfbAna->Q_cldfb_state = Q10; move16(); -#ifndef HARM_CORE_SW - IF( old_synthFB_fx ) - free( old_synthFB_fx ); -#endif } } @@ -2951,17 +1796,12 @@ ivas_error core_switching_pre_dec_ivas_fx( } ELSE { -#ifdef HARM_CORE_SW set16_fx( hHQ_core->old_out_fx, 0, output_frame ); set16_fx( hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); hHQ_core->Q_old_wtda_LB = Q15; move16(); hHQ_core->Q_old_wtda = Q15; move16(); -#else - set16_fx( hHQ_core->old_out_fx, 0, output_frame ); - set32_fx( hHQ_core->old_out_LB_fx32, 0, L_FRAME16k ); -#endif } } @@ -3030,7 +1870,6 @@ ivas_error core_switching_pre_dec_ivas_fx( /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ IF( NE_16( st->core, AMR_WB_CORE ) ) { -#ifdef HARM_CORE_SW L_tmp = st->total_brate; move32(); test(); @@ -3048,25 +1887,10 @@ ivas_error core_switching_pre_dec_ivas_fx( { configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); } -#else - test(); - IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) - { - configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode ); - } - ELSE - { - configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); - } -#endif } ELSE { -#ifdef HARM_CORE_SW configureFdCngDec_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); -#else - configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); -#endif if ( st->VAD ) { @@ -3085,7 +1909,6 @@ ivas_error core_switching_pre_dec_ivas_fx( lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); } -#ifdef HARM_CORE_SW IF( EQ_16( st->element_mode, EVS_MONO ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); @@ -3113,7 +1936,6 @@ ivas_error core_switching_pre_dec_ivas_fx( } } ELSE -#endif { L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); @@ -3146,14 +1968,6 @@ ivas_error core_switching_pre_dec_ivas_fx( return error; } -#ifndef HARM_CORE_SW -/*---------------------------------------------------------------------* - * core_switching_hq_prepare_dec() - * - * Preprocessing in the first HQ frame after ACELP frame - * Modify bit allocation for HQ core by removing ACELP subframe budget - *---------------------------------------------------------------------*/ -#endif /*---------------------------------------------------------------------* * bandwidth_switching_detect() @@ -3161,11 +1975,7 @@ ivas_error core_switching_pre_dec_ivas_fx( * Classification for band-width switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW void bandwidth_switching_detect_fx( -#else -void bandwidth_switching_detect_ivas_fx( -#endif Decoder_State *st_fx /* i/o: encoder state structure */ ) { @@ -3281,191 +2091,3 @@ void bandwidth_switching_detect_ivas_fx( return; } -#ifndef HARM_CORE_SW -/*---------------------------------------------------------------------* - * bw_switching_pre_proc() - * - * Band-width switching pre-processing - *---------------------------------------------------------------------*/ -void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out /* i : number of output channels */, - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ) -{ - Word16 i; - Word32 syn_dct_fx[L_FRAME]; - - - IF( st->element_mode > EVS_MONO ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( 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 ) ) ) - { - /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ - Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; - Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) ); - st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16 - move16(); - } - - return; - } - - - test(); - test(); - IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) - { - /*----------------------------------------------------------------------* - * Calculate tilt of the ACELP core synthesis - *----------------------------------------------------------------------*/ - - st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame ); - move16(); - /*-------------------------------------------------------------------------------* - * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis - *-------------------------------------------------------------------------------*/ - edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q ); - Word64 W_tmp = 0; - move64(); - Word32 tmp; - Word16 shift; - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); - tmp = W_extract_h( W_tmp ); - tmp = L_shr( tmp, 8 ); - - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); - move16(); - W_tmp = 0; - move64(); - FOR( ; i < L_FRAME; i++ ) - { - W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); - tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32 - tmp = L_shr( tmp, 7 ); // divide by 128 - tmp = getSqrtWord32( tmp ); - st->enerLH_fx = tmp; - move32(); - st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); - move16(); - } - ELSE - { - IF( st->hHQ_core->old_is_transient[0] ) - { - Word32 tmp, L_tmp = 0; - move32(); - FOR( i = 0; i < 32; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - - L_tmp = 0; - move32(); - FOR( ; i < 64; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); - } - - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLH_fx = tmp; - move32(); - st->enerLH_fx_Q = Q_audio; - move16(); - } - ELSE - { - Word32 tmp, L_tmp = 0; - move32(); - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - - L_tmp = 0; - move32(); - FOR( ; i < L_FRAME; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) - { - st->prev_ener_shb_fx = 0; - move16(); - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV ); - } - } - ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) - { - st->attenu_fx = 3277; // 0.1f in Q15 - move16(); - } - - test(); - test(); - test(); - test(); - test(); - if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) - { - st->prev_fractive = 0; - move16(); - } - - return; -} -#endif diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index e7b378a6d..f320e323f 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -315,11 +315,7 @@ ivas_error evs_dec_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ) != IVAS_ERR_OK ) -#else - IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -350,11 +346,7 @@ ivas_error evs_dec_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, NULL, NULL, 0, output_frame, core_switching_flag, 0, 1, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) -#else - if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -363,11 +355,7 @@ ivas_error evs_dec_fx( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW bw_switching_pre_proc_fx( st_fx, -1, 1, old_syn_12k8_16k_fx ); -#else - bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx ); -#endif /*---------------------------------------------------------------------* * WB TBE decoding diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index efd629036..b71f0df7d 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -76,11 +76,7 @@ ivas_error ivas_core_dec_fx( Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q15 Word16 core_switching_flag[CPE_CHANNELS]; Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q6 -#ifdef HARM_CORE_SW Word16 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; -#else - Word32 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k]; -#endif Word16 unbits[CPE_CHANNELS]; Word16 sid_bw[CPE_CHANNELS]; FRAME_MODE frameMode[CPE_CHANNELS]; @@ -437,11 +433,7 @@ ivas_error ivas_core_dec_fx( * Detect bandwidth switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW bandwidth_switching_detect_fx( st ); -#else - bandwidth_switching_detect_ivas_fx( st ); -#endif /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching @@ -456,11 +448,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_DEPREC( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0 -#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -484,9 +472,6 @@ ivas_error ivas_core_dec_fx( IF( st->core == ACELP_CORE ) { /* ACELP core decoder */ -#ifndef HARM_CORE_SW - Word16 old_syn_12k8_16k_fx_16[L_FRAME16k]; -#endif Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx; IF( save_hb_synth_32_fx ) @@ -537,11 +522,7 @@ ivas_error ivas_core_dec_fx( st->Q_syn_factor = 0; move16(); -#ifdef HARM_CORE_SW 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[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, 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 ) ) -#else - 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_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 ) ) -#endif { return error; } @@ -574,12 +555,6 @@ ivas_error ivas_core_dec_fx( hSCE->q_save_hb_synth_fx = Q11; move16(); } -#ifndef HARM_CORE_SW - IF( st->hBWE_FD != NULL ) - { - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) - } -#endif } Copy_Scale_sig_32_16( st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0 ); // Q0 @@ -861,13 +836,6 @@ ivas_error ivas_core_dec_fx( move16(); } -#ifndef HARM_CORE_SW - Word16 q_audio, old_syn_fx; - old_syn_fx = Q11; - move16(); - q_audio = Q12; - move16(); -#endif test(); test(); @@ -920,11 +888,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx } -#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -954,11 +918,7 @@ ivas_error ivas_core_dec_fx( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n] ); -#else - ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio ); -#endif IF( st->hHQ_core == NULL ) { diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index d3a4b7f74..d44ebdb3f 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -364,11 +364,7 @@ ivas_error ivas_mct_dec_fx( dirac_stereo_flag = 0; } -#ifdef HARM_CORE_SW IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index ed2060cef..7e9bf3a18 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -5478,11 +5478,7 @@ void ivas_swb_tbe_dec_fx( const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ -#ifdef HARM_CORE_SW const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ -#else - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ -#endif Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ Word16 *pitch_buf_fx, /* i : Q6 */ @@ -5553,10 +5549,8 @@ void ivas_swb_tbe_dec_fx( hBWE_TD = st->hBWE_TD; -#ifdef HARM_CORE_SW Word32 old_syn_12k8_16k_fx[L_FRAME16k]; Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx16, old_syn_12k8_16k_fx, st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) -#endif /* initializations */ GainFrame_fx = 0; diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index f6dbe7938..51994c772 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -136,11 +136,7 @@ void amr_wb_enc_fx( /* Updates in case of HQ -> AMR-WB IO mode switching */ Q_new = 0; move16(); /* prevent compiler warning only*/ -#ifdef HARM_CORE_SW core_switching_pre_enc_fx( st, NULL, 0, NULL, 0, 0, 0 ); -#else - core_switching_pre_enc_fx( st, NULL, NULL, 0, 0 ); -#endif set16_fx( hf_gain_fx, 0, NB_SUBFR ); set16_fx( old_inp, 0, L_INP_12k8 ); diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 29272023d..95688a82a 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -21,13 +21,9 @@ void core_switching_pre_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ -#ifdef HARM_CORE_SW const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ -#endif const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ -#ifdef HARM_CORE_SW const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ -#endif const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ) @@ -212,12 +208,10 @@ void core_switching_pre_enc_fx( set16_fx( hLPDmem->mem_syn2, 0, M ); set16_fx( hLPDmem->mem_syn, 0, M ); set16_fx( hLPDmem->mem_syn1_fx, 0, M ); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { hLPDmem->q_mem_syn = Q15; } -#endif hLPDmem->mem_w0 = 0; move16(); hLPDmem->tilt_code = 0; @@ -249,13 +243,11 @@ void core_switching_pre_enc_fx( } Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/ -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); } ELSE -#endif { set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); } @@ -366,7 +358,6 @@ void core_switching_pre_enc_fx( Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); } -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) @@ -382,7 +373,6 @@ void core_switching_pre_enc_fx( } } ELSE -#endif { Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ } @@ -400,7 +390,6 @@ void core_switching_pre_enc_fx( Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); } -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) @@ -416,7 +405,6 @@ void core_switching_pre_enc_fx( } } ELSE -#endif { Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/ } @@ -424,12 +412,8 @@ void core_switching_pre_enc_fx( tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); /*Q(Q_shb_spch)*/ -#ifdef HARM_CORE_SW hBWE_FD->Q_new_input_hp = 0; move16(); -#else - add( 0, 0 ); -#endif IF( NE_16( st_fx->last_extl, WB_BWE ) ) { @@ -445,7 +429,6 @@ void core_switching_pre_enc_fx( move16(); /* Set to a High Exponent so it is 1^-30 */ } -#ifdef HARM_CORE_SW /*---------------------------------------------------------------------* * band-width switching from WB -> SWB/FB *---------------------------------------------------------------------*/ @@ -473,7 +456,6 @@ void core_switching_pre_enc_fx( } } -#endif return; } @@ -514,19 +496,15 @@ void core_switching_post_enc_fx( hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); hBWE_FD->mem_deemph_old_syn_fx = 0; move16(); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { hBWE_FD->q_mem_deemph_old_syn = 0; move16(); } -#endif } ELSE { -#ifdef HARM_CORE_SW IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) -#endif { *Qmus = Qsp; /* Write Qout */ move16(); @@ -565,7 +543,6 @@ void core_switching_post_enc_fx( test(); test(); test(); -#ifdef HARM_CORE_SW test(); test(); test(); @@ -573,19 +550,16 @@ void core_switching_post_enc_fx( test(); test(); test(); -#endif IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) ) ) { set16_fx( hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { InitSWBencBufferStates_fx( st_fx->hBWE_TD, NULL ); } ELSE -#endif { set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); } @@ -595,26 +569,18 @@ void core_switching_post_enc_fx( hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); -#ifdef HARM_CORE_SW IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { set16_fx( st_fx->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); } ELSE -#endif { set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 ); } } -#ifdef HARM_CORE_SW ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && ( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) ) || ( NE_16( st_fx->last_bwidth, st_fx->bwidth ) ) || ( NE_16( st_fx->last_codec_mode, MODE1 ) ) || ( NE_16( st_fx->rf_mode_last, st_fx->rf_mode ) ) ) ) -#else - ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && - ( NE_32( st_fx->last_total_brate, st_fx->total_brate ) || NE_16( st_fx->last_bwidth, st_fx->bwidth ) || - NE_16( st_fx->last_codec_mode, MODE1 ) || NE_16( st_fx->rf_mode, st_fx->rf_mode_last ) ) ) -#endif { set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); @@ -639,7 +605,6 @@ void core_switching_post_enc_fx( fb_tbe_reset_enc_fx( hBWE_TD->elliptic_bpf_2_48k_mem_fx, &hBWE_TD->prev_fb_energy_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &hBWE_TD->prev_fb_energy_fx_Q ); } -#ifdef HARM_CORE_SW /* Fade towards init value for non HQ_CORE */ test(); IF( NE_16( st_fx->element_mode, EVS_MONO ) && st_fx->hHQ_core != NULL ) @@ -649,7 +614,6 @@ void core_switching_post_enc_fx( st_fx->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st_fx->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st_fx->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ move32(); } -#endif } return; @@ -784,539 +748,3 @@ void core_switching_hq_prepare_enc_fx( } return; } -#ifndef HARM_CORE_SW - -void core_switching_pre_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz q_old_inp_12k8 */ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz q_old_inp_16k */ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ - const Word16 active_cnt, /* i : active frame counter */ - const Word16 last_element_mode /* i : last_element_mode */ -) -{ - Word16 Sample_Delay_HP, Sample_Delay_LP; - Word16 tmp16; - Word16 tmp; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - - /* Mode switching */ - test(); - test(); - test(); - IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && ( st_fx->element_mode > EVS_MONO ) ) ) ) - { - IF( hLPDmem != NULL ) - { - Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); - } - - if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - st_fx->igf = 0; - move16(); - } - - IF( hBWE_TD != NULL ) - { - IF( st_fx->last_core != ACELP_CORE ) - { - /* reset BWE memories */ - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - move32(); - } - - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - test(); - IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) - { - if ( st_fx->element_mode == EVS_MONO ) - { - st_fx->last_core = HQ_CORE; - move16(); - } - IF( hHQ_core != NULL ) - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - } - test(); - /*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/ - IF( ( st_fx->element_mode == EVS_MONO ) && hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); - } - } - - test(); - IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) ) - { - Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); - - st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); - move16(); - } - - st_fx->use_acelp_preq = 0; - move16(); - } - - test(); - test(); - test(); - if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) ) - { - /* very first frame is HQ_CORE */ - st_fx->last_core = HQ_CORE; - move16(); - } - - test(); - test(); - IF( EQ_16( st_fx->core, HQ_CORE ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */ - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - - IF( hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); - } - } - - /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores - within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ - test(); - test(); - IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) - { - IF( hSC_VBR != NULL ) - { - hSC_VBR->last_last_ppp_mode = 0; - move16(); - hSC_VBR->last_ppp_mode = 0; - move16(); - hSC_VBR->last_nelp_mode = 0; - move16(); - } - } - - test(); - test(); - test(); - IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) - { - st_fx->act_count = 3; - move16(); - st_fx->uv_count = 0; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) /* EVS and HQ -> ACELP */ || - ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) || - ( st_fx->core == ACELP_CORE && GT_16( st_fx->last_L_frame, L_FRAME16k ) ) /* TCX @ 25.6/32 kHz -> ACELP */ ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); - } - ELSE - { - Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); - } - - /* Reset ACELP parameters */ - IF( hLPDmem != NULL ) - { - move16(); - hLPDmem->syn[M] = 0; - move16(); - set16_fx( hLPDmem->mem_syn2, 0, M ); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn1_fx, 0, M ); - hLPDmem->q_mem_syn = Q15; - move16(); - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - /* set16_fx( st_fx->dispMem, 0, 8 ); */ - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); - } - st_fx->Nb_ACELP_frames = 0; - move16(); - - set16_fx( st_fx->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - init_gp_clip_fx( st_fx->clip_var_fx ); - st_fx->last_coder_type = GENERIC; - move16(); - - tmp16 = add( NB_SUBFR, 1 ); - - if ( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - tmp16 = NB_SUBFR; - move16(); - } - - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); - /* Reset old ACELP buffers */ - test(); - IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL ) - { - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - } - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - - /* reset BWE memories */ - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - test(); - test(); - test(); - IF( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) ) - { - /* Reset the ACELP core in case of TCX->ACELP core switching */ - st_fx->Nb_ACELP_frames = 0; - move16(); - - IF( hLPDmem != NULL ) - { - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - init_gp_clip_fx( st_fx->clip_var_fx ); - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - } - - st_fx->last_coder_type = GENERIC; - move16(); - - tmp16 = shr( st_fx->L_frame, 6 ); - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); - /* Reset old TD BWE buffers */ - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - - /* reset BWE memories */ - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - test(); - test(); - test(); - IF( GE_32( st_fx->input_Fs, 16000 ) && NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) && hBWE_FD != NULL ) - { - test(); - IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->modeCount = 0; - move16(); - } - - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - IF( ( GE_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || - ( GE_32( st_fx->input_Fs, 48000 ) && NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) ) - { - /* we are switching to SWB BWE - reset SWB BWE buffers */ - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); - IF( ( st_fx->element_mode > EVS_MONO ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - } - IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) - { - Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp - } - ELSE - { - Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8 - hBWE_FD->prev_Q_input_lp = q_old_inp_12k8; - move16(); - Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - } - } - ELSE - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - } - IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) - { - Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp - } - ELSE - { - Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k - hBWE_FD->prev_Q_input_lp = q_old_inp_16k; - move16(); - Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - } - } - - tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); - Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); - hBWE_FD->Q_new_input_hp = 0; - move16(); - - IF( NE_16( st_fx->last_extl, WB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->modeCount = 0; - move16(); - } - hBWE_FD->EnergyLF_fx = 0; - hBWE_FD->EnergyLF_exp = 0; - move32(); - move16(); - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); /*8.0 in Q0 */ - st_fx->EnergyLT_fx_exp = 30; - move16(); /* Set to a High Exponent so it is 1^-30 */ - } - - /*---------------------------------------------------------------------* - * band-width switching from WB -> SWB/FB - *---------------------------------------------------------------------*/ - - IF( st_fx->element_mode > EVS_MONO ) - { - IF( st_fx->bwidth_sw_cnt == 0 ) - { - test(); - IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) - { - st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); - move16(); - } - } - ELSE - { - st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); - move16(); - IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) ) - { - st_fx->bwidth_sw_cnt = 0; - move16(); - } - } - } - - return; -} - - -/*---------------------------------------------------------------------* - * core_switching_post_enc() - * - * Postprocessing for ACELP/HQ core switching - *---------------------------------------------------------------------*/ - -void core_switching_post_enc_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ -) -{ - IF( EQ_16( st->core, HQ_CORE ) ) - { - st->use_acelp_preq = 0; - move16(); - - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - st->hBWE_FD->mem_deemph_old_syn_fx = 0; - move16(); - st->hBWE_FD->q_mem_deemph_old_syn = 0; - move16(); - } - ELSE - { - IF( st->hBWE_TD == NULL ) - { - return; - } - - test(); - /* reset SWB TBE buffers */ - IF( EQ_16( st->extl, WB_TBE ) && NE_16( st->last_extl, WB_TBE ) ) - { - wb_tbe_extras_reset_fx( st->hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, st->hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); - - IF( NE_16( st->last_extl, WB_BWE ) ) - { - set16_fx( st->hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set16_fx( st->hBWE_TD->decim_state2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - } - - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); - set16_fx( st->hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); - set32_fx( st->hBWE_TD->mem_csfilt_fx, 0, 2 ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - - IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && - ( EQ_16( st->last_core, HQ_CORE ) || NE_16( st->L_frame, st->last_L_frame ) || ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) ) ) - { - set16_fx( st->hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - - InitSWBencBufferStates_fx( st->hBWE_TD, NULL ); - swb_tbe_reset_fx( st->hBWE_TD->mem_csfilt_fx, st->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, st->hBWE_TD->state_lpc_syn_fx, st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->state_syn_shbexc_fx, &( st->hBWE_TD->tbe_demph_fx ), &( st->hBWE_TD->tbe_premph_fx ), st->hBWE_TD->mem_stp_swb_fx, &( st->hBWE_TD->gain_prec_swb_fx ) ); - - set16_fx( st->hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); - set16_fx( st->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); - } - ELSE IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && ( ( EQ_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) || ( NE_16( st->last_codec_mode, MODE1 ) ) || ( NE_16( st->rf_mode_last, st->rf_mode ) ) ) ) - { - set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; - move16(); - } - ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) - { - TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth ); - } - - test(); - test(); - test(); - test(); - /* Interp_3_2 CNG buffers reset */ - IF( EQ_16( st->extl, FB_TBE ) && ( ( NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) || NE_16( st->L_frame, st->last_L_frame ) ) ) - { - set16_fx( st->hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->fb_tbe_demph_fx = 0; - move16(); - fb_tbe_reset_enc_fx( st->hBWE_TD->elliptic_bpf_2_48k_mem_fx, &st->hBWE_TD->prev_fb_energy_fx, st->hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &st->hBWE_TD->prev_fb_energy_fx_Q ); - } - /* Fade towards init value for non HQ_CORE */ - IF( st->hHQ_core != NULL ) - { - st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/ - move32(); - st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ - move32(); - } - } - - return; -} -#endif diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 5fd5a8963..5f696e899 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -260,11 +260,7 @@ ivas_error evs_enc_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW core_switching_pre_enc_fx( st, old_inp_12k8, 0, old_inp_16k, 0, 0, 0 ); -#else - core_switching_pre_enc_fx( st, old_inp_12k8, old_inp_16k, 0, 0 ); -#endif /*---------------------------------------------------------------------* * ACELP core encoding diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index cd1e34af4..334b84581 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -325,11 +325,7 @@ ivas_error ivas_core_enc_fx( * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW core_switching_pre_enc_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode ); -#else - core_switching_pre_enc_ivas_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode ); -#endif /*---------------------------------------------------------------------* * ACELP core encoding @@ -672,11 +668,7 @@ ivas_error ivas_core_enc_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ -#ifdef HARM_CORE_SW core_switching_post_enc_fx( st, NULL, NULL, NULL, 0, 0, 0, NULL ); -#else - core_switching_post_enc_ivas_fx( st ); -#endif /*---------------------------------------------------------------------* * WB TBE encoding diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 5f773c341..2f606063e 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -127,13 +127,9 @@ void core_switching_post_enc_fx( void core_switching_pre_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ -#ifdef HARM_CORE_SW const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ -#endif const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ -#ifdef HARM_CORE_SW const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ -#endif const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ); -- GitLab From b25dd1a456dae190fd9bbc23069cf7e6c57a1c25 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:24:06 +0100 Subject: [PATCH 15/26] [cleanup] accept HARM_PREPROC --- lib_com/options.h | 1 - lib_enc/amr_wb_enc_fx.c | 8 - lib_enc/dtx_fx.c | 569 ------------------------- lib_enc/init_enc_fx.c | 11 - lib_enc/ivas_core_pre_proc_front_fx.c | 33 -- lib_enc/ivas_front_vad_fx.c | 12 - lib_enc/ivas_stereo_switching_enc_fx.c | 4 - lib_enc/pitch_ol2_fx.c | 222 ---------- lib_enc/pre_proc_fx.c | 13 - lib_enc/prot_fx_enc.h | 48 --- lib_enc/vad_fx.c | 200 --------- 11 files changed, 1121 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ec24990e5..78413540e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,7 +88,6 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define HARM_PREPROC /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX */ #define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ #define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ #define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 51994c772..985c2852b 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -310,11 +310,7 @@ void amr_wb_enc_fx( } /* apply DTX hangover for CNG analysis */ -#ifdef HARM_PREPROC vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL, NULL ); -#else - vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL ); -#endif /*-----------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX enabled @@ -336,11 +332,7 @@ void amr_wb_enc_fx( move16(); } -#ifdef HARM_PREPROC dtx_fx( st, -1, -1, vad_flag_dtx, inp, Q_new ); -#else - dtx_fx( st, vad_flag_dtx, inp, Q_new ); -#endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index b9ec0c872..b6b4e5a34 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -63,11 +63,7 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate, /* _ None */ /*==================================================================================*/ -#ifdef HARM_PREPROC void dtx_fx( -#else -void dtx_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ @@ -82,7 +78,6 @@ void dtx_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; Word32 total_brate_ref; -#ifdef HARM_PREPROC Word16 flag_lp_noise; flag_lp_noise = 0; @@ -96,7 +91,6 @@ void dtx_ivas_fx( flag_lp_noise = 1; move16(); } -#endif total_brate_ref = st_fx->total_brate; move32(); @@ -113,11 +107,7 @@ void dtx_ivas_fx( test(); test(); test(); -#ifdef HARM_PREPROC last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || flag_lp_noise || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); -#else - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); -#endif test(); test(); @@ -125,11 +115,7 @@ void dtx_ivas_fx( test(); last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || -#ifdef HARM_PREPROC flag_lp_noise; -#else - LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); -#endif } /* Initialization */ @@ -244,11 +230,7 @@ void dtx_ivas_fx( test(); br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || -#ifdef HARM_PREPROC flag_lp_noise; -#else - LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 ); -#endif } test(); @@ -638,466 +620,6 @@ void dtx_ivas_fx( return; } -#ifndef HARM_PREPROC -/*==================================================================================*/ -/* FUNCTION : dtx_fx() */ -/*----------------------------------------------------------------------------------*/ -/* PURPOSE : Discontinuous transmission operation */ -/*----------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Encoder_State_Fx) st_fx : encoder state structure */ -/* _ (Word16) vad : vad flag Q0 */ -/* _ (Word16[]) speech_fx : Pointer to the speech frame qSpeech */ -/* _ (Word16) qSpeech : speech buffer qformat value */ -/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ -/*----------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */ -/* _ (Encoder_State_Fx) st_fx : encoder state structure */ -/*----------------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*==================================================================================*/ -void dtx_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad, /* i : vad flag for DTX Q0*/ - const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ - -) -{ - Word16 alpha, j, i, Q_speech2; - Word32 L_tmp; - DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - - Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; - - IF( st_fx->dtx_sce_sba != 0 ) - { - last_br_cng_flag = 1; - last_br_flag = 1; - br_dtx_flag = 1; - move16(); - move16(); - move16(); - } - ELSE - { - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); - - last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); - br_dtx_flag = 0; - move16(); - } - /* Initialization */ - IF( st_fx->ini_frame == 0 ) - { - st_fx->active_cnt = CNG_TYPE_HO; - move16(); - - st_fx->cng_type = FD_CNG; - move16(); - test(); - IF( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - st_fx->cng_type = LP_CNG; - move16(); - } - } - test(); - test(); - IF( st_fx->Opt_DTX_ON && vad == 0 && - GT_16( st_fx->ini_frame, 2 ) && /* CNG coding starts after 2 frames */ - st_fx->fd_cng_reset_flag == 0 && - NE_16( st_fx->last_core, AMR_WB_CORE ) && - st_fx->Opt_AMR_WB == 0 ) - { - test(); - test(); - test(); - IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) && - NE_32( st_fx->last_total_brate_cng, st_fx->total_brate ) && last_br_cng_flag ) - { - st_fx->total_brate = st_fx->last_total_brate_cng; - move32(); - test(); - IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) - { - st_fx->Opt_SC_VBR = 0; - move16(); - } - st_fx->rf_mode = st_fx->last_rf_mode_cng; - move16(); - st_fx->bwidth = st_fx->last_bwidth_cng; - move16(); - st_fx->codec_mode = st_fx->last_codec_mode_cng; - move16(); - } - test(); - test(); - IF( LE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) && last_br_flag ) - - { - st_fx->total_brate = st_fx->last_total_brate; - move32(); - test(); - IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) ) - { - st_fx->Opt_SC_VBR = 0; - move16(); - } - - st_fx->Opt_RF_ON = 0; - move16(); - test(); - test(); - test(); - IF( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && NE_16( st_fx->bwidth, NB ) ) - { - st_fx->Opt_RF_ON = 1; - move16(); - } - st_fx->rf_mode = st_fx->Opt_RF_ON; - move16(); - st_fx->bwidth = st_fx->last_bwidth; - move32(); - IF( ( st_fx->element_mode > EVS_MONO ) ) - { - st_fx->codec_mode = MODE1; - move16(); - } - ELSE - { - st_fx->codec_mode = get_codec_mode( st_fx->total_brate ); - } - } - } - - /*------------------------------------------------------------------------* - * Select SID or FRAME_NO_DATA frame if DTX is enabled - *------------------------------------------------------------------------*/ - - if ( st_fx->dtx_sce_sba == 0 ) - { - br_dtx_flag = LE_32( st_fx->total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || - EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st_fx->element_brate, IVAS_64k ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) ); - } - test(); - test(); - test(); - test(); - IF( st_fx->Opt_DTX_ON && vad == 0 && - GT_16( st_fx->ini_frame, 2 ) && /* CNG coding starts after 2 frames */ - br_dtx_flag && - st_fx->fd_cng_reset_flag == 0 ) - { - /* reset counter */ - st_fx->active_cnt = 0; - move16(); - - IF( st_fx->Opt_AMR_WB ) - { - st_fx->last_total_brate_cng = -1; - st_fx->last_rf_mode_cng = st_fx->rf_mode; - move32(); - move16(); - } - ELSE - { - st_fx->last_total_brate_cng = st_fx->total_brate; - st_fx->last_bwidth_cng = st_fx->bwidth; - st_fx->last_codec_mode_cng = st_fx->codec_mode; - move32(); - move16(); - move16(); - } - - IF( hDtxEnc->cnt_SID == 0 ) - { - /* this will be a SID frame */ - IF( st_fx->Opt_AMR_WB ) - { - st_fx->core_brate = SID_1k75; - move32(); - } - ELSE - { - st_fx->core_brate = SID_2k40; - move32(); - } - } - ELSE - { - /* this will be a no data frame */ - st_fx->core_brate = FRAME_NO_DATA; - move32(); - } - - test(); - test(); - IF( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB ) - { - /* force SID frame when switching from HQ core or AMR-WB IO mode into inactive frame in ACELP core when DTX is on */ - st_fx->core_brate = SID_2k40; - move32(); - } - - { - test(); - test(); - test(); - test(); - IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */ - { - test(); - test(); - IF( EQ_16( st_fx->element_mode, EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) ) - { - st_fx->codec_mode = MODE2; - move16(); - } - } - ELSE - { - st_fx->cng_type = LP_CNG; - move16(); - IF( st_fx->codec_mode == MODE2 ) - { - hTdCngEnc->lp_cng_mode2 = 1; - move16(); - } - st_fx->codec_mode = MODE1; - move16(); - } - } - - /* reset the bitstream (IVAS format signalling was already written) */ - IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) - { - reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); - } - } - - /*------------------------------------------------------------------------* - * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame) - *------------------------------------------------------------------------*/ - /* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */ - test(); - test(); - IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) ) - { - IF( hDtxEnc != NULL ) - { - hDtxEnc->cnt_SID = 0; - move16(); - - /* change SID update rate */ - /* first SID update is only 8 (3) frames after the active speech end */ - IF( !st_fx->Opt_AMR_WB ) - { - hDtxEnc->max_SID = FIXED_SID_RATE; - move16(); - } - ELSE - { - hDtxEnc->max_SID = 3; - move16(); /* first SID update is only 3 frames after the active speech end */ - } - - IF( LT_16( hDtxEnc->interval_SID, hDtxEnc->max_SID ) ) - { - hDtxEnc->max_SID = hDtxEnc->interval_SID; - move16(); /* change SID update rate */ - } - - hDtxEnc->cng_cnt = 0; - move16(); /* reset the counter of CNG frames for averaging */ - } - test(); - IF( GE_16( st_fx->active_cnt, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_SCE ) ) - { - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st_fx->cng_type, LP_CNG ) && ( ( EQ_16( st_fx->input_bwidth, NB ) && GT_32( st_fx->bckr_tilt_lt, 589824l /*9.f Q16*/ ) ) || ( GT_16( st_fx->input_bwidth, NB ) && GT_32( st_fx->bckr_tilt_lt, 2949120l /*45.f Q16*/ ) ) ) ) - { - st_fx->cng_type = FD_CNG; - move16(); - } - ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( ( EQ_16( st_fx->input_bwidth, NB ) && LT_32( st_fx->bckr_tilt_lt, 131072l /*2.f Q16*/ ) ) || ( GT_16( st_fx->input_bwidth, NB ) && LT_32( st_fx->bckr_tilt_lt, 655360l /*10.f Q16*/ ) ) ) ) - { - st_fx->cng_type = LP_CNG; - move16(); - } - } - st_fx->last_total_brate_cng = -1; - } - ELSE IF( st_fx->Opt_AMR_WB ) - { - st_fx->cng_type = LP_CNG; - move16(); - } - st_fx->active_cnt = add( st_fx->active_cnt, 1 ); - st_fx->active_cnt = s_min( st_fx->active_cnt, 200 ); - } - - /*------------------------------------------------------------------------* - * Update speech and background noise long-term energy - *------------------------------------------------------------------------*/ - IF( hDtxEnc != NULL ) - { - hDtxEnc->frame_ener_fx = L_deposit_l( 0 ); - - IF( st_fx->Opt_DTX_ON ) - { - Q_speech2 = add( shl( Q_speech, 1 ), 7 ); - FOR( j = 0; j < 16; j++ ) - { - L_tmp = L_mult0( *speech, *speech ); /*2*Q_speech*/ - speech++; - FOR( i = 1; i < L_FRAME / 16; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ - speech++; - } - hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */ - } - - /* Active speech (voiced) */ - - IF( EQ_16( st_fx->clas, VOICED_CLAS ) ) - { - alpha = ALPHA_ENER_SLOW_FX; - move16(); - if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) ) - { - alpha = ALPHA_ENER_FAST_FX; /*Q15 */ - move16(); - } - - /*st_fx->lt_ener_voiced_fx = alpha * st_fx->lt_ener_voiced_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/ - L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ - L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/ - hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ - - hDtxEnc->VarDTX_cnt_voiced = add( hDtxEnc->VarDTX_cnt_voiced, 1 ); - - hDtxEnc->VarDTX_cnt_voiced = s_min( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT ); - } - /* Background noise */ - ELSE IF( !st_fx->Opt_AMR_WB ) - { - alpha = ALPHA_ENER_SLOW_FX; /*Q15 */ - move16(); - if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) ) - { - alpha = ALPHA_ENER_FAST_FX; /*Q15 */ - move16(); - } - - /*st_fx->lt_ener_noise_fx = alpha * st_fx->lt_ener_noise_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/ - L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ - L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/ - hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/ - move32(); - - hDtxEnc->VarDTX_cnt_noise = add( hDtxEnc->VarDTX_cnt_noise, 1 ); - - hDtxEnc->VarDTX_cnt_noise = s_min( hDtxEnc->VarDTX_cnt_noise, MIN_CNT ); - } - } - } - - /* Update of the SID counter */ - update_SID_cnt_fx( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB ); - - /* Update encoded bandwidth */ - test(); - test(); - IF( st_fx->Opt_DTX_ON && ( st_fx->core_brate == SID_2k40 || st_fx->core_brate == FRAME_NO_DATA ) ) - { - - st_fx->bwidth = st_fx->last_bwidth; - move16(); - test(); - IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) ) - { - st_fx->bwidth = st_fx->last_bwidth_cng; - move16(); - } - - test(); - test(); - IF( st_fx->Opt_RF_ON && ( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) && ( EQ_16( st_fx->bwidth, NB ) ) ) - { - st_fx->codec_mode = MODE1; - move16(); - reset_rf_indices_fx( st_fx ); - st_fx->Opt_RF_ON = 0; - move16(); - st_fx->rf_mode = 0; - move16(); - } - - test(); - test(); - IF( st_fx->Opt_RF_ON && NE_32( st_fx->total_brate, ACELP_13k20 ) ) - { - reset_rf_indices_fx( st_fx ); - move16(); - st_fx->Opt_RF_ON = 0; - move16(); - st_fx->rf_mode = 0; - move16(); - } - - /* Set and limit the encoded bandwidth */ - IF( EQ_16( st_fx->codec_mode, MODE2 ) ) - { - Word16 n, bits_frame_nominal; - - UWord16 lsb; - Word16 tmpbandwidthMin; - - Mpy_32_16_ss( st_fx->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ - bits_frame_nominal = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ - - FOR( n = 0; n < FRAME_SIZE_NB; n++ ) - { - IF( EQ_16( FrameSizeConfig[n].frame_bits, bits_frame_nominal ) ) - { - BREAK; - } - } - if ( n == FRAME_SIZE_NB ) - { - assert( !"Bitrate not supported: not part of EVS" ); - } - tmpbandwidthMin = FrameSizeConfig[n].bandwidth_min; - if ( EQ_16( st_fx->rf_mode, 1 ) ) - { - tmpbandwidthMin = WB; - } - st_fx->bwidth = s_max( s_min( st_fx->bwidth, FrameSizeConfig[n].bandwidth_max ), tmpbandwidthMin ); - } - } - - return; -} -#endif /*---------------------------------------------------------------------* * update_SID_cnt() @@ -1544,97 +1066,6 @@ void td_cng_enc_init_fx( const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ) -#ifndef HARM_PREPROC -{ - - hTdCngEnc->cng_seed = RANDOM_INITSEED; - hTdCngEnc->cng_ener_seed = RANDOM_INITSEED; - hTdCngEnc->cng_ener_seed1 = RANDOM_INITSEED; - hTdCngEnc->lp_ener_fx = 0; - hTdCngEnc->old_enr_index = -1; - hTdCngEnc->Enew_fx = 0; - - hTdCngEnc->lp_sp_enr_fx = 0; - hTdCngEnc->last_allow_cn_step = 0; - move16(); - move32(); - move16(); - move16(); - move32(); - move16(); - move16(); - - IF( Opt_DTX_ON ) - { - hTdCngEnc->cng_hist_ptr = -1; - move16(); - set16_fx( hTdCngEnc->cng_lsp_hist_fx, 0, DTX_HIST_SIZE * M ); - set16_fx( hTdCngEnc->cng_ener_hist_fx, 0, DTX_HIST_SIZE ); - - hTdCngEnc->ho_hist_ptr = -1; - move16(); - hTdCngEnc->ho_sid_bw = L_deposit_l( 0 ); - set16_fx( hTdCngEnc->ho_lsp_hist_fx, 0, HO_HIST_SIZE * M ); - set32_fx( hTdCngEnc->ho_ener_hist_fx, 0, HO_HIST_SIZE ); - set32_fx( hTdCngEnc->ho_env_hist_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG ); - hTdCngEnc->ho_hist_size = 0; - move16(); - hTdCngEnc->act_cnt = 0; - move16(); - } - - set16_fx( hTdCngEnc->ho_16k_lsp, 0, HO_HIST_SIZE ); - hTdCngEnc->act_cnt2 = 0; - hTdCngEnc->num_ho = 0; - move16(); - move16(); - - hTdCngEnc->ho_circ_ptr = -1; - move16(); - set16_fx( hTdCngEnc->ho_lsp_circ_fx, 0, HO_HIST_SIZE * M ); - set32_fx( hTdCngEnc->ho_ener_circ_fx, 0, HO_HIST_SIZE ); - set32_fx( hTdCngEnc->ho_env_circ_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG ); - hTdCngEnc->ho_circ_size = 0; - hTdCngEnc->burst_ho_cnt = 0; - move16(); - move16(); - - hTdCngEnc->cng_buf_cnt = 0; - - - set32_fx( hTdCngEnc->lp_env_fx, 0, 20 ); - set32_fx( hTdCngEnc->cng_res_env_fx, 0, 20 * 8 ); - set16_fx( hTdCngEnc->exc_mem_fx, 0, 24 ); - set16_fx( hTdCngEnc->exc_mem1_fx, 0, 30 ); - set16_fx( hTdCngEnc->exc_mem2_fx, 0, 30 ); - set32_fx( hTdCngEnc->old_env_fx, 0, NUM_ENV_CNG ); - - /* SWB CNG/DTX */ - hTdCngEnc->last_wb_cng_ener_fx = -1541; /* Q8 */ - move16(); - hTdCngEnc->last_shb_cng_ener_fx = -1541; /* Q8 */ - move16(); - hTdCngEnc->mov_wb_cng_ener_fx = -1541; /* Q8 */ - move16(); - hTdCngEnc->mov_shb_cng_ener_fx = -1541; /* Q8 */ - move16(); - hTdCngEnc->shb_cng_ini_cnt = 1; - move16(); - hTdCngEnc->shb_NO_DATA_cnt = 0; - move16(); - hTdCngEnc->last_SID_bwidth = s_min( max_bwidth, SWB ); - hTdCngEnc->last_vad = 0; - move16(); - - return; -} - -void td_cng_enc_init_ivas_fx( - TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ - const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ -) -#endif { hTdCngEnc->cng_seed = RANDOM_INITSEED; move16(); diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index b58fe5177..4a55101d5 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -686,18 +686,7 @@ ivas_error init_encoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef HARM_PREPROC td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); -#else - IF( st->element_mode == EVS_MONO ) - { - td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); - } - ELSE - { - td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); - } -#endif } ELSE { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 8090f9ede..abe017232 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -168,13 +168,8 @@ ivas_error pre_proc_front_ivas_fx( Word32 *signal32_in_fx; Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */ CLDFB_SCALE_FACTOR cldfbScale; -#ifdef HARM_PREPROC Word16 temp1F_icatdmResampBuf_fx[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */ Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */ -#else - Word16 *temp1F_icatdmResampBuf_fx; - Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */ -#endif Word32 tmpF_fx[STEREO_DFT_BAND_MAX]; Word32 *res_cod_SNR_M_fx; Word16 snr_sum_he_fx; /* HE SAD parameters */ @@ -214,20 +209,8 @@ ivas_error pre_proc_front_ivas_fx( Word16 Qfact_PS, q_lf_E_fx; Word16 enerBuffer_fx_exp_buf[CLDFB_NO_CHANNELS_MAX]; Word32 bckr_temp[NB_BANDS]; -#ifndef HARM_PREPROC - mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) ); - temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) ); - set16_fx( fft_buff_fx, 0, 512 ); -#endif Word16 Q_min; Word16 input_frame_full; -#ifndef HARM_PREPROC - FOR( Word16 k = 0; k < CLDFB_NO_COL_MAX; k++ ) - { - set32_fx( realBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX ); - } -#endif Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; Word16 Q_inp_const = -1; move16(); @@ -771,11 +754,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { -#ifdef HARM_PREPROC *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ -#else - *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ -#endif move16(); } ELSE @@ -949,11 +928,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef HARM_PREPROC dtx_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); -#else - dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new ); -#endif test(); test(); @@ -1161,11 +1136,7 @@ ivas_error pre_proc_front_ivas_fx( Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) ); /* Q7 */ /* Detection of very short stable pitch period */ -#ifdef HARM_PREPROC StableHighPitchDetect_fx( element_mode, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx ); -#else - StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx ); -#endif /* 1/4 pitch precision improvement */ IF( LE_32( element_brate, IVAS_32k ) ) @@ -1590,10 +1561,6 @@ ivas_error pre_proc_front_ivas_fx( *Q_new = sub( *Q_new, Q_inp_const ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1 move16(); -#ifndef HARM_PREPROC - free( mem_decim_dummy_fx ); - free( temp1F_icatdmResampBuf_fx ); -#endif pop_wmops(); #ifdef FIX_2344_ALIGN_PREPROC return; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index b6df30eda..dcec13574 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -287,11 +287,7 @@ ivas_error front_vad_fx( move16(); } -#ifdef HARM_PREPROC vad_flag_dtx[n] = dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */ -#else - vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */ -#endif move16(); if ( EQ_16( n_chan, 1 ) ) @@ -604,11 +600,7 @@ ivas_error front_vad_spar_fx( corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */ -#ifdef HARM_PREPROC dtx_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); -#else - dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); -#endif /* linear prediction analysis */ alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */ @@ -693,11 +685,7 @@ ivas_error front_vad_spar_fx( st->old_pitch_la = st->pitch[2]; /* Q0 */ move16(); -#ifdef HARM_PREPROC StableHighPitchDetect_fx( IVAS_SCE /* needs to be other than EVS_MONO */, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); -#else - StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx ); -#endif IF( st->hSpMusClas != NULL ) { diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index d99a95d7a..a87edb39f 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -385,11 +385,7 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef HARM_PREPROC td_cng_enc_init_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); -#else - td_cng_enc_init_ivas_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth ); -#endif } /* allocate TCA data structure */ diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 51cda9c13..ff9a2ab64 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -211,210 +211,6 @@ void pitch_ol2_fx( return; } -#ifndef HARM_PREPROC -/*-------------------------------------------------------------------* - * StableHighPitchDetect() - * - * stable very short pitch detection - *-------------------------------------------------------------------*/ -void StableHighPitchDetect_fx( - Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */ - Word16 pitch[], /* i/o: OL pitch buffer */ - const Word16 voicing[], /* i : OL pitch gains */ - const Word16 wsp[], /* i : weighted speech */ - const Word16 localVAD, /* i : local VAD flag */ - Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains */ - Word16 *voicing0_sm, /* i/o: smoothed high pitch gains */ - Word16 *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy*/ - Word16 *predecision_flag, /* i/o: predecision flag */ - Word32 *diff_sm, /* i/o: smoothed pitch frequency difference */ - Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency */ - Word16 Q_new, - Word16 EspecdB[] ) -{ - Word16 i, pitch_freq_point; - Word16 T, Tp, pit_min; - Word16 energy0_16, energy1_16, ratio, voicing_m; - Word32 energy0, energy1, cor_max, diff, sum_energy; - const Word16 *pt_wsp; - Word16 tmp, tmp1, exp, diff16, cor_max16, exp1, exp2, pit_min_up; - Word32 L_tmp, L_tmp1; - Word16 Top; - - /*voicing = (voicing[0] + voicing[1] + voicing[2] )/3;*/ - L_tmp = L_mult( voicing[0], 10923 /*1/3 in Q15*/ ); - L_tmp = L_mac( L_tmp, voicing[1], 10923 /*1/3 in Q15*/ ); - L_tmp = L_mac( L_tmp, voicing[2], 10923 /*1/3 in Q15*/ ); - voicing_m = round_fx_sat( L_tmp ); - /**voicing_sm = 0.75f*(*voicing_sm) + 0.25f*voicing;*/ - *voicing_sm = round_fx( L_mac( L_mult( *voicing_sm, 24576 /*0.75f Q15*/ ), voicing_m, 8192 /*0.25f Q15*/ ) ); - move16(); - /* pitch_freq_point = (short)(L_FFT/(mult_fact*T_op[1])+0.5f);*/ - Top = pitch[1]; - move16(); - exp = norm_s( Top ); - tmp = div_s( shl( 1, sub( 14, exp ) ), Top ); /*Q(29 - exp)*/ - L_tmp = L_mult0( tmp, L_FFT ); /*Q(29 - exp)*/ - pitch_freq_point = extract_h( L_add( L_shl( L_tmp, sub( exp, 13 ) ), 32768 ) ); /* Q0*/ - diff = L_deposit_l( 0 ); - sum_energy = L_deposit_l( 0 ); - FOR( i = 1; i < 2 * pitch_freq_point; i++ ) - { - diff = L_add( diff, sub( EspecdB[pitch_freq_point], EspecdB[i] ) ); - sum_energy = L_add( sum_energy, EspecdB[i] ); - } - /*sum_energy /= (2*pitch_freq_point-1);*/ - tmp = sub( shl( pitch_freq_point, 1 ), 1 ); - exp = norm_s( tmp ); - tmp1 = div_s( shl( 1, sub( 14, exp ) ), tmp ); /*Q(29-exp)*/ - L_tmp = Mult_32_16( sum_energy, tmp1 ); - sum_energy = L_shl( L_tmp, sub( exp, 14 ) ); - /**diff_sm = 0.2f * diff + 0.8f * *diff_sm;*/ - *diff_sm = L_add( Mult_32_16( diff, 6554 ), Mult_32_16( *diff_sm, 26214 ) ); - move32(); - /**energy_sm = 0.2f * sum_energy + 0.8f * *energy_sm;*/ - *energy_sm = L_add( Mult_32_16( sum_energy, 6554 ), Mult_32_16( *energy_sm, 26214 ) ); - move32(); - /*diff /= sum_energy;*/ - - IF( sum_energy ) - { - exp = norm_l( sum_energy ); - tmp = extract_h( L_shl( sum_energy, exp ) ); - exp = sub( sub( 30, exp ), 7 ); - IF( tmp < 0 ) - { - tmp = abs_s( tmp ); - tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ - BASOP_SATURATE_WARNING_OFF_EVS - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); - BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); - } - ELSE - { - tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ - BASOP_SATURATE_WARNING_OFF_EVS - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); - BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); - } - } - ELSE - { - diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); - } - test(); - test(); - if ( LT_32( *diff_sm, -1280 /*-10.0f Q7*/ ) && LT_32( *energy_sm, 4928 /*38.5f Q7*/ ) && LT_16( diff16, -26214 /*-.8f Q15*/ ) ) - { - *predecision_flag = 1; - move16(); - } - test(); - test(); - if ( GT_32( *diff_sm, 1280 /*10.0f Q7*/ ) && GT_32( *energy_sm, 10624 /*83.0f Q7*/ ) && GT_16( diff16, 16384 /*.5 Q15*/ ) ) - { - *predecision_flag = 0; - move16(); - } - - /* short pitch possiblity pre-decision */ - maximum_fx( EspecdB, 7, &energy0_16 ); - maximum_fx( EspecdB + 8, 7, &energy1_16 ); - ratio = s_max( sub( energy1_16, energy0_16 ), 0 ); /*Q7 */ - /*ratio *= max(voicing,0);*/ - tmp = s_max( voicing_m, 0 ); - ratio = mult_r( ratio, tmp ); /*Q7*/ - /**LF_EnergyRatio_sm = (15*(*LF_EnergyRatio_sm) + ratio)/16;*/ - L_tmp = L_mult( ratio, 2048 ); - L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 ); - *LF_EnergyRatio_sm = round_fx( L_tmp ); - move16(); - test(); - if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) ) - { - *predecision_flag = 1; - move16(); - } - - if ( LT_16( *LF_EnergyRatio_sm, 2048 /*16.0f Q7*/ ) ) - { - *predecision_flag = 0; - move16(); - } - - /* short pitch candidate detection */ - Tp = pitch[1]; - move16(); - cor_max = 0; - move16(); - pt_wsp = wsp + 3 * L_SUBFR; - pit_min = PIT_MIN_DOUBLEEXTEND; - move16(); - pit_min_up = PIT_MIN; - move16(); - FOR( T = pit_min; T <= pit_min_up; T++ ) - { - energy1 = Dot_product( pt_wsp, pt_wsp - T, L_SUBFR ); - test(); - IF( ( GT_32( energy1, cor_max ) ) || ( EQ_16( T, pit_min ) ) ) - { - cor_max = L_add( energy1, 0 ); - Tp = T; - move16(); - } - } - energy0 = Dot_product12( pt_wsp, pt_wsp, L_SUBFR, &exp1 ); - exp1 = sub( exp1, shl( Q_new, 1 ) ); - energy1 = Dot_product12( pt_wsp - Tp, pt_wsp - Tp, L_SUBFR, &exp2 ); - exp2 = sub( exp2, shl( Q_new, 1 ) ); - /* cor_max *= inv_sqrt( energy0*energy1 );*/ - L_tmp = Mult_32_32( energy0, energy1 ); - exp = norm_l( L_tmp ); - L_tmp1 = L_shl( L_tmp, exp ); - - exp = 31 - exp - ( 31 - exp1 - exp2 ); - move16(); - L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ - cor_max = Mult_32_32( cor_max, L_tmp1 ); - exp = 31 - ( shl( Q_new, 1 ) + 1 ) - ( 31 - exp ) + 31; - cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ - /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ - *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); - move16(); - - /* final short pitch detection */ - test(); - test(); - test(); - *flag_spitch = 0; - move16(); - IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && - ( GT_16( *voicing0_sm, 16384 ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 21299 ) ) ) ) - { - *flag_spitch = 1; - move16(); - pitch[0] = Tp; - move16(); - pitch[1] = Tp; - move16(); - pitch[2] = Tp; - move16(); - } - - return; -} - - -/*-------------------------------------------------------------------* - * pitch_ol2() - * - * Open-loop pitch precision improvement with 1/4 resolution - * The pitch is searched in the interval vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst, NULL ); -#else - vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst ); -#endif /*----------------------------------------------------------------* * NB/WB/SWB/FB bandwidth detector @@ -336,11 +332,7 @@ void pre_proc_fx( * Select SID or FRAME_NO_DATA frame if DTX enabled *-----------------------------------------------------------------*/ -#ifdef HARM_PREPROC dtx_fx( st, -1, -1, vad_flag_dtx, inp_12k8, *Q_new ); -#else - dtx_fx( st, vad_flag_dtx, inp_12k8, *Q_new ); -#endif /*----------------------------------------------------------------* * Adjust FD-CNG Noise Estimator @@ -458,13 +450,8 @@ void pre_proc_fx( move16(); /* Detection of very short stable st->pitch period (MODE1 bit-rates) */ -#ifdef HARM_PREPROC StableHighPitchDetect_fx( EVS_MONO, &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx ); -#else - StableHighPitchDetect_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, - &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx ); -#endif /* 1/4 pitch precision improvement */ IF( LE_32( st->total_brate, ACELP_24k40 ) ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2f606063e..e18c097f5 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -140,15 +140,6 @@ Word16 correlation_shift_fx( ); void dtx_fx( -#ifndef HARM_PREPROC - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad, /* i : vad flag Q0*/ - const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/ - Word16 Q_speech /* i : Q factor for speech */ -); - -void dtx_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ @@ -158,18 +149,6 @@ void dtx_ivas_fx( ); Word16 dtx_hangover_addition_fx( -#ifndef HARM_PREPROC - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad_flag, /* i Q0 */ - const Word16 lp_snr, /* i Q8 */ - const Word16 cldfb_subtraction, /* i Q0 number of DTX-HO frames CLDFB wants to reduce */ - Word16 *vad_hover_flag_ptr, - VAD_HANDLE hVAD, /* i/o: VAD data handle */ - NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ -); - -Word16 ivas_dtx_hangover_addition_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -577,9 +556,7 @@ void speech_music_classif_fx( ); void StableHighPitchDetect_fx( -#ifdef HARM_PREPROC const Word16 element_mode, /* i : element mode */ -#endif Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/ Word16 pitch[], /* i/o: OL pitch buffer */ const Word16 voicing[], /* i : OL pitch gains */ @@ -593,24 +570,6 @@ void StableHighPitchDetect_fx( Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency */ Word16 Q_new, Word16 EspecdB[] ); -#ifndef HARM_PREPROC - -void StableHighPitchDetect_ivas_fx( - Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */ - Word16 pitch[], /* i/o: OL pitch buffer Q0 */ - const Word16 voicing[], /* i : OL pitch gains Q15 */ - const Word16 wsp[], /* i : weighted speech Qx */ - const Word16 localVAD, - Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains Q15 */ - Word16 *voicing0_sm, /* i/o: smoothed high pitch gains Q15 */ - Word16 *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy Q7 */ - Word16 *predecision_flag, /* i/o: predecision flag */ - Word32 *diff_sm, /* i/o: smoothed pitch frequency difference Q7 */ - Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency Q7 */ - Word16 Q_new, - Word16 EspecdB[] /* Q7 */ -); -#endif void swb_bwe_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -1168,13 +1127,6 @@ void td_cng_enc_init_fx( const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ ); -#ifndef HARM_PREPROC -void td_cng_enc_init_ivas_fx( - TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/ - const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/ -); -#endif void dtx_enc_init_fx( Encoder_State *st, /* i : Encoder state handle */ const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 21abc589d..5f1356def 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -229,204 +229,6 @@ static void sign_thr_snr_acc_fx( *-----------------------------------------------------------------*/ Word16 dtx_hangover_addition_fx( -#ifndef HARM_PREPROC - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 vad_flag, /* i Q0 */ - const Word16 lp_snr, /* i Q8 */ - const Word16 cldfb_subtraction, /* i Q0 number of DTX-HO frames CLDFB wants to reduce */ - Word16 *vad_hover_flag_ptr, - VAD_HANDLE hVAD, /* i/o: VAD data handle */ - NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ -) -{ - Word16 hangover_short_dtx; /* Q0 */ - Word16 flag_dtx; /* Q0 */ - Word16 tmp; /* Q0 */ - if ( hNoiseEst == NULL ) - { - hNoiseEst = st_fx->hNoiseEst; - move16(); - } - - if ( hVAD == NULL ) - { - move16(); - hVAD = st_fx->hVAD; - } - - - flag_dtx = 0; - move16(); - - /* Determine initial hangover length */ - hangover_short_dtx = 2; - move16(); - - test(); - test(); - if ( ( ( LT_16( lp_snr, ( 16 * 256 ) ) ) && ( st_fx->input_bwidth != NB ) ) || ( GT_16( hVAD->prim_act_he_fx, 31130 ) ) ) /*.95*Q15*/ - { - hangover_short_dtx = 3; - move16(); - } - - /* Adjust hangover according to activity history */ - IF( GT_16( hVAD->vad_prim_cnt_16, 12 ) ) /* 12 requires roughly > 80% primary activity */ - { - hangover_short_dtx = add( hangover_short_dtx, 2 ); - } - - IF( GT_16( hVAD->vad_flag_cnt_50, 40 ) ) /* 40 requires roughtly > 80% flag activity */ - { - hangover_short_dtx = add( hangover_short_dtx, 5 ); - } - - /* Keep hangover_short lower than maximum hangover count */ - if ( GT_16( hangover_short_dtx, HANGOVER_LONG_FX - 1 ) ) - { - hangover_short_dtx = ( HANGOVER_LONG_FX - 1 ); - move16(); - } - - /* Only allow short HO if not sufficient active frames in clean speech*/ - - tmp = 3; - move16(); /* default for EVS*/ - if ( EQ_16( st_fx->core, AMR_WB_CORE ) ) - { - tmp = 2; - move16(); /* default for AMRWBIO*/ - } - - /* need to be a bit stricter with the DTXHO in very clean WB, SWB cond for EVS12k8VAD section */ - test(); - test(); - if ( ( NE_16( st_fx->input_bwidth, NB ) ) /* WB or SWB or FB */ - && ( NE_16( st_fx->core, AMR_WB_CORE ) ) && ( GT_16( lp_snr, 25 * 256 ) ) ) - { - tmp = 2; - move16(); - } - - /* limit dtx hangover addition up to "tmp" frames in clean cond */ - IF( tmp != 0 ) - { - test(); - test(); - test(); - if ( ( GT_16( hangover_short_dtx, tmp ) ) && ( ( LT_16( hVAD->vad_prim_cnt_16, 7 ) ) || ( ( GT_16( lp_snr, ( 16 * 256 ) ) ) && ( LT_16( hVAD->prim_act_he_fx, 27853 ) ) /*0.85f*2^15 */ - ) ) ) - { - hangover_short_dtx = tmp; - move16(); - } - } - - - /* hangover adjustment from combined FFT+CLDFBVAD */ - IF( NE_16( st_fx->core, AMR_WB_CORE ) ) - { - hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); /* Q0 */ - hangover_short_dtx = s_max( hangover_short_dtx, 0 ); - } - - IF( vad_flag != 0 ) /* Speech present */ - { - flag_dtx = 1; - move16(); - - /* Add hangover after sufficient # of active frames or sufficient activity during last second */ - test(); - if ( ( GE_16( hVAD->nb_active_frames, ACTIVE_FRAMES_FX ) ) || ( GT_16( hVAD->vad_flag_cnt_50, 45 ) ) ) /* 45 requires roughly > 90% flag activity */ - { - hVAD->hangover_cnt_dtx = 0; - move16(); - } - - /* inside HO period */ - test(); - IF( ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) && ( hVAD->hangover_cnt_dtx != 0 ) ) - { - hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); /* Q0 */ - move16(); - } - hVAD->hangover_terminate_flag = 0; - move16(); /* float fix FIX_HO_TERMINATE */ - - /* Music hangover when music detected */ - test(); - test(); - test(); - if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */ - { - hVAD->hangover_cnt_music = 0; - move16(); - } - - /* inside Music HO period */ - test(); - IF( ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) && ( hVAD->hangover_cnt_music != 0 ) ) - { - hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 ); - move16(); - } - } - ELSE - { - /* Reset the counter of speech frames necessary to start hangover algorithm */ - IF( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) /* inside HO period */ - { - hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); - move16(); - } - IF( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) /* inside HO period */ - { - hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 ); - move16(); - } - - /* fast terminate DTX hangover if st->hangover_terminate_flag is set */ - IF( hVAD->hangover_terminate_flag != 0 ) - { - hVAD->hangover_cnt = HANGOVER_LONG_FX; - move16(); - hVAD->hangover_cnt_dtx = HANGOVER_LONG_FX; - move16(); - hVAD->hangover_terminate_flag = 0; - move16(); - /* Only shorten music hangover when low energy frames */ - if ( LT_16( hNoiseEst->Etot_lp_fx, 20 * 256 ) ) - { - hVAD->hangover_cnt_music = HANGOVER_LONG_MUSIC_FX; - move16(); - } - } - - if ( LE_16( hVAD->hangover_cnt_dtx, hangover_short_dtx ) ) /* "hard" hangover */ - { - flag_dtx = 1; - move16(); - } - - if ( LE_16( hVAD->hangover_cnt_music, 15 ) ) /* "hard" hangover music */ - { - flag_dtx = 1; - move16(); - } - } - - - test(); - if ( flag_dtx != 0 && st_fx->localVAD == 0 ) - { - *vad_hover_flag_ptr = 1; - move16(); - } - - return flag_dtx; -} -Word16 ivas_dtx_hangover_addition_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ const Word16 lp_snr, /* i Q8 */ @@ -549,7 +351,6 @@ Word16 ivas_dtx_hangover_addition_fx( move16(); /* float fix FIX_HO_TERMINATE */ /* Music hangover when music detected */ -#ifdef HARM_PREPROC test(); test(); test(); @@ -562,7 +363,6 @@ Word16 ivas_dtx_hangover_addition_fx( } } ELSE -#endif { test(); test(); -- GitLab From d0e32552402a39fe6b1d19faff139e77f3f05e4e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:24:54 +0100 Subject: [PATCH 16/26] [cleanup] accept FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN --- lib_com/options.h | 1 - lib_enc/enc_gen_voic_fx.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 78413540e..d3e224d4d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN /* Dolby: Fix missing update of low-rate pitch gain in the S/M classifier */ #define FIX_2257_INCR_GUARD_BITS /* FhG: take correct rendering frame-size into account for guard-bits calculation */ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 5e0a67dbc..f7ba1ce2f 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -310,15 +310,8 @@ void encod_gen_voic_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } -#ifndef FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN - IF( st_fx->element_mode == EVS_MONO ) - { -#endif /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#ifndef FIX_2306_MISSING_UPDATE_LOWRATE_PITCH_GAIN - } -#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames -- GitLab From 5d7f6b54e52b5a85a229acf778a4c5667205eb17 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:25:32 +0100 Subject: [PATCH 17/26] [cleanup] accept FIX_2257_INCR_GUARD_BITS --- lib_com/cldfb_fx.c | 2 -- lib_com/options.h | 1 - 2 files changed, 3 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 49ca0627c..f0c0d8158 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -595,9 +595,7 @@ void cldfbAnalysis_ts_fx_var_q( IF( NE_16( h_cldfb->Q_cldfb_state, *q_cldfb ) ) { Word16 norm_st = L_norm_arr( timeBuffer_fx, offset ); -#ifdef FIX_2257_INCR_GUARD_BITS norm_st = sub( norm_st, find_guarded_bits_fx( shr( h_cldfb->no_channels, 2 ) ) ); -#endif IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) ) { scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ); diff --git a/lib_com/options.h b/lib_com/options.h index d3e224d4d..f1179d81a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2257_INCR_GUARD_BITS /* FhG: take correct rendering frame-size into account for guard-bits calculation */ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ -- GitLab From 49fca380f64187357a00cf6471cdc3790e2541bc Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:26:12 +0100 Subject: [PATCH 18/26] [cleanup] accept FIX_2315_AGC_MEMORY_RESET --- lib_com/options.h | 1 - lib_dec/core_switching_dec_fx.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f1179d81a..f0f793557 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ #define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 1454f8c41..ec5a641da 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1539,14 +1539,9 @@ ivas_error core_switching_pre_dec_fx( /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); -#ifndef FIX_2315_AGC_MEMORY_RESET - set16_fx( st->agc_mem_fx, 0, 2 ); -#endif } -#ifdef FIX_2315_AGC_MEMORY_RESET set16_fx( st->agc_mem_fx, 0, 2 ); -#endif st->mem_deemph_fx = 0; move16(); IF( !st->last_con_tcx ) -- GitLab From b1148c8286c141818b299b5134d0c98222bc2e1b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:26:59 +0100 Subject: [PATCH 19/26] [cleanup] accept FIX_2312_CONDITION_MISSING_GSC_DEC_LR --- lib_com/gs_gains_fx.c | 4 ---- lib_com/options.h | 1 - 2 files changed, 5 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 61e7144e8..35d802de7 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -1074,10 +1074,8 @@ Word16 gsc_gaindec_fx( idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); -#ifdef FIX_2312_CONDITION_MISSING_GSC_DEC_LR IF( !( coder_type == INACTIVE && st_fx->tdm_LRTD_flag == 0 && EQ_16( st_fx->idchan, 1 ) ) || GT_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) { -#endif idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 ); @@ -1118,13 +1116,11 @@ Word16 gsc_gaindec_fx( move16(); y_gainQ_fx[14] = y_gain_tmp3_fx[3]; /*Q12*/ move16(); -#ifdef FIX_2312_CONDITION_MISSING_GSC_DEC_LR } ELSE { set16_fx( y_gainQ_fx + 3, 0, MBANDS_GN16k - 3 ); } -#endif } ELSE { diff --git a/lib_com/options.h b/lib_com/options.h index f0f793557..21f84c317 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ #define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ -- GitLab From 1f539ba780ba915a7198eb93912d3c6cb78f2d60 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:27:41 +0100 Subject: [PATCH 20/26] [cleanup] accept FIX_2313_HF_RESET_16KHZ --- lib_com/options.h | 1 - lib_dec/core_switching_dec_fx.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 21f84c317..6cf18783d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ #define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index ec5a641da..4d2948ba9 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1222,11 +1222,7 @@ ivas_error core_switching_pre_dec_fx( move16(); test(); -#ifdef FIX_2313_HF_RESET_16KHZ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#else - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#endif { 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 @@ -1649,11 +1645,7 @@ ivas_error core_switching_pre_dec_fx( } test(); -#ifdef FIX_2313_HF_RESET_16KHZ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#else - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#endif { 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 @@ -1704,11 +1696,7 @@ ivas_error core_switching_pre_dec_fx( move16(); test(); -#ifdef FIX_2313_HF_RESET_16KHZ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#else - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) -#endif { hf_synth_reset_fx( st->hBWE_zero ); set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -- GitLab From de08a5eb27ba1c73ca8a219df4717ee4256c1347 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:28:24 +0100 Subject: [PATCH 21/26] [cleanup] accept OPT_2308_FIND_TARGET --- lib_com/options.h | 1 - lib_enc/find_tar_fx.c | 45 ------------------------------------------- 2 files changed, 46 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6cf18783d..df29d7f16 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define OPT_2308_FIND_TARGET /* VA: Issue 2308, Speeds up computation and improve accuracy of the impulse response */ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index a315c4301..9a236731f 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -173,12 +173,8 @@ void find_targets_ivas_fx( { Word16 i; Word16 temp[M + 6 * L_SUBFR]; /* error of quantization */ -#ifndef OPT_2308_FIND_TARGET - Word16 scale, scaleq, j, d, s, s2, tmp; -#else Word16 scale, scaleq, j, d, s, tmp; Word32 s2; -#endif Word16 Aqs[M + 1]; Word32 h1_32[6 * L_SUBFR]; Word16 sf; @@ -238,57 +234,17 @@ void find_targets_ivas_fx( { Copy( p_Aq, Aqs, M + 1 ); /* Q12 */ s = add( scaleq, 1 ); -#ifndef OPT_2308_FIND_TARGET - s2 = shr( 16384, d ); -#else s2 = L_shr( ( 16384 << 16 ), d ); -#endif } ELSE { Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */ s = add( scale, 1 ); -#ifndef OPT_2308_FIND_TARGET - s2 = 16384; - move16(); -#else s2 = ( 16384 << 16 ); move32(); -#endif } set32_fx( h1_32, 0, L_subfr ); -#ifndef OPT_2308_FIND_TARGET - FOR( i = 0; i < M; i++ ) - { - Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ - FOR( j = 1; j <= i; j++ ) - { - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ - } - h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ - move32(); - } - - Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ - FOR( j = 1; j <= M; j++ ) - { - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ - } - h1_32[M] = W_extract_l( Ltmp64 ); /* Q27 */ - move32(); - - FOR( i = M + 1; i < L_subfr; i++ ) - { - Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ - FOR( j = 2; j <= M; j++ ) - { - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ - } - h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ - move32(); - } -#else FOR( i = 0; i < M; i++ ) { Ltmp64 = W_mult_32_16( s2, Ap[i] ); /* Q27 */ @@ -319,7 +275,6 @@ void find_targets_ivas_fx( move32(); } -#endif sf = sub( L_norm_arr( h1_32, L_subfr ), 1 ); Copy_Scale_sig32_16( h1_32, h1, L_subfr, sf ); // Q11 + sf -- GitLab From 110b4754d9514f53c06c2845f4613b7c621c5af6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:29:09 +0100 Subject: [PATCH 22/26] [cleanup] accept OPT_NBE_2311_HARM_GSC_GAIN --- lib_com/gs_gains_fx.c | 542 ------------------------------------------ lib_com/options.h | 1 - lib_com/prot_fx.h | 26 -- lib_enc/gs_enc_fx.c | 16 -- 4 files changed, 585 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 35d802de7..cc48a5e63 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -392,9 +392,7 @@ void Ener_per_band_comp_ivas_fx( static void GSC_gain_adj( const Word16 coder_type, /* i : Coder type */ -#ifdef OPT_NBE_2311_HARM_GSC_GAIN const Word16 Mbands_gn, /* i : Number of band */ -#endif const Word32 core_brate, /* i : Bit rate */ const Word16 mean_g, /* i : Average gain Q12 */ Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */ @@ -404,24 +402,14 @@ static void GSC_gain_adj( { /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ Word16 Gain_off, i; -#ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 Fac_div; Fac_div = 102; move16(); -#endif -#ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) -#else - IF( coder_type != INACTIVE ) -#endif { -#ifdef OPT_NBE_2311_HARM_GSC_GAIN FOR( i = 0; i < Mbands_gn; i++ ) -#else - FOR( i = 0; i < MBANDS_GN; i++ ) -#endif { old_y_gain[i] = y_gain_tmp[i]; move16(); @@ -434,7 +422,6 @@ static void GSC_gain_adj( Gain_off = 0; move16(); -#ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */ { @@ -444,9 +431,6 @@ static void GSC_gain_adj( move16(); } ELSE IF( LE_32( core_brate, ACELP_7k20 ) ) -#else - IF( LE_32( core_brate, ACELP_7k20 ) ) -#endif { Gain_off = 32767; move16(); /* 8 -> Q12 */ @@ -478,11 +462,7 @@ static void GSC_gain_adj( old_y_gain[i] = y_gain_tmp[i]; move16(); /*y_gainQ[i] = y_gain_tmp[i]+mean_4g[0]-(i*(Gain_off/20.f)/((float) Mbands_gn));*/ -#ifdef OPT_NBE_2311_HARM_GSC_GAIN y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, Fac_div /* 20/MBANDS_GN in Q15 */ ) ) ) ); -#else - y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 102 /* 20/MBANDS_GN in Q15 */ ) ) ) ); -#endif move16(); } } @@ -490,483 +470,6 @@ static void GSC_gain_adj( return; } -#ifndef OPT_NBE_2311_HARM_GSC_GAIN -/*-------------------------------------------------------------------* - * GSC_gain_adj_ivas_fx() - * - * Quantization of the energy per band - *-------------------------------------------------------------------*/ - -static void GSC_gain_adj_ivas_fx( - const Word16 coder_type, /* i : Coder type */ - const Word16 Mbands_gn, /* i : Number of band */ - const Word32 core_brate, /* i : Bit rate */ - const Word16 mean_g, /* i : Average gain Q12 */ - Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */ - const Word16 *y_gain_tmp, /* i : Dequantized gains */ - Word16 *y_gainQ /* i/o: Output gains Q12 */ -) -{ - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - Word16 Gain_off, i; - - test(); - IF( ( coder_type != INACTIVE ) && NE_16( coder_type, UNVOICED ) ) - { - FOR( i = 0; i < Mbands_gn; i++ ) - { - old_y_gain[i] = y_gain_tmp[i]; - move16(); - y_gainQ[i] = add( y_gain_tmp[i], mean_g ); - move16(); - } - } - ELSE - { - Gain_off = 0; - move16(); - - test(); - IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) - { - Gain_off = 18432; - move16(); /* 9 -> Q11 */ - } - IF( LE_32( core_brate, ACELP_7k20 ) ) - { - Gain_off = 16384; - move16(); /* 8 -> Q11 */ - } - ELSE IF( LE_32( core_brate, ACELP_8k00 ) ) - { - Gain_off = 13517; - move16(); /* 6.6f -> Q11 */ - } - ELSE IF( LE_32( core_brate, ACELP_9k60 ) ) - { - Gain_off = 9830; - move16(); /*4.8f-> Q11 */ - } - ELSE IF( LE_32( core_brate, ACELP_11k60 ) ) - { - Gain_off = 7168; - move16(); /* 3.5f -> Q11 */ - } - ELSE IF( LE_32( core_brate, ACELP_13k20 ) ) - { - Gain_off = 6144; - move16(); /* 3.0f -> Q11 dB */ - } - - /*mimic ACELP decay of energy for low rates*/ - FOR( i = 0; i < Mbands_gn; i++ ) - { - old_y_gain[i] = y_gain_tmp[i]; - move16(); - y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 205 /* 20/MBANDS_GN in Q16 */ ) ) ) ); - move16(); - } - } - - return; -} - -/*-------------------------------------------------------------------* - * GSC_gain_DQ() - * - * Form the final vector after gain quantization/Dequantization - * Common to both encoder and decoder - *-------------------------------------------------------------------*/ - -static void GSC_gain_DQ_fx( - const Word16 element_mode, /* i : element mode */ - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word16 coder_type, /* i : Coder type */ - const Word16 Mbands_gn, /* i : Number of band */ - const Word32 core_brate, /* i : Core bitrate */ - const Word16 mean_g, /* i : Average gain Q12 */ - const Word16 *Gain_in, /* i : Unquantized gain vector Q12 */ - Word16 *Gain_out /* o : Level adjusted unquantized gain vector Q12 */ -) -{ - Word16 Gain_off; - Word16 i; - - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - Gain_off = 0; - move16(); - - test(); - IF( coder_type == INACTIVE || EQ_16( coder_type, UNVOICED ) ) - { - test(); - IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) - { - Gain_off = 1843; // 9/20 in Q12 - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_7k20 ) ) - { - Gain_off = 1638; // 8/20 in Q12; /* 0 dB */ - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_8k00 ) ) - { - Gain_off = 1351; // 6.6f/20 in Q12 /* ~-3.3 dB */ - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_9k60 ) ) - { - Gain_off = 983; // 4.8f/20 in Q12 /* ~-2.4 dB */ - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_11k60 ) ) - { - Gain_off = 717; // 3.5f/20 in Q12 /* ~-2.4 dB */ - move16(); - } - ELSE IF( LE_32( core_brate, ACELP_13k20 ) ) - { - Gain_off = 614; // 3.0f/20 in Q12 /* ~-2.4 dB */ - move16(); - } - } - - test(); - IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) ) - { - FOR( i = 0; i < Mbands_gn; i++ ) - { - Gain_out[i] = add( Gain_in[i], mean_g ); // Q12 - move16(); - } - } - ELSE - { - /*mimic ACELP decay of energy for low rates*/ - test(); - IF( element_mode == EVS_MONO && EQ_16( enc_dec, DEC ) ) - { - /* This is to keep EVS mono bit-exact with the standard (there might be a small desynchronization between encoder and decoder but there is no real quality or interop. issue) */ - FOR( i = 0; i < Mbands_gn; i++ ) - { - Gain_out[i] = add( Gain_out[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12 - move16(); - // Gain_out[i] += mean_g - i * ( Gain_off / 20.f ) / ( (float) Mbands_gn ); - } - } - ELSE - { - FOR( i = 0; i < Mbands_gn; i++ ) - { - Gain_out[i] = add( Gain_in[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12 - move16(); - // Gain_out[i] = Gain_in[i] + mean_g - ( i * ( Gain_off / 20.f ) / ( (float) Mbands_gn ) ); - } - } - } - - return; -} - - -/*-------------------------------------------------------------------* - * gsc_gainQ() - * - * Quantization of the energy per band - *-------------------------------------------------------------------*/ - -Word16 gsc_gainQ_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 element_mode, /* i : element mode */ - const Word16 idchan, /* i : channel ID */ - const Word16 y_gain4[], - /* i : Energy per band */ // Q12 - Word16 y_gainQ[], - /* o : quantized energy per band */ // Q12 - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 L_frame, /* i : frame length */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word32 core_brate_inp /* i : true core bitrate */ -) -{ - Word16 y_gain_tmp[MBANDS_GN16k]; - Word16 y_gain_tmp2[MBANDS_GN16k]; - Word16 i, idx_g = 0; - move16(); - Word16 mean_4g_fx[1], ftmp1_fx; - Word16 Mbands_gn = MBANDS_GN; - move16(); - Word16 y_gain_tmp3[MBANDS_GN]; - Word32 L_tmp; - - if ( EQ_16( L_frame, L_FRAME16k ) ) - { - Mbands_gn = MBANDS_GN16k; - move16(); - } - - mean_4g_fx[0] = 0; - move32(); - - test(); - test(); - IF( ( EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && bwidth == NB ) - { - L_tmp = 0; - move32(); - FOR( i = 0; i < 10; i++ ) - { - L_tmp = L_add( L_tmp, y_gain4[i] ); - } - L_tmp = L_sub( Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ), 2457 /* 0.6f in Q12 */ ); // Q12 - ftmp1_fx = extract_l( L_tmp ); - FOR( i = 0; i < Mbands_gn; i++ ) - { - IF( LT_16( y_gain4[i], ftmp1_fx ) ) - { - y_gain_tmp2[i] = ftmp1_fx; /*Q12*/ - } - ELSE - { - y_gain_tmp2[i] = y_gain4[i]; /*Q12*/ - } - move16(); - } - - /* Quantized mean gain without clipping */ - L_tmp = 0; - move32(); - FOR( i = 0; i < 10; i++ ) - { - L_tmp = L_add( L_tmp, y_gain4[i] ); - } - L_tmp = Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ); // Q12 - mean_4g_fx[0] = extract_l( L_tmp ); // Q12 - move16(); - idx_g = vquant_fx( mean_4g_fx, Gain_meanNB_fx, mean_4g_fx, Gain_mean_dicNB_fx, 1, 64 ); - push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); - - FOR( i = 0; i < Mbands_gn; i++ ) - { - y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12 - move16(); - } - - if ( LT_16( y_gain_tmp[9], -1229 /* -0.3f in Q12 */ ) ) - { - y_gain_tmp[9] = -1229; /* -0.3f in Q12 */ - move16(); - } - - set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 ); - idx_g = vquant_fx( y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - IF( LT_32( core_brate, ACELP_9k60 ) ) - { - idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NB_fx, 3, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NB_fx, 4, 16 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); - } - ELSE - { - idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NBHR_fx, 3, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NBHR_fx, 4, 128 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); - } - - test(); - IF( LE_32( core_brate, ACELP_9k60 ) && coder_type == INACTIVE ) - { - /* Some energy is needed in high band for stat_noise_uv_enc() to be functional in inactive speech */ - y_gain_tmp[10] = mean_fx( y_gain_tmp + 6, 3 ); /*Q12*/ - move16(); - y_gain_tmp[11] = mean_fx( y_gain_tmp + 7, 3 ); /*Q12*/ - move16(); - y_gain_tmp[12] = mean_fx( y_gain_tmp + 8, 3 ); /*Q12*/ - move16(); - y_gain_tmp[13] = mean_fx( y_gain_tmp + 9, 3 ); /*Q12*/ - move16(); - y_gain_tmp[14] = mean_fx( y_gain_tmp + 10, 3 ); /*Q12*/ - move16(); - y_gain_tmp[15] = mean_fx( y_gain_tmp + 11, 3 ); /*Q12*/ - move16(); - } - ELSE - { - set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 ); - } - } - ELSE - { - L_tmp = 0; - move32(); - FOR( i = 0; i < 16; i++ ) - { - L_tmp = L_add( L_tmp, y_gain4[i] ); - } - L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12 - ftmp1_fx = extract_l( L_tmp ); - FOR( i = 0; i < Mbands_gn; i++ ) - { - IF( LT_16( y_gain4[i], sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) ) - { - y_gain_tmp2[i] = sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ ); - } - ELSE IF( GT_16( y_gain4[i], add( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) ) - { - y_gain_tmp2[i] = add( ftmp1_fx, 2457 /* 0.6 in Q12*/ ); - } - ELSE - { - y_gain_tmp2[i] = y_gain4[i]; - } - move16(); - } - - L_tmp = 0; - move32(); - FOR( i = 0; i < 16; i++ ) - { - L_tmp = L_add( L_tmp, y_gain_tmp2[i] ); - } - L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12 - mean_4g_fx[0] = extract_l( L_tmp ); // Q12 - move16(); - idx_g = vquant_fx( mean_4g_fx, mean_m_fx, mean_4g_fx, mean_gain_dic_fx, 1, 64 ); - push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 ); - - /* Subtraction of the average gain */ - FOR( i = 0; i < Mbands_gn; i++ ) - { - y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12 - move16(); - } - - IF( LT_32( core_brate, ACELP_9k60 ) ) - { - /* prediction and quantization of the average gain */ - - /*--------------------------------------------------------------------------------------* - * Quantization of the first 8 bands - * Keep only 4 bands out of the last 8 bands - *--------------------------------------------------------------------------------------*/ - - Copy( y_gain_tmp, y_gain_tmp2, 8 ); - - y_gain_tmp2[8] = y_gain_tmp[8]; - move16(); - y_gain_tmp2[9] = y_gain_tmp[10]; - move16(); - y_gain_tmp2[10] = y_gain_tmp[12]; - move16(); - y_gain_tmp2[11] = y_gain_tmp[14]; - move16(); - - idx_g = 0; - move16(); - idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - test(); - test(); - test(); - IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) ) - { - idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - /*----------------------------------------------------------------------* - * Vector quantization of the first 8 bands + quantization of the 4 bands out of the last 8 - * Interpolation of the last 4 bands Q to create bands 8-16 - *----------------------------------------------------------------------*/ - - idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 ); - - /* Update to quantized vector */ - Copy( y_gain_tmp2, y_gain_tmp, 8 ); - - Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 ); - set16_fx( y_gain_tmp + 8, 0, 8 ); - fft_rel_fx( y_gain_tmp2 + 8, 4, 2 ); - - Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 ); - y_gain_tmp[15] = y_gain_tmp2[11]; - move16(); - ifft_rel_fx( y_gain_tmp + 8, 8, 3 ); - - FOR( i = 8; i < 16; i++ ) - { - y_gain_tmp[i] = shl( mult( y_gain_tmp[i], 23101 /* 1.41 in Q14 */ ), 1 ); /*Q12*/ - move16(); - } - - y_gain_tmp[8] = y_gain_tmp3[0]; - move16(); - y_gain_tmp[10] = y_gain_tmp3[1]; - move16(); - y_gain_tmp[12] = y_gain_tmp3[2]; - move16(); - y_gain_tmp[14] = y_gain_tmp3[3]; - move16(); - } - ELSE - { - Copy( y_gain_tmp2, y_gain_tmp, 3 ); - set16_fx( y_gain_tmp + 3, 0, MBANDS_GN16k - 3 ); - } - } - ELSE - { - IF( EQ_16( L_frame, L_FRAME ) ) - { - idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); - - idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); - } - ELSE - { - idx_g = vquant_fx( y_gain_tmp, YG_mean16HR_fx, y_gain_tmp, YG_dicHR_1_fx, 4, 128 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 ); - - idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16HR_fx + 4, y_gain_tmp + 4, YG_dicHR_2_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16HR_fx + 8, y_gain_tmp + 8, YG_dicHR_3_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16HR_16kHz_fx, y_gain_tmp + 12, YG_dicHR_4_16kHz_fx, 4, 64 ); - push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); - - idx_g = vquant_fx( y_gain_tmp + 16, YG_meanL2G_16kHz_fx, y_gain_tmp + 16, YG_dicL2G_16kHz_fx, 2, 8 ); - push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 ); - } - } - } - - GSC_gain_DQ_fx( element_mode, ENC, coder_type, Mbands_gn, core_brate, mean_4g_fx[0], y_gain_tmp, y_gainQ ); - - return mean_4g_fx[0]; -} -#endif /*==========================================================================*/ /* FUNCTION : Word16 gsc_gaindec_ivas_fx() */ @@ -1158,19 +661,7 @@ Word16 gsc_gaindec_fx( } } -#ifndef OPT_NBE_2311_HARM_GSC_GAIN - IF( st_fx->element_mode == EVS_MONO ) - { - GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); - } - ELSE - { - /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ - GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); - } -#else GSC_gain_adj( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx ); -#endif return mean_4g_fx; } @@ -1182,7 +673,6 @@ Word16 gsc_gaindec_fx( * Quantization of the energy per band *-------------------------------------------------------------------*/ -#ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 idchan, /* i : channel ID */ @@ -1195,43 +685,23 @@ Word16 gsc_gainQ_fx( const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ const Word32 core_brate_inp /* i : true core bitrate */ ) -#else -Word16 gsc_gainQ_fx( /*Q12*/ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 y_gain4[], /* i : Energy per band Q12 */ - Word16 y_gainQ[], /* o : quantized energy per band Q12 */ - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth /* i : input signal bandwidth */ -) -#endif { -#ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 y_gain_tmp[MBANDS_GN16k], y_gain_tmp2[MBANDS_GN16k]; -#else - Word16 y_gain_tmp[MBANDS_GN], y_gain_tmp2[MBANDS_GN]; -#endif Word16 i, idx_g = 0; move16(); Word16 mean_4g[1] = { 0 }, tmp16, tmp1, tmp2; move16(); Word16 Mbands_gn = MBANDS_GN; -#ifdef OPT_NBE_2311_HARM_GSC_GAIN Word16 y_gain_tmp3[MBANDS_GN16k]; -#else - Word16 y_gain_tmp3[MBANDS_GN]; -#endif Word16 cnt; Word32 L_tmp; mean_4g[0] = 0; -#ifdef OPT_NBE_2311_HARM_GSC_GAIN if ( EQ_16( L_frame, L_FRAME16k ) ) { Mbands_gn = MBANDS_GN16k; move16(); } -#endif test(); test(); @@ -1385,13 +855,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); -#ifdef OPT_NBE_2311_HARM_GSC_GAIN test(); test(); test(); IF( !( coder_type == INACTIVE && tdm_LRTD_flag == 0 && EQ_16( idchan, 1 ) ) || GT_32( core_brate_inp, GSC_LRES_GAINQ_LIMIT ) ) { -#endif idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 ); idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 ); @@ -1424,20 +892,16 @@ Word16 gsc_gainQ_fx( /*Q12*/ move16(); y_gain_tmp[14] = y_gain_tmp3[3]; move16(); -#ifdef OPT_NBE_2311_HARM_GSC_GAIN } ELSE { Copy( y_gain_tmp2, y_gain_tmp, 3 ); set16_fx( y_gain_tmp + 3, 0, MBANDS_GN16k - 3 ); } -#endif } ELSE { -#ifdef OPT_NBE_2311_HARM_GSC_GAIN IF( EQ_16( L_frame, L_FRAME ) ) -#endif { idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 ); @@ -1451,7 +915,6 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 ); push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 ); } -#ifdef OPT_NBE_2311_HARM_GSC_GAIN ELSE { idx_g = vquant_fx( y_gain_tmp, YG_mean16HR_fx, y_gain_tmp, YG_dicHR_1_fx, 4, 128 ); @@ -1469,16 +932,11 @@ Word16 gsc_gainQ_fx( /*Q12*/ idx_g = vquant_fx( y_gain_tmp + 16, YG_meanL2G_16kHz_fx, y_gain_tmp + 16, YG_dicL2G_16kHz_fx, 2, 8 ); push_indice( hBstr, IND_Y_GAIN_HF, idx_g, 3 ); } -#endif } } /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ -#ifdef OPT_NBE_2311_HARM_GSC_GAIN GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); -#else - GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ ); -#endif return mean_4g[0]; /*Q12*/ } diff --git a/lib_com/options.h b/lib_com/options.h index df29d7f16..a317b3ec5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bde8b871d..289923aa5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1504,19 +1504,8 @@ Word16 gsc_gaindec_fx( const Word16 bwidth_fx /* i : i signal bandwidth */ ); -#ifndef OPT_NBE_2311_HARM_GSC_GAIN Word16 gsc_gainQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 y_gain4[], /* i : Energy per band Q13 */ - Word16 y_gainQ[], /* o : quantized energy per band Q13 */ - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth /* i : signal bandwidth */ -); - -Word16 gsc_gainQ_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 element_mode, /* i : element mode */ const Word16 idchan, /* i : channel ID */ const Word16 y_gain4[], /* i : Energy per band Q12 */ Word16 y_gainQ[], /* o : quantized energy per band Q12 */ @@ -1528,21 +1517,6 @@ Word16 gsc_gainQ_ivas_fx( const Word32 core_brate_inp /* i : true core bitrate */ ); -#else -Word16 gsc_gainQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 idchan, /* i : channel ID */ - const Word16 y_gain4[], /* i : Energy per band Q12 */ - Word16 y_gainQ[], /* o : quantized energy per band Q12 */ - const Word32 core_brate, /* i : Core rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 L_frame, /* i : frame length */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word32 core_brate_inp /* i : true core bitrate */ -); -#endif - void fer_energy_fx( const Word16 L_frame, /* i : frame length */ const Word16 clas, /* i : frame classification */ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 79b419633..4037aaa5e 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -997,25 +997,9 @@ void gsc_enc_fx( i--; } -#ifndef OPT_NBE_2311_HARM_GSC_GAIN -#ifdef FIX_1904_HARM_GSC_ENC - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be BE */ - { - mean_gain = gsc_gainQ_ivas_fx( hBstr, st_fx->element_mode, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); - *tmp_noise = mult( mean_gain, 20480 ); // 20480 => 10 in Q11 - } - ELSE -#endif - { - mean_gain = gsc_gainQ_fx( hBstr, /*st_fX->element_mode, st_fx->idchan,IVAS_CODE*/ Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth /*, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate*/ ); - *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ - } - move16(); -#else mean_gain = gsc_gainQ_fx( hBstr, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ move16(); -#endif /*--------------------------------------------------------------------------------------* * Frequency encoder -- GitLab From 70adb62b3fc50f91b54e273e2326887c334b6b26 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:30:07 +0100 Subject: [PATCH 23/26] [cleanup] accept FIX_2261_REMOVE_LP_RESCALING --- lib_com/options.h | 1 - lib_enc/acelp_core_enc_fx.c | 14 -------------- lib_enc/ivas_core_enc_fx.c | 9 --------- lib_enc/ivas_front_vad_fx.c | 3 --- lib_enc/ivas_ism_enc_fx.c | 6 ------ 5 files changed, 33 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a317b3ec5..f71b23a4c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,7 +108,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 1aa59f93f..920d100e4 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1067,13 +1067,6 @@ ivas_error acelp_core_enc_ivas_fx( move16(); st->hLPDmem->q_mem_syn = st->Q_syn; move16(); -#ifndef FIX_2261_REMOVE_LP_RESCALING - // Scaling Aq to Q12 - FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) - { - Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); - } -#endif /* synthesis at 12.8kHz sampling rate */ syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn ); @@ -1208,13 +1201,6 @@ ivas_error acelp_core_enc_ivas_fx( st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15 move16(); } -#ifndef FIX_2261_REMOVE_LP_RESCALING - // Scaling Aq to Q12 - FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) - { - Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); - } -#endif test(); IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) { diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 334b84581..3a19ad171 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -223,9 +223,6 @@ ivas_error ivas_core_enc_fx( // fft_buff_fx_exp = add(fft_buff_fx_exp,1); FOR( i = 0; i < st->nb_subfr; i++ ) { -#ifndef FIX_2261_REMOVE_LP_RESCALING - Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 -#endif Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } @@ -349,12 +346,6 @@ ivas_error ivas_core_enc_fx( test(); IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { -#ifndef FIX_2261_REMOVE_LP_RESCALING - FOR( i = 0; i < st->nb_subfr; i++ ) - { - Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 - } -#endif TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; Word16 Q_spec_old, L_spec; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index dcec13574..bab92da6e 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -631,9 +631,6 @@ ivas_error front_vad_spar_fx( } relE_fx = sub( Etot_fx[0], extract_h( st->lp_speech_32fx ) ); -#ifndef FIX_2261_REMOVE_LP_RESCALING - Scale_sig( A_fx, ( L_FRAME / L_SUBFR ) * ( M + 1 ), -2 ); // Q12 -#endif st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */ st->mem_wsp_q = Q_inp_12k8; move16(); diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 02d0b86f0..40f683925 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -238,12 +238,6 @@ ivas_error ivas_ism_enc_fx( /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ -#ifndef FIX_2261_REMOVE_LP_RESCALING - FOR( i = 0; i < hSCE->hCoreCoder[0]->nb_subfr; i++ ) - { - Scale_sig( &A_fx[sce_id][0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[sce_id][0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 - } -#endif set16_fx( old_wsp_fx[sce_id][0], 0, L_WSP ); q_old_wsp = Q15; -- GitLab From 9208e1f558183c7cd112b2cd3376866680ec2e3b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:30:56 +0100 Subject: [PATCH 24/26] [cleanup] accept NONBE_OPT_2239_IVAS_FILTER_PROCESS --- lib_com/ivas_filters_fx.c | 199 -------------------------------- lib_com/ivas_prot_fx.h | 16 --- lib_com/ivas_stat_com.h | 7 -- lib_com/ivas_transient_det_fx.c | 62 ---------- lib_com/options.h | 1 - lib_dec/ivas_lfe_dec_fx.c | 4 - lib_enc/ivas_lfe_enc_fx.c | 4 - 7 files changed, 293 deletions(-) diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index ffbdf7187..bcba83b89 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -67,40 +67,18 @@ void ivas_filters_init_fx( filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN]; move32(); move32(); -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31; filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31; move16(); move16(); -#else - filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1; - filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1; - move16(); - move16(); -#endif } -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; move64(); move64(); move64(); -#else - filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; - move32(); - move32(); - move32(); - filter_state->state_e[0][0] = 0; - filter_state->state_e[0][1] = 0; - filter_state->state_e[0][2] = 0; - move16(); - move16(); - move16(); -#endif } ELSE { @@ -117,7 +95,6 @@ void ivas_filters_init_fx( move32(); move32(); move32(); -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); filter_state->num_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ), Q31 ); @@ -126,19 +103,8 @@ void ivas_filters_init_fx( move16(); move16(); move16(); -#else - filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i]; - filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN]; - filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2]; - filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3]; - move16(); - move16(); - move16(); - move16(); -#endif } -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; @@ -151,38 +117,11 @@ void ivas_filters_init_fx( move64(); move64(); move64(); -#else - filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0; - filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0; - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - filter_state->state_e[0][0] = 0; - filter_state->state_e[0][1] = 0; - filter_state->state_e[0][2] = 0; - filter_state->state_e[1][0] = 0; - filter_state->state_e[1][1] = 0; - filter_state->state_e[1][2] = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); -#endif } return; } -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, const Word16 stage, const Word64 in ); /*-----------------------------------------------------------------------------------------* @@ -309,141 +248,3 @@ void ivas_filter_process_fx64( return; } -#else -static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); - -/*-----------------------------------------------------------------------------------------* - * Function ivas_filter_process() - * - * Process call for selecting the type filter - *-----------------------------------------------------------------------------------------*/ - -void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : number of samples to filter */ - Word16 q_factor ) -{ - Word16 pIn_Out_e[L_FRAME_MAX]; - Word16 i; - - SWITCH( filter_state->order ) - { - case IVAS_FILTER_ORDER_1: - set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length ); - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e ); - /* Scale pIn_Out_fx back to input Q */ - FOR( i = 0; i < length; i++ ) - { - pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor) - move32(); - } - BREAK; - case IVAS_FILTER_ORDER_4: - set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length ); - /* biquad-1 */ - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e ); - /* biquad-2 */ - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, pIn_Out_e ); - /* Scale pIn_Out_fx back to input Q */ - FOR( i = 0; i < length; i++ ) - { - pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor) - move32(); - } - BREAK; - default: - BREAK; - } - - return; -} - -void ivas_filter_process_exp_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ - const Word16 length, /* i : number of samples to filter */ - Word16 *pIn_Out_e ) -{ - SWITCH( filter_state->order ) - { - case IVAS_FILTER_ORDER_1: - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e ); - /* Scale pIn_Out_fx back to input Q */ - BREAK; - case IVAS_FILTER_ORDER_4: - /* biquad-1 */ - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e ); - /* biquad-2 */ - ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, pIn_Out_e ); - /* Scale pIn_Out_fx back to input Q */ - BREAK; - default: - BREAK; - } - - return; -} - -/*-----------------------------------------------------------------------------------------* - * Function ivas_iir_2_filter() - * - * Process call for filtering a signal - *-----------------------------------------------------------------------------------------*/ - -static void ivas_iir_2_filter_fx( - ivas_filters_process_state_t *filter_state, - Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e) - const Word16 length, - const Word16 stage, - Word16 *pIn_Out_e ) -{ - Word16 i, j; - - Word32 *pIn_fx = pIn_Out_fx; - Word32 *pOut_fx = pIn_Out_fx; - Word32 tmp_pIn_buf_i_fx; - Word16 tmp_pIn_buf_i_e; - - Word32 L_tmp_prod, L_tmp; - Word16 L_prod_e, L_tmp_e; - - FOR( i = 0; i < length; i++ ) - { - tmp_pIn_buf_i_fx = pIn_fx[i]; - move32(); - tmp_pIn_buf_i_e = pIn_Out_e[i]; - move16(); - - L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ); // Q31 -(pIn_Out_e[i]+ filter_state->num_e[stage][0]) - L_prod_e = add( pIn_Out_e[i], filter_state->num_e[stage][0] ); - - pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &pIn_Out_e[i] ); // Q31 - pIn_Out_e[i] - move32(); - - FOR( j = 1; j < filter_state->filt_len; j++ ) - { - L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e - L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e ); - - L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e - - L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] ) - L_prod_e = add( pIn_Out_e[i], filter_state->den_e[stage][j] ); - - filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1] - move32(); - /*In case when exponent is less than -31 the value is very small and negligible hence resetting it to zero to avoid exponent overflow*/ - IF( LT_16( filter_state->state_e[stage][j - 1], -31 ) ) - { - filter_state->state_fx[stage][j - 1] = 0; - move32(); - filter_state->state_e[stage][j - 1] = 0; - move16(); - } - } - } - - return; -} -#endif diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 2f280d47d..31dfb1ea2 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3775,7 +3775,6 @@ void ivas_lfe_enc_fx( BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS void ivas_filter_process_fx32( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ @@ -3787,21 +3786,6 @@ void ivas_filter_process_fx64( Word64 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length /* i : number of samples to filter */ ); -#else -void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i : signal subject to filtering */ - const Word16 length, /* i : number of samples to filter */ - Word16 q_factor -); - -void ivas_filter_process_exp_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ - const Word16 length, /* i : number of samples to filter */ - Word16 *pIn_Out_e -); -#endif ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 2d8df33a0..d3737fa19 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -655,16 +655,9 @@ typedef struct ivas_filters_process_state_t Word16 filt_len; Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 num_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; Word16 den_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -#else - Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; - Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN]; -#endif } ivas_filters_process_state_t; diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 2b200933a..9c54f91f4 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -44,11 +44,7 @@ *------------------------------------------------------------------------------------------*/ #define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS #define IVAS_TDET_PARM_ENV_EPS_fx ( ( (Word64) 21474 ) << 12 ) // Q11+32 -#else -#define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 -#endif #define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29 #define IVAS_TDET_PARM_TRANS_THR ( 107374182 ) // Q30 @@ -396,7 +392,6 @@ void ivas_td_decorr_get_ducking_gains_fx( Word32 duck_mult_fac = hTranDet->duck_mult_fac; /*Q29*/ move32(); -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS Word64 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; Word32 fast_fx, slow_fx; Word16 fast_e, slow_e; @@ -465,63 +460,6 @@ void ivas_td_decorr_get_ducking_gains_fx( hTranDet->out_duck_gain = out_duck_gain; /*Q30*/ move32(); } -#else - Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k]; - Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k]; - - Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/ - - set16_fx( e_fast_e, 31 - Q11, L_FRAME48k ); - - /* env hpf */ - ivas_filter_process_exp_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, e_fast_e ); - - - FOR( i = 0; i < frame_len; i++ ) - { - // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ - e_fast_fx[i] = BASOP_Util_Add_Mant32Exp( L_abs( e_fast_fx[i] ), e_fast_e[i], IVAS_TDET_PARM_ENV_EPS_fx, 0, &e_fast_e[i] ); - move32(); - e_slow_fx[i] = e_fast_fx[i]; - move32(); - e_slow_e[i] = e_fast_e[i]; - move16(); - } - - /* env fast*/ - ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e ); - - /* env slow */ - ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e ); - - IF( tdet_flag ) - { - FOR( i = 0; i < frame_len; i++ ) - { - in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/ - pIn_duck_gains[i] = in_duck_gain; /*Q30*/ - move32(); - } - hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ - move32(); - } - ELSE - { - FOR( i = 0; i < frame_len; i++ ) - { - in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/ - pIn_duck_gains[i] = in_duck_gain; /*Q30*/ - move32(); - out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], e_fast_e[i], e_slow_fx[i], e_slow_e[i], duck_mult_fac ); /*Q30*/ - pOut_duck_gains[i] = out_duck_gain; /*Q30*/ - move32(); - } - hTranDet->in_duck_gain = in_duck_gain; /*Q30*/ - move32(); - hTranDet->out_duck_gain = out_duck_gain; /*Q30*/ - move32(); - } -#endif return; } diff --git a/lib_com/options.h b/lib_com/options.h index f71b23a4c..04289323f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,7 +115,6 @@ /* #################### Start BASOP optimization switches ############################ */ -#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */ #define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 31ad2acf2..20b2ac7c7 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -407,11 +407,7 @@ void ivas_lfe_dec_fx( IF( hLFE->filter_state.order > 0 ) { /* Low Pass Filter */ -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame ); -#else - ivas_filter_process_fx( &hLFE->filter_state, output_lfe_ch, output_frame, q_out ); -#endif } /* add delay to make overall max(block_offset, 11.5) */ diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 9ed990f8a..a76db70a1 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -684,11 +684,7 @@ void ivas_lfe_lpf_enc_apply_fx( const Word16 input_frame /* i : input frame length per channel */ ) { -#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame ); -#else - ivas_filter_process_fx( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 ); -#endif return; } -- GitLab From 32e2dc3685167e224d61f9990bf85f4b82ef2c87 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:31:44 +0100 Subject: [PATCH 25/26] [cleanup] accept NONBE_OPT_2193_EIG2X2 --- lib_com/options.h | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 371 ------------------ 2 files changed, 372 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 04289323f..1986a5d7b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,7 +115,6 @@ /* #################### Start BASOP optimization switches ############################ */ -#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */ /* #################### End BASOP optimization switches ############################ */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 011d4b253..f20e58c42 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3463,7 +3463,6 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( return; } -#ifdef NONBE_OPT_2193_EIG2X2 static Word32 eig2x2_div_fx( Word32 num, Word32 den ); static Word32 eig2x2_div_fx( Word32 num, Word32 den ) @@ -3474,7 +3473,6 @@ static Word32 eig2x2_div_fx( Word32 num, Word32 den ) } return div_w_newton( num, den ); } -#endif static void eig2x2_fx( const Word32 E1_fx, /*q_E*/ @@ -3489,7 +3487,6 @@ static void eig2x2_fx( Word32 D_fx[BINAURAL_CHANNELS], /*q_D*/ Word16 *q_D ) { -#ifdef NONBE_OPT_2193_EIG2X2 Word32 pm_fx, add_fx; Word32 tmp1, tmp2, e1, e2, c_re, c_im, c0_im, c1_im; Word32 s0_fx, s1_fx, nval0_fx, nval1_fx; @@ -3801,374 +3798,6 @@ static void eig2x2_fx( move32(); Uim_fx[i11][1] = Mpy_32_32( c1_im, nval1_fx ); move32(); -#else - Word16 chA, chB, ch; - Word32 s_fx, normVal_fx, crossSquare_fx, a_fx, pm_fx, add_fx; - Word32 tmp1, tmp2, tmp3, e1, e2, c_re, c_im; - Word16 q_crossSquare, q_tmp1, q_tmp2, exp_tmp3, exp, q_e, q_c, q_U_1, q_U_2; - Word32 epsilon_mant = 1180591621; - Word16 epsilon_exp = -39; - move32(); - move16(); - - pm_fx = 0; - move32(); - add_fx = 0; - move32(); - q_tmp2 = 0; - move16(); - - FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) - { - FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) - { - Ure_fx[chA][chB] = 0; - move32(); - Uim_fx[chA][chB] = 0; - move32(); - } - } - - exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 ); - c_re = L_shl( Cre_fx, exp ); - c_im = L_shl( Cim_fx, exp ); - q_c = add( q_C, exp ); - - exp = sub( get_min_scalefactor( E1_fx, E2_fx ), 2 ); - e1 = L_shl( E1_fx, exp ); - e2 = L_shl( E2_fx, exp ); - q_e = add( q_E, exp ); - - /*crossSquare_fx = (c_re * c_re) + (c_im * c_im) - a_fx = (e1 + e2) * (e1 + e2) - 4.0f * ((e1 * e2) - crossSquare_fx) = (e1 - e2)^2 + 4 * crossSquare_fx - pm_fx = 0.5f * sqrtf(max(0.0f, a_fx)) - add_fx = 0.5f * (e1 + e2)*/ - - IF( L_and( c_re == 0, c_im == 0 ) ) - { - /* if c_re = 0 and c_im = 0, then crossSquare_fx = (c_re * c_re) + (c_im * c_im) = 0 - a_fx = (E1 - E2)^2 - pm_fx = 0.5 * sqrt(max(0, a_fx)) = 0.5 * max(0, (e1 - e2)) */ - crossSquare_fx = 0; - move32(); - q_crossSquare = Q31; - move16(); - pm_fx = L_shr( L_max( 0, L_abs( L_sub( e1, e2 ) ) ), 1 ); - q_tmp2 = q_e; - move16(); - } - ELSE - { - crossSquare_fx = Madd_32_32( Mpy_32_32( c_re, c_re ), c_im, c_im ); - q_crossSquare = sub( add( q_c, q_c ), 31 ); - IF( EQ_32( e1, e2 ) ) - { - /* if e1 - e2 = 0, then a_fx = 4 * crossSquare_fx - pm_fx = 0.5 * sqrt(max(0, 4 * crossSquare_fx)) = sqrt(0, crossSquare_fx)*/ - test(); - test(); - IF( EQ_32( c_re, 0 ) || LT_32( L_abs( c_re ), ONE_IN_Q15 ) ) - { - /* if c_re = 0, then crossSquare_fx = c_im^2 => pm_fx = max(0, c_im) */ - pm_fx = L_max( 0, L_abs( c_im ) ); - q_tmp2 = q_c; - move16(); - } - ELSE IF( c_im == 0 || LT_32( L_abs( c_im ), ONE_IN_Q15 ) ) - { - /* if c_im = 0, then crossSquare_fx = c_re^2 => pm_fx = max(0, c_re) */ - pm_fx = L_max( 0, L_abs( c_re ) ); - q_tmp2 = q_c; - move16(); - } - ELSE - { - exp = sub( 31, q_crossSquare ); - pm_fx = Sqrt32( L_max( 0, crossSquare_fx ), &exp ); - q_tmp2 = sub( 31, exp ); - } - } - ELSE - { - /* if e1, e2 >> c_re, c_im then (e1 - e2)^2 ~ (e1 - e2)^2 + 4 * crossSquare_fx - a_fx = (E1 - E2)^2 - pm_fx = 0.5 * sqrt(max(0, a_fx)) = 0.5 * max(0, (e1 - e2)) */ - - IF( GT_16( sub( q_c, q_e ), Q15 ) ) - { - pm_fx = L_shr( L_max( 0, L_abs( L_sub( e1, e2 ) ) ), 1 ); - q_tmp2 = q_e; - move16(); - } - ELSE - { - tmp2 = crossSquare_fx; - move32(); - q_tmp2 = sub( q_crossSquare, 2 ); // crossSquare_fx = 4 * crossSquare_fx; - - tmp1 = Mpy_32_32( L_sub( e1, e2 ), L_sub( e1, e2 ) ); - q_tmp1 = sub( add( q_e, q_e ), 31 ); - - a_fx = BASOP_Util_Add_Mant32Exp( tmp1, sub( 31, q_tmp1 ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); // (E1 - E2)^2 + 4 * crossSquare_fx - q_tmp2 = sub( 31, q_tmp2 ); - - exp = sub( 31, q_tmp2 ); - pm_fx = Sqrt32( L_max( 0, L_sub( a_fx, 1 ) ), &exp ); - pm_fx = L_shr( pm_fx, 1 ); - q_tmp2 = sub( 31, exp ); - } - } - } - // add_fx = 0.5 * (e1 + e2) - add_fx = L_shr( L_add( e1, e2 ), 1 ); - q_tmp1 = q_e; - move16(); - - IF( LT_16( q_tmp1, q_tmp2 ) ) - { - D_fx[0] = L_add( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ); - move32(); - D_fx[1] = L_max( 0, L_sub( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ) ); - move32(); - *q_D = sub( q_tmp1, 1 ); - move16(); - } - ELSE - { - D_fx[0] = L_add( L_shr( add_fx, add( sub( q_tmp1, q_tmp2 ), 1 ) ), L_shr( pm_fx, 1 ) ); - move32(); - D_fx[1] = L_max( 0, L_sub( L_shr( add_fx, add( sub( q_tmp1, q_tmp2 ), 1 ) ), L_shr( pm_fx, 1 ) ) ); - move32(); - *q_D = sub( q_tmp2, 1 ); - move16(); - } - - /* Numeric case, when input is practically zeros */ - // IF( D_fx[0] < EPSILON_FX ) - - IF( LT_32( L_shl_sat( D_fx[0], sub( sub( 31, *q_D ), EPSILON_EXP ) ), EPSILON_MANT ) ) - { - Ure_fx[0][0] = ONE_IN_Q31; - move32(); - Ure_fx[1][1] = ONE_IN_Q31; - move32(); - *q_U = Q31; - move16(); - - return; - } - - /* Numeric case, when input is near an identity matrix with a gain */ - tmp1 = Mpy_32_32( INV_1000_Q31, add_fx ); - - IF( LT_16( q_tmp1, q_tmp2 ) ) - { - IF( LT_32( L_shr( pm_fx, sub( q_tmp2, q_tmp1 ) ), tmp1 ) ) - { - Ure_fx[0][0] = ONE_IN_Q30; - move32(); - Ure_fx[1][1] = ONE_IN_Q30; - move32(); - *q_U = Q30; - move16(); - - return; - } - } - ELSE - { - IF( LT_32( pm_fx, L_shr( tmp1, sub( q_tmp1, q_tmp2 ) ) ) ) - { - Ure_fx[0][0] = ONE_IN_Q30; - move32(); - Ure_fx[1][1] = ONE_IN_Q30; - move32(); - *q_U = Q30; - move16(); - - return; - } - } - - q_U_1 = 0; - q_U_2 = 0; - move16(); - move16(); - - /* Eigenvectors */ - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - Word16 q_diff = sub( q_e, *q_D ); - IF( q_diff > 0 ) - { - tmp1 = L_sub( D_fx[ch], L_shr( e1, q_diff ) ); - tmp2 = L_sub( D_fx[ch], L_shr( e2, q_diff ) ); - q_tmp1 = *q_D; - move16(); - } - ELSE - { - tmp1 = L_sub( L_shl( D_fx[ch], q_diff ), e1 ); - tmp2 = L_sub( L_shl( D_fx[ch], q_diff ), e2 ); - q_tmp1 = q_e; - move16(); - } - - IF( GT_32( L_abs( tmp2 ), L_abs( tmp1 ) ) ) - { - s_fx = tmp2; - move32(); - exp = sub( norm_l( s_fx ), 1 ); - tmp2 = Mpy_32_32( s_fx, s_fx ); - q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); - - tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); - q_tmp2 = sub( 31, q_tmp2 ); - - tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); - - tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); - exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); - normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 - q_tmp2 = sub( 31, exp ); - - q_diff = sub( q_c, q_tmp1 ); - IF( q_diff > 0 ) - { - c_re = L_shr( c_re, q_diff ); - c_im = L_shr( c_im, q_diff ); - q_c = q_tmp1; - move16(); - } - ELSE - { - s_fx = L_shl( s_fx, q_diff ); - q_tmp1 = q_c; - move16(); - } - - Ure_fx[0][ch] = Mpy_32_32( s_fx, normVal_fx ); - move32(); - Ure_fx[1][ch] = Mpy_32_32( c_re, normVal_fx ); - move32(); - Uim_fx[1][ch] = Mpy_32_32( c_im, normVal_fx ); - move32(); - q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 ); - - IF( q_U_2 != 0 ) - { - q_diff = sub( q_U_2, q_U_1 ); - IF( q_diff > 0 ) - { - Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], q_diff ); - Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], q_diff ); - Uim_fx[0][ch - 1] = L_shr( Uim_fx[0][ch - 1], q_diff ); - q_U_2 = q_U_1; - move32(); - move32(); - move32(); - move16(); - } - ELSE IF( GT_16( q_U_1, q_U_2 ) ) - { - Ure_fx[1][ch] = L_shl( Ure_fx[1][ch], q_diff ); - Ure_fx[0][ch] = L_shl( Ure_fx[0][ch], q_diff ); - Uim_fx[1][ch] = L_shl( Uim_fx[1][ch], q_diff ); - q_U_1 = q_U_2; - move32(); - move32(); - move32(); - move16(); - } - } - q_U_2 = q_U_1; - move16(); - } - ELSE - { - s_fx = tmp1; - move32(); - - exp = sub( norm_l( s_fx ), 1 ); - tmp2 = Mpy_32_32( s_fx, s_fx ); - q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); - - tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); - q_tmp2 = sub( 31, q_tmp2 ); - - tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); - - tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); - exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); - normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 - q_tmp2 = sub( 31, exp ); - - q_diff = sub( q_c, q_tmp1 ); - IF( q_diff > 0 ) - { - c_re = L_shr( c_re, q_diff ); - c_im = L_shr( c_im, q_diff ); - q_c = q_tmp1; - move16(); - } - ELSE - { - s_fx = L_shl( s_fx, q_diff ); - q_tmp1 = q_c; - move16(); - } - - Ure_fx[1][ch] = Mpy_32_32( s_fx, normVal_fx ); - move32(); - Ure_fx[0][ch] = Mpy_32_32( c_re, normVal_fx ); - move32(); - Uim_fx[0][ch] = Mpy_32_32( L_negate( c_im ), normVal_fx ); - move32(); - q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 ); - - IF( q_U_1 != 0 ) - { - q_diff = sub( q_U_2, q_U_1 ); - IF( q_diff > 0 ) - { - Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], q_diff ); - Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], q_diff ); - Uim_fx[0][ch] = L_shr( Uim_fx[0][ch], q_diff ); - q_U_2 = q_U_1; - move32(); - move32(); - move32(); - move16(); - } - ELSE IF( GT_16( q_U_1, q_U_2 ) ) - { - Ure_fx[1][ch - 1] = L_shl( Ure_fx[1][ch - 1], q_diff ); - Ure_fx[0][ch - 1] = L_shl( Ure_fx[0][ch - 1], q_diff ); - Uim_fx[1][ch - 1] = L_shl( Uim_fx[1][ch - 1], q_diff ); - q_U_1 = q_U_2; - move32(); - move32(); - move32(); - move16(); - } - } - q_U_1 = q_U_2; - move16(); - } - } - - if ( q_U_1 != 0 ) - { - *q_U = q_U_1; - move16(); - } - - if ( q_U_1 == 0 ) - { - *q_U = q_U_2; - move16(); - } -#endif return; } -- GitLab From 36b1701ca255628fdb745269ff0d939d45959885 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 22:34:17 +0100 Subject: [PATCH 26/26] formatting --- lib_com/gs_gains_fx.c | 16 ++++---- lib_com/ivas_filters_fx.c | 1 - lib_com/ivas_transient_det_fx.c | 2 +- lib_com/options.h | 4 -- lib_com/prot_fx.h | 17 ++++---- lib_dec/core_switching_dec_fx.c | 3 +- lib_dec/swb_tbe_dec_fx.c | 8 ++-- lib_dec/updt_dec_fx.c | 12 +++--- lib_enc/core_switching_enc_fx.c | 10 ++--- lib_enc/enc_gen_voic_fx.c | 4 +- lib_enc/hq_lr_enc_fx.c | 1 - lib_enc/long_enr_fx.c | 70 ++++++++++++++++----------------- lib_enc/lsf_enc_fx.c | 42 ++++++++++---------- lib_enc/prot_fx_enc.h | 30 +++++++------- lib_isar/isar_lcld_decoder.c | 10 ++--- lib_rend/lib_rend_fx.c | 1 - 16 files changed, 109 insertions(+), 122 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index cc48a5e63..a36d3ddeb 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -391,8 +391,8 @@ void Ener_per_band_comp_ivas_fx( *-------------------------------------------------------------------*/ static void GSC_gain_adj( - const Word16 coder_type, /* i : Coder type */ - const Word16 Mbands_gn, /* i : Number of band */ + const Word16 coder_type, /* i : Coder type */ + const Word16 Mbands_gn, /* i : Number of band */ const Word32 core_brate, /* i : Bit rate */ const Word16 mean_g, /* i : Average gain Q12 */ Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */ @@ -494,12 +494,12 @@ static void GSC_gain_adj( /*! r: average frequency gain */ Word16 gsc_gaindec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ - const Word32 core_brate_fx, /* i : core used */ - Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth_fx /* i : input signal bandwidth */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */ + const Word32 core_brate_fx, /* i : core used */ + Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth_fx /* i : input signal bandwidth */ ) { Word16 idx_g_fx, i; diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index bcba83b89..5f1b1423b 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -247,4 +247,3 @@ void ivas_filter_process_fx64( return; } - diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 9c54f91f4..ea3acdb9e 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -43,7 +43,7 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) +#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) #define IVAS_TDET_PARM_ENV_EPS_fx ( ( (Word64) 21474 ) << 12 ) // Q11+32 #define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29 diff --git a/lib_com/options.h b/lib_com/options.h index 1986a5d7b..b38e1d635 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,10 +113,6 @@ /* ##################### End NON-BE switches ########################### */ -/* #################### Start BASOP optimization switches ############################ */ - - -/* #################### End BASOP optimization switches ############################ */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 289923aa5..420992dcf 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7635,8 +7635,7 @@ ivas_error core_switching_pre_dec_fx( const Word32 last_element_brate, /* i : last element bitrate */ const Word16 Q_old_synthFB, Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 -); + Word16 *Q_olapBufferSynth2 ); ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -7689,9 +7688,9 @@ void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth16, /* i : decoded synthesis Qpostd */ - const Word32 *synth, /* i : decoded synthesis Qpostd */ - const Word16 Qpostd /* i : Synthesis Q value */ + const Word16 *synth16, /* i : decoded synthesis Qpostd */ + const Word32 *synth, /* i : decoded synthesis Qpostd */ + const Word16 Qpostd /* i : Synthesis Q value */ ); void update_decoder_LPD_cng( @@ -10167,11 +10166,11 @@ void ivas_swb_tbe_dec_fx( STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ Word16 *Q_white_exc ); Word16 swb_bwe_dec_fx32( diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 4d2948ba9..3bfcb453d 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1182,7 +1182,7 @@ ivas_error core_switching_pre_dec_fx( } IF( hBPF != NULL ) { - set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ + set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ hBPF->pst_mem_deemp_err_fx = 0; move16(); @@ -2073,4 +2073,3 @@ void bandwidth_switching_detect_fx( return; } - diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 7e9bf3a18..b9fb6f1b7 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -5477,11 +5477,11 @@ void ivas_swb_tbe_dec_fx( STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ Word16 *Q_white_exc ) { Word16 i, j, cnt, n; diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 7489e9278..868c62fe7 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -397,10 +397,10 @@ void updt_IO_switch_dec_fx( *-------------------------------------------------------------------*/ static void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ const Word32 *synth32, /* i : synthesis signal32 Qpost */ - const Word16 Qpost /* i : Synthesis Q value */ + const Word16 Qpost /* i : Synthesis Q value */ ) { test(); @@ -474,9 +474,9 @@ void updt_dec_common_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 hq_core_type_fx, /* i : HQ core type */ const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth16, /* i : decoded synthesis Qpostd */ - const Word32 *synth, /* i : decoded synthesis Qpostd */ - const Word16 Qpostd /* i : Synthesis Q value */ + const Word16 *synth16, /* i : decoded synthesis Qpostd */ + const Word32 *synth, /* i : decoded synthesis Qpostd */ + const Word16 Qpostd /* i : Synthesis Q value */ ) { diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 95688a82a..497f4ad9e 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -19,11 +19,11 @@ *---------------------------------------------------------------------*/ void core_switching_pre_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ + const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ + const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/ + const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index f7ba1ce2f..5e1a43a8c 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -310,8 +310,8 @@ void encod_gen_voic_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } - /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ - st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ + /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ + st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index b2b7ac9cb..74a3a15df 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -23,7 +23,6 @@ static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_a static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L_ybuf[] /*Q12*/, Word32 L_y2[] /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 k_sort[], const Word16 bands, const Word32 L_qint /*Q29*/, const Word16 Ngq, const Word16 gqlevs, const Word16 gqbits ); - /*--------------------------------------------------------------------------* * spt_shorten_domain_set() * diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 61354bf87..46e455617 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -165,50 +165,50 @@ void long_enr_fx( * and total active speech energy *-----------------------------------------------------------------*/ - IF( LT_16( st_fx->ini_frame, 4 ) ) + IF( LT_16( st_fx->ini_frame, 4 ) ) + { + st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */ + move16(); + tmp = add( st_fx->lp_noise_fx, 2560 ); /*10.0 in Q8*/ + st_fx->lp_speech_fx = s_max( st_fx->lp_speech_fx, tmp ); /* Q8 */ + move16(); + } + ELSE + { + /* if ( st->ini_frame < 150 ) { + st->lp_noise = 0.95f * st->lp_noise + 0.05f * st->totalNoise; + } else { + st->lp_noise = 0.98f * st->lp_noise + 0.02f * st->totalNoise; + } */ + alpha = 655; /* 0.02 Q15 */ + move16(); + if ( LT_16( st_fx->ini_frame, 150 ) ) /* should match HE_LT_CNT_INIT_FX */ { - st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */ - move16(); - tmp = add( st_fx->lp_noise_fx, 2560 ); /*10.0 in Q8*/ - st_fx->lp_speech_fx = s_max( st_fx->lp_speech_fx, tmp ); /* Q8 */ + alpha = 1638; /* 0.05 Q15 */ move16(); } - ELSE + st_fx->lp_noise_fx = noise_est_AR1_Qx( hNoiseEst->totalNoise_fx, st_fx->lp_noise_fx, alpha ); /* Q8 state, alpha in Q15 */ + move16(); + + test(); + IF( ( localVAD_HE_SAD != 0 ) && ( high_lpn_flag == 0 ) ) { - /* if ( st->ini_frame < 150 ) { - st->lp_noise = 0.95f * st->lp_noise + 0.05f * st->totalNoise; - } else { - st->lp_noise = 0.98f * st->lp_noise + 0.02f * st->totalNoise; - } */ - alpha = 655; /* 0.02 Q15 */ - move16(); - if ( LT_16( st_fx->ini_frame, 150 ) ) /* should match HE_LT_CNT_INIT_FX */ + IF( LT_16( sub( st_fx->lp_speech_fx, Etot ), 10 * 256 ) ) /* 10.0 in Q8 */ { - alpha = 1638; /* 0.05 Q15 */ + /* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */ + st_fx->lp_speech_fx = noise_est_AR1_Qx( Etot, st_fx->lp_speech_fx, 655 ); /* Q8 state, 0.02 in Q15 */ move16(); } - st_fx->lp_noise_fx = noise_est_AR1_Qx( hNoiseEst->totalNoise_fx, st_fx->lp_noise_fx, alpha ); /* Q8 state, alpha in Q15 */ - move16(); - - test(); - IF( ( localVAD_HE_SAD != 0 ) && ( high_lpn_flag == 0 ) ) + ELSE { - IF( LT_16( sub( st_fx->lp_speech_fx, Etot ), 10 * 256 ) ) /* 10.0 in Q8 */ - { - /* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */ - st_fx->lp_speech_fx = noise_est_AR1_Qx( Etot, st_fx->lp_speech_fx, 655 ); /* Q8 state, 0.02 in Q15 */ - move16(); - } - ELSE - { - st_fx->lp_speech_fx = sub( st_fx->lp_speech_fx, 13 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/ - move16(); - } + st_fx->lp_speech_fx = sub( st_fx->lp_speech_fx, 13 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/ + move16(); } } + } - /* Update */ - st_fx->hNoiseEst->Etot_last_fx = Etot; + /* Update */ + st_fx->hNoiseEst->Etot_last_fx = Etot; - return; - } + return; +} diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 3995f1ab7..b423a7ae6 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -62,14 +62,14 @@ static void lsf_mid_enc_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, Wo /*===========================================================================*/ void lsf_enc_fx( - Encoder_State *st_fx, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector */ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ + Encoder_State *st_fx, /* i/o: state structure */ + Word16 *lsf_new, /* o : quantized LSF vector */ + Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ + Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ + Word16 *Aq, /* o : quantized A(z) for 4 subframes */ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new ) { Word16 nBits = 0; @@ -357,10 +357,10 @@ void lsf_enc_fx( static void lsfq_CNG_fx( const Word16 element_mode, /* i : element mode */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle*/ - const Word16 *lsf, /*x2.56 unquantized LSF vector */ - const Word16 *wghts, /*Q10 LSF weights */ - Word16 *qlsf, /*x2.56 quantized LSF vecotor */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle*/ + const Word16 *lsf, /*x2.56 unquantized LSF vector */ + const Word16 *wghts, /*Q10 LSF weights */ + Word16 *qlsf, /*x2.56 quantized LSF vecotor */ Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales ) @@ -2737,17 +2737,17 @@ static void FFT_Mid_Interpol_16k_fx( static void lsf_mid_enc_fx( const Word16 element_mode, /* i : element mode */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 nb_bits, /* i : number of bits */ - const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/ - const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/ - const Word16 qlsp1[], /* i : quantized LSPs from frame end */ - Word16 lsp[], /* i/o: mid-frame LSP */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - Word32 Bin_Ener_old[], /* i/o: per bin old log energy spectrum */ - Word32 Bin_Ener[], /* i : per bin log energy spectrum */ - Word16 Q_ener, /* i : Q value of Bin_ener */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 nb_bits, /* i : number of bits */ + const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/ + const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/ + const Word16 qlsp1[], /* i : quantized LSPs from frame end */ + Word16 lsp[], /* i/o: mid-frame LSP */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + Word32 Bin_Ener_old[], /* i/o: per bin old log energy spectrum */ + Word32 Bin_Ener[], /* i : per bin log energy spectrum */ + Word16 Q_ener, /* i : Q value of Bin_ener */ Word16 ppp_mode, Word16 nelp_mode ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index e18c097f5..f6fc25fde 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -125,11 +125,11 @@ void core_switching_post_enc_fx( ); void core_switching_pre_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/ + const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ + const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/ + const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ const Word16 active_cnt, /* i : active frame counter Q0*/ const Word16 last_element_mode /* i : last_element_mode Q0*/ ); @@ -557,10 +557,10 @@ void speech_music_classif_fx( void StableHighPitchDetect_fx( const Word16 element_mode, /* i : element mode */ - Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/ - Word16 pitch[], /* i/o: OL pitch buffer */ - const Word16 voicing[], /* i : OL pitch gains */ - const Word16 wsp[], /* i : weighted speech */ + Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/ + Word16 pitch[], /* i/o: OL pitch buffer */ + const Word16 voicing[], /* i : OL pitch gains */ + const Word16 wsp[], /* i : weighted speech */ const Word16 localVAD, Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains */ Word16 *voicing0_sm, /* i/o: smoothed high pitch gains */ @@ -1752,14 +1752,14 @@ void CNG_reset_enc_fx( ); void lsf_enc_fx( - Encoder_State *st_fx, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector */ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ + Encoder_State *st_fx, /* i/o: state structure */ + Word16 *lsf_new, /* o : quantized LSF vector */ + Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ + Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ + Word16 *Aq, /* o : quantized A(z) for 4 subframes */ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new ); void Es_pred_enc_fx( diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index d34c56dac..5f41dd707 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -105,7 +105,6 @@ struct LCLD_DECODER Word32 ***pppiQLCLDImag; PredictionDecoder *psPredictionDecoder; - }; static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, Word32 num, const UWord16 ( *ppuiEncTable )[2], Word32 iSize, Word32 iReadLength, UWord32 *iTables ); @@ -781,8 +780,7 @@ static void ApplyRMSEnvelope_fx( const Word32 iNumBands, const Word32 *piBandwid static void ReplaceSign_fx( const Word32 iNumBlocks, const Word32 iNumLCLDBands, Word32 **ppiSignReal, Word32 **ppiSignImag, Word32 **ppfReal, Word32 **ppfImag, const Word32 *piBandwidths ); -static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag -); +static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag ); static void InvMSCoding_fx( const Word32 iNumBlocks, const Word32 iNumBands, const Word32 *piBandwidths, const Word32 iMSMode, const Word32 *piMSFlags, const Word32 *piLRPhaseDiffs, const Word32 *piMSPredCoefs, Word32 ***pppfReal, Word32 ***pppfImag ); @@ -1004,8 +1002,7 @@ Word32 DecodeLCLDFrame( psLCLDDecoder->pppiAlloc[n], psLCLDDecoder->pppiQLCLDReal[n], psLCLDDecoder->pppiQLCLDImag[n], - pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] - ); + pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] ); ReplaceSign_fx( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiLCLDSignReal[n], @@ -1275,8 +1272,7 @@ static void InvQuantizeSpectrum_fx( Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, - Word32 **ppfImag -) + Word32 **ppfImag ) { Word32 b, k, n; Word32 iBlockOffest, iFBOffset; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 232c38ee5..67b72c030 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5721,7 +5721,6 @@ ivas_error IVAS_REND_DisableHeadRotation( } - /*-------------------------------------------------------------------* * IVAS_REND_SetOrientationTrackingMode() * -- GitLab