diff --git a/lib_com/options.h b/lib_com/options.h index 523ba0ab821e9f6d47c4568d427fc38ed50afa87..8ab9f0b4c903c9e370774be26214f0c2cb0145da 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #define FIX_2405_HARM_SMC_INIT /* VA, basop 2405, harmonisation of SMC init */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE /* VA: reduction of unnecessary scaling, non-BE part */ +#define FIX_2403_COMBINE_PITCH_OL /* VA : basop 2403, reusing common code between EVS and IVAS in pitch_ol */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index ab58b31bf72c982784571d6aba066143b4cead9f..b7f79eeea18f68a1b73f029d84691e5931284e1f 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -15,6 +15,7 @@ /*-----------------------------------------------------------------* * Local Constants *-----------------------------------------------------------------*/ + #define PIT_MIN2 20 /* pit_min for pitch tracking */ #define PIT_MIN_1 44 /* for second pitch track */ #define PIT_MIN2_1 24 @@ -58,11 +59,17 @@ static Word32 Dot_product12_OL( Word16 *sum1, const Word16 x[], const Word16 y[] static Word32 Dot_product12_OL_back( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 ); +#ifdef FIX_2403_COMBINE_PITCH_OL +static void pitch_ol_resolve_fx( Word16 pitch[3], Word16 voicing[3], Word16 *old_pitch, Word16 *old_corr, Word16 *old_thres, Word16 *delta_pit, const Word16 element_mode, const Word16 corr_shift, const Word16 relE, const Word16 Opt_SC_VBR, Word16 pitchX[NHFR][2 * NSECT], Word16 corX[NHFR][2 * NSECT], Word16 scaledX[NHFR][2 * NSECT], const Word16 sect0, const Word16 *pit_max, const Word16 pit_min_coding ); +#endif + + /*-----------------------------------------------------------------* * pitch_ol_init() * * Open loop pitch variable initialization *-----------------------------------------------------------------*/ + void pitch_ol_init_fx( Word16 *old_thres, /* o : threshold for reinforcement of past pitch influence */ Word16 *old_pitch, /* o : pitch of the 2nd half-frame of previous frame */ @@ -78,8 +85,321 @@ void pitch_ol_init_fx( move16(); *old_corr = 0; move16(); + + return; +} + +#ifdef FIX_2403_COMBINE_PITCH_OL +/*-----------------------------------------------------------------* + * pitch_ol_resolve_fx() + * + * + *-----------------------------------------------------------------*/ + +static void pitch_ol_resolve_fx( + Word16 pitch[3], /* o : open loop pitch lag for each half-frame Q0 */ + Word16 voicing[3], /* o : maximum normalized correlation for each half-frame Q15 */ + Word16 *old_pitch, /* i/o: pitch of the 2nd half-frame of previous frame Q0 */ + Word16 *old_corr, /* i/o: correlation of old_pitch Q15 */ + Word16 *old_thres, /* i/o: maximum correlation weighting with respect to past Q15 or Q14) */ + Word16 *delta_pit, /* i/o: old pitch extrapolation correction Q0 */ + const Word16 element_mode, /* i : if element_mode != EVS old_thres is in Q14 */ + const Word16 corr_shift, /* i : normalized correlation correction Q15 */ + const Word16 relE, /* i : relative frame energy Q8 */ + const Word16 Opt_SC_VBR, /* i : SC-VBR flag */ + Word16 pitchX[NHFR][2 * NSECT], /* i : pitch candidates Q0 */ + Word16 corX[NHFR][2 * NSECT], /* i : correlation candidates Q15 */ + Word16 scaledX[NHFR][2 * NSECT], /* i/o: scaled correlation candidates Q12 */ + const Word16 sect0, /* i : section offset */ + const Word16 *pit_max, /* i : maximum pitch delays (array) */ + const Word16 pit_min_coding /* i : minimum pitch delay for coding */ +) +{ + Word16 i, ind, ind1, ind_corX, ind1_corX; + Word16 fac, ftmp, k, tmp16, diff, cnt; + Word16 add_sect0, sub_sect0; + Word16 coh_flag, coh_flag1; + Word16 cor_mean; + Word32 Ltmp; + + Word16 pitch_tmp[2 * NHFR]; + Word16 ind_tmp[2 * NHFR]; + Word16 cor_tmp[2 * NHFR]; + Word16 thres1[2 * NHFR]; + Word16 tmp_buf[NHFR + 1]; + + /*-----------------------------------------------------------------* + * Favor a smaller delay if it happens that it has its multiple + * in the longer-delay sections (harmonics check) + *-----------------------------------------------------------------*/ + + FOR( i = 0; i < 2; i++ ) /* loop for the 2 half-frames */ + { + fac = THRES0; + move16(); + find_mult_fx( &fac, pitchX[i][2], pitchX[i][3], pit_max[7], &scaledX[i][2], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 3rd section */ + find_mult_fx( &fac, pitchX[i][1], pitchX[i][2], pit_max[5], &scaledX[i][1], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + test(); + IF( ( sect0 == 0 ) && GE_16( shl( pitchX[i][0], 1 ), pit_min_coding ) ) + { + find_mult_fx( &fac, pitchX[i][0], pitchX[i][1], pit_max[3], &scaledX[i][0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + } + fac = THRES0; + move16(); + find_mult_fx( &fac, pitchX[i][NSECT + 2], pitchX[i][NSECT + 3], pit_max[7], &scaledX[i][NSECT + 2], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 3rd section */ + find_mult_fx( &fac, pitchX[i][NSECT + 1], pitchX[i][NSECT + 2], pit_max[6], &scaledX[i][NSECT + 1], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + test(); + IF( ( sect0 == 0 ) && GE_16( shl( pitchX[i][NSECT + 0], 1 ), pit_min_coding ) ) + { + find_mult_fx( &fac, pitchX[i][NSECT + 0], pitchX[i][NSECT + 1], pit_max[4], &scaledX[i][NSECT + 0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + } + } + + fac = THRES0; + move16(); /* the look-ahead */ + find_mult_fx( &fac, pitchX[i][2], pitchX[i][3], pit_max[7], &scaledX[i][2], old_pitch, old_corr, 2, 2 ); /* Multiples in 3rd section */ + find_mult_fx( &fac, pitchX[i][1], pitchX[i][2], pit_max[5], &scaledX[i][1], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + test(); + IF( ( sect0 == 0 ) && GE_16( shl( pitchX[i][0], 1 ), pit_min_coding ) ) + { + find_mult_fx( &fac, pitchX[i][0], pitchX[i][1], pit_max[3], &scaledX[i][0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + } + + fac = THRES0; + move16(); + find_mult_fx( &fac, pitchX[i][NSECT + 2], pitchX[i][NSECT + 3], pit_max[7], &scaledX[i][NSECT + 2], old_pitch, old_corr, 2, 2 ); /* Multiples in 3rd section */ + find_mult_fx( &fac, pitchX[i][NSECT + 1], pitchX[i][NSECT + 2], pit_max[6], &scaledX[i][NSECT + 1], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ + test(); + IF( ( sect0 == 0 ) && GE_16( shl( pitchX[i][NSECT + 0], 1 ), pit_min_coding ) ) + { + find_mult_fx( &fac, pitchX[i][NSECT + 0], pitchX[i][NSECT + 1], pit_max[4], &scaledX[i][NSECT + 0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */ /* Multiples in 2nd section */ + } + + /*-----------------------------------------------------------------* + * Do 1st estimate for pitch values + * Adjust the normalized correlation using estimated noise level + * Compute the maximum scaling for the neighbour correlation + * reinforcement + *-----------------------------------------------------------------*/ + + add_sect0 = add( NSECT, sect0 ); + sub_sect0 = sub( NSECT, sect0 ); + FOR( i = 0; i < NHFR; i++ ) + { + /* 1st set of pitch candidates */ + ind = add( maximum_fx( scaledX[i] + sect0, sub_sect0, &ftmp ), sect0 ); + ind_tmp[i] = ind; + move16(); + pitch_tmp[i] = pitchX[i][ind]; + move16(); + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); + move16(); + + /* Higher is the neighbour's correlation, higher is the weighting */ + /* operands are Q15, result is Q15 */ + thres1[i] = mult( THRES1, cor_tmp[i] ); + move16(); + + /* 2nd set of pitch candidates */ + ind1 = add( maximum_fx( scaledX[i] + add_sect0, sub_sect0, &ftmp ), add_sect0 ); + ind_tmp[i + NHFR] = ind1; + move16(); + pitch_tmp[i + NHFR] = pitchX[i][ind1]; + move16(); + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); + move16(); + + /* Higher is the neighbour's correlation, higher is the weighting */ + /* operands are Q15, result is Q15 */ + thres1[i + NHFR] = mult( THRES1, cor_tmp[i + NHFR] ); + move16(); + } + /*---- + -------------------------------------------------------------* + * Take into account previous and next pitch values of the present + * frame and look-ahead. Choose the pitch lags and normalize + * correlations for each half-frame & look-ahead + *-----------------------------------------------------------------*/ + + pitch_neighbour_fx( sect0, pitch_tmp, pitchX, cor_tmp, scaledX, thres1, ind_tmp ); + + FOR( i = 0; i < NHFR; i++ ) + { + ind = add( maximum_fx( scaledX[i] + sect0, sub_sect0, &ftmp ), sect0 ); + ind_corX = add( maximum_fx( corX[i] + sect0, sub_sect0, &ftmp ), sect0 ); + + ind1 = add( maximum_fx( scaledX[i] + add_sect0, sub_sect0, &ftmp ), add_sect0 ); + ind1_corX = add( maximum_fx( corX[i] + add_sect0, sub_sect0, &ftmp ), add_sect0 ); + + if ( GT_16( scaledX[i][ind1], scaledX[i][ind] ) ) + { + ind = ind1; + move16(); + } + test(); + if ( Opt_SC_VBR && GT_16( corX[i][ind1_corX], corX[i][ind_corX] ) ) + { + ind_corX = ind1_corX; + move16(); + } + test(); + test(); + test(); + IF( Opt_SC_VBR && ( LT_16( mult( pitchX[i][ind], 13107 /*0.4 in Q15*/ ), pitchX[i][ind_corX] ) ) && + ( GT_16( mult( pitchX[i][ind], 19661 /*0.6 in Q15*/ ), pitchX[i][ind_corX] ) ) && + ( GE_16( corX[i][ind_corX], 29491 /*0.9 in Q15*/ ) ) ) + { + pitch[i] = pitchX[i][ind_corX]; + move16(); + voicing[i] = corX[i][ind_corX]; + move16(); + } + ELSE + { + pitch[i] = pitchX[i][ind]; + move16(); + voicing[i] = corX[i][ind]; + move16(); + } + } + + /*-----------------------------------------------------------------* + * Increase the threshold for correlation reinforcement with + * the past if correlation high and pitch stable + *-----------------------------------------------------------------*/ + + /* all Q15 here */ + /* cor_mean = 0.5f * (voicing[0] + voicing[1]) + corr_shift; */ + Ltmp = L_mult( voicing[0], 16384 /*.5 Q15*/ ); + Ltmp = L_mac( Ltmp, voicing[1], 16384 /*.5 Q15*/ ); + cor_mean = round_fx( L_add( Ltmp, corr_shift ) ); + + /* pitch unstable in present frame or from previous frame or normalized correlation too low */ + coh_flag = pitch_coherence_fx( pitch[0], pitch[1], COH_FAC, DELTA_COH ); + move16(); + coh_flag1 = pitch_coherence_fx( pitch[0], *old_pitch, COH_FAC, DELTA_COH ); + move16(); + + test(); + test(); + test(); + IF( ( coh_flag == 0 ) || ( coh_flag1 == 0 ) || ( LT_16( cor_mean, CORR_TH0 ) ) || ( LT_16( relE, THR_relE ) ) ) + { + /* Reset the threshold */ + *old_thres = 0; + move16(); + } + ELSE + { + /* The threshold increase is directly dependent on normalized correlation */ + /* *old_thres += (0.16f * cor_mean); */ + IF( element_mode != EVS_MONO ) + { + *old_thres = round_fx( L_mac0( L_deposit_h( *old_thres ), 5243 /* 0.16f in Q15 */, cor_mean ) ); // Q14 + } + ELSE + { + *old_thres = round_fx( L_mac( L_deposit_h( *old_thres ), 5243 /* 0.16f in Q15 */, cor_mean ) ); // Q15 + } + move16(); + } + IF( element_mode != EVS_MONO ) + { + *old_thres = s_min( *old_thres, 11469 /* 0.7f in Q14 */ ); // Q14 + } + ELSE + { + *old_thres = s_min( *old_thres, THRES3 /* 0.7f in Q14 */ ); // Q15 + } + move16(); + + IF( GT_16( voicing[1], voicing[0] ) ) + { + *old_corr = voicing[1]; + move16(); + } + ELSE + { + *old_corr = cor_mean; + move16(); + } + + /*-----------------------------------------------------------------* + * Extrapolate the pitch value for the next frame by estimating + * the pitch evolution. This value is added to the old_pitch + * in the next frame and is then used when the normalized + * correlation is reinforced by the past estimate + *-----------------------------------------------------------------*/ + + tmp_buf[0] = *old_pitch; + move16(); + FOR( i = 0; i < NHFR; i++ ) + { + tmp_buf[i + 1] = pitch[i]; + move16(); + } + + *delta_pit = 0; + move16(); + cnt = 0; + move16(); + + FOR( i = 0; i < NHFR; i++ ) + { + diff = sub( tmp_buf[i + 1], tmp_buf[i] ); + move16(); + coh_flag = pitch_coherence_fx( tmp_buf[i], tmp_buf[i + 1], COH_FAC, DELTA_COH ); + + if ( coh_flag != 0 ) + { + *delta_pit = add( *delta_pit, diff ); + move16(); + } + cnt = add( cnt, coh_flag ); + } + if ( EQ_16( cnt, 2 ) ) + { + /* *delta_pit /= 2; */ + *delta_pit = shr( *delta_pit, 1 ); + move16(); + } + IF( EQ_16( cnt, 3 ) ) + { + k = *delta_pit; + move16(); + /* *delta_pit /= 3; */ + if ( k < 0 ) + { + *delta_pit = mult( *delta_pit, -32768 /*-1 Q15*/ ); + move16(); + } + tmp16 = mult( *delta_pit, 10923 /*1/3 Q15*/ ); + if ( k < 0 ) + { + tmp16 = mult( tmp16, -32768 /*-1 Q15*/ ); + } + *delta_pit = tmp16; + move16(); + } + + /*--------------------------------------------------------------* + * Update old pitch, upsample pitch, + *--------------------------------------------------------------*/ + + *old_pitch = pitch[1]; + move16(); + + FOR( i = 0; i < NHFR; i++ ) + { + /* compensate decimation */ + pitch[i] = i_mult2( pitch[i], OPL_DECIM ); + move16(); + } + + return; } +#endif /*==================================================================================*/ /* FUNCTION : pitch_ol_fx() */ @@ -166,12 +486,18 @@ void pitch_ol_fx( Word16 *pt_exp1, *pt_exp2, *pt_exp3, *pt_exp4; Word16 *pt1, *pt2, *pt3, *pt4, *pt5, *pt6; Word16 *pt_cor0, *pt_cor1, *pt_cor2, *pt_cor3, *pt_cor4, *pt_cor5, *pt_cor6; +#ifndef FIX_2403_COMBINE_PITCH_OL Word16 thres1[6]; Word16 diff, cnt, ind, ind1, offset, offset1, offset_la, offset_la1, coh_flag, coh_flag1; Word16 ind_corX, ind1_corX; Word16 i, j, k, m, pit_min, pit_min1, sect0, subsect0, add_sect0, sub_sect0, old_tmp, old_tmp1, len_x, len_x1; +#else + Word16 cnt, ind, ind1, offset, offset1, offset_la, offset_la1; + Word16 i, j, k, m, pit_min, pit_min1, sect0, subsect0, old_tmp, old_tmp1, len_x, len_x1; +#endif Word16 len_temp; +#ifndef FIX_2403_COMBINE_PITCH_OL Word16 pitchX[NHFR][2 * NSECT], pitch_tmp[2 * NHFR], ind_tmp[2 * NHFR], tmp_buf[NHFR + 1]; Word16 enr0[NSECT], enr0_exp[NSECT], enr0_1[NSECT], enr0_1_exp[NSECT], enr1, enr1_exp, enr2_exp; @@ -179,6 +505,14 @@ void pitch_ol_fx( Word16 fac, tmp16, tmp16_2; Word16 qCorX, qScaledX; Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT], cor_tmp[2 * NHFR], cor_mean; +#else + Word16 pitchX[NHFR][2 * NSECT]; + Word16 enr0[NSECT], enr0_exp[NSECT], enr0_1[NSECT], enr0_1_exp[NSECT], enr1, enr1_exp, enr2_exp; + Word32 enr, enr2, Ltmp; + Word16 tmp16, tmp16_2; + Word16 qCorX, qScaledX; + Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT]; +#endif const Word16 *len, *len1, *sublen, *sublen1, *pit_max, *sec_length, *sec_length1; Word16 pit_min_coding; @@ -298,6 +632,7 @@ void pitch_ol_fx( /*-----------------------------------------------------------------------------* * Estimate the new pitch by extrapolating the old pitch value for 2 half-frames *-----------------------------------------------------------------------------*/ + old_tmp = add( *old_pitch, *delta_pit ); old_tmp = s_min( old_tmp, PIT_MAX / OPL_DECIM ); old_tmp = s_max( old_tmp, pit_min ); @@ -308,6 +643,7 @@ void pitch_ol_fx( /*-----------------------------------------------------------------* * Loop for all three half-frames (current frame + look-ahead) *-----------------------------------------------------------------*/ + pt_cor0 = scaled_buf + DELTA_COH - 1; pt_cor2 = pt_cor0 - pit_min + old_tmp; @@ -378,6 +714,7 @@ void pitch_ol_fx( /*----------------------------------------------------------* * Find correlation for the non-overlapping pitch lag values *----------------------------------------------------------*/ + exp_sect[subsect0] = 0; move16(); pt_cor5 = pt_cor1; @@ -413,6 +750,7 @@ void pitch_ol_fx( /*----------------------------------------------------------* * For each subsection, find the correlation *----------------------------------------------------------*/ + FOR( j = subsect0; j < NSUBSECT; j++ ) { len_temp = sublen[j]; @@ -525,6 +863,7 @@ void pitch_ol_fx( /*-----------------------------------------------------------------* * Find correlation for the non-overlapping pitch lag values *-----------------------------------------------------------------*/ + exp_sect[subsect0] = 0; move16(); pt_cor5 = pt_cor1; @@ -673,6 +1012,7 @@ void pitch_ol_fx( * Scale correlation function in the neighbourhood of * the extrapolated pitch *-----------------------------------------------------------------*/ + pt_cor1 = pt_cor2 - ( DELTA_COH - 1 ); pt_cor3 = pt_cor4 - ( DELTA_COH - 1 ); pt2 = scale1; @@ -802,6 +1142,9 @@ void pitch_ol_fx( } /* FOR j < NSECT */ } /* FOR i < NHFR */ +#ifdef FIX_2403_COMBINE_PITCH_OL + pitch_ol_resolve_fx( pitch, voicing, old_pitch, old_corr, old_thres, delta_pit, EVS_MONO, corr_shift, relE, Opt_SC_VBR, pitchX, corX, scaledX, sect0, pit_max, pit_min_coding ); +#else /*-----------------------------------------------------------------* * Favor a smaller delay if it happens that it has its multiple * in the longer-delay sections (harmonics check) @@ -1050,10 +1393,12 @@ void pitch_ol_fx( pitch[i] = i_mult2( pitch[i], OPL_DECIM ); move16(); } +#endif return; } + void pitch_ol_ivas_fx( Word16 pitch[3], /* o : open loop pitch lag for each half-frame in range [29,231] Q0 */ Word16 voicing[3], /* o : maximum normalized correlation for each half-frame in [0,1.0[ Q15 */ @@ -1072,7 +1417,11 @@ void pitch_ol_ivas_fx( Word16 qwsp /* i : Q factor for wsp Q0 */ ) { +#ifndef FIX_2403_COMBINE_PITCH_OL Word16 ftmp, old_wsp2[( L_WSP - L_INTERPOL ) / OPL_DECIM], *wsp2; +#else + Word16 old_wsp2[( L_WSP - L_INTERPOL ) / OPL_DECIM], *wsp2; +#endif Word16 tmp_mem[3]; Word16 scale1[2 * DELTA_COH - 1]; @@ -1082,6 +1431,7 @@ void pitch_ol_ivas_fx( Word16 *pt1, *pt2, *pt3, *pt4, *pt5, *pt6; Word16 *pt_cor0, *pt_cor1, *pt_cor2, *pt_cor3, *pt_cor4; Word16 *pt_cor0_exp, *pt_cor1_exp, *pt_cor2_exp, *pt_cor3_exp, *pt_cor4_exp; +#ifndef FIX_2403_COMBINE_PITCH_OL Word16 thres1[6]; Word16 diff, cnt, ind, ind1, offset, offset1, offset_la, offset_la1, coh_flag, coh_flag1; Word16 ind_corX, ind1_corX; @@ -1096,6 +1446,20 @@ void pitch_ol_ivas_fx( Word32 Ltmp; Word16 fac, tmp16, tmp16_2; Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT], cor_tmp[2 * NHFR], cor_mean; +#else + Word16 cnt, ind, ind1, offset, offset1, offset_la, offset_la1; + Word16 i, j, k, m, pit_min, pit_min1, sect0, subsect0, old_tmp, old_tmp1, len_x, len_x1; + Word16 len_temp; + Word16 pitchX[NHFR][2 * NSECT]; + + Word16 enr0_exp[NSECT], enr0_1_exp[NSECT], enr1_exp; + Word32 enr0[NSECT], enr0_1[NSECT], enr1; + Word64 temp, temp1; + Word32 Ltmp; + Word16 tmp16, tmp16_2; + Word16 scaledX[NHFR][2 * NSECT], corX[NHFR][2 * NSECT]; +#endif + const Word16 *len, *len1, *sublen, *sublen1, *pit_max, *sec_length, *sec_length1; Word16 pit_min_coding; @@ -1163,6 +1527,7 @@ void pitch_ol_ivas_fx( * Extend the decimation of wsp to the end of the speech buffer * Update wsp memory *--------------------------------------------------------------*/ + Copy( st_old_wsp2, old_wsp2, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); wsp2 = old_wsp2 + ( ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); @@ -1212,6 +1577,7 @@ void pitch_ol_ivas_fx( /*-----------------------------------------------------------------------------* * Estimate the new pitch by extrapolating the old pitch value for 2 half-frames *-----------------------------------------------------------------------------*/ + old_tmp = add( *old_pitch, *delta_pit ); old_tmp = s_min( old_tmp, PIT_MAX / OPL_DECIM ); old_tmp = s_max( old_tmp, pit_min ); @@ -1222,6 +1588,7 @@ void pitch_ol_ivas_fx( /*-----------------------------------------------------------------* * Loop for all three half-frames (current frame + look-ahead) *-----------------------------------------------------------------*/ + pt_cor0 = scaled_buf + DELTA_COH - 1; pt_cor0_exp = scaled_buf_exp + DELTA_COH - 1; @@ -1341,6 +1708,7 @@ void pitch_ol_ivas_fx( /*----------------------------------------------------------* * For each subsection, find the correlation *----------------------------------------------------------*/ + FOR( j = subsect0; j < NSUBSECT; j++ ) { len_temp = sublen[j]; @@ -1426,6 +1794,7 @@ void pitch_ol_ivas_fx( /*-----------------------------------------------------------------* * For each section in both sets, find fixed vector energy *-----------------------------------------------------------------*/ + FOR( j = sect0; j < NSECT; j++ ) /* loop for each section */ { /* 1st set */ @@ -1606,6 +1975,7 @@ void pitch_ol_ivas_fx( * Scale correlation function in the neighbourhood of * the extrapolated pitch *-----------------------------------------------------------------*/ + pt_cor1 = pt_cor2 - ( DELTA_COH - 1 ); pt_cor1_exp = pt_cor2_exp - ( DELTA_COH - 1 ); pt_cor3 = pt_cor4 - ( DELTA_COH - 1 ); @@ -1758,6 +2128,9 @@ void pitch_ol_ivas_fx( } /* FOR j < NSECT */ } /* FOR i < NHFR */ +#ifdef FIX_2403_COMBINE_PITCH_OL + pitch_ol_resolve_fx( pitch, voicing, old_pitch, old_corr, old_thres, delta_pit, IVAS_SCE, corr_shift, relE, Opt_SC_VBR, pitchX, corX, scaledX, sect0, pit_max, pit_min_coding ); /* any element mode other than EVS_MONO is OK here */ +#else /*-----------------------------------------------------------------* * Favor a smaller delay if it happens that it has its multiple * in the longer-delay sections (harmonics check) @@ -2007,7 +2380,7 @@ void pitch_ol_ivas_fx( pitch[i] = i_mult2( pitch[i], OPL_DECIM ); move16(); } - +#endif return; } @@ -2018,6 +2391,7 @@ void pitch_ol_ivas_fx( * Verifies whether max pitch delays in higher sections have multiples * in lower sections *-----------------------------------------------------------------*/ + static void find_mult_fx( Word16 *fac, /* i/o: correlation scaling factor Q12 */ Word16 pitch0, /* i : pitch of max correlation in the c section */ @@ -2054,6 +2428,8 @@ static void find_mult_fx( pit_min = add( pit_min, pitch0 ); /* next multiple */ delta = add( delta, step ); /* the incertitude to the allowed range */ } + + return; } /*---------------------------------------------------------------------------* @@ -2062,6 +2438,7 @@ static void find_mult_fx( * Verifies if the maximum correlation pitch lag is coherent with neighbour * values *---------------------------------------------------------------------------*/ + static void pitch_neighbour_fx( Word16 sect0, /* i : indicates whether section 0 (below PIT_MIN) is used */ Word16 pitch_tmp[], /* i : estimated pitch values for each half-frame & look-ahead */ @@ -2175,13 +2552,17 @@ static void pitch_neighbour_fx( } } } + + return; } + /*-----------------------------------------------------------------* * pitch_coherence_fx * * Verify if pitch evolution is smooth *-----------------------------------------------------------------*/ + static Word16 pitch_coherence_fx( Word16 pitch0, /* i : first pitch to compare */ Word16 pitch1, /* i : 2nd pitch to compare */ @@ -2208,11 +2589,13 @@ static Word16 pitch_coherence_fx( return pc; } + /*-----------------------------------------------------------------* * LP_Decim2_Copy: * * Decimate a vector by 2 with 2nd order fir filter. *-----------------------------------------------------------------*/ + static void LP_Decim2_Copy( const Word16 x[], /* i: signal to process */ Word16 y[], /* o: signal to process */ @@ -2262,20 +2645,26 @@ static void LP_Decim2_Copy( y[j++] = round_fx( L_tmp ); move16(); } + + return; } + + /*---------------------------------------------------------------------* * Dot_product12_OL * * two different length dot products of x and y *---------------------------------------------------------------------*/ -static Word32 Dot_product12_OL( /* o : Q31: normalized result (1 < val <= -1) */ - Word16 *sum1, /* o : Q31: normalized result 2 */ - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg, /* i : vector length */ - const Word16 lg2, /* i : vector length 2 */ - Word16 *exp, /* o : exponent of result (0..+30) */ - Word16 *exp2 /* o : exponent of result 2 (0..+30) */ + +/* o : Q31: normalized result (1 < val <= -1) */ +static Word32 Dot_product12_OL( + Word16 *sum1, /* o : Q31: normalized result 2 */ + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg, /* i : vector length */ + const Word16 lg2, /* i : vector length 2 */ + Word16 *exp, /* o : exponent of result (0..+30) */ + Word16 *exp2 /* o : exponent of result 2 (0..+30) */ ) { Word16 i, sft; @@ -2327,19 +2716,22 @@ static Word32 Dot_product12_OL( /* o : Q31: normalized result return L_sum; } + /*---------------------------------------------------------------------* * Dot_product12_OL_back() * * two different length dot products of x and y, computed backward *---------------------------------------------------------------------*/ -static Word32 Dot_product12_OL_back( /* o : Q31: normalized result (1 < val <= -1) */ - Word16 *sum1, /* o : Q31: normalized result 2 */ - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg, /* i : vector length */ - const Word16 lg2, /* i : vector length 2 */ - Word16 *exp, /* o : exponent of result (0..+30) */ - Word16 *exp2 /* o : exponent of result 2 (0..+30) */ + +/* o : Q31: normalized result (1 < val <= -1) */ +static Word32 Dot_product12_OL_back( + Word16 *sum1, /* o : Q31: normalized result 2 */ + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg, /* i : vector length */ + const Word16 lg2, /* i : vector length 2 */ + Word16 *exp, /* o : exponent of result (0..+30) */ + Word16 *exp2 /* o : exponent of result 2 (0..+30) */ ) { Word16 i, sft; @@ -2391,6 +2783,13 @@ static Word32 Dot_product12_OL_back( /* o : Q31: normalized r return L_sum; } + +/*---------------------------------------------------------------------* + * pitchDoubling_det_fx() + * + * + *---------------------------------------------------------------------*/ + void pitchDoubling_det_fx( Word16 *wspeech, Word16 *pitch_ol, @@ -2402,7 +2801,6 @@ void pitchDoubling_det_fx( Word16 new_Top[2]; Word16 m, T; - /*save initial values*/ new_Top[0] = pitch_ol[0]; @@ -2412,7 +2810,6 @@ void pitchDoubling_det_fx( FOR( m = 2; m < 5; m++ ) { - /* T= pitch_ol[0]/m; */ T = mult( pitch_ol[0], One_div_fx[m - 1] ); @@ -2465,4 +2862,5 @@ void pitchDoubling_det_fx( pitch_ol[1] = new_Top[1]; move16(); -} /*end of pitch doubling detection*/ + return; +}