📄 fir_filter.c
字号:
/************************************************************
Copyright (C), 2007 by SEED Electronic Technology LTD.
FileName: FIR_filter.c
Author: Marine Version : V1.0 Date:Dec25,2006
Description: FIR滤波
*************************************************************/
/***********************************************************
Function: fir_filter
Description: 对一组数据进行FIR滤波
Calls: No
Called By: main
Input: const int x[]:输入信号的缓冲数组,int类型,在滤波中不可修改
const int h[]:滤波器的系数数组,int类型,在滤波中不可修改
short y[]:输出信号的缓冲数组,short类型
n:滤波器长度,本例中为ORDER_FIR
m:输入信号的长度,即数组x[]的长度
s:生成整型的滤波器系数时使用的移位数目,本例中为ROUND_FIR
Output: No
Return: No
Others: 需要打开-o3编译选项
************************************************************/
void fir_filter(const int x[],const int h[],short y[],int n,int m,int s)
{
int i, j;
long y0, y1;
long round;
round=1L<<(s-1);
_nassert(m>=16);
_nassert(n>=16);
for(j=0;j<(m>>1);j++)
{
y0=round;
y1=round;
for(i=0; i<(n>>1); i++)
{
y0+=_mpy(x[i+j],h[i]);
y0+=_mpyh(x[i+j],h[i]);
y1+=_mpyhl(x[i+j],h[i]);
y1+=_mpylh(x[i+j+1],h[i]);
}
*y++=(short)(y0>>s);
*y++=(short)(y1>>s);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -