Changeset 1291 in SHVCSoftware
- Timestamp:
- 18 Jul 2015, 02:28:34 (9 years ago)
- Location:
- branches/SHM-dev/source/Lib
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
r1290 r1291 85 85 , m_pcPPS ( NULL ) 86 86 , m_pcPic ( NULL ) 87 #if ADAPTIVE_QP_SELECTION88 , m_pcTrQuant ( NULL )89 #endif90 87 , m_colFromL0Flag ( true ) 91 88 , m_noOutputPriorPicsFlag ( false ) -
branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
r1290 r1291 2049 2049 const TComPPS* getPPS() const { return m_pcPPS; } 2050 2050 2051 #if ADAPTIVE_QP_SELECTION2052 Void setTrQuant( TComTrQuant* pcTrQuant ) { m_pcTrQuant = pcTrQuant; }2053 TComTrQuant* getTrQuant() { return m_pcTrQuant; }2054 const TComTrQuant* getTrQuant() const { return m_pcTrQuant; }2055 #endif2056 2057 2051 Void setPPSId( Int PPSId ) { m_iPPSId = PPSId; } 2058 2052 Int getPPSId() const { return m_iPPSId; } -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r1290 r1291 82 82 // ==================================================================================================================== 83 83 84 Void TEncCavlc::resetEntropy( )84 Void TEncCavlc::resetEntropy(const TComSlice *pSlice) 85 85 { 86 86 } -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h
r1287 r1291 73 73 74 74 protected: 75 TComSlice* m_pcSlice;76 77 75 Void codeShortTermRefPicSet ( const TComReferencePictureSet* pcRPS, Bool calledFromSliceHeader, Int idx ); 78 76 Bool findMatchingLTRP ( TComSlice* pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag ); … … 80 78 public: 81 79 82 Void resetEntropy ( );83 SliceType determineCabacInitIdx ( ) { assert(0); return I_SLICE; };80 Void resetEntropy (const TComSlice *pSlice); 81 SliceType determineCabacInitIdx (const TComSlice *pSlice) { assert(0); return I_SLICE; }; 84 82 85 83 Void setBitstream ( TComBitIf* p ) { m_pcBitIf = p; } 86 Void setSlice ( TComSlice* p ) { m_pcSlice = p; }87 84 Void resetBits () { m_pcBitIf->resetBits(); } 88 85 UInt getNumberOfWrittenBits() { return m_pcBitIf->getNumberOfWrittenBits(); } -
branches/SHM-dev/source/Lib/TLibEncoder/TEncEntropy.cpp
r1290 r1291 49 49 //! \{ 50 50 51 Void TEncEntropy::setEntropyCoder ( TEncEntropyIf* e , TComSlice* pcSlice)51 Void TEncEntropy::setEntropyCoder ( TEncEntropyIf* e ) 52 52 { 53 53 m_pcEntropyCoderIf = e; 54 m_pcEntropyCoderIf->setSlice ( pcSlice );55 54 } 56 55 -
branches/SHM-dev/source/Lib/TLibEncoder/TEncEntropy.h
r1287 r1291 63 63 { 64 64 public: 65 virtual Void resetEntropy ( ) = 0;66 virtual SliceType determineCabacInitIdx ( ) = 0;65 virtual Void resetEntropy (const TComSlice *pSlice) = 0; 66 virtual SliceType determineCabacInitIdx (const TComSlice *pSlice) = 0; 67 67 virtual Void setBitstream ( TComBitIf* p ) = 0; 68 virtual Void setSlice ( TComSlice* p ) = 0;69 68 virtual Void resetBits () = 0; 70 69 virtual UInt getNumberOfWrittenBits() = 0; … … 133 132 { 134 133 public: 135 Void setEntropyCoder ( TEncEntropyIf* e , TComSlice* pcSlice);134 Void setEntropyCoder ( TEncEntropyIf* e ); 136 135 Void setBitstream ( TComBitIf* p ) { m_pcEntropyCoderIf->setBitstream(p); } 137 136 Void resetBits () { m_pcEntropyCoderIf->resetBits(); } 138 137 UInt getNumberOfWrittenBits () { return m_pcEntropyCoderIf->getNumberOfWrittenBits(); } 139 Void resetEntropy ( ) { m_pcEntropyCoderIf->resetEntropy(); }140 SliceType determineCabacInitIdx ( ) { return m_pcEntropyCoderIf->determineCabacInitIdx(); }138 Void resetEntropy (const TComSlice *pSlice) { m_pcEntropyCoderIf->resetEntropy(pSlice); } 139 SliceType determineCabacInitIdx (const TComSlice *pSlice) { return m_pcEntropyCoderIf->determineCabacInitIdx(pSlice); } 141 140 142 141 Void encodeSliceHeader ( TComSlice* pcSlice ); -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r1290 r1291 1242 1242 } 1243 1243 1244 static Void 1245 cabac_zero_word_padding(TComSlice *const pcSlice, TComPic *const pcPic, const std::size_t binCountsInNalUnits, const std::size_t numBytesInVclNalUnits, std::ostringstream &nalUnitData, const Bool cabacZeroWordPaddingEnabled) 1246 { 1247 #if !SVC_EXTENSION 1248 const TComSPS &sps=*(pcSlice->getSPS()); 1249 #endif 1250 const Int log2subWidthCxsubHeightC = (pcPic->getComponentScaleX(COMPONENT_Cb)+pcPic->getComponentScaleY(COMPONENT_Cb)); 1251 const Int minCuWidth = pcPic->getMinCUWidth(); 1252 const Int minCuHeight = pcPic->getMinCUHeight(); 1253 #if SVC_EXTENSION 1254 const Int paddedWidth = ((pcSlice->getPicWidthInLumaSamples() + minCuWidth - 1) / minCuWidth) * minCuWidth; 1255 const Int paddedHeight= ((pcSlice->getPicHeightInLumaSamples() + minCuHeight - 1) / minCuHeight) * minCuHeight; 1256 const Int rawBits = paddedWidth * paddedHeight * 1257 (pcSlice->getBitDepth(CHANNEL_TYPE_LUMA) + 2*(pcSlice->getBitDepth(CHANNEL_TYPE_CHROMA)>>log2subWidthCxsubHeightC)); 1258 #else 1259 const Int paddedWidth = ((sps.getPicWidthInLumaSamples() + minCuWidth - 1) / minCuWidth) * minCuWidth; 1260 const Int paddedHeight= ((sps.getPicHeightInLumaSamples() + minCuHeight - 1) / minCuHeight) * minCuHeight; 1261 const Int rawBits = paddedWidth * paddedHeight * 1262 (sps.getBitDepth(CHANNEL_TYPE_LUMA) + 2*(sps.getBitDepth(CHANNEL_TYPE_CHROMA)>>log2subWidthCxsubHeightC)); 1263 #endif 1264 const std::size_t threshold = (32/3)*numBytesInVclNalUnits + (rawBits/32); 1265 if (binCountsInNalUnits >= threshold) 1266 { 1267 // need to add additional cabac zero words (each one accounts for 3 bytes (=00 00 03)) to increase numBytesInVclNalUnits 1268 const std::size_t targetNumBytesInVclNalUnits = ((binCountsInNalUnits - (rawBits/32))*3+31)/32; 1269 1270 if (targetNumBytesInVclNalUnits>numBytesInVclNalUnits) // It should be! 1271 { 1272 const std::size_t numberOfAdditionalBytesNeeded=targetNumBytesInVclNalUnits - numBytesInVclNalUnits; 1273 const std::size_t numberOfAdditionalCabacZeroWords=(numberOfAdditionalBytesNeeded+2)/3; 1274 const std::size_t numberOfAdditionalCabacZeroBytes=numberOfAdditionalCabacZeroWords*3; 1275 if (cabacZeroWordPaddingEnabled) 1276 { 1277 std::vector<Char> zeroBytesPadding(numberOfAdditionalCabacZeroBytes, Char(0)); 1278 for(std::size_t i=0; i<numberOfAdditionalCabacZeroWords; i++) 1279 { 1280 zeroBytesPadding[i*3+2]=3; // 00 00 03 1281 } 1282 nalUnitData.write(&(zeroBytesPadding[0]), numberOfAdditionalCabacZeroBytes); 1283 printf("Adding %d bytes of padding\n", UInt(numberOfAdditionalCabacZeroWords*3)); 1284 } 1285 else 1286 { 1287 printf("Standard would normally require adding %d bytes of padding\n", UInt(numberOfAdditionalCabacZeroWords*3)); 1288 } 1289 } 1290 } 1291 } 1292 1293 #if EFFICIENT_FIELD_IRAP 1294 class EfficientFieldIRAPMapping 1295 { 1296 private: 1297 Int IRAPGOPid; 1298 Bool IRAPtoReorder; 1299 Bool swapIRAPForward; 1300 1301 public: 1302 EfficientFieldIRAPMapping() : 1303 IRAPGOPid(-1), 1304 IRAPtoReorder(false), 1305 swapIRAPForward(false) 1306 { } 1307 1308 Void initialize(const Bool isField, const Int picIdInGOP, const Int gopSize, const Int POCLast, const Int numPicRcvd, const Int lastIDR, TEncGOP *pEncGop, TEncCfg *pCfg); 1309 1310 Int adjustGOPid(const Int gopID); 1311 Int restoreGOPid(const Int gopID); 1312 Int GetIRAPGOPid() const { return IRAPGOPid; } 1313 }; 1314 1315 #if SVC_EXTENSION 1316 Void EfficientFieldIRAPMapping::initialize(const Bool isField, const Int picIdInGOP, const Int gopSize, const Int POCLast, const Int numPicRcvd, const Int lastIDR, TEncGOP *pEncGop, TEncCfg *pCfg ) 1317 #else 1318 Void EfficientFieldIRAPMapping::initialize(const Bool isField, const Int gopSize, const Int POCLast, const Int numPicRcvd, const Int lastIDR, TEncGOP *pEncGop, TEncCfg *pCfg ) 1319 #endif 1320 { 1321 if(isField) 1322 { 1323 Int pocCurr; 1324 #if SVC_EXTENSION 1325 for ( Int iGOPid=picIdInGOP; iGOPid < picIdInGOP+1; iGOPid++ ) 1326 #else 1327 for ( Int iGOPid=0; iGOPid < gopSize; iGOPid++ ) 1328 #endif 1329 { 1330 // determine actual POC 1331 if(POCLast == 0) //case first frame or first top field 1332 { 1333 pocCurr=0; 1334 } 1335 else if(POCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value 1336 { 1337 pocCurr = 1; 1338 } 1339 else 1340 { 1341 pocCurr = POCLast - numPicRcvd + pCfg->getGOPEntry(iGOPid).m_POC - isField; 1342 } 1343 1344 // check if POC corresponds to IRAP 1345 NalUnitType tmpUnitType = pEncGop->getNalUnitType(pocCurr, lastIDR, isField); 1346 if(tmpUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && tmpUnitType <= NAL_UNIT_CODED_SLICE_CRA) // if picture is an IRAP 1347 { 1348 if(pocCurr%2 == 0 && iGOPid < gopSize-1 && pCfg->getGOPEntry(iGOPid).m_POC == pCfg->getGOPEntry(iGOPid+1).m_POC-1) 1349 { // if top field and following picture in enc order is associated bottom field 1350 IRAPGOPid = iGOPid; 1351 IRAPtoReorder = true; 1352 swapIRAPForward = true; 1353 break; 1354 } 1355 if(pocCurr%2 != 0 && iGOPid > 0 && pCfg->getGOPEntry(iGOPid).m_POC == pCfg->getGOPEntry(iGOPid-1).m_POC+1) 1356 { 1357 // if picture is an IRAP remember to process it first 1358 IRAPGOPid = iGOPid; 1359 IRAPtoReorder = true; 1360 swapIRAPForward = false; 1361 break; 1362 } 1363 } 1364 } 1365 } 1366 } 1367 1368 Int EfficientFieldIRAPMapping::adjustGOPid(const Int GOPid) 1369 { 1370 if(IRAPtoReorder) 1371 { 1372 if(swapIRAPForward) 1373 { 1374 if(GOPid == IRAPGOPid) 1375 { 1376 return IRAPGOPid +1; 1377 } 1378 else if(GOPid == IRAPGOPid +1) 1379 { 1380 return IRAPGOPid; 1381 } 1382 } 1383 else 1384 { 1385 if(GOPid == IRAPGOPid -1) 1386 { 1387 return IRAPGOPid; 1388 } 1389 else if(GOPid == IRAPGOPid) 1390 { 1391 return IRAPGOPid -1; 1392 } 1393 } 1394 } 1395 return GOPid; 1396 } 1397 1398 Int EfficientFieldIRAPMapping::restoreGOPid(const Int GOPid) 1399 { 1400 if(IRAPtoReorder) 1401 { 1402 if(swapIRAPForward) 1403 { 1404 if(GOPid == IRAPGOPid) 1405 { 1406 IRAPtoReorder = false; 1407 return IRAPGOPid +1; 1408 } 1409 else if(GOPid == IRAPGOPid +1) 1410 { 1411 return GOPid -1; 1412 } 1413 } 1414 else 1415 { 1416 if(GOPid == IRAPGOPid) 1417 { 1418 return IRAPGOPid -1; 1419 } 1420 else if(GOPid == IRAPGOPid -1) 1421 { 1422 IRAPtoReorder = false; 1423 return IRAPGOPid; 1424 } 1425 } 1426 } 1427 return GOPid; 1428 } 1429 1430 #endif 1431 1432 static UInt calculateCollocatedFromL1Flag(TEncCfg *pCfg, const Int GOPid, const Int gopSize) 1433 { 1434 Int iCloseLeft=1, iCloseRight=-1; 1435 for(Int i = 0; i<pCfg->getGOPEntry(GOPid).m_numRefPics; i++) 1436 { 1437 Int iRef = pCfg->getGOPEntry(GOPid).m_referencePics[i]; 1438 if(iRef>0&&(iRef<iCloseRight||iCloseRight==-1)) 1439 { 1440 iCloseRight=iRef; 1441 } 1442 else if(iRef<0&&(iRef>iCloseLeft||iCloseLeft==1)) 1443 { 1444 iCloseLeft=iRef; 1445 } 1446 } 1447 if(iCloseRight>-1) 1448 { 1449 iCloseRight=iCloseRight+pCfg->getGOPEntry(GOPid).m_POC-1; 1450 } 1451 if(iCloseLeft<1) 1452 { 1453 iCloseLeft=iCloseLeft+pCfg->getGOPEntry(GOPid).m_POC-1; 1454 while(iCloseLeft<0) 1455 { 1456 iCloseLeft+=gopSize; 1457 } 1458 } 1459 Int iLeftQP=0, iRightQP=0; 1460 for(Int i=0; i<gopSize; i++) 1461 { 1462 if(pCfg->getGOPEntry(i).m_POC==(iCloseLeft%gopSize)+1) 1463 { 1464 iLeftQP= pCfg->getGOPEntry(i).m_QPOffset; 1465 } 1466 if (pCfg->getGOPEntry(i).m_POC==(iCloseRight%gopSize)+1) 1467 { 1468 iRightQP=pCfg->getGOPEntry(i).m_QPOffset; 1469 } 1470 } 1471 if(iCloseRight>-1&&iRightQP<iLeftQP) 1472 { 1473 return 0; 1474 } 1475 else 1476 { 1477 return 1; 1478 } 1479 } 1480 1244 1481 // ==================================================================================================================== 1245 1482 // Public member functions … … 1247 1484 #if SVC_EXTENSION 1248 1485 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, 1486 #else 1487 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, 1488 #endif 1249 1489 TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, 1250 1490 Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ) 1251 #else 1252 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, 1253 TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, 1254 Bool isField, Bool isTff, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ) 1255 #endif 1491 1256 1492 { 1257 1493 // TODO: Split this function up. … … 1275 1511 1276 1512 #if EFFICIENT_FIELD_IRAP 1277 Int IRAPGOPid = -1; 1278 Bool IRAPtoReorder = false; 1279 Bool swapIRAPForward = false; 1280 if(isField) 1281 { 1282 Int pocCurr; 1513 EfficientFieldIRAPMapping effFieldIRAPMap; 1283 1514 #if SVC_EXTENSION 1284 for ( Int iGOPid=iPicIdInGOP; iGOPid < iPicIdInGOP+1; iGOPid++ ) 1285 #else 1286 for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ ) 1287 #endif 1288 { 1289 // determine actual POC 1290 if(iPOCLast == 0) //case first frame or first top field 1291 { 1292 pocCurr=0; 1293 } 1294 else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value 1295 { 1296 pocCurr = 1; 1297 } 1298 else 1299 { 1300 pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField; 1301 } 1302 1303 // check if POC corresponds to IRAP 1304 NalUnitType tmpUnitType = getNalUnitType(pocCurr, m_iLastIDR, isField); 1305 if(tmpUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && tmpUnitType <= NAL_UNIT_CODED_SLICE_CRA) // if picture is an IRAP 1306 { 1307 if(pocCurr%2 == 0 && iGOPid < m_iGopSize-1 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid+1).m_POC-1) 1308 { // if top field and following picture in enc order is associated bottom field 1309 IRAPGOPid = iGOPid; 1310 IRAPtoReorder = true; 1311 swapIRAPForward = true; 1312 break; 1313 } 1314 if(pocCurr%2 != 0 && iGOPid > 0 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid-1).m_POC+1) 1315 { 1316 // if picture is an IRAP remember to process it first 1317 IRAPGOPid = iGOPid; 1318 IRAPtoReorder = true; 1319 swapIRAPForward = false; 1320 break; 1321 } 1322 } 1323 } 1324 } 1325 #endif 1515 effFieldIRAPMap.initialize(isField, iPicIdInGOP, m_iGopSize, iPOCLast, iNumPicRcvd, m_iLastIDR, this, m_pcCfg); 1516 #else 1517 effFieldIRAPMap.initialize(isField, m_iGopSize, iPOCLast, iNumPicRcvd, m_iLastIDR, this, m_pcCfg); 1518 #endif 1519 #endif 1520 1326 1521 // reset flag indicating whether pictures have been encoded 1327 1522 for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ ) … … 1336 1531 { 1337 1532 #if EFFICIENT_FIELD_IRAP 1338 if(IRAPtoReorder) 1339 { 1340 if(swapIRAPForward) 1341 { 1342 if(iGOPid == IRAPGOPid) 1343 { 1344 iGOPid = IRAPGOPid +1; 1345 } 1346 else if(iGOPid == IRAPGOPid +1) 1347 { 1348 iGOPid = IRAPGOPid; 1349 } 1350 } 1351 else 1352 { 1353 if(iGOPid == IRAPGOPid -1) 1354 { 1355 iGOPid = IRAPGOPid; 1356 } 1357 else if(iGOPid == IRAPGOPid) 1358 { 1359 iGOPid = IRAPGOPid -1; 1360 } 1361 } 1362 } 1363 #endif 1364 1365 UInt uiColDir = 1; 1533 iGOPid=effFieldIRAPMap.adjustGOPid(iGOPid); 1534 #endif 1535 1366 1536 //-- For time output for each slice 1367 1537 clock_t iBeforeTime = clock(); 1368 1538 1369 //select uiColDir 1370 Int iCloseLeft=1, iCloseRight=-1; 1371 for(Int i = 0; i<m_pcCfg->getGOPEntry(iGOPid).m_numRefPics; i++) 1372 { 1373 Int iRef = m_pcCfg->getGOPEntry(iGOPid).m_referencePics[i]; 1374 if(iRef>0&&(iRef<iCloseRight||iCloseRight==-1)) 1375 { 1376 iCloseRight=iRef; 1377 } 1378 else if(iRef<0&&(iRef>iCloseLeft||iCloseLeft==1)) 1379 { 1380 iCloseLeft=iRef; 1381 } 1382 } 1383 if(iCloseRight>-1) 1384 { 1385 iCloseRight=iCloseRight+m_pcCfg->getGOPEntry(iGOPid).m_POC-1; 1386 } 1387 if(iCloseLeft<1) 1388 { 1389 iCloseLeft=iCloseLeft+m_pcCfg->getGOPEntry(iGOPid).m_POC-1; 1390 while(iCloseLeft<0) 1391 { 1392 iCloseLeft+=m_iGopSize; 1393 } 1394 } 1395 Int iLeftQP=0, iRightQP=0; 1396 for(Int i=0; i<m_iGopSize; i++) 1397 { 1398 if(m_pcCfg->getGOPEntry(i).m_POC==(iCloseLeft%m_iGopSize)+1) 1399 { 1400 iLeftQP= m_pcCfg->getGOPEntry(i).m_QPOffset; 1401 } 1402 if (m_pcCfg->getGOPEntry(i).m_POC==(iCloseRight%m_iGopSize)+1) 1403 { 1404 iRightQP=m_pcCfg->getGOPEntry(i).m_QPOffset; 1405 } 1406 } 1407 if(iCloseRight>-1&&iRightQP<iLeftQP) 1408 { 1409 uiColDir=0; 1410 } 1539 UInt uiColDir = calculateCollocatedFromL1Flag(m_pcCfg, iGOPid, m_iGopSize); 1411 1540 1412 1541 /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding … … 1433 1562 { 1434 1563 #if EFFICIENT_FIELD_IRAP 1435 if(IRAPtoReorder) 1436 { 1437 if(swapIRAPForward) 1438 { 1439 if(iGOPid == IRAPGOPid) 1440 { 1441 iGOPid = IRAPGOPid +1; 1442 IRAPtoReorder = false; 1443 } 1444 else if(iGOPid == IRAPGOPid +1) 1445 { 1446 iGOPid --; 1447 } 1448 } 1449 else 1450 { 1451 if(iGOPid == IRAPGOPid) 1452 { 1453 iGOPid = IRAPGOPid -1; 1454 } 1455 else if(iGOPid == IRAPGOPid -1) 1456 { 1457 iGOPid = IRAPGOPid; 1458 IRAPtoReorder = false; 1459 } 1460 } 1461 } 1564 iGOPid=effFieldIRAPMap.restoreGOPid(iGOPid); 1462 1565 #endif 1463 1566 continue; … … 2051 2154 } 2052 2155 } 2053 #endif //SVC_EXTENSION 2054 2055 #if ADAPTIVE_QP_SELECTION 2056 pcSlice->setTrQuant( m_pcEncTop->getTrQuant() ); 2057 #endif 2058 2059 #if SVC_EXTENSION 2156 2060 2157 if( pcSlice->getSliceType() == B_SLICE ) 2061 2158 { … … 2474 2571 /////////////////////////////////////////////////////////////////////////////////////////////////// File writing 2475 2572 // Set entropy coder 2476 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder , pcSlice);2573 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder ); 2477 2574 2478 2575 if ( m_bSeqFirst ) … … 2557 2654 } 2558 2655 2559 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder , pcSlice);2560 m_pcEntropyCoder->resetEntropy ( );2656 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder ); 2657 m_pcEntropyCoder->resetEntropy ( pcSlice ); 2561 2658 /* start slice NALunit */ 2562 2659 #if SVC_EXTENSION … … 2619 2716 // The final bitstream is either nalu.m_Bitstream or pcBitstreamRedirect; 2620 2717 // Complete the slice header info. 2621 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder , pcSlice);2718 m_pcEntropyCoder->setEntropyCoder ( m_pcCavlcCoder ); 2622 2719 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 2623 2720 #if SVC_EXTENSION … … 2675 2772 2676 2773 // cabac_zero_words processing 2677 { 2678 #if !SVC_EXTENSION 2679 const TComSPS &sps=*(pcSlice->getSPS()); 2680 #endif 2681 const Int log2subWidthCxsubHeightC = (pcPic->getComponentScaleX(COMPONENT_Cb)+pcPic->getComponentScaleY(COMPONENT_Cb)); 2682 const Int minCuWidth = pcPic->getMinCUWidth(); 2683 const Int minCuHeight = pcPic->getMinCUHeight(); 2684 #if SVC_EXTENSION 2685 const Int paddedWidth = ((pcSlice->getPicWidthInLumaSamples() + minCuWidth - 1) / minCuWidth) * minCuWidth; 2686 const Int paddedHeight= ((pcSlice->getPicHeightInLumaSamples() + minCuHeight - 1) / minCuHeight) * minCuHeight; 2687 const Int rawBits = paddedWidth * paddedHeight * 2688 (pcSlice->getBitDepth(CHANNEL_TYPE_LUMA) + 2*(pcSlice->getBitDepth(CHANNEL_TYPE_CHROMA)>>log2subWidthCxsubHeightC)); 2689 #else 2690 const Int paddedWidth = ((pcSlice->getSPS()->getPicWidthInLumaSamples() + minCuWidth - 1) / minCuWidth) * minCuWidth; 2691 const Int paddedHeight= ((pcSlice->getSPS()->getPicHeightInLumaSamples() + minCuHeight - 1) / minCuHeight) * minCuHeight; 2692 const Int rawBits = paddedWidth * paddedHeight * 2693 (sps.getBitDepth(CHANNEL_TYPE_LUMA) + 2*(sps.getBitDepth(CHANNEL_TYPE_CHROMA)>>log2subWidthCxsubHeightC)); 2694 #endif 2695 const std::size_t threshold = (32/3)*numBytesInVclNalUnits + (rawBits/32); 2696 if (binCountsInNalUnits >= threshold) 2697 { 2698 // need to add additional cabac zero words (each one accounts for 3 bytes (=00 00 03)) to increase numBytesInVclNalUnits 2699 const std::size_t targetNumBytesInVclNalUnits = ((binCountsInNalUnits - (rawBits/32))*3+31)/32; 2700 2701 if (targetNumBytesInVclNalUnits>numBytesInVclNalUnits) // It should be! 2702 { 2703 const std::size_t numberOfAdditionalBytesNeeded=targetNumBytesInVclNalUnits - numBytesInVclNalUnits; 2704 const std::size_t numberOfAdditionalCabacZeroWords=(numberOfAdditionalBytesNeeded+2)/3; 2705 const std::size_t numberOfAdditionalCabacZeroBytes=numberOfAdditionalCabacZeroWords*3; 2706 if (m_pcCfg->getCabacZeroWordPaddingEnabled()) 2707 { 2708 std::vector<Char> zeroBytesPadding(numberOfAdditionalCabacZeroBytes, Char(0)); 2709 for(std::size_t i=0; i<numberOfAdditionalCabacZeroWords; i++) 2710 { 2711 zeroBytesPadding[i*3+2]=3; // 00 00 03 2712 } 2713 accessUnit.back()->m_nalUnitData.write(&(zeroBytesPadding[0]), numberOfAdditionalCabacZeroBytes); 2714 printf("Adding %d bytes of padding\n", UInt(numberOfAdditionalCabacZeroWords*3)); 2715 } 2716 else 2717 { 2718 printf("Standard would normally require adding %d bytes of padding\n", UInt(numberOfAdditionalCabacZeroWords*3)); 2719 } 2720 } 2721 } 2722 } 2774 cabac_zero_word_padding(pcSlice, pcPic, binCountsInNalUnits, numBytesInVclNalUnits, accessUnit.back()->m_nalUnitData, m_pcCfg->getCabacZeroWordPaddingEnabled()); 2723 2775 2724 2776 pcPic->compressMotion(); … … 2747 2799 2748 2800 m_pcCfg->setEncodedFlag(iGOPid, true); 2749 xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE ); 2750 2751 //In case of field coding, compute the interlaced PSNR for both fields 2752 if(isField) 2753 { 2754 Bool bothFieldsAreEncoded = false; 2755 Int correspondingFieldPOC = pcPic->getPOC(); 2756 Int currentPicGOPPoc = m_pcCfg->getGOPEntry(iGOPid).m_POC; 2757 if(pcPic->getPOC() == 0) 2758 { 2759 // particular case for POC 0 and 1. 2760 // If they are not encoded first and separately from other pictures, we need to change this 2761 // POC 0 is always encoded first then POC 1 is encoded 2762 bothFieldsAreEncoded = false; 2763 } 2764 else if(pcPic->getPOC() == 1) 2765 { 2766 // if we are at POC 1, POC 0 has been encoded for sure 2767 correspondingFieldPOC = 0; 2768 bothFieldsAreEncoded = true; 2769 } 2770 else 2771 { 2772 if(pcPic->getPOC()%2 == 1) 2773 { 2774 correspondingFieldPOC -= 1; // all odd POC are associated with the preceding even POC (e.g poc 1 is associated to poc 0) 2775 currentPicGOPPoc -= 1; 2776 } 2777 else 2778 { 2779 correspondingFieldPOC += 1; // all even POC are associated with the following odd POC (e.g poc 0 is associated to poc 1) 2780 currentPicGOPPoc += 1; 2781 } 2782 for(Int i = 0; i < m_iGopSize; i ++) 2783 { 2784 if(m_pcCfg->getGOPEntry(i).m_POC == currentPicGOPPoc) 2785 { 2786 bothFieldsAreEncoded = m_pcCfg->getGOPEntry(i).m_isEncoded; 2787 break; 2788 } 2789 } 2790 } 2791 2792 if(bothFieldsAreEncoded) 2793 { 2794 //get complementary top field 2795 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 2796 while ((*iterPic)->getPOC() != correspondingFieldPOC) 2797 { 2798 iterPic ++; 2799 } 2800 TComPic* correspondingFieldPic = *(iterPic); 2801 2802 if( (pcPic->isTopField() && isTff) || (!pcPic->isTopField() && !isTff)) 2803 { 2804 xCalculateInterlacedAddPSNR(pcPic, correspondingFieldPic, pcPic->getPicYuvRec(), correspondingFieldPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE ); 2805 } 2806 else 2807 { 2808 xCalculateInterlacedAddPSNR(correspondingFieldPic, pcPic, correspondingFieldPic->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE ); 2809 } 2810 } 2811 } 2801 2802 xCalculateAddPSNRs( isField, isTff, iGOPid, pcPic, accessUnit, rcListPic, dEncTime, snr_conversion, printFrameMSE ); 2812 2803 2813 2804 if (!digestStr.empty()) … … 2850 2841 } 2851 2842 2852 xCreatePictureTimingSEI(IRAPGOPid, leadingSeiMessages, nestedSeiMessages, duInfoSeiMessages, accessUnit, pcSlice, isField, duData); 2843 #if EFFICIENT_FIELD_IRAP 2844 xCreatePictureTimingSEI(effFieldIRAPMap.GetIRAPGOPid(), leadingSeiMessages, nestedSeiMessages, duInfoSeiMessages, accessUnit, pcSlice, isField, duData); 2845 #else 2846 xCreatePictureTimingSEI(0, leadingSeiMessages, nestedSeiMessages, duInfoSeiMessages, accessUnit, pcSlice, isField, duData); 2847 #endif 2853 2848 if (m_pcCfg->getScalableNestingSEIEnabled()) 2854 2849 { … … 2884 2879 { 2885 2880 OutputNALUnit nalu(NAL_UNIT_EOS, 0, pcSlice->getLayerId()); 2886 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder , pcSlice);2881 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder); 2887 2882 accessUnit.push_back(new NALUnitEBSP(nalu)); 2888 2883 m_prevPicHasEos = true; … … 2910 2905 2911 2906 #if EFFICIENT_FIELD_IRAP 2912 if(IRAPtoReorder) 2913 { 2914 if(swapIRAPForward) 2915 { 2916 if(iGOPid == IRAPGOPid) 2917 { 2918 iGOPid = IRAPGOPid +1; 2919 IRAPtoReorder = false; 2920 } 2921 else if(iGOPid == IRAPGOPid +1) 2922 { 2923 iGOPid --; 2924 } 2925 } 2926 else 2927 { 2928 if(iGOPid == IRAPGOPid) 2929 { 2930 iGOPid = IRAPGOPid -1; 2931 } 2932 else if(iGOPid == IRAPGOPid -1) 2933 { 2934 iGOPid = IRAPGOPid; 2935 IRAPtoReorder = false; 2936 } 2937 } 2938 } 2907 iGOPid=effFieldIRAPMap.restoreGOPid(iGOPid); 2939 2908 #endif 2940 2909 } // iGOPid-loop … … 3152 3121 #endif 3153 3122 3123 Void TEncGOP::xCalculateAddPSNRs( const Bool isField, const Bool isFieldTopFieldFirst, const Int iGOPid, TComPic* pcPic, const AccessUnit&accessUnit, TComList<TComPic*> &rcListPic, const Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ) 3124 { 3125 xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE ); 3126 3127 //In case of field coding, compute the interlaced PSNR for both fields 3128 if(isField) 3129 { 3130 Bool bothFieldsAreEncoded = false; 3131 Int correspondingFieldPOC = pcPic->getPOC(); 3132 Int currentPicGOPPoc = m_pcCfg->getGOPEntry(iGOPid).m_POC; 3133 if(pcPic->getPOC() == 0) 3134 { 3135 // particular case for POC 0 and 1. 3136 // If they are not encoded first and separately from other pictures, we need to change this 3137 // POC 0 is always encoded first then POC 1 is encoded 3138 bothFieldsAreEncoded = false; 3139 } 3140 else if(pcPic->getPOC() == 1) 3141 { 3142 // if we are at POC 1, POC 0 has been encoded for sure 3143 correspondingFieldPOC = 0; 3144 bothFieldsAreEncoded = true; 3145 } 3146 else 3147 { 3148 if(pcPic->getPOC()%2 == 1) 3149 { 3150 correspondingFieldPOC -= 1; // all odd POC are associated with the preceding even POC (e.g poc 1 is associated to poc 0) 3151 currentPicGOPPoc -= 1; 3152 } 3153 else 3154 { 3155 correspondingFieldPOC += 1; // all even POC are associated with the following odd POC (e.g poc 0 is associated to poc 1) 3156 currentPicGOPPoc += 1; 3157 } 3158 for(Int i = 0; i < m_iGopSize; i ++) 3159 { 3160 if(m_pcCfg->getGOPEntry(i).m_POC == currentPicGOPPoc) 3161 { 3162 bothFieldsAreEncoded = m_pcCfg->getGOPEntry(i).m_isEncoded; 3163 break; 3164 } 3165 } 3166 } 3167 3168 if(bothFieldsAreEncoded) 3169 { 3170 //get complementary top field 3171 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 3172 while ((*iterPic)->getPOC() != correspondingFieldPOC) 3173 { 3174 iterPic ++; 3175 } 3176 TComPic* correspondingFieldPic = *(iterPic); 3177 3178 if( (pcPic->isTopField() && isFieldTopFieldFirst) || (!pcPic->isTopField() && !isFieldTopFieldFirst)) 3179 { 3180 xCalculateInterlacedAddPSNR(pcPic, correspondingFieldPic, pcPic->getPicYuvRec(), correspondingFieldPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE ); 3181 } 3182 else 3183 { 3184 xCalculateInterlacedAddPSNR(correspondingFieldPic, pcPic, correspondingFieldPic->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime, snr_conversion, printFrameMSE ); 3185 } 3186 } 3187 } 3188 } 3189 3154 3190 Void TEncGOP::xCalculateAddPSNR( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit& accessUnit, Double dEncTime, const InputColourSpaceConversion conversion, const Bool printFrameMSE ) 3155 3191 { -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h
r1289 r1291 219 219 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField ); 220 220 221 Void xCalculateAddPSNRs ( const Bool isField, const Bool isFieldTopFieldFirst, const Int iGOPid, TComPic* pcPic, const AccessUnit&accessUnit, TComList<TComPic*> &rcListPic, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ); 221 222 Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE ); 222 223 Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic* pcPicOrgSecondField, -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
r1287 r1291 246 246 { 247 247 m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder; 248 m_pcRDGoOnSbacCoder->setSlice(pcSlice); 249 m_pcRDGoOnSbacCoder->resetEntropy(); 248 m_pcRDGoOnSbacCoder->resetEntropy(pcSlice); 250 249 m_pcRDGoOnSbacCoder->resetBits(); 251 250 -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSbac.cpp
r1290 r1291 58 58 // new structure here 59 59 : m_pcBitIf ( NULL ) 60 , m_pcSlice ( NULL )61 60 , m_pcBinIf ( NULL ) 62 61 , m_numContextModels ( 0 ) … … 104 103 // ==================================================================================================================== 105 104 106 Void TEncSbac::resetEntropy ( )107 { 108 Int iQp = m_pcSlice->getSliceQp();109 SliceType eSliceType = m_pcSlice->getSliceType();110 111 SliceType encCABACTableIdx = m_pcSlice->getEncCABACTableIdx();112 if (! m_pcSlice->isIntra() && (encCABACTableIdx==B_SLICE || encCABACTableIdx==P_SLICE) && m_pcSlice->getPPS()->getCabacInitPresentFlag())105 Void TEncSbac::resetEntropy (const TComSlice *pSlice) 106 { 107 Int iQp = pSlice->getSliceQp(); 108 SliceType eSliceType = pSlice->getSliceType(); 109 110 SliceType encCABACTableIdx = pSlice->getEncCABACTableIdx(); 111 if (!pSlice->isIntra() && (encCABACTableIdx==B_SLICE || encCABACTableIdx==P_SLICE) && pSlice->getPPS()->getCabacInitPresentFlag()) 113 112 { 114 113 eSliceType = encCABACTableIdx; … … 161 160 * stores the index of the closest table. This index is used for the next P/B slice when cabac_init_present_flag is true. 162 161 */ 163 SliceType TEncSbac::determineCabacInitIdx( )164 { 165 Int qp = m_pcSlice->getSliceQp();166 167 if (! m_pcSlice->isIntra())162 SliceType TEncSbac::determineCabacInitIdx(const TComSlice *pSlice) 163 { 164 Int qp = pSlice->getSliceQp(); 165 166 if (!pSlice->isIntra()) 168 167 { 169 168 SliceType aSliceTypeChoices[] = {B_SLICE, P_SLICE}; -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSbac.h
r1287 r1291 74 74 75 75 // Virtual list 76 Void resetEntropy ( );77 SliceType determineCabacInitIdx ( );76 Void resetEntropy (const TComSlice *pSlice); 77 SliceType determineCabacInitIdx (const TComSlice *pSlice); 78 78 Void setBitstream ( TComBitIf* p ) { m_pcBitIf = p; m_pcBinIf->init( p ); } 79 Void setSlice ( TComSlice* p ) { m_pcSlice = p; }80 79 81 80 Void load ( const TEncSbac* pSrc ); … … 130 129 protected: 131 130 TComBitIf* m_pcBitIf; 132 TComSlice* m_pcSlice;133 131 TEncBinIf* m_pcBinIf; 134 132 -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r1289 r1291 119 119 m_pcCfg = pcEncTop; 120 120 m_pcListPic = pcEncTop->getListPic(); 121 #if SVC_EXTENSION 122 m_ppcTEncTop = pcEncTop->getLayerEnc(); 123 #endif 121 124 122 m_pcGOPEncoder = pcEncTop->getGOPEncoder(); 125 123 m_pcCuEncoder = pcEncTop->getCuEncoder(); … … 140 138 m_piRdPicQp = (Int* )xMalloc( Int, m_pcCfg->getDeltaQpRD() * 2 + 1 ); 141 139 m_pcRateCtrl = pcEncTop->getRateCtrl(); 140 141 #if SVC_EXTENSION 142 m_ppcTEncTop = pcEncTop->getLayerEnc(); 143 #endif 142 144 } 143 145 … … 724 726 725 727 UInt startCtuTsAddr, boundingCtuTsAddr; 726 xDetermineStartAndBoundingCtuTsAddr ( startCtuTsAddr, boundingCtuTsAddr, pcPic , false);728 xDetermineStartAndBoundingCtuTsAddr ( startCtuTsAddr, boundingCtuTsAddr, pcPic ); 727 729 728 730 for( UInt ctuTsAddr = startCtuTsAddr, ctuRsAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap( startCtuTsAddr); … … 757 759 UInt startCtuTsAddr; 758 760 UInt boundingCtuTsAddr; 759 TComSlice* pcSlice = pcPic->getSlice(getSliceIdx());761 TComSlice* const pcSlice = pcPic->getSlice(getSliceIdx()); 760 762 pcSlice->setSliceSegmentBits(0); 761 xDetermineStartAndBoundingCtuTsAddr ( startCtuTsAddr, boundingCtuTsAddr, pcPic , false);763 xDetermineStartAndBoundingCtuTsAddr ( startCtuTsAddr, boundingCtuTsAddr, pcPic ); 762 764 763 765 // initialize cost values - these are used by precompressSlice (they should be parameters). … … 766 768 m_uiPicDist = 0; 767 769 768 m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST] , pcSlice);769 m_pcEntropyCoder->resetEntropy ( );770 m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST] ); 771 m_pcEntropyCoder->resetEntropy ( pcSlice ); 770 772 771 773 TEncBinCABAC* pRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); … … 858 860 if (ctuRsAddr == firstCtuRsAddrOfTile) 859 861 { 860 m_pppcRDSbacCoder[0][CI_CURR_BEST]->resetEntropy( );862 m_pppcRDSbacCoder[0][CI_CURR_BEST]->resetEntropy(pcSlice); 861 863 } 862 864 else if ( ctuXPosInCtus == tileXPosInCtus && m_pcCfg->getWaveFrontsynchro()) 863 865 { 864 866 // reset and then update contexts to the state at the end of the top-right CTU (if within current slice and tile). 865 m_pppcRDSbacCoder[0][CI_CURR_BEST]->resetEntropy( );867 m_pppcRDSbacCoder[0][CI_CURR_BEST]->resetEntropy(pcSlice); 866 868 // Sync if the Top-Right is available. 867 869 TComDataCU *pCtuUp = pCtu->getCtuAbove(); … … 878 880 879 881 // set go-on entropy coder (used for all trial encodings - the cu encoder and encoder search also have a copy of the same pointer) 880 m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder , pcSlice);882 m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder ); 881 883 m_pcEntropyCoder->setBitstream( &tempBitCounter ); 882 884 tempBitCounter.resetBits(); … … 944 946 // which is used if there is a limit of the number of bytes per slice-segment. 945 947 946 m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST] , pcSlice);948 m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST] ); 947 949 m_pcEntropyCoder->setBitstream( &tempBitCounter ); 948 950 pRDSbacCoder->setBinCountingEnableFlag( true ); … … 1049 1051 Void TEncSlice::encodeSlice ( TComPic* pcPic, TComOutputBitstream* pcSubstreams, UInt &numBinsCoded ) 1050 1052 { 1051 TComSlice * pcSlice= pcPic->getSlice(getSliceIdx());1053 TComSlice *const pcSlice = pcPic->getSlice(getSliceIdx()); 1052 1054 1053 1055 const UInt startCtuTsAddr = pcSlice->getSliceSegmentCurStartCtuTsAddr(); … … 1060 1062 // initialise entropy coder for the slice 1061 1063 m_pcSbacCoder->init( (TEncBinIf*)m_pcBinCABAC ); 1062 m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder , pcSlice);1063 m_pcEntropyCoder->resetEntropy ();1064 m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder ); 1065 m_pcEntropyCoder->resetEntropy ( pcSlice ); 1064 1066 1065 1067 numBinsCoded = 0; … … 1117 1119 if (ctuTsAddr != startCtuTsAddr) // if it is the first CTU, then the entropy coder has already been reset 1118 1120 { 1119 m_pcEntropyCoder->resetEntropy( );1121 m_pcEntropyCoder->resetEntropy(pcSlice); 1120 1122 } 1121 1123 } … … 1125 1127 if (ctuTsAddr != startCtuTsAddr) // if it is the first CTU, then the entropy coder has already been reset 1126 1128 { 1127 m_pcEntropyCoder->resetEntropy( );1129 m_pcEntropyCoder->resetEntropy(pcSlice); 1128 1130 } 1129 1131 TComDataCU *pCtuUp = pCtu->getCtuAbove(); … … 1229 1231 if (pcSlice->getPPS()->getCabacInitPresentFlag() && !pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag()) 1230 1232 { 1231 m_encCABACTableIdx = m_pcEntropyCoder->determineCabacInitIdx( );1233 m_encCABACTableIdx = m_pcEntropyCoder->determineCabacInitIdx(pcSlice); 1232 1234 } 1233 1235 else … … 1240 1242 1241 1243 Void TEncSlice::calculateBoundingCtuTsAddrForSlice(UInt &startCtuTSAddrSlice, UInt &boundingCtuTSAddrSlice, Bool &haveReachedTileBoundary, 1242 TComPic* pcPic, const Bool encodingSlice, constInt sliceMode, const Int sliceArgument, const UInt sliceCurEndCtuTSAddr)1244 TComPic* pcPic, const Int sliceMode, const Int sliceArgument, const UInt sliceCurEndCtuTSAddr) 1243 1245 { 1244 1246 TComSlice* pcSlice = pcPic->getSlice(getSliceIdx()); 1245 1247 const UInt numberOfCtusInFrame = pcPic->getNumberOfCtusInFrame(); 1248 const TComPPS &pps=*(pcSlice->getPPS()); 1246 1249 boundingCtuTSAddrSlice=0; 1247 1250 haveReachedTileBoundary=false; … … 1256 1259 break; 1257 1260 case FIXED_NUMBER_OF_BYTES: 1258 boundingCtuTSAddrSlice = (encodingSlice) ? sliceCurEndCtuTSAddr : numberOfCtusInFrame;1261 boundingCtuTSAddrSlice = numberOfCtusInFrame; // This will be adjusted later if required. 1259 1262 break; 1260 1263 case FIXED_NUMBER_OF_TILES: … … 1283 1286 1284 1287 // Adjust for tiles and wavefronts. 1288 const Bool wavefrontsAreEnabled = pps.getEntropyCodingSyncEnabledFlag(); 1289 1285 1290 if ((sliceMode == FIXED_NUMBER_OF_CTU || sliceMode == FIXED_NUMBER_OF_BYTES) && 1286 ( m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0))1291 (pps.getNumTileRowsMinus1() > 0 || pps.getNumTileColumnsMinus1() > 0)) 1287 1292 { 1288 1293 const UInt ctuRSAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap(startCtuTSAddrSlice); 1289 1294 const UInt startTileIdx = pcPic->getPicSym()->getTileIdxMap(ctuRSAddr); 1290 const Bool wavefrontsAreEnabled = m_pcCfg->getWaveFrontsynchro();1291 1295 1292 1296 const TComTile *pStartingTile = pcPic->getPicSym()->getTComTile(startTileIdx); … … 1315 1319 } 1316 1320 } 1317 else if ((sliceMode == FIXED_NUMBER_OF_CTU || sliceMode == FIXED_NUMBER_OF_BYTES) && pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()&& ((startCtuTSAddrSlice % pcPic->getFrameWidthInCtus()) != 0))1321 else if ((sliceMode == FIXED_NUMBER_OF_CTU || sliceMode == FIXED_NUMBER_OF_BYTES) && wavefrontsAreEnabled && ((startCtuTSAddrSlice % pcPic->getFrameWidthInCtus()) != 0)) 1318 1322 { 1319 1323 // Adjust for wavefronts (no tiles). … … 1331 1335 * Updates startCtuTsAddr, boundingCtuTsAddr with appropriate CTU address 1332 1336 */ 1333 Void TEncSlice::xDetermineStartAndBoundingCtuTsAddr ( UInt& startCtuTsAddr, UInt& boundingCtuTsAddr, TComPic* pcPic , const Bool encodingSlice ) // TODO: this is now only ever called with encodingSlice=false1337 Void TEncSlice::xDetermineStartAndBoundingCtuTsAddr ( UInt& startCtuTsAddr, UInt& boundingCtuTsAddr, TComPic* pcPic ) 1334 1338 { 1335 1339 TComSlice* pcSlice = pcPic->getSlice(getSliceIdx()); … … 1340 1344 UInt boundingCtuTsAddrSlice; 1341 1345 calculateBoundingCtuTsAddrForSlice(startCtuTsAddrSlice, boundingCtuTsAddrSlice, haveReachedTileBoundarySlice, pcPic, 1342 encodingSlice,m_pcCfg->getSliceMode(), m_pcCfg->getSliceArgument(), pcSlice->getSliceCurEndCtuTsAddr());1346 m_pcCfg->getSliceMode(), m_pcCfg->getSliceArgument(), pcSlice->getSliceCurEndCtuTsAddr()); 1343 1347 pcSlice->setSliceCurEndCtuTsAddr( boundingCtuTsAddrSlice ); 1344 1348 pcSlice->setSliceCurStartCtuTsAddr( startCtuTsAddrSlice ); … … 1349 1353 UInt boundingCtuTsAddrSliceSegment; 1350 1354 calculateBoundingCtuTsAddrForSlice(startCtuTsAddrSliceSegment, boundingCtuTsAddrSliceSegment, haveReachedTileBoundarySliceSegment, pcPic, 1351 encodingSlice,m_pcCfg->getSliceSegmentMode(), m_pcCfg->getSliceSegmentArgument(), pcSlice->getSliceSegmentCurEndCtuTsAddr());1355 m_pcCfg->getSliceSegmentMode(), m_pcCfg->getSliceSegmentArgument(), pcSlice->getSliceSegmentCurEndCtuTsAddr()); 1352 1356 if (boundingCtuTsAddrSliceSegment>boundingCtuTsAddrSlice) 1353 1357 { … … 1381 1385 xCalcACDCParamSlice(pcSlice); 1382 1386 } 1383 #endif //SVC_EXTENSION1387 #endif 1384 1388 //! \} -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h
r1287 r1291 105 105 Void setUpLambda(TComSlice* slice, const Double dLambda, Int iQP); 106 106 #endif 107 Void calculateBoundingCtuTsAddrForSlice(UInt &startCtuTSAddrSlice, UInt &boundingCtuTSAddrSlice, Bool &haveReachedTileBoundary, TComPic* pcPic, const Bool encodingSlice, constInt sliceMode, const Int sliceArgument, const UInt uiSliceCurEndCtuTSAddr);107 Void calculateBoundingCtuTsAddrForSlice(UInt &startCtuTSAddrSlice, UInt &boundingCtuTSAddrSlice, Bool &haveReachedTileBoundary, TComPic* pcPic, const Int sliceMode, const Int sliceArgument, const UInt uiSliceCurEndCtuTSAddr); 108 108 109 109 #if SVC_EXTENSION … … 133 133 134 134 TEncCu* getCUEncoder() { return m_pcCuEncoder; } ///< CU encoder 135 Void xDetermineStartAndBoundingCtuTsAddr ( UInt& startCtuTsAddr, UInt& boundingCtuTsAddr, TComPic* pcPic , const Bool encodingSlice);135 Void xDetermineStartAndBoundingCtuTsAddr ( UInt& startCtuTsAddr, UInt& boundingCtuTsAddr, TComPic* pcPic ); 136 136 UInt getSliceIdx() { return m_uiSliceIdx; } 137 137 Void setSliceIdx(UInt i) { m_uiSliceIdx = i; } … … 146 146 Double xGetQPValueAccordingToLambda ( Double lambda ); 147 147 148 #if SVC_EXTENSION 149 #if JCTVC_M0259_LAMBDAREFINEMENT 148 #if SVC_EXTENSION && JCTVC_M0259_LAMBDAREFINEMENT 150 149 Double xCalEnhLambdaFactor( Double deltaQP , Double beta ); 151 150 #endif 152 #endif //SVC_EXTENSION153 151 }; 154 152
Note: See TracChangeset for help on using the changeset viewer.