Changeset 431 in SHVCSoftware for branches/SHM-3.1-dev/source/Lib
- Timestamp:
- 11 Oct 2013, 05:54:02 (11 years ago)
- Location:
- branches/SHM-3.1-dev/source/Lib
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-3.1-dev/source/Lib/TLibCommon/CommonDef.h
r412 r431 59 59 #define NV_VERSION "3.0.1" ///< Current software version 60 60 #else 61 #define NV_VERSION "1 1.0" ///< Current software version61 #define NV_VERSION "12.0" ///< Current software version 62 62 #endif 63 63 … … 200 200 201 201 NAL_UNIT_CODED_SLICE_TSA_N, // 2 202 NAL_UNIT_CODED_SLICE_T SA_R, // 3202 NAL_UNIT_CODED_SLICE_TLA_R, // 3 203 203 204 204 NAL_UNIT_CODED_SLICE_STSA_N, // 4 -
branches/SHM-3.1-dev/source/Lib/TLibCommon/NAL.h
r412 r431 76 76 return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R 77 77 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N 78 || m_nalUnitType == NAL_UNIT_CODED_SLICE_T SA_R78 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA_R 79 79 || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N 80 80 || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComMv.h
r370 r431 40 40 41 41 #include "CommonDef.h" 42 #include <cstdlib> 42 43 43 44 //! \ingroup TLibCommon -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPic.cpp
r389 r431 53 53 , m_bUsedByCurr (false) 54 54 , m_bIsLongTerm (false) 55 , m_bIsUsedAsLongTerm (false)56 55 , m_apcPicSym (NULL) 57 56 , m_pcPicYuvPred (NULL) -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPic.h
r377 r431 66 66 Bool m_bUsedByCurr; // Used by current picture 67 67 Bool m_bIsLongTerm; // IS long term picture 68 Bool m_bIsUsedAsLongTerm; // long term picture is used as reference before69 68 TComPicSym* m_apcPicSym; // Symbol 70 69 … … 88 87 Window m_defaultDisplayWindow; 89 88 89 Bool m_isTop; 90 Bool m_isField; 91 90 92 std::vector<std::vector<TComDataCU*> > m_vSliceCUDataLink; 91 93 … … 194 196 std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter (Int sliceID) { return m_vSliceCUDataLink[sliceID];} 195 197 198 /* field coding parameters*/ 199 200 Void setTopField(bool b) {m_isTop = b;} 201 Bool isTopField() {return m_isTop;} 202 Void setField(bool b) {m_isField = b;} 203 Bool isField() {return m_isField;} 204 196 205 /** transfer ownership of seis to this picture */ 197 206 void setSEIs(SEIMessages& seis) { m_SEIs = seis; } -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPicSym.cpp
r377 r431 61 61 ,m_uiNumAllocatedSlice (0) 62 62 ,m_apcTComDataCU (NULL) 63 ,m_iTileBoundaryIndependenceIdr (0)64 63 ,m_iNumColumnsMinus1 (0) 65 64 ,m_iNumRowsMinus1(0) -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPicSym.h
r313 r431 100 100 TComDataCU** m_apcTComDataCU; ///< array of CU data 101 101 102 Int m_iTileBoundaryIndependenceIdr;103 102 Int m_iNumColumnsMinus1; 104 103 Int m_iNumRowsMinus1; -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComPrediction.cpp
r345 r431 696 696 Int k, l, bottomLeft, topRight; 697 697 Int horPred; 698 Int leftColumn[MAX_CU_SIZE ], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];698 Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; 699 699 UInt blkSize = width; 700 700 UInt offset2D = width; -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComRdCost.h
r313 r431 116 116 private: 117 117 // for distortion 118 Int m_iBlkWidth;119 Int m_iBlkHeight;120 118 121 119 #if AMP_SAD -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComRom.cpp
r414 r431 55 55 ::memset( g_aucConvertToBit, -1, sizeof( g_aucConvertToBit ) ); 56 56 c=0; 57 for ( i=4; i< MAX_CU_SIZE; i*=2 )57 for ( i=4; i<=MAX_CU_SIZE; i*=2 ) 58 58 { 59 59 g_aucConvertToBit[ i ] = c; 60 60 c++; 61 61 } 62 g_aucConvertToBit[ i ] = c;63 62 64 63 c=2; … … 278 277 279 278 #if FAST_UDI_USE_MPM 280 const UChar g_aucIntraModeNumFast[ 7] =279 const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = 281 280 { 282 281 3, // 2x2 … … 285 284 3, // 16x16 286 285 3, // 32x32 287 3, // 64x64 288 3 // 128x128 286 3 // 64x64 289 287 }; 290 288 #else // FAST_UDI_USE_MPM 291 const UChar g_aucIntraModeNumFast[ 7] =289 const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = 292 290 { 293 291 3, // 2x2 … … 296 294 4, // 16x16 33 297 295 4, // 32x32 33 298 5, // 64x64 33 299 4 // 128x128 33 296 5 // 64x64 33 300 297 }; 301 298 #endif // FAST_UDI_USE_MPM -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComRom.h
r414 r431 51 51 // ==================================================================================================================== 52 52 53 #define MAX_CU_DEPTH 7// log2(LCUSize)53 #define MAX_CU_DEPTH 6 // log2(LCUSize) 54 54 #define MAX_CU_SIZE (1<<(MAX_CU_DEPTH)) // maximum allowable size of CU 55 55 #define MIN_PU_SIZE 4 … … 131 131 // ==================================================================================================================== 132 132 133 extern const UChar g_aucIntraModeNumFast[ 7];133 extern const UChar g_aucIntraModeNumFast[ MAX_CU_DEPTH ]; 134 134 135 135 #if FAST_INTRA_SHVC -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComSlice.cpp
r430 r431 186 186 m_aiNumRefIdx[0] = 0; 187 187 m_aiNumRefIdx[1] = 0; 188 188 189 m_colFromL0Flag = 1; 189 190 … … 292 293 if (!pocHasMsb) 293 294 { 294 poc = poc % pocCycle;295 poc = poc & (pocCycle - 1); 295 296 } 296 297 … … 303 304 if (!pocHasMsb) 304 305 { 305 picPoc = picPoc % pocCycle;306 picPoc = picPoc & (pocCycle - 1); 306 307 } 307 308 … … 966 967 } 967 968 968 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic)969 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) 969 970 { 970 971 for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) … … 992 993 { 993 994 pocCRA = getPOC(); 994 prevRAPisBLA = false;995 associatedIRAPType = getNalUnitType(); 995 996 } 996 997 else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found 997 998 { 998 999 pocCRA = getPOC(); 999 prevRAPisBLA = false;1000 associatedIRAPType = getNalUnitType(); 1000 1001 } 1001 1002 else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP … … 1004 1005 { 1005 1006 pocCRA = getPOC(); 1006 prevRAPisBLA = true;1007 associatedIRAPType = getNalUnitType(); 1007 1008 } 1008 1009 } … … 1029 1030 { 1030 1031 TComPic* rpcPic; 1032 setAssociatedIRAPPOC(pocCRA); 1031 1033 Int pocCurr = getPOC(); 1032 1034 … … 1195 1197 } 1196 1198 1197 Int TComSlice::m_prev POC = 0;1199 Int TComSlice::m_prevTid0POC = 0; 1198 1200 1199 1201 /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. … … 1250 1252 } 1251 1253 1254 1255 Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) 1256 { 1257 TComPic* rpcPic; 1258 1259 Int nalUnitType = this->getNalUnitType(); 1260 1261 // When a picture is a leading picture, it shall be a RADL or RASL picture. 1262 if(this->getAssociatedIRAPPOC() > this->getPOC()) 1263 { 1264 // Do not check IRAP pictures since they may get a POC lower than their associated IRAP 1265 if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || 1266 nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) 1267 { 1268 assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1269 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || 1270 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 1271 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); 1272 } 1273 } 1274 1275 // When a picture is a trailing picture, it shall not be a RADL or RASL picture. 1276 if(this->getAssociatedIRAPPOC() < this->getPOC()) 1277 { 1278 assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && 1279 nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && 1280 nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && 1281 nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); 1282 } 1283 1284 // No RASL pictures shall be present in the bitstream that are associated 1285 // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. 1286 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1287 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 1288 { 1289 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && 1290 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); 1291 } 1292 1293 // No RASL pictures shall be present in the bitstream that are associated with 1294 // an IDR picture. 1295 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1296 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 1297 { 1298 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && 1299 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); 1300 } 1301 1302 // No RADL pictures shall be present in the bitstream that are associated with 1303 // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated 1304 // with an IDR picture having nal_unit_type equal to IDR_N_LP. 1305 if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 1306 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) 1307 { 1308 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && 1309 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); 1310 } 1311 1312 // loop through all pictures in the reference picture buffer 1313 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 1314 while ( iterPic != rcListPic.end()) 1315 { 1316 rpcPic = *(iterPic++); 1317 if (rpcPic->getPOC() == this->getPOC()) 1318 { 1319 continue; 1320 } 1321 1322 // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture 1323 // in decoding order shall precede the IRAP picture in output order. 1324 // (Note that any picture following in output order would be present in the DPB) 1325 if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) 1326 { 1327 if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || 1328 nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || 1329 nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 1330 nalUnitType == NAL_UNIT_CODED_SLICE_CRA || 1331 nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || 1332 nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) 1333 { 1334 assert(rpcPic->getPOC() < this->getPOC()); 1335 } 1336 } 1337 1338 // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture 1339 // in decoding order shall precede any RADL picture associated with the IRAP 1340 // picture in output order. 1341 if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) 1342 { 1343 if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 1344 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) 1345 { 1346 // rpcPic precedes the IRAP in decoding order 1347 if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) 1348 { 1349 // rpcPic must not be the IRAP picture 1350 if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) 1351 { 1352 assert(rpcPic->getPOC() < this->getPOC()); 1353 } 1354 } 1355 } 1356 } 1357 1358 // When a picture is a leading picture, it shall precede, in decoding order, 1359 // all trailing pictures that are associated with the same IRAP picture. 1360 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1361 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || 1362 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 1363 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) 1364 { 1365 if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) 1366 { 1367 // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB 1368 // rpcPic would violate the constraint if it was a trailing picture 1369 assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); 1370 } 1371 } 1372 1373 // Any RASL picture associated with a CRA or BLA picture shall precede any 1374 // RADL picture associated with the CRA or BLA picture in output order 1375 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1376 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 1377 { 1378 if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || 1379 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || 1380 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 1381 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && 1382 this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) 1383 { 1384 if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || 1385 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) 1386 { 1387 assert(rpcPic->getPOC() > this->getPOC()); 1388 } 1389 } 1390 } 1391 1392 // Any RASL picture associated with a CRA picture shall follow, in output 1393 // order, any IRAP picture that precedes the CRA picture in decoding order. 1394 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 1395 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 1396 { 1397 if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) 1398 { 1399 if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && 1400 (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || 1401 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || 1402 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 1403 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || 1404 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || 1405 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) 1406 { 1407 assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); 1408 } 1409 } 1410 } 1411 } 1412 } 1413 1252 1414 /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. 1253 1415 */ … … 1256 1418 TComPic* rpcPic; 1257 1419 Int i, isReference; 1420 1421 checkLeadingPictureRestrictions(rcListPic); 1258 1422 1259 1423 // loop through all pictures in the reference picture buffer … … 1292 1456 else 1293 1457 { 1294 if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) 1458 Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); 1459 Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); 1460 Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); 1461 if(rpcPic->getIsLongTerm() && curPoc == refPoc) 1295 1462 { 1296 1463 isReference = 1; … … 1311 1478 assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); 1312 1479 //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture 1313 if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_T SA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N)1480 if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) 1314 1481 { 1315 1482 assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); … … 1352 1519 else 1353 1520 { 1354 if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced()) 1521 Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); 1522 Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); 1523 Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); 1524 if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) 1355 1525 { 1356 1526 isAvailable = 1; … … 1371 1541 if (!pReferencePictureSet->getCheckLTMSBPresent(i)) 1372 1542 { 1373 curPoc = curPoc % pocCycle;1374 refPoc = refPoc % pocCycle;1543 curPoc = curPoc & (pocCycle - 1); 1544 refPoc = refPoc & (pocCycle - 1); 1375 1545 } 1376 1546 … … 2114 2284 } 2115 2285 2116 2286 /* 2117 2287 Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. 2118 2288 */ 2119 2289 Int i, j; 2120 2290 UInt birateValue, cpbSizeValue; … … 2410 2580 TComScalingList::TComScalingList() 2411 2581 { 2412 m_useTransformSkip = false;2413 2582 init(); 2414 2583 } 2584 2415 2585 TComScalingList::~TComScalingList() 2416 2586 { … … 2495 2665 { 2496 2666 src = getScalingListAddress(sizeIdc, listIdc); 2667 2497 2668 fseek(fp,0,0); 2498 2669 do -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComSlice.h
r425 r431 166 166 #endif 167 167 168 Bool getUseTransformSkip () { return m_useTransformSkip; }169 Void setUseTransformSkip (Bool b) { m_useTransformSkip = b; }170 171 168 Int* getScalingListAddress (UInt sizeId, UInt listId) { return m_scalingListCoef[sizeId][listId]; } //!< get matrix coefficient 172 173 169 Bool checkPredMode (UInt sizeId, UInt listId); 174 175 170 Void setRefMatrixId (UInt sizeId, UInt listId, UInt u) { m_refMatrixId[sizeId][listId] = u; } //!< set reference matrix ID 176 171 UInt getRefMatrixId (UInt sizeId, UInt listId) { return m_refMatrixId[sizeId][listId]; } //!< get reference matrix ID … … 201 196 Void init (); 202 197 Void destroy (); 203 204 198 Int m_scalingListDC [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< the DC value of the matrix coefficient for 16x16 205 199 Bool m_useDefaultScalingMatrixFlag [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< UseDefaultScalingMatrixFlag … … 213 207 214 208 UInt m_predMatrixId [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< reference list index 215 216 Int *m_scalingListCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix 217 218 Bool m_useTransformSkip; //!< transform skipping flag for setting default scaling matrix for 4x4 209 Int *m_scalingListCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; //!< quantization matrix 219 210 }; 220 211 … … 1627 1618 Int m_iPOC; 1628 1619 Int m_iLastIDR; 1629 static Int m_prevPOC; 1620 Int m_iAssociatedIRAP; 1621 NalUnitType m_iAssociatedIRAPType; 1622 static Int m_prevTid0POC; 1630 1623 TComReferencePictureSet *m_pcRPS; 1631 1624 TComReferencePictureSet m_LocalRPS; … … 1788 1781 Void setRPSidx ( Int iBDidx ) { m_iBDidx = iBDidx; } 1789 1782 Int getRPSidx () { return m_iBDidx; } 1790 Int getPrev POC () { return m_prevPOC; }1783 Int getPrevTid0POC () { return m_prevTid0POC; } 1791 1784 TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; } 1792 1785 Void setLastIDR(Int iIDRPOC) { m_iLastIDR = iIDRPOC; } 1793 1786 Int getLastIDR() { return m_iLastIDR; } 1787 Void setAssociatedIRAPPOC(Int iAssociatedIRAPPOC) { m_iAssociatedIRAP = iAssociatedIRAPPOC; } 1788 Int getAssociatedIRAPPOC() { return m_iAssociatedIRAP; } 1789 Void setAssociatedIRAPType(NalUnitType associatedIRAPType) { m_iAssociatedIRAPType = associatedIRAPType; } 1790 NalUnitType getAssociatedIRAPType() { return m_iAssociatedIRAPType; } 1794 1791 SliceType getSliceType () { return m_eSliceType; } 1795 1792 Int getPOC () { return m_iPOC; } … … 1817 1814 Void checkColRefIdx (UInt curSliceIdx, TComPic* pic); 1818 1815 Bool getIsUsedAsLongTerm (Int i, Int j) { return m_bIsUsedAsLongTerm[i][j]; } 1816 Void setIsUsedAsLongTerm (Int i, Int j, Bool value) { m_bIsUsedAsLongTerm[i][j] = value; } 1819 1817 Bool getCheckLDC () { return m_bCheckLDC; } 1820 1818 Bool getMvdL1ZeroFlag () { return m_bLMvdL1Zero; } … … 1826 1824 Void setReferenced(Bool b) { m_bRefenced = b; } 1827 1825 Bool isReferenced() { return m_bRefenced; } 1828 Void setPOC ( Int i ) { m_iPOC = i; if(getTLayer()==0) m_prevPOC=i; } 1826 Bool isReferenceNalu() { return ((getNalUnitType() <= NAL_UNIT_RESERVED_VCL_R15) && (getNalUnitType()%2 != 0)) || ((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_RESERVED_IRAP_VCL23) ); } 1827 Void setPOC ( Int i ) { m_iPOC = i; if ((getTLayer()==0) && (isReferenceNalu() && (getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) {m_prevTid0POC=i;} } 1829 1828 Void setNalUnitType ( NalUnitType e ) { m_eNalUnitType = e; } 1830 1829 NalUnitType getNalUnitType () const { return m_eNalUnitType; } … … 1848 1847 #endif 1849 1848 1850 Void checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic);1849 Void checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic); 1851 1850 Void decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic); 1852 1851 Void setSliceType ( SliceType e ) { m_eSliceType = e; } … … 1917 1916 Void setTLayerInfo( UInt uiTLayer ); 1918 1917 Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum ); 1918 Void checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic ); 1919 1919 Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList); 1920 1920 Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ); -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TComWeightPrediction.h
r313 r431 53 53 class TComWeightPrediction 54 54 { 55 wpScalingParam m_wp0[3], m_wp1[3];56 57 55 public: 58 56 TComWeightPrediction(); -
branches/SHM-3.1-dev/source/Lib/TLibCommon/TypeDef.h
r425 r431 43 43 #define SYNTAX_BYTES 10 ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)] 44 44 45 #define HM12_RANDOM_ACCESS 146 45 #define RANDOM_ACCESS_SEI_FIX 1 46 #if SVC_EXTENSION 47 47 #define VPS_NUH_LAYER_ID 1 ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0 48 #if SVC_EXTENSION49 48 #define MAX_LAYERS 2 ///< max number of layers the codec is supposed to handle 50 49 #define POC_RESET_FLAG 1 ///< JCTVC-N0244: POC reset flag for layer pictures. … … 156 155 #define RC_SHVC_HARMONIZATION 1 ///< JCTVC-M0037: rate control for SHVC 157 156 157 #define VIEW_ID_RELATED_SIGNALING 1 ///< Introduce syntax elements view_id_len_minus1 and view_id_val 158 #define M0043_LAYERS_PRESENT_SEI 0 ///< JCTVC-M0043: add layers present SEI. Macro shall be equal to 0 according to the JCTVC-N0174 discussion. The code is to be removed. 158 159 #else 159 160 #define SYNTAX_OUTPUT 0 … … 165 166 166 167 #define FIX1071 1 ///< fix for issue #1071 167 #define VIEW_ID_RELATED_SIGNALING 1 ///< Introduce syntax elements view_id_len_minus1 and view_id_val168 #define M0043_LAYERS_PRESENT_SEI 0 ///< JCTVC-M0043: add layers present SEI. Macro shall be equal to 0 according to the JCTVC-N0174 discussion. The code is to be removed.169 168 170 169 #define MAX_NUM_PICS_IN_SOP 1024 -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/NALread.cpp
r412 r431 126 126 else 127 127 { 128 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_T SA_R128 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA_R 129 129 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N 130 130 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/SEIread.cpp
r313 r431 349 349 350 350 /* restore primary bitstream for sei_message */ 351 getBitstream()->deleteFifo(); 351 352 delete getBitstream(); 352 353 setBitstream(bs); -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/SyntaxElementParser.cpp
r313 r431 52 52 if (length < 10) 53 53 { 54 fprintf( g_hTrace, "%-50s u(%d) : % d\n", pSymbolName, length, rValue );54 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 55 55 } 56 56 else 57 57 { 58 fprintf( g_hTrace, "%-50s u(%d) : % d\n", pSymbolName, length, rValue );58 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 59 59 } 60 60 fflush ( g_hTrace ); … … 65 65 xReadUvlc (rValue); 66 66 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 67 fprintf( g_hTrace, "%-50s ue(v) : % d\n", pSymbolName, rValue );67 fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 68 68 fflush ( g_hTrace ); 69 69 } -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
r427 r431 1614 1614 READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 1615 1615 Int iPOClsb = uiCode; 1616 Int iPrevPOC = rpcSlice->getPrev POC();1616 Int iPrevPOC = rpcSlice->getPrevTid0POC(); 1617 1617 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 1618 Int iPrevPOClsb = iPrevPOC %iMaxPOClsb;1618 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); 1619 1619 Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; 1620 1620 Int iPOCmsb; … … 1738 1738 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 1739 1739 rps->setCheckLTMSBPresent(j,false); 1740 1741 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 1742 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 1743 { 1744 deltaPocMSBCycleLT = 0; 1745 } 1740 1746 } 1741 1747 prevDeltaMSB = deltaPocMSBCycleLT; -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecSlice.h
r313 r431 65 65 TDecEntropy* m_pcEntropyDecoder; 66 66 TDecCu* m_pcCuDecoder; 67 UInt m_uiCurrSliceIdx;68 67 69 68 TDecSbac* m_pcBufferSbacDecoders; ///< line to store temporary contexts, one per column of tiles. -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecTop.cpp
r424 r431 57 57 g_nSymbolCounter = 0; 58 58 #endif 59 m_associatedIRAPType = NAL_UNIT_INVALID; 59 60 m_pocCRA = 0; 60 m_prevRAPisBLA = false;61 61 m_pocRandomAccess = MAX_INT; 62 62 #if !SVC_EXTENSION … … 77 77 m_pBLSyntaxFile = NULL; 78 78 #endif 79 #if HM12_RANDOM_ACCESS80 79 m_prevSliceSkipped = false; 81 80 m_skippedPOC = 0; 82 #endif83 81 } 84 82 … … 700 698 #endif 701 699 702 #if HM12_RANDOM_ACCESS703 700 // set POC for dependent slices in skipped pictures 704 701 if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) … … 706 703 m_apcSlicePilot->setPOC(m_skippedPOC); 707 704 } 708 #endif 705 706 m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); 707 m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); 709 708 710 709 // Skip pictures due to random access 711 710 if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) 712 711 { 713 #if HM12_RANDOM_ACCESS714 712 m_prevSliceSkipped = true; 715 713 m_skippedPOC = m_apcSlicePilot->getPOC(); 716 #endif717 714 return false; 718 715 } … … 720 717 if (isSkipPictureForBLA(iPOCLastDisplay)) 721 718 { 722 #if HM12_RANDOM_ACCESS723 719 m_prevSliceSkipped = true; 724 720 m_skippedPOC = m_apcSlicePilot->getPOC(); 725 #endif726 721 return false; 727 722 } 728 723 729 #if HM12_RANDOM_ACCESS730 724 // clear previous slice skipped flag 731 725 m_prevSliceSkipped = false; 732 #endif733 726 734 727 // exit when a new picture is found … … 913 906 xGetNewPicBuffer (m_apcSlicePilot, pcPic); 914 907 908 Bool isField = false; 909 Bool isTff = false; 910 911 if(!m_SEIs.empty()) 912 { 913 // Check if any new Picture Timing SEI has arrived 914 SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); 915 if (pictureTimingSEIs.size()>0) 916 { 917 SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); 918 isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2); 919 isTff = (pictureTiming->m_picStruct == 1); 920 } 921 } 922 923 //Set Field/Frame coding mode 924 m_pcPic->setField(isField); 925 m_pcPic->setTopField(isTff); 926 915 927 // transfer any SEI messages that have been received to the picture 916 928 pcPic->setSEIs(m_SEIs); … … 1052 1064 if (bNextSlice) 1053 1065 { 1054 pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_ prevRAPisBLA, m_cListPic );1066 pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); 1055 1067 // Set reference list 1056 1068 #if SVC_EXTENSION … … 1251 1263 pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); 1252 1264 } 1253 pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip());1254 1265 if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) 1255 1266 { … … 1497 1508 case NAL_UNIT_CODED_SLICE_TRAIL_R: 1498 1509 case NAL_UNIT_CODED_SLICE_TRAIL_N: 1499 case NAL_UNIT_CODED_SLICE_T SA_R:1510 case NAL_UNIT_CODED_SLICE_TLA_R: 1500 1511 case NAL_UNIT_CODED_SLICE_TSA_N: 1501 1512 case NAL_UNIT_CODED_SLICE_STSA_R: … … 1532 1543 Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) 1533 1544 { 1534 if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) 1545 if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && 1546 m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) 1535 1547 { 1536 1548 iPOCLastDisplay++; -
branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecTop.h
r414 r431 67 67 Int m_iMaxRefPicNum; 68 68 69 NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture 69 70 Int m_pocCRA; ///< POC number of the latest CRA picture 70 Bool m_prevRAPisBLA; ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture71 71 Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) 72 72 … … 107 107 Bool m_bFirstSliceInSequence; 108 108 #endif 109 #if HM12_RANDOM_ACCESS110 109 Bool m_prevSliceSkipped; 111 110 Int m_skippedPOC; 112 #endif113 111 114 112 #if SVC_EXTENSION … … 122 120 fstream* m_pBLReconFile; 123 121 Int m_iBLSourceWidth; 124 Int m_iBLSourceHeight; 122 Int m_iBLSourceHeight; 125 123 #endif 126 124 #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS … … 159 157 160 158 Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); 159 #if SVC_EXTENSION 161 160 #if EARLY_REF_PIC_MARKING 162 161 Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList); 163 162 #endif 164 165 #if SVC_EXTENSION166 163 UInt getLayerId () { return m_layerId; } 167 164 Void setLayerId (UInt layer) { m_layerId = layer; } -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncAnalyze.cpp
r313 r431 57 57 #endif 58 58 59 TEncAnalyze m_gcAnalyzeAll_in; 59 60 //! \} -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncAnalyze.h
r313 r431 131 131 fclose(pFile); 132 132 } 133 134 Void printOutInterlaced ( Char cDelim, Double bits ) 135 { 136 Double dFps = m_dFrmRate; //--CFG_KDY 137 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 138 139 printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); 140 //printf( "\t------------ " " ----------" " -------- " " -------- " " --------\n" ); 141 printf( "\t %8d %c" "%12.4lf " "%8.4lf " "%8.4lf " "%8.4lf\n", 142 getNumPic(), cDelim, 143 bits * dScale, 144 getPsnrY() / (Double)getNumPic(), 145 getPsnrU() / (Double)getNumPic(), 146 getPsnrV() / (Double)getNumPic() ); 147 } 148 149 Void printSummaryOutInterlaced (Int bits) 150 { 151 FILE* pFile = fopen ("summaryTotal.txt", "at"); 152 Double dFps = m_dFrmRate; //--CFG_KDY 153 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 154 155 fprintf(pFile, "%f\t %f\t %f\t %f\n", bits * dScale, 156 getPsnrY() / (Double)getNumPic(), 157 getPsnrU() / (Double)getNumPic(), 158 getPsnrV() / (Double)getNumPic() ); 159 fclose(pFile); 160 } 133 161 134 162 Void printSummary(Char ch) … … 178 206 #endif 179 207 208 extern TEncAnalyze m_gcAnalyzeAll_in; 180 209 //! \} 181 210 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r427 r431 1281 1281 if( !pcSlice->getPocResetFlag() ) 1282 1282 { 1283 picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1283 picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1284 1284 } 1285 1285 else 1286 1286 { 1287 picOrderCntLSB = (pcSlice->getPocValueBeforeReset()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1288 } 1289 #else 1290 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1287 picOrderCntLSB = (pcSlice->getPocValueBeforeReset()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1288 } 1289 #else 1290 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1291 1291 #endif 1292 1292 WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); … … 2142 2142 { 2143 2143 // Bool state = true, state2 = false; 2144 Int lsb = ltrpPOC % (1<<pcSlice->getSPS()->getBitsForPOC());2144 Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 2145 2145 for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) 2146 2146 { -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCu.cpp
r389 r431 379 379 m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); 380 380 381 // variables for fast encoder decision382 Bool bEarlySkip = false;383 Bool bTrySplit = true;384 Double fRD_Skip = MAX_DOUBLE;385 386 381 // variable for Early CU determination 387 382 Bool bSubBranch = true; … … 390 385 Bool doNotBlockPu = true; 391 386 Bool earlyDetectionSkipMode = false; 392 393 Bool bTrySplitDQP = true;394 395 static Double afCost[ MAX_CU_DEPTH ];396 static Int aiNum [ MAX_CU_DEPTH ];397 398 if ( rpcBestCU->getAddr() == 0 )399 {400 ::memset( afCost, 0, sizeof( afCost ) );401 ::memset( aiNum, 0, sizeof( aiNum ) );402 }403 387 404 388 Bool bBoundary = false; … … 471 455 if (rpcBestCU->getLayerId() > 0) 472 456 { 473 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 474 testInter = false; 475 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 476 testInter = false; 457 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 458 { 459 testInter = false; 460 } 461 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 462 { 463 testInter = false; 464 } 477 465 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 478 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 479 testInter = false; 466 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 467 { 468 testInter = false; 469 } 480 470 #endif 481 471 } … … 487 477 iQP = lowestQP; 488 478 } 489 // variables for fast encoder decision490 bEarlySkip = false;491 bTrySplit = true;492 fRD_Skip = MAX_DOUBLE;493 479 494 480 rpcTempCU->initEstData( uiDepth, iQP ); … … 509 495 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N 510 496 rpcTempCU->initEstData( uiDepth, iQP ); 511 512 // fast encoder decision for early skip 513 if ( m_pcEncCfg->getUseFastEnc() ) 514 { 515 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ]; 516 if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] ) 517 { 518 bEarlySkip = true; 519 bTrySplit = false; 520 } 521 } 497 522 498 #if (ENCODER_FAST_MODE == 2) 523 499 if (testInter) 524 500 { 525 501 #endif 526 527 502 if(!m_pcEncCfg->getUseEarlySkipDetection()) 528 503 { 529 504 // 2Nx2N, NxN 530 if ( !bEarlySkip ) 505 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 506 if(m_pcEncCfg->getUseCbfFastMode()) 531 507 { 532 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 533 if(m_pcEncCfg->getUseCbfFastMode()) 534 { 535 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 536 } 508 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 537 509 } 538 510 } 539 511 #if (ENCODER_FAST_MODE == 2) 540 } 541 #endif 542 543 } 544 545 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) 546 { 547 if(iQP == iBaseQP) 548 { 549 bTrySplitDQP = bTrySplit; 550 } 551 } 552 else 553 { 554 bTrySplitDQP = bTrySplit; 555 } 512 } 513 #endif 514 } 515 556 516 if (isAddLowestQP && (iQP == lowestQP)) 557 517 { … … 580 540 // do inter modes, NxN, 2NxN, and Nx2N 581 541 #if (ENCODER_FAST_MODE) 582 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter )542 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter ) 583 543 #else 584 544 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) … … 586 546 { 587 547 // 2Nx2N, NxN 588 if ( !bEarlySkip)548 if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) 589 549 { 590 if( !( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) ))550 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) 591 551 { 592 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) 593 { 594 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 595 rpcTempCU->initEstData( uiDepth, iQP ); 596 } 552 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 553 rpcTempCU->initEstData( uiDepth, iQP ); 597 554 } 598 555 } … … 734 691 735 692 // do normal intra modes 736 if ( !bEarlySkip )737 {738 693 // speedup for inter frames 739 694 #if (ENCODER_FAST_MODE) … … 761 716 } 762 717 } 763 }764 718 765 719 // test PCM … … 803 757 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 804 758 805 // accumulate statistics for early skip806 if ( m_pcEncCfg->getUseFastEnc() )807 {808 if ( rpcBestCU->isSkipped(0) )809 {810 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];811 afCost[ iIdx ] += rpcBestCU->getTotalCost();812 aiNum [ iIdx ] ++;813 }814 }815 816 759 // Early CU determination 817 760 if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) ) … … 896 839 897 840 // further split 898 if( bSubBranch && bTrySplitDQP &&uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )841 if( bSubBranch && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) 899 842 { 900 843 UChar uhNextDepth = uiDepth+1; -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r429 r431 375 375 // ==================================================================================================================== 376 376 #if SVC_EXTENSION 377 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )378 #else 379 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )377 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff) 378 #else 379 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff) 380 380 #endif 381 381 { … … 390 390 TComOutputBitstream* pcSubstreamsOut = NULL; 391 391 392 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut );392 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField ); 393 393 394 394 m_iNumPicCoded = 0; … … 463 463 464 464 /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding 465 Int pocCurr = iPOCLast -iNumPicRcvd+ m_pcCfg->getGOPEntry(iGOPid).m_POC; 466 Int iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 467 if(iPOCLast == 0) 465 Int iTimeOffset; 466 Int pocCurr; 467 468 if(iPOCLast == 0) //case first frame or first top field 468 469 { 469 470 pocCurr=0; 470 471 iTimeOffset = 1; 471 472 } 473 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 474 { 475 pocCurr = 1; 476 iTimeOffset = 1; 477 } 478 else 479 { 480 pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField; 481 iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 482 } 483 472 484 if(pocCurr>=m_pcCfg->getFramesToBeEncoded()) 473 485 { … … 490 502 accessUnitsInGOP.push_back(AccessUnit()); 491 503 AccessUnit& accessUnit = accessUnitsInGOP.back(); 492 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr );504 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField ); 493 505 494 506 // Slice data initialization … … 499 511 #if SVC_EXTENSION 500 512 pcPic->setLayerId( m_layerId ); 501 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS() ); 502 #else 503 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 504 #endif 513 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS(), isField ); 514 #else 515 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), isField ); 516 #endif 517 518 //Set Frame/Field coding 519 pcSlice->getPic()->setField(isField); 520 505 521 #if POC_RESET_FLAG 506 522 if( !pcSlice->getPocResetFlag() ) // For picture that are not reset, we should adjust the value of POC calculated from the configuration files. … … 602 618 pcSlice->setLFCrossSliceBoundaryFlag( pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() ); 603 619 pcSlice->setScalingList ( m_pcEncTop->getScalingList() ); 604 pcSlice->getScalingList()->setUseTransformSkip(m_pcEncTop->getPPS()->getUseTransformSkip());605 620 if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF) 606 621 { … … 818 833 } 819 834 } 820 #endif // SVC_EXTENSION835 #endif //#if SVC_EXTENSION 821 836 if(pcSlice->getTemporalLayerNonReferenceFlag()) 822 837 { 823 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R) 838 if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R && 839 !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE)) 840 // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker) 824 841 { 825 842 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N); … … 863 880 else 864 881 { 865 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_T SA_R);882 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R); 866 883 } 867 884 #if ALIGN_TSA_STSA_PICS … … 875 892 { 876 893 assert( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ) || 877 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_T SA_R ) );894 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R ) ); 878 895 // TSA pictures are aligned within an access unit. 879 896 } … … 1019 1036 if( pcSlice->getMFMEnabledFlag() ) 1020 1037 #else 1021 1022 #endif 1023 1024 1038 if( pcSlice->getSPS()->getMFMEnabledFlag() ) 1039 #endif 1040 { 1041 pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic()); 1025 1042 #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING 1026 1027 #endif 1028 1029 #else 1030 // Set reference list1031 pcSlice->setRefPicList ( rcListPic );1043 pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice)); 1044 #endif 1045 } 1046 #else 1047 // Set reference list 1048 pcSlice->setRefPicList ( rcListPic ); 1032 1049 #endif //SVC_EXTENSION 1033 1050 pcSlice->setRefPicListModificationSvc(); … … 1080 1097 #endif 1081 1098 } 1082 #endif 1099 #else //SVC_EXTENSION 1100 // Set reference list 1101 pcSlice->setRefPicList ( rcListPic ); 1102 #endif //#if SVC_EXTENSION 1083 1103 1084 1104 // Slice info. refinement … … 1662 1682 } 1663 1683 } 1664 pictureTimingSEI.m_auCpbRemovalDelay = std::m ax<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the .1684 pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the . 1665 1685 #if POC_RESET_FLAG 1666 1686 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pocCurr - m_totalCoded; … … 2201 2221 xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2202 2222 2223 //In case of field coding, compute the interlaced PSNR for both fields 2224 if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff))) 2225 { 2226 //get complementary top field 2227 TComPic* pcPicTop; 2228 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 2229 while ((*iterPic)->getPOC() != pcPic->getPOC()-1) 2230 { 2231 iterPic ++; 2232 } 2233 pcPicTop = *(iterPic); 2234 xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2235 } 2236 2203 2237 if (digestStr) 2204 2238 { … … 2333 2367 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 2334 2368 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2369 pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0; 2335 2370 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); 2336 2371 writeRBSPTrailingBits(nalu.m_Bitstream); … … 2451 2486 2452 2487 #if SVC_EXTENSION 2453 assert ( m_iNumPicCoded <= 1 );2454 #else 2455 assert ( m_iNumPicCoded == iNumPicRcvd);2488 assert ( m_iNumPicCoded <= 1 || (isField && iPOCLast == 1) ); 2489 #else 2490 assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) ); 2456 2491 #endif 2457 2492 } 2458 2493 2459 2494 #if !SVC_EXTENSION 2460 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded )2495 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, Bool isField) 2461 2496 { 2462 2497 assert (uiNumAllPicCoded == m_gcAnalyzeAll.getNumPic()); … … 2464 2499 2465 2500 //--CFG_KDY 2466 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2467 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2468 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2469 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2501 if(isField) 2502 { 2503 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() * 2); 2504 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() * 2); 2505 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() * 2); 2506 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() * 2); 2507 } 2508 else 2509 { 2510 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2511 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2512 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2513 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2514 } 2470 2515 2471 2516 //-- all … … 2490 2535 m_gcAnalyzeB.printSummary('B'); 2491 2536 #endif 2537 2538 if(isField) 2539 { 2540 //-- interlaced summary 2541 m_gcAnalyzeAll_in.setFrmRate( m_pcCfg->getFrameRate()); 2542 printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); 2543 m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll.getBits()); 2544 2545 #if _SUMMARY_OUT_ 2546 m_gcAnalyzeAll_in.printSummaryOutInterlaced(); 2547 #endif 2548 } 2492 2549 2493 2550 printf("\nRVM: %.3lf\n" , xCalculateRVM()); … … 2531 2588 // ==================================================================================================================== 2532 2589 2590 2591 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ) 2592 { 2593 assert( iNumPicRcvd > 0 ); 2594 // Exception for the first frames 2595 if ( ( isField && (iPOCLast == 0 || iPOCLast == 1) ) || (!isField && (iPOCLast == 0)) ) 2596 { 2597 m_iGopSize = 1; 2598 } 2599 else 2600 { 2601 m_iGopSize = m_pcCfg->getGOPSize(); 2602 } 2603 assert (m_iGopSize > 0); 2604 2605 return; 2606 } 2607 2533 2608 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ) 2534 2609 { … … 2553 2628 TComPic*& rpcPic, 2554 2629 TComPicYuv*& rpcPicYuvRecOut, 2555 Int pocCurr ) 2630 Int pocCurr, 2631 Bool isField) 2556 2632 { 2557 2633 Int i; 2558 2634 // Rec. output 2559 2635 TComList<TComPicYuv*>::iterator iterPicYuvRec = rcListPicYuvRecOut.end(); 2560 for ( i = 0; i < iNumPicRcvd - iTimeOffset + 1; i++ ) 2561 { 2562 iterPicYuvRec--; 2563 } 2564 2636 2637 if (isField) 2638 { 2639 for ( i = 0; i < ( (pocCurr == 0 ) || (pocCurr == 1 ) ? (iNumPicRcvd - iTimeOffset + 1) : (iNumPicRcvd - iTimeOffset + 2) ); i++ ) 2640 { 2641 iterPicYuvRec--; 2642 } 2643 } 2644 else 2645 { 2646 for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ ) 2647 { 2648 iterPicYuvRec--; 2649 } 2650 } 2651 2652 if (isField) 2653 { 2654 if(pocCurr == 1) 2655 { 2656 iterPicYuvRec++; 2657 } 2658 } 2565 2659 rpcPicYuvRecOut = *(iterPicYuvRec); 2566 2660 … … 2647 2741 switch (type) 2648 2742 { 2649 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";2650 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";2651 case NAL_UNIT_CODED_SLICE_T SA_R: return "TSA_R";2652 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";2653 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";2654 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N";2743 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R"; 2744 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N"; 2745 case NAL_UNIT_CODED_SLICE_TLA_R: return "TLA_R"; 2746 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N"; 2747 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R"; 2748 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N"; 2655 2749 case NAL_UNIT_CODED_SLICE_BLA_W_LP: return "BLA_W_LP"; 2656 2750 case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL"; 2657 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";2751 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP"; 2658 2752 case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL"; 2659 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";2660 case NAL_UNIT_CODED_SLICE_CRA: return "CRA";2753 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP"; 2754 case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; 2661 2755 case NAL_UNIT_CODED_SLICE_RADL_R: return "RADL_R"; 2662 2756 case NAL_UNIT_CODED_SLICE_RASL_R: return "RASL_R"; 2663 case NAL_UNIT_VPS: return "VPS";2664 case NAL_UNIT_SPS: return "SPS";2665 case NAL_UNIT_PPS: return "PPS";2666 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD";2667 case NAL_UNIT_EOS: return "EOS";2668 case NAL_UNIT_EOB: return "EOB";2669 case NAL_UNIT_FILLER_DATA: return "FILLER";2757 case NAL_UNIT_VPS: return "VPS"; 2758 case NAL_UNIT_SPS: return "SPS"; 2759 case NAL_UNIT_PPS: return "PPS"; 2760 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD"; 2761 case NAL_UNIT_EOS: return "EOS"; 2762 case NAL_UNIT_EOB: return "EOB"; 2763 case NAL_UNIT_FILLER_DATA: return "FILLER"; 2670 2764 case NAL_UNIT_PREFIX_SEI: return "SEI"; 2671 2765 case NAL_UNIT_SUFFIX_SEI: return "SEI"; 2672 default: return "UNK";2766 default: return "UNK"; 2673 2767 } 2674 2768 } … … 2874 2968 printf("]"); 2875 2969 } 2970 } 2971 2972 2973 Void reinterlace(Pel* top, Pel* bottom, Pel* dst, UInt stride, UInt width, UInt height, Bool isTff) 2974 { 2975 2976 for (Int y = 0; y < height; y++) 2977 { 2978 for (Int x = 0; x < width; x++) 2979 { 2980 dst[x] = isTff ? (UChar) top[x] : (UChar) bottom[x]; 2981 dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar) top[x]; 2982 } 2983 top += stride; 2984 bottom += stride; 2985 dst += stride*2; 2986 } 2987 } 2988 2989 Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ) 2990 { 2991 Int x, y; 2992 2993 UInt64 uiSSDY_in = 0; 2994 UInt64 uiSSDU_in = 0; 2995 UInt64 uiSSDV_in = 0; 2996 2997 Double dYPSNR_in = 0.0; 2998 Double dUPSNR_in = 0.0; 2999 Double dVPSNR_in = 0.0; 3000 3001 /*------ INTERLACED PSNR -----------*/ 3002 3003 /* Luma */ 3004 3005 Pel* pOrgTop = pcPicOrgTop->getPicYuvOrg()->getLumaAddr(); 3006 Pel* pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getLumaAddr(); 3007 Pel* pRecTop = pcPicRecTop->getLumaAddr(); 3008 Pel* pRecBottom = pcPicRecBottom->getLumaAddr(); 3009 3010 Int iWidth; 3011 Int iHeight; 3012 Int iStride; 3013 3014 iWidth = pcPicOrgTop->getPicYuvOrg()->getWidth () - m_pcEncTop->getPad(0); 3015 iHeight = pcPicOrgTop->getPicYuvOrg()->getHeight() - m_pcEncTop->getPad(1); 3016 iStride = pcPicOrgTop->getPicYuvOrg()->getStride(); 3017 Int iSize = iWidth*iHeight; 3018 bool isTff = pcPicOrgTop->isTopField(); 3019 3020 TComPicYuv* pcOrgInterlaced = new TComPicYuv; 3021 pcOrgInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 3022 3023 TComPicYuv* pcRecInterlaced = new TComPicYuv; 3024 pcRecInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 3025 3026 Pel* pOrgInterlaced = pcOrgInterlaced->getLumaAddr(); 3027 Pel* pRecInterlaced = pcRecInterlaced->getLumaAddr(); 3028 3029 //=== Interlace fields ==== 3030 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3031 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3032 3033 //===== calculate PSNR ===== 3034 for( y = 0; y < iHeight << 1; y++ ) 3035 { 3036 for( x = 0; x < iWidth; x++ ) 3037 { 3038 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3039 uiSSDY_in += iDiff * iDiff; 3040 } 3041 pOrgInterlaced += iStride; 3042 pRecInterlaced += iStride; 3043 } 3044 3045 /*Chroma*/ 3046 3047 iHeight >>= 1; 3048 iWidth >>= 1; 3049 iStride >>= 1; 3050 3051 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCbAddr(); 3052 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCbAddr(); 3053 pRecTop = pcPicRecTop->getCbAddr(); 3054 pRecBottom = pcPicRecBottom->getCbAddr(); 3055 pOrgInterlaced = pcOrgInterlaced->getCbAddr(); 3056 pRecInterlaced = pcRecInterlaced->getCbAddr(); 3057 3058 //=== Interlace fields ==== 3059 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3060 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3061 3062 //===== calculate PSNR ===== 3063 for( y = 0; y < iHeight << 1; y++ ) 3064 { 3065 for( x = 0; x < iWidth; x++ ) 3066 { 3067 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3068 uiSSDU_in += iDiff * iDiff; 3069 } 3070 pOrgInterlaced += iStride; 3071 pRecInterlaced += iStride; 3072 } 3073 3074 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCrAddr(); 3075 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCrAddr(); 3076 pRecTop = pcPicRecTop->getCrAddr(); 3077 pRecBottom = pcPicRecBottom->getCrAddr(); 3078 pOrgInterlaced = pcOrgInterlaced->getCrAddr(); 3079 pRecInterlaced = pcRecInterlaced->getCrAddr(); 3080 3081 //=== Interlace fields ==== 3082 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3083 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3084 3085 //===== calculate PSNR ===== 3086 for( y = 0; y < iHeight << 1; y++ ) 3087 { 3088 for( x = 0; x < iWidth; x++ ) 3089 { 3090 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3091 uiSSDV_in += iDiff * iDiff; 3092 } 3093 pOrgInterlaced += iStride; 3094 pRecInterlaced += iStride; 3095 } 3096 3097 Int maxvalY = 255 << (g_bitDepthY-8); 3098 Int maxvalC = 255 << (g_bitDepthC-8); 3099 Double fRefValueY = (Double) maxvalY * maxvalY * iSize*2; 3100 Double fRefValueC = (Double) maxvalC * maxvalC * iSize*2 / 4.0; 3101 dYPSNR_in = ( uiSSDY_in ? 10.0 * log10( fRefValueY / (Double)uiSSDY_in ) : 99.99 ); 3102 dUPSNR_in = ( uiSSDU_in ? 10.0 * log10( fRefValueC / (Double)uiSSDU_in ) : 99.99 ); 3103 dVPSNR_in = ( uiSSDV_in ? 10.0 * log10( fRefValueC / (Double)uiSSDV_in ) : 99.99 ); 3104 3105 /* calculate the size of the access unit, excluding: 3106 * - any AnnexB contributions (start_code_prefix, zero_byte, etc.,) 3107 * - SEI NAL units 3108 */ 3109 UInt numRBSPBytes = 0; 3110 for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++) 3111 { 3112 UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size()); 3113 3114 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 3115 numRBSPBytes += numRBSPBytes_nal; 3116 } 3117 3118 UInt uibits = numRBSPBytes * 8 ; 3119 3120 //===== add PSNR ===== 3121 m_gcAnalyzeAll_in.addResult (dYPSNR_in, dUPSNR_in, dVPSNR_in, (Double)uibits); 3122 3123 printf("\n Interlaced frame %d: [Y %6.4lf dB U %6.4lf dB V %6.4lf dB]", pcPicOrgBottom->getPOC()/2 , dYPSNR_in, dUPSNR_in, dVPSNR_in ); 3124 3125 pcOrgInterlaced->destroy(); 3126 delete pcOrgInterlaced; 3127 pcRecInterlaced->destroy(); 3128 delete pcRecInterlaced; 2876 3129 } 2877 3130 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncGOP.h
r345 r431 145 145 Void init ( TEncTop* pcTEncTop ); 146 146 #if SVC_EXTENSION 147 Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );147 Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 148 148 #else 149 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );149 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 150 150 #endif 151 151 Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); … … 156 156 TComList<TComPic*>* getListPic() { return m_pcListPic; } 157 157 158 Void printOutSummary ( UInt uiNumAllPicCoded ); 158 #if !SVC_EXTENSION 159 Void printOutSummary ( UInt uiNumAllPicCoded, Bool isField); 160 #endif 159 161 Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); 160 162 … … 166 168 167 169 protected: 170 171 Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ); 168 172 Void xInitGOP ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ); 169 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr );173 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField ); 170 174 171 175 Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); 176 Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ); 172 177 173 178 UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r401 r431 180 180 #if SVC_EXTENSION 181 181 //\param vps VPS associated with the slice 182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps )183 #else 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField ) 183 #else 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ) 185 185 #endif 186 186 { … … 298 298 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 ); 299 299 Int SHIFT_QP = 12; 300 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames ); 300 301 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) ); 302 301 303 #if FULL_NBIT 302 304 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8); -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncSlice.h
r313 r431 118 118 #if SVC_EXTENSION 119 119 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 120 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps );120 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField ); 121 121 #else 122 122 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ); 124 124 #endif 125 125 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncTop.cpp
r414 r431 308 308 } 309 309 310 Void TEncTop::init( )310 Void TEncTop::init(Bool isFieldCoding) 311 311 { 312 312 // initialize SPS … … 319 319 m_cPPS.setSPS(&m_cSPS); 320 320 xInitPPS(); 321 xInitRPS( );321 xInitRPS(isFieldCoding); 322 322 323 323 xInitPPSforTiles(); … … 396 396 397 397 // compress GOP 398 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut );398 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 399 399 400 400 #if RATE_CONTROL_LAMBDA_DOMAIN … … 456 456 457 457 // compress GOP 458 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 458 459 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 459 460 460 461 #if RATE_CONTROL_LAMBDA_DOMAIN … … 467 468 iNumEncoded = m_iNumPicRcvd; 468 469 m_iNumPicRcvd = 0; 470 m_uiNumAllPicCoded += iNumEncoded; 471 } 472 #endif 473 474 /**------------------------------------------------ 475 Separate interlaced frame into two fields 476 -------------------------------------------------**/ 477 void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) 478 { 479 if (!isTop) 480 { 481 org += stride; 482 } 483 for (Int y = 0; y < height>>1; y++) 484 { 485 for (Int x = 0; x < width; x++) 486 { 487 dstField[x] = org[x]; 488 } 489 490 dstField += stride; 491 org += stride*2; 492 } 493 494 } 495 496 #if SVC_EXTENSION 497 Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ) 498 { 499 if (pcPicYuvOrg) 500 { 501 /* -- TOP FIELD -- */ 502 /* -- Top field initialization -- */ 503 504 TComPic *pcTopField; 505 xGetNewPicBuffer( pcTopField ); 506 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 507 pcTopField->setReconMark (false); 508 509 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 510 pcTopField->getPicYuvRec()->setBorderExtension(false); 511 pcTopField->setTopField(isTff); 512 513 Int nHeight = pcPicYuvOrg->getHeight(); 514 Int nWidth = pcPicYuvOrg->getWidth(); 515 Int nStride = pcPicYuvOrg->getStride(); 516 Int nPadLuma = pcPicYuvOrg->getLumaMargin(); 517 Int nPadChroma = pcPicYuvOrg->getChromaMargin(); 518 519 // Get pointers 520 Pel * PicBufY = pcPicYuvOrg->getBufY(); 521 Pel * PicBufU = pcPicYuvOrg->getBufU(); 522 Pel * PicBufV = pcPicYuvOrg->getBufV(); 523 524 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 525 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 526 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 527 528 // compute image characteristics 529 if ( getUseAdaptiveQP() ) 530 { 531 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 532 } 533 534 /* -- Defield -- */ 535 536 Bool isTop = isTff; 537 538 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 539 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 540 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 541 542 /* -- BOTTOM FIELD -- */ 543 /* -- Bottom field initialization -- */ 544 545 TComPic* pcBottomField; 546 xGetNewPicBuffer( pcBottomField ); 547 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 548 pcBottomField->setReconMark (false); 549 550 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 551 pcBottomField->getPicYuvRec()->setBorderExtension(false); 552 pcBottomField->setTopField(!isTff); 553 554 nHeight = pcPicYuvOrg->getHeight(); 555 nWidth = pcPicYuvOrg->getWidth(); 556 nStride = pcPicYuvOrg->getStride(); 557 nPadLuma = pcPicYuvOrg->getLumaMargin(); 558 nPadChroma = pcPicYuvOrg->getChromaMargin(); 559 560 // Get pointers 561 PicBufY = pcPicYuvOrg->getBufY(); 562 PicBufU = pcPicYuvOrg->getBufU(); 563 PicBufV = pcPicYuvOrg->getBufV(); 564 565 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 566 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 567 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 568 569 // Compute image characteristics 570 if ( getUseAdaptiveQP() ) 571 { 572 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 573 } 574 575 /* -- Defield -- */ 576 577 isTop = !isTff; 578 579 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 580 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 581 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 582 583 } 584 } 585 586 Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ) 587 { 588 // compress GOP 589 if (m_iPOCLast == 0) // compress field 0 590 { 591 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 592 } 593 594 if (pcPicYuvOrg) 595 { 596 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 597 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 598 { 599 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 600 } 601 else 602 { 603 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 604 } 605 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 606 } 607 608 // compress GOP 609 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 610 611 m_uiNumAllPicCoded ++; 612 } 613 #else 614 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff) 615 { 616 /* -- TOP FIELD -- */ 617 618 if (pcPicYuvOrg) 619 { 620 621 /* -- Top field initialization -- */ 622 623 TComPic *pcTopField; 624 xGetNewPicBuffer( pcTopField ); 625 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 626 pcTopField->setReconMark (false); 627 628 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 629 pcTopField->getPicYuvRec()->setBorderExtension(false); 630 pcTopField->setTopField(isTff); 631 632 Int nHeight = pcPicYuvOrg->getHeight(); 633 Int nWidth = pcPicYuvOrg->getWidth(); 634 Int nStride = pcPicYuvOrg->getStride(); 635 Int nPadLuma = pcPicYuvOrg->getLumaMargin(); 636 Int nPadChroma = pcPicYuvOrg->getChromaMargin(); 637 638 // Get pointers 639 Pel * PicBufY = pcPicYuvOrg->getBufY(); 640 Pel * PicBufU = pcPicYuvOrg->getBufU(); 641 Pel * PicBufV = pcPicYuvOrg->getBufV(); 642 643 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 644 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 645 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 646 647 // compute image characteristics 648 if ( getUseAdaptiveQP() ) 649 { 650 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 651 } 652 653 /* -- Defield -- */ 654 655 Bool isTop = isTff; 656 657 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 658 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 659 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 660 661 } 662 663 if (m_iPOCLast == 0) // compress field 0 664 { 665 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 666 } 667 668 /* -- BOTTOM FIELD -- */ 669 670 if (pcPicYuvOrg) 671 { 672 673 /* -- Bottom field initialization -- */ 674 675 TComPic* pcBottomField; 676 xGetNewPicBuffer( pcBottomField ); 677 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 678 pcBottomField->setReconMark (false); 679 680 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 681 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 682 { 683 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 684 } 685 else 686 { 687 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 688 } 689 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 690 691 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 692 pcBottomField->getPicYuvRec()->setBorderExtension(false); 693 pcBottomField->setTopField(!isTff); 694 695 int nHeight = pcPicYuvOrg->getHeight(); 696 int nWidth = pcPicYuvOrg->getWidth(); 697 int nStride = pcPicYuvOrg->getStride(); 698 int nPadLuma = pcPicYuvOrg->getLumaMargin(); 699 int nPadChroma = pcPicYuvOrg->getChromaMargin(); 700 701 // Get pointers 702 Pel * PicBufY = pcPicYuvOrg->getBufY(); 703 Pel * PicBufU = pcPicYuvOrg->getBufU(); 704 Pel * PicBufV = pcPicYuvOrg->getBufV(); 705 706 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 707 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 708 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 709 710 // Compute image characteristics 711 if ( getUseAdaptiveQP() ) 712 { 713 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 714 } 715 716 /* -- Defield -- */ 717 718 Bool isTop = !isTff; 719 720 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 721 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 722 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 723 724 } 725 726 if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) ) 727 { 728 iNumEncoded = 0; 729 return; 730 } 731 732 // compress GOP 733 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 734 735 iNumEncoded = m_iNumPicRcvd; 736 m_iNumPicRcvd = 0; 469 737 m_uiNumAllPicCoded += iNumEncoded; 470 738 } … … 911 1179 912 1180 //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. 913 Void TEncTop::xInitRPS( )1181 Void TEncTop::xInitRPS(Bool isFieldCoding) 914 1182 { 915 1183 TComReferencePictureSet* rps; 916 1184 917 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs );1185 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs+1); 918 1186 TComRPSList* rpsList = m_cSPS.getRPSList(); 919 1187 … … 1016 1284 printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 1017 1285 rps->setNumberOfNegativePictures(numNeg); 1018 rps->setNumberOfP ositivePictures(numNeg+numPos);1286 rps->setNumberOfPictures(numNeg+numPos); 1019 1287 } 1020 1288 if (numPos != rps->getNumberOfPositivePictures()) … … 1022 1290 printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 1023 1291 rps->setNumberOfPositivePictures(numPos); 1024 rps->setNumberOfP ositivePictures(numNeg+numPos);1292 rps->setNumberOfPictures(numNeg+numPos); 1025 1293 } 1026 1294 RPSTemp.setNumberOfPictures(numNeg+numPos); … … 1086 1354 #endif //INTER_RPS_AUTO 1087 1355 } 1088 1356 //In case of field coding, we need to set special parameters for the first bottom field of the sequence, since it is not specified in the cfg file. 1357 //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. 1358 if (isFieldCoding) 1359 { 1360 rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); 1361 rps->setNumberOfPictures(1); 1362 rps->setNumberOfNegativePictures(1); 1363 rps->setNumberOfPositivePictures(0); 1364 rps->setNumberOfLongtermPictures(0); 1365 rps->setDeltaPOC(0,-1); 1366 rps->setPOC(0,0); 1367 rps->setUsed(0,true); 1368 rps->setInterRPSPrediction(false); 1369 rps->setDeltaRIdxMinus1(0); 1370 rps->setDeltaRPS(0); 1371 rps->setNumRefIdc(0); 1372 } 1089 1373 } 1090 1374 … … 1095 1379 { 1096 1380 slice->setRPSidx(GOPid); 1097 1098 1381 for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) 1099 1382 { … … 1119 1402 } 1120 1403 1404 if(POCCurr == 1 && slice->getPic()->isField()) 1405 { 1406 slice->setRPSidx(m_iGOPSize+m_extraRPSs); 1407 } 1408 1121 1409 slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); 1122 1410 slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); 1123 1124 1411 } 1125 1412 -
branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncTop.h
r414 r431 144 144 Window m_scaledRefLayerWindow[MAX_LAYERS]; 145 145 #endif 146 #endif147 146 #if POC_RESET_FLAG 148 147 Int m_pocAdjustmentValue; 148 #endif 149 149 #endif 150 150 protected: … … 154 154 155 155 Void xInitPPSforTiles (); 156 Void xInitRPS ( );///< initialize PPS from encoder options156 Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options 157 157 #if SVC_EXTENSION 158 158 Void xInitILRP(); … … 164 164 Void create (); 165 165 Void destroy (); 166 Void init ( );166 Void init (Bool isFieldCoding); 167 167 Void deletePicBuffer (); 168 168 … … 209 209 Int getNumPicRcvd () { return m_iNumPicRcvd; } 210 210 Void setNumPicRcvd ( Int num ) { m_iNumPicRcvd = num; } 211 #endif212 211 #if SCALED_REF_LAYER_OFFSETS 213 212 Void setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; } 214 213 UInt getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; } 215 214 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 215 #endif 216 216 #endif 217 217 … … 236 236 fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; } 237 237 #endif 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ); 239 239 Void encodePrep( TComPicYuv* pcPicYuvOrg ); 240 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ); 241 Void encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ); 240 242 #if VPS_EXTN_DIRECT_REF_LAYERS 241 243 TEncTop* getRefLayerEnc(UInt refLayerIdc); 242 244 #endif 243 #else244 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,245 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded );246 #endif247 248 void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); }249 245 #if POC_RESET_FLAG 250 246 Int getPocAdjustmentValue() { return m_pocAdjustmentValue;} 251 247 Void setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x; } 252 248 #endif 249 #else //SVC_EXTENSION 250 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 251 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 252 253 /// encode several number of pictures until end-of-sequence 254 Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 255 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff); 256 257 Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField); } 258 #endif //#if SVC_EXTENSION 253 259 }; 254 260 -
branches/SHM-3.1-dev/source/Lib/TLibVideoIO/TVideoIOYuv.cpp
r313 r431 339 339 } 340 340 341 static Bool writeField(ostream& fd, Pel* top, Pel* bottom, Bool is16bit, 342 UInt stride, 343 UInt width, UInt height, bool isTff) 344 { 345 Int write_len = width * (is16bit ? 2 : 1)*2; 346 UChar *buf = new UChar[write_len]; 347 for (Int y = 0; y < height; y++) 348 { 349 if (!is16bit) 350 { 351 for (Int x = 0; x < width; x++) 352 { 353 buf[x] = isTff ? (UChar) top[x] : (UChar) bottom[x]; 354 buf[width+x] = isTff ? (UChar) bottom[x] : (UChar) top[x]; 355 } 356 } 357 else 358 { 359 for (Int x = 0; x < width; x++) 360 { 361 buf[2*x] = isTff ? top[x] & 0xff : bottom[x] & 0xff; 362 buf[2*x+1] = isTff ? (top[x] >> 8) & 0xff : (bottom[x] >> 8) & 0xff; 363 364 buf[width+2*x] = isTff ? bottom[x] & 0xff : top[x] & 0xff; 365 buf[width+2*x+1] = isTff ? (bottom[x] >> 8) & 0xff : (top[x] >> 8) & 0xff; 366 } 367 } 368 369 fd.write(reinterpret_cast<Char*>(buf), write_len); 370 if (fd.eof() || fd.fail() ) 371 { 372 delete[] buf; 373 return false; 374 } 375 top += stride; 376 bottom += stride; 377 } 378 delete[] buf; 379 return true; 380 } 341 381 /** 342 382 * Read one Y'CbCr frame, performing any required input scaling to change … … 501 541 } 502 542 543 544 /** 545 * Write one Y'CbCr frame. No bit-depth conversion is performed, pcPicYuv is 546 * assumed to be at TVideoIO::m_fileBitdepth depth. 547 * 548 * @param pPicTop input top field YUV buffer class pointer 549 * @param pPicBottom input bottom field YUV buffer class pointer 550 * @param aiPad source padding size, aiPad[0] = horizontal, aiPad[1] = vertical 551 * @return true for success, false in case of error 552 */ 553 Bool TVideoIOYuv::write( TComPicYuv* pPicTop, TComPicYuv* pPicBottom, Int cropLeft, Int cropRight, Int cropTop, Int cropBottom , bool isTff) 554 { 555 // compute actual YUV frame size excluding padding size 556 Int iStride = pPicTop->getStride(); 557 UInt width = pPicTop->getWidth() - cropLeft - cropRight; 558 UInt height = pPicTop->getHeight() - cropTop - cropBottom; 559 Bool is16bit = m_fileBitDepthY > 8 || m_fileBitDepthC > 8; 560 561 TComPicYuv *dstPicTop = NULL; 562 TComPicYuv *dstPicBottom = NULL; 563 564 Bool retval = true; 565 566 if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0) 567 { 568 dstPicTop = new TComPicYuv; 569 dstPicTop->create( pPicTop->getWidth(), pPicTop->getHeight(), 1, 1, 0 ); 570 pPicTop->copyToPic(dstPicTop); 571 572 dstPicBottom = new TComPicYuv; 573 dstPicBottom->create( pPicBottom->getWidth(), pPicBottom->getHeight(), 1, 1, 0 ); 574 pPicBottom->copyToPic(dstPicBottom); 575 576 Pel minvalY = 0; 577 Pel minvalC = 0; 578 Pel maxvalY = (1 << m_fileBitDepthY) - 1; 579 Pel maxvalC = (1 << m_fileBitDepthC) - 1; 580 #if CLIP_TO_709_RANGE 581 if (-m_bitDepthShiftY < 0 && m_fileBitDepthY >= 8) 582 { 583 /* ITU-R BT.709 compliant clipping for converting say 10b to 8b */ 584 minvalY = 1 << (m_fileBitDepthY - 8); 585 maxvalY = (0xff << (m_fileBitDepthY - 8)) -1; 586 } 587 if (-m_bitDepthShiftC < 0 && m_fileBitDepthC >= 8) 588 { 589 /* ITU-R BT.709 compliant clipping for converting say 10b to 8b */ 590 minvalC = 1 << (m_fileBitDepthC - 8); 591 maxvalC = (0xff << (m_fileBitDepthC - 8)) -1; 592 } 593 #endif 594 scalePlane(dstPicTop->getLumaAddr(), dstPicTop->getStride(), dstPicTop->getWidth(), dstPicTop->getHeight(), -m_bitDepthShiftY, minvalY, maxvalY); 595 scalePlane(dstPicTop->getCbAddr(), dstPicTop->getCStride(), dstPicTop->getWidth()>>1, dstPicTop->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC); 596 scalePlane(dstPicTop->getCrAddr(), dstPicTop->getCStride(), dstPicTop->getWidth()>>1, dstPicTop->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC); 597 598 scalePlane(dstPicBottom->getLumaAddr(), dstPicBottom->getStride(), dstPicBottom->getWidth(), dstPicBottom->getHeight(), -m_bitDepthShiftY, minvalY, maxvalY); 599 scalePlane(dstPicBottom->getCbAddr(), dstPicBottom->getCStride(), dstPicBottom->getWidth()>>1, dstPicBottom->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC); 600 scalePlane(dstPicBottom->getCrAddr(), dstPicBottom->getCStride(), dstPicBottom->getWidth()>>1, dstPicBottom->getHeight()>>1, -m_bitDepthShiftC, minvalC, maxvalC); 601 } 602 else 603 { 604 dstPicTop = pPicTop; 605 dstPicBottom = pPicBottom; 606 } 607 // location of upper left pel in a plane 608 Int planeOffset = 0; //cropLeft + cropTop * iStride; 609 //Write luma 610 if (! writeField(m_cHandle, dstPicTop->getLumaAddr() + planeOffset, dstPicBottom->getLumaAddr() + planeOffset, is16bit, iStride, width, height, isTff)) 611 { 612 retval=false; 613 goto exit; 614 } 615 616 width >>= 1; 617 height >>= 1; 618 iStride >>= 1; 619 cropLeft >>= 1; 620 cropRight >>= 1; 621 622 planeOffset = 0; // cropLeft + cropTop * iStride; 623 624 //Write chroma U 625 if (! writeField(m_cHandle, dstPicTop->getCbAddr() + planeOffset, dstPicBottom->getCbAddr() + planeOffset, is16bit, iStride, width, height, isTff)) 626 { 627 retval=false; 628 goto exit; 629 } 630 631 //Write chroma V 632 if (! writeField(m_cHandle, dstPicTop->getCrAddr() + planeOffset, dstPicBottom->getCrAddr() + planeOffset, is16bit, iStride, width, height, isTff)) 633 634 { 635 retval=false; 636 goto exit; 637 } 638 639 exit: 640 if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0) 641 { 642 dstPicTop->destroy(); 643 delete dstPicTop; 644 dstPicBottom->destroy(); 645 delete dstPicBottom; 646 } 647 return retval; 648 } -
branches/SHM-3.1-dev/source/Lib/TLibVideoIO/TVideoIOYuv.h
r313 r431 72 72 Bool read ( TComPicYuv* pPicYuv, Int aiPad[2] ); ///< read one YUV frame with padding parameter 73 73 Bool write( TComPicYuv* pPicYuv, Int confLeft=0, Int confRight=0, Int confTop=0, Int confBottom=0 ); 74 Bool write( TComPicYuv* pPicYuv, TComPicYuv* pPicYuv2, Int confLeft=0, Int confRight=0, Int confTop=0, Int confBottom=0 , bool isTff=false); 74 75 75 76 Bool isEof (); ///< check for end-of-file
Note: See TracChangeset for help on using the changeset viewer.