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