Changeset 644 in SHVCSoftware for trunk/source/App
- Timestamp:
- 25 Mar 2014, 21:51:30 (11 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-5.1-dev (added) merged: 599-600,602-643
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
/branches/SHM-5.0-dev/source merged: 601 /branches/SHM-5.1-dev/source (added) merged: 600,602-643
- Property svn:mergeinfo changed
-
trunk/source/App/TAppDecoder/TAppDecTop.cpp
r595 r644 41 41 #include <fcntl.h> 42 42 #include <assert.h> 43 43 #include <iostream> 44 44 #include "TAppDecTop.h" 45 45 #include "TLibDecoder/AnnexBread.h" 46 46 #include "TLibDecoder/NALread.h" 47 48 47 //! \ingroup TAppDecoder 49 48 //! \{ … … 255 254 openedReconFile[curLayerId] = true; 256 255 } 256 #if ALIGNED_BUMPING 257 Bool outputPicturesFlag = true; 258 #if NO_OUTPUT_OF_PRIOR_PICS 259 if( m_acTDecTop[nalu.m_layerId].getNoOutputOfPriorPicsFlags() ) 260 { 261 outputPicturesFlag = false; 262 } 263 #endif 264 265 if (nalu.m_nalUnitType == NAL_UNIT_EOS) // End of sequence 266 { 267 flushAllPictures( nalu.m_layerId, outputPicturesFlag ); 268 } 269 if( bNewPicture ) // New picture, slice header parsed but picture not decoded 270 { 271 #if NO_OUTPUT_OF_PRIOR_PICS 272 if( 273 #else 274 if ( bNewPOC && 275 #endif 276 ( nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL 277 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP 278 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP 279 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL 280 || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) ) 281 { 282 flushAllPictures( nalu.m_layerId, outputPicturesFlag ); 283 } 284 else 285 { 286 this->checkOutputBeforeDecoding( nalu.m_layerId ); 287 } 288 } 289 290 /* The following code has to be executed when the last DU of the picture is decoded 291 TODO: Need code to identify end of decoding a picture 292 { 293 this->checkOutputAfterDecoding( ); 294 } */ 295 #else 257 296 if ( bNewPicture && bNewPOC && 258 297 ( nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL … … 273 312 xWriteOutput( pcListPic, curLayerId, nalu.m_temporalId ); 274 313 } 275 } 276 } 314 #endif 315 } 316 } 317 #if ALIGNED_BUMPING 318 flushAllPictures( true ); 319 #else 277 320 for(UInt layer = 0; layer <= m_tgtLayerId; layer++) 278 321 { 279 322 xFlushOutput( m_acTDecTop[layer].getListPic(), layer ); 280 323 } 324 #endif 281 325 // delete buffers 282 326 #if AVC_BASE … … 987 1031 return false; 988 1032 } 989 1033 #if ALIGNED_BUMPING 1034 // Function outputs a picture, and marks it as not needed for output. 1035 Void TAppDecTop::xOutputAndMarkPic( TComPic *pic, const Char *reconFile, const Int layerIdx, Int &pocLastDisplay, DpbStatus &dpbStatus ) 1036 { 1037 if ( reconFile ) 1038 { 1039 const Window &conf = pic->getConformanceWindow(); 1040 const Window &defDisp = m_respectDefDispWindow ? pic->getDefDisplayWindow() : Window(); 1041 Int xScal = 1, yScal = 1; 1042 #if REPN_FORMAT_IN_VPS 1043 UInt chromaFormatIdc = pic->getSlice(0)->getChromaFormatIdc(); 1044 xScal = TComSPS::getWinUnitX( chromaFormatIdc ); 1045 yScal = TComSPS::getWinUnitY( chromaFormatIdc ); 1046 #endif 1047 m_acTVideoIOYuvReconFile[layerIdx].write( pic->getPicYuvRec(), 1048 conf.getWindowLeftOffset() * xScal + defDisp.getWindowLeftOffset(), 1049 conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(), 1050 conf.getWindowTopOffset() * yScal + defDisp.getWindowTopOffset(), 1051 conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() ); 1052 } 1053 // update POC of display order 1054 pocLastDisplay = pic->getPOC(); 1055 1056 // Mark as not needed for output 1057 pic->setOutputMark(false); 1058 1059 // "erase" non-referenced picture in the reference picture list after display 1060 if ( !pic->getSlice(0)->isReferenced() && pic->getReconMark() == true ) 1061 { 1062 pic->setReconMark(false); 1063 1064 // mark it should be extended later 1065 pic->getPicYuvRec()->setBorderExtension( false ); 1066 1067 dpbStatus.m_numPicsInLayer[layerIdx]--; 1068 } 1069 } 1070 1071 Void TAppDecTop::flushAllPictures(Int layerId, Bool outputPictures) 1072 { 1073 // First "empty" all pictures that are not used for reference and not needed for output 1074 emptyUnusedPicturesNotNeededForOutput(); 1075 1076 if( outputPictures ) // All pictures in the DPB in that layer are to be output; this means other pictures would also be output 1077 { 1078 std::vector<Int> listOfPocs; 1079 std::vector<Int> listOfPocsInEachLayer[MAX_LAYERS]; 1080 std::vector<Int> listOfPocsPositionInEachLayer[MAX_LAYERS]; 1081 DpbStatus dpbStatus; 1082 1083 // Find the status of the DPB 1084 xFindDPBStatus(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus); 1085 1086 if( listOfPocs.size() ) 1087 { 1088 while( listOfPocsInEachLayer[layerId].size() ) // As long as there picture in the layer to be output 1089 { 1090 bumpingProcess( listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus ); 1091 } 1092 } 1093 } 1094 1095 // Now remove all pictures from the layer DPB? 1096 markAllPicturesAsErased(layerId); 1097 } 1098 Void TAppDecTop::flushAllPictures(Bool outputPictures) 1099 { 1100 // First "empty" all pictures that are not used for reference and not needed for output 1101 emptyUnusedPicturesNotNeededForOutput(); 1102 1103 if( outputPictures ) // All pictures in the DPB are to be output 1104 { 1105 std::vector<Int> listOfPocs; 1106 std::vector<Int> listOfPocsInEachLayer[MAX_LAYERS]; 1107 std::vector<Int> listOfPocsPositionInEachLayer[MAX_LAYERS]; 1108 DpbStatus dpbStatus; 1109 1110 // Find the status of the DPB 1111 xFindDPBStatus(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus); 1112 1113 while( dpbStatus.m_numAUsNotDisplayed ) 1114 { 1115 bumpingProcess( listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus ); 1116 } 1117 } 1118 1119 // Now remove all pictures from the DPB? 1120 markAllPicturesAsErased(); 1121 } 1122 1123 Void TAppDecTop::markAllPicturesAsErased() 1124 { 1125 for(Int i = 0; i < MAX_LAYERS; i++) 1126 { 1127 m_acTDecTop[i].getListPic()->clear(); 1128 } 1129 } 1130 1131 Void TAppDecTop::markAllPicturesAsErased(Int layerIdx) 1132 { 1133 m_acTDecTop[layerIdx].getListPic()->clear(); 1134 } 1135 1136 Void TAppDecTop::checkOutputBeforeDecoding(Int layerIdx) 1137 { 1138 1139 std::vector<Int> listOfPocs; 1140 std::vector<Int> listOfPocsInEachLayer[MAX_LAYERS]; 1141 std::vector<Int> listOfPocsPositionInEachLayer[MAX_LAYERS]; 1142 DpbStatus dpbStatus; 1143 1144 // First "empty" all pictures that are not used for reference and not needed for output 1145 emptyUnusedPicturesNotNeededForOutput(); 1146 1147 // Find the status of the DPB 1148 xFindDPBStatus(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus); 1149 1150 // If not picture to be output, return 1151 if( listOfPocs.size() == 0 ) 1152 { 1153 return; 1154 } 1155 1156 // Find DPB-information from the VPS 1157 DpbStatus maxDpbLimit; 1158 Int targetLsIdx, subDpbIdx; 1159 TComVPS *vps = findDpbParametersFromVps(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, maxDpbLimit); 1160 if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) 1161 { 1162 targetLsIdx = 0; 1163 subDpbIdx = 0; 1164 } 1165 else 1166 { 1167 targetLsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); 1168 subDpbIdx = vps->getSubDpbAssigned( targetLsIdx, layerIdx ); 1169 } 1170 // Assume that listOfPocs is sorted in increasing order - if not have to sort it. 1171 while( ifInvokeBumpingBeforeDecoding(dpbStatus, maxDpbLimit, layerIdx, subDpbIdx) ) 1172 { 1173 bumpingProcess( listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus ); 1174 } 1175 } 1176 1177 Void TAppDecTop::checkOutputAfterDecoding() 1178 { 1179 std::vector<Int> listOfPocs; 1180 std::vector<Int> listOfPocsInEachLayer[MAX_LAYERS]; 1181 std::vector<Int> listOfPocsPositionInEachLayer[MAX_LAYERS]; 1182 DpbStatus dpbStatus; 1183 1184 // First "empty" all pictures that are not used for reference and not needed for output 1185 emptyUnusedPicturesNotNeededForOutput(); 1186 1187 // Find the status of the DPB 1188 xFindDPBStatus(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus); 1189 1190 // If not picture to be output, return 1191 if( listOfPocs.size() == 0 ) 1192 { 1193 return; 1194 } 1195 1196 // Find DPB-information from the VPS 1197 DpbStatus maxDpbLimit; 1198 findDpbParametersFromVps(listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, maxDpbLimit); 1199 1200 // Assume that listOfPocs is sorted in increasing order - if not have to sort it. 1201 while( ifInvokeBumpingAfterDecoding(dpbStatus, maxDpbLimit) ) 1202 { 1203 bumpingProcess( listOfPocs, listOfPocsInEachLayer, listOfPocsPositionInEachLayer, dpbStatus ); 1204 } 1205 } 1206 1207 Void TAppDecTop::bumpingProcess(std::vector<Int> &listOfPocs, std::vector<Int> *listOfPocsInEachLayer, std::vector<Int> *listOfPocsPositionInEachLayer, DpbStatus &dpbStatus) 1208 { 1209 // Choose the smallest POC value 1210 Int pocValue = *(listOfPocs.begin()); 1211 std::vector<int>::iterator it; 1212 TComList<TComPic*>::iterator iterPic; 1213 for( Int layerIdx = 0; layerIdx < dpbStatus.m_numLayers; layerIdx++) 1214 { 1215 // Check if picture with pocValue is present. 1216 it = find( listOfPocsInEachLayer[layerIdx].begin(), listOfPocsInEachLayer[layerIdx].end(), pocValue ); 1217 if( it != listOfPocsInEachLayer[layerIdx].end() ) // picture found. 1218 { 1219 Int picPosition = std::distance( listOfPocsInEachLayer[layerIdx].begin(), it ); 1220 Int j; 1221 for(j = 0, iterPic = m_acTDecTop[layerIdx].getListPic()->begin(); j < listOfPocsPositionInEachLayer[layerIdx][picPosition]; j++) // Picture to be output 1222 { 1223 iterPic++; 1224 } 1225 TComPic *pic = *iterPic; 1226 1227 xOutputAndMarkPic( pic, m_pchReconFile[layerIdx], layerIdx, m_aiPOCLastDisplay[layerIdx], dpbStatus ); 1228 1229 listOfPocsInEachLayer[layerIdx].erase( it ); 1230 listOfPocsPositionInEachLayer[layerIdx].erase( listOfPocsPositionInEachLayer[layerIdx].begin() + picPosition ); 1231 } 1232 } 1233 // Update sub-DPB status 1234 for( Int subDpbIdx = 0; subDpbIdx < dpbStatus.m_numSubDpbs; subDpbIdx++) 1235 { 1236 dpbStatus.m_numPicsInSubDpb[subDpbIdx]--; 1237 } 1238 dpbStatus.m_numAUsNotDisplayed--; 1239 1240 // Remove the picture from the listOfPocs 1241 listOfPocs.erase( listOfPocs.begin() ); 1242 } 1243 1244 TComVPS *TAppDecTop::findDpbParametersFromVps(std::vector<Int> const &listOfPocs, std::vector<Int> const *listOfPocsInEachLayer, std::vector<Int> const *listOfPocsPositionInEachLayer, DpbStatus &maxDpbLimit) 1245 { 1246 Int targetOutputLsIdx = getCommonDecoderParams()->getTargetOutputLayerSetIdx(); 1247 TComVPS *vps = NULL; 1248 1249 if( targetOutputLsIdx == 0 ) // Only base layer is output 1250 { 1251 TComSPS *sps = NULL; 1252 assert( listOfPocsInEachLayer[0].size() != 0 ); 1253 TComList<TComPic*>::iterator iterPic; 1254 Int j; 1255 for(j = 0, iterPic = m_acTDecTop[0].getListPic()->begin(); j < listOfPocsPositionInEachLayer[0][0]; j++) // Picture to be output 1256 { 1257 iterPic++; 1258 } 1259 TComPic *pic = *iterPic; 1260 sps = pic->getSlice(0)->getSPS(); assert( sps->getLayerId() == 0 ); 1261 vps = pic->getSlice(0)->getVPS(); 1262 Int highestTId = sps->getMaxTLayers() - 1; 1263 1264 maxDpbLimit.m_numAUsNotDisplayed = sps->getNumReorderPics( highestTId ); // m_numAUsNotDisplayed is only variable name - stores reorderpics 1265 maxDpbLimit.m_maxLatencyIncrease = sps->getMaxLatencyIncrease( highestTId ) > 0; 1266 if( maxDpbLimit.m_maxLatencyIncrease ) 1267 { 1268 maxDpbLimit.m_maxLatencyPictures = sps->getMaxLatencyIncrease( highestTId ) + sps->getNumReorderPics( highestTId ) - 1; 1269 } 1270 maxDpbLimit.m_numPicsInLayer[0] = sps->getMaxDecPicBuffering( highestTId ); 1271 maxDpbLimit.m_numPicsInSubDpb[0] = sps->getMaxDecPicBuffering( highestTId ); 1272 } 1273 else 1274 { 1275 // ------------------------------------- 1276 // Find the VPS used for the pictures 1277 // ------------------------------------- 1278 for(Int i = 0; i < MAX_LAYERS; i++) 1279 { 1280 if( m_acTDecTop[i].getListPic()->empty() ) 1281 { 1282 assert( listOfPocsInEachLayer[i].size() == 0 ); 1283 continue; 1284 } 1285 std::vector<Int>::const_iterator it; 1286 it = find( listOfPocsInEachLayer[i].begin(), listOfPocsInEachLayer[i].end(), listOfPocs[0] ); 1287 TComList<TComPic*>::iterator iterPic; 1288 if( it != listOfPocsInEachLayer[i].end() ) 1289 { 1290 Int picPosition = std::distance( listOfPocsInEachLayer[i].begin(), it ); 1291 Int j; 1292 for(j = 0, iterPic = m_acTDecTop[i].getListPic()->begin(); j < listOfPocsPositionInEachLayer[i][picPosition]; j++) // Picture to be output 1293 { 1294 iterPic++; 1295 } 1296 TComPic *pic = *iterPic; 1297 vps = pic->getSlice(0)->getVPS(); 1298 break; 1299 } 1300 } 1301 1302 Int targetLsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); 1303 Int highestTId = vps->getMaxTLayers() - 1; 1304 1305 maxDpbLimit.m_numAUsNotDisplayed = vps->getMaxVpsNumReorderPics( targetOutputLsIdx, highestTId ); // m_numAUsNotDisplayed is only variable name - stores reorderpics 1306 maxDpbLimit.m_maxLatencyIncrease = vps->getMaxVpsLatencyIncreasePlus1(targetOutputLsIdx, highestTId ) > 0; 1307 if( maxDpbLimit.m_maxLatencyIncrease ) 1308 { 1309 maxDpbLimit.m_maxLatencyPictures = vps->getMaxVpsNumReorderPics( targetOutputLsIdx, highestTId ) + vps->getMaxVpsLatencyIncreasePlus1(targetOutputLsIdx, highestTId ) - 1; 1310 } 1311 for(Int i = 0; i < vps->getNumLayersInIdList( targetLsIdx ); i++) 1312 { 1313 maxDpbLimit.m_numPicsInLayer[i] = vps->getMaxVpsLayerDecPicBuffMinus1( targetOutputLsIdx, i, highestTId ) + 1; 1314 maxDpbLimit.m_numPicsInSubDpb[vps->getSubDpbAssigned( targetLsIdx, i )] = vps->getMaxVpsDecPicBufferingMinus1( targetOutputLsIdx, vps->getSubDpbAssigned( targetLsIdx, i ), highestTId) + 1; 1315 } 1316 // ------------------------------------- 1317 } 1318 return vps; 1319 } 1320 Void TAppDecTop::emptyUnusedPicturesNotNeededForOutput() 1321 { 1322 for(Int layerIdx = 0; layerIdx < MAX_LAYERS; layerIdx++) 1323 { 1324 TComList <TComPic*> *pcListPic = m_acTDecTop[layerIdx].getListPic(); 1325 TComList<TComPic*>::iterator iterPic = pcListPic->begin(); 1326 while ( iterPic != pcListPic->end() ) 1327 { 1328 TComPic *pic = *iterPic; 1329 if( !pic->getSlice(0)->isReferenced() && !pic->getOutputMark() ) 1330 { 1331 // Emtpy the picture buffer 1332 pic->setReconMark( false ); 1333 } 1334 iterPic++; 1335 } 1336 } 1337 } 1338 1339 Bool TAppDecTop::ifInvokeBumpingBeforeDecoding( const DpbStatus &dpbStatus, const DpbStatus &dpbLimit, const Int layerIdx, const Int subDpbIdx ) 1340 { 1341 Bool retVal = false; 1342 // Number of reorder picutres 1343 retVal |= ( dpbStatus.m_numAUsNotDisplayed > dpbLimit.m_numAUsNotDisplayed ); 1344 1345 // Number of pictures in each sub-DPB 1346 retVal |= ( dpbStatus.m_numPicsInSubDpb[subDpbIdx] >= dpbLimit.m_numPicsInSubDpb[subDpbIdx] ); 1347 1348 // Number of pictures in each layer 1349 retVal |= ( dpbStatus.m_numPicsInLayer[layerIdx] >= dpbLimit.m_numPicsInLayer[layerIdx]); 1350 1351 return retVal; 1352 } 1353 1354 Bool TAppDecTop::ifInvokeBumpingAfterDecoding( const DpbStatus &dpbStatus, const DpbStatus &dpbLimit ) 1355 { 1356 Bool retVal = false; 1357 1358 // Number of reorder picutres 1359 retVal |= ( dpbStatus.m_numAUsNotDisplayed > dpbLimit.m_numAUsNotDisplayed ); 1360 1361 return retVal; 1362 } 1363 1364 Void TAppDecTop::xFindDPBStatus( std::vector<Int> &listOfPocs 1365 , std::vector<Int> *listOfPocsInEachLayer 1366 , std::vector<Int> *listOfPocsPositionInEachLayer 1367 , DpbStatus &dpbStatus 1368 ) 1369 { 1370 TComVPS *vps = NULL; 1371 dpbStatus.init(); 1372 for( Int i = 0; i < MAX_LAYERS; i++ ) 1373 { 1374 if( m_acTDecTop[i].getListPic()->empty() ) 1375 { 1376 continue; 1377 } 1378 1379 // To check # AUs that have at least one picture not output, 1380 // For each layer, populate listOfPOcs if not already present 1381 TComList<TComPic*>::iterator iterPic = m_acTDecTop[i].getListPic()->begin(); 1382 Int picPositionInList = 0; 1383 while (iterPic != m_acTDecTop[i].getListPic()->end()) 1384 { 1385 TComPic* pic = *(iterPic); 1386 if( pic->getReconMark() ) 1387 { 1388 if( vps == NULL ) 1389 { 1390 vps = pic->getSlice(0)->getVPS(); 1391 } 1392 1393 std::vector<Int>::iterator it; 1394 if( pic->getOutputMark() ) // && pic->getPOC() > m_aiPOCLastDisplay[i]) 1395 { 1396 it = find( listOfPocs.begin(), listOfPocs.end(), pic->getPOC() ); // Check if already included 1397 if( it == listOfPocs.end() ) // New POC value - i.e. new AU - add to the list 1398 { 1399 listOfPocs.push_back( pic->getPOC() ); 1400 } 1401 listOfPocsInEachLayer [i].push_back( pic->getPOC() ); // POC to be output in each layer 1402 listOfPocsPositionInEachLayer [i].push_back( picPositionInList ); // For ease of access 1403 } 1404 if( pic->getSlice(0)->isReferenced() || pic->getOutputMark() ) 1405 { 1406 dpbStatus.m_numPicsInLayer[i]++; // Count pictures that are "used for reference" or "needed for output" 1407 } 1408 } 1409 iterPic++; 1410 picPositionInList++; 1411 } 1412 } 1413 1414 assert( vps != NULL ); // No picture in any DPB? 1415 std::sort( listOfPocs.begin(), listOfPocs.end() ); // Sort in increasing order of POC 1416 Int targetLsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); 1417 // Update status 1418 dpbStatus.m_numAUsNotDisplayed = listOfPocs.size(); // Number of AUs not displayed 1419 dpbStatus.m_numLayers = vps->getNumLayersInIdList( targetLsIdx ); 1420 dpbStatus.m_numSubDpbs = vps->getNumSubDpbs( vps->getOutputLayerSetIdx( 1421 this->getCommonDecoderParams()->getTargetOutputLayerSetIdx() ) ); 1422 1423 for(Int i = 0; i < dpbStatus.m_numLayers; i++) 1424 { 1425 dpbStatus.m_numPicsNotDisplayedInLayer[i] = listOfPocsInEachLayer[i].size(); 1426 dpbStatus.m_numPicsInSubDpb[vps->getSubDpbAssigned(targetLsIdx,i)] += dpbStatus.m_numPicsInLayer[i]; 1427 } 1428 assert( dpbStatus.m_numAUsNotDisplayed != -1 ); 1429 1430 1431 } 1432 #endif 990 1433 //! \} -
trunk/source/App/TAppDecoder/TAppDecTop.h
r595 r644 55 55 // Class definition 56 56 // ==================================================================================================================== 57 57 #if ALIGNED_BUMPING 58 struct DpbStatus; 59 #endif 58 60 /// decoder application class 59 61 class TAppDecTop : public TAppDecCfg … … 98 100 #endif 99 101 Bool isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet 102 #if ALIGNED_BUMPING 103 Void checkOutputBeforeDecoding(Int layerIdx); 104 Void checkOutputAfterDecoding(); 105 Void flushAllPictures(Bool outputPictures); 106 Void flushAllPictures(Int layerId, Bool outputPictures); 107 108 Void xOutputAndMarkPic( TComPic *pic, const Char *reconFile, const Int layerID, Int &pocLastDisplay, DpbStatus &dpbStatus); 109 Void xFindDPBStatus( std::vector<Int> &listOfPocs 110 , std::vector<Int> *listOfPocsInEachLayer 111 , std::vector<Int> *listOfPocsPositionInEachLayer 112 , DpbStatus &dpbStatus 113 ); 114 115 Bool ifInvokeBumpingBeforeDecoding( const DpbStatus &dpbStatus, const DpbStatus &dpbLimit, const Int layerIdx, const Int subDpbIdx ); 116 Bool ifInvokeBumpingAfterDecoding ( const DpbStatus &dpbStatus, const DpbStatus &dpbLimit ); 117 Void bumpingProcess(std::vector<Int> &listOfPocs, std::vector<Int> *listOfPocsInEachLayer, std::vector<Int> *listOfPocsPositionInEachLayer, DpbStatus &dpbStatus); 118 Void emptyUnusedPicturesNotNeededForOutput(); 119 Void markAllPicturesAsErased(); 120 Void markAllPicturesAsErased(Int layerIdx); 121 TComVPS* findDpbParametersFromVps(std::vector<Int> const &listOfPocs, std::vector<Int> const *listOfPocsInEachLayer, std::vector<Int> const *listOfPocsPositionInEachLayer, DpbStatus &maxDpbLimit); 122 #endif 100 123 }; 101 124 125 #if ALIGNED_BUMPING 126 struct DpbStatus 127 { 128 // Number of AUs and pictures 129 Int m_numAUsNotDisplayed; 130 Int m_numPicsNotDisplayedInLayer[MAX_LAYERS]; 131 Int m_numPicsInLayer[MAX_LAYERS]; // Pictures marked as used_for_reference or needed for output in the layer 132 Int m_numPicsInSubDpb[MAX_LAYERS]; // Pictures marked as used_for_reference or needed for output in the sub-DPB 133 Bool m_maxLatencyIncrease; 134 Int m_maxLatencyPictures; 135 136 Int m_numSubDpbs; 137 Int m_numLayers; 138 139 DpbStatus() 140 { 141 init(); 142 } 143 Void init() 144 { 145 m_numAUsNotDisplayed = 0; 146 m_maxLatencyIncrease = false; 147 m_maxLatencyPictures = 0; 148 ::memset( m_numPicsInLayer, 0, sizeof(m_numPicsInLayer) ); 149 ::memset( m_numPicsInSubDpb, 0, sizeof(m_numPicsInSubDpb) ); 150 ::memset(m_numPicsNotDisplayedInLayer, 0, sizeof(m_numPicsNotDisplayedInLayer) ); 151 m_numSubDpbs = -1; 152 m_numLayers = -1; 153 } 154 }; 155 #endif 102 156 //! \} 103 157 -
trunk/source/App/TAppEncoder/TAppEncCfg.cpp
r595 r644 385 385 string cfg_scaledRefLayerBottomOffset [MAX_LAYERS]; 386 386 Int* cfg_numScaledRefLayerOffsets[MAX_LAYERS]; 387 #if P0312_VERT_PHASE_ADJ 388 string cfg_vertPhasePositionEnableFlag[MAX_LAYERS]; 389 #endif 387 390 388 391 #if O0098_SCALED_REF_LAYER_ID … … 393 396 string* cfg_scaledRefLayerRightOffsetPtr [MAX_LAYERS]; 394 397 string* cfg_scaledRefLayerBottomOffsetPtr [MAX_LAYERS]; 398 #if P0312_VERT_PHASE_ADJ 399 string* cfg_vertPhasePositionEnableFlagPtr[MAX_LAYERS]; 400 #endif 401 395 402 #if RC_SHVC_HARMONIZATION 396 403 Bool* cfg_RCEnableRateControl [MAX_LAYERS]; … … 451 458 { 452 459 #if O0098_SCALED_REF_LAYER_ID 453 cfg_scaledRefLayerIdPtr [layer] = &cfg_scaledRefLayerId[layer] 454 #endif 455 cfg_scaledRefLayerLeftOffsetPtr [layer] = &cfg_scaledRefLayerLeftOffset[layer] 456 cfg_scaledRefLayerTopOffsetPtr [layer] = &cfg_scaledRefLayerTopOffset[layer] 457 cfg_scaledRefLayerRightOffsetPtr [layer] = &cfg_scaledRefLayerRightOffset[layer] 460 cfg_scaledRefLayerIdPtr [layer] = &cfg_scaledRefLayerId[layer]; 461 #endif 462 cfg_scaledRefLayerLeftOffsetPtr [layer] = &cfg_scaledRefLayerLeftOffset[layer]; 463 cfg_scaledRefLayerTopOffsetPtr [layer] = &cfg_scaledRefLayerTopOffset[layer]; 464 cfg_scaledRefLayerRightOffsetPtr [layer] = &cfg_scaledRefLayerRightOffset[layer]; 458 465 cfg_scaledRefLayerBottomOffsetPtr[layer] = &cfg_scaledRefLayerBottomOffset[layer]; 466 #if P0312_VERT_PHASE_ADJ 467 cfg_vertPhasePositionEnableFlagPtr[layer] = &cfg_vertPhasePositionEnableFlag[layer]; 468 #endif 459 469 } 460 470 #if RC_SHVC_HARMONIZATION … … 569 579 " bottom-right luma sample of the EL picture, in units of two luma samples") 570 580 ("ScaledRefLayerBottomOffset%d", cfg_scaledRefLayerBottomOffsetPtr,string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to" 571 " bottom-right luma sample of the EL picture, in units of two luma samples") 581 " bottom-right luma sample of the EL picture, in units of two luma samples") 582 #if P0312_VERT_PHASE_ADJ 583 ("VertPhasePositionEnableFlag%d", cfg_vertPhasePositionEnableFlagPtr,string(""), MAX_LAYERS, "VertPhasePositionEnableFlag for layer %d") 584 #endif 572 585 #if O0194_DIFFERENT_BITDEPTH_EL_BL 573 586 ("InputBitDepth%d", cfg_InputBitDepthY, 8, MAX_LAYERS, "Bit-depth of input file for layer %d") … … 588 601 #if N0147_IRAP_ALIGN_FLAG 589 602 ("CrossLayerIrapAlignFlag", m_crossLayerIrapAlignFlag, true, "align IRAP across layers" ) 603 #endif 604 #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG 605 ("CrossLayerAlignedIdrOnlyFlag", m_crossLayerAlignedIdrOnlyFlag, true, "only idr for IRAP across layers" ) 590 606 #endif 591 607 #if O0194_WEIGHTED_PREDICTION_CGS … … 714 730 ("LambdaModifier5,-LM5", m_adLambdaModifier[ 5 ], ( Double )1.0, "Lambda modifier for temporal layer 5") 715 731 ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6") 716 ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( Double )1.0, "Lambda modifier for temporal layer 7")717 732 #endif 718 733 … … 1070 1085 assert( strcmp(cfg_scaledRefLayerId[layer].c_str(), "")); 1071 1086 #endif 1087 #if P0312_VERT_PHASE_ADJ 1072 1088 assert( strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(), "") || 1073 1089 strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(), "") || 1074 1090 strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(), "") || 1075 strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),"") 1076 ); 1091 strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),"") || 1092 strcmp(cfg_vertPhasePositionEnableFlag[layer].c_str(),"") ); 1093 #else 1094 assert( strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(), "") || 1095 strcmp(cfg_scaledRefLayerRightOffset[layer].c_str(), "") || 1096 strcmp(cfg_scaledRefLayerTopOffset[layer].c_str(), "") || 1097 strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),"") ); 1098 #endif 1077 1099 } 1078 1100 … … 1150 1172 } 1151 1173 } 1174 #if P0312_VERT_PHASE_ADJ 1175 // VertPhasePositionEnableFlag // 1176 if(strcmp(cfg_vertPhasePositionEnableFlag[layer].c_str(), "")) 1177 { 1178 cfgStringToArray( &tempArray, cfg_vertPhasePositionEnableFlag[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "VertPhasePositionEnableFlag"); 1179 if(tempArray) 1180 { 1181 for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) 1182 { 1183 m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] = tempArray[i]; 1184 } 1185 delete [] tempArray; tempArray = NULL; 1186 } 1187 } 1188 #endif 1152 1189 } 1153 1190 #if VPS_EXTN_DIRECT_REF_LAYERS … … 2342 2379 printf("Cross layer IRAP alignment : %d\n", m_crossLayerIrapAlignFlag ); 2343 2380 #endif 2381 #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG 2382 printf("IDR only for IRAP : %d\n", m_crossLayerAlignedIdrOnlyFlag ); 2383 #endif 2344 2384 #if O0194_WEIGHTED_PREDICTION_CGS 2345 2385 printf("InterLayerWeightedPred : %d\n", m_useInterLayerWeightedPred ); -
trunk/source/App/TAppEncoder/TAppEncCfg.h
r595 r644 384 384 Bool m_crossLayerIrapAlignFlag; 385 385 #endif 386 #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG 387 Bool m_crossLayerAlignedIdrOnlyFlag; 388 #endif 386 389 #if O0149_CROSS_LAYER_BLA_FLAG 387 390 Bool m_crossLayerBLAFlag; -
trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp
r540 r644 60 60 ::memset(m_scaledRefLayerRightOffset, 0, sizeof(m_scaledRefLayerRightOffset)); 61 61 ::memset(m_scaledRefLayerBottomOffset, 0, sizeof(m_scaledRefLayerBottomOffset)); 62 #if P0312_VERT_PHASE_ADJ 63 ::memset(m_vertPhasePositionEnableFlag, 0, sizeof(m_vertPhasePositionEnableFlag)); 64 #endif 62 65 } 63 66 -
trunk/source/App/TAppEncoder/TAppEncLayerCfg.h
r588 r644 97 97 Int m_scaledRefLayerRightOffset [MAX_LAYERS]; 98 98 Int m_scaledRefLayerBottomOffset[MAX_LAYERS]; 99 #if P0312_VERT_PHASE_ADJ 100 Bool m_vertPhasePositionEnableFlag[MAX_LAYERS]; 101 #endif 102 99 103 #if O0194_DIFFERENT_BITDEPTH_EL_BL 100 104 Int m_inputBitDepthY; ///< bit-depth of input file (luma component) -
trunk/source/App/TAppEncoder/TAppEncTop.cpp
r597 r644 570 570 m_acTEncTop[layer].setScaledRefLayerId(i, m_acLayerCfg[layer].m_scaledRefLayerId[i]); 571 571 #endif 572 #if P0312_VERT_PHASE_ADJ 573 m_acTEncTop[layer].setVertPhasePositionEnableFlag( i, m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] ); 574 m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], 575 2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i], m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] ); 576 #else 572 577 m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], 573 578 2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]); 579 #endif 574 580 } 575 581 } … … 956 962 #endif 957 963 m_acTEncTop[layer].init(isFieldCoding); 964 #if P0182_VPS_VUI_PS_FLAG 965 m_acTEncTop[layer].getVPS()->setSPSId(layer, m_acTEncTop[layer].getSPS()->getSPSId()); 966 m_acTEncTop[layer].getVPS()->setPPSId(layer, m_acTEncTop[layer].getPPS()->getPPSId()); 967 #endif 958 968 } 959 969 #if VPS_RENAME … … 1193 1203 // at the encoder, modify below 1194 1204 Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j ); 1195 oldValue += vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j ) ;1205 oldValue += vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j ) + 1; 1196 1206 vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue ); 1197 1207 #else … … 1200 1210 maxNumReorderPics = std::max( maxNumReorderPics, m_acTEncTop[layerId].getNumReorderPics(j)); 1201 1211 } 1212 #if RESOLUTION_BASED_DPB 1213 for(Int k = 0; k < vps->getNumSubDpbs(i); k++) 1214 { 1215 // Decrement m_maxVpsDecPicBufferingMinus1 1216 Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j ); 1217 vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue - 1 ); 1218 } 1219 #endif 1202 1220 vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics); 1203 1221 vps->determineSubDpbInfoFlags(); … … 1286 1304 vps->setCrossLayerPictureTypeAlignFlag( m_crossLayerPictureTypeAlignFlag ); 1287 1305 #endif 1306 #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG 1307 vps->setCrossLayerAlignedIdrOnlyFlag( m_crossLayerAlignedIdrOnlyFlag ); 1308 #endif 1288 1309 #if N0147_IRAP_ALIGN_FLAG 1289 1310 vps->setCrossLayerIrapAlignFlag( m_crossLayerIrapAlignFlag ); … … 1327 1348 #endif 1328 1349 1350 #if P0300_ALT_OUTPUT_LAYER_FLAG 1351 for (Int k = 0; k < MAX_VPS_LAYER_SETS_PLUS1; k++) 1352 { 1353 vps->setAltOuputLayerFlag( k, m_altOutputLayerFlag ); 1354 } 1355 #else 1329 1356 #if O0153_ALT_OUTPUT_LAYER_FLAG 1330 1357 vps->setAltOuputLayerFlag( m_altOutputLayerFlag ); 1358 #endif 1359 #endif 1360 1361 #if P0312_VERT_PHASE_ADJ 1362 Bool vpsVuiVertPhaseInUseFlag = false; 1363 for( UInt layerId = 1; layerId < m_numLayers; layerId++ ) 1364 { 1365 for( i = 0; i < m_acLayerCfg[layerId].m_numScaledRefLayerOffsets; i++ ) 1366 { 1367 if( m_acTEncTop[layerId].getVertPhasePositionEnableFlag(i) ) 1368 { 1369 vpsVuiVertPhaseInUseFlag = true; 1370 break; 1371 } 1372 } 1373 } 1374 vps->setVpsVuiVertPhaseInUseFlag( vpsVuiVertPhaseInUseFlag ); 1375 #endif 1376 1377 #if O0164_MULTI_LAYER_HRD 1378 vps->setVpsVuiBspHrdPresentFlag(false); 1379 TEncTop *pcCfg = &m_acTEncTop[0]; 1380 if( pcCfg->getBufferingPeriodSEIEnabled() ) 1381 { 1382 vps->setVpsVuiBspHrdPresentFlag(true); 1383 vps->setVpsNumBspHrdParametersMinus1(vps->getNumLayerSets() - 2); 1384 vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); 1385 for ( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) 1386 { 1387 vps->setBspCprmsPresentFlag(i, true); 1388 1389 UInt layerId = i + 1; 1390 TEncTop *pcCfgLayer = &m_acTEncTop[layerId]; 1391 1392 Int iPicWidth = pcCfgLayer->getSourceWidth(); 1393 Int iPicHeight = pcCfgLayer->getSourceHeight(); 1394 UInt uiWidthInCU = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth; 1395 UInt uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; 1396 UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; 1397 1398 UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_uiMaxCUDepth << 1); 1399 UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 ); 1400 if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 ) 1401 { 1402 numDU ++; 1403 } 1404 vps->getBspHrd(i)->setNumDU( numDU ); 1405 vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) ); 1406 } 1407 for(UInt h = 1; h <= (vps->getNumLayerSets()-1); h++) 1408 { 1409 vps->setNumBitstreamPartitions(h, 1); 1410 for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) 1411 { 1412 for( UInt j = 0; j <= (vps->getMaxLayers()-1); j++ ) 1413 { 1414 if (vps->getLayerIdIncludedFlag(h, j) && h == j) 1415 { 1416 vps->setLayerInBspFlag(h, i, j, true); 1417 } 1418 } 1419 } 1420 vps->setNumBspSchedCombinations(h, 1); 1421 for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) 1422 { 1423 for( UInt j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) 1424 { 1425 vps->setBspCombHrdIdx(h, i, j, 0); 1426 vps->setBspCombSchedIdx(h, i, j, 0); 1427 } 1428 } 1429 } 1430 } 1331 1431 #endif 1332 1432
Note: See TracChangeset for help on using the changeset viewer.