[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 | * |
---|
[1179] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 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> |
---|
[1313] | 38 | #if NH_3D |
---|
[608] | 39 | |
---|
[2] | 40 | /////// TRenImagePlane /////// |
---|
| 41 | |
---|
| 42 | template<class T> |
---|
| 43 | TRenImagePlane<T>::TRenImagePlane() { m_bClean = true; } |
---|
| 44 | |
---|
| 45 | template<class T> |
---|
| 46 | TRenImagePlane<T>::TRenImagePlane(UInt uiWidth, UInt uiHeight, UInt uiPad) |
---|
| 47 | : m_uiWidth(uiWidth), m_uiHeight(uiHeight), m_uiStride(uiWidth+2*uiPad), m_uiWidthOrg(uiWidth+2*uiPad), m_uiHeightOrg(uiHeight+2*uiPad), m_uiPad(uiPad) |
---|
| 48 | { |
---|
| 49 | m_pcDataOrg = new T[ m_uiWidthOrg * m_uiHeightOrg ]; |
---|
| 50 | m_pcData = m_pcDataOrg + m_uiPad * m_uiStride + m_uiPad; |
---|
| 51 | m_bClean = true; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | template<class T> |
---|
| 55 | TRenImagePlane<T>::TRenImagePlane(TRenImagePlane* pcPlane) |
---|
| 56 | : m_uiWidth (pcPlane->getWidth ()) |
---|
| 57 | , m_uiHeight (pcPlane->getHeight ()) |
---|
| 58 | , m_uiStride (pcPlane->getStride ()) |
---|
| 59 | , m_uiWidthOrg(pcPlane->getWidthOrg()) |
---|
| 60 | , m_uiHeightOrg(pcPlane->getHeightOrg()) |
---|
| 61 | , m_uiPad (pcPlane->getPad ()) |
---|
| 62 | { |
---|
| 63 | m_pcData = new T[m_uiWidthOrg*m_uiHeightOrg]; |
---|
| 64 | m_bClean = true; |
---|
| 65 | assign( pcPlane ); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | template<typename T> |
---|
| 69 | TRenImagePlane<T>::TRenImagePlane( T* pcDataOrg, UInt uiWidthOrg, UInt uiHeightOrg, UInt uiStride, UInt uiPad ) |
---|
| 70 | : m_pcData (pcDataOrg + uiStride * uiPad + uiPad ) |
---|
| 71 | , m_uiWidth (uiWidthOrg - 2* uiPad ) |
---|
| 72 | , m_uiHeight (uiHeightOrg - 2* uiPad ) |
---|
| 73 | , m_uiStride (uiStride ) |
---|
| 74 | , m_pcDataOrg (pcDataOrg ) |
---|
| 75 | , m_uiWidthOrg (uiWidthOrg ) |
---|
| 76 | , m_uiHeightOrg(uiHeightOrg) |
---|
| 77 | , m_uiPad (uiPad ) |
---|
| 78 | , m_bClean (false ) |
---|
| 79 | { |
---|
| 80 | |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | template<typename T> |
---|
[56] | 84 | Void TRenImagePlane<T>::setData( T* pDataOrg, UInt uiWidthOrg, UInt uiHeightOrg, UInt uiStride, UInt uiPad, Bool bClean /*= false*/ ) |
---|
[2] | 85 | { |
---|
| 86 | deleteData(); |
---|
| 87 | m_uiPad = uiPad; |
---|
| 88 | m_pcDataOrg = pDataOrg; |
---|
| 89 | m_uiWidthOrg = uiWidthOrg; |
---|
| 90 | m_uiHeightOrg = uiHeightOrg; |
---|
| 91 | m_uiWidth = uiWidthOrg - 2* uiPad; |
---|
| 92 | m_uiHeight = uiHeightOrg - 2* uiPad; |
---|
| 93 | m_uiStride = uiStride; |
---|
| 94 | m_pcData = m_pcDataOrg + uiPad * m_uiStride + uiPad; |
---|
| 95 | m_bClean = bClean; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | template<typename T> |
---|
| 99 | Void TRenImagePlane<T>::setData( TRenImagePlane<T>* pcInPlane, Bool bClean ) |
---|
| 100 | { |
---|
| 101 | deleteData(); |
---|
| 102 | m_uiPad = pcInPlane->getPad(); |
---|
| 103 | m_pcDataOrg = pcInPlane->getPlaneDataOrg(); |
---|
| 104 | m_uiWidthOrg = pcInPlane->getWidthOrg(); |
---|
| 105 | m_uiHeightOrg = pcInPlane->getHeightOrg(); |
---|
| 106 | m_uiWidth = pcInPlane->getWidth(); |
---|
| 107 | m_uiHeight = pcInPlane->getHeight(); |
---|
| 108 | m_uiStride = pcInPlane->getStride(); |
---|
| 109 | m_pcData = pcInPlane->getPlaneData(); |
---|
| 110 | m_bClean = bClean; |
---|
| 111 | pcInPlane->setClean( !m_bClean ); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | template<typename T> |
---|
| 115 | Void TRenImagePlane<T>::setClean( Bool bClean ) |
---|
| 116 | { |
---|
| 117 | m_bClean = bClean; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | template<class T> |
---|
| 121 | T* TRenImagePlane<T>::getPlaneData() |
---|
| 122 | { |
---|
| 123 | return m_pcData; |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | template<class T> |
---|
| 128 | T* TRenImagePlane<T>::getPlaneDataOrg() |
---|
| 129 | { |
---|
| 130 | return m_pcDataOrg; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | template<class T> |
---|
| 135 | Void TRenImagePlane<T>::assign(Pel* pcSourceData, UInt uiSourceStride ) |
---|
| 136 | { |
---|
| 137 | T* pcTargetData = m_pcDataOrg; |
---|
| 138 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 139 | { |
---|
| 140 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 141 | { |
---|
| 142 | pcTargetData[uiXPos] = (T) pcSourceData[uiXPos]; |
---|
| 143 | } |
---|
| 144 | pcTargetData += m_uiStride; |
---|
| 145 | pcSourceData += uiSourceStride; |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | template<class T> |
---|
| 150 | Void TRenImagePlane<T>::assign(Pel cData) |
---|
| 151 | { |
---|
| 152 | T* pcTargetData = m_pcDataOrg; |
---|
| 153 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 154 | { |
---|
| 155 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 156 | { |
---|
| 157 | pcTargetData[uiXPos] = (T) cData; |
---|
| 158 | } |
---|
| 159 | pcTargetData += m_uiStride; |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | template<class T> |
---|
| 164 | Void TRenImagePlane<T>::assign(Double* pdData, UInt uiSourceStride ) |
---|
| 165 | { |
---|
| 166 | T* pcTargetData = m_pcDataOrg; |
---|
| 167 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 168 | { |
---|
| 169 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 170 | { |
---|
| 171 | pcTargetData[uiXPos] = (T) pdData[uiXPos]; |
---|
| 172 | } |
---|
| 173 | pcTargetData += m_uiStride; |
---|
| 174 | pdData += uiSourceStride; |
---|
| 175 | |
---|
| 176 | } |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | template<class T> |
---|
| 180 | Void TRenImagePlane<T>::assign(Double dData) |
---|
| 181 | { |
---|
| 182 | T* pcTargetData = m_pcDataOrg; |
---|
| 183 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 184 | { |
---|
| 185 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 186 | { |
---|
| 187 | pcTargetData[uiXPos] = (T) dData; |
---|
| 188 | } |
---|
| 189 | pcTargetData += m_uiStride; |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | template<class T> |
---|
| 195 | Void TRenImagePlane<T>::assign(Bool* pbData, UInt uiSourceStride ) |
---|
| 196 | { |
---|
| 197 | T* pcTargetData = m_pcDataOrg; |
---|
| 198 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 199 | { |
---|
| 200 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 201 | { |
---|
| 202 | pcTargetData[uiXPos] = (T) pbData[uiXPos]; |
---|
| 203 | } |
---|
| 204 | pcTargetData += m_uiStride; |
---|
| 205 | pbData += uiSourceStride; |
---|
| 206 | } |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | template<class T> |
---|
| 210 | Void TRenImagePlane<T>::assign(Int iData) |
---|
| 211 | { |
---|
| 212 | T* pcTargetData = m_pcDataOrg; |
---|
| 213 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 214 | { |
---|
| 215 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 216 | { |
---|
| 217 | pcTargetData[uiXPos] = (T) iData; |
---|
| 218 | } |
---|
| 219 | pcTargetData += m_uiStride; |
---|
| 220 | } |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | template<class T> |
---|
| 224 | Void TRenImagePlane<T>::assign(Int* piData, UInt uiSourceStride ) |
---|
| 225 | { |
---|
| 226 | T* pcTargetData = m_pcDataOrg; |
---|
| 227 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 228 | { |
---|
| 229 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 230 | { |
---|
| 231 | pcTargetData[uiXPos] = (T) piData[uiXPos]; |
---|
| 232 | } |
---|
| 233 | pcTargetData += m_uiStride; |
---|
| 234 | piData += uiSourceStride; |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | template<class T> |
---|
| 239 | Void TRenImagePlane<T>::assign(Bool data) |
---|
| 240 | { |
---|
| 241 | T* pcTargetData = m_pcDataOrg; |
---|
| 242 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 243 | { |
---|
| 244 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 245 | { |
---|
| 246 | pcTargetData[uiXPos] = (T) data; |
---|
| 247 | } |
---|
| 248 | pcTargetData += m_uiStride; |
---|
| 249 | } |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | // Assignments to Bool |
---|
| 253 | |
---|
| 254 | template<> |
---|
| 255 | Void TRenImagePlane<Bool>::assign(Int* piData, UInt uiSourceStride ) |
---|
| 256 | { |
---|
| 257 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 258 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 259 | { |
---|
| 260 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 261 | { |
---|
| 262 | pcTargetData[uiXPos] = (piData[uiXPos] == 0); |
---|
| 263 | } |
---|
| 264 | pcTargetData += m_uiStride; |
---|
| 265 | piData += uiSourceStride; |
---|
| 266 | |
---|
| 267 | } |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | template<> |
---|
| 271 | Void TRenImagePlane<Bool>::assign(Int iData) |
---|
| 272 | { |
---|
| 273 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 274 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 275 | { |
---|
| 276 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 277 | { |
---|
| 278 | pcTargetData[uiXPos] = (iData == 0); |
---|
| 279 | } |
---|
| 280 | pcTargetData += m_uiStride; |
---|
| 281 | } |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | template<> |
---|
| 285 | Void TRenImagePlane<Bool>::assign(Pel* pcData, UInt uiSourceStride ) |
---|
| 286 | { |
---|
| 287 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 288 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 289 | { |
---|
| 290 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 291 | { |
---|
| 292 | pcTargetData[uiXPos] = (pcData[uiXPos] == 0); |
---|
| 293 | } |
---|
| 294 | pcTargetData += m_uiStride; |
---|
| 295 | pcData += uiSourceStride; |
---|
| 296 | |
---|
| 297 | } |
---|
| 298 | } |
---|
| 299 | |
---|
| 300 | template<> |
---|
| 301 | Void TRenImagePlane<Bool>::assign(Pel cData) |
---|
| 302 | { |
---|
| 303 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 304 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 305 | { |
---|
| 306 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 307 | { |
---|
| 308 | pcTargetData[uiXPos] = (cData == 0); |
---|
| 309 | } |
---|
| 310 | pcTargetData += m_uiStride; |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | template<> |
---|
| 315 | Void TRenImagePlane<Bool>::assign(Double* pdData, UInt uiSourceStride ) |
---|
| 316 | { |
---|
| 317 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 318 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 319 | { |
---|
| 320 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 321 | { |
---|
| 322 | pcTargetData[uiXPos] = ( pdData[uiXPos] == 0); |
---|
| 323 | } |
---|
| 324 | pcTargetData += m_uiStride; |
---|
| 325 | pdData += uiSourceStride; |
---|
| 326 | |
---|
| 327 | } |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | |
---|
| 331 | |
---|
| 332 | template<> |
---|
| 333 | Void TRenImagePlane<Bool>::assign(Double dData) |
---|
| 334 | { |
---|
| 335 | Bool* pcTargetData = m_pcDataOrg; |
---|
| 336 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 337 | { |
---|
| 338 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 339 | { |
---|
| 340 | pcTargetData [uiXPos] = (dData == 0); |
---|
| 341 | } |
---|
| 342 | pcTargetData += m_uiStride; |
---|
| 343 | } |
---|
| 344 | } |
---|
| 345 | |
---|
| 346 | |
---|
| 347 | // Assignments to Pel |
---|
| 348 | template<> |
---|
| 349 | Void TRenImagePlane<Pel>::assign(Double* pdData, UInt uiSourceStride ) |
---|
| 350 | { |
---|
| 351 | Pel* pcTargetData = m_pcDataOrg; |
---|
| 352 | for (UInt uiYPos = 0; uiYPos < m_uiHeightOrg; uiYPos++) |
---|
| 353 | { |
---|
| 354 | for (UInt uiXPos = 0; uiXPos < m_uiWidthOrg; uiXPos++) |
---|
| 355 | { |
---|
| 356 | pcTargetData[uiXPos] = (Pel) ( pdData[uiXPos] + pdData[uiXPos] < 0 ? -0.5 : 0.5 ) ; |
---|
| 357 | } |
---|
| 358 | pcTargetData += m_uiStride; |
---|
| 359 | pdData += uiSourceStride; |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | template<class T> |
---|
| 364 | Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcPlane) |
---|
| 365 | { |
---|
| 366 | assign(pcPlane->getPlaneDataOrg(), pcPlane->getStride()); |
---|
| 367 | } |
---|
| 368 | |
---|
| 369 | template<class T> |
---|
| 370 | Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcPlane, UInt uiRow, UInt uiStartOffset, UInt uiEndOffset) |
---|
| 371 | { |
---|
| 372 | T* pcTargetData = m_pcData + uiRow * m_uiStride; |
---|
| 373 | T* pcSourceData = pcPlane->getPlaneData() + uiRow * pcPlane->getStride(); |
---|
| 374 | |
---|
| 375 | for (UInt uiPosX = uiStartOffset; uiPosX <= uiEndOffset; uiPosX++) |
---|
| 376 | { |
---|
| 377 | pcTargetData[uiPosX] = pcSourceData[uiPosX]; |
---|
| 378 | } |
---|
| 379 | |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | template<class T> |
---|
| 383 | Void TRenImagePlane<T>::assign(TRenImagePlane<T>* pcSourcePlane, UInt uiSourceRowStart, UInt uiSourceColStart, UInt uiWidth, UInt uiHeight) |
---|
| 384 | { |
---|
| 385 | T* acSourceData; |
---|
| 386 | T* acDestData; |
---|
| 387 | |
---|
| 388 | acSourceData = pcSourcePlane->getPlaneData(); |
---|
| 389 | acSourceData += uiSourceRowStart * pcSourcePlane->getStride() + uiSourceColStart; |
---|
| 390 | acDestData = m_pcData; |
---|
| 391 | |
---|
| 392 | for (UInt uiPosY = 0; uiPosY < uiHeight ; uiPosY++) |
---|
| 393 | { |
---|
| 394 | for (UInt uiPosX = 0; uiPosX < uiWidth ; uiPosX++) |
---|
| 395 | { |
---|
| 396 | acDestData[uiPosX] = acSourceData[uiPosX]; |
---|
| 397 | } |
---|
| 398 | acSourceData += pcSourcePlane->getStride(); |
---|
| 399 | acDestData += this ->getStride(); |
---|
| 400 | }; |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | |
---|
| 404 | |
---|
| 405 | template<class T> |
---|
| 406 | Void TRenImagePlane<T>::assign( T data , UInt uiRow, UInt uiStartOffset, UInt uiEndOffset) |
---|
| 407 | { |
---|
| 408 | T* pcTargetData = m_pcData + uiRow * m_uiStride; |
---|
| 409 | for (UInt uiPosX = uiStartOffset; uiPosX <= uiEndOffset; uiPosX++) |
---|
| 410 | { |
---|
| 411 | pcTargetData[uiPosX] = data; |
---|
| 412 | } |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | |
---|
| 416 | template<class T> |
---|
| 417 | Void TRenImagePlane<T>::devide( Double dDevisor ) |
---|
| 418 | { |
---|
| 419 | T* pcTargetData = m_pcDataOrg; |
---|
| 420 | for (UInt uiPosY = 0; uiPosY < (m_uiHeightOrg); uiPosY++) |
---|
| 421 | { |
---|
| 422 | for (UInt uiPosX = 0; uiPosX < m_uiWidthOrg; uiPosX++) |
---|
| 423 | { |
---|
| 424 | pcTargetData[uiPosX] = (T) ( ( Double )pcTargetData[uiPosX] / dDevisor ); |
---|
| 425 | } |
---|
| 426 | pcTargetData += m_uiStride; |
---|
| 427 | } |
---|
| 428 | }; |
---|
| 429 | |
---|
| 430 | template<class T> |
---|
| 431 | Void TRenImagePlane<T>::multiply( Double dMultiplier ) { |
---|
| 432 | T* pcTargetData = m_pcDataOrg; |
---|
| 433 | for (UInt uiPosY = 0; uiPosY < (m_uiHeightOrg); uiPosY++) |
---|
| 434 | { |
---|
| 435 | for (UInt uiPosX = 0; uiPosX < m_uiWidthOrg; uiPosX++) |
---|
| 436 | { |
---|
| 437 | pcTargetData[uiPosX] = (T) ( ( Double )pcTargetData[uiPosX] * dMultiplier ); |
---|
| 438 | } |
---|
| 439 | pcTargetData += m_uiStride; |
---|
| 440 | } |
---|
| 441 | }; |
---|
| 442 | |
---|
| 443 | |
---|
| 444 | template<> |
---|
| 445 | Void TRenImagePlane<Bool>::devide( Double dDevisor ) |
---|
| 446 | { |
---|
| 447 | assert(0); |
---|
| 448 | }; |
---|
| 449 | |
---|
| 450 | template<> |
---|
| 451 | Void TRenImagePlane<Bool>::multiply( Double dMultiplier ) |
---|
| 452 | { |
---|
| 453 | assert(0); |
---|
| 454 | }; |
---|
| 455 | |
---|
| 456 | |
---|
| 457 | template<class T> |
---|
| 458 | Void TRenImagePlane<T>::deleteData() |
---|
| 459 | { |
---|
| 460 | if (m_bClean) |
---|
| 461 | { |
---|
| 462 | if (m_pcDataOrg) |
---|
| 463 | { |
---|
| 464 | delete[] m_pcDataOrg; |
---|
| 465 | }; |
---|
| 466 | } |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | template<class T> |
---|
| 470 | TRenImagePlane<T>::~TRenImagePlane() |
---|
| 471 | { |
---|
| 472 | deleteData(); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | |
---|
| 476 | template<typename T> |
---|
| 477 | Void TRenImagePlane<T>::extendMargin() |
---|
| 478 | { |
---|
| 479 | Int iPad = (Int) m_uiPad; |
---|
| 480 | T* pcData = m_pcData; |
---|
| 481 | |
---|
| 482 | for ( Int iPosY = 0; iPosY < (Int) m_uiHeight; iPosY++) |
---|
| 483 | { |
---|
| 484 | for ( Int iPosX = 0; iPosX < (Int) iPad; iPosX++ ) |
---|
| 485 | { |
---|
| 486 | pcData[ -iPad + iPosX ] = pcData[0]; |
---|
| 487 | pcData[m_uiWidth + iPosX ] = pcData[m_uiWidth -1 ]; |
---|
| 488 | } |
---|
| 489 | pcData += m_uiStride; |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | |
---|
| 493 | pcData -= (m_uiStride + iPad); |
---|
| 494 | for ( Int iPosY = 0; iPosY < iPad; iPosY++ ) |
---|
| 495 | { |
---|
[56] | 496 | memcpy( pcData + (iPosY+1)*m_uiStride, pcData, sizeof(T)*(m_uiWidth + (iPad<<1)) ); |
---|
[2] | 497 | } |
---|
| 498 | |
---|
| 499 | pcData -= ((m_uiHeight-1) * m_uiStride); |
---|
| 500 | for ( Int iPosY = 0; iPosY < iPad; iPosY++ ) |
---|
| 501 | { |
---|
[56] | 502 | memcpy( pcData - (iPosY+1)*m_uiStride, pcData, sizeof(T)*(m_uiWidth + (iPad<<1)) ); |
---|
[2] | 503 | } |
---|
| 504 | } |
---|
| 505 | |
---|
| 506 | template class TRenImagePlane<Pel>; |
---|
| 507 | template class TRenImagePlane<Double>; |
---|
| 508 | template class TRenImagePlane<Bool>; |
---|
| 509 | template class TRenImagePlane<Int>; |
---|
| 510 | |
---|
| 511 | /////// TRenImagePlanePart /////// |
---|
| 512 | |
---|
| 513 | template<typename T> |
---|
| 514 | TRenImagePlanePart<T>::TRenImagePlanePart( TRenImagePlane<T>* pPlane, UInt uHorOff, UInt uVerOff, UInt uWidth, UInt uHeight ) |
---|
| 515 | : TRenImagePlane<T>( pPlane->getPlaneData() + uHorOff + uVerOff * pPlane->getStride(), uWidth, uHeight, pPlane->getStride(),0) |
---|
| 516 | { |
---|
| 517 | |
---|
| 518 | } |
---|
| 519 | |
---|
| 520 | template<typename T> |
---|
| 521 | TRenImagePlanePart<T>::~TRenImagePlanePart() |
---|
| 522 | { |
---|
| 523 | this->m_pcData = NULL; |
---|
| 524 | } |
---|
| 525 | |
---|
| 526 | template class TRenImagePlanePart<Pel>; |
---|
| 527 | template class TRenImagePlanePart<Double>; |
---|
| 528 | template class TRenImagePlanePart<Bool>; |
---|
| 529 | template class TRenImagePlanePart<Int>; |
---|
[1313] | 530 | #endif // NH_3D |
---|
[608] | 531 | |
---|