Changeset 189 in SHVCSoftware for trunk/source/Lib/TLibDecoder


Ignore:
Timestamp:
13 May 2013, 16:58:44 (12 years ago)
Author:
seregin
Message:

merge with SHM-2.0-dev branch

Location:
trunk/source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/source

  • trunk/source/Lib/TLibDecoder/NALread.cpp

    r125 r189  
    5050//! \ingroup TLibDecoder
    5151//! \{
    52 static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, Bool isVclNalUnit)
     52static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *bitstream, Bool isVclNalUnit)
    5353{
    5454  UInt zeroCount = 0;
    5555  vector<uint8_t>::iterator it_read, it_write;
    5656
    57   for (it_read = it_write = nalUnitBuf.begin(); it_read != nalUnitBuf.end(); it_read++, it_write++)
     57  UInt pos = 0;
     58  bitstream->clearEmulationPreventionByteLocation();
     59  for (it_read = it_write = nalUnitBuf.begin(); it_read != nalUnitBuf.end(); it_read++, it_write++, pos++)
    5860  {
    5961    assert(zeroCount < 2 || *it_read >= 0x03);
    6062    if (zeroCount == 2 && *it_read == 0x03)
    6163    {
     64      bitstream->pushEmulationPreventionByteLocation( pos );
     65      pos++;
    6266      it_read++;
    6367      zeroCount = 0;
     
    109113  if ( nalu.m_temporalId )
    110114  {
    111     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA
    112          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT
     115    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP
     116         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL
    113117         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP
    114          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR
     118         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL
    115119         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP
    116120         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
     
    122126  else
    123127  {
    124     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA
     128    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA_R
    125129         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
    126130         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
     
    136140  /* perform anti-emulation prevention */
    137141  TComInputBitstream *pcBitstream = new TComInputBitstream(NULL);
    138   convertPayloadToRBSP(nalUnitBuf, (nalUnitBuf[0] & 64) == 0);
     142  convertPayloadToRBSP(nalUnitBuf, pcBitstream, (nalUnitBuf[0] & 64) == 0);
    139143 
    140144  nalu.m_Bitstream = new TComInputBitstream(&nalUnitBuf);
     145  nalu.m_Bitstream->setEmulationPreventionByteLocation(pcBitstream->getEmulationPreventionByteLocation());
    141146  delete pcBitstream;
    142147  readNalUnitHeader(nalu);
  • trunk/source/Lib/TLibDecoder/SEIread.cpp

    r125 r189  
    9090    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
    9191    break;
     92#if J0149_TONE_MAPPING_SEI
     93  case SEI::TONE_MAPPING_INFO:
     94    fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n");
     95    break;
     96#endif
     97#if L0208_SOP_DESCRIPTION_SEI
     98  case SEI::SOP_DESCRIPTION:
     99    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     100    break;
     101#endif
     102#if K0180_SCALABLE_NESTING_SEI
     103  case SEI::SCALABLE_NESTING:
     104    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
     105    break;
     106#endif
    92107  default:
    93108    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
     
    154169  SEI *sei = NULL;
    155170
    156   if(nalUnitType == NAL_UNIT_SEI)
     171  if(nalUnitType == NAL_UNIT_PREFIX_SEI)
    157172  {
    158173    switch (payloadType)
     
    219234      xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize);
    220235      break;
     236#if J0149_TONE_MAPPING_SEI
     237    case SEI::TONE_MAPPING_INFO:
     238      sei = new SEIToneMappingInfo;
     239      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize);
     240      break;
     241#endif
     242#if L0208_SOP_DESCRIPTION_SEI
     243    case SEI::SOP_DESCRIPTION:
     244      sei = new SEISOPDescription;
     245      xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize);
     246      break;
     247#endif
     248#if K0180_SCALABLE_NESTING_SEI
     249    case SEI::SCALABLE_NESTING:
     250      sei = new SEIScalableNesting;
     251      xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps);
     252      break;
     253#endif
    221254    default:
    222255      for (UInt i = 0; i < payloadSize; i++)
     
    284317    {
    285318      UInt reservedPayloadExtensionData;
    286       READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");
     319      READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data");
    287320    }
    288321
    289322    UInt dummy;
    290     READ_CODE (1, dummy, "payload_bit_equal_to_one");
    291     READ_CODE (payloadBitsRemaining-1, dummy, "payload_bit_equal_to_zero");
     323    READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--;
     324    while (payloadBitsRemaining)
     325    {
     326      READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--;
     327    }
    292328  }
    293329
     
    632668}
    633669
     670#if J0149_TONE_MAPPING_SEI
     671Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/)
     672{
     673  Int i;
     674  UInt val;
     675  READ_UVLC( val, "tone_map_id" );                         sei.m_toneMapId = val;
     676  READ_FLAG( val, "tone_map_cancel_flag" );                sei.m_toneMapCancelFlag = val;
     677
     678  if ( !sei.m_toneMapCancelFlag )
     679  {
     680    READ_FLAG( val, "tone_map_persistence_flag" );         sei.m_toneMapPersistenceFlag = val;
     681    READ_CODE( 8, val, "coded_data_bit_depth" );           sei.m_codedDataBitDepth = val;
     682    READ_CODE( 8, val, "target_bit_depth" );               sei.m_targetBitDepth = val;
     683    READ_UVLC( val, "model_id" );                          sei.m_modelId = val;
     684    switch(sei.m_modelId)
     685    {
     686    case 0:
     687      {
     688        READ_CODE( 32, val, "min_value" );                 sei.m_minValue = val;
     689        READ_CODE( 32, val, "max_value" );                 sei.m_maxValue = val;
     690        break;
     691      }
     692    case 1:
     693      {
     694        READ_CODE( 32, val, "sigmoid_midpoint" );          sei.m_sigmoidMidpoint = val;
     695        READ_CODE( 32, val, "sigmoid_width" );             sei.m_sigmoidWidth = val;
     696        break;
     697      }
     698    case 2:
     699      {
     700        UInt num = 1u << sei.m_targetBitDepth;
     701        sei.m_startOfCodedInterval.resize(num+1);
     702        for(i = 0; i < num; i++)
     703        {
     704          READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" );
     705          sei.m_startOfCodedInterval[i] = val;
     706        }
     707        sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth;
     708        break;
     709      }
     710    case 3:
     711      {
     712        READ_CODE( 16, val,  "num_pivots" );                       sei.m_numPivots = val;
     713        sei.m_codedPivotValue.resize(sei.m_numPivots);
     714        sei.m_targetPivotValue.resize(sei.m_numPivots);
     715        for(i = 0; i < sei.m_numPivots; i++ )
     716        {
     717          READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" );
     718          sei.m_codedPivotValue[i] = val;
     719          READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3),    val, "target_pivot_value" );
     720          sei.m_targetPivotValue[i] = val;
     721        }
     722        break;
     723      }
     724    case 4:
     725      {
     726        READ_CODE( 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedValue = val;
     727        if( sei.m_cameraIsoSpeedValue == 255) //Extended_ISO
     728        {
     729          READ_CODE( 32,   val,   "camera_iso_speed_value" );            sei.m_cameraIsoSpeedValue = val;
     730        }
     731        READ_FLAG( val, "exposure_compensation_value_sign_flag" );       sei.m_exposureCompensationValueSignFlag = val;
     732        READ_CODE( 16, val, "exposure_compensation_value_numerator" );   sei.m_exposureCompensationValueNumerator = val;
     733        READ_CODE( 16, val, "exposure_compensation_value_denom_idc" );   sei.m_exposureCompensationValueDenomIdc = val;
     734        READ_CODE( 32, val, "ref_screen_luminance_white" );              sei.m_refScreenLuminanceWhite = val;
     735        READ_CODE( 32, val, "extended_range_white_level" );              sei.m_extendedRangeWhiteLevel = val;
     736        READ_CODE( 16, val, "nominal_black_level_luma_code_value" );     sei.m_nominalBlackLevelLumaCodeValue = val;
     737        READ_CODE( 16, val, "nominal_white_level_luma_code_value" );     sei.m_nominalWhiteLevelLumaCodeValue= val;
     738        READ_CODE( 16, val, "extended_white_level_luma_code_value" );    sei.m_extendedWhiteLevelLumaCodeValue = val;
     739        break;
     740      }
     741    default:
     742      {
     743        assert(!"Undefined SEIToneMapModelId");
     744        break;
     745      }
     746    }//switch model id
     747  }// if(!sei.m_toneMapCancelFlag)
     748
     749  xParseByteAlign();
     750}
     751#endif
     752
     753#if L0208_SOP_DESCRIPTION_SEI
     754Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize)
     755{
     756  Int iCode;
     757  UInt uiCode;
     758
     759  READ_UVLC( uiCode,           "sop_seq_parameter_set_id"            ); sei.m_sopSeqParameterSetId = uiCode;
     760  READ_UVLC( uiCode,           "num_pics_in_sop_minus1"              ); sei.m_numPicsInSopMinus1 = uiCode;
     761  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
     762  {
     763    READ_CODE( 6, uiCode,                     "sop_desc_vcl_nalu_type" );  sei.m_sopDescVclNaluType[i] = uiCode;
     764    READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id"   );  sei.m_sopDescTemporalId[i] = uiCode;
     765    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
     766    {
     767      READ_UVLC( sei.m_sopDescStRpsIdx[i],    "sop_desc_st_rps_idx"    ); sei.m_sopDescStRpsIdx[i] = uiCode;
     768    }
     769    if (i > 0)
     770    {
     771      READ_SVLC( iCode,                       "sop_desc_poc_delta"     ); sei.m_sopDescPocDelta[i] = iCode;
     772    }
     773  }
     774
     775  xParseByteAlign();
     776}
     777#endif
     778
     779#if K0180_SCALABLE_NESTING_SEI
     780Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps)
     781{
     782  UInt uiCode;
     783  SEIMessages seis;
     784
     785  READ_FLAG( uiCode,            "bitstream_subset_flag"         ); sei.m_bitStreamSubsetFlag = uiCode;
     786  READ_FLAG( uiCode,            "nesting_op_flag"               ); sei.m_nestingOpFlag = uiCode;
     787  if (sei.m_nestingOpFlag)
     788  {
     789    READ_FLAG( uiCode,            "default_op_flag"               ); sei.m_defaultOpFlag = uiCode;
     790    READ_UVLC( uiCode,            "nesting_num_ops_minus1"        ); sei.m_nestingNumOpsMinus1 = uiCode;
     791    for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++)
     792    {
     793      READ_CODE( 3,        uiCode,  "nesting_max_temporal_id_plus1"   ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode;
     794      READ_UVLC( uiCode,            "nesting_op_idx"                  ); sei.m_nestingOpIdx[i] = uiCode;
     795    }
     796  }
     797  else
     798  {
     799    READ_FLAG( uiCode,            "all_layers_flag"               ); sei.m_allLayersFlag       = uiCode;
     800    if (!sei.m_allLayersFlag)
     801    {
     802      READ_CODE( 3,        uiCode,  "nesting_no_op_max_temporal_id_plus1"  ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode;
     803      READ_UVLC( uiCode,            "nesting_num_layers_minus1"            ); sei.m_nestingNumLayersMinus1        = uiCode;
     804      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
     805      {
     806        READ_CODE( 6,           uiCode,     "nesting_layer_id"      ); sei.m_nestingLayerId[i]   = uiCode;
     807      }
     808    }
     809  }
     810
     811  // byte alignment
     812  while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
     813  {
     814    UInt code;
     815    READ_FLAG( code, "nesting_zero_bit" );
     816  }
     817
     818  sei.m_callerOwnsSEIs = false;
     819
     820  // read nested SEI messages
     821  do {
     822    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps);
     823  } while (m_pcBitstream->getNumBitsLeft() > 8);
     824
     825}
     826#endif
     827
    634828Void SEIReader::xParseByteAlign()
    635829{
  • trunk/source/Lib/TLibDecoder/SEIread.h

    r125 r189  
    7070  Void xParseSEITemporalLevel0Index   (SEITemporalLevel0Index &sei, UInt payloadSize);
    7171  Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize);
     72#if J0149_TONE_MAPPING_SEI
     73  Void xParseSEIToneMappingInfo       (SEIToneMappingInfo& sei, UInt payloadSize);
     74#endif
     75#if L0208_SOP_DESCRIPTION_SEI
     76  Void xParseSEISOPDescription        (SEISOPDescription &sei, UInt payloadSize);
     77#endif
     78#if K0180_SCALABLE_NESTING_SEI
     79  Void xParseSEIScalableNesting       (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps);
     80#endif
    7281  Void xParseByteAlign();
    7382};
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r125 r189  
    593593
    594594  READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
    595   g_bitDepthY = 8 + uiCode;
    596   pcSPS->setBitDepthY(g_bitDepthY);
     595  pcSPS->setBitDepthY( uiCode + 8 );
    597596  pcSPS->setQpBDOffsetY( (Int) (6*uiCode) );
    598597
    599598  READ_UVLC( uiCode,    "bit_depth_chroma_minus8" );
    600   g_bitDepthC = 8 + uiCode;
    601   pcSPS->setBitDepthC(g_bitDepthC);
     599  pcSPS->setBitDepthC( uiCode + 8 );
    602600  pcSPS->setQpBDOffsetC( (Int) (6*uiCode) );
    603601
     
    608606  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    609607  {
     608#if L0323_DPB
     609    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1");
     610    pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
     611#else
    610612    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering");
    611613    pcSPS->setMaxDecPicBuffering( uiCode, i);
     614#endif
    612615    READ_UVLC ( uiCode, "sps_num_reorder_pics" );
    613616    pcSPS->setNumReorderPics(uiCode, i);
     
    628631
    629632  READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" );
    630   UInt log2MinCUSize = uiCode + 3;
     633  Int log2MinCUSize = uiCode + 3;
     634  pcSPS->setLog2MinCodingBlockSize(log2MinCUSize);
    631635  READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" );
    632   UInt uiMaxCUDepthCorrect = uiCode;
    633   pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUWidth  = 1<<(log2MinCUSize + uiMaxCUDepthCorrect);
    634   pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUHeight = 1<<(log2MinCUSize + uiMaxCUDepthCorrect);
     636  pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
     637  Int maxCUDepthDelta = uiCode;
     638  pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + maxCUDepthDelta) );
     639  pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) );
    635640  READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" );   pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 );
    636641
     
    640645  READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" );    pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 );
    641646  READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" );    pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 );
    642   g_uiAddCUDepth = 0;
    643   while( ( pcSPS->getMaxCUWidth() >> uiMaxCUDepthCorrect ) > ( 1 << ( pcSPS->getQuadtreeTULog2MinSize() + g_uiAddCUDepth )  ) )
    644   {
    645     g_uiAddCUDepth++;
    646   }
    647   pcSPS->setMaxCUDepth( uiMaxCUDepthCorrect+g_uiAddCUDepth  );
    648   g_uiMaxCUDepth  = uiMaxCUDepthCorrect+g_uiAddCUDepth;
    649   // BB: these parameters may be removed completly and replaced by the fixed values
    650   pcSPS->setMinTrDepth( 0 );
    651   pcSPS->setMaxTrDepth( 1 );
     647
     648  Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() );
     649  pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth );
     650
    652651  READ_FLAG( uiCode, "scaling_list_enabled_flag" );                 pcSPS->setScalingListFlag ( uiCode );
    653652  if(pcSPS->getScalingListFlag())
     
    712711    parseVUI(pcSPS->getVuiParameters(), pcSPS);
    713712  }
     713
     714#if SCALED_REF_LAYER_OFFSETS
     715  if( pcSPS->getLayerId() > 0 )
     716  {
     717    Int iCode;
     718    Window& scaledWindow = pcSPS->getScaledRefLayerWindow();
     719    READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
     720    READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
     721    READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
     722    READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
     723  }
     724#endif
    714725
    715726  READ_FLAG( uiCode, "sps_extension_flag");
     
    746757  for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
    747758  {
     759#if L0323_DPB
     760    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering_minus1[i]" );     pcVPS->setMaxDecPicBuffering( uiCode + 1, i );
     761#else
    748762    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering[i]" );     pcVPS->setMaxDecPicBuffering( uiCode, i );
     763#endif
    749764    READ_UVLC( uiCode,  "vps_num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
    750765    READ_UVLC( uiCode,  "vps_max_latency_increase[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
     
    785800    }
    786801  }
     802#if DERIVE_LAYER_ID_LIST_VARIABLES
     803  pcVPS->deriveLayerIdListVariables();
     804#endif
    787805#if L0043_TIMING_INFO
    788806  TimingInfo *timingInfo = pcVPS->getTimingInfo();
     
    900918  }
    901919#endif
     920#if VPS_MOVE_DIR_DEPENDENCY_FLAG
     921#if VPS_EXTN_DIRECT_REF_LAYERS
     922  // For layer 0
     923  vps->setNumDirectRefLayers(0, 0);
     924  // For other layers
     925  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     926  {
     927    UInt numDirectRefLayers = 0;
     928    for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     929    {
     930      READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false);
     931      if(uiCode)
     932      {
     933        vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr);
     934        numDirectRefLayers++;
     935      }
     936    }
     937    vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers);
     938  }
     939#endif
     940#endif
    902941
    903942#if VPS_EXTN_PROFILE_INFO
    904943  // Profile-tier-level signalling
     944#if VPS_PROFILE_OUTPUT_LAYERS
     945  READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" );     assert( uiCode == (vps->getNumLayerSets() - 1) );
     946  READ_CODE(  6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 );
     947  vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel());
     948  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     949#else
    905950  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
    906951  for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++)
     952#endif
    907953  {
    908954    READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false);
    909955    if( !vps->getProfilePresentFlag(idx) )
    910956    {
     957#if VPS_PROFILE_OUTPUT_LAYERS
     958      READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
     959#else
    911960      READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
     961#endif
    912962      assert( vps->getProfileLayerSetRef(idx) < idx );
    913963      // Copy profile information as indicated
     
    918968#endif
    919969
     970#if VPS_PROFILE_OUTPUT_LAYERS
     971  READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false );
     972  Int numOutputLayerSets = 0;
     973  if(! vps->getMoreOutputLayerSetsThanDefaultFlag() )
     974  {
     975    numOutputLayerSets = vps->getNumLayerSets();
     976  }
     977  else
     978  {
     979    READ_CODE( 10, uiCode, "num_add_output_layer_sets" );          vps->setNumAddOutputLayerSets( uiCode );
     980    numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets();
     981  }
     982  if( numOutputLayerSets > 1 )
     983  {
     984    READ_FLAG( uiCode, "default_one_target_output_layer_flag" );   vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false );
     985  }
     986  vps->setNumOutputLayerSets( numOutputLayerSets );
     987
     988  for(i = 1; i < numOutputLayerSets; i++)
     989  {
     990    if( i > (vps->getNumLayerSets() - 1) )
     991    {
     992      Int numBits = 1;
     993      while ((1 << numBits) < (vps->getNumLayerSets() - 1))
     994      {
     995        numBits++;
     996      }
     997      READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1");   vps->setOutputLayerSetIdx( i, uiCode + 1);
     998      Int lsIdx = vps->getOutputLayerSetIdx(i);
     999      for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
     1000      {
     1001        READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode);
     1002      }
     1003    }
     1004    else
     1005    {
     1006      // i <= (vps->getNumLayerSets() - 1)
     1007      // Assign OutputLayerFlag depending on default_one_target_output_layer_flag
     1008      Int lsIdx = i;
     1009      if( vps->getDefaultOneTargetOutputLayerFlag() )
     1010      {
     1011        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
     1012        {
     1013          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)));
     1014        }
     1015      }
     1016      else
     1017      {
     1018        for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
     1019        {
     1020          vps->setOutputLayerFlag(i, j, 1);
     1021        }
     1022      }
     1023    }
     1024    Int numBits = 1;
     1025    while ((1 << numBits) < (vps->getNumProfileTierLevel()))
     1026    {
     1027      numBits++;
     1028    }
     1029    READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
     1030  }
     1031#else
    9201032#if VPS_EXTN_OP_LAYER_SETS
    9211033  // Target output layer signalling
     
    9231035  for(i = 0; i < vps->getNumOutputLayerSets(); i++)
    9241036  {
     1037#if VPS_OUTPUT_LAYER_SET_IDX
     1038    READ_UVLC( uiCode,           "vps_output_layer_set_idx_minus1[i]"); vps->setOutputLayerSetIdx(i, uiCode + 1);
     1039#else
    9251040    READ_UVLC( uiCode,           "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode);
     1041#endif
    9261042    Int lsIdx = vps->getOutputLayerSetIdx(i);
    9271043    for(j = 0; j <= vps->getMaxLayerId(); j++)
     
    9321048      }
    9331049    }
    934   } 
    935 #endif
     1050  }
     1051#endif
     1052#endif
     1053#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1054   READ_FLAG(uiCode, "max_one_active_ref_layer_flag" );
     1055   vps->setMaxOneActiveRefLayerFlag(uiCode);   
     1056#endif
     1057
     1058#if !VPS_MOVE_DIR_DEPENDENCY_FLAG
    9361059#if VPS_EXTN_DIRECT_REF_LAYERS
    9371060  // For layer 0
     
    9521075    vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers);
    9531076  }
     1077#endif
    9541078#endif
    9551079}
     
    10741198        iPOCmsb = iPrevPOCmsb;
    10751199      }
    1076       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1077         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     1200      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1201        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    10781202        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    10791203      {
     
    10841208
    10851209      TComReferencePictureSet* rps;
     1210      rps = rpcSlice->getLocalRPS();
     1211      rpcSlice->setRPS(rps);
    10861212      READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
    10871213      if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
    10881214      {
    1089         rps = rpcSlice->getLocalRPS();
    10901215        parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
    1091         rpcSlice->setRPS(rps);
    10921216      }
    10931217      else // use reference to short-term reference picture set in PPS
     
    11061230          uiCode = 0;
    11071231        }
    1108         rpcSlice->setRPS(sps->getRPSList()->getReferencePictureSet(uiCode));
    1109 
    1110         rps = rpcSlice->getRPS();
     1232        memcpy(rps,sps->getRPSList()->getReferencePictureSet(uiCode),sizeof(TComReferencePictureSet));
    11111233      }
    11121234      if(sps->getLongTermRefsPresent())
     
    11311253        rps->setNumberOfLongtermPictures(numOfLtrp);
    11321254        Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC();
    1133         Int prevLSB = 0, prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
     1255        Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
    11341256        for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
    11351257        {
     
    11581280            READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
    11591281            Bool deltaFlag = false;
    1160             //            First LTRP                               || First LTRP from SH           || curr LSB    != prev LSB
    1161             if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) || (pocLsbLt != prevLSB) )
     1282            //            First LTRP                               || First LTRP from SH
     1283            if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
    11621284            {
    11631285              deltaFlag = true;
     
    11841306            rps->setCheckLTMSBPresent(j,false); 
    11851307          }
    1186           prevLSB = pocLsbLt;
    11871308          prevDeltaMSB = deltaPocMSBCycleLT;
    11881309        }
     
    11901311        rps->setNumberOfPictures(offset);       
    11911312      } 
    1192       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1193         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     1313      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1314        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    11941315        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    11951316      {
     
    12021323        rpcSlice->setRPS(rps);
    12031324      }
     1325
     1326
    12041327      if (rpcSlice->getSPS()->getTMVPFlagsPresent())
    12051328      {
     
    12121335      }
    12131336    }
     1337
     1338#if REF_IDX_FRAMEWORK
     1339#if JCTVC_M0458_INTERLAYER_RPS_SIG   
     1340    rpcSlice->setActiveNumILRRefIdx(0);
     1341    if((sps->getLayerId() > 0)  &&  (rpcSlice->getNumILRRefIdx() > 0) )
     1342    {     
     1343      READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");
     1344      rpcSlice->setInterLayerPredEnabledFlag(uiCode);
     1345      if( rpcSlice->getInterLayerPredEnabledFlag())
     1346      {
     1347        if(rpcSlice->getNumILRRefIdx() > 1)
     1348        {
     1349          Int numBits = 1;
     1350          while ((1 << numBits) < rpcSlice->getNumILRRefIdx())
     1351          {
     1352            numBits++;
     1353          }
     1354          if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag())
     1355          {
     1356            READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" );
     1357            rpcSlice->setActiveNumILRRefIdx(uiCode + 1);         
     1358          }
     1359          else
     1360          {
     1361            rpcSlice->setActiveNumILRRefIdx(1);         
     1362          }
     1363          for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
     1364          {
     1365            READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 
     1366            rpcSlice->setInterLayerPredLayerIdc(uiCode,i);         
     1367          }
     1368        }
     1369        else
     1370        {
     1371          rpcSlice->setActiveNumILRRefIdx(1);         
     1372          rpcSlice->setInterLayerPredLayerIdc(0,0);     
     1373        }
     1374      }
     1375    }
     1376#else
     1377    if( rpcSlice->getLayerId() > 0 )
     1378    {
     1379      rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) );
     1380    }
     1381#endif
     1382#endif
     1383
    12141384    if(sps->getUseSAO())
    12151385    {
     
    14231593        if(!rpcSlice->getDeblockingFilterDisable())
    14241594        {
    1425           READ_SVLC( iCode, "beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
    1426           READ_SVLC( iCode, "tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     1595          READ_SVLC( iCode, "slice_beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
     1596          assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 &&
     1597                 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <=  6);
     1598          READ_SVLC( iCode, "slice_tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     1599          assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 &&
     1600                 rpcSlice->getDeblockingFilterTcOffsetDiv2() <=  6);
    14271601        }
    14281602      }
     
    14561630  }
    14571631 
    1458   if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
    1459   {
    14601632    UInt *entryPointOffset          = NULL;
    14611633    UInt numEntryPointOffsets, offsetLenMinus1;
    1462 
     1634  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1635  {
    14631636    READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets );
    14641637    if (numEntryPointOffsets>0)
     
    14771650#endif
    14781651    }
     1652  }
     1653  else
     1654  {
     1655    rpcSlice->setNumEntryPointOffsets ( 0 );
     1656  }
     1657
     1658  if(pps->getSliceHeaderExtensionPresentFlag())
     1659  {
     1660    READ_UVLC(uiCode,"slice_header_extension_length");
     1661    for(Int i=0; i<uiCode; i++)
     1662    {
     1663      UInt ignore;
     1664      READ_CODE(8,ignore,"slice_header_extension_data_byte");
     1665    }
     1666  }
     1667  m_pcBitstream->readByteAlignment();
     1668
     1669  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1670  {
     1671    Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
     1672    Int  curEntryPointOffset     = 0;
     1673    Int  prevEntryPointOffset    = 0;
     1674    for (UInt idx=0; idx<numEntryPointOffsets; idx++)
     1675    {
     1676      curEntryPointOffset += entryPointOffset[ idx ];
     1677
     1678      Int emulationPreventionByteCount = 0;
     1679      for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     1680      {
     1681        if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
     1682             m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) <  ( curEntryPointOffset  + endOfSliceHeaderLocation ) )
     1683        {
     1684          emulationPreventionByteCount++;
     1685        }
     1686      }
     1687
     1688      entryPointOffset[ idx ] -= emulationPreventionByteCount;
     1689      prevEntryPointOffset = curEntryPointOffset;
     1690    }
    14791691
    14801692    if ( pps->getTilesEnabledFlag() )
     
    15121724    }
    15131725  }
    1514   else
    1515   {
    1516     rpcSlice->setNumEntryPointOffsets ( 0 );
    1517   }
    1518 
    1519   if(pps->getSliceHeaderExtensionPresentFlag())
    1520   {
    1521     READ_UVLC(uiCode,"slice_header_extension_length");
    1522     for(Int i=0; i<uiCode; i++)
    1523     {
    1524       UInt ignore;
    1525       READ_CODE(8,ignore,"slice_header_extension_data_byte");
    1526     }
    1527   }
    1528   m_pcBitstream->readByteAlignment();
     1726
    15291727  return;
    15301728}
     
    17711969// ====================================================================================================================
    17721970
    1773 
    1774 /** Parse PCM alignment zero bits.
    1775 * \returns Void
    1776 */
    1777 Void TDecCavlc::xReadPCMAlignZero( )
    1778 {
    1779   UInt uiNumberOfBits = m_pcBitstream->getNumBitsUntilByteAligned();
    1780 
    1781   if(uiNumberOfBits)
    1782   {
    1783     UInt uiBits;
    1784     UInt uiSymbol;
    1785 
    1786     for(uiBits = 0; uiBits < uiNumberOfBits; uiBits++)
    1787     {
    1788       xReadFlag( uiSymbol );
    1789       assert( uiSymbol == 0 );
    1790     }
    1791   }
    1792 }
    1793 
    1794 Void TDecCavlc::xReadUnaryMaxSymbol( UInt& ruiSymbol, UInt uiMaxSymbol )
    1795 {
    1796   if (uiMaxSymbol == 0)
    1797   {
    1798     ruiSymbol = 0;
    1799     return;
    1800   }
    1801 
    1802   xReadFlag( ruiSymbol );
    1803 
    1804   if (ruiSymbol == 0 || uiMaxSymbol == 1)
    1805   {
    1806     return;
    1807   }
    1808 
    1809   UInt uiSymbol = 0;
    1810   UInt uiCont;
    1811 
    1812   do
    1813   {
    1814     xReadFlag( uiCont );
    1815     uiSymbol++;
    1816   }
    1817   while( uiCont && (uiSymbol < uiMaxSymbol-1) );
    1818 
    1819   if( uiCont && (uiSymbol == uiMaxSymbol-1) )
    1820   {
    1821     uiSymbol++;
    1822   }
    1823 
    1824   ruiSymbol = uiSymbol;
    1825 }
    1826 
    1827 Void TDecCavlc::xReadExGolombLevel( UInt& ruiSymbol )
    1828 {
    1829   UInt uiSymbol ;
    1830   UInt uiCount = 0;
    1831   do
    1832   {
    1833     xReadFlag( uiSymbol );
    1834     uiCount++;
    1835   }
    1836   while( uiSymbol && (uiCount != 13));
    1837 
    1838   ruiSymbol = uiCount-1;
    1839 
    1840   if( uiSymbol )
    1841   {
    1842     xReadEpExGolomb( uiSymbol, 0 );
    1843     ruiSymbol += uiSymbol+1;
    1844   }
    1845 
    1846   return;
    1847 }
    1848 
    1849 Void TDecCavlc::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount )
    1850 {
    1851   UInt uiSymbol = 0;
    1852   UInt uiBit = 1;
    1853 
    1854 
    1855   while( uiBit )
    1856   {
    1857     xReadFlag( uiBit );
    1858     uiSymbol += uiBit << uiCount++;
    1859   }
    1860 
    1861   uiCount--;
    1862   while( uiCount-- )
    1863   {
    1864     xReadFlag( uiBit );
    1865     uiSymbol += uiBit << uiCount;
    1866   }
    1867 
    1868   ruiSymbol = uiSymbol;
    1869 
    1870   return;
    1871 }
    1872 
    1873 UInt TDecCavlc::xGetBit()
    1874 {
    1875   UInt ruiCode;
    1876   m_pcBitstream->read( 1, ruiCode );
    1877   return ruiCode;
    1878 }
    1879 
    1880 
    18811971/** parse explicit wp tables
    18821972* \param TComSlice* pcSlice
     
    18951985  // decode delta_luma_log2_weight_denom :
    18961986  READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );     // ue(v): luma_log2_weight_denom
     1987  assert( uiLog2WeightDenomLuma <= 7 );
    18971988  if( bChroma )
    18981989  {
    18991990    READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );     // se(v): delta_chroma_log2_weight_denom
    19001991    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0);
     1992    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7);
    19011993    uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma);
    19021994  }
     
    19372029        Int iDeltaWeight;
    19382030        READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" );  // se(v): delta_luma_weight_l0[i]
     2031        assert( iDeltaWeight >= -128 );
     2032        assert( iDeltaWeight <=  127 );
    19392033        wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom));
    19402034        READ_SVLC( wp[0].iOffset, "luma_offset_lX" );       // se(v): luma_offset_l0[i]
     2035        assert( wp[0].iOffset >= -128 );
     2036        assert( wp[0].iOffset <=  127 );
    19412037      }
    19422038      else
     
    19532049            Int iDeltaWeight;
    19542050            READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" );  // se(v): chroma_weight_l0[i][j]
     2051            assert( iDeltaWeight >= -128 );
     2052            assert( iDeltaWeight <=  127 );
    19552053            wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom));
    19562054
    19572055            Int iDeltaChroma;
    19582056            READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" );  // se(v): delta_chroma_offset_l0[i][j]
     2057            assert( iDeltaChroma >= -512 );
     2058            assert( iDeltaChroma <=  511 );
    19592059            Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
    19602060            wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) );
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.h

    r125 r189  
    6161 
    6262protected:
    63   Void  xReadEpExGolomb       ( UInt& ruiSymbol, UInt uiCount );
    64   Void  xReadExGolombLevel    ( UInt& ruiSymbol );
    65   Void  xReadUnaryMaxSymbol   ( UInt& ruiSymbol, UInt uiMaxSymbol );
    66  
    67   Void  xReadPCMAlignZero     ();
    68 
    69   UInt  xGetBit             ();
    70  
    7163  void  parseShortTermRefPicSet            (TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Int idx);
    72 private:
    7364 
    7465public:
  • trunk/source/Lib/TLibDecoder/TDecCu.cpp

    r125 r189  
    370370  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
    371371#endif
    372  
     372
    373373  // Coefficient decoding
    374374  Bool bCodeDQP = getdQPFlag();
  • trunk/source/Lib/TLibDecoder/TDecGop.cpp

    r125 r189  
    247247    for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++)
    248248    {
     249#if REF_IDX_FRAMEWORK && VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     250      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR( m_layerId ) )
     251      {
     252        printf( "%d(%d) ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     253      }
     254      else
     255#endif
    249256      printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
    250257    }
  • trunk/source/Lib/TLibDecoder/TDecSlice.h

    r125 r189  
    9191  Void      initCtxMem(  UInt i );
    9292  Void      setCtxMem( TDecSbac* sb, Int b )   { CTXMem[b] = sb; }
     93  Int       getCtxMemSize( )                   { return (Int)CTXMem.size(); }
    9394#if SVC_EXTENSION
    9495  TDecTop*  getLayerDec   ( UInt LayerId )  { return m_ppcTDecTop[LayerId]; } 
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r125 r189  
    113113    if(m_cIlpPic[i])
    114114    {
    115       //m_cIlpPic[i]->setPicYuvRec(NULL);
    116115      m_cIlpPic[i]->destroy();
    117116      delete m_cIlpPic[i];
     
    143142  if(m_layerId>0)
    144143  {
     144    g_bitDepthY     = pcSPS->getBitDepthY();
     145    g_bitDepthC     = pcSPS->getBitDepthC();
     146    g_uiMaxCUWidth  = pcSPS->getMaxCUWidth();
     147    g_uiMaxCUHeight = pcSPS->getMaxCUHeight();
     148    g_uiMaxCUDepth  = pcSPS->getMaxCUDepth();
     149    g_uiAddCUDepth  = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() );
     150
    145151    Int  numReorderPics[MAX_TLAYER];
    146152    Window &conformanceWindow = pcSPS->getConformanceWindow();
     
    154160    if (m_cIlpPic[0] == NULL)
    155161    {
    156       for (Int j=0; j<1/*MAX_NUM_REF*/; j++)
    157       {
     162      for (Int j=0; j< 1/*MAX_NUM_REF*/; j++)  // to be set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
     163      {
     164
    158165        m_cIlpPic[j] = new  TComPic;
    159         //m_cIlpPic[j]->createWithOutYuv(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, &m_cSPS, true);
    160166#if SVC_UPSAMPLING
    161167        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
     
    176182  if(m_cIlpPic[0])
    177183  {
    178     //m_cIlpPic[0]->setPicYuvRec(pcPic->getFullPelBaseRec());
    179184    m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
    180185    m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
    181     m_cIlpPic[0]->setLayerId(0); //set reference layerId
     186    m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId
    182187    m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
    183188    m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     
    231236  }
    232237
     238#if L0323_DPB
     239  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
     240#else
    233241  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded
     242#endif
    234243  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
    235244  {
     
    239248    if(m_layerId > 0)
    240249    {
     250#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     251      TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( m_layerId );
     252#else
    241253      TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 );
     254#endif
    242255      //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
    243256      TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
     
    339352  cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );
    340353  cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );
     354  cFillSlice.setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() );
    341355  cFillSlice.initSlice( m_layerId );
    342356#else
     
    350364  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );
    351365  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );
     366  cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() );
    352367  cFillPic->getSlice(0)->initSlice( m_layerId );
    353368#else
     
    405420  assert (sps != 0);
    406421
    407   if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->getIdrPicFlag()) )
     422  if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) )
    408423#else
    409424  m_parameterSetManagerDecoder.applyPrefetchedPS();
     
    415430  assert (sps != 0);
    416431
    417   if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->getIdrPicFlag()))
     432  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
    418433#endif
    419434  {
     
    422437  }
    423438
     439  if( pps->getDependentSliceSegmentsEnabledFlag() )
     440  {
     441    Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
     442
     443    if (m_cSliceDecoder.getCtxMemSize() != NumCtx)
     444    {
     445      m_cSliceDecoder.initCtxMem(NumCtx);
     446      for ( UInt st = 0; st < NumCtx; st++ )
     447      {
     448        TDecSbac* ctx = NULL;
     449        ctx = new TDecSbac;
     450        ctx->init( &m_cBinCABAC );
     451        m_cSliceDecoder.setCtxMem( ctx, st );
     452      }
     453    }
     454  }
     455
    424456  m_apcSlicePilot->setPPS(pps);
    425457  m_apcSlicePilot->setSPS(sps);
     458
    426459  pps->setSPS(sps);
    427460  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
    428461  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
    429462
    430   for (Int i = 0; i < sps->getMaxCUDepth() - g_uiAddCUDepth; i++)
     463  g_bitDepthY     = sps->getBitDepthY();
     464  g_bitDepthC     = sps->getBitDepthC();
     465  g_uiMaxCUWidth  = sps->getMaxCUWidth();
     466  g_uiMaxCUHeight = sps->getMaxCUHeight();
     467  g_uiMaxCUDepth  = sps->getMaxCUDepth();
     468  g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
     469
     470  for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
    431471  {
    432472    sps->setAMPAcc( i, sps->getUseAMP() );
    433473  }
    434474
    435   for (Int i = sps->getMaxCUDepth() - g_uiAddCUDepth; i < sps->getMaxCUDepth(); i++)
     475  for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++)
    436476  {
    437477    sps->setAMPAcc( i, 0 );
     
    439479
    440480  m_cSAO.destroy();
    441   m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight );
    442   m_cLoopFilter.        create( g_uiMaxCUDepth );
     481  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() );
     482  m_cLoopFilter.create( sps->getMaxCUDepth() );
    443483}
    444484
     
    451491  TComPic*&   pcPic         = m_pcPic;
    452492#if SVC_EXTENSION
     493  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) );
    453494  m_apcSlicePilot->initSlice( nalu.m_layerId );
    454495#else
     
    467508
    468509  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
    469   if((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N) ||
    470      (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) ||
    471      (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N))
    472   {
    473     m_apcSlicePilot->setTemporalLayerNonReferenceFlag(true);
    474   }
     510  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
     511                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
     512                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
     513                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
     514                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
     515  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
     516 
    475517  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
    476518  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
     
    481523  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
    482524#endif
    483   if (m_apcSlicePilot->isNextSlice())
    484   {
    485     // Skip pictures due to random access
    486     if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
    487     {
    488       return false;
    489     }
    490     // Skip TFD pictures associated with BLA/BLANT pictures
    491     if (isSkipPictureForBLA(iPOCLastDisplay))
    492     {
    493       return false;
    494     }
    495   }
     525
     526  // Skip pictures due to random access
     527  if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
     528  {
     529    return false;
     530  }
     531  // Skip TFD pictures associated with BLA/BLANT pictures
     532  if (isSkipPictureForBLA(iPOCLastDisplay))
     533  {
     534    return false;
     535  }
    496536
    497537  // exit when a new picture is found
     
    506546  }
    507547#else
    508   if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence)
     548  //we should only get a different poc for a new picture (with CTU address==0)
     549  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0))
     550  {
     551    printf ("Warning, the first slice of a picture might have been lost!\n");
     552  }
     553  // exit when a new picture is found
     554  if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence )
    509555  {
    510556    if (m_prevPOC >= m_pocRandomAccess)
     
    537583  {
    538584#if AVC_BASE
    539   if( m_layerId == 1 )
    540   {
    541     TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
    542     fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
    543     const Window &conf = pBLPic->getConformanceWindow();
    544     UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
    545     UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
    546        
    547     if( pFile->good() )
    548     {
    549       UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
    550 
    551       pFile->seekg((UInt)uiPos, ios::beg );
    552 
    553       Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
    554       UInt uiStride = pBLPic->getPicYuvRec()->getStride();
    555       for( Int i = 0; i < uiHeight; i++ )
    556       {
    557         for( Int j = 0; j < uiWidth; j++ )
     585    if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
     586    {
     587      TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     588      fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
     589#if ILP_DECODED_PICTURE
     590      UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth();
     591      UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight();
     592#else
     593      const Window &conf = pBLPic->getConformanceWindow();
     594      UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
     595      UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
     596#endif
     597
     598      if( pFile->good() )
     599      {
     600        UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
     601
     602        pFile->seekg((UInt)uiPos, ios::beg );
     603
     604        Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
     605        UInt uiStride = pBLPic->getPicYuvRec()->getStride();
     606        for( Int i = 0; i < uiHeight; i++ )
    558607        {
    559           pPel[j] = pFile->get();
     608          for( Int j = 0; j < uiWidth; j++ )
     609          {
     610            pPel[j] = pFile->get();
     611          }
     612          pPel += uiStride;
    560613        }
    561         pPel += uiStride;
    562       }
    563 
    564       pPel = pBLPic->getPicYuvRec()->getCbAddr();
    565       uiStride = pBLPic->getPicYuvRec()->getCStride();
    566       for( Int i = 0; i < uiHeight/2; i++ )
    567       {
    568         for( Int j = 0; j < uiWidth/2; j++ )
     614
     615        pPel = pBLPic->getPicYuvRec()->getCbAddr();
     616        uiStride = pBLPic->getPicYuvRec()->getCStride();
     617        for( Int i = 0; i < uiHeight/2; i++ )
    569618        {
    570           pPel[j] = pFile->get();
     619          for( Int j = 0; j < uiWidth/2; j++ )
     620          {
     621            pPel[j] = pFile->get();
     622          }
     623          pPel += uiStride;
    571624        }
    572         pPel += uiStride;
    573       }
    574 
    575       pPel = pBLPic->getPicYuvRec()->getCrAddr();
    576       uiStride = pBLPic->getPicYuvRec()->getCStride();
    577       for( Int i = 0; i < uiHeight/2; i++ )
    578       {
    579         for( Int j = 0; j < uiWidth/2; j++ )
     625
     626        pPel = pBLPic->getPicYuvRec()->getCrAddr();
     627        uiStride = pBLPic->getPicYuvRec()->getCStride();
     628        for( Int i = 0; i < uiHeight/2; i++ )
    580629        {
    581           pPel[j] = pFile->get();
     630          for( Int j = 0; j < uiWidth/2; j++ )
     631          {
     632            pPel[j] = pFile->get();
     633          }
     634          pPel += uiStride;
    582635        }
    583         pPel += uiStride;
    584       }
    585     }
    586   }
     636      }
     637    }
    587638#endif
    588639
     
    732783  if (bNextSlice)
    733784  {
    734     pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA );
     785    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic );
    735786    // Set reference list
    736 #if REF_LIST_BUGFIX
     787#if REF_IDX_FRAMEWORK
    737788    if (m_layerId == 0)
    738     {
    739       pcSlice->setRefPicList( m_cListPic );
    740     }
     789#endif
     790#if FIX1071
     791    pcSlice->setRefPicList( m_cListPic, true );
    741792#else
    742793    pcSlice->setRefPicList( m_cListPic );
     
    747798    {
    748799#if AVC_BASE
    749       pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
     800      if( m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
     801      {
     802        pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
    750803#if AVC_SYNTAX
    751       TComPic* pBLPic = pcSlice->getBaseColPic();
    752       if( pcSlice->getPOC() == 0 )
    753       {
    754         // initialize partition order.
    755         UInt* piTmp = &g_auiZscanToRaster[0];
    756         initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
    757         initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
    758       }     
    759       pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
    760       pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
    761 #endif
    762 
     804        TComPic* pBLPic = pcSlice->getBaseColPic();
     805        if( pcSlice->getPOC() == 0 )
     806        {
     807          // initialize partition order.
     808          UInt* piTmp = &g_auiZscanToRaster[0];
     809          initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
     810          initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
     811        }     
     812        pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
     813        pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
     814#endif
     815      }
     816      else
     817      {
     818#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     819        TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId );
     820#else
     821        TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
     822#endif
     823        TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
     824        pcSlice->setBaseColPic ( *cListPic, m_layerId );
     825      }
     826#else
     827#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     828      TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId );
    763829#else
    764830      TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
     831#endif
    765832      TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
    766833      pcSlice->setBaseColPic ( *cListPic, m_layerId );
     
    769836      if ( pcPic->isSpatialEnhLayer())
    770837      {   
     838#if SCALED_REF_LAYER_OFFSETS
     839        m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     840#else
    771841        m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     842#endif
    772843      }
    773844      else
     
    778849#endif
    779850    }
    780 #endif
    781851
    782852#if REF_IDX_FRAMEWORK
     
    785855      setILRPic(pcPic);
    786856#if REF_IDX_MFM
    787       pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
    788 #endif
    789 #if REF_LIST_BUGFIX
    790       pcSlice->setRefPicListSvc( m_cListPic, m_cIlpPic);
    791 #else
    792       pcSlice->addRefPicList ( m_cIlpPic,
    793                                1,
    794                                ((pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
    795                                 (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ? 0: -1);
    796 #endif
    797     }
    798 #endif
     857      if( pcSlice->getSPS()->getMFMEnabledFlag() )
     858      {
     859        pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
     860      }
     861#endif
     862      pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic);
     863    }
     864#endif
     865
     866#endif //SVC_EXTENSION
    799867
    800868    // For generalized B
     
    839907    //---------------
    840908    pcSlice->setRefPOCList();
     909#if !L0034_COMBINED_LIST_CLEANUP
    841910    pcSlice->setNoBackPredFlag( false );
    842911    if ( pcSlice->getSliceType() == B_SLICE )
     
    855924      }
    856925    }
     926#endif
    857927  }
    858928
     
    878948    m_cTrQuant.setUseScalingList(false);
    879949  }
     950
     951#if SIMPLIFIED_MV_POS_SCALING
     952  if (m_layerId > 0)
     953  {
     954#if SCALED_REF_LAYER_OFFSETS
     955    const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
     956
     957    Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
     958    Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
     959
     960    Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     961    Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     962#else
     963    const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
     964    const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     965
     966    Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     967    Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     968
     969    Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     970    Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     971#endif
     972    g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     973    g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     974
     975    g_posScalingFactor[m_layerId][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
     976    g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
     977  }
     978#endif
    880979
    881980  //  Decode a picture
     
    9471046{
    9481047#if SVC_EXTENSION
    949   if(nalUnitType == NAL_UNIT_SEI_SUFFIX)
     1048  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    9501049  {
    9511050    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
     
    9671066  }
    9681067#else
    969   if(nalUnitType == NAL_UNIT_SEI_SUFFIX)
     1068  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    9701069  {
    9711070    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     
    10031102    case NAL_UNIT_VPS:
    10041103      xDecodeVPS();
     1104#if AVC_BASE
     1105      if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
     1106      {
     1107        if( !m_ppcTDecTop[0]->getBLReconFile()->good() )
     1108        {
     1109          printf( "Base layer YUV input reading error\n" );
     1110          exit(EXIT_FAILURE);
     1111        }       
     1112#if AVC_SYNTAX
     1113        if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() )
     1114        {
     1115          printf( "Base layer syntax input reading error\n" );
     1116          exit(EXIT_FAILURE);
     1117        }
     1118#endif
     1119      }
     1120      else
     1121      {
     1122        TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic();
     1123        cListPic->clear();
     1124      }
     1125#endif
    10051126      return false;
    10061127     
     
    10081129      xDecodeSPS();
    10091130#if AVC_BASE
     1131      if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
    10101132      {
    10111133        TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     
    10191141#if AVC_SYNTAX
    10201142
    1021           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
    1022 #else
    1023           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
    1024 #endif
    1025 #else
    1026           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, onformanceWindow, defaultDisplayWindow, numReorderPics, true);
     1143          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
     1144#else
     1145          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
     1146#endif
     1147#else
     1148          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
    10271149#endif
    10281150        }
     
    10351157      return false;
    10361158     
    1037     case NAL_UNIT_SEI:
    1038     case NAL_UNIT_SEI_SUFFIX:
     1159    case NAL_UNIT_PREFIX_SEI:
     1160    case NAL_UNIT_SUFFIX_SEI:
    10391161      xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
    10401162      return false;
     
    10421164    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    10431165    case NAL_UNIT_CODED_SLICE_TRAIL_N:
    1044     case NAL_UNIT_CODED_SLICE_TLA:
     1166    case NAL_UNIT_CODED_SLICE_TLA_R:
    10451167    case NAL_UNIT_CODED_SLICE_TSA_N:
    10461168    case NAL_UNIT_CODED_SLICE_STSA_R:
    10471169    case NAL_UNIT_CODED_SLICE_STSA_N:
    1048     case NAL_UNIT_CODED_SLICE_BLA:
    1049     case NAL_UNIT_CODED_SLICE_BLANT:
     1170    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
     1171    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
    10501172    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
    1051     case NAL_UNIT_CODED_SLICE_IDR:
     1173    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
    10521174    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    10531175    case NAL_UNIT_CODED_SLICE_CRA:
    10541176    case NAL_UNIT_CODED_SLICE_RADL_N:
    1055     case NAL_UNIT_CODED_SLICE_DLP:
     1177    case NAL_UNIT_CODED_SLICE_RADL_R:
    10561178    case NAL_UNIT_CODED_SLICE_RASL_N:
    1057     case NAL_UNIT_CODED_SLICE_TFD:
     1179    case NAL_UNIT_CODED_SLICE_RASL_R:
    10581180#if SVC_EXTENSION
    10591181      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC);
     
    10771199Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
    10781200{
    1079   if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TFD || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
     1201  if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    10801202  {
    10811203    iPOCLastDisplay++;
     
    11081230  {
    11091231    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
    1110         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
     1232        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    11111233        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    1112         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT )
     1234        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL )
    11131235    {
    11141236      // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
    11151237      m_pocRandomAccess = m_apcSlicePilot->getPOC();
    11161238    }
    1117     else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     1239    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    11181240    {
    11191241      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
     
    11311253  }
    11321254  // skip the reordered pictures, if necessary
    1133   else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TFD || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
     1255  else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    11341256  {
    11351257    iPOCLastDisplay++;
     
    11401262}
    11411263
     1264#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     1265TDecTop* TDecTop::getRefLayerDec( UInt layerId )
     1266{
     1267  TComVPS* vps = m_parameterSetManagerDecoder[0].getActiveVPS();
     1268  if( vps->getNumDirectRefLayers( m_layerId ) <= 0 )
     1269  {
     1270#if ZERO_NUM_DIRECT_LAYERS
     1271    return (TDecTop *)getLayerDec( 0 );
     1272#else
     1273    return NULL;
     1274#endif
     1275  }
     1276
     1277  // currently only one reference layer is supported
     1278  assert( vps->getNumDirectRefLayers( m_layerId ) == 1 );
     1279#if JCTVC_M0458_INTERLAYER_RPS_SIG
     1280  assert( vps->getMaxOneActiveRefLayerFlag() == 1 );
     1281#endif
     1282 
     1283  return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, 0 ) );
     1284}
     1285#endif
     1286
    11421287//! \}
  • trunk/source/Lib/TLibDecoder/TDecTop.h

    r125 r189  
    154154  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
    155155  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
    156   Void                setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
    157   TDecTop*            getLayerDec(UInt layer)   { return m_ppcTDecTop[layer]; }
     156  Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
     157  TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
     158#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     159  TDecTop*  getRefLayerDec(UInt layerId);
     160#endif
    158161#if AVC_BASE
    159162  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
Note: See TracChangeset for help on using the changeset viewer.