[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2011, ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[2] | 33 | |
---|
| 34 | |
---|
| 35 | #include "TRenImagePlane.h" |
---|
| 36 | #include "TRenFilter.h" |
---|
[56] | 37 | #include <string.h> |
---|
[2] | 38 | /////// TRenImagePlane /////// |
---|
| 39 | |
---|
| 40 | template<class T> |
---|
| 41 | TRenImagePlane<T>::TRenImagePlane() { m_bClean = true; } |
---|
| 42 | |
---|
| 43 | template<class T> |
---|
| 44 | TRenImagePlane<T>::TRenImagePlane(UInt uiWidth, UInt uiHeight, UInt uiPad) |
---|
| 45 | : m_uiWidth(uiWidth), m_uiHeight(uiHeight), m_uiStride(uiWidth+2*uiPad), m_uiWidthOrg(uiWidth+2*uiPad), m_uiHeightOrg(uiHeight+2*uiPad), m_uiPad(uiPad) |
---|
| 46 | { |
---|
| 47 | m_pcDataOrg = new T[ m_uiWidthOrg * m_uiHeightOrg ]; |
---|
| 48 | m_pcData = m_pcDataOrg + m_uiPad * m_uiStride + m_uiPad; |
---|
| 49 | m_bClean = true; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | template<class T> |
---|
| 53 | TRenImagePlane<T>::TRenImagePlane(TRenImagePlane* pcPlane) |
---|
| 54 | : m_uiWidth (pcPlane->getWidth ()) |
---|
| 55 | , m_uiHeight (pcPlane->getHeight ()) |
---|
| 56 | , m_uiStride (pcPlane->getStride ()) |
---|
| 57 | , m_uiWidthOrg(pcPlane->getWidthOrg()) |
---|
| 58 | , m_uiHeightOrg(pcPlane->getHeightOrg()) |
---|
| 59 | , m_uiPad (pcPlane->getPad ()) |
---|
| 60 | { |
---|
| 61 | m_pcData = new T[m_uiWidthOrg*m_uiHeightOrg]; |
---|
| 62 | m_bClean = true; |
---|
| 63 | assign( pcPlane ); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | template<typename T> |
---|
| 67 | TRenImagePlane<T>::TRenImagePlane( T* pcDataOrg, UInt uiWidthOrg, UInt uiHeightOrg, UInt uiStride, UInt uiPad ) |
---|
| 68 | : m_pcData (pcDataOrg + uiStride * uiPad + uiPad ) |
---|
| 69 | , m_uiWidth (uiWidthOrg - 2* uiPad ) |
---|
| 70 | , m_uiHeight (uiHeightOrg - 2* uiPad ) |
---|
| 71 | , m_uiStride (uiStride ) |
---|
| 72 | , m_pcDataOrg (pcDataOrg ) |
---|
| 73 | , m_uiWidthOrg (uiWidthOrg ) |
---|
| 74 | , m_uiHeightOrg(uiHeightOrg) |
---|
| 75 | , m_uiPad (uiPad ) |
---|
| 76 | , m_bClean (false ) |
---|
| 77 | { |
---|
| 78 | |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | template<typename T> |
---|
[56] | 82 | Void TRenImagePlane<T>::setData( T* pDataOrg, UInt uiWidthOrg, UInt uiHeightOrg, UInt uiStride, UInt uiPad, Bool bClean /*= false*/ ) |
---|
[2] | 83 | { |
---|
| 84 | deleteData(); |
---|
| 85 | m_uiPad = uiPad; |
---|
| 86 | m_pcDataOrg = pDataOrg; |
---|
| 87 | m_uiWidthOrg = uiWidthOrg; |
---|
| 88 | m_uiHeightOrg = uiHeightOrg; |
---|
| 89 | m_uiWidth = uiWidthOrg - 2* uiPad; |
---|
| 90 | m_uiHeight = uiHeightOrg - 2* uiPad; |
---|
| 91 | m_uiStride = uiStride; |
---|
| 92 | m_pcData = m_pcDataOrg + uiPad * m_uiStride + uiPad; |
---|
| 93 | m_bClean = bClean; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | template<typename T> |
---|
| 97 | Void TRenImagePlane<T>::setData( TRenImagePlane<T>* pcInPlane, Bool bClean ) |
---|
| 98 | { |
---|
| 99 | deleteData(); |
---|
| 100 | m_uiPad = pcInPlane->getPad(); |
---|
| 101 | m_pcDataOrg = pcInPlane->getPlaneDataOrg(); |
---|
| 102 | m_uiWidthOrg = pcInPlane->getWidthOrg(); |
---|
| 103 | m_uiHeightOrg = pcInPlane->getHeightOrg(); |
---|
| 104 | m_uiWidth = pcInPlane->getWidth(); |
---|
| 105 | m_uiHeight = pcInPlane->getHeight(); |
---|
| 106 | m_uiStride = pcInPlane->getStride(); |
---|
| 107 | m_pcData = pcInPlane->getPlaneData(); |
---|
| 108 | m_bClean = bClean; |
---|
| 109 | pcInPlane->setClean( !m_bClean ); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | template<typename T> |
---|
| 113 | Void TRenImagePlane<T>::setClean( Bool bClean ) |
---|
| 114 | { |
---|
| 115 | m_bClean = bClean; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | template<class T> |
---|
| 119 | T* TRenImagePlane<T>::getPlaneData() |
---|
| 120 | { |
---|
| 121 | return m_pcData; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | template<class T> |
---|
| 126 | T* TRenImagePlane<T>::getPlaneDataOrg() |
---|
| 127 | { |
---|
| 128 | return m_pcDataOrg; |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | template<class T> |
---|
| 133 | Void TRenImagePlane<T>::assign(Pel* pcSourceData, UInt uiSourceStride ) |
---|
| 134 | { |
---|
| 135 | T* pcTargetData = m_pcDataOrg; |
---|
| 136 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 137 | { |
---|
| 138 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 139 | { |
---|
| 140 | pcTargetData[uiXPos] = (T) pcSourceData[uiXPos]; |
---|
| 141 | } |
---|
| 142 | pcTargetData += m_uiStride; |
---|
| 143 | pcSourceData += uiSourceStride; |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | template<class T> |
---|
| 148 | Void TRenImagePlane<T>::assign(Pel cData) |
---|
| 149 | { |
---|
| 150 | T* pcTargetData = m_pcDataOrg; |
---|
| 151 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 152 | { |
---|
| 153 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 154 | { |
---|
| 155 | pcTargetData[uiXPos] = (T) cData; |
---|
| 156 | } |
---|
| 157 | pcTargetData += m_uiStride; |
---|
| 158 | } |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | template<class T> |
---|
| 162 | Void TRenImagePlane<T>::assign(Double* pdData, UInt uiSourceStride ) |
---|
| 163 | { |
---|
| 164 | T* pcTargetData = m_pcDataOrg; |
---|
| 165 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 166 | { |
---|
| 167 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 168 | { |
---|
| 169 | pcTargetData[uiXPos] = (T) pdData[uiXPos]; |
---|
| 170 | } |
---|
| 171 | pcTargetData += m_uiStride; |
---|
| 172 | pdData += uiSourceStride; |
---|
| 173 | |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | template<class T> |
---|
| 178 | Void TRenImagePlane<T>::assign(Double dData) |
---|
| 179 | { |
---|
| 180 | T* pcTargetData = m_pcDataOrg; |
---|
| 181 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 182 | { |
---|
| 183 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 184 | { |
---|
| 185 | pcTargetData[uiXPos] = (T) dData; |
---|
| 186 | } |
---|
| 187 | pcTargetData += m_uiStride; |
---|
| 188 | } |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | template<class T> |
---|
| 193 | Void TRenImagePlane<T>::assign(Bool* pbData, UInt uiSourceStride ) |
---|
| 194 | { |
---|
| 195 | T* pcTargetData = m_pcDataOrg; |
---|
| 196 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 197 | { |
---|
| 198 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 199 | { |
---|
| 200 | pcTargetData[uiXPos] = (T) pbData[uiXPos]; |
---|
| 201 | } |
---|
| 202 | pcTargetData += m_uiStride; |
---|
| 203 | pbData += uiSourceStride; |
---|
| 204 | } |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | template<class T> |
---|
| 208 | Void TRenImagePlane<T>::assign(Int iData) |
---|
| 209 | { |
---|
| 210 | T* pcTargetData = m_pcDataOrg; |
---|
| 211 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 212 | { |
---|
| 213 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 214 | { |
---|
| 215 | pcTargetData[uiXPos] = (T) iData; |
---|
| 216 | } |
---|
| 217 | pcTargetData += m_uiStride; |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | template<class T> |
---|
| 222 | Void TRenImagePlane<T>::assign(Int* piData, UInt uiSourceStride ) |
---|
| 223 | { |
---|
| 224 | T* pcTargetData = m_pcDataOrg; |
---|
| 225 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 226 | { |
---|
| 227 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 228 | { |
---|
| 229 | pcTargetData[uiXPos] = (T) piData[uiXPos]; |
---|
| 230 | } |
---|
| 231 | pcTargetData += m_uiStride; |
---|
| 232 | piData += uiSourceStride; |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | template<class T> |
---|
| 237 | Void TRenImagePlane<T>::assign(Bool data) |
---|
| 238 | { |
---|
| 239 | T* pcTargetData = m_pcDataOrg; |
---|
| 240 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 241 | { |
---|
| 242 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 243 | { |
---|
| 244 | pcTargetData[uiXPos] = (T) data; |
---|
| 245 | } |
---|
| 246 | pcTargetData += m_uiStride; |
---|
| 247 | } |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | // Assignments to Bool |
---|
| 251 | |
---|
| 252 | template<> |
---|
| 253 | Void TRenImagePlane<Bool>::assign(Int* piData, UInt uiSourceStride ) |
---|
| 254 | { |
---|
| 255 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 256 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 257 | { |
---|
| 258 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 259 | { |
---|
| 260 | pcTargetData[uiXPos] = (piData[uiXPos] == 0); |
---|
| 261 | } |
---|
| 262 | pcTargetData += m_uiStride; |
---|
| 263 | piData += uiSourceStride; |
---|
| 264 | |
---|
| 265 | } |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | template<> |
---|
| 269 | Void TRenImagePlane<Bool>::assign(Int iData) |
---|
| 270 | { |
---|
| 271 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 272 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 273 | { |
---|
| 274 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 275 | { |
---|
| 276 | pcTargetData[uiXPos] = (iData == 0); |
---|
| 277 | } |
---|
| 278 | pcTargetData += m_uiStride; |
---|
| 279 | } |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | template<> |
---|
| 283 | Void TRenImagePlane<Bool>::assign(Pel* pcData, UInt uiSourceStride ) |
---|
| 284 | { |
---|
| 285 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 286 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 287 | { |
---|
| 288 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 289 | { |
---|
| 290 | pcTargetData[uiXPos] = (pcData[uiXPos] == 0); |
---|
| 291 | } |
---|
| 292 | pcTargetData += m_uiStride; |
---|
| 293 | pcData += uiSourceStride; |
---|
| 294 | |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | template<> |
---|
| 299 | Void TRenImagePlane<Bool>::assign(Pel cData) |
---|
| 300 | { |
---|
| 301 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 302 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 303 | { |
---|
| 304 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 305 | { |
---|
| 306 | pcTargetData[uiXPos] = (cData == 0); |
---|
| 307 | } |
---|
| 308 | pcTargetData += m_uiStride; |
---|
| 309 | } |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | template<> |
---|
| 313 | Void TRenImagePlane<Bool>::assign(Double* pdData, UInt uiSourceStride ) |
---|
| 314 | { |
---|
| 315 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 316 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 317 | { |
---|
| 318 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 319 | { |
---|
| 320 | pcTargetData[uiXPos] = ( pdData[uiXPos] == 0); |
---|
| 321 | } |
---|
| 322 | pcTargetData += m_uiStride; |
---|
| 323 | pdData += uiSourceStride; |
---|
| 324 | |
---|
| 325 | } |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | |
---|
| 330 | template<> |
---|
| 331 | Void TRenImagePlane<Bool>::assign(Double dData) |
---|
| 332 | { |
---|
| 333 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 334 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 335 | { |
---|
| 336 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 337 | { |
---|
| 338 | pcTargetData [uiXPos] = (dData == 0); |
---|
| 339 | } |
---|
| 340 | pcTargetData += m_uiStride; |
---|
| 341 | } |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | |
---|
| 345 | // Assignments to Pel |
---|
| 346 | template<> |
---|
| 347 | Void TRenImagePlane<Pel>::assign(Double* pdData, UInt uiSourceStride ) |
---|
| 348 | { |
---|
| 349 | Pel* pcTargetData = m_pcDataOrg; |
---|
| 350 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 351 | { |
---|
| 352 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 353 | { |
---|
| 354 | pcTargetData[uiXPos] = (Pel) ( pdData[uiXPos] + pdData[uiXPos] < 0 ? -0.5 : 0.5 ) ; |
---|
| 355 | } |
---|
| 356 | pcTargetData += m_uiStride; |
---|
| 357 | pdData += uiSourceStride; |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | |
---|
| 361 | template<class T> |
---|
| 362 | Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcPlane) |
---|
| 363 | { |
---|
| 364 | assign(pcPlane->getPlaneDataOrg(), pcPlane->getStride()); |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | template<class T> |
---|
| 368 | Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcPlane, UInt uiRow, UInt uiStartOffset, UInt uiEndOffset) |
---|
| 369 | { |
---|
| 370 | T* pcTargetData = m_pcData + uiRow * m_uiStride; |
---|
| 371 | T* pcSourceData = pcPlane->getPlaneData() + uiRow * pcPlane->getStride(); |
---|
| 372 | |
---|
| 373 | for (UInt uiPosX = uiStartOffset; uiPosX <= uiEndOffset; uiPosX++) |
---|
| 374 | { |
---|
| 375 | pcTargetData[uiPosX] = pcSourceData[uiPosX]; |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | } |
---|
| 379 | |
---|
| 380 | template<class T> |
---|
| 381 | Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcSourcePlane, UInt uiSourceRowStart, UInt uiSourceColStart, UInt uiWidth, UInt uiHeight) |
---|
| 382 | { |
---|
| 383 | T* acSourceData; |
---|
| 384 | T* acDestData; |
---|
| 385 | |
---|
| 386 | acSourceData = pcSourcePlane->getPlaneData(); |
---|
| 387 | acSourceData += uiSourceRowStart * pcSourcePlane->getStride() + uiSourceColStart; |
---|
| 388 | acDestData = m_pcData; |
---|
| 389 | |
---|
| 390 | for (UInt uiPosY = 0; uiPosY < uiHeight ; uiPosY++) |
---|
| 391 | { |
---|
| 392 | for (UInt uiPosX = 0; uiPosX < uiWidth ; uiPosX++) |
---|
| 393 | { |
---|
| 394 | acDestData[uiPosX] = acSourceData[uiPosX]; |
---|
| 395 | } |
---|
| 396 | acSourceData += pcSourcePlane->getStride(); |
---|
| 397 | acDestData += this ->getStride(); |
---|
| 398 | }; |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | |
---|
| 402 | |
---|
| 403 | template<class T> |
---|
| 404 | Void TRenImagePlane<T>::assign( T data , UInt uiRow, UInt uiStartOffset, UInt uiEndOffset) |
---|
| 405 | { |
---|
| 406 | T* pcTargetData = m_pcData + uiRow * m_uiStride; |
---|
| 407 | for (UInt uiPosX = uiStartOffset; uiPosX <= uiEndOffset; uiPosX++) |
---|
| 408 | { |
---|
| 409 | pcTargetData[uiPosX] = data; |
---|
| 410 | } |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | |
---|
| 414 | template<class T> |
---|
| 415 | Void TRenImagePlane<T>::devide( Double dDevisor ) |
---|
| 416 | { |
---|
| 417 | T* pcTargetData = m_pcDataOrg; |
---|
| 418 | for (UInt uiPosY = 0; uiPosY < (m_uiHeightOrg); uiPosY++) |
---|
| 419 | { |
---|
| 420 | for (UInt uiPosX = 0; uiPosX < m_uiWidthOrg; uiPosX++) |
---|
| 421 | { |
---|
| 422 | pcTargetData[uiPosX] = (T) ( ( Double )pcTargetData[uiPosX] / dDevisor ); |
---|
| 423 | } |
---|
| 424 | pcTargetData += m_uiStride; |
---|
| 425 | } |
---|
| 426 | }; |
---|
| 427 | |
---|
| 428 | template<class T> |
---|
| 429 | Void TRenImagePlane<T>::multiply( Double dMultiplier ) { |
---|
| 430 | T* pcTargetData = m_pcDataOrg; |
---|
| 431 | for (UInt uiPosY = 0; uiPosY < (m_uiHeightOrg); uiPosY++) |
---|
| 432 | { |
---|
| 433 | for (UInt uiPosX = 0; uiPosX < m_uiWidthOrg; uiPosX++) |
---|
| 434 | { |
---|
| 435 | pcTargetData[uiPosX] = (T) ( ( Double )pcTargetData[uiPosX] * dMultiplier ); |
---|
| 436 | } |
---|
| 437 | pcTargetData += m_uiStride; |
---|
| 438 | } |
---|
| 439 | }; |
---|
| 440 | |
---|
| 441 | |
---|
| 442 | template<> |
---|
| 443 | Void TRenImagePlane<Bool>::devide( Double dDevisor ) |
---|
| 444 | { |
---|
| 445 | assert(0); |
---|
| 446 | }; |
---|
| 447 | |
---|
| 448 | template<> |
---|
| 449 | Void TRenImagePlane<Bool>::multiply( Double dMultiplier ) |
---|
| 450 | { |
---|
| 451 | assert(0); |
---|
| 452 | }; |
---|
| 453 | |
---|
| 454 | |
---|
| 455 | template<class T> |
---|
| 456 | Void TRenImagePlane<T>::deleteData() |
---|
| 457 | { |
---|
| 458 | if (m_bClean) |
---|
| 459 | { |
---|
| 460 | if (m_pcDataOrg) |
---|
| 461 | { |
---|
| 462 | delete[] m_pcDataOrg; |
---|
| 463 | }; |
---|
| 464 | } |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | template<class T> |
---|
| 468 | TRenImagePlane<T>::~TRenImagePlane() |
---|
| 469 | { |
---|
| 470 | deleteData(); |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | |
---|
| 474 | template<typename T> |
---|
| 475 | Void TRenImagePlane<T>::extendMargin() |
---|
| 476 | { |
---|
| 477 | Int iPad = (Int) m_uiPad; |
---|
| 478 | T* pcData = m_pcData; |
---|
| 479 | |
---|
| 480 | for ( Int iPosY = 0; iPosY < (Int) m_uiHeight; iPosY++) |
---|
| 481 | { |
---|
| 482 | for ( Int iPosX = 0; iPosX < (Int) iPad; iPosX++ ) |
---|
| 483 | { |
---|
| 484 | pcData[ -iPad + iPosX ] = pcData[0]; |
---|
| 485 | pcData[m_uiWidth + iPosX ] = pcData[m_uiWidth -1 ]; |
---|
| 486 | } |
---|
| 487 | pcData += m_uiStride; |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | |
---|
| 491 | pcData -= (m_uiStride + iPad); |
---|
| 492 | for ( Int iPosY = 0; iPosY < iPad; iPosY++ ) |
---|
| 493 | { |
---|
[56] | 494 | memcpy( pcData + (iPosY+1)*m_uiStride, pcData, sizeof(T)*(m_uiWidth + (iPad<<1)) ); |
---|
[2] | 495 | } |
---|
| 496 | |
---|
| 497 | pcData -= ((m_uiHeight-1) * m_uiStride); |
---|
| 498 | for ( Int iPosY = 0; iPosY < iPad; iPosY++ ) |
---|
| 499 | { |
---|
[56] | 500 | memcpy( pcData - (iPosY+1)*m_uiStride, pcData, sizeof(T)*(m_uiWidth + (iPad<<1)) ); |
---|
[2] | 501 | } |
---|
| 502 | } |
---|
| 503 | |
---|
| 504 | template class TRenImagePlane<Pel>; |
---|
| 505 | template class TRenImagePlane<Double>; |
---|
| 506 | template class TRenImagePlane<Bool>; |
---|
| 507 | template class TRenImagePlane<Int>; |
---|
| 508 | |
---|
| 509 | /////// TRenImagePlanePart /////// |
---|
| 510 | |
---|
| 511 | template<typename T> |
---|
| 512 | TRenImagePlanePart<T>::TRenImagePlanePart( TRenImagePlane<T>* pPlane, UInt uHorOff, UInt uVerOff, UInt uWidth, UInt uHeight ) |
---|
| 513 | : TRenImagePlane<T>( pPlane->getPlaneData() + uHorOff + uVerOff * pPlane->getStride(), uWidth, uHeight, pPlane->getStride(),0) |
---|
| 514 | { |
---|
| 515 | |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | template<typename T> |
---|
| 519 | TRenImagePlanePart<T>::~TRenImagePlanePart() |
---|
| 520 | { |
---|
| 521 | this->m_pcData = NULL; |
---|
| 522 | } |
---|
| 523 | |
---|
| 524 | template class TRenImagePlanePart<Pel>; |
---|
| 525 | template class TRenImagePlanePart<Double>; |
---|
| 526 | template class TRenImagePlanePart<Bool>; |
---|
| 527 | template class TRenImagePlanePart<Int>; |
---|