/* * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include #include #ifdef WEBRTC_ANDROID #include #endif #include "modules/audio_coding/codecs/isac/main/source/pitch_estimator.h" #include "modules/audio_coding/codecs/isac/main/source/isac_vad.h" static void WebRtcIsac_AllPoleFilter(double* InOut, double* Coef, size_t lengthInOut, int orderCoef) { /* the state of filter is assumed to be in InOut[-1] to InOut[-orderCoef] */ double scal; double sum; size_t n; int k; //if (fabs(Coef[0]-1.0)<0.001) { if ( (Coef[0] > 0.9999) && (Coef[0] < 1.0001) ) { for(n = 0; n < lengthInOut; n++) { sum = Coef[1] * InOut[-1]; for(k = 2; k <= orderCoef; k++){ sum += Coef[k] * InOut[-k]; } *InOut++ -= sum; } } else { scal = 1.0 / Coef[0]; for(n=0;nbuffer, sizeof(double) * PITCH_WLPCBUFLEN); memcpy(tmpbuffer+PITCH_WLPCBUFLEN, in, sizeof(double) * PITCH_FRAME_LEN); memcpy(wfdata->buffer, tmpbuffer+PITCH_FRAME_LEN, sizeof(double) * PITCH_WLPCBUFLEN); dp=weoutbuf; dp2=whoutbuf; for (k=0;kweostate[k]; *dp2++ = wfdata->whostate[k]; opol[k]=0.0; } opol[0]=1.0; opol[PITCH_WLPCORDER]=0.0; weo=dp; who=dp2; endpos=PITCH_WLPCBUFLEN + PITCH_SUBFRAME_LEN; inp=tmpbuffer + PITCH_WLPCBUFLEN; for (n=0; nwindow[k]*tmpbuffer[start+k]; } /* Get LPC polynomial */ WebRtcIsac_AutoCorr(corr, ext, PITCH_WLPCWINLEN, PITCH_WLPCORDER); corr[0]=1.01*corr[0]+1.0; /* White noise correction */ WebRtcIsac_LevDurb(apol, rc, corr, PITCH_WLPCORDER); WebRtcIsac_BwExpand(apolr, apol, rho, PITCH_WLPCORDER+1); /* Filtering */ WebRtcIsac_ZeroPoleFilter(inp, apol, apolr, PITCH_SUBFRAME_LEN, PITCH_WLPCORDER, weo); WebRtcIsac_ZeroPoleFilter(inp, apolr, opol, PITCH_SUBFRAME_LEN, PITCH_WLPCORDER, who); inp+=PITCH_SUBFRAME_LEN; endpos+=PITCH_SUBFRAME_LEN; weo+=PITCH_SUBFRAME_LEN; who+=PITCH_SUBFRAME_LEN; } /* Export filter states */ for (k=0;kweostate[k]=weoutbuf[PITCH_FRAME_LEN+k]; wfdata->whostate[k]=whoutbuf[PITCH_FRAME_LEN+k]; } /* Export output data */ memcpy(weiout, weoutbuf+PITCH_WLPCORDER, sizeof(double) * PITCH_FRAME_LEN); memcpy(whiout, whoutbuf+PITCH_WLPCORDER, sizeof(double) * PITCH_FRAME_LEN); }