-
Notifications
You must be signed in to change notification settings - Fork 3
/
ctoolbox.cpp
67 lines (57 loc) · 2.19 KB
/
ctoolbox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/***************************************************************************
ctoolbox.cpp - description
-------------------
begin : Wed Aug 4 1999
copyright : (C) 1999 by Thorsten Janke
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "ctoolbox.h"
CToolBox::CToolBox()
{
}
CToolBox::~CToolBox()
{
}
// CToolBox::filter_tp( char... )
// filter_tp chSrc to chDest with nSize and
// feedback coefficient fC2
void CToolBox::filter_tp( char* chDest, char* chSrc, int nSize)
{
int nRun;
unsigned char fData;;
unsigned char fFilterData;
for ( nRun= 0; nRun< nSize; nRun++ )
{
fData = (unsigned char) chSrc[nRun];
fFilterData = (unsigned char) chDest[nRun];
fFilterData = (fData >> 1)
+ (fFilterData>>1);
chDest[nRun] = (int)fFilterData;
}
}
// returns average of chSrc with size nSize
int CToolBox::getAverage( char* chSrc, int nSize )
{
float fSum = 0;
for( int i=0; i< nSize; i++ )
fSum += chSrc[i];
fSum = fSum / (nSize) ;
return (int)fSum;
}
// filter one byte
void CToolBox::filter_tp( char* chDest, char* chSrc)
{
unsigned char fData = (unsigned char) *chSrc;
unsigned char fFilterData = (unsigned char) *chDest;
fFilterData = (fData >> 1)
+ (fFilterData>>1);
*chDest = fFilterData;
}