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


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:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/source

  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r125 r189  
    8484    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
    8585    break;
     86#if J0149_TONE_MAPPING_SEI
     87  case SEI::TONE_MAPPING_INFO:
     88    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
     89    break;
     90#endif
     91#if L0208_SOP_DESCRIPTION_SEI
     92  case SEI::SOP_DESCRIPTION:
     93    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     94    break;
     95#endif
     96#if K0180_SCALABLE_NESTING_SEI
     97  case SEI::SCALABLE_NESTING:
     98    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
     99    break;
     100#endif
    86101  default:
    87102    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
     
    91106#endif
    92107
     108#if K0180_SCALABLE_NESTING_SEI
     109void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps)
     110#else
    93111void SEIWriter::xWriteSEIpayloadData(const SEI& sei, TComSPS *sps)
     112#endif
    94113{
    95114  switch (sei.payloadType())
     
    128147    xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei));
    129148    break;
     149#if J0149_TONE_MAPPING_SEI
     150  case SEI::TONE_MAPPING_INFO:
     151    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
     152    break;
     153#endif
     154#if L0208_SOP_DESCRIPTION_SEI
     155  case SEI::SOP_DESCRIPTION:
     156    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
     157    break;
     158#endif
     159#if K0180_SCALABLE_NESTING_SEI
     160  case SEI::SCALABLE_NESTING:
     161    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
     162    break;
     163#endif
    130164  default:
    131165    assert(!"Unhandled SEI message");
     
    145179  setBitstream(&bs_count);
    146180
     181
     182#if K0180_SCALABLE_NESTING_SEI
     183
     184#if ENC_DEC_TRACE
     185  Bool traceEnable = g_HLSTraceEnable;
     186  g_HLSTraceEnable = false;
     187#endif
     188  xWriteSEIpayloadData(bs_count, sei, sps);
     189#if ENC_DEC_TRACE
     190  g_HLSTraceEnable = traceEnable;
     191#endif
     192
     193#else
     194
    147195#if ENC_DEC_TRACE
    148196  g_HLSTraceEnable = false;
     
    152200  g_HLSTraceEnable = true;
    153201#endif
     202
     203#endif
     204
    154205  UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits();
    155206  assert(0 == payload_data_num_bits % 8);
     
    158209
    159210#if ENC_DEC_TRACE
     211#if K0180_SCALABLE_NESTING_SEI
     212  if (g_HLSTraceEnable)
     213#endif
    160214  xTraceSEIHeader();
    161215#endif
     
    177231  /* payloadData */
    178232#if ENC_DEC_TRACE
     233#if K0180_SCALABLE_NESTING_SEI
     234  if (g_HLSTraceEnable)
     235#endif
    179236  xTraceSEIMessageType(sei.payloadType());
    180237#endif
    181238
     239#if K0180_SCALABLE_NESTING_SEI
     240  xWriteSEIpayloadData(bs, sei, sps);
     241#else
    182242  xWriteSEIpayloadData(sei, sps);
     243#endif
    183244}
    184245
     
    421482  xWriteByteAlign();
    422483}
     484
     485#if J0149_TONE_MAPPING_SEI
     486Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei)
     487{
     488  Int i;
     489  WRITE_UVLC( sei.m_toneMapId,                    "tone_map_id" );
     490  WRITE_FLAG( sei.m_toneMapCancelFlag,            "tone_map_cancel_flag" );
     491  if( !sei.m_toneMapCancelFlag )
     492  {
     493    WRITE_FLAG( sei.m_toneMapPersistenceFlag,     "tone_map_persistence_flag" );
     494    WRITE_CODE( sei.m_codedDataBitDepth,    8,    "coded_data_bit_depth" );
     495    WRITE_CODE( sei.m_targetBitDepth,       8,    "target_bit_depth" );
     496    WRITE_UVLC( sei.m_modelId,                    "model_id" );
     497    switch(sei.m_modelId)
     498    {
     499    case 0:
     500      {
     501        WRITE_CODE( sei.m_minValue,  32,        "min_value" );
     502        WRITE_CODE( sei.m_maxValue, 32,         "max_value" );
     503        break;
     504      }
     505    case 1:
     506      {
     507        WRITE_CODE( sei.m_sigmoidMidpoint, 32,  "sigmoid_midpoint" );
     508        WRITE_CODE( sei.m_sigmoidWidth,    32,  "sigmoid_width"    );
     509        break;
     510      }
     511    case 2:
     512      {
     513        UInt num = 1u << sei.m_targetBitDepth;
     514        for(i = 0; i < num; i++)
     515        {
     516          WRITE_CODE( sei.m_startOfCodedInterval[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,  "start_of_coded_interval" );
     517        }
     518        break;
     519      }
     520    case 3:
     521      {
     522        WRITE_CODE( sei.m_numPivots, 16,          "num_pivots" );
     523        for(i = 0; i < sei.m_numPivots; i++ )
     524        {
     525          WRITE_CODE( sei.m_codedPivotValue[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,       "coded_pivot_value" );
     526          WRITE_CODE( sei.m_targetPivotValue[i], (( sei.m_targetBitDepth + 7 ) >> 3 ) << 3,         "target_pivot_value");
     527        }
     528        break;
     529      }
     530    case 4:
     531      {
     532        WRITE_CODE( sei.m_cameraIsoSpeedIdc,    8,    "camera_iso_speed_idc" );
     533        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
     534        {
     535          WRITE_CODE( sei.m_cameraIsoSpeedValue,    32,    "camera_iso_speed_value" );
     536        }
     537        WRITE_FLAG( sei.m_exposureCompensationValueSignFlag,           "exposure_compensation_value_sign_flag" );
     538        WRITE_CODE( sei.m_exposureCompensationValueNumerator,     16,  "exposure_compensation_value_numerator" );
     539        WRITE_CODE( sei.m_exposureCompensationValueDenomIdc,      16,  "exposure_compensation_value_denom_idc" );
     540        WRITE_CODE( sei.m_refScreenLuminanceWhite,                32,  "ref_screen_luminance_white" );
     541        WRITE_CODE( sei.m_extendedRangeWhiteLevel,                32,  "extended_range_white_level" );
     542        WRITE_CODE( sei.m_nominalBlackLevelLumaCodeValue,         16,  "nominal_black_level_luma_code_value" );
     543        WRITE_CODE( sei.m_nominalWhiteLevelLumaCodeValue,         16,  "nominal_white_level_luma_code_value" );
     544        WRITE_CODE( sei.m_extendedWhiteLevelLumaCodeValue,        16,  "extended_white_level_luma_code_value" );
     545        break;
     546      }
     547    default:
     548      {
     549        assert(!"Undefined SEIToneMapModelId");
     550        break;
     551      }
     552    }//switch m_modelId
     553  }//if(!sei.m_toneMapCancelFlag)
     554
     555  xWriteByteAlign();
     556}
     557#endif
     558
    423559Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
    424560{
     
    455591}
    456592
     593#if L0208_SOP_DESCRIPTION_SEI
     594Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei)
     595{
     596  WRITE_UVLC( sei.m_sopSeqParameterSetId,           "sop_seq_parameter_set_id"               );
     597  WRITE_UVLC( sei.m_numPicsInSopMinus1,             "num_pics_in_sop_minus1"               );
     598  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
     599  {
     600    WRITE_CODE( sei.m_sopDescVclNaluType[i], 6, "sop_desc_vcl_nalu_type" );
     601    WRITE_CODE( sei.m_sopDescTemporalId[i],  3, "sop_desc_temporal_id" );
     602    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
     603    {
     604      WRITE_UVLC( sei.m_sopDescStRpsIdx[i],           "sop_desc_st_rps_idx"               );
     605    }
     606    if (i > 0)
     607    {
     608      WRITE_SVLC( sei.m_sopDescPocDelta[i],           "sop_desc_poc_delta"               );
     609    }
     610  }
     611
     612  xWriteByteAlign();
     613}
     614#endif
     615
     616#if K0180_SCALABLE_NESTING_SEI
     617Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps)
     618{
     619  WRITE_FLAG( sei.m_bitStreamSubsetFlag,             "bitstream_subset_flag"         );
     620  WRITE_FLAG( sei.m_nestingOpFlag,                   "nesting_op_flag      "         );
     621  if (sei.m_nestingOpFlag)
     622  {
     623    WRITE_FLAG( sei.m_defaultOpFlag,                 "default_op_flag"               );
     624    WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops"               );
     625    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
     626    {
     627      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
     628      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id"       );
     629      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
     630    }
     631  }
     632  else
     633  {
     634    WRITE_FLAG( sei.m_allLayersFlag,                      "all_layers_flag"               );
     635    if (!sei.m_allLayersFlag)
     636    {
     637      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
     638      WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"            );
     639      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
     640      {
     641        WRITE_CODE( sei.m_nestingLayerId[i], 6,           "nesting_layer_id"              );
     642      }
     643    }
     644  }
     645 
     646  // byte alignment
     647  while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
     648  {
     649    WRITE_FLAG( 0, "nesting_zero_bit" );
     650  }
     651
     652  // write nested SEI messages
     653  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
     654  {
     655    writeSEImessage(bs, *(*it), sps);
     656  }
     657}
     658#endif
     659
    457660Void SEIWriter::xWriteByteAlign()
    458661{
  • trunk/source/Lib/TLibEncoder/SEIwrite.h

    r125 r189  
    5050
    5151protected:
     52#if K0180_SCALABLE_NESTING_SEI
     53  Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps);
     54#else
    5255  Void xWriteSEIpayloadData(const SEI& sei, TComSPS *sps);
     56#endif
    5357  Void xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei);
    5458  Void xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei);
     
    6367  Void xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei);
    6468  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
     69#if J0149_TONE_MAPPING_SEI
     70  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
     71#endif
     72#if L0208_SOP_DESCRIPTION_SEI
     73  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
     74#endif
     75#if K0180_SCALABLE_NESTING_SEI
     76  Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps);
     77#endif
    6578  Void xWriteByteAlign();
    6679};
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r125 r189  
    3939#include "TEncCavlc.h"
    4040#include "SEIwrite.h"
    41 
     41#include <iostream>
    4242//! \ingroup TLibEncoder
    4343//! \{
     
    285285  WRITE_FLAG(pcVUI->getNeutralChromaIndicationFlag(),           "neutral_chroma_indication_flag");
    286286  WRITE_FLAG(pcVUI->getFieldSeqFlag(),                          "field_seq_flag");
    287   assert(pcVUI->getFieldSeqFlag() == 0);                        // not currently supported
    288287  WRITE_FLAG(pcVUI->getFrameFieldInfoPresentFlag(),             "frame_field_info_present_flag");
    289288
     
    474473  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    475474  {
     475#if L0323_DPB
     476    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1,       "sps_max_dec_pic_buffering_minus1[i]" );
     477#else
    476478    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i),           "sps_max_dec_pic_buffering[i]" );
     479#endif
    477480    WRITE_UVLC( pcSPS->getNumReorderPics(i),               "sps_num_reorder_pics[i]" );
    478481    WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i),           "sps_max_latency_increase[i]" );
     
    484487  assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() );
    485488 
    486   UInt MinCUSize = pcSPS->getMaxCUWidth() >> ( pcSPS->getMaxCUDepth()-g_uiAddCUDepth );
    487   UInt log2MinCUSize = 0;
    488   while(MinCUSize > 1)
    489   {
    490     MinCUSize >>= 1;
    491     log2MinCUSize++;
    492   }
    493 
    494   WRITE_UVLC( log2MinCUSize - 3,                                                     "log2_min_coding_block_size_minus3" );
    495   WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth,                                 "log2_diff_max_min_coding_block_size" );
     489  WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3,                                "log2_min_coding_block_size_minus3" );
     490  WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(),                             "log2_diff_max_min_coding_block_size" );
    496491  WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2,                                 "log2_min_transform_block_size_minus2" );
    497492  WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" );
     
    558553      codeVUI(pcSPS->getVuiParameters(), pcSPS);
    559554  }
     555#if SCALED_REF_LAYER_OFFSETS
     556  if( pcSPS->getLayerId() > 0 )
     557  {
     558    Window scaledWindow = pcSPS->getScaledRefLayerWindow();
     559    WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
     560    WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
     561    WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
     562    WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
     563  }
     564#endif
    560565
    561566  WRITE_FLAG( 0, "sps_extension_flag" );
     
    583588  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
    584589  {
     590#if L0323_DPB
     591    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1,       "vps_max_dec_pic_buffering_minus1[i]" );
     592#else
    585593    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i),           "vps_max_dec_pic_buffering[i]" );
     594#endif
    586595    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "vps_num_reorder_pics[i]" );
    587596    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "vps_max_latency_increase[i]" );
     
    623632    }
    624633  }
     634#if DERIVE_LAYER_ID_LIST_VARIABLES
     635  pcVPS->deriveLayerIdListVariables();
     636#endif
    625637#if L0043_TIMING_INFO
    626638  TimingInfo *timingInfo = pcVPS->getTimingInfo();
     
    703715  }
    704716#endif
     717#if VPS_MOVE_DIR_DEPENDENCY_FLAG
     718#if VPS_EXTN_DIRECT_REF_LAYERS
     719  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     720  {
     721    for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     722    {
     723      WRITE_FLAG(vps->getDirectDependencyFlag(layerCtr, refLayerCtr), "direct_dependency_flag[i][j]" );
     724    }
     725  }
     726#endif
     727#endif
    705728#if VPS_EXTN_PROFILE_INFO
    706729  // Profile-tier-level signalling
     730#if VPS_PROFILE_OUTPUT_LAYERS
     731  WRITE_CODE( vps->getNumLayerSets() - 1   , 10, "vps_number_layer_sets_minus1" );     
     732  WRITE_CODE( vps->getNumProfileTierLevel() - 1,  6, "vps_num_profile_tier_level_minus1");
     733  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     734#else
    707735  for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++)
     736#endif
    708737  {
    709738    WRITE_FLAG( vps->getProfilePresentFlag(idx),       "vps_profile_present_flag[i]" );
    710739    if( !vps->getProfilePresentFlag(idx) )
    711740    {
     741#if VPS_PROFILE_OUTPUT_LAYERS
     742      WRITE_CODE( vps->getProfileLayerSetRef(idx) - 1, 6, "profile_ref_minus1[i]" );
     743#else
    712744      WRITE_UVLC( vps->getProfileLayerSetRef(idx) - 1, "vps_profile_layer_set_ref_minus1[i]" );
     745#endif
    713746    }
    714747    codePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 );
    715748  }
    716749#endif
     750
     751#if VPS_PROFILE_OUTPUT_LAYERS
     752  Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
     753  WRITE_FLAG(  (numOutputLayerSets > vps->getNumLayerSets()), "more_output_layer_sets_than_default_flag" );
     754  if(numOutputLayerSets > vps->getNumLayerSets())
     755  {
     756    WRITE_CODE( numOutputLayerSets - vps->getNumLayerSets(), 10, "num_add_output_layer_sets" );
     757  }
     758  if( numOutputLayerSets > 1 )
     759  {
     760    WRITE_FLAG( vps->getDefaultOneTargetOutputLayerFlag(), "default_one_target_output_layer_flag" );   
     761  }
     762
     763  for(i = 1; i < numOutputLayerSets; i++)
     764  {
     765    if( i > (vps->getNumLayerSets() - 1) )
     766    {
     767      Int numBits = 1;
     768      while ((1 << numBits) < (vps->getNumLayerSets() - 1))
     769      {
     770        numBits++;
     771      }
     772      WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "output_layer_set_idx_minus1"); 
     773      Int lsIdx = vps->getOutputLayerSetIdx(i);
     774      for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
     775      {
     776        WRITE_FLAG( vps->getOutputLayerFlag(i,j), "output_layer_flag[i][j]");
     777      }
     778    }
     779    Int numBits = 1;
     780    while ((1 << numBits) < (vps->getNumProfileTierLevel()))
     781    {
     782      numBits++;
     783    }
     784    WRITE_CODE( vps->getProfileLevelTierIdx(i), numBits, "profile_level_tier_idx[i]" );     
     785  }
     786#else
    717787#if VPS_EXTN_OP_LAYER_SETS
    718788  // Target output layer signalling
     
    720790  for(i = 0; i < vps->getNumOutputLayerSets(); i++)
    721791  {
     792#if VPS_OUTPUT_LAYER_SET_IDX
     793    assert(vps->getOutputLayerSetIdx(i) > 0);
     794    WRITE_UVLC( vps->getOutputLayerSetIdx(i) - 1,           "vps_output_layer_set_idx_minus1[i]");
     795#else
    722796    WRITE_UVLC( vps->getOutputLayerSetIdx(i),           "vps_output_layer_set_idx[i]");
     797#endif
    723798    Int lsIdx = vps->getOutputLayerSetIdx(i);
    724799    for(j = 0; j <= vps->getMaxLayerId(); j++)
     
    731806  }
    732807#endif
     808#endif
     809#if JCTVC_M0458_INTERLAYER_RPS_SIG
     810      WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
     811#endif
     812#if !VPS_MOVE_DIR_DEPENDENCY_FLAG
    733813#if VPS_EXTN_DIRECT_REF_LAYERS
    734814  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     
    739819    }
    740820  }
     821#endif
    741822#endif
    742823}
     
    810891      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
    811892      TComReferencePictureSet* rps = pcSlice->getRPS();
     893     
     894#if FIX1071
     895      // Deal with bitstream restriction stating that:
     896      // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     897      // Ideally this process should not be repeated for each slice in a picture
     898      TComReferencePictureSet altRps;
     899      Bool useAltRps = false;
     900#if SVC_EXTENSION
     901      if( pcSlice->getLayerId() == 0 )
     902#endif
     903      if (pcSlice->getRapPicFlag())
     904      {
     905        for (Int picIdx = 0; !useAltRps && picIdx < rps->getNumberOfPictures(); picIdx++)
     906        {
     907          useAltRps = rps->getUsed(picIdx);
     908        }
     909        if (useAltRps)
     910        {
     911          memcpy(&altRps, rps, sizeof(TComReferencePictureSet));
     912          rps = &altRps;
     913          for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
     914          {
     915            rps->setUsed(picIdx, false);
     916          }
     917        }
     918      }
     919
     920      if(pcSlice->getRPSidx() < 0 || useAltRps)
     921#else
    812922      if(pcSlice->getRPSidx() < 0)
     923#endif
    813924      {
    814925        WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
     
    9021013        }
    9031014      }
     1015
    9041016      if (pcSlice->getSPS()->getTMVPFlagsPresent())
    9051017      {
     
    9071019      }
    9081020    }
     1021
     1022#if JCTVC_M0458_INTERLAYER_RPS_SIG   
     1023    if((pcSlice->getSPS()->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) )
     1024    {
     1025      WRITE_FLAG(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_enabled_flag");
     1026      if( pcSlice->getInterLayerPredEnabledFlag())
     1027      {
     1028        if(pcSlice->getNumILRRefIdx() > 1)
     1029        {
     1030          Int numBits = 1;
     1031          while ((1 << numBits) < pcSlice->getNumILRRefIdx())
     1032          {
     1033            numBits++;
     1034          }
     1035          if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag())
     1036          {
     1037            WRITE_CODE(pcSlice->getNumInterLayerRefPics(), numBits,"num_inter_layer_ref_pics_minus1");
     1038          }       
     1039          for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     1040            WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]");   
     1041        }
     1042      }
     1043    }     
     1044#endif
     1045
    9091046    if(pcSlice->getSPS()->getUseSAO())
    9101047    {
     
    10651202    }
    10661203  }
     1204
    10671205  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
    10681206  {
     
    13891527// ====================================================================================================================
    13901528
    1391 
    1392 /** Write PCM alignment bits.
    1393  * \returns Void
    1394  */
    1395 Void  TEncCavlc::xWritePCMAlignZero    ()
    1396 {
    1397   m_pcBitIf->writeAlignZero();
    1398 }
    1399 
    1400 Void TEncCavlc::xWriteUnaryMaxSymbol( UInt uiSymbol, UInt uiMaxSymbol )
    1401 {
    1402   if (uiMaxSymbol == 0)
    1403   {
    1404     return;
    1405   }
    1406   xWriteFlag( uiSymbol ? 1 : 0 );
    1407   if ( uiSymbol == 0 )
    1408   {
    1409     return;
    1410   }
    1411  
    1412   Bool bCodeLast = ( uiMaxSymbol > uiSymbol );
    1413  
    1414   while( --uiSymbol )
    1415   {
    1416     xWriteFlag( 1 );
    1417   }
    1418   if( bCodeLast )
    1419   {
    1420     xWriteFlag( 0 );
    1421   }
    1422   return;
    1423 }
    1424 
    1425 Void TEncCavlc::xWriteExGolombLevel( UInt uiSymbol )
    1426 {
    1427   if( uiSymbol )
    1428   {
    1429     xWriteFlag( 1 );
    1430     UInt uiCount = 0;
    1431     Bool bNoExGo = (uiSymbol < 13);
    1432    
    1433     while( --uiSymbol && ++uiCount < 13 )
    1434     {
    1435       xWriteFlag( 1 );
    1436     }
    1437     if( bNoExGo )
    1438     {
    1439       xWriteFlag( 0 );
    1440     }
    1441     else
    1442     {
    1443       xWriteEpExGolomb( uiSymbol, 0 );
    1444     }
    1445   }
    1446   else
    1447   {
    1448     xWriteFlag( 0 );
    1449   }
    1450   return;
    1451 }
    1452 
    1453 Void TEncCavlc::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount )
    1454 {
    1455   while( uiSymbol >= (UInt)(1<<uiCount) )
    1456   {
    1457     xWriteFlag( 1 );
    1458     uiSymbol -= 1<<uiCount;
    1459     uiCount  ++;
    1460   }
    1461   xWriteFlag( 0 );
    1462   while( uiCount-- )
    1463   {
    1464     xWriteFlag( (uiSymbol>>uiCount) & 1 );
    1465   }
    1466   return;
    1467 }
    1468 
    14691529/** code explicit wp tables
    14701530 * \param TComSlice* pcSlice
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r125 r189  
    6868  TComSlice*    m_pcSlice;
    6969  UInt          m_uiCoeffCost;
    70 
    71   Void  xWritePCMAlignZero    ();
    72   Void  xWriteEpExGolomb      ( UInt uiSymbol, UInt uiCount );
    73   Void  xWriteExGolombLevel    ( UInt uiSymbol );
    74   Void  xWriteUnaryMaxSymbol  ( UInt uiSymbol, UInt uiMaxSymbol );
    7570
    7671  Void codeShortTermRefPicSet              ( TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Bool calledFromSliceHeader, Int idx );
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r125 r189  
    158158  Int       m_loopFilterTcOffsetDiv2;
    159159  Bool      m_DeblockingFilterControlPresent;
     160#if L0386_DB_METRIC
     161  Bool      m_DeblockingFilterMetric;
     162#endif
    160163  Bool      m_bUseSAO;
    161164  Int       m_maxNumOffsetsPerPic;
     
    188191  Bool      m_bUseASR;
    189192  Bool      m_bUseHADME;
     193#if !L0034_COMBINED_LIST_CLEANUP
    190194  Bool      m_bUseLComb;
     195#endif
    191196  Bool      m_useRDOQ;
    192197  Bool      m_useRDOQTS;
     
    234239  Int       m_pictureTimingSEIEnabled;
    235240  Int       m_recoveryPointSEIEnabled;
     241#if J0149_TONE_MAPPING_SEI
     242  Bool      m_toneMappingInfoSEIEnabled;
     243  Int       m_toneMapId;
     244  Bool      m_toneMapCancelFlag;
     245  Bool      m_toneMapPersistenceFlag;
     246  Int       m_codedDataBitDepth;
     247  Int       m_targetBitDepth;
     248  Int       m_modelId;
     249  Int       m_minValue;
     250  Int       m_maxValue;
     251  Int       m_sigmoidMidpoint;
     252  Int       m_sigmoidWidth;
     253  Int       m_numPivots;
     254  Int       m_cameraIsoSpeedIdc;
     255  Int       m_cameraIsoSpeedValue;
     256  Int       m_exposureCompensationValueSignFlag;
     257  Int       m_exposureCompensationValueNumerator;
     258  Int       m_exposureCompensationValueDenomIdc;
     259  Int       m_refScreenLuminanceWhite;
     260  Int       m_extendedRangeWhiteLevel;
     261  Int       m_nominalBlackLevelLumaCodeValue;
     262  Int       m_nominalWhiteLevelLumaCodeValue;
     263  Int       m_extendedWhiteLevelLumaCodeValue;
     264  Int*      m_startOfCodedInterval;
     265  Int*      m_codedPivotValue;
     266  Int*      m_targetPivotValue;
     267#endif
    236268  Int       m_framePackingSEIEnabled;
    237269  Int       m_framePackingSEIType;
     
    243275  Int       m_gradualDecodingRefreshInfoEnabled;
    244276  Int       m_decodingUnitInfoSEIEnabled;
     277#if L0208_SOP_DESCRIPTION_SEI
     278  Int       m_SOPDescriptionSEIEnabled;
     279#endif
     280#if K0180_SCALABLE_NESTING_SEI
     281  Int       m_scalableNestingSEIEnabled;
     282#endif
    245283  //====== Weighted Prediction ========
    246284  Bool      m_useWeightedPred;       //< Use of Weighting Prediction (P_SLICE)
     
    379417  Void      setLoopFilterTcOffset           ( Int   i )      { m_loopFilterTcOffsetDiv2    = i; }
    380418  Void      setDeblockingFilterControlPresent ( Bool b ) { m_DeblockingFilterControlPresent = b; }
     419#if L0386_DB_METRIC
     420  Void      setDeblockingFilterMetric       ( Bool  b )      { m_DeblockingFilterMetric = b; }
     421#endif
    381422
    382423  //====== Motion search ========
     
    433474  Int       getLoopFilterTcOffset           ()      { return m_loopFilterTcOffsetDiv2; }
    434475  Bool      getDeblockingFilterControlPresent()  { return  m_DeblockingFilterControlPresent; }
     476#if L0386_DB_METRIC
     477  Bool      getDeblockingFilterMetric       ()      { return m_DeblockingFilterMetric; }
     478#endif
    435479
    436480  //==== Motion search ========
     
    450494  Void      setUseASR                       ( Bool  b )     { m_bUseASR     = b; }
    451495  Void      setUseHADME                     ( Bool  b )     { m_bUseHADME   = b; }
     496#if !L0034_COMBINED_LIST_CLEANUP
    452497  Void      setUseLComb                     ( Bool  b )     { m_bUseLComb   = b; }
     498#endif
    453499  Void      setUseRDOQ                      ( Bool  b )     { m_useRDOQ    = b; }
    454500  Void      setUseRDOQTS                    ( Bool  b )     { m_useRDOQTS  = b; }
     
    472518  Bool      getUseASR                       ()      { return m_bUseASR;     }
    473519  Bool      getUseHADME                     ()      { return m_bUseHADME;   }
     520#if !L0034_COMBINED_LIST_CLEANUP
    474521  Bool      getUseLComb                     ()      { return m_bUseLComb;   }
     522#endif
    475523  Bool      getUseRDOQ                      ()      { return m_useRDOQ;    }
    476524  Bool      getUseRDOQTS                    ()      { return m_useRDOQTS;  }
     
    569617  Void  setRecoveryPointSEIEnabled(Int b)                { m_recoveryPointSEIEnabled = b; }
    570618  Int   getRecoveryPointSEIEnabled()                     { return m_recoveryPointSEIEnabled; }
     619#if J0149_TONE_MAPPING_SEI
     620  Void  setToneMappingInfoSEIEnabled(Bool b)                 {  m_toneMappingInfoSEIEnabled = b;  }
     621  Bool  getToneMappingInfoSEIEnabled()                       {  return m_toneMappingInfoSEIEnabled;  }
     622  Void  setTMISEIToneMapId(Int b)                            {  m_toneMapId = b;  }
     623  Int   getTMISEIToneMapId()                                 {  return m_toneMapId;  }
     624  Void  setTMISEIToneMapCancelFlag(Bool b)                   {  m_toneMapCancelFlag=b;  }
     625  Bool  getTMISEIToneMapCancelFlag()                         {  return m_toneMapCancelFlag;  }
     626  Void  setTMISEIToneMapPersistenceFlag(Bool b)              {  m_toneMapPersistenceFlag = b;  }
     627  Bool   getTMISEIToneMapPersistenceFlag()                   {  return m_toneMapPersistenceFlag;  }
     628  Void  setTMISEICodedDataBitDepth(Int b)                    {  m_codedDataBitDepth = b;  }
     629  Int   getTMISEICodedDataBitDepth()                         {  return m_codedDataBitDepth;  }
     630  Void  setTMISEITargetBitDepth(Int b)                       {  m_targetBitDepth = b;  }
     631  Int   getTMISEITargetBitDepth()                            {  return m_targetBitDepth;  }
     632  Void  setTMISEIModelID(Int b)                              {  m_modelId = b;  }
     633  Int   getTMISEIModelID()                                   {  return m_modelId;  }
     634  Void  setTMISEIMinValue(Int b)                             {  m_minValue = b;  }
     635  Int   getTMISEIMinValue()                                  {  return m_minValue;  }
     636  Void  setTMISEIMaxValue(Int b)                             {  m_maxValue = b;  }
     637  Int   getTMISEIMaxValue()                                  {  return m_maxValue;  }
     638  Void  setTMISEISigmoidMidpoint(Int b)                      {  m_sigmoidMidpoint = b;  }
     639  Int   getTMISEISigmoidMidpoint()                           {  return m_sigmoidMidpoint;  }
     640  Void  setTMISEISigmoidWidth(Int b)                         {  m_sigmoidWidth = b;  }
     641  Int   getTMISEISigmoidWidth()                              {  return m_sigmoidWidth;  }
     642  Void  setTMISEIStartOfCodedInterva( Int*  p )              {  m_startOfCodedInterval = p;  }
     643  Int*  getTMISEIStartOfCodedInterva()                       {  return m_startOfCodedInterval;  }
     644  Void  setTMISEINumPivots(Int b)                            {  m_numPivots = b;  }
     645  Int   getTMISEINumPivots()                                 {  return m_numPivots;  }
     646  Void  setTMISEICodedPivotValue( Int*  p )                  {  m_codedPivotValue = p;  }
     647  Int*  getTMISEICodedPivotValue()                           {  return m_codedPivotValue;  }
     648  Void  setTMISEITargetPivotValue( Int*  p )                 {  m_targetPivotValue = p;  }
     649  Int*  getTMISEITargetPivotValue()                          {  return m_targetPivotValue;  }
     650  Void  setTMISEICameraIsoSpeedIdc(Int b)                    {  m_cameraIsoSpeedIdc = b;  }
     651  Int   getTMISEICameraIsoSpeedIdc()                         {  return m_cameraIsoSpeedIdc;  }
     652  Void  setTMISEICameraIsoSpeedValue(Int b)                  {  m_cameraIsoSpeedValue = b;  }
     653  Int   getTMISEICameraIsoSpeedValue()                       {  return m_cameraIsoSpeedValue;  }
     654  Void  setTMISEIExposureCompensationValueSignFlag(Int b)    {  m_exposureCompensationValueSignFlag = b;  }
     655  Int   getTMISEIExposureCompensationValueSignFlag()         {  return m_exposureCompensationValueSignFlag;  }
     656  Void  setTMISEIExposureCompensationValueNumerator(Int b)   {  m_exposureCompensationValueNumerator = b;  }
     657  Int   getTMISEIExposureCompensationValueNumerator()        {  return m_exposureCompensationValueNumerator;  }
     658  Void  setTMISEIExposureCompensationValueDenomIdc(Int b)    {  m_exposureCompensationValueDenomIdc =b;  }
     659  Int   getTMISEIExposureCompensationValueDenomIdc()         {  return m_exposureCompensationValueDenomIdc;  }
     660  Void  setTMISEIRefScreenLuminanceWhite(Int b)              {  m_refScreenLuminanceWhite = b;  }
     661  Int   getTMISEIRefScreenLuminanceWhite()                   {  return m_refScreenLuminanceWhite;  }
     662  Void  setTMISEIExtendedRangeWhiteLevel(Int b)              {  m_extendedRangeWhiteLevel = b;  }
     663  Int   getTMISEIExtendedRangeWhiteLevel()                   {  return m_extendedRangeWhiteLevel;  }
     664  Void  setTMISEINominalBlackLevelLumaCodeValue(Int b)       {  m_nominalBlackLevelLumaCodeValue = b;  }
     665  Int   getTMISEINominalBlackLevelLumaCodeValue()            {  return m_nominalBlackLevelLumaCodeValue;  }
     666  Void  setTMISEINominalWhiteLevelLumaCodeValue(Int b)       {  m_nominalWhiteLevelLumaCodeValue = b;  }
     667  Int   getTMISEINominalWhiteLevelLumaCodeValue()            {  return m_nominalWhiteLevelLumaCodeValue;  }
     668  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
     669  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
     670#endif
    571671  Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
    572672  Int   getFramePackingArrangementSEIEnabled()           { return m_framePackingSEIEnabled; }
     
    587687  Void  setDecodingUnitInfoSEIEnabled(Int b)                { m_decodingUnitInfoSEIEnabled = b;    }
    588688  Int   getDecodingUnitInfoSEIEnabled()                     { return m_decodingUnitInfoSEIEnabled; }
     689#if L0208_SOP_DESCRIPTION_SEI
     690  Void  setSOPDescriptionSEIEnabled(Int b)                { m_SOPDescriptionSEIEnabled = b; }
     691  Int   getSOPDescriptionSEIEnabled()                     { return m_SOPDescriptionSEIEnabled; }
     692#endif
     693#if K0180_SCALABLE_NESTING_SEI
     694  Void  setScalableNestingSEIEnabled(Int b)                { m_scalableNestingSEIEnabled = b; }
     695  Int   getScalableNestingSEIEnabled()                     { return m_scalableNestingSEIEnabled; }
     696#endif
    589697  Void      setUseWP               ( Bool b )    { m_useWeightedPred   = b;    }
    590698  Void      setWPBiPred            ( Bool b )    { m_useWeightedBiPred = b;    }
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r125 r189  
    9696#if L0045_NON_NESTED_SEI_RESTRICTIONS
    9797  xResetNonNestedSEIPresentFlags();
     98#if K0180_SCALABLE_NESTING_SEI
     99  xResetNestedSEIPresentFlags();
     100#endif
    98101#endif
    99102#if SVC_UPSAMPLING
     
    134137  m_pcSliceEncoder       = pcTEncTop->getSliceEncoder();
    135138  m_pcListPic            = pcTEncTop->getListPic(); 
     139 
    136140  m_pcEntropyCoder       = pcTEncTop->getEntropyCoder();
    137141  m_pcCavlcCoder         = pcTEncTop->getCavlcCoder();
     
    210214}
    211215
     216#if J0149_TONE_MAPPING_SEI
     217SEIToneMappingInfo*  TEncGOP::xCreateSEIToneMappingInfo()
     218{
     219  SEIToneMappingInfo *seiToneMappingInfo = new SEIToneMappingInfo();
     220  seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();
     221  seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();
     222  seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag();
     223
     224  seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth();
     225  assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);
     226  seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();
     227  assert( (seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17) || (seiToneMappingInfo->m_targetBitDepth  == 255) );
     228  seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();
     229  assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);
     230
     231  switch( seiToneMappingInfo->m_modelId)
     232  {
     233  case 0:
     234    {
     235      seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue();
     236      seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue();
     237      break;
     238    }
     239  case 1:
     240    {
     241      seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint();
     242      seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth();
     243      break;
     244    }
     245  case 2:
     246    {
     247      UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth);
     248      seiToneMappingInfo->m_startOfCodedInterval.resize(num);
     249      Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva();
     250      if(ptmp)
     251      {
     252        for(int i=0; i<num;i++)
     253        {
     254          seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i];
     255        }
     256      }
     257      break;
     258    }
     259  case 3:
     260    {
     261      seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots();
     262      seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots);
     263      seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots);
     264      Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue();
     265      Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue();
     266      if(ptmpcoded&&ptmptarget)
     267      {
     268        for(int i=0; i<(seiToneMappingInfo->m_numPivots);i++)
     269        {
     270          seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i];
     271          seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i];
     272         }
     273       }
     274       break;
     275     }
     276  case 4:
     277     {
     278       seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc();
     279       seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
     280       assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
     281       seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
     282       seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
     283       seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc();
     284       seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite();
     285       seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel();
     286       assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );
     287       seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue();
     288       seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue();
     289       assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );
     290       seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue();
     291       assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );
     292       break;
     293    }
     294  default:
     295    {
     296      assert(!"Undefined SEIToneMapModelId");
     297      break;
     298    }
     299  }
     300  return seiToneMappingInfo;
     301}
     302#endif
    212303Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    213304{
    214   OutputNALUnit nalu(NAL_UNIT_SEI);
     305  OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    215306
    216307  if(m_pcCfg->getActiveParameterSetsSEIEnabled())
     
    233324    SEIFramePacking *sei = xCreateSEIFramePacking ();
    234325
    235     nalu = NALUnit(NAL_UNIT_SEI);
     326    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    236327    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    237328    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     
    244335    SEIDisplayOrientation *sei = xCreateSEIDisplayOrientation();
    245336
    246     nalu = NALUnit(NAL_UNIT_SEI);
     337    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    247338    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    248339    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     
    251342    delete sei;
    252343  }
     344#if J0149_TONE_MAPPING_SEI
     345  if(m_pcCfg->getToneMappingInfoSEIEnabled())
     346  {
     347    SEIToneMappingInfo *sei = xCreateSEIToneMappingInfo ();
     348     
     349    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     350    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     351    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     352    writeRBSPTrailingBits(nalu.m_Bitstream);
     353    accessUnit.push_back(new NALUnitEBSP(nalu));
     354    delete sei;
     355  }
     356#endif
    253357}
    254358
     
    276380  m_iNumPicCoded = 0;
    277381  SEIPictureTiming pictureTimingSEI;
     382#if L0208_SOP_DESCRIPTION_SEI
     383  Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled();
     384#endif
     385#if K0180_SCALABLE_NESTING_SEI
     386  // Initialize Scalable Nesting SEI with single layer values
     387  SEIScalableNesting scalableNestingSEI;
     388  scalableNestingSEI.m_bitStreamSubsetFlag           = 1;      // If the nested SEI messages are picture buffereing SEI mesages, picure timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1
     389  scalableNestingSEI.m_nestingOpFlag                 = 0;
     390  scalableNestingSEI.m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
     391  scalableNestingSEI.m_allLayersFlag                 = 0;
     392  scalableNestingSEI.m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
     393  scalableNestingSEI.m_nestingNumLayersMinus1        = 1 - 1;  //nesting_num_layers_minus1
     394  scalableNestingSEI.m_nestingLayerId[0]             = 0;
     395  scalableNestingSEI.m_callerOwnsSEIs                = true;
     396#endif
    278397#if L0044_DU_DPB_OUTPUT_DELAY_HRD
    279398  Int picSptDpbOutputDuDelay = 0;
     
    348467    }
    349468
    350     if( getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     469    if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    351470    {
    352471      m_iLastIDR = pocCurr;
     
    364483#if SVC_EXTENSION
    365484    pcPic->setLayerId( m_layerId );
    366 #endif
    367 
     485    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS() );
     486#else
    368487    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
     488#endif
    369489    pcSlice->setLastIDR(m_iLastIDR);
    370490    pcSlice->setSliceIdx(0);
     
    411531    }
    412532    // Set the nal unit type
    413     pcSlice->setNalUnitType(getNalUnitType(pocCurr));
     533    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
    414534#if IDR_ALIGNMENT
    415535    if (m_layerId > 0)
    416536    {
     537#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     538      TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(m_layerId)->getListPic();
     539#else
    417540      TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();
     541#endif
    418542      pcSlice->setBaseColPic (*cListPic, m_layerId );
    419543    }
     
    424548    {
    425549#if IDR_ALIGNMENT
    426       if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR )
    427       {
    428         pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_IDR);
     550      if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     551      {
     552        pcSlice->setNalUnitType(pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType());
    429553      }
    430554      else
     
    432556      pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
    433557    }
     558#if ZERO_NUM_DIRECT_LAYERS
     559    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     560    {
     561      pcSlice->setSliceType(I_SLICE);
     562    }
     563    else
     564#endif
    434565    if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() )
    435566    {
    436       if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     567      if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    437568          (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
    438569           pcSlice->getSliceType() == B_SLICE )
     
    442573    }
    443574#endif
    444     if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    445     {
    446       if(pcSlice->getTemporalLayerNonReferenceFlag())
     575    if(pcSlice->getTemporalLayerNonReferenceFlag())
     576    {
     577      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    447578      {
    448579        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N);
     580    }
     581      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RADL_R)
     582      {
     583        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RADL_N);
     584      }
     585      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RASL_R)
     586      {
     587        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RASL_N);
    449588      }
    450589    }
     
    471610        else
    472611        {
    473           pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA);
     612          pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R);
    474613        }
    475614      }
     
    524663    pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
    525664
    526 #if REF_LIST_BUGFIX
     665#if REF_IDX_FRAMEWORK
     666#if ZERO_NUM_DIRECT_LAYERS
     667    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     668#else
    527669    if(m_layerId > 0)
    528     {
    529       if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     670#endif
     671    {
     672#if JCTVC_M0458_INTERLAYER_RPS_SIG
     673      if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     674      {
     675        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getActiveNumILRRefIdx());
     676        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getActiveNumILRRefIdx());
     677      }
     678      else
     679      {
     680        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getActiveNumILRRefIdx());
     681        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx());
     682      }
     683#else
     684      if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    530685      {
    531686        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumILRRefIdx());
     
    537692        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getNumILRRefIdx());
    538693      }
     694#endif
    539695    }
    540696#endif
     
    545701
    546702#if SVC_EXTENSION     
     703#if ZERO_NUM_DIRECT_LAYERS
     704    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     705#else
    547706    if(m_layerId > 0)
     707#endif
    548708    {
    549709#if !IDR_ALIGNMENT
     
    553713#if SVC_UPSAMPLING
    554714      if ( pcPic->isSpatialEnhLayer())
    555       {   
     715      {
     716#if SCALED_REF_LAYER_OFFSETS
     717        m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     718#else
    556719        m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     720#endif
    557721      }
    558722      else
     
    573737
    574738    //  Set reference list
    575 #if REF_LIST_BUGFIX
     739#if REF_IDX_FRAMEWORK
     740#if ZERO_NUM_DIRECT_LAYERS
     741    if(m_layerId ==  0 || ( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 ) )
     742#else
    576743    if(m_layerId ==  0)
     744#endif
    577745    {
    578746      pcSlice->setRefPicList( rcListPic);
     
    582750#endif
    583751#if REF_IDX_FRAMEWORK
     752#if ZERO_NUM_DIRECT_LAYERS
     753    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     754#else
    584755    if(m_layerId > 0)
     756#endif
    585757    {
    586758      m_pcEncTop->setILRPic(pcPic);
     
    592764      }
    593765#endif
    594 #if REF_LIST_BUGFIX
    595766      pcSlice->setRefPicListModificationSvc();
    596       pcSlice->setRefPicListSvc( rcListPic, m_pcEncTop->getIlpList() );
    597 #else
    598       pcSlice->addRefPicList ( m_pcEncTop->getIlpList(), 1);
    599 #endif
     767      pcSlice->setRefPicList( rcListPic, false, m_pcEncTop->getIlpList());
    600768
    601769#if REF_IDX_MFM
     
    607775        for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
    608776        {
    609           if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR() )
     777          if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId) )
    610778          {
    611779            ColRefIdx = colIdx;
     
    620788          for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
    621789          {
    622             if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR() )
     790            if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId) )
    623791            {
    624792              ColRefIdx = colIdx;
     
    644812      pcSlice->setSliceType ( P_SLICE );
    645813    }
    646 
     814#if !L0034_COMBINED_LIST_CLEANUP
    647815    if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb())
    648816    {
     
    656824      pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0));
    657825    }
     826#endif
    658827
    659828    if (pcSlice->getSliceType() == B_SLICE)
     
    683852      pcSlice->setCheckLDC(bLowDelay); 
    684853    }
     854    else
     855    {
     856      pcSlice->setCheckLDC(true); 
     857    }
    685858
    686859    uiColDir = 1-uiColDir;
     
    689862    pcSlice->setRefPOCList();
    690863
     864#if L0034_COMBINED_LIST_CLEANUP
     865    pcSlice->setList1IdxToList0Idx();
     866#else
    691867    pcSlice->setNoBackPredFlag( false );
    692868    if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())
     
    712888    }
    713889    pcSlice->generateCombinedList();
     890#endif
    714891
    715892    if (m_pcEncTop->getTMVPModeId() == 2)
     
    8311008    UInt uiNumSlices = 1;
    8321009
     1010#if SIMPLIFIED_MV_POS_SCALING
     1011    if (m_layerId > 0)
     1012    {
     1013#if SCALED_REF_LAYER_OFFSETS
     1014      const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow();
     1015
     1016      Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
     1017      Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
     1018
     1019      Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     1020      Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     1021#else
     1022      const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
     1023      const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     1024
     1025      Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     1026      Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     1027
     1028      Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     1029      Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     1030#endif
     1031      g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     1032      g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     1033
     1034      g_posScalingFactor[m_layerId][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
     1035      g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
     1036    }
     1037#endif
     1038
    8331039    UInt uiInternalAddress = pcPic->getNumPartInCU()-4;
    8341040    UInt uiExternalAddress = pcPic->getPicSym()->getNumberOfCUsInFrame()-1;
     
    9491155    startCUAddrSliceSegmentIdx++;
    9501156#if AVC_BASE
    951     if( m_layerId == 0 )
     1157    if( m_layerId == 0 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() )
    9521158    {
    9531159      pcPic->getPicYuvOrg()->copyToPic( pcPic->getPicYuvRec() );
     
    10271233    Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
    10281234    m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
     1235#if L0386_DB_METRIC
     1236    if ( m_pcCfg->getDeblockingFilterMetric() )
     1237    {
     1238      dblMetric(pcPic, uiNumSlices);
     1239    }
     1240#endif
    10291241    m_pcLoopFilter->loopFilterPic( pcPic );
    10301242
     
    10591271      OutputNALUnit nalu(NAL_UNIT_VPS, 0, m_layerId);
    10601272#if AVC_BASE
    1061       if( m_layerId == 1 )
     1273      if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) )
    10621274#else
    10631275      if( m_layerId == 0 )
     
    11331345    }
    11341346
     1347#if L0208_SOP_DESCRIPTION_SEI
     1348    if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
     1349    {
     1350      Int SOPcurrPOC = pocCurr;
     1351
     1352      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     1353      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1354      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     1355
     1356      SEISOPDescription SOPDescriptionSEI;
     1357      SOPDescriptionSEI.m_sopSeqParameterSetId = pcSlice->getSPS()->getSPSId();
     1358
     1359      UInt i = 0;
     1360      UInt prevEntryId = iGOPid;
     1361      for (j = iGOPid; j < m_iGopSize; j++)
     1362      {
     1363        Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;
     1364        if ((SOPcurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())
     1365        {
     1366          SOPcurrPOC += deltaPOC;
     1367          SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR);
     1368          SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
     1369          SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j);
     1370          SOPDescriptionSEI.m_sopDescPocDelta[i] = deltaPOC;
     1371
     1372          prevEntryId = j;
     1373          i++;
     1374        }
     1375      }
     1376
     1377      SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1;
     1378
     1379      m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS());
     1380      writeRBSPTrailingBits(nalu.m_Bitstream);
     1381      accessUnit.push_back(new NALUnitEBSP(nalu));
     1382
     1383      writeSOP = false;
     1384    }
     1385#endif
     1386
    11351387    if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
    11361388        ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
     
    11781430       || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
    11791431    {
    1180       OutputNALUnit nalu(NAL_UNIT_SEI);
     1432      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    11811433      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    11821434      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    12191471      writeRBSPTrailingBits(nalu.m_Bitstream);
    12201472#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1473      {
    12211474      UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    12221475      UInt offsetPosition = m_activeParameterSetSEIPresentInAU;   // Insert BP SEI after APS SEI
     
    12281481      accessUnit.insert(it, new NALUnitEBSP(nalu));
    12291482      m_bufferingPeriodSEIPresentInAU = true;
     1483      }
    12301484#else
    12311485      accessUnit.push_back(new NALUnitEBSP(nalu));
     1486#endif
     1487
     1488#if K0180_SCALABLE_NESTING_SEI
     1489      if (m_pcCfg->getScalableNestingSEIEnabled())
     1490      {
     1491        OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI);
     1492        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1493        m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream);
     1494        scalableNestingSEI.m_nestedSEIs.clear();
     1495        scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period);
     1496        m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     1497        writeRBSPTrailingBits(naluTmp.m_Bitstream);
     1498#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1499        UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     1500        UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU;   // Insert BP SEI after non-nested APS, BP and PT SEIs
     1501        AccessUnit::iterator it;
     1502        for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     1503        {
     1504          it++;
     1505        }
     1506        accessUnit.insert(it, new NALUnitEBSP(naluTmp));
     1507        m_nestedBufferingPeriodSEIPresentInAU = true;
     1508#else
     1509        accessUnit.push_back(new NALUnitEBSP(naluTmp));
     1510#endif
     1511      }
    12321512#endif
    12331513
     
    12411521      {
    12421522        // Gradual decoding refresh SEI
    1243         OutputNALUnit nalu(NAL_UNIT_SEI);
     1523        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    12441524        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    12451525        m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    12531533      }
    12541534    // Recovery point SEI
    1255       OutputNALUnit nalu(NAL_UNIT_SEI);
     1535      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    12561536      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    12571537      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    14441724
    14451725          pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength );
    1446           if (!sliceSegment)
    1447           {
    14481726            pcSlice->setTileLocationCount ( 0 );
    1449             m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info.
    1450           }
    1451           else
    1452           {
    1453             m_pcSliceEncoder->encodeSlice(pcPic, &nalu.m_Bitstream, pcSubstreamsOut); // nalu.m_Bitstream is only used for CAVLC tile position info.
    1454           }
     1727          m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut);
    14551728
    14561729          {
     
    14841757              if (ui+1 < pcSlice->getPPS()->getNumSubstreams())
    14851758              {
    1486                 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits();
     1759                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
    14871760              }
    14881761            }
     
    15161789          // If current NALU is the last NALU of slice and a NALU was buffered, then (a) Write current NALU (b) Update an write buffered NALU at approproate location in NALU list.
    15171790          Bool bNALUAlignedWrittenToList    = false; // used to ensure current NALU is not written more than once to the NALU list.
    1518           xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);
     1791          xAttachSliceDataToNalUnit(nalu, pcBitstreamRedirect);
    15191792          accessUnit.push_back(new NALUnitEBSP(nalu));
    15201793#if RATE_CONTROL_LAMBDA_DOMAIN
     
    15441817            {
    15451818              UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size());
    1546               if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     1819              if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    15471820              {
    15481821                numRBSPBytes += numRBSPBytes_nal;
     
    16401913        }
    16411914#if SVC_EXTENSION
    1642         OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer(), m_layerId);
    1643 #else
    1644         OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer());
     1915        OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer(), m_layerId);
     1916#else
     1917        OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer());
    16451918#endif
    16461919
     
    16671940        sei_temporal_level0_index.rapIdx = m_rapIdx;
    16681941
    1669         OutputNALUnit nalu(NAL_UNIT_SEI);
     1942        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    16701943
    16711944        /* write the SEI messages */
     
    18072080        if( m_pcCfg->getPictureTimingSEIEnabled() )
    18082081        {
    1809           OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
     2082          {
     2083            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    18102084          m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    18112085          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
     
    18272101#endif
    18282102        }
     2103#if K0180_SCALABLE_NESTING_SEI
     2104          if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI
     2105          {
     2106            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
     2107            m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2108            scalableNestingSEI.m_nestedSEIs.clear();
     2109            scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI);
     2110            m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     2111            writeRBSPTrailingBits(nalu.m_Bitstream);
     2112#if L0045_NON_NESTED_SEI_RESTRICTIONS
     2113            UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     2114            UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     2115              + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU + m_nestedBufferingPeriodSEIPresentInAU;    // Insert PT SEI after APS and BP SEI
     2116            AccessUnit::iterator it;
     2117            for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     2118            {
     2119              it++;
     2120            }
     2121            accessUnit.insert(it, new NALUnitEBSP(nalu));
     2122            m_nestedPictureTimingSEIPresentInAU = true;
     2123#else
     2124            AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
     2125            accessUnit.insert(it, new NALUnitEBSP(nalu));
     2126#endif
     2127          }
     2128#endif
     2129
     2130        }
    18292131        if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
    18302132        {             
     
    18322134          for( Int i = 0; i < ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 ); i ++ )
    18332135          {
    1834             OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
     2136            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    18352137
    18362138            SEIDecodingUnitInfo tempSEI;
     
    18802182                  break;
    18812183                }
    1882                 if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     2184                if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    18832185                {
    18842186                  ctr++;
     
    18912193#if L0045_NON_NESTED_SEI_RESTRICTIONS
    18922194      xResetNonNestedSEIPresentFlags();
     2195#if K0180_SCALABLE_NESTING_SEI
     2196      xResetNestedSEIPresentFlags();
     2197#endif
    18932198#endif
    18942199      pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut);
     
    21132418    case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";
    21142419    case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";
    2115     case NAL_UNIT_CODED_SLICE_TLA: return "TLA";
     2420    case NAL_UNIT_CODED_SLICE_TLA_R:      return "TLA_R";
    21162421    case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";
    21172422    case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";
    21182423    case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N";
    2119     case NAL_UNIT_CODED_SLICE_BLA: return "BLA";
    2120     case NAL_UNIT_CODED_SLICE_BLANT: return "BLANT";
     2424    case NAL_UNIT_CODED_SLICE_BLA_W_LP:   return "BLA_W_LP";
     2425    case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL";
    21212426    case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";
    2122     case NAL_UNIT_CODED_SLICE_IDR: return "IDR";
     2427    case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL";
    21232428    case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";
    21242429    case NAL_UNIT_CODED_SLICE_CRA: return "CRA";
    2125     case NAL_UNIT_CODED_SLICE_DLP: return "DLP";
    2126     case NAL_UNIT_CODED_SLICE_TFD: return "TFD";
     2430    case NAL_UNIT_CODED_SLICE_RADL_R:     return "RADL_R";
     2431    case NAL_UNIT_CODED_SLICE_RASL_R:     return "RASL_R";
    21272432    case NAL_UNIT_VPS: return "VPS";
    21282433    case NAL_UNIT_SPS: return "SPS";
     
    21322437    case NAL_UNIT_EOB: return "EOB";
    21332438    case NAL_UNIT_FILLER_DATA: return "FILLER";
    2134     case NAL_UNIT_SEI: return "SEI";
     2439    case NAL_UNIT_PREFIX_SEI:             return "SEI";
     2440    case NAL_UNIT_SUFFIX_SEI:             return "SEI";
    21352441    default: return "UNK";
    21362442  }
     
    22232529    printf("*** %6s numBytesInNALunit: %u\n", nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal);
    22242530#endif
    2225     if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     2531    if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    22262532    {
    22272533      numRBSPBytes += numRBSPBytes_nal;
     
    23142620    for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++)
    23152621    {
     2622#if REF_IDX_FRAMEWORK && VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     2623      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR(m_layerId) )
     2624      {
     2625        printf( "%d(%d) ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     2626      }
     2627      else
     2628#endif
    23162629      printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR());
    23172630    }
     
    23252638 * This function checks the configuration and returns the appropriate nal_unit_type for the picture.
    23262639 */
    2327 NalUnitType TEncGOP::getNalUnitType(Int pocCurr)
     2640NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR)
    23282641{
    23292642  if (pocCurr == 0)
    23302643  {
    2331     return NAL_UNIT_CODED_SLICE_IDR;
     2644    return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    23322645  }
    23332646  if (pocCurr % m_pcCfg->getIntraPeriod() == 0)
     
    23392652    else if (m_pcCfg->getDecodingRefreshType() == 2)
    23402653    {
    2341       return NAL_UNIT_CODED_SLICE_IDR;
     2654      return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    23422655    }
    23432656  }
     
    23512664      // controlling the reference pictures used for encoding that leading picture. Such a leading
    23522665      // picture need not be marked as a TFD picture.
    2353       return NAL_UNIT_CODED_SLICE_TFD;
     2666      return NAL_UNIT_CODED_SLICE_RASL_R;
     2667    }
     2668  }
     2669  if (lastIDR>0)
     2670  {
     2671    if (pocCurr < lastIDR)
     2672    {
     2673      return NAL_UNIT_CODED_SLICE_RADL_R;
    23542674    }
    23552675  }
     
    24022722}
    24032723
    2404 /** Determine the difference between consecutive tile sizes (in bytes) and writes it to  bistream rNalu [slice header]
    2405  * \param rpcBitstreamRedirect contains the bitstream to be concatenated to rNalu. rpcBitstreamRedirect contains slice payload. rpcSlice contains tile location information.
    2406  * \returns Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
     2724/** Attaches the input bitstream to the stream in the output NAL unit
     2725    Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
     2726 *  \param codedSliceData contains the coded slice data (bitstream) to be concatenated to rNalu
     2727 *  \param rNalu          target NAL unit
    24072728 */
    2408 Void TEncGOP::xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice)
     2729Void TEncGOP::xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& codedSliceData)
    24092730{
    24102731  // Byte-align
     
    24122733
    24132734  // Perform bitstream concatenation
    2414   if (rpcBitstreamRedirect->getNumberOfWrittenBits() > 0)
    2415   {
    2416     UInt uiBitCount  = rpcBitstreamRedirect->getNumberOfWrittenBits();
    2417     if (rpcBitstreamRedirect->getByteStreamLength()>0)
    2418     {
    2419       UChar *pucStart  =  reinterpret_cast<UChar*>(rpcBitstreamRedirect->getByteStream());
    2420       UInt uiWriteByteCount = 0;
    2421       while (uiWriteByteCount < (uiBitCount >> 3) )
    2422       {
    2423         UInt uiBits = (*pucStart);
    2424         rNalu.m_Bitstream.write(uiBits, 8);
    2425         pucStart++;
    2426         uiWriteByteCount++;
    2427       }
    2428     }
    2429     UInt uiBitsHeld = (uiBitCount & 0x07);
    2430     for (UInt uiIdx=0; uiIdx < uiBitsHeld; uiIdx++)
    2431     {
    2432       rNalu.m_Bitstream.write((rpcBitstreamRedirect->getHeldBits() & (1 << (7-uiIdx))) >> (7-uiIdx), 1);
    2433     }         
     2735  if (codedSliceData->getNumberOfWrittenBits() > 0)
     2736    {
     2737    rNalu.m_Bitstream.addSubstream(codedSliceData);
    24342738  }
    24352739
    24362740  m_pcEntropyCoder->setBitstream(&rNalu.m_Bitstream);
    24372741
    2438   delete rpcBitstreamRedirect;
    2439   rpcBitstreamRedirect = new TComOutputBitstream;
     2742  codedSliceData->clear();
    24402743}
    24412744
     
    25622865     }               
    25632866  }
    2564   assert(it != accessUnit.end());
     2867//  assert(it != accessUnit.end());  // Triggers with some legit configurations
    25652868  return seiStartPos;
    25662869}
    25672870#endif
     2871
     2872#if L0386_DB_METRIC
     2873Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices )
     2874{
     2875  TComPicYuv* pcPicYuvRec = pcPic->getPicYuvRec();
     2876  Pel* Rec    = pcPicYuvRec->getLumaAddr( 0 );
     2877  Pel* tempRec = Rec;
     2878  Int  stride = pcPicYuvRec->getStride();
     2879  UInt log2maxTB = pcPic->getSlice(0)->getSPS()->getQuadtreeTULog2MaxSize();
     2880  UInt maxTBsize = (1<<log2maxTB);
     2881  const UInt minBlockArtSize = 8;
     2882  const UInt picWidth = pcPicYuvRec->getWidth();
     2883  const UInt picHeight = pcPicYuvRec->getHeight();
     2884  const UInt noCol = (picWidth>>log2maxTB);
     2885  const UInt noRows = (picHeight>>log2maxTB);
     2886  UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64));
     2887  UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64));
     2888  UInt colIdx = 0;
     2889  UInt rowIdx = 0;
     2890  Pel p0, p1, p2, q0, q1, q2;
     2891 
     2892  Int qp = pcPic->getSlice(0)->getSliceQp();
     2893  Int bitdepthScale = 1 << (g_bitDepthY-8);
     2894  Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale;
     2895  const Int thr2 = (beta>>2);
     2896  const Int thr1 = 2*bitdepthScale;
     2897  UInt a = 0;
     2898 
     2899  memset(colSAD, 0, noCol*sizeof(UInt64));
     2900  memset(rowSAD, 0, noRows*sizeof(UInt64));
     2901 
     2902  if (maxTBsize > minBlockArtSize)
     2903  {
     2904    // Analyze vertical artifact edges
     2905    for(Int c = maxTBsize; c < picWidth; c += maxTBsize)
     2906    {
     2907      for(Int r = 0; r < picHeight; r++)
     2908      {
     2909        p2 = Rec[c-3];
     2910        p1 = Rec[c-2];
     2911        p0 = Rec[c-1];
     2912        q0 = Rec[c];
     2913        q1 = Rec[c+1];
     2914        q2 = Rec[c+2];
     2915        a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
     2916        if ( thr1 < a && a < thr2)
     2917        {
     2918          colSAD[colIdx] += abs(p0 - q0);
     2919        }
     2920        Rec += stride;
     2921      }
     2922      colIdx++;
     2923      Rec = tempRec;
     2924    }
     2925   
     2926    // Analyze horizontal artifact edges
     2927    for(Int r = maxTBsize; r < picHeight; r += maxTBsize)
     2928    {
     2929      for(Int c = 0; c < picWidth; c++)
     2930      {
     2931        p2 = Rec[c + (r-3)*stride];
     2932        p1 = Rec[c + (r-2)*stride];
     2933        p0 = Rec[c + (r-1)*stride];
     2934        q0 = Rec[c + r*stride];
     2935        q1 = Rec[c + (r+1)*stride];
     2936        q2 = Rec[c + (r+2)*stride];
     2937        a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
     2938        if (thr1 < a && a < thr2)
     2939        {
     2940          rowSAD[rowIdx] += abs(p0 - q0);
     2941        }
     2942      }
     2943      rowIdx++;
     2944    }
     2945  }
     2946 
     2947  UInt64 colSADsum = 0;
     2948  UInt64 rowSADsum = 0;
     2949  for(Int c = 0; c < noCol-1; c++)
     2950  {
     2951    colSADsum += colSAD[c];
     2952  }
     2953  for(Int r = 0; r < noRows-1; r++)
     2954  {
     2955    rowSADsum += rowSAD[r];
     2956  }
     2957 
     2958  colSADsum <<= 10;
     2959  rowSADsum <<= 10;
     2960  colSADsum /= (noCol-1);
     2961  colSADsum /= picHeight;
     2962  rowSADsum /= (noRows-1);
     2963  rowSADsum /= picWidth;
     2964 
     2965  UInt64 avgSAD = ((colSADsum + rowSADsum)>>1);
     2966  avgSAD >>= (g_bitDepthY-8);
     2967 
     2968  if ( avgSAD > 2048 )
     2969  {
     2970    avgSAD >>= 9;
     2971    Int offset = Clip3(2,6,(Int)avgSAD);
     2972    for (Int i=0; i<uiNumSlices; i++)
     2973    {
     2974      pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(true);
     2975      pcPic->getSlice(i)->setDeblockingFilterDisable(false);
     2976      pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( offset );
     2977      pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( offset );
     2978    }
     2979  }
     2980  else
     2981  {
     2982    for (Int i=0; i<uiNumSlices; i++)
     2983    {
     2984      pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(false);
     2985      pcPic->getSlice(i)->setDeblockingFilterDisable(        pcPic->getSlice(i)->getPPS()->getPicDisableDeblockingFilterFlag() );
     2986      pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterBetaOffsetDiv2() );
     2987      pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2(   pcPic->getSlice(i)->getPPS()->getDeblockingFilterTcOffsetDiv2()   );
     2988    }
     2989  }
     2990 
     2991  free(colSAD);
     2992  free(rowSAD);
     2993}
     2994#endif
    25682995//! \}
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r125 r189  
    131131  Bool                    m_bufferingPeriodSEIPresentInAU;
    132132  Bool                    m_pictureTimingSEIPresentInAU;
     133#if K0180_SCALABLE_NESTING_SEI
     134  Bool                    m_nestedBufferingPeriodSEIPresentInAU;
     135  Bool                    m_nestedPictureTimingSEIPresentInAU;
     136#endif
    133137#endif
    134138public:
     
    149153  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
    150154#endif
    151   Void xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice);
     155  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect);
    152156
    153157 
     
    160164 
    161165  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
    162   NalUnitType getNalUnitType( Int pocCurr );
     166  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr );
    163167  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
    164168protected:
     
    178182  SEIFramePacking*        xCreateSEIFramePacking();
    179183  SEIDisplayOrientation*  xCreateSEIDisplayOrientation();
     184
     185#if J0149_TONE_MAPPING_SEI
     186  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
     187#endif
    180188
    181189  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
     
    188196    m_pictureTimingSEIPresentInAU      = false;
    189197  }
     198#if K0180_SCALABLE_NESTING_SEI
     199  Void xResetNestedSEIPresentFlags()
     200  {
     201    m_nestedBufferingPeriodSEIPresentInAU    = false;
     202    m_nestedPictureTimingSEIPresentInAU      = false;
     203  }
     204#endif
     205#endif
     206#if L0386_DB_METRIC
     207  Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
    190208#endif
    191209};// END CLASS DEFINITION TEncGOP
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r125 r189  
    16771677#endif
    16781678{
    1679 #if SAO_CHROMA_LAMBDA
    1680   m_dLambdaLuma    = dLambdaLuma;
    1681   m_dLambdaChroma  = dLambdaChroma;
    1682 #else
    1683   m_dLambdaLuma    = dLambda;
    1684   m_dLambdaChroma  = dLambda;
    1685 #endif
    1686 
    16871679  if(m_bUseNIF)
    16881680  {
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h

    r125 r189  
    5757{
    5858private:
    59   Double            m_dLambdaLuma;
    60   Double            m_dLambdaChroma;
    61 
    6259  TEncEntropy*      m_pcEntropyCoder;
    6360  TEncSbac***       m_pppcRDSbacCoder;              ///< for CABAC
  • trunk/source/Lib/TLibEncoder/TEncSbac.h

    r125 r189  
    109109  Void  xWriteEpExGolomb     ( UInt uiSymbol, UInt uiCount );
    110110  Void  xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam );
    111   Void  xWriteTerminatingBit ( UInt uiBit );
    112111 
    113112  Void  xCopyFrom            ( TEncSbac* pSrc );
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r125 r189  
    32493249    UInt          uiBitsTempL0[MAX_NUM_REF];
    32503250
     3251#if L0034_COMBINED_LIST_CLEANUP
     3252    TComMv        mvValidList1;
     3253    Int           refIdxValidList1 = 0;
     3254    UInt          bitsValidList1 = MAX_UINT;
     3255    UInt          costValidList1 = MAX_UINT;
     3256#endif
     3257
    32513258#if (ENCODER_FAST_MODE)
    32523259    Bool          testILR;
     
    32893296#if (ENCODER_FAST_MODE)
    32903297        TComPic* pcPic    = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp );
    3291         if( !testILR && pcPic->isILR() && (ePartSize == SIZE_2Nx2N) )
     3298        if( !testILR && pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )
    32923299        {
    32933300          continue;
     
    33263333        uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
    33273334#if ZERO_MVD_EST
     3335#if L0034_COMBINED_LIST_CLEANUP
     3336        if ( iRefList == 0 || pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
     3337#else
    33283338        if ((iRefList != 1 || !pcCU->getSlice()->getNoBackPredFlag()) &&
    33293339            (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) <= 0 || pcCU->getSlice()->getRefIdxOfLC(eRefPicList, iRefIdxTemp)>=0))
     3340#endif
    33303341        {
    33313342          uiZeroMvdBitsTemp = uiBitsTemp;
     
    33473358       
    33483359#if GPB_SIMPLE_UNI
     3360#if L0034_COMBINED_LIST_CLEANUP
     3361        if ( iRefList == 1 )    // list 1
     3362        {
     3363          if ( pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) >= 0 )
     3364          {
     3365            cMvTemp[1][iRefIdxTemp] = cMvTemp[0][pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
     3366            uiCostTemp = uiCostTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
     3367            /*first subtract the bit-rate part of the cost of the other list*/
     3368            uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )] );
     3369            /*correct the bit-rate part of the current ref*/
     3370            m_pcRdCost->setPredictor  ( cMvPred[iRefList][iRefIdxTemp] );
     3371            uiBitsTemp += m_pcRdCost->getBits( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() );
     3372            /*calculate the correct cost*/
     3373            uiCostTemp += m_pcRdCost->getCost( uiBitsTemp );
     3374          }
     3375          else
     3376          {
     3377            xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     3378          }
     3379        }
     3380        else
     3381        {
     3382          xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     3383        }
     3384#else
    33493385        if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0)
    33503386        {
     
    33883424          }       
    33893425        }
     3426#endif
    33903427#else
    33913428        xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     
    33943431        xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
    33953432
     3433#if L0034_COMBINED_LIST_CLEANUP
     3434        if ( iRefList == 0 )
     3435        {
     3436          uiCostTempL0[iRefIdxTemp] = uiCostTemp;
     3437          uiBitsTempL0[iRefIdxTemp] = uiBitsTemp;
     3438        }
     3439        if ( uiCostTemp < uiCost[iRefList] )
     3440        {
     3441          uiCost[iRefList] = uiCostTemp;
     3442          uiBits[iRefList] = uiBitsTemp; // storing for bi-prediction
     3443
     3444          // set motion
     3445          cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
     3446          iRefIdx[iRefList] = iRefIdxTemp;
     3447        }
     3448
     3449        if ( iRefList == 1 && uiCostTemp < costValidList1 && pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
     3450        {
     3451          costValidList1 = uiCostTemp;
     3452          bitsValidList1 = uiBitsTemp;
     3453
     3454          // set motion
     3455          mvValidList1     = cMvTemp[iRefList][iRefIdxTemp];
     3456          refIdxValidList1 = iRefIdxTemp;
     3457        }
     3458#else
    33963459        if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && !pcCU->getSlice()->getNoBackPredFlag())
    33973460        {
     
    34493512            }
    34503513          }
     3514#endif
    34513515      }
    34523516    }
     
    35163580       
    35173581        Int         iRefList    = iIter % 2;
     3582#if L0034_COMBINED_LIST_CLEANUP
     3583        if ( m_pcEncCfg->getUseFastEnc() )
     3584        {
     3585          if( uiCost[0] <= uiCost[1] )
     3586          {
     3587            iRefList = 1;
     3588          }
     3589          else
     3590          {
     3591            iRefList = 0;
     3592          }
     3593        }
     3594        else if ( iIter == 0 )
     3595        {
     3596          iRefList = 0;
     3597        }
     3598        if ( iIter == 0 && !pcCU->getSlice()->getMvdL1ZeroFlag())
     3599        {
     3600          pcCU->getCUMvField(RefPicList(1-iRefList))->setAllMv( cMv[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     3601          pcCU->getCUMvField(RefPicList(1-iRefList))->setAllRefIdx( iRefIdx[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     3602          TComYuv*  pcYuvPred = &m_acYuvPred[1-iRefList];
     3603          motionCompensation ( pcCU, pcYuvPred, RefPicList(1-iRefList), iPartIdx );
     3604        }
     3605#else
    35183606        if ( m_pcEncCfg->getUseFastEnc() && (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) )
    35193607        {
    35203608          iRefList = 1;
    35213609        }
     3610#endif
    35223611        RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    35233612
     
    35333622        Bool     testIter = true;
    35343623        TComPic* pcPic    = pcCU->getSlice()->getRefPic( RefPicList(1 - iRefList), iRefIdxBi[1 - iRefList] );
    3535         if(pcPic->isILR() && (ePartSize == SIZE_2Nx2N))
     3624        if(pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N))
    35363625        {
    35373626          testIter = false;  //the fixed part is ILR, skip this iteration       
     
    35483637          Bool testRefIdx = true;
    35493638          pcPic           = pcCU->getSlice()->getRefPic( RefPicList(iRefList) , iRefIdxTemp );
    3550           if(pcPic->isILR() && (ePartSize == SIZE_2Nx2N))
     3639          if(pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N))
    35513640          {
    35523641            testRefIdx = false;  //the refined part is ILR, skip this reference pic           
     
    36803769    UInt uiMEBits = 0;
    36813770    // Set Motion Field_
     3771#if L0034_COMBINED_LIST_CLEANUP
     3772    cMv[1] = mvValidList1;
     3773    iRefIdx[1] = refIdxValidList1;
     3774    uiBits[1] = bitsValidList1;
     3775    uiCost[1] = costValidList1;
     3776#else
    36823777    if ( pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 ) )
    36833778    {
    36843779      uiCost[1] = MAX_UINT;
    36853780    }
     3781#endif
    36863782#if AMP_MRG
    36873783    if (bTestNormalMC)
     
    42124308  //  Do integer search
    42134309#if REF_IDX_ME_ZEROMV
    4214   if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR())  //ILR reference pic
     4310  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId()))  //ILR reference pic
    42154311  {
    42164312    rcMv.setZero();  //use Mv(0, 0) for integer ME
     
    42454341  {
    42464342#if REF_IDX_ME_ZEROMV
    4247     if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR())  //ILR reference pic
     4343    if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId()))  //ILR reference pic
    42484344    {
    42494345      xPatternSearchFracDIFMv0( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi );
     
    46634759    while( pcCU->getWidth(0) > (pcCU->getSlice()->getSPS()->getMaxTrSize()<<uiTrLevel) ) uiTrLevel++;
    46644760  }
    4665   UInt uiMaxTrMode = pcCU->getSlice()->getSPS()->getMaxTrDepth() + uiTrLevel;
     4761  UInt uiMaxTrMode = 1 + uiTrLevel;
    46664762 
    46674763  while((uiWidth>>uiMaxTrMode) < (g_uiMaxCUWidth>>g_uiMaxCUDepth)) uiMaxTrMode--;
     
    62196315    for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
    62206316    {
    6221       if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR() )
     6317      if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) )
    62226318      {
    62236319        iRefIdxTemp = refIdx;
  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r125 r189  
    178178 \param pPPS          PPS associated with the slice
    179179 */
     180#if SVC_EXTENSION
     181//\param vps          VPS associated with the slice
     182Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps )
     183#else
    180184Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )
     185#endif
    181186{
    182187  Double dQP;
     
    189194  rpcSlice->setPic( pcPic );
    190195#if SVC_EXTENSION
    191   rpcSlice->initSlice( pcPic->getLayerId() );
     196  UInt layerId = pcPic->getLayerId();
     197  rpcSlice->setVPS( vps );
     198  rpcSlice->initSlice( layerId );
    192199#else
    193200  rpcSlice->initSlice();
     
    337344  }
    338345
     346#if JCTVC_M0259_LAMBDAREFINEMENT
     347  if( rpcSlice->getLayerId() > 0 && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
     348  {
     349    Int nCurLayer = rpcSlice->getLayerId();
     350    Double gamma = xCalEnhLambdaFactor( m_ppcTEncTop[nCurLayer-1]->getQP() - m_ppcTEncTop[nCurLayer]->getQP() ,
     351      1.0 * m_ppcTEncTop[nCurLayer]->getSourceWidth() * m_ppcTEncTop[nCurLayer]->getSourceHeight()
     352      / m_ppcTEncTop[nCurLayer-1]->getSourceWidth() / m_ppcTEncTop[nCurLayer-1]->getSourceHeight() );
     353    dLambda *= gamma;
     354  }
     355#endif
     356
    339357  // store lambda
    340358  m_pcRdCost ->setLambda( dLambda );
     
    354372  qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    355373  weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     374#if JCTVC_M0259_LAMBDAREFINEMENT
     375  if( rpcSlice->getLayerId() > 0 && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 )
     376  {
     377    dLambda *= 1.1;
     378    weight *= 1.15;
     379  }
     380#endif
    356381  m_pcRdCost->setCrDistortionWeight(weight);
    357382#endif
     
    400425  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    401426 
     427#if L0386_DB_METRIC
     428  if ( m_pcCfg->getDeblockingFilterMetric() )
     429  {
     430    rpcSlice->setDeblockingFilterOverrideFlag(true);
     431    rpcSlice->setDeblockingFilterDisable(false);
     432    rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
     433    rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 );
     434  } else
     435#endif
    402436  if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
    403437  {
     
    452486  rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
    453487  xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() );
     488
     489#if SVC_EXTENSION && REF_IDX_FRAMEWORK
     490  if( layerId > 0 )
     491  {
     492#if JCTVC_M0458_INTERLAYER_RPS_SIG
     493  // currently only one reference layer is supported in software and no decision logic to select yet.
     494  // hence num of active inter layer references is set to one always
     495    if( rpcSlice->getNumILRRefIdx() > 0 )
     496    {
     497      rpcSlice->setActiveNumILRRefIdx(1);
     498      rpcSlice->setInterLayerPredEnabledFlag(1);
     499    }
     500#else
     501    rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( layerId ) );
     502#endif
     503  }
     504
     505#endif
    454506}
    455507
     
    11821234 \retval rpcBitstream  bitstream class
    11831235 */
    1184 Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcBitstream, TComOutputBitstream* pcSubstreams )
     1236Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams )
    11851237{
    11861238  UInt       uiCUAddr;
     
    13621414      }
    13631415      {
    1364           UInt uiCounter = 0;
    1365           vector<uint8_t>& rbsp   = pcSubstreams[uiSubStrm].getFIFO();
    1366           for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
    1367           {
    1368             /* 1) find the next emulated 00 00 {00,01,02,03}
    1369              * 2a) if not found, write all remaining bytes out, stop.
    1370              * 2b) otherwise, write all non-emulated bytes out
    1371              * 3) insert emulation_prevention_three_byte
    1372              */
    1373             vector<uint8_t>::iterator found = it;
    1374             do
    1375             {
    1376               /* NB, end()-1, prevents finding a trailing two byte sequence */
    1377               found = search_n(found, rbsp.end()-1, 2, 0);
    1378               found++;
    1379               /* if not found, found == end, otherwise found = second zero byte */
    1380               if (found == rbsp.end())
    1381               {
    1382                 break;
    1383               }
    1384               if (*(++found) <= 3)
    1385               {
    1386                 break;
    1387               }
    1388             } while (true);
    1389             it = found;
    1390             if (found != rbsp.end())
    1391             {
    1392               it++;
    1393               uiCounter++;
    1394             }
    1395           }
    1396        
     1416        UInt numStartCodeEmulations = pcSubstreams[uiSubStrm].countStartCodeEmulations();
    13971417        UInt uiAccumulatedSubstreamLength = 0;
    13981418        for (Int iSubstrmIdx=0; iSubstrmIdx < iNumSubstreams; iSubstrmIdx++)
     
    14021422        // add bits coded in previous dependent slices + bits coded so far
    14031423        // add number of emulation prevention byte count in the tile
    1404         pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + uiCounter );
     1424        pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + numStartCodeEmulations );
    14051425      }
    14061426    }
     
    18751895}
    18761896
     1897#if JCTVC_M0259_LAMBDAREFINEMENT
     1898Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP , Double beta )
     1899{
     1900  double tmp = beta * pow( 2.0 , deltaQP / 6 );
     1901  double gamma = tmp / ( tmp + 1 );
     1902  return( gamma );
     1903}
     1904#endif
    18771905//! \}
  • trunk/source/Lib/TLibEncoder/TEncSlice.h

    r125 r189  
    116116 
    117117  /// preparation of slice encoding (reference marking, QP and lambda)
     118#if SVC_EXTENSION
     119  Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
     120                                Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps );
     121#else
    118122  Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
    119123                                Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );
     124#endif
     125
    120126#if RATE_CONTROL_LAMBDA_DOMAIN
    121127  Void    resetQP             ( TComPic* pic, Int sliceQP, Double lambda );
     
    126132  Void    precompressSlice    ( TComPic*& rpcPic                                );      ///< precompress slice for multi-loop opt.
    127133  Void    compressSlice       ( TComPic*& rpcPic                                );      ///< analysis stage of slice
    128   Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* rpcBitstream, TComOutputBitstream* pcSubstreams  );
     134  Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams  );
    129135 
    130136  // misc. functions
     
    141147private:
    142148  Double  xGetQPValueAccordingToLambda ( Double lambda );
     149
     150#if JCTVC_M0259_LAMBDAREFINEMENT
     151private:
     152  Double  xCalEnhLambdaFactor( Double deltaQP , Double beta );
     153#endif
    143154};
    144155
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r125 r189  
    294294    if(m_cIlpPic[i])
    295295    {
    296       //m_cIlpPic[i]->setPicYuvRec(NULL);
    297296      m_cIlpPic[i]->destroy();
    298297      delete m_cIlpPic[i];
     
    500499    {
    501500      TEncPic* pcEPic = new TEncPic;
     501
    502502#if SVC_EXTENSION //Temporal solution, should be modified
    503503      if(m_layerId > 0)
    504504      {
     505#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     506        TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId );
     507#else
    505508        TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
     509#endif
    506510        if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() )
    507511        {
     
    527531      if(m_layerId > 0)
    528532      {
     533#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     534        TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId );
     535#else
    529536        TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
     537#endif
    530538        if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() )
    531539        {
     
    543551#endif
    544552    }
     553
    545554    if (getUseSAO())
    546555    {
     
    566575#if REF_IDX_MFM
    567576  m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag);
     577#endif
     578#if SCALED_REF_LAYER_OFFSETS
     579  m_cSPS.getScaledRefLayerWindow() = m_scaledRefLayerWindow;
    568580#endif
    569581  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
     
    599611  m_cSPS.setMaxCUHeight   ( g_uiMaxCUHeight     );
    600612  m_cSPS.setMaxCUDepth    ( g_uiMaxCUDepth      );
    601   m_cSPS.setMinTrDepth    ( 0                   );
    602   m_cSPS.setMaxTrDepth    ( 1                   );
     613
     614  Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth );
     615  Int log2MinCUSize = 0;
     616  while(minCUSize > 1)
     617  {
     618    minCUSize >>= 1;
     619    log2MinCUSize++;
     620  }
     621
     622  m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);
     623  m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth);
    603624#if SVC_EXTENSION
    604625  m_cSPS.setSPSId         ( m_iSPSIdCnt       );
     
    618639
    619640  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
    620  
     641#if !L0034_COMBINED_LIST_CLEANUP
    621642  m_cSPS.setUseLComb    ( m_bUseLComb           );
     643#endif
    622644 
    623645  Int i;
     
    763785  m_cPPS.setOutputFlagPresentFlag( false );
    764786  m_cPPS.setSignHideFlag(getSignHideFlag());
     787#if L0386_DB_METRIC
     788  if ( getDeblockingFilterMetric() )
     789  {
     790    m_cPPS.setDeblockingFilterControlPresentFlag (true);
     791    m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);
     792    m_cPPS.setPicDisableDeblockingFilterFlag(false);
     793    m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);
     794    m_cPPS.setDeblockingFilterTcOffsetDiv2(0);
     795  }
     796  else
     797  {
    765798  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
     799  }
     800#else
     801  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
     802#endif
    766803  m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
    767804  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
     
    810847    }
    811848  }
    812 #if REF_LIST_BUGFIX
     849#if REF_IDX_FRAMEWORK
    813850  if (!m_layerId)
    814851  {
     
    10361073}
    10371074
     1075#if L0208_SOP_DESCRIPTION_SEI
     1076Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid )
     1077{
     1078  int rpsIdx = GOPid;
     1079
     1080  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
     1081  {   
     1082    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
     1083    {
     1084      Int POCIndex = POCCurr%m_uiIntraPeriod;
     1085      if(POCIndex == 0)
     1086      {
     1087        POCIndex = m_uiIntraPeriod;
     1088      }
     1089      if(POCIndex == m_GOPList[extraNum].m_POC)
     1090      {
     1091        rpsIdx = extraNum;
     1092      }
     1093    }
     1094    else
     1095    {
     1096      if(POCCurr==m_GOPList[extraNum].m_POC)
     1097      {
     1098        rpsIdx = extraNum;
     1099      }
     1100    }
     1101  }
     1102
     1103  return rpsIdx;
     1104}
     1105#endif
     1106
    10381107Void  TEncTop::xInitPPSforTiles()
    10391108{
     
    11181187}
    11191188
     1189#if SVC_EXTENSION
     1190#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     1191TEncTop* TEncTop::getRefLayerEnc( UInt layerId )
     1192{
     1193  if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 )
     1194  {
     1195#if ZERO_NUM_DIRECT_LAYERS
     1196    return (TEncTop *)getLayerEnc( 0 );
     1197#else
     1198    return NULL;
     1199#endif
     1200  }
     1201
     1202  // currently only one reference layer is supported
     1203  assert( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() == 1 );
     1204
     1205  return (TEncTop *)getLayerEnc( getVPS()->getRefLayerId( m_layerId, 0 ) );
     1206}
     1207#endif
     1208
    11201209#if REF_IDX_FRAMEWORK
    11211210Void TEncTop::xInitILRP()
     
    11231212  if(m_layerId>0)
    11241213  {
     1214    g_bitDepthY     = m_cSPS.getBitDepthY();
     1215    g_bitDepthC     = m_cSPS.getBitDepthC();
     1216    g_uiMaxCUWidth  = m_cSPS.getMaxCUWidth();
     1217    g_uiMaxCUHeight = m_cSPS.getMaxCUHeight();
     1218    g_uiMaxCUDepth  = m_cSPS.getMaxCUDepth();
     1219    g_uiAddCUDepth  = max (0, m_cSPS.getLog2MinCodingBlockSize() - (Int)m_cSPS.getQuadtreeTULog2MinSize() );
     1220
    11251221    Int  numReorderPics[MAX_TLAYER];
    11261222    Window &conformanceWindow = m_cSPS.getConformanceWindow();
     
    11321228      {
    11331229        m_cIlpPic[j] = new  TComPic;
    1134         //m_cIlpPic[j]->createWithOutYuv(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, &m_cSPS, true);
    11351230#if SVC_UPSAMPLING
    11361231        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
     
    11511246  if(m_cIlpPic[0])
    11521247  {
    1153     //m_cIlpPic[0]->setPicYuvRec(pcPic->getFullPelBaseRec());
    11541248    m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
    11551249    m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
    1156     m_cIlpPic[0]->setLayerId(0); //set reference layerId
     1250    m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId
    11571251    m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
    11581252    m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     
    11601254}
    11611255#endif
     1256#endif
    11621257//! \}
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r125 r189  
    139139  Bool                    m_bMFMEnabledFlag;
    140140#endif
     141#if SCALED_REF_LAYER_OFFSETS
     142  Window                  m_scaledRefLayerWindow;
     143#endif
    141144protected:
    142145  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
     
    192195  TComPPS*                getPPS                () { return  &m_cPPS;                 }
    193196  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
     197#if L0208_SOP_DESCRIPTION_SEI
     198  Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid );
     199#endif
    194200  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
    195201#if SVC_EXTENSION
     
    200206  Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
    201207#endif
     208#if SCALED_REF_LAYER_OFFSETS
     209  Window&  getScaledRefLayerWindow()            { return m_scaledRefLayerWindow; }
     210#endif
    202211
    203212  // -------------------------------------------------------------------------------------------------------------------
     
    209218#if REF_IDX_FRAMEWORK
    210219  TComPic** getIlpList() { return m_cIlpPic; }
    211   Void setILRPic(TComPic *pcPic);
     220  Void      setILRPic(TComPic *pcPic);
    212221#endif
    213222#if REF_IDX_MFM
    214   Void setMFMEnabledFlag       (Bool flag)   {m_bMFMEnabledFlag = flag;}
    215   Bool getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}   
     223  Void      setMFMEnabledFlag       (Bool flag)   {m_bMFMEnabledFlag = flag;}
     224  Bool      getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}   
    216225#endif
    217226#if AVC_SYNTAX
     
    219228  fstream*  getBLSyntaxFile() { return m_pBLSyntaxFile; }
    220229#endif
    221   Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
    222               std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP  );
    223   Void encodePrep( TComPicYuv* pcPicYuvOrg );
     230  Void      encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP  );
     231  Void      encodePrep( TComPicYuv* pcPicYuvOrg );
     232#if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE
     233  TEncTop*  getRefLayerEnc(UInt layerId);
     234#endif
    224235#else
    225236  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
  • trunk/source/Lib/TLibEncoder/WeightPredAnalysis.cpp

    r125 r189  
    235235        Int offset = (Int)( ((currDC<<log2Denom) - ((Int64)weight * refDC) + (Int64)realOffset) >> realLog2Denom );
    236236
    237         // Chroma offset range limination
     237        // Chroma offset range limitation
    238238        if(comp)
    239239        {
    240           Int shift = 1 << (g_bitDepthC - 1);
    241           Int pred = ( shift - ( ( shift*weight)>>(log2Denom) ) );
     240          Int pred = ( 128 - ( ( 128*weight)>>(log2Denom) ) );
    242241          Int deltaOffset = Clip3( -512, 511, (offset - pred) );    // signed 10bit
    243242          offset = Clip3( -128, 127, (deltaOffset + pred) );        // signed 8bit
     243        }
     244        // Luma offset range limitation
     245        else
     246        {
     247          offset = Clip3( -128, 127, offset);
    244248        }
    245249
Note: See TracChangeset for help on using the changeset viewer.