diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6b23f8eed198af607f8b4b11bdab3383248a7de2..5483d155aa8fbe64c18f98ac3edd356615a6739e 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1974,6 +1974,7 @@ void ivas_DetectTonalComponents_fx( const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, const Word32 secondLastPowerSpectrum[], + const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9fe14b5bdf2bd06c018ddcee0caee93b4913d238..b6b9b7f4a4e59a045190440dbd0ab18619fb934b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6461,6 +6461,7 @@ void ivas_RefineTonalComponents_fx( const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, const Word32 secondLastPowerSpectrum[], + const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index ca7bec1408a10c55203b4a1990f6a7cc95bb71c8..e50abddd6e25c43a74c5daa081dff5c2292dd242 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -30,6 +30,7 @@ static void modifyThresholds( Word16 F0, Word16 origF0, Word16 *thresholdModific static void RefineThresholdsUsingPitch( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void ivas_RefineThresholdsUsingPitch_fx( const Word16 nSamples, const Word16 nSamplesCore, const Word32 powerSpectrum[], const Word32 lastPitchLag, const Word32 currentPitchLag, Word16 *pF0, Word16 *thresholdModification ); static void findTonalComponents( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); +static void ivas_findTonalComponents_fx( Word16 *indexOfTonalPeak, Word16 *lowerIndex, Word16 *upperIndex, Word16 *numIndexes, Word16 nSamples, const Word32 *powerSpectrum, const Word16 powerSpectrum_e, Word16 F0, Word16 *thresholdModification, Word16 element_mode ); /*-------------------------------------------------------------------* * DetectTonalComponents() @@ -52,7 +53,8 @@ void ivas_DetectTonalComponents_fx( const Word16 scaleFactors[], const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], /*Qx*/ + const Word32 secondLastPowerSpectrum[], /*Q31-secondLastPowerSpectrum_e*/ + const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/ @@ -127,7 +129,7 @@ void ivas_DetectTonalComponents_fx( ivas_RefineThresholdsUsingPitch_fx( nSamples, nSamplesCore, secondLastPowerSpectrum, lastPitchLag, currentPitchLag, &F0, thresholdModification ); /* Find peaks in the second last frame */ - findTonalComponents( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, F0, thresholdModification, element_mode ); + ivas_findTonalComponents_fx( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, secondLastPowerSpectrum_e, F0, thresholdModification, element_mode ); } void DetectTonalComponents( @@ -306,7 +308,8 @@ void ivas_RefineTonalComponents_fx( const Word16 scaleFactors[], const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], /*Qx*/ + const Word32 secondLastPowerSpectrum[], /*Q31-secondLastPowerSpectrum_e*/ + const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/ @@ -322,7 +325,7 @@ void ivas_RefineTonalComponents_fx( ivas_DetectTonalComponents_fx( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum, - lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, nSamples, nSamplesCore, floorPowerSpectrum, + lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, secondLastPowerSpectrum_e, nSamples, nSamplesCore, floorPowerSpectrum, psychParamsCurrent, element_mode ); nPreservedPeaks = 0; @@ -1280,6 +1283,171 @@ static void RefineThresholdsUsingPitch( return; } +static void ivas_findTonalComponents_fx( + Word16 *indexOfTonalPeak, /* OUT Q0*/ + Word16 *lowerIndex, /* OUT Q0*/ + Word16 *upperIndex, /* OUT Q0*/ + Word16 *numIndexes, /* OUT Q0*/ + Word16 nSamples, /* IN */ + const Word32 *powerSpectrum, /* IN Q31-powerSpectrum_e*/ + const Word16 powerSpectrum_e, + Word16 F0, /* IN */ + Word16 *thresholdModification, /* IN Q10*/ + Word16 element_mode ) /* IN */ +{ + Word32 envelope[L_FRAME_MAX]; /*powerSpec_exp + LEVEL_EXP*/ + Word32 smoothedSpectrum[L_FRAME_MAX]; /*powerSpec_exp + LEVEL_EXP*/ + Word16 nrOfFIS; + Word16 upperIdx, lowerIdx, lowerBound; + Word16 k, j, m; + Word32 biggerNeighbor; + Word16 tmp_loop1, tmp_loop2, tmp_loop3; + + getEnvelope( nSamples, powerSpectrum, F0, envelope, smoothedSpectrum ); + + + nrOfFIS = 0; + move16(); + lowerBound = 0; + move16(); + + k = GROUP_LENGTH / 2; + move16(); + tmp_loop1 = sub( nSamples, ( GROUP_LENGTH - GROUP_LENGTH / 2 ) ); + tmp_loop2 = sub( nSamples, 1 ); + WHILE( LE_16( k, tmp_loop1 ) ) + { + Word64 mult_64 = W_mult_32_16( envelope[k], thresholdModification[k] ); // (Q31-(powerSpectrum_e+LEVEL_EXP))+1+10 + Word16 lshift = W_norm( mult_64 ); + Word32 mult_32 = W_extract_h( W_shl( mult_64, lshift ) ); //(Q31-(powerSpectrum_e+LEVEL_EXP) + lshift )+11 -32 + Word16 mult_exp = sub( Q31, sub( add( sub( Q31, add( powerSpectrum_e, LEVEL_EXP ) ), add( 10, lshift ) ), 31 ) ); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( smoothedSpectrum[k], ( powerSpectrum_e + LEVEL_EXP ), mult_32, mult_exp ); + /* There is 3 bits headroom in envelope and max of thresholdModification is 16384, so shifting left for 4 would produce overflow only when the result is anyhow close to 1 */ + IF( EQ_16( flag, 1 ) ) + { + /* The check that bin at k is bigger than bins at k-1 and k+1 is needed to avoid deadlocks when the thresholds are low. */ + /* It removes some true peaks, especially if non weighted sum is used for the smoothed spectrum. */ + biggerNeighbor = L_max( powerSpectrum[k - 1], powerSpectrum[k + 1] ); /*Qx*/ + + IF( GE_32( powerSpectrum[k], biggerNeighbor ) ) + { + /* Find the right foot */ + upperIdx = add( k, 1 ); + WHILE( LT_16( upperIdx, tmp_loop2 ) ) + { + IF( LT_32( powerSpectrum[upperIdx], powerSpectrum[upperIdx + 1] ) ) + { + /* Side lobes may increase for certain amount */ + IF( LT_32( L_shl( Mpy_32_16_1( powerSpectrum[upperIdx], ALLOWED_SIDE_LOBE_FLUCTUATION ), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP ), powerSpectrum[upperIdx + 1] ) ) + { + BREAK; + } + /* Check for further decrease after a side lobe increase */ + FOR( j = add( upperIdx, 1 ); j < tmp_loop2; j++ ) + { + IF( LT_32( powerSpectrum[j], L_shl( Mpy_32_16_1( powerSpectrum[j + 1], ALLOWED_SIDE_LOBE_FLUCTUATION ), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP ) ) ) + { + BREAK; + } + } + /* Side lobe increase must be 2 times smaller than the decrease to the foot */ + /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */ + test(); + test(); + test(); + IF( ( EQ_16( element_mode, EVS_MONO ) && GT_32( Mpy_32_32( L_shl( powerSpectrum[upperIdx + 1], 1 ), powerSpectrum[j] ), Mpy_32_32( powerSpectrum[upperIdx], powerSpectrum[upperIdx] ) ) ) || + ( NE_16( element_mode, EVS_MONO ) && ( GT_64( W_mult_32_32( L_shl( powerSpectrum[upperIdx + 1], 1 ), powerSpectrum[j] ), W_mult_32_32( powerSpectrum[upperIdx], powerSpectrum[upperIdx] ) ) ) ) ) + { + BREAK; + } + upperIdx = sub( j, 1 ); + } + upperIdx = add( upperIdx, 1 ); + } + /* left foot */ + lowerIdx = sub( k, 1 ); + WHILE( GT_16( lowerIdx, lowerBound ) ) + { + IF( LT_32( powerSpectrum[lowerIdx], powerSpectrum[lowerIdx - 1] ) ) + { + /* Side lobes may increase for certain amount */ + IF( LT_32( L_shl( Mpy_32_16_1( powerSpectrum[lowerIdx], ALLOWED_SIDE_LOBE_FLUCTUATION ), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP ), powerSpectrum[lowerIdx - 1] ) ) + { + BREAK; + } + /* Check for further decrease after a side lobe increase */ + FOR( j = sub( lowerIdx, 1 ); j > 0; j-- ) + { + IF( LT_32( powerSpectrum[j], L_shl( Mpy_32_16_1( powerSpectrum[j - 1], ALLOWED_SIDE_LOBE_FLUCTUATION ), ALLOWED_SIDE_LOBE_FLUCTUATION_EXP ) ) ) + { + BREAK; + } + } + /* Side lobe increase must be 2 times smaller than the decrease to the foot */ + /* Eq. to 2.0f*powerSpectrum[lowerIdx-1]/powerSpectrum[lowerIdx] > powerSpectrum[lowerIdx]/powerSpectrum[j] */ + IF( GT_32( Mpy_32_32( L_shl( powerSpectrum[lowerIdx - 1], 1 ), powerSpectrum[j] ), Mpy_32_32( powerSpectrum[lowerIdx], powerSpectrum[lowerIdx] ) ) ) + { + BREAK; + } + lowerIdx = add( j, 1 ); + } + lowerIdx = sub( lowerIdx, 1 ); + } + + lowerBound = upperIdx; + move16(); + + /* Check if there is a bigger peak up to the next peak foot */ + tmp_loop3 = s_min( upperIdx, tmp_loop1 ); + FOR( j = s_max( GROUP_LENGTH / 2, lowerIdx ); j <= tmp_loop3; j++ ) + { + if ( GT_32( powerSpectrum[j], powerSpectrum[k] ) ) + { + + k = j; + move16(); + } + } + + assert( ( nrOfFIS == 0 ) || ( indexOfTonalPeak[nrOfFIS - 1] < k ) ); + + lowerIndex[nrOfFIS] = sub( k, GROUP_LENGTH / 2 ); + move16(); + + upperIndex[nrOfFIS] = add( k, ( GROUP_LENGTH - GROUP_LENGTH / 2 - 1 ) ); + move16(); + + test(); + IF( ( nrOfFIS > 0 ) && ( LE_16( lowerIndex[nrOfFIS], upperIndex[nrOfFIS - 1] ) ) ) + { + m = shr( add( k, indexOfTonalPeak[nrOfFIS - 1] ), 1 ); + upperIndex[nrOfFIS - 1] = m; + move16(); + lowerIndex[nrOfFIS] = add( m, 1 ); + move16(); + } + + indexOfTonalPeak[nrOfFIS++] = k; + move16(); + + IF( EQ_16( nrOfFIS, MAX_NUMBER_OF_IDX ) ) + { + BREAK; + } + /* Jump to the next foot of the peak. */ + k = upperIdx; + move16(); + } + } + k = add( k, 1 ); + } + + *numIndexes = nrOfFIS; + move16(); + return; +} + + static void ivas_RefineThresholdsUsingPitch_fx( const Word16 nSamples, const Word16 nSamplesCore, diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 7826546236b7c3baffb643a9adb11e38181509d0..b21fb44e378bf5a4a7cea83f395e6cbbce51178f 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1476,6 +1476,7 @@ ivas_error acelp_core_dec_ivas_fx( IF( st->hTcxDec != NULL ) { Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/ + st->hTcxDec->Q_old_syn_Overl = -1; } Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/ diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index d45655903fb6f8f427e3d28ea4f7e91cbd2be7a2..9c2cdd5c03835e8c01dffa2a1d775b743be5127b 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -756,6 +756,7 @@ ivas_error amr_wb_dec_fx( /* TCX=Q-1, ACELP2 Q0 */ Copy_Scale_sig( syn_fx + L_FRAME / 2, hTcxDec->old_syn_Overl, L_FRAME / 2, sub( -1, st_fx->Q_syn ) ); + hTcxDec->Q_old_syn_Overl = -1; Copy_Scale_sig( syn_fx + L_FRAME - M - 1, st_fx->syn, M + 1, sub( 0, st_fx->Q_syn ) ); /*------------------------------------------------------------------* diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index d1ed7ad8c90fcdc38719cf2e07f0c5ba0fad4cef..49a6b6f3b4b9003d6a23c734b575db6561908acb 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3608,7 +3608,8 @@ void decoder_tcx_ivas_fx( st->hHQ_core->Q_old_wtda_LB = 0; move16(); - Scale_sig( st->hTcxDec->old_syn_Overl, 320, 1 ); // Scaling to Q_syn + Scale_sig( st->hTcxDec->old_syn_Overl, 320, st->Q_syn - st->hTcxDec->Q_old_syn_Overl ); // Scaling to Q_syn + st->hTcxDec->Q_old_syn_Overl = st->Q_syn; Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) ); Scale_sig( synth_fx, L_frame_glob, st->Q_syn ); // Scaling to Q_syn @@ -3625,7 +3626,8 @@ void decoder_tcx_ivas_fx( // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; // Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); - Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 + st->Q_syn ) ); // Scaling to Q-2 + Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 + st->hTcxDec->Q_old_syn_Overl = -2; } /*-------------------------------------------------------------------* diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 5cc06dabf285301cae74d550d27f09128f1954d1..e804d200927334135725f05bc7294f3e4da06dce 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -2036,6 +2036,7 @@ void con_tcx_ivas_fx( st->Q_syn = Q_syn; move16(); Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ + st->hTcxDec->Q_old_syn_Overl = -1; lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 151ba7d1eafa6fc83452492bcae937152ed6127e..1899c8bea485a504c671ac909b1840d61025bd77 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1187,11 +1187,12 @@ void ivas_mdct_core_reconstruct_fx( { Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, sub( -1, st->Q_syn ) ) ); // Q(-1 - st->Q_syn) -> q_win - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win + Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win + st->hTcxDec->Q_old_syn_Overl = q_win; + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win #ifdef MSAN_FIX Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win @@ -1260,7 +1261,8 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); // q_win -> Q(-1 - st->Q_syn) st->hTcxDec->Q_syn_Overl_TDAC = sub( -1, st->Q_syn ); move16(); - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); // q_win -> Q(-1 - st->Q_syn) + Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) + st->hTcxDec->Q_old_syn_Overl = sub( -1, st->Q_syn ); #ifdef MSAN_FIX Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn @@ -1307,6 +1309,7 @@ void ivas_mdct_core_reconstruct_fx( move16(); st->Q_syn = q_syn; move16(); + st->hTcxDec->Q_old_syn_Overl = add( st->hTcxDec->Q_old_syn_Overl, q_syn ); IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) { diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index c70e606ac7c54298dc672c03b3e7b91dedadc02b..066f6993dd602bd5934d7568e8950392c0b779e2 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -804,6 +804,7 @@ ivas_error stereo_memory_dec_fx( { Copy32( tmpF_buff, st->hTcxDec->old_syn_Overl_32, L_FRAME16k / 2 ); /* Q11 */ Copy_Scale_sig32_16( st->hTcxDec->old_syn_Overl_32, st->hTcxDec->old_syn_Overl, L_FRAME16k / 2, add( st->Q_syn, 5 ) ); //(st->Qsyn - (11 - 16)) + st->hTcxDec->Q_old_syn_Overl = st->Q_syn; } st->hTcxDec->q_old_synth = st->Q_syn; move16(); @@ -2027,6 +2028,7 @@ void stereo_switching_dec( move16(); Copy( sts[0]->delay_buf_out_fx, sts[1]->delay_buf_out_fx, HQ_DELTA_MAX * HQ_DELAY_COMP ); /* Q0 */ Copy( sts[0]->hTcxDec->old_syn_Overl, sts[1]->hTcxDec->old_syn_Overl, 256 ); /* Q_old_syn_Overl*/ + sts[1]->hTcxDec->Q_old_syn_Overl = sts[0]->hTcxDec->Q_old_syn_Overl; } } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) ) diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 36cadf6ffea2934dc2a7ebf63f9927240c33ba46..043ae5601147dd6285fe45e12ef4eda036470997 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -814,6 +814,7 @@ static void ivas_CalcPowerSpecAndDetectTonalComponents_fx( hTonalMDCTConc->lastBlockData.scaleFactors_exp, hTonalMDCTConc->lastBlockData.scaleFactors_max_e, powerSpectrum, + powerSpectrum_exp, nSamples, hTonalMDCTConc->nSamplesCore, floorPowerSpectrum, psychParamsCurrent, element_mode ); @@ -1319,6 +1320,8 @@ void TonalMDCTConceal_Detect_ivas_fx( powerSpectrum[i] = Mpy_32_32( t, t ); // Q(31-secondLastMDST_exp+powerSpectrum_exp) move32(); } + powerSpectrum_exp = 0; + move16(); } ELSE { @@ -1336,6 +1339,7 @@ void TonalMDCTConceal_Detect_ivas_fx( powerSpectrum[i] = Mpy_32_32( t, t ); // 2*(Q31 - powerSpectrum_exp -3)-31 move32(); } + powerSpectrum_exp = sub( 31, sub( shl( sub( Q31 - 3, powerSpectrum_exp ), 1 ), 31 ) ); } ivas_RefineTonalComponents_fx( (Word16 *) hTonalMDCTConc->pTCI->indexOfTonalPeak, @@ -1352,6 +1356,7 @@ void TonalMDCTConceal_Detect_ivas_fx( hTonalMDCTConc->lastBlockData.scaleFactors_exp, hTonalMDCTConc->lastBlockData.scaleFactors_max_e, powerSpectrum, + powerSpectrum_exp, nSamples, hTonalMDCTConc->nSamplesCore, extract_l( Mpy_32_16_1( L_mult0( hTonalMDCTConc->nSamples, hTonalMDCTConc->nSamples ), 82 ) ), element_mode, psychParamsCurrent ); /* floorPowerSpectrum */