Changeset 296 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
- Timestamp:
- 20 Feb 2013, 22:07:43 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
r56 r296 66 66 m_pClipTable = NULL; 67 67 m_pClipTableBase = NULL; 68 #if SAO_UNIT_INTERLEAVING69 68 m_lumaTableBo = NULL; 70 #else71 m_ppLumaTableBo0 = NULL;72 m_ppLumaTableBo1 = NULL;73 #endif74 69 m_iUpBuff1 = NULL; 75 70 m_iUpBuff2 = NULL; … … 136 131 2, 137 132 2, 138 #if !SAO_UNIT_INTERLEAVING139 1,140 #endif141 133 1 142 134 }; … … 161 153 SAO_EO_LEN, 162 154 SAO_EO_LEN, 163 #if !SAO_UNIT_INTERLEAVING164 SAO_BO_LEN,165 #endif166 155 SAO_BO_LEN 167 156 }; … … 259 248 * m_iNumTotalParts must allow for sufficient storage in any allocated arrays */ 260 249 m_iNumTotalParts = max(3,m_aiNumCulPartsLevel[m_uiMaxSplitLevel]); 261 #if !SAO_UNIT_INTERLEAVING262 UInt auiTable[2][LUMA_GROUP_NUM] =263 {{0, 0, 0, 0, 0, 0, 0, 0,264 1, 2, 3, 4, 5, 6, 7, 8,265 9,10,11,12,13,14,15,16,266 0, 0, 0, 0, 0, 0, 0, 0},267 268 {1, 2, 3, 4, 5, 6, 7, 8,269 0, 0, 0, 0, 0, 0, 0, 0,270 0, 0, 0, 0, 0, 0, 0, 0,271 9,10,11,12,13,14,15,16}};272 #endif273 250 274 251 UInt uiInternalBitDepth = g_uiBitDepth+g_uiBitIncrement; … … 276 253 UInt uiBoRangeShift = uiInternalBitDepth - SAO_BO_BITS; 277 254 278 #if SAO_UNIT_INTERLEAVING279 255 m_lumaTableBo = new Pel [uiPixelRange]; 280 256 for (Int k2=0; k2<uiPixelRange; k2++) … … 282 258 m_lumaTableBo[k2] = 1 + (k2>>uiBoRangeShift); 283 259 } 284 #else285 m_ppLumaTableBo0 = new Pel [uiPixelRange];286 m_ppLumaTableBo1 = new Pel [uiPixelRange];287 for (Int k2=0; k2<uiPixelRange; k2++)288 {289 m_ppLumaTableBo0[k2] = auiTable[0][k2>>uiBoRangeShift];290 m_ppLumaTableBo1[k2] = auiTable[1][k2>>uiBoRangeShift];291 }292 #endif293 260 m_iUpBuff1 = new Int[m_iPicWidth+2]; 294 261 m_iUpBuff2 = new Int[m_iPicWidth+2]; … … 345 312 delete [] m_iOffsetBo; m_iOffsetBo = NULL; 346 313 } 347 #if SAO_UNIT_INTERLEAVING348 314 if (m_lumaTableBo) 349 315 { 350 316 delete[] m_lumaTableBo; m_lumaTableBo = NULL; 351 317 } 352 #else353 if (m_ppLumaTableBo0)354 {355 delete[] m_ppLumaTableBo0; m_ppLumaTableBo0 = NULL;356 }357 if (m_ppLumaTableBo1)358 {359 delete[] m_ppLumaTableBo1; m_ppLumaTableBo1 = NULL;360 }361 #endif362 318 363 319 … … 416 372 pcSaoParam->iNumClass[j] = m_iNumClass[j]; 417 373 } 418 #if SAO_UNIT_INTERLEAVING419 374 pcSaoParam->numCuInWidth = m_iNumCuInWidth; 420 375 pcSaoParam->numCuInHeight = m_iNumCuInHeight; … … 422 377 pcSaoParam->saoLcuParam[1] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth]; 423 378 pcSaoParam->saoLcuParam[2] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth]; 424 #endif425 379 } 426 380 … … 448 402 449 403 pSaoPart->UpPartIdx = iParentPartIdx; 450 #if !SAO_UNIT_INTERLEAVING451 pSaoPart->bEnableFlag = 0;452 #endif453 404 pSaoPart->iBestType = -1; 454 405 pSaoPart->iLength = 0; 455 406 456 #if SAO_UNIT_INTERLEAVING457 407 pSaoPart->bandPosition = 0; 458 408 459 409 for (j=0;j<MAX_NUM_SAO_OFFSETS;j++) 460 #else461 for (j=0;j<MAX_NUM_SAO_CLASS;j++)462 #endif463 410 { 464 411 pSaoPart->iOffset[j] = 0; … … 545 492 pcSaoParam->psSaoPart[1] = 0; 546 493 pcSaoParam->psSaoPart[2] = 0; 547 #if SAO_UNIT_INTERLEAVING548 494 if( pcSaoParam->saoLcuParam[0]) 549 495 { … … 558 504 delete [] pcSaoParam->saoLcuParam[2]; pcSaoParam->saoLcuParam[2] = NULL; 559 505 } 560 #endif561 506 } 562 507 … … 572 517 for(Int i=0; i< m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; i++) 573 518 { 574 #if !SAO_UNIT_INTERLEAVING575 pcSaoParam->psSaoPart[c][i].bEnableFlag = 0;576 #endif577 519 pcSaoParam->psSaoPart[c][i].iBestType = -1; 578 520 pcSaoParam->psSaoPart[c][i].iLength = 0; … … 582 524 pcSaoParam->psSaoPart[c][i].iMinDist = MAX_INT; 583 525 pcSaoParam->psSaoPart[c][i].iMinRate = MAX_INT; 584 #if SAO_UNIT_INTERLEAVING585 526 pcSaoParam->psSaoPart[c][i].bandPosition = 0; 586 527 for (Int j=0;j<MAX_NUM_SAO_OFFSETS;j++) 587 #else588 for (Int j=0;j<MAX_NUM_SAO_CLASS;j++)589 #endif590 528 { 591 529 pcSaoParam->psSaoPart[c][i].iOffset[j] = 0; … … 594 532 } 595 533 } 596 #if SAO_UNIT_INTERLEAVING597 534 pcSaoParam->oneUnitFlag[0] = 0; 598 535 pcSaoParam->oneUnitFlag[1] = 0; … … 601 538 resetLcuPart(pcSaoParam->saoLcuParam[1]); 602 539 resetLcuPart(pcSaoParam->saoLcuParam[2]); 603 #endif604 540 } 605 541 } … … 882 818 break; 883 819 } 884 #if SAO_UNIT_INTERLEAVING885 820 case SAO_BO: 886 #else887 case SAO_BO_0:888 case SAO_BO_1:889 #endif890 821 { 891 822 for (y=0; y< height; y++) … … 1108 1039 break; 1109 1040 } 1110 #if SAO_UNIT_INTERLEAVING1111 1041 case SAO_BO: 1112 #else1113 case SAO_BO_0:1114 case SAO_BO_1:1115 #endif1116 1042 { 1117 1043 for (y=0; y<iLcuHeight; y++) … … 1134 1060 } 1135 1061 } 1136 #if !SAO_UNIT_INTERLEAVING1137 /** sample adaptive offset process for one partition1138 * \param *psQTPart, uiPartIdx, iYCbCr1139 */1140 Void TComSampleAdaptiveOffset::processSaoOnePart(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr)1141 {1142 int i;1143 UInt uiEdgeType, uiTypeIdx;1144 Pel* ppLumaTable = NULL;1145 SAOQTPart* pOnePart= &(psQTPart[uiPartIdx]);1146 1147 static Int iOffset[LUMA_GROUP_NUM];1148 Int LcuIdxX;1149 Int LcuIdxY;1150 Int iAddr;1151 Int iFrameWidthInCU = m_pcPic->getFrameWidthInCU();1152 1153 if(pOnePart->bEnableFlag)1154 {1155 uiTypeIdx = pOnePart->iBestType;1156 if (uiTypeIdx == SAO_BO_0 || uiTypeIdx == SAO_BO_1)1157 {1158 for (i=0;i<pOnePart->iLength;i++)1159 iOffset[i+1] = pOnePart->iOffset[i] << m_uiSaoBitIncrease;1160 1161 if (uiTypeIdx == SAO_BO_0 )1162 {1163 ppLumaTable = m_ppLumaTableBo0;1164 }1165 if (uiTypeIdx == SAO_BO_1 )1166 {1167 ppLumaTable = m_ppLumaTableBo1;1168 }1169 1170 #if FULL_NBIT1171 for (i=0;i<(1<<(g_uiBitDepth));i++)1172 #else1173 for (i=0;i<(1<<(g_uiBitIncrement+8));i++)1174 #endif1175 {1176 m_iOffsetBo[i] = m_pClipTable[i + iOffset[ppLumaTable[i]]];1177 }1178 1179 }1180 if (uiTypeIdx == SAO_EO_0 || uiTypeIdx == SAO_EO_1 || uiTypeIdx == SAO_EO_2 || uiTypeIdx == SAO_EO_3)1181 {1182 for (i=0;i<pOnePart->iLength;i++)1183 {1184 iOffset[i+1] = pOnePart->iOffset[i] << m_uiSaoBitIncrease;1185 }1186 for (uiEdgeType=0;uiEdgeType<6;uiEdgeType++)1187 {1188 m_iOffsetEo[uiEdgeType]= iOffset[m_auiEoTable[uiEdgeType]];1189 }1190 }1191 for (LcuIdxY = pOnePart->StartCUY; LcuIdxY<= pOnePart->EndCUY; LcuIdxY++)1192 {1193 for (LcuIdxX = pOnePart->StartCUX; LcuIdxX<= pOnePart->EndCUX; LcuIdxX++)1194 {1195 iAddr = LcuIdxY * iFrameWidthInCU + LcuIdxX;1196 processSaoCu(iAddr, uiTypeIdx, iYCbCr);1197 }1198 }1199 }1200 }1201 1202 /** Process quadtree sample adaptive offset1203 * \param psQTPart, uiPartIdx, iYCbCr1204 */1205 Void TComSampleAdaptiveOffset::processSaoQuadTree(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr)1206 {1207 SAOQTPart* pSaoPart= &(psQTPart[uiPartIdx]);1208 1209 if (uiPartIdx == 0)1210 {1211 initTmpSaoQuadTree(psQTPart, iYCbCr);1212 xSaoAllPart(psQTPart, iYCbCr);1213 return;1214 }1215 1216 if (!pSaoPart->bSplit)1217 {1218 if (pSaoPart->bEnableFlag)1219 {1220 processSaoOnePart(psQTPart, uiPartIdx, iYCbCr);1221 }1222 return;1223 }1224 1225 if (pSaoPart->PartLevel < m_uiMaxSplitLevel)1226 {1227 processSaoQuadTree(psQTPart, pSaoPart->DownPartsIdx[0], iYCbCr);1228 processSaoQuadTree(psQTPart, pSaoPart->DownPartsIdx[1], iYCbCr);1229 processSaoQuadTree(psQTPart, pSaoPart->DownPartsIdx[2], iYCbCr);1230 processSaoQuadTree(psQTPart, pSaoPart->DownPartsIdx[3], iYCbCr);1231 }1232 }1233 1234 /** run SAO processing in LCU order1235 * \param *psQTPart, iYCbCr1236 */1237 Void TComSampleAdaptiveOffset::xSaoAllPart(SAOQTPart *psQTPart, Int iYCbCr)1238 {1239 int i;1240 UInt uiEdgeType;1241 Pel* ppLumaTable = NULL;1242 Int iTypeIdx;1243 1244 static Int iOffset[LUMA_GROUP_NUM];1245 Int LcuIdxX;1246 Int LcuIdxY;1247 Int iAddr;1248 Int iFrameWidthInCU = m_pcPic->getFrameWidthInCU();1249 Int iFrameHeightInCU = m_pcPic->getFrameHeightInCU();1250 Int iPartIdx;1251 Pel *pRec;1252 Int iPicWidthTmp;1253 Int iStride;1254 Pel *pTmpUSwap;1255 Int iIsChroma = (iYCbCr == 0) ? 0:1;1256 1257 SAOQTPart* pOnePart;1258 1259 for (LcuIdxY = 0; LcuIdxY< iFrameHeightInCU; LcuIdxY++)1260 {1261 iAddr = LcuIdxY * iFrameWidthInCU;1262 if (iYCbCr == 0)1263 {1264 pRec = m_pcPic->getPicYuvRec()->getLumaAddr(iAddr);1265 iStride = m_pcPic->getStride();1266 iPicWidthTmp = m_iPicWidth;1267 }1268 else if (iYCbCr == 1)1269 {1270 pRec = m_pcPic->getPicYuvRec()->getCbAddr(iAddr);1271 iStride = m_pcPic->getCStride();1272 iPicWidthTmp = m_iPicWidth>>1;1273 }1274 else1275 {1276 pRec = m_pcPic->getPicYuvRec()->getCrAddr(iAddr);1277 iStride = m_pcPic->getCStride();1278 iPicWidthTmp = m_iPicWidth>>1;1279 }1280 1281 // pRec += iStride*(m_uiMaxCUHeight-1);1282 for (i=0;i<(m_uiMaxCUHeight>>iIsChroma)+1;i++)1283 {1284 m_pTmpL1[i] = pRec[0];1285 pRec+=iStride;1286 }1287 pRec-=(iStride<<1);1288 1289 memcpy(m_pTmpU2, pRec, sizeof(Pel)*iPicWidthTmp);1290 1291 for (LcuIdxX = 0; LcuIdxX< iFrameWidthInCU; LcuIdxX++)1292 {1293 iAddr = LcuIdxY * iFrameWidthInCU + LcuIdxX;1294 iPartIdx = m_iLcuPartIdx[iAddr];1295 if (iPartIdx>=0)1296 {1297 pOnePart = &(psQTPart[iPartIdx]);1298 iTypeIdx = pOnePart->iBestType;1299 if (iTypeIdx>=0)1300 {1301 if (iTypeIdx == SAO_BO_0 || iTypeIdx == SAO_BO_1)1302 {1303 for (i=0;i<pOnePart->iLength;i++)1304 iOffset[i+1] = pOnePart->iOffset[i] << m_uiSaoBitIncrease;1305 1306 if (iTypeIdx == SAO_BO_0 )1307 {1308 ppLumaTable = m_ppLumaTableBo0;1309 }1310 if (iTypeIdx == SAO_BO_1 )1311 {1312 ppLumaTable = m_ppLumaTableBo1;1313 }1314 1315 #if FULL_NBIT1316 for (i=0;i<(1<<(g_uiBitDepth));i++)1317 #else1318 for (i=0;i<(1<<(g_uiBitIncrement+8));i++)1319 #endif1320 {1321 m_iOffsetBo[i] = m_pClipTable[i + iOffset[ppLumaTable[i]]];1322 }1323 1324 }1325 if (iTypeIdx == SAO_EO_0 || iTypeIdx == SAO_EO_1 || iTypeIdx == SAO_EO_2 || iTypeIdx == SAO_EO_3)1326 {1327 for (i=0;i<pOnePart->iLength;i++)1328 {1329 iOffset[i+1] = pOnePart->iOffset[i] << m_uiSaoBitIncrease;1330 }1331 for (uiEdgeType=0;uiEdgeType<6;uiEdgeType++)1332 {1333 m_iOffsetEo[uiEdgeType]= iOffset[m_auiEoTable[uiEdgeType]];1334 }1335 }1336 processSaoCu(iAddr, iTypeIdx, iYCbCr);1337 }1338 }1339 else1340 {1341 if (LcuIdxX != (iFrameWidthInCU-1))1342 {1343 if( m_iLcuPartIdx[iAddr+1] >=0)1344 {1345 if (iYCbCr == 0)1346 {1347 pRec = m_pcPic->getPicYuvRec()->getLumaAddr(iAddr);1348 iStride = m_pcPic->getStride();1349 }1350 else if (iYCbCr == 1)1351 {1352 pRec = m_pcPic->getPicYuvRec()->getCbAddr(iAddr);1353 iStride = m_pcPic->getCStride();1354 }1355 else1356 {1357 pRec = m_pcPic->getPicYuvRec()->getCrAddr(iAddr);1358 iStride = m_pcPic->getCStride();1359 }1360 Int iWidthShift = m_uiMaxCUWidth>>iIsChroma;1361 for (i=0;i<(m_uiMaxCUHeight>>iIsChroma)+1;i++)1362 {1363 m_pTmpL1[i] = pRec[iWidthShift-1];1364 pRec+=iStride;1365 }1366 }1367 }1368 }1369 }1370 pTmpUSwap = m_pTmpU1;1371 m_pTmpU1 = m_pTmpU2;1372 m_pTmpU2 = pTmpUSwap;1373 }1374 }1375 1376 /** initialize buffer for quadtree boundary1377 * \param *psQTPart, iYCbCr1378 */1379 Void TComSampleAdaptiveOffset::initTmpSaoQuadTree(SAOQTPart *psQTPart, Int iYCbCr)1380 {1381 Pel *pRec;1382 Int iPicWidthTmp;1383 1384 1385 memset(m_iLcuPartIdx,-1, sizeof(Int)*m_iNumCuInWidth*m_iNumCuInHeight);1386 convertSaoQt2Lcu(psQTPart, 0);1387 1388 if (iYCbCr == 0)1389 {1390 pRec = m_pcPic->getPicYuvRec()->getLumaAddr();1391 iPicWidthTmp = m_iPicWidth;1392 }1393 else if (iYCbCr == 1)1394 {1395 pRec = m_pcPic->getPicYuvRec()->getCbAddr();1396 iPicWidthTmp = m_iPicWidth>>1;1397 }1398 else1399 {1400 pRec = m_pcPic->getPicYuvRec()->getCrAddr();1401 iPicWidthTmp = m_iPicWidth>>1;1402 }1403 1404 memcpy(m_pTmpU1, pRec, sizeof(Pel)*iPicWidthTmp);1405 }1406 1407 /** recursive covert quadtree partition index to each LCU1408 * \param psQTPart, uiPartIdx1409 */1410 Void TComSampleAdaptiveOffset::convertSaoQt2Lcu(SAOQTPart *psQTPart,UInt uiPartIdx)1411 {1412 1413 SAOQTPart* pSaoPart= &(psQTPart[uiPartIdx]);1414 1415 if (!pSaoPart->bSplit)1416 {1417 xSaoQt2Lcu(psQTPart, uiPartIdx);1418 return;1419 }1420 1421 if (pSaoPart->PartLevel < m_uiMaxSplitLevel)1422 {1423 convertSaoQt2Lcu(psQTPart, pSaoPart->DownPartsIdx[0]);1424 convertSaoQt2Lcu(psQTPart, pSaoPart->DownPartsIdx[1]);1425 convertSaoQt2Lcu(psQTPart, pSaoPart->DownPartsIdx[2]);1426 convertSaoQt2Lcu(psQTPart, pSaoPart->DownPartsIdx[3]);1427 }1428 }1429 1430 /** assign quadtree partition index to each LCU1431 * \param psQTPart, uiPartIdx1432 */1433 1434 Void TComSampleAdaptiveOffset::xSaoQt2Lcu(SAOQTPart *psQTPart,UInt uiPartIdx)1435 {1436 Int LcuIdxX;1437 Int LcuIdxY;1438 Int iAddr;1439 Int iFrameWidthInCU = m_iNumCuInWidth;1440 1441 for (LcuIdxY = psQTPart[uiPartIdx].StartCUY; LcuIdxY<= psQTPart[uiPartIdx].EndCUY; LcuIdxY++)1442 {1443 for (LcuIdxX = psQTPart[uiPartIdx].StartCUX; LcuIdxX<= psQTPart[uiPartIdx].EndCUX; LcuIdxX++)1444 {1445 iAddr = LcuIdxY * iFrameWidthInCU + LcuIdxX;1446 if (psQTPart[uiPartIdx].bEnableFlag)1447 {1448 m_iLcuPartIdx[iAddr] = (Int)uiPartIdx;1449 }1450 else1451 {1452 m_iLcuPartIdx[iAddr] = -1;1453 }1454 }1455 }1456 }1457 #endif1458 1062 /** Sample adaptive offset process 1459 1063 * \param pcPic, pcSaoParam … … 1474 1078 } 1475 1079 1476 #if SAO_UNIT_INTERLEAVING1477 1080 if (m_saoInterleavingFlag) 1478 1081 { … … 1496 1099 1497 1100 1498 #else1499 Int iY = 0;1500 processSaoQuadTree( pcSaoParam->psSaoPart[iY], 0 , iY);1501 1502 Int iCb = 1;1503 Int iCr = 2;1504 if (pcSaoParam->bSaoFlag[iCb])1505 {1506 processSaoQuadTree( pcSaoParam->psSaoPart[iCb], 0 , iCb);1507 }1508 if (pcSaoParam->bSaoFlag[iCr])1509 {1510 processSaoQuadTree( pcSaoParam->psSaoPart[iCr], 0 , iCr);1511 }1512 #endif1513 1101 m_pcPic = NULL; 1514 1102 } … … 1533 1121 } 1534 1122 } 1535 #if SAO_UNIT_INTERLEAVING1536 1123 /** Process SAO all units 1537 1124 * \param saoLcuParam SAO LCU parameters … … 1789 1376 1790 1377 1791 #endif1792 1378 1793 1379 //! \}
Note: See TracChangeset for help on using the changeset viewer.