1 | |
---|
2 | |
---|
3 | #include "TRenImage.h" |
---|
4 | #include "TRenImagePlane.h" |
---|
5 | #include "TRenFilter.h" |
---|
6 | |
---|
7 | template<typename T> |
---|
8 | TRenImage<T>::TRenImage( TRenImage& rcIn ) |
---|
9 | { |
---|
10 | allocatePlanes( rcIn.getPlane(0)->getWidth(), rcIn.getPlane(0)->getHeight(), rcIn.getNumberOfFullPlanes(), rcIn.getNumberOfQuaterPlanes() ) ; assign(&rcIn); |
---|
11 | } |
---|
12 | |
---|
13 | template<typename T> |
---|
14 | TRenImage<T>::TRenImage( UInt uiWidth, UInt uiHeight, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes ) |
---|
15 | { |
---|
16 | allocatePlanes( uiWidth, uiHeight, uiNumberOfFullPlanes, uiNumberOfQuaterPlanes ); |
---|
17 | } |
---|
18 | |
---|
19 | template<typename T> |
---|
20 | TRenImage<T>::TRenImage() : m_uiNumberOfFullPlanes(0), m_uiNumberOfQuaterPlanes(0), m_uiNumberOfPlanes(0), m_apcPlanes(0) |
---|
21 | { |
---|
22 | |
---|
23 | } |
---|
24 | |
---|
25 | |
---|
26 | template<> |
---|
27 | TRenImage<Pel>::TRenImage( TComPicYuv* pcPicYuv, Bool bFirstPlaneOnly ) |
---|
28 | { |
---|
29 | if (bFirstPlaneOnly) //400 |
---|
30 | { |
---|
31 | m_uiNumberOfPlanes = 1; |
---|
32 | m_uiNumberOfFullPlanes = 1; |
---|
33 | m_uiNumberOfQuaterPlanes = 0; |
---|
34 | m_apcPlanes = new TRenImagePlane<Pel>*[ m_uiNumberOfPlanes ]; |
---|
35 | m_apcPlanes[0] = new TRenImagePlane<Pel>( pcPicYuv->getBufY(), pcPicYuv->getWidth() + (REN_LUMA_MARGIN << 1), pcPicYuv->getHeight()+ (REN_LUMA_MARGIN << 1), pcPicYuv->getStride (), REN_LUMA_MARGIN ); |
---|
36 | } |
---|
37 | else //420 |
---|
38 | { |
---|
39 | m_uiNumberOfPlanes = 3; |
---|
40 | m_uiNumberOfFullPlanes = 1; |
---|
41 | m_uiNumberOfQuaterPlanes = 2; |
---|
42 | |
---|
43 | m_apcPlanes = new TRenImagePlane<Pel>*[ m_uiNumberOfPlanes ]; |
---|
44 | m_apcPlanes[0] = new TRenImagePlane<Pel>( pcPicYuv->getBufY(), pcPicYuv->getWidth() + (REN_LUMA_MARGIN << 1), pcPicYuv->getHeight() + (REN_LUMA_MARGIN << 1), pcPicYuv->getStride (), REN_LUMA_MARGIN ); |
---|
45 | m_apcPlanes[1] = new TRenImagePlane<Pel>( pcPicYuv->getBufU(), (pcPicYuv->getWidth()>>1)+ REN_LUMA_MARGIN , (pcPicYuv->getHeight()>>1) + REN_LUMA_MARGIN , pcPicYuv->getCStride(), REN_LUMA_MARGIN >> 1 ); |
---|
46 | m_apcPlanes[2] = new TRenImagePlane<Pel>( pcPicYuv->getBufV(), (pcPicYuv->getWidth()>>1)+ REN_LUMA_MARGIN , (pcPicYuv->getHeight()>>1) + REN_LUMA_MARGIN , pcPicYuv->getCStride(), REN_LUMA_MARGIN >> 1 ); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | template<typename T> |
---|
51 | TRenImage<T>* TRenImage<T>::create() |
---|
52 | { |
---|
53 | return new TRenImage( m_apcPlanes[0]->getWidth(), m_apcPlanes[0]->getHeight(), m_uiNumberOfFullPlanes, m_uiNumberOfQuaterPlanes ); |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | template<typename T> |
---|
58 | TRenImage<T>::TRenImage( TComPicYuv* pcPicYuv, Bool bFirstPlaneOnly ) |
---|
59 | { |
---|
60 | assert(0); |
---|
61 | } |
---|
62 | |
---|
63 | template<class T> |
---|
64 | TRenImagePlane<T>* TRenImage<T>::getPlane(UInt uiPlaneNumber) const |
---|
65 | { |
---|
66 | return m_apcPlanes[uiPlaneNumber]; |
---|
67 | } |
---|
68 | |
---|
69 | template<class T> |
---|
70 | TRenImagePlane<T>** TRenImage<T>::getPlanes() const |
---|
71 | { |
---|
72 | return m_apcPlanes; |
---|
73 | } |
---|
74 | |
---|
75 | template<typename T> |
---|
76 | Void TRenImage<T>::allocatePlanes( UInt uiWidth, UInt uiHeight, UInt uiNumberOfFullPlanes, UInt uiNumberOfQuaterPlanes ) |
---|
77 | { |
---|
78 | assert( uiNumberOfFullPlanes + uiNumberOfQuaterPlanes); |
---|
79 | |
---|
80 | UInt uiHalfWidth = uiWidth / 2; |
---|
81 | UInt uiHalfHeight = uiHeight / 2; |
---|
82 | |
---|
83 | uiHalfWidth = (uiHalfWidth == 0) ? 1 : uiHalfWidth ; |
---|
84 | uiHalfHeight = (uiHalfHeight == 0) ? 1 : uiHalfHeight; |
---|
85 | |
---|
86 | m_uiNumberOfPlanes = uiNumberOfFullPlanes + uiNumberOfQuaterPlanes; ; |
---|
87 | m_uiNumberOfFullPlanes = uiNumberOfFullPlanes; |
---|
88 | m_uiNumberOfQuaterPlanes = uiNumberOfQuaterPlanes; |
---|
89 | |
---|
90 | this->m_apcPlanes = new TRenImagePlane<T>*[m_uiNumberOfPlanes]; |
---|
91 | |
---|
92 | for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfFullPlanes; uiCurPlane++) |
---|
93 | { |
---|
94 | this->m_apcPlanes[uiCurPlane] = new TRenImagePlane<T>(uiWidth, uiHeight, REN_LUMA_MARGIN); |
---|
95 | }; |
---|
96 | |
---|
97 | for (UInt uiCurPlane = 0; uiCurPlane < uiNumberOfQuaterPlanes; uiCurPlane++) |
---|
98 | { |
---|
99 | this->m_apcPlanes[uiCurPlane+uiNumberOfFullPlanes] = new TRenImagePlane<T>(uiHalfWidth, uiHalfHeight, REN_LUMA_MARGIN >> 1); |
---|
100 | }; |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | template<class T> |
---|
105 | Void TRenImage<T>::assign(Int iVal) |
---|
106 | { |
---|
107 | for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++) |
---|
108 | { |
---|
109 | m_apcPlanes[uiCurPlane]->assign( iVal); |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | |
---|
114 | template<class T> |
---|
115 | Void TRenImage<T>::devide( Double dDevisor ) |
---|
116 | { |
---|
117 | for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++) |
---|
118 | { |
---|
119 | m_apcPlanes[uiCurPlane]->devide(dDevisor); |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | template<class T> template<class S> |
---|
125 | Void TRenImage<T>::assign( TRenImage<S>* pcSrcImage ) |
---|
126 | { |
---|
127 | if (pcSrcImage->getNumberOfPlanes() != m_uiNumberOfPlanes ) |
---|
128 | { |
---|
129 | assert(0); |
---|
130 | } |
---|
131 | |
---|
132 | for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++) |
---|
133 | { |
---|
134 | m_apcPlanes[uiCurPlane]->assign(pcSrcImage->getPlane(uiCurPlane)->getPlaneDataOrg(),pcSrcImage->getPlane(uiCurPlane)->getStride()); |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | |
---|
139 | template<typename T> |
---|
140 | Void TRenImage<T>::setData( TRenImage* pcInputImage, Bool bClean ) |
---|
141 | { |
---|
142 | for (UInt uiPlane = 0; uiPlane < m_uiNumberOfPlanes; uiPlane++) |
---|
143 | { |
---|
144 | m_apcPlanes[uiPlane]->setData( pcInputImage->getPlane( uiPlane ), bClean ); |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | template<typename T> |
---|
149 | Void TRenImage<T>::extendMargin() |
---|
150 | { |
---|
151 | for (UInt uiPlane = 0; uiPlane < m_uiNumberOfPlanes; uiPlane++) |
---|
152 | { |
---|
153 | m_apcPlanes[uiPlane]->extendMargin(); |
---|
154 | } |
---|
155 | } |
---|
156 | |
---|
157 | template<class T> |
---|
158 | Void TRenImage<T>::xDeletePlanes() |
---|
159 | { |
---|
160 | for (UInt uiCurPlane = 0; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++) |
---|
161 | { |
---|
162 | if ( m_apcPlanes[uiCurPlane]) |
---|
163 | { |
---|
164 | delete m_apcPlanes[uiCurPlane]; |
---|
165 | } |
---|
166 | m_apcPlanes[uiCurPlane] = 0; |
---|
167 | } |
---|
168 | } |
---|
169 | |
---|
170 | |
---|
171 | template<class T> |
---|
172 | Void TRenImage<T>::init() |
---|
173 | { |
---|
174 | // YUV-init |
---|
175 | m_apcPlanes[0]->assign((Pel) 0 ); |
---|
176 | |
---|
177 | for (UInt uiCurPlane = 1; uiCurPlane < m_uiNumberOfPlanes; uiCurPlane++) |
---|
178 | { |
---|
179 | m_apcPlanes[uiCurPlane]->assign( (Pel) ((g_uiIBDI_MAX+1) >> 1) ); |
---|
180 | } |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | template<class T> |
---|
185 | TRenImage<T>::~TRenImage() { |
---|
186 | xDeletePlanes(); |
---|
187 | delete[] m_apcPlanes; |
---|
188 | } |
---|
189 | |
---|
190 | |
---|
191 | |
---|
192 | template<class T> |
---|
193 | UInt TRenImage<T>::getNumberOfPlanes() const |
---|
194 | { |
---|
195 | return m_uiNumberOfPlanes; |
---|
196 | } |
---|
197 | |
---|
198 | template<class T> |
---|
199 | UInt TRenImage<T>::getNumberOfQuaterPlanes() const |
---|
200 | { |
---|
201 | return m_uiNumberOfQuaterPlanes; |
---|
202 | } |
---|
203 | |
---|
204 | template<class T> |
---|
205 | UInt TRenImage<T>::getNumberOfFullPlanes() const |
---|
206 | { |
---|
207 | return m_uiNumberOfFullPlanes; |
---|
208 | } |
---|
209 | |
---|
210 | template class TRenImage<Pel>; |
---|
211 | template class TRenImage<Int>; |
---|
212 | template class TRenImage<Double>; |
---|
213 | template class TRenImage<Bool>; |
---|
214 | |
---|
215 | |
---|
216 | template Void TRenImage<Pel>::assign<Pel> (TRenImage<Pel>* ); |
---|
217 | |
---|
218 | |
---|