nmpp
iSupport.h
1//------------------------------------------------------------------------
2//
3// $Workfile:: iSupport.h $
4//
5// Neuro mtr processing library
6//
7// Copyright (c) RC Module Inc.
8//
9// $Revision: 1.1 $ $Date: 2005/02/10 12:36:38 $
10//
19//------------------------------------------------------------------------
20#ifndef __IMALLOC_H
21#define __IMALLOC_H
22#include "nmtype.h"
23/*
24__INLINE__ int nmppsSizeOf_8s(nm8s* a, int nCount) {
25 return nCount>>2;
26}
27__INLINE__ int nmppsSizeOf_8u(nm8u*, int nCount) {
28 return nCount>>2;
29}
30__INLINE__ int nmppsSizeOf_32s(nm32s*, int nCount) {
31 return nCount;
32}
33__INLINE__ int nmppsSizeOf_32u(nm32u*, int nCount) {
34 return nCount;
35}
36
37*/
38
39// __INLINE__ int nmppsSizeOf_8s(nm8s*, int nCount){
40// return nCount>>2;
41// }
42// __INLINE__ int nmppsSizeOf_8u(nm8u*, int nCount){
43// return nCount>>2;
44// }
45// __INLINE__ int nmppsSizeOf_32s(nm32s*, int nCount){
46// return nCount;
47// }
48// __INLINE__ int nmppsSizeOf_32u(nm32u*, int nCount){
49// return nCount;
50// }
51
52template <class T> class C_Img
53{
54protected:
55
56public:
57 int m_nBorder;
58 T* m_pContainer;
59 T* m_pData;
60 int m_nWidth;
61 int m_nHeight;
62 int m_nStride;
63 int m_nSize;
64 C_Img(int nWidth,int nHeight, int nStride, int nBorder, void* (*allocator32)(int))
65 {
66 m_nWidth=nWidth;
67 m_nHeight=nHeight;
68 m_nBorder=nBorder;
69 m_nStride=nStride;
70 m_nSize=m_nStride*m_nHeight;
71 m_pContainer=(T*)allocator32(nmppsSizeOf_(m_pData,m_nStride*(m_nHeight+2*m_nBorder)));
72 //nmppsMalloc_64s(&m_pContainer, m_nStride*(m_nHeight+2*m_nBorder), nHint);
73 m_pData=nmppsAddr_(m_pContainer,m_nStride*m_nBorder);
74 }
75 C_Img(T* pData, int nWidth,int nHeight, int nStride, int nBorder)
76 {
77 m_nWidth=nWidth;
78 m_nHeight=nHeight;
79 m_nBorder=nBorder;
80 m_nStride=nStride;
81 m_nSize=m_nStride*m_nHeight;
82 m_pContainer=0;;
83 m_pData=pData;
84
85 }
86 ~C_Img()
87 {
88 if (m_pContainer)
89 nmppsFree(m_pContainer);
90 }
91 void Fill(T color)
92 {
93 nmppsSet_(m_pContainer,color,m_nSize+2*m_nBorder*m_nStride);
94 }
95};
96
97//*****************************************************************************
98
99 /*
100 \internal
101 \defgroup nmppiMalloc nmppiMalloc
102 \ingroup iSupport
103 \brief
104 \ru Распределение памяти для изображений библиотеки.
105 \en Memory allocation for library images.
106
107 \~
108 \ru Начало и конец распределяемой памяти выравнивается на начало
109 64-х разрядного слова.
110 \en Begin and end of the allocated memory are being
111 aligned to 64-bit word.
112 \~
113 \param nWidth
114 \ru Ширина изображения в пикселях.
115 \en Image width in pixels.
116 \~
117 \param nHeight
118 \ru Высота изображения в пикселях.
119 \en Image height in pixels.
120 \~
121 \param hint
122 \ru Номер банка памяти. Может принимать значения
123 MEM_LOCAL, MEM_GLOBAL.
124 \en Number of memory bank. Admissible values for memory bank
125 are MEM_LOCAL, MEM_GLOBAL.
126 \~
127 \note \ru Память, распределенная с помощью функций nmppiMalloc должна
128 освобождаться только с помощью функции nmppiFree.
129 \en Memory allocated by function nmppiMalloc should be
130 deallocated by nmppiFree function only.
131 \~
132 */
134/*
135void nmppiMalloc(nm1** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
136void nmppiMalloc(nm2s** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
137void nmppiMalloc(nm2u** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
138void nmppiMalloc(nm4s** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
139void nmppiMalloc(nm4u** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
140void nmppiMalloc(nm8u** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
141void nmppiMalloc(nm8s** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
142void nmppiMalloc(nm16u** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
143void nmppiMalloc(nm16s** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
144void nmppiMalloc(nm32u** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
145void nmppiMalloc(nm32s** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
146void nmppiMalloc(nm64u** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
147void nmppiMalloc(nm64s** pptr, int nWidth, int nHeight, int hint = MEM_LOCAL);
148*/
150
151//*****************************************************************************
152 /*
153 \defgroup nmppiFree nmppiFree
154 \ingroup iSupport
155 \brief
156 \ru Освобождение памяти для изображений.
157 \en Memory deallocation for images.
158 \~
159 \note
160 \ru Данная функция должна вызываться только для
161 векторов, распределенных с помощью функций
162 nmppiMalloc.
163 \en This function should be called only for matrixis
164 allocated by nmppiMalloc functions.
165 \~
166 */
168//void nmppiFree(void* ptr);
170
171
181__INLINE__ void nmppiReleaseObject(nm64s* pKernel);
183
184
185
186#endif
Definition: iSupport.h:53
long long nm64s
Definition: nmtype.h:375