/*==================================================================================== EVS Codec 3GPP TS26.442 Apr 03, 2018. Version 12.11.0 / 13.6.0 / 14.2.0 ====================================================================================*/ #include "options.h" /* Compilation switches */ #include "cnst_fx.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "stl.h" /*----------------------------------------------------------------------------------* * findpulse() * * Find first pitch pulse in a frame *----------------------------------------------------------------------------------*/ Word16 findpulse_fx( /* o : pulse position */ const Word16 L_frame, /* i : length of the frame */ const Word16 res[], /* i : Residual signal <12 bits */ const Word16 T0, /* i : Pitch estimation Q0 */ const Word16 enc, /* i : enc = 1 -> encoder side; enc = 0 -> decoder side */ Word16 *sign /* i/o: sign of the maximum */ ) { const Word16 *ptr; Word16 maxval; Word16 i, maxi; Word32 Ltmp; Word16 resf[L_FRAME16k]; /* Low pass filtered residual */ IF (enc != DEC) { /*------------------------------------------------------------------------* * 1. Very simple LP filter *------------------------------------------------------------------------*/ /* resf[0] = 0.50f * res[0] + 0.25f * res[1] */ Ltmp = L_mult(res[0], 16384); resf[0] = mac_r(Ltmp, res[1], 8192); move16(); FOR (i=1; i= 0) { *sign = 0; move16(); }*/ *sign = negate(shr(ptr[-maxi], 15)); move16(); } ELSE { /*-----------------------------------------------------------------* * 2. Find "biggest" pulse in the last pitch section according to the sign *-----------------------------------------------------------------*/ maxval = 0; move16(); maxi = 0; move16(); IF (*sign == 0) { FOR (i = 0; i < T0; i++) { if (sub(res[i], maxval) >= 0) { maxi = add(i, 1); } maxval = s_max(res[i], maxval); } } ELSE { FOR (i = 0; i < T0; i++) { if (sub(res[i], maxval) <= 0) { maxi = add(i, 1); } maxval = s_min(res[i], maxval); } } } return maxi; }