Changeset 438 in 3DVCSoftware for branches/HTM-DEV-0.2-dev/source/Lib/TLibEncoder/TEncGOP.cpp
- Timestamp:
- 23 May 2013, 15:40:36 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-DEV-0.2-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r401 r438 96 96 #if L0045_NON_NESTED_SEI_RESTRICTIONS 97 97 xResetNonNestedSEIPresentFlags(); 98 #if K0180_SCALABLE_NESTING_SEI 99 xResetNestedSEIPresentFlags(); 100 #endif 101 #endif 98 #endif 99 102 100 #if H_MV 103 101 m_layerId = 0; … … 108 106 #endif 109 107 #endif 108 110 109 return; 111 110 } … … 212 211 } 213 212 214 #if J0149_TONE_MAPPING_SEI215 SEIToneMappingInfo* TEncGOP::xCreateSEIToneMappingInfo()216 {217 SEIToneMappingInfo *seiToneMappingInfo = new SEIToneMappingInfo();218 seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();219 seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();220 seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag();221 222 seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth();223 assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);224 seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();225 assert( (seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17) || (seiToneMappingInfo->m_targetBitDepth == 255) );226 seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();227 assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);228 229 switch( seiToneMappingInfo->m_modelId)230 {231 case 0:232 {233 seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue();234 seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue();235 break;236 }237 case 1:238 {239 seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint();240 seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth();241 break;242 }243 case 2:244 {245 UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth);246 seiToneMappingInfo->m_startOfCodedInterval.resize(num);247 Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva();248 if(ptmp)249 {250 for(int i=0; i<num;i++)251 {252 seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i];253 }254 }255 break;256 }257 case 3:258 {259 seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots();260 seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots);261 seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots);262 Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue();263 Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue();264 if(ptmpcoded&&ptmptarget)265 {266 for(int i=0; i<(seiToneMappingInfo->m_numPivots);i++)267 {268 seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i];269 seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i];270 }271 }272 break;273 }274 case 4:275 {276 seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc();277 seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();278 assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );279 seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();280 seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();281 seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc();282 seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite();283 seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel();284 assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );285 seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue();286 seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue();287 assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );288 seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue();289 assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );290 break;291 }292 default:293 {294 assert(!"Undefined SEIToneMapModelId");295 break;296 }297 }298 return seiToneMappingInfo;299 }300 #endif301 213 Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps) 302 214 { 303 OutputNALUnit nalu(NAL_UNIT_ PREFIX_SEI);215 OutputNALUnit nalu(NAL_UNIT_SEI); 304 216 305 217 if(m_pcCfg->getActiveParameterSetsSEIEnabled()) … … 322 234 SEIFramePacking *sei = xCreateSEIFramePacking (); 323 235 324 nalu = NALUnit(NAL_UNIT_ PREFIX_SEI);236 nalu = NALUnit(NAL_UNIT_SEI); 325 237 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 326 238 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); … … 333 245 SEIDisplayOrientation *sei = xCreateSEIDisplayOrientation(); 334 246 335 nalu = NALUnit(NAL_UNIT_ PREFIX_SEI);247 nalu = NALUnit(NAL_UNIT_SEI); 336 248 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 337 249 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); … … 340 252 delete sei; 341 253 } 342 #if J0149_TONE_MAPPING_SEI343 if(m_pcCfg->getToneMappingInfoSEIEnabled())344 {345 SEIToneMappingInfo *sei = xCreateSEIToneMappingInfo ();346 347 nalu = NALUnit(NAL_UNIT_PREFIX_SEI);348 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);349 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);350 writeRBSPTrailingBits(nalu.m_Bitstream);351 accessUnit.push_back(new NALUnitEBSP(nalu));352 delete sei;353 }354 #endif355 254 } 356 255 … … 358 257 // Public member functions 359 258 // ==================================================================================================================== 259 360 260 #if H_MV 361 261 Void TEncGOP::initGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP) … … 365 265 } 366 266 #endif 267 367 268 #if H_MV 368 269 Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid) … … 374 275 TComPicYuv* pcPicYuvRecOut; 375 276 TComSlice* pcSlice; 376 TComOutputBitstream *pcBitstreamRedirect; 377 pcBitstreamRedirect = new TComOutputBitstream; 277 TComOutputBitstream* pcBitstreamRedirect = new TComOutputBitstream; 378 278 AccessUnit::iterator itLocationToPushSliceHeaderNALU; // used to store location where NALU containing slice header is to be inserted 379 279 UInt uiOneBitstreamPerSliceLength = 0; … … 386 286 m_iNumPicCoded = 0; 387 287 #endif 288 388 289 SEIPictureTiming pictureTimingSEI; 389 #if L0208_SOP_DESCRIPTION_SEI390 Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled();391 #endif392 #if K0180_SCALABLE_NESTING_SEI393 // Initialize Scalable Nesting SEI with single layer values394 SEIScalableNesting scalableNestingSEI;395 scalableNestingSEI.m_bitStreamSubsetFlag = 1; // If the nested SEI messages are picture buffereing SEI mesages, picure timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1396 scalableNestingSEI.m_nestingOpFlag = 0;397 scalableNestingSEI.m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1398 scalableNestingSEI.m_allLayersFlag = 0;399 scalableNestingSEI.m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1400 scalableNestingSEI.m_nestingNumLayersMinus1 = 1 - 1; //nesting_num_layers_minus1401 scalableNestingSEI.m_nestingLayerId[0] = 0;402 scalableNestingSEI.m_callerOwnsSEIs = true;403 #endif404 290 #if L0044_DU_DPB_OUTPUT_DELAY_HRD 405 291 Int picSptDpbOutputDuDelay = 0; … … 408 294 UInt *accumNalsDU = NULL; 409 295 SEIDecodingUnitInfo decodingUnitInfoSEI; 296 410 297 #if !H_MV 411 298 for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ ) 412 299 #endif 300 413 301 { 414 302 UInt uiColDir = 1; … … 469 357 if(pocCurr>=m_pcCfg->getFramesToBeEncoded()) 470 358 { 359 471 360 #if H_MV 472 361 delete pcBitstreamRedirect; … … 475 364 continue; 476 365 #endif 477 } 478 479 if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 366 367 } 368 369 if( getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 480 370 { 481 371 m_iLastIDR = pocCurr; … … 495 385 pcSlice->setLastIDR(m_iLastIDR); 496 386 pcSlice->setSliceIdx(0); 387 497 388 #if H_MV 498 389 pcPic ->setLayerId ( getLayerId() ); … … 506 397 #endif 507 398 #endif 399 508 400 //set default slice level flag to the same as SPS level flag 509 401 pcSlice->setLFCrossSliceBoundaryFlag( pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() ); … … 545 437 #if H_MV 546 438 // Set the nal unit type 547 pcSlice->setNalUnitType(getNalUnitType(pocCurr , m_iLastIDR));439 pcSlice->setNalUnitType(getNalUnitType(pocCurr)); 548 440 if( pcSlice->getSliceType() == B_SLICE ) 549 441 { … … 559 451 } 560 452 // Set the nal unit type 561 pcSlice->setNalUnitType(getNalUnitType(pocCurr , m_iLastIDR));562 #endif 563 if(pcSlice->get TemporalLayerNonReferenceFlag())564 { 565 if(pcSlice->get NalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)453 pcSlice->setNalUnitType(getNalUnitType(pocCurr)); 454 #endif 455 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R) 456 { 457 if(pcSlice->getTemporalLayerNonReferenceFlag()) 566 458 { 567 459 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N); 568 }569 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RADL_R)570 {571 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RADL_N);572 }573 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RASL_R)574 {575 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RASL_N);576 460 } 577 461 } … … 598 482 else 599 483 { 600 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA _R);484 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA); 601 485 } 602 486 } … … 684 568 } 685 569 #endif 686 #if !L0034_COMBINED_LIST_CLEANUP 570 687 571 if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb()) 688 572 { … … 696 580 pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0)); 697 581 } 698 #endif699 582 700 583 if (pcSlice->getSliceType() == B_SLICE) … … 722 605 pcSlice->setCheckLDC(bLowDelay); 723 606 } 724 else725 {726 pcSlice->setCheckLDC(true);727 }728 607 729 608 uiColDir = 1-uiColDir; … … 732 611 pcSlice->setRefPOCList(); 733 612 734 #if L0034_COMBINED_LIST_CLEANUP735 pcSlice->setList1IdxToList0Idx();736 #else737 613 pcSlice->setNoBackPredFlag( false ); 738 614 if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag()) … … 758 634 } 759 635 pcSlice->generateCombinedList(); 760 #endif761 636 762 637 if (m_pcEncTop->getTMVPModeId() == 2) … … 1064 939 Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); 1065 940 m_pcLoopFilter->setCfg(bLFCrossTileBoundary); 1066 #if L0386_DB_METRIC1067 if ( m_pcCfg->getDeblockingFilterMetric() )1068 {1069 dblMetric(pcPic, uiNumSlices);1070 }1071 #endif1072 941 m_pcLoopFilter->loopFilterPic( pcPic ); 1073 942 … … 1168 1037 } 1169 1038 1170 #if L0208_SOP_DESCRIPTION_SEI1171 if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP1172 {1173 Int SOPcurrPOC = pocCurr;1174 1175 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);1176 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);1177 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);1178 1179 SEISOPDescription SOPDescriptionSEI;1180 SOPDescriptionSEI.m_sopSeqParameterSetId = pcSlice->getSPS()->getSPSId();1181 1182 UInt i = 0;1183 UInt prevEntryId = iGOPid;1184 for (j = iGOPid; j < m_iGopSize; j++)1185 {1186 Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;1187 if ((SOPcurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())1188 {1189 SOPcurrPOC += deltaPOC;1190 SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR);1191 SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;1192 SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j);1193 SOPDescriptionSEI.m_sopDescPocDelta[i] = deltaPOC;1194 1195 prevEntryId = j;1196 i++;1197 }1198 }1199 1200 SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1;1201 1202 m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS());1203 writeRBSPTrailingBits(nalu.m_Bitstream);1204 accessUnit.push_back(new NALUnitEBSP(nalu));1205 1206 writeSOP = false;1207 }1208 #endif1209 1210 1039 if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) && 1211 1040 ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) && … … 1253 1082 || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) ) 1254 1083 { 1255 OutputNALUnit nalu(NAL_UNIT_ PREFIX_SEI);1084 OutputNALUnit nalu(NAL_UNIT_SEI); 1256 1085 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1257 1086 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); … … 1294 1123 writeRBSPTrailingBits(nalu.m_Bitstream); 1295 1124 #if L0045_NON_NESTED_SEI_RESTRICTIONS 1296 {1297 1125 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 1298 1126 UInt offsetPosition = m_activeParameterSetSEIPresentInAU; // Insert BP SEI after APS SEI … … 1304 1132 accessUnit.insert(it, new NALUnitEBSP(nalu)); 1305 1133 m_bufferingPeriodSEIPresentInAU = true; 1306 }1307 1134 #else 1308 1135 accessUnit.push_back(new NALUnitEBSP(nalu)); 1309 1136 #endif 1310 1137 1311 #if K0180_SCALABLE_NESTING_SEI1312 if (m_pcCfg->getScalableNestingSEIEnabled())1313 {1314 OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI);1315 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);1316 m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream);1317 scalableNestingSEI.m_nestedSEIs.clear();1318 scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period);1319 m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());1320 writeRBSPTrailingBits(naluTmp.m_Bitstream);1321 #if L0045_NON_NESTED_SEI_RESTRICTIONS1322 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);1323 UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU; // Insert BP SEI after non-nested APS, BP and PT SEIs1324 AccessUnit::iterator it;1325 for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)1326 {1327 it++;1328 }1329 accessUnit.insert(it, new NALUnitEBSP(naluTmp));1330 m_nestedBufferingPeriodSEIPresentInAU = true;1331 #else1332 accessUnit.push_back(new NALUnitEBSP(naluTmp));1333 #endif1334 }1335 #endif1336 1337 1138 m_lastBPSEI = m_totalCoded; 1338 1139 m_cpbRemovalDelay = 0; … … 1344 1145 { 1345 1146 // Gradual decoding refresh SEI 1346 OutputNALUnit nalu(NAL_UNIT_ PREFIX_SEI);1147 OutputNALUnit nalu(NAL_UNIT_SEI); 1347 1148 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1348 1149 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); … … 1356 1157 } 1357 1158 // Recovery point SEI 1358 OutputNALUnit nalu(NAL_UNIT_ PREFIX_SEI);1159 OutputNALUnit nalu(NAL_UNIT_SEI); 1359 1160 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1360 1161 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); … … 1547 1348 1548 1349 pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength ); 1350 if (!sliceSegment) 1351 { 1549 1352 pcSlice->setTileLocationCount ( 0 ); 1550 m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut); 1353 m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info. 1354 } 1355 else 1356 { 1357 m_pcSliceEncoder->encodeSlice(pcPic, &nalu.m_Bitstream, pcSubstreamsOut); // nalu.m_Bitstream is only used for CAVLC tile position info. 1358 } 1551 1359 1552 1360 { … … 1580 1388 if (ui+1 < pcSlice->getPPS()->getNumSubstreams()) 1581 1389 { 1582 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);1390 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits(); 1583 1391 } 1584 1392 } … … 1612 1420 // If current NALU is the last NALU of slice and a NALU was buffered, then (a) Write current NALU (b) Update an write buffered NALU at approproate location in NALU list. 1613 1421 Bool bNALUAlignedWrittenToList = false; // used to ensure current NALU is not written more than once to the NALU list. 1614 x AttachSliceDataToNalUnit(nalu, pcBitstreamRedirect);1422 xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice); 1615 1423 accessUnit.push_back(new NALUnitEBSP(nalu)); 1616 1424 #if RATE_CONTROL_LAMBDA_DOMAIN … … 1640 1448 { 1641 1449 UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size()); 1642 if ((*it)->m_nalUnitType != NAL_UNIT_ PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)1450 if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX) 1643 1451 { 1644 1452 numRBSPBytes += numRBSPBytes_nal; … … 1710 1518 pcPic->compressMotion(); 1711 1519 #endif 1520 1712 1521 #if H_MV 1713 1522 m_pocLastCoded = pcPic->getPOC(); … … 1740 1549 digestStr = digestToString(sei_recon_picture_digest.digest, 4); 1741 1550 } 1742 OutputNALUnit nalu(NAL_UNIT_S UFFIX_SEI, pcSlice->getTLayer());1551 OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer()); 1743 1552 1744 1553 /* write the SEI messages */ … … 1764 1573 sei_temporal_level0_index.rapIdx = m_rapIdx; 1765 1574 1766 OutputNALUnit nalu(NAL_UNIT_ PREFIX_SEI);1575 OutputNALUnit nalu(NAL_UNIT_SEI); 1767 1576 1768 1577 /* write the SEI messages */ … … 1904 1713 if( m_pcCfg->getPictureTimingSEIEnabled() ) 1905 1714 { 1906 { 1907 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 1715 OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer()); 1908 1716 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1909 1717 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); … … 1925 1733 #endif 1926 1734 } 1927 #if K0180_SCALABLE_NESTING_SEI1928 if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI1929 {1930 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());1931 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);1932 scalableNestingSEI.m_nestedSEIs.clear();1933 scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI);1934 m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());1935 writeRBSPTrailingBits(nalu.m_Bitstream);1936 #if L0045_NON_NESTED_SEI_RESTRICTIONS1937 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);1938 UInt offsetPosition = m_activeParameterSetSEIPresentInAU1939 + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU + m_nestedBufferingPeriodSEIPresentInAU; // Insert PT SEI after APS and BP SEI1940 AccessUnit::iterator it;1941 for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)1942 {1943 it++;1944 }1945 accessUnit.insert(it, new NALUnitEBSP(nalu));1946 m_nestedPictureTimingSEIPresentInAU = true;1947 #else1948 AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));1949 accessUnit.insert(it, new NALUnitEBSP(nalu));1950 #endif1951 }1952 #endif1953 1954 }1955 1735 if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() ) 1956 1736 { … … 1958 1738 for( Int i = 0; i < ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 ); i ++ ) 1959 1739 { 1960 OutputNALUnit nalu(NAL_UNIT_ PREFIX_SEI, pcSlice->getTLayer());1740 OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer()); 1961 1741 1962 1742 SEIDecodingUnitInfo tempSEI; … … 2006 1786 break; 2007 1787 } 2008 if ((*it)->m_nalUnitType != NAL_UNIT_ PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)1788 if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX) 2009 1789 { 2010 1790 ctr++; … … 2017 1797 #if L0045_NON_NESTED_SEI_RESTRICTIONS 2018 1798 xResetNonNestedSEIPresentFlags(); 2019 #if K0180_SCALABLE_NESTING_SEI2020 xResetNestedSEIPresentFlags();2021 #endif2022 1799 #endif 2023 1800 pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut); … … 2052 1829 assert ( m_iNumPicCoded == iNumPicRcvd ); 2053 1830 #endif 1831 2054 1832 } 2055 1833 … … 2245 2023 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R"; 2246 2024 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N"; 2247 case NAL_UNIT_CODED_SLICE_TLA _R: return "TLA_R";2025 case NAL_UNIT_CODED_SLICE_TLA: return "TLA"; 2248 2026 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N"; 2249 2027 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R"; 2250 2028 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N"; 2251 case NAL_UNIT_CODED_SLICE_BLA _W_LP: return "BLA_W_LP";2252 case NAL_UNIT_CODED_SLICE_BLA _W_RADL: return "BLA_W_RADL";2029 case NAL_UNIT_CODED_SLICE_BLA: return "BLA"; 2030 case NAL_UNIT_CODED_SLICE_BLANT: return "BLANT"; 2253 2031 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP"; 2254 case NAL_UNIT_CODED_SLICE_IDR _W_RADL: return "IDR_W_RADL";2032 case NAL_UNIT_CODED_SLICE_IDR: return "IDR"; 2255 2033 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP"; 2256 2034 case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; 2257 case NAL_UNIT_CODED_SLICE_ RADL_R: return "RADL_R";2258 case NAL_UNIT_CODED_SLICE_ RASL_R: return "RASL_R";2035 case NAL_UNIT_CODED_SLICE_DLP: return "DLP"; 2036 case NAL_UNIT_CODED_SLICE_TFD: return "TFD"; 2259 2037 case NAL_UNIT_VPS: return "VPS"; 2260 2038 case NAL_UNIT_SPS: return "SPS"; … … 2264 2042 case NAL_UNIT_EOB: return "EOB"; 2265 2043 case NAL_UNIT_FILLER_DATA: return "FILLER"; 2266 case NAL_UNIT_PREFIX_SEI: return "SEI"; 2267 case NAL_UNIT_SUFFIX_SEI: return "SEI"; 2044 case NAL_UNIT_SEI: return "SEI"; 2268 2045 default: return "UNK"; 2269 2046 } … … 2356 2133 printf("*** %6s numBytesInNALunit: %u\n", nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal); 2357 2134 #endif 2358 if ((*it)->m_nalUnitType != NAL_UNIT_ PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)2135 if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX) 2359 2136 { 2360 2137 numRBSPBytes += numRBSPBytes_nal; … … 2366 2143 2367 2144 //===== add PSNR ===== 2145 2368 2146 #if H_MV 2369 2147 m_pcEncTop->getAnalyzeAll()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); … … 2371 2149 m_gcAnalyzeAll.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); 2372 2150 #endif 2151 2373 2152 TComSlice* pcSlice = pcPic->getSlice(0); 2374 2153 if (pcSlice->isIntra()) 2375 2154 { 2155 2376 2156 #if H_MV 2377 2157 m_pcEncTop->getAnalyzeI()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); … … 2379 2159 m_gcAnalyzeI.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); 2380 2160 #endif 2161 2381 2162 } 2382 2163 if (pcSlice->isInterP()) 2383 2164 { 2165 2384 2166 #if H_MV 2385 2167 m_pcEncTop->getAnalyzeP()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); … … 2387 2169 m_gcAnalyzeP.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); 2388 2170 #endif 2171 2389 2172 } 2390 2173 if (pcSlice->isInterB()) 2391 2174 { 2175 2392 2176 #if H_MV 2393 2177 m_pcEncTop->getAnalyzeB()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); … … 2395 2179 m_gcAnalyzeB.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits); 2396 2180 #endif 2181 2397 2182 } 2398 2183 … … 2401 2186 2402 2187 #if ADAPTIVE_QP_SELECTION 2188 2403 2189 #if H_MV 2404 2190 printf("Layer %3d POC %4d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits", … … 2419 2205 uibits ); 2420 2206 #endif 2207 2421 2208 #else 2209 2422 2210 #if H_MV 2423 2211 printf("Layer %3d POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits", … … 2436 2224 uibits ); 2437 2225 #endif 2226 2438 2227 #endif 2439 2228 … … 2468 2257 * This function checks the configuration and returns the appropriate nal_unit_type for the picture. 2469 2258 */ 2470 NalUnitType TEncGOP::getNalUnitType(Int pocCurr , Int lastIDR)2259 NalUnitType TEncGOP::getNalUnitType(Int pocCurr) 2471 2260 { 2472 2261 if (pocCurr == 0) 2473 2262 { 2474 return NAL_UNIT_CODED_SLICE_IDR _W_RADL;2263 return NAL_UNIT_CODED_SLICE_IDR; 2475 2264 } 2476 2265 if (pocCurr % m_pcCfg->getIntraPeriod() == 0) … … 2482 2271 else if (m_pcCfg->getDecodingRefreshType() == 2) 2483 2272 { 2484 return NAL_UNIT_CODED_SLICE_IDR _W_RADL;2273 return NAL_UNIT_CODED_SLICE_IDR; 2485 2274 } 2486 2275 } … … 2494 2283 // controlling the reference pictures used for encoding that leading picture. Such a leading 2495 2284 // picture need not be marked as a TFD picture. 2496 return NAL_UNIT_CODED_SLICE_RASL_R; 2497 } 2498 } 2499 if (lastIDR>0) 2500 { 2501 if (pocCurr < lastIDR) 2502 { 2503 return NAL_UNIT_CODED_SLICE_RADL_R; 2285 return NAL_UNIT_CODED_SLICE_TFD; 2504 2286 } 2505 2287 } … … 2552 2334 } 2553 2335 2554 /** Attaches the input bitstream to the stream in the output NAL unit 2555 Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call. 2556 * \param codedSliceData contains the coded slice data (bitstream) to be concatenated to rNalu 2557 * \param rNalu target NAL unit 2336 /** Determine the difference between consecutive tile sizes (in bytes) and writes it to bistream rNalu [slice header] 2337 * \param rpcBitstreamRedirect contains the bitstream to be concatenated to rNalu. rpcBitstreamRedirect contains slice payload. rpcSlice contains tile location information. 2338 * \returns Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call. 2558 2339 */ 2559 Void TEncGOP::x AttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& codedSliceData)2340 Void TEncGOP::xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice) 2560 2341 { 2561 2342 // Byte-align … … 2563 2344 2564 2345 // Perform bitstream concatenation 2565 if (codedSliceData->getNumberOfWrittenBits() > 0) 2566 { 2567 rNalu.m_Bitstream.addSubstream(codedSliceData); 2346 if (rpcBitstreamRedirect->getNumberOfWrittenBits() > 0) 2347 { 2348 UInt uiBitCount = rpcBitstreamRedirect->getNumberOfWrittenBits(); 2349 if (rpcBitstreamRedirect->getByteStreamLength()>0) 2350 { 2351 UChar *pucStart = reinterpret_cast<UChar*>(rpcBitstreamRedirect->getByteStream()); 2352 UInt uiWriteByteCount = 0; 2353 while (uiWriteByteCount < (uiBitCount >> 3) ) 2354 { 2355 UInt uiBits = (*pucStart); 2356 rNalu.m_Bitstream.write(uiBits, 8); 2357 pucStart++; 2358 uiWriteByteCount++; 2359 } 2360 } 2361 UInt uiBitsHeld = (uiBitCount & 0x07); 2362 for (UInt uiIdx=0; uiIdx < uiBitsHeld; uiIdx++) 2363 { 2364 rNalu.m_Bitstream.write((rpcBitstreamRedirect->getHeldBits() & (1 << (7-uiIdx))) >> (7-uiIdx), 1); 2365 } 2568 2366 } 2569 2367 2570 2368 m_pcEntropyCoder->setBitstream(&rNalu.m_Bitstream); 2571 2369 2572 codedSliceData->clear(); 2370 delete rpcBitstreamRedirect; 2371 rpcBitstreamRedirect = new TComOutputBitstream; 2573 2372 } 2574 2373 … … 2695 2494 } 2696 2495 } 2697 // assert(it != accessUnit.end()); // Triggers with some legit configurations 2496 assert(it != accessUnit.end()); 2698 2497 return seiStartPos; 2699 2498 } 2700 2499 #endif 2701 2500 2702 #if L0386_DB_METRIC2703 Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices )2704 {2705 TComPicYuv* pcPicYuvRec = pcPic->getPicYuvRec();2706 Pel* Rec = pcPicYuvRec->getLumaAddr( 0 );2707 Pel* tempRec = Rec;2708 Int stride = pcPicYuvRec->getStride();2709 UInt log2maxTB = pcPic->getSlice(0)->getSPS()->getQuadtreeTULog2MaxSize();2710 UInt maxTBsize = (1<<log2maxTB);2711 const UInt minBlockArtSize = 8;2712 const UInt picWidth = pcPicYuvRec->getWidth();2713 const UInt picHeight = pcPicYuvRec->getHeight();2714 const UInt noCol = (picWidth>>log2maxTB);2715 const UInt noRows = (picHeight>>log2maxTB);2716 UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64));2717 UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64));2718 UInt colIdx = 0;2719 UInt rowIdx = 0;2720 Pel p0, p1, p2, q0, q1, q2;2721 2722 Int qp = pcPic->getSlice(0)->getSliceQp();2723 Int bitdepthScale = 1 << (g_bitDepthY-8);2724 Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale;2725 const Int thr2 = (beta>>2);2726 const Int thr1 = 2*bitdepthScale;2727 UInt a = 0;2728 2729 memset(colSAD, 0, noCol*sizeof(UInt64));2730 memset(rowSAD, 0, noRows*sizeof(UInt64));2731 2732 if (maxTBsize > minBlockArtSize)2733 {2734 // Analyze vertical artifact edges2735 for(Int c = maxTBsize; c < picWidth; c += maxTBsize)2736 {2737 for(Int r = 0; r < picHeight; r++)2738 {2739 p2 = Rec[c-3];2740 p1 = Rec[c-2];2741 p0 = Rec[c-1];2742 q0 = Rec[c];2743 q1 = Rec[c+1];2744 q2 = Rec[c+2];2745 a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);2746 if ( thr1 < a && a < thr2)2747 {2748 colSAD[colIdx] += abs(p0 - q0);2749 }2750 Rec += stride;2751 }2752 colIdx++;2753 Rec = tempRec;2754 }2755 2756 // Analyze horizontal artifact edges2757 for(Int r = maxTBsize; r < picHeight; r += maxTBsize)2758 {2759 for(Int c = 0; c < picWidth; c++)2760 {2761 p2 = Rec[c + (r-3)*stride];2762 p1 = Rec[c + (r-2)*stride];2763 p0 = Rec[c + (r-1)*stride];2764 q0 = Rec[c + r*stride];2765 q1 = Rec[c + (r+1)*stride];2766 q2 = Rec[c + (r+2)*stride];2767 a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);2768 if (thr1 < a && a < thr2)2769 {2770 rowSAD[rowIdx] += abs(p0 - q0);2771 }2772 }2773 rowIdx++;2774 }2775 }2776 2777 UInt64 colSADsum = 0;2778 UInt64 rowSADsum = 0;2779 for(Int c = 0; c < noCol-1; c++)2780 {2781 colSADsum += colSAD[c];2782 }2783 for(Int r = 0; r < noRows-1; r++)2784 {2785 rowSADsum += rowSAD[r];2786 }2787 2788 colSADsum <<= 10;2789 rowSADsum <<= 10;2790 colSADsum /= (noCol-1);2791 colSADsum /= picHeight;2792 rowSADsum /= (noRows-1);2793 rowSADsum /= picWidth;2794 2795 UInt64 avgSAD = ((colSADsum + rowSADsum)>>1);2796 avgSAD >>= (g_bitDepthY-8);2797 2798 if ( avgSAD > 2048 )2799 {2800 avgSAD >>= 9;2801 Int offset = Clip3(2,6,(Int)avgSAD);2802 for (Int i=0; i<uiNumSlices; i++)2803 {2804 pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(true);2805 pcPic->getSlice(i)->setDeblockingFilterDisable(false);2806 pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( offset );2807 pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( offset );2808 }2809 }2810 else2811 {2812 for (Int i=0; i<uiNumSlices; i++)2813 {2814 pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(false);2815 pcPic->getSlice(i)->setDeblockingFilterDisable( pcPic->getSlice(i)->getPPS()->getPicDisableDeblockingFilterFlag() );2816 pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterBetaOffsetDiv2() );2817 pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterTcOffsetDiv2() );2818 }2819 }2820 2821 free(colSAD);2822 free(rowSAD);2823 }2824 #endif2825 2501 #if H_MV 2826 2502 Void TEncGOP::xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid ) … … 2846 2522 { 2847 2523 Int numModifications = 0; 2848 2524 2849 2525 for( Int k = 0; k < ge.m_numInterViewRefPics; k++ ) 2850 2526 { … … 2853 2529 2854 2530 // set inter-view modifications 2855 Bool isModified = false;2856 Int tempList[16];2857 for( Int k = 0; k < 16; k++ ) { tempList[k] = -1; }2858 2859 2531 if( (maxRefListSize > 1) && (numModifications > 0) ) 2860 2532 { 2533 refPicListModification->setRefPicListModificationFlagL( li, true ); 2534 Int tempList[16]; 2535 for( Int k = 0; k < 16; k++ ) { tempList[k] = -1; } 2536 2537 Bool isModified = false; 2861 2538 for( Int k = 0; k < ge.m_numInterViewRefPics; k++ ) 2862 2539 { … … 2877 2554 } 2878 2555 } 2879 } 2880 2881 refPicListModification->setRefPicListModificationFlagL( li, isModified ); 2882 2883 if( isModified ) 2884 { 2885 Int temporalRefIdx = 0; 2886 for( Int i = 0; i < pcSlice->getNumRefIdx( ( li == 0 ) ? REF_PIC_LIST_0 : REF_PIC_LIST_1 ); i++ ) 2887 { 2888 if( tempList[i] >= 0 ) 2889 { 2890 refPicListModification->setRefPicSetIdxL( li, i, tempList[i] ); 2891 } 2892 else 2893 { 2894 refPicListModification->setRefPicSetIdxL( li, i, temporalRefIdx ); 2895 temporalRefIdx++; 2896 } 2897 } 2898 } 2556 if( isModified ) 2557 { 2558 Int temporalRefIdx = 0; 2559 for( Int i = 0; i < pcSlice->getNumRefIdx( ( li == 0 ) ? REF_PIC_LIST_0 : REF_PIC_LIST_1 ); i++ ) 2560 { 2561 if( tempList[i] >= 0 ) 2562 { 2563 refPicListModification->setRefPicSetIdxL( li, i, tempList[i] ); 2564 } 2565 else 2566 { 2567 refPicListModification->setRefPicSetIdxL( li, i, temporalRefIdx ); 2568 temporalRefIdx++; 2569 } 2570 } 2571 } 2572 else 2573 { 2574 refPicListModification->setRefPicListModificationFlagL( li, false ); 2575 } 2576 } 2899 2577 } 2900 2578 } 2901 2579 #endif 2580 2902 2581 //! \}
Note: See TracChangeset for help on using the changeset viewer.