[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[608] | 6 | * Copyright (c) 2010-2013, 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | /** \file TComYuv.cpp |
---|
| 35 | \brief general YUV buffer class |
---|
| 36 | \todo this should be merged with TComPicYuv |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #include <stdlib.h> |
---|
| 40 | #include <memory.h> |
---|
| 41 | #include <assert.h> |
---|
| 42 | #include <math.h> |
---|
| 43 | |
---|
| 44 | #include "CommonDef.h" |
---|
| 45 | #include "TComYuv.h" |
---|
[56] | 46 | #include "TComInterpolationFilter.h" |
---|
[2] | 47 | |
---|
[56] | 48 | //! \ingroup TLibCommon |
---|
| 49 | //! \{ |
---|
| 50 | |
---|
[2] | 51 | TComYuv::TComYuv() |
---|
| 52 | { |
---|
| 53 | m_apiBufY = NULL; |
---|
| 54 | m_apiBufU = NULL; |
---|
| 55 | m_apiBufV = NULL; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | TComYuv::~TComYuv() |
---|
| 59 | { |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | Void TComYuv::create( UInt iWidth, UInt iHeight ) |
---|
| 63 | { |
---|
| 64 | // memory allocation |
---|
| 65 | m_apiBufY = (Pel*)xMalloc( Pel, iWidth*iHeight ); |
---|
| 66 | m_apiBufU = (Pel*)xMalloc( Pel, iWidth*iHeight >> 2 ); |
---|
| 67 | m_apiBufV = (Pel*)xMalloc( Pel, iWidth*iHeight >> 2 ); |
---|
| 68 | |
---|
| 69 | // set width and height |
---|
| 70 | m_iWidth = iWidth; |
---|
| 71 | m_iHeight = iHeight; |
---|
| 72 | m_iCWidth = iWidth >> 1; |
---|
| 73 | m_iCHeight = iHeight >> 1; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | Void TComYuv::destroy() |
---|
| 77 | { |
---|
| 78 | // memory free |
---|
| 79 | xFree( m_apiBufY ); m_apiBufY = NULL; |
---|
| 80 | xFree( m_apiBufU ); m_apiBufU = NULL; |
---|
| 81 | xFree( m_apiBufV ); m_apiBufV = NULL; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | Void TComYuv::clear() |
---|
| 85 | { |
---|
| 86 | ::memset( m_apiBufY, 0, ( m_iWidth * m_iHeight )*sizeof(Pel) ); |
---|
| 87 | ::memset( m_apiBufU, 0, ( m_iCWidth * m_iCHeight )*sizeof(Pel) ); |
---|
| 88 | ::memset( m_apiBufV, 0, ( m_iCWidth * m_iCHeight )*sizeof(Pel) ); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | Void TComYuv::copyToPicYuv ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
| 92 | { |
---|
| 93 | copyToPicLuma ( pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx ); |
---|
| 94 | copyToPicChroma( pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx ); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | Void TComYuv::copyToPicLuma ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
| 98 | { |
---|
| 99 | Int y, iWidth, iHeight; |
---|
| 100 | iWidth = m_iWidth >>uiPartDepth; |
---|
| 101 | iHeight = m_iHeight>>uiPartDepth; |
---|
| 102 | |
---|
| 103 | Pel* pSrc = getLumaAddr(uiPartIdx, iWidth); |
---|
| 104 | Pel* pDst = pcPicYuvDst->getLumaAddr ( iCuAddr, uiAbsZorderIdx ); |
---|
| 105 | |
---|
| 106 | UInt iSrcStride = getStride(); |
---|
| 107 | UInt iDstStride = pcPicYuvDst->getStride(); |
---|
| 108 | |
---|
| 109 | for ( y = iHeight; y != 0; y-- ) |
---|
| 110 | { |
---|
| 111 | ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth); |
---|
[622] | 112 | |
---|
| 113 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
| 114 | if ( g_traceCopyBack && g_nSymbolCounter >= g_stopAtCounter ) |
---|
| 115 | { |
---|
| 116 | for ( Int x = 0; x < iWidth; x++) |
---|
| 117 | { |
---|
| 118 | std::cout << pSrc[ x ] << " " ; |
---|
| 119 | } |
---|
| 120 | std::cout << std::endl; |
---|
| 121 | } |
---|
| 122 | #endif |
---|
| 123 | |
---|
[2] | 124 | pDst += iDstStride; |
---|
| 125 | pSrc += iSrcStride; |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | Void TComYuv::copyToPicChroma( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
| 130 | { |
---|
| 131 | Int y, iWidth, iHeight; |
---|
| 132 | iWidth = m_iCWidth >>uiPartDepth; |
---|
| 133 | iHeight = m_iCHeight>>uiPartDepth; |
---|
| 134 | |
---|
| 135 | Pel* pSrcU = getCbAddr(uiPartIdx, iWidth); |
---|
| 136 | Pel* pSrcV = getCrAddr(uiPartIdx, iWidth); |
---|
| 137 | Pel* pDstU = pcPicYuvDst->getCbAddr( iCuAddr, uiAbsZorderIdx ); |
---|
| 138 | Pel* pDstV = pcPicYuvDst->getCrAddr( iCuAddr, uiAbsZorderIdx ); |
---|
| 139 | |
---|
| 140 | UInt iSrcStride = getCStride(); |
---|
| 141 | UInt iDstStride = pcPicYuvDst->getCStride(); |
---|
| 142 | for ( y = iHeight; y != 0; y-- ) |
---|
| 143 | { |
---|
| 144 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(iWidth) ); |
---|
| 145 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(iWidth) ); |
---|
| 146 | pSrcU += iSrcStride; |
---|
| 147 | pSrcV += iSrcStride; |
---|
| 148 | pDstU += iDstStride; |
---|
| 149 | pDstV += iDstStride; |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | Void TComYuv::copyFromPicYuv ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
| 154 | { |
---|
| 155 | copyFromPicLuma ( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx ); |
---|
| 156 | copyFromPicChroma( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx ); |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | Void TComYuv::copyFromPicLuma ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
| 160 | { |
---|
| 161 | Int y; |
---|
| 162 | |
---|
| 163 | Pel* pDst = m_apiBufY; |
---|
| 164 | Pel* pSrc = pcPicYuvSrc->getLumaAddr ( iCuAddr, uiAbsZorderIdx ); |
---|
| 165 | |
---|
| 166 | UInt iDstStride = getStride(); |
---|
| 167 | UInt iSrcStride = pcPicYuvSrc->getStride(); |
---|
| 168 | for ( y = m_iHeight; y != 0; y-- ) |
---|
| 169 | { |
---|
| 170 | ::memcpy( pDst, pSrc, sizeof(Pel)*m_iWidth); |
---|
| 171 | pDst += iDstStride; |
---|
| 172 | pSrc += iSrcStride; |
---|
| 173 | } |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | Void TComYuv::copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
| 177 | { |
---|
| 178 | Int y; |
---|
| 179 | |
---|
| 180 | Pel* pDstU = m_apiBufU; |
---|
| 181 | Pel* pDstV = m_apiBufV; |
---|
| 182 | Pel* pSrcU = pcPicYuvSrc->getCbAddr( iCuAddr, uiAbsZorderIdx ); |
---|
| 183 | Pel* pSrcV = pcPicYuvSrc->getCrAddr( iCuAddr, uiAbsZorderIdx ); |
---|
| 184 | |
---|
| 185 | UInt iDstStride = getCStride(); |
---|
| 186 | UInt iSrcStride = pcPicYuvSrc->getCStride(); |
---|
| 187 | for ( y = m_iCHeight; y != 0; y-- ) |
---|
| 188 | { |
---|
| 189 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(m_iCWidth) ); |
---|
| 190 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(m_iCWidth) ); |
---|
| 191 | pSrcU += iSrcStride; |
---|
| 192 | pSrcV += iSrcStride; |
---|
| 193 | pDstU += iDstStride; |
---|
| 194 | pDstV += iDstStride; |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
| 199 | { |
---|
| 200 | copyToPartLuma ( pcYuvDst, uiDstPartIdx ); |
---|
| 201 | copyToPartChroma( pcYuvDst, uiDstPartIdx ); |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | Void TComYuv::copyToPartLuma( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
| 205 | { |
---|
| 206 | Int y; |
---|
| 207 | |
---|
| 208 | Pel* pSrc = m_apiBufY; |
---|
| 209 | Pel* pDst = pcYuvDst->getLumaAddr( uiDstPartIdx ); |
---|
| 210 | |
---|
| 211 | UInt iSrcStride = getStride(); |
---|
| 212 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 213 | for ( y = m_iHeight; y != 0; y-- ) |
---|
| 214 | { |
---|
| 215 | ::memcpy( pDst, pSrc, sizeof(Pel)*m_iWidth); |
---|
| 216 | pDst += iDstStride; |
---|
| 217 | pSrc += iSrcStride; |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | Void TComYuv::copyToPartChroma( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
| 222 | { |
---|
| 223 | Int y; |
---|
| 224 | |
---|
| 225 | Pel* pSrcU = m_apiBufU; |
---|
| 226 | Pel* pSrcV = m_apiBufV; |
---|
| 227 | Pel* pDstU = pcYuvDst->getCbAddr( uiDstPartIdx ); |
---|
| 228 | Pel* pDstV = pcYuvDst->getCrAddr( uiDstPartIdx ); |
---|
| 229 | |
---|
| 230 | UInt iSrcStride = getCStride(); |
---|
| 231 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 232 | for ( y = m_iCHeight; y != 0; y-- ) |
---|
| 233 | { |
---|
| 234 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(m_iCWidth) ); |
---|
| 235 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(m_iCWidth) ); |
---|
| 236 | pSrcU += iSrcStride; |
---|
| 237 | pSrcV += iSrcStride; |
---|
| 238 | pDstU += iDstStride; |
---|
| 239 | pDstV += iDstStride; |
---|
| 240 | } |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | Void TComYuv::copyPartToYuv( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
| 244 | { |
---|
| 245 | copyPartToLuma ( pcYuvDst, uiSrcPartIdx ); |
---|
| 246 | copyPartToChroma( pcYuvDst, uiSrcPartIdx ); |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | Void TComYuv::copyPartToLuma( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
| 250 | { |
---|
| 251 | Int y; |
---|
| 252 | |
---|
| 253 | Pel* pSrc = getLumaAddr(uiSrcPartIdx); |
---|
| 254 | Pel* pDst = pcYuvDst->getLumaAddr( 0 ); |
---|
| 255 | |
---|
| 256 | UInt iSrcStride = getStride(); |
---|
| 257 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 258 | |
---|
| 259 | UInt uiHeight = pcYuvDst->getHeight(); |
---|
| 260 | UInt uiWidth = pcYuvDst->getWidth(); |
---|
| 261 | |
---|
| 262 | for ( y = uiHeight; y != 0; y-- ) |
---|
| 263 | { |
---|
| 264 | ::memcpy( pDst, pSrc, sizeof(Pel)*uiWidth); |
---|
| 265 | pDst += iDstStride; |
---|
| 266 | pSrc += iSrcStride; |
---|
| 267 | } |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | Void TComYuv::copyPartToChroma( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
| 271 | { |
---|
| 272 | Int y; |
---|
| 273 | |
---|
| 274 | Pel* pSrcU = getCbAddr( uiSrcPartIdx ); |
---|
| 275 | Pel* pSrcV = getCrAddr( uiSrcPartIdx ); |
---|
| 276 | Pel* pDstU = pcYuvDst->getCbAddr( 0 ); |
---|
| 277 | Pel* pDstV = pcYuvDst->getCrAddr( 0 ); |
---|
| 278 | |
---|
| 279 | UInt iSrcStride = getCStride(); |
---|
| 280 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 281 | |
---|
| 282 | UInt uiCHeight = pcYuvDst->getCHeight(); |
---|
| 283 | UInt uiCWidth = pcYuvDst->getCWidth(); |
---|
| 284 | |
---|
| 285 | for ( y = uiCHeight; y != 0; y-- ) |
---|
| 286 | { |
---|
| 287 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(uiCWidth) ); |
---|
| 288 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(uiCWidth) ); |
---|
| 289 | pSrcU += iSrcStride; |
---|
| 290 | pSrcV += iSrcStride; |
---|
| 291 | pDstU += iDstStride; |
---|
| 292 | pDstV += iDstStride; |
---|
| 293 | } |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | Void TComYuv::copyPartToPartYuv ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
| 297 | { |
---|
| 298 | copyPartToPartLuma (pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
| 299 | copyPartToPartChroma (pcYuvDst, uiPartIdx, iWidth>>1, iHeight>>1 ); |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | Void TComYuv::copyPartToPartLuma ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
| 303 | { |
---|
| 304 | Pel* pSrc = getLumaAddr(uiPartIdx); |
---|
| 305 | Pel* pDst = pcYuvDst->getLumaAddr(uiPartIdx); |
---|
| 306 | if( pSrc == pDst ) |
---|
| 307 | { |
---|
| 308 | //th not a good idea |
---|
| 309 | //th best would be to fix the caller |
---|
| 310 | return ; |
---|
| 311 | } |
---|
| 312 | |
---|
| 313 | UInt iSrcStride = getStride(); |
---|
| 314 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 315 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
| 316 | { |
---|
| 317 | ::memcpy( pDst, pSrc, iWidth * sizeof(Pel) ); |
---|
| 318 | pSrc += iSrcStride; |
---|
| 319 | pDst += iDstStride; |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | Void TComYuv::copyPartToPartChroma( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
| 324 | { |
---|
| 325 | Pel* pSrcU = getCbAddr(uiPartIdx); |
---|
| 326 | Pel* pSrcV = getCrAddr(uiPartIdx); |
---|
| 327 | Pel* pDstU = pcYuvDst->getCbAddr(uiPartIdx); |
---|
| 328 | Pel* pDstV = pcYuvDst->getCrAddr(uiPartIdx); |
---|
| 329 | |
---|
| 330 | if( pSrcU == pDstU && pSrcV == pDstV) |
---|
| 331 | { |
---|
| 332 | //th not a good idea |
---|
| 333 | //th best would be to fix the caller |
---|
| 334 | return ; |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | UInt iSrcStride = getCStride(); |
---|
| 338 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 339 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
| 340 | { |
---|
| 341 | ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) ); |
---|
| 342 | ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) ); |
---|
| 343 | pSrcU += iSrcStride; |
---|
| 344 | pSrcV += iSrcStride; |
---|
| 345 | pDstU += iDstStride; |
---|
| 346 | pDstV += iDstStride; |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | |
---|
[608] | 350 | Void TComYuv::copyPartToPartChroma( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt chromaId) |
---|
[2] | 351 | { |
---|
[608] | 352 | if(chromaId == 0) |
---|
[2] | 353 | { |
---|
[608] | 354 | Pel* pSrcU = getCbAddr(uiPartIdx); |
---|
| 355 | Pel* pDstU = pcYuvDst->getCbAddr(uiPartIdx); |
---|
| 356 | if( pSrcU == pDstU) |
---|
[2] | 357 | { |
---|
[608] | 358 | return ; |
---|
[2] | 359 | } |
---|
[608] | 360 | UInt iSrcStride = getCStride(); |
---|
| 361 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 362 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
[2] | 363 | { |
---|
[608] | 364 | ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) ); |
---|
| 365 | pSrcU += iSrcStride; |
---|
| 366 | pDstU += iDstStride; |
---|
[2] | 367 | } |
---|
| 368 | } |
---|
[608] | 369 | else if (chromaId == 1) |
---|
[2] | 370 | { |
---|
[608] | 371 | Pel* pSrcV = getCrAddr(uiPartIdx); |
---|
| 372 | Pel* pDstV = pcYuvDst->getCrAddr(uiPartIdx); |
---|
| 373 | if( pSrcV == pDstV) |
---|
[2] | 374 | { |
---|
[608] | 375 | return; |
---|
[2] | 376 | } |
---|
[608] | 377 | UInt iSrcStride = getCStride(); |
---|
| 378 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 379 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
| 380 | { |
---|
| 381 | ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) ); |
---|
| 382 | pSrcV += iSrcStride; |
---|
| 383 | pDstV += iDstStride; |
---|
| 384 | } |
---|
[2] | 385 | } |
---|
[608] | 386 | else |
---|
[2] | 387 | { |
---|
[608] | 388 | Pel* pSrcU = getCbAddr(uiPartIdx); |
---|
| 389 | Pel* pSrcV = getCrAddr(uiPartIdx); |
---|
| 390 | Pel* pDstU = pcYuvDst->getCbAddr(uiPartIdx); |
---|
| 391 | Pel* pDstV = pcYuvDst->getCrAddr(uiPartIdx); |
---|
| 392 | |
---|
| 393 | if( pSrcU == pDstU && pSrcV == pDstV) |
---|
[2] | 394 | { |
---|
[608] | 395 | //th not a good idea |
---|
| 396 | //th best would be to fix the caller |
---|
| 397 | return ; |
---|
[2] | 398 | } |
---|
[608] | 399 | UInt iSrcStride = getCStride(); |
---|
| 400 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 401 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
[2] | 402 | { |
---|
[608] | 403 | ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) ); |
---|
| 404 | ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) ); |
---|
| 405 | pSrcU += iSrcStride; |
---|
| 406 | pSrcV += iSrcStride; |
---|
| 407 | pDstU += iDstStride; |
---|
| 408 | pDstV += iDstStride; |
---|
[2] | 409 | } |
---|
| 410 | } |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | Void TComYuv::addClip( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 414 | { |
---|
| 415 | addClipLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); |
---|
| 416 | addClipChroma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | Void TComYuv::addClipLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 420 | { |
---|
| 421 | Int x, y; |
---|
| 422 | |
---|
| 423 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 424 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 425 | Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 426 | |
---|
| 427 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 428 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 429 | UInt iDstStride = getStride(); |
---|
| 430 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 431 | { |
---|
| 432 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 433 | { |
---|
[608] | 434 | pDst[x] = ClipY( pSrc0[x] + pSrc1[x] ); |
---|
[2] | 435 | } |
---|
| 436 | pSrc0 += iSrc0Stride; |
---|
| 437 | pSrc1 += iSrc1Stride; |
---|
| 438 | pDst += iDstStride; |
---|
| 439 | } |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | Void TComYuv::addClipChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 443 | { |
---|
| 444 | Int x, y; |
---|
| 445 | |
---|
| 446 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 447 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 448 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 449 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 450 | Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 451 | Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 452 | |
---|
| 453 | UInt iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 454 | UInt iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 455 | UInt iDstStride = getCStride(); |
---|
| 456 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 457 | { |
---|
| 458 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 459 | { |
---|
[608] | 460 | pDstU[x] = ClipC( pSrcU0[x] + pSrcU1[x] ); |
---|
| 461 | pDstV[x] = ClipC( pSrcV0[x] + pSrcV1[x] ); |
---|
[2] | 462 | } |
---|
| 463 | |
---|
| 464 | pSrcU0 += iSrc0Stride; |
---|
| 465 | pSrcU1 += iSrc1Stride; |
---|
| 466 | pSrcV0 += iSrc0Stride; |
---|
| 467 | pSrcV1 += iSrc1Stride; |
---|
| 468 | pDstU += iDstStride; |
---|
| 469 | pDstV += iDstStride; |
---|
| 470 | } |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | Void TComYuv::subtract( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 474 | { |
---|
| 475 | subtractLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); |
---|
| 476 | subtractChroma( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); |
---|
| 477 | } |
---|
| 478 | |
---|
| 479 | Void TComYuv::subtractLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 480 | { |
---|
| 481 | Int x, y; |
---|
| 482 | |
---|
| 483 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 484 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 485 | Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 486 | |
---|
| 487 | Int iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 488 | Int iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 489 | Int iDstStride = getStride(); |
---|
| 490 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 491 | { |
---|
| 492 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 493 | { |
---|
| 494 | pDst[x] = pSrc0[x] - pSrc1[x]; |
---|
| 495 | } |
---|
| 496 | pSrc0 += iSrc0Stride; |
---|
| 497 | pSrc1 += iSrc1Stride; |
---|
| 498 | pDst += iDstStride; |
---|
| 499 | } |
---|
| 500 | } |
---|
| 501 | |
---|
| 502 | Void TComYuv::subtractChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 503 | { |
---|
| 504 | Int x, y; |
---|
| 505 | |
---|
| 506 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 507 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 508 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 509 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 510 | Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 511 | Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 512 | |
---|
| 513 | Int iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 514 | Int iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 515 | Int iDstStride = getCStride(); |
---|
| 516 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 517 | { |
---|
| 518 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 519 | { |
---|
| 520 | pDstU[x] = pSrcU0[x] - pSrcU1[x]; |
---|
| 521 | pDstV[x] = pSrcV0[x] - pSrcV1[x]; |
---|
| 522 | } |
---|
| 523 | pSrcU0 += iSrc0Stride; |
---|
| 524 | pSrcU1 += iSrc1Stride; |
---|
| 525 | pSrcV0 += iSrc0Stride; |
---|
| 526 | pSrcV1 += iSrc1Stride; |
---|
| 527 | pDstU += iDstStride; |
---|
| 528 | pDstV += iDstStride; |
---|
| 529 | } |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | Void TComYuv::addAvg( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight ) |
---|
| 533 | { |
---|
| 534 | Int x, y; |
---|
| 535 | |
---|
| 536 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 537 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr ( iPartUnitIdx ); |
---|
| 538 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr ( iPartUnitIdx ); |
---|
| 539 | |
---|
| 540 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 541 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr ( iPartUnitIdx ); |
---|
| 542 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr ( iPartUnitIdx ); |
---|
| 543 | |
---|
| 544 | Pel* pDstY = getLumaAddr( iPartUnitIdx ); |
---|
| 545 | Pel* pDstU = getCbAddr ( iPartUnitIdx ); |
---|
| 546 | Pel* pDstV = getCrAddr ( iPartUnitIdx ); |
---|
| 547 | |
---|
| 548 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 549 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 550 | UInt iDstStride = getStride(); |
---|
[608] | 551 | Int shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthY; |
---|
[56] | 552 | Int offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS; |
---|
[2] | 553 | |
---|
[56] | 554 | for ( y = 0; y < iHeight; y++ ) |
---|
[2] | 555 | { |
---|
[56] | 556 | for ( x = 0; x < iWidth; x += 4 ) |
---|
[2] | 557 | { |
---|
[608] | 558 | pDstY[ x + 0 ] = ClipY( ( pSrcY0[ x + 0 ] + pSrcY1[ x + 0 ] + offset ) >> shiftNum ); |
---|
| 559 | pDstY[ x + 1 ] = ClipY( ( pSrcY0[ x + 1 ] + pSrcY1[ x + 1 ] + offset ) >> shiftNum ); |
---|
| 560 | pDstY[ x + 2 ] = ClipY( ( pSrcY0[ x + 2 ] + pSrcY1[ x + 2 ] + offset ) >> shiftNum ); |
---|
| 561 | pDstY[ x + 3 ] = ClipY( ( pSrcY0[ x + 3 ] + pSrcY1[ x + 3 ] + offset ) >> shiftNum ); |
---|
[2] | 562 | } |
---|
| 563 | pSrcY0 += iSrc0Stride; |
---|
| 564 | pSrcY1 += iSrc1Stride; |
---|
| 565 | pDstY += iDstStride; |
---|
| 566 | } |
---|
| 567 | |
---|
[608] | 568 | shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthC; |
---|
| 569 | offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS; |
---|
| 570 | |
---|
[2] | 571 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 572 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 573 | iDstStride = getCStride(); |
---|
| 574 | |
---|
| 575 | iWidth >>=1; |
---|
| 576 | iHeight >>=1; |
---|
| 577 | |
---|
| 578 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 579 | { |
---|
| 580 | for ( x = iWidth-1; x >= 0; ) |
---|
| 581 | { |
---|
| 582 | // note: chroma min width is 2 |
---|
[608] | 583 | pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 584 | pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 585 | pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 586 | pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
[2] | 587 | } |
---|
| 588 | |
---|
| 589 | pSrcU0 += iSrc0Stride; |
---|
| 590 | pSrcU1 += iSrc1Stride; |
---|
| 591 | pSrcV0 += iSrc0Stride; |
---|
| 592 | pSrcV1 += iSrc1Stride; |
---|
| 593 | pDstU += iDstStride; |
---|
| 594 | pDstV += iDstStride; |
---|
| 595 | } |
---|
| 596 | } |
---|
| 597 | |
---|
| 598 | Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight ) |
---|
| 599 | { |
---|
| 600 | Int x, y; |
---|
| 601 | |
---|
| 602 | Pel* pSrc = pcYuvSrc->getLumaAddr(uiPartIdx); |
---|
| 603 | Pel* pSrcU = pcYuvSrc->getCbAddr(uiPartIdx); |
---|
| 604 | Pel* pSrcV = pcYuvSrc->getCrAddr(uiPartIdx); |
---|
| 605 | |
---|
| 606 | Pel* pDst = getLumaAddr(uiPartIdx); |
---|
| 607 | Pel* pDstU = getCbAddr(uiPartIdx); |
---|
| 608 | Pel* pDstV = getCrAddr(uiPartIdx); |
---|
| 609 | |
---|
| 610 | Int iSrcStride = pcYuvSrc->getStride(); |
---|
| 611 | Int iDstStride = getStride(); |
---|
| 612 | |
---|
| 613 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 614 | { |
---|
| 615 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 616 | { |
---|
[56] | 617 | #if DISABLING_CLIP_FOR_BIPREDME |
---|
| 618 | pDst[x ] = (pDst[x ]<<1) - pSrc[x ] ; |
---|
| 619 | #else |
---|
| 620 | pDst[x ] = Clip( (pDst[x ]<<1) - pSrc[x ] ); |
---|
| 621 | #endif |
---|
[2] | 622 | } |
---|
| 623 | pSrc += iSrcStride; |
---|
| 624 | pDst += iDstStride; |
---|
| 625 | } |
---|
| 626 | |
---|
| 627 | iSrcStride = pcYuvSrc->getCStride(); |
---|
| 628 | iDstStride = getCStride(); |
---|
| 629 | |
---|
| 630 | uiHeight >>= 1; |
---|
| 631 | uiWidht >>= 1; |
---|
| 632 | |
---|
| 633 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 634 | { |
---|
| 635 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 636 | { |
---|
[56] | 637 | #if DISABLING_CLIP_FOR_BIPREDME |
---|
| 638 | pDstU[x ] = (pDstU[x ]<<1) - pSrcU[x ] ; |
---|
| 639 | pDstV[x ] = (pDstV[x ]<<1) - pSrcV[x ] ; |
---|
| 640 | #else |
---|
| 641 | pDstU[x ] = Clip( (pDstU[x ]<<1) - pSrcU[x ] ); |
---|
| 642 | pDstV[x ] = Clip( (pDstV[x ]<<1) - pSrcV[x ] ); |
---|
| 643 | #endif |
---|
[2] | 644 | } |
---|
| 645 | pSrcU += iSrcStride; |
---|
| 646 | pSrcV += iSrcStride; |
---|
| 647 | pDstU += iDstStride; |
---|
| 648 | pDstV += iDstStride; |
---|
| 649 | } |
---|
| 650 | } |
---|
[608] | 651 | |
---|
| 652 | #if H_3D |
---|
| 653 | Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
[443] | 654 | { |
---|
[608] | 655 | Int x, y; |
---|
| 656 | |
---|
| 657 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx); |
---|
| 658 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx); |
---|
| 659 | Pel* pDst = getLumaAddr( uiTrUnitIdx); |
---|
| 660 | |
---|
| 661 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 662 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 663 | UInt iDstStride = getStride(); |
---|
| 664 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 665 | { |
---|
| 666 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 667 | { |
---|
| 668 | pDst[x] = ClipY( pSrc0[x] + pSrc1[x] ); |
---|
| 669 | } |
---|
| 670 | pSrc0 += iSrc0Stride; |
---|
| 671 | pSrc1 += iSrc1Stride; |
---|
| 672 | pDst += iDstStride; |
---|
| 673 | } |
---|
| 674 | } |
---|
| 675 | |
---|
| 676 | #if H_3D_ARP |
---|
| 677 | Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip ) |
---|
| 678 | { |
---|
[443] | 679 | addARPLuma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth , uiHeight , bClip ); |
---|
| 680 | addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip ); |
---|
| 681 | } |
---|
| 682 | |
---|
[608] | 683 | Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip ) |
---|
[443] | 684 | { |
---|
| 685 | Int x, y; |
---|
| 686 | |
---|
| 687 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx ); |
---|
| 688 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx ); |
---|
| 689 | Pel* pDst = getLumaAddr( uiAbsPartIdx ); |
---|
| 690 | |
---|
| 691 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 692 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 693 | UInt iDstStride = getStride(); |
---|
| 694 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 695 | { |
---|
| 696 | for ( x = uiWidth-1; x >= 0; x-- ) |
---|
| 697 | { |
---|
| 698 | pDst[x] = pSrc0[x] + pSrc1[x]; |
---|
| 699 | if( bClip ) |
---|
[608] | 700 | { |
---|
| 701 | pDst[x] = ClipY( pDst[x] ); |
---|
| 702 | } |
---|
[443] | 703 | } |
---|
| 704 | pSrc0 += iSrc0Stride; |
---|
| 705 | pSrc1 += iSrc1Stride; |
---|
| 706 | pDst += iDstStride; |
---|
| 707 | } |
---|
| 708 | } |
---|
| 709 | |
---|
[608] | 710 | Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip ) |
---|
[443] | 711 | { |
---|
| 712 | Int x, y; |
---|
| 713 | |
---|
| 714 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx ); |
---|
| 715 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx ); |
---|
| 716 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx ); |
---|
| 717 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx ); |
---|
| 718 | Pel* pDstU = getCbAddr( uiAbsPartIdx ); |
---|
| 719 | Pel* pDstV = getCrAddr( uiAbsPartIdx ); |
---|
| 720 | |
---|
| 721 | UInt iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 722 | UInt iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 723 | UInt iDstStride = getCStride(); |
---|
| 724 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 725 | { |
---|
| 726 | for ( x = uiWidth-1; x >= 0; x-- ) |
---|
| 727 | { |
---|
| 728 | pDstU[x] = pSrcU0[x] + pSrcU1[x]; |
---|
| 729 | pDstV[x] = pSrcV0[x] + pSrcV1[x]; |
---|
| 730 | if( bClip ) |
---|
| 731 | { |
---|
[608] | 732 | pDstU[x] = ClipC( pDstU[x] ); |
---|
| 733 | pDstV[x] = ClipC( pDstV[x] ); |
---|
[443] | 734 | } |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | pSrcU0 += iSrc0Stride; |
---|
| 738 | pSrcU1 += iSrc1Stride; |
---|
| 739 | pSrcV0 += iSrc0Stride; |
---|
| 740 | pSrcV1 += iSrc1Stride; |
---|
| 741 | pDstU += iDstStride; |
---|
| 742 | pDstV += iDstStride; |
---|
| 743 | } |
---|
| 744 | } |
---|
| 745 | |
---|
[608] | 746 | Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ) |
---|
[443] | 747 | { |
---|
| 748 | subtractARPLuma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth , uiHeight ); |
---|
| 749 | subtractARPChroma( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 ); |
---|
| 750 | } |
---|
| 751 | |
---|
[608] | 752 | Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ) |
---|
[443] | 753 | { |
---|
| 754 | Int x, y; |
---|
| 755 | |
---|
| 756 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx ); |
---|
| 757 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx ); |
---|
| 758 | Pel* pDst = getLumaAddr( uiAbsPartIdx ); |
---|
| 759 | |
---|
| 760 | Int iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 761 | Int iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 762 | Int iDstStride = getStride(); |
---|
| 763 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 764 | { |
---|
| 765 | for ( x = uiWidth-1; x >= 0; x-- ) |
---|
| 766 | { |
---|
| 767 | pDst[x] = pSrc0[x] - pSrc1[x]; |
---|
| 768 | } |
---|
| 769 | pSrc0 += iSrc0Stride; |
---|
| 770 | pSrc1 += iSrc1Stride; |
---|
| 771 | pDst += iDstStride; |
---|
| 772 | } |
---|
| 773 | } |
---|
| 774 | |
---|
[608] | 775 | Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ) |
---|
[443] | 776 | { |
---|
| 777 | Int x, y; |
---|
| 778 | |
---|
| 779 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx ); |
---|
| 780 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx ); |
---|
| 781 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx ); |
---|
| 782 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx ); |
---|
| 783 | Pel* pDstU = getCbAddr( uiAbsPartIdx ); |
---|
| 784 | Pel* pDstV = getCrAddr( uiAbsPartIdx ); |
---|
| 785 | |
---|
| 786 | Int iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 787 | Int iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 788 | Int iDstStride = getCStride(); |
---|
| 789 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 790 | { |
---|
| 791 | for ( x = uiWidth-1; x >= 0; x-- ) |
---|
| 792 | { |
---|
| 793 | pDstU[x] = pSrcU0[x] - pSrcU1[x]; |
---|
| 794 | pDstV[x] = pSrcV0[x] - pSrcV1[x]; |
---|
| 795 | } |
---|
| 796 | pSrcU0 += iSrc0Stride; |
---|
| 797 | pSrcU1 += iSrc1Stride; |
---|
| 798 | pSrcV0 += iSrc0Stride; |
---|
| 799 | pSrcV1 += iSrc1Stride; |
---|
| 800 | pDstU += iDstStride; |
---|
| 801 | pDstV += iDstStride; |
---|
| 802 | } |
---|
| 803 | } |
---|
| 804 | |
---|
| 805 | Void TComYuv::multiplyARP( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ) |
---|
| 806 | { |
---|
| 807 | multiplyARPLuma( uiAbsPartIdx , uiWidth , uiHeight , dW ); |
---|
| 808 | multiplyARPChroma( uiAbsPartIdx , uiWidth >> 1 , uiHeight >> 1 , dW ); |
---|
| 809 | } |
---|
| 810 | |
---|
[608] | 811 | Void TComYuv::xxMultiplyLine( Pel* pSrcDst , UInt uiWidth , UChar dW ) |
---|
[443] | 812 | { |
---|
| 813 | assert( dW == 2 ); |
---|
| 814 | for( UInt x = 0 ; x < uiWidth ; x++ ) |
---|
| 815 | pSrcDst[x] = pSrcDst[x] >> 1; |
---|
| 816 | } |
---|
| 817 | |
---|
| 818 | Void TComYuv::multiplyARPLuma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ) |
---|
| 819 | { |
---|
| 820 | Pel* pDst = getLumaAddr( uiAbsPartIdx ); |
---|
| 821 | Int iDstStride = getStride(); |
---|
| 822 | for ( Int y = uiHeight-1; y >= 0; y-- ) |
---|
| 823 | { |
---|
| 824 | xxMultiplyLine( pDst , uiWidth , dW ); |
---|
| 825 | pDst += iDstStride; |
---|
| 826 | } |
---|
| 827 | } |
---|
| 828 | |
---|
| 829 | Void TComYuv::multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ) |
---|
| 830 | { |
---|
| 831 | Pel* pDstU = getCbAddr( uiAbsPartIdx ); |
---|
| 832 | Pel* pDstV = getCrAddr( uiAbsPartIdx ); |
---|
| 833 | |
---|
| 834 | Int iDstStride = getCStride(); |
---|
| 835 | for ( Int y = uiHeight-1; y >= 0; y-- ) |
---|
| 836 | { |
---|
| 837 | xxMultiplyLine( pDstU , uiWidth , dW ); |
---|
| 838 | xxMultiplyLine( pDstV , uiWidth , dW ); |
---|
| 839 | pDstU += iDstStride; |
---|
| 840 | pDstV += iDstStride; |
---|
| 841 | } |
---|
| 842 | } |
---|
| 843 | #endif |
---|
[608] | 844 | #endif |
---|
[56] | 845 | //! \} |
---|