Ignore:
Timestamp:
3 May 2013, 15:34:11 (12 years ago)
Author:
tech
Message:

Update to HM-10.1.

Location:
branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/SEIwrite.cpp

    r324 r362  
    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{
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/SEIwrite.h

    r324 r362  
    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};
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r331 r362  
    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" );
     
    575570  WRITE_FLAG( pcVPS->getTemporalNestingFlag(),                "vps_temporal_id_nesting_flag" );
    576571  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
     572#if H_MV
    577573  WRITE_CODE( 0xffff,                              16,        "vps_extension_offset" );
     574#else
     575  WRITE_CODE( 0xffff,                              16,        "vps_reserved_ffff_16bits" );
     576#endif
    578577  codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 );
    579578#if SIGNAL_BITRATE_PICRATE_IN_VPS
     
    584583  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
    585584  {
     585#if L0323_DPB
     586    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1,       "vps_max_dec_pic_buffering_minus1[i]" );
     587#else
    586588    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i),           "vps_max_dec_pic_buffering[i]" );
     589#endif
    587590    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "vps_num_reorder_pics[i]" );
    588591    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "vps_max_latency_increase[i]" );
     
    790793      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
    791794      TComReferencePictureSet* rps = pcSlice->getRPS();
     795     
     796#if FIX1071
     797      // Deal with bitstream restriction stating that:
     798      // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     799      // Ideally this process should not be repeated for each slice in a picture
     800      TComReferencePictureSet altRps;
     801      Bool useAltRps = false;
     802      if (pcSlice->getRapPicFlag())
     803      {
     804        for (Int picIdx = 0; !useAltRps && picIdx < rps->getNumberOfPictures(); picIdx++)
     805        {
     806          useAltRps = rps->getUsed(picIdx);
     807        }
     808        if (useAltRps)
     809        {
     810          memcpy(&altRps, rps, sizeof(TComReferencePictureSet));
     811          rps = &altRps;
     812          for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
     813          {
     814            rps->setUsed(picIdx, false);
     815          }
     816        }
     817      }
     818
     819      if(pcSlice->getRPSidx() < 0 || useAltRps)
     820#else
    792821      if(pcSlice->getRPSidx() < 0)
     822#endif
    793823      {
    794824        WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
     
    13731403// ====================================================================================================================
    13741404
    1375 
    1376 /** Write PCM alignment bits.
    1377  * \returns Void
    1378  */
    1379 Void  TEncCavlc::xWritePCMAlignZero    ()
    1380 {
    1381   m_pcBitIf->writeAlignZero();
    1382 }
    1383 
    1384 Void TEncCavlc::xWriteUnaryMaxSymbol( UInt uiSymbol, UInt uiMaxSymbol )
    1385 {
    1386   if (uiMaxSymbol == 0)
    1387   {
    1388     return;
    1389   }
    1390   xWriteFlag( uiSymbol ? 1 : 0 );
    1391   if ( uiSymbol == 0 )
    1392   {
    1393     return;
    1394   }
    1395  
    1396   Bool bCodeLast = ( uiMaxSymbol > uiSymbol );
    1397  
    1398   while( --uiSymbol )
    1399   {
    1400     xWriteFlag( 1 );
    1401   }
    1402   if( bCodeLast )
    1403   {
    1404     xWriteFlag( 0 );
    1405   }
    1406   return;
    1407 }
    1408 
    1409 Void TEncCavlc::xWriteExGolombLevel( UInt uiSymbol )
    1410 {
    1411   if( uiSymbol )
    1412   {
    1413     xWriteFlag( 1 );
    1414     UInt uiCount = 0;
    1415     Bool bNoExGo = (uiSymbol < 13);
    1416    
    1417     while( --uiSymbol && ++uiCount < 13 )
    1418     {
    1419       xWriteFlag( 1 );
    1420     }
    1421     if( bNoExGo )
    1422     {
    1423       xWriteFlag( 0 );
    1424     }
    1425     else
    1426     {
    1427       xWriteEpExGolomb( uiSymbol, 0 );
    1428     }
    1429   }
    1430   else
    1431   {
    1432     xWriteFlag( 0 );
    1433   }
    1434   return;
    1435 }
    1436 
    1437 Void TEncCavlc::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount )
    1438 {
    1439   while( uiSymbol >= (UInt)(1<<uiCount) )
    1440   {
    1441     xWriteFlag( 1 );
    1442     uiSymbol -= 1<<uiCount;
    1443     uiCount  ++;
    1444   }
    1445   xWriteFlag( 0 );
    1446   while( uiCount-- )
    1447   {
    1448     xWriteFlag( (uiSymbol>>uiCount) & 1 );
    1449   }
    1450   return;
    1451 }
    1452 
    14531405/** code explicit wp tables
    14541406 * \param TComSlice* pcSlice
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncCavlc.h

    r324 r362  
    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 );
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncCfg.h

    r324 r362  
    7474  Int m_interViewRefPosL[2][MAX_NUM_REF_PICS]; 
    7575#endif
    76 
    7776  GOPEntry()
    7877  : m_POC(-1)
     
    9897#if H_MV
    9998    ::memset( m_interViewRefs,   0, sizeof(m_interViewRefs) );
    100     ::memset( m_interViewRefPosL[0], -1, sizeof(m_interViewRefPosL[0]) );
    101     ::memset( m_interViewRefPosL[1], -1, sizeof(m_interViewRefPosL[1]) );
    102 #endif
     99    ::memset( m_interViewRefPosL[0], -1, sizeof(m_interViewRefPosL[0]) );    ::memset( m_interViewRefPosL[1], -1, sizeof(m_interViewRefPosL[1]) );#endif
    103100  }
    104101};
     
    172169  Int       m_loopFilterTcOffsetDiv2;
    173170  Bool      m_DeblockingFilterControlPresent;
     171#if L0386_DB_METRIC
     172  Bool      m_DeblockingFilterMetric;
     173#endif
    174174  Bool      m_bUseSAO;
    175175  Int       m_maxNumOffsetsPerPic;
     
    202202  Bool      m_bUseASR;
    203203  Bool      m_bUseHADME;
     204#if !L0034_COMBINED_LIST_CLEANUP
    204205  Bool      m_bUseLComb;
     206#endif
    205207  Bool      m_useRDOQ;
    206208  Bool      m_useRDOQTS;
     
    248250  Int       m_pictureTimingSEIEnabled;
    249251  Int       m_recoveryPointSEIEnabled;
     252#if J0149_TONE_MAPPING_SEI
     253  Bool      m_toneMappingInfoSEIEnabled;
     254  Int       m_toneMapId;
     255  Bool      m_toneMapCancelFlag;
     256  Bool      m_toneMapPersistenceFlag;
     257  Int       m_codedDataBitDepth;
     258  Int       m_targetBitDepth;
     259  Int       m_modelId;
     260  Int       m_minValue;
     261  Int       m_maxValue;
     262  Int       m_sigmoidMidpoint;
     263  Int       m_sigmoidWidth;
     264  Int       m_numPivots;
     265  Int       m_cameraIsoSpeedIdc;
     266  Int       m_cameraIsoSpeedValue;
     267  Int       m_exposureCompensationValueSignFlag;
     268  Int       m_exposureCompensationValueNumerator;
     269  Int       m_exposureCompensationValueDenomIdc;
     270  Int       m_refScreenLuminanceWhite;
     271  Int       m_extendedRangeWhiteLevel;
     272  Int       m_nominalBlackLevelLumaCodeValue;
     273  Int       m_nominalWhiteLevelLumaCodeValue;
     274  Int       m_extendedWhiteLevelLumaCodeValue;
     275  Int*      m_startOfCodedInterval;
     276  Int*      m_codedPivotValue;
     277  Int*      m_targetPivotValue;
     278#endif
    250279  Int       m_framePackingSEIEnabled;
    251280  Int       m_framePackingSEIType;
     
    257286  Int       m_gradualDecodingRefreshInfoEnabled;
    258287  Int       m_decodingUnitInfoSEIEnabled;
     288#if L0208_SOP_DESCRIPTION_SEI
     289  Int       m_SOPDescriptionSEIEnabled;
     290#endif
     291#if K0180_SCALABLE_NESTING_SEI
     292  Int       m_scalableNestingSEIEnabled;
     293#endif
    259294  //====== Weighted Prediction ========
    260295  Bool      m_useWeightedPred;       //< Use of Weighting Prediction (P_SLICE)
     
    325360#endif
    326361#endif
    327 
    328362public:
    329363  TEncCfg()
     
    409443  Void      setLoopFilterTcOffset           ( Int   i )      { m_loopFilterTcOffsetDiv2    = i; }
    410444  Void      setDeblockingFilterControlPresent ( Bool b ) { m_DeblockingFilterControlPresent = b; }
     445#if L0386_DB_METRIC
     446  Void      setDeblockingFilterMetric       ( Bool  b )      { m_DeblockingFilterMetric = b; }
     447#endif
    411448
    412449  //====== Motion search ========
     
    463500  Int       getLoopFilterTcOffset           ()      { return m_loopFilterTcOffsetDiv2; }
    464501  Bool      getDeblockingFilterControlPresent()  { return  m_DeblockingFilterControlPresent; }
     502#if L0386_DB_METRIC
     503  Bool      getDeblockingFilterMetric       ()      { return m_DeblockingFilterMetric; }
     504#endif
    465505
    466506  //==== Motion search ========
     
    480520  Void      setUseASR                       ( Bool  b )     { m_bUseASR     = b; }
    481521  Void      setUseHADME                     ( Bool  b )     { m_bUseHADME   = b; }
     522#if !L0034_COMBINED_LIST_CLEANUP
    482523  Void      setUseLComb                     ( Bool  b )     { m_bUseLComb   = b; }
     524#endif
    483525  Void      setUseRDOQ                      ( Bool  b )     { m_useRDOQ    = b; }
    484526  Void      setUseRDOQTS                    ( Bool  b )     { m_useRDOQTS  = b; }
     
    502544  Bool      getUseASR                       ()      { return m_bUseASR;     }
    503545  Bool      getUseHADME                     ()      { return m_bUseHADME;   }
     546#if !L0034_COMBINED_LIST_CLEANUP
    504547  Bool      getUseLComb                     ()      { return m_bUseLComb;   }
     548#endif
    505549  Bool      getUseRDOQ                      ()      { return m_useRDOQ;    }
    506550  Bool      getUseRDOQTS                    ()      { return m_useRDOQTS;  }
     
    599643  Void  setRecoveryPointSEIEnabled(Int b)                { m_recoveryPointSEIEnabled = b; }
    600644  Int   getRecoveryPointSEIEnabled()                     { return m_recoveryPointSEIEnabled; }
     645#if J0149_TONE_MAPPING_SEI
     646  Void  setToneMappingInfoSEIEnabled(Bool b)                 {  m_toneMappingInfoSEIEnabled = b;  }
     647  Bool  getToneMappingInfoSEIEnabled()                       {  return m_toneMappingInfoSEIEnabled;  }
     648  Void  setTMISEIToneMapId(Int b)                            {  m_toneMapId = b;  }
     649  Int   getTMISEIToneMapId()                                 {  return m_toneMapId;  }
     650  Void  setTMISEIToneMapCancelFlag(Bool b)                   {  m_toneMapCancelFlag=b;  }
     651  Bool  getTMISEIToneMapCancelFlag()                         {  return m_toneMapCancelFlag;  }
     652  Void  setTMISEIToneMapPersistenceFlag(Bool b)              {  m_toneMapPersistenceFlag = b;  }
     653  Bool   getTMISEIToneMapPersistenceFlag()                   {  return m_toneMapPersistenceFlag;  }
     654  Void  setTMISEICodedDataBitDepth(Int b)                    {  m_codedDataBitDepth = b;  }
     655  Int   getTMISEICodedDataBitDepth()                         {  return m_codedDataBitDepth;  }
     656  Void  setTMISEITargetBitDepth(Int b)                       {  m_targetBitDepth = b;  }
     657  Int   getTMISEITargetBitDepth()                            {  return m_targetBitDepth;  }
     658  Void  setTMISEIModelID(Int b)                              {  m_modelId = b;  }
     659  Int   getTMISEIModelID()                                   {  return m_modelId;  }
     660  Void  setTMISEIMinValue(Int b)                             {  m_minValue = b;  }
     661  Int   getTMISEIMinValue()                                  {  return m_minValue;  }
     662  Void  setTMISEIMaxValue(Int b)                             {  m_maxValue = b;  }
     663  Int   getTMISEIMaxValue()                                  {  return m_maxValue;  }
     664  Void  setTMISEISigmoidMidpoint(Int b)                      {  m_sigmoidMidpoint = b;  }
     665  Int   getTMISEISigmoidMidpoint()                           {  return m_sigmoidMidpoint;  }
     666  Void  setTMISEISigmoidWidth(Int b)                         {  m_sigmoidWidth = b;  }
     667  Int   getTMISEISigmoidWidth()                              {  return m_sigmoidWidth;  }
     668  Void  setTMISEIStartOfCodedInterva( Int*  p )              {  m_startOfCodedInterval = p;  }
     669  Int*  getTMISEIStartOfCodedInterva()                       {  return m_startOfCodedInterval;  }
     670  Void  setTMISEINumPivots(Int b)                            {  m_numPivots = b;  }
     671  Int   getTMISEINumPivots()                                 {  return m_numPivots;  }
     672  Void  setTMISEICodedPivotValue( Int*  p )                  {  m_codedPivotValue = p;  }
     673  Int*  getTMISEICodedPivotValue()                           {  return m_codedPivotValue;  }
     674  Void  setTMISEITargetPivotValue( Int*  p )                 {  m_targetPivotValue = p;  }
     675  Int*  getTMISEITargetPivotValue()                          {  return m_targetPivotValue;  }
     676  Void  setTMISEICameraIsoSpeedIdc(Int b)                    {  m_cameraIsoSpeedIdc = b;  }
     677  Int   getTMISEICameraIsoSpeedIdc()                         {  return m_cameraIsoSpeedIdc;  }
     678  Void  setTMISEICameraIsoSpeedValue(Int b)                  {  m_cameraIsoSpeedValue = b;  }
     679  Int   getTMISEICameraIsoSpeedValue()                       {  return m_cameraIsoSpeedValue;  }
     680  Void  setTMISEIExposureCompensationValueSignFlag(Int b)    {  m_exposureCompensationValueSignFlag = b;  }
     681  Int   getTMISEIExposureCompensationValueSignFlag()         {  return m_exposureCompensationValueSignFlag;  }
     682  Void  setTMISEIExposureCompensationValueNumerator(Int b)   {  m_exposureCompensationValueNumerator = b;  }
     683  Int   getTMISEIExposureCompensationValueNumerator()        {  return m_exposureCompensationValueNumerator;  }
     684  Void  setTMISEIExposureCompensationValueDenomIdc(Int b)    {  m_exposureCompensationValueDenomIdc =b;  }
     685  Int   getTMISEIExposureCompensationValueDenomIdc()         {  return m_exposureCompensationValueDenomIdc;  }
     686  Void  setTMISEIRefScreenLuminanceWhite(Int b)              {  m_refScreenLuminanceWhite = b;  }
     687  Int   getTMISEIRefScreenLuminanceWhite()                   {  return m_refScreenLuminanceWhite;  }
     688  Void  setTMISEIExtendedRangeWhiteLevel(Int b)              {  m_extendedRangeWhiteLevel = b;  }
     689  Int   getTMISEIExtendedRangeWhiteLevel()                   {  return m_extendedRangeWhiteLevel;  }
     690  Void  setTMISEINominalBlackLevelLumaCodeValue(Int b)       {  m_nominalBlackLevelLumaCodeValue = b;  }
     691  Int   getTMISEINominalBlackLevelLumaCodeValue()            {  return m_nominalBlackLevelLumaCodeValue;  }
     692  Void  setTMISEINominalWhiteLevelLumaCodeValue(Int b)       {  m_nominalWhiteLevelLumaCodeValue = b;  }
     693  Int   getTMISEINominalWhiteLevelLumaCodeValue()            {  return m_nominalWhiteLevelLumaCodeValue;  }
     694  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
     695  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
     696#endif
    601697  Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
    602698  Int   getFramePackingArrangementSEIEnabled()           { return m_framePackingSEIEnabled; }
     
    617713  Void  setDecodingUnitInfoSEIEnabled(Int b)                { m_decodingUnitInfoSEIEnabled = b;    }
    618714  Int   getDecodingUnitInfoSEIEnabled()                     { return m_decodingUnitInfoSEIEnabled; }
     715#if L0208_SOP_DESCRIPTION_SEI
     716  Void  setSOPDescriptionSEIEnabled(Int b)                { m_SOPDescriptionSEIEnabled = b; }
     717  Int   getSOPDescriptionSEIEnabled()                     { return m_SOPDescriptionSEIEnabled; }
     718#endif
     719#if K0180_SCALABLE_NESTING_SEI
     720  Void  setScalableNestingSEIEnabled(Int b)                { m_scalableNestingSEIEnabled = b; }
     721  Int   getScalableNestingSEIEnabled()                     { return m_scalableNestingSEIEnabled; }
     722#endif
    619723  Void      setUseWP               ( Bool b )    { m_useWeightedPred   = b;    }
    620724  Void      setWPBiPred            ( Bool b )    { m_useWeightedBiPred = b;    }
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r324 r362  
    9696#if L0045_NON_NESTED_SEI_RESTRICTIONS
    9797  xResetNonNestedSEIPresentFlags();
    98 #endif
    99 
     98#if K0180_SCALABLE_NESTING_SEI
     99  xResetNestedSEIPresentFlags();
     100#endif
     101#endif
    100102#if H_MV
    101103  m_layerId      = 0;
     
    106108#endif
    107109#endif
    108 
    109110  return;
    110111}
     
    211212}
    212213
     214#if J0149_TONE_MAPPING_SEI
     215SEIToneMappingInfo*  TEncGOP::xCreateSEIToneMappingInfo()
     216{
     217  SEIToneMappingInfo *seiToneMappingInfo = new SEIToneMappingInfo();
     218  seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();
     219  seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();
     220  seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag();
     221
     222  seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth();
     223  assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);
     224  seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();
     225  assert( (seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17) || (seiToneMappingInfo->m_targetBitDepth  == 255) );
     226  seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();
     227  assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);
     228
     229  switch( seiToneMappingInfo->m_modelId)
     230  {
     231  case 0:
     232    {
     233      seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue();
     234      seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue();
     235      break;
     236    }
     237  case 1:
     238    {
     239      seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint();
     240      seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth();
     241      break;
     242    }
     243  case 2:
     244    {
     245      UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth);
     246      seiToneMappingInfo->m_startOfCodedInterval.resize(num);
     247      Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva();
     248      if(ptmp)
     249      {
     250        for(int i=0; i<num;i++)
     251        {
     252          seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i];
     253        }
     254      }
     255      break;
     256    }
     257  case 3:
     258    {
     259      seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots();
     260      seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots);
     261      seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots);
     262      Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue();
     263      Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue();
     264      if(ptmpcoded&&ptmptarget)
     265      {
     266        for(int i=0; i<(seiToneMappingInfo->m_numPivots);i++)
     267        {
     268          seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i];
     269          seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i];
     270         }
     271       }
     272       break;
     273     }
     274  case 4:
     275     {
     276       seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc();
     277       seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
     278       assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
     279       seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
     280       seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
     281       seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc();
     282       seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite();
     283       seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel();
     284       assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );
     285       seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue();
     286       seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue();
     287       assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );
     288       seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue();
     289       assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );
     290       break;
     291    }
     292  default:
     293    {
     294      assert(!"Undefined SEIToneMapModelId");
     295      break;
     296    }
     297  }
     298  return seiToneMappingInfo;
     299}
     300#endif
    213301Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    214302{
    215   OutputNALUnit nalu(NAL_UNIT_SEI);
     303  OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    216304
    217305  if(m_pcCfg->getActiveParameterSetsSEIEnabled())
     
    234322    SEIFramePacking *sei = xCreateSEIFramePacking ();
    235323
    236     nalu = NALUnit(NAL_UNIT_SEI);
     324    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    237325    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    238326    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     
    245333    SEIDisplayOrientation *sei = xCreateSEIDisplayOrientation();
    246334
    247     nalu = NALUnit(NAL_UNIT_SEI);
     335    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    248336    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    249337    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     
    252340    delete sei;
    253341  }
     342#if J0149_TONE_MAPPING_SEI
     343  if(m_pcCfg->getToneMappingInfoSEIEnabled())
     344  {
     345    SEIToneMappingInfo *sei = xCreateSEIToneMappingInfo ();
     346     
     347    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     348    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     349    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     350    writeRBSPTrailingBits(nalu.m_Bitstream);
     351    accessUnit.push_back(new NALUnitEBSP(nalu));
     352    delete sei;
     353  }
     354#endif
    254355}
    255356
     
    275376  TComPicYuv*     pcPicYuvRecOut;
    276377  TComSlice*      pcSlice;
    277   TComOutputBitstream* pcBitstreamRedirect = new TComOutputBitstream;
     378  TComOutputBitstream  *pcBitstreamRedirect;
     379  pcBitstreamRedirect = new TComOutputBitstream;
    278380  AccessUnit::iterator  itLocationToPushSliceHeaderNALU; // used to store location where NALU containing slice header is to be inserted
    279381  UInt                  uiOneBitstreamPerSliceLength = 0;
     
    286388  m_iNumPicCoded = 0;
    287389#endif
    288 
    289390  SEIPictureTiming pictureTimingSEI;
     391#if L0208_SOP_DESCRIPTION_SEI
     392  Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled();
     393#endif
     394#if K0180_SCALABLE_NESTING_SEI
     395  // Initialize Scalable Nesting SEI with single layer values
     396  SEIScalableNesting scalableNestingSEI;
     397  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
     398  scalableNestingSEI.m_nestingOpFlag                 = 0;
     399  scalableNestingSEI.m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
     400  scalableNestingSEI.m_allLayersFlag                 = 0;
     401  scalableNestingSEI.m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
     402  scalableNestingSEI.m_nestingNumLayersMinus1        = 1 - 1;  //nesting_num_layers_minus1
     403  scalableNestingSEI.m_nestingLayerId[0]             = 0;
     404  scalableNestingSEI.m_callerOwnsSEIs                = true;
     405#endif
    290406#if L0044_DU_DPB_OUTPUT_DELAY_HRD
    291407  Int picSptDpbOutputDuDelay = 0;
     
    298414  for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
    299415#endif
    300 
    301416  {
    302417    UInt uiColDir = 1;
     
    364479      continue;
    365480#endif
    366 
    367     }
    368 
    369     if( getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     481    }
     482
     483    if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    370484    {
    371485      m_iLastIDR = pocCurr;
     
    385499    pcSlice->setLastIDR(m_iLastIDR);
    386500    pcSlice->setSliceIdx(0);
    387 
    388501#if H_MV
    389502    pcPic  ->setLayerId     ( getLayerId() );
     
    397510#endif
    398511#endif
    399 
    400512    //set default slice level flag to the same as SPS level flag
    401513    pcSlice->setLFCrossSliceBoundaryFlag(  pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()  );
     
    437549#if H_MV
    438550    // Set the nal unit type
    439     pcSlice->setNalUnitType(getNalUnitType(pocCurr));
     551    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
    440552    if( pcSlice->getSliceType() == B_SLICE )
    441553    {
     
    451563    }
    452564    // Set the nal unit type
    453     pcSlice->setNalUnitType(getNalUnitType(pocCurr));
    454 #endif
    455     if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    456     {
    457       if(pcSlice->getTemporalLayerNonReferenceFlag())
     565    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
     566#endif
     567    if(pcSlice->getTemporalLayerNonReferenceFlag())
     568    {
     569      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    458570      {
    459571        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N);
     572      }
     573      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RADL_R)
     574      {
     575        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RADL_N);
     576      }
     577      if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RASL_R)
     578      {
     579        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RASL_N);
    460580      }
    461581    }
     
    482602        else
    483603        {
    484           pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA);
     604          pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R);
    485605        }
    486606      }
     
    568688    }
    569689#endif
    570 
     690#if !L0034_COMBINED_LIST_CLEANUP
    571691    if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb())
    572692    {
     
    580700      pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0));
    581701    }
     702#endif
    582703
    583704    if (pcSlice->getSliceType() == B_SLICE)
     
    605726      pcSlice->setCheckLDC(bLowDelay); 
    606727    }
     728    else
     729    {
     730      pcSlice->setCheckLDC(true); 
     731    }
    607732
    608733    uiColDir = 1-uiColDir;
     
    611736    pcSlice->setRefPOCList();
    612737
     738#if L0034_COMBINED_LIST_CLEANUP
     739    pcSlice->setList1IdxToList0Idx();
     740#else
    613741    pcSlice->setNoBackPredFlag( false );
    614742    if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())
     
    634762    }
    635763    pcSlice->generateCombinedList();
     764#endif
    636765
    637766    if (m_pcEncTop->getTMVPModeId() == 2)
     
    9391068    Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
    9401069    m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
     1070#if L0386_DB_METRIC
     1071    if ( m_pcCfg->getDeblockingFilterMetric() )
     1072    {
     1073      dblMetric(pcPic, uiNumSlices);
     1074    }
     1075#endif
    9411076    m_pcLoopFilter->loopFilterPic( pcPic );
    9421077
     
    10371172    }
    10381173
     1174#if L0208_SOP_DESCRIPTION_SEI
     1175    if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
     1176    {
     1177      Int SOPcurrPOC = pocCurr;
     1178
     1179      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     1180      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1181      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     1182
     1183      SEISOPDescription SOPDescriptionSEI;
     1184      SOPDescriptionSEI.m_sopSeqParameterSetId = pcSlice->getSPS()->getSPSId();
     1185
     1186      UInt i = 0;
     1187      UInt prevEntryId = iGOPid;
     1188      for (j = iGOPid; j < m_iGopSize; j++)
     1189      {
     1190        Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;
     1191        if ((SOPcurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())
     1192        {
     1193          SOPcurrPOC += deltaPOC;
     1194          SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR);
     1195          SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
     1196          SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j);
     1197          SOPDescriptionSEI.m_sopDescPocDelta[i] = deltaPOC;
     1198
     1199          prevEntryId = j;
     1200          i++;
     1201        }
     1202      }
     1203
     1204      SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1;
     1205
     1206      m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS());
     1207      writeRBSPTrailingBits(nalu.m_Bitstream);
     1208      accessUnit.push_back(new NALUnitEBSP(nalu));
     1209
     1210      writeSOP = false;
     1211    }
     1212#endif
     1213
    10391214    if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
    10401215        ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
     
    10821257       || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
    10831258    {
    1084       OutputNALUnit nalu(NAL_UNIT_SEI);
     1259      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    10851260      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    10861261      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    11231298      writeRBSPTrailingBits(nalu.m_Bitstream);
    11241299#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1300      {
    11251301      UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    11261302      UInt offsetPosition = m_activeParameterSetSEIPresentInAU;   // Insert BP SEI after APS SEI
     
    11321308      accessUnit.insert(it, new NALUnitEBSP(nalu));
    11331309      m_bufferingPeriodSEIPresentInAU = true;
     1310      }
    11341311#else
    11351312      accessUnit.push_back(new NALUnitEBSP(nalu));
    11361313#endif
    11371314
     1315#if K0180_SCALABLE_NESTING_SEI
     1316      if (m_pcCfg->getScalableNestingSEIEnabled())
     1317      {
     1318        OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI);
     1319        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1320        m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream);
     1321        scalableNestingSEI.m_nestedSEIs.clear();
     1322        scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period);
     1323        m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     1324        writeRBSPTrailingBits(naluTmp.m_Bitstream);
     1325#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1326        UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     1327        UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU;   // Insert BP SEI after non-nested APS, BP and PT SEIs
     1328        AccessUnit::iterator it;
     1329        for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     1330        {
     1331          it++;
     1332        }
     1333        accessUnit.insert(it, new NALUnitEBSP(naluTmp));
     1334        m_nestedBufferingPeriodSEIPresentInAU = true;
     1335#else
     1336        accessUnit.push_back(new NALUnitEBSP(naluTmp));
     1337#endif
     1338      }
     1339#endif
     1340
    11381341      m_lastBPSEI = m_totalCoded;
    11391342      m_cpbRemovalDelay = 0;
     
    11451348      {
    11461349        // Gradual decoding refresh SEI
    1147         OutputNALUnit nalu(NAL_UNIT_SEI);
     1350        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    11481351        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    11491352        m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    11571360      }
    11581361    // Recovery point SEI
    1159       OutputNALUnit nalu(NAL_UNIT_SEI);
     1362      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    11601363      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    11611364      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    13481551
    13491552          pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength );
    1350           if (!sliceSegment)
    1351           {
    13521553            pcSlice->setTileLocationCount ( 0 );
    1353             m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info.
    1354           }
    1355           else
    1356           {
    1357             m_pcSliceEncoder->encodeSlice(pcPic, &nalu.m_Bitstream, pcSubstreamsOut); // nalu.m_Bitstream is only used for CAVLC tile position info.
    1358           }
     1554          m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut);
    13591555
    13601556          {
     
    13881584              if (ui+1 < pcSlice->getPPS()->getNumSubstreams())
    13891585              {
    1390                 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits();
     1586                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
    13911587              }
    13921588            }
     
    14201616          // 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.
    14211617          Bool bNALUAlignedWrittenToList    = false; // used to ensure current NALU is not written more than once to the NALU list.
    1422           xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);
     1618          xAttachSliceDataToNalUnit(nalu, pcBitstreamRedirect);
    14231619          accessUnit.push_back(new NALUnitEBSP(nalu));
    14241620#if RATE_CONTROL_LAMBDA_DOMAIN
     
    14481644            {
    14491645              UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size());
    1450               if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     1646              if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    14511647              {
    14521648                numRBSPBytes += numRBSPBytes_nal;
     
    15491745          digestStr = digestToString(sei_recon_picture_digest.digest, 4);
    15501746        }
    1551         OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer());
     1747        OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer());
    15521748
    15531749        /* write the SEI messages */
     
    15731769        sei_temporal_level0_index.rapIdx = m_rapIdx;
    15741770
    1575         OutputNALUnit nalu(NAL_UNIT_SEI);
     1771        OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    15761772
    15771773        /* write the SEI messages */
     
    17131909        if( m_pcCfg->getPictureTimingSEIEnabled() )
    17141910        {
    1715           OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
     1911          {
     1912            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    17161913          m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    17171914          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
     
    17331930#endif
    17341931        }
     1932#if K0180_SCALABLE_NESTING_SEI
     1933          if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI
     1934          {
     1935            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
     1936            m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     1937            scalableNestingSEI.m_nestedSEIs.clear();
     1938            scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI);
     1939            m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
     1940            writeRBSPTrailingBits(nalu.m_Bitstream);
     1941#if L0045_NON_NESTED_SEI_RESTRICTIONS
     1942            UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     1943            UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     1944              + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU + m_nestedBufferingPeriodSEIPresentInAU;    // Insert PT SEI after APS and BP SEI
     1945            AccessUnit::iterator it;
     1946            for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     1947            {
     1948              it++;
     1949            }
     1950            accessUnit.insert(it, new NALUnitEBSP(nalu));
     1951            m_nestedPictureTimingSEIPresentInAU = true;
     1952#else
     1953            AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
     1954            accessUnit.insert(it, new NALUnitEBSP(nalu));
     1955#endif
     1956          }
     1957#endif
     1958
     1959        }
    17351960        if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
    17361961        {             
     
    17381963          for( Int i = 0; i < ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 ); i ++ )
    17391964          {
    1740             OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
     1965            OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    17411966
    17421967            SEIDecodingUnitInfo tempSEI;
     
    17862011                  break;
    17872012                }
    1788                 if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     2013                if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    17892014                {
    17902015                  ctr++;
     
    17972022#if L0045_NON_NESTED_SEI_RESTRICTIONS
    17982023      xResetNonNestedSEIPresentFlags();
     2024#if K0180_SCALABLE_NESTING_SEI
     2025      xResetNestedSEIPresentFlags();
     2026#endif
    17992027#endif
    18002028      pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut);
     
    20232251    case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";
    20242252    case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";
    2025     case NAL_UNIT_CODED_SLICE_TLA: return "TLA";
     2253    case NAL_UNIT_CODED_SLICE_TLA_R:      return "TLA_R";
    20262254    case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";
    20272255    case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";
    20282256    case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N";
    2029     case NAL_UNIT_CODED_SLICE_BLA: return "BLA";
    2030     case NAL_UNIT_CODED_SLICE_BLANT: return "BLANT";
     2257    case NAL_UNIT_CODED_SLICE_BLA_W_LP:   return "BLA_W_LP";
     2258    case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL";
    20312259    case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";
    2032     case NAL_UNIT_CODED_SLICE_IDR: return "IDR";
     2260    case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL";
    20332261    case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";
    20342262    case NAL_UNIT_CODED_SLICE_CRA: return "CRA";
    2035     case NAL_UNIT_CODED_SLICE_DLP: return "DLP";
    2036     case NAL_UNIT_CODED_SLICE_TFD: return "TFD";
     2263    case NAL_UNIT_CODED_SLICE_RADL_R:     return "RADL_R";
     2264    case NAL_UNIT_CODED_SLICE_RASL_R:     return "RASL_R";
    20372265    case NAL_UNIT_VPS: return "VPS";
    20382266    case NAL_UNIT_SPS: return "SPS";
     
    20422270    case NAL_UNIT_EOB: return "EOB";
    20432271    case NAL_UNIT_FILLER_DATA: return "FILLER";
    2044     case NAL_UNIT_SEI: return "SEI";
     2272    case NAL_UNIT_PREFIX_SEI:             return "SEI";
     2273    case NAL_UNIT_SUFFIX_SEI:             return "SEI";
    20452274    default: return "UNK";
    20462275  }
     
    21332362    printf("*** %6s numBytesInNALunit: %u\n", nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal);
    21342363#endif
    2135     if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
     2364    if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    21362365    {
    21372366      numRBSPBytes += numRBSPBytes_nal;
     
    21432372
    21442373  //===== add PSNR =====
    2145 
    21462374#if H_MV
    21472375  m_pcEncTop->getAnalyzeAll()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     
    21532381  if (pcSlice->isIntra())
    21542382  {
    2155 
    21562383#if H_MV
    21572384    m_pcEncTop->getAnalyzeI()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     
    21632390  if (pcSlice->isInterP())
    21642391  {
    2165 
    21662392#if H_MV
    21672393    m_pcEncTop->getAnalyzeP()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     
    21692395    m_gcAnalyzeP.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
    21702396#endif
    2171 
    21722397  }
    21732398  if (pcSlice->isInterB())
    21742399  {
    2175 
    21762400#if H_MV
    21772401    m_pcEncTop->getAnalyzeB()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     
    21792403    m_gcAnalyzeB.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
    21802404#endif
    2181 
    21822405  }
    21832406
     
    21862409
    21872410#if ADAPTIVE_QP_SELECTION
    2188 
    21892411#if H_MV
    21902412  printf("Layer %3d   POC %4d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits",
     
    22052427         uibits );
    22062428#endif
    2207 
    22082429#else
    2209 
    22102430#if H_MV
    22112431  printf("Layer %3d   POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits",
     
    22262446
    22272447#endif
    2228 
    22292448  printf(" [Y %6.4lf dB    U %6.4lf dB    V %6.4lf dB]", dYPSNR, dUPSNR, dVPSNR );
    22302449  printf(" [ET %5.0f ]", dEncTime );
     
    22572476 * This function checks the configuration and returns the appropriate nal_unit_type for the picture.
    22582477 */
    2259 NalUnitType TEncGOP::getNalUnitType(Int pocCurr)
     2478NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR)
    22602479{
    22612480  if (pocCurr == 0)
    22622481  {
    2263     return NAL_UNIT_CODED_SLICE_IDR;
     2482    return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    22642483  }
    22652484  if (pocCurr % m_pcCfg->getIntraPeriod() == 0)
     
    22712490    else if (m_pcCfg->getDecodingRefreshType() == 2)
    22722491    {
    2273       return NAL_UNIT_CODED_SLICE_IDR;
     2492      return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    22742493    }
    22752494  }
     
    22832502      // controlling the reference pictures used for encoding that leading picture. Such a leading
    22842503      // picture need not be marked as a TFD picture.
    2285       return NAL_UNIT_CODED_SLICE_TFD;
     2504      return NAL_UNIT_CODED_SLICE_RASL_R;
     2505    }
     2506  }
     2507  if (lastIDR>0)
     2508  {
     2509    if (pocCurr < lastIDR)
     2510    {
     2511      return NAL_UNIT_CODED_SLICE_RADL_R;
    22862512    }
    22872513  }
     
    23342560}
    23352561
    2336 /** Determine the difference between consecutive tile sizes (in bytes) and writes it to  bistream rNalu [slice header]
    2337  * \param rpcBitstreamRedirect contains the bitstream to be concatenated to rNalu. rpcBitstreamRedirect contains slice payload. rpcSlice contains tile location information.
    2338  * \returns Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
     2562/** Attaches the input bitstream to the stream in the output NAL unit
     2563    Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
     2564 *  \param codedSliceData contains the coded slice data (bitstream) to be concatenated to rNalu
     2565 *  \param rNalu          target NAL unit
    23392566 */
    2340 Void TEncGOP::xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice)
     2567Void TEncGOP::xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& codedSliceData)
    23412568{
    23422569  // Byte-align
     
    23442571
    23452572  // Perform bitstream concatenation
    2346   if (rpcBitstreamRedirect->getNumberOfWrittenBits() > 0)
    2347   {
    2348     UInt uiBitCount  = rpcBitstreamRedirect->getNumberOfWrittenBits();
    2349     if (rpcBitstreamRedirect->getByteStreamLength()>0)
    2350     {
    2351       UChar *pucStart  =  reinterpret_cast<UChar*>(rpcBitstreamRedirect->getByteStream());
    2352       UInt uiWriteByteCount = 0;
    2353       while (uiWriteByteCount < (uiBitCount >> 3) )
    2354       {
    2355         UInt uiBits = (*pucStart);
    2356         rNalu.m_Bitstream.write(uiBits, 8);
    2357         pucStart++;
    2358         uiWriteByteCount++;
    2359       }
    2360     }
    2361     UInt uiBitsHeld = (uiBitCount & 0x07);
    2362     for (UInt uiIdx=0; uiIdx < uiBitsHeld; uiIdx++)
    2363     {
    2364       rNalu.m_Bitstream.write((rpcBitstreamRedirect->getHeldBits() & (1 << (7-uiIdx))) >> (7-uiIdx), 1);
    2365     }         
     2573  if (codedSliceData->getNumberOfWrittenBits() > 0)
     2574    {
     2575    rNalu.m_Bitstream.addSubstream(codedSliceData);
    23662576  }
    23672577
    23682578  m_pcEntropyCoder->setBitstream(&rNalu.m_Bitstream);
    23692579
    2370   delete rpcBitstreamRedirect;
    2371   rpcBitstreamRedirect = new TComOutputBitstream;
     2580  codedSliceData->clear();
    23722581}
    23732582
     
    24942703     }               
    24952704  }
    2496   assert(it != accessUnit.end());
     2705//  assert(it != accessUnit.end());  // Triggers with some legit configurations
    24972706  return seiStartPos;
    24982707}
    24992708#endif
    25002709
     2710#if L0386_DB_METRIC
     2711Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices )
     2712{
     2713  TComPicYuv* pcPicYuvRec = pcPic->getPicYuvRec();
     2714  Pel* Rec    = pcPicYuvRec->getLumaAddr( 0 );
     2715  Pel* tempRec = Rec;
     2716  Int  stride = pcPicYuvRec->getStride();
     2717  UInt log2maxTB = pcPic->getSlice(0)->getSPS()->getQuadtreeTULog2MaxSize();
     2718  UInt maxTBsize = (1<<log2maxTB);
     2719  const UInt minBlockArtSize = 8;
     2720  const UInt picWidth = pcPicYuvRec->getWidth();
     2721  const UInt picHeight = pcPicYuvRec->getHeight();
     2722  const UInt noCol = (picWidth>>log2maxTB);
     2723  const UInt noRows = (picHeight>>log2maxTB);
     2724  UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64));
     2725  UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64));
     2726  UInt colIdx = 0;
     2727  UInt rowIdx = 0;
     2728  Pel p0, p1, p2, q0, q1, q2;
     2729 
     2730  Int qp = pcPic->getSlice(0)->getSliceQp();
     2731  Int bitdepthScale = 1 << (g_bitDepthY-8);
     2732  Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale;
     2733  const Int thr2 = (beta>>2);
     2734  const Int thr1 = 2*bitdepthScale;
     2735  UInt a = 0;
     2736 
     2737  memset(colSAD, 0, noCol*sizeof(UInt64));
     2738  memset(rowSAD, 0, noRows*sizeof(UInt64));
     2739 
     2740  if (maxTBsize > minBlockArtSize)
     2741  {
     2742    // Analyze vertical artifact edges
     2743    for(Int c = maxTBsize; c < picWidth; c += maxTBsize)
     2744    {
     2745      for(Int r = 0; r < picHeight; r++)
     2746      {
     2747        p2 = Rec[c-3];
     2748        p1 = Rec[c-2];
     2749        p0 = Rec[c-1];
     2750        q0 = Rec[c];
     2751        q1 = Rec[c+1];
     2752        q2 = Rec[c+2];
     2753        a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
     2754        if ( thr1 < a && a < thr2)
     2755        {
     2756          colSAD[colIdx] += abs(p0 - q0);
     2757        }
     2758        Rec += stride;
     2759      }
     2760      colIdx++;
     2761      Rec = tempRec;
     2762    }
     2763   
     2764    // Analyze horizontal artifact edges
     2765    for(Int r = maxTBsize; r < picHeight; r += maxTBsize)
     2766    {
     2767      for(Int c = 0; c < picWidth; c++)
     2768      {
     2769        p2 = Rec[c + (r-3)*stride];
     2770        p1 = Rec[c + (r-2)*stride];
     2771        p0 = Rec[c + (r-1)*stride];
     2772        q0 = Rec[c + r*stride];
     2773        q1 = Rec[c + (r+1)*stride];
     2774        q2 = Rec[c + (r+2)*stride];
     2775        a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
     2776        if (thr1 < a && a < thr2)
     2777        {
     2778          rowSAD[rowIdx] += abs(p0 - q0);
     2779        }
     2780      }
     2781      rowIdx++;
     2782    }
     2783  }
     2784 
     2785  UInt64 colSADsum = 0;
     2786  UInt64 rowSADsum = 0;
     2787  for(Int c = 0; c < noCol-1; c++)
     2788  {
     2789    colSADsum += colSAD[c];
     2790  }
     2791  for(Int r = 0; r < noRows-1; r++)
     2792  {
     2793    rowSADsum += rowSAD[r];
     2794  }
     2795 
     2796  colSADsum <<= 10;
     2797  rowSADsum <<= 10;
     2798  colSADsum /= (noCol-1);
     2799  colSADsum /= picHeight;
     2800  rowSADsum /= (noRows-1);
     2801  rowSADsum /= picWidth;
     2802 
     2803  UInt64 avgSAD = ((colSADsum + rowSADsum)>>1);
     2804  avgSAD >>= (g_bitDepthY-8);
     2805 
     2806  if ( avgSAD > 2048 )
     2807  {
     2808    avgSAD >>= 9;
     2809    Int offset = Clip3(2,6,(Int)avgSAD);
     2810    for (Int i=0; i<uiNumSlices; i++)
     2811    {
     2812      pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(true);
     2813      pcPic->getSlice(i)->setDeblockingFilterDisable(false);
     2814      pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( offset );
     2815      pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( offset );
     2816    }
     2817  }
     2818  else
     2819  {
     2820    for (Int i=0; i<uiNumSlices; i++)
     2821    {
     2822      pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(false);
     2823      pcPic->getSlice(i)->setDeblockingFilterDisable(        pcPic->getSlice(i)->getPPS()->getPicDisableDeblockingFilterFlag() );
     2824      pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterBetaOffsetDiv2() );
     2825      pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2(   pcPic->getSlice(i)->getPPS()->getDeblockingFilterTcOffsetDiv2()   );
     2826    }
     2827  }
     2828 
     2829  free(colSAD);
     2830  free(rowSAD);
     2831}
     2832#endif
    25012833#if H_MV
    25022834Void TEncGOP::xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid )
     
    25782910}
    25792911#endif
    2580 
    25812912//! \}
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncGOP.h

    r324 r362  
    132132  Bool                    m_bufferingPeriodSEIPresentInAU;
    133133  Bool                    m_pictureTimingSEIPresentInAU;
     134#if K0180_SCALABLE_NESTING_SEI
     135  Bool                    m_nestedBufferingPeriodSEIPresentInAU;
     136  Bool                    m_nestedPictureTimingSEIPresentInAU;
     137#endif
    134138#endif
    135139public:
     
    141145 
    142146  Void  init        ( TEncTop* pcTEncTop );
    143 
    144147#if H_MV
    145148  Void  initGOP     ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP);
     
    148151  Void  compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
    149152#endif
    150 
    151   Void xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice);
     153  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect);
    152154
    153155#if H_MV
     
    167169  Void  printOutSummary      ( UInt uiNumAllPicCoded );
    168170#endif
    169 
    170171  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits );
    171172 
    172173  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
    173   NalUnitType getNalUnitType( Int pocCurr );
     174  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr );
    174175  Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& );
    175176protected:
     
    189190  SEIFramePacking*        xCreateSEIFramePacking();
    190191  SEIDisplayOrientation*  xCreateSEIDisplayOrientation();
     192
     193#if J0149_TONE_MAPPING_SEI
     194  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
     195#endif
    191196
    192197  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
     
    199204    m_pictureTimingSEIPresentInAU      = false;
    200205  }
    201 #endif
    202 
     206#if K0180_SCALABLE_NESTING_SEI
     207  Void xResetNestedSEIPresentFlags()
     208  {
     209    m_nestedBufferingPeriodSEIPresentInAU    = false;
     210    m_nestedPictureTimingSEIPresentInAU      = false;
     211  }
     212#endif
    203213#if H_MV
    204214   Void  xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid );
    205215#endif
    206 
     216#if L0386_DB_METRIC
     217  Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
     218#endif
    207219};// END CLASS DEFINITION TEncGOP
    208220
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r324 r362  
    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  {
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h

    r324 r362  
    5757{
    5858private:
    59   Double            m_dLambdaLuma;
    60   Double            m_dLambdaChroma;
    61 
    6259  TEncEntropy*      m_pcEntropyCoder;
    6360  TEncSbac***       m_pppcRDSbacCoder;              ///< for CABAC
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncSbac.h

    r324 r362  
    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 );
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r324 r362  
    32093209    UInt          uiBitsTempL0[MAX_NUM_REF];
    32103210
     3211#if L0034_COMBINED_LIST_CLEANUP
     3212    TComMv        mvValidList1;
     3213    Int           refIdxValidList1 = 0;
     3214    UInt          bitsValidList1 = MAX_UINT;
     3215    UInt          costValidList1 = MAX_UINT;
     3216#endif
     3217
    32113218    xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
    32123219   
     
    32553262        uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
    32563263#if ZERO_MVD_EST
     3264#if L0034_COMBINED_LIST_CLEANUP
     3265        if ( iRefList == 0 || pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
     3266#else
    32573267        if ((iRefList != 1 || !pcCU->getSlice()->getNoBackPredFlag()) &&
    32583268            (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) <= 0 || pcCU->getSlice()->getRefIdxOfLC(eRefPicList, iRefIdxTemp)>=0))
     3269#endif
    32593270        {
    32603271          uiZeroMvdBitsTemp = uiBitsTemp;
     
    32763287       
    32773288#if GPB_SIMPLE_UNI
     3289#if L0034_COMBINED_LIST_CLEANUP
     3290        if ( iRefList == 1 )    // list 1
     3291        {
     3292          if ( pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) >= 0 )
     3293          {
     3294            cMvTemp[1][iRefIdxTemp] = cMvTemp[0][pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
     3295            uiCostTemp = uiCostTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )];
     3296            /*first subtract the bit-rate part of the cost of the other list*/
     3297            uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp )] );
     3298            /*correct the bit-rate part of the current ref*/
     3299            m_pcRdCost->setPredictor  ( cMvPred[iRefList][iRefIdxTemp] );
     3300            uiBitsTemp += m_pcRdCost->getBits( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() );
     3301            /*calculate the correct cost*/
     3302            uiCostTemp += m_pcRdCost->getCost( uiBitsTemp );
     3303          }
     3304          else
     3305          {
     3306            xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     3307          }
     3308        }
     3309        else
     3310        {
     3311          xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     3312        }
     3313#else
    32783314        if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0)
    32793315        {
     
    33173353          }       
    33183354        }
     3355#endif
    33193356#else
    33203357        xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     
    33233360        xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
    33243361
     3362#if L0034_COMBINED_LIST_CLEANUP
     3363        if ( iRefList == 0 )
     3364        {
     3365          uiCostTempL0[iRefIdxTemp] = uiCostTemp;
     3366          uiBitsTempL0[iRefIdxTemp] = uiBitsTemp;
     3367        }
     3368        if ( uiCostTemp < uiCost[iRefList] )
     3369        {
     3370          uiCost[iRefList] = uiCostTemp;
     3371          uiBits[iRefList] = uiBitsTemp; // storing for bi-prediction
     3372
     3373          // set motion
     3374          cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
     3375          iRefIdx[iRefList] = iRefIdxTemp;
     3376        }
     3377
     3378        if ( iRefList == 1 && uiCostTemp < costValidList1 && pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 )
     3379        {
     3380          costValidList1 = uiCostTemp;
     3381          bitsValidList1 = uiBitsTemp;
     3382
     3383          // set motion
     3384          mvValidList1     = cMvTemp[iRefList][iRefIdxTemp];
     3385          refIdxValidList1 = iRefIdxTemp;
     3386        }
     3387#else
    33253388        if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && !pcCU->getSlice()->getNoBackPredFlag())
    33263389        {
     
    33723435            }
    33733436          }
     3437#endif
    33743438      }
    33753439    }
     
    34353499       
    34363500        Int         iRefList    = iIter % 2;
     3501#if L0034_COMBINED_LIST_CLEANUP
     3502        if ( m_pcEncCfg->getUseFastEnc() )
     3503        {
     3504          if( uiCost[0] <= uiCost[1] )
     3505          {
     3506            iRefList = 1;
     3507          }
     3508          else
     3509          {
     3510            iRefList = 0;
     3511          }
     3512        }
     3513        else if ( iIter == 0 )
     3514        {
     3515          iRefList = 0;
     3516        }
     3517        if ( iIter == 0 && !pcCU->getSlice()->getMvdL1ZeroFlag())
     3518        {
     3519          pcCU->getCUMvField(RefPicList(1-iRefList))->setAllMv( cMv[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     3520          pcCU->getCUMvField(RefPicList(1-iRefList))->setAllRefIdx( iRefIdx[1-iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     3521          TComYuv*  pcYuvPred = &m_acYuvPred[1-iRefList];
     3522          motionCompensation ( pcCU, pcYuvPred, RefPicList(1-iRefList), iPartIdx );
     3523        }
     3524#else
    34373525        if ( m_pcEncCfg->getUseFastEnc() && (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) )
    34383526        {
    34393527          iRefList = 1;
    34403528        }
     3529#endif
    34413530        RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    34423531
     
    35733662    UInt uiMEBits = 0;
    35743663    // Set Motion Field_
     3664#if L0034_COMBINED_LIST_CLEANUP
     3665    cMv[1] = mvValidList1;
     3666    iRefIdx[1] = refIdxValidList1;
     3667    uiBits[1] = bitsValidList1;
     3668    uiCost[1] = costValidList1;
     3669#else
    35753670    if ( pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 ) )
    35763671    {
    35773672      uiCost[1] = MAX_UINT;
    35783673    }
     3674#endif
    35793675#if AMP_MRG
    35803676    if (bTestNormalMC)
     
    45224618    while( pcCU->getWidth(0) > (pcCU->getSlice()->getSPS()->getMaxTrSize()<<uiTrLevel) ) uiTrLevel++;
    45234619  }
    4524   UInt uiMaxTrMode = pcCU->getSlice()->getSPS()->getMaxTrDepth() + uiTrLevel;
     4620  UInt uiMaxTrMode = 1 + uiTrLevel;
    45254621 
    45264622  while((uiWidth>>uiMaxTrMode) < (g_uiMaxCUWidth>>g_uiMaxCUDepth)) uiMaxTrMode--;
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r324 r362  
    438438#endif
    439439
     440#if L0386_DB_METRIC
     441  if ( m_pcCfg->getDeblockingFilterMetric() )
     442  {
     443    rpcSlice->setDeblockingFilterOverrideFlag(true);
     444    rpcSlice->setDeblockingFilterDisable(false);
     445    rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
     446    rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 );
     447  } else
     448#endif
    440449  if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
    441450  {
     
    12231232 \retval rpcBitstream  bitstream class
    12241233 */
    1225 Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcBitstream, TComOutputBitstream* pcSubstreams )
     1234Void TEncSlice::encodeSlice   ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams )
    12261235{
    12271236  UInt       uiCUAddr;
     
    14031412      }
    14041413      {
    1405           UInt uiCounter = 0;
    1406           vector<uint8_t>& rbsp   = pcSubstreams[uiSubStrm].getFIFO();
    1407           for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
    1408           {
    1409             /* 1) find the next emulated 00 00 {00,01,02,03}
    1410              * 2a) if not found, write all remaining bytes out, stop.
    1411              * 2b) otherwise, write all non-emulated bytes out
    1412              * 3) insert emulation_prevention_three_byte
    1413              */
    1414             vector<uint8_t>::iterator found = it;
    1415             do
    1416             {
    1417               /* NB, end()-1, prevents finding a trailing two byte sequence */
    1418               found = search_n(found, rbsp.end()-1, 2, 0);
    1419               found++;
    1420               /* if not found, found == end, otherwise found = second zero byte */
    1421               if (found == rbsp.end())
    1422               {
    1423                 break;
    1424               }
    1425               if (*(++found) <= 3)
    1426               {
    1427                 break;
    1428               }
    1429             } while (true);
    1430             it = found;
    1431             if (found != rbsp.end())
    1432             {
    1433               it++;
    1434               uiCounter++;
    1435             }
    1436           }
    1437        
     1414        UInt numStartCodeEmulations = pcSubstreams[uiSubStrm].countStartCodeEmulations();
    14381415        UInt uiAccumulatedSubstreamLength = 0;
    14391416        for (Int iSubstrmIdx=0; iSubstrmIdx < iNumSubstreams; iSubstrmIdx++)
     
    14431420        // add bits coded in previous dependent slices + bits coded so far
    14441421        // add number of emulation prevention byte count in the tile
    1445         pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + uiCounter );
     1422        pcSlice->addTileLocation( ((pcSlice->getTileOffstForMultES() + uiAccumulatedSubstreamLength - uiBitsOriginallyInSubstreams) >> 3) + numStartCodeEmulations );
    14461423      }
    14471424    }
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncSlice.h

    r324 r362  
    122122  Void    precompressSlice    ( TComPic*& rpcPic                                );      ///< precompress slice for multi-loop opt.
    123123  Void    compressSlice       ( TComPic*& rpcPic                                );      ///< analysis stage of slice
    124   Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* rpcBitstream, TComOutputBitstream* pcSubstreams  );
     124  Void    encodeSlice         ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams  );
    125125 
    126126  // misc. functions
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r324 r362  
    8181  m_pcBitCounters          = NULL;
    8282  m_pcRdCosts              = NULL;
    83 
    8483#if H_MV
    8584  m_ivPicLists = NULL;
     
    9695Void TEncTop::create ()
    9796{
    98 
    9997#if !H_MV
    10098  // initialize global variables
     
    288286Void TEncTop::init()
    289287{
    290 
    291288  // initialize SPS
    292289  xInitSPS();
     
    348345}
    349346#endif
    350 
    351347Void TEncTop::deletePicBuffer()
    352348{
     
    375371 \retval  iNumEncoded         number of encoded pictures
    376372 */
    377 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded
    378373#if H_MV
    379                      , Int gopId
    380 #endif               
    381                      )
    382 {
    383 
     374Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded , Int gopId )
     375{
     376#else
     377Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
     378{
     379#endif
    384380#if H_3D
    385381  TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() );
     
    389385  }
    390386#endif
    391 
    392387#if H_MV
    393388  if( gopId == 0)
     
    547542  m_cSPS.setMaxCUHeight   ( g_uiMaxCUHeight     );
    548543  m_cSPS.setMaxCUDepth    ( g_uiMaxCUDepth      );
    549   m_cSPS.setMinTrDepth    ( 0                   );
    550   m_cSPS.setMaxTrDepth    ( 1                   );
     544
     545  Int minCUSize = m_cSPS.getMaxCUWidth() >> ( m_cSPS.getMaxCUDepth()-g_uiAddCUDepth );
     546  Int log2MinCUSize = 0;
     547  while(minCUSize > 1)
     548  {
     549    minCUSize >>= 1;
     550    log2MinCUSize++;
     551  }
     552
     553  m_cSPS.setLog2MinCodingBlockSize(log2MinCUSize);
     554  m_cSPS.setLog2DiffMaxMinCodingBlockSize(m_cSPS.getMaxCUDepth()-g_uiAddCUDepth);
    551555 
    552556  m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);
     
    563567
    564568  m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
    565  
     569#if !L0034_COMBINED_LIST_CLEANUP
    566570  m_cSPS.setUseLComb    ( m_bUseLComb           );
     571#endif
    567572 
    568573  Int i;
     
    716721  m_cPPS.setOutputFlagPresentFlag( false );
    717722  m_cPPS.setSignHideFlag(getSignHideFlag());
     723#if L0386_DB_METRIC
     724  if ( getDeblockingFilterMetric() )
     725  {
     726    m_cPPS.setDeblockingFilterControlPresentFlag (true);
     727    m_cPPS.setDeblockingFilterOverrideEnabledFlag(true);
     728    m_cPPS.setPicDisableDeblockingFilterFlag(false);
     729    m_cPPS.setDeblockingFilterBetaOffsetDiv2(0);
     730    m_cPPS.setDeblockingFilterTcOffsetDiv2(0);
     731  }
     732  else
     733  {
    718734  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
     735  }
     736#else
     737  m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );
     738#endif
    719739  m_cPPS.setLog2ParallelMergeLevelMinus2   (m_log2ParallelMergeLevelMinus2 );
    720740  m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG);
     
    9901010}
    9911011
     1012#if L0208_SOP_DESCRIPTION_SEI
     1013Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid )
     1014{
     1015  int rpsIdx = GOPid;
     1016
     1017  for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++)
     1018  {   
     1019    if(m_uiIntraPeriod > 0 && getDecodingRefreshType() > 0)
     1020    {
     1021      Int POCIndex = POCCurr%m_uiIntraPeriod;
     1022      if(POCIndex == 0)
     1023      {
     1024        POCIndex = m_uiIntraPeriod;
     1025      }
     1026      if(POCIndex == m_GOPList[extraNum].m_POC)
     1027      {
     1028        rpsIdx = extraNum;
     1029      }
     1030    }
     1031    else
     1032    {
     1033      if(POCCurr==m_GOPList[extraNum].m_POC)
     1034      {
     1035        rpsIdx = extraNum;
     1036      }
     1037    }
     1038  }
     1039
     1040  return rpsIdx;
     1041}
     1042#endif
     1043
    9921044Void  TEncTop::xInitPPSforTiles()
    9931045{
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncTop.h

    r324 r362  
    195195  TComPPS*                getPPS                () { return  &m_cPPS;                 }
    196196  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
    197200  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
    198 
    199201#if H_MV
    200202  TEncAnalyze*            getAnalyzeAll         () { return &m_cAnalyzeAll; }
     
    210212  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
    211213#endif
    212 
    213 
    214214  // -------------------------------------------------------------------------------------------------------------------
    215215  // encoder function
     
    217217
    218218  /// encode several number of pictures until end-of-sequence
     219#if H_MV
     220  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded  , Int gopId  ); 
     221#else
    219222  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
    220               std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded
    221 #if H_MV
    222               , Int gopId
    223 #endif       
    224               ); 
    225 
    226 #if H_MV
    227   void printSummary      ( Int numAllPicCoded );
     223              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 
     224#endif
     225
     226#if H_MV
     227  Void printSummary      ( Int numAllPicCoded );
    228228#else
    229229  void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); }
    230230#endif
    231 
    232231};
    233232
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp

    r324 r362  
    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.