www.pudn.com > CryptoPhone-src-031122.zip > do_zfilt.c


/* Copyright 2001,2002,2003 NAH6 
 * All Rights Reserved 
 * 
 * Parts Copyright DoD, Parts Copyright Starium 
 * 
 */ 
/************************************************************************** 
* 
* ROUTINE 
*		do_zfilt 
*		do_zfilt_dynamic 
* 
* FUNCTION 
*		pole filter - given a filter structure 
*		do_zfilt assumes static coefficients 
*		do_zfilt_dynamic assumes changing coefficients 
* 
* SYNOPSIS 
*		subroutine do_zfilt(flt, coef, data) 
* 
*   formal  
* 
*                       data    I/O 
*       name            type    type    function 
*       -------------------------------------------------------------------	 
*	flt		FILTER	i/o	FILTER structure 
*	coef		float	 i	coefficients 
*	data		float	i/o	input/filtered output data	 
* 
*************************************************************************** 
*        
* DESCRIPTION 
* 
*	Nonrecursive all-zero in-place time-domain filter. 
*	The filter is implemented in a direct form realisation. 
* 
*               N       -i 
*       H(z) = SUM b(i)z 
*              i=0 
* 
*       x(t) ->---(z0)----- b0 >------+-----> y(t) 
*                  |                  | 
*                  z1------ b1 >------+ 
*                  |                  | 
*                  z2------ b2 >------+ 
*                  |                  | 
*                  :                  : 
*                  |                  | 
*                  zN------ bN >------+ 
* 
* 
*************************************************************************** 
* 
* CALLED BY 
* 
*	FindAdaptResidual FindLPCResidual UpdateEverything 
*	HPF_InSpeech HPF_OutSpeech PostFilter  
* 
***************************************************************************/ 
 
#include "celpfilt.h" 
 
void do_zfilt( 
FILTER *flt, 
float data[]) 
{ 
  register float ar; 
  int t, j; 
 
  for (t = 0; t < flt->data_length; t++) 
  { 
    flt->memory[0] = data[t]; 
    ar   = 0.0; 
    for (j = flt->order; j > 0; j--) 
    { 
      ar  += flt->memory[j] * flt->coef[j]; 
      flt->memory[j] = flt->memory[j-1]; 
    } 
    data[t] = ar + flt->memory[0] * flt->coef[0]; 
  } 
} 
 
void do_zfilt_dynamic( 
FILTER 	*flt, 
float	coef[], 
float 	data[]) 
{ 
  register float ar; 
  int t, j; 
 
  for (t = 0; t < flt->data_length; t++) 
  { 
    flt->memory[0] = data[t]; 
    ar   = 0.0; 
    for (j = flt->order; j > 0; j--) 
    { 
      ar  += flt->memory[j] * coef[j]; 
      flt->memory[j] = flt->memory[j-1]; 
    } 
    data[t] = ar + flt->memory[0] * coef[0]; 
  } 
}