Changeset 443 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
- Timestamp:
- 26 May 2013, 15:41:34 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
r296 r443 62 62 TComSampleAdaptiveOffset::TComSampleAdaptiveOffset() 63 63 { 64 #if !LGE_SAO_MIGRATION_D0091 64 65 m_pcPic = NULL; 66 #endif 65 67 m_iOffsetBo = NULL; 66 68 m_pClipTable = NULL; … … 71 73 m_iUpBufft = NULL; 72 74 ipSwap = NULL; 75 #if !LGE_SAO_MIGRATION_D0091 73 76 m_pcYuvTmp = NULL; 77 #endif 74 78 75 79 m_pTmpU1 = NULL; … … 85 89 } 86 90 91 #if !LGE_SAO_MIGRATION_D0091 87 92 const Int TComSampleAdaptiveOffset::m_aiNumPartsInRow[5] = 88 93 { … … 102 107 256 //level 4 103 108 }; 109 #endif 104 110 105 111 const Int TComSampleAdaptiveOffset::m_aiNumCulPartsLevel[5] = … … 124 130 0 125 131 }; 126 132 #if !LGE_SAO_MIGRATION_D0091 127 133 const UInt TComSampleAdaptiveOffset::m_iWeightSao[MAX_NUM_SAO_TYPE] = 128 134 { … … 146 152 6 147 153 }; 154 #endif 148 155 149 156 Int TComSampleAdaptiveOffset::m_iNumClass[MAX_NUM_SAO_TYPE] = … … 187 194 return idx; 188 195 } 196 #if !LGE_SAO_MIGRATION_D0091 189 197 /** convert quadtree Idx to Level, Row, and Col 190 198 * \param idx, *level, *row, *col … … 223 231 } 224 232 } 233 #endif 225 234 /** create SampleAdaptiveOffset memory. 226 235 * \param … … 317 326 } 318 327 319 328 #if LGE_SAO_MIGRATION_D0091 329 if (m_iUpBuff1) 330 { 331 m_iUpBuff1--; 332 delete [] m_iUpBuff1; m_iUpBuff1 = NULL; 333 } 334 if (m_iUpBuff2) 335 { 336 m_iUpBuff2--; 337 delete [] m_iUpBuff2; m_iUpBuff2 = NULL; 338 } 339 if (m_iUpBufft) 340 { 341 m_iUpBufft--; 342 delete [] m_iUpBufft; m_iUpBufft = NULL; 343 } 344 #else 320 345 m_iUpBuff1--; 321 346 m_iUpBuff2--; … … 334 359 delete [] m_iUpBufft; m_iUpBufft = NULL; 335 360 } 361 #endif 336 362 if (m_pTmpL1) 337 363 { … … 368 394 initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1, 0, m_iNumCuInHeight-1,1); 369 395 initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1, 0, m_iNumCuInHeight-1,2); 396 #if !LGE_SAO_MIGRATION_D0091 370 397 for(Int j=0;j<MAX_NUM_SAO_TYPE;j++) 371 398 { 372 399 pcSaoParam->iNumClass[j] = m_iNumClass[j]; 373 400 } 401 #endif 374 402 pcSaoParam->numCuInWidth = m_iNumCuInWidth; 375 403 pcSaoParam->numCuInHeight = m_iNumCuInHeight; … … 405 433 pSaoPart->iLength = 0; 406 434 435 #if LGE_SAO_MIGRATION_D0091 436 pSaoPart->subTypeIdx = 0; 437 #else 407 438 pSaoPart->bandPosition = 0; 439 #endif 408 440 409 441 for (j=0;j<MAX_NUM_SAO_OFFSETS;j++) … … 514 546 for(Int c=0; c<iNumComponet; c++) 515 547 { 548 #if LGE_SAO_MIGRATION_D0091 549 if (c<2) 550 { 516 551 pcSaoParam->bSaoFlag[c] = 0; 552 } 553 #else 554 pcSaoParam->bSaoFlag[c] = 0; 555 #endif 517 556 for(Int i=0; i< m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; i++) 518 557 { … … 524 563 pcSaoParam->psSaoPart[c][i].iMinDist = MAX_INT; 525 564 pcSaoParam->psSaoPart[c][i].iMinRate = MAX_INT; 565 #if LGE_SAO_MIGRATION_D0091 566 pcSaoParam->psSaoPart[c][i].subTypeIdx = 0; 567 #else 526 568 pcSaoParam->psSaoPart[c][i].bandPosition = 0; 569 #endif 527 570 for (Int j=0;j<MAX_NUM_SAO_OFFSETS;j++) 528 571 { … … 557 600 m_pcPic = pcPic; 558 601 m_uiNumSlicesInPic = numSlicesInPic; 602 #if LGE_SAO_MIGRATION_D0091 603 m_iSGDepth = 0; 604 #else 559 605 m_iSGDepth = pcPic->getSliceGranularityForNDBFilter(); 606 #endif 560 607 m_bUseNIF = ( pcPic->getIndependentSliceBoundaryForNDBFilter() || pcPic->getIndependentTileBoundaryForNDBFilter() ); 561 608 if(m_bUseNIF) … … 958 1005 uiEdgeType = iSignDown + m_iUpBuff1[x] + 2; 959 1006 m_iUpBuff1[x]= -iSignDown; 960 961 1007 pRec[x] = m_pClipTable[pRec[x] + m_iOffsetEo[uiEdgeType]]; 962 1008 } … … 1065 1111 Void TComSampleAdaptiveOffset::SAOProcess(TComPic* pcPic, SAOParam* pcSaoParam) 1066 1112 { 1113 #if LGE_SAO_MIGRATION_D0091 1114 if (pcSaoParam->bSaoFlag[0] || pcSaoParam->bSaoFlag[1]) 1115 #else 1067 1116 if (pcSaoParam->bSaoFlag[0]) 1117 #endif 1068 1118 { 1069 1119 #if FULL_NBIT … … 1077 1127 m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp); 1078 1128 } 1079 1129 #if LGE_SAO_MIGRATION_D0091 1130 if (m_saoLcuBasedOptimization) 1131 #else 1080 1132 if (m_saoInterleavingFlag) 1133 #endif 1081 1134 { 1082 1135 pcSaoParam->oneUnitFlag[0] = 0; … … 1085 1138 } 1086 1139 Int iY = 0; 1140 #if LGE_SAO_MIGRATION_D0091 1141 if (pcSaoParam->bSaoFlag[0]) 1142 { 1143 processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY); 1144 } 1145 if(pcSaoParam->bSaoFlag[1]) 1146 { 1147 processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1);//Cb 1148 processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2);//Cr 1149 } 1150 #else 1087 1151 processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY); 1088 1152 … … 1097 1161 processSaoUnitAll( pcSaoParam->saoLcuParam[iCr], pcSaoParam->oneUnitFlag[iCr], iCr); 1098 1162 } 1099 1100 1163 #endif 1101 1164 m_pcPic = NULL; 1102 1165 } … … 1154 1217 Int typeIdx; 1155 1218 1219 #if LGE_SAO_MIGRATION_D0091 1220 Int offset[LUMA_GROUP_NUM+1]; 1221 #else 1156 1222 static Int offset[LUMA_GROUP_NUM+1]; 1223 #endif 1157 1224 Int idxX; 1158 1225 Int idxY; … … 1164 1231 Int isChroma = (yCbCr == 0) ? 0:1; 1165 1232 Bool mergeLeftFlag; 1166 1167 1233 #if LGE_SAO_MIGRATION_D0091 1234 offset[0] = 0; 1235 #endif 1168 1236 for (idxY = 0; idxY< frameHeightInCU; idxY++) 1169 1237 { … … 1201 1269 { 1202 1270 addr = idxY * frameWidthInCU + idxX; 1203 1204 1271 if (oneUnitFlag) 1205 1272 { … … 1225 1292 for (i=0; i<saoLcuParam[addr].length; i++) 1226 1293 { 1294 #if LGE_SAO_MIGRATION_D0091 1295 offset[ (saoLcuParam[addr].subTypeIdx +i)%SAO_MAX_BO_CLASSES +1] = saoLcuParam[addr].offset[i] << m_uiSaoBitIncrease; 1296 #else 1227 1297 offset[ (saoLcuParam[addr].bandPosition +i)%SAO_MAX_BO_CLASSES +1] = saoLcuParam[addr].offset[i] << m_uiSaoBitIncrease; 1298 #endif 1228 1299 } 1229 1300 … … 1304 1375 saoLcuParam[i].offset[j] = 0; 1305 1376 } 1377 #if LGE_SAO_MIGRATION_D0091 1378 saoLcuParam[i].subTypeIdx = 0; 1379 #else 1306 1380 saoLcuParam[i].bandPosition = 0; 1381 #endif 1307 1382 } 1308 1383 } … … 1353 1428 saoLcuParam[addr].partIdxTmp = (Int)partIdx; 1354 1429 saoLcuParam[addr].typeIdx = saoQTPart[partIdx].iBestType; 1430 #if LGE_SAO_MIGRATION_D0091 1431 saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx; 1432 #else 1355 1433 saoLcuParam[addr].bandPosition = saoQTPart[partIdx].bandPosition; 1434 #endif 1356 1435 if (saoLcuParam[addr].typeIdx!=-1) 1357 1436 { … … 1365 1444 { 1366 1445 saoLcuParam[addr].length = 0; 1446 #if LGE_SAO_MIGRATION_D0091 1447 saoLcuParam[addr].subTypeIdx = saoQTPart[partIdx].subTypeIdx; 1448 #else 1367 1449 saoLcuParam[addr].bandPosition = saoQTPart[partIdx].bandPosition; 1450 #endif 1368 1451 for (j=0;j<MAX_NUM_SAO_OFFSETS;j++) 1369 1452 { … … 1375 1458 } 1376 1459 1377 1378 1460 #if LGE_SAO_MIGRATION_D0091 1461 Void TComSampleAdaptiveOffset::resetSaoUnit(SaoLcuParam* saoUnit) 1462 { 1463 saoUnit->partIdx = 0; 1464 saoUnit->partIdxTmp = 0; 1465 saoUnit->mergeLeftFlag = 0; 1466 saoUnit->mergeUpFlag = 0; 1467 saoUnit->typeIdx = -1; 1468 saoUnit->length = 0; 1469 saoUnit->subTypeIdx = 0; 1470 1471 for (Int i=0;i<4;i++) 1472 { 1473 saoUnit->offset[i] = 0; 1474 } 1475 } 1476 1477 Void TComSampleAdaptiveOffset::copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc ) 1478 { 1479 saoUnitDst->mergeLeftFlag = saoUnitSrc->mergeLeftFlag; 1480 saoUnitDst->mergeUpFlag = saoUnitSrc->mergeUpFlag; 1481 saoUnitDst->typeIdx = saoUnitSrc->typeIdx; 1482 saoUnitDst->length = saoUnitSrc->length; 1483 1484 saoUnitDst->subTypeIdx = saoUnitSrc->subTypeIdx; 1485 for (Int i=0;i<4;i++) 1486 { 1487 saoUnitDst->offset[i] = saoUnitSrc->offset[i]; 1488 } 1489 } 1490 1491 /** PCM LF disable process. 1492 * \param pcPic picture (TComPic) pointer 1493 * \returns Void 1494 * 1495 * \note Replace filtered sample values of PCM mode blocks with the transmitted and reconstructed ones. 1496 */ 1497 Void TComSampleAdaptiveOffset::PCMLFDisableProcess (TComPic* pcPic) 1498 { 1499 xPCMRestoration(pcPic); 1500 } 1501 1502 /** Picture-level PCM restoration. 1503 * \param pcPic picture (TComPic) pointer 1504 * \returns Void 1505 */ 1506 Void TComSampleAdaptiveOffset::xPCMRestoration(TComPic* pcPic) 1507 { 1508 Bool bPCMFilter = (pcPic->getSlice(0)->getSPS()->getUsePCM() && pcPic->getSlice(0)->getSPS()->getPCMFilterDisableFlag())? true : false; 1509 #if LOSSLESS_CODING 1510 if(bPCMFilter || pcPic->getSlice(0)->getSPS()->getUseLossless()) 1511 #else 1512 if(bPCMFilter) 1513 #endif 1514 { 1515 for( UInt uiCUAddr = 0; uiCUAddr < pcPic->getNumCUsInFrame() ; uiCUAddr++ ) 1516 { 1517 TComDataCU* pcCU = pcPic->getCU(uiCUAddr); 1518 xPCMCURestoration(pcCU, 0, 0); 1519 } 1520 } 1521 } 1522 1523 /** PCM CU restoration. 1524 * \param pcCU pointer to current CU 1525 * \param uiAbsPartIdx part index 1526 * \param uiDepth CU depth 1527 * \returns Void 1528 */ 1529 Void TComSampleAdaptiveOffset::xPCMCURestoration ( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth ) 1530 { 1531 TComPic* pcPic = pcCU->getPic(); 1532 UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); 1533 UInt uiQNumParts = uiCurNumParts>>2; 1534 1535 // go to sub-CU 1536 if( pcCU->getDepth(uiAbsZorderIdx) > uiDepth ) 1537 { 1538 for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++, uiAbsZorderIdx+=uiQNumParts ) 1539 { 1540 UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsZorderIdx] ]; 1541 UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsZorderIdx] ]; 1542 if( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) 1543 xPCMCURestoration( pcCU, uiAbsZorderIdx, uiDepth+1 ); 1544 } 1545 return; 1546 } 1547 1548 // restore PCM samples 1549 if ((pcCU->getIPCMFlag(uiAbsZorderIdx)&& pcPic->getSlice(0)->getSPS()->getPCMFilterDisableFlag()) || pcCU->isLosslessCoded( uiAbsZorderIdx)) 1550 { 1551 xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_LUMA ); 1552 xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_CHROMA_U); 1553 xPCMSampleRestoration (pcCU, uiAbsZorderIdx, uiDepth, TEXT_CHROMA_V); 1554 } 1555 } 1556 1557 /** PCM sample restoration. 1558 * \param pcCU pointer to current CU 1559 * \param uiAbsPartIdx part index 1560 * \param uiDepth CU depth 1561 * \param ttText texture component type 1562 * \returns Void 1563 */ 1564 Void TComSampleAdaptiveOffset::xPCMSampleRestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText) 1565 { 1566 TComPicYuv* pcPicYuvRec = pcCU->getPic()->getPicYuvRec(); 1567 Pel* piSrc; 1568 Pel* piPcm; 1569 UInt uiStride; 1570 UInt uiWidth; 1571 UInt uiHeight; 1572 UInt uiPcmLeftShiftBit; 1573 UInt uiX, uiY; 1574 UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); 1575 UInt uiLumaOffset = uiMinCoeffSize*uiAbsZorderIdx; 1576 UInt uiChromaOffset = uiLumaOffset>>2; 1577 1578 if( ttText == TEXT_LUMA ) 1579 { 1580 piSrc = pcPicYuvRec->getLumaAddr( pcCU->getAddr(), uiAbsZorderIdx); 1581 piPcm = pcCU->getPCMSampleY() + uiLumaOffset; 1582 uiStride = pcPicYuvRec->getStride(); 1583 uiWidth = (g_uiMaxCUWidth >> uiDepth); 1584 uiHeight = (g_uiMaxCUHeight >> uiDepth); 1585 if ( pcCU->isLosslessCoded(uiAbsZorderIdx) ) 1586 { 1587 uiPcmLeftShiftBit = 0; 1588 } 1589 else 1590 { 1591 uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); 1592 } 1593 } 1594 else 1595 { 1596 if( ttText == TEXT_CHROMA_U ) 1597 { 1598 piSrc = pcPicYuvRec->getCbAddr( pcCU->getAddr(), uiAbsZorderIdx ); 1599 piPcm = pcCU->getPCMSampleCb() + uiChromaOffset; 1600 } 1601 else 1602 { 1603 piSrc = pcPicYuvRec->getCrAddr( pcCU->getAddr(), uiAbsZorderIdx ); 1604 piPcm = pcCU->getPCMSampleCr() + uiChromaOffset; 1605 } 1606 1607 uiStride = pcPicYuvRec->getCStride(); 1608 uiWidth = ((g_uiMaxCUWidth >> uiDepth)/2); 1609 uiHeight = ((g_uiMaxCUWidth >> uiDepth)/2); 1610 if ( pcCU->isLosslessCoded(uiAbsZorderIdx) ) 1611 { 1612 uiPcmLeftShiftBit = 0; 1613 } 1614 else 1615 { 1616 uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); 1617 } 1618 } 1619 1620 for( uiY = 0; uiY < uiHeight; uiY++ ) 1621 { 1622 for( uiX = 0; uiX < uiWidth; uiX++ ) 1623 { 1624 piSrc[uiX] = (piPcm[uiX] << uiPcmLeftShiftBit); 1625 } 1626 piPcm += uiWidth; 1627 piSrc += uiStride; 1628 } 1629 } 1630 #endif 1379 1631 //! \}
Note: See TracChangeset for help on using the changeset viewer.