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

Integrated JCTVC-O0164: Multi-layer HRD operation

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.