Changeset 1243 in SHVCSoftware for branches/SHM-dev
- Timestamp:
- 13 Jul 2015, 22:49:06 (9 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibEncoder
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp
r1242 r1243 1504 1504 rpcTempCU->setChromaQpAdjSubParts( rpcTempCU->getCUTransquantBypass(0) ? 0 : m_ChromaQpAdjIdc, 0, uiDepth ); 1505 1505 1506 Bool bSeparateLumaChroma = true; // choose estimation mode1507 1508 Distortion uiPreCalcDistC = 0;1509 if (rpcBestCU->getPic()->getChromaFormat()==CHROMA_400)1510 {1511 bSeparateLumaChroma=true;1512 }1513 1514 1506 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE]; 1515 1507 1516 if( !bSeparateLumaChroma ) 1517 { 1518 // after this function, the direction will be PLANAR, DC, HOR or VER 1519 // however, if Luma ends up being one of those, the chroma dir must be later changed to DM_CHROMA. 1520 m_pcPredSearch->preestChromaPredMode( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth] ); 1521 } 1522 m_pcPredSearch->estIntraPredQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], resiLuma, uiPreCalcDistC, bSeparateLumaChroma DEBUG_STRING_PASS_INTO(sTest) ); 1508 m_pcPredSearch->estIntraPredLumaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], resiLuma DEBUG_STRING_PASS_INTO(sTest) ); 1523 1509 1524 1510 m_ppcRecoYuvTemp[uiDepth]->copyToPicComponent(COMPONENT_Y, rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getCtuRsAddr(), rpcTempCU->getZorderIdxInCtu() ); … … 1526 1512 if (rpcBestCU->getPic()->getChromaFormat()!=CHROMA_400) 1527 1513 { 1528 m_pcPredSearch->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], resiLuma , uiPreCalcDistCDEBUG_STRING_PASS_INTO(sTest) );1514 m_pcPredSearch->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], resiLuma DEBUG_STRING_PASS_INTO(sTest) ); 1529 1515 } 1530 1516 -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
r1235 r1243 1362 1362 1363 1363 Void 1364 TEncSearch::xRecurIntraCodingQT(Bool bLumaOnly, 1365 TComYuv* pcOrgYuv, 1366 TComYuv* pcPredYuv, 1367 TComYuv* pcResiYuv, 1368 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE], 1369 Distortion& ruiDistY, 1370 Distortion& ruiDistC, 1364 TEncSearch::xRecurIntraCodingLumaQT(TComYuv* pcOrgYuv, 1365 TComYuv* pcPredYuv, 1366 TComYuv* pcResiYuv, 1367 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE], 1368 Distortion& ruiDistY, 1371 1369 #if HHI_RQT_INTRA_SPEEDUP 1372 Bool bCheckFirst,1373 #endif 1374 Double& dRDCost,1375 TComTU& rTu1376 DEBUG_STRING_FN_DECLARE(sDebug))1370 Bool bCheckFirst, 1371 #endif 1372 Double& dRDCost, 1373 TComTU& rTu 1374 DEBUG_STRING_FN_DECLARE(sDebug)) 1377 1375 { 1378 1376 TComDataCU *pcCU = rTu.getCU(); … … 1383 1381 Bool bCheckFull = ( uiLog2TrSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ); 1384 1382 Bool bCheckSplit = ( uiLog2TrSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); 1385 const UInt numValidComp = (bLumaOnly) ? 1 : pcOrgYuv->getNumberValidComponents();1386 1383 1387 1384 Pel resiLumaSplit [NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE]; … … 1427 1424 #endif 1428 1425 Double dSingleCost = MAX_DOUBLE; 1426 Distortion uiSingleDistLuma = 0; 1427 UInt uiSingleCbfLuma = 0; 1429 1428 Distortion uiSingleDist[MAX_NUM_CHANNEL_TYPE] = {0,0}; 1430 1429 UInt uiSingleCbf[MAX_NUM_COMPONENT] = {0,0,0}; … … 1446 1445 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_QT_TRAFO_ROOT ] ); 1447 1446 1448 Distortion singleDistTmp [MAX_NUM_CHANNEL_TYPE] = { 0, 0 };1449 UInt singleCbfTmp [MAX_NUM_COMPONENT] = { 0, 0, 0 };1447 Distortion singleDistTmpLuma = 0; 1448 UInt singleCbfTmpLuma = 0; 1450 1449 Double singleCostTmp = 0; 1451 1450 Int firstCheckId = 0; … … 1455 1454 DEBUG_STRING_NEW(sModeString) 1456 1455 Int default0Save1Load2 = 0; 1457 singleDistTmp [0]=singleDistTmp[1]=0;1456 singleDistTmpLuma=0; 1458 1457 if(modeId == firstCheckId) 1459 1458 { … … 1465 1464 } 1466 1465 1467 for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++) 1468 { 1469 const ComponentID compID = ComponentID(ch); 1470 if (rTu.ProcessComponentSection(compID)) 1471 { 1472 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(compID); 1473 pcCU->setTransformSkipSubParts ( modeId, compID, uiAbsPartIdx, totalAdjustedDepthChan ); 1474 1475 xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, singleDistTmp[toChannelType(compID)], compID, rTu DEBUG_STRING_PASS_INTO(sModeString), default0Save1Load2 ); 1476 } 1477 singleCbfTmp[compID] = pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepth ); 1478 } 1466 if (rTu.ProcessComponentSection(COMPONENT_Y)) 1467 { 1468 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(COMPONENT_Y); 1469 pcCU->setTransformSkipSubParts ( modeId, COMPONENT_Y, uiAbsPartIdx, totalAdjustedDepthChan ); 1470 1471 xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, singleDistTmpLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sModeString), default0Save1Load2 ); 1472 } 1473 singleCbfTmpLuma = pcCU->getCbf( uiAbsPartIdx, COMPONENT_Y, uiTrDepth ); 1474 1479 1475 //----- determine rate and r-d cost ----- 1480 if(modeId == 1 && singleCbfTmp [COMPONENT_Y]== 0)1476 if(modeId == 1 && singleCbfTmpLuma == 0) 1481 1477 { 1482 1478 //In order not to code TS flag when cbf is zero, the case for TS with cbf being zero is forbidden. … … 1485 1481 else 1486 1482 { 1487 UInt uiSingleBits = xGetIntraBitsQT( rTu, true, !bLumaOnly, false );1488 singleCostTmp = m_pcRdCost->calcRdCost( uiSingleBits, singleDistTmp [CHANNEL_TYPE_LUMA] + singleDistTmp[CHANNEL_TYPE_CHROMA]);1483 UInt uiSingleBits = xGetIntraBitsQT( rTu, true, false, false ); 1484 singleCostTmp = m_pcRdCost->calcRdCost( uiSingleBits, singleDistTmpLuma ); 1489 1485 } 1490 1486 if(singleCostTmp < dSingleCost) … … 1492 1488 DEBUG_STRING_SWAP(sDebug, sModeString) 1493 1489 dSingleCost = singleCostTmp; 1494 uiSingleDist[CHANNEL_TYPE_LUMA] = singleDistTmp[CHANNEL_TYPE_LUMA]; 1495 uiSingleDist[CHANNEL_TYPE_CHROMA] = singleDistTmp[CHANNEL_TYPE_CHROMA]; 1496 for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) 1497 uiSingleCbf[ch] = singleCbfTmp[ch]; 1490 uiSingleDistLuma = singleDistTmpLuma; 1491 uiSingleCbfLuma = singleCbfTmpLuma; 1498 1492 1499 1493 bestModeId[COMPONENT_Y] = modeId; 1500 1494 if(bestModeId[COMPONENT_Y] == firstCheckId) 1501 1495 { 1502 xStoreIntraResultQT(COMPONENT_Y, bLumaOnly?COMPONENT_Y:COMPONENT_Cr,rTu );1496 xStoreIntraResultQT(COMPONENT_Y, rTu ); 1503 1497 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 1504 1498 } … … 1523 1517 } 1524 1518 1525 for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++) 1526 { 1527 const ComponentID compID=ComponentID(ch); 1528 if (rTu.ProcessComponentSection(compID)) 1529 { 1530 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(compID); 1531 pcCU ->setTransformSkipSubParts ( bestModeId[COMPONENT_Y], compID, uiAbsPartIdx, totalAdjustedDepthChan ); 1532 } 1519 if (rTu.ProcessComponentSection(COMPONENT_Y)) 1520 { 1521 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(COMPONENT_Y); 1522 pcCU ->setTransformSkipSubParts ( bestModeId[COMPONENT_Y], COMPONENT_Y, uiAbsPartIdx, totalAdjustedDepthChan ); 1533 1523 } 1534 1524 1535 1525 if(bestModeId[COMPONENT_Y] == firstCheckId) 1536 1526 { 1537 xLoadIntraResultQT(COMPONENT_Y, bLumaOnly?COMPONENT_Y:COMPONENT_Cr, rTu ); 1538 for(UInt ch=COMPONENT_Y; ch< numValidComp; ch++) 1539 { 1540 const ComponentID compID=ComponentID(ch); 1541 if (rTu.ProcessComponentSection(compID)) 1542 pcCU->setCbfSubParts ( uiSingleCbf[compID] << uiTrDepth, compID, uiAbsPartIdx, rTu.GetTransformDepthTotalAdj(compID) ); 1543 } 1527 xLoadIntraResultQT(COMPONENT_Y, rTu ); 1528 if (rTu.ProcessComponentSection(COMPONENT_Y)) 1529 pcCU->setCbfSubParts ( uiSingleCbfLuma << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, rTu.GetTransformDepthTotalAdj(COMPONENT_Y) ); 1544 1530 1545 1531 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 1546 }1547 1548 if( !bLumaOnly )1549 {1550 bestModeId[COMPONENT_Cb] = bestModeId[COMPONENT_Cr] = bestModeId[COMPONENT_Y];1551 if (rTu.ProcessComponentSection(COMPONENT_Cb) && bestModeId[COMPONENT_Y] == 1)1552 {1553 //In order not to code TS flag when cbf is zero, the case for TS with cbf being zero is forbidden.1554 for (UInt ch=COMPONENT_Cb; ch<numValidComp; ch++)1555 {1556 if (uiSingleCbf[ch] == 0)1557 {1558 const ComponentID compID=ComponentID(ch);1559 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(compID);1560 pcCU ->setTransformSkipSubParts ( 0, compID, uiAbsPartIdx, totalAdjustedDepthChan);1561 bestModeId[ch] = 0;1562 }1563 }1564 }1565 1532 } 1566 1533 } … … 1574 1541 //----- code luma/chroma block with given intra prediction mode and store Cbf----- 1575 1542 dSingleCost = 0.0; 1576 for (UInt ch=COMPONENT_Y; ch<numValidComp; ch++) 1577 { 1578 const ComponentID compID = ComponentID(ch); 1579 1580 if (rTu.ProcessComponentSection(compID)) 1581 { 1582 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(compID); 1583 pcCU ->setTransformSkipSubParts ( 0, compID, uiAbsPartIdx, totalAdjustedDepthChan ); 1584 } 1585 1586 xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDist[toChannelType(compID)], compID, rTu DEBUG_STRING_PASS_INTO(sDebug)); 1587 1588 if( bCheckSplit ) 1589 { 1590 uiSingleCbf[compID] = pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepth ); 1591 } 1543 if (rTu.ProcessComponentSection(COMPONENT_Y)) 1544 { 1545 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(COMPONENT_Y); 1546 pcCU ->setTransformSkipSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, totalAdjustedDepthChan ); 1547 } 1548 1549 xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDistLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sDebug)); 1550 1551 if( bCheckSplit ) 1552 { 1553 uiSingleCbfLuma = pcCU->getCbf( uiAbsPartIdx, COMPONENT_Y, uiTrDepth ); 1592 1554 } 1593 1555 //----- determine rate and r-d cost ----- 1594 UInt uiSingleBits = xGetIntraBitsQT( rTu, true, !bLumaOnly, false );1556 UInt uiSingleBits = xGetIntraBitsQT( rTu, true, false, false ); 1595 1557 1596 1558 if(m_pcEncCfg->getRDpenalty() && (uiLog2TrSize==5) && !isIntraSlice) … … 1599 1561 } 1600 1562 1601 dSingleCost = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDist [CHANNEL_TYPE_LUMA] + uiSingleDist[CHANNEL_TYPE_CHROMA]);1563 dSingleCost = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDistLuma ); 1602 1564 1603 1565 if (pcCU->getSlice()->getPPS()->getUseCrossComponentPrediction()) … … 1629 1591 } 1630 1592 //----- code splitted block ----- 1631 Double dSplitCost 1632 Distortion uiSplitDist [MAX_NUM_CHANNEL_TYPE] = {0,0};1633 UInt uiSplitCbf [MAX_NUM_COMPONENT] = {0,0,0};1593 Double dSplitCost = 0.0; 1594 Distortion uiSplitDistLuma = 0; 1595 UInt uiSplitCbfLuma = 0; 1634 1596 1635 1597 TComTURecurse tuRecurseChild(rTu, false); … … 1639 1601 DEBUG_STRING_NEW(sChild) 1640 1602 #if HHI_RQT_INTRA_SPEEDUP 1641 xRecurIntraCoding QT( bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSplit, uiSplitDist[0], uiSplitDist[1], bCheckFirst, dSplitCost, tuRecurseChild DEBUG_STRING_PASS_INTO(sChild) );1603 xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSplit, uiSplitDistLuma, bCheckFirst, dSplitCost, tuRecurseChild DEBUG_STRING_PASS_INTO(sChild) ); 1642 1604 #else 1643 xRecurIntraCoding QT( bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSplit, uiSplitDist[0], uiSplitDist[1], dSplitCost, tuRecurseChild DEBUG_STRING_PASS_INTO(sChild) );1605 xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSplit, uiSplitDistLuma, dSplitCost, tuRecurseChild DEBUG_STRING_PASS_INTO(sChild) ); 1644 1606 #endif 1645 1607 DEBUG_STRING_APPEND(sSplit, sChild) 1646 for(UInt ch=0; ch<numValidComp; ch++) 1647 { 1648 uiSplitCbf[ch] |= pcCU->getCbf( tuRecurseChild.GetAbsPartIdxTU(), ComponentID(ch), tuRecurseChild.GetTransformDepthRel() ); 1649 } 1608 uiSplitCbfLuma |= pcCU->getCbf( tuRecurseChild.GetAbsPartIdxTU(), COMPONENT_Y, tuRecurseChild.GetTransformDepthRel() ); 1650 1609 } while (tuRecurseChild.nextSection(rTu) ); 1651 1610 1652 1611 UInt uiPartsDiv = rTu.GetAbsPartIdxNumParts(); 1653 for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++) 1654 { 1655 if (uiSplitCbf[ch]) 1612 { 1613 if (uiSplitCbfLuma) 1656 1614 { 1657 1615 const UInt flag=1<<uiTrDepth; 1658 const ComponentID compID=ComponentID(ch); 1659 UChar *pBase=pcCU->getCbf( compID ); 1616 UChar *pBase=pcCU->getCbf( COMPONENT_Y ); 1660 1617 for( UInt uiOffs = 0; uiOffs < uiPartsDiv; uiOffs++ ) 1661 1618 { … … 1668 1625 1669 1626 //----- determine rate and r-d cost ----- 1670 UInt uiSplitBits = xGetIntraBitsQT( rTu, true, !bLumaOnly, false );1671 dSplitCost = m_pcRdCost->calcRdCost( uiSplitBits, uiSplitDist [CHANNEL_TYPE_LUMA] + uiSplitDist[CHANNEL_TYPE_CHROMA]);1627 UInt uiSplitBits = xGetIntraBitsQT( rTu, true, false, false ); 1628 dSplitCost = m_pcRdCost->calcRdCost( uiSplitBits, uiSplitDistLuma ); 1672 1629 1673 1630 //===== compare and set best ===== … … 1676 1633 //--- update cost --- 1677 1634 DEBUG_STRING_SWAP(sSplit, sDebug) 1678 ruiDistY += uiSplitDist[CHANNEL_TYPE_LUMA]; 1679 ruiDistC += uiSplitDist[CHANNEL_TYPE_CHROMA]; 1635 ruiDistY += uiSplitDistLuma; 1680 1636 dRDCost += dSplitCost; 1681 1637 … … 1701 1657 //--- set transform index and Cbf values --- 1702 1658 pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiFullDepth ); 1703 for(UInt ch=0; ch<numValidComp; ch++) 1704 { 1705 const ComponentID compID=ComponentID(ch); 1706 const TComRectangle &tuRect=rTu.getRect(compID); 1707 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(compID); 1708 pcCU->setCbfSubParts ( uiSingleCbf[compID] << uiTrDepth, compID, uiAbsPartIdx, totalAdjustedDepthChan ); 1709 pcCU ->setTransformSkipSubParts ( bestModeId[compID], compID, uiAbsPartIdx, totalAdjustedDepthChan ); 1710 1711 //--- set reconstruction for next intra prediction blocks --- 1712 const UInt uiQTLayer = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - uiLog2TrSize; 1713 const UInt uiZOrder = pcCU->getZorderIdxInCtu() + uiAbsPartIdx; 1714 const UInt uiWidth = tuRect.width; 1715 const UInt uiHeight = tuRect.height; 1716 Pel* piSrc = m_pcQTTempTComYuv[ uiQTLayer ].getAddr( compID, uiAbsPartIdx ); 1717 UInt uiSrcStride = m_pcQTTempTComYuv[ uiQTLayer ].getStride ( compID ); 1718 Pel* piDes = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), uiZOrder ); 1719 UInt uiDesStride = pcCU->getPic()->getPicYuvRec()->getStride ( compID ); 1720 1721 for( UInt uiY = 0; uiY < uiHeight; uiY++, piSrc += uiSrcStride, piDes += uiDesStride ) 1722 { 1723 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1724 { 1725 piDes[ uiX ] = piSrc[ uiX ]; 1726 } 1727 } 1728 } 1729 } 1730 ruiDistY += uiSingleDist[CHANNEL_TYPE_LUMA]; 1731 ruiDistC += uiSingleDist[CHANNEL_TYPE_CHROMA]; 1659 const TComRectangle &tuRect=rTu.getRect(COMPONENT_Y); 1660 const UInt totalAdjustedDepthChan = rTu.GetTransformDepthTotalAdj(COMPONENT_Y); 1661 pcCU->setCbfSubParts ( uiSingleCbfLuma << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, totalAdjustedDepthChan ); 1662 pcCU ->setTransformSkipSubParts ( bestModeId[COMPONENT_Y], COMPONENT_Y, uiAbsPartIdx, totalAdjustedDepthChan ); 1663 1664 //--- set reconstruction for next intra prediction blocks --- 1665 const UInt uiQTLayer = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - uiLog2TrSize; 1666 const UInt uiZOrder = pcCU->getZorderIdxInCtu() + uiAbsPartIdx; 1667 const UInt uiWidth = tuRect.width; 1668 const UInt uiHeight = tuRect.height; 1669 Pel* piSrc = m_pcQTTempTComYuv[ uiQTLayer ].getAddr( COMPONENT_Y, uiAbsPartIdx ); 1670 UInt uiSrcStride = m_pcQTTempTComYuv[ uiQTLayer ].getStride ( COMPONENT_Y ); 1671 Pel* piDes = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), uiZOrder ); 1672 UInt uiDesStride = pcCU->getPic()->getPicYuvRec()->getStride ( COMPONENT_Y ); 1673 1674 for( UInt uiY = 0; uiY < uiHeight; uiY++, piSrc += uiSrcStride, piDes += uiDesStride ) 1675 { 1676 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1677 { 1678 piDes[ uiX ] = piSrc[ uiX ]; 1679 } 1680 } 1681 } 1682 ruiDistY += uiSingleDistLuma; 1732 1683 dRDCost += dSingleCost; 1733 1684 } … … 1735 1686 1736 1687 Void 1737 TEncSearch::xSetIntraResultQT(Bool bLumaOnly, 1738 TComYuv* pcRecoYuv, 1739 TComTU &rTu) 1688 TEncSearch::xSetIntraResultLumaQT(TComYuv* pcRecoYuv, TComTU &rTu) 1740 1689 { 1741 1690 TComDataCU *pcCU = rTu.getCU(); … … 1748 1697 UInt uiQTLayer = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - uiLog2TrSize; 1749 1698 1750 Bool bSkipChroma = !rTu.ProcessChannelSection(CHANNEL_TYPE_CHROMA);1751 1752 1699 //===== copy transform coefficients ===== 1753 1700 1754 const UInt numChannelsToProcess = (bLumaOnly || bSkipChroma) ? 1 : ::getNumberValidComponents(pcCU->getPic()->getChromaFormat()); 1755 for (UInt ch=0; ch<numChannelsToProcess; ch++) 1756 { 1757 const ComponentID compID = ComponentID(ch); 1758 const TComRectangle &tuRect=rTu.getRect(compID); 1759 const UInt coeffOffset = rTu.getCoefficientOffset(compID); 1760 const UInt numCoeffInBlock = tuRect.width * tuRect.height; 1761 1762 if (numCoeffInBlock!=0) 1763 { 1764 const TCoeff* srcCoeff = m_ppcQTTempCoeff[compID][uiQTLayer] + coeffOffset; 1765 TCoeff* destCoeff = pcCU->getCoeff(compID) + coeffOffset; 1766 ::memcpy( destCoeff, srcCoeff, sizeof(TCoeff)*numCoeffInBlock ); 1701 const TComRectangle &tuRect=rTu.getRect(COMPONENT_Y); 1702 const UInt coeffOffset = rTu.getCoefficientOffset(COMPONENT_Y); 1703 const UInt numCoeffInBlock = tuRect.width * tuRect.height; 1704 1705 if (numCoeffInBlock!=0) 1706 { 1707 const TCoeff* srcCoeff = m_ppcQTTempCoeff[COMPONENT_Y][uiQTLayer] + coeffOffset; 1708 TCoeff* destCoeff = pcCU->getCoeff(COMPONENT_Y) + coeffOffset; 1709 ::memcpy( destCoeff, srcCoeff, sizeof(TCoeff)*numCoeffInBlock ); 1767 1710 #if ADAPTIVE_QP_SELECTION 1768 const TCoeff* srcArlCoeff = m_ppcQTTempArlCoeff[compID][ uiQTLayer ] + coeffOffset; 1769 TCoeff* destArlCoeff = pcCU->getArlCoeff (compID) + coeffOffset; 1770 ::memcpy( destArlCoeff, srcArlCoeff, sizeof( TCoeff ) * numCoeffInBlock ); 1771 #endif 1772 m_pcQTTempTComYuv[ uiQTLayer ].copyPartToPartComponent( compID, pcRecoYuv, uiAbsPartIdx, tuRect.width, tuRect.height ); 1773 } 1774 } // End of channel loop 1711 const TCoeff* srcArlCoeff = m_ppcQTTempArlCoeff[COMPONENT_Y][ uiQTLayer ] + coeffOffset; 1712 TCoeff* destArlCoeff = pcCU->getArlCoeff (COMPONENT_Y) + coeffOffset; 1713 ::memcpy( destArlCoeff, srcArlCoeff, sizeof( TCoeff ) * numCoeffInBlock ); 1714 #endif 1715 m_pcQTTempTComYuv[ uiQTLayer ].copyPartToPartComponent( COMPONENT_Y, pcRecoYuv, uiAbsPartIdx, tuRect.width, tuRect.height ); 1716 } 1775 1717 1776 1718 } … … 1780 1722 do 1781 1723 { 1782 xSetIntraResult QT( bLumaOnly,pcRecoYuv, tuRecurseChild );1724 xSetIntraResultLumaQT( pcRecoYuv, tuRecurseChild ); 1783 1725 } while (tuRecurseChild.nextSection(rTu)); 1784 1726 } … … 1787 1729 1788 1730 Void 1789 TEncSearch::xStoreIntraResultQT(const ComponentID first, 1790 const ComponentID lastIncl, 1791 TComTU &rTu ) 1731 TEncSearch::xStoreIntraResultQT(const ComponentID compID, TComTU &rTu ) 1792 1732 { 1793 1733 TComDataCU *pcCU=rTu.getCU(); … … 1795 1735 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); 1796 1736 const UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); 1797 if ( first==COMPONENT_Y || uiTrMode == uiTrDepth )1737 if ( compID==COMPONENT_Y || uiTrMode == uiTrDepth ) 1798 1738 { 1799 1739 assert(uiTrMode == uiTrDepth); … … 1801 1741 const UInt uiQTLayer = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - uiLog2TrSize; 1802 1742 1803 1804 for(UInt compID_=first; compID_<=lastIncl; compID_++) 1805 { 1806 ComponentID compID=ComponentID(compID_); 1807 if (rTu.ProcessComponentSection(compID)) 1808 { 1809 const TComRectangle &tuRect=rTu.getRect(compID); 1810 1811 //===== copy transform coefficients ===== 1812 const UInt uiNumCoeff = tuRect.width * tuRect.height; 1813 TCoeff* pcCoeffSrc = m_ppcQTTempCoeff[compID] [ uiQTLayer ] + rTu.getCoefficientOffset(compID); 1814 TCoeff* pcCoeffDst = m_pcQTTempTUCoeff[compID]; 1815 1816 ::memcpy( pcCoeffDst, pcCoeffSrc, sizeof( TCoeff ) * uiNumCoeff ); 1743 if (rTu.ProcessComponentSection(compID)) 1744 { 1745 const TComRectangle &tuRect=rTu.getRect(compID); 1746 1747 //===== copy transform coefficients ===== 1748 const UInt uiNumCoeff = tuRect.width * tuRect.height; 1749 TCoeff* pcCoeffSrc = m_ppcQTTempCoeff[compID] [ uiQTLayer ] + rTu.getCoefficientOffset(compID); 1750 TCoeff* pcCoeffDst = m_pcQTTempTUCoeff[compID]; 1751 1752 ::memcpy( pcCoeffDst, pcCoeffSrc, sizeof( TCoeff ) * uiNumCoeff ); 1817 1753 #if ADAPTIVE_QP_SELECTION 1818 TCoeff* pcArlCoeffSrc = m_ppcQTTempArlCoeff[compID] [ uiQTLayer ] + rTu.getCoefficientOffset(compID); 1819 TCoeff* pcArlCoeffDst = m_ppcQTTempTUArlCoeff[compID]; 1820 ::memcpy( pcArlCoeffDst, pcArlCoeffSrc, sizeof( TCoeff ) * uiNumCoeff ); 1821 #endif 1822 //===== copy reconstruction ===== 1823 m_pcQTTempTComYuv[ uiQTLayer ].copyPartToPartComponent( compID, &m_pcQTTempTransformSkipTComYuv, uiAbsPartIdx, tuRect.width, tuRect.height ); 1824 } 1754 TCoeff* pcArlCoeffSrc = m_ppcQTTempArlCoeff[compID] [ uiQTLayer ] + rTu.getCoefficientOffset(compID); 1755 TCoeff* pcArlCoeffDst = m_ppcQTTempTUArlCoeff[compID]; 1756 ::memcpy( pcArlCoeffDst, pcArlCoeffSrc, sizeof( TCoeff ) * uiNumCoeff ); 1757 #endif 1758 //===== copy reconstruction ===== 1759 m_pcQTTempTComYuv[ uiQTLayer ].copyPartToPartComponent( compID, &m_pcQTTempTransformSkipTComYuv, uiAbsPartIdx, tuRect.width, tuRect.height ); 1825 1760 } 1826 1761 } … … 1829 1764 1830 1765 Void 1831 TEncSearch::xLoadIntraResultQT(const ComponentID first, 1832 const ComponentID lastIncl, 1833 TComTU &rTu) 1766 TEncSearch::xLoadIntraResultQT(const ComponentID compID, TComTU &rTu) 1834 1767 { 1835 1768 TComDataCU *pcCU=rTu.getCU(); … … 1837 1770 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); 1838 1771 const UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); 1839 if ( first==COMPONENT_Y || uiTrMode == uiTrDepth )1772 if ( compID==COMPONENT_Y || uiTrMode == uiTrDepth ) 1840 1773 { 1841 1774 assert(uiTrMode == uiTrDepth); … … 1844 1777 const UInt uiZOrder = pcCU->getZorderIdxInCtu() + uiAbsPartIdx; 1845 1778 1846 for(UInt compID_=first; compID_<=lastIncl; compID_++) 1847 { 1848 ComponentID compID=ComponentID(compID_); 1849 if (rTu.ProcessComponentSection(compID)) 1850 { 1851 const TComRectangle &tuRect=rTu.getRect(compID); 1852 1853 //===== copy transform coefficients ===== 1854 const UInt uiNumCoeff = tuRect.width * tuRect.height; 1855 TCoeff* pcCoeffDst = m_ppcQTTempCoeff[compID] [ uiQTLayer ] + rTu.getCoefficientOffset(compID); 1856 TCoeff* pcCoeffSrc = m_pcQTTempTUCoeff[compID]; 1857 1858 ::memcpy( pcCoeffDst, pcCoeffSrc, sizeof( TCoeff ) * uiNumCoeff ); 1779 if (rTu.ProcessComponentSection(compID)) 1780 { 1781 const TComRectangle &tuRect=rTu.getRect(compID); 1782 1783 //===== copy transform coefficients ===== 1784 const UInt uiNumCoeff = tuRect.width * tuRect.height; 1785 TCoeff* pcCoeffDst = m_ppcQTTempCoeff[compID] [ uiQTLayer ] + rTu.getCoefficientOffset(compID); 1786 TCoeff* pcCoeffSrc = m_pcQTTempTUCoeff[compID]; 1787 1788 ::memcpy( pcCoeffDst, pcCoeffSrc, sizeof( TCoeff ) * uiNumCoeff ); 1859 1789 #if ADAPTIVE_QP_SELECTION 1860 TCoeff* pcArlCoeffDst = m_ppcQTTempArlCoeff[compID] [ uiQTLayer ] + rTu.getCoefficientOffset(compID); 1861 TCoeff* pcArlCoeffSrc = m_ppcQTTempTUArlCoeff[compID]; 1862 ::memcpy( pcArlCoeffDst, pcArlCoeffSrc, sizeof( TCoeff ) * uiNumCoeff ); 1863 #endif 1864 //===== copy reconstruction ===== 1865 m_pcQTTempTransformSkipTComYuv.copyPartToPartComponent( compID, &m_pcQTTempTComYuv[ uiQTLayer ], uiAbsPartIdx, tuRect.width, tuRect.height ); 1866 1867 Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), uiZOrder ); 1868 UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (compID); 1869 Pel* piRecQt = m_pcQTTempTComYuv[ uiQTLayer ].getAddr( compID, uiAbsPartIdx ); 1870 UInt uiRecQtStride = m_pcQTTempTComYuv[ uiQTLayer ].getStride (compID); 1871 UInt uiWidth = tuRect.width; 1872 UInt uiHeight = tuRect.height; 1873 Pel* pRecQt = piRecQt; 1874 Pel* pRecIPred = piRecIPred; 1875 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 1876 { 1877 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1878 { 1879 pRecIPred[ uiX ] = pRecQt [ uiX ]; 1880 } 1881 pRecQt += uiRecQtStride; 1882 pRecIPred += uiRecIPredStride; 1883 } 1790 TCoeff* pcArlCoeffDst = m_ppcQTTempArlCoeff[compID] [ uiQTLayer ] + rTu.getCoefficientOffset(compID); 1791 TCoeff* pcArlCoeffSrc = m_ppcQTTempTUArlCoeff[compID]; 1792 ::memcpy( pcArlCoeffDst, pcArlCoeffSrc, sizeof( TCoeff ) * uiNumCoeff ); 1793 #endif 1794 //===== copy reconstruction ===== 1795 m_pcQTTempTransformSkipTComYuv.copyPartToPartComponent( compID, &m_pcQTTempTComYuv[ uiQTLayer ], uiAbsPartIdx, tuRect.width, tuRect.height ); 1796 1797 Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), uiZOrder ); 1798 UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (compID); 1799 Pel* piRecQt = m_pcQTTempTComYuv[ uiQTLayer ].getAddr( compID, uiAbsPartIdx ); 1800 UInt uiRecQtStride = m_pcQTTempTComYuv[ uiQTLayer ].getStride (compID); 1801 UInt uiWidth = tuRect.width; 1802 UInt uiHeight = tuRect.height; 1803 Pel* pRecQt = piRecQt; 1804 Pel* pRecIPred = piRecIPred; 1805 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 1806 { 1807 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1808 { 1809 pRecIPred[ uiX ] = pRecQt [ uiX ]; 1810 } 1811 pRecQt += uiRecQtStride; 1812 pRecIPred += uiRecIPredStride; 1884 1813 } 1885 1814 } … … 2088 2017 if (!isOneMode && !isLastMode) 2089 2018 { 2090 xStoreIntraResultQT(compID, compID,TUIterator);2019 xStoreIntraResultQT(compID, TUIterator); 2091 2020 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ uiFullDepth ][ CI_TEMP_BEST ] ); 2092 2021 } … … 2102 2031 if(bestModeId < totalModesToTest) 2103 2032 { 2104 xLoadIntraResultQT(compID, compID,TUIterator);2033 xLoadIntraResultQT(compID, TUIterator); 2105 2034 pcCU->setCbfPartRange( singleCbfC << uiTrDepth, compID, subTUAbsPartIdx, partIdxesPerSubTU ); 2106 2035 … … 2210 2139 2211 2140 Void 2212 TEncSearch::preestChromaPredMode( TComDataCU* pcCU, 2213 TComYuv* pcOrgYuv, 2214 TComYuv* pcPredYuv ) 2215 { 2216 2217 //===== loop over partitions ===== 2218 const UInt uiInitTrDepth = pcCU->getPartitionSize(0) != SIZE_2Nx2N && enable4ChromaPUsInIntraNxNCU(pcOrgYuv->getChromaFormat()) ? 1 : 0; 2219 TComTURecurse tuRecurseCU(pcCU, 0); 2220 TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); 2221 const ChromaFormat chFmt = tuRecurseWithPU.GetChromaFormat(); 2222 Bool bFilterEnabled=filterIntraReferenceSamples(CHANNEL_TYPE_CHROMA, chFmt, pcCU->getSlice()->getSPS()->getDisableIntraReferenceSmoothing()); 2223 2224 do 2225 { 2226 if (tuRecurseWithPU.ProcessChannelSection(CHANNEL_TYPE_CHROMA)) 2227 { 2228 const TComRectangle &rect=tuRecurseWithPU.getRect(COMPONENT_Cb); 2229 const UInt uiWidth = rect.width; 2230 const UInt uiHeight = rect.height; 2231 const UInt partIdx = tuRecurseWithPU.GetAbsPartIdxCU(); 2232 const UInt uiStride = pcOrgYuv ->getStride(COMPONENT_Cb); 2233 Pel* piOrgU = pcOrgYuv ->getAddr ( COMPONENT_Cb, partIdx ); //TODO: Change this into an array and loop over chroma components below 2234 Pel* piOrgV = pcOrgYuv ->getAddr ( COMPONENT_Cr, partIdx ); 2235 Pel* piPredU = pcPredYuv->getAddr ( COMPONENT_Cb, partIdx ); 2236 Pel* piPredV = pcPredYuv->getAddr ( COMPONENT_Cr, partIdx ); 2237 2238 //===== init pattern ===== 2239 Bool bAboveAvail = false; 2240 Bool bLeftAvail = false; 2241 DEBUG_STRING_NEW(sTemp) 2242 initAdiPatternChType( tuRecurseWithPU, bAboveAvail, bLeftAvail, COMPONENT_Cb, bFilterEnabled DEBUG_STRING_PASS_INTO(sTemp) ); 2243 initAdiPatternChType( tuRecurseWithPU, bAboveAvail, bLeftAvail, COMPONENT_Cr, bFilterEnabled DEBUG_STRING_PASS_INTO(sTemp) ); 2244 2245 //===== get best prediction modes (using SAD) ===== 2246 UInt uiMinMode = 0; 2247 UInt uiMaxMode = 4; 2248 UInt uiBestMode = MAX_UINT; 2249 Distortion uiMinSAD = std::numeric_limits<Distortion>::max(); 2250 const UInt mappedModeTable[4] = {PLANAR_IDX,DC_IDX,HOR_IDX,VER_IDX}; 2251 2252 DistParam distParamU, distParamV; 2253 const Bool bUseHadamard=pcCU->getCUTransquantBypass(0) == 0; 2254 m_pcRdCost->setDistParam(distParamU, g_bitDepth[CHANNEL_TYPE_CHROMA], piOrgU, uiStride, piPredU, uiStride, uiWidth, uiHeight, bUseHadamard); 2255 m_pcRdCost->setDistParam(distParamV, g_bitDepth[CHANNEL_TYPE_CHROMA], piOrgV, uiStride, piPredV, uiStride, uiWidth, uiHeight, bUseHadamard); 2256 distParamU.bApplyWeight = false; 2257 distParamV.bApplyWeight = false; 2258 2259 for( UInt uiMode_ = uiMinMode; uiMode_ < uiMaxMode; uiMode_++ ) 2260 { 2261 UInt uiMode=mappedModeTable[uiMode_]; 2262 //--- get prediction --- 2263 const Bool bUseFilter=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Cb, uiMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getDisableIntraReferenceSmoothing()); 2264 2265 predIntraAng( COMPONENT_Cb, uiMode, piOrgU, uiStride, piPredU, uiStride, tuRecurseCU, bAboveAvail, bLeftAvail, bUseFilter ); 2266 predIntraAng( COMPONENT_Cr, uiMode, piOrgV, uiStride, piPredV, uiStride, tuRecurseCU, bAboveAvail, bLeftAvail, bUseFilter ); 2267 2268 //--- get SAD --- 2269 Distortion uiSAD = distParamU.DistFunc(&distParamU); 2270 uiSAD += distParamV.DistFunc(&distParamV); 2271 //--- check --- 2272 if( uiSAD < uiMinSAD ) 2273 { 2274 uiMinSAD = uiSAD; 2275 uiBestMode = uiMode; 2276 } 2277 } 2278 2279 //===== set chroma pred mode ===== 2280 pcCU->setIntraDirSubParts( CHANNEL_TYPE_CHROMA, uiBestMode, partIdx, tuRecurseWithPU.getCUDepth() + uiInitTrDepth ); 2281 } 2282 } while (tuRecurseWithPU.nextSection(tuRecurseCU)); 2283 } 2284 2285 2286 2287 2288 Void 2289 TEncSearch::estIntraPredQT(TComDataCU* pcCU, 2290 TComYuv* pcOrgYuv, 2291 TComYuv* pcPredYuv, 2292 TComYuv* pcResiYuv, 2293 TComYuv* pcRecoYuv, 2294 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE], 2295 Distortion& ruiDistC, 2296 Bool bLumaOnly 2297 DEBUG_STRING_FN_DECLARE(sDebug)) 2141 TEncSearch::estIntraPredLumaQT(TComDataCU* pcCU, 2142 TComYuv* pcOrgYuv, 2143 TComYuv* pcPredYuv, 2144 TComYuv* pcResiYuv, 2145 TComYuv* pcRecoYuv, 2146 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE] 2147 DEBUG_STRING_FN_DECLARE(sDebug)) 2298 2148 { 2299 2149 const UInt uiDepth = pcCU->getDepth(0); 2300 2150 const UInt uiInitTrDepth = pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1; 2301 const UInt uiInitTrDepthC = pcCU->getPartitionSize(0) != SIZE_2Nx2N && enable4ChromaPUsInIntraNxNCU(pcOrgYuv->getChromaFormat()) ? 1 : 0;2302 2151 const UInt uiNumPU = 1<<(2*uiInitTrDepth); 2303 2152 const UInt uiQNumParts = pcCU->getTotalNumPart() >> 2; … … 2306 2155 const UInt numberValidComponents = getNumberValidComponents(chFmt); 2307 2156 Distortion uiOverallDistY = 0; 2308 Distortion uiOverallDistC = 0;2309 2157 UInt CandNum; 2310 2158 Double CandCostList[ FAST_UDI_MAX_RDMODE_NUM ]; … … 2483 2331 UInt uiBestPUMode = 0; 2484 2332 Distortion uiBestPUDistY = 0; 2485 Distortion uiBestPUDistC = 0;2486 2333 Double dBestPUCost = MAX_DOUBLE; 2487 2334 … … 2506 2353 // determine residual for partition 2507 2354 Distortion uiPUDistY = 0; 2508 Distortion uiPUDistC = 0;2509 2355 Double dPUCost = 0.0; 2510 2356 #if HHI_RQT_INTRA_SPEEDUP 2511 xRecurIntraCoding QT( bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, uiPUDistC, true, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );2357 xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, true, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) ); 2512 2358 #else 2513 xRecurIntraCoding QT( bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, uiPUDistC, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) );2359 xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sMode) ); 2514 2360 #endif 2515 2361 … … 2528 2374 uiBestPUMode = uiOrgMode; 2529 2375 uiBestPUDistY = uiPUDistY; 2530 uiBestPUDistC = uiPUDistC;2531 2376 dBestPUCost = dPUCost; 2532 2377 2533 xSetIntraResult QT( bLumaOnly,pcRecoYuv, tuRecurseWithPU );2378 xSetIntraResultLumaQT( pcRecoYuv, tuRecurseWithPU ); 2534 2379 2535 2380 if (pcCU->getSlice()->getPPS()->getUseCrossComponentPrediction()) … … 2593 2438 // determine residual for partition 2594 2439 Distortion uiPUDistY = 0; 2595 Distortion uiPUDistC = 0;2596 2440 Double dPUCost = 0.0; 2597 2441 2598 xRecurIntraCoding QT( bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, uiPUDistC, false, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sModeTree));2442 xRecurIntraCodingLumaQT( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaPU, uiPUDistY, false, dPUCost, tuRecurseWithPU DEBUG_STRING_PASS_INTO(sModeTree)); 2599 2443 2600 2444 // check r-d cost … … 2604 2448 uiBestPUMode = uiOrgMode; 2605 2449 uiBestPUDistY = uiPUDistY; 2606 uiBestPUDistC = uiPUDistC;2607 2450 dBestPUCost = dPUCost; 2608 2451 2609 xSetIntraResult QT( bLumaOnly,pcRecoYuv, tuRecurseWithPU );2452 xSetIntraResultLumaQT( pcRecoYuv, tuRecurseWithPU ); 2610 2453 2611 2454 if (pcCU->getSlice()->getPPS()->getUseCrossComponentPrediction()) … … 2639 2482 //--- update overall distortion --- 2640 2483 uiOverallDistY += uiBestPUDistY; 2641 uiOverallDistC += uiBestPUDistC;2642 2484 2643 2485 //--- update transform index and cbf --- … … 2654 2496 if( !tuRecurseWithPU.IsLastSection() ) 2655 2497 { 2656 const Bool bSkipChroma = tuRecurseWithPU.ProcessChannelSection(CHANNEL_TYPE_CHROMA); 2657 2658 const UInt numChannelToProcess = (bLumaOnly || bSkipChroma) ? 1 : getNumberValidComponents(pcCU->getPic()->getChromaFormat()); 2659 2660 for (UInt ch=0; ch<numChannelToProcess; ch++) 2661 { 2662 const ComponentID compID = ComponentID(ch); 2663 const TComRectangle &puRect=tuRecurseWithPU.getRect(compID); 2664 const UInt uiCompWidth = puRect.width; 2665 const UInt uiCompHeight = puRect.height; 2666 2667 const UInt uiZOrder = pcCU->getZorderIdxInCtu() + uiPartOffset; 2668 Pel* piDes = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), uiZOrder ); 2669 const UInt uiDesStride = pcCU->getPic()->getPicYuvRec()->getStride( compID); 2670 const Pel* piSrc = pcRecoYuv->getAddr( compID, uiPartOffset ); 2671 const UInt uiSrcStride = pcRecoYuv->getStride( compID); 2672 2673 for( UInt uiY = 0; uiY < uiCompHeight; uiY++, piSrc += uiSrcStride, piDes += uiDesStride ) 2674 { 2675 for( UInt uiX = 0; uiX < uiCompWidth; uiX++ ) 2676 { 2677 piDes[ uiX ] = piSrc[ uiX ]; 2678 } 2498 const TComRectangle &puRect=tuRecurseWithPU.getRect(COMPONENT_Y); 2499 const UInt uiCompWidth = puRect.width; 2500 const UInt uiCompHeight = puRect.height; 2501 2502 const UInt uiZOrder = pcCU->getZorderIdxInCtu() + uiPartOffset; 2503 Pel* piDes = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), uiZOrder ); 2504 const UInt uiDesStride = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y); 2505 const Pel* piSrc = pcRecoYuv->getAddr( COMPONENT_Y, uiPartOffset ); 2506 const UInt uiSrcStride = pcRecoYuv->getStride( COMPONENT_Y); 2507 2508 for( UInt uiY = 0; uiY < uiCompHeight; uiY++, piSrc += uiSrcStride, piDes += uiDesStride ) 2509 { 2510 for( UInt uiX = 0; uiX < uiCompWidth; uiX++ ) 2511 { 2512 piDes[ uiX ] = piSrc[ uiX ]; 2679 2513 } 2680 2514 } … … 2682 2516 2683 2517 //=== update PU data ==== 2684 pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiBestPUMode, uiPartOffset, uiDepth + uiInitTrDepth ); 2685 if (!bLumaOnly && getChromasCorrespondingPULumaIdx(uiPartOffset, chFmt)==uiPartOffset) 2686 { 2687 UInt chromaDir=pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, getChromasCorrespondingPULumaIdx(uiPartOffset, chFmt)); 2688 if (chromaDir == uiBestPUMode && tuRecurseWithPU.ProcessChannelSection(CHANNEL_TYPE_CHROMA)) 2689 { 2690 pcCU->setIntraDirSubParts ( CHANNEL_TYPE_CHROMA, DM_CHROMA_IDX, getChromasCorrespondingPULumaIdx(uiPartOffset, chFmt), uiDepth + uiInitTrDepthC ); 2691 } 2692 } 2693 //pcCU->copyToPic ( uiDepth, uiPU, uiInitTrDepth ); // Unnecessary copy? 2518 pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiBestPUMode, uiPartOffset, uiDepth + uiInitTrDepth ); 2694 2519 } while (tuRecurseWithPU.nextSection(tuRecurseCU)); 2695 2520 … … 2719 2544 2720 2545 //===== set distortion (rate and r-d costs are determined later) ===== 2721 ruiDistC = uiOverallDistC; 2722 pcCU->getTotalDistortion() = uiOverallDistY + uiOverallDistC; 2546 pcCU->getTotalDistortion() = uiOverallDistY; 2723 2547 } 2724 2548 … … 2732 2556 TComYuv* pcResiYuv, 2733 2557 TComYuv* pcRecoYuv, 2734 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE], 2735 Distortion uiPreCalcDistC 2558 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE] 2736 2559 DEBUG_STRING_FN_DECLARE(sDebug)) 2737 2560 { 2738 pcCU->getTotalDistortion () -= uiPreCalcDistC;2739 2740 //const UInt uiDepthCU = pcCU->getDepth(0);2741 2561 const UInt uiInitTrDepth = pcCU->getPartitionSize(0) != SIZE_2Nx2N && enable4ChromaPUsInIntraNxNCU(pcOrgYuv->getChromaFormat()) ? 1 : 0; 2742 // const UInt uiNumPU = 1<<(2*uiInitTrDepth);2743 2562 2744 2563 TComTURecurse tuRecurseCU(pcCU, 0); -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.h
r1029 r1243 174 174 175 175 public: 176 Void preestChromaPredMode ( TComDataCU* pcCU, 177 TComYuv* pcOrgYuv, 178 TComYuv* pcPredYuv ); 179 180 Void estIntraPredQT ( TComDataCU* pcCU, 176 Void estIntraPredLumaQT ( TComDataCU* pcCU, 181 177 TComYuv* pcOrgYuv, 182 178 TComYuv* pcPredYuv, 183 179 TComYuv* pcResiYuv, 184 180 TComYuv* pcRecoYuv, 185 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE], 186 Distortion& ruiDistC, 187 Bool bLumaOnly 181 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE] 188 182 DEBUG_STRING_FN_DECLARE(sDebug)); 189 183 … … 193 187 TComYuv* pcResiYuv, 194 188 TComYuv* pcRecoYuv, 195 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE], 196 Distortion uiPreCalcDistC 189 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE] 197 190 DEBUG_STRING_FN_DECLARE(sDebug)); 198 191 … … 278 271 ); 279 272 280 Void xRecurIntraCodingQT ( Bool bLumaOnly, 281 TComYuv* pcOrgYuv, 273 Void xRecurIntraCodingLumaQT ( TComYuv* pcOrgYuv, 282 274 TComYuv* pcPredYuv, 283 275 TComYuv* pcResiYuv, 284 276 Pel resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE], 285 277 Distortion& ruiDistY, 286 Distortion& ruiDistC,287 278 #if HHI_RQT_INTRA_SPEEDUP 288 Bool bCheckFirst, 289 #endif 290 Double& dRDCost, 291 TComTU &rTu 292 DEBUG_STRING_FN_DECLARE(sDebug)); 293 294 Void xSetIntraResultQT ( Bool bLumaOnly, 295 TComYuv* pcRecoYuv, 279 Bool bCheckFirst, 280 #endif 281 Double& dRDCost, 282 TComTU &rTu 283 DEBUG_STRING_FN_DECLARE(sDebug)); 284 285 Void xSetIntraResultLumaQT ( TComYuv* pcRecoYuv, 296 286 TComTU &rTu); 297 287 … … 323 313 Void xSetIntraResultChromaQT ( TComYuv* pcRecoYuv, TComTU &rTu); 324 314 325 Void xStoreIntraResultQT ( const ComponentID first, const ComponentID lastIncl, TComTU &rTu);326 Void xLoadIntraResultQT ( const ComponentID first, const ComponentID lastIncl, TComTU &rTu);315 Void xStoreIntraResultQT ( const ComponentID compID, TComTU &rTu); 316 Void xLoadIntraResultQT ( const ComponentID compID, TComTU &rTu); 327 317 328 318
Note: See TracChangeset for help on using the changeset viewer.