Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComLoopFilter.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComLoopFilter.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 * … … 39 39 #include "TComSlice.h" 40 40 #include "TComMv.h" 41 #include "TComTU.h" 41 42 42 43 //! \ingroup TLibCommon … … 47 48 // ==================================================================================================================== 48 49 49 #define EDGE_VER 0 50 #define EDGE_HOR 1 51 #define QpUV(iQpY) ( ((iQpY) < 0) ? (iQpY) : (((iQpY) > 57) ? ((iQpY)-6) : g_aucChromaScale[(iQpY)]) ) 50 //#define EDGE_VER 0 51 //#define EDGE_HOR 1 52 52 53 53 #define DEFAULT_INTRA_TC_OFFSET 2 ///< Default intra TC offset … … 57 57 // ==================================================================================================================== 58 58 59 const UChar TComLoopFilter::sm_tcTable[ 54] =59 const UChar TComLoopFilter::sm_tcTable[MAX_QP + 1 + DEFAULT_INTRA_TC_OFFSET] = 60 60 { 61 61 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,5,5,6,6,7,8,9,10,11,13,14,16,18,20,22,24 62 62 }; 63 63 64 const UChar TComLoopFilter::sm_betaTable[ 52] =64 const UChar TComLoopFilter::sm_betaTable[MAX_QP + 1] = 65 65 { 66 66 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64 … … 75 75 , m_bLFCrossTileBoundary(true) 76 76 { 77 for( UInt uiDir = 0; uiDir < 2; uiDir++ )78 { 79 m_aapucBS [ uiDir] = NULL;80 m_aapbEdgeFilter[ uiDir] = NULL;77 for( Int edgeDir = 0; edgeDir < NUM_EDGE_DIR; edgeDir++ ) 78 { 79 m_aapucBS [edgeDir] = NULL; 80 m_aapbEdgeFilter[edgeDir] = NULL; 81 81 } 82 82 } … … 98 98 destroy(); 99 99 m_uiNumPartitions = 1 << ( uiMaxCUDepth<<1 ); 100 for( UInt uiDir = 0; uiDir < 2; uiDir++ )101 { 102 m_aapucBS [ uiDir] = new UChar[m_uiNumPartitions];103 m_aapbEdgeFilter[ uiDir] = new Bool [m_uiNumPartitions];100 for( Int edgeDir = 0; edgeDir < NUM_EDGE_DIR; edgeDir++ ) 101 { 102 m_aapucBS [edgeDir] = new UChar[m_uiNumPartitions]; 103 m_aapbEdgeFilter[edgeDir] = new Bool [m_uiNumPartitions]; 104 104 } 105 105 } … … 107 107 Void TComLoopFilter::destroy() 108 108 { 109 for( UInt uiDir = 0; uiDir < 2; uiDir++ ) 110 { 111 if (m_aapucBS) 112 { 113 delete [] m_aapucBS [uiDir]; 114 m_aapucBS [uiDir] = NULL; 115 } 116 if (m_aapbEdgeFilter[uiDir]) 117 { 118 delete [] m_aapbEdgeFilter[uiDir]; 119 m_aapbEdgeFilter[uiDir] = NULL; 109 for( Int edgeDir = 0; edgeDir < NUM_EDGE_DIR; edgeDir++ ) 110 { 111 if (m_aapucBS[edgeDir] != NULL) 112 { 113 delete [] m_aapucBS[edgeDir]; 114 m_aapucBS[edgeDir] = NULL; 115 } 116 117 if (m_aapbEdgeFilter[edgeDir]) 118 { 119 delete [] m_aapbEdgeFilter[edgeDir]; 120 m_aapbEdgeFilter[edgeDir] = NULL; 120 121 } 121 122 } … … 130 131 { 131 132 // Horizontal filtering 132 for ( UInt uiCUAddr = 0; uiCUAddr < pcPic->getNumCUsInFrame(); uiCUAddr++ )133 { 134 TComDataCU* p cCU = pcPic->getCU( uiCUAddr );133 for ( UInt ctuRsAddr = 0; ctuRsAddr < pcPic->getNumberOfCtusInFrame(); ctuRsAddr++ ) 134 { 135 TComDataCU* pCtu = pcPic->getCtu( ctuRsAddr ); 135 136 136 137 ::memset( m_aapucBS [EDGE_VER], 0, sizeof( UChar ) * m_uiNumPartitions ); … … 138 139 139 140 // CU-based deblocking 140 xDeblockCU( p cCU, 0, 0, EDGE_VER );141 xDeblockCU( pCtu, 0, 0, EDGE_VER ); 141 142 } 142 143 143 144 // Vertical filtering 144 for ( UInt uiCUAddr = 0; uiCUAddr < pcPic->getNumCUsInFrame(); uiCUAddr++ )145 { 146 TComDataCU* p cCU = pcPic->getCU( uiCUAddr );145 for ( UInt ctuRsAddr = 0; ctuRsAddr < pcPic->getNumberOfCtusInFrame(); ctuRsAddr++ ) 146 { 147 TComDataCU* pCtu = pcPic->getCtu( ctuRsAddr ); 147 148 148 149 ::memset( m_aapucBS [EDGE_HOR], 0, sizeof( UChar ) * m_uiNumPartitions ); … … 150 151 151 152 // CU-based deblocking 152 xDeblockCU( p cCU, 0, 0, EDGE_HOR );153 xDeblockCU( pCtu, 0, 0, EDGE_HOR ); 153 154 } 154 155 } … … 160 161 161 162 /** 162 - Deblocking filter process in CU-based (the same function as conventional's) 163 . 164 \param Edge the direction of the edge in block boundary (horizonta/vertical), which is added newly 163 Deblocking filter process in CU-based (the same function as conventional's) 164 165 \param pcCU Pointer to CTU/CU structure 166 \param uiAbsZorderIdx Position in CU 167 \param uiDepth Depth in CU 168 \param edgeDir the direction of the edge in block boundary (horizontal/vertical), which is added newly 165 169 */ 166 Void TComLoopFilter::xDeblockCU( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, Int Edge)167 { 168 if(pcCU->getPic()==0||pcCU->getPartitionSize(uiAbsZorderIdx)== SIZE_NONE)170 Void TComLoopFilter::xDeblockCU( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, DeblockEdgeDir edgeDir ) 171 { 172 if(pcCU->getPic()==0||pcCU->getPartitionSize(uiAbsZorderIdx)==NUMBER_OF_PART_SIZES) 169 173 { 170 174 return; 171 175 } 172 176 TComPic* pcPic = pcCU->getPic(); 173 UInt uiCurNumParts = pcPic->getNumPart InCU() >> (uiDepth<<1);177 UInt uiCurNumParts = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1); 174 178 UInt uiQNumParts = uiCurNumParts>>2; 175 179 const TComSPS &sps = *(pcCU->getSlice()->getSPS()); 180 176 181 if( pcCU->getDepth(uiAbsZorderIdx) > uiDepth ) 177 182 { … … 180 185 UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsZorderIdx] ]; 181 186 UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsZorderIdx] ]; 182 if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )183 { 184 xDeblockCU( pcCU, uiAbsZorderIdx, uiDepth+1, Edge);187 if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) 188 { 189 xDeblockCU( pcCU, uiAbsZorderIdx, uiDepth+1, edgeDir ); 185 190 } 186 191 } 187 192 return; 188 193 } 189 194 190 195 xSetLoopfilterParam( pcCU, uiAbsZorderIdx ); 191 192 xSetEdgefilterTU ( pcCU, uiAbsZorderIdx , uiAbsZorderIdx, uiDepth);196 TComTURecurse tuRecurse(pcCU, uiAbsZorderIdx); 197 xSetEdgefilterTU ( tuRecurse ); 193 198 xSetEdgefilterPU ( pcCU, uiAbsZorderIdx ); 194 195 Int iDir = Edge; 199 200 const UInt uiPelsInPart = sps.getMaxCUWidth() >> sps.getMaxTotalCUDepth(); 201 196 202 for( UInt uiPartIdx = uiAbsZorderIdx; uiPartIdx < uiAbsZorderIdx + uiCurNumParts; uiPartIdx++ ) 197 203 { 198 204 UInt uiBSCheck; 199 if( (g_uiMaxCUWidth >> g_uiMaxCUDepth) == 4 )200 { 201 uiBSCheck = ( iDir == EDGE_VER && uiPartIdx%2 == 0) || (iDir == EDGE_HOR && (uiPartIdx-((uiPartIdx>>2)<<2))/2 == 0);205 if( uiPelsInPart == 4 ) 206 { 207 uiBSCheck = (edgeDir == EDGE_VER && uiPartIdx%2 == 0) || (edgeDir == EDGE_HOR && (uiPartIdx-((uiPartIdx>>2)<<2))/2 == 0); 202 208 } 203 209 else … … 205 211 uiBSCheck = 1; 206 212 } 207 208 if ( m_aapbEdgeFilter[iDir][uiPartIdx] && uiBSCheck ) 209 { 210 xGetBoundaryStrengthSingle ( pcCU, iDir, uiPartIdx ); 211 } 212 } 213 214 UInt uiPelsInPart = g_uiMaxCUWidth >> g_uiMaxCUDepth; 213 214 if ( m_aapbEdgeFilter[edgeDir][uiPartIdx] && uiBSCheck ) 215 { 216 xGetBoundaryStrengthSingle ( pcCU, edgeDir, uiPartIdx ); 217 } 218 } 219 215 220 UInt PartIdxIncr = DEBLOCK_SMALLEST_BLOCK / uiPelsInPart ? DEBLOCK_SMALLEST_BLOCK / uiPelsInPart : 1 ; 216 217 UInt uiSizeInPU = pcPic->getNumPartInWidth()>>(uiDepth); 218 219 for ( UInt iEdge = 0; iEdge < uiSizeInPU ; iEdge+=PartIdxIncr) 220 { 221 xEdgeFilterLuma ( pcCU, uiAbsZorderIdx, uiDepth, iDir, iEdge ); 222 if ( (uiPelsInPart>DEBLOCK_SMALLEST_BLOCK) || (iEdge % ( (DEBLOCK_SMALLEST_BLOCK<<1)/uiPelsInPart ) ) == 0 ) 223 { 224 xEdgeFilterChroma ( pcCU, uiAbsZorderIdx, uiDepth, iDir, iEdge ); 225 } 226 } 227 } 228 229 Void TComLoopFilter::xSetEdgefilterMultiple( TComDataCU* pcCU, UInt uiScanIdx, UInt uiDepth, Int iDir, Int iEdgeIdx, Bool bValue,UInt uiWidthInBaseUnits, UInt uiHeightInBaseUnits ) 230 { 221 222 UInt uiSizeInPU = pcPic->getNumPartInCtuWidth()>>(uiDepth); 223 const ChromaFormat chFmt=pcPic->getChromaFormat(); 224 const UInt shiftFactor = edgeDir == EDGE_VER ? pcPic->getComponentScaleX(COMPONENT_Cb) : pcPic->getComponentScaleY(COMPONENT_Cb); 225 const Bool bAlwaysDoChroma=chFmt==CHROMA_444; 226 227 for ( Int iEdge = 0; iEdge < uiSizeInPU ; iEdge+=PartIdxIncr) 228 { 229 xEdgeFilterLuma ( pcCU, uiAbsZorderIdx, uiDepth, edgeDir, iEdge ); 230 if ( chFmt!=CHROMA_400 && (bAlwaysDoChroma || 231 (uiPelsInPart>DEBLOCK_SMALLEST_BLOCK) || 232 (iEdge % ( (DEBLOCK_SMALLEST_BLOCK<<shiftFactor)/uiPelsInPart ) ) == 0 233 ) 234 ) 235 { 236 xEdgeFilterChroma ( pcCU, uiAbsZorderIdx, uiDepth, edgeDir, iEdge ); 237 } 238 } 239 } 240 241 Void TComLoopFilter::xSetEdgefilterMultiple( TComDataCU* pcCU, 242 UInt uiAbsZorderIdx, 243 UInt uiDepth, 244 DeblockEdgeDir edgeDir, 245 Int iEdgeIdx, 246 Bool bValue, 247 UInt uiWidthInBaseUnits, 248 UInt uiHeightInBaseUnits, 249 const TComRectangle *rect) 250 { 231 251 if ( uiWidthInBaseUnits == 0 ) 232 252 { 233 uiWidthInBaseUnits = pcCU->getPic()->getNumPartIn Width () >> uiDepth;253 uiWidthInBaseUnits = pcCU->getPic()->getNumPartInCtuWidth () >> uiDepth; 234 254 } 235 255 if ( uiHeightInBaseUnits == 0 ) 236 256 { 237 uiHeightInBaseUnits = pcCU->getPic()->getNumPartIn Height() >> uiDepth;238 } 239 const UInt uiNumElem = iDir == 0? uiHeightInBaseUnits : uiWidthInBaseUnits;257 uiHeightInBaseUnits = pcCU->getPic()->getNumPartInCtuHeight() >> uiDepth; 258 } 259 const UInt uiNumElem = edgeDir == EDGE_VER ? uiHeightInBaseUnits : uiWidthInBaseUnits; 240 260 assert( uiNumElem > 0 ); 241 261 assert( uiWidthInBaseUnits > 0 ); … … 243 263 for( UInt ui = 0; ui < uiNumElem; ui++ ) 244 264 { 245 const UInt uiBsIdx = xCalcBsIdx( pcCU, ui ScanIdx, iDir, iEdgeIdx, ui);246 m_aapbEdgeFilter[ iDir][uiBsIdx] = bValue;265 const UInt uiBsIdx = xCalcBsIdx( pcCU, uiAbsZorderIdx, edgeDir, iEdgeIdx, ui, rect ); 266 m_aapbEdgeFilter[edgeDir][uiBsIdx] = bValue; 247 267 if (iEdgeIdx == 0) 248 268 { 249 m_aapucBS[iDir][uiBsIdx] = bValue; 250 } 251 } 252 } 253 254 Void TComLoopFilter::xSetEdgefilterTU( TComDataCU* pcCU, UInt absTUPartIdx, UInt uiAbsZorderIdx, UInt uiDepth ) 255 { 256 if( pcCU->getTransformIdx( uiAbsZorderIdx ) + pcCU->getDepth( uiAbsZorderIdx) > uiDepth ) 257 { 258 const UInt uiCurNumParts = pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1); 259 const UInt uiQNumParts = uiCurNumParts>>2; 260 for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++, uiAbsZorderIdx+=uiQNumParts ) 261 { 262 UInt nsAddr = uiAbsZorderIdx; 263 xSetEdgefilterTU( pcCU,nsAddr, uiAbsZorderIdx, uiDepth + 1 ); 264 } 269 m_aapucBS[edgeDir][uiBsIdx] = bValue; 270 } 271 } 272 } 273 274 Void TComLoopFilter::xSetEdgefilterTU( TComTU &rTu ) 275 { 276 TComDataCU* pcCU = rTu.getCU(); 277 UInt uiTransDepthTotal = rTu.GetTransformDepthTotal(); 278 279 if( pcCU->getTransformIdx( rTu.GetAbsPartIdxTU() ) + pcCU->getDepth( rTu.GetAbsPartIdxTU()) > uiTransDepthTotal ) 280 { 281 TComTURecurse tuChild(rTu, false); 282 do 283 { 284 xSetEdgefilterTU( tuChild ); 285 } while (tuChild.nextSection(rTu)); 265 286 return; 266 287 } 267 288 268 Int trWidth = pcCU->getWidth( uiAbsZorderIdx ) >> pcCU->getTransformIdx( uiAbsZorderIdx);269 Int trHeight = pcCU->getHeight( uiAbsZorderIdx ) >> pcCU->getTransformIdx( uiAbsZorderIdx);270 271 UInt uiWidthInBaseUnits = trWidth / (g_uiMaxCUWidth >> g_uiMaxCUDepth);272 UInt uiHeightInBaseUnits = trHeight / (g_uiMaxCUWidth >> g_uiMaxCUDepth);273 274 xSetEdgefilterMultiple( pcCU, absTUPartIdx, uiDepth, EDGE_VER, 0, m_stLFCUParam.bInternalEdge, uiWidthInBaseUnits, uiHeightInBaseUnits);275 xSetEdgefilterMultiple( pcCU, absTUPartIdx, uiDepth, EDGE_HOR, 0, m_stLFCUParam.bInternalEdge, uiWidthInBaseUnits, uiHeightInBaseUnits);289 const TComRectangle &rect = rTu.getRect(COMPONENT_Y); 290 const TComSPS &sps=*(pcCU->getSlice()->getSPS()); 291 292 const UInt uiWidthInBaseUnits = rect.width / (sps.getMaxCUWidth() >> sps.getMaxTotalCUDepth()); 293 const UInt uiHeightInBaseUnits = rect.height / (sps.getMaxCUHeight() >> sps.getMaxTotalCUDepth()); 294 295 xSetEdgefilterMultiple( pcCU, rTu.GetAbsPartIdxCU(), uiTransDepthTotal, EDGE_VER, 0, m_stLFCUParam.bInternalEdge, uiWidthInBaseUnits, uiHeightInBaseUnits, &rect ); 296 xSetEdgefilterMultiple( pcCU, rTu.GetAbsPartIdxCU(), uiTransDepthTotal, EDGE_HOR, 0, m_stLFCUParam.bInternalEdge, uiWidthInBaseUnits, uiHeightInBaseUnits, &rect ); 276 297 } 277 298 … … 279 300 { 280 301 const UInt uiDepth = pcCU->getDepth( uiAbsZorderIdx ); 281 const UInt uiWidthInBaseUnits = pcCU->getPic()->getNumPartIn Width () >> uiDepth;282 const UInt uiHeightInBaseUnits = pcCU->getPic()->getNumPartIn Height() >> uiDepth;302 const UInt uiWidthInBaseUnits = pcCU->getPic()->getNumPartInCtuWidth () >> uiDepth; 303 const UInt uiHeightInBaseUnits = pcCU->getPic()->getNumPartInCtuHeight() >> uiDepth; 283 304 const UInt uiHWidthInBaseUnits = uiWidthInBaseUnits >> 1; 284 305 const UInt uiHHeightInBaseUnits = uiHeightInBaseUnits >> 1; 285 306 const UInt uiQWidthInBaseUnits = uiWidthInBaseUnits >> 2; 286 307 const UInt uiQHeightInBaseUnits = uiHeightInBaseUnits >> 2; 287 308 288 309 xSetEdgefilterMultiple( pcCU, uiAbsZorderIdx, uiDepth, EDGE_VER, 0, m_stLFCUParam.bLeftEdge ); 289 310 xSetEdgefilterMultiple( pcCU, uiAbsZorderIdx, uiDepth, EDGE_HOR, 0, m_stLFCUParam.bTopEdge ); 290 311 291 312 switch ( pcCU->getPartitionSize( uiAbsZorderIdx ) ) 292 313 { … … 343 364 UInt uiX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsZorderIdx ] ]; 344 365 UInt uiY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsZorderIdx ] ]; 345 366 346 367 TComDataCU* pcTempCU; 347 368 UInt uiTempPartIdx; 348 369 349 370 m_stLFCUParam.bInternalEdge = ! pcCU->getSlice()->getDeblockingFilterDisable(); 350 371 351 372 if ( (uiX == 0) || pcCU->getSlice()->getDeblockingFilterDisable() ) 352 373 { … … 360 381 { 361 382 pcTempCU = pcCU->getPULeft( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), !m_bLFCrossTileBoundary); 362 if ( pcTempCU ) 383 384 if ( pcTempCU != NULL ) 363 385 { 364 386 m_stLFCUParam.bLeftEdge = true; … … 369 391 } 370 392 } 371 393 372 394 if ( (uiY == 0 ) || pcCU->getSlice()->getDeblockingFilterDisable() ) 373 395 { … … 382 404 pcTempCU = pcCU->getPUAbove( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary); 383 405 384 if ( pcTempCU )406 if ( pcTempCU != NULL ) 385 407 { 386 408 m_stLFCUParam.bTopEdge = true; … … 393 415 } 394 416 395 Void TComLoopFilter::xGetBoundaryStrengthSingle ( TComDataCU* pcCU, Int iDir, UInt uiAbsPartIdx ) 396 { 397 TComSlice* const pcSlice = pcCU->getSlice(); 398 399 const UInt uiPartQ = uiAbsPartIdx; 400 TComDataCU* const pcCUQ = pcCU; 401 417 Void TComLoopFilter::xGetBoundaryStrengthSingle ( TComDataCU* pCtu, DeblockEdgeDir edgeDir, UInt uiAbsPartIdx4x4BlockWithinCtu ) 418 { 419 TComSlice * const pcSlice = pCtu->getSlice(); 420 421 const Bool lfCrossSliceBoundaryFlag=pCtu->getSlice()->getLFCrossSliceBoundaryFlag(); 422 423 const UInt uiPartQ = uiAbsPartIdx4x4BlockWithinCtu; 424 TComDataCU* const pcCUQ = pCtu; 425 402 426 UInt uiPartP; 403 427 TComDataCU* pcCUP; 404 428 UInt uiBs = 0; 405 429 406 430 //-- Calculate Block Index 407 if ( iDir == EDGE_VER)408 { 409 pcCUP = pcCUQ->getPULeft(uiPartP, uiPartQ, ! pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), !m_bLFCrossTileBoundary);410 } 411 else // ( iDir == EDGE_HOR)412 { 413 pcCUP = pcCUQ->getPUAbove(uiPartP, uiPartQ, !p cCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary);414 } 415 431 if (edgeDir == EDGE_VER) 432 { 433 pcCUP = pcCUQ->getPULeft(uiPartP, uiPartQ, !lfCrossSliceBoundaryFlag, !m_bLFCrossTileBoundary); 434 } 435 else // (edgeDir == EDGE_HOR) 436 { 437 pcCUP = pcCUQ->getPUAbove(uiPartP, uiPartQ, !pCtu->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary); 438 } 439 416 440 //-- Set BS for Intra MB : BS = 4 or 3 417 441 if ( pcCUP->isIntra(uiPartP) || pcCUQ->isIntra(uiPartQ) ) … … 419 443 uiBs = 2; 420 444 } 421 445 422 446 //-- Set BS for not Intra MB : BS = 2 or 1 or 0 423 447 if ( !pcCUP->isIntra(uiPartP) && !pcCUQ->isIntra(uiPartQ) ) … … 425 449 UInt nsPartQ = uiPartQ; 426 450 UInt nsPartP = uiPartP; 427 428 if ( m_aapucBS[ iDir][uiAbsPartIdx] && (pcCUQ->getCbf( nsPartQ, TEXT_LUMA, pcCUQ->getTransformIdx(nsPartQ)) != 0 || pcCUP->getCbf( nsPartP, TEXT_LUMA, pcCUP->getTransformIdx(nsPartP) ) != 0) )451 452 if ( m_aapucBS[edgeDir][uiAbsPartIdx4x4BlockWithinCtu] && (pcCUQ->getCbf( nsPartQ, COMPONENT_Y, pcCUQ->getTransformIdx(nsPartQ)) != 0 || pcCUP->getCbf( nsPartP, COMPONENT_Y, pcCUP->getTransformIdx(nsPartP) ) != 0) ) 429 453 { 430 454 uiBs = 1; … … 432 456 else 433 457 { 434 if (iDir == EDGE_HOR)435 {436 pcCUP = pcCUQ->getPUAbove(uiPartP, uiPartQ, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary);437 }438 458 if (pcSlice->isInterB() || pcCUP->getSlice()->isInterB()) 439 459 { … … 448 468 iRefIdx = pcCUQ->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartQ); 449 469 piRefQ1 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx); 450 470 451 471 TComMv pcMvP0 = pcCUP->getCUMvField(REF_PIC_LIST_0)->getMv(uiPartP); 452 472 TComMv pcMvP1 = pcCUP->getCUMvField(REF_PIC_LIST_1)->getMv(uiPartP); … … 454 474 TComMv pcMvQ1 = pcCUQ->getCUMvField(REF_PIC_LIST_1)->getMv(uiPartQ); 455 475 456 if (piRefP0 == NULL) pcMvP0.setZero(); 457 if (piRefP1 == NULL) pcMvP1.setZero(); 458 if (piRefQ0 == NULL) pcMvQ0.setZero(); 459 if (piRefQ1 == NULL) pcMvQ1.setZero(); 476 if (piRefP0 == NULL) 477 { 478 pcMvP0.setZero(); 479 } 480 if (piRefP1 == NULL) 481 { 482 pcMvP1.setZero(); 483 } 484 if (piRefQ0 == NULL) 485 { 486 pcMvQ0.setZero(); 487 } 488 if (piRefQ1 == NULL) 489 { 490 pcMvQ1.setZero(); 491 } 460 492 461 493 if ( ((piRefP0==piRefQ0)&&(piRefP1==piRefQ1)) || ((piRefP0==piRefQ1)&&(piRefP1==piRefQ0)) ) … … 506 538 TComMv pcMvQ0 = pcCUQ->getCUMvField(REF_PIC_LIST_0)->getMv(uiPartQ); 507 539 508 if (piRefP0 == NULL) pcMvP0.setZero(); 509 if (piRefQ0 == NULL) pcMvQ0.setZero(); 510 540 if (piRefP0 == NULL) 541 { 542 pcMvP0.setZero(); 543 } 544 if (piRefQ0 == NULL) 545 { 546 pcMvQ0.setZero(); 547 } 548 511 549 uiBs = ((piRefP0 != piRefQ0) || 512 550 (abs(pcMvQ0.getHor() - pcMvP0.getHor()) >= 4) || … … 515 553 } // enf of "if( one of BCBP == 0 )" 516 554 } // enf of "if( not Intra )" 517 518 m_aapucBS[iDir][uiAbsPartIdx] = uiBs; 519 } 520 521 522 Void TComLoopFilter::xEdgeFilterLuma( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, Int iDir, Int iEdge ) 523 { 524 TComPicYuv* pcPicYuvRec = pcCU->getPic()->getPicYuvRec(); 525 Pel* piSrc = pcPicYuvRec->getLumaAddr( pcCU->getAddr(), uiAbsZorderIdx ); 526 Pel* piTmpSrc = piSrc; 527 528 Int iStride = pcPicYuvRec->getStride(); 555 556 m_aapucBS[edgeDir][uiAbsPartIdx4x4BlockWithinCtu] = uiBs; 557 } 558 559 560 Void TComLoopFilter::xEdgeFilterLuma( TComDataCU* const pcCU, const UInt uiAbsZorderIdx, const UInt uiDepth, const DeblockEdgeDir edgeDir, const Int iEdge ) 561 { 562 TComPicYuv *pcPicYuvRec = pcCU->getPic()->getPicYuvRec(); 563 Pel *piSrc = pcPicYuvRec->getAddr(COMPONENT_Y, pcCU->getCtuRsAddr(), uiAbsZorderIdx ); 564 Pel *piTmpSrc = piSrc; 565 const TComSPS &sps = *(pcCU->getSlice()->getSPS()); 566 const Bool ppsTransquantBypassEnableFlag = pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag(); 567 const Int bitDepthLuma = sps.getBitDepth(CHANNEL_TYPE_LUMA); 568 const Bool lfCrossSliceBoundaryFlag = pcCU->getSlice()->getLFCrossSliceBoundaryFlag(); 569 570 Int iStride = pcPicYuvRec->getStride(COMPONENT_Y); 529 571 Int iQP = 0; 530 572 Int iQP_P = 0; 531 573 Int iQP_Q = 0; 532 UInt uiNumParts = pcCU->getPic()->getNumPartIn Width()>>uiDepth;533 534 UInt uiPelsInPart = g_uiMaxCUWidth >> g_uiMaxCUDepth;574 UInt uiNumParts = pcCU->getPic()->getNumPartInCtuWidth()>>uiDepth; 575 576 UInt uiPelsInPart = sps.getMaxCUWidth() >> sps.getMaxTotalCUDepth(); 535 577 UInt uiBsAbsIdx = 0, uiBs = 0; 536 578 Int iOffset, iSrcStep; 537 538 Bool bPCMFilter = ( pcCU->getSlice()->getSPS()->getUsePCM() && pcCU->getSlice()->getSPS()->getPCMFilterDisableFlag())? true : false;579 580 Bool bPCMFilter = (sps.getUsePCM() && sps.getPCMFilterDisableFlag())? true : false; 539 581 Bool bPartPNoFilter = false; 540 Bool bPartQNoFilter = false; 582 Bool bPartQNoFilter = false; 541 583 UInt uiPartPIdx = 0; 542 584 UInt uiPartQIdx = 0; 543 TComDataCU* pcCUP = pcCU; 585 TComDataCU* pcCUP = pcCU; 544 586 TComDataCU* pcCUQ = pcCU; 545 587 Int betaOffsetDiv2 = pcCUQ->getSlice()->getDeblockingFilterBetaOffsetDiv2(); 546 588 Int tcOffsetDiv2 = pcCUQ->getSlice()->getDeblockingFilterTcOffsetDiv2(); 547 589 548 if ( iDir == EDGE_VER)590 if (edgeDir == EDGE_VER) 549 591 { 550 592 iOffset = 1; … … 552 594 piTmpSrc += iEdge*uiPelsInPart; 553 595 } 554 else // ( iDir == EDGE_HOR)596 else // (edgeDir == EDGE_HOR) 555 597 { 556 598 iOffset = iStride; … … 558 600 piTmpSrc += iEdge*uiPelsInPart*iStride; 559 601 } 560 602 603 const Int iBitdepthScale = 1 << (bitDepthLuma-8); 604 561 605 for ( UInt iIdx = 0; iIdx < uiNumParts; iIdx++ ) 562 606 { 563 uiBsAbsIdx = xCalcBsIdx( pcCU, uiAbsZorderIdx, iDir, iEdge, iIdx);564 uiBs = m_aapucBS[ iDir][uiBsAbsIdx];607 uiBsAbsIdx = xCalcBsIdx( pcCU, uiAbsZorderIdx, edgeDir, iEdge, iIdx); 608 uiBs = m_aapucBS[edgeDir][uiBsAbsIdx]; 565 609 if ( uiBs ) 566 610 { … … 568 612 uiPartQIdx = uiBsAbsIdx; 569 613 // Derive neighboring PU index 570 if ( iDir == EDGE_VER)571 { 572 pcCUP = pcCUQ->getPULeft (uiPartPIdx, uiPartQIdx,! pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), !m_bLFCrossTileBoundary);614 if (edgeDir == EDGE_VER) 615 { 616 pcCUP = pcCUQ->getPULeft (uiPartPIdx, uiPartQIdx,!lfCrossSliceBoundaryFlag, !m_bLFCrossTileBoundary); 573 617 } 574 618 else // (iDir == EDGE_HOR) 575 619 { 576 pcCUP = pcCUQ->getPUAbove(uiPartPIdx, uiPartQIdx,! pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary);620 pcCUP = pcCUQ->getPUAbove(uiPartPIdx, uiPartQIdx,!lfCrossSliceBoundaryFlag, false, !m_bLFCrossTileBoundary); 577 621 } 578 622 579 623 iQP_P = pcCUP->getQP(uiPartPIdx); 580 624 iQP = (iQP_P + iQP_Q + 1) >> 1; 581 Int iBitdepthScale = 1 << (g_bitDepthY-8); 582 625 583 626 Int iIndexTC = Clip3(0, MAX_QP+DEFAULT_INTRA_TC_OFFSET, Int(iQP + DEFAULT_INTRA_TC_OFFSET*(uiBs-1) + (tcOffsetDiv2 << 1))); 584 627 Int iIndexB = Clip3(0, MAX_QP, iQP + (betaOffsetDiv2 << 1)); 585 628 586 629 Int iTc = sm_tcTable[iIndexTC]*iBitdepthScale; 587 630 Int iBeta = sm_betaTable[iIndexB]*iBitdepthScale; 588 631 Int iSideThreshold = (iBeta+(iBeta>>1))>>3; 589 632 Int iThrCut = iTc*10; 633 590 634 591 635 UInt uiBlocksInPart = uiPelsInPart / 4 ? uiPelsInPart / 4 : 1; … … 598 642 Int d0 = dp0 + dq0; 599 643 Int d3 = dp3 + dq3; 600 644 601 645 Int dp = dp0 + dp3; 602 646 Int dq = dq0 + dq3; 603 647 Int d = d0 + d3; 604 605 if (bPCMFilter || p cCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())648 649 if (bPCMFilter || ppsTransquantBypassEnableFlag) 606 650 { 607 651 // Check if each of PUs is I_PCM with LF disabling … … 615 659 616 660 if (d < iBeta) 617 { 661 { 618 662 Bool bFilterP = (dp < iSideThreshold); 619 663 Bool bFilterQ = (dq < iSideThreshold); 620 664 621 665 Bool sw = xUseStrongFiltering( iOffset, 2*d0, iBeta, iTc, piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+0)) 622 666 && xUseStrongFiltering( iOffset, 2*d3, iBeta, iTc, piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+3)); 623 667 624 668 for ( Int i = 0; i < DEBLOCK_SMALLEST_BLOCK/2; i++) 625 669 { 626 xPelFilterLuma( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+i), iOffset, iTc, sw, bPartPNoFilter, bPartQNoFilter, iThrCut, bFilterP, bFilterQ );670 xPelFilterLuma( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+i), iOffset, iTc, sw, bPartPNoFilter, bPartQNoFilter, iThrCut, bFilterP, bFilterQ, bitDepthLuma); 627 671 } 628 672 } … … 633 677 634 678 635 Void TComLoopFilter::xEdgeFilterChroma( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, Int iDir, Int iEdge ) 636 { 637 TComPicYuv* pcPicYuvRec = pcCU->getPic()->getPicYuvRec(); 638 Int iStride = pcPicYuvRec->getCStride(); 639 Pel* piSrcCb = pcPicYuvRec->getCbAddr( pcCU->getAddr(), uiAbsZorderIdx ); 640 Pel* piSrcCr = pcPicYuvRec->getCrAddr( pcCU->getAddr(), uiAbsZorderIdx ); 679 Void TComLoopFilter::xEdgeFilterChroma( TComDataCU* const pcCU, const UInt uiAbsZorderIdx, const UInt uiDepth, const DeblockEdgeDir edgeDir, const Int iEdge ) 680 { 681 TComPicYuv *pcPicYuvRec = pcCU->getPic()->getPicYuvRec(); 682 Int iStride = pcPicYuvRec->getStride(COMPONENT_Cb); 683 Pel *piSrcCb = pcPicYuvRec->getAddr( COMPONENT_Cb, pcCU->getCtuRsAddr(), uiAbsZorderIdx ); 684 Pel *piSrcCr = pcPicYuvRec->getAddr( COMPONENT_Cr, pcCU->getCtuRsAddr(), uiAbsZorderIdx ); 685 const TComSPS &sps = *(pcCU->getSlice()->getSPS()); 686 const Int bitDepthChroma = sps.getBitDepth(CHANNEL_TYPE_CHROMA); 687 688 const UInt uiPelsInPartChromaH = sps.getMaxCUWidth() >> (sps.getMaxTotalCUDepth()+pcPicYuvRec->getComponentScaleX(COMPONENT_Cb)); 689 const UInt uiPelsInPartChromaV = sps.getMaxCUHeight() >> (sps.getMaxTotalCUDepth()+pcPicYuvRec->getComponentScaleY(COMPONENT_Cb)); 690 641 691 Int iQP = 0; 642 692 Int iQP_P = 0; 643 693 Int iQP_Q = 0; 644 645 UInt uiPelsInPartChroma = g_uiMaxCUWidth >> (g_uiMaxCUDepth+1); 646 694 647 695 Int iOffset, iSrcStep; 648 649 const UInt uiLCUWidthInBaseUnits = pcCU->getPic()->getNumPartInWidth(); 650 696 UInt uiLoopLength; 697 698 const UInt uiCtuWidthInBaseUnits = pcCU->getPic()->getNumPartInCtuWidth(); 699 651 700 Bool bPCMFilter = (pcCU->getSlice()->getSPS()->getUsePCM() && pcCU->getSlice()->getSPS()->getPCMFilterDisableFlag())? true : false; 652 701 Bool bPartPNoFilter = false; 653 Bool bPartQNoFilter = false; 654 UInt uiPartPIdx; 655 UInt uiPartQIdx; 656 TComDataCU* pcCUP; 702 Bool bPartQNoFilter = false; 657 703 TComDataCU* pcCUQ = pcCU; 658 704 Int tcOffsetDiv2 = pcCU->getSlice()->getDeblockingFilterTcOffsetDiv2(); 659 705 660 706 // Vertical Position 661 UInt uiEdgeNumInLCUVert = g_auiZscanToRaster[uiAbsZorderIdx]%uiLCUWidthInBaseUnits + iEdge; 662 UInt uiEdgeNumInLCUHor = g_auiZscanToRaster[uiAbsZorderIdx]/uiLCUWidthInBaseUnits + iEdge; 663 664 if ( (uiPelsInPartChroma < DEBLOCK_SMALLEST_BLOCK) && (( (uiEdgeNumInLCUVert%(DEBLOCK_SMALLEST_BLOCK/uiPelsInPartChroma))&&(iDir==0) ) || ( (uiEdgeNumInLCUHor%(DEBLOCK_SMALLEST_BLOCK/uiPelsInPartChroma))&& iDir ) )) 707 UInt uiEdgeNumInCtuVert = g_auiZscanToRaster[uiAbsZorderIdx]%uiCtuWidthInBaseUnits + iEdge; 708 UInt uiEdgeNumInCtuHor = g_auiZscanToRaster[uiAbsZorderIdx]/uiCtuWidthInBaseUnits + iEdge; 709 710 if ( (uiPelsInPartChromaH < DEBLOCK_SMALLEST_BLOCK) && (uiPelsInPartChromaV < DEBLOCK_SMALLEST_BLOCK) && 711 ( 712 ( (uiEdgeNumInCtuVert%(DEBLOCK_SMALLEST_BLOCK/uiPelsInPartChromaH)) && (edgeDir==EDGE_VER) ) || 713 ( (uiEdgeNumInCtuHor %(DEBLOCK_SMALLEST_BLOCK/uiPelsInPartChromaV)) && (edgeDir==EDGE_HOR) ) 714 ) 715 ) 665 716 { 666 717 return; 667 718 } 668 669 UInt uiNumParts = pcCU->getPic()->getNumPartInWidth()>>uiDepth; 670 719 720 721 const Bool lfCrossSliceBoundaryFlag=pcCU->getSlice()->getLFCrossSliceBoundaryFlag(); 722 723 UInt uiNumParts = pcCU->getPic()->getNumPartInCtuWidth()>>uiDepth; 724 671 725 UInt uiBsAbsIdx; 672 726 UChar ucBs; 673 727 674 728 Pel* piTmpSrcCb = piSrcCb; 675 729 Pel* piTmpSrcCr = piSrcCr; 676 677 678 if (iDir == EDGE_VER) 730 731 if (edgeDir == EDGE_VER) 679 732 { 680 733 iOffset = 1; 681 734 iSrcStep = iStride; 682 piTmpSrcCb += iEdge*uiPelsInPartChroma; 683 piTmpSrcCr += iEdge*uiPelsInPartChroma; 684 } 685 else // (iDir == EDGE_HOR) 735 piTmpSrcCb += iEdge*uiPelsInPartChromaH; 736 piTmpSrcCr += iEdge*uiPelsInPartChromaH; 737 uiLoopLength=uiPelsInPartChromaV; 738 } 739 else // (edgeDir == EDGE_HOR) 686 740 { 687 741 iOffset = iStride; 688 742 iSrcStep = 1; 689 piTmpSrcCb += iEdge*iStride*uiPelsInPartChroma; 690 piTmpSrcCr += iEdge*iStride*uiPelsInPartChroma; 691 } 692 743 piTmpSrcCb += iEdge*iStride*uiPelsInPartChromaV; 744 piTmpSrcCr += iEdge*iStride*uiPelsInPartChromaV; 745 uiLoopLength=uiPelsInPartChromaH; 746 } 747 748 const Int iBitdepthScale = 1 << (pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-8); 749 693 750 for ( UInt iIdx = 0; iIdx < uiNumParts; iIdx++ ) 694 751 { 695 uiBsAbsIdx = xCalcBsIdx( pcCU, uiAbsZorderIdx, iDir, iEdge, iIdx);696 ucBs = m_aapucBS[ iDir][uiBsAbsIdx];697 752 uiBsAbsIdx = xCalcBsIdx( pcCU, uiAbsZorderIdx, edgeDir, iEdge, iIdx); 753 ucBs = m_aapucBS[edgeDir][uiBsAbsIdx]; 754 698 755 if ( ucBs > 1) 699 756 { 700 757 iQP_Q = pcCU->getQP( uiBsAbsIdx ); 701 uiPartQIdx = uiBsAbsIdx;758 UInt uiPartQIdx = uiBsAbsIdx; 702 759 // Derive neighboring PU index 703 if (iDir == EDGE_VER) 704 { 705 pcCUP = pcCUQ->getPULeft (uiPartPIdx, uiPartQIdx,!pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), !m_bLFCrossTileBoundary); 706 } 707 else // (iDir == EDGE_HOR) 708 { 709 pcCUP = pcCUQ->getPUAbove(uiPartPIdx, uiPartQIdx,!pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary); 760 TComDataCU* pcCUP; 761 UInt uiPartPIdx; 762 763 if (edgeDir == EDGE_VER) 764 { 765 pcCUP = pcCUQ->getPULeft (uiPartPIdx, uiPartQIdx,!lfCrossSliceBoundaryFlag, !m_bLFCrossTileBoundary); 766 } 767 else // (edgeDir == EDGE_HOR) 768 { 769 pcCUP = pcCUQ->getPUAbove(uiPartPIdx, uiPartQIdx,!lfCrossSliceBoundaryFlag, false, !m_bLFCrossTileBoundary); 710 770 } 711 771 712 772 iQP_P = pcCUP->getQP(uiPartPIdx); 713 773 714 774 if (bPCMFilter || pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 715 775 { … … 722 782 bPartQNoFilter = bPartQNoFilter || (pcCUQ->isLosslessCoded(uiPartQIdx)); 723 783 } 724 784 725 785 for ( UInt chromaIdx = 0; chromaIdx < 2; chromaIdx++ ) 726 786 { 727 Int chromaQPOffset = (chromaIdx == 0) ? pcCU->getSlice()->getPPS()->getChromaCbQpOffset() : pcCU->getSlice()->getPPS()->getChromaCrQpOffset();787 Int chromaQPOffset = pcCU->getSlice()->getPPS()->getQpOffset(ComponentID(chromaIdx + 1)); 728 788 Pel* piTmpSrcChroma = (chromaIdx == 0) ? piTmpSrcCb : piTmpSrcCr; 729 789 730 iQP = QpUV( ((iQP_P + iQP_Q + 1) >> 1) + chromaQPOffset ); 731 Int iBitdepthScale = 1 << (g_bitDepthC-8); 790 iQP = ((iQP_P + iQP_Q + 1) >> 1) + chromaQPOffset; 791 if (iQP >= chromaQPMappingTableSize) 792 { 793 if (pcPicYuvRec->getChromaFormat()==CHROMA_420) 794 { 795 iQP -=6; 796 } 797 else if (iQP>51) 798 { 799 iQP=51; 800 } 801 } 802 else if (iQP >= 0 ) 803 { 804 iQP = getScaledChromaQP(iQP, pcPicYuvRec->getChromaFormat()); 805 } 732 806 733 807 Int iIndexTC = Clip3(0, MAX_QP+DEFAULT_INTRA_TC_OFFSET, iQP + DEFAULT_INTRA_TC_OFFSET*(ucBs - 1) + (tcOffsetDiv2 << 1)); 734 808 Int iTc = sm_tcTable[iIndexTC]*iBitdepthScale; 735 809 736 for ( UInt uiStep = 0; uiStep < ui PelsInPartChroma; uiStep++ )737 { 738 xPelFilterChroma( piTmpSrcChroma + iSrcStep*(uiStep+iIdx*ui PelsInPartChroma), iOffset, iTc , bPartPNoFilter, bPartQNoFilter);810 for ( UInt uiStep = 0; uiStep < uiLoopLength; uiStep++ ) 811 { 812 xPelFilterChroma( piTmpSrcChroma + iSrcStep*(uiStep+iIdx*uiLoopLength), iOffset, iTc , bPartPNoFilter, bPartQNoFilter, bitDepthChroma); 739 813 } 740 814 } … … 755 829 \param bFilterSecondP decision weak filter/no filter for partP 756 830 \param bFilterSecondQ decision weak filter/no filter for partQ 831 \param bitDepthLuma luma bit depth 757 832 */ 758 __inline Void TComLoopFilter::xPelFilterLuma( Pel* piSrc, Int iOffset, Int tc , Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ)833 __inline Void TComLoopFilter::xPelFilterLuma( Pel* piSrc, Int iOffset, Int tc, Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ, const Int bitDepthLuma) 759 834 { 760 835 Int delta; 761 836 762 837 Pel m4 = piSrc[0]; 763 838 Pel m3 = piSrc[-iOffset]; … … 785 860 if ( abs(delta) < iThrCut ) 786 861 { 787 delta = Clip3(-tc, tc, delta); 788 piSrc[-iOffset] = Clip Y((m3+delta));789 piSrc[0] = Clip Y((m4-delta));862 delta = Clip3(-tc, tc, delta); 863 piSrc[-iOffset] = ClipBD((m3+delta), bitDepthLuma); 864 piSrc[0] = ClipBD((m4-delta), bitDepthLuma); 790 865 791 866 Int tc2 = tc>>1; … … 793 868 { 794 869 Int delta1 = Clip3(-tc2, tc2, (( ((m1+m3+1)>>1)- m2+delta)>>1)); 795 piSrc[-iOffset*2] = Clip Y((m2+delta1));870 piSrc[-iOffset*2] = ClipBD((m2+delta1), bitDepthLuma); 796 871 } 797 872 if(bFilterSecondQ) 798 873 { 799 874 Int delta2 = Clip3(-tc2, tc2, (( ((m6+m4+1)>>1)- m5-delta)>>1)); 800 piSrc[ iOffset] = Clip Y((m5+delta2));875 piSrc[ iOffset] = ClipBD((m5+delta2), bitDepthLuma); 801 876 } 802 877 } … … 825 900 \param bPartPNoFilter indicator to disable filtering on partP 826 901 \param bPartQNoFilter indicator to disable filtering on partQ 902 \param bitDepthChroma chroma bit depth 827 903 */ 828 __inline Void TComLoopFilter::xPelFilterChroma( Pel* piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter )904 __inline Void TComLoopFilter::xPelFilterChroma( Pel* piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter, const Int bitDepthChroma) 829 905 { 830 906 Int delta; 831 907 832 908 Pel m4 = piSrc[0]; 833 909 Pel m3 = piSrc[-iOffset]; 834 910 Pel m5 = piSrc[ iOffset]; 835 911 Pel m2 = piSrc[-iOffset*2]; 836 912 837 913 delta = Clip3(-tc,tc, (((( m4 - m3 ) << 2 ) + m2 - m5 + 4 ) >> 3) ); 838 piSrc[-iOffset] = Clip C(m3+delta);839 piSrc[0] = Clip C(m4-delta);914 piSrc[-iOffset] = ClipBD((m3+delta), bitDepthChroma); 915 piSrc[0] = ClipBD((m4-delta), bitDepthChroma); 840 916 841 917 if(bPartPNoFilter) … … 874 950 return abs( piSrc[-iOffset*3] - 2*piSrc[-iOffset*2] + piSrc[-iOffset] ) ; 875 951 } 876 952 877 953 __inline Int TComLoopFilter::xCalcDQ( Pel* piSrc, Int iOffset) 878 954 {
Note: See TracChangeset for help on using the changeset viewer.