Changeset 628 in SHVCSoftware for branches/SHM-5.1-dev/source/Lib/TLibEncoder


Ignore:
Timestamp:
14 Mar 2014, 15:29:06 (12 years ago)
Author:
nokia
Message:

Integrated JCTVC-O0164: Multi-layer HRD operation

Location:
branches/SHM-5.1-dev/source/Lib/TLibEncoder
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-5.1-dev/source/Lib/TLibEncoder/SEIwrite.cpp

    r616 r628  
    105105#endif
    106106#if SUB_BITSTREAM_PROPERTY_SEI
    107     case SEI::SUB_BITSTREAM_PROPERTY:
    108       fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n");
    109       break;
     107  case SEI::SUB_BITSTREAM_PROPERTY:
     108    fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n");
     109    break;
     110#endif
     111#if O0164_MULTI_LAYER_HRD
     112  case SEI::BSP_NESTING:
     113    fprintf( g_hTrace, "=========== Bitstream partition nesting SEI message ===========\n");
     114    break;
     115  case SEI::BSP_INITIAL_ARRIVAL_TIME:
     116    fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n");
     117    break;
     118  case SEI::BSP_HRD:
     119    fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
     120    break;
    110121#endif
    111122#endif //SVC_EXTENSION
     
    117128#endif
    118129
     130#if O0164_MULTI_LAYER_HRD
     131void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting& nestingSei, const SEIBspNesting& bspNestingSei)
     132#else
    119133void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps)
     134#endif
    120135{
    121136  switch (sei.payloadType())
     
    161176    break;
    162177  case SEI::SCALABLE_NESTING:
     178#if O0164_MULTI_LAYER_HRD
     179    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), vps, sps);
     180#else
    163181    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
     182#endif
    164183    break;
    165184#if SVC_EXTENSION
     
    179198     break;
    180199#endif
     200#if O0164_MULTI_LAYER_HRD
     201   case SEI::BSP_NESTING:
     202     xWriteSEIBspNesting(bs, *static_cast<const SEIBspNesting*>(&sei), vps, sps, nestingSei);
     203     break;
     204   case SEI::BSP_INITIAL_ARRIVAL_TIME:
     205     xWriteSEIBspInitialArrivalTime(*static_cast<const SEIBspInitialArrivalTime*>(&sei), vps, sps, nestingSei, bspNestingSei);
     206     break;
     207   case SEI::BSP_HRD:
     208     xWriteSEIBspHrd(*static_cast<const SEIBspHrd*>(&sei), sps, nestingSei);
     209     break;
     210#endif
    181211#endif //SVC_EXTENSION
    182212  default:
     
    189219 * in bitstream bs.
    190220 */
     221#if O0164_MULTI_LAYER_HRD
     222Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
     223#else
    191224Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, TComSPS *sps)
     225#endif
    192226{
    193227  /* calculate how large the payload data is */
     
    202236  g_HLSTraceEnable = false;
    203237#endif
     238#if O0164_MULTI_LAYER_HRD
     239  xWriteSEIpayloadData(bs_count, sei, vps, sps, *nestingSei, *bspNestingSei);
     240#else
    204241  xWriteSEIpayloadData(bs_count, sei, sps);
     242#endif
    205243#if ENC_DEC_TRACE
    206244  g_HLSTraceEnable = traceEnable;
     
    237275#endif
    238276
     277#if O0164_MULTI_LAYER_HRD
     278  xWriteSEIpayloadData(bs, sei, vps, sps, *nestingSei, *bspNestingSei);
     279#else
    239280  xWriteSEIpayloadData(bs, sei, sps);
     281#endif
    240282}
    241283
     
    577619}
    578620
     621#if O0164_MULTI_LAYER_HRD
     622Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComVPS *vps, TComSPS *sps)
     623#else
    579624Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps)
     625#endif
    580626{
    581627  WRITE_FLAG( sei.m_bitStreamSubsetFlag,             "bitstream_subset_flag"         );
     
    587633    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
    588634    {
    589       WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
    590635      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id"       );
    591636      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
     
    615660  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
    616661  {
     662#if O0164_MULTI_LAYER_HRD
     663    writeSEImessage(bs, *(*it), vps, sps, &sei);
     664#else
    617665    writeSEImessage(bs, *(*it), sps);
     666#endif
    618667  }
    619668}
     
    699748}
    700749#endif
     750
     751#if O0164_MULTI_LAYER_HRD
     752Void SEIWriter::xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei)
     753{
     754  WRITE_UVLC( sei.m_bspIdx, "bsp_idx" );
     755
     756  while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
     757  {
     758    WRITE_FLAG( 0, "bsp_nesting_zero_bit" );
     759  }
     760
     761  // write nested SEI messages
     762  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
     763  {
     764    writeSEImessage(bs, *(*it), vps, sps, &nestingSei, &sei);
     765  }
     766}
     767
     768Void SEIWriter::xWriteSEIBspInitialArrivalTime(const SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei)
     769{
     770  assert(vps->getVpsVuiPresentFlag());
     771
     772  UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]);
     773  UInt len;
     774  UInt hrdIdx;
     775
     776  if (schedCombCnt > 0)
     777  {
     778    hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx);
     779  }
     780  else
     781  {
     782    hrdIdx = 0;
     783  }
     784
     785  TComHRD *hrd = vps->getBspHrd(hrdIdx);
     786
     787  if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag())
     788  {
     789    len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1;
     790  }
     791  else
     792  {
     793    len = 23 + 1;
     794  }
     795
     796  if (hrd->getNalHrdParametersPresentFlag())
     797  {
     798    for(UInt i = 0; i < schedCombCnt; i++)
     799    {
     800      WRITE_CODE( sei.m_nalInitialArrivalDelay[i], len, "nal_initial_arrival_delay" );
     801    }
     802  }
     803  else
     804  {
     805    for(UInt i = 0; i < schedCombCnt; i++)
     806    {
     807      WRITE_CODE( sei.m_vclInitialArrivalDelay[i], len, "vcl_initial_arrival_delay" );
     808    }
     809  }
     810}
     811
     812Void SEIWriter::xWriteSEIBspHrd(const SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei)
     813{
     814  WRITE_UVLC( sei.m_seiNumBspHrdParametersMinus1, "sei_num_bsp_hrd_parameters_minus1" );
     815  for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++)
     816  {
     817    if (i > 0)
     818    {
     819      WRITE_FLAG( sei.m_seiBspCprmsPresentFlag[i], "sei_bsp_cprms_present_flag" );
     820    }
     821    xCodeHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1);
     822  }
     823  for (UInt h = 0; h <= nestingSei.m_nestingNumOpsMinus1; h++)
     824  {
     825    UInt lsIdx = nestingSei.m_nestingOpIdx[h];
     826    WRITE_UVLC( sei.m_seiNumBitstreamPartitionsMinus1[lsIdx], "num_sei_bitstream_partitions_minus1[i]");
     827    for (UInt i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++)
     828    {
     829      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
     830      {
     831        if (sei.m_layerIdIncludedFlag[lsIdx][j])
     832        {
     833          WRITE_FLAG( sei.m_seiLayerInBspFlag[lsIdx][i][j], "sei_layer_in_bsp_flag[lsIdx][i][j]" );
     834        }
     835      }
     836    }
     837    WRITE_UVLC( sei.m_seiNumBspSchedCombinationsMinus1[lsIdx], "sei_num_bsp_sched_combinations_minus1[i]");
     838    for (UInt i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++)
     839    {
     840      for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++)
     841      {
     842        WRITE_UVLC( sei.m_seiBspCombHrdIdx[lsIdx][i][j], "sei_bsp_comb_hrd_idx[lsIdx][i][j]");
     843        WRITE_UVLC( sei.m_seiBspCombScheddx[lsIdx][i][j], "sei_bsp_comb_sched_idx[lsIdx][i][j]");
     844      }
     845    }
     846  }
     847}
     848
     849Void SEIWriter::xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 )
     850{
     851  if( commonInfPresentFlag )
     852  {
     853    WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 ,  "nal_hrd_parameters_present_flag" );
     854    WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 ,  "vcl_hrd_parameters_present_flag" );
     855    if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() )
     856    {
     857      WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0,  "sub_pic_cpb_params_present_flag" );
     858      if( hrd->getSubPicCpbParamsPresentFlag() )
     859      {
     860        WRITE_CODE( hrd->getTickDivisorMinus2(), 8,              "tick_divisor_minus2" );
     861        WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5,  "du_cpb_removal_delay_length_minus1" );
     862        WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" );
     863        WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5,   "dpb_output_delay_du_length_minus1"  );
     864      }
     865      WRITE_CODE( hrd->getBitRateScale(), 4,                     "bit_rate_scale" );
     866      WRITE_CODE( hrd->getCpbSizeScale(), 4,                     "cpb_size_scale" );
     867      if( hrd->getSubPicCpbParamsPresentFlag() )
     868      {
     869        WRITE_CODE( hrd->getDuCpbSizeScale(), 4,                "du_cpb_size_scale" );
     870      }
     871      WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" );
     872      WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(),        5, "au_cpb_removal_delay_length_minus1" );
     873      WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(),         5, "dpb_output_delay_length_minus1" );
     874    }
     875  }
     876  Int i, j, nalOrVcl;
     877  for( i = 0; i <= maxNumSubLayersMinus1; i ++ )
     878  {
     879    WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0,          "fixed_pic_rate_general_flag");
     880    if( !hrd->getFixedPicRateFlag( i ) )
     881    {
     882      WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag");
     883    }
     884    else
     885    {
     886      hrd->setFixedPicRateWithinCvsFlag( i, true );
     887    }
     888    if( hrd->getFixedPicRateWithinCvsFlag( i ) )
     889    {
     890      WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ),           "elemental_duration_in_tc_minus1");
     891    }
     892    else
     893    {
     894      WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0,           "low_delay_hrd_flag");
     895    }
     896    if (!hrd->getLowDelayHrdFlag( i ))
     897    {
     898      WRITE_UVLC( hrd->getCpbCntMinus1( i ),                      "cpb_cnt_minus1");
     899    }
     900   
     901    for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
     902    {
     903      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
     904          ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
     905      {
     906        for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
     907        {
     908          WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1");
     909          WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1");
     910          if( hrd->getSubPicCpbParamsPresentFlag() )
     911          {
     912            WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); 
     913            WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1");
     914          }
     915          WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag");
     916        }
     917      }
     918    }
     919  }
     920}
     921
     922#endif
     923
    701924#endif //SVC_EXTENSION
    702925
  • branches/SHM-5.1-dev/source/Lib/TLibEncoder/SEIwrite.h

    r595 r628  
    4747  virtual ~SEIWriter() {};
    4848
     49#if O0164_MULTI_LAYER_HRD
     50  void writeSEImessage(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
     51#else
    4952  void writeSEImessage(TComBitIf& bs, const SEI& sei, TComSPS *sps);
     53#endif
    5054
    5155protected:
     56#if O0164_MULTI_LAYER_HRD
     57  Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting& nestingSei, const SEIBspNesting& bspNestingSei);
     58#else
    5259  Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps);
     60#endif
    5361  Void xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei);
    5462  Void xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei);
     
    6573  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
    6674  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
     75#if O0164_MULTI_LAYER_HRD
     76  Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComVPS *vps, TComSPS *sps);
     77#else
    6778  Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps);
     79#endif
    6880  Void xWriteByteAlign();
    6981#if SVC_EXTENSION
     
    7789  Void xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei);
    7890#endif
     91#if O0164_MULTI_LAYER_HRD
     92  Void xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei);
     93  Void xWriteSEIBspInitialArrivalTime(const SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei);
     94  Void xWriteSEIBspHrd(const SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei);
     95  Void xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 );
     96#endif
    7997#endif //SVC_EXTENSION
    8098};
  • branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r627 r628  
    15231523#endif
    15241524#endif
     1525#if O0164_MULTI_LAYER_HRD
     1526    WRITE_FLAG(vps->getVpsVuiBspHrdPresentFlag(), "vps_vui_bsp_hrd_present_flag" );
     1527    if (vps->getVpsVuiBspHrdPresentFlag())
     1528    {
     1529      WRITE_UVLC( vps->getVpsNumBspHrdParametersMinus1(), "vps_num_bsp_hrd_parameters_minus1" );
     1530      for (UInt i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++)
     1531      {
     1532        if (i > 0)
     1533        {
     1534          WRITE_FLAG( vps->getBspCprmsPresentFlag(i), "bsp_cprms_present_flag[i]" );
     1535        }
     1536        codeHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1);
     1537      }
     1538      for (UInt h = 1; h <= (vps->getNumLayerSets()-1); h++)
     1539      {
     1540        WRITE_UVLC( vps->getNumBitstreamPartitions(h), "num_bitstream_partitions[i]");
     1541        for (UInt i = 0; i < vps->getNumBitstreamPartitions(h); i++)
     1542        {
     1543          for (UInt j = 0; j <= (vps->getMaxLayers()-1); j++)
     1544          {
     1545            if (vps->getLayerIdIncludedFlag(h, j))
     1546            {
     1547              WRITE_FLAG( vps->getLayerInBspFlag(h, i, j), "layer_in_bsp_flag[h][i][j]" );
     1548            }
     1549          }
     1550        }
     1551        if (vps->getNumBitstreamPartitions(h))
     1552        {
     1553          WRITE_UVLC( vps->getNumBspSchedCombinations(h), "num_bsp_sched_combinations[h]");
     1554          for (UInt i = 0; i < vps->getNumBspSchedCombinations(h); i++)
     1555          {
     1556            for (UInt j = 0; j < vps->getNumBitstreamPartitions(h); j++)
     1557            {
     1558              WRITE_UVLC( vps->getBspCombHrdIdx(h, i, j), "bsp_comb_hrd_idx[h][i][j]");
     1559              WRITE_UVLC( vps->getBspCombSchedIdx(h, i, j), "bsp_comb_sched_idx[h][i][j]");
     1560            }
     1561          }
     1562        }
     1563      }
     1564    }
     1565#endif
    15251566#if P0182_VPS_VUI_PS_FLAG
    15261567    for(i = 1; i < vps->getMaxLayers(); i++)
  • branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r627 r628  
    303303    //nalu = NALUnit(NAL_UNIT_SEI);
    304304    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     305#if O0164_MULTI_LAYER_HRD
     306    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     307#else
    305308    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     309#endif
    306310    writeRBSPTrailingBits(nalu.m_Bitstream);
    307311    accessUnit.push_back(new NALUnitEBSP(nalu));
     
    316320    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    317321    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     322#if O0164_MULTI_LAYER_HRD
     323    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     324#else
    318325    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     326#endif
    319327    writeRBSPTrailingBits(nalu.m_Bitstream);
    320328    accessUnit.push_back(new NALUnitEBSP(nalu));
     
    327335    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    328336    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     337#if O0164_MULTI_LAYER_HRD
     338    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     339#else
    329340    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     341#endif
    330342    writeRBSPTrailingBits(nalu.m_Bitstream);
    331343    accessUnit.push_back(new NALUnitEBSP(nalu));
     
    338350    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    339351    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     352#if O0164_MULTI_LAYER_HRD
     353    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     354#else
    340355    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     356#endif
    341357    writeRBSPTrailingBits(nalu.m_Bitstream);
    342358    accessUnit.push_back(new NALUnitEBSP(nalu));
     
    350366    SEILayersNotPresent *sei = xCreateSEILayersNotPresent ();
    351367    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     368#if O0164_MULTI_LAYER_HRD
     369    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     370#else
    352371    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     372#endif
    353373    writeRBSPTrailingBits(nalu.m_Bitstream);
    354374    accessUnit.push_back(new NALUnitEBSP(nalu));
     
    364384    nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_pcCfg->getNumLayer()-1); // For highest layer
    365385    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     386#if O0164_MULTI_LAYER_HRD
     387    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     388#else
    366389    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     390#endif
    367391    writeRBSPTrailingBits(nalu.m_Bitstream);
    368392    accessUnit.push_back(new NALUnitEBSP(nalu));
     
    17351759      xCreateLeadingSEIMessages(accessUnit, pcSlice->getSPS());
    17361760
     1761#if O0164_MULTI_LAYER_HRD
     1762      if (pcSlice->getLayerId() == 0 && m_pcEncTop->getVPS()->getVpsVuiBspHrdPresentFlag())
     1763      {
     1764        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, 0, 1);
     1765        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1766        m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     1767        SEIScalableNesting *scalableBspNestingSei = xCreateBspNestingSEI(pcSlice);
     1768        m_seiWriter.writeSEImessage(nalu.m_Bitstream, *scalableBspNestingSei, m_pcEncTop->getVPS(), pcSlice->getSPS());
     1769        writeRBSPTrailingBits(nalu.m_Bitstream);
     1770
     1771        UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     1772        UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     1773          + m_bufferingPeriodSEIPresentInAU
     1774          + m_pictureTimingSEIPresentInAU
     1775          + m_nestedPictureTimingSEIPresentInAU;  // Insert SEI after APS, BP and PT SEI
     1776        AccessUnit::iterator it;
     1777        for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     1778        {
     1779          it++;
     1780        }
     1781        accessUnit.insert(it, new NALUnitEBSP(nalu));
     1782      }
     1783#endif
     1784
    17371785      m_bSeqFirst = false;
    17381786    }
     
    17691817      SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1;
    17701818
     1819#if O0164_MULTI_LAYER_HRD
     1820      m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
     1821#else
    17711822      m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS());
     1823#endif
    17721824      writeRBSPTrailingBits(nalu.m_Bitstream);
    17731825      accessUnit.push_back(new NALUnitEBSP(nalu));
     
    18531905      sei_buffering_period.m_dpbDelayOffset = 0;
    18541906
     1907#if O0164_MULTI_LAYER_HRD
     1908      m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_buffering_period, m_pcEncTop->getVPS(), pcSlice->getSPS());
     1909#else
    18551910      m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_buffering_period, pcSlice->getSPS());
     1911#endif
    18561912      writeRBSPTrailingBits(nalu.m_Bitstream);
    18571913      {
     
    18741930        scalableNestingSEI.m_nestedSEIs.clear();
    18751931        scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period);
     1932#if O0164_MULTI_LAYER_HRD
     1933        m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
     1934#else
    18761935        m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     1936#endif
    18771937        writeRBSPTrailingBits(naluTmp.m_Bitstream);
    18781938        UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     
    19031963        seiGradualDecodingRefreshInfo.m_gdrForegroundFlag = true; // Indicating all "foreground"
    19041964
     1965#if O0164_MULTI_LAYER_HRD
     1966        m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiGradualDecodingRefreshInfo, m_pcEncTop->getVPS(), pcSlice->getSPS() );
     1967#else
    19051968        m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiGradualDecodingRefreshInfo, pcSlice->getSPS() );
     1969#endif
    19061970        writeRBSPTrailingBits(nalu.m_Bitstream);
    19071971        accessUnit.push_back(new NALUnitEBSP(nalu));
     
    19211985      sei_recovery_point.m_brokenLinkFlag    = false;
    19221986
     1987#if O0164_MULTI_LAYER_HRD
     1988      m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_recovery_point, m_pcEncTop->getVPS(), pcSlice->getSPS() );
     1989#else
    19231990      m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_recovery_point, pcSlice->getSPS() );
     1991#endif
    19241992      writeRBSPTrailingBits(nalu.m_Bitstream);
    19251993      accessUnit.push_back(new NALUnitEBSP(nalu));
     
    22882356        /* write the SEI messages */
    22892357        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2358#if O0164_MULTI_LAYER_HRD
     2359        m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_recon_picture_digest, m_pcEncTop->getVPS(), pcSlice->getSPS());
     2360#else
    22902361        m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_recon_picture_digest, pcSlice->getSPS());
     2362#endif
    22912363        writeRBSPTrailingBits(nalu.m_Bitstream);
    22922364
     
    23122384        /* write the SEI messages */
    23132385        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2386#if O0164_MULTI_LAYER_HRD
     2387        m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_temporal_level0_index, m_pcEncTop->getVPS(), pcSlice->getSPS());
     2388#else
    23142389        m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_temporal_level0_index, pcSlice->getSPS());
     2390#endif
    23152391        writeRBSPTrailingBits(nalu.m_Bitstream);
    23162392
     
    24622538          m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    24632539          pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0;
     2540#if O0164_MULTI_LAYER_HRD
     2541          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
     2542#else
    24642543          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
     2544#endif
    24652545          writeRBSPTrailingBits(nalu.m_Bitstream);
    24662546          UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     
    24812561            scalableNestingSEI.m_nestedSEIs.clear();
    24822562            scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI);
     2563#if O0164_MULTI_LAYER_HRD
     2564            m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
     2565#else
    24832566            m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     2567#endif
    24842568            writeRBSPTrailingBits(nalu.m_Bitstream);
    24852569            UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     
    25132597            {
    25142598              // Insert before the first slice.
     2599#if O0164_MULTI_LAYER_HRD
     2600              m_seiWriter.writeSEImessage(nalu.m_Bitstream, tempSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
     2601#else
    25152602              m_seiWriter.writeSEImessage(nalu.m_Bitstream, tempSEI, pcSlice->getSPS());
     2603#endif
    25162604              writeRBSPTrailingBits(nalu.m_Bitstream);
    25172605
     
    25352623                {
    25362624                  // Insert before the first slice.
     2625#if O0164_MULTI_LAYER_HRD
     2626                  m_seiWriter.writeSEImessage(nalu.m_Bitstream, tempSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
     2627#else
    25372628                  m_seiWriter.writeSEImessage(nalu.m_Bitstream, tempSEI, pcSlice->getSPS());
     2629#endif
    25382630                  writeRBSPTrailingBits(nalu.m_Bitstream);
    25392631
     
    36713763}
    36723764#endif
     3765
     3766#if O0164_MULTI_LAYER_HRD
     3767SEIScalableNesting* TEncGOP::xCreateBspNestingSEI(TComSlice *pcSlice)
     3768{
     3769  SEIScalableNesting *seiScalableNesting = new SEIScalableNesting();
     3770  SEIBspInitialArrivalTime *seiBspInitialArrivalTime = new SEIBspInitialArrivalTime();
     3771  SEIBspNesting *seiBspNesting = new SEIBspNesting();
     3772  SEIBufferingPeriod *seiBufferingPeriod = new SEIBufferingPeriod();
     3773
     3774  // Scalable nesting SEI
     3775
     3776  seiScalableNesting->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
     3777  seiScalableNesting->m_nestingOpFlag                 = 1;
     3778  seiScalableNesting->m_defaultOpFlag                 = 0;
     3779  seiScalableNesting->m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
     3780  seiScalableNesting->m_nestingOpIdx[0]               = 1;
     3781  seiScalableNesting->m_allLayersFlag                 = 0;
     3782  seiScalableNesting->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
     3783  seiScalableNesting->m_nestingNumLayersMinus1        = 1 - 1;  //nesting_num_layers_minus1
     3784  seiScalableNesting->m_nestingLayerId[0]             = 0;
     3785  seiScalableNesting->m_callerOwnsSEIs                = true;
     3786
     3787  // Bitstream partition nesting SEI
     3788
     3789  seiBspNesting->m_bspIdx = 0;
     3790  seiBspNesting->m_callerOwnsSEIs = true;
     3791
     3792  // Buffering period SEI
     3793
     3794  UInt uiInitialCpbRemovalDelay = (90000/2);                      // 0.5 sec
     3795  seiBufferingPeriod->m_initialCpbRemovalDelay      [0][0]     = uiInitialCpbRemovalDelay;
     3796  seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][0]     = uiInitialCpbRemovalDelay;
     3797  seiBufferingPeriod->m_initialCpbRemovalDelay      [0][1]     = uiInitialCpbRemovalDelay;
     3798  seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][1]     = uiInitialCpbRemovalDelay;
     3799
     3800  Double dTmp = (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale();
     3801
     3802  UInt uiTmp = (UInt)( dTmp * 90000.0 );
     3803  uiInitialCpbRemovalDelay -= uiTmp;
     3804  uiInitialCpbRemovalDelay -= uiTmp / ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 );
     3805  seiBufferingPeriod->m_initialAltCpbRemovalDelay      [0][0]  = uiInitialCpbRemovalDelay;
     3806  seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][0]  = uiInitialCpbRemovalDelay;
     3807  seiBufferingPeriod->m_initialAltCpbRemovalDelay      [0][1]  = uiInitialCpbRemovalDelay;
     3808  seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][1]  = uiInitialCpbRemovalDelay;
     3809
     3810  seiBufferingPeriod->m_rapCpbParamsPresentFlag              = 0;
     3811  //for the concatenation, it can be set to one during splicing.
     3812  seiBufferingPeriod->m_concatenationFlag = 0;
     3813  //since the temporal layer HRD is not ready, we assumed it is fixed
     3814  seiBufferingPeriod->m_auCpbRemovalDelayDelta = 1;
     3815  seiBufferingPeriod->m_cpbDelayOffset = 0;
     3816  seiBufferingPeriod->m_dpbDelayOffset = 0;
     3817
     3818  // Intial arrival time SEI message
     3819
     3820  seiBspInitialArrivalTime->m_nalInitialArrivalDelay[0] = 0;
     3821  seiBspInitialArrivalTime->m_vclInitialArrivalDelay[0] = 0;
     3822
     3823
     3824  seiBspNesting->m_nestedSEIs.push_back(seiBufferingPeriod);
     3825  seiBspNesting->m_nestedSEIs.push_back(seiBspInitialArrivalTime);
     3826  seiScalableNesting->m_nestedSEIs.push_back(seiBspNesting); // BSP nesting SEI is contained in scalable nesting SEI
     3827
     3828  return seiScalableNesting;
     3829}
     3830#endif
     3831
    36733832#endif //SVC_EXTENSION
    36743833
  • branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncGOP.h

    r595 r628  
    211211  SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets();
    212212#endif
     213#if O0164_MULTI_LAYER_HRD
     214  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice);
     215#endif
    213216#endif //SVC_EXTENSION
    214217};// END CLASS DEFINITION TEncGOP
Note: See TracChangeset for help on using the changeset viewer.