Changeset 655 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComWedgelet.cpp
- Timestamp:
- 23 Oct 2013, 23:01:30 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComWedgelet.cpp
r622 r655 175 175 } 176 176 177 #if !SEC_DMM2_E0146_HHIFIX178 Bool TComWedgelet::checkPredDirAbovePossible( UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset )179 {180 WedgeResolution eContDWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiPredDirBlockSize]];181 UInt uiContDStartEndMax = 0;182 UInt uiContDStartEndOffset = 0;183 switch( eContDWedgeRes )184 {185 case( DOUBLE_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize>>1); uiContDStartEndOffset = (uiPredDirBlockOffset>>1); break; }186 case( FULL_PEL ): { uiContDStartEndMax = uiPredDirBlockSize; uiContDStartEndOffset = uiPredDirBlockOffset; break; }187 case( HALF_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize<<1); uiContDStartEndOffset = (uiPredDirBlockOffset<<1); break; }188 }189 190 if( m_uhOri == 2 || m_uhOri == 3 || m_uhOri == 4 )191 {192 UInt uiThisStartEndMax = 0;193 switch( m_eWedgeRes )194 {195 case( DOUBLE_PEL ): { uiThisStartEndMax = (m_uiWidth>>1); break; }196 case( FULL_PEL ): { uiThisStartEndMax = m_uiWidth; break; }197 case( HALF_PEL ): { uiThisStartEndMax = (m_uiWidth<<1); break; }198 }199 200 UChar uhStartX = m_uhXs;201 UChar uhStartY = m_uhYs;202 UChar uhEndX = m_uhXe;203 UChar uhEndY = m_uhYe;204 205 if( 2 == m_uhOri )206 {207 std::swap( uhStartX, uhEndX );208 std::swap( uhStartY, uhEndY );209 }210 211 UInt uiScaledEndX = (UInt)uhEndX;212 Int iDeltaRes = (Int)eContDWedgeRes - (Int)m_eWedgeRes;213 if( iDeltaRes > 0 ) { uiScaledEndX <<= iDeltaRes; }214 if( iDeltaRes < 0 ) { uiScaledEndX >>= -iDeltaRes; }215 216 if( ((UInt)uhEndY == (uiThisStartEndMax-1)) && ((uiScaledEndX-uiContDStartEndOffset) > 0 && (uiScaledEndX-uiContDStartEndOffset) < (uiContDStartEndMax-1)) )217 {218 return true;219 }220 }221 222 return false;223 }224 225 Bool TComWedgelet::checkPredDirLeftPossible( UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset )226 {227 WedgeResolution eContDWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiPredDirBlockSize]];228 UInt uiContDStartEndMax = 0;229 UInt uiContDStartEndOffset = 0;230 switch( eContDWedgeRes )231 {232 case( DOUBLE_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize>>1); uiContDStartEndOffset = (uiPredDirBlockOffset>>1); break; }233 case( FULL_PEL ): { uiContDStartEndMax = uiPredDirBlockSize; uiContDStartEndOffset = uiPredDirBlockOffset; break; }234 case( HALF_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize<<1); uiContDStartEndOffset = (uiPredDirBlockOffset<<1); break; }235 }236 237 if( m_uhOri == 1 || m_uhOri == 2 || m_uhOri == 5 )238 {239 UInt uiThisStartEndMax = 0;240 switch( m_eWedgeRes )241 {242 case( DOUBLE_PEL ): { uiThisStartEndMax = (m_uiHeight>>1); break; }243 case( FULL_PEL ): { uiThisStartEndMax = m_uiHeight; break; }244 case( HALF_PEL ): { uiThisStartEndMax = (m_uiHeight<<1); break; }245 }246 247 UChar uhStartX = m_uhXs;248 UChar uhStartY = m_uhYs;249 UChar uhEndX = m_uhXe;250 UChar uhEndY = m_uhYe;251 252 if( 1 == m_uhOri || 5 == m_uhOri )253 {254 std::swap( uhStartX, uhEndX );255 std::swap( uhStartY, uhEndY );256 }257 258 UInt uiScaledEndY = (UInt)uhEndY;259 Int iDeltaRes = (Int)eContDWedgeRes - (Int)m_eWedgeRes;260 if( iDeltaRes > 0 ) { uiScaledEndY <<= iDeltaRes; }261 if( iDeltaRes < 0 ) { uiScaledEndY >>= -iDeltaRes; }262 263 if( ((UInt)uhEndX == (uiThisStartEndMax-1)) && ((uiScaledEndY-uiContDStartEndOffset) > 0 && (uiScaledEndY-uiContDStartEndOffset) < (uiContDStartEndMax-1)) )264 {265 return true;266 }267 }268 269 return false;270 }271 272 Void TComWedgelet::getPredDirStartEndAbove( UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset, Int iDeltaEnd )273 {274 ruhXs = 0;275 ruhYs = 0;276 ruhXe = 0;277 ruhYe = 0;278 279 // get start/end of reference (=this) wedgelet280 UInt uiRefStartX = (UInt)getStartX();281 UInt uiRefStartY = (UInt)getStartY();282 UInt uiRefEndX = (UInt)getEndX();283 UInt uiRefEndY = (UInt)getEndY();284 285 WedgeResolution eContDWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiPredDirBlockSize]];286 UInt uiContDStartEndMax = 0;287 UInt uiContDStartEndOffset = 0;288 switch( eContDWedgeRes )289 {290 case( DOUBLE_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize>>1); uiContDStartEndOffset = (uiPredDirBlockOffset>>1); break; }291 case( FULL_PEL ): { uiContDStartEndMax = uiPredDirBlockSize; uiContDStartEndOffset = uiPredDirBlockOffset; break; }292 case( HALF_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize<<1); uiContDStartEndOffset = (uiPredDirBlockOffset<<1); break; }293 }294 Int iContDMaxPos = (Int)uiContDStartEndMax - 1;295 296 // swap if start/end if line orientation is not from top to bottom297 if( 2 == (UInt)getOri() )298 {299 std::swap( uiRefStartX, uiRefEndX );300 std::swap( uiRefStartY, uiRefEndY );301 }302 303 // calc slopes304 Int iA_DeltaX = (Int)uiRefEndX - (Int)uiRefStartX;305 Int iA_DeltaY = (Int)uiRefEndY - (Int)uiRefStartY;306 307 // get aligned end x value of ref wedge308 UInt uiScaledRefEndX = uiRefEndX;309 Int iDeltaRes = (Int)eContDWedgeRes - (Int)m_eWedgeRes;310 if( iDeltaRes > 0 ) { uiScaledRefEndX <<= iDeltaRes; }311 if( iDeltaRes < 0 ) { uiScaledRefEndX >>= -iDeltaRes; }312 313 assert( uiScaledRefEndX >= uiContDStartEndOffset );314 Int iAlignedRefEndX = (Int)uiScaledRefEndX - (Int)uiContDStartEndOffset;315 316 // special for straight vertical wedge317 if( iA_DeltaX == 0 )318 {319 ruhXs = (UChar)iAlignedRefEndX;320 ruhYs = 0;321 322 Int iXe = iAlignedRefEndX + iDeltaEnd;323 if( iXe < 0 )324 {325 ruhXe = 0;326 ruhYe = (UChar)min( max( (iContDMaxPos + iXe), 0 ), iContDMaxPos );327 328 return;329 }330 else if( iXe > iContDMaxPos )331 {332 ruhXe = (UChar)iContDMaxPos;333 ruhYe = (UChar)min( max( (iContDMaxPos - (iXe - iContDMaxPos)), 0 ), iContDMaxPos );334 335 std::swap( ruhXs, ruhXe );336 std::swap( ruhYs, ruhYe );337 return;338 }339 else340 {341 ruhXe = (UChar)iXe;342 ruhYe = (UChar)iContDMaxPos;343 344 return;345 }346 }347 348 // special for straight horizontal short bottom line349 if( iA_DeltaY == 0 )350 {351 switch( (UInt)getOri() )352 {353 case( 2 ):354 {355 ruhXs = (UChar)(iAlignedRefEndX-1);356 ruhYs = 0;357 ruhXe = 0;358 ruhYe = (UChar)min( max( iDeltaEnd, 0 ), iContDMaxPos );359 360 return;361 }362 case( 3 ):363 {364 ruhXs = (UChar)(iAlignedRefEndX+1);365 ruhYs = 0;366 ruhXe = (UChar)iContDMaxPos;367 ruhYe = (UChar)min( max( -iDeltaEnd, 0 ), iContDMaxPos );368 369 std::swap( ruhXs, ruhXe );370 std::swap( ruhYs, ruhYe );371 return;372 }373 default:374 {375 assert( 0 );376 return;377 }378 }379 }380 381 // set start point depending on slope382 if( abs( iA_DeltaX ) >= abs( iA_DeltaY ) ) { if( iA_DeltaX < 0 ) { ruhXs = (UChar)(iAlignedRefEndX-1); ruhYs = 0; }383 if( iA_DeltaX > 0 ) { ruhXs = (UChar)(iAlignedRefEndX+1); ruhYs = 0; } }384 else { ruhXs = (UChar)(iAlignedRefEndX); ruhYs = 0; }385 386 // calc end point and determine orientation387 Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iContDMaxPos * ((Double)iA_DeltaX / (Double)iA_DeltaY) );388 389 if( iVirtualEndX < 0 )390 {391 Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iA_DeltaY / (Double)iA_DeltaX) ) + iDeltaEnd;392 if( iYe < (Int)uiContDStartEndMax )393 {394 ruhXe = 0;395 ruhYe = (UChar)max( iYe, 0 );396 397 return;398 }399 else400 {401 ruhXe = (UChar)min( (iYe - iContDMaxPos), iContDMaxPos );402 ruhYe = (UChar)iContDMaxPos;403 404 return;405 }406 }407 else if( iVirtualEndX > iContDMaxPos )408 {409 Int iYe = roftoi( (Double)(iContDMaxPos - (Int)ruhXs) * ((Double)iA_DeltaY / (Double)iA_DeltaX) ) - iDeltaEnd;410 if( iYe < (Int)uiContDStartEndMax )411 {412 ruhXe = (UChar)iContDMaxPos;413 ruhYe = (UChar)max( iYe, 0 );414 415 std::swap( ruhXs, ruhXe );416 std::swap( ruhYs, ruhYe );417 return;418 }419 else420 {421 ruhXe = (UChar)max( (iContDMaxPos - (iYe - iContDMaxPos)), 0 );422 ruhYe = (UChar)iContDMaxPos;423 424 return;425 }426 }427 else428 {429 Int iXe = iVirtualEndX + iDeltaEnd;430 if( iXe < 0 )431 {432 ruhXe = 0;433 ruhYe = (UChar)max( (iContDMaxPos + iXe), 0 );434 435 return;436 }437 else if( iXe > iContDMaxPos )438 {439 ruhXe = (UChar)iContDMaxPos;440 ruhYe = (UChar)max( (iContDMaxPos - (iXe - iContDMaxPos)), 0 );441 442 std::swap( ruhXs, ruhXe );443 std::swap( ruhYs, ruhYe );444 return;445 }446 else447 {448 ruhXe = (UChar)iXe;449 ruhYe = (UChar)iContDMaxPos;450 451 return;452 }453 }454 }455 456 Void TComWedgelet::getPredDirStartEndLeft( UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, UInt uiPredDirBlockSize, UInt uiPredDirBlockOffset, Int iDeltaEnd )457 {458 ruhXs = 0;459 ruhYs = 0;460 ruhXe = 0;461 ruhYe = 0;462 463 // get start/end of reference (=this) wedgelet464 UInt uiRefStartX = (UInt)getStartX();465 UInt uiRefStartY = (UInt)getStartY();466 UInt uiRefEndX = (UInt)getEndX();467 UInt uiRefEndY = (UInt)getEndY();468 469 WedgeResolution eContDWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiPredDirBlockSize]];470 UInt uiContDStartEndMax = 0;471 UInt uiContDStartEndOffset = 0;472 switch( eContDWedgeRes )473 {474 case( DOUBLE_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize>>1); uiContDStartEndOffset = (uiPredDirBlockOffset>>1); break; }475 case( FULL_PEL ): { uiContDStartEndMax = uiPredDirBlockSize; uiContDStartEndOffset = uiPredDirBlockOffset; break; }476 case( HALF_PEL ): { uiContDStartEndMax = (uiPredDirBlockSize<<1); uiContDStartEndOffset = (uiPredDirBlockOffset<<1); break; }477 }478 Int iContDMaxPos = (Int)uiContDStartEndMax - 1;479 480 // swap if start/end if line orientation is not from left to right481 if( 1 == (UInt)getOri() || 5 == (UInt)getOri() )482 {483 std::swap( uiRefStartX, uiRefEndX );484 std::swap( uiRefStartY, uiRefEndY );485 }486 487 Int iL_DeltaX = (Int)uiRefEndX - (Int)uiRefStartX;488 Int iL_DeltaY = (Int)uiRefEndY - (Int)uiRefStartY;489 490 UInt uiScaledRefEndY = uiRefEndY;491 Int iDeltaRes = (Int)eContDWedgeRes - (Int)m_eWedgeRes;492 if( iDeltaRes > 0 ) { uiScaledRefEndY <<= iDeltaRes; }493 if( iDeltaRes < 0 ) { uiScaledRefEndY >>= -iDeltaRes; }494 495 assert( uiScaledRefEndY >= uiContDStartEndOffset );496 Int iAlignedRefEndY = (Int)uiScaledRefEndY - (Int)uiContDStartEndOffset;497 498 // special for straight horizontal wedge499 if( iL_DeltaY == 0 )500 {501 ruhXs = 0;502 ruhYs = (UChar)iAlignedRefEndY;503 504 Int iYe = iAlignedRefEndY - iDeltaEnd;505 if( iYe < 0 )506 {507 ruhXe = (UChar)min( max( (iContDMaxPos + iYe), 0 ), iContDMaxPos );508 ruhYe = 0;509 510 std::swap( ruhXs, ruhXe );511 std::swap( ruhYs, ruhYe );512 return;513 }514 else if( iYe > iContDMaxPos )515 {516 ruhXe = (UChar)min( max( (iContDMaxPos - (iYe - iContDMaxPos)), 0 ), iContDMaxPos );517 ruhYe = (UChar)iContDMaxPos;518 519 return;520 }521 else522 {523 ruhXe = (UChar)iContDMaxPos;524 ruhYe = (UChar)iYe;525 526 std::swap( ruhXs, ruhXe );527 std::swap( ruhYs, ruhYe );528 return;529 }530 }531 532 // special for straight vertical short right line533 if( iL_DeltaX == 0 )534 {535 switch( (UInt)getOri() )536 {537 case( 1 ):538 {539 ruhXs = 0;540 ruhYs = (UChar)(iAlignedRefEndY+1);541 ruhXe = (UChar)min( max( iDeltaEnd, 0 ), iContDMaxPos );542 ruhYe = (UChar)iContDMaxPos;543 544 return;545 }546 case( 2 ):547 {548 ruhXs = 0;549 ruhYs = (UChar)(iAlignedRefEndY-1);550 ruhXe = (UChar)min( max( -iDeltaEnd, 0 ), iContDMaxPos );551 ruhYe = 0;552 553 std::swap( ruhXs, ruhXe );554 std::swap( ruhYs, ruhYe );555 return;556 }557 default:558 {559 assert( 0 );560 return;561 }562 }563 }564 565 // set start point depending on slope566 if( abs( iL_DeltaY ) >= abs( iL_DeltaX ) ) { if( iL_DeltaY < 0 ) { ruhYs = (UChar)(iAlignedRefEndY-1); ruhXs = 0; }567 if( iL_DeltaY > 0 ) { ruhYs = (UChar)(iAlignedRefEndY+1); ruhXs = 0; } }568 else { ruhYs = (UChar)(iAlignedRefEndY); ruhXs = 0; }569 570 // calc end point and determine orientation571 Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iContDMaxPos * ((Double)iL_DeltaY / (Double)iL_DeltaX) );572 573 if( iVirtualEndY < 0 )574 {575 Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iL_DeltaX / (Double)iL_DeltaY) ) - iDeltaEnd;576 if( iXe < (Int)uiContDStartEndMax )577 {578 ruhXe = (UChar)max( iXe, 0 );579 ruhYe = 0;580 581 std::swap( ruhXs, ruhXe );582 std::swap( ruhYs, ruhYe );583 return;584 }585 else586 {587 ruhXe = (UChar)iContDMaxPos;588 ruhYe = (UChar)min( (iXe - iContDMaxPos), iContDMaxPos );589 590 std::swap( ruhXs, ruhXe );591 std::swap( ruhYs, ruhYe );592 return;593 }594 }595 else if( iVirtualEndY > iContDMaxPos )596 {597 Int iXe = roftoi( (Double)(iContDMaxPos - (Int)ruhYs ) * ((Double)iL_DeltaX / (Double)iL_DeltaY) ) + iDeltaEnd;598 if( iXe < (Int)uiContDStartEndMax )599 {600 ruhXe = (UChar)max( iXe, 0 );601 ruhYe = (UChar)iContDMaxPos;602 603 return;604 }605 else606 {607 ruhXe = (UChar)iContDMaxPos;608 ruhYe = (UChar)max( (iContDMaxPos - (iXe - iContDMaxPos)), 0 );609 610 std::swap( ruhXs, ruhXe );611 std::swap( ruhYs, ruhYe );612 return;613 }614 }615 else616 {617 Int iYe = iVirtualEndY - iDeltaEnd;618 if( iYe < 0 )619 {620 ruhXe = (UChar)max( (iContDMaxPos + iYe), 0 );621 ruhYe = 0;622 623 std::swap( ruhXs, ruhXe );624 std::swap( ruhYs, ruhYe );625 return;626 }627 else if( iYe > iContDMaxPos )628 {629 ruhXe = (UChar)max( (iContDMaxPos - (iYe - iContDMaxPos)), 0 );630 ruhYe = (UChar)iContDMaxPos;631 632 return;633 }634 else635 {636 ruhXe = (UChar)iContDMaxPos;637 ruhYe = (UChar)iYe;638 639 std::swap( ruhXs, ruhXe );640 std::swap( ruhYs, ruhYe );641 return;642 }643 }644 }645 #endif646 647 177 Void TComWedgelet::xGenerateWedgePattern() 648 178 {
Note: See TracChangeset for help on using the changeset viewer.