/* * 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. */ /* * lattice.c * * contains the normalized lattice filter routines (MA and AR) for iSAC codec * */ #include "settings.h" #include "codec.h" #include #include #ifdef WEBRTC_ANDROID #include #endif /* filter the signal using normalized lattice filter */ /* MA filter */ void WebRtcIsac_NormLatticeFilterMa(int orderCoef, float *stateF, float *stateG, float *lat_in, double *filtcoeflo, double *lat_out) { int n,k,i,u,temp1; int ord_1 = orderCoef+1; float sth[MAX_AR_MODEL_ORDER]; float cth[MAX_AR_MODEL_ORDER]; float inv_cth[MAX_AR_MODEL_ORDER]; double a[MAX_AR_MODEL_ORDER+1]; float f[MAX_AR_MODEL_ORDER+1][HALF_SUBFRAMELEN], g[MAX_AR_MODEL_ORDER+1][HALF_SUBFRAMELEN]; float gain1; for (u=0;u=0;i--) //get the state of f&g for the first input, for all orders { ARf[i][0] = cth[i]*ARf[i+1][0] - sth[i]*stateG[i]; ARg[i+1][0] = sth[i]*ARf[i+1][0] + cth[i]* stateG[i]; } ARg[0][0] = ARf[0][0]; for(n=0;n<(HALF_SUBFRAMELEN-1);n++) { for(k=orderCoef-1;k>=0;k--) { ARf[k][n+1] = cth[k]*ARf[k+1][n+1] - sth[k]*ARg[k][n]; ARg[k+1][n+1] = sth[k]*ARf[k+1][n+1] + cth[k]* ARg[k][n]; } ARg[0][n+1] = ARf[0][n+1]; } memcpy(lat_out+u * HALF_SUBFRAMELEN, &(ARf[0][0]), sizeof(float) * HALF_SUBFRAMELEN); /* cannot use memcpy in the following */ for (i=0;i0; m--) { tmp_inv = 1.0f / cth2; for (k=1; k<=m; k++) { tmp[k] = ((float)a[k] - sth[m] * (float)a[m-k+1]) * tmp_inv; } for (k=1; k