diff --git a/lib_com/options.h b/lib_com/options.h index ca5c3bc29b006e461ff631757dabaef1d41f8033..af2752dcde23f0c28141100d603bd77c100c141f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,6 +92,7 @@ #define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */ #define FIX_2480_HARM_TONALMDCT /* FhG: basop issue 2480: Harmonize TonalMDCTConceal_Detect_fx() and TonalMDCTConceal_Detect_ivas_fx() */ #define FIX_2479_HARM_PITCH_GAIN /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */ +#define HARMONIZE_2481_EXTEND_SHRINK /* FhG: basop issue 2481: Harmonize extend_frm_*fx() and shrink_frm_*fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 27fc1afa0672ebdc42f4d25a60e743f87e891885..75a1fba48760389b4355915818ad0da7b231502b 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -149,6 +149,8 @@ static Word16 find_synch_fx( apa_state_t *ps, const Word16 *in, Word16 l_in, Wor static bool copy_frm_fx( apa_state_t *ps, const Word16 frm_in[], Word16 frm_out[], UWord16 *l_frm_out ); +#ifndef HARMONIZE_2481_EXTEND_SHRINK + static bool shrink_frm_fx( apa_state_t *ps, const Word16 frm_in[], UWord16 maxScaling, Word16 frm_out[], UWord16 *l_frm_out ); static bool shrink_frm_ivas_fx( apa_state_t *ps, const Word16 frm_in[], UWord16 maxScaling, Word16 frm_out[], Word16 Q_frm_in, UWord16 *l_frm_out ); @@ -157,6 +159,14 @@ static bool extend_frm_fx( apa_state_t *ps, const Word16 frm_in[], Word16 frm_ou static bool extend_frm_ivas_fx( apa_state_t *ps, const Word16 frm_in[], Word16 frm_out[], Word16 Q_frm_in, UWord16 *l_frm_out ); +#else + +static bool shrink_frm_fx( apa_state_t *ps, const Word16 frm_in[], UWord16 maxScaling, Word16 frm_out[], Word16 Q_frm_in, UWord16 *l_frm_out, bool bIsEVS ); + +static bool extend_frm_fx( apa_state_t *ps, const Word16 frm_in[], Word16 frm_out[], Word16 Q_frm_in, UWord16 *l_frm_out, bool bIsEVS ); + +#endif // !HARMONIZE_2481_EXTEND_SHRINK + /*---------------------------------------------------------------------* * Public functions *---------------------------------------------------------------------*/ @@ -790,12 +800,21 @@ UWord8 apa_exec_fx( /* shrink */ ELSE IF( LT_32( ps->scale, 100 ) ) { + +#ifndef HARMONIZE_2481_EXTEND_SHRINK shrink_frm_fx( ps, frm_in, maxScaling, a_out, &l_frm_out ); +#else + shrink_frm_fx( ps, frm_in, maxScaling, a_out, 0, &l_frm_out, true ); +#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* extend */ ELSE { +#ifndef HARMONIZE_2481_EXTEND_SHRINK extend_frm_fx( ps, frm_in, a_out, &l_frm_out ); +#else + extend_frm_fx( ps, frm_in, a_out, 0, &l_frm_out, true ); +#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* control the amount/frequency of scaling */ IF( NE_32( l_frm_out, ps->l_frm ) ) @@ -1025,12 +1044,20 @@ UWord8 apa_exec_ivas_fx( /* shrink */ IF( LT_32( ps->scale, 100 ) ) { +#ifndef HARMONIZE_2481_EXTEND_SHRINK shrink_frm_ivas_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out ); +#else + shrink_frm_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out, false ); +#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* extend */ ELSE { +#ifndef HARMONIZE_2481_EXTEND_SHRINK extend_frm_ivas_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out ); +#else + extend_frm_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out, false ); +#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* control the amount/frequency of scaling */ IF( NE_32( l_frm_out, ps->l_frm ) ) @@ -1590,6 +1617,8 @@ static bool copy_frm_fx( * ******************************************************************************** */ +#ifndef HARMONIZE_2481_EXTEND_SHRINK + static bool shrink_frm_fx( apa_state_t *ps, const Word16 frm_in_fx[], // Qx @@ -1758,6 +1787,9 @@ static bool shrink_frm_fx( return 0; } +#endif // !HARMONIZE_2481_EXTEND_SHRINK + +#ifndef HARMONIZE_2481_EXTEND_SHRINK static bool shrink_frm_ivas_fx( apa_state_t *ps, const Word16 frm_in_fx[], // Qx @@ -1765,6 +1797,16 @@ static bool shrink_frm_ivas_fx( Word16 frm_out_fx[], // Qx Word16 Q_frm_in, UWord16 *l_frm_out ) +#else +static bool shrink_frm_fx( + apa_state_t *ps, + const Word16 frm_in_fx[], // Qx + UWord16 maxScaling, + Word16 frm_out_fx[], // Qx + Word16 Q_frm_in, + UWord16 *l_frm_out, + bool bIsEVS ) +#endif // !HARMONIZE_2481_EXTEND_SHRINK { bool findSynchResult = 0; move16(); @@ -1775,6 +1817,9 @@ static bool shrink_frm_ivas_fx( Word32 quality_fx = 0; UWord16 l_frm; UWord16 l_seg; +#ifdef HARMONIZE_2481_EXTEND_SHRINK + bool bIsSilence; +#endif // HARMONIZE_2481_EXTEND_SHRINK move16(); move32(); @@ -1799,7 +1844,20 @@ static bool shrink_frm_ivas_fx( } /* calculate overlap position */ +#ifndef HARMONIZE_2481_EXTEND_SHRINK IF( isSilence_ivas_fx( frm_in_fx, Q_frm_in, l_seg, 10 ) ) +#else + + IF( bIsEVS ) + { + bIsSilence = isSilence_fx( frm_in_fx, l_seg, 10 ); + } + ELSE + { + bIsSilence = isSilence_ivas_fx( frm_in_fx, Q_frm_in, l_seg, 10 ); + } + IF( bIsSilence ) +#endif // !HARMONIZE_2481_EXTEND_SHRINK { /* maximum scaling */ energy_fx = -65 * ( 1 << 8 ); // Q8 @@ -1840,11 +1898,26 @@ static bool shrink_frm_ivas_fx( { /* find synch */ scaleSignal16( frm_in_fx, ps->frmInScaled, l_frm, ps->signalScaleForCorrelation ); +#ifndef HARMONIZE_2481_EXTEND_SHRINK ps->signalScaleForCorrelation = sub( ps->signalScaleForCorrelation, Q_frm_in ); move16(); findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (UWord16) ( sub( s_end, s_start ) ), 0, l_seg, 0, &energy_fx, &quality_fx, &xtract ); ps->signalScaleForCorrelation = add( ps->signalScaleForCorrelation, Q_frm_in ); move16(); +#else + IF( bIsEVS ) + { + findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (UWord16) ( sub( s_end, s_start ) ), 0, l_seg, 0, &energy_fx, &quality_fx, &xtract ); + } + ELSE + { + ps->signalScaleForCorrelation = sub( ps->signalScaleForCorrelation, Q_frm_in ); + move16(); + findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (UWord16) ( sub( s_end, s_start ) ), 0, l_seg, 0, &energy_fx, &quality_fx, &xtract ); + ps->signalScaleForCorrelation = add( ps->signalScaleForCorrelation, Q_frm_in ); + move16(); + } +#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* assert synch_pos is cleanly divisible by number of channels */ @@ -1876,7 +1949,11 @@ static bool shrink_frm_ivas_fx( ELSE { /* sufficient quality */ +#ifndef HARMONIZE_2481_EXTEND_SHRINK IF( ps->bad_frame_count > 0 ) +#else + IF( GT_32( ps->bad_frame_count, 0 ) ) +#endif // !HARMONIZE_2481_EXTEND_SHRINK { ps->bad_frame_count = u_extract_l( UL_subNsD( ps->bad_frame_count, 1 ) ); move16(); @@ -1952,6 +2029,7 @@ static bool shrink_frm_ivas_fx( * ******************************************************************************** */ +#ifndef HARMONIZE_2481_EXTEND_SHRINK static bool extend_frm_fx( apa_state_t *ps, const Word16 frm_in_fx[], // Qx @@ -2206,13 +2284,24 @@ static bool extend_frm_fx( return 0; } +#endif // !HARMONIZE_2481_EXTEND_SHRINK +#ifndef HARMONIZE_2481_EXTEND_SHRINK static bool extend_frm_ivas_fx( apa_state_t *ps, const Word16 frm_in_fx[], // Qx Word16 frm_out_fx[], // Qx Word16 Q_frm_in, UWord16 *l_frm_out ) +#else +static bool extend_frm_fx( + apa_state_t *ps, + const Word16 frm_in_fx[], // Qx + Word16 frm_out_fx[], // Qx + Word16 Q_frm_in, + UWord16 *l_frm_out, + bool bIsEVS ) +#endif // !HARMONIZE_2481_EXTEND_SHRINK { bool findSynchResult = 0; move16(); @@ -2229,6 +2318,10 @@ static bool extend_frm_ivas_fx( Word32 quality_fx = 0; move32(); UWord16 l_frm, l_seg; +#ifdef HARMONIZE_2481_EXTEND_SHRINK + bool bIsSilence; +#endif // HARMONIZE_2481_EXTEND_SHRINK + const Word16 *fadeOut_fx, *fadeIn_fx; Word16 *out_fx; @@ -2334,7 +2427,19 @@ static bool extend_frm_ivas_fx( IF( over[n] ) { /* calculate overlap position */ +#ifndef HARMONIZE_2481_EXTEND_SHRINK IF( isSilence_ivas_fx( frm_in_fx, Q_frm_in, l_seg, 10 ) ) +#else + IF( bIsEVS ) + { + bIsSilence = isSilence_fx( frm_in_fx, l_seg, 10 ); + } + ELSE + { + bIsSilence = isSilence_ivas_fx( frm_in_fx, Q_frm_in, l_seg, 10 ); + } + IF( bIsSilence ) +#endif // !HARMONIZE_2481_EXTEND_SHRINK { /* maximum scaling */ energy_fx = -65 * ( 1 << 8 ); // Q8 @@ -2362,9 +2467,22 @@ static bool extend_frm_ivas_fx( frmInScaled = ps->frmInScaled; assert( sizeof( ps->frmInScaled ) / sizeof( ps->frmInScaled[0] ) >= 2 * (size_t) l_frm ); scaleSignal16( frm_in_fx, frmInScaled, shl( l_frm, 1 ), ps->signalScaleForCorrelation ); +#ifndef HARMONIZE_2481_EXTEND_SHRINK ps->signalScaleForCorrelation = sub( ps->signalScaleForCorrelation, Q_frm_in ); findSynchResult = find_synch_fx( ps, frmInScaled, extract_l( L_shl( l_frm, 1 ) ), s_start, sub( s_end, s_start ), sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); ps->signalScaleForCorrelation = add( ps->signalScaleForCorrelation, Q_frm_in ); +#else + IF( bIsEVS ) + { + findSynchResult = find_synch_fx( ps, frmInScaled, extract_l( L_shl( l_frm, 1 ) ), s_start, sub( s_end, s_start ), sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); + } + ELSE + { + ps->signalScaleForCorrelation = sub( ps->signalScaleForCorrelation, Q_frm_in ); + findSynchResult = find_synch_fx( ps, frmInScaled, extract_l( L_shl( l_frm, 1 ) ), s_start, sub( s_end, s_start ), sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); + ps->signalScaleForCorrelation = add( ps->signalScaleForCorrelation, Q_frm_in ); + } +#endif // !HARMONIZE_2481_EXTEND_SHRINK } /* assert synch_pos is cleanly divisible by number of channels */ assert( xtract[n] % ps->num_channels == 0 ); diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index 5ab60f3bea9a13cbe5731d451b4df963af6d5181..af12f22ba59815d51733c6f111d82ec2aff918ba 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -64,8 +64,12 @@ Word32 cross_correlation_self_fx( const Word16 *signal, Word16 y, Word16 corr_len ); - +#ifdef HARMONIZE_2481_EXTEND_SHRINK +bool isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ); +bool isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 segments ); +#else Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ); Word8 isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 segments ); +#endif #endif /* JBM_PCMDSP_SIMILARITYESTIMATION_H */ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 16fd9193f328427f11517cc28cfb20f69d86f89f..e1ddd5993d05fd7705206c4b29b09b553bd619eb 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -190,11 +190,19 @@ Word32 cross_correlation_self_fx( const Word16 *signal, return sum; } +#ifdef HARMONIZE_2481_EXTEND_SHRINK +bool isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) +#else Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) +#endif { Word16 i, j, samplesPerSegment; Word32 energy, maxEnergy; +#ifdef HARMONIZE_2481_EXTEND_SHRINK + bool ret; +#else Word8 ret; +#endif assert( len > 0 ); assert( segments > 0 ); @@ -205,7 +213,11 @@ Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) * 20 * log10(sum_i(abs(signal[i]))) > -65 */ +#ifdef HARMONIZE_2481_EXTEND_SHRINK + ret = true; +#else ret = 1; +#endif move16(); energy = 0; move32(); @@ -227,7 +239,11 @@ Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) * => energy > samplesPerSegment * 10 ^ (-65 / 20) * 32768 */ IF( GT_32( energy, maxEnergy ) ) { +#ifdef HARMONIZE_2481_EXTEND_SHRINK + ret = false; +#else ret = 0; +#endif move16(); BREAK; } @@ -239,13 +255,22 @@ Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) /* check last segment */ if ( GT_32( energy, maxEnergy ) ) { +#ifdef HARMONIZE_2481_EXTEND_SHRINK + ret = false; +#else ret = 0; +#endif move16(); } + return ret; } +#ifdef HARMONIZE_2481_EXTEND_SHRINK +bool isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 segments ) +#else Word8 isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 segments ) +#endif { Word16 i, j, samplesPerSegment; Word64 energy, maxEnergy; @@ -276,7 +301,11 @@ Word8 isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 * => energy > samplesPerSegment * 10 ^ (-65 / 10) * 32768 * 32768.0*/ IF( GT_64( energy, maxEnergy ) ) { +#ifdef HARMONIZE_2481_EXTEND_SHRINK + return false; +#else return 0; +#endif } IF( EQ_16( i, j ) ) { @@ -286,5 +315,9 @@ Word8 isSilence_ivas_fx( const Word16 *signal, Word16 q_sig, Word16 len, Word16 } } +#ifdef HARMONIZE_2481_EXTEND_SHRINK + return true; +#else return 1; +#endif }