Changeset 133 in SHVCSoftware for branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp
- Timestamp:
- 28 Apr 2013, 08:49:16 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r125 r133 96 96 #if L0045_NON_NESTED_SEI_RESTRICTIONS 97 97 xResetNonNestedSEIPresentFlags(); 98 #if K0180_SCALABLE_NESTING_SEI 99 xResetNestedSEIPresentFlags(); 100 #endif 98 101 #endif 99 102 #if SVC_UPSAMPLING … … 134 137 m_pcSliceEncoder = pcTEncTop->getSliceEncoder(); 135 138 m_pcListPic = pcTEncTop->getListPic(); 139 136 140 m_pcEntropyCoder = pcTEncTop->getEntropyCoder(); 137 141 m_pcCavlcCoder = pcTEncTop->getCavlcCoder(); … … 210 214 } 211 215 216 #if J0149_TONE_MAPPING_SEI 217 SEIToneMappingInfo* TEncGOP::xCreateSEIToneMappingInfo() 218 { 219 SEIToneMappingInfo *seiToneMappingInfo = new SEIToneMappingInfo(); 220 seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId(); 221 seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag(); 222 seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag(); 223 224 seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth(); 225 assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14); 226 seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth(); 227 assert( (seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17) || (seiToneMappingInfo->m_targetBitDepth == 255) ); 228 seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID(); 229 assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4); 230 231 switch( seiToneMappingInfo->m_modelId) 232 { 233 case 0: 234 { 235 seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue(); 236 seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue(); 237 break; 238 } 239 case 1: 240 { 241 seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint(); 242 seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth(); 243 break; 244 } 245 case 2: 246 { 247 UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth); 248 seiToneMappingInfo->m_startOfCodedInterval.resize(num); 249 Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva(); 250 if(ptmp) 251 { 252 for(int i=0; i<num;i++) 253 { 254 seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i]; 255 } 256 } 257 break; 258 } 259 case 3: 260 { 261 seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots(); 262 seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots); 263 seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots); 264 Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue(); 265 Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue(); 266 if(ptmpcoded&&ptmptarget) 267 { 268 for(int i=0; i<(seiToneMappingInfo->m_numPivots);i++) 269 { 270 seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i]; 271 seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i]; 272 } 273 } 274 break; 275 } 276 case 4: 277 { 278 seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc(); 279 seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue(); 280 assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 ); 281 seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag(); 282 seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator(); 283 seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc(); 284 seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite(); 285 seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel(); 286 assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 ); 287 seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue(); 288 seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue(); 289 assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue ); 290 seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue(); 291 assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue ); 292 break; 293 } 294 default: 295 { 296 assert(!"Undefined SEIToneMapModelId"); 297 break; 298 } 299 } 300 return seiToneMappingInfo; 301 } 302 #endif 212 303 Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps) 213 304 { 214 OutputNALUnit nalu(NAL_UNIT_ SEI);305 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI); 215 306 216 307 if(m_pcCfg->getActiveParameterSetsSEIEnabled()) … … 233 324 SEIFramePacking *sei = xCreateSEIFramePacking (); 234 325 235 nalu = NALUnit(NAL_UNIT_ SEI);326 nalu = NALUnit(NAL_UNIT_PREFIX_SEI); 236 327 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 237 328 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); … … 244 335 SEIDisplayOrientation *sei = xCreateSEIDisplayOrientation(); 245 336 246 nalu = NALUnit(NAL_UNIT_ SEI);337 nalu = NALUnit(NAL_UNIT_PREFIX_SEI); 247 338 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 248 339 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); … … 251 342 delete sei; 252 343 } 344 #if J0149_TONE_MAPPING_SEI 345 if(m_pcCfg->getToneMappingInfoSEIEnabled()) 346 { 347 SEIToneMappingInfo *sei = xCreateSEIToneMappingInfo (); 348 349 nalu = NALUnit(NAL_UNIT_PREFIX_SEI); 350 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 351 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); 352 writeRBSPTrailingBits(nalu.m_Bitstream); 353 accessUnit.push_back(new NALUnitEBSP(nalu)); 354 delete sei; 355 } 356 #endif 253 357 } 254 358 … … 276 380 m_iNumPicCoded = 0; 277 381 SEIPictureTiming pictureTimingSEI; 382 #if L0208_SOP_DESCRIPTION_SEI 383 Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled(); 384 #endif 385 #if K0180_SCALABLE_NESTING_SEI 386 // Initialize Scalable Nesting SEI with single layer values 387 SEIScalableNesting scalableNestingSEI; 388 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 1 389 scalableNestingSEI.m_nestingOpFlag = 0; 390 scalableNestingSEI.m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1 391 scalableNestingSEI.m_allLayersFlag = 0; 392 scalableNestingSEI.m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1 393 scalableNestingSEI.m_nestingNumLayersMinus1 = 1 - 1; //nesting_num_layers_minus1 394 scalableNestingSEI.m_nestingLayerId[0] = 0; 395 scalableNestingSEI.m_callerOwnsSEIs = true; 396 #endif 278 397 #if L0044_DU_DPB_OUTPUT_DELAY_HRD 279 398 Int picSptDpbOutputDuDelay = 0; … … 348 467 } 349 468 350 if( getNalUnitType(pocCurr ) == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR_N_LP )469 if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 351 470 { 352 471 m_iLastIDR = pocCurr; … … 411 530 } 412 531 // Set the nal unit type 413 pcSlice->setNalUnitType(getNalUnitType(pocCurr ));532 pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR)); 414 533 #if IDR_ALIGNMENT 415 534 if (m_layerId > 0) … … 424 543 { 425 544 #if IDR_ALIGNMENT 426 if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR )427 { 428 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_IDR);545 if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 546 { 547 pcSlice->setNalUnitType(pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType()); 429 548 } 430 549 else … … 434 553 if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() ) 435 554 { 436 if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA ) &&555 if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && 437 556 (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && 438 557 pcSlice->getSliceType() == B_SLICE ) … … 442 561 } 443 562 #endif 444 if(pcSlice->get NalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)445 { 446 if(pcSlice->get TemporalLayerNonReferenceFlag())563 if(pcSlice->getTemporalLayerNonReferenceFlag()) 564 { 565 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R) 447 566 { 448 567 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); 449 576 } 450 577 } … … 471 598 else 472 599 { 473 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA );600 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R); 474 601 } 475 602 } … … 527 654 if(m_layerId > 0) 528 655 { 529 if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )656 if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) 530 657 { 531 658 pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumILRRefIdx()); … … 644 771 pcSlice->setSliceType ( P_SLICE ); 645 772 } 646 773 #if !L0034_COMBINED_LIST_CLEANUP 647 774 if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb()) 648 775 { … … 656 783 pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0)); 657 784 } 785 #endif 658 786 659 787 if (pcSlice->getSliceType() == B_SLICE) … … 683 811 pcSlice->setCheckLDC(bLowDelay); 684 812 } 813 else 814 { 815 pcSlice->setCheckLDC(true); 816 } 685 817 686 818 uiColDir = 1-uiColDir; … … 689 821 pcSlice->setRefPOCList(); 690 822 823 #if L0034_COMBINED_LIST_CLEANUP 824 pcSlice->setList1IdxToList0Idx(); 825 #else 691 826 pcSlice->setNoBackPredFlag( false ); 692 827 if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag()) … … 712 847 } 713 848 pcSlice->generateCombinedList(); 849 #endif 714 850 715 851 if (m_pcEncTop->getTMVPModeId() == 2) … … 1027 1163 Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); 1028 1164 m_pcLoopFilter->setCfg(bLFCrossTileBoundary); 1165 #if L0386_DB_METRIC 1166 if ( m_pcCfg->getDeblockingFilterMetric() ) 1167 { 1168 dblMetric(pcPic, uiNumSlices); 1169 } 1170 #endif 1029 1171 m_pcLoopFilter->loopFilterPic( pcPic ); 1030 1172 … … 1133 1275 } 1134 1276 1277 #if L0208_SOP_DESCRIPTION_SEI 1278 if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP 1279 { 1280 Int SOPcurrPOC = pocCurr; 1281 1282 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI); 1283 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1284 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 1285 1286 SEISOPDescription SOPDescriptionSEI; 1287 SOPDescriptionSEI.m_sopSeqParameterSetId = pcSlice->getSPS()->getSPSId(); 1288 1289 UInt i = 0; 1290 UInt prevEntryId = iGOPid; 1291 for (j = iGOPid; j < m_iGopSize; j++) 1292 { 1293 Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC; 1294 if ((SOPcurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded()) 1295 { 1296 SOPcurrPOC += deltaPOC; 1297 SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR); 1298 SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId; 1299 SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j); 1300 SOPDescriptionSEI.m_sopDescPocDelta[i] = deltaPOC; 1301 1302 prevEntryId = j; 1303 i++; 1304 } 1305 } 1306 1307 SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1; 1308 1309 m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS()); 1310 writeRBSPTrailingBits(nalu.m_Bitstream); 1311 accessUnit.push_back(new NALUnitEBSP(nalu)); 1312 1313 writeSOP = false; 1314 } 1315 #endif 1316 1135 1317 if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) && 1136 1318 ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) && … … 1178 1360 || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) ) 1179 1361 { 1180 OutputNALUnit nalu(NAL_UNIT_ SEI);1362 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI); 1181 1363 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1182 1364 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); … … 1219 1401 writeRBSPTrailingBits(nalu.m_Bitstream); 1220 1402 #if L0045_NON_NESTED_SEI_RESTRICTIONS 1403 { 1221 1404 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 1222 1405 UInt offsetPosition = m_activeParameterSetSEIPresentInAU; // Insert BP SEI after APS SEI … … 1228 1411 accessUnit.insert(it, new NALUnitEBSP(nalu)); 1229 1412 m_bufferingPeriodSEIPresentInAU = true; 1413 } 1230 1414 #else 1231 1415 accessUnit.push_back(new NALUnitEBSP(nalu)); 1232 1416 #endif 1233 1417 1418 #if K0180_SCALABLE_NESTING_SEI 1419 if (m_pcCfg->getScalableNestingSEIEnabled()) 1420 { 1421 OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI); 1422 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1423 m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream); 1424 scalableNestingSEI.m_nestedSEIs.clear(); 1425 scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period); 1426 m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS()); 1427 writeRBSPTrailingBits(naluTmp.m_Bitstream); 1428 #if L0045_NON_NESTED_SEI_RESTRICTIONS 1429 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 1430 UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU; // Insert BP SEI after non-nested APS, BP and PT SEIs 1431 AccessUnit::iterator it; 1432 for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++) 1433 { 1434 it++; 1435 } 1436 accessUnit.insert(it, new NALUnitEBSP(naluTmp)); 1437 m_nestedBufferingPeriodSEIPresentInAU = true; 1438 #else 1439 accessUnit.push_back(new NALUnitEBSP(naluTmp)); 1440 #endif 1441 } 1442 #endif 1443 1234 1444 m_lastBPSEI = m_totalCoded; 1235 1445 m_cpbRemovalDelay = 0; … … 1241 1451 { 1242 1452 // Gradual decoding refresh SEI 1243 OutputNALUnit nalu(NAL_UNIT_ SEI);1453 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI); 1244 1454 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1245 1455 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); … … 1253 1463 } 1254 1464 // Recovery point SEI 1255 OutputNALUnit nalu(NAL_UNIT_ SEI);1465 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI); 1256 1466 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1257 1467 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); … … 1444 1654 1445 1655 pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength ); 1446 if (!sliceSegment)1447 {1448 1656 pcSlice->setTileLocationCount ( 0 ); 1449 m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info. 1450 } 1451 else 1452 { 1453 m_pcSliceEncoder->encodeSlice(pcPic, &nalu.m_Bitstream, pcSubstreamsOut); // nalu.m_Bitstream is only used for CAVLC tile position info. 1454 } 1657 m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut); 1455 1658 1456 1659 { … … 1484 1687 if (ui+1 < pcSlice->getPPS()->getNumSubstreams()) 1485 1688 { 1486 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() ;1689 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3); 1487 1690 } 1488 1691 } … … 1516 1719 // 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. 1517 1720 Bool bNALUAlignedWrittenToList = false; // used to ensure current NALU is not written more than once to the NALU list. 1518 x WriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);1721 xAttachSliceDataToNalUnit(nalu, pcBitstreamRedirect); 1519 1722 accessUnit.push_back(new NALUnitEBSP(nalu)); 1520 1723 #if RATE_CONTROL_LAMBDA_DOMAIN … … 1544 1747 { 1545 1748 UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size()); 1546 if ((*it)->m_nalUnitType != NAL_UNIT_ SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)1749 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 1547 1750 { 1548 1751 numRBSPBytes += numRBSPBytes_nal; … … 1640 1843 } 1641 1844 #if SVC_EXTENSION 1642 OutputNALUnit nalu(NAL_UNIT_S EI_SUFFIX, pcSlice->getTLayer(), m_layerId);1845 OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer(), m_layerId); 1643 1846 #else 1644 OutputNALUnit nalu(NAL_UNIT_S EI_SUFFIX, pcSlice->getTLayer());1847 OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer()); 1645 1848 #endif 1646 1849 … … 1667 1870 sei_temporal_level0_index.rapIdx = m_rapIdx; 1668 1871 1669 OutputNALUnit nalu(NAL_UNIT_ SEI);1872 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI); 1670 1873 1671 1874 /* write the SEI messages */ … … 1807 2010 if( m_pcCfg->getPictureTimingSEIEnabled() ) 1808 2011 { 1809 OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer()); 2012 { 2013 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 1810 2014 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 1811 2015 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); … … 1827 2031 #endif 1828 2032 } 2033 #if K0180_SCALABLE_NESTING_SEI 2034 if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI 2035 { 2036 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 2037 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2038 scalableNestingSEI.m_nestedSEIs.clear(); 2039 scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI); 2040 m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS()); 2041 writeRBSPTrailingBits(nalu.m_Bitstream); 2042 #if L0045_NON_NESTED_SEI_RESTRICTIONS 2043 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 2044 UInt offsetPosition = m_activeParameterSetSEIPresentInAU 2045 + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU + m_nestedBufferingPeriodSEIPresentInAU; // Insert PT SEI after APS and BP SEI 2046 AccessUnit::iterator it; 2047 for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++) 2048 { 2049 it++; 2050 } 2051 accessUnit.insert(it, new NALUnitEBSP(nalu)); 2052 m_nestedPictureTimingSEIPresentInAU = true; 2053 #else 2054 AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice)); 2055 accessUnit.insert(it, new NALUnitEBSP(nalu)); 2056 #endif 2057 } 2058 #endif 2059 2060 } 1829 2061 if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() ) 1830 2062 { … … 1832 2064 for( Int i = 0; i < ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 ); i ++ ) 1833 2065 { 1834 OutputNALUnit nalu(NAL_UNIT_ SEI, pcSlice->getTLayer());2066 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 1835 2067 1836 2068 SEIDecodingUnitInfo tempSEI; … … 1880 2112 break; 1881 2113 } 1882 if ((*it)->m_nalUnitType != NAL_UNIT_ SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)2114 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 1883 2115 { 1884 2116 ctr++; … … 1891 2123 #if L0045_NON_NESTED_SEI_RESTRICTIONS 1892 2124 xResetNonNestedSEIPresentFlags(); 2125 #if K0180_SCALABLE_NESTING_SEI 2126 xResetNestedSEIPresentFlags(); 2127 #endif 1893 2128 #endif 1894 2129 pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut); … … 2113 2348 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R"; 2114 2349 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N"; 2115 case NAL_UNIT_CODED_SLICE_TLA : return "TLA";2350 case NAL_UNIT_CODED_SLICE_TLA_R: return "TLA_R"; 2116 2351 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N"; 2117 2352 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R"; 2118 2353 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N"; 2119 case NAL_UNIT_CODED_SLICE_BLA : return "BLA";2120 case NAL_UNIT_CODED_SLICE_BLA NT: return "BLANT";2354 case NAL_UNIT_CODED_SLICE_BLA_W_LP: return "BLA_W_LP"; 2355 case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL"; 2121 2356 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP"; 2122 case NAL_UNIT_CODED_SLICE_IDR : return "IDR";2357 case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL"; 2123 2358 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP"; 2124 2359 case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; 2125 case NAL_UNIT_CODED_SLICE_ DLP: return "DLP";2126 case NAL_UNIT_CODED_SLICE_ TFD: return "TFD";2360 case NAL_UNIT_CODED_SLICE_RADL_R: return "RADL_R"; 2361 case NAL_UNIT_CODED_SLICE_RASL_R: return "RASL_R"; 2127 2362 case NAL_UNIT_VPS: return "VPS"; 2128 2363 case NAL_UNIT_SPS: return "SPS"; … … 2132 2367 case NAL_UNIT_EOB: return "EOB"; 2133 2368 case NAL_UNIT_FILLER_DATA: return "FILLER"; 2134 case NAL_UNIT_SEI: return "SEI"; 2369 case NAL_UNIT_PREFIX_SEI: return "SEI"; 2370 case NAL_UNIT_SUFFIX_SEI: return "SEI"; 2135 2371 default: return "UNK"; 2136 2372 } … … 2223 2459 printf("*** %6s numBytesInNALunit: %u\n", nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal); 2224 2460 #endif 2225 if ((*it)->m_nalUnitType != NAL_UNIT_ SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)2461 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 2226 2462 { 2227 2463 numRBSPBytes += numRBSPBytes_nal; … … 2325 2561 * This function checks the configuration and returns the appropriate nal_unit_type for the picture. 2326 2562 */ 2327 NalUnitType TEncGOP::getNalUnitType(Int pocCurr )2563 NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR) 2328 2564 { 2329 2565 if (pocCurr == 0) 2330 2566 { 2331 return NAL_UNIT_CODED_SLICE_IDR ;2567 return NAL_UNIT_CODED_SLICE_IDR_W_RADL; 2332 2568 } 2333 2569 if (pocCurr % m_pcCfg->getIntraPeriod() == 0) … … 2339 2575 else if (m_pcCfg->getDecodingRefreshType() == 2) 2340 2576 { 2341 return NAL_UNIT_CODED_SLICE_IDR ;2577 return NAL_UNIT_CODED_SLICE_IDR_W_RADL; 2342 2578 } 2343 2579 } … … 2351 2587 // controlling the reference pictures used for encoding that leading picture. Such a leading 2352 2588 // picture need not be marked as a TFD picture. 2353 return NAL_UNIT_CODED_SLICE_TFD; 2589 return NAL_UNIT_CODED_SLICE_RASL_R; 2590 } 2591 } 2592 if (lastIDR>0) 2593 { 2594 if (pocCurr < lastIDR) 2595 { 2596 return NAL_UNIT_CODED_SLICE_RADL_R; 2354 2597 } 2355 2598 } … … 2402 2645 } 2403 2646 2404 /** Determine the difference between consecutive tile sizes (in bytes) and writes it to bistream rNalu [slice header] 2405 * \param rpcBitstreamRedirect contains the bitstream to be concatenated to rNalu. rpcBitstreamRedirect contains slice payload. rpcSlice contains tile location information. 2406 * \returns Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call. 2647 /** Attaches the input bitstream to the stream in the output NAL unit 2648 Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call. 2649 * \param codedSliceData contains the coded slice data (bitstream) to be concatenated to rNalu 2650 * \param rNalu target NAL unit 2407 2651 */ 2408 Void TEncGOP::x WriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice)2652 Void TEncGOP::xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& codedSliceData) 2409 2653 { 2410 2654 // Byte-align … … 2412 2656 2413 2657 // Perform bitstream concatenation 2414 if (rpcBitstreamRedirect->getNumberOfWrittenBits() > 0) 2415 { 2416 UInt uiBitCount = rpcBitstreamRedirect->getNumberOfWrittenBits(); 2417 if (rpcBitstreamRedirect->getByteStreamLength()>0) 2418 { 2419 UChar *pucStart = reinterpret_cast<UChar*>(rpcBitstreamRedirect->getByteStream()); 2420 UInt uiWriteByteCount = 0; 2421 while (uiWriteByteCount < (uiBitCount >> 3) ) 2422 { 2423 UInt uiBits = (*pucStart); 2424 rNalu.m_Bitstream.write(uiBits, 8); 2425 pucStart++; 2426 uiWriteByteCount++; 2427 } 2428 } 2429 UInt uiBitsHeld = (uiBitCount & 0x07); 2430 for (UInt uiIdx=0; uiIdx < uiBitsHeld; uiIdx++) 2431 { 2432 rNalu.m_Bitstream.write((rpcBitstreamRedirect->getHeldBits() & (1 << (7-uiIdx))) >> (7-uiIdx), 1); 2433 } 2658 if (codedSliceData->getNumberOfWrittenBits() > 0) 2659 { 2660 rNalu.m_Bitstream.addSubstream(codedSliceData); 2434 2661 } 2435 2662 2436 2663 m_pcEntropyCoder->setBitstream(&rNalu.m_Bitstream); 2437 2664 2438 delete rpcBitstreamRedirect; 2439 rpcBitstreamRedirect = new TComOutputBitstream; 2665 codedSliceData->clear(); 2440 2666 } 2441 2667 … … 2562 2788 } 2563 2789 } 2564 assert(it != accessUnit.end()); 2790 // assert(it != accessUnit.end()); // Triggers with some legit configurations 2565 2791 return seiStartPos; 2566 2792 } 2567 2793 #endif 2794 2795 #if L0386_DB_METRIC 2796 Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices ) 2797 { 2798 TComPicYuv* pcPicYuvRec = pcPic->getPicYuvRec(); 2799 Pel* Rec = pcPicYuvRec->getLumaAddr( 0 ); 2800 Pel* tempRec = Rec; 2801 Int stride = pcPicYuvRec->getStride(); 2802 UInt log2maxTB = pcPic->getSlice(0)->getSPS()->getQuadtreeTULog2MaxSize(); 2803 UInt maxTBsize = (1<<log2maxTB); 2804 const UInt minBlockArtSize = 8; 2805 const UInt picWidth = pcPicYuvRec->getWidth(); 2806 const UInt picHeight = pcPicYuvRec->getHeight(); 2807 const UInt noCol = (picWidth>>log2maxTB); 2808 const UInt noRows = (picHeight>>log2maxTB); 2809 UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64)); 2810 UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64)); 2811 UInt colIdx = 0; 2812 UInt rowIdx = 0; 2813 Pel p0, p1, p2, q0, q1, q2; 2814 2815 Int qp = pcPic->getSlice(0)->getSliceQp(); 2816 Int bitdepthScale = 1 << (g_bitDepthY-8); 2817 Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale; 2818 const Int thr2 = (beta>>2); 2819 const Int thr1 = 2*bitdepthScale; 2820 UInt a = 0; 2821 2822 memset(colSAD, 0, noCol*sizeof(UInt64)); 2823 memset(rowSAD, 0, noRows*sizeof(UInt64)); 2824 2825 if (maxTBsize > minBlockArtSize) 2826 { 2827 // Analyze vertical artifact edges 2828 for(Int c = maxTBsize; c < picWidth; c += maxTBsize) 2829 { 2830 for(Int r = 0; r < picHeight; r++) 2831 { 2832 p2 = Rec[c-3]; 2833 p1 = Rec[c-2]; 2834 p0 = Rec[c-1]; 2835 q0 = Rec[c]; 2836 q1 = Rec[c+1]; 2837 q2 = Rec[c+2]; 2838 a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1); 2839 if ( thr1 < a && a < thr2) 2840 { 2841 colSAD[colIdx] += abs(p0 - q0); 2842 } 2843 Rec += stride; 2844 } 2845 colIdx++; 2846 Rec = tempRec; 2847 } 2848 2849 // Analyze horizontal artifact edges 2850 for(Int r = maxTBsize; r < picHeight; r += maxTBsize) 2851 { 2852 for(Int c = 0; c < picWidth; c++) 2853 { 2854 p2 = Rec[c + (r-3)*stride]; 2855 p1 = Rec[c + (r-2)*stride]; 2856 p0 = Rec[c + (r-1)*stride]; 2857 q0 = Rec[c + r*stride]; 2858 q1 = Rec[c + (r+1)*stride]; 2859 q2 = Rec[c + (r+2)*stride]; 2860 a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1); 2861 if (thr1 < a && a < thr2) 2862 { 2863 rowSAD[rowIdx] += abs(p0 - q0); 2864 } 2865 } 2866 rowIdx++; 2867 } 2868 } 2869 2870 UInt64 colSADsum = 0; 2871 UInt64 rowSADsum = 0; 2872 for(Int c = 0; c < noCol-1; c++) 2873 { 2874 colSADsum += colSAD[c]; 2875 } 2876 for(Int r = 0; r < noRows-1; r++) 2877 { 2878 rowSADsum += rowSAD[r]; 2879 } 2880 2881 colSADsum <<= 10; 2882 rowSADsum <<= 10; 2883 colSADsum /= (noCol-1); 2884 colSADsum /= picHeight; 2885 rowSADsum /= (noRows-1); 2886 rowSADsum /= picWidth; 2887 2888 UInt64 avgSAD = ((colSADsum + rowSADsum)>>1); 2889 avgSAD >>= (g_bitDepthY-8); 2890 2891 if ( avgSAD > 2048 ) 2892 { 2893 avgSAD >>= 9; 2894 Int offset = Clip3(2,6,(Int)avgSAD); 2895 for (Int i=0; i<uiNumSlices; i++) 2896 { 2897 pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(true); 2898 pcPic->getSlice(i)->setDeblockingFilterDisable(false); 2899 pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( offset ); 2900 pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( offset ); 2901 } 2902 } 2903 else 2904 { 2905 for (Int i=0; i<uiNumSlices; i++) 2906 { 2907 pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(false); 2908 pcPic->getSlice(i)->setDeblockingFilterDisable( pcPic->getSlice(i)->getPPS()->getPicDisableDeblockingFilterFlag() ); 2909 pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 2910 pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 2911 } 2912 } 2913 2914 free(colSAD); 2915 free(rowSAD); 2916 } 2917 #endif 2568 2918 //! \}
Note: See TracChangeset for help on using the changeset viewer.