SDC C-Project CF Review 프로그램
LYW
2022-07-26 73f77c34a0d680de9e562a7e572764ffc746fbac
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#pragma once
 
// templateÀ» »ç¿ëÇÑ ¹è¿­ °ø°£ »ý¼º, ±âº»ÀûÀ¸·Î ¸Þ¸ð¸®´Â Àç»ç¿ë ¸ñÀû.
// 1Â÷¿ø : CMosisLine
// 2Â÷¿ø : CMosisSquare, CSquareSquare
 
 
template<typename Ty>
class CMosisLine
{
    Ty    *m_pData;
    int    m_nData;
    int m_nSpace;
    
public:
    CMosisLine() : m_pData(NULL), m_nData(0), m_nSpace(0)    {}
    ~CMosisLine()    {Release();}
public:
    void    Release()        {if(m_pData) delete[] m_pData; m_pData= NULL; m_nData= m_nSpace= 0;    }
    BOOL    SetSize(int n);
public:
    Ty        *GetAddr()    {return m_pData;}
    Ty        *GetData(int i)    {return m_pData+ i;}
    int        GetSize()        {return m_nData;}
    BOOL    CopyFrom(Ty *p, int n)    {if(! SetSize(n)) return FALSE; memcpy(GetAddr(), p, sizeof(Ty)*n); return TRUE;}
};
 
 
 
template<typename Ty>
class CMosisSquare
{
    Ty            *m_pData;
    int            m_nWidth;
    int            m_nHeight;
    int            m_nSpace;        // Àç»ç¿ëÀ» À§ÇØ ½ÇÁ¦ ¸Þ¸ð¸®»óÀÇ Å©±â.
 
public:
    CMosisSquare(): m_pData(NULL), m_nSpace(0), m_nWidth(0), m_nHeight(0)    {}
    ~CMosisSquare()    {Release();}
 
protected:
    void Release(){if(m_pData) delete[] m_pData; m_pData= NULL; m_nWidth= m_nHeight= m_nSpace= 0;}
 
public:
    BOOL SetSize(int w, int h);
    static int GetSquareNum(int n){    int sq= 1;    while(sq < n){sq= sq<< 1;}    return sq;    }
 
public:
    Ty*    GetData(int x, int y)    {return m_pData+ x+ y*m_nWidth;};
    Ty* GetAddress()            {return m_pData;}
    int GetWidth()                {return m_nWidth;}
    int GetHeight()                {return m_nHeight;}
    int    GetDataSize(){return GetWidth()*GetHeight();}
 
public:
    BOOL    IsValidBuff(){return (GetAddress() != NULL) && (GetWidth()>0) && (GetHeight()>0);}
};
 
 
// FFT¿¡¼­ 2^n °³ÀÇ µ¥ÀÌÅ͸¦ ¸ð»çÇϱâ À§ÇØ ¸Þ¸ð¸® °ø°£°ú ½ÇÁ¦ »ç¿ë µ¥ÀÌÅÍ °³¼ö¸¦ º°µµ ºÐ¸®.
template<typename Ty>
class CSquareSquare
{
    Ty            *m_pData;
    int            m_nRealWidth, m_nWidth;
    int            m_nRealHeight, m_nHeight;
    int            m_nSpace;        // Àç»ç¿ëÀ» À§ÇØ ½ÇÁ¦ ¸Þ¸ð¸®»óÀÇ Å©±â.
 
public:
    CSquareSquare(): m_pData(NULL), m_nWidth(0), m_nRealWidth(0), m_nHeight(0), m_nRealHeight(0), m_nSpace(0)    {}
    ~CSquareSquare()    {Release();}
 
protected:
    void Release(){if(m_pData) delete[] m_pData; m_pData= NULL; m_nWidth= m_nRealWidth= m_nHeight= m_nRealHeight= m_nSpace= 0;}
 
public:
    BOOL SetSize(int w, int h);
    static int GetSquareNum(int n){    int sq= 1;    while(sq < n){sq= sq<< 1;}    return sq;    }
public:
    Ty*    GetData(int x, int y)    {return m_pData+ x+ y*m_nWidth;};
    Ty* GetAddress()            {return m_pData;}
    int GetWidth()                {return m_nWidth;}
    int GetRealWidth()            {return m_nRealWidth;}
    int GetHeight()                {return m_nHeight;}
    int GetRealHeight()            {return m_nRealHeight;}
};
 
 
 
 
template<typename Ty> BOOL CMosisLine<Ty>::SetSize(int n)
{
    if(m_pData)
    {
        if(n < m_nSpace)
        {
            m_nData= n;
            return TRUE;
        }
        Release();
    }
 
    m_pData= new Ty[n];
 
    if(m_pData == NULL)        return FALSE;
 
    m_nData= m_nSpace= n;
    return TRUE;
}
 
 
template<typename Ty> BOOL CMosisSquare<Ty>::SetSize(int width, int height)
{
    int space= width*height;
 
    if(m_pData)
    {
        if(space <= m_nSpace)
        {
            m_nWidth= width;
            m_nHeight= height;
            return TRUE;
        }
        Release();
    }
 
    m_pData= new Ty[space];
    if(m_pData == NULL)    return FALSE;
 
    m_nWidth= width;
    m_nHeight= height;
    m_nSpace= space;
 
    return TRUE;
}
 
 
template<typename Ty> BOOL CSquareSquare<Ty>::SetSize(int w, int h)
{
    int width= GetSquareNum(w);
    int height= GetSquareNum(h);
    int space= width*height;
 
    if(m_pData)
    {
        if(space <= m_nSpace)
        {
            m_nWidth= width;
            m_nRealWidth= w;
            m_nHeight= height;
            m_nRealHeight= h;
            return TRUE;
        }
        Release();
    }
 
    m_pData= new Ty[space];
    if(m_pData == NULL)    return FALSE;
 
    m_nWidth= width;
    m_nRealWidth= w;
    m_nHeight= height;
    m_nRealHeight= h;
    m_nSpace= space;
 
    return TRUE;
}