xref: /haiku/src/add-ons/media/plugins/ape_reader/MAClib/NNFilter.h (revision be878f60874196f746f336f235797c8efa25004e)
1 #ifndef APE_NNFILTER_H
2 #define APE_NNFILTER_H
3 
4 #include "RollBuffer.h"
5 #define NN_WINDOW_ELEMENTS    512
6 //#define NN_TEST_MMX
7 
8 class CNNFilter
9 {
10 public:
11 
12     CNNFilter(int nOrder, int nShift, int nVersion);
13     ~CNNFilter();
14 
15     int Compress(int nInput);
16     int Decompress(int nInput);
17     void Flush();
18 
19 private:
20 
21     int m_nOrder;
22     int m_nShift;
23     int m_nVersion;
24     BOOL m_bMMXAvailable;
25     int m_nRunningAverage;
26 
27     CRollBuffer<short> m_rbInput;
28     CRollBuffer<short> m_rbDeltaM;
29 
30     short * m_paryM;
31 
GetSaturatedShortFromInt(int nValue)32     inline short GetSaturatedShortFromInt(int nValue) const
33     {
34         return short((nValue == short(nValue)) ? nValue : (nValue >> 31) ^ 0x7FFF);
35     }
36 
37     inline int CalculateDotProductNoMMX(short * pA, short * pB, int nOrder);
38     inline void AdaptNoMMX(short * pM, short * pAdapt, int nDirection, int nOrder);
39 };
40 
41 #endif // #ifndef APE_NNFILTER_H
42